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
This commit is contained in:
helixhorned 2013-07-13 21:04:52 +00:00
parent adbd6394fc
commit d7e4d5afbf
5 changed files with 33 additions and 25 deletions

View file

@ -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();

View file

@ -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

View file

@ -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)
{

View file

@ -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;
}

View file

@ -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);