Fix size of sector bitmap in do_look() and draw_map()
They allocated twice as much as needed.
This commit is contained in:
parent
c89f8172ec
commit
d44ae3ef96
2 changed files with 6 additions and 6 deletions
|
@ -72,12 +72,12 @@ do_look(short type)
|
||||||
|
|
||||||
if (!snxtitem(&ni, type, player->argp[1], NULL))
|
if (!snxtitem(&ni, type, player->argp[1], NULL))
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
|
bitmap = calloc(WORLD_SZ() / 8, 1);
|
||||||
|
if (!bitmap) {
|
||||||
logerror("malloc failed in do_look\n");
|
logerror("malloc failed in do_look\n");
|
||||||
pr("Memory error. Tell the deity.\n");
|
pr("Memory error. Tell the deity.\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
|
|
||||||
while (nxtitem(&ni, &unit)) {
|
while (nxtitem(&ni, &unit)) {
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -147,7 +147,7 @@ draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
bitmap = malloc((WORLD_X * WORLD_Y) / 8);
|
bitmap = malloc(WORLD_SZ() / 8);
|
||||||
if (!wmapbuf || !wmap || !bitmap) {
|
if (!wmapbuf || !wmap || !bitmap) {
|
||||||
pr("Memory error, tell the deity.\n");
|
pr("Memory error, tell the deity.\n");
|
||||||
logerror("malloc failed in draw_map\n");
|
logerror("malloc failed in draw_map\n");
|
||||||
|
@ -202,7 +202,7 @@ draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
|
||||||
if (!player->god) {
|
if (!player->god) {
|
||||||
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
|
memset(bitmap, 0, WORLD_SZ() / 8);
|
||||||
bitinit2(nsp, bitmap, player->cnum);
|
bitinit2(nsp, bitmap, player->cnum);
|
||||||
}
|
}
|
||||||
while (nxtsct(nsp, §) && !player->aborted) {
|
while (nxtsct(nsp, §) && !player->aborted) {
|
||||||
|
@ -221,7 +221,7 @@ draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
if (!player->god) {
|
if (!player->god) {
|
||||||
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
|
memset(bitmap, 0, WORLD_SZ() / 8);
|
||||||
bitinit2(nsp, bitmap, player->cnum);
|
bitinit2(nsp, bitmap, player->cnum);
|
||||||
}
|
}
|
||||||
while (nxtsct(nsp, §) && !player->aborted) {
|
while (nxtsct(nsp, §) && !player->aborted) {
|
||||||
|
@ -265,7 +265,7 @@ draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
|
|
||||||
snxtsct_rewind(nsp);
|
snxtsct_rewind(nsp);
|
||||||
if (!player->god) {
|
if (!player->god) {
|
||||||
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
|
memset(bitmap, 0, WORLD_SZ() / 8);
|
||||||
bitinit2(nsp, bitmap, player->cnum);
|
bitinit2(nsp, bitmap, player->cnum);
|
||||||
}
|
}
|
||||||
while (nxtsct(nsp, §) && !player->aborted) {
|
while (nxtsct(nsp, §) && !player->aborted) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue