View Single Post
Old May 9, 2017, 10:11   #92
PowerWyrm's Avatar
Join Date: Apr 2008
Posts: 2,832
PowerWyrm is on a distinguished road
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 (or to learn more about this new variant!
PowerWyrm is offline   Reply With Quote