# SystemThe Shortest Save/Load Code Ever

#### SerraAvenger

##### Cuz I can
NOTE:
I think I read some time ago that your system doesn't use multiple integers, instead it tries to save as much info into one integer as possible in order to save space...
Just in case you really map n-dimensional arrays into integers (I did that), this might be intersting for you...

length = Log_base( integer + 1)
length = length1 + length2 = Log_base( integer1 + 1 ) + Log_base( integer2 + 1 ) = Log_base( integer1 * integer2 + integer1 + integer 2 + 1 )
mapping n-dimensional arrays:
length = Log_base( integer1_max * integer2 + integer1 +1 )
since integer1_max >= integer1,

integer1_max * integer2 >= ( integer1 + 1 ) * integer2 (in any reasonable case it's > )

hence it is actually stupid to compress everything into one integer, lots of space will be lost. In fact it should be clever to encode every number on its own and use + and - as a seperator. That way you can save _any_ JASS integer in upto x digits (with a reasonable base of 36, that would be log(2^31)/log(36)=31*log(2)/log(36)=5.99=> 6 ), which is absolutely fine. The smaller the integer, the shorter the code... That is the most clever "compression" I can actually think of.
(example code, in base 10)
+304-41423-425+3566
->
+304
-41423
-425
+3566
In base 36 the code would ofc get much shorter.

If you find any flaws, plz tell me....

#### Zwiebelchen

##### You can change this now in User CP.
I use KODE in Gaias Retaliation ORPG; however, I got a really strange problem:

When reaching a certain number of digits (I think at around 12 blocks a 4 digits or something), the system doesn't load anymore. There is no invalid code displaying and the "loading lag" occurs. However, nothing else happens. It works fine with shorter codes, though (for example saving with the progressive int being 0)

May it be possible that KODE can not save up to that many digits?

This is what we store:

- a progressive int (10,5) ... common values at around 1000-10000
- ordinary ints: 1000, 12x300, 12x2, 3x200, 51, 7, 20, 50x4

EDIT: testet it with the following edit of the KODE's source code:
JASS:
``````
function load_code takes player p, integer security, string s returns boolean
local integer num_chars
call BJDebugMsg(&quot;KODE executed&quot;)
call clear_bits()
set num_chars = parse_code(s)
call decrypt(p, get_num_bits_supported(num_chars))
call BJDebugMsg(&quot;KODE did reach end&quot;)
return is_valid(security)
endfunction``````

As expected, only the first message is displayed.

In fact, everything works fine until decrypt.

#### SerraAvenger

##### Cuz I can
Try to put a couple of waits into the decrypt loop, then see if it _still_ stops working with so many digits. Sounds like an OP problem to me. If it works then, but you don't want to have that pause, you'll need a system that doesn't encrypt/decrypt but uses hashsums... I could code you one, if you want.

#### Zwiebelchen

##### You can change this now in User CP.
Hmm, I set the encryption strength lower and it works ...

Seems like there is a need to split the decryption process into multiple threads to avoid operation limit.
Feel free to write an optimized system SerraAvenger, I think Korolen is fine with that too. ^^

#### SerraAvenger

##### Cuz I can
Hmm, I set the encryption strength lower and it works ...

Seems like there is a need to split the decryption process into multiple threads to avoid operation limit.
Feel free to write an optimized system SerraAvenger, I think Korolen is fine with that too. ^^
Glad you got it to work.

I won't copy this system just to make it avoid the op limit. I'm no fan of heavy decription / encription after all when it comes to save load codes... Doesn't make them harder to crack, but means a lot of hazzle. Mapping to a different alphabet would be more than enough, if you ask me.

wishes, Davey

#### Zwiebelchen

##### You can change this now in User CP.
Well, I encountered another problem with KODE, which is something I can not fix without a new security method.

The problem is, that KODE does not recognize in its validy checker, wether a letter is capital oder lowercase.

This means that if you load a code with the exact same letters, but without the right caps (if you used a 62 letter system), the code loads (and of course, returns weird results) ...
A checksum validy checker may be the better solution here, so I would gladly take your offer to improve KODE @SerraAvenger.

#### xXGauntletXx

##### New Member
After looking at kode, then gobbledygook (sp?) it seemed much easier to edit gobbledygook than kode.
To make kode MPI took much more work than to change 1 value in gobbledygook.

#### TriggerHappy

##### ...
To make kode MPI took much more work than to change 1 value in gobbledygook.
Kode is MPI, last time I checked.

#### Korolen

##### New User (Why do I keep getting those red bars?)
Kode is MPI, last time I checked.
Kode is neither MPI nor not MPI, the categorization doesn't really apply to a save/load system. Kode can generate codes for as many players as you need it to, one right after the other.

#### Zwiebelchen

##### You can change this now in User CP.
So what about the issue I mentioned ... is this going to be fixed?

General chit-chat
Help Users
• No one is chatting at the moment.
• Ghan:
The old shoutbox wasn't supported anymore. We updated xenForo, so it had to be replaced.
• jonas:
let's see if everyone finds it... the nice thing about the shoutbox was I could check on it even while logged out, but the existence of this one is hidden when you're not logged in
• Ghan:
We can fix that.
• Ghan:
Chat should show on the sidebar when not logged in now.
• Ghan:
• Ghan:
Test!
• tom_mai78101:
I must be in a test server.
• tom_mai78101:
Nice, Twitter tweets embedding now works
• Wizard:
Yup.
• Ghan:
Excellent.
• Ghan:
@tom_mai78101 Hello there.
• Ghan:
Tagging works in the chat too.
• tom_mai78101:
@Ghan Missed it.
• Wizard:
Still fixing things here and there. Added widgets to the portal, will make it match the ones here on the forum index tomorrow.
• Ghan:
The venerable World Editor Tutorials site has been converted to HTTPS at last.
• jonas:
cool
• jonas:
and I can even edit my messages, nice
• seph ir oth:
GENERAL CHIT CHAT, YOU ARE A BOLD ONE
• Ghan:
Hello there
• The Helper:
this new chatbox is great and the forum software update is great too
+1
• The Helper:
upgrade has fixed forum registration spam problem
• tom_mai78101:
Something tells me we might be able to customize the chatbox a bit, considering that there's a gap under every message.
• Wizard:
Going to deploy a fix soon, just had to take some time for myself this weekend.
• Varine:
Unbelievable. Time for yourself? How dare you!