diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index b770e8027..d5f257ccb 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -499,12 +499,20 @@ enum EVENT_MAXEVENT = EVENT_NUMEVENTS - 1 }; -enum +enum miscConstants { MAXSLEEPDIST = 16384, SLEEPTIME = 1536, ZOFFSET6 = (4 << 8), - FOURSLEIGHT = (1 << 8) + FOURSLEIGHT = (1 << 8), + + MOVEFIFOSIZ =256, + HORIZ_MIN =-99, + HORIZ_MAX =299, + AUTO_AIM_ANGLE =48, + PHEIGHT_DUKE =(38<<8), + PHEIGHT_RR =(40<<8) + }; enum diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 8b70ef98f..64571e680 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -252,6 +252,7 @@ void initactorflags_r() TILE_HURTRAIL = HURTRAIL; TILE_FLOORPLASMA = FLOORPLASMA; + PHEIGHT = PHEIGHT_RR; } END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 0c857e63d..aadb6c37e 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -28,25 +28,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "net.h" #include "tarray.h" #include "constants.h" +#include "types.h" BEGIN_DUKE_NS extern int32_t playerswhenstarted; -#define MOVEFIFOSIZ 256 - -#define HORIZ_MIN -99 -#define HORIZ_MAX 299 -#define AUTO_AIM_ANGLE 48 -#define PHEIGHT_DUKE (38<<8) -#define PHEIGHT_RR (40<<8); extern int32_t PHEIGHT; -#define WEAPON_POS_LOWER -9 -#define WEAPON_POS_RAISE 10 -#define WEAPON_POS_START 6 - -#define MAX_WEAPON_RECS 256 enum gamemode_t { MODE_MENU = 0x00000001, @@ -55,19 +44,9 @@ enum gamemode_t { MODE_EOL = 0x00000008, MODE_TYPE = 0x00000010, MODE_RESTART = 0x00000020, - MODE_SENDTOWHOM = 0x00000040, }; -typedef struct { - ESyncBits bits; - int16_t fvel, svel; - fix16_t q16avel, q16horz; -} input_t; -#pragma pack(push,1) - - -// KEEPINSYNC lunatic/_defs_game.lua typedef struct { struct player_struct *ps; @@ -81,13 +60,11 @@ typedef struct // NOTE: wchoice[HANDREMOTE_WEAPON .. MAX_WEAPONS-1] unused uint8_t frags[MAXPLAYERS]; - char playerreadyflag, playerquitflag, connected; char user_name[32]; char syncval[SYNCFIFOSIZ][MAXSYNCBYTES]; double lastInputTicks; } playerdata_t; -#pragma pack(pop) # define PWEAPON(Player, Weapon, Wmember) (aplWeapon ## Wmember [Weapon][Player]) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index bb6b00ec5..3c5c57dab 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -3109,8 +3109,7 @@ HORIZONLY: if (p->horizoff > -5 && p->horizoff < 5) p->horizoff = 0; } - if (p->horiz > 299) p->horiz = 299; - else if (p->horiz < -99) p->horiz = -99; + horiz = clamp(horiz, HORIZ_MIN, HORIZ_MAX); #endif //Shooting code/changes diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 9d8ca50a9..39139357a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -4208,8 +4208,7 @@ HORIZONLY: if (p->horizoff > -5 && p->horizoff < 5) p->horizoff = 0; } - if (p->horiz > 299) p->horiz = 299; - else if (p->horiz < -99) p->horiz = -99; + horiz = clamp(horiz, HORIZ_MIN, HORIZ_MAX); #endif //Shooting code/changes diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index b4ff777a5..523b981e1 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -514,8 +514,7 @@ FAKEHORIZONLY: myhoriz -= (myhardlanding<<4); } - if (myhoriz > 299) myhoriz = 299; - else if (myhoriz < -99) myhoriz = -99; + myhoriz = clamp(myhoriz, HORIZ_MIN, HORIZ_MAX); if(p->knee_incs > 0) { diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 1473fe911..b72da1db5 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -681,7 +681,6 @@ void enterlevel(char g) displayrooms(myconnectindex,65536); displayrest(screenpeek); - clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); ps[myconnectindex].over_shoulder_on = 0; clearfrags(); diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index e2099f985..8a1f11a73 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -989,7 +989,6 @@ void loadlevel(const char *filename) displayrest(screenpeek); nextpage(); - clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); if (waitabort == 1) gameexit(" "); ps[myconnectindex].over_shoulder_on = 0; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index aebfee29a..96a8b4a5d 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -608,8 +608,7 @@ void displayrooms(int snum, int smoothratio) if (cposz > fz - (4 << 8)) cposz = fz - (4 << 8); } - if (choriz > 299) choriz = 299; - else if (choriz < -99) choriz = -99; + choriz = clamp(choriz, HORIZ_MIN, HORIZ_MAX); if (isRR() && sector[sect].lotag == 848) { diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 491c3b7d4..4232f5426 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -34,6 +34,13 @@ struct ActorInfo int aimoffset; }; +struct input_t // original name was input which is too generic for a type name. +{ + fixed_t q16avel, q16horz; // These were expanded to 16.16 fixed point. + short fvel, svel; + ESyncBits bits; +}; + struct player_orig { int ox, oy, oz; diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index cd3e02e8c..0227222be 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -354,8 +354,6 @@ inline int G_CheckPlayerColor(int color) static void G_Startup(void) { - int32_t i; - timerInit(TICRATE); timerSetCallback(gameTimerHandler); @@ -398,11 +396,6 @@ static void G_Startup(void) strncpy(boardfilename, startupMap, BMAX_PATH); } - for (i=0; i 1) Printf("Multiplayer initialized.\n"); @@ -677,8 +670,6 @@ int GameInterface::app_main() G_Startup(); // a bunch of stuff including compiling cons - g_player[0].playerquitflag = 1; - g_player[myconnectindex].ps->palette = BASEPAL; for (int i=1, j=numplayers; j