Encoder Framework 1.1.0.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Now implementing Encoder into maps is easy.


The Encoder Framework includes all of the latest systems, a quickstart tutorial to using the framework and Encoder, as well as links to tutorials that cover things like installing Lua and World Editor NewGen.


Features supported
  • Backwards Compatible Codes
  • Online and Offline bases
  • Online and Offline checksums
  • Simple settings for all Encoders
  • Automatic -save and -load commands
  • Save function and support for multiple Loaders
  • load once and max load attempt


Simply copy all of the triggers into your map and Encoder is installed.


save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code save load code


Keywords:
save/load, encoder, save, load, saver, loader
Contents

Just another Warcraft III map (Map)

Reviews
09:13, 29th Aug 2011 Bribe: Deprecated
Level 31
Joined
Jul 10, 2007
Messages
6,307
Well, the map explains how to use it if you explore it =P.

The best bet is to read docs at the very top and then go through the non system trigs and read descriptions on each area ;D.

Every area is explained ^)^.

edit
load bug fixed

no bugs left =P


And yea, I made a save/load code in like 10 seconds with this >.>


updated to use latest Encoder, BigInt and Base
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
Any suggestions?

What'd you have trouble with? : )

edit
There is a lot of information, and I did try to link to various tutorials that covered it as well as write some quickstart guides to using Encoder ^)^.


There are also tons of settings everywhere, from various systems and various areas of the framework ^)^.


I think the best tip is to just explore it all. Dealing with backwards compatible save/load codes as well as conditional save/load is pretty complex ^)^.
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
Humm..
I haven't tested it yet, cuz i see almost all your encoder writen in a very complex language, so...
But, i think this system is very useful and need to dl-ed
:)
I'll try to understand the system, if i had any question, i'll leave a vm for you
 
Level 3
Joined
Mar 14, 2011
Messages
32
Hi nestharus this is really useful (but its quite confusing)

I have question.. how do I link a specific catalog to a hero in "herocatalog" and retrieve it in the saving trigger?

JASS:
    struct StaffCatalog extends array
        implement Catalog
        
        private static method onInit takes nothing returns nothing
            call add('I00J')
            call add('I017')
            call add('I01I')
            call add('I030')
            call add('I05B')
            call add('I04A')
        endmethod
    endstruct

    struct Mage extends array
        implement Catalog
        
        private static method onInit takes nothing returns nothing
            call addCatalog(StaffCatalog.catalog)
        endmethod
    endstruct

Something like this? If this is right, how do I link it to the mage?


Also I found something strange in the demo map
when I remove the second range (save3) and just allow saving/loading of save1 and save2 ,the code doesnt work
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,307
Also I found something strange in the demo map
when I remove the second range (save3) and just allow saving/loading of save1 and save2 ,the code doesnt work

The last value added to an Encoder can't be linked to anything. Furthermore, the last value added should be your largest value. Also, be sure that you updated the Save and Load functions to reflect your changes =).


Here are some examples of retrieving values from catalogs-
integer id = Catalog['hpea'].id

That'll retrieve the catalog id for 'hpea' if it was added to the catalog.

This one will convert a catalog id into a unit type id, like 'hpea'
integer raw = Catalog[1].raw

So for your catalogs, you'd have like
integer raw = StaffCatalog[1].raw

= )


So, for saving, you'd want to make the CodeRange go from 0/1 to your maximum catalog value (Catalog.count) and then retrieve id of a unit type id for saving and convert that id back into a unit type id for loading =).


So you are using .id in saving and .raw in loading.


The Encoder demo map has some great catalog examples as well as using them in save/load ;P.


And I think that Catalog design is the hardest thing in save/load when you get to the complex catalogs Oo.
 
Level 3
Joined
Mar 14, 2011
Messages
32
thanks for reply...

would be nice to see a demo save/load with class specific items though like in pearl east kingdom :O
i have very faint idea of how it looks
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
oh, Pearl East Kingdom no longer has that in it. jxtranghero deleted it all after destroying his backwards compatible codes and replaced it with CodeGen =).


I'll cnp an example here for you to see real fast. Yes, class specific items with item charges is about as complicated as it gets =P.

