From 5938a5797070d9c5c1293f7bb90b245307266bc6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:57:33 -0400 Subject: [PATCH 1/3] totalmarelap and totalmarebonuslap player variables --- src/d_player.h | 2 ++ src/lua_playerlib.c | 8 ++++++++ src/p_map.c | 4 +++- src/p_saveg.c | 4 ++++ src/p_setup.c | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index 648867b92..e7e6e4827 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -472,6 +472,8 @@ typedef struct player_s UINT8 lastmare; // previous mare UINT8 lastmarelap; // previous mare lap UINT8 lastmarebonuslap; // previous mare bonus lap + UINT8 totalmarelap; // total mare lap + UINT8 totalmarebonuslap; // total mare bonus lap INT32 maxlink; // maximum link obtained UINT8 texttimer; // nights_texttime should not be local UINT8 textvar; // which line of NiGHTS text to show -- let's not use cheap hacks diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 114aa27b0..67efe7710 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -318,6 +318,10 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->lastmarelap); else if (fastcmp(field,"lastmarebonuslap")) lua_pushinteger(L, plr->lastmarebonuslap); + else if (fastcmp(field,"totalmarelap")) + lua_pushinteger(L, plr->totalmarelap); + else if (fastcmp(field,"totalmarebonuslap")) + lua_pushinteger(L, plr->totalmarebonuslap); else if (fastcmp(field,"maxlink")) lua_pushinteger(L, plr->maxlink); else if (fastcmp(field,"texttimer")) @@ -610,6 +614,10 @@ static int player_set(lua_State *L) plr->lastmarelap = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmarebonuslap")) plr->lastmarebonuslap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarelap")) + plr->totalmarelap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarebonuslap")) + plr->totalmarebonuslap = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"maxlink")) plr->maxlink = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"texttimer")) diff --git a/src/p_map.c b/src/p_map.c index 7d3538573..6e5e03a8d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1114,12 +1114,14 @@ static boolean PIT_CheckThing(mobj_t *thing) )) { pl->marelap++; + pl->totalmarelap++; pl->lapbegunat = leveltime; pl->lapstartedtime = pl->nightstime; - if (pl->bonustime) + if (pl->bonustime) { pl->marebonuslap++; + pl->totalmarebonuslap++; // Respawn rings and items P_ReloadRings(); diff --git a/src/p_saveg.c b/src/p_saveg.c index e18802f57..bcc582cd0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -213,6 +213,8 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].lastmare); WRITEUINT8(save_p, players[i].lastmarelap); WRITEUINT8(save_p, players[i].lastmarebonuslap); + WRITEUINT8(save_p, players[i].totalmarelap); + WRITEUINT8(save_p, players[i].totalmarebonuslap); WRITEINT32(save_p, players[i].maxlink); WRITEUINT8(save_p, players[i].texttimer); WRITEUINT8(save_p, players[i].textvar); @@ -408,6 +410,8 @@ static void P_NetUnArchivePlayers(void) players[i].lastmare = READUINT8(save_p); players[i].lastmarelap = READUINT8(save_p); players[i].lastmarebonuslap = READUINT8(save_p); + players[i].totalmarelap = READUINT8(save_p); + players[i].totalmarebonuslap = READUINT8(save_p); players[i].maxlink = READINT32(save_p); players[i].texttimer = READUINT8(save_p); players[i].textvar = READUINT8(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index 4b10f431c..ee462193d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2382,6 +2382,7 @@ static void P_LevelInitStuff(void) players[i].finishedtime = players[i].finishedspheres =\ players[i].finishedrings = players[i].lastmare =\ players[i].lastmarelap = players[i].lastmarebonuslap =\ + players[i].totalmarelap = players[i].totalmarebonuslap =\ players[i].marebegunat = players[i].textvar =\ players[i].texttimer = players[i].linkcount =\ players[i].linktimer = players[i].flyangle =\ From ec8d26402929b5099e2fd922a707c04d98070cf3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:59:34 -0400 Subject: [PATCH 2/3] totalmarescore player variable for NiGHTS scoring # Conflicts: # src/p_setup.c --- src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_setup.c | 4 ++-- src/p_user.c | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index e7e6e4827..fd41c7621 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -469,6 +469,7 @@ typedef struct player_s INT16 finishedrings; // The rings/stars you had left upon finishing the mare UINT32 marescore; // score for this nights stage UINT32 lastmarescore; // score for the last mare + UINT32 totalmarescore; // score for all mares UINT8 lastmare; // previous mare UINT8 lastmarelap; // previous mare lap UINT8 lastmarebonuslap; // previous mare bonus lap diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 67efe7710..f973061f1 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -312,6 +312,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->marescore); else if (fastcmp(field,"lastmarescore")) lua_pushinteger(L, plr->lastmarescore); + else if (fastcmp(field,"totalmarescore")) + lua_pushinteger(L, plr->totalmarescore); else if (fastcmp(field,"lastmare")) lua_pushinteger(L, plr->lastmare); else if (fastcmp(field,"lastmarelap")) @@ -608,6 +610,8 @@ static int player_set(lua_State *L) plr->marescore = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmarescore")) plr->lastmarescore = (UINT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarescore")) + plr->totalmarescore = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmare")) plr->lastmare = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmarelap")) diff --git a/src/p_saveg.c b/src/p_saveg.c index bcc582cd0..22d43f358 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -210,6 +210,7 @@ static void P_NetArchivePlayers(void) WRITEINT16(save_p, players[i].finishedrings); WRITEUINT32(save_p, players[i].marescore); WRITEUINT32(save_p, players[i].lastmarescore); + WRITEUINT32(save_p, players[i].totalmarescore); WRITEUINT8(save_p, players[i].lastmare); WRITEUINT8(save_p, players[i].lastmarelap); WRITEUINT8(save_p, players[i].lastmarebonuslap); @@ -407,6 +408,7 @@ static void P_NetUnArchivePlayers(void) players[i].finishedrings = READINT16(save_p); players[i].marescore = READUINT32(save_p); players[i].lastmarescore = READUINT32(save_p); + players[i].totalmarescore = READUINT32(save_p); players[i].lastmare = READUINT8(save_p); players[i].lastmarelap = READUINT8(save_p); players[i].lastmarebonuslap = READUINT8(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index ee462193d..368b95dd5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2389,8 +2389,8 @@ static void P_LevelInitStuff(void) players[i].anotherflyangle = players[i].nightstime =\ players[i].mare = players[i].marelap =\ players[i].marebonuslap = players[i].lapbegunat =\ - players[i].lapstartedtime = players[i].realtime =\ - players[i].exiting = 0; + players[i].lapstartedtime = players[i].totalmarescore =\ + players[i].realtime = players[i].exiting = 0; // i guess this could be part of the above but i feel mildly uncomfortable implicitly casting players[i].gotcontinue = false; diff --git a/src/p_user.c b/src/p_user.c index 06f42dcad..9d677b4bc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -733,6 +733,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(players[i].marescore, leveltime - player->marebegunat, players[i].mare + 1); // transfer scores anyway + players[i].totalmarescore += players[i].marescore; players[i].lastmarescore = players[i].marescore; players[i].marescore = 0; @@ -759,6 +760,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(player->marescore, leveltime - player->marebegunat, (UINT8)(oldmare + 1)); // Starting a new mare, transfer scores + player->totalmarescore += players[i].marescore; player->lastmarescore = player->marescore; player->marescore = 0; player->marebegunat = leveltime; From 0c8e2ffd7872df0342f483176a0e9e70d2d18fc4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:26:18 -0400 Subject: [PATCH 3/3] Totalmarescore typo --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 9d677b4bc..8177338da 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -760,7 +760,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(player->marescore, leveltime - player->marebegunat, (UINT8)(oldmare + 1)); // Starting a new mare, transfer scores - player->totalmarescore += players[i].marescore; + player->totalmarescore += player->marescore; player->lastmarescore = player->marescore; player->marescore = 0; player->marebegunat = leveltime;