From: Holger Schemel Date: Wed, 23 Nov 2016 19:06:50 +0000 (+0100) Subject: added function to get the size of a player's inventory for all game engines X-Git-Tag: 4.0.0.0~21 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c0af2ea18f282ed36a71eda3092c8060b0a72df5;p=rocksndiamonds.git added function to get the size of a player's inventory for all game engines --- diff --git a/src/game.c b/src/game.c index 3d2f055f..6144f0d2 100644 --- a/src/game.c +++ b/src/game.c @@ -2050,6 +2050,16 @@ static int compareGamePanelOrderInfo(const void *object1, const void *object2) return compare_result; } +int getPlayerInventorySize(int player_nr) +{ + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + return level.native_em_level->ply[player_nr]->dynamite; + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + return level.native_sp_level->game_sp->red_disk_count; + else + return stored_player[player_nr].inventory_size; +} + void InitGameControlValues() { int i; @@ -2187,15 +2197,8 @@ void UpdateGameControlValues() get_key_element_from_nr(k); } - if (level.game_engine_type == GAME_ENGINE_TYPE_EM) - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - level.native_em_level->ply[i]->dynamite; - else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - level.native_sp_level->game_sp->red_disk_count; - else - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - stored_player[i].inventory_size; + game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += + getPlayerInventorySize(i); if (stored_player[i].num_white_keys > 0) game_panel_controls[GAME_PANEL_KEY_WHITE].value = @@ -2222,15 +2225,8 @@ void UpdateGameControlValues() get_key_element_from_nr(k); } - if (level.game_engine_type == GAME_ENGINE_TYPE_EM) - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - level.native_em_level->ply[player_nr]->dynamite; - else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - level.native_sp_level->game_sp->red_disk_count; - else - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - stored_player[player_nr].inventory_size; + game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += + getPlayerInventorySize(player_nr); if (stored_player[player_nr].num_white_keys > 0) game_panel_controls[GAME_PANEL_KEY_WHITE].value = EL_DC_KEY_WHITE; diff --git a/src/game.h b/src/game.h index 22e59af6..7bf665e8 100644 --- a/src/game.h +++ b/src/game.h @@ -344,6 +344,8 @@ void DEBUG_SetMaximumDynamite(); void GetPlayerConfig(void); int GetElementFromGroupElement(int); +int getPlayerInventorySize(int); + void DrawGameValue_Time(int); void DrawGameDoorValues(void);