JASS:
//! textmacro CATALOG_2
    struct ItemCatalog2 extends array
        //can be changed to arrays if adding charged reg items that collide with these
        readonly static integer CHARGE_99_0 = 0
        readonly static integer CHARGE_99_1 = 0
        readonly static integer CHARGE_20_0 = 0
        readonly static integer CHARGE_20_1 = 0
        
        private static integer array catalogs
        private static integer array classCatalogs
        
        method raw takes integer va returns integer
            return CatalogRaw(this, va)
        endmethod
        
        method id takes integer va returns integer
            return CatalogId(this, va)
        endmethod
        
        method operator count takes nothing returns integer
            return CatalogCount(this)
        endmethod
        
        static method operator [] takes integer i returns thistype
            return classCatalogs[GetUnitPointValueByType(i)]
        endmethod
        
        private static method onInit takes nothing returns nothing
            //item classes
            /*
                0   --------------------------	Off-Hand
                1	--------------------------	Clothes
                2	--------------------------	Leather
                3	--------------------------	Chain
                4	--------------------------	Plated
                5	--------------------------	Sword/Axe/Hammer/Two-Handed
                6	--------------------------	Dagger/Katar/Fist
                7	--------------------------	Mace/Wand/Staff/Book/Runes
                8	--------------------------	Bow/Crossbow
            */
            set catalogs[0] = CatalogCreate()
            set catalogs[1] = CatalogCreate()
            set catalogs[2] = CatalogCreate()
            set catalogs[3] = CatalogCreate()
            set catalogs[4] = CatalogCreate()
            set catalogs[5] = CatalogCreate()
            set catalogs[6] = CatalogCreate()
            set catalogs[7] = CatalogCreate()
            set catalogs[8] = CatalogCreate()
            
            //can be split up into each class and so forth if wanting super class specific items
            
            //0
            //      warrior, warlord, legionaire, brigand, pikeman, lancer
            //      0,1,2,3,4,5, rune
            //
            //1 
            //      rogue, elu, slayer, shadow slayer, blader, executioner
            //      0,1,2,3,6, rune
            //2 
            //      oracles, prophet, medium, sage, trickster, dualist, shaman, witch doctor
            //      0,1,7, rune
            //3 
            //      ranger
            //      0,1,2,8, rune
            //4
            //      Refugee
            //      0
            set classCatalogs[0] = CatalogCreate()      //war
            set classCatalogs[1] = CatalogCreate()      //rog
            set classCatalogs[2] = CatalogCreate()      //medium
            set classCatalogs[3] = CatalogCreate()      //ranger
            set classCatalogs[4] = CatalogCreate()      //refugee
            
            //class 0
            set CHARGE_99_0 = 1
            call CatalogAdd(catalogs[0], '0')        //Stone
            set CHARGE_99_1 = 1
            set CHARGE_20_0 = 2
            call CatalogAdd(catalogs[0], '0')        //Minor Healing Potion          0
            call CatalogAdd(catalogs[0], '0')        //Greater Healing Potion        0
            call CatalogAdd(catalogs[0], '0')        //Minor Mana Potion             0
            call CatalogAdd(catalogs[0], '0')        //Greater Mana Potion           0
            call CatalogAdd(catalogs[0], '0')        //Minor Rejuvenation Potion     0
            call CatalogAdd(catalogs[0], '0')        //Greater Rejuvenation Potion   0
            call CatalogAdd(catalogs[0], '0')        //Green Potion                  0
            call CatalogAdd(catalogs[0], '0')        //Sleep Potion                  0
            call CatalogAdd(catalogs[0], '0')        //Blue Herbs                    0
            call CatalogAdd(catalogs[0], '0')        //Green Herbs                   0
            call CatalogAdd(catalogs[0], '0')        //Mushroom                      0
            call CatalogAdd(catalogs[0], '0')        //Red Herbs                     0
            call CatalogAdd(catalogs[0], '0')        //Yellow Herbs                  0
            set CHARGE_20_1 = CatalogCount(catalogs[0])
            call CatalogAdd(catalogs[0], '0')        //Boar Tusk                     0
            call CatalogAdd(catalogs[0], '0')        //Iron Shield                   0
            call CatalogAdd(catalogs[0], '0')        //Wooden Shield                 0
            call CatalogAdd(catalogs[0], '0')        //Blood Stone Heart             0
            call CatalogAdd(catalogs[0], '0')        //Necklace of Nobleman          0
            call CatalogAdd(catalogs[0], '0')        //Silverkey of Brotherhood      0
            call CatalogAdd(catalogs[0], '0')        //Medal of Great Honor          0
            
            //auto added on loading refugee, no need to save
            //call CatalogAdd(catalogs[], 'I04Q')         //Refugee's Blade               0
            //call CatalogAdd(catalogs[], 'I04S')         //Refugee's Boots               0
            //call CatalogAdd(catalogs[], 'I04R')         //Refugee's Suit                0
            
            //class 1
            call CatalogAdd(catalogs[1], '0')        //Bandana                       1
            call CatalogAdd(catalogs[1], '0')        //Bandit Hat                    1
            call CatalogAdd(catalogs[1], '0')        //Hawk Mask                     1
            call CatalogAdd(catalogs[1], '0')        //Hood                          1
            call CatalogAdd(catalogs[1], '0')        //Hood Cape                     1
            call CatalogAdd(catalogs[1], '0')        //Mage Hat                      1
            call CatalogAdd(catalogs[1], '0')        //Mantle                        1
            call CatalogAdd(catalogs[1], '0')        //Robe                          1
            call CatalogAdd(catalogs[1], '0')        //Royal Cape                    1
            call CatalogAdd(catalogs[1], '0')        //Sandals                       1
            call CatalogAdd(catalogs[1], '0')        //Vestment                      1
            call CatalogAdd(catalogs[1], '0')        //Peasant                       1
            call CatalogAdd(catalogs[1], '0')        //Zyria Reinforcer Coat         1
            call CatalogAdd(catalogs[1], '0')        //Pirate Hat                    1
            call CatalogAdd(catalogs[1], '0')        //Wirs Legs                     1
            
            //class 2
            call CatalogAdd(catalogs[2], '0')        //Bandits Armor                 2
            call CatalogAdd(catalogs[2], '0')        //Boots of Speed                2
            call CatalogAdd(catalogs[2], '0')        //Full Leather Armor            2
            call CatalogAdd(catalogs[2], '0')        //Hard Leather Armor            2
            call CatalogAdd(catalogs[2], '0')        //Hat                           2
            call CatalogAdd(catalogs[2], '0')        //Leather Armor                 2
            call CatalogAdd(catalogs[2], '0')        //Hard Scales Armor             2
            call CatalogAdd(catalogs[2], '0')        //Zyria Reinforcer Armor        2
            
            //class 3
            call CatalogAdd(catalogs[3], '0')        //Naga Armor                    3
            
            //class 4
            call CatalogAdd(catalogs[4], '0')        //Plated Boots                  4
            call CatalogAdd(catalogs[4], '0')        //Plated Helm                   4
            call CatalogAdd(catalogs[4], '0')        //Full Pated Mail               4
            call CatalogAdd(catalogs[4], '0')        //Bronze Helm                   4
            call CatalogAdd(catalogs[4], '0')        //Boots of Horde                4
            call CatalogAdd(catalogs[4], '0')        //Mythril Helm                  4
            
            //class 5
            call CatalogAdd(catalogs[5], '0')        //Axe                           5
            call CatalogAdd(catalogs[5], '0')        //Iron Sword                    5
            call CatalogAdd(catalogs[5], '0')        //Lance                         5
            call CatalogAdd(catalogs[5], '0')        //Large Axe                     5
            call CatalogAdd(catalogs[5], '0')        //Long Horn                     5
            call CatalogAdd(catalogs[5], '0')        //Long Sword                    5
            call CatalogAdd(catalogs[5], '0')        //Small Axe                     5
            call CatalogAdd(catalogs[5], '0')        //Spear                         5
            call CatalogAdd(catalogs[5], '0')        //Pike                          5
            call CatalogAdd(catalogs[5], '0')        //Mythril Sword                 5
            call CatalogAdd(catalogs[5], '0')        //Pick Axe                      5
            call CatalogAdd(catalogs[5], '0')        //Enforcer Axe                  5
            
            //class 6
            call CatalogAdd(catalogs[6], '0')        //Dagger                        6
            call CatalogAdd(catalogs[6], '0')        //Mythril Dagger                6
            call CatalogAdd(catalogs[6], '0')        //Spider Claw                   6
            call CatalogAdd(catalogs[6], '0')        //Wild Fangs                    6
            call CatalogAdd(catalogs[6], '0')        //Heretic Blade                 6
            call CatalogAdd(catalogs[6], '0')        //Hammer Forge                  6
            
            //class 7
            call CatalogAdd(catalogs[7], '0')        //Bone Wand                     7
            call CatalogAdd(catalogs[7], '0')        //Novice Stick                  7
            call CatalogAdd(catalogs[7], '0')        //Mind Staff                    7
            
            //class 8
            call CatalogAdd(catalogs[8], 'I046')        //Wooden Bow                    8
            
            call CatalogAddCatalog(classCatalogs[0], catalogs[0])
            call CatalogAddCatalog(classCatalogs[0], catalogs[1])
            call CatalogAddCatalog(classCatalogs[0], catalogs[2])
            call CatalogAddCatalog(classCatalogs[0], catalogs[3])
            call CatalogAddCatalog(classCatalogs[0], catalogs[4])
            call CatalogAddCatalog(classCatalogs[0], catalogs[5])
            call CatalogAddCatalog(classCatalogs[1], catalogs[0])
            call CatalogAddCatalog(classCatalogs[1], catalogs[1])
            call CatalogAddCatalog(classCatalogs[1], catalogs[2])
            call CatalogAddCatalog(classCatalogs[1], catalogs[3])
            call CatalogAddCatalog(classCatalogs[1], catalogs[6])
            call CatalogAddCatalog(classCatalogs[2], catalogs[0])
            call CatalogAddCatalog(classCatalogs[2], catalogs[1])
            call CatalogAddCatalog(classCatalogs[2], catalogs[7])
            call CatalogAddCatalog(classCatalogs[3], catalogs[0])
            call CatalogAddCatalog(classCatalogs[3], catalogs[1])
            call CatalogAddCatalog(classCatalogs[3], catalogs[2])
            call CatalogAddCatalog(classCatalogs[3], catalogs[8])
            call CatalogAddCatalog(classCatalogs[4], catalogs[0])
        endmethod
    endstruct

    struct HeroCatalog2 extends array
        implement Catalog
        readonly static integer HERO_0_0 = 0
        readonly static integer HERO_0_1 = 0
        readonly static integer HERO_1_0 = 0
        readonly static integer HERO_1_1 = 0
        readonly static integer HERO_2_0 = 0
        readonly static integer HERO_2_1 = 0
        readonly static integer HERO_3_0 = 0
        readonly static integer HERO_3_1 = 0
        readonly static integer HERO_4_0 = 0
        readonly static integer HERO_4_1 = 0
        
        private static method onInit takes nothing returns nothing
            //0
            set HERO_0_0 = 1
            call add('0')        //Warrior
            call add('0')        //Warlord
            call add('0')        //Legionaire
            call add('0')        //Brigand
            call add('0')        //Pikeman
            call add('0')        //Lancer
            set HERO_0_1 = count
            
            //1
            set HERO_1_0 = count+1
            call add('0')        //Rogue
            call add('0')        //Eluminator
            call add('0')        //Slayers
            call add('0')        //Shadow Slayer
            call add('0')        //Blader
            call add('0')        //Executioner
            set HERO_1_1 = count
            
            //2
            set HERO_2_0 = count+1
            call add('0')        //Oracles
            call add('0')        //Medium
            call add('0')        //Shaman
            call add('0')        //Trickster
            call add('0')        //Dualist
            call add('0')        //Prophet
            call add('0')        //Sage
            call add('0')        //Witch Doctor
            set HERO_2_1 = count
            
            //3
            set HERO_3_0 = count+1
            call add('0')        //Ranger
            set HERO_3_1 = HERO_3_0
            
            //solo??
            call add('0')        //Wanderer
            
            //4
            set HERO_4_0 = HERO_3_1+2
            call add('0')        //Refugee
            set HERO_4_1 = HERO_4_0
        endmethod
    endstruct
//! endtextmacro

JASS:
//! textmacro ENCODER_2    
    globals
        constant integer ENCODER_2_ELEMENT = 2
        constant integer ENCODER_2_ITEM_CHARGE_99 = 3
        constant integer ENCODER_2_ITEM_CHARGE_20 = 4
    endglobals
    
    private function Encoder2 takes nothing returns nothing
        local Encoder encoder = BuildEncoder(2) //version 2
        
        local CodeRange hero = CodeRange.create(1, HeroCatalog2.count)
        
        local CodeRange array items
            local CodeRange itemCharge99 = CodeRange.create(1,99)   //perishable
            local CodeRange itemCharge20 = CodeRange.create(1,20)   //perishable
        
        local CodeRange elements = CodeRange.create(0,0)
            local CodeRange element = CodeRange.create(5,150)
            
        local CodeRange level = CodeRange.create(1,20)
            local CodeRange xp = CodeRange.create(0, 99)
            
        local CodeRange resource = CodeRange.create(0,100000)
        
        local CodeRange horse = CodeRange.create(0,HorseCatalog1.count)
        
        local integer i
        local integer ic = 0
        local integer it = 4
        local integer ii
        
        //6 slot inventory for 5 classes of heroes
        /*
            0   1   2   3   4
        
            0	6	12	18  24
            1	7	13	19  25
            2	8	14	20  26
            3	9	15	21  27
            4	10	16	22  28
            5	11	17	23  29
        */
        loop
            set i = ItemCatalog2[it].count
            
            //create item ranges and link them to charges
            set ii = 5
            loop
                set items[ic+ii] = CodeRange.create(0, i)
                call items[ic+ii].link(ItemCatalog2.CHARGE_99_0, ItemCatalog2.CHARGE_99_1, itemCharge99, ENCODER_2_ITEM_CHARGE_99)
                call items[ic+ii].link(ItemCatalog2.CHARGE_20_0, ItemCatalog2.CHARGE_20_1, itemCharge20, ENCODER_2_ITEM_CHARGE_20)
                exitwhen ii == 0
                set ii = ii - 1
            endloop
            
            //link item ranges to item ranges
            set ii = 0
            loop
                call items[ic+ii].link(1,i,items[ic+ii+1],0)
                exitwhen ii == 4
                set ii = ii + 1
            endloop
            
            set ic = ic + 6
            exitwhen it == 0
            set it = it - 1
        endloop
        
        //2 slot inventory horse (class 4)
        call horse.link(HorseCatalog1.SLOT_2_0,HorseCatalog1.SLOT_2_1,items[28],0)
        
        //4 slot inventory horse
        call horse.link(HorseCatalog1.SLOT_4_0,HorseCatalog1.SLOT_4_1,items[26],0)
        
        //6 slot inventory horse
        call horse.link(HorseCatalog1.SLOT_6_0,HorseCatalog1.SLOT_6_1,items[24],0)
        
        //elemental stats
        call elements.linka(element)        //dark
        call elements.linka(element)        //earth
        call elements.linka(element)        //fire
        call elements.linka(element)        //light
        call elements.linka(element)        //poison
        call elements.linka(element)        //water
        call elements.linka(element)        //wind
        
        //hero
        call hero.linka(level)                                                  //level
            call level.link(1,19,xp,0)                                          //xp
        
        //6 slot inventory
        call hero.link(HeroCatalog2.HERO_0_0, HeroCatalog2.HERO_0_1, items[0], 0)
        call hero.link(HeroCatalog2.HERO_1_0, HeroCatalog2.HERO_1_1, items[6], 0)
        call hero.link(HeroCatalog2.HERO_2_0, HeroCatalog2.HERO_2_1, items[12], 0)
        call hero.link(HeroCatalog2.HERO_3_0, HeroCatalog2.HERO_3_1, items[18], 0)
        call hero.link(HeroCatalog2.HERO_4_0, HeroCatalog2.HERO_4_1, items[24], 0)
        
        call hero.link(1, HeroCatalog2.HERO_4_0-1, elements, ENCODER_2_ELEMENT)      //elements
        
        call encoder.add(hero)
        call encoder.add(horse)
        call encoder.add(resource)
    endfunction
