Plan for larger hero reserve
Making the reserve larger
The hero reserve is currently limited in size.
The arrays that store hero instance data are 41 elements (0-40) and they can only be filled up to 38 heroes because there must always be 3 empty slots so that a single-hero active party will be possible.
There are already some functions wrapping these constants, such as herocount(), free_slots_in_party(), first_free_slot_in_party(), and first_free_slot_in_reserve_party()
- Make sure that all these limits are actually checked and enforced when trying to add new heroes
- Replace all code that hard-codes the array limit of 0-40
- Find all the places where the array limit is currently completely unchecked
- Make a list of all in-memory arrays that store hero data
- gam.hero(slot) as GameState - a bunch of hero state data. I could move other stuff into this struct
- eqstuf(slot, eqslot) as integer - stores hero equipment
- spell(slot, spellist, spellslot) as integer - spell lists
- learnmask() as integer - recent spell learning info
- lmp(slot, lev) as integer - level MP
- Add a new function returning the current size of the reserve
- Many places will already loop to UBOUND(some_hero_array) but others will not
- Verify that more heroes can be saved in RSAV files
- Store the reserve size limit in the general game data
- Add code to make the in-memory arrays bigger on-demand, up to the limit set in the general data
- make the limit in the general game data editable.
- Test very large hero reserves
More hero definitions
The number of hero definitions is limited to 60 (numbered 0-59) This limit is imposed by the equipability bitsets in the ITM lump.
- Enlarge the records in the ITM lump to allow more space for equipability bitsets. To support a max of 3000 hero definitions, 183 more bytes would be enough space
- Switch the ITM lump over to the items.reld format. This is more work, but the items.reld format is already planned, and it paves the way for a lot of other improvements.
The rest of the plan
- After increasing the number of equipability bits, remove the arbitrary limit of 0-59 from the hero editor code. This step should be pretty easy.