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

> I removed half the players in LTeX (idlers). The memory usage
> dropped by about half. I saved the game then restarted the
> server, and a turn was made - everything is ok.
So the last patch fixed it? If this is the case, should both patches be
applied to 2.3.1 before it is released on the weekend? I added file #14560 as
bug #19007.

Memory saving is mostly due to the freed private/known maps ...

> Still, could you help me understand: 1u << (p - l * 8), which
> really means 1u << (p - p / 4), which is of course 1u << (0.75
> * p). For 126 players, you cannot shift 1 by 94 bits left!

I will try - if it is wrong please correct me!

lines is (now) calculated as the number of int values needed to save the
known information of each tile, i.e (max used player index / 32 + 1).

example: max used player index = 60 => 60/32 + 1 = 1 + 1 = 2

Now the player information has to be saved in the int values. It is done
such, that in int 1, information for player 0 .. 31 is saved, int 2 takes
player 32 to 63 etc. Calculating the bit index within the int is done using
the following equation:

[bit] = p - l * 8

with p = (player index) and l = p / 32; as l is an int the last equation is
equal to l = floor(p/32), i.e. round down. Thus, the equation reads

[bit] = p - floor(p/32) * 8

which limits it to values between 0 and 31.

l is also used to select the correct int value in the calucaltion of the
index for the bitvector known (lines 2836-2837 in savegame2.c of trunk):

known[l * MAP_INDEX_SIZE + tile_index(ptile)] |= (1u << (p - l * 8));



    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Nachricht geschickt von/durch Gna!
  http://gna.org/


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

Reply via email to