Replace the revolting build pointer data structure by a proper data
type. Make it abstract because that's possible. Change data layout so that the slots belonging to a sector are together in memory, it's nicer to the cache. (bp): The new type. Users changed. (get_wp): Update accordingly. (alloc_bp): New. (update_main, calc_all): Use it. Before, calc_all() allocated 1/7 more than necessary.
This commit is contained in:
parent
ac9cdf5bb9
commit
5507e8a1dc
13 changed files with 51 additions and 39 deletions
|
@ -184,7 +184,7 @@ calc_all(long p_sect[][2],
|
|||
int *planes, int *pbuild, int *npbuild, int *pmaint)
|
||||
{
|
||||
struct natstr *np;
|
||||
int *bp;
|
||||
struct bp *bp;
|
||||
long pop = 0;
|
||||
int n, civ_tax, uw_tax, mil_pay;
|
||||
struct sctstr *sp;
|
||||
|
@ -197,7 +197,7 @@ calc_all(long p_sect[][2],
|
|||
*planes = *pbuild = *npbuild = *pmaint = 0;
|
||||
|
||||
np = getnatp(player->cnum);
|
||||
bp = calloc(WORLD_X * WORLD_Y * 8, sizeof(int));
|
||||
bp = alloc_bp();
|
||||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||
fill_update_array(bp, sp);
|
||||
if (sp->sct_own == player->cnum) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue