System The Shortest Save/Load Code Ever

Korolen

New User (Why do I keep getting those red bars?)
Reaction score
69
> Kode produces, as far as I know of, the shortest codes for any save/load system.
> It wastes *zero* space when saving normal integers because they have an arbitrary maximum size.

That's open to debate.


> Other code systems, such as AceHart's system don't do this

You have some backup for that claim?
While I admit that I haven't read the source code for your code system, I have read the tutorial/manual for it which outlines its usage. The way it works gives the user the freedom of not specifying a maximum value for integers added to the code in their script but rather have it guessed automatically by the system, right? Because of that, the code that the player gets must contain information specifying the size of the integers in it as opposed to the save/load functions statically providing that data as in Kode. As I outlined before, I designed Kode to save integers in the minimum possible way short of compression. I have yet to find another system that operates in the same manner.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> the code that the player gets must contain information specifying the size of the integers

Not really.
A Hero level, for example, of 3 will need less than 1 character, whereas level 50 will need nearly 2.
There's not much of a point to artificial limits.
 
Reaction score
341
You never answered my question :(

if anyone can answer plz do

Ok , so i am trying to use this in my map and i get a couple errors.

First , Whenever i try 2 save 6 items my it loads none of em , but when i save 5 items it loads all of them

Second , whenever i get past lvl 11 it only loads up to level 11.

Third , when i save a hero and load it , it gives me an entire different hero (even though the saved hero is in the hero array )
 

Korolen

New User (Why do I keep getting those red bars?)
Reaction score
69
You never answered my question :(

if anyone can answer plz do

I can only help you if you post your code. Without that information, it's impossible for me to show you what's wrong.

You might consider using AceHart's system, though, as it's quite a bit simpler to use than Kode.
 
Reaction score
341
I just download the map. dont modify it at ALL. i just downlload > open > test ..



Ive tried the JASS/GUI Versions of the latest versions
 
Reaction score
341
Bump


Anyone gotta answer to my question?

lol Korolean , acehart?



EDIT: ok... now im gettin more errors that make no sense . if i change one thing in the save code i get like 5 errors. heres my code

JASS:
function get_hero_type_index takes integer t returns integer

    local integer i = 0

    loop

        exitwhen i >= 4

        if udg_Demo_Hero_Types<i> == t then

            return i

        endif

        set i = i + 1

    endloop

    return -1

endfunction



function get_item_type_index takes integer t returns integer

    local integer i = 0

    loop

        exitwhen i &gt;= udg_Demo_Item_Types_Length

        if udg_Demo_Item_Types<i> == t then

            return i

        endif

        set i = i + 1

    endloop

    return -1

endfunction



function save_hero takes unit u returns nothing

    local integer i = 0

    local integer item_count = 0

    local item m

    local integer t = get_hero_type_index(GetUnitTypeId(u))

    

    call clear_bits()

    

    set i = 0

    loop

        exitwhen i &gt;= 6
        set m = udg_RealSavingItems[( ( GetConvertedPlayerId(GetTriggerPlayer()) * 50 ) + i )]  
    call DisplayTextToForce( GetPlayersAll(), GetItemName(udg_SavingItems[( ( GetConvertedPlayerId(GetTriggerPlayer()) * 20 ) + i )]) )      
        if m != null then

            call push_int(get_item_type_index(GetItemTypeId(m)), udg_Demo_Item_Types_Length)

            set item_count = item_count + 1

        endif

        set i = i + 1

    endloop

    call push_int(item_count, 6)

    

    set i = 0

    loop

        exitwhen i &gt;= 3

        call push_int(GetHeroStatBJ(i, u, false), 60)

        set i = i + 1

    endloop

    



function Trig_Save_Hero_Actions takes nothing returns nothing

    local group g = GetUnitsSelectedAll(Player(0))

    local unit u

    if CountUnitsInGroup(g) == 1 then

        set u = FirstOfGroup(g)

        if IsUnitType(u, UNIT_TYPE_HERO) then

            call save_hero(u)

            call RemoveUnit(u)

            call BJDebugMsg(format_code(create_code(GetTriggerPlayer(), 10), 4))

        endif

        set u = null

    endif

    call DestroyGroup(g)

    set g = null

endfunction



//===========================================================================

function InitTrig_Save_Hero takes nothing returns nothing

    set gg_trg_Save_Hero = CreateTrigger()

    call TriggerRegisterPlayerChatEvent(gg_trg_Save_Hero, Player(0), &quot;-savehero&quot;, true)

    call TriggerAddAction(gg_trg_Save_Hero, function Trig_Save_Hero_Actions)

endfunction



</i></i>
 

Bird

Ultra Cool Member
Reaction score
29
"Security is simple but effective. After the code has been generated, a customizable number of 0s are appended to the bits that make up the code. Then, the bits are is encrypted using the player's name as a key."

Does this mean that you have to be online using the same Blizzard acct name to keep using your character?

So, for someone to steal your Character, they would have to witness your code, and then go to a different Blizzard server, register your acct name, and load the code?

Is this accurate?
 
P

Psychopath

Guest
Hello.

Will this save/load system be able to save your account name? Then others wont be able to steal the code and use it.

And can you do something like: "-saveall" to save everything instead of "-savehero, -savenum, etc"?

Thanks in advance.
 

dannyboydude

Ultra Cool Member
Reaction score
33
i dont have much knoledge in jass but
if you dont have much knoledge just use AceHarts save/load
easy to add / change things
i added quite a few things and its gui friendly
 

cleeezzz

The Undead Ranger.
Reaction score
268
followed the example but its not even showing the code =/

JASS:
scope SaveStats initializer Init

private function Actions takes nothing returns nothing
    local string s
    local player p = GetTriggerPlayer()
    call clear_bits()
    call BJDebugMsg(&quot;hi&quot;)
    call push_progressive_int(TKills[GetPlayerId(p)], 10, 6)
    call BJDebugMsg(&quot;hi&quot;)
    call push_progressive_int(TDeaths[GetPlayerId(p)], 10, 6)
    call BJDebugMsg(&quot;hi&quot;)  //shows this HI and does not show any messages below this line
    set s = create_code(p,5)
     call BJDebugMsg(&quot;hi&quot;)
    set s = format_code(s, 3)
    call BJDebugMsg(&quot;hi&quot;)
    call BJDebugMsg(s)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( trig, Player(0), &quot;-save&quot;, true )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


tkills and tdeaths are set to 50 and 60 for test purposes

(also, how do i "pop" these 2 integers out? i dont get it)
 

Korolen

New User (Why do I keep getting those red bars?)
Reaction score
69
followed the example but its not even showing the code =/

JASS:
scope SaveStats initializer Init

private function Actions takes nothing returns nothing
    local string s
    local player p = GetTriggerPlayer()
    call clear_bits()
    call BJDebugMsg(&quot;hi&quot;)
    call push_progressive_int(TKills[GetPlayerId(p)], 10, 6)
    call BJDebugMsg(&quot;hi&quot;)
    call push_progressive_int(TDeaths[GetPlayerId(p)], 10, 6)
    call BJDebugMsg(&quot;hi&quot;)  //shows this HI and does not show any messages below this line
    set s = create_code(p,5)
     call BJDebugMsg(&quot;hi&quot;)
    set s = format_code(s, 3)
    call BJDebugMsg(&quot;hi&quot;)
    call BJDebugMsg(s)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( trig, Player(0), &quot;-save&quot;, true )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


tkills and tdeaths are set to 50 and 60 for test purposes

(also, how do i "pop" these 2 integers out? i dont get it)

My guess is that you forgot to set Kode_Charmap and Kode_Security in the Variable Editor. When you copy the trigger out of the Kode distribution map, the WE doesn't copy the default values for the variables, just the variables themselves.

Aside from that, I'd have to get more information to see what's causing the thread to crash. A war3err report or a copy of your map and I'd be able to help you further :)
 
Reaction score
341
This save/load has bugs , i tried saving 5 items , and they all loaded , i tried saving *6* items and none of them loaded. Note this was in the demo map when i had modified nothing.
 

Korolen

New User (Why do I keep getting those red bars?)
Reaction score
69
This save/load has bugs , i tried saving 5 items , and they all loaded , i tried saving *6* items and none of them loaded. Note this was in the demo map when i had modified nothing.

I'm very interested in any bugs you can find in Kode. This sounds like a bug in the demo map, but I'd be happy to take a look. Exactly what steps did you follow for this to happen? By the way, the demo only works with a couple of items so if you created anything else, it will most likely brake the code.
 

cleeezzz

The Undead Ranger.
Reaction score
268
ahh missed that instruction =/ sorry.

i dont understand how to pop the integer out though, what if the limit is both 10^6?

edit: nvm, doesn't matter, just pop it out reverse order. thanks

(btw imma use it in my map if you dont mind, ill give credits)
 

Prediter[BuB

Well-Known Member
Reaction score
35
Wait could I use this to make a campaign map and a hero and make a copy of that map and change terrain would the save system work between the two maps?
 

Korolen

New User (Why do I keep getting those red bars?)
Reaction score
69
Wait could I use this to make a campaign map and a hero and make a copy of that map and change terrain would the save system work between the two maps?

A code is not specific to a map, but rather to a loading and saving procedure, which, of course, could be the same between multiple maps.
 

cleeezzz

The Undead Ranger.
Reaction score
268
hey i have a serious problem, it seems that your system somehow affects GetRandomInt. In one certain function, it always returns 5, but after deleting the kode system, it returns 1 through 6 randomly. have any idea why?
 

Korolen

New User (Why do I keep getting those red bars?)
Reaction score
69
hey i have a serious problem, it seems that your system somehow affects GetRandomInt. In one certain function, it always returns 5, but after deleting the kode system, it returns 1 through 6 randomly. have any idea why?

Yeah... I guess a side effect of loading/saving a code is that the random number generator would always be set to a predictable value.

Just generate a random number before using a Kode function that seeds the generator, and after you're done with Kode, re-seed the generator with the original number you generated.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top