diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-27 13:54:57 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-27 17:38:11 +0100 |
| commit | b4f904ecdcf6b0857d28ab4a877ad0f3468153f7 (patch) | |
| tree | 656b7c75ff57963e18dac972e38baf9ba3d46ddb /src | |
| parent | 69f753d26f44c28668d23e0ba40bb3994141df82 (diff) | |
| download | jancity-b4f904ecdcf6b0857d28ab4a877ad0f3468153f7.tar.gz | |
Remove hp
Diffstat (limited to 'src')
| -rw-r--r-- | src/building/inc/building.h | 1 | ||||
| -rw-r--r-- | src/building/src/building.c | 14 | ||||
| -rw-r--r-- | src/instance/inc/instance.h | 10 | ||||
| -rw-r--r-- | src/instance/src/instance.c | 13 | ||||
| -rw-r--r-- | src/player/src/human_player.c | 4 | ||||
| -rw-r--r-- | src/player/src/human_player_gui.c | 34 | ||||
| -rw-r--r-- | src/unit/inc/unit.h | 4 | ||||
| -rw-r--r-- | src/unit/src/unit.c | 12 |
8 files changed, 4 insertions, 88 deletions
diff --git a/src/building/inc/building.h b/src/building/inc/building.h index a0ab539..7c7d45f 100644 --- a/src/building/inc/building.h +++ b/src/building/inc/building.h @@ -31,7 +31,6 @@ struct building_cfg void building_create(const struct building_cfg *cfg, struct building *b); void building_set_alive_cb(void (*f)(const struct util_rect *dim, bool alive, void *p), void *p); int building_render(const struct building *b, const struct camera *cam, bool sel); -instance_hp building_maxhp(const struct building *b); const char *building_str(const struct building *b); extern struct sprite building_sprites[MAX_BUILDING_TYPES]; diff --git a/src/building/src/building.c b/src/building/src/building.c index 5ff9183..457d9e6 100644 --- a/src/building/src/building.c +++ b/src/building/src/building.c @@ -6,16 +6,6 @@ struct sprite building_sprites[MAX_BUILDING_TYPES]; -instance_hp building_maxhp(const struct building *const b) -{ - static const instance_hp hp[] = - { - [BUILDING_TYPE_BARRACKS] = 100 - }; - - return hp[b->type]; -} - int building_render(const struct building *const b, const struct camera *const cam, const bool sel) { @@ -33,8 +23,7 @@ int building_render(const struct building *const b, .prim_type = INSTANCE_RENDER_CFG_SPRITE, .prim = {.s = s}, .cam = cam, - .sel = sel, - .max_hp = building_maxhp(b) + .sel = sel }; return instance_render(&cfg); @@ -69,7 +58,6 @@ void building_create(const struct building_cfg *const cfg, i->r.x = cfg->x; i->r.y = cfg->y; i->alive = true; - i->hp = building_maxhp(b); if (cb) cb(&i->r, i->alive, op); diff --git a/src/instance/inc/instance.h b/src/instance/inc/instance.h index ca8a606..c6f20d2 100644 --- a/src/instance/inc/instance.h +++ b/src/instance/inc/instance.h @@ -12,17 +12,12 @@ extern "C" { #endif -typedef unsigned int instance_hp; - struct instance { - bool alive, dying; - unsigned int hp; + bool alive; struct util_rect r; }; -typedef bool (*instance_attacked_cb)(struct instance *i, unsigned int ap); -typedef bool (*instance_sheltered_cb)(struct instance *self, struct instance *other); typedef void (*instance_done_cb)(struct instance *i, void *op); struct instance_render_cfg @@ -48,15 +43,12 @@ struct instance_render_cfg } prim; bool sel; - instance_hp max_hp; const struct instance_render_off { short x, y; } *off; }; -bool instance_attacked(struct instance *self, unsigned int ap); -void instance_clear_pools(void); int instance_render(const struct instance_render_cfg *cfg); int instance_render_target(const struct instance *const i, const struct camera *cam); void instance_cyclic(void); diff --git a/src/instance/src/instance.c b/src/instance/src/instance.c index 7fcd9b4..1e9e039 100644 --- a/src/instance/src/instance.c +++ b/src/instance/src/instance.c @@ -8,19 +8,6 @@ static unsigned char line_g; static bool line_g_flip; -bool instance_attacked(struct instance *const self, const instance_hp ap) -{ - if (self->hp > ap) - self->hp -= ap; - else - { - self->hp = 0; - self->alive = false; - } - - return !self->alive; -} - void instance_cyclic(void) { if (!line_g_flip) diff --git a/src/player/src/human_player.c b/src/player/src/human_player.c index 08cfbe0..7f67ec7 100644 --- a/src/player/src/human_player.c +++ b/src/player/src/human_player.c @@ -279,8 +279,8 @@ static void update_selected(struct human_player *const h) { struct sel_instance *const si = &h->sel[i]; - if (si->d.i && (!si->d.i->alive || si->d.i->dying - || si->type == INSTANCE_TYPE_UNIT)) + if (si->d.i + && (!si->d.i->alive || si->type == INSTANCE_TYPE_UNIT)) { si->d.i = NULL; h->n_sel--; diff --git a/src/player/src/human_player_gui.c b/src/player/src/human_player_gui.c index 60a7ecd..3f79848 100644 --- a/src/player/src/human_player_gui.c +++ b/src/player/src/human_player_gui.c @@ -25,8 +25,6 @@ static int render_sel_single_building(const struct human_player *const h, const struct sel_instance *const sel, struct gui_common *const r) { const struct building *const b = sel->d.b; - const struct instance *const in = &b->instance; - const instance_hp hp = in->hp, max_hp = building_maxhp(b); struct gui_label bl; gui_label_init(&bl); @@ -35,21 +33,6 @@ static int render_sel_single_building(const struct human_player *const h, bl.text = building_str(b); gui_add_child(r, &bl.common); - char hp_str[sizeof "65535/65535"]; - - const int rs = snprintf(hp_str, sizeof hp_str, "%u/%u", hp, max_hp); - - if (rs < 0 || rs >= sizeof hp_str) - return -1; - - struct gui_label hpl; - - gui_label_init(&hpl); - hpl.common.x = X_OFF; - hpl.common.y = HP_Y; - hpl.text = hp_str; - gui_add_child(r, &hpl.common); - return gui_render(r); } @@ -57,8 +40,6 @@ static int render_sel_single_unit(const struct human_player *const h, const struct sel_instance *const sel, struct gui_common *const r) { const struct unit *const u = sel->d.u; - const struct instance *const in = &u->instance; - const instance_hp hp = in->hp, max_hp = unit_maxhp(u); enum {CARRY_X = 96, CARRY_Y = 8}; struct gui_label ul; @@ -69,21 +50,6 @@ static int render_sel_single_unit(const struct human_player *const h, ul.text = unit_str(u); gui_add_child(r, &ul.common); - char hp_str[sizeof "65535/65535"]; - - const int rs = snprintf(hp_str, sizeof hp_str, "%u/%u", hp, max_hp); - - if (rs < 0 || rs >= sizeof hp_str) - return -1; - - struct gui_label hpl; - - gui_label_init(&hpl); - hpl.common.x = X_OFF; - hpl.common.y = HP_Y; - hpl.text = hp_str; - gui_add_child(r, &hpl.common); - return gui_render(r); } diff --git a/src/unit/inc/unit.h b/src/unit/inc/unit.h index a200c63..d86704d 100644 --- a/src/unit/inc/unit.h +++ b/src/unit/inc/unit.h @@ -25,8 +25,6 @@ struct unit_target { struct instance *ins; enum unit_state state; - instance_sheltered_cb shelter; - instance_attacked_cb attack; instance_done_cb done; void *op; }; @@ -73,9 +71,7 @@ bool unit_can_harvest(const struct unit *u); bool unit_target_valid(const struct unit *u, const struct unit_target *t); void unit_set_target(struct unit *u, const struct unit_target *t); void unit_move_to(struct unit *u, unsigned long x, unsigned long y); -bool unit_attacked(struct instance *, instance_hp ap); void unit_update(struct unit *u); -instance_hp unit_maxhp(const struct unit *u); const char *unit_str(const struct unit *u); enum diff --git a/src/unit/src/unit.c b/src/unit/src/unit.c index 0590adb..a95cca3 100644 --- a/src/unit/src/unit.c +++ b/src/unit/src/unit.c @@ -216,16 +216,6 @@ void unit_move_to(struct unit *const u, const unsigned long x, const unsigned lo u->ty = y > y_off ? fix16_from_int(y - y_off) : 0; } -instance_hp unit_maxhp(const struct unit *const u) -{ - static const instance_hp hp[] = - { - [UNIT_TYPE_PEASANT] = 25 - }; - - return hp[u->type]; -} - static int get_ux(const struct unit *const u) { switch (u->dir) @@ -416,7 +406,6 @@ int unit_render(const struct unit *const u, const struct camera *const cam, .prim = {.quad = &rcfg.qcfg}, .cam = cam, .sel = sel, - .max_hp = unit_maxhp(u), .off = &rcfg.off }; @@ -448,7 +437,6 @@ void unit_create(const struct unit_cfg *const cfg, struct unit *const u) .instance = { .alive = true, - .hp = unit_maxhp(u) }, .type = cfg->type, |