//! endtextmacro


You can go ahead and study that up ; p


I removed all of the type ids for obvious reasons =)


And Save/Load functions. Look at where I retrieve the item catalog for a specific hero. In the object editor, I assigned the different heroes different point values and used that to get to the catalogs =). The reason for this is because different heroes shared the same item catalogs =P.

From there, I used that catalog I retrieved to convert the item into an id as well as convert back. You'll see this catalog retrieval in both.

Yes, Pearl East Kingdom had a very complicated save/load code >: ).


Also, take a look at the Encoder, specifically here
JASS:
        //6 slot inventory
        call hero.link(HeroCatalog2.HERO_0_0, HeroCatalog2.HERO_0_1, items[0], 0)
        call hero.link(HeroCatalog2.HERO_1_0, HeroCatalog2.HERO_1_1, items[6], 0)
        call hero.link(HeroCatalog2.HERO_2_0, HeroCatalog2.HERO_2_1, items[12], 0)
        call hero.link(HeroCatalog2.HERO_3_0, HeroCatalog2.HERO_3_1, items[18], 0)
        call hero.link(HeroCatalog2.HERO_4_0, HeroCatalog2.HERO_4_1, items[24], 0)

Remember that each range is different. This is the reasno why I have different hero ranges. The more item catalogs you have, the more ranges you'll need and the more links like the above you'll need.

Class specific items are really hard to do, but they are worth it in the end ; ). If you have 10 different item catalogs for example with 100 items each in them, that's a range of 100 saved into code rather than a range of 1000 >: P.

Also, you do know how to properly link up inventories right?

item.link(1,itemCount,item2,1)

etc... this way you don't end up saving a full empty inventory ^)^.
JASS:
    private function Save takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
        local DataBuffer buffer = GetCurrentEncoder().write(pid)
        local unit u
        local integer i
        local integer array items
        local item array it
        local integer ic = 5
        local integer t
        local ItemCatalog2 cat
        
        set u = udg_Heroes[pid+1]
        set cat = ItemCatalog2[GetUnitTypeId(u)]
        
        call buffer.write(HeroCatalog2[GetUnitTypeId(u)].id)
        
        call buffer.write(GetHeroLevel(u))
        if (GetHeroLevel(u) < 20) then
            call buffer.write(GetPercentHeroXP(u))
        endif
        
        set i = 5
        loop
            set t = cat.id(GetItemTypeId(UnitItemInSlot(u, i)))
            if (t != 0) then
                set items[ic] = t
                set it[ic] = UnitItemInSlot(u, i)
                set ic = ic - 1
            endif
            exitwhen i == 0
            set i = i - 1
        endloop
        set ic = 5
        loop
            call buffer.write(items[ic])
            if (buffer.id == ENCODER_2_ITEM_CHARGE_99 ) then
                set t = GetItemCharges(it[ic])
                if (t > 99) then
                    set t = 99
                endif
                call buffer.write(t)
            elseif (buffer.id == ENCODER_2_ITEM_CHARGE_20) then
                set t = GetItemCharges(it[ic])
                if (t > 20) then
                    set t = 20
                endif
                call buffer.write(t)
            endif
            set it[ic] = null
            exitwhen ic == 0 or items[ic] == 0
            set ic = ic - 1
        endloop
        
        if (buffer.id == ENCODER_2_ELEMENT) then
            call buffer.write(udg_Stat_Dark[pid+1])
            call buffer.write(udg_Stat_Earth[pid+1])
            call buffer.write(udg_Stat_Fire[pid+1])
            call buffer.write(udg_Stat_Light[pid+1])
            call buffer.write(udg_Stat_Poison[pid+1])
            call buffer.write(udg_Stat_Water[pid+1])
            call buffer.write(udg_Stat_Wind[pid+1])
        endif
        
        if (udg_Hero_Cart[pid+1]) then
            set u = udg_Horse[pid+1]
            set cat = ItemCatalog2[4]
            call buffer.write(HorseCatalog1[GetUnitTypeId(u)].id)
            set i = UnitInventorySize(u)-1
            set ic = i
            loop
                set t = cat.id(GetItemTypeId(UnitItemInSlot(u, i)))
                if (t != 0) then
                    set items[ic] = t
                    set ic = ic - 1
                endif
                exitwhen i == 0
                set i = i - 1
            endloop
            set ic = UnitInventorySize(u)-1
            loop
                call buffer.write(items[ic])
                exitwhen ic == 0 or items[ic] == 0
                set ic = ic - 1
            endloop
        else
            call buffer.write(0)
        endif
        
        set i = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
        if (i > 100000) then
            set i = 100000
        endif
        call buffer.write(i)
        
        call DisplayTimedTextToPlayer(p, 0, 0, 60, "Encoder Version: " + GetCurrentEncoder().toString())
        call DisplayTimedTextToPlayer(p, 0, 0, 60, buffer.code)
        
        set u = null
        return false
    endfunction

JASS:
//! textmacro LOAD_2
    private function Load2 takes nothing returns nothing
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
        local integer i
        local unit u
        local unit u2
        local DataBuffer buffer = bf
        local ItemCatalog2 cat
        local integer t
        local item it
        
        call RemoveHero(p)
        set u = CreateHero(HeroCatalog2[buffer.read()].raw, p)
        set cat = ItemCatalog2[GetUnitTypeId(u)]
        
        set i = buffer.read()
        if (i > 1) then
            call SetHeroLevel(u, i, false)
        endif
        call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, i*2)
        if (i < 20) then
            call AddPercentHeroXP(u, buffer.read())
        endif
        
        set i = 5
        loop
            set t = buffer.read()
            exitwhen t == 0
            set it = CreateItem(cat.raw(t), 0, 0)
            call UnitAddItem(u, it)
            if (buffer.id == ENCODER_2_ITEM_CHARGE_99 or buffer.id == ENCODER_2_ITEM_CHARGE_20) then
                call SetItemCharges(it, buffer.read())
            endif
            exitwhen i == 0
            set i = i - 1
        endloop
        if (GetUnitPointValueByType(GetUnitTypeId(u)) == 4) then
            call UnitAddItemById(u, 'I04Q')
            call UnitAddItemById(u, 'I04S')
            call UnitAddItemById(u, 'I04R')
        endif
        
        if (buffer.id == ENCODER_2_ELEMENT) then
            set udg_Stat_Dark[pid+1] = buffer.read()
            set udg_Stat_Earth[pid+1] = buffer.read()
            set udg_Stat_Fire[pid+1] = buffer.read()
            set udg_Stat_Light[pid+1] = buffer.read()
            set udg_Stat_Poison[pid+1] = buffer.read()
            set udg_Stat_Water[pid+1] = buffer.read()
            set udg_Stat_Wind[pid+1] = buffer.read()
        endif
        
        set i = buffer.read()
        if (i != 0) then
            set udg_Hero_Cart[pid+1] = true
            set u2 = CreateUnit(p, HorseCatalog1[i].raw, GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
            set udg_Horse[pid+1] = u2
            set cat = ItemCatalog2[4]
            loop
                set i = buffer.read()
                exitwhen i == 0
                set it = CreateItem(cat.raw(i), 0, 0)
                call UnitAddItem(u2, it)
                if (buffer.id == ENCODER_2_ITEM_CHARGE_99 or buffer.id == ENCODER_2_ITEM_CHARGE_20) then
                    call SetItemCharges(it, buffer.read())
                endif
            endloop
        endif
        
        call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, buffer.read())
        
        set it = null
        set u = null
        set u2 = null
    endfunction
//! endtextmacro
 
Last edited:
Level 3
Joined
Mar 14, 2011
Messages
32
Thanks a TON! :))
looks hella complicated on catalog

set cat = ItemCatalog2[GetUnitTypeId(u)] <- is this the retrieval?
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,307
Oh yea, and for your charges, I know this isn't in the example because Pearl East Kingdom didn't need this, but if you have something like this

warrior with 2 items of max charge 15
rogue with 2 different items of max charge 15

You're going to obviously need to do an array for your CHARGE_15 thingie, that way you can retrieve the different regions for the 2 catalogs.

For example, item charge of 15 in warrior might start at 10. For rogue, it might start at 12.

Eh, it'll make more sense when you browse through. This was what I mentioned in the comment above the item charge thingie =).



And Encoder is of course the only save/load system with the power to do this complex stuff =P.


If you master the art of Catalog design, you could write an in-depth Catalog design tutorial ;D.
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
Hello nestharus, i still get confused with the encoder (tried to understand, but still no sign of an understanding)
:'(
Can you make encoder only for save and loading, like in codegen, where you can set the item, heroes, and i think, encoder would be able to store heroes' ability, can you describe to me where is the setting?
And how do i make the save /load?
Confused..
Once again, thanks
 
Level 3
Joined
Mar 14, 2011
Messages
32
Is it fine to update the save function without making new one?


Also in here
JASS:
call horse.link(HorseCatalog1.SLOT_2_0,HorseCatalog1.SLOT_2_1,items[28],0)
        
call horse.link(HorseCatalog1.SLOT_4_0,HorseCatalog1.SLOT_4_1,items[26],0)
        
call horse.link(HorseCatalog1.SLOT_6_0,HorseCatalog1.SLOT_6_1,items[24],0)

are those item arrays random?
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
Is it fine to update the save function without making new one?

yea... you should always be saving with the latest Encoder ; P. It doesn't make sense to support saving older encoders when there is a new one :D.

are those item arrays random?

no = )


It should be 2 slots on first horse, 4 slots on second, and 6 on last.

But those items I linked to are the first items in each array.

Remember the inventory trick?

item1 -> item2 -> item3 etc


so what I'm doing there is linking to second last on the 2 slot horse, then linking to one leaving 4 slots on the 4 slot horse, then first for 6 slot horse =).


Remember Pearl East Kingdom has horses? Yaaaa >.>
 
Level 3
Joined
Mar 14, 2011
Messages
32
ahh now I see :)

ive been testing my encoder for about 20~30 times and 3 times the game froze when i loaded my hero..
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,307
ive been testing my encoder for about 20~30 times and 3 times the game froze when i loaded my hero..

It sounds like you're doing something funky =P.

You are doing a very complex save/load code. Maybe post it up in World Editor Help Zone so we can start a new thread on this and perhaps have other sets of eyes looking at it.

