player: limit data sizes for resources and population
- All platforms should allow for the same resources. - Population is not expected to exceed UCHAR_MAX on any platform.
This commit is contained in:
parent
9da37c198e
commit
eee1205446
|
@ -9,6 +9,7 @@
|
|||
#include <peripheral.h>
|
||||
#include <player.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -60,7 +61,7 @@ struct human_player
|
|||
|
||||
size_t n_sel;
|
||||
bool top_gui;
|
||||
unsigned long gui_res[MAX_RESOURCE_TYPES];
|
||||
uint32_t gui_res[MAX_RESOURCE_TYPES];
|
||||
};
|
||||
|
||||
int human_player_init(const struct human_player_cfg *cfg, struct human_player *h);
|
||||
|
|
|
@ -36,8 +36,8 @@ struct player
|
|||
bool alive;
|
||||
struct unit units[PLAYER_MAX_UNITS];
|
||||
struct building buildings[PLAYER_MAX_BUILDINGS];
|
||||
unsigned long resources[MAX_RESOURCE_TYPES];
|
||||
size_t pop, bpop;
|
||||
uint32_t resources[MAX_RESOURCE_TYPES];
|
||||
unsigned char pop, bpop;
|
||||
|
||||
struct
|
||||
{
|
||||
|
|
|
@ -726,6 +726,8 @@ int human_player_init(const struct human_player_cfg *const cfg,
|
|||
cursor_init(&h->cam.cursor);
|
||||
h->cam.dim = cfg->dim;
|
||||
h->top_gui = true;
|
||||
UTIL_STATIC_ASSERT(sizeof h->gui_res == sizeof h->pl.resources,
|
||||
"unexpected sizeof for h->gui_res");
|
||||
memmove(h->gui_res, h->pl.resources, sizeof h->gui_res);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue