From 4af227fec63cd55e4557e9d7f5e00ca0e28c2138 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 May 2020 23:19:36 +0200 Subject: [PATCH] - resetinventory. --- source/games/duke/src/premap.cpp | 26 ++++++------ source/games/duke/src/premap.h | 2 +- source/games/duke/src/zz_game.cpp | 4 +- source/games/duke/src/zz_premap.cpp | 63 ++--------------------------- 4 files changed, 20 insertions(+), 75 deletions(-) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index a09d895df..b965985b4 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -303,25 +303,28 @@ void resetweapons(int snum) // //--------------------------------------------------------------------------- -void resetinventory(short snum) +void resetinventory(int snum) { - struct player_struct *p; + struct player_struct* p; p = &ps[snum]; - p->inven_icon = 0; + p->inven_icon = 0; p->boot_amount = 0; - p->scuba_on = 0;p->scuba_amount = 0; - p->heat_amount = 0;p->heat_on = 0; - p->jetpack_on = 0;p->jetpack_amount = 0; - p->shield_amount = max_armour_amount; + p->scuba_on = 0; + p->scuba_amount = 0; + p->heat_amount = 0; + p->heat_on = 0; + p->jetpack_on = 0; + p->jetpack_amount = 0; + p->shield_amount = max_armour_amount; p->holoduke_on = -1; - p->holoduke_amount = 0; + p->holoduke_amount = 0; p->firstaid_amount = 0; p->steroids_amount = 0; p->inven_icon = 0; - if (ud.multimode > 1 && ud.coop != 1) + if (isRR() && ud.multimode > 1 && ud.coop != 1) { p->keys[0] = 1; p->keys[1] = 1; @@ -354,9 +357,7 @@ void resetinventory(short snum) if (numplayers < 2) { - ufospawn = ud.m_player_skill*4+1; - if (ufospawn > 32) - ufospawn = 32; + ufospawn = std::min(ud.m_player_skill*4+1, 32); ufocnt = 0; hulkspawn = ud.m_player_skill + 1; } @@ -366,6 +367,7 @@ void resetinventory(short snum) ufocnt = 0; hulkspawn = 2; } + OnEvent(EVENT_RESETINVENTORY, snum, p->i); } diff --git a/source/games/duke/src/premap.h b/source/games/duke/src/premap.h index 438a4b8f4..2c5a2ec1f 100644 --- a/source/games/duke/src/premap.h +++ b/source/games/duke/src/premap.h @@ -36,7 +36,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum); void G_ResetTimers(uint8_t keepgtics); void G_UpdateScreenArea(void); void P_RandomSpawnPoint(int playerNum); -void P_ResetInventory(int playerNum); +void resetinventory(int playerNum); void P_ResetPlayer(int playerNum); void resetplayerstats(int playerNum); void resetweapons(int playerNum); diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index c0b3239c2..aada66ae9 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -4064,8 +4064,8 @@ MAIN_LOOP_RESTART: for (bssize_t TRAVERSE_CONNECT(i)) { - P_ResetWeapons(i); - P_ResetInventory(i); + resetweapons(i); + resetinventory(i); } G_NewGame_EnterLevel(); diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index c75eb491e..cb8d86d7e 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -303,70 +303,13 @@ void P_ResetPlayer(int playerNum) actor[pPlayer->i].owner = pPlayer->i; actor[pPlayer->i].t_data[4] = 0; - P_ResetInventory(playerNum); + resetinventory(playerNum); resetweapons(playerNum); //pPlayer->reloading = 0; pPlayer->movement_lock = 0; } -void P_ResetInventory(int playerNum) -{ - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - - Bmemset(pPlayer->inv_amount, 0, sizeof(pPlayer->inv_amount)); - - pPlayer->scuba_on = 0; - pPlayer->heat_on = 0; - pPlayer->jetpack_on = 0; - pPlayer->holoduke_on = -1; - pPlayer->inven_icon = ICON_NONE; - pPlayer->inv_amount[GET_SHIELD] = max_armour_amount; - - if (RR) - { - if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) - { - pPlayer->keys[0] = 1; - pPlayer->keys[1] = 1; - pPlayer->keys[2] = 1; - pPlayer->keys[3] = 1; - pPlayer->keys[4] = 1; - } - else - { - pPlayer->keys[0] = 0; - pPlayer->keys[1] = 0; - pPlayer->keys[2] = 0; - pPlayer->keys[3] = 0; - pPlayer->keys[4] = 0; - } - - pPlayer->drunkang = pPlayer->eatang = 1647; - pPlayer->drink_amt = pPlayer->eat = 0; - pPlayer->drink_timer = pPlayer->eat_timer = 4096; - pPlayer->shotgun_state[0] = pPlayer->shotgun_state[1] = 0; - pPlayer->detonate_time = 0; - pPlayer->detonate_count = 0; - pPlayer->recoil = 0; - pPlayer->yehaa_timer = 0; - resetlanepics(); - if (!g_netServer && numplayers < 2) - { - g_ufoSpawn = min(ud.m_player_skill*4+1, 32); - g_ufoCnt = 0; - g_hulkSpawn = ud.m_player_skill + 1; - } - else - { - g_ufoSpawn = 32; - g_ufoCnt = 0; - g_hulkSpawn = 2; - } - } - - VM_OnEvent(EVENT_RESETINVENTORY, pPlayer->i, playerNum); -} static void resetprestat(int playerNum, int gameMode) { @@ -426,7 +369,7 @@ static void resetprestat(int playerNum, int gameMode) || (!(g_gametypeFlags[ud.coop] & GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1)) { resetweapons(playerNum); - P_ResetInventory(playerNum); + resetinventory(playerNum); } else if (pPlayer->curr_weapon == HANDREMOTE_WEAPON && !isRR()) { @@ -1622,7 +1565,7 @@ int G_EnterLevel(int gameMode) case FLOORSLIME__STATIC: case FLOORPLASMA__STATIC: resetweapons(i); - P_ResetInventory(i); + resetinventory(i); g_player[i].ps->gotweapon.Clear(PISTOL_WEAPON); g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0;