From 4598cf13d727f2d0384a26d684c36cd43cf98164 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jul 2020 21:42:46 +0200 Subject: [PATCH] - reverted the frags array to its original form, moved InitRRRASkies to zz_common.cpp and deleted zz_premap.cpp. --- source/games/duke/CMakeLists.txt | 1 - source/games/duke/src/2d_d.cpp | 4 +- source/games/duke/src/2d_r.cpp | 4 +- source/games/duke/src/names.h | 2 +- source/games/duke/src/player.cpp | 4 +- source/games/duke/src/player.h | 3 +- source/games/duke/src/premap.cpp | 15 +++++ source/games/duke/src/zz_common.cpp | 31 +++++++++++ source/games/duke/src/zz_global.cpp | 3 + source/games/duke/src/zz_premap.cpp | 79 --------------------------- source/games/duke/src/zz_savegame.cpp | 4 +- 11 files changed, 58 insertions(+), 92 deletions(-) delete mode 100644 source/games/duke/src/zz_premap.cpp diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 63b2fb520..7be8c997c 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -48,7 +48,6 @@ set( PCH_SOURCES src/zz_game.cpp src/zz_global.cpp src/zz_player.cpp - src/zz_premap.cpp src/zz_savegame.cpp ) diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index d05bf6bbc..5335bd761 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -715,7 +715,7 @@ public: for (int y = 0; y < playerswhenstarted; y++) { - int frag = g_player[i].frags[y];// frags[i][y]); + int frag = frags[i][y]; if (i == y) { mysnprintf(tempbuf, 32, "%-4ld", ps[y].fraggedself); @@ -750,7 +750,7 @@ public: { if (i == y) yfragtotal += ps[i].fraggedself; - int frag = g_player[i].frags[y];// frags[i][y]); + int frag = frags[i][y]; yfragtotal += frag; } mysnprintf(tempbuf, 32, "%-4ld", yfragtotal); diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index 2e6128e51..c5a989cc0 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -298,7 +298,7 @@ public: for (int y = 0; y < playerswhenstarted; y++) { - int frag = g_player[i].frags[y];// frags[i][y]); + int frag = frags[i][y]; if (i == y) { mysnprintf(tempbuf, 32, "%-4ld", ps[y].fraggedself); @@ -333,7 +333,7 @@ public: { if (i == y) yfragtotal += ps[i].fraggedself; - int frag = g_player[i].frags[y];// frags[i][y]); + int frag = frags[i][y]; yfragtotal += frag; } mysnprintf(tempbuf, 32, "%-4ld", yfragtotal); diff --git a/source/games/duke/src/names.h b/source/games/duke/src/names.h index 42264323d..5f638408a 100644 --- a/source/games/duke/src/names.h +++ b/source/games/duke/src/names.h @@ -21,7 +21,7 @@ extern int TILE_APLAYERTOP; extern int TILE_CAMCORNER; extern int TILE_CAMLIGHT; extern int TILE_STATIC; -extern int TILE_BOTTOMSTATUSBAR;; +extern int TILE_BOTTOMSTATUSBAR; extern int TILE_SPINNINGNUKEICON; extern int TILE_THREEDEE; extern int TILE_INGAMEDUKETHREEDEE; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 0aeee4128..267bf49a2 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -500,9 +500,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) if (p->frag_ps != snum) { ps[p->frag_ps].frag++; - //frags[p->frag_ps][snum]++; - g_player[p->frag_ps].frags[snum]++; // TRANSITIONAL - g_player[snum].frags[snum]++; // deaths + frags[p->frag_ps][snum]++; auto pname = &g_player[p->frag_ps].user_name[0]; // TRANSITIONAL //&ud.user_name[p->frag_ps][0]); diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 0c6d0d22c..798c05cbb 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -57,13 +57,14 @@ typedef struct int32_t pcolor, pteam; // NOTE: wchoice[HANDREMOTE_WEAPON .. MAX_WEAPONS-1] unused - uint8_t frags[MAXPLAYERS]; char user_name[32]; double lastInputTicks; } playerdata_t; +extern uint16_t frags[MAXPLAYERS][MAXPLAYERS]; + # define PWEAPON(Player, Weapon, Wmember) (aplWeapon ## Wmember [Weapon][Player]) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 537af6d4c..36057b868 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -913,6 +913,21 @@ static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode) // //--------------------------------------------------------------------------- +static void clearfrags(void) +{ + for (int i = 0; i < ud.multimode; i++) + { + ps[i].frag = ps[i].fraggedself = 0; + } + memset(frags, 0, sizeof(frags)); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int enterlevel(MapRecord *mi, int gamemode) { // flushpackets(); diff --git a/source/games/duke/src/zz_common.cpp b/source/games/duke/src/zz_common.cpp index a697c7600..c5b54f930 100644 --- a/source/games/duke/src/zz_common.cpp +++ b/source/games/duke/src/zz_common.cpp @@ -12,6 +12,7 @@ #include "rts.h" #include "gamecontrol.h" #include "palettecontainer.h" +#include "names.h" #include "common.h" @@ -98,5 +99,35 @@ void G_SetupGlobalPsky(void) g_pskyidx = skyIdx; } +void G_InitRRRASkies(void) +{ + if (!isRRRA()) + return; + + for (int i = 0; i < MAXSECTORS; i++) + { + if (sector[i].ceilingpicnum != TILE_LA && sector[i].ceilingpicnum != TILE_MOONSKY1 && sector[i].ceilingpicnum != TILE_BIGORBIT1) + { + int const picnum = sector[i].ceilingpicnum; + if (tileWidth(picnum) == 512) + { + psky_t *sky = tileSetupSky(picnum); + sky->horizfrac = 32768; + sky->lognumtiles = 1; + sky->tileofs[0] = 0; + sky->tileofs[1] = 0; + } + else if (tileWidth(picnum) == 1024) + { + psky_t *sky = tileSetupSky(picnum); + sky->horizfrac = 32768; + sky->lognumtiles = 0; + sky->tileofs[0] = 0; + } + } + } +} + + END_DUKE_NS diff --git a/source/games/duke/src/zz_global.cpp b/source/games/duke/src/zz_global.cpp index 3570ac1b2..fc3e33a89 100644 --- a/source/games/duke/src/zz_global.cpp +++ b/source/games/duke/src/zz_global.cpp @@ -53,8 +53,11 @@ int32_t g_spriteGravity = 176; int32_t g_timerTicsPerSecond = TICRATE; int32_t g_tripbombRadius = 3880; +uint16_t frags[MAXPLAYERS][MAXPLAYERS]; + int16_t weaponsandammosprites[15]; TileInfo tileinfo[MAXTILES]; // This is not from EDuke32. + END_DUKE_NS diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp deleted file mode 100644 index 1cf6fe34e..000000000 --- a/source/games/duke/src/zz_premap.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- -#include "ns.h" // Must come before everything else! - -#include "duke3d.h" -#include "savegame.h" -#include "statistics.h" -#include "menu/menu.h" -#include "mapinfo.h" -#include "cmdlib.h" -#include "v_2ddrawer.h" -#include "secrets.h" -#include "sbar.h" -#include "glbackend/glbackend.h" - -BEGIN_DUKE_NS - -void G_InitRRRASkies(void) -{ - if (!isRRRA()) - return; - - for (int i = 0; i < MAXSECTORS; i++) - { - if (sector[i].ceilingpicnum != TILE_LA && sector[i].ceilingpicnum != TILE_MOONSKY1 && sector[i].ceilingpicnum != TILE_BIGORBIT1) - { - int const picnum = sector[i].ceilingpicnum; - if (tileWidth(picnum) == 512) - { - psky_t *sky = tileSetupSky(picnum); - sky->horizfrac = 32768; - sky->lognumtiles = 1; - sky->tileofs[0] = 0; - sky->tileofs[1] = 0; - } - else if (tileWidth(picnum) == 1024) - { - psky_t *sky = tileSetupSky(picnum); - sky->horizfrac = 32768; - sky->lognumtiles = 0; - sky->tileofs[0] = 0; - } - } - } -} - -void resetpspritevars(int gameMode); - -void clearfrags(void) -{ - for (int i = 0; i < ud.multimode; i++) - { - playerdata_t *const pPlayerData = &g_player[i]; - ps[i].frag = ps[i].fraggedself = 0; - memset(pPlayerData->frags, 0, sizeof(pPlayerData->frags)); - } -} - - -END_DUKE_NS diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index a17e873c9..c25e620fc 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -538,7 +538,7 @@ static void sv_rrrafog(); #define SVARDATALEN \ ((sizeof(g_player[0].user_name)+sizeof(g_player[0].pcolor)+sizeof(g_player[0].pteam) \ - +sizeof(g_player[0].frags)+sizeof(struct player_struct))*MAXPLAYERS) + +sizeof(struct player_struct))*MAXPLAYERS) static uint8_t savegame_restdata[SVARDATALEN]; @@ -943,7 +943,6 @@ static void sv_restsave() CPDAT(g_player[i].user_name, 32); CPDAT(&g_player[i].pcolor, sizeof(g_player[0].pcolor)); CPDAT(&g_player[i].pteam, sizeof(g_player[0].pteam)); - CPDAT(&g_player[i].frags[0], sizeof(g_player[0].frags)); CPDAT(g_player[i].ps ? g_player[i].ps : &dummy_ps, sizeof(struct player_struct)); } @@ -961,7 +960,6 @@ static void sv_restload() CPDAT(g_player[i].user_name, 32); CPDAT(&g_player[i].pcolor, sizeof(g_player[0].pcolor)); CPDAT(&g_player[i].pteam, sizeof(g_player[0].pteam)); - CPDAT(&g_player[i].frags[0], sizeof(g_player[0].frags)); CPDAT(g_player[i].ps ? g_player[i].ps : &dummy_ps, sizeof(struct player_struct)); } #undef CPDAT