- newgame is clean now.

This commit is contained in:
Christoph Oelckers 2020-07-07 22:41:31 +02:00
parent 63eaec916b
commit ecddd8687c
6 changed files with 94 additions and 72 deletions

View File

@ -54,7 +54,7 @@ static void dowarp(MapRecord *map)
if (ps[myconnectindex].gm & MODE_GAME)
{
G_NewGame(map, ud.m_player_skill);
newgame(map, ud.m_player_skill);
ps[myconnectindex].gm = MODE_RESTART;
}
else G_NewGame_EnterLevel(map, ud.m_player_skill);

View File

@ -3,6 +3,8 @@
#include "screenjob.h"
#include "constants.h"
struct MapRecord;
BEGIN_DUKE_NS
// dumping ground for all external function prototypes to keep them out of the important headers.
@ -221,5 +223,7 @@ void prelevel_r(int g);
void e4intro(CompletionFunc completion);
void clearfrags(void);
int exitlevel();
int enterlevel(MapRecord* mi, int gm);
void newgame(MapRecord* mi, int sk);
END_DUKE_NS

View File

@ -90,7 +90,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk
static inline void G_NewGame_EnterLevel(MapRecord *map, int skill)
{
G_NewGame(map, skill);
newgame(map, skill);
if (enterlevel(map, MODE_GAME))
G_BackToMenu();

View File

@ -768,6 +768,94 @@ void resettimevars(void)
//
//---------------------------------------------------------------------------
void newgame(MapRecord* map, int sk)
{
auto p = &ps[0];
handleevents();
ready2send = 0;
#if 0
if (ud.m_recstat != 2 && ud.last_level >= 0 && ud.multimode > 1 && ud.coop != 1)
dobonus(1);
if (isRR() && !isRRRA() && map->levelNumber == levelnum(0, 6))
dobonus(0);
#endif
show_shareware = 26 * 34;
ud.nextLevel = map;
ud.player_skill = sk;
ud.secretlevel = 0;
ud.from_bonus = 0;
ud.last_level = -1;
if (!isRR() && map->levelNumber == levelnum(3, 0) && (ud.multimode < 2))
{
e4intro([](bool) {});
}
p->zoom = 768;
p->gm = 0;
M_ClearMenus();
ResetGameVars();
if (m_coop != 1)
{
if (isWW2GI())
{
for (int i = 0; i < 12/*MAX_WEAPONS*/; i++) // aboive 12 have no data defined and would crash.
{
if (aplWeaponWorksLike[i][0] == PISTOL_WEAPON)
{
p->curr_weapon = i;
p->gotweapon.Set(i);
p->ammo_amount[i] = 48;
}
else if (aplWeaponWorksLike[i][0] == KNEE_WEAPON || aplWeaponWorksLike[i][0] == HANDREMOTE_WEAPON)
{
p->gotweapon.Set(i);
}
}
}
else
{
p->curr_weapon = PISTOL_WEAPON;
p->gotweapon.Set(PISTOL_WEAPON);
p->gotweapon.Set(KNEE_WEAPON);
p->ammo_amount[PISTOL_WEAPON] = 48;
p->gotweapon.Set(HANDREMOTE_WEAPON);
p->last_weapon = -1;
}
p->last_weapon = -1;
}
display_mirror = 0;
if (ud.multimode > 1)
{
if (numplayers < 2)
{
connecthead = 0;
for (int i = 0; i < MAXPLAYERS; i++) connectpoint2[i] = i + 1;
connectpoint2[ud.multimode - 1] = -1;
}
}
else
{
connecthead = 0;
connectpoint2[0] = -1;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode)
{
int16_t lbang;

View File

@ -29,8 +29,6 @@ BEGIN_DUKE_NS
extern int16_t ambientlotag[64];
extern int16_t ambienthitag[64];
int enterlevel(MapRecord *mi, int gameMode);
void G_NewGame(MapRecord *mi, int skillNum);
void P_ResetPlayer(int pn);
void G_ResetInterpolations(void);
void G_InitRRRASkies(void);

View File

@ -63,74 +63,6 @@ void G_InitRRRASkies(void)
}
}
void G_NewGame(MapRecord *map, int skillNum)
{
struct player_struct *const pPlayer = g_player[0].ps;
handleevents();
ready2send = 0;
#if 0
if (m_recstat != 2 && ud.last_level >= 0 &&
(g_netServer || ud.multimode > 1) && (ud.coop&GAMETYPE_SCORESHEET))
{
dobonus(1);
}
if (isRR() && !isRRRA() && map->levelNumber == levelnum(0, 6))
dobonus(0);
#endif
show_shareware = REALGAMETICSPERSEC*30;
ud.nextLevel = map;
ud.player_skill = skillNum;
ud.secretlevel = 0;
ud.from_bonus = 0;
ud.last_level = -1;
int const UserMap = false;// Menu_HaveUserMap();
// we don't want the intro to play after the multiplayer setup screen.
if (!isRR() && (!g_netServer && ud.multimode < 2) && UserMap == 0 && map->levelNumber == levelnum(3, 0))
{
e4intro([](bool) {});
}
pPlayer->zoom = 768;
pPlayer->gm = 0;
M_ClearMenus();
ResetGameVars();
//AddLog("Newgame");
if (m_coop != 1)
{
for (int weaponNum = 0; weaponNum < 12/*MAX_WEAPONS*/; weaponNum++)
{
auto const worksLike = isWW2GI() ? PWEAPON(0, weaponNum, WorksLike) : weaponNum;
if (worksLike == PISTOL_WEAPON)
{
pPlayer->curr_weapon = weaponNum;
pPlayer->gotweapon.Set(weaponNum);
pPlayer->ammo_amount[weaponNum] = min<int16_t>(max_ammo_amount[weaponNum], 48);
}
else if (worksLike == KNEE_WEAPON || (!isRR() && worksLike == HANDREMOTE_WEAPON) || (isRRRA() && worksLike == SLINGBLADE_WEAPON))
{
pPlayer->gotweapon.Set(weaponNum);
if (isRRRA())
pPlayer->ammo_amount[KNEE_WEAPON] = 1;
}
}
pPlayer->last_weapon = -1;
}
display_mirror = 0;
}
void resetpspritevars(int gameMode);
void clearfrags(void)