Follow-up Comment #19, bug #18776 (project freeciv):

The allocated table is not always of constant size:
+verbose+
int lines = player_count()/32 + 1;
---
./player.c:640: int player_count(void)
./player.c:641: {
./player.c:642:   return player_slots.used_slots;
./player.c:643: }
+verbose+

Should this be MAX_NUM_PLAYERS?

This part is really perplexing:
+verbose+
   2782             known[l * MAP_INDEX_SIZE + tile_index(ptile)]
   2783               |= (1u << (p - l * 8));
-verbose-
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:
+verbose+
   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)
-verbose-
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:

  <http://gna.org/bugs/?18776>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to