I know how you feel, but we'll get through it ^)^.


Just post up your Encoder object with range values as well as your Catalogs (leave out type id values) and we'll figure out what's going on.


Be sure to comment all of your code so that everyone can read it easily : ).
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
It has tons of instructions on what to do with it. It has so many instructions that people get overwhelmed when first opening it.


Unless you mean how to port it over to another map, which is information I'm going to omit since anyone who knows how to use the trigger editor and knows how to read the information in the map would know.


The map is perfectly fine.


And who cares about the name, seriously.


Unless I feel like adding Catalog examples, the map is staying as it is.


It's already helped a few people get Encoder into their map as well as understand Encoder better and it's helped me put Encoder into people's maps. The design was based off of a framework for Encoder made for an ORPG map that I shall not mention the name of or credit (since I designed/put it into that map, the map and author of that map deserve 0 credit and aren't even worth mentioning).

I pretty much cnp'd all of the code out of that map w/o the author's permission and changed a couple of things =). But again, w/e, I don't need the author's permission to use my own stuff =P, even if I originally made it for that author >: ).
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,307
The framework in this is much improved over the one found in the demo map, yes. This design actually came from the code I wrote for jxtrang's Pearl East Kingdom (almost identical, but I did improve a few things).


I made this since a lot of people were using the one in the Encoder demo map and I thought that the one in the demo map was really bad (was meant to just be a demonstration of how to use the system).


This framework can deal with most maps using Encoder ^)^.


I think the biggest and most important thing in frameworks is support for backwards compatible codes =).


Now there is still one improvement that can be made to Encoder that I'll prob do in the next few days. This improvement is very small (1 line of code actually). It prevents a code from one encoder object being loaded into another when they both have the same checksum (the backwards compatible code stuff). The reason that they can be loaded into each other is because the checksums are still valid. While the code would load in the wrong encoder, the data would be all fudged up. To counter this, the checksums need to be different based on the encoder version.

The update to Encoder would just change this line found in Encoder.create
set eh[t][i]=ph[i]-ph[i]/r*r+m

to this
set eh[t][i]=ph[i]-ph[i]/r*r+m+ev

The ev refers to the encoder version. By adding the encoder version to the checksum, this ensures the checksums are different between each encoder =).

The reason I am hesitant to do this is because a checksum might be very big (the maximum value for example). By adding a value to it, this could cause it to overflow.

This is I think the last issue that needs to be resolved in Encoder : P, and the current method I have for solving it is a method I don't like.

Feel free to change that line to +ev if you want to have that right now =). Just do a CTRL+F to find it.

Well, another one is to generate the player hash at the create method and append the encoder version to the player's name. By doing this, the hashes would be different for each encoder, meaning the checksums would be different w/o going over the limit. I like this method a lot, but it has quite a bit more overhead.

We shall see. I'm more than likely going to go with the latter method, but again the update won't take place for at least a few days.

This will not change the API or any of the settings. To apply an update w/o losing settings, just replace the actual code area (skip the config area) : P.
 
Level 2
Joined
Mar 11, 2011
Messages
6
Here. I have a question :
- I can save/load all ability and it level if my hero already learned?
I making a RPG map! should, i need this system!
hello and thank you very much!>:D<
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
I can save/load all ability and it level if my hero already learned?
Yes you can =).

should, i need this system

If the max levels of abilities between heroes is different or the number of abilities between heroes is different, then you can benefit a lot from this system, otherwise about the only benefit you will get is not saving xp when a hero is max level.

If you have hero specific gear, you will benefit from this system.

If you have a general inventory (standard wc3 inventory), you will benefit from this system ^)^.

If you have some items with item charges, you will benefit from this system.

If you have items of different properties, you will benefit from this system (like bags).

If you have none of that (only the level thing), then I suggest you take in JASS Submissions for the simple save/load framework :p.



Encoder specializes in dynamic codes, so if you have any values that may or may not be present in the code, like hero xp (max lvl hero doesn't need xp), or may have different boundaries depending on circumstances (like max inventory size may be different between heroes) then Encoder is right for you. If all of your values are always present and always have the same min/max range, then you can get away with a simpler save/load system.
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
Updated to make the framework easier to work with and made it so that codes of different versions couldn't be loaded under the wrong version. However, this means that you want to keep your security value away from the max security value possible (the current formula is security + version to get the security value of a given version).



If anyone thinks that some areas need to be documented better, let me know and I'll write some more documentation.
 
Top