View Single Post
Old May 9, 2017, 10:11   #92
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,832
PowerWyrm is on a distinguished road
Quote:
Originally Posted by t4nk View Post
come to think of it, why does obj-init.c do that? and why does it start assigning from a_max, leaving zeroed out struct at the beginning?
That's what the code does everywhere. The main reason is to put zero as index in the savefiles where there is nothing to save, while keeping a trivial loading routine: read index, assign struct = structs[index]. Otherwise, you would have to check the index, see if it's zero, assign null in that case, assign struct = structs[index-1] in other cases.

Note that in PWMAngband, I do the latter. It makes loading savefiles more complex, but simplifies all the rest (in particular, the init/parsing code).
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote