Follow-up Comment #19, bug #18776 (project freeciv):
The allocated table is not always of constant size:
int lines = player_count()/32 + 1;
./player.c:640: int player_count(void)
./player.c:642: return player_slots.used_slots;
Should this be MAX_NUM_PLAYERS?
This part is really perplexing:
2782 known[l * MAP_INDEX_SIZE + tile_index(ptile)]
2783 |= (1u << (p - l * 8));
Suppose there is a player with index 60. p = 60, l = 1. (p - l * 8) = (60 -
8) = 52. 1 << 52 bits is more than an int can handle.
I added these lines:
2779 fprintf(stderr, "save: size of known: %dn", lines *
MAP_INDEX_SIZE * sizeof(*known));
2780 fprintf(stderr, "save: known index: %dn", l *
MAP_INDEX_SIZE + tile_index(ptile));
save: size of known: 336960
save: known index: 86016
Segmentation fault (core dumped)
336960/4 = 84240.
I don't really understand what this code does, especially the SAVE_MAP_CHAR
so I didn't attempt to fix it. Will this code work, if there are two players
with indexes 0 and 125?
Reply to this item at:
Message sent via/by Gna!
Freeciv-dev mailing list