(XYOFFSET): Returned twice the value it should.
(finish_sects): Allocated twice as much space as needed, to make it work with the broken XYOFFSET().
This commit is contained in:
parent
e09f50a7d3
commit
6d9e78af4c
2 changed files with 4 additions and 10 deletions
|
@ -36,9 +36,8 @@
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
/* Used to calculate an offset into an array. Used for
|
/* Fast version of sctoff() for normalized arguments: */
|
||||||
dynamically sizing the world. */
|
#define XYOFFSET(x, y) (((y) * WORLD_X + (x)) / 2)
|
||||||
#define XYOFFSET(x, y) (((y) * WORLD_X) + (x))
|
|
||||||
|
|
||||||
#define XNORM(x) \
|
#define XNORM(x) \
|
||||||
(((x) < 0) ? ((WORLD_X - (-(x) % WORLD_X)) % WORLD_X) : ((x) % WORLD_X))
|
(((x) < 0) ? ((WORLD_X - (-(x) % WORLD_X)) % WORLD_X) : ((x) % WORLD_X))
|
||||||
|
|
|
@ -77,20 +77,15 @@ finish_sects(int etu)
|
||||||
if (g_distptrs == NULL) {
|
if (g_distptrs == NULL) {
|
||||||
logerror("First update since reboot, allocating buffer\n");
|
logerror("First update since reboot, allocating buffer\n");
|
||||||
/* Allocate the information buffer */
|
/* Allocate the information buffer */
|
||||||
g_distptrs = (struct distinfo *)(malloc((WORLD_X * WORLD_Y) *
|
g_distptrs = malloc((WORLD_X * WORLD_Y / 2) * sizeof(*g_distptrs));
|
||||||
sizeof(struct distinfo)));
|
|
||||||
if (g_distptrs == NULL) {
|
if (g_distptrs == NULL) {
|
||||||
logerror("malloc failed in finish_sects.\n");
|
logerror("malloc failed in finish_sects.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logerror("Allocated '%lu' bytes '%d' indices\n",
|
|
||||||
(unsigned long)(WORLD_X * WORLD_Y * sizeof(struct distinfo)),
|
|
||||||
WORLD_X * WORLD_Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wipe it clean */
|
/* Wipe it clean */
|
||||||
memset(g_distptrs, 0, ((WORLD_X * WORLD_Y) * sizeof(struct distinfo)));
|
memset(g_distptrs, 0, (WORLD_X * WORLD_Y / 2) * sizeof(*g_distptrs));
|
||||||
|
|
||||||
logerror("delivering...\n");
|
logerror("delivering...\n");
|
||||||
/* Do deliveries */
|
/* Do deliveries */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue