From d7e4d5afbf7fca157f4fc640c415f4ad6c9e7366 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 13 Jul 2013 21:04:52 +0000 Subject: [PATCH] Factor out repeated few-liner into G_NewGame_EnterLevel(), misc. cleanup. git-svn-id: https://svn.eduke32.com/eduke32@3950 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 15 ++++++++------- polymer/eduke32/source/game.h | 10 ++++++++++ polymer/eduke32/source/menus.c | 3 +-- polymer/eduke32/source/osdcmds.c | 6 ++---- polymer/eduke32/source/premap.c | 24 ++++++++++++------------ 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 955ac9c91..0a4223b05 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -10914,14 +10914,19 @@ static int32_t G_EndOfLevel(void) } } } + ud.display_bonus_screen = 1; ready2send = 0; - if (numplayers > 1) g_player[myconnectindex].ps->gm = MODE_GAME; + + if (numplayers > 1) + g_player[myconnectindex].ps->gm = MODE_GAME; + if (G_EnterLevel(g_player[myconnectindex].ps->gm)) { G_BackToMenu(); return 2; } + Net_WaitForServer(); return 1; @@ -11713,9 +11718,7 @@ MAIN_LOOP_RESTART: P_ResetInventory(i); } - G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + G_NewGame_EnterLevel(); Net_WaitForServer(); } @@ -11735,9 +11738,7 @@ MAIN_LOOP_RESTART: } else if (ud.warp_on == 1) { - G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + G_NewGame_EnterLevel(); } else G_UpdateScreenArea(); diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index a1c861909..336e12e3d 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __game_h__ #define __game_h__ +#include "premap.h" + #define USERQUOTE_LEFTOFFSET 5 #define USERQUOTE_RIGHTOFFSET 14 @@ -540,4 +542,12 @@ enum cheatindex_t #include "game_inline.h" +static inline void G_NewGame_EnterLevel(void) +{ + G_NewGame(ud.m_volume_number, ud.m_level_number, ud.m_player_skill); + + if (G_EnterLevel(MODE_GAME)) + G_BackToMenu(); +} + #endif diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 34c19d1c0..3ca787a21 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2439,8 +2439,7 @@ cheat_for_port_credits2: nextpage(); } - G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + G_NewGame_EnterLevel(); } else if (x == -1) { diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 9943975de..b749b72fe 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -159,8 +159,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm) ud.multimode = 1; - G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + G_NewGame_EnterLevel(); } return OSDCMD_OK; @@ -286,8 +285,7 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm) ud.multimode = 1; - G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + G_NewGame_EnterLevel(); return OSDCMD_OK; } diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 4be308818..c2f431555 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1407,7 +1407,7 @@ static inline void prelevel(char g) } -void G_NewGame(int32_t vn,int32_t ln,int32_t sk) +void G_NewGame(int32_t vn, int32_t ln, int32_t sk) { DukePlayer_t *p = g_player[0].ps; int32_t i; @@ -1451,17 +1451,17 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk) g_showShareware = GAMETICSPERSEC*34; - ud.level_number = ln; - ud.volume_number = vn; - ud.player_skill = sk; - ud.secretlevel = 0; + ud.level_number = ln; + ud.volume_number = vn; + ud.player_skill = sk; + ud.secretlevel = 0; ud.from_bonus = 0; parallaxyscale = 0; ud.last_level = -1; g_lastSaveSlot = -1; - p->zoom = 768; - p->gm = 0; + p->zoom = 768; + p->gm = 0; #if !defined LUNATIC //AddLog("Newgame"); @@ -1500,7 +1500,7 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk) p->last_weapon = -1; } - display_mirror = 0; + display_mirror = 0; VM_OnEvent(EVENT_NEWGAME, g_player[myconnectindex].ps->i, myconnectindex, -1, 0); } @@ -1807,7 +1807,8 @@ void G_SetupFilenameBasedMusic(char *levnamebuf, const char *boardfilename, int3 Bmemcpy(p+1, "mid", 4); fil = kopen4loadfrommod(levnamebuf,0); - // XXX: should pull in a "default user map" song entry, probably E1L8 (which would need to not get clobbered) + // XXX: should pull in a "default user map" song entry, probably E1L8 + // (which would need to not get clobbered) if (fil == -1) Bstrcpy(levnamebuf, "dethtoll.mid"); else kclose(fil); @@ -1824,7 +1825,6 @@ int32_t G_EnterLevel(int32_t g) // waitforeverybody(); vote_map = vote_episode = voting = -1; - if ((g&MODE_DEMO) != MODE_DEMO) ud.recstat = ud.m_recstat; ud.respawn_monsters = ud.m_respawn_monsters; ud.respawn_items = ud.m_respawn_items; ud.respawn_inventory = ud.m_respawn_inventory; @@ -1834,6 +1834,8 @@ int32_t G_EnterLevel(int32_t g) ud.ffire = ud.m_ffire; ud.noexits = ud.m_noexits; + if ((g&MODE_DEMO) != MODE_DEMO) + ud.recstat = ud.m_recstat; if ((g&MODE_DEMO) == 0 && ud.recstat == 2) ud.recstat = 0; @@ -2031,8 +2033,6 @@ int32_t G_EnterLevel(int32_t g) g_restorePalette = -1; -// mmulti_flushpackets(); - G_FadePalette(0,0,0,0); G_UpdateScreenArea(); clearview(0L);