Wc3C.net (http://www.wc3c.net/forums.php)
-   Systems (http://www.wc3c.net/forumdisplay.php?f=648)
-   -   Optimal Save System 0.4 (http://www.wc3c.net/showthread.php?t=87360)

PipeDream 09-16-2006 02:38 AM

Optimal Save System 0.4
4 Attachment(s)
Added a few unit tests
Various bug fixes including deallocation issue

Port to vJass. No more location lists.

fixed broken sample name hashing routine

initial release

I got tired of hand writing save systems from scratch for aftermath everytime we wanted to change a few values, so I wrote this automated system.
- Flexible. Can generate codes of any length using integer data from zero to around twenty nine million.
- *Space optimal. Guaranteed to pack your code into as few characters as mathematically possible, assuming all possibilities for saving are equiprobable
- Fast
- *Creates few excess strings
- Simple interface
- *Save code character sets can be any length
- Configurable hash checking: A random code will work with a probability you specify

* items are advantages over Vex's system. The main advantage of Vex's system is that it has been tested far more heavily.

It takes some of the hell out of hand tuning a homegrown save system which can take up a day even if you are familiar with the math involved.

If someone knows all the characters that are valid in a bnet name, please let me know.

Remember, the best you can hope for is helping honest users remain honest.

map-maker 09-16-2006 03:43 AM

letters a-z, numbers 0-9, _, -, ., are the only characters allowed in b.net names i believe.

DioD 09-16-2006 10:22 AM

a!=A soo

a-z A-Z 0-9 and chars

Vexorian 09-16-2006 09:07 PM

Checked the code and the only reason not to approve this or the heap are the screenshots or rather the lack of it. S= log of omega probably has a meaning but that really won't help here, could you make a simple screenshot of the generated code ? and for the arrays system take a screenshot of the array's code, better syntax highlighted and post that, cause that cow doesn't help as an screenshot.

PipeDream 09-16-2006 11:54 PM

Sure. Those adequate?
Equation is a reference to information entropy. Number of chars required is proportional to the logarithm of the number of states your system can be in. This system is supposed to get that constant as small as possible.

Xandramas 09-25-2006 09:22 PM

Your save engine is confusing. It says First create him a savecode:
local location savecode = Savecode_new()
Now store the data in it. The way to store data is to pack it in an integer, taking a value from 0 to n, including n. Then call

Why dont u just include the trigger required for it? I dont know jass and this is not clear please clarify.

Vexorian 09-25-2006 10:18 PM

I think he expects you to use all JASS, you can't blame him anyways

Kratos 07-29-2007 04:52 AM

Is there no way to just declare the variables you want saved in JASS by using a simple copy and paste and then set them in GUI? I freaking hate JASS so much. Or at least create an example that actually saves something instead of just displaying a random code..

Vexorian 07-29-2007 05:11 AM

How about you begin loving Jass. Or you learn Jass, or you try not to use a system that requires you to know Jass?

PipeDream 07-29-2007 07:18 AM

*waves goodbye to location lists* 0.3, vJassified
BTW, at this point the non vJass version has been tested heavily in NOTD Aftermath, so I can encourage use of 0.2. 0.3 is only probably fine.

darkwulfv 07-29-2007 06:06 PM


Originally Posted by Kratos
I freaking hate JASS so much.

Good for you, now either learn it or stop complaining about PipeDream's system and find one that's in GUI.

Switch33 08-22-2007 05:15 AM

Can you by any chance give an example of how to save say a hero's inventory? Cause i am not exactly sure you seem to have an example set up to save only integers ranging from # to n only. Not sure how an item would fit in there.

PipeDream 08-22-2007 05:26 AM

A simple approach would be to give each item type a unique number from 0 to n. Loop through the hero's inventory, look up the item type number for each item, save the number.

Charged items will present complications.

Ammorth 09-19-2007 05:01 AM

While trying to figure out how the system works, I believe I have ran across a slight problem. Saving a code simotaneous times within the vJass version, without loading in-between, causes the system to op in s__BigNum_MulSmall. The modified example is as follows, which will display the error with War3Err.

Hidden information:
Collapse JASS:
function commtest takes nothing returns nothing
    call BJDebugMsg(I2S(Savecode_scommhash("yomp")))
    call BJDebugMsg(I2S(Savecode_scommhash("fruitcup")))

//Something can probably be made nicer to use with a macro

function Trig_test_savecode_Actions takes nothing returns nothing
    local string s
    local Savecode loadcode

//--- Data you want to save ---
    local integer medal1 = 10
    local integer medal2 = 3
    local integer medalmax = 13
    local integer XP = 1337
    local integer XPmax = 1000000

    local Savecode savecode = Savecode.create()

    call SetPlayerName(Player(0),"yomp")
    call SetPlayerName(Player(1),"fruitcup")

    call savecode.Encode(medal1,medalmax)
    call savecode.Encode(medal2,medalmax)
    call savecode.Encode(XP,XPmax)

//--- Savecode_save generates the savecode for a specific player ---
    set s = savecode.Save(Player(0),1)
    call BJDebugMsg("Savecode: " + colorize(s))
    call savecode.destroy()
    call PolledWait(1.)
    call Trig_test_savecode_Actions()

function InitTrig_example_use takes nothing returns nothing
    set gg_trg_example_use = CreateTrigger(  )
    call TriggerAddAction( gg_trg_example_use, function Trig_test_savecode_Actions )
//    call TriggerAddAction( gg_trg_example_use, function commtest )

I believe it has something to do with not clearing the lists entirely. Of course, I have not been able to completely understand the system, but this is what I understand.

PipeDream 09-24-2007 10:23 AM

Thanks for letting me know. If someone needs this fixed, let me know, but it should not affect saves. Or, use the location version.

All times are GMT. The time now is 06:37 AM.

Powered by vBulletin (Copyright ©2000 - 2020, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services