- cleanup on pausing code.

This commit is contained in:
Christoph Oelckers 2020-07-15 18:10:31 +02:00
parent 381e15a9b2
commit a0cd407632
27 changed files with 145 additions and 163 deletions

View file

@ -195,4 +195,5 @@ enum
}; };
void updatePauseStatus(); void updatePauseStatus();
void updatePauseStatus(bool state, bool multiplayer);
extern int paused; extern int paused;

View file

@ -462,13 +462,7 @@ CVAR(String, usermapfolder, "", CVAR_ARCHIVE);
CUSTOM_CVAR(Int, playercolor, 0, CVAR_ARCHIVE|CVAR_USERINFO) CUSTOM_CVAR(Int, playercolor, 0, CVAR_ARCHIVE|CVAR_USERINFO)
{ {
if (self < 0 || self > 10) self = 0; if (self < 0 || self > 10) self = 0;
else ;// gi->UpdatePlayerColor(); // this part is game specific else ;// gi->PlayerColorChanged(); // this part is game specific
}
CUSTOM_CVAR(Int, playerteam, 0, CVAR_USERINFO) // this one is transient and won't be saved.
{
if (self < 0 || self > 3) self = 0;
else ;// gi->UpdatePlayerTeam(); // this part is game specific
} }
// Will only become useful if the obituary system gets overhauled and for localization // Will only become useful if the obituary system gets overhauled and for localization

View file

@ -110,7 +110,6 @@ EXTERN_CVAR(Int, m_marker)
EXTERN_CVAR(Int, m_ffire) EXTERN_CVAR(Int, m_ffire)
EXTERN_CVAR(Int, m_noexits) EXTERN_CVAR(Int, m_noexits)
EXTERN_CVAR(Int, playercolor) EXTERN_CVAR(Int, playercolor)
EXTERN_CVAR(Int, playerteam)
extern bool gNoAutoLoad; extern bool gNoAutoLoad;
extern int hud_statusbarrange; // will be set by the game's configuration setup. extern int hud_statusbarrange; // will be set by the game's configuration setup.

View file

@ -203,3 +203,9 @@ void CONTROL_GetInput(ControlInfo* info)
info->dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f; info->dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f;
} }
} }
CCMD(pause)
{
inputState.SetPause();
}

View file

@ -36,6 +36,11 @@ class InputState
KEYFIFOSIZ = 64, KEYFIFOSIZ = 64,
}; };
enum EAction
{
Action_Pause = 1,
};
uint8_t KeyStatus[NUM_KEYS]; uint8_t KeyStatus[NUM_KEYS];
kb_scancode g_keyFIFO[KEYFIFOSIZ]; kb_scancode g_keyFIFO[KEYFIFOSIZ];
@ -47,6 +52,8 @@ class InputState
vec2f_t g_mousePos; vec2f_t g_mousePos;
int actions;
void keySetState(int32_t key, int32_t state); void keySetState(int32_t key, int32_t state);
public: public:
@ -166,6 +173,7 @@ public:
keyFlushChars(); keyFlushChars();
keyFlushScans(); keyFlushScans();
buttonMap.ResetButtonStates(); // this is important. If all input is cleared, the buttons must be cleared as well. buttonMap.ResetButtonStates(); // this is important. If all input is cleared, the buttons must be cleared as well.
actions = 0;
} }
bool CheckAllInput() bool CheckAllInput()
@ -178,6 +186,10 @@ public:
return res; return res;
} }
void SetPause() { actions |= Action_Pause; }
void ClearPause() { actions &= ~Action_Pause; }
bool CheckPause() { bool b = !!(actions & Action_Pause); ClearPause(); return b; }
}; };
extern InputState inputState; extern InputState inputState;

View file

@ -2273,11 +2273,7 @@ GAMELOOP:
// loc_11FBC: // loc_11FBC:
while (paused) while (paused)
{ {
inputState.ClearAllInput(); updatePauseStatus();
if (WaitAnyKey(-1) != sc_Pause)
{
paused = kFalse;
}
} }
} }

View file

@ -711,7 +711,7 @@ public:
mysnprintf(tempbuf, 32, "%ld", i + 1); mysnprintf(tempbuf, 32, "%ld", i + 1);
MiniText(30, 90 + t, tempbuf, 0); MiniText(30, 90 + t, tempbuf, 0);
MiniText(38, 90 + t, g_player[i].user_name, 0, -1, ps[i].palookup); MiniText(38, 90 + t, ud.user_name[i], 0, -1, ps[i].palookup);
for (int y = 0; y < playerswhenstarted; y++) for (int y = 0; y < playerswhenstarted; y++)
{ {

View file

@ -294,7 +294,7 @@ public:
mysnprintf(tempbuf, 32, "%ld", i + 1); mysnprintf(tempbuf, 32, "%ld", i + 1);
MiniText(30, 90 + t, tempbuf, 0); MiniText(30, 90 + t, tempbuf, 0);
MiniText(38, 90 + t, g_player[i].user_name, 0, -1, ps[i].palookup); MiniText(38, 90 + t, ud.user_name[i], 0, -1, ps[i].palookup);
for (int y = 0; y < playerswhenstarted; y++) for (int y = 0; y < playerswhenstarted; y++)
{ {

View file

@ -58,7 +58,7 @@ static void dowarp(MapRecord *map)
newgame(map, ud.m_player_skill); newgame(map, ud.m_player_skill);
ps[myconnectindex].gm = MODE_RESTART; ps[myconnectindex].gm = MODE_RESTART;
} }
else G_NewGame_EnterLevel(map, ud.m_player_skill); else startnewgame(map, ud.m_player_skill);
} }
static int ccmd_levelwarp(CCmdFuncPtr parm) static int ccmd_levelwarp(CCmdFuncPtr parm)

View file

@ -318,7 +318,7 @@ void GameInterface::StartGame(FNewGameStartup& gs)
auto map = FindMapByLevelNum(levelnum(gs.Episode, gs.Level)); auto map = FindMapByLevelNum(levelnum(gs.Episode, gs.Level));
if (map) if (map)
{ {
G_NewGame_EnterLevel(map, ud.m_player_skill); startnewgame(map, ud.m_player_skill);
} }
} }

View file

@ -185,6 +185,7 @@ void initwaterdrip(int j, int i);
int initreactor(int j, int i, bool isrecon); int initreactor(int j, int i, bool isrecon);
void spawneffector(int i); void spawneffector(int i);
void gameexitfrommenu(); void gameexitfrommenu();
int startrts(int lumpNum, int localPlayer);
void pickrandomspot(int pn); void pickrandomspot(int pn);
void resetinventory(int pn); void resetinventory(int pn);
@ -225,5 +226,8 @@ void clearfrags(void);
int exitlevel(); int exitlevel();
int enterlevel(MapRecord* mi, int gm); int enterlevel(MapRecord* mi, int gm);
void newgame(MapRecord* mi, int sk); void newgame(MapRecord* mi, int sk);
void startnewgame(MapRecord* map, int skill);
void setlocalplayerinput(player_struct *pp);
void PlayerColorChanged(void);
END_DUKE_NS END_DUKE_NS

View file

@ -69,15 +69,6 @@ struct TileInfo
extern TileInfo tileinfo[MAXTILES]; extern TileInfo tileinfo[MAXTILES];
extern int startrts(int lumpNum, int localPlayer);
static inline void G_NewGame_EnterLevel(MapRecord *map, int skill)
{
newgame(map, skill);
if (enterlevel(map, MODE_GAME))
G_BackToMenu();
}
extern void setupbackdrop(); extern void setupbackdrop();

View file

@ -423,7 +423,7 @@ void displayrest(int smoothratio)
if (ud.scrollmode == 0) if (ud.scrollmode == 0)
{ {
if (pp->newowner == -1 && !ud.pause_on) if (pp->newowner == -1 && !paused)
{ {
if (screenpeek == myconnectindex && numplayers > 1) if (screenpeek == myconnectindex && numplayers > 1)
{ {
@ -447,7 +447,7 @@ void displayrest(int smoothratio)
} }
else else
{ {
if (!ud.pause_on) if (!paused)
{ {
ud.fola += ud.folavel >> 3; ud.fola += ud.folavel >> 3;
ud.folx += (ud.folfvel * sintable[(512 + 2048 - ud.fola) & 2047]) >> 14; ud.folx += (ud.folfvel * sintable[(512 + 2048 - ud.fola) & 2047]) >> 14;
@ -490,7 +490,7 @@ void displayrest(int smoothratio)
} }
} }
if (ud.pause_on == 1 && (ps[myconnectindex].gm & MODE_MENU) == 0) if (paused == 1 && (ps[myconnectindex].gm & MODE_MENU) == 0)
fi.PrintPaused(); fi.PrintPaused();
} }

View file

@ -239,7 +239,7 @@ int domovethings()
if (numplayers < 2 && !isRR()) if (numplayers < 2 && !isRR())
S_PlaySound(GENERIC_AMBIENCE17, CHAN_AUTO, CHANF_UI); S_PlaySound(GENERIC_AMBIENCE17, CHAN_AUTO, CHANF_UI);
Printf(PRINT_NOTIFY, "%s is history!", g_player[i].user_name); Printf(PRINT_NOTIFY, "%s is history!", ud.user_name[i]);
quickkill(&ps[i]); quickkill(&ps[i]);
deletesprite(ps[i].i); deletesprite(ps[i].i);
@ -249,7 +249,7 @@ int domovethings()
//if(ud.recstat == 1) record(); //if(ud.recstat == 1) record();
if (ud.pause_on == 0) if (paused == 0)
{ {
global_random = krand(); global_random = krand();
movedummyplayers();//ST 13 movedummyplayers();//ST 13
@ -257,7 +257,7 @@ int domovethings()
for (i = connecthead; i >= 0; i = connectpoint2[i]) for (i = connecthead; i >= 0; i = connectpoint2[i])
{ {
if (ud.pause_on == 0) if (paused == 0)
{ {
auto p = &ps[i]; auto p = &ps[i];
if (p->pals.a > 0) if (p->pals.a > 0)
@ -268,7 +268,7 @@ int domovethings()
} }
} }
if (ud.pause_on == 0) if (paused == 0)
{ {
if (levelTextTime > 0) if (levelTextTime > 0)
levelTextTime--; levelTextTime--;

View file

@ -160,7 +160,7 @@ inline void SetPlayerPal(player_struct* p, PalEntry pe)
inline int calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) inline int calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
{ {
if (!((ud.multimode < 2 && ((ps[myconnectindex].gm & MODE_MENU) == 0)) || if (!((ud.multimode < 2 && ((ps[myconnectindex].gm & MODE_MENU) == 0)) ||
ud.multimode > 1 || ud.recstat == 2) || ud.pause_on) ud.multimode > 1 || ud.recstat == 2) || paused)
{ {
return 65536; return 65536;
} }

View file

@ -105,16 +105,8 @@ void hud_input(int snum)
{ {
p->interface_toggle_flag = 1; p->interface_toggle_flag = 1;
if (PlayerInput(snum, SKB_PAUSE))
{
ud.pause_on = !ud.pause_on;
if (ud.pause_on == 1 && PlayerInput(snum, SKB_RUN)) ud.pause_on = 2; // Mode 2 is silent, i.e. prints no notification.
Mus_SetPaused(ud.pause_on);
S_PauseSounds(ud.pause_on);
}
// Don't go on if paused or dead. // Don't go on if paused or dead.
if (ud.pause_on) return; if (paused) return;
if (sprite[p->i].extra <= 0) return; if (sprite[p->i].extra <= 0) return;
// Activate an inventory item. This just forwards to the other inventory bits. If the inventory selector was taken out of the playsim this could be removed. // Activate an inventory item. This just forwards to the other inventory bits. If the inventory selector was taken out of the playsim this could be removed.

View file

@ -39,6 +39,50 @@ source as it is released.
BEGIN_DUKE_NS BEGIN_DUKE_NS
//---------------------------------------------------------------------------
//
// callback for playercolor CVAR
//
//---------------------------------------------------------------------------
inline int playercolor2lookup(int color)
{
static int8_t player_pals[] = { 0, 9, 10, 11, 12, 13, 14, 15, 16, 21, 23, };
if (color >= 0 && color < 10) return player_pals[color];
return 0;
}
void PlayerColorChanged(void)
{
if (ud.recstat != 0)
return;
if (ud.multimode > 1)
{
//Net_SendClientInfo();
}
else
{
ps[myconnectindex].palookup = ud.user_pals[myconnectindex] = playercolor2lookup(playercolor);
}
if (sprite[ps[myconnectindex].i].picnum == TILE_APLAYER && sprite[ps[myconnectindex].i].pal != 1)
sprite[ps[myconnectindex].i].pal = ud.user_pals[myconnectindex];
}
//---------------------------------------------------------------------------
//
// Sync local player with CVARs.
//
//---------------------------------------------------------------------------
void setlocalplayerinput(player_struct* pp)
{
pp->aim_mode = in_mousemode;
pp->auto_aim = cl_autoaim;
pp->weaponswitch = cl_weaponswitch;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// why is this such a mess? // why is this such a mess?
@ -502,8 +546,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
ps[p->frag_ps].frag++; ps[p->frag_ps].frag++;
frags[p->frag_ps][snum]++; frags[p->frag_ps][snum]++;
auto pname = &g_player[p->frag_ps].user_name[0]; // TRANSITIONAL auto pname = &ud.user_name[p->frag_ps][0];
//&ud.user_name[p->frag_ps][0]);
if (snum == screenpeek) if (snum == screenpeek)
{ {
quoteMgr.InitializeQuote(QUOTE_RESERVED, "Killed by %s", pname); quoteMgr.InitializeQuote(QUOTE_RESERVED, "Killed by %s", pname);

View file

@ -48,14 +48,8 @@ enum gamemode_t {
typedef struct typedef struct
{ {
bool horizRecenter;
float horizAngleAdjust; float horizAngleAdjust;
fix16_t horizSkew; fix16_t horizSkew;
int32_t pcolor, pteam;
// NOTE: wchoice[HANDREMOTE_WEAPON .. MAX_WEAPONS-1] unused
char user_name[32];
double lastInputTicks; double lastInputTicks;
} playerdata_t; } playerdata_t;

View file

@ -415,7 +415,7 @@ void resetprestat(int snum,int g)
animatecnt = 0; animatecnt = 0;
parallaxtype = 0; parallaxtype = 0;
randomseed = 17L; randomseed = 17L;
ud.pause_on = 0; paused = 0;
ud.camerasprite =-1; ud.camerasprite =-1;
ud.eog = 0; ud.eog = 0;
tempwallptr = 0; tempwallptr = 0;
@ -623,14 +623,14 @@ void resetpspritevars(int g)
if (s->pal == 0) if (s->pal == 0)
{ {
s->pal = ps[j].palookup = which_palookup; s->pal = ps[j].palookup = which_palookup;
//ud.user_pals[j] = which_palookup; ud.user_pals[j] = which_palookup;
which_palookup++; which_palookup++;
if (which_palookup == 17) which_palookup = 9; if (which_palookup == 17) which_palookup = 9;
} }
else /*ud.user_pals[j] =*/ ps[j].palookup = s->pal; else ud.user_pals[j] = ps[j].palookup = s->pal;
} }
else else
s->pal = ps[j].palookup = g_player[j].pcolor;// ud.user_pals[j]; s->pal = ps[j].palookup = ud.user_pals[j];
ps[j].i = i; ps[j].i = i;
ps[j].frag_ps = j; ps[j].frag_ps = j;
@ -1009,6 +1009,24 @@ int enterlevel(MapRecord *mi, int gamemode)
return 0; return 0;
} }
//---------------------------------------------------------------------------
//
// Start a new game from the menu
//
//---------------------------------------------------------------------------
void startnewgame(MapRecord* map, int skill)
{
newgame(map, skill);
if (enterlevel(map, MODE_GAME))
{
ps[myconnectindex].gm = 0;
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// Ideally this will become the only place where map progression gets set up. // Ideally this will become the only place where map progression gets set up.

View file

@ -295,7 +295,7 @@ void setdrugmode(player_struct *p, int oyrepeat)
{ {
if (!paused) if (!paused)
{ {
if (p->DrugMode > 0 && !(p->gm & MODE_TYPE) && !ud.pause_on) if (p->DrugMode > 0 && !(p->gm & MODE_TYPE) && !paused)
{ {
int var_8c; int var_8c;
if (p->drug_stat[0] == 0) if (p->drug_stat[0] == 0)
@ -491,7 +491,7 @@ void displayrooms(int snum, int smoothratio)
videoSetCorrectedAspect(); videoSetCorrectedAspect();
smoothratio = min(max(smoothratio, 0), 65536); smoothratio = min(max(smoothratio, 0), 65536);
if (ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536; if (paused || ps[snum].on_crane > -1) smoothratio = 65536;
sect = p->cursectnum; sect = p->cursectnum;
if (sect < 0 || sect >= MAXSECTORS) return; if (sect < 0 || sect >= MAXSECTORS) return;

View file

@ -47,8 +47,9 @@ struct user_defs
unsigned char show_help, scrollmode, clipping; unsigned char show_help, scrollmode, clipping;
char user_name[MAXPLAYERS][32]; char user_name[MAXPLAYERS][32];
unsigned char overhead_on, last_overhead, showweapons; unsigned char overhead_on, last_overhead, showweapons;
unsigned char user_pals[MAXPLAYERS];
short pause_on, from_bonus; short from_bonus;
short camerasprite, last_camsprite; short camerasprite, last_camsprite;
short last_level, secretlevel; short last_level, secretlevel;

View file

@ -58,6 +58,7 @@ int32_t moveloop(void);
int menuloop(void); int menuloop(void);
void advancequeue(int myconnectindex); void advancequeue(int myconnectindex);
input_t& nextinput(int myconnectindex); input_t& nextinput(int myconnectindex);
void GetInput();
int16_t max_ammo_amount[MAX_WEAPONS]; int16_t max_ammo_amount[MAX_WEAPONS];
int32_t spriteqamount = 64; int32_t spriteqamount = 64;
@ -287,14 +288,6 @@ static int parsedefinitions_game(scriptfile *, int);
=================== ===================
*/ */
inline int G_CheckPlayerColor(int color)
{
static int32_t player_pals[] = { 0, 9, 10, 11, 12, 13, 14, 15, 16, 21, 23, };
if (color >= 0 && color < 10) return player_pals[color];
return 0;
}
static void G_Startup(void) static void G_Startup(void)
{ {
timerInit(TICRATE); timerInit(TICRATE);
@ -346,46 +339,6 @@ static void G_Startup(void)
screenpeek = myconnectindex; screenpeek = myconnectindex;
} }
static void P_SetupMiscInputSettings(void)
{
struct player_struct *pp = &ps[myconnectindex];
pp->aim_mode = in_mousemode;
pp->auto_aim = cl_autoaim;
pp->weaponswitch = cl_weaponswitch;
}
void G_UpdatePlayerFromMenu(void)
{
if (ud.recstat != 0)
return;
if (numplayers > 1)
{
//Net_SendClientInfo();
if (sprite[ps[myconnectindex].i].picnum == TILE_APLAYER && sprite[ps[myconnectindex].i].pal != 1)
sprite[ps[myconnectindex].i].pal = g_player[myconnectindex].pcolor;
}
else
{
P_SetupMiscInputSettings();
ps[myconnectindex].palookup = g_player[myconnectindex].pcolor = G_CheckPlayerColor(playercolor);
g_player[myconnectindex].pteam = playerteam;
if (sprite[ps[myconnectindex].i].picnum == TILE_APLAYER && sprite[ps[myconnectindex].i].pal != 1)
sprite[ps[myconnectindex].i].pal = g_player[myconnectindex].pcolor;
}
}
void G_BackToMenu(void)
{
ps[myconnectindex].gm = 0;
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
inputState.keyFlushChars();
}
void app_loop(); void app_loop();
// TODO: reorder (net)weaponhit to eliminate slop and update assertion // TODO: reorder (net)weaponhit to eliminate slop and update assertion
@ -480,8 +433,7 @@ int GameInterface::app_main()
ud.ShowOpponentWeapons = 0; ud.ShowOpponentWeapons = 0;
ud.camerasprite = -1; ud.camerasprite = -1;
ud.camera_time = 0;//4; ud.camera_time = 0;//4;
playerteam = 0;
S_InitSound(); S_InitSound();
@ -513,8 +465,7 @@ int GameInterface::app_main()
for (int i=1, j=numplayers; j<ud.multimode; j++) for (int i=1, j=numplayers; j<ud.multimode; j++)
{ {
Bsprintf(g_player[j].user_name,"%s %d", GStrings("PLAYER"),j+1); Bsprintf(ud.user_name[j],"%s %d", GStrings("PLAYER"),j+1);
g_player[j].pteam = i;
ps[j].weaponswitch = 3; ps[j].weaponswitch = 3;
ps[j].auto_aim = 0; ps[j].auto_aim = 0;
i = 1-i; i = 1-i;
@ -606,13 +557,9 @@ MAIN_LOOP_RESTART:
} }
ud.showweapons = ud.ShowOpponentWeapons; ud.showweapons = ud.ShowOpponentWeapons;
P_SetupMiscInputSettings(); setlocalplayerinput(&ps[myconnectindex]);
g_player[myconnectindex].pteam = playerteam; PlayerColorChanged();
inputState.ClearAllInput();
if (playercolor) ps[myconnectindex].palookup = g_player[myconnectindex].pcolor = G_CheckPlayerColor(playercolor);
else ps[myconnectindex].palookup = g_player[myconnectindex].pcolor;
inputState.ClearKeyStatus(sc_Pause); // JBF: I hate the pause key
do //main loop do //main loop
{ {
@ -637,13 +584,7 @@ MAIN_LOOP_RESTART:
{ {
ototalclock += TICSPERFRAME; ototalclock += TICSPERFRAME;
if (isRRRA() && ps[myconnectindex].OnMotorcycle) GetInput();
P_GetInputMotorcycle(myconnectindex);
else if (isRRRA() && ps[myconnectindex].OnBoat)
P_GetInputBoat(myconnectindex);
else
P_GetInput(myconnectindex);
// this is where we fill the input_t struct that is actually processed by P_ProcessInput() // this is where we fill the input_t struct that is actually processed by P_ProcessInput()
auto const pPlayer = &ps[myconnectindex]; auto const pPlayer = &ps[myconnectindex];
auto const q16ang = fix16_to_int(pPlayer->q16ang); auto const q16ang = fix16_to_int(pPlayer->q16ang);
@ -682,12 +623,7 @@ MAIN_LOOP_RESTART:
if (G_FPSLimit()) if (G_FPSLimit())
{ {
if (isRRRA() && ps[myconnectindex].OnMotorcycle) GetInput();
P_GetInputMotorcycle(myconnectindex);
else if (isRRRA() && ps[myconnectindex].OnBoat)
P_GetInputBoat(myconnectindex);
else
P_GetInput(myconnectindex);
int const smoothRatio = calc_smoothratio(totalclock, ototalclock); int const smoothRatio = calc_smoothratio(totalclock, ototalclock);

View file

@ -98,7 +98,7 @@ void P_GetInput(int const playerNum)
return; return;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) if (paused)
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -114,9 +114,7 @@ void P_GetInput(int const playerNum)
if (numplayers == 1) if (numplayers == 1)
{ {
pPlayer->aim_mode = in_mousemode; setlocalplayerinput(pPlayer);
pPlayer->auto_aim = cl_autoaim;
pPlayer->weaponswitch = cl_weaponswitch;
} }
@ -327,7 +325,7 @@ void P_GetInput(int const playerNum)
localInput.bits |= (mouseaim << SK_AIMMODE); localInput.bits |= (mouseaim << SK_AIMMODE);
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
localInput.bits |= !!inputState.GetKeyStatus(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.CheckPause() << SK_PAUSE;
//localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE; fixme.This needs to be done differently //localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE; fixme.This needs to be done differently
if (isRR()) if (isRR())
@ -391,14 +389,13 @@ void P_GetInput(int const playerNum)
= atan2f(pPlayer->q16horiz - F16(100), F16(128)) * (512.f / fPI) + scaleAdjustmentToInterval(thisPlayer.horizAngleAdjust); = atan2f(pPlayer->q16horiz - F16(100), F16(128)) * (512.f / fPI) + scaleAdjustmentToInterval(thisPlayer.horizAngleAdjust);
pPlayer->q16horiz = F16(100) + Blrintf(F16(128) * tanf(horizAngle * (fPI / 512.f))); pPlayer->q16horiz = F16(100) + Blrintf(F16(128) * tanf(horizAngle * (fPI / 512.f)));
} }
else if (pPlayer->return_to_center > 0 || thisPlayer.horizRecenter) else if (pPlayer->return_to_center > 0)
{ {
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_from_dbl(200 / 3) - fix16_sdiv(pPlayer->q16horiz, F16(1.5)))))); pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_from_dbl(200 / 3) - fix16_sdiv(pPlayer->q16horiz, F16(1.5))))));
if ((!pPlayer->return_to_center && thisPlayer.horizRecenter) || (pPlayer->q16horiz >= F16(99.9) && pPlayer->q16horiz <= F16(100.1))) if ((pPlayer->q16horiz >= F16(99.9) && pPlayer->q16horiz <= F16(100.1)))
{ {
pPlayer->q16horiz = F16(100); pPlayer->q16horiz = F16(100);
thisPlayer.horizRecenter = false;
} }
if (pPlayer->q16horizoff >= F16(-0.1) && pPlayer->q16horizoff <= F16(0.1)) if (pPlayer->q16horizoff >= F16(-0.1) && pPlayer->q16horizoff <= F16(0.1))
@ -446,7 +443,7 @@ void P_GetInputMotorcycle(int playerNum)
auto const pPlayer = &ps[playerNum]; auto const pPlayer = &ps[playerNum];
ControlInfo info; ControlInfo info;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) if (paused)
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -462,9 +459,7 @@ void P_GetInputMotorcycle(int playerNum)
if (numplayers == 1) if (numplayers == 1)
{ {
pPlayer->aim_mode = in_mousemode; setlocalplayerinput(pPlayer);
pPlayer->auto_aim = cl_autoaim;
pPlayer->weaponswitch = cl_weaponswitch;
} }
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -497,7 +492,7 @@ void P_GetInputMotorcycle(int playerNum)
localInput.bits |= buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT;
localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) || localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) ||
(buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= !!inputState.GetKeyStatus(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.CheckPause() << SK_PAUSE;
localInput.bits |= buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE;
localInput.bits |= buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK;
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
@ -638,7 +633,7 @@ void P_GetInputBoat(int playerNum)
auto const pPlayer = &ps[playerNum]; auto const pPlayer = &ps[playerNum];
ControlInfo info; ControlInfo info;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) if (paused)
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -654,9 +649,7 @@ void P_GetInputBoat(int playerNum)
if (numplayers == 1) if (numplayers == 1)
{ {
pPlayer->aim_mode = in_mousemode; setlocalplayerinput(pPlayer);
pPlayer->auto_aim = cl_autoaim;
pPlayer->weaponswitch = cl_weaponswitch;
} }
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -687,9 +680,9 @@ void P_GetInputBoat(int playerNum)
localInput.bits |= buttonMap.ButtonDown(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= buttonMap.ButtonDown(gamefunc_Steroids) << SK_STEROIDS;
localInput.bits |= buttonMap.ButtonDown(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= buttonMap.ButtonDown(gamefunc_NightVision) << SK_NIGHTVISION;
localInput.bits |= buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT;
localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) || localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) ||
(buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= !!inputState.GetKeyStatus(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.CheckPause() << SK_PAUSE;
localInput.bits |= buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE;
localInput.bits |= buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK;
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
@ -805,4 +798,15 @@ void P_GetInputBoat(int playerNum)
localInput.fvel = clamp((input.fvel += pPlayer->MotoSpeed), -(MAXVELMOTO / 8), MAXVELMOTO); localInput.fvel = clamp((input.fvel += pPlayer->MotoSpeed), -(MAXVELMOTO / 8), MAXVELMOTO);
} }
void GetInput()
{
updatePauseStatus();
if (isRRRA() && ps[myconnectindex].OnMotorcycle)
P_GetInputMotorcycle(myconnectindex);
else if (isRRRA() && ps[myconnectindex].OnBoat)
P_GetInputBoat(myconnectindex);
else
P_GetInput(myconnectindex);
}
END_DUKE_NS END_DUKE_NS

View file

@ -533,9 +533,7 @@ static void sv_restsave();
static void sv_restload(); static void sv_restload();
static void sv_rrrafog(); static void sv_rrrafog();
#define SVARDATALEN \ #define SVARDATALEN 1
((sizeof(g_player[0].user_name)+sizeof(g_player[0].pcolor)+sizeof(g_player[0].pteam) \
+sizeof(struct player_struct))*MAXPLAYERS)
static uint8_t savegame_restdata[SVARDATALEN]; static uint8_t savegame_restdata[SVARDATALEN];
@ -561,7 +559,6 @@ static const dataspec_t svgm_udnetw[] =
{ DS_NOCHK, &ud.coop, sizeof(ud.coop), 1 }, { DS_NOCHK, &ud.coop, sizeof(ud.coop), 1 },
{ DS_NOCHK, &ud.marker, sizeof(ud.marker), 1 }, { DS_NOCHK, &ud.marker, sizeof(ud.marker), 1 },
{ DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 }, { DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 },
{ 0, &ud.pause_on, sizeof(ud.pause_on), 1 },
{ 0, connectpoint2, sizeof(connectpoint2), 1 }, { 0, connectpoint2, sizeof(connectpoint2), 1 },
{ 0, &randomseed, sizeof(randomseed), 1 }, { 0, &randomseed, sizeof(randomseed), 1 },
{ 0, &global_random, sizeof(global_random), 1 }, { 0, &global_random, sizeof(global_random), 1 },
@ -933,9 +930,6 @@ static void sv_restsave()
#define CPDAT(ptr,sz) do { Bmemcpy(mem, ptr, sz), mem+=sz ; } while (0) #define CPDAT(ptr,sz) do { Bmemcpy(mem, ptr, sz), mem+=sz ; } while (0)
for (int i = 0; i < MAXPLAYERS; i++) for (int i = 0; i < MAXPLAYERS; i++)
{ {
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(&ps[i], sizeof(struct player_struct)); CPDAT(&ps[i], sizeof(struct player_struct));
} }
@ -949,9 +943,6 @@ static void sv_restload()
#define CPDAT(ptr,sz) Bmemcpy(ptr, mem, sz), mem+=sz #define CPDAT(ptr,sz) Bmemcpy(ptr, mem, sz), mem+=sz
for (int i = 0; i < MAXPLAYERS; i++) for (int i = 0; i < MAXPLAYERS; i++)
{ {
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(&ps[i], sizeof(struct player_struct)); CPDAT(&ps[i], sizeof(struct player_struct));
} }
#undef CPDAT #undef CPDAT

View file

@ -3160,10 +3160,10 @@ getinput(SW_PACKET *loc, SWBOOL tied)
} }
#endif #endif
} }
else if (inputState.GetKeyStatus(sc_Pause)) else if (inputState.CheckPause())
{ {
SET_LOC_KEY(loc->bits, SK_PAUSE, inputState.GetKeyStatus(sc_Pause)); SET_LOC_KEY(loc->bits, SK_PAUSE, true);
inputState.ClearKeyStatus(sc_Pause); inputState.ClearPause();
} }
SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, buttonMap.ButtonDown(gamefunc_Center_View)); SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, buttonMap.ButtonDown(gamefunc_Center_View));

View file

@ -42,6 +42,7 @@ Home "+Aim_Up"
End "+Aim_Down" End "+Aim_Down"
RCtrl "+Fire" RCtrl "+Fire"
Scroll "+Holster_Weapon" Scroll "+Holster_Weapon"
Pause "pause"
Enter "+Inventory" Enter "+Inventory"
KP-Enter "+Inventory" KP-Enter "+Inventory"

View file

@ -1079,7 +1079,6 @@ OptionMenu "NewPlayerMenu" //protected
Option "$PLYRMNU_PLAYERCOLOR", "playercolor", "PlayerColorsSW" Option "$PLYRMNU_PLAYERCOLOR", "playercolor", "PlayerColorsSW"
} }
Option "$PLYRMNU_PLAYERGENDER", "playergender", "Gender" Option "$PLYRMNU_PLAYERGENDER", "playergender", "Gender"
Option "$PLYRMNU_TEAM", "playerteam", "PlayerTeam"
Submenu "$PLRMNU_TAUNTS", "TauntsMenu" Submenu "$PLRMNU_TAUNTS", "TauntsMenu"
Class "NewPlayerMenu" Class "NewPlayerMenu"
} }