mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 11:50:49 +00:00
Merge branch 'Packet' into back_to_basics2
# Conflicts: # source/core/gamestruct.h # source/games/duke/src/gameloop.cpp # source/games/duke/src/player_d.cpp
This commit is contained in:
commit
2f05a93547
123 changed files with 6608 additions and 2741 deletions
|
@ -783,6 +783,9 @@ set (PCH_SOURCES
|
|||
core/mathutil.cpp
|
||||
core/rts.cpp
|
||||
core/ct_chat.cpp
|
||||
core/d_net.cpp
|
||||
core/d_protocol.cpp
|
||||
core/mainloop.cpp
|
||||
core/gameconfigfile.cpp
|
||||
core/gamecvars.cpp
|
||||
core/gamecontrol.cpp
|
||||
|
@ -912,6 +915,7 @@ set (PCH_SOURCES
|
|||
common/engine/sc_man.cpp
|
||||
common/engine/palettecontainer.cpp
|
||||
common/engine/stringtable.cpp
|
||||
common/engine/i_net.cpp
|
||||
common/engine/i_interface.cpp
|
||||
common/engine/renderstyle.cpp
|
||||
common/engine/v_colortables.cpp
|
||||
|
|
|
@ -4749,7 +4749,7 @@ void MoveDude(spritetype *pSprite)
|
|||
if (pPlayer) {
|
||||
pPlayer->posture = 0;
|
||||
pPlayer->bubbleTime = 0;
|
||||
if (!pPlayer->cantJump && pPlayer->input.syncFlags.jump) {
|
||||
if (!pPlayer->cantJump && (pPlayer->input.actions & SB_JUMP)) {
|
||||
zvel[nSprite] = -0x6aaaa;
|
||||
pPlayer->cantJump = 1;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
void LocalKeys(void);
|
||||
void InitCheats();
|
||||
|
||||
bool bNoDemo = false;
|
||||
|
@ -72,12 +71,13 @@ char gUserMapFilename[BMAX_PATH];
|
|||
|
||||
short BloodVersion = 0x115;
|
||||
|
||||
bool gameRestart;
|
||||
int gNetPlayers;
|
||||
int gQuitRequest;
|
||||
|
||||
int gChokeCounter = 0;
|
||||
|
||||
bool gQuitGame;
|
||||
int gQuitRequest;
|
||||
|
||||
enum gametokens
|
||||
{
|
||||
|
@ -386,7 +386,6 @@ void StartLevel(MapRecord *level)
|
|||
}
|
||||
}
|
||||
bVanilla = false;
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla;
|
||||
memset(xsprite,0,sizeof(xsprite));
|
||||
memset(sprite,0,kMaxSprites*sizeof(spritetype));
|
||||
//drawLoadingScreen();
|
||||
|
@ -518,20 +517,20 @@ bool gRestartGame = false;
|
|||
|
||||
void ProcessFrame(void)
|
||||
{
|
||||
char buffer[128];
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
gPlayer[i].input.syncFlags.value &= ~flag_buttonmask;
|
||||
gPlayer[i].input.syncFlags.value |= gFifoInput[gNetFifoTail & 255][i].syncFlags.value;
|
||||
if (gFifoInput[gNetFifoTail&255][i].syncFlags.newWeapon)
|
||||
gPlayer[i].newWeapon = gFifoInput[gNetFifoTail&255][i].syncFlags.newWeapon;
|
||||
gPlayer[i].input.fvel = gFifoInput[gNetFifoTail&255][i].fvel;
|
||||
gPlayer[i].input.q16avel = gFifoInput[gNetFifoTail&255][i].q16avel;
|
||||
gPlayer[i].input.svel = gFifoInput[gNetFifoTail&255][i].svel;
|
||||
gPlayer[i].input.q16horz = gFifoInput[gNetFifoTail&255][i].q16horz;
|
||||
auto& inp = gPlayer[i].input;
|
||||
auto oldactions = inp.actions;
|
||||
|
||||
inp = gFifoInput[gNetFifoTail & 255][i];
|
||||
inp.actions |= oldactions & ~(SB_BUTTON_MASK|SB_RUN|SB_WEAPONMASK_BITS); // should be everything non-button and non-weapon
|
||||
|
||||
int newweap = inp.getNewWeapon();
|
||||
if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap;
|
||||
}
|
||||
gNetFifoTail++;
|
||||
|
||||
#if 0
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
if (gPlayer[i].input.syncFlags.quit)
|
||||
|
@ -554,15 +553,14 @@ void ProcessFrame(void)
|
|||
levelRestart();
|
||||
return;
|
||||
}
|
||||
if (gPlayer[i].input.syncFlags.pause)
|
||||
{
|
||||
gPlayer[i].input.syncFlags.pause = 0;
|
||||
if (paused && gGameOptions.nGameType > 0 && numplayers > 1)
|
||||
{
|
||||
sprintf(buffer,"%s paused the game",gProfile[i].name);
|
||||
viewSetMessage(buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// This is single player only.
|
||||
if (gameRestart)
|
||||
{
|
||||
gameRestart = false;
|
||||
levelRestart();
|
||||
return;
|
||||
}
|
||||
viewClearInterpolations();
|
||||
{
|
||||
|
@ -595,7 +593,7 @@ void ProcessFrame(void)
|
|||
ambProcess();
|
||||
viewUpdateDelirium();
|
||||
viewUpdateShake();
|
||||
sfxUpdate3DSounds();
|
||||
gi->UpdateSounds();
|
||||
if (gMe->hand == 1)
|
||||
{
|
||||
const int CHOKERATE = 8;
|
||||
|
@ -672,42 +670,9 @@ void ParseOptions(void)
|
|||
|
||||
void ReadAllRFS();
|
||||
|
||||
static const char* actions[] = {
|
||||
"Move_Forward",
|
||||
"Move_Backward",
|
||||
"Turn_Left",
|
||||
"Turn_Right",
|
||||
"Strafe",
|
||||
"Fire",
|
||||
"Open",
|
||||
"Run",
|
||||
"Alt_Fire", // Duke3D", Blood
|
||||
"Jump",
|
||||
"Crouch",
|
||||
"Look_Up",
|
||||
"Look_Down",
|
||||
"Look_Left",
|
||||
"Look_Right",
|
||||
"Strafe_Left",
|
||||
"Strafe_Right",
|
||||
"Aim_Up",
|
||||
"Aim_Down",
|
||||
"SendMessage",
|
||||
"Shrink_Screen",
|
||||
"Enlarge_Screen",
|
||||
"Show_Opponents_Weapon",
|
||||
"See_Coop_View",
|
||||
"Mouse_Aiming",
|
||||
"Dpad_Select",
|
||||
"Dpad_Aiming",
|
||||
"Third_Person_View",
|
||||
"Toggle_Crouch",
|
||||
};
|
||||
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
InitCheats();
|
||||
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
||||
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
|
||||
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
|
||||
ReadAllRFS();
|
||||
|
@ -746,14 +711,14 @@ void GameInterface::app_init()
|
|||
|
||||
Printf(PRINT_NONOTIFY, "Initializing network users\n");
|
||||
netInitialize(true);
|
||||
videoInit();
|
||||
Printf(PRINT_NONOTIFY, "Initializing sound system\n");
|
||||
sndInit();
|
||||
registerosdcommands();
|
||||
registerinputcommands();
|
||||
|
||||
gChoke.sub_83ff0(518, sub_84230);
|
||||
UpdateDacs(0, true);
|
||||
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla;
|
||||
}
|
||||
|
||||
static void gameInit()
|
||||
|
@ -841,8 +806,10 @@ static void drawBackground()
|
|||
{
|
||||
twod->ClearScreen();
|
||||
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
|
||||
#if 0
|
||||
if (gQuitRequest && !gQuitGame)
|
||||
netBroadcastMyLogoff(gQuitRequest == 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void commonTicker()
|
||||
|
@ -934,7 +901,6 @@ void GameInterface::RunGameFrame()
|
|||
|
||||
case GS_LEVEL:
|
||||
gameTicker();
|
||||
LocalKeys();
|
||||
break;
|
||||
|
||||
case GS_FINALE:
|
||||
|
|
|
@ -30,41 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
|
||||
enum GameFunction_t
|
||||
{
|
||||
gamefunc_Move_Forward,
|
||||
gamefunc_Move_Backward,
|
||||
gamefunc_Turn_Left,
|
||||
gamefunc_Turn_Right,
|
||||
gamefunc_Strafe,
|
||||
gamefunc_Fire,
|
||||
gamefunc_Open,
|
||||
gamefunc_Run,
|
||||
gamefunc_Alt_Fire, // Duke3D, Blood
|
||||
gamefunc_Jump,
|
||||
gamefunc_Crouch,
|
||||
gamefunc_Look_Up,
|
||||
gamefunc_Look_Down,
|
||||
gamefunc_Look_Left,
|
||||
gamefunc_Look_Right,
|
||||
gamefunc_Strafe_Left,
|
||||
gamefunc_Strafe_Right,
|
||||
gamefunc_Aim_Up,
|
||||
gamefunc_Aim_Down,
|
||||
gamefunc_SendMessage,
|
||||
gamefunc_Shrink_Screen,
|
||||
gamefunc_Enlarge_Screen,
|
||||
gamefunc_Show_Opponents_Weapon,
|
||||
gamefunc_See_Coop_View,
|
||||
gamefunc_Mouse_Aiming,
|
||||
gamefunc_Dpad_Select,
|
||||
gamefunc_Dpad_Aiming,
|
||||
gamefunc_Third_Person_View,
|
||||
gamefunc_Toggle_Crouch,
|
||||
NUM_ACTIONS
|
||||
};
|
||||
|
||||
struct INIDESCRIPTION {
|
||||
const char *pzName;
|
||||
const char *pzFilename;
|
||||
|
@ -119,8 +84,8 @@ struct GameInterface : ::GameInterface
|
|||
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
|
||||
void QuitToTitle() override;
|
||||
FString GetCoordString() override;
|
||||
void clearlocalinputstate() override;
|
||||
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
||||
void UpdateSounds() override;
|
||||
|
||||
GameStats getStats() override;
|
||||
};
|
||||
|
|
|
@ -43,8 +43,6 @@ InputPacket gInput, gNetInput;
|
|||
bool bSilentAim = false;
|
||||
|
||||
int iTurnCount = 0;
|
||||
static int WeaponToSend;
|
||||
static SYNCFLAGS BitsToSend;
|
||||
|
||||
void ctrlInit(void)
|
||||
{
|
||||
|
@ -66,44 +64,6 @@ float gViewAngleAdjust;
|
|||
float gViewLookAdjust;
|
||||
int gViewLookRecenter;
|
||||
|
||||
void LocalKeys(void)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Third_Person_View);
|
||||
if (gViewPos > VIEWPOS_0)
|
||||
gViewPos = VIEWPOS_0;
|
||||
else
|
||||
gViewPos = VIEWPOS_1;
|
||||
}
|
||||
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_See_Coop_View);
|
||||
if (gGameOptions.nGameType == 1)
|
||||
{
|
||||
gViewIndex = connectpoint2[gViewIndex];
|
||||
if (gViewIndex == -1)
|
||||
gViewIndex = connecthead;
|
||||
gView = &gPlayer[gViewIndex];
|
||||
}
|
||||
else if (gGameOptions.nGameType == 3)
|
||||
{
|
||||
int oldViewIndex = gViewIndex;
|
||||
do
|
||||
{
|
||||
gViewIndex = connectpoint2[gViewIndex];
|
||||
if (gViewIndex == -1)
|
||||
gViewIndex = connecthead;
|
||||
if (oldViewIndex == gViewIndex || gMe->teamId == gPlayer[gViewIndex].teamId)
|
||||
break;
|
||||
} while (oldViewIndex != gViewIndex);
|
||||
gView = &gPlayer[gViewIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctrlGetInput(void)
|
||||
{
|
||||
int prevPauseState = paused;
|
||||
|
@ -124,19 +84,11 @@ void ctrlGetInput(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (paused != prevPauseState)
|
||||
{
|
||||
gInput.syncFlags.pause = 1;
|
||||
}
|
||||
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
InputPacket input = {};
|
||||
|
||||
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
||||
if (!mouseaim) gInput.syncFlags.lookCenter = 1;
|
||||
|
||||
if (numplayers == 1)
|
||||
{
|
||||
gProfile[myconnectindex].nAutoAim = cl_autoaim;
|
||||
|
@ -145,15 +97,10 @@ void ctrlGetInput(void)
|
|||
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
if (gQuitRequest)
|
||||
gInput.syncFlags.quit = 1;
|
||||
ApplyGlobalInput(gInput, &info);
|
||||
|
||||
gInput.syncFlags.value |= BitsToSend.value;
|
||||
if (WeaponToSend != 0)
|
||||
gInput.syncFlags.newWeapon = WeaponToSend;
|
||||
|
||||
BitsToSend.value = 0;
|
||||
WeaponToSend = 0;
|
||||
bool mouseaim = !!(gInput.actions & SB_AIMMODE);
|
||||
if (!mouseaim) gInput.actions |= SB_CENTERVIEW;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
|
||||
{
|
||||
|
@ -177,47 +124,12 @@ void ctrlGetInput(void)
|
|||
{
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
|
||||
cl_showweapon = (cl_showweapon + 1) & 3;
|
||||
}
|
||||
if (gInput.actions & (SB_LOOK_UP|SB_LOOK_DOWN))
|
||||
gInput.actions |= SB_CENTERVIEW;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Jump))
|
||||
gInput.syncFlags.jump = 1;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch))
|
||||
gInput.syncFlags.crouch = 1;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Fire))
|
||||
gInput.syncFlags.shoot = 1;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Alt_Fire))
|
||||
gInput.syncFlags.shoot2 = 1;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Open))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Open);
|
||||
gInput.syncFlags.action = 1;
|
||||
}
|
||||
|
||||
gInput.syncFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Look_Up);
|
||||
gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Look_Down);
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Up) || buttonMap.ButtonDown(gamefunc_Look_Down))
|
||||
gInput.syncFlags.lookCenter = 1;
|
||||
else
|
||||
{
|
||||
gInput.syncFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Aim_Up);
|
||||
gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down);
|
||||
}
|
||||
|
||||
int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||
int const run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run);
|
||||
int const run = !!(gInput.actions & SB_RUN);
|
||||
int const keyMove = (1 + run) << 10;
|
||||
|
||||
gInput.syncFlags.run |= run;
|
||||
|
||||
if (gInput.fvel < keyMove && gInput.fvel > -keyMove)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
|
@ -276,7 +188,7 @@ void ctrlGetInput(void)
|
|||
if (turnRight)
|
||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));
|
||||
|
||||
if ((run2 || run) && turnHeldTime > 24)
|
||||
if (run && turnHeldTime > 24)
|
||||
input.q16avel <<= 1;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
|
@ -337,52 +249,4 @@ void ctrlGetInput(void)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic
|
||||
// registration to only have the commands active when this game module runs.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static int ccmd_slot(CCmdFuncPtr parm)
|
||||
{
|
||||
if (parm->numparms != 1) return CCMD_SHOWHELP;
|
||||
|
||||
auto slot = atoi(parm->parms[0]);
|
||||
if (slot >= 1 && slot <= 10)
|
||||
{
|
||||
WeaponToSend = slot;
|
||||
return CCMD_OK;
|
||||
}
|
||||
return CCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
void registerinputcommands()
|
||||
{
|
||||
C_RegisterFunction("slot", "slot <weaponslot>: select a weapon from the given slot (1-10)", ccmd_slot);
|
||||
C_RegisterFunction("weapprev", nullptr, [](CCmdFuncPtr)->int { if (gPlayer[myconnectindex].nextWeapon == 0) BitsToSend.prevWeapon = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("weapnext", nullptr, [](CCmdFuncPtr)->int { if (gPlayer[myconnectindex].nextWeapon == 0) BitsToSend.nextWeapon = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend.pause = 1; sendPause = true; return CCMD_OK; });
|
||||
C_RegisterFunction("proximitybombs", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 11; return CCMD_OK; });
|
||||
C_RegisterFunction("remotebombs", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 12; return CCMD_OK; });
|
||||
C_RegisterFunction("jumpboots", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useJumpBoots = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useMedKit = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend.lookCenter = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend.holsterWeapon = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend.prevItem = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend.nextItem = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("crystalball", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useCrystalBall = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("beastvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useBeastVision = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend.spin180 = 1; return CCMD_OK; });
|
||||
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useItem = 1; return CCMD_OK; });
|
||||
}
|
||||
|
||||
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
||||
void GameInterface::clearlocalinputstate()
|
||||
{
|
||||
WeaponToSend = 0;
|
||||
BitsToSend.value = 0;
|
||||
}
|
||||
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -22,10 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
//-------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
#include "packet.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
extern InputPacket gInput, gNetInput;
|
||||
extern bool bSilentAim;
|
||||
|
||||
|
|
|
@ -295,8 +295,7 @@ void GameInterface::QuitToTitle()
|
|||
gQuitGame = true;
|
||||
gRestartGame = true;
|
||||
}
|
||||
else
|
||||
gQuitRequest = 2;
|
||||
//else gQuitRequest = 2;
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -42,7 +42,6 @@ void sub_5571C(char mode);
|
|||
void sub_557C4(int x, int y, int interpolation);
|
||||
void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int viewPlayer);
|
||||
int32_t registerosdcommands(void);
|
||||
void registerinputcommands(void);
|
||||
int qanimateoffs(int a1, int a2);
|
||||
int32_t qgetpalookup(int32_t a1, int32_t a2);
|
||||
void HookReplaceFunctions();
|
||||
|
|
|
@ -1990,7 +1990,7 @@ void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex) {
|
|||
|
||||
xsprite[pSpr->extra].medium = kMediumNormal;
|
||||
if (pPlayer) {
|
||||
pPlayer->posture = (!pPlayer->input.syncFlags.crouch) ? kPostureStand : kPostureCrouch;
|
||||
pPlayer->posture = (!(pPlayer->input.actions & SB_CROUCH)) ? kPostureStand : kPostureCrouch;
|
||||
pPlayer->nWaterPal = 0;
|
||||
}
|
||||
|
||||
|
@ -2087,7 +2087,7 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
|
|||
|
||||
xsprite[pSprite->extra].medium = kMediumNormal;
|
||||
if (pPlayer) {
|
||||
pPlayer->posture = (!pPlayer->input.syncFlags.crouch) ? kPostureStand : kPostureCrouch;
|
||||
pPlayer->posture = (!(pPlayer->input.actions & SB_CROUCH)) ? kPostureStand : kPostureCrouch;
|
||||
pPlayer->nWaterPal = 0;
|
||||
}
|
||||
|
||||
|
@ -2889,10 +2889,10 @@ bool condCheckPlayer(XSPRITE* pXCond, int cmpOp, bool PUSH) {
|
|||
case 2: return (pPlayer->input.fvel < 0); // backward
|
||||
case 3: return (pPlayer->input.svel > 0); // left
|
||||
case 4: return (pPlayer->input.svel < 0); // right
|
||||
case 5: return (pPlayer->input.syncFlags.jump); // jump
|
||||
case 6: return (pPlayer->input.syncFlags.crouch); // crouch
|
||||
case 7: return (pPlayer->input.syncFlags.shoot); // normal fire weapon
|
||||
case 8: return (pPlayer->input.syncFlags.shoot2); // alt fire weapon
|
||||
case 5: return !!(pPlayer->input.actions & SB_JUMP); // jump
|
||||
case 6: return !!(pPlayer->input.actions & SB_CROUCH); // crouch
|
||||
case 7: return !!(pPlayer->input.actions & SB_FIRE); // normal fire weapon
|
||||
case 8: return !!(pPlayer->input.actions & SB_ALTFIRE); // alt fire weapon
|
||||
default:
|
||||
condError(pXCond, "Player conditions:\nSpecify a correct key!");
|
||||
break;
|
||||
|
|
|
@ -201,17 +201,62 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
|
|||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_third_person_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (gViewPos > VIEWPOS_0)
|
||||
gViewPos = VIEWPOS_0;
|
||||
else
|
||||
gViewPos = VIEWPOS_1;
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_coop_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (gGameOptions.nGameType == 1)
|
||||
{
|
||||
gViewIndex = connectpoint2[gViewIndex];
|
||||
if (gViewIndex == -1)
|
||||
gViewIndex = connecthead;
|
||||
gView = &gPlayer[gViewIndex];
|
||||
}
|
||||
else if (gGameOptions.nGameType == 3)
|
||||
{
|
||||
int oldViewIndex = gViewIndex;
|
||||
do
|
||||
{
|
||||
gViewIndex = connectpoint2[gViewIndex];
|
||||
if (gViewIndex == -1)
|
||||
gViewIndex = connecthead;
|
||||
if (oldViewIndex == gViewIndex || gMe->teamId == gPlayer[gViewIndex].teamId)
|
||||
break;
|
||||
} while (oldViewIndex != gViewIndex);
|
||||
gView = &gPlayer[gViewIndex];
|
||||
}
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_show_weapon(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
cl_showweapon = (cl_showweapon + 1) & 3;
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t registerosdcommands(void)
|
||||
{
|
||||
C_RegisterFunction("map","map <mapname>: loads the given map", osdcmd_map);
|
||||
|
||||
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
|
||||
C_RegisterFunction("god","god: toggles god mode", osdcmd_god);
|
||||
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
|
||||
|
||||
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", osdcmd_levelwarp);
|
||||
|
||||
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
|
||||
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
|
||||
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_coop_view);
|
||||
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_show_weapon);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
extern bool gameRestart;
|
||||
|
||||
PROFILE gProfile[kMaxPlayers];
|
||||
|
||||
PLAYER gPlayer[kMaxPlayers];
|
||||
|
@ -545,15 +547,22 @@ void packPrevItem(PLAYER *pPlayer)
|
|||
{
|
||||
if (pPlayer->packItemTime > 0)
|
||||
{
|
||||
for (int nPrev = ClipLow(pPlayer->packItemId-1,0); nPrev >= 0; nPrev--)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int nPrev = pPlayer->packItemId-1; nPrev >= 0; nPrev--)
|
||||
{
|
||||
if (pPlayer->packSlots[nPrev].curAmount)
|
||||
{
|
||||
pPlayer->packItemId = nPrev;
|
||||
break;
|
||||
pPlayer->packItemTime = 600;
|
||||
return;
|
||||
}
|
||||
}
|
||||
pPlayer->packItemId = 4;
|
||||
if (pPlayer->packSlots[4].curAmount) break;
|
||||
}
|
||||
}
|
||||
|
||||
pPlayer->packItemTime = 600;
|
||||
}
|
||||
|
||||
|
@ -561,14 +570,20 @@ void packNextItem(PLAYER *pPlayer)
|
|||
{
|
||||
if (pPlayer->packItemTime > 0)
|
||||
{
|
||||
for (int nNext = ClipHigh(pPlayer->packItemId+1,5); nNext < 5; nNext++)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int nNext = pPlayer->packItemId + 1; nNext < 5; nNext++)
|
||||
{
|
||||
if (pPlayer->packSlots[nNext].curAmount)
|
||||
{
|
||||
pPlayer->packItemId = nNext;
|
||||
break;
|
||||
pPlayer->packItemTime = 600;
|
||||
return;
|
||||
}
|
||||
}
|
||||
pPlayer->packItemId = 0;
|
||||
if (pPlayer->packSlots[0].curAmount) break;
|
||||
}
|
||||
}
|
||||
pPlayer->packItemTime = 600;
|
||||
}
|
||||
|
@ -749,7 +764,7 @@ void playerStart(int nPlayer, int bNewLevel)
|
|||
pPlayer->nextWeapon = 0;
|
||||
xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0;
|
||||
pInput->q16avel = 0;
|
||||
pInput->syncFlags.value = 0;
|
||||
pInput->actions = 0;
|
||||
pInput->fvel = 0;
|
||||
pInput->svel = 0;
|
||||
pInput->q16horz = 0;
|
||||
|
@ -1295,6 +1310,14 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
|
|||
|
||||
void ProcessInput(PLAYER *pPlayer)
|
||||
{
|
||||
enum
|
||||
{
|
||||
Item_MedKit = 0,
|
||||
Item_CrystalBall = 1,
|
||||
Item_BeastVision = 2,
|
||||
Item_JumpBoots = 3
|
||||
};
|
||||
|
||||
spritetype *pSprite = pPlayer->pSprite;
|
||||
XSPRITE *pXSprite = pPlayer->pXSprite;
|
||||
int nSprite = pPlayer->nSprite;
|
||||
|
@ -1308,8 +1331,8 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
gViewLookAdjust = 0.f;
|
||||
}
|
||||
|
||||
pPlayer->isRunning = pInput->syncFlags.run;
|
||||
if ((pInput->syncFlags.value & flag_buttonmask_norun) || pInput->fvel || pInput->svel || pInput->q16avel)
|
||||
pPlayer->isRunning = !!(pInput->actions & SB_RUN);
|
||||
if ((pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->q16avel)
|
||||
pPlayer->restTime = 0;
|
||||
else if (pPlayer->restTime >= 0)
|
||||
pPlayer->restTime += 4;
|
||||
|
@ -1331,8 +1354,8 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
pPlayer->q16horiz = mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), fix16_from_int(120));
|
||||
}
|
||||
if (pPlayer->curWeapon)
|
||||
pInput->syncFlags.newWeapon = pPlayer->curWeapon;
|
||||
if (pInput->syncFlags.action)
|
||||
pInput->setNewWeapon(pPlayer->curWeapon);
|
||||
if (pInput->actions & SB_OPEN)
|
||||
{
|
||||
if (bSeqStat)
|
||||
{
|
||||
|
@ -1348,12 +1371,12 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
playerReset(pPlayer);
|
||||
if (gGameOptions.nGameType == 0 && numplayers == 1)
|
||||
{
|
||||
pInput->syncFlags.restart = 1;
|
||||
gameRestart = 1;
|
||||
}
|
||||
else
|
||||
playerStart(pPlayer->nPlayer);
|
||||
}
|
||||
pInput->syncFlags.action = 0;
|
||||
pInput->actions &= ~SB_OPEN;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1410,11 +1433,11 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
}
|
||||
if (pInput->q16avel)
|
||||
pPlayer->q16ang = (pPlayer->q16ang+pInput->q16avel)&0x7ffffff;
|
||||
if (pInput->syncFlags.spin180)
|
||||
if (pInput->actions & SB_TURNAROUND)
|
||||
{
|
||||
if (!pPlayer->spin)
|
||||
pPlayer->spin = -1024;
|
||||
pInput->syncFlags.spin180 = 0;
|
||||
pInput->actions &= ~SB_TURNAROUND;
|
||||
}
|
||||
if (pPlayer->spin < 0)
|
||||
{
|
||||
|
@ -1432,22 +1455,22 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
gViewAngleAdjust += float(pSprite->ang - pPlayer->angold);
|
||||
pPlayer->q16ang = (pPlayer->q16ang+fix16_from_int(pSprite->ang-pPlayer->angold))&0x7ffffff;
|
||||
pPlayer->angold = pSprite->ang = fix16_to_int(pPlayer->q16ang);
|
||||
if (!pInput->syncFlags.jump)
|
||||
if (!(pInput->actions & SB_JUMP))
|
||||
pPlayer->cantJump = 0;
|
||||
|
||||
switch (pPlayer->posture) {
|
||||
case 1:
|
||||
if (pInput->syncFlags.jump)
|
||||
if (pInput->actions & SB_JUMP)
|
||||
zvel[nSprite] -= pPosture->normalJumpZ;//0x5b05;
|
||||
if (pInput->syncFlags.crouch)
|
||||
if (pInput->actions & SB_CROUCH)
|
||||
zvel[nSprite] += pPosture->normalJumpZ;//0x5b05;
|
||||
break;
|
||||
case 2:
|
||||
if (!pInput->syncFlags.crouch)
|
||||
if (!(pInput->actions & SB_CROUCH))
|
||||
pPlayer->posture = 0;
|
||||
break;
|
||||
default:
|
||||
if (!pPlayer->cantJump && pInput->syncFlags.jump && pXSprite->height == 0) {
|
||||
if (!pPlayer->cantJump && (pInput->actions & SB_JUMP) && pXSprite->height == 0) {
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0)
|
||||
#endif
|
||||
|
@ -1458,11 +1481,11 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
pPlayer->cantJump = 1;
|
||||
}
|
||||
|
||||
if (pInput->syncFlags.crouch)
|
||||
if (pInput->actions & SB_CROUCH)
|
||||
pPlayer->posture = 2;
|
||||
break;
|
||||
}
|
||||
if (pInput->syncFlags.action)
|
||||
if (pInput->actions & SB_OPEN)
|
||||
{
|
||||
int a2, a3;
|
||||
int hit = ActionScan(pPlayer, &a2, &a3);
|
||||
|
@ -1535,24 +1558,24 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
zvel[pSprite2->index] = zvel[nSprite];
|
||||
pPlayer->hand = 0;
|
||||
}
|
||||
pInput->syncFlags.action = 0;
|
||||
pInput->actions &= ~SB_OPEN;
|
||||
}
|
||||
if (bVanilla)
|
||||
{
|
||||
if (pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown)
|
||||
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
|
||||
{
|
||||
if (pPlayer->q16look < 0)
|
||||
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_int(4), fix16_from_int(0));
|
||||
if (pPlayer->q16look > 0)
|
||||
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_int(4), fix16_from_int(0));
|
||||
if (!pPlayer->q16look)
|
||||
pInput->syncFlags.lookCenter = 0;
|
||||
pInput->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pInput->syncFlags.lookUp)
|
||||
if (pInput->actions & (SB_LOOK_UP|SB_AIM_UP))
|
||||
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_int(4), fix16_from_int(60));
|
||||
if (pInput->syncFlags.lookDown)
|
||||
if (pInput->actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
|
||||
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_int(4), fix16_from_int(-60));
|
||||
}
|
||||
pPlayer->q16look = fix16_clamp(pPlayer->q16look+pInput->q16horz, fix16_from_int(-60), fix16_from_int(60));
|
||||
|
@ -1569,33 +1592,33 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
int downAngle = -347;
|
||||
double lookStepUp = 4.0*upAngle/60.0;
|
||||
double lookStepDown = -4.0*downAngle/60.0;
|
||||
if (pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown)
|
||||
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
|
||||
{
|
||||
if (pPlayer->q16look < 0)
|
||||
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_dbl(lookStepDown), fix16_from_int(0));
|
||||
if (pPlayer->q16look > 0)
|
||||
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_dbl(lookStepUp), fix16_from_int(0));
|
||||
if (!pPlayer->q16look)
|
||||
pInput->syncFlags.lookCenter = 0;
|
||||
pInput->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pInput->syncFlags.lookUp)
|
||||
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
|
||||
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_dbl(lookStepUp), fix16_from_int(upAngle));
|
||||
if (pInput->syncFlags.lookDown)
|
||||
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
|
||||
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_dbl(lookStepDown), fix16_from_int(downAngle));
|
||||
}
|
||||
if (pPlayer == gMe && numplayers == 1)
|
||||
{
|
||||
if (pInput->syncFlags.lookUp)
|
||||
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
|
||||
{
|
||||
gViewLookAdjust += float(lookStepUp);
|
||||
}
|
||||
if (pInput->syncFlags.lookDown)
|
||||
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
|
||||
{
|
||||
gViewLookAdjust -= float(lookStepDown);
|
||||
}
|
||||
gViewLookRecenter = pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown;
|
||||
gViewLookRecenter = ((pInput->actions & SB_CENTERVIEW) && !pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN));
|
||||
}
|
||||
pPlayer->q16look = fix16_clamp(pPlayer->q16look+(pInput->q16horz<<3), fix16_from_int(downAngle), fix16_from_int(upAngle));
|
||||
pPlayer->q16horiz = fix16_from_float(100.f*tanf(fix16_to_float(pPlayer->q16look)*fPI/1024.f));
|
||||
|
@ -1627,49 +1650,49 @@ void ProcessInput(PLAYER *pPlayer)
|
|||
pPlayer->q16slopehoriz = 0;
|
||||
}
|
||||
pPlayer->slope = (-fix16_to_int(pPlayer->q16horiz))<<7;
|
||||
if (pInput->syncFlags.prevItem)
|
||||
if (pInput->actions & SB_INVPREV)
|
||||
{
|
||||
pInput->syncFlags.prevItem = 0;
|
||||
pInput->actions&= ~SB_INVPREV;
|
||||
packPrevItem(pPlayer);
|
||||
}
|
||||
if (pInput->syncFlags.nextItem)
|
||||
if (pInput->actions & SB_INVNEXT)
|
||||
{
|
||||
pInput->syncFlags.nextItem = 0;
|
||||
pInput->actions &= ~SB_INVNEXT;
|
||||
packNextItem(pPlayer);
|
||||
}
|
||||
if (pInput->syncFlags.useItem)
|
||||
if (pInput->actions & SB_INVUSE)
|
||||
{
|
||||
pInput->syncFlags.useItem = 0;
|
||||
pInput->actions &= ~SB_INVUSE;
|
||||
if (pPlayer->packSlots[pPlayer->packItemId].curAmount > 0)
|
||||
packUseItem(pPlayer, pPlayer->packItemId);
|
||||
}
|
||||
if (pInput->syncFlags.useBeastVision)
|
||||
if (pInput->isItemUsed(Item_BeastVision))
|
||||
{
|
||||
pInput->syncFlags.useBeastVision = 0;
|
||||
pInput->clearItemUsed(Item_BeastVision);
|
||||
if (pPlayer->packSlots[3].curAmount > 0)
|
||||
packUseItem(pPlayer, 3);
|
||||
}
|
||||
if (pInput->syncFlags.useCrystalBall)
|
||||
if (pInput->isItemUsed(Item_CrystalBall))
|
||||
{
|
||||
pInput->syncFlags.useCrystalBall = 0;
|
||||
pInput->clearItemUsed(Item_CrystalBall);
|
||||
if (pPlayer->packSlots[2].curAmount > 0)
|
||||
packUseItem(pPlayer, 2);
|
||||
}
|
||||
if (pInput->syncFlags.useJumpBoots)
|
||||
if (pInput->isItemUsed(Item_JumpBoots))
|
||||
{
|
||||
pInput->syncFlags.useJumpBoots = 0;
|
||||
pInput->clearItemUsed(Item_JumpBoots);
|
||||
if (pPlayer->packSlots[4].curAmount > 0)
|
||||
packUseItem(pPlayer, 4);
|
||||
}
|
||||
if (pInput->syncFlags.useMedKit)
|
||||
if (pInput->isItemUsed(Item_MedKit))
|
||||
{
|
||||
pInput->syncFlags.useMedKit = 0;
|
||||
pInput->clearItemUsed(Item_MedKit);
|
||||
if (pPlayer->packSlots[0].curAmount > 0)
|
||||
packUseItem(pPlayer, 0);
|
||||
}
|
||||
if (pInput->syncFlags.holsterWeapon)
|
||||
if (pInput->actions & SB_HOLSTER)
|
||||
{
|
||||
pInput->syncFlags.holsterWeapon = 0;
|
||||
pInput->actions &= ~SB_HOLSTER;
|
||||
if (pPlayer->curWeapon)
|
||||
{
|
||||
WeaponLower(pPlayer);
|
||||
|
|
|
@ -119,8 +119,8 @@ struct PLAYER
|
|||
char hasFlag;
|
||||
short used2[8]; // ??
|
||||
int damageControl[7];
|
||||
char curWeapon;
|
||||
char nextWeapon;
|
||||
int8_t curWeapon;
|
||||
int8_t nextWeapon;
|
||||
int weaponTimer;
|
||||
int weaponState;
|
||||
int weaponAmmo; //rename
|
||||
|
|
|
@ -66,7 +66,7 @@ void viewInitializePrediction(void)
|
|||
predict.at6f = gMe->cantJump;
|
||||
predict.at70 = gMe->isRunning;
|
||||
predict.at72 = gMe->isUnderwater;
|
||||
predict.at71 = gMe->input.syncFlags.jump;
|
||||
predict.at71 = !!(gMe->input.actions & SB_JUMP);
|
||||
predict.at50 = gMe->pSprite->x;
|
||||
predict.at54 = gMe->pSprite->y;
|
||||
predict.at58 = gMe->pSprite->z;
|
||||
|
@ -78,7 +78,7 @@ void viewInitializePrediction(void)
|
|||
predict.at6a = gMe->pXSprite->height;
|
||||
predict.at48 = gMe->posture;
|
||||
predict.at4c = gMe->spin;
|
||||
predict.at6e = gMe->input.syncFlags.lookCenter;
|
||||
predict.at6e = !!(gMe->input.actions & SB_CENTERVIEW);
|
||||
memcpy(&predict.at75,&gSpriteHit[gMe->pSprite->extra],sizeof(SPRITEHIT));
|
||||
predict.at0 = gMe->bobPhase;
|
||||
predict.at4 = gMe->bobAmp;
|
||||
|
@ -135,8 +135,8 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
gViewLookAdjust = 0.f;
|
||||
}
|
||||
|
||||
predict.at70 = pInput->syncFlags.run;
|
||||
predict.at71 = pInput->syncFlags.jump;
|
||||
predict.at70 = !!(gMe->input.actions & SB_RUN);
|
||||
predict.at71 = !!(gMe->input.actions & SB_JUMP);
|
||||
if (predict.at48 == 1)
|
||||
{
|
||||
int x = Cos(fix16_to_int(predict.at30));
|
||||
|
@ -190,7 +190,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
}
|
||||
if (pInput->q16avel)
|
||||
predict.at30 = (predict.at30+pInput->q16avel)&0x7ffffff;
|
||||
if (pInput->syncFlags.spin180)
|
||||
if (pInput->actions & SB_TURNAROUND)
|
||||
if (!predict.at4c)
|
||||
predict.at4c = -1024;
|
||||
if (predict.at4c < 0)
|
||||
|
@ -215,11 +215,11 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
case 1:
|
||||
if (predict.at71)
|
||||
predict.at64 -= pPosture->normalJumpZ;//0x5b05;
|
||||
if (pInput->syncFlags.crouch)
|
||||
if (pInput->actions & SB_CROUCH)
|
||||
predict.at64 += pPosture->normalJumpZ;//0x5b05;
|
||||
break;
|
||||
case 2:
|
||||
if (!pInput->syncFlags.crouch)
|
||||
if (!(pInput->actions & SB_CROUCH))
|
||||
predict.at48 = 0;
|
||||
break;
|
||||
default:
|
||||
|
@ -228,7 +228,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
else predict.at64 = pPosture->normalJumpZ;//-0xbaaaa;
|
||||
predict.at6f = 1;
|
||||
}
|
||||
if (pInput->syncFlags.crouch)
|
||||
if (pInput->actions & SB_CROUCH)
|
||||
predict.at48 = 2;
|
||||
break;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
int downAngle = -347;
|
||||
double lookStepUp = 4.0*upAngle/60.0;
|
||||
double lookStepDown = -4.0*downAngle/60.0;
|
||||
if (predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown)
|
||||
if (predict.at6e && !pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN))
|
||||
{
|
||||
if (predict.at20 < 0)
|
||||
predict.at20 = fix16_min(predict.at20+fix16_from_dbl(lookStepDown), fix16_from_int(0));
|
||||
|
@ -273,22 +273,22 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (pInput->syncFlags.lookUp)
|
||||
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
|
||||
predict.at20 = fix16_min(predict.at20+fix16_from_dbl(lookStepUp), fix16_from_int(upAngle));
|
||||
if (pInput->syncFlags.lookDown)
|
||||
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
|
||||
predict.at20 = fix16_max(predict.at20-fix16_from_dbl(lookStepDown), fix16_from_int(downAngle));
|
||||
}
|
||||
if (numplayers > 1 && gPrediction)
|
||||
{
|
||||
if (pInput->syncFlags.lookUp)
|
||||
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
|
||||
{
|
||||
gViewLookAdjust += float(lookStepUp);
|
||||
}
|
||||
if (pInput->syncFlags.lookDown)
|
||||
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
|
||||
{
|
||||
gViewLookAdjust -= float(lookStepDown);
|
||||
}
|
||||
gViewLookRecenter = predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown;
|
||||
gViewLookRecenter = predict.at6e && !pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN);
|
||||
}
|
||||
predict.at20 = fix16_clamp(predict.at20+(pInput->q16horz<<3), fix16_from_int(downAngle), fix16_from_int(upAngle));
|
||||
predict.at24 = fix16_from_float(100.f*tanf(fix16_to_float(predict.at20)*fPI/1024.f));
|
||||
|
|
|
@ -121,7 +121,7 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
|
|||
}
|
||||
|
||||
|
||||
void sfxUpdate3DSounds(void)
|
||||
void GameInterface::UpdateSounds()
|
||||
{
|
||||
SoundListener listener;
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0);
|
|||
void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = -1);
|
||||
void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1);
|
||||
void sfxKillAllSounds(void);
|
||||
void sfxUpdate3DSounds(void);
|
||||
void sfxSetReverb(bool toggle);
|
||||
void sfxSetReverb2(bool toggle);
|
||||
|
||||
|
|
|
@ -322,7 +322,6 @@ void viewInit(void)
|
|||
FontSet(2, 4288, 1);
|
||||
FontSet(3, 4384, 1);
|
||||
FontSet(4, 4480, 0);
|
||||
enginePostInit(); // This must not be done earlier!
|
||||
|
||||
lensdata = fileSystem.LoadFile("lens.dat");
|
||||
dassert(lensdata.Size() == kLensSize * kLensSize * sizeof(int));
|
||||
|
|
|
@ -1766,17 +1766,17 @@ char sub_4F0E0(PLAYER *pPlayer)
|
|||
switch (pPlayer->weaponState)
|
||||
{
|
||||
case 5:
|
||||
if (!pPlayer->input.syncFlags.shoot2)
|
||||
if (!(pPlayer->input.actions & SB_ALTFIRE))
|
||||
pPlayer->weaponState = 6;
|
||||
return 1;
|
||||
case 6:
|
||||
if (pPlayer->input.syncFlags.shoot2)
|
||||
if (pPlayer->input.actions & SB_ALTFIRE)
|
||||
{
|
||||
pPlayer->weaponState = 3;
|
||||
pPlayer->fuseTime = pPlayer->weaponTimer;
|
||||
StartQAV(pPlayer, 13, nClientDropCan, 0);
|
||||
}
|
||||
else if (pPlayer->input.syncFlags.shoot)
|
||||
else if (pPlayer->input.actions & SB_FIRE)
|
||||
{
|
||||
pPlayer->weaponState = 7;
|
||||
pPlayer->fuseTime = 0;
|
||||
|
@ -1786,7 +1786,7 @@ char sub_4F0E0(PLAYER *pPlayer)
|
|||
case 7:
|
||||
{
|
||||
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536);
|
||||
if (!pPlayer->input.syncFlags.shoot)
|
||||
if (!(pPlayer->input.actions & SB_FIRE))
|
||||
{
|
||||
if (!pPlayer->fuseTime)
|
||||
pPlayer->fuseTime = pPlayer->weaponTimer;
|
||||
|
@ -1804,17 +1804,17 @@ char sub_4F200(PLAYER *pPlayer)
|
|||
switch (pPlayer->weaponState)
|
||||
{
|
||||
case 4:
|
||||
if (!pPlayer->input.syncFlags.shoot2)
|
||||
if (!(pPlayer->input.actions & SB_ALTFIRE))
|
||||
pPlayer->weaponState = 5;
|
||||
return 1;
|
||||
case 5:
|
||||
if (pPlayer->input.syncFlags.shoot2)
|
||||
if (pPlayer->input.actions & SB_ALTFIRE)
|
||||
{
|
||||
pPlayer->weaponState = 1;
|
||||
pPlayer->fuseTime = pPlayer->weaponTimer;
|
||||
StartQAV(pPlayer, 22, nClientDropBundle, 0);
|
||||
}
|
||||
else if (pPlayer->input.syncFlags.shoot)
|
||||
else if (pPlayer->input.actions & SB_FIRE)
|
||||
{
|
||||
pPlayer->weaponState = 6;
|
||||
pPlayer->fuseTime = 0;
|
||||
|
@ -1824,7 +1824,7 @@ char sub_4F200(PLAYER *pPlayer)
|
|||
case 6:
|
||||
{
|
||||
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536);
|
||||
if (!pPlayer->input.syncFlags.shoot)
|
||||
if (!(pPlayer->input.actions & SB_FIRE))
|
||||
{
|
||||
if (!pPlayer->fuseTime)
|
||||
pPlayer->fuseTime = pPlayer->weaponTimer;
|
||||
|
@ -1844,7 +1844,7 @@ char sub_4F320(PLAYER *pPlayer)
|
|||
case 9:
|
||||
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536);
|
||||
pPlayer->weaponTimer = 0;
|
||||
if (!pPlayer->input.syncFlags.shoot)
|
||||
if (!(pPlayer->input.actions & SB_FIRE))
|
||||
{
|
||||
pPlayer->weaponState = 8;
|
||||
StartQAV(pPlayer, 29, nClientThrowProx, 0);
|
||||
|
@ -1860,7 +1860,7 @@ char sub_4F3A0(PLAYER *pPlayer)
|
|||
{
|
||||
case 13:
|
||||
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536);
|
||||
if (!pPlayer->input.syncFlags.shoot)
|
||||
if (!(pPlayer->input.actions & SB_FIRE))
|
||||
{
|
||||
pPlayer->weaponState = 11;
|
||||
StartQAV(pPlayer, 39, nClientThrowRemote, 0);
|
||||
|
@ -1879,7 +1879,7 @@ char sub_4F414(PLAYER *pPlayer)
|
|||
StartQAV(pPlayer, 114, nClientFireLifeLeech, 1);
|
||||
return 1;
|
||||
case 6:
|
||||
if (!pPlayer->input.syncFlags.shoot2)
|
||||
if (!(pPlayer->input.actions & SB_ALTFIRE))
|
||||
{
|
||||
pPlayer->weaponState = 2;
|
||||
StartQAV(pPlayer, 118, -1, 0);
|
||||
|
@ -1906,7 +1906,7 @@ char sub_4F484(PLAYER *pPlayer)
|
|||
StartQAV(pPlayer, 77, nClientFireTesla, 1);
|
||||
return 1;
|
||||
case 5:
|
||||
if (!pPlayer->input.syncFlags.shoot)
|
||||
if (!(pPlayer->input.actions & SB_FIRE))
|
||||
{
|
||||
pPlayer->weaponState = 2;
|
||||
if (sub_4B2C8(pPlayer, 7, 10) && powerupCheck(pPlayer, kPwUpTwoGuns))
|
||||
|
@ -1967,8 +1967,8 @@ void WeaponProcess(PLAYER *pPlayer) {
|
|||
WeaponPlay(pPlayer);
|
||||
UpdateAimVector(pPlayer);
|
||||
pPlayer->weaponTimer -= 4;
|
||||
char bShoot = pPlayer->input.syncFlags.shoot;
|
||||
char bShoot2 = pPlayer->input.syncFlags.shoot2;
|
||||
bool bShoot = pPlayer->input.actions & SB_FIRE;
|
||||
bool bShoot2 = pPlayer->input.actions & SB_ALTFIRE;
|
||||
if (pPlayer->qavLoop && pPlayer->pXSprite->health > 0)
|
||||
{
|
||||
if (bShoot && CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1))
|
||||
|
@ -2025,9 +2025,9 @@ void WeaponProcess(PLAYER *pPlayer) {
|
|||
pPlayer->newWeapon = pPlayer->nextWeapon;
|
||||
pPlayer->nextWeapon = 0;
|
||||
}
|
||||
if (pPlayer->input.syncFlags.nextWeapon)
|
||||
if (pPlayer->input.getNewWeapon() == WeaponSel_Next)
|
||||
{
|
||||
pPlayer->input.syncFlags.nextWeapon = 0;
|
||||
pPlayer->input.setNewWeapon(0);
|
||||
pPlayer->weaponState = 0;
|
||||
pPlayer->nextWeapon = 0;
|
||||
int t;
|
||||
|
@ -2041,9 +2041,9 @@ void WeaponProcess(PLAYER *pPlayer) {
|
|||
}
|
||||
pPlayer->newWeapon = weapon;
|
||||
}
|
||||
if (pPlayer->input.syncFlags.prevWeapon)
|
||||
else if (pPlayer->input.getNewWeapon() == WeaponSel_Prev)
|
||||
{
|
||||
pPlayer->input.syncFlags.prevWeapon = 0;
|
||||
pPlayer->input.setNewWeapon(0);
|
||||
pPlayer->weaponState = 0;
|
||||
pPlayer->nextWeapon = 0;
|
||||
int t;
|
||||
|
@ -2057,6 +2057,38 @@ void WeaponProcess(PLAYER *pPlayer) {
|
|||
}
|
||||
pPlayer->newWeapon = weapon;
|
||||
}
|
||||
else if (pPlayer->input.getNewWeapon() == WeaponSel_Alt)
|
||||
{
|
||||
char weapon;
|
||||
|
||||
switch (pPlayer->curWeapon)
|
||||
{
|
||||
case 6:
|
||||
weapon = 11;
|
||||
break;
|
||||
case 11:
|
||||
weapon = 12;
|
||||
break;
|
||||
case 12:
|
||||
weapon = 6;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
pPlayer->input.setNewWeapon(0);
|
||||
pPlayer->weaponState = 0;
|
||||
pPlayer->nextWeapon = 0;
|
||||
int t = 0;
|
||||
pPlayer->weaponMode[weapon] = t;
|
||||
if (pPlayer->curWeapon)
|
||||
{
|
||||
WeaponLower(pPlayer);
|
||||
pPlayer->nextWeapon = weapon;
|
||||
return;
|
||||
}
|
||||
pPlayer->newWeapon = weapon;
|
||||
}
|
||||
if (pPlayer->weaponState == -1)
|
||||
{
|
||||
pPlayer->weaponState = 0;
|
||||
|
|
|
@ -74,7 +74,6 @@ enum rendmode_t {
|
|||
|
||||
#define MAXVOXELS 1024
|
||||
#define MAXSTATUS 1024
|
||||
#define MAXPLAYERS 16
|
||||
// Maximum number of component tiles in a multi-psky:
|
||||
#define MAXPSKYTILES 16
|
||||
#define MAXSPRITESONSCREEN 2560
|
||||
|
|
|
@ -18,6 +18,7 @@ struct SystemCallbacks
|
|||
IntRect(*GetSceneRect)();
|
||||
FString(*GetLocationDescription)();
|
||||
void (*MenuDim)();
|
||||
FString(*GetPlayerName)(int i);
|
||||
};
|
||||
|
||||
extern SystemCallbacks *sysCallbacks;
|
||||
|
|
1070
source/common/engine/i_net.cpp
Normal file
1070
source/common/engine/i_net.cpp
Normal file
File diff suppressed because it is too large
Load diff
85
source/common/engine/i_net.h
Normal file
85
source/common/engine/i_net.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
#ifndef __I_NET_H__
|
||||
#define __I_NET_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Called by D_DoomMain.
|
||||
int I_InitNetwork (void);
|
||||
void I_NetCmd (void);
|
||||
|
||||
enum ENetConstants
|
||||
{
|
||||
MAXNETNODES = 8, // max computers in a game
|
||||
DOOMCOM_ID = 0x12345678,
|
||||
BACKUPTICS = 36, // number of tics to remember
|
||||
MAXTICDUP = 5,
|
||||
LOCALCMDTICS =(BACKUPTICS*MAXTICDUP),
|
||||
MAX_MSGLEN = 14000,
|
||||
|
||||
CMD_SEND = 1,
|
||||
CMD_GET = 2,
|
||||
};
|
||||
|
||||
// [RH]
|
||||
// New generic packet structure:
|
||||
//
|
||||
// Header:
|
||||
// One byte with following flags.
|
||||
// One byte with starttic
|
||||
// One byte with master's maketic (master -> slave only!)
|
||||
// If NCMD_RETRANSMIT set, one byte with retransmitfrom
|
||||
// If NCMD_XTICS set, one byte with number of tics (minus 3, so theoretically up to 258 tics in one packet)
|
||||
// If NCMD_QUITTERS, one byte with number of players followed by one byte with each player's consolenum
|
||||
// If NCMD_MULTI, one byte with number of players followed by one byte with each player's consolenum
|
||||
// - The first player's consolenum is not included in this list, because it always matches the sender
|
||||
//
|
||||
// For each tic:
|
||||
// Two bytes with consistancy check, followed by tic data
|
||||
//
|
||||
// Setup packets are different, and are described just before D_ArbitrateNetStart().
|
||||
|
||||
enum ENCMD
|
||||
{
|
||||
NCMD_EXIT = 0x80,
|
||||
NCMD_RETRANSMIT = 0x40,
|
||||
NCMD_SETUP = 0x20,
|
||||
NCMD_MULTI = 0x10, // multiple players in this packet
|
||||
NCMD_QUITTERS = 0x08, // one or more players just quit (packet server only)
|
||||
NCMD_COMPRESSED = 0x04, // remainder of packet is compressed
|
||||
|
||||
NCMD_XTICS = 0x03, // packet contains >2 tics
|
||||
NCMD_2TICS = 0x02, // packet contains 2 tics
|
||||
NCMD_1TICS = 0x01, // packet contains 1 tic
|
||||
NCMD_0TICS = 0x00, // packet contains 0 tics
|
||||
};
|
||||
|
||||
//
|
||||
// Network packet data.
|
||||
//
|
||||
struct doomcom_t
|
||||
{
|
||||
uint32_t id; // should be DOOMCOM_ID
|
||||
int16_t intnum; // DOOM executes an int to execute commands
|
||||
|
||||
// communication between DOOM and the driver
|
||||
int16_t command; // CMD_SEND or CMD_GET
|
||||
int16_t remotenode; // dest for send, set by get (-1 = no packet).
|
||||
int16_t datalength; // bytes in data to be sent
|
||||
|
||||
// info common to all nodes
|
||||
int16_t numnodes; // console is always node 0.
|
||||
int16_t ticdup; // 1 = no duplication, 2-5 = dup for slow nets
|
||||
|
||||
// info specific to this node
|
||||
int16_t consoleplayer;
|
||||
int16_t numplayers;
|
||||
|
||||
// packet data to be sent
|
||||
uint8_t data[MAX_MSGLEN];
|
||||
|
||||
};
|
||||
|
||||
extern doomcom_t doomcom;
|
||||
extern bool netgame, multiplayer;
|
||||
|
||||
#endif
|
|
@ -58,7 +58,7 @@
|
|||
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
|
||||
|
||||
EXTERN_CVAR(Int, vid_maxfps)
|
||||
CVAR(Bool, cl_capfps, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
EXTERN_CVAR(Bool, cl_capfps)
|
||||
EXTERN_CVAR(Int, screenblocks)
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -175,11 +175,6 @@ int I_GetBuildTime()
|
|||
return NSToBuildTic(CurrentFrameStartTime - FirstFrameStartTime);
|
||||
}
|
||||
|
||||
void I_ResetTime()
|
||||
{
|
||||
FirstFrameStartTime = CurrentFrameStartTime = 0;
|
||||
}
|
||||
|
||||
double I_GetTimeFrac()
|
||||
{
|
||||
int currentTic = NSToTic(CurrentFrameStartTime - FirstFrameStartTime);
|
||||
|
|
|
@ -15,9 +15,6 @@ uint64_t I_GetTimeNS();
|
|||
// Called by Build games in lieu of totalclock, returns current time in tics at ticrate of 120.
|
||||
int I_GetBuildTime();
|
||||
|
||||
// Reset timer variables to zero when called.
|
||||
void I_ResetTime();
|
||||
|
||||
double I_GetTimeFrac();
|
||||
double I_GetBuildTimeFrac();
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ static FGameTexture *conback;
|
|||
static uint32_t conshade;
|
||||
static bool conline;
|
||||
|
||||
extern int gametic;
|
||||
extern bool advancedemo;
|
||||
|
||||
extern FBaseCVar *CVars;
|
||||
|
|
2149
source/core/d_net.cpp
Normal file
2149
source/core/d_net.cpp
Normal file
File diff suppressed because it is too large
Load diff
84
source/core/d_net.h
Normal file
84
source/core/d_net.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
|
||||
#ifndef __D_NET__
|
||||
#define __D_NET__
|
||||
|
||||
#include "i_net.h"
|
||||
#include "d_ticcmd.h"
|
||||
|
||||
enum
|
||||
{
|
||||
MAXPLAYERS = 8
|
||||
};
|
||||
|
||||
class FDynamicBuffer
|
||||
{
|
||||
public:
|
||||
FDynamicBuffer ();
|
||||
~FDynamicBuffer ();
|
||||
|
||||
void SetData (const uint8_t *data, int len);
|
||||
uint8_t *GetData (int *len = NULL);
|
||||
|
||||
private:
|
||||
uint8_t *m_Data;
|
||||
int m_Len, m_BufferLen;
|
||||
};
|
||||
|
||||
extern FDynamicBuffer NetSpecs[MAXPLAYERS][BACKUPTICS];
|
||||
|
||||
// Create any new ticcmds and broadcast to other players.
|
||||
void NetUpdate (void);
|
||||
|
||||
// Broadcasts special packets to other players
|
||||
// to notify of game exit
|
||||
void D_QuitNetGame (void);
|
||||
|
||||
//? how many ticks to run?
|
||||
void TryRunTics (void);
|
||||
|
||||
//Use for checking to see if the netgame has stalled
|
||||
void Net_CheckLastReceived(int);
|
||||
|
||||
// [RH] Functions for making and using special "ticcmds"
|
||||
void Net_NewMakeTic ();
|
||||
void Net_WriteByte (uint8_t);
|
||||
void Net_WriteWord (short);
|
||||
void Net_WriteLong (int);
|
||||
void Net_WriteFloat (float);
|
||||
void Net_WriteString (const char *);
|
||||
void Net_WriteBytes (const uint8_t *, int len);
|
||||
|
||||
void Net_DoCommand (int type, uint8_t **stream, int player);
|
||||
void Net_SkipCommand (int type, uint8_t **stream);
|
||||
|
||||
void Net_ClearBuffers ();
|
||||
|
||||
bool D_CheckNetGame(void);
|
||||
|
||||
void Net_ClearFifo(void);
|
||||
|
||||
|
||||
// Netgame stuff (buffers and pointers, i.e. indices).
|
||||
|
||||
// This is the interface to the packet driver, a separate program
|
||||
// in DOS, but just an abstraction here.
|
||||
extern doomcom_t doomcom;
|
||||
|
||||
extern struct ticcmd_t localcmds[LOCALCMDTICS];
|
||||
|
||||
extern int maketic;
|
||||
extern int nettics[MAXNETNODES];
|
||||
extern int netdelay[MAXNETNODES][BACKUPTICS];
|
||||
extern int nodeforplayer[MAXPLAYERS];
|
||||
|
||||
extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
|
||||
extern int ticdup;
|
||||
extern bool nodeingame[MAXNETNODES]; // set false as nodes leave game
|
||||
extern bool hadlate;
|
||||
extern uint64_t lastglobalrecvtime; // Identify the last time a packet was received.
|
||||
extern bool playeringame[MAXPLAYERS]; // as long as network isn't working - true for the first player, false for all others.
|
||||
extern ticcmd_t playercmds[MAXPLAYERS];
|
||||
extern short consistancy[MAXPLAYERS][BACKUPTICS];
|
||||
|
||||
|
||||
#endif
|
443
source/core/d_protocol.cpp
Normal file
443
source/core/d_protocol.cpp
Normal file
|
@ -0,0 +1,443 @@
|
|||
/*
|
||||
** d_protocol.cpp
|
||||
** Basic network packet creation routines and simple IFF parsing
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 1998-2006 Randy Heit
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#include "d_protocol.h"
|
||||
#include "d_net.h"
|
||||
#include "cmdlib.h"
|
||||
#include "serializer.h"
|
||||
|
||||
extern int gametic;
|
||||
|
||||
|
||||
char *ReadString (uint8_t **stream)
|
||||
{
|
||||
char *string = *((char **)stream);
|
||||
|
||||
*stream += strlen (string) + 1;
|
||||
return copystring (string);
|
||||
}
|
||||
|
||||
const char *ReadStringConst(uint8_t **stream)
|
||||
{
|
||||
const char *string = *((const char **)stream);
|
||||
*stream += strlen (string) + 1;
|
||||
return string;
|
||||
}
|
||||
|
||||
int ReadByte (uint8_t **stream)
|
||||
{
|
||||
uint8_t v = **stream;
|
||||
*stream += 1;
|
||||
return v;
|
||||
}
|
||||
|
||||
int ReadWord (uint8_t **stream)
|
||||
{
|
||||
short v = (((*stream)[0]) << 8) | (((*stream)[1]));
|
||||
*stream += 2;
|
||||
return v;
|
||||
}
|
||||
|
||||
int ReadLong (uint8_t **stream)
|
||||
{
|
||||
int v = (((*stream)[0]) << 24) | (((*stream)[1]) << 16) | (((*stream)[2]) << 8) | (((*stream)[3]));
|
||||
*stream += 4;
|
||||
return v;
|
||||
}
|
||||
|
||||
float ReadFloat (uint8_t **stream)
|
||||
{
|
||||
union
|
||||
{
|
||||
int i;
|
||||
float f;
|
||||
} fakeint;
|
||||
fakeint.i = ReadLong (stream);
|
||||
return fakeint.f;
|
||||
}
|
||||
|
||||
void WriteString (const char *string, uint8_t **stream)
|
||||
{
|
||||
char *p = *((char **)stream);
|
||||
|
||||
while (*string) {
|
||||
*p++ = *string++;
|
||||
}
|
||||
|
||||
*p++ = 0;
|
||||
*stream = (uint8_t *)p;
|
||||
}
|
||||
|
||||
|
||||
void WriteByte (uint8_t v, uint8_t **stream)
|
||||
{
|
||||
**stream = v;
|
||||
*stream += 1;
|
||||
}
|
||||
|
||||
void WriteWord (short v, uint8_t **stream)
|
||||
{
|
||||
(*stream)[0] = v >> 8;
|
||||
(*stream)[1] = v & 255;
|
||||
*stream += 2;
|
||||
}
|
||||
|
||||
void WriteLong (int v, uint8_t **stream)
|
||||
{
|
||||
(*stream)[0] = v >> 24;
|
||||
(*stream)[1] = (v >> 16) & 255;
|
||||
(*stream)[2] = (v >> 8) & 255;
|
||||
(*stream)[3] = v & 255;
|
||||
*stream += 4;
|
||||
}
|
||||
|
||||
void WriteFloat (float v, uint8_t **stream)
|
||||
{
|
||||
union
|
||||
{
|
||||
int i;
|
||||
float f;
|
||||
} fakeint;
|
||||
fakeint.f = v;
|
||||
WriteLong (fakeint.i, stream);
|
||||
}
|
||||
|
||||
// Returns the number of bytes read
|
||||
int UnpackUserCmd (InputPacket *ucmd, const InputPacket *basis, uint8_t **stream)
|
||||
{
|
||||
uint8_t *start = *stream;
|
||||
uint8_t flags;
|
||||
|
||||
if (basis != NULL)
|
||||
{
|
||||
if (basis != ucmd)
|
||||
{
|
||||
memcpy (ucmd, basis, sizeof(InputPacket));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (ucmd, 0, sizeof(InputPacket));
|
||||
}
|
||||
|
||||
flags = ReadByte (stream);
|
||||
|
||||
if (flags)
|
||||
{
|
||||
// We can support up to 29 buttons, using from 0 to 4 bytes to store them.
|
||||
if (flags & UCMDF_BUTTONS)
|
||||
ucmd->actions = ESyncBits::FromInt(ReadLong(stream));
|
||||
if (flags & UCMDF_PITCH)
|
||||
ucmd->q16horz = ReadLong(stream);
|
||||
if (flags & UCMDF_YAW)
|
||||
ucmd->q16avel = ReadLong(stream);
|
||||
if (flags & UCMDF_FORWARDMOVE)
|
||||
ucmd->fvel = ReadWord (stream);
|
||||
if (flags & UCMDF_SIDEMOVE)
|
||||
ucmd->svel = ReadWord (stream);
|
||||
if (flags & UCMDF_UPMOVE)
|
||||
ucmd->q16horiz = ReadWord (stream);
|
||||
if (flags & UCMDF_ROLL)
|
||||
ucmd->q16ang = ReadWord (stream);
|
||||
}
|
||||
|
||||
return int(*stream - start);
|
||||
}
|
||||
|
||||
// Returns the number of bytes written
|
||||
int PackUserCmd (const InputPacket *ucmd, const InputPacket *basis, uint8_t **stream)
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
uint8_t *temp = *stream;
|
||||
uint8_t *start = *stream;
|
||||
InputPacket blank;
|
||||
|
||||
if (basis == NULL)
|
||||
{
|
||||
memset (&blank, 0, sizeof(blank));
|
||||
basis = ␣
|
||||
}
|
||||
|
||||
WriteByte (0, stream); // Make room for the packing bits
|
||||
|
||||
if (ucmd->actions != basis->actions)
|
||||
{
|
||||
flags |= UCMDF_BUTTONS;
|
||||
WriteLong(ucmd->actions, stream);
|
||||
}
|
||||
if (ucmd->q16horz != basis->q16horz)
|
||||
{
|
||||
flags |= UCMDF_PITCH;
|
||||
WriteLong (ucmd->q16horz, stream);
|
||||
}
|
||||
if (ucmd->q16avel != basis->q16avel)
|
||||
{
|
||||
flags |= UCMDF_YAW;
|
||||
WriteLong (ucmd->q16avel, stream);
|
||||
}
|
||||
if (ucmd->fvel != basis->fvel)
|
||||
{
|
||||
flags |= UCMDF_FORWARDMOVE;
|
||||
WriteWord (ucmd->fvel, stream);
|
||||
}
|
||||
if (ucmd->svel != basis->svel)
|
||||
{
|
||||
flags |= UCMDF_SIDEMOVE;
|
||||
WriteWord (ucmd->svel, stream);
|
||||
}
|
||||
if (ucmd->q16horiz != basis->q16horiz)
|
||||
{
|
||||
flags |= UCMDF_UPMOVE;
|
||||
WriteLong (ucmd->q16horiz, stream);
|
||||
}
|
||||
if (ucmd->q16ang != basis->q16ang)
|
||||
{
|
||||
flags |= UCMDF_ROLL;
|
||||
WriteLong (ucmd->q16ang, stream);
|
||||
}
|
||||
|
||||
// Write the packing bits
|
||||
WriteByte (flags, &temp);
|
||||
|
||||
return int(*stream - start);
|
||||
}
|
||||
|
||||
FSerializer &Serialize(FSerializer &arc, const char *key, ticcmd_t &cmd, ticcmd_t *def)
|
||||
{
|
||||
if (arc.BeginObject(key))
|
||||
{
|
||||
arc("consistency", cmd.consistancy)
|
||||
("ucmd", cmd.ucmd)
|
||||
.EndObject();
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
FSerializer &Serialize(FSerializer &arc, const char *key, InputPacket &cmd, InputPacket *def)
|
||||
{
|
||||
if (arc.BeginObject(key))
|
||||
{
|
||||
arc("actions", cmd.actions)
|
||||
("horz", cmd.q16horz)
|
||||
("avel", cmd.q16avel)
|
||||
("ang", cmd.q16ang)
|
||||
("fvel", cmd.fvel)
|
||||
("svwl", cmd.svel)
|
||||
("q16horiz", cmd.q16horiz)
|
||||
.EndObject();
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t **stream)
|
||||
{
|
||||
if (basis == NULL)
|
||||
{
|
||||
if (ucmd->actions != 0 ||
|
||||
ucmd->q16horz != 0 ||
|
||||
ucmd->q16avel != 0 ||
|
||||
ucmd->fvel != 0 ||
|
||||
ucmd->svel != 0 ||
|
||||
ucmd->q16horiz != 0 ||
|
||||
ucmd->q16ang != 0)
|
||||
{
|
||||
WriteByte (DEM_USERCMD, stream);
|
||||
return PackUserCmd (ucmd, basis, stream) + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (ucmd->actions != basis->actions ||
|
||||
ucmd->q16horz != basis->q16horz ||
|
||||
ucmd->q16avel != basis->q16avel ||
|
||||
ucmd->fvel != basis->fvel ||
|
||||
ucmd->svel != basis->svel ||
|
||||
ucmd->q16horiz != basis->q16horiz ||
|
||||
ucmd->q16ang != basis->q16ang)
|
||||
{
|
||||
WriteByte (DEM_USERCMD, stream);
|
||||
return PackUserCmd (ucmd, basis, stream) + 1;
|
||||
}
|
||||
|
||||
WriteByte (DEM_EMPTYUSERCMD, stream);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int SkipTicCmd (uint8_t **stream, int count)
|
||||
{
|
||||
int i, skip;
|
||||
uint8_t *flow = *stream;
|
||||
|
||||
for (i = count; i > 0; i--)
|
||||
{
|
||||
bool moreticdata = true;
|
||||
|
||||
flow += 2; // Skip consistancy marker
|
||||
while (moreticdata)
|
||||
{
|
||||
uint8_t type = *flow++;
|
||||
|
||||
if (type == DEM_USERCMD)
|
||||
{
|
||||
moreticdata = false;
|
||||
skip = 1;
|
||||
if (*flow & UCMDF_PITCH) skip += 4;
|
||||
if (*flow & UCMDF_YAW) skip += 4;
|
||||
if (*flow & UCMDF_FORWARDMOVE) skip += 2;
|
||||
if (*flow & UCMDF_SIDEMOVE) skip += 2;
|
||||
if (*flow & UCMDF_UPMOVE) skip += 4;
|
||||
if (*flow & UCMDF_ROLL) skip += 4;
|
||||
if (*flow & UCMDF_BUTTONS) skip += 4;
|
||||
flow += skip;
|
||||
}
|
||||
else if (type == DEM_EMPTYUSERCMD)
|
||||
{
|
||||
moreticdata = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_SkipCommand (type, &flow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skip = int(flow - *stream);
|
||||
*stream = flow;
|
||||
|
||||
return skip;
|
||||
}
|
||||
|
||||
extern short consistancy[MAXPLAYERS][BACKUPTICS];
|
||||
void ReadTicCmd (uint8_t **stream, int player, int tic)
|
||||
{
|
||||
int type;
|
||||
uint8_t *start;
|
||||
ticcmd_t *tcmd;
|
||||
|
||||
int ticmod = tic % BACKUPTICS;
|
||||
|
||||
tcmd = &netcmds[player][ticmod];
|
||||
tcmd->consistancy = ReadWord (stream);
|
||||
|
||||
start = *stream;
|
||||
|
||||
while ((type = ReadByte (stream)) != DEM_USERCMD && type != DEM_EMPTYUSERCMD)
|
||||
Net_SkipCommand (type, stream);
|
||||
|
||||
NetSpecs[player][ticmod].SetData (start, int(*stream - start - 1));
|
||||
|
||||
if (type == DEM_USERCMD)
|
||||
{
|
||||
UnpackUserCmd (&tcmd->ucmd,
|
||||
tic ? &netcmds[player][(tic-1)%BACKUPTICS].ucmd : NULL, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tic)
|
||||
{
|
||||
memcpy (&tcmd->ucmd, &netcmds[player][(tic-1)%BACKUPTICS].ucmd, sizeof(tcmd->ucmd));
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (&tcmd->ucmd, 0, sizeof(tcmd->ucmd));
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (player==consoleplayer&&tic>BACKUPTICS)
|
||||
assert(consistancy[player][ticmod] == tcmd->consistancy);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RunNetSpecs (int player, int buf)
|
||||
{
|
||||
uint8_t *stream;
|
||||
int len;
|
||||
|
||||
if (gametic % ticdup == 0)
|
||||
{
|
||||
stream = NetSpecs[player][buf].GetData (&len);
|
||||
if (stream)
|
||||
{
|
||||
uint8_t *end = stream + len;
|
||||
while (stream < end)
|
||||
{
|
||||
int type = ReadByte (&stream);
|
||||
Net_DoCommand (type, &stream, player);
|
||||
}
|
||||
#if 0
|
||||
if (!demorecording)
|
||||
#endif
|
||||
NetSpecs[player][buf].SetData (NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *lenspot;
|
||||
|
||||
// Write the header of an IFF chunk and leave space
|
||||
// for the length field.
|
||||
void StartChunk (int id, uint8_t **stream)
|
||||
{
|
||||
WriteLong (id, stream);
|
||||
lenspot = *stream;
|
||||
*stream += 4;
|
||||
}
|
||||
|
||||
// Write the length field for the chunk and insert
|
||||
// pad byte if the chunk is odd-sized.
|
||||
void FinishChunk (uint8_t **stream)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (!lenspot)
|
||||
return;
|
||||
|
||||
len = int(*stream - lenspot - 4);
|
||||
WriteLong (len, &lenspot);
|
||||
if (len & 1)
|
||||
WriteByte (0, stream);
|
||||
|
||||
lenspot = NULL;
|
||||
}
|
||||
|
||||
// Skip past an unknown chunk. *stream should be
|
||||
// pointing to the chunk's length field.
|
||||
void SkipChunk (uint8_t **stream)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = ReadLong (stream);
|
||||
*stream += len + (len & 1);
|
||||
}
|
119
source/core/d_protocol.h
Normal file
119
source/core/d_protocol.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
** d_protocol.h
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 1998-2006 Randy Heit
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#ifndef __D_PROTOCOL_H__
|
||||
#define __D_PROTOCOL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "packet.h"
|
||||
|
||||
// The IFF routines here all work with big-endian IDs, even if the host
|
||||
// system is little-endian.
|
||||
#define BIGE_ID(a,b,c,d) ((d)|((c)<<8)|((b)<<16)|((a)<<24))
|
||||
|
||||
#define FORM_ID BIGE_ID('F','O','R','M')
|
||||
#define ZDEM_ID BIGE_ID('R','D','E','M')
|
||||
#define ZDHD_ID BIGE_ID('R','Z','H','D')
|
||||
#define VARS_ID BIGE_ID('V','A','R','S')
|
||||
#define UINF_ID BIGE_ID('U','I','N','F')
|
||||
#define COMP_ID BIGE_ID('C','O','M','P')
|
||||
#define BODY_ID BIGE_ID('B','O','D','Y')
|
||||
#define NETD_ID BIGE_ID('N','E','T','D')
|
||||
#define WEAP_ID BIGE_ID('W','E','A','P')
|
||||
|
||||
#define ANGLE2SHORT(x) ((((x)/360) & 65535)
|
||||
#define SHORT2ANGLE(x) ((x)*360)
|
||||
|
||||
|
||||
struct zdemoheader_s {
|
||||
uint8_t demovermajor;
|
||||
uint8_t demoverminor;
|
||||
uint8_t minvermajor;
|
||||
uint8_t minverminor;
|
||||
uint8_t map[8];
|
||||
unsigned int rngseed;
|
||||
uint8_t consoleplayer;
|
||||
};
|
||||
|
||||
|
||||
class FArchive;
|
||||
|
||||
// When transmitted, the above message is preceded by a uint8_t
|
||||
// indicating which fields are actually present in the message.
|
||||
enum
|
||||
{
|
||||
UCMDF_BUTTONS = 0x01,
|
||||
UCMDF_PITCH = 0x02,
|
||||
UCMDF_YAW = 0x04,
|
||||
UCMDF_FORWARDMOVE = 0x08,
|
||||
UCMDF_SIDEMOVE = 0x10,
|
||||
UCMDF_UPMOVE = 0x20,
|
||||
UCMDF_ROLL = 0x40,
|
||||
};
|
||||
|
||||
// When changing the following enum, be sure to update Net_SkipCommand()
|
||||
// and Net_DoCommand() in d_net.cpp.
|
||||
enum EDemoCommand
|
||||
{
|
||||
DEM_BAD, // 0 Bad command
|
||||
DEM_USERCMD,
|
||||
DEM_EMPTYUSERCMD,
|
||||
};
|
||||
|
||||
void StartChunk (int id, uint8_t **stream);
|
||||
void FinishChunk (uint8_t **stream);
|
||||
void SkipChunk (uint8_t **stream);
|
||||
|
||||
int UnpackUserCmd (InputPacket *ucmd, const InputPacket*basis, uint8_t **stream);
|
||||
int PackUserCmd (const InputPacket*ucmd, const InputPacket*basis, uint8_t **stream);
|
||||
int WriteUserCmdMessage (InputPacket*ucmd, const InputPacket*basis, uint8_t **stream);
|
||||
|
||||
struct ticcmd_t;
|
||||
|
||||
int SkipTicCmd (uint8_t **stream, int count);
|
||||
void ReadTicCmd (uint8_t **stream, int player, int tic);
|
||||
void RunNetSpecs (int player, int buf);
|
||||
|
||||
int Readuint8_t (uint8_t **stream);
|
||||
int Reauint32_t (uint8_t **stream);
|
||||
int ReadLong (uint8_t **stream);
|
||||
float ReadFloat (uint8_t **stream);
|
||||
char *ReadString (uint8_t **stream);
|
||||
const char *ReadStringConst(uint8_t **stream);
|
||||
void WriteByte (uint8_t val, uint8_t **stream);
|
||||
void WriteWord (short val, uint8_t **stream);
|
||||
void WriteLong (int val, uint8_t **stream);
|
||||
void WriteFloat (float val, uint8_t **stream);
|
||||
void WriteString (const char *string, uint8_t **stream);
|
||||
|
||||
#endif //__D_PROTOCOL_H__
|
42
source/core/d_ticcmd.h
Normal file
42
source/core/d_ticcmd.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// System specific interface stuff.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __D_TICCMD_H__
|
||||
#define __D_TICCMD_H__
|
||||
|
||||
#include "d_protocol.h"
|
||||
#include "packet.h"
|
||||
|
||||
// The data sampled per tick (single player)
|
||||
// and transmitted to other peers (multiplayer).
|
||||
// Mainly movements/button commands per game tick,
|
||||
// plus a checksum for internal state consistency.
|
||||
struct ticcmd_t
|
||||
{
|
||||
InputPacket ucmd;
|
||||
uint16_t consistancy; // checks for net game
|
||||
};
|
||||
|
||||
|
||||
FArchive &operator<< (FArchive &arc, ticcmd_t &cmd);
|
||||
|
||||
#endif // __D_TICCMD_H__
|
|
@ -69,6 +69,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "screenjob.h"
|
||||
#include "statusbar.h"
|
||||
#include "uiinput.h"
|
||||
#include "d_net.h"
|
||||
|
||||
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
@ -95,12 +96,12 @@ GameInterface* gi;
|
|||
int myconnectindex, numplayers;
|
||||
int connecthead, connectpoint2[MAXMULTIPLAYERS];
|
||||
auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries.
|
||||
int gameclock;
|
||||
int gameclock, gameclockstart;
|
||||
int lastTic;
|
||||
|
||||
bool sendPause;
|
||||
int automapMode;
|
||||
bool automapFollow;
|
||||
extern bool pauseext;
|
||||
|
||||
CCMD(togglemap)
|
||||
{
|
||||
|
@ -119,7 +120,7 @@ CCMD(togglefollow)
|
|||
gi->ResetFollowPos(true);
|
||||
}
|
||||
|
||||
glcycle_t thinktime, actortime, gameupdatetime, drawtime;
|
||||
cycle_t thinktime, actortime, gameupdatetime, drawtime;
|
||||
|
||||
gamestate_t gamestate = GS_STARTUP;
|
||||
|
||||
|
@ -137,10 +138,10 @@ void S_ParseSndInfo();
|
|||
void I_DetectOS(void);
|
||||
void LoadScripts();
|
||||
void app_loop();
|
||||
void DrawFullscreenBlends();
|
||||
void MainLoop();
|
||||
|
||||
|
||||
bool AppActive;
|
||||
bool AppActive = true;
|
||||
|
||||
FString currentGame;
|
||||
FString LumpFilter;
|
||||
|
@ -281,15 +282,6 @@ void UserConfig::ProcessOptions()
|
|||
Printf("Build-format config files not supported and will be ignored\n");
|
||||
}
|
||||
|
||||
#if 0 // MP disabled pending evaluation
|
||||
auto v = Args->CheckValue("-port");
|
||||
if (v) netPort = strtol(v, nullptr, 0);
|
||||
|
||||
netServerMode = Args->CheckParm("-server");
|
||||
netServerAddress = Args->CheckValue("-connect");
|
||||
netPassword = Args->CheckValue("-password");
|
||||
#endif
|
||||
|
||||
auto v = Args->CheckValue("-addon");
|
||||
if (v)
|
||||
{
|
||||
|
@ -427,7 +419,6 @@ void UserConfig::ProcessOptions()
|
|||
C_DoCommand("stat coord");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -868,9 +859,18 @@ int RunGame()
|
|||
auto exec = C_ParseCmdLineParams(nullptr);
|
||||
if (exec) exec->ExecCommands();
|
||||
|
||||
gamestate = GS_LEVEL;
|
||||
SetupGameButtons();
|
||||
gi->app_init();
|
||||
app_loop();
|
||||
enginePostInit(); // This must not be done earlier!
|
||||
videoInit();
|
||||
|
||||
// Duke has transitioned to the new main loop, the other games haven't yet.
|
||||
if (g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_RRALL | GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI))
|
||||
{
|
||||
D_CheckNetGame();
|
||||
MainLoop();
|
||||
}
|
||||
else app_loop();
|
||||
return 0; // this is never reached. app_loop only exits via exception.
|
||||
}
|
||||
|
||||
|
@ -903,8 +903,9 @@ void TickSubsystems()
|
|||
if (cnt == 5) nexttick = nowtick + tickInterval;
|
||||
}
|
||||
|
||||
static void updatePauseStatus()
|
||||
void updatePauseStatus()
|
||||
{
|
||||
// This must go through the network in multiplayer games.
|
||||
if (M_Active() || System_WantGuiCapture())
|
||||
{
|
||||
paused = 1;
|
||||
|
@ -927,13 +928,6 @@ static void updatePauseStatus()
|
|||
paused ? S_PauseSound(!pausedWithKey, !paused) : S_ResumeSound(paused);
|
||||
}
|
||||
|
||||
static void checkTimerActive()
|
||||
{
|
||||
FStat *stat = FStat::FindStat("fps");
|
||||
glcycle_t::active = (stat != NULL && stat->isActive());
|
||||
}
|
||||
|
||||
|
||||
void app_loop()
|
||||
{
|
||||
gamestate = GS_STARTUP;
|
||||
|
@ -944,13 +938,10 @@ void app_loop()
|
|||
{
|
||||
I_SetFrameTime();
|
||||
TickSubsystems();
|
||||
twod->SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
|
||||
handleevents();
|
||||
updatePauseStatus();
|
||||
D_ProcessEvents();
|
||||
checkTimerActive();
|
||||
|
||||
gi->RunGameFrame();
|
||||
|
||||
|
@ -972,6 +963,7 @@ void app_loop()
|
|||
}
|
||||
catch (CRecoverableError& err)
|
||||
{
|
||||
gi->ErrorCleanup();
|
||||
C_FullConsole();
|
||||
Printf(TEXTCOLOR_RED "%s\n", err.what());
|
||||
}
|
||||
|
@ -1128,6 +1120,16 @@ void S_SetSoundPaused(int state)
|
|||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (!netgame
|
||||
#if 0 //def _DEBUG
|
||||
&& !demoplayback
|
||||
#endif
|
||||
)
|
||||
{
|
||||
pauseext = !state;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FString G_GetDemoPath()
|
||||
|
@ -1221,3 +1223,18 @@ CCMD(taunt)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void startmainmenu()
|
||||
{
|
||||
gamestate = GS_MENUSCREEN;
|
||||
M_StartControlPanel(false);
|
||||
M_SetMenu(NAME_Mainmenu);
|
||||
FX_StopAllSounds();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,15 @@
|
|||
#include "tarray.h"
|
||||
#include "name.h"
|
||||
#include "memarena.h"
|
||||
#include "stats.h"
|
||||
|
||||
extern FString currentGame;
|
||||
extern FString LumpFilter;
|
||||
class FArgs;
|
||||
extern bool GUICapture;
|
||||
extern bool AppActive;
|
||||
extern cycle_t drawtime, actortime, thinktime, gameupdatetime;
|
||||
extern bool r_NoInterpolate;
|
||||
|
||||
extern FMemArena dump; // this is for memory blocks than cannot be deallocated without some huge effort. Put them in here so that they do not register on shutdown.
|
||||
|
||||
|
@ -43,6 +47,8 @@ extern FStringCVar* const CombatMacros[];
|
|||
void CONFIG_ReadCombatMacros();
|
||||
|
||||
int GameMain();
|
||||
void startmainmenu();
|
||||
void updatePauseStatus();
|
||||
|
||||
struct UserConfig
|
||||
{
|
||||
|
@ -217,4 +223,5 @@ extern int automapMode;
|
|||
extern bool automapFollow;
|
||||
extern bool sendPause;
|
||||
extern int gameclock;
|
||||
extern int gameclockstart;
|
||||
extern int lastTic;
|
||||
|
|
|
@ -230,8 +230,6 @@ CUSTOM_CVARD(Int, in_mousebias, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE, "emulates the
|
|||
else if (self > 32) self = 32;
|
||||
}
|
||||
|
||||
CVARD(Bool, in_mousesmoothing, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE, "enable/disable mouse input smoothing")
|
||||
|
||||
CUSTOM_CVARD(Float, in_mousesensitivity, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "changes the mouse sensitivity")
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
|
|
|
@ -89,8 +89,6 @@ EXTERN_CVAR(Int, gl_ssao)
|
|||
EXTERN_CVAR(Bool, use_joystick)
|
||||
EXTERN_CVAR(Int, in_mousebias)
|
||||
EXTERN_CVAR(Bool, in_mouseflip)
|
||||
EXTERN_CVAR(Bool, in_mousemode)
|
||||
EXTERN_CVAR(Bool, in_mousesmoothing)
|
||||
EXTERN_CVAR(Float, in_mousesensitivity)
|
||||
EXTERN_CVAR(Float, in_mousescalex)
|
||||
EXTERN_CVAR(Float, in_mousescaley)
|
||||
|
|
|
@ -6,6 +6,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
|
|||
#include "vectors.h"
|
||||
#include "engineerrors.h"
|
||||
#include "stats.h"
|
||||
#include "packet.h"
|
||||
|
||||
struct GameStats
|
||||
{
|
||||
|
@ -54,7 +55,7 @@ struct ReservedSpace
|
|||
|
||||
enum EMenuSounds : int;
|
||||
|
||||
extern glcycle_t drawtime, actortime, thinktime, gameupdatetime;
|
||||
extern cycle_t drawtime, actortime, thinktime, gameupdatetime;
|
||||
|
||||
struct GameInterface
|
||||
{
|
||||
|
@ -62,7 +63,6 @@ struct GameInterface
|
|||
virtual ~GameInterface() {}
|
||||
virtual bool GenerateSavePic() { return false; }
|
||||
virtual void app_init() = 0;
|
||||
virtual void RunGameFrame() = 0;
|
||||
virtual void clearlocalinputstate() {}
|
||||
virtual void UpdateScreenSize() {}
|
||||
virtual void FreeGameData() {}
|
||||
|
@ -93,6 +93,18 @@ struct GameInterface
|
|||
virtual void ExitFromMenu() { throw CExitEvent(0); }
|
||||
virtual ReservedSpace GetReservedScreenSpace(int viewsize) { return { 0, 0 }; }
|
||||
virtual void ResetFollowPos(bool) {}
|
||||
virtual void GetInput(InputPacket* packet) {}
|
||||
virtual void UpdateSounds() {}
|
||||
virtual void ErrorCleanup() {}
|
||||
virtual void Startup() {}
|
||||
virtual void DrawBackground() {}
|
||||
virtual void Render() {}
|
||||
virtual void Ticker() {}
|
||||
virtual int GetPlayerChecksum(int pnum) { return 0x12345678 + pnum; }
|
||||
|
||||
virtual void RunGameFrame() {} // this must go away once things are done.
|
||||
|
||||
|
||||
virtual FString statFPS()
|
||||
{
|
||||
FString output;
|
||||
|
|
|
@ -38,8 +38,15 @@
|
|||
#include "gamecvars.h"
|
||||
#include "v_video.h"
|
||||
#include "statusbar.h"
|
||||
#include"packet.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "gamestruct.h"
|
||||
|
||||
static int WeaponToSend = 0;
|
||||
ESyncBits ActionsToSend = 0;
|
||||
static int dpad_lock = 0;
|
||||
bool sendPause;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -48,22 +55,9 @@
|
|||
|
||||
void InputState::GetMouseDelta(ControlInfo * info)
|
||||
{
|
||||
vec2f_t input, finput;
|
||||
|
||||
input = g_mousePos;
|
||||
vec2f_t finput = g_mousePos;
|
||||
g_mousePos = {};
|
||||
|
||||
if (in_mousesmoothing)
|
||||
{
|
||||
static vec2f_t last;
|
||||
finput = { (input.x + last.x) * 0.5f, (input.y + last.y) * 0.5f };
|
||||
last = input;
|
||||
}
|
||||
else
|
||||
{
|
||||
finput = { input.x, input.y };
|
||||
}
|
||||
|
||||
info->mousex = finput.x * (16.f / 32.f) * in_mousesensitivity * in_mousescalex / 3.f;
|
||||
info->mousey = finput.y * (16.f / 64.f) * in_mousesensitivity * in_mousescaley;
|
||||
|
||||
|
@ -127,6 +121,9 @@ void InputState::ClearAllInput()
|
|||
{
|
||||
memset(KeyStatus, 0, sizeof(KeyStatus));
|
||||
AnyKeyStatus = false;
|
||||
ActionsToSend = 0;
|
||||
WeaponToSend = 0;
|
||||
dpad_lock = 0;
|
||||
buttonMap.ResetButtonStates(); // this is important. If all input is cleared, the buttons must be cleared as well.
|
||||
gi->clearlocalinputstate(); // also clear game local input state.
|
||||
}
|
||||
|
@ -163,6 +160,9 @@ int32_t handleevents(void)
|
|||
setViewport(hud_size);
|
||||
setsizeneeded = false;
|
||||
}
|
||||
#pragma message ("only for old game loop")
|
||||
twod->SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
|
||||
I_StartFrame();
|
||||
I_StartTic();
|
||||
|
@ -194,3 +194,209 @@ void CONTROL_GetInput(ControlInfo* info)
|
|||
info->dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SetupGameButtons()
|
||||
{
|
||||
static const char* actions[] = {
|
||||
"Move_Forward",
|
||||
"Move_Backward",
|
||||
"Turn_Left",
|
||||
"Turn_Right",
|
||||
"Strafe",
|
||||
"Fire",
|
||||
"Open",
|
||||
"Run",
|
||||
"Alt_Fire",
|
||||
"Jump",
|
||||
"Crouch",
|
||||
"Look_Up",
|
||||
"Look_Down",
|
||||
"Look_Left",
|
||||
"Look_Right",
|
||||
"Strafe_Left",
|
||||
"Strafe_Right",
|
||||
"Aim_Up",
|
||||
"Aim_Down",
|
||||
"Shrink_Screen",
|
||||
"Enlarge_Screen",
|
||||
"Mouse_Aiming",
|
||||
"Dpad_Select",
|
||||
"Dpad_Aiming",
|
||||
"Toggle_Crouch",
|
||||
"Quick_Kick",
|
||||
};
|
||||
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD(slot)
|
||||
{
|
||||
// The max differs between games so we have to handle this here.
|
||||
int max = (g_gameType & GAMEFLAG_PSEXHUMED) || (g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_SHAREWARE)) == (GAMEFLAG_DUKE | GAMEFLAG_SHAREWARE) ? 7 : (g_gameType & GAMEFLAG_BLOOD) ? 12 : 10;
|
||||
if (argv.argc() != 2)
|
||||
{
|
||||
Printf("slot <weaponslot>: select a weapon from the given slot (1-%d)", max);
|
||||
}
|
||||
|
||||
auto slot = atoi(argv[1]);
|
||||
if (slot >= 1 && slot <= max)
|
||||
{
|
||||
WeaponToSend = slot;
|
||||
}
|
||||
}
|
||||
|
||||
CCMD(weapprev)
|
||||
{
|
||||
WeaponToSend = WeaponSel_Prev;
|
||||
}
|
||||
|
||||
CCMD(weapnext)
|
||||
{
|
||||
WeaponToSend = WeaponSel_Next;
|
||||
}
|
||||
|
||||
CCMD(weapalt)
|
||||
{
|
||||
WeaponToSend = WeaponSel_Alt; // Only used by SW - should also be made usable by Blood ans Duke which put multiple weapons in the same slot.
|
||||
}
|
||||
|
||||
CCMD(useitem)
|
||||
{
|
||||
int max = (g_gameType & GAMEFLAG_PSEXHUMED)? 6 : (g_gameType & GAMEFLAG_SW)? 7 : (g_gameType & GAMEFLAG_BLOOD) ? 4 : 5;
|
||||
if (argv.argc() != 2)
|
||||
{
|
||||
Printf("useitem <itemnum>: activates an inventory item (1-%d)", max);
|
||||
}
|
||||
|
||||
auto slot = atoi(argv[1]);
|
||||
if (slot >= 1 && slot <= max)
|
||||
{
|
||||
ActionsToSend |= ESyncBits::FromInt(SB_ITEM_BIT_1 << (slot - 1));
|
||||
}
|
||||
}
|
||||
|
||||
CCMD(invprev)
|
||||
{
|
||||
ActionsToSend |= SB_INVPREV;
|
||||
}
|
||||
|
||||
CCMD(invnext)
|
||||
{
|
||||
ActionsToSend |= SB_INVNEXT;
|
||||
}
|
||||
|
||||
CCMD(invuse)
|
||||
{
|
||||
ActionsToSend |= SB_INVUSE;
|
||||
}
|
||||
|
||||
CCMD(centerview)
|
||||
{
|
||||
ActionsToSend |= SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
CCMD(turnaround)
|
||||
{
|
||||
ActionsToSend |= SB_TURNAROUND;
|
||||
}
|
||||
|
||||
CCMD(holsterweapon)
|
||||
{
|
||||
ActionsToSend |= SB_HOLSTER;
|
||||
}
|
||||
|
||||
CCMD(backoff)
|
||||
{
|
||||
ActionsToSend |= SB_ESCAPE;
|
||||
}
|
||||
|
||||
CCMD(pause)
|
||||
{
|
||||
sendPause = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ApplyGlobalInput(InputPacket& input, ControlInfo *info)
|
||||
{
|
||||
if (WeaponToSend != 0) input.setNewWeapon(WeaponToSend);
|
||||
WeaponToSend = 0;
|
||||
if (info && buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
{
|
||||
// These buttons should not autorepeat. The game handlers are not really equipped for that.
|
||||
if (info->dz > 0 && !(dpad_lock & 1)) { dpad_lock |= 1; input.setNewWeapon(WeaponSel_Prev); }
|
||||
else dpad_lock &= ~1;
|
||||
if (info->dz < 0 && !(dpad_lock & 2)) { dpad_lock |= 2; input.setNewWeapon(WeaponSel_Next); }
|
||||
else dpad_lock &= ~2;
|
||||
if ((info->dx < 0 || info->dyaw < 0) && !(dpad_lock & 4)) { dpad_lock |= 4; input.actions |= SB_INVPREV; }
|
||||
else dpad_lock &= ~4;
|
||||
if ((info->dx > 0 || info->dyaw > 0) && !(dpad_lock & 8)) { dpad_lock |= 8; input.actions |= SB_INVNEXT; }
|
||||
else dpad_lock &= ~8;
|
||||
|
||||
// This eats the controller input for regular use
|
||||
info->dx = 0;
|
||||
info->dz = 0;
|
||||
info->dyaw = 0;
|
||||
}
|
||||
else dpad_lock = 0;
|
||||
|
||||
input.actions |= ActionsToSend;
|
||||
ActionsToSend = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info->dz > 0))
|
||||
input.actions |= SB_AIM_UP;
|
||||
|
||||
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info->dz < 0)))
|
||||
input.actions |= SB_AIM_DOWN;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
info->dz = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Jump))
|
||||
input.actions |= SB_JUMP;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch))
|
||||
input.actions |= SB_CROUCH;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Fire))
|
||||
input.actions |= SB_FIRE;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Alt_Fire))
|
||||
input.actions |= SB_ALTFIRE;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Open))
|
||||
{
|
||||
if (g_gameType & GAMEFLAG_BLOOD) buttonMap.ClearButton(gamefunc_Open);
|
||||
input.actions |= SB_OPEN;
|
||||
}
|
||||
if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)))
|
||||
input.actions |= SB_RUN;
|
||||
|
||||
if (in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming))
|
||||
input.actions |= SB_AIMMODE;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Up))
|
||||
input.actions |= SB_LOOK_UP;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Down))
|
||||
input.actions |= SB_LOOK_DOWN;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Left))
|
||||
input.actions |= SB_LOOK_LEFT;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Right))
|
||||
input.actions |= SB_LOOK_RIGHT;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "d_event.h"
|
||||
#include "m_joy.h"
|
||||
#include "gamecvars.h"
|
||||
#include "packet.h"
|
||||
|
||||
|
||||
struct ControlInfo
|
||||
|
@ -62,3 +63,38 @@ extern InputState inputState;
|
|||
|
||||
void CONTROL_GetInput(ControlInfo* info);
|
||||
int32_t handleevents(void);
|
||||
|
||||
enum GameFunction_t
|
||||
{
|
||||
gamefunc_Move_Forward, //
|
||||
gamefunc_Move_Backward, //
|
||||
gamefunc_Turn_Left, //
|
||||
gamefunc_Turn_Right, //
|
||||
gamefunc_Strafe, //
|
||||
gamefunc_Fire,
|
||||
gamefunc_Open,
|
||||
gamefunc_Run,
|
||||
gamefunc_Alt_Fire,
|
||||
gamefunc_Jump,
|
||||
gamefunc_Crouch,
|
||||
gamefunc_Look_Up,
|
||||
gamefunc_Look_Down,
|
||||
gamefunc_Look_Left,
|
||||
gamefunc_Look_Right,
|
||||
gamefunc_Strafe_Left, //
|
||||
gamefunc_Strafe_Right, //
|
||||
gamefunc_Aim_Up,
|
||||
gamefunc_Aim_Down,
|
||||
gamefunc_Shrink_Screen, // Automap only
|
||||
gamefunc_Enlarge_Screen, // Automap only
|
||||
gamefunc_Mouse_Aiming,
|
||||
gamefunc_Dpad_Select,
|
||||
gamefunc_Dpad_Aiming,
|
||||
gamefunc_Toggle_Crouch,
|
||||
gamefunc_Quick_Kick,
|
||||
NUM_ACTIONS
|
||||
};
|
||||
|
||||
void SetupGameButtons();
|
||||
void ApplyGlobalInput(InputPacket& input, ControlInfo *info);
|
||||
extern ESyncBits ActionsToSend;
|
539
source/core/mainloop.cpp
Normal file
539
source/core/mainloop.cpp
Normal file
|
@ -0,0 +1,539 @@
|
|||
/*
|
||||
** mainloop.cpp
|
||||
** Implements the main game loop
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2020 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
// For G_Ticker and TryRunTics the following applies:
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright 1999-2016 Randy Heit
|
||||
// Copyright 2002-2020 Christoph Oelckers
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
// $Log:$
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// DOOM Network game communication and protocol,
|
||||
// all OS independent parts.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include "c_cvars.h"
|
||||
#include "i_time.h"
|
||||
#include "d_net.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "c_console.h"
|
||||
#include "menu.h"
|
||||
#include "i_system.h"
|
||||
#include "raze_sound.h"
|
||||
#include "raze_music.h"
|
||||
#include "vm.h"
|
||||
#include "gamestate.h"
|
||||
#include "screenjob.h"
|
||||
#include "mmulti.h"
|
||||
#include "c_console.h"
|
||||
#include "menu.h"
|
||||
#include "uiinput.h"
|
||||
#include "v_video.h"
|
||||
#include "glbackend/glbackend.h"
|
||||
#include "palette.h"
|
||||
#include "build.h"
|
||||
#include "g_input.h"
|
||||
|
||||
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, cl_capfps, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
ticcmd_t playercmds[MAXPLAYERS];
|
||||
|
||||
static uint64_t stabilityticduration = 0;
|
||||
static uint64_t stabilitystarttime = 0;
|
||||
|
||||
bool pauseext;
|
||||
bool r_NoInterpolate;
|
||||
int entertic;
|
||||
int oldentertics;
|
||||
int gametic;
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void G_BuildTiccmd(ticcmd_t* cmd)
|
||||
{
|
||||
I_GetEvent();
|
||||
gi->GetInput(&cmd->ucmd);
|
||||
cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS];
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static void GameTicker()
|
||||
{
|
||||
int i;
|
||||
|
||||
handleevents();
|
||||
|
||||
#if 0
|
||||
// Todo: Migrate state changes to here instead of doing them ad-hoc
|
||||
while (gameaction != ga_nothing)
|
||||
{
|
||||
switch (gameaction)
|
||||
{
|
||||
}
|
||||
C_AdjustBottom();
|
||||
}
|
||||
#endif
|
||||
|
||||
// get commands, check consistancy, and build new consistancy check
|
||||
int buf = (gametic / ticdup) % BACKUPTICS;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i])
|
||||
{
|
||||
ticcmd_t* cmd = &playercmds[i];
|
||||
ticcmd_t* newcmd = &netcmds[i][buf];
|
||||
|
||||
if ((gametic % ticdup) == 0)
|
||||
{
|
||||
RunNetSpecs(i, buf);
|
||||
}
|
||||
#if 0
|
||||
if (demorecording)
|
||||
{
|
||||
G_WriteDemoTiccmd(newcmd, i, buf);
|
||||
}
|
||||
if (demoplayback)
|
||||
{
|
||||
G_ReadDemoTiccmd(cmd, i);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
*cmd = *newcmd;
|
||||
}
|
||||
|
||||
|
||||
if (netgame && /*!demoplayback &&*/ (gametic % ticdup) == 0)
|
||||
{
|
||||
#if 0
|
||||
//players[i].inconsistant = 0;
|
||||
if (gametic > BACKUPTICS * ticdup && consistancy[i][buf] != cmd->consistancy)
|
||||
{
|
||||
players[i].inconsistant = gametic - BACKUPTICS * ticdup;
|
||||
}
|
||||
#endif
|
||||
consistancy[i][buf] = gi->GetPlayerChecksum(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
C_RunDelayedCommands();
|
||||
updatePauseStatus();
|
||||
|
||||
switch (gamestate)
|
||||
{
|
||||
default:
|
||||
case GS_STARTUP:
|
||||
artClearMapArt();
|
||||
gi->Startup();
|
||||
break;
|
||||
|
||||
case GS_LEVEL:
|
||||
gameupdatetime.Reset();
|
||||
gameupdatetime.Clock();
|
||||
gameclock = I_GetBuildTime() - gameclockstart;
|
||||
gi->Ticker();
|
||||
gameupdatetime.Unclock();
|
||||
break;
|
||||
|
||||
case GS_MENUSCREEN:
|
||||
case GS_FULLCONSOLE:
|
||||
case GS_INTERMISSION:
|
||||
case GS_INTRO:
|
||||
// These elements do not tick at game rate.
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Display
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void Display()
|
||||
{
|
||||
if (screen == nullptr || !AppActive && (screen->IsFullscreen() || !vid_activeinbackground))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
screen->FrameTime = I_msTimeFS();
|
||||
screen->BeginFrame();
|
||||
twodpsp.ClearClipRect();
|
||||
twod->ClearClipRect();
|
||||
switch (gamestate)
|
||||
{
|
||||
case GS_MENUSCREEN:
|
||||
gi->DrawBackground();
|
||||
break;
|
||||
|
||||
case GS_INTRO:
|
||||
case GS_INTERMISSION:
|
||||
// screen jobs are not bound by the game ticker so they need to be ticked in the display loop.
|
||||
RunScreenJobFrame();
|
||||
break;
|
||||
|
||||
case GS_LEVEL:
|
||||
if (gametic != 0)
|
||||
{
|
||||
screen->BeginFrame();
|
||||
screen->SetSceneRenderTarget(gl_ssao != 0);
|
||||
twodpsp.Clear();
|
||||
twod->Clear();
|
||||
twod->SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
gameclock = I_GetBuildTime() - gameclockstart;
|
||||
gi->Render();
|
||||
DrawFullscreenBlends();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
NetUpdate(); // send out any new accumulation
|
||||
|
||||
if (gamestate != GS_INTRO) // do not draw overlays on the intros
|
||||
{
|
||||
// Draw overlay elements
|
||||
CT_Drawer();
|
||||
C_DrawConsole();
|
||||
M_Drawer();
|
||||
FStat::PrintStat(twod);
|
||||
DrawRateStuff();
|
||||
}
|
||||
|
||||
videoShowFrame(1);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Forces playsim processing time to be consistent across frames.
|
||||
// This improves interpolation for frames in between tics.
|
||||
//
|
||||
// With this cvar off the mods with a high playsim processing time will appear
|
||||
// less smooth as the measured time used for interpolation will vary.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static void TicStabilityWait()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace std::this_thread;
|
||||
|
||||
if (!r_ticstability)
|
||||
return;
|
||||
|
||||
uint64_t start = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
while (true)
|
||||
{
|
||||
uint64_t cur = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
if (cur - start > stabilityticduration)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void TicStabilityBegin()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
stabilitystarttime = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
static void TicStabilityEnd()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
uint64_t stabilityendtime = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
stabilityticduration = std::min(stabilityendtime - stabilitystarttime, (uint64_t)1'000'000);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// The most important function in the engine.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void TryRunTics (void)
|
||||
{
|
||||
int i;
|
||||
int lowtic;
|
||||
int realtics;
|
||||
int availabletics;
|
||||
int counts;
|
||||
int numplaying;
|
||||
|
||||
// If paused, do not eat more CPU time than we need, because it
|
||||
// will all be wasted anyway.
|
||||
if (pauseext)
|
||||
r_NoInterpolate = true;
|
||||
bool doWait = cl_capfps || r_NoInterpolate;
|
||||
|
||||
// get real tics
|
||||
if (doWait)
|
||||
{
|
||||
entertic = I_WaitForTic (oldentertics);
|
||||
}
|
||||
else
|
||||
{
|
||||
entertic = I_GetTime ();
|
||||
}
|
||||
realtics = entertic - oldentertics;
|
||||
oldentertics = entertic;
|
||||
|
||||
// get available tics
|
||||
NetUpdate ();
|
||||
|
||||
if (pauseext)
|
||||
return;
|
||||
|
||||
lowtic = INT_MAX;
|
||||
numplaying = 0;
|
||||
for (i = 0; i < doomcom.numnodes; i++)
|
||||
{
|
||||
if (nodeingame[i])
|
||||
{
|
||||
numplaying++;
|
||||
if (nettics[i] < lowtic)
|
||||
lowtic = nettics[i];
|
||||
}
|
||||
}
|
||||
|
||||
availabletics = lowtic - gametic / ticdup;
|
||||
|
||||
// decide how many tics to run
|
||||
if (realtics < availabletics-1)
|
||||
counts = realtics+1;
|
||||
else if (realtics < availabletics)
|
||||
counts = realtics;
|
||||
else
|
||||
counts = availabletics;
|
||||
|
||||
// Uncapped framerate needs seprate checks
|
||||
if (counts == 0 && !doWait)
|
||||
{
|
||||
TicStabilityWait();
|
||||
|
||||
// Check possible stall conditions
|
||||
Net_CheckLastReceived(counts);
|
||||
if (realtics >= 1)
|
||||
{
|
||||
C_Ticker();
|
||||
M_Ticker();
|
||||
// Repredict the player for new buffered movement
|
||||
#if 0
|
||||
gi->Unpredict();
|
||||
gi->Predict(myconnectindex);
|
||||
#endif
|
||||
}
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
I_GetEvent();
|
||||
gi->GetInput(nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (counts < 1)
|
||||
counts = 1;
|
||||
|
||||
// wait for new tics if needed
|
||||
while (lowtic < gametic + counts)
|
||||
{
|
||||
NetUpdate ();
|
||||
lowtic = INT_MAX;
|
||||
|
||||
for (i = 0; i < doomcom.numnodes; i++)
|
||||
if (nodeingame[i] && nettics[i] < lowtic)
|
||||
lowtic = nettics[i];
|
||||
|
||||
lowtic = lowtic * ticdup;
|
||||
|
||||
if (lowtic < gametic)
|
||||
I_Error ("TryRunTics: lowtic < gametic");
|
||||
|
||||
// Check possible stall conditions
|
||||
Net_CheckLastReceived (counts);
|
||||
|
||||
// Update time returned by I_GetTime, but only if we are stuck in this loop
|
||||
if (lowtic < gametic + counts)
|
||||
I_SetFrameTime();
|
||||
|
||||
// don't stay in here forever -- give the menu a chance to work
|
||||
if (I_GetTime () - entertic >= 1)
|
||||
{
|
||||
C_Ticker ();
|
||||
M_Ticker ();
|
||||
// Repredict the player for new buffered movement
|
||||
#if 0
|
||||
gi->Unpredict();
|
||||
gi->Predict(myconnectindex);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Tic lowtic is high enough to process this gametic. Clear all possible waiting info
|
||||
hadlate = false;
|
||||
#if 0
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
players[i].waiting = false;
|
||||
#endif
|
||||
lastglobalrecvtime = I_GetTime (); //Update the last time the game tic'd over
|
||||
|
||||
// run the count tics
|
||||
if (counts > 0)
|
||||
{
|
||||
#if 0
|
||||
gi->Unpredict();
|
||||
#endif
|
||||
while (counts--)
|
||||
{
|
||||
TicStabilityBegin();
|
||||
if (gametic > lowtic)
|
||||
{
|
||||
I_Error ("gametic>lowtic");
|
||||
}
|
||||
#if 0
|
||||
if (advancedemo)
|
||||
{
|
||||
D_DoAdvanceDemo ();
|
||||
}
|
||||
#endif
|
||||
C_Ticker ();
|
||||
M_Ticker ();
|
||||
GameTicker();
|
||||
gametic++;
|
||||
|
||||
NetUpdate (); // check for new console commands
|
||||
TicStabilityEnd();
|
||||
}
|
||||
#if 0
|
||||
gi->Predict(myconnectindex);
|
||||
#endif
|
||||
gi->UpdateSounds();
|
||||
soundEngine->UpdateSounds(I_GetTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
TicStabilityWait();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// MainLoop - will never return aside from exceptions being thrown.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void MainLoop ()
|
||||
{
|
||||
int lasttic = 0;
|
||||
|
||||
// Clamp the timer to TICRATE until the playloop has been entered.
|
||||
r_NoInterpolate = true;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
// frame syncronous IO operations
|
||||
if (gametic > lasttic)
|
||||
{
|
||||
lasttic = gametic;
|
||||
I_StartFrame ();
|
||||
}
|
||||
I_SetFrameTime();
|
||||
|
||||
TryRunTics (); // will run at least one tic
|
||||
// Update display, next frame, with current state.
|
||||
I_StartTic();
|
||||
|
||||
Display();
|
||||
Mus_UpdateMusic(); // must be at the end.
|
||||
}
|
||||
catch (CRecoverableError &error)
|
||||
{
|
||||
if (error.GetMessage ())
|
||||
{
|
||||
Printf (PRINT_BOLD, "\n%s\n", error.GetMessage());
|
||||
}
|
||||
gi->ErrorCleanup();
|
||||
C_FullConsole();
|
||||
}
|
||||
catch (CVMAbortException &error)
|
||||
{
|
||||
error.MaybePrintMessage();
|
||||
Printf("%s", error.stacktrace.GetChars());
|
||||
gi->ErrorCleanup();
|
||||
C_FullConsole();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,168 +4,69 @@
|
|||
#include "fix16.h"
|
||||
#include "tflags.h"
|
||||
|
||||
|
||||
// Blood flags
|
||||
enum
|
||||
{
|
||||
flag_buttonmask = 127,
|
||||
flag_buttonmask_norun = 126
|
||||
};
|
||||
|
||||
|
||||
enum ESyncBits_ : uint32_t
|
||||
{
|
||||
SKB_JUMP = 1 << 0,
|
||||
SKB_CROUCH = 1 << 1,
|
||||
SKB_FIRE = 1 << 2,
|
||||
SKB_AIM_UP = 1 << 3,
|
||||
SKB_AIM_DOWN = 1 << 4,
|
||||
SKB_RUN = 1 << 5,
|
||||
SKB_LOOK_LEFT = 1 << 6,
|
||||
SKB_LOOK_RIGHT = 1 << 7,
|
||||
SKB_FIRST_WEAPON_BIT = 1 << 8,
|
||||
SKB_STEROIDS = 1 << 12,
|
||||
SKB_LOOK_UP = 1 << 13,
|
||||
SKB_LOOK_DOWN = 1 << 14,
|
||||
SKB_NIGHTVISION = 1 << 15,
|
||||
SKB_MEDKIT = 1 << 16,
|
||||
SKB_MULTIFLAG = 1 << 17,
|
||||
SKB_CENTER_VIEW = 1 << 18,
|
||||
SKB_HOLSTER = 1 << 19,
|
||||
SKB_INV_LEFT = 1 << 20,
|
||||
SKB_PAUSE = 1 << 21,
|
||||
SKB_QUICK_KICK = 1 << 22,
|
||||
SKB_AIMMODE = 1 << 23,
|
||||
SKB_HOLODUKE = 1 << 24,
|
||||
SKB_JETPACK = 1 << 25,
|
||||
SKB_GAMEQUIT = 1 << 26,
|
||||
SKB_INV_RIGHT = 1 << 27,
|
||||
SKB_TURNAROUND = 1 << 28,
|
||||
SKB_OPEN = 1 << 29,
|
||||
SKB_INVENTORY = 1 << 30,
|
||||
SKB_ESCAPE = 1u << 31,
|
||||
SB_FIRST_WEAPON_BIT = 1 << 0,
|
||||
SB_ITEM_BIT_1 = 1 << 4,
|
||||
SB_ITEM_BIT_2 = 1 << 5,
|
||||
SB_ITEM_BIT_3 = 1 << 6,
|
||||
SB_ITEM_BIT_4 = 1 << 7,
|
||||
SB_ITEM_BIT_5 = 1 << 8,
|
||||
SB_ITEM_BIT_6 = 1 << 9,
|
||||
SB_ITEM_BIT_7 = 1 << 10,
|
||||
|
||||
SKB_WEAPONMASK_BITS = (15u * SKB_FIRST_WEAPON_BIT),
|
||||
SKB_INTERFACE_BITS = (SKB_WEAPONMASK_BITS | SKB_STEROIDS | SKB_NIGHTVISION | SKB_MEDKIT | SKB_QUICK_KICK | \
|
||||
SKB_HOLSTER | SKB_INV_LEFT | SKB_PAUSE | SKB_HOLODUKE | SKB_JETPACK | SKB_INV_RIGHT | \
|
||||
SKB_TURNAROUND | SKB_OPEN | SKB_INVENTORY | SKB_ESCAPE),
|
||||
SB_INVPREV = 1 << 11,
|
||||
SB_INVNEXT = 1 << 12,
|
||||
SB_INVUSE = 1 << 13,
|
||||
SB_CENTERVIEW = 1 << 14,
|
||||
SB_TURNAROUND = 1 << 15,
|
||||
SB_HOLSTER = 1 << 16,
|
||||
SB_OPEN = 1 << 17,
|
||||
|
||||
SKB_NONE = 0,
|
||||
SKB_ALL = ~0u
|
||||
SB_AIMMODE = 1 << 18,
|
||||
SB_QUICK_KICK = 1 << 19, // Duke only.
|
||||
SB_CROUCH_LOCK = 1 << 19, // SW only.
|
||||
SB_ESCAPE = 1 << 20,
|
||||
|
||||
SB_AIM_UP = 1 << 21,
|
||||
SB_AIM_DOWN = 1 << 22,
|
||||
SB_LOOK_LEFT = 1 << 23,
|
||||
SB_LOOK_RIGHT = 1 << 24,
|
||||
SB_LOOK_UP = 1 << 25,
|
||||
SB_LOOK_DOWN = 1 << 26,
|
||||
SB_RUN = 1 << 27,
|
||||
SB_JUMP = 1 << 28,
|
||||
SB_CROUCH = 1 << 29,
|
||||
SB_FIRE = 1 << 30,
|
||||
SB_ALTFIRE = 1u << 31,
|
||||
|
||||
SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits
|
||||
SB_ITEMUSE_BITS = (127u * SB_ITEM_BIT_1),
|
||||
|
||||
SB_BUTTON_MASK = SB_ALTFIRE|SB_FIRE|SB_CROUCH|SB_JUMP|SB_LOOK_UP|SB_LOOK_DOWN|SB_AIM_UP|SB_AIM_DOWN|SB_LOOK_LEFT|SB_LOOK_RIGHT, // all input from buttons (i.e. active while held)
|
||||
SB_INTERFACE_MASK = (SB_INVPREV|SB_INVNEXT|SB_INVUSE|SB_CENTERVIEW|SB_TURNAROUND|SB_HOLSTER|SB_OPEN|SB_ESCAPE|SB_QUICK_KICK), // all input from CCMDs
|
||||
SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_ITEMUSE_BITS | SB_INTERFACE_MASK),
|
||||
SB_ALL = ~0u
|
||||
};
|
||||
|
||||
// enforce type safe operations on the input bits.
|
||||
using ESyncBits = TFlags<ESyncBits_, uint32_t>;
|
||||
DEFINE_TFLAGS_OPERATORS(ESyncBits)
|
||||
|
||||
union SYNCFLAGS
|
||||
|
||||
enum
|
||||
{
|
||||
uint32_t value;
|
||||
struct
|
||||
{
|
||||
unsigned int run : 1;
|
||||
unsigned int jump : 1;
|
||||
unsigned int crouch : 1;
|
||||
unsigned int shoot : 1;
|
||||
unsigned int shoot2 : 1;
|
||||
unsigned int lookUp : 1;
|
||||
unsigned int lookDown : 1;
|
||||
unsigned int action : 1;
|
||||
unsigned int jab : 1;
|
||||
unsigned int prevItem : 1;
|
||||
unsigned int nextItem : 1;
|
||||
unsigned int useItem : 1;
|
||||
unsigned int prevWeapon : 1;
|
||||
unsigned int nextWeapon : 1;
|
||||
unsigned int holsterWeapon : 1;
|
||||
unsigned int lookCenter : 1;
|
||||
unsigned int lookLeft : 1;
|
||||
unsigned int lookRight : 1;
|
||||
unsigned int spin180 : 1;
|
||||
unsigned int pause : 1;
|
||||
unsigned int quit : 1;
|
||||
unsigned int restart : 1;
|
||||
unsigned int useBeastVision : 1;
|
||||
unsigned int useCrystalBall : 1;
|
||||
unsigned int useJumpBoots : 1;
|
||||
unsigned int useMedKit : 1;
|
||||
unsigned int newWeapon : 4;
|
||||
// The maximum valid weapons for the respective games.
|
||||
WeaponSel_Max = 10,
|
||||
WeaponSel_MaxExhumed = 7,
|
||||
WeaponSel_MaxBlood = 12,
|
||||
|
||||
// Use named constants instead of magic values for these. The maximum of the supported games is 12 weapons for Blood so these 3 are free.
|
||||
// Should there ever be need for more weapons to select, the bit field needs to be expanded.
|
||||
WeaponSel_Next = 13,
|
||||
WeaponSel_Prev = 14,
|
||||
WeaponSel_Alt = 15
|
||||
};
|
||||
};
|
||||
|
||||
// SW
|
||||
|
||||
//
|
||||
// NETWORK - REDEFINABLE SHARED (SYNC) KEYS BIT POSITIONS
|
||||
//
|
||||
|
||||
// weapons takes up 4 bits
|
||||
#define SK_WEAPON_BIT0 0
|
||||
#define SK_WEAPON_BIT1 1
|
||||
#define SK_WEAPON_BIT2 2
|
||||
#define SK_WEAPON_BIT3 3
|
||||
#define SK_WEAPON_MASK (BIT(SK_WEAPON_BIT0)| \
|
||||
BIT(SK_WEAPON_BIT1)| \
|
||||
BIT(SK_WEAPON_BIT2)| \
|
||||
BIT(SK_WEAPON_BIT3)) // 16 possible numbers 0-15
|
||||
|
||||
#define SK_INV_HOTKEY_BIT0 4
|
||||
#define SK_INV_HOTKEY_BIT1 5
|
||||
#define SK_INV_HOTKEY_BIT2 6
|
||||
#define SK_INV_HOTKEY_MASK (BIT(SK_INV_HOTKEY_BIT0)|BIT(SK_INV_HOTKEY_BIT1)|BIT(SK_INV_HOTKEY_BIT2))
|
||||
|
||||
#define SK_AUTO_AIM 7
|
||||
#define SK_CENTER_VIEW 8
|
||||
#define SK_PAUSE 9
|
||||
|
||||
#define SK_MESSAGE 11
|
||||
#define SK_LOOK_UP 12
|
||||
#define SK_LOOK_DOWN 13
|
||||
#define SK_CRAWL_LOCK 14
|
||||
#define SK_FLY 15
|
||||
|
||||
#define SK_RUN 16
|
||||
#define SK_SHOOT 17
|
||||
#define SK_OPERATE 18
|
||||
#define SK_JUMP 19
|
||||
#define SK_CRAWL 20
|
||||
#define SK_SNAP_UP 21
|
||||
#define SK_SNAP_DOWN 22
|
||||
#define SK_QUIT_GAME 23
|
||||
|
||||
#define SK_MULTI_VIEW 24
|
||||
|
||||
#define SK_TURN_180 25
|
||||
|
||||
#define SK_INV_LEFT 26
|
||||
#define SK_INV_RIGHT 27
|
||||
|
||||
#define SK_INV_USE 29
|
||||
#define SK_HIDE_WEAPON 30
|
||||
#define SK_SPACE_BAR 31
|
||||
|
||||
|
||||
// Exhumed
|
||||
|
||||
enum {
|
||||
kButtonJump = 0x1,
|
||||
kButtonOpen = 0x4,
|
||||
kButtonFire = 0x8,
|
||||
kButtonCrouch = 0x10,
|
||||
kButtonCheatGuns = 0x20,
|
||||
kButtonCheatGodMode = 0x40,
|
||||
kButtonCheatKeys = 0x80,
|
||||
kButtonCheatItems = 0x100,
|
||||
|
||||
kButtonWeaponShift = 13,
|
||||
kButtonWeaponBits = 7 << kButtonWeaponShift, // upper 3 bits.
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct InputPacket
|
||||
{
|
||||
|
@ -175,17 +76,34 @@ struct InputPacket
|
|||
fix16_t q16horz;
|
||||
fix16_t q16horiz; // only used by SW
|
||||
fix16_t q16ang; // only used by SW
|
||||
ESyncBits actions;
|
||||
|
||||
// Making this a union lets some constructs fail. Since these names are transitional only the added memory use doesn't really matter.
|
||||
// for Duke
|
||||
ESyncBits sbits;
|
||||
|
||||
// for SW
|
||||
int32_t bits;
|
||||
int getNewWeapon() const
|
||||
{
|
||||
return (actions & SB_WEAPONMASK_BITS).GetValue();
|
||||
}
|
||||
|
||||
// for Blood
|
||||
SYNCFLAGS syncFlags;
|
||||
void setNewWeapon(int weap)
|
||||
{
|
||||
actions = (actions & ~SB_WEAPONMASK_BITS) | (ESyncBits::FromInt(weap) & SB_WEAPONMASK_BITS);
|
||||
}
|
||||
|
||||
bool isItemUsed(int num)
|
||||
{
|
||||
return !!(actions & ESyncBits::FromInt(SB_ITEM_BIT_1 << num));
|
||||
}
|
||||
|
||||
void setItemUsed(int num)
|
||||
{
|
||||
actions |= ESyncBits::FromInt(SB_ITEM_BIT_1 << num);
|
||||
}
|
||||
|
||||
void clearItemUsed(int num)
|
||||
{
|
||||
actions &= ~ESyncBits::FromInt(SB_ITEM_BIT_1 << num);
|
||||
}
|
||||
|
||||
// For Exhumed
|
||||
uint16_t buttons;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -186,5 +186,6 @@ extern glblend_t glblend[MAXBLENDTABS];
|
|||
FRenderStyle GetRenderStyle(int blend, int def);
|
||||
extern void SetRenderStyleFromBlend(uint8_t enable, uint8_t blend, uint8_t def);
|
||||
float GetAlphaFromBlend(uint32_t maskprops, uint32_t blend);
|
||||
void DrawFullscreenBlends();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -82,6 +82,8 @@ const char *GetVersionString();
|
|||
#define SAVEVER_SW 7
|
||||
#define SAVEVER_PS 6
|
||||
|
||||
#define NETGAMEVERSION 1
|
||||
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
#define GAME_DIR GAMENAME
|
||||
#else
|
||||
|
|
|
@ -45,10 +45,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "screenjob.h"
|
||||
#include "c_console.h"
|
||||
#include "cheathandler.h"
|
||||
#include "inputstate.h"
|
||||
#include "core/menu/menu.h"
|
||||
|
||||
BEGIN_PS_NS
|
||||
|
||||
extern short bPlayerPan;
|
||||
extern short bLockPan;
|
||||
|
||||
extern const char* s_buildRev;
|
||||
extern const char* s_buildTimestamp;
|
||||
|
@ -56,10 +59,8 @@ BEGIN_PS_NS
|
|||
|
||||
void uploadCinemaPalettes();
|
||||
int32_t registerosdcommands(void);
|
||||
void registerinputcommands();
|
||||
void InitFonts();
|
||||
|
||||
int htimer = 0;
|
||||
int EndLevel = false;
|
||||
|
||||
|
||||
|
@ -84,9 +85,6 @@ void InstallEngine()
|
|||
uploadCinemaPalettes();
|
||||
LoadPaletteLookups();
|
||||
InitFonts();
|
||||
videoInit();
|
||||
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19950829;
|
||||
}
|
||||
|
||||
void RemoveEngine()
|
||||
|
@ -435,6 +433,23 @@ void GameMove(void)
|
|||
totalmoves++;
|
||||
}
|
||||
|
||||
static int SelectNextWeapon(int weap2)
|
||||
{
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SelectPrevWeapon(int weap2)
|
||||
{
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SelectAltWeapon(int weap2)
|
||||
{
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GameTicker()
|
||||
{
|
||||
|
@ -454,8 +469,7 @@ void GameTicker()
|
|||
{
|
||||
lastTic = currentTic;
|
||||
|
||||
int lLocalButtons = GetLocalInput(); // shouldn't this be placed in localInput?
|
||||
PlayerInterruptKeys();
|
||||
PlayerInterruptKeys(false);
|
||||
|
||||
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.q16avel);
|
||||
inita &= kAngleMask;
|
||||
|
@ -467,12 +481,98 @@ void GameTicker()
|
|||
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
|
||||
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
|
||||
}
|
||||
int weap2 = localInput.getNewWeapon();
|
||||
if (weap2 == WeaponSel_Next)
|
||||
{
|
||||
weap2 = SelectNextWeapon(weap2);
|
||||
}
|
||||
else if (weap2 == WeaponSel_Prev)
|
||||
{
|
||||
weap2 = SelectPrevWeapon(weap2);
|
||||
}
|
||||
else if (weap2 == WeaponSel_Alt)
|
||||
{
|
||||
weap2 = SelectAltWeapon(weap2);
|
||||
}
|
||||
|
||||
if (localInput.actions & SB_INVPREV)
|
||||
{
|
||||
int nItem = nPlayerItem[nLocalPlayer];
|
||||
|
||||
int i;
|
||||
for (i = 6; i > 0; i--)
|
||||
{
|
||||
nItem--;
|
||||
if (nItem < 0) nItem = 5;
|
||||
|
||||
if (PlayerList[nLocalPlayer].items[nItem] != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > 0) SetPlayerItem(nLocalPlayer, nItem);
|
||||
}
|
||||
|
||||
if (localInput.actions & SB_INVNEXT)
|
||||
{
|
||||
int nItem = nPlayerItem[nLocalPlayer];
|
||||
|
||||
int i;
|
||||
for (i = 6; i > 0; i--)
|
||||
{
|
||||
nItem++;
|
||||
if (nItem == 6) nItem = 0;
|
||||
|
||||
if (PlayerList[nLocalPlayer].items[nItem] != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > 0) SetPlayerItem(nLocalPlayer, nItem);
|
||||
}
|
||||
|
||||
if (localInput.actions & SB_INVUSE)
|
||||
{
|
||||
if (nPlayerItem[nLocalPlayer] != -1)
|
||||
{
|
||||
localInput.setItemUsed(nPlayerItem[nLocalPlayer]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (localInput.isItemUsed(i))
|
||||
{
|
||||
localInput.clearItemUsed(i);
|
||||
if (PlayerList[nLocalPlayer].items[i] > 0)
|
||||
{
|
||||
if (nItemMagic[i] <= PlayerList[nLocalPlayer].nMagic)
|
||||
{
|
||||
sPlayerInput[nLocalPlayer].nItem = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (localInput.actions & SB_CENTERVIEW)
|
||||
{
|
||||
bLockPan = false;
|
||||
bPlayerPan = false;
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92);
|
||||
nDestVertPan[nLocalPlayer] = fix16_from_int(92);
|
||||
}
|
||||
if (localInput.actions & SB_TURNAROUND)
|
||||
{
|
||||
// todo
|
||||
}
|
||||
|
||||
|
||||
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
|
||||
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
|
||||
// make weapon selection persist until it gets used up.
|
||||
if ((lLocalButtons & kButtonWeaponBits) == 0) lLocalButtons |= sPlayerInput[nLocalPlayer].buttons & kButtonWeaponBits;
|
||||
sPlayerInput[nLocalPlayer].buttons = lLocalButtons | lLocalCodes;
|
||||
sPlayerInput[nLocalPlayer].buttons = lLocalCodes;
|
||||
int weap = sPlayerInput[nLocalPlayer].getNewWeapon();
|
||||
sPlayerInput[nLocalPlayer].actions = localInput.actions;
|
||||
if (weap2 <= 0 || weap2 > 7) sPlayerInput[nLocalPlayer].SetNewWeapon(weap);
|
||||
sPlayerInput[nLocalPlayer].nTarget = besttarget;
|
||||
|
||||
Ra[nLocalPlayer].nTarget = besttarget;
|
||||
|
@ -501,57 +601,12 @@ void ExitGame()
|
|||
throw CExitEvent(0);
|
||||
}
|
||||
|
||||
void InitTimer()
|
||||
{
|
||||
htimer = 1;
|
||||
}
|
||||
|
||||
static const char* actions[] =
|
||||
{
|
||||
"Move_Forward",
|
||||
"Move_Backward",
|
||||
"Turn_Left",
|
||||
"Turn_Right",
|
||||
"Strafe",
|
||||
"Fire",
|
||||
"Open",
|
||||
"Run",
|
||||
"Alt_Fire", // Duke3D", Blood
|
||||
"Jump",
|
||||
"Crouch",
|
||||
"Look_Up",
|
||||
"Look_Down",
|
||||
"Look_Left",
|
||||
"Look_Right",
|
||||
"Strafe_Left",
|
||||
"Strafe_Right",
|
||||
"Aim_Up",
|
||||
"Aim_Down",
|
||||
"SendMessage",
|
||||
"Shrink_Screen",
|
||||
"Enlarge_Screen",
|
||||
"Show_Opponents_Weapon",
|
||||
"See_Coop_View",
|
||||
"Mouse_Aiming",
|
||||
"Dpad_Select",
|
||||
"Dpad_Aiming",
|
||||
"Last_Weapon",
|
||||
"Alt_Weapon",
|
||||
"Third_Person_View",
|
||||
"Toggle_Crouch", // This is the last one used by EDuke32.
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
int i;
|
||||
//int esi = 1;
|
||||
//int edi = esi;
|
||||
|
||||
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
||||
|
||||
help_disabled = true;
|
||||
// Create the global level table. Parts of the engine need it, even though the game itself does not.
|
||||
for (int i = 0; i <= 32; i++)
|
||||
|
@ -569,7 +624,6 @@ void GameInterface::app_init()
|
|||
|
||||
SetCheats(excheats, countof(excheats));
|
||||
registerosdcommands();
|
||||
registerinputcommands();
|
||||
if (nNetPlayerCount == -1)
|
||||
{
|
||||
nNetPlayerCount = nCfgNetPlayers - 1;
|
||||
|
@ -587,22 +641,18 @@ void GameInterface::app_init()
|
|||
Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime);
|
||||
}
|
||||
|
||||
|
||||
enginePostInit();
|
||||
|
||||
InitView();
|
||||
InitFX();
|
||||
seq_LoadSequences();
|
||||
InitStatus();
|
||||
InitTimer();
|
||||
|
||||
for (i = 0; i < kMaxPlayers; i++) {
|
||||
nPlayerLives[i] = kDefaultLives;
|
||||
}
|
||||
|
||||
ResetEngine();
|
||||
ResetView();
|
||||
resettiming();
|
||||
GrabPalette();
|
||||
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19950829;
|
||||
}
|
||||
|
||||
void mychangespritesect(int nSprite, int nSector)
|
||||
|
|
|
@ -35,43 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_PS_NS
|
||||
|
||||
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
|
||||
enum GameFunction_t
|
||||
{
|
||||
gamefunc_Move_Forward,
|
||||
gamefunc_Move_Backward,
|
||||
gamefunc_Turn_Left,
|
||||
gamefunc_Turn_Right,
|
||||
gamefunc_Strafe,
|
||||
gamefunc_Fire,
|
||||
gamefunc_Open,
|
||||
gamefunc_Run,
|
||||
gamefunc_Alt_Fire, // Duke3D, Blood
|
||||
gamefunc_Jump,
|
||||
gamefunc_Crouch,
|
||||
gamefunc_Look_Up,
|
||||
gamefunc_Look_Down,
|
||||
gamefunc_Look_Left,
|
||||
gamefunc_Look_Right,
|
||||
gamefunc_Strafe_Left,
|
||||
gamefunc_Strafe_Right,
|
||||
gamefunc_Aim_Up,
|
||||
gamefunc_Aim_Down,
|
||||
gamefunc_SendMessage,
|
||||
gamefunc_Shrink_Screen,
|
||||
gamefunc_Enlarge_Screen,
|
||||
gamefunc_Show_Opponents_Weapon,
|
||||
gamefunc_See_Coop_View,
|
||||
gamefunc_Mouse_Aiming,
|
||||
gamefunc_Dpad_Select,
|
||||
gamefunc_Dpad_Aiming,
|
||||
gamefunc_Last_Weapon,
|
||||
gamefunc_Alt_Weapon,
|
||||
gamefunc_Third_Person_View,
|
||||
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
|
||||
NUM_ACTIONS,
|
||||
|
||||
};
|
||||
|
||||
#define kTimerTicks 120
|
||||
|
||||
|
@ -122,12 +85,10 @@ void StatusMessage(int messageTime, const char *fmt, ...);
|
|||
|
||||
int DoSpiritHead();
|
||||
|
||||
void CheckKeys();
|
||||
void CheckKeys2();
|
||||
void GameTicker();
|
||||
void InitLevel(int);
|
||||
void InitNewGame();
|
||||
void startmainmenu();
|
||||
|
||||
int showmap(short nLevel, short nLevelNew, short nLevelBest);
|
||||
void menu_DoPlasma();
|
||||
|
@ -145,8 +106,6 @@ extern int GameAction;
|
|||
|
||||
extern int nNetPlayerCount;
|
||||
|
||||
extern int htimer;
|
||||
|
||||
extern int nNetTime;
|
||||
|
||||
extern short nTotalPlayers;
|
||||
|
@ -288,8 +247,9 @@ struct GameInterface : ::GameInterface
|
|||
bool SaveGame(FSaveGameNode* sv) override;
|
||||
bool CanSave() override;
|
||||
ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; }
|
||||
void clearlocalinputstate() override;
|
||||
void QuitToTitle() override;
|
||||
void UpdateSounds() override;
|
||||
void ErrorCleanup() override;
|
||||
|
||||
::GameStats getStats() override;
|
||||
};
|
||||
|
|
|
@ -141,20 +141,6 @@ static void GameDisplay(void)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void startmainmenu()
|
||||
{
|
||||
gamestate = GS_MENUSCREEN;
|
||||
M_StartControlPanel(false);
|
||||
M_SetMenu(NAME_Mainmenu);
|
||||
StopAllSounds();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void drawmenubackground()
|
||||
{
|
||||
auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
|
||||
|
@ -260,10 +246,9 @@ void CheckProgression()
|
|||
|
||||
void GameLoop()
|
||||
{
|
||||
CheckKeys();
|
||||
GameTicker();
|
||||
PlayerInterruptKeys();
|
||||
UpdateSounds();
|
||||
PlayerInterruptKeys(true);
|
||||
gi->UpdateSounds();
|
||||
CheckKeys2();
|
||||
}
|
||||
|
||||
|
@ -271,8 +256,6 @@ void GameLoop()
|
|||
void GameInterface::RunGameFrame()
|
||||
{
|
||||
again:
|
||||
try
|
||||
{
|
||||
CheckProgression();
|
||||
switch (gamestate)
|
||||
{
|
||||
|
@ -312,14 +295,12 @@ void GameInterface::RunGameFrame()
|
|||
|
||||
}
|
||||
}
|
||||
catch (CRecoverableError&)
|
||||
|
||||
void GameInterface::ErrorCleanup()
|
||||
{
|
||||
// Clear all progression sensitive variables here.
|
||||
GameAction = -1;
|
||||
EndLevel = false;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
END_PS_NS
|
||||
|
|
|
@ -28,7 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_PS_NS
|
||||
|
||||
int WeaponToSend, BitsToSend;
|
||||
extern short bPlayerPan;
|
||||
extern short bLockPan;
|
||||
|
||||
short nInputStack = 0;
|
||||
|
||||
|
@ -71,28 +72,10 @@ void InitInput()
|
|||
|
||||
void ClearSpaceBar(short nPlayer)
|
||||
{
|
||||
sPlayerInput[nPlayer].buttons &= 0x0FB;
|
||||
sPlayerInput[nPlayer].actions &= SB_OPEN;
|
||||
buttonMap.ClearButton(gamefunc_Open);
|
||||
}
|
||||
|
||||
int GetLocalInput()
|
||||
{
|
||||
int lLocalButtons;
|
||||
if (PlayerList[nLocalPlayer].nHealth)
|
||||
{
|
||||
lLocalButtons = (buttonMap.ButtonDown(gamefunc_Crouch) << 4) | (buttonMap.ButtonDown(gamefunc_Fire) << 3)
|
||||
| (buttonMap.ButtonDown(gamefunc_Jump) << 0);
|
||||
lLocalButtons |= (WeaponToSend << 13);
|
||||
WeaponToSend = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lLocalButtons = 0;
|
||||
}
|
||||
|
||||
lLocalButtons |= buttonMap.ButtonDown(gamefunc_Open) << 2;
|
||||
return lLocalButtons;
|
||||
}
|
||||
|
||||
void BackupInput()
|
||||
{
|
||||
|
@ -104,33 +87,6 @@ void SendInput()
|
|||
|
||||
}
|
||||
|
||||
void CheckKeys()
|
||||
{
|
||||
// go to 3rd person view?
|
||||
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
|
||||
{
|
||||
if (!nFreeze)
|
||||
{
|
||||
if (bCamera) {
|
||||
bCamera = false;
|
||||
}
|
||||
else {
|
||||
bCamera = true;
|
||||
}
|
||||
|
||||
if (bCamera)
|
||||
GrabPalette();
|
||||
}
|
||||
buttonMap.ClearButton(gamefunc_Third_Person_View);
|
||||
return;
|
||||
}
|
||||
|
||||
if (paused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t nonsharedtimer;
|
||||
|
||||
void CheckKeys2()
|
||||
|
@ -156,53 +112,219 @@ void CheckKeys2()
|
|||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic
|
||||
// registration to only have the commands active when this game module runs.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static int ccmd_slot(CCmdFuncPtr parm)
|
||||
void PlayerInterruptKeys(bool after)
|
||||
{
|
||||
if (parm->numparms != 1) return CCMD_SHOWHELP;
|
||||
ControlInfo info;
|
||||
memset(&info, 0, sizeof(ControlInfo)); // this is done within CONTROL_GetInput() anyway
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
auto slot = atoi(parm->parms[0]);
|
||||
if (slot >= 1 && slot <= 7)
|
||||
static double lastInputTicks;
|
||||
auto const currentHiTicks = I_msTimeF();
|
||||
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
|
||||
|
||||
lastInputTicks = currentHiTicks;
|
||||
|
||||
auto scaleAdjustmentToInterval = [=](double x) { return x * (120 / 4) / (1000.0 / elapsedInputTicks); };
|
||||
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
InputPacket tempinput{};
|
||||
fix16_t input_angle = 0;
|
||||
|
||||
if (PlayerList[nLocalPlayer].nHealth == 0)
|
||||
{
|
||||
WeaponToSend = slot;
|
||||
return CCMD_OK;
|
||||
}
|
||||
return CCMD_SHOWHELP;
|
||||
localInput = {};
|
||||
lPlayerYVel = 0;
|
||||
lPlayerXVel = 0;
|
||||
nPlayerDAng = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int ccmd_centerview(CCmdFuncPtr parm);
|
||||
|
||||
|
||||
void registerinputcommands()
|
||||
if (!after)
|
||||
{
|
||||
C_RegisterFunction("slot", "slot <weaponslot>: select a weapon from the given slot (1-10)", ccmd_slot);
|
||||
C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { /*BitsToSend |= SKB_PAUSE;*/ sendPause = true; return CCMD_OK; });
|
||||
C_RegisterFunction("centerview", nullptr, ccmd_centerview);
|
||||
C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) SetPrevItem(nLocalPlayer); return CCMD_OK; });
|
||||
C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) SetNextItem(nLocalPlayer); return CCMD_OK; });
|
||||
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) UseCurItem(nLocalPlayer); return CCMD_OK; });
|
||||
// todo: These still need to be implemented.
|
||||
C_RegisterFunction("weapprev", nullptr, [](CCmdFuncPtr)->int { /*WeaponToSend = 11;*/ return CCMD_OK; });
|
||||
C_RegisterFunction("weapnext", nullptr, [](CCmdFuncPtr)->int { /*WeaponToSend = 12;*/ return CCMD_OK; });
|
||||
localInput = {};
|
||||
ApplyGlobalInput(localInput, &info);
|
||||
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= ~(SB_FIRE | SB_JUMP | SB_CROUCH);
|
||||
}
|
||||
|
||||
// These are only here to silence the engine when the keys bound to them are pressed. The functions do not exist.
|
||||
C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { return CCMD_OK; });
|
||||
C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { return CCMD_OK; });
|
||||
|
||||
// JBF: Run key behaviour is selectable
|
||||
int const playerRunning = !!(localInput.actions & SB_RUN);
|
||||
int const turnAmount = playerRunning ? 12 : 8;
|
||||
int const keyMove = playerRunning ? 12 : 6;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
tempinput.svel -= info.mousex * 4.f;
|
||||
tempinput.svel -= info.dyaw * keyMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
input_angle = fix16_sadd(input_angle, fix16_from_float(info.mousex));
|
||||
input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||
}
|
||||
|
||||
bool mouseaim = !!(localInput.actions & SB_AIMMODE);
|
||||
|
||||
if (mouseaim)
|
||||
tempinput.q16horz = fix16_sadd(tempinput.q16horz, fix16_from_float(info.mousey));
|
||||
else
|
||||
tempinput.fvel -= info.mousey * 8.f;
|
||||
|
||||
if (!in_mouseflip) tempinput.q16horz = -tempinput.q16horz;
|
||||
|
||||
tempinput.q16horz = fix16_ssub(tempinput.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch)));
|
||||
tempinput.svel -= info.dx * keyMove;
|
||||
tempinput.fvel -= info.dz * keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
tempinput.svel -= -keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
||||
tempinput.svel -= keyMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
static int turn = 0;
|
||||
static int counter = 0;
|
||||
// normal, non strafing movement
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
{
|
||||
turn -= 2;
|
||||
|
||||
if (turn < -turnAmount)
|
||||
turn = -turnAmount;
|
||||
}
|
||||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
||||
{
|
||||
turn += 2;
|
||||
|
||||
if (turn > turnAmount)
|
||||
turn = turnAmount;
|
||||
}
|
||||
|
||||
if (turn < 0)
|
||||
{
|
||||
turn++;
|
||||
if (turn > 0)
|
||||
turn = 0;
|
||||
}
|
||||
|
||||
if (turn > 0)
|
||||
{
|
||||
turn--;
|
||||
if (turn < 0)
|
||||
turn = 0;
|
||||
}
|
||||
|
||||
//if ((counter++) % 4 == 0) // what was this for???
|
||||
input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(turn * 2)));
|
||||
|
||||
}
|
||||
|
||||
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
||||
void GameInterface::clearlocalinputstate()
|
||||
{
|
||||
WeaponToSend = 0;
|
||||
BitsToSend = 0;
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
|
||||
tempinput.svel += keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
|
||||
tempinput.svel += -keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
tempinput.fvel += keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
tempinput.fvel += -keyMove;
|
||||
|
||||
localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12);
|
||||
localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12);
|
||||
|
||||
localInput.q16avel = fix16_sadd(localInput.q16avel, input_angle);
|
||||
|
||||
if (!nFreeze)
|
||||
{
|
||||
PlayerList[nLocalPlayer].q16angle = fix16_sadd(PlayerList[nLocalPlayer].q16angle, input_angle) & 0x7FFFFFF;
|
||||
|
||||
// A horiz diff of 128 equal 45 degrees,
|
||||
// so we convert horiz to 1024 angle units
|
||||
|
||||
float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - fix16_from_int(92), fix16_from_int(128)) * (512.f / fPI) + fix16_to_float(tempinput.q16horz), -255.f, 255.f);
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92) + Blrintf(fix16_from_int(128) * tanf(horizAngle * (fPI / 512.f)));
|
||||
|
||||
// Look/aim up/down functions.
|
||||
if (localInput.actions & (SB_LOOK_UP|SB_AIM_UP))
|
||||
{
|
||||
bLockPan = false;
|
||||
if (PlayerList[nLocalPlayer].q16horiz < fix16_from_int(180)) {
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
|
||||
}
|
||||
|
||||
bPlayerPan = true;
|
||||
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
|
||||
}
|
||||
else if (localInput.actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
|
||||
{
|
||||
bLockPan = false;
|
||||
if (PlayerList[nLocalPlayer].q16horiz > fix16_from_int(4)) {
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_ssub(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
|
||||
}
|
||||
|
||||
bPlayerPan = true;
|
||||
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
|
||||
}
|
||||
}
|
||||
|
||||
// loc_1C048:
|
||||
if (totalvel[nLocalPlayer] > 20) {
|
||||
bPlayerPan = false;
|
||||
}
|
||||
|
||||
if (mouseaim)
|
||||
bLockPan = true;
|
||||
|
||||
// loc_1C05E
|
||||
fix16_t ecx = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz;
|
||||
|
||||
if (mouseaim)
|
||||
{
|
||||
ecx = 0;
|
||||
}
|
||||
|
||||
if (!nFreeze)
|
||||
{
|
||||
if (ecx)
|
||||
{
|
||||
if (ecx / 4 == 0)
|
||||
{
|
||||
if (ecx >= 0) {
|
||||
ecx = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecx = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecx /= 4;
|
||||
|
||||
if (ecx > fix16_from_int(4))
|
||||
{
|
||||
ecx = fix16_from_int(4);
|
||||
}
|
||||
else if (ecx < -fix16_from_int(4))
|
||||
{
|
||||
ecx = -fix16_from_int(4);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, ecx);
|
||||
}
|
||||
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
END_PS_NS
|
||||
|
|
|
@ -316,22 +316,6 @@ void UseItem(short nPlayer, short nItem)
|
|||
}
|
||||
}
|
||||
|
||||
void UseCurItem(short nPlayer)
|
||||
{
|
||||
int nItem = nPlayerItem[nPlayer];
|
||||
|
||||
if (nItem >= 0)
|
||||
{
|
||||
if (PlayerList[nPlayer].items[nItem] > 0)
|
||||
{
|
||||
if (nItemMagic[nItem] <= PlayerList[nPlayer].nMagic)
|
||||
{
|
||||
sPlayerInput[nPlayer].nItem = nItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - bool return type?
|
||||
int GrabItem(short nPlayer, short nItem)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "aistuff.h"
|
||||
#include "ps_input.h"
|
||||
#include "cheathandler.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
BEGIN_PS_NS
|
||||
|
||||
|
@ -193,7 +194,29 @@ static int osdcmd_spawn(CCmdFuncPtr parm)
|
|||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_third_person_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (!nFreeze)
|
||||
{
|
||||
if (bCamera) {
|
||||
bCamera = false;
|
||||
}
|
||||
else {
|
||||
bCamera = true;
|
||||
}
|
||||
|
||||
if (bCamera)
|
||||
GrabPalette();
|
||||
}
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_noop(CCmdFuncPtr parm)
|
||||
{
|
||||
// this is for silencing key bindings only.
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
int32_t registerosdcommands(void)
|
||||
{
|
||||
|
@ -206,6 +229,9 @@ int32_t registerosdcommands(void)
|
|||
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
|
||||
C_RegisterFunction("spawn","spawn <creaturetype>: spawns a creature",osdcmd_spawn);
|
||||
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
|
||||
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
|
||||
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_noop);
|
||||
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_noop);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ fix16_t nPlayerDAng = 0;
|
|||
short obobangle = 0, bobangle = 0;
|
||||
short bPlayerPan = 0;
|
||||
short bLockPan = 0;
|
||||
bool g_MyAimMode;
|
||||
|
||||
static actionSeq ActionSeq[] = {
|
||||
{18, 0}, {0, 0}, {9, 0}, {27, 0}, {63, 0},
|
||||
|
@ -130,224 +129,6 @@ short PlayerCount;
|
|||
short nNetStartSprites;
|
||||
short nCurStartSprite;
|
||||
|
||||
/*
|
||||
typedef struct
|
||||
{
|
||||
fixed dx;
|
||||
fixed dy;
|
||||
fixed dz;
|
||||
fixed dyaw;
|
||||
fixed dpitch;
|
||||
fixed droll;
|
||||
} ControlInfo;
|
||||
*/
|
||||
|
||||
void PlayerInterruptKeys()
|
||||
{
|
||||
ControlInfo info;
|
||||
memset(&info, 0, sizeof(ControlInfo)); // this is done within CONTROL_GetInput() anyway
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
static double lastInputTicks;
|
||||
auto const currentHiTicks = I_msTimeF();
|
||||
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
|
||||
|
||||
lastInputTicks = currentHiTicks;
|
||||
|
||||
auto scaleAdjustmentToInterval = [=](double x) { return x * (120 / 4) / (1000.0 / elapsedInputTicks); };
|
||||
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
localInput = {};
|
||||
InputPacket input {};
|
||||
fix16_t input_angle = 0;
|
||||
|
||||
if (PlayerList[nLocalPlayer].nHealth == 0)
|
||||
{
|
||||
lPlayerYVel = 0;
|
||||
lPlayerXVel = 0;
|
||||
nPlayerDAng = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// JBF: Run key behaviour is selectable
|
||||
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||
int const turnAmount = playerRunning ? 12 : 8;
|
||||
int const keyMove = playerRunning ? 12 : 6;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
input.svel -= info.mousex * 4.f;
|
||||
input.svel -= info.dyaw * keyMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
input_angle = fix16_sadd(input_angle, fix16_from_float(info.mousex));
|
||||
input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||
}
|
||||
|
||||
g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
||||
|
||||
if (g_MyAimMode)
|
||||
input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey));
|
||||
else
|
||||
input.fvel -= info.mousey * 8.f;
|
||||
|
||||
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
||||
|
||||
input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch)));
|
||||
input.svel -= info.dx * keyMove;
|
||||
input.fvel -= info.dz * keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
input.svel -= -keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
||||
input.svel -= keyMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
static int turn = 0;
|
||||
static int counter = 0;
|
||||
// normal, non strafing movement
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
{
|
||||
turn -= 2;
|
||||
|
||||
if (turn < -turnAmount)
|
||||
turn = -turnAmount;
|
||||
}
|
||||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
||||
{
|
||||
turn += 2;
|
||||
|
||||
if (turn > turnAmount)
|
||||
turn = turnAmount;
|
||||
}
|
||||
|
||||
if (turn < 0)
|
||||
{
|
||||
turn++;
|
||||
if (turn > 0)
|
||||
turn = 0;
|
||||
}
|
||||
|
||||
if (turn > 0)
|
||||
{
|
||||
turn--;
|
||||
if (turn < 0)
|
||||
turn = 0;
|
||||
}
|
||||
|
||||
//if ((counter++) % 4 == 0) // what was this for???
|
||||
input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(turn * 2)));
|
||||
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
|
||||
input.svel += keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
|
||||
input.svel += -keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
input.fvel += keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
input.fvel += -keyMove;
|
||||
|
||||
localInput.fvel = clamp(localInput.fvel + input.fvel, -12, 12);
|
||||
localInput.svel = clamp(localInput.svel + input.svel, -12, 12);
|
||||
|
||||
localInput.q16avel = fix16_sadd(localInput.q16avel, input_angle);
|
||||
|
||||
if (!nFreeze)
|
||||
{
|
||||
PlayerList[nLocalPlayer].q16angle = fix16_sadd(PlayerList[nLocalPlayer].q16angle, input_angle) & 0x7FFFFFF;
|
||||
|
||||
// A horiz diff of 128 equal 45 degrees,
|
||||
// so we convert horiz to 1024 angle units
|
||||
|
||||
float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - fix16_from_int(92), fix16_from_int(128)) * (512.f / fPI) + fix16_to_float(input.q16horz), -255.f, 255.f);
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92) + Blrintf(fix16_from_int(128) * tanf(horizAngle * (fPI / 512.f)));
|
||||
|
||||
// Look/aim up/down functions.
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Up) || buttonMap.ButtonDown(gamefunc_Aim_Up))
|
||||
{
|
||||
bLockPan = false;
|
||||
if (PlayerList[nLocalPlayer].q16horiz < fix16_from_int(180)) {
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
|
||||
}
|
||||
|
||||
bPlayerPan = true;
|
||||
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
|
||||
}
|
||||
else if (buttonMap.ButtonDown(gamefunc_Look_Down) || buttonMap.ButtonDown(gamefunc_Aim_Down))
|
||||
{
|
||||
bLockPan = false;
|
||||
if (PlayerList[nLocalPlayer].q16horiz > fix16_from_int(4)) {
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_ssub(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
|
||||
}
|
||||
|
||||
bPlayerPan = true;
|
||||
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
|
||||
}
|
||||
}
|
||||
|
||||
// loc_1C048:
|
||||
if (totalvel[nLocalPlayer] > 20) {
|
||||
bPlayerPan = false;
|
||||
}
|
||||
|
||||
if (g_MyAimMode)
|
||||
bLockPan = true;
|
||||
|
||||
// loc_1C05E
|
||||
fix16_t ecx = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz;
|
||||
|
||||
if (g_MyAimMode)
|
||||
{
|
||||
ecx = 0;
|
||||
}
|
||||
|
||||
if (!nFreeze)
|
||||
{
|
||||
if (ecx)
|
||||
{
|
||||
if (ecx / 4 == 0)
|
||||
{
|
||||
if (ecx >= 0) {
|
||||
ecx = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecx = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecx /= 4;
|
||||
|
||||
if (ecx > fix16_from_int(4))
|
||||
{
|
||||
ecx = fix16_from_int(4);
|
||||
}
|
||||
else if (ecx < -fix16_from_int(4))
|
||||
{
|
||||
ecx = -fix16_from_int(4);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, ecx);
|
||||
}
|
||||
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184));
|
||||
}
|
||||
}
|
||||
|
||||
void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle)
|
||||
{
|
||||
*x = sPlayerSave[nPlayer].x;
|
||||
|
@ -1498,6 +1279,7 @@ loc_1AB8E:
|
|||
int var_5C = SectFlag[nViewSect] & kSectUnderwater;
|
||||
|
||||
uint16_t buttons = sPlayerInput[nPlayer].buttons;
|
||||
auto actions = sPlayerInput[nPlayer].actions;
|
||||
|
||||
if (buttons & kButtonCheatGodMode) // LOBODEITY cheat
|
||||
{
|
||||
|
@ -2754,7 +2536,7 @@ do_default_b:
|
|||
|
||||
if (!PlayerList[nPlayer].bIsMummified)
|
||||
{
|
||||
if (buttons & kButtonOpen)
|
||||
if (actions & SB_OPEN)
|
||||
{
|
||||
ClearSpaceBar(nPlayer);
|
||||
|
||||
|
@ -2770,7 +2552,7 @@ do_default_b:
|
|||
}
|
||||
|
||||
// was int var_38 = buttons & 0x8
|
||||
if (buttons & kButtonFire)
|
||||
if (actions & SB_FIRE)
|
||||
{
|
||||
FireWeapon(nPlayer);
|
||||
}
|
||||
|
@ -2787,7 +2569,7 @@ do_default_b:
|
|||
}
|
||||
|
||||
// Jumping
|
||||
if (buttons & kButtonJump)
|
||||
if (actions & SB_JUMP)
|
||||
{
|
||||
if (bUnderwater)
|
||||
{
|
||||
|
@ -2805,7 +2587,7 @@ do_default_b:
|
|||
|
||||
// goto loc_1BE70:
|
||||
}
|
||||
else if (buttons & kButtonCrouch)
|
||||
else if (actions & SB_CROUCH)
|
||||
{
|
||||
if (bUnderwater)
|
||||
{
|
||||
|
@ -2866,7 +2648,7 @@ loc_1BD2E:
|
|||
}
|
||||
}
|
||||
// loc_1BE30
|
||||
if (buttons & kButtonFire) // was var_38
|
||||
if (actions & SB_FIRE) // was var_38
|
||||
{
|
||||
if (bUnderwater)
|
||||
{
|
||||
|
@ -2884,7 +2666,7 @@ loc_1BD2E:
|
|||
|
||||
// loc_1BE70:
|
||||
// Handle player pressing number keys to change weapon
|
||||
uint8_t var_90 = (buttons >> 13) & 0xF;
|
||||
uint8_t var_90 = sPlayerInput[nPlayer].getNewWeapon();
|
||||
|
||||
if (var_90)
|
||||
{
|
||||
|
@ -2898,7 +2680,7 @@ loc_1BD2E:
|
|||
}
|
||||
else // player is mummified
|
||||
{
|
||||
if (buttons & kButtonFire)
|
||||
if (actions & SB_FIRE)
|
||||
{
|
||||
FireWeapon(nPlayer);
|
||||
}
|
||||
|
@ -2927,7 +2709,7 @@ loc_1BD2E:
|
|||
else // else, player's health is less than 0
|
||||
{
|
||||
// loc_1C0E9
|
||||
if (buttons & kButtonOpen)
|
||||
if (actions & SB_OPEN)
|
||||
{
|
||||
ClearSpaceBar(nPlayer);
|
||||
|
||||
|
@ -3089,17 +2871,6 @@ loc_1BD2E:
|
|||
}
|
||||
}
|
||||
|
||||
int ccmd_centerview(CCmdFuncPtr parm)
|
||||
{
|
||||
return CCMD_OK;
|
||||
bLockPan = false;
|
||||
bPlayerPan = false;
|
||||
PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92);
|
||||
nDestVertPan[nLocalPlayer] = fix16_from_int(92);
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
|
||||
static SavegameHelper sgh("player",
|
||||
SV(lPlayerXVel),
|
||||
SV(lPlayerYVel),
|
||||
|
@ -3108,7 +2879,6 @@ static SavegameHelper sgh("player",
|
|||
SV(bobangle),
|
||||
SV(bPlayerPan),
|
||||
SV(bLockPan),
|
||||
SV(g_MyAimMode),
|
||||
SV(nStandHeight),
|
||||
SV(PlayerCount),
|
||||
SV(nNetStartSprites),
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_PS_NS
|
||||
|
||||
void PlayerInterruptKeys();
|
||||
void PlayerInterruptKeys(bool after);
|
||||
void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle);
|
||||
void SetSavePoint(int nPlayer, int x, int y, int z, short nSector, short nAngle);
|
||||
void InitPlayer();
|
||||
|
|
|
@ -24,6 +24,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_PS_NS
|
||||
|
||||
enum {
|
||||
kButtonCheatGuns = 0x20,
|
||||
kButtonCheatGodMode = 0x40,
|
||||
kButtonCheatKeys = 0x80,
|
||||
kButtonCheatItems = 0x100,
|
||||
};
|
||||
|
||||
// 32 bytes
|
||||
struct PlayerInput
|
||||
{
|
||||
|
@ -33,6 +40,18 @@ struct PlayerInput
|
|||
short nTarget;
|
||||
fix16_t horizon;
|
||||
int8_t nItem;
|
||||
ESyncBits actions;
|
||||
|
||||
int getNewWeapon() const
|
||||
{
|
||||
return (actions & SB_WEAPONMASK_BITS).GetValue();
|
||||
}
|
||||
|
||||
void SetNewWeapon(int weap)
|
||||
{
|
||||
actions = (actions & ~SB_WEAPONMASK_BITS) | (ESyncBits::FromInt(weap) & SB_WEAPONMASK_BITS);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void InitInput();
|
||||
|
|
|
@ -310,6 +310,7 @@ void seq_LoadSequences()
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
FILE* f = fopen("seq.dump", "wb");
|
||||
|
||||
fwrite(SeqBase, 1, sizeof(SeqBase), f);
|
||||
|
@ -326,6 +327,7 @@ void seq_LoadSequences()
|
|||
fwrite(ChunkPict, 1, sizeof(ChunkPict), f);
|
||||
fwrite(ChunkFlag, 1, sizeof(ChunkFlag), f);
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
nShadowPic = seq_GetFirstSeqPicnum(kSeqShadow);
|
||||
nShadowWidth = tilesiz[nShadowPic].x;
|
||||
|
|
|
@ -490,7 +490,7 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void UpdateSounds()
|
||||
void GameInterface::UpdateSounds()
|
||||
{
|
||||
if (nFreeze)
|
||||
return;
|
||||
|
|
|
@ -117,7 +117,6 @@ extern short nCreepyTimer;
|
|||
extern short StaticSound[];
|
||||
|
||||
|
||||
void UpdateSounds();
|
||||
void UpdateCreepySounds();
|
||||
|
||||
void InitFX();
|
||||
|
|
|
@ -384,51 +384,6 @@ void SetPlayerItem(short nPlayer, short nItem)
|
|||
}
|
||||
}
|
||||
|
||||
void SetNextItem(int nPlayer)
|
||||
{
|
||||
short nItem = nPlayerItem[nPlayer];
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 6; i > 0; i--)
|
||||
{
|
||||
nItem++;
|
||||
if (nItem == 6)
|
||||
nItem = 0;
|
||||
|
||||
if (PlayerList[nPlayer].items[nItem] != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
SetPlayerItem(nPlayer, nItem);
|
||||
}
|
||||
}
|
||||
|
||||
void SetPrevItem(int nPlayer)
|
||||
{
|
||||
if (nPlayerItem[nPlayer] == -1)
|
||||
return;
|
||||
|
||||
int nItem = nPlayerItem[nPlayer];
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 6; i > 0; i--)
|
||||
{
|
||||
nItem--;
|
||||
if (nItem < 0)
|
||||
nItem = 5;
|
||||
|
||||
if (PlayerList[nPlayer].items[nItem] != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
SetPlayerItem(nPlayer, nItem);
|
||||
}
|
||||
}
|
||||
|
||||
void MoveStatus()
|
||||
{
|
||||
if (nItemSeq >= 0)
|
||||
|
|
|
@ -36,8 +36,6 @@ void MoveStatus();
|
|||
void DrawSnakeCamStatus();
|
||||
void DrawStatus();
|
||||
int BuildStatusAnim(int val, int nFlags);
|
||||
void SetNextItem(int nPlayer);
|
||||
void SetPrevItem(int nPlayer);
|
||||
void SetCounter(short nVal);
|
||||
void SetCounterImmediate(short nVal);
|
||||
|
||||
|
|
|
@ -1522,7 +1522,7 @@ bool queball(int i, int pocket, int queball, int stripeball)
|
|||
// if(s->pal == 12)
|
||||
{
|
||||
j = getincangle(ps[p].getang(), getangle(s->x - ps[p].posx, s->y - ps[p].posy));
|
||||
if (j > -64 && j < 64 && PlayerInput(p, SKB_OPEN))
|
||||
if (j > -64 && j < 64 && PlayerInput(p, SB_OPEN))
|
||||
if (ps[p].toggle_key_flag == 1)
|
||||
{
|
||||
int a = headspritestat[STAT_ACTOR];
|
||||
|
|
|
@ -2126,13 +2126,13 @@ void movetransports_d(void)
|
|||
else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break;
|
||||
|
||||
if (onfloorz == 0 && abs(sprite[i].z - ps[p].posz) < 6144)
|
||||
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SKB_JUMP))) ||
|
||||
(ps[p].jetpack_on && (PlayerInput(p, SKB_CROUCH) ^ !!ps[p].crouch_toggle)))
|
||||
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP))) ||
|
||||
(ps[p].jetpack_on && (PlayerInput(p, SB_CROUCH) ^ !!ps[p].crouch_toggle)))
|
||||
{
|
||||
ps[p].oposx = ps[p].posx += sprite[sprite[i].owner].x - sprite[i].x;
|
||||
ps[p].oposy = ps[p].posy += sprite[sprite[i].owner].y - sprite[i].y;
|
||||
|
||||
if (ps[p].jetpack_on && (PlayerInput(p, SKB_JUMP) || ps[p].jetpack_on < 11))
|
||||
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
|
||||
ps[p].posz = sprite[sprite[i].owner].z - 6144;
|
||||
else ps[p].posz = sprite[sprite[i].owner].z + 6144;
|
||||
ps[p].oposz = ps[p].posz;
|
||||
|
@ -2149,7 +2149,7 @@ void movetransports_d(void)
|
|||
|
||||
k = 0;
|
||||
|
||||
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SKB_CROUCH) || ps[p].poszv > 2048))
|
||||
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].poszv > 2048))
|
||||
// if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) )
|
||||
{
|
||||
k = 1;
|
||||
|
@ -2478,7 +2478,7 @@ static void greenslime(int i)
|
|||
|
||||
s->ang = ps[p].getang();
|
||||
|
||||
if ((PlayerInput(p, SKB_FIRE) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0)
|
||||
if ((PlayerInput(p, SB_FIRE) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0)
|
||||
if (ps[p].quick_kick > 0 || (ps[p].curr_weapon != HANDREMOTE_WEAPON && ps[p].curr_weapon != HANDBOMB_WEAPON && ps[p].curr_weapon != TRIPBOMB_WEAPON && ps[p].ammo_amount[ps[p].curr_weapon] >= 0))
|
||||
{
|
||||
for (x = 0; x < 8; x++)
|
||||
|
|
|
@ -1755,13 +1755,13 @@ void movetransports_r(void)
|
|||
else break;
|
||||
|
||||
if (onfloorz == 0 && abs(sprite[i].z - ps[p].posz) < 6144)
|
||||
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SKB_JUMP)) ||
|
||||
(ps[p].jetpack_on && PlayerInput(p, SKB_CROUCH)))
|
||||
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) ||
|
||||
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
|
||||
{
|
||||
ps[p].oposx = ps[p].posx += sprite[OW].x - sprite[i].x;
|
||||
ps[p].oposy = ps[p].posy += sprite[OW].y - sprite[i].y;
|
||||
|
||||
if (ps[p].jetpack_on && (PlayerInput(p, SKB_JUMP) || ps[p].jetpack_on < 11))
|
||||
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
|
||||
ps[p].posz = sprite[OW].z - 6144;
|
||||
else ps[p].posz = sprite[OW].z + 6144;
|
||||
ps[p].oposz = ps[p].posz;
|
||||
|
|
|
@ -33,6 +33,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "mapinfo.h"
|
||||
#include "cheathandler.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -285,22 +286,62 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
|
|||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_third_person_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (!isRRRA() || (!ps[myconnectindex].OnMotorcycle && !ps[myconnectindex].OnBoat))
|
||||
{
|
||||
if (ps[myconnectindex].over_shoulder_on)
|
||||
ps[myconnectindex].over_shoulder_on = 0;
|
||||
else
|
||||
{
|
||||
ps[myconnectindex].over_shoulder_on = 1;
|
||||
cameradist = 0;
|
||||
cameraclock = gameclock;
|
||||
}
|
||||
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
|
||||
}
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_coop_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (ud.coop || ud.recstat == 2)
|
||||
{
|
||||
screenpeek = connectpoint2[screenpeek];
|
||||
if (screenpeek == -1) screenpeek = 0;
|
||||
}
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_show_weapon(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (ud.multimode > 1)
|
||||
{
|
||||
ud.showweapons = 1 - ud.showweapons;
|
||||
cl_showweapon = ud.showweapons;
|
||||
FTA(QUOTE_WEAPON_MODE_OFF - ud.showweapons, &ps[screenpeek]);
|
||||
}
|
||||
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
|
||||
int registerosdcommands(void)
|
||||
{
|
||||
C_RegisterFunction("map","map <mapname>: warp to the given map, identified by its name", ccmd_map);
|
||||
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", ccmd_levelwarp);
|
||||
|
||||
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", ccmd_give);
|
||||
C_RegisterFunction("god","god: toggles god mode", ccmd_god);
|
||||
|
||||
C_RegisterFunction("noclip","noclip: toggles clipping mode", ccmd_noclip);
|
||||
C_RegisterFunction("restartmap", "restartmap: restarts the current map", ccmd_restartmap);
|
||||
|
||||
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
|
||||
|
||||
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
|
||||
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
|
||||
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_coop_view);
|
||||
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_show_weapon);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,41 +3,6 @@
|
|||
|
||||
// all game constants got collected here.
|
||||
|
||||
// Most of these should be replaced by CCMDs eventually
|
||||
enum GameFunction_t
|
||||
{
|
||||
gamefunc_Move_Forward,
|
||||
gamefunc_Move_Backward,
|
||||
gamefunc_Turn_Left,
|
||||
gamefunc_Turn_Right,
|
||||
gamefunc_Strafe,
|
||||
gamefunc_Fire,
|
||||
gamefunc_Open,
|
||||
gamefunc_Run,
|
||||
gamefunc_Jump,
|
||||
gamefunc_Crouch,
|
||||
gamefunc_Look_Up,
|
||||
gamefunc_Look_Down,
|
||||
gamefunc_Look_Left,
|
||||
gamefunc_Look_Right,
|
||||
gamefunc_Strafe_Left,
|
||||
gamefunc_Strafe_Right,
|
||||
gamefunc_Aim_Up,
|
||||
gamefunc_Aim_Down,
|
||||
gamefunc_Shrink_Screen, // CCMD
|
||||
gamefunc_Enlarge_Screen, // CCMD
|
||||
gamefunc_Show_Opponents_Weapon, // CCMD
|
||||
gamefunc_See_Coop_View, // CCMD
|
||||
gamefunc_Mouse_Aiming, // CCMD
|
||||
gamefunc_Quick_Kick,
|
||||
gamefunc_Dpad_Select,
|
||||
gamefunc_Dpad_Aiming,
|
||||
gamefunc_Third_Person_View, // CCMD
|
||||
gamefunc_Toggle_Crouch,
|
||||
NUM_ACTIONS
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
TICRATE = 120,
|
||||
|
|
|
@ -293,7 +293,7 @@ void GameInterface::StartGame(FNewGameStartup& gs)
|
|||
|
||||
while (S_CheckSoundPlaying(skillsound))
|
||||
{
|
||||
S_Update();
|
||||
gi->UpdateSounds();
|
||||
soundEngine->UpdateSounds(I_GetTime());
|
||||
I_GetEvent();
|
||||
}
|
||||
|
@ -356,8 +356,7 @@ void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam)
|
|||
|
||||
void GameInterface::QuitToTitle()
|
||||
{
|
||||
ps[myconnectindex].gm = MODE_DEMO;
|
||||
artClearMapArt();
|
||||
gamestate = GS_STARTUP;
|
||||
}
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -30,7 +30,6 @@ struct GameInterface : public ::GameInterface
|
|||
{
|
||||
const char* Name() override { return "Duke"; }
|
||||
void app_init() override;
|
||||
void RunGameFrame() override;
|
||||
void clearlocalinputstate() override;
|
||||
bool GenerateSavePic() override;
|
||||
void PlayHudSound() override;
|
||||
|
@ -53,6 +52,12 @@ struct GameInterface : public ::GameInterface
|
|||
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
||||
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
||||
void ResetFollowPos(bool message) override;
|
||||
void GetInput(InputPacket* packet) override;
|
||||
void UpdateSounds() override;
|
||||
void Startup() override;
|
||||
void DrawBackground() override;
|
||||
void Render() override;
|
||||
void Ticker() override;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -110,12 +110,12 @@ int makepainsounds(int snum, int type);
|
|||
void playerCrouch(int snum);
|
||||
void playerJump(int snum, int fz, int cz);
|
||||
void applylook(int snum, double factor, fixed_t adjustment);
|
||||
void checklook(int snum, int sb_snum);
|
||||
void checklook(int snum, ESyncBits actions);
|
||||
void playerCenterView(int snum);
|
||||
void playerLookUp(int snum, ESyncBits sb_snum);
|
||||
void playerLookDown(int snum, ESyncBits sb_snum);
|
||||
void playerAimUp(int snum, ESyncBits sb_snum);
|
||||
void playerAimDown(int snum, ESyncBits sb_snum);
|
||||
void playerLookUp(int snum, ESyncBits actions);
|
||||
void playerLookDown(int snum, ESyncBits actions);
|
||||
void playerAimUp(int snum, ESyncBits actions);
|
||||
void playerAimDown(int snum, ESyncBits actions);
|
||||
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz);
|
||||
void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n);
|
||||
int hits(int i);
|
||||
|
@ -193,7 +193,6 @@ void resetinventory(int pn);
|
|||
void resetplayerstats(int pn);
|
||||
void resetweapons(int pn);
|
||||
void resetprestat(int snum, int g);
|
||||
void clearfifo(void);
|
||||
void prelevel_common(int g);
|
||||
void cacheit_d();
|
||||
void cacheit_r();
|
||||
|
@ -212,7 +211,7 @@ void dobonus(int bonusonly, const CompletionFunc& completion);
|
|||
void dobonus_d(bool bonusonly, const CompletionFunc& completion);
|
||||
void dobonus_r(bool bonusonly, const CompletionFunc& completion);
|
||||
|
||||
void displayrest(double smoothratio);
|
||||
void drawoverlays(double smoothratio);
|
||||
void drawbackground(void);
|
||||
void displayrooms(int32_t playerNum, double smoothratio);
|
||||
void setgamepalette(int palid);
|
||||
|
@ -232,10 +231,8 @@ void PlayerColorChanged(void);
|
|||
void nonsharedkeys(void);
|
||||
void apply_seasick(player_struct* p, double scalefactor);
|
||||
void calcviewpitch(player_struct* p, double factor);
|
||||
void sethorizon(int snum, int sb_snum, double factor, fixed_t adjustment);
|
||||
void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment);
|
||||
bool movementBlocked(int snum);
|
||||
void GetInput();
|
||||
void startmainmenu();
|
||||
void loadcons();
|
||||
|
||||
void updateinterpolations();
|
||||
|
@ -244,6 +241,7 @@ void setinterpolation(int* posptr);
|
|||
void stopinterpolation(int* posptr);
|
||||
void dointerpolations(int smoothratio);
|
||||
int* animateptr(int i);
|
||||
void resetGameClock();
|
||||
|
||||
void backuppos(player_struct* p, bool noclipping = false);
|
||||
void backuplook(player_struct* p);
|
||||
|
|
|
@ -46,7 +46,6 @@ BEGIN_DUKE_NS
|
|||
void SetDispatcher();
|
||||
void InitCheats();
|
||||
int registerosdcommands(void);
|
||||
void registerinputcommands(void);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -233,47 +232,6 @@ static void setupbackdrop()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void SetupGameButtons()
|
||||
{
|
||||
static const char* actions[] = {
|
||||
"Move_Forward",
|
||||
"Move_Backward",
|
||||
"Turn_Left",
|
||||
"Turn_Right",
|
||||
"Strafe",
|
||||
"Fire",
|
||||
"Open",
|
||||
"Run",
|
||||
"Jump",
|
||||
"Crouch",
|
||||
"Look_Up",
|
||||
"Look_Down",
|
||||
"Look_Left",
|
||||
"Look_Right",
|
||||
"Strafe_Left",
|
||||
"Strafe_Right",
|
||||
"Aim_Up",
|
||||
"Aim_Down",
|
||||
"Shrink_Screen",
|
||||
"Enlarge_Screen",
|
||||
"Show_Opponents_Weapon",
|
||||
"See_Coop_View",
|
||||
"Mouse_Aiming",
|
||||
"Quick_Kick",
|
||||
"Dpad_Select",
|
||||
"Dpad_Aiming",
|
||||
"Third_Person_View",
|
||||
"Toggle_Crouch",
|
||||
};
|
||||
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void loaddefs()
|
||||
{
|
||||
const char* defsfile = G_DefFile();
|
||||
|
@ -314,7 +272,7 @@ static void initTiles()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void Startup(void)
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
if (isRR()) C_SetNotifyFontScale(0.5);
|
||||
ud.god = 0;
|
||||
|
@ -355,8 +313,6 @@ static void Startup(void)
|
|||
|
||||
OnEvent(EVENT_INIT);
|
||||
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;
|
||||
|
||||
if (engineInit())
|
||||
G_FatalEngineError();
|
||||
|
||||
|
@ -371,7 +327,6 @@ static void Startup(void)
|
|||
InitCheats();
|
||||
checkcommandline();
|
||||
registerosdcommands();
|
||||
registerinputcommands();
|
||||
|
||||
screenpeek = myconnectindex;
|
||||
ps[myconnectindex].palette = BASEPAL;
|
||||
|
@ -391,21 +346,7 @@ static void Startup(void)
|
|||
}
|
||||
|
||||
ud.last_level = -1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// main entry point, sets up the game module and the engine, then enters the main loop
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
Startup();
|
||||
enginePostInit();
|
||||
videoInit();
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;//bVanilla;
|
||||
}
|
||||
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -157,7 +157,7 @@ void FTA(int q, struct player_struct* p)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void drawbackground(void)
|
||||
void GameInterface::DrawBackground()
|
||||
{
|
||||
twod->ClearScreen();
|
||||
auto tex = tileGetTexture(TILE_MENUSCREEN);
|
||||
|
@ -217,7 +217,7 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4])
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void displayrest(double smoothratio)
|
||||
void drawoverlays(double smoothratio)
|
||||
{
|
||||
int i, j;
|
||||
unsigned char fader = 0, fadeg = 0, fadeb = 0, fadef = 0, tintr = 0, tintg = 0, tintb = 0, tintf = 0, dotint = 0;
|
||||
|
|
|
@ -1163,7 +1163,7 @@ int ParseState::parse(void)
|
|||
s = g_sp->xvel;
|
||||
|
||||
// sigh... this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable.
|
||||
if( (l& pducking) && ps[g_p].on_ground && (PlayerInput(g_p, SKB_CROUCH) ^ !!(ps[g_p].crouch_toggle) ))
|
||||
if( (l& pducking) && ps[g_p].on_ground && (PlayerInput(g_p, SB_CROUCH) ^ !!(ps[g_p].crouch_toggle) ))
|
||||
j = 1;
|
||||
else if( (l& pfalling) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && ps[g_p].poszv > 2048 )
|
||||
j = 1;
|
||||
|
@ -1171,15 +1171,15 @@ int ParseState::parse(void)
|
|||
j = 1;
|
||||
else if( (l& pstanding) && s >= 0 && s < 8)
|
||||
j = 1;
|
||||
else if( (l& pwalking) && s >= 8 && !(PlayerInput(g_p, SKB_RUN)) )
|
||||
else if( (l& pwalking) && s >= 8 && !(PlayerInput(g_p, SB_RUN)) )
|
||||
j = 1;
|
||||
else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SKB_RUN) )
|
||||
else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SB_RUN) )
|
||||
j = 1;
|
||||
else if( (l& phigher) && ps[g_p].posz < (g_sp->z-(48<<8)) )
|
||||
j = 1;
|
||||
else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SKB_RUN)) )
|
||||
else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SB_RUN)) )
|
||||
j = 1;
|
||||
else if( (l& prunningback) && s <= -8 && (PlayerInput(g_p, SKB_RUN)) )
|
||||
else if( (l& prunningback) && s <= -8 && (PlayerInput(g_p, SB_RUN)) )
|
||||
j = 1;
|
||||
else if( (l& pkicking) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) )
|
||||
j = 1;
|
||||
|
@ -1244,7 +1244,7 @@ int ParseState::parse(void)
|
|||
parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) < *insptr);
|
||||
break;
|
||||
case concmd_ifhitspace:
|
||||
parseifelse(PlayerInput(g_p, SKB_OPEN));
|
||||
parseifelse(PlayerInput(g_p, SB_OPEN));
|
||||
break;
|
||||
case concmd_ifoutside:
|
||||
parseifelse(sector[g_sp->sectnum].ceilingstat & 1);
|
||||
|
|
|
@ -38,152 +38,20 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// abstract the queue's implementation
|
||||
// All access to the input queues should go through this function interface.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
static InputPacket inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
||||
static int movefifoend[MAXPLAYERS];
|
||||
static int movefifoplc;
|
||||
static int bufferjitter;
|
||||
|
||||
void clearfifo(void)
|
||||
{
|
||||
loc = {};
|
||||
memset(&inputfifo, 0, sizeof(inputfifo));
|
||||
memset(sync, 0, sizeof(sync));
|
||||
}
|
||||
|
||||
|
||||
static inline void GetNextInput()
|
||||
{
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
memcpy(&sync[i], &inputfifo[movefifoplc & (MOVEFIFOSIZ - 1)][i], sizeof(InputPacket));
|
||||
|
||||
movefifoplc++;
|
||||
}
|
||||
|
||||
static void advancequeue(int myconnectindex)
|
||||
{
|
||||
movefifoend[myconnectindex]++;
|
||||
}
|
||||
|
||||
static InputPacket& nextinput(int myconnectindex)
|
||||
{
|
||||
return inputfifo[movefifoend[myconnectindex] & (MOVEFIFOSIZ - 1)][myconnectindex];
|
||||
}
|
||||
|
||||
bool shouldprocessinput(int myconnectindex)
|
||||
{
|
||||
if (movefifoend[myconnectindex] - movefifoplc > bufferjitter)
|
||||
{
|
||||
int i;
|
||||
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
if (movefifoplc == movefifoend[i]) return false;
|
||||
if (i >= 0) return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void fakedomovethings()
|
||||
{
|
||||
// prediction
|
||||
}
|
||||
|
||||
static void fakedomovethingscorrect()
|
||||
{
|
||||
// unprediction
|
||||
}
|
||||
|
||||
void prediction()
|
||||
{
|
||||
#if 0
|
||||
// We currently have no net code driving this.
|
||||
if (numplayers > 1)
|
||||
while (fakemovefifoplc < movefifoend[myconnectindex]) fakedomovethings();
|
||||
getpackets();
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
void mploadsave()
|
||||
{
|
||||
for(int i=connecthead;i>=0;i=connectpoint2[i])
|
||||
if( sync[i].bits&(1<<17) )
|
||||
{
|
||||
multiflag = 2;
|
||||
multiwhat = (sync[i].bits>>18)&1;
|
||||
multipos = (unsigned) (sync[i].bits>>19)&15;
|
||||
multiwho = i;
|
||||
|
||||
if( multiwhat )
|
||||
{
|
||||
saveplayer( multipos );
|
||||
multiflag = 0;
|
||||
|
||||
if(multiwho != myconnectindex)
|
||||
{
|
||||
strcpy(&fta_quotes[122],&ud.user_name[multiwho][0]);
|
||||
strcat(&fta_quotes[122]," SAVED A MULTIPLAYER GAME");
|
||||
FTA(122,&ps[myconnectindex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(&fta_quotes[122],"MULTIPLAYER GAME SAVED");
|
||||
FTA(122,&ps[myconnectindex]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// waitforeverybody();
|
||||
|
||||
j = loadplayer( multipos );
|
||||
|
||||
multiflag = 0;
|
||||
|
||||
if(j == 0 && !isRR())
|
||||
{
|
||||
if(multiwho != myconnectindex)
|
||||
{
|
||||
strcpy(&fta_quotes[122],&ud.user_name[multiwho][0]);
|
||||
strcat(&fta_quotes[122]," LOADED A MULTIPLAYER GAME");
|
||||
FTA(122,&ps[myconnectindex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(&fta_quotes[122],"MULTIPLAYER GAME LOADED");
|
||||
FTA(122,&ps[myconnectindex]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int domovethings()
|
||||
void GameInterface::Ticker()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
// mplpadsave();
|
||||
|
||||
// Make copies so that the originals do not have to be modified.
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
sync[i] = playercmds[i].ucmd;
|
||||
}
|
||||
ud.camerasprite = -1;
|
||||
lockclock += TICSPERFRAME;
|
||||
|
||||
if (earthquaketime > 0) earthquaketime--;
|
||||
if (rtsplaying > 0) rtsplaying--;
|
||||
|
@ -194,49 +62,17 @@ int domovethings()
|
|||
}
|
||||
|
||||
everyothertime++;
|
||||
GetNextInput();
|
||||
updateinterpolations();
|
||||
|
||||
j = -1;
|
||||
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
if (PlayerInput(i, SKB_GAMEQUIT))
|
||||
{
|
||||
if (i == myconnectindex) gameexitfrommenu();
|
||||
if (screenpeek == i)
|
||||
{
|
||||
screenpeek = connectpoint2[i];
|
||||
if (screenpeek < 0) screenpeek = connecthead;
|
||||
}
|
||||
|
||||
if (i == connecthead) connecthead = connectpoint2[connecthead];
|
||||
else connectpoint2[j] = connectpoint2[i];
|
||||
|
||||
numplayers--;
|
||||
ud.multimode--;
|
||||
|
||||
//closedemowrite();
|
||||
|
||||
if (numplayers < 2 && !isRR())
|
||||
S_PlaySound(GENERIC_AMBIENCE17, CHAN_AUTO, CHANF_UI);
|
||||
|
||||
Printf(PRINT_NOTIFY, "%s is history!", ud.user_name[i]);
|
||||
|
||||
quickkill(&ps[i]);
|
||||
deletesprite(ps[i].i);
|
||||
}
|
||||
else j = i;
|
||||
}
|
||||
|
||||
//if(ud.recstat == 1) record();
|
||||
|
||||
if (playrunning())
|
||||
{
|
||||
global_random = krand();
|
||||
movedummyplayers();//ST 13
|
||||
r_NoInterpolate = false;
|
||||
}
|
||||
else r_NoInterpolate = true;
|
||||
|
||||
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
if (playrunning())
|
||||
{
|
||||
|
@ -258,8 +94,6 @@ int domovethings()
|
|||
fi.think();
|
||||
}
|
||||
|
||||
fakedomovethingscorrect();
|
||||
|
||||
if ((everyothertime & 1) == 0)
|
||||
{
|
||||
fi.animatewalls();
|
||||
|
@ -269,99 +103,11 @@ int domovethings()
|
|||
if (isRR() && ud.recstat == 0 && ud.multimode < 2)
|
||||
dotorch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int moveloop()
|
||||
{
|
||||
prediction();
|
||||
|
||||
if (numplayers < 2) bufferjitter = 0;
|
||||
while (shouldprocessinput(myconnectindex))
|
||||
{
|
||||
if( domovethings() ) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool GameTicker()
|
||||
{
|
||||
if (ps[myconnectindex].gm == MODE_DEMO)
|
||||
{
|
||||
M_ClearMenus();
|
||||
return true;
|
||||
}
|
||||
|
||||
//Net_GetPackets();
|
||||
|
||||
nonsharedkeys();
|
||||
|
||||
gameupdatetime.Reset();
|
||||
gameupdatetime.Clock();
|
||||
|
||||
int const currentTic = I_GetTime();
|
||||
gameclock = I_GetBuildTime();
|
||||
|
||||
while (playrunning() && currentTic - lastTic >= 1)
|
||||
{
|
||||
lastTic = currentTic;
|
||||
|
||||
GetInput();
|
||||
auto const pPlayer = &ps[myconnectindex];
|
||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||
auto& input = nextinput(myconnectindex);
|
||||
|
||||
input = loc;
|
||||
input.fvel = mulscale9(loc.fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||
mulscale9(loc.svel, sintable[(q16ang + 2048) & 2047]) +
|
||||
pPlayer->fric.x;
|
||||
input.svel = mulscale9(loc.fvel, sintable[(q16ang + 2048) & 2047]) +
|
||||
mulscale9(loc.svel, sintable[(q16ang + 1536) & 2047]) +
|
||||
pPlayer->fric.y;
|
||||
loc = {};
|
||||
|
||||
advancequeue(myconnectindex);
|
||||
|
||||
if (playrunning())
|
||||
{
|
||||
moveloop();
|
||||
}
|
||||
}
|
||||
|
||||
gameupdatetime.Unclock();
|
||||
|
||||
if (ps[myconnectindex].gm & (MODE_EOL | MODE_RESTART))
|
||||
{
|
||||
exitlevel();
|
||||
}
|
||||
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
GetInput();
|
||||
}
|
||||
|
||||
S_Update();
|
||||
|
||||
drawtime.Reset();
|
||||
drawtime.Clock();
|
||||
double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio;
|
||||
displayrooms(screenpeek, smoothRatio);
|
||||
displayrest(smoothRatio);
|
||||
drawtime.Unclock();
|
||||
|
||||
return (ps[myconnectindex].gm & MODE_DEMO);
|
||||
nonsharedkeys();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -370,31 +116,23 @@ bool GameTicker()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void startmainmenu()
|
||||
void resetGameClock()
|
||||
{
|
||||
gamestate = GS_MENUSCREEN;
|
||||
M_StartControlPanel(false);
|
||||
M_SetMenu(NAME_Mainmenu);
|
||||
FX_StopAllSounds();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::RunGameFrame()
|
||||
{
|
||||
switch (gamestate)
|
||||
{
|
||||
default:
|
||||
case GS_STARTUP:
|
||||
I_ResetTime();
|
||||
lastTic = -1;
|
||||
I_SetFrameTime();
|
||||
gameclockstart = I_GetBuildTime();
|
||||
gameclock = 0;
|
||||
lockclock = 0;
|
||||
cloudclock = 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::Startup()
|
||||
{
|
||||
resetGameClock();
|
||||
ps[myconnectindex].ftq = 0;
|
||||
|
||||
if (userConfig.CommandMap.IsNotEmpty())
|
||||
|
@ -417,25 +155,25 @@ void GameInterface::RunGameFrame()
|
|||
{
|
||||
fi.ShowLogo([](bool) { startmainmenu(); });
|
||||
}
|
||||
break;
|
||||
|
||||
case GS_MENUSCREEN:
|
||||
case GS_FULLCONSOLE:
|
||||
drawbackground();
|
||||
break;
|
||||
|
||||
case GS_LEVEL:
|
||||
if (GameTicker()) gamestate = GS_STARTUP;
|
||||
else videoSetBrightness(thunder_brightness);
|
||||
break;
|
||||
|
||||
case GS_INTERMISSION:
|
||||
case GS_INTRO:
|
||||
RunScreenJobFrame(); // This handles continuation through its completion callback.
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::Render()
|
||||
{
|
||||
drawtime.Reset();
|
||||
drawtime.Clock();
|
||||
videoSetBrightness(thunder_brightness);
|
||||
double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio;
|
||||
displayrooms(screenpeek, smoothRatio);
|
||||
drawoverlays(smoothRatio);
|
||||
drawtime.Unclock();
|
||||
}
|
||||
|
||||
|
||||
END_DUKE_NS
|
||||
|
||||
|
|
|
@ -63,9 +63,7 @@ int16_t max_ammo_amount[MAX_WEAPONS];
|
|||
int16_t weaponsandammosprites[15];
|
||||
int PHEIGHT = PHEIGHT_DUKE;
|
||||
int duke3d_globalflags;
|
||||
InputPacket loc;
|
||||
uint8_t ready2send;
|
||||
int gamequit;
|
||||
int playerswhenstarted;
|
||||
int show_shareware;
|
||||
int screenpeek;
|
||||
|
@ -116,8 +114,6 @@ int16_t cyclers[MAXCYCLERS][6];
|
|||
int16_t mirrorsector[64];
|
||||
int16_t mirrorwall[64];
|
||||
|
||||
int lockclock;
|
||||
|
||||
// Redneck Rampage
|
||||
int wupass;
|
||||
int chickenplant;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "sounds.h"
|
||||
#include "constants.h"
|
||||
#include "types.h"
|
||||
#include "d_net.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -51,8 +52,6 @@ extern int16_t weaponsandammosprites[15];
|
|||
extern int32_t PHEIGHT;
|
||||
extern int duke3d_globalflags;
|
||||
extern uint8_t ready2send;
|
||||
extern InputPacket loc;
|
||||
extern int gamequit;
|
||||
extern int playerswhenstarted;
|
||||
extern int show_shareware;
|
||||
extern int screenpeek;
|
||||
|
@ -108,8 +107,6 @@ extern int16_t cyclers[MAXCYCLERS][6];
|
|||
extern int16_t mirrorsector[64];
|
||||
extern int16_t mirrorwall[64];
|
||||
|
||||
extern int lockclock;
|
||||
|
||||
extern int wupass;
|
||||
extern int chickenplant;
|
||||
extern int thunderon;
|
||||
|
|
|
@ -118,22 +118,33 @@ inline bool isIn(int value, const std::initializer_list<int>& list)
|
|||
// these are mainly here to avoid directly accessing the input data so that it can be more easily refactored later.
|
||||
inline bool PlayerInput(int pl, ESyncBits bit)
|
||||
{
|
||||
return (!!((sync[pl].sbits) & bit));
|
||||
}
|
||||
|
||||
inline void PlayerSetInput(int pl, ESyncBits bit)
|
||||
{
|
||||
sync[pl].sbits |= bit;
|
||||
}
|
||||
|
||||
inline void PlayerClearInput(int pl, ESyncBits bit)
|
||||
{
|
||||
sync[pl].sbits &= ~bit;
|
||||
return (!!((sync[pl].actions) & bit));
|
||||
}
|
||||
|
||||
inline ESyncBits PlayerInputBits(int pl, ESyncBits bits)
|
||||
{
|
||||
return (sync[pl].sbits & bits);
|
||||
return (sync[pl].actions & bits);
|
||||
}
|
||||
|
||||
inline void PlayerSetInput(int pl, ESyncBits bit)
|
||||
{
|
||||
sync[pl].actions |= bit;
|
||||
}
|
||||
|
||||
|
||||
inline int PlayerNewWeapon(int pl)
|
||||
{
|
||||
return sync[pl].getNewWeapon();
|
||||
}
|
||||
|
||||
inline void PlayerSetItemUsed(int pl, int num)
|
||||
{
|
||||
sync[pl].setItemUsed(num - 1);
|
||||
}
|
||||
|
||||
inline bool PlayerUseItem(int pl, int num)
|
||||
{
|
||||
return sync[pl].isItemUsed(num - 1);
|
||||
}
|
||||
|
||||
inline int PlayerInputSideVel(int pl)
|
||||
|
@ -151,6 +162,11 @@ inline fixed_t PlayerInputAngVel(int pl)
|
|||
return sync[pl].q16avel;
|
||||
}
|
||||
|
||||
inline fixed_t PlayerHorizon(int pl)
|
||||
{
|
||||
return sync[pl].q16horz;
|
||||
}
|
||||
|
||||
inline void clearfriction()
|
||||
{
|
||||
for (int i = 0; i != -1; i = connectpoint2[i])
|
||||
|
|
|
@ -39,14 +39,12 @@ source as it is released.
|
|||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
static int WeaponToSend;
|
||||
static ESyncBits BitsToSend;
|
||||
|
||||
// State timer counters.
|
||||
static int nonsharedtimer;
|
||||
static int turnheldtime;
|
||||
static int lastcontroltime;
|
||||
static double lastCheck;
|
||||
static InputPacket loc; // input accumulation buffer.
|
||||
|
||||
void GameInterface::ResetFollowPos(bool message)
|
||||
{
|
||||
|
@ -68,48 +66,9 @@ void GameInterface::ResetFollowPos(bool message)
|
|||
|
||||
void nonsharedkeys(void)
|
||||
{
|
||||
if (ud.recstat == 2)
|
||||
{
|
||||
ControlInfo noshareinfo;
|
||||
CONTROL_GetInput(&noshareinfo);
|
||||
}
|
||||
|
||||
if (System_WantGuiCapture())
|
||||
return;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_See_Coop_View) && (ud.coop || ud.recstat == 2))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_See_Coop_View);
|
||||
screenpeek = connectpoint2[screenpeek];
|
||||
if (screenpeek == -1) screenpeek = 0;
|
||||
}
|
||||
|
||||
if ((ud.multimode > 1) && buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
|
||||
ud.showweapons = 1 - ud.showweapons;
|
||||
cl_showweapon = ud.showweapons;
|
||||
FTA(QUOTE_WEAPON_MODE_OFF - ud.showweapons, &ps[screenpeek]);
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Third_Person_View);
|
||||
|
||||
if (!isRRRA() || (!ps[myconnectindex].OnMotorcycle && !ps[myconnectindex].OnBoat))
|
||||
{
|
||||
if (ps[myconnectindex].over_shoulder_on)
|
||||
ps[myconnectindex].over_shoulder_on = 0;
|
||||
else
|
||||
{
|
||||
ps[myconnectindex].over_shoulder_on = 1;
|
||||
cameradist = 0;
|
||||
cameraclock = gameclock;
|
||||
}
|
||||
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
|
||||
}
|
||||
}
|
||||
|
||||
if (automapMode != am_off)
|
||||
{
|
||||
int j;
|
||||
|
@ -146,7 +105,6 @@ void hud_input(int snum)
|
|||
{
|
||||
int i, k;
|
||||
uint8_t dainv;
|
||||
unsigned int j;
|
||||
struct player_struct* p;
|
||||
short unk;
|
||||
|
||||
|
@ -154,7 +112,7 @@ void hud_input(int snum)
|
|||
p = &ps[snum];
|
||||
|
||||
i = p->aim_mode;
|
||||
p->aim_mode = PlayerInput(snum, SKB_AIMMODE);
|
||||
p->aim_mode = PlayerInput(snum, SB_AIMMODE);
|
||||
if (p->aim_mode < i)
|
||||
p->return_to_center = 9;
|
||||
|
||||
|
@ -163,7 +121,7 @@ void hud_input(int snum)
|
|||
|
||||
if (isRR())
|
||||
{
|
||||
if (PlayerInput(snum, SKB_QUICK_KICK) && p->last_pissed_time == 0)
|
||||
if (PlayerInput(snum, SB_QUICK_KICK) && p->last_pissed_time == 0)
|
||||
{
|
||||
if (!isRRRA() || sprite[p->i].extra > 0)
|
||||
{
|
||||
|
@ -181,7 +139,7 @@ void hud_input(int snum)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (PlayerInput(snum, SKB_QUICK_KICK) && p->quick_kick == 0 && (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0))
|
||||
if (PlayerInput(snum, SB_QUICK_KICK) && p->quick_kick == 0 && (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_QUICKKICK, -1, snum, -1);
|
||||
|
@ -193,9 +151,9 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!PlayerInput(snum, SKB_QUICK_KICK)) p->quick_kick_msg = false;
|
||||
if (!PlayerInput(snum, SB_QUICK_KICK)) p->quick_kick_msg = false;
|
||||
|
||||
if (!PlayerInputBits(snum, SKB_INTERFACE_BITS))
|
||||
if (!PlayerInputBits(snum, SB_INTERFACE_BITS))
|
||||
p->interface_toggle_flag = 0;
|
||||
else if (p->interface_toggle_flag == 0)
|
||||
{
|
||||
|
@ -206,25 +164,17 @@ void hud_input(int snum)
|
|||
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.
|
||||
if (PlayerInput(snum, SKB_INVENTORY) && p->newowner == -1)
|
||||
if (PlayerInput(snum, SB_INVUSE) && p->newowner == -1)
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_INVENTORY, -1, snum, -1);
|
||||
if (GetGameVarID(g_iReturnVarID, -1, snum) == 0)
|
||||
{
|
||||
switch (p->inven_icon)
|
||||
{
|
||||
// Yet another place where no symbolic constants were used. :(
|
||||
case ICON_JETPACK: PlayerSetInput(snum, SKB_JETPACK); break;
|
||||
case ICON_HOLODUKE: PlayerSetInput(snum, SKB_HOLODUKE); break;
|
||||
case ICON_HEATS: PlayerSetInput(snum, SKB_NIGHTVISION); break;
|
||||
case ICON_FIRSTAID: PlayerSetInput(snum, SKB_MEDKIT); break;
|
||||
case ICON_STEROIDS: PlayerSetInput(snum, SKB_STEROIDS); break;
|
||||
}
|
||||
if (p->inven_icon > ICON_NONE && p->inven_icon <= ICON_HEATS) PlayerSetItemUsed(snum, p->inven_icon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isRR() && PlayerInput(snum, SKB_NIGHTVISION))
|
||||
if (!isRR() && PlayerUseItem(snum, ICON_HEATS))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_USENIGHTVISION, -1, snum, -1);
|
||||
|
@ -238,7 +188,7 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (PlayerInput(snum, SKB_STEROIDS))
|
||||
if (PlayerUseItem(snum, ICON_STEROIDS))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_USESTEROIDS, -1, snum, -1);
|
||||
|
@ -255,11 +205,11 @@ void hud_input(int snum)
|
|||
return;
|
||||
}
|
||||
|
||||
if (PlayerInput(snum, SKB_INV_LEFT) || PlayerInput(snum, SKB_INV_RIGHT))
|
||||
if (PlayerInput(snum, SB_INVPREV) || PlayerInput(snum, SB_INVNEXT))
|
||||
{
|
||||
p->invdisptime = 26 * 2;
|
||||
|
||||
if (PlayerInput(snum, SKB_INV_RIGHT)) k = 1;
|
||||
if (PlayerInput(snum, SB_INVNEXT)) k = 1;
|
||||
else k = 0;
|
||||
|
||||
dainv = p->inven_icon;
|
||||
|
@ -321,13 +271,13 @@ void hud_input(int snum)
|
|||
else dainv = 0;
|
||||
|
||||
// These events force us to keep the inventory selector in the playsim as opposed to the UI where it really belongs.
|
||||
if (PlayerInput(snum, SKB_INV_LEFT))
|
||||
if (PlayerInput(snum, SB_INVPREV))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, dainv, -1, snum);
|
||||
OnEvent(EVENT_INVENTORYLEFT, -1, snum, -1);
|
||||
dainv = GetGameVarID(g_iReturnVarID, -1, snum);
|
||||
}
|
||||
if (PlayerInput(snum, SKB_INV_RIGHT))
|
||||
if (PlayerInput(snum, SB_INVNEXT))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, dainv, -1, snum);
|
||||
OnEvent(EVENT_INVENTORYRIGHT, -1, snum, -1);
|
||||
|
@ -339,18 +289,14 @@ void hud_input(int snum)
|
|||
if (dainv >= 1 && dainv < 8) FTA(invquotes[dainv - 1], p);
|
||||
}
|
||||
|
||||
j = (PlayerInputBits(snum, SKB_WEAPONMASK_BITS) / SKB_FIRST_WEAPON_BIT) - 1;
|
||||
if (j >= 0)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
if (j > 0 && p->kickback_pic > 0)
|
||||
p->wantweaponfire = j;
|
||||
int weap = PlayerNewWeapon(snum);
|
||||
if (weap > 1 && p->kickback_pic > 0)
|
||||
p->wantweaponfire = weap - 1;
|
||||
|
||||
// Here we have to be extra careful that the weapons do not get mixed up, so let's keep the code for Duke and RR completely separate.
|
||||
fi.selectweapon(snum, j);
|
||||
fi.selectweapon(snum, weap);
|
||||
|
||||
if (PlayerInput(snum, SKB_HOLSTER))
|
||||
if (PlayerInput(snum, SB_HOLSTER))
|
||||
{
|
||||
if (p->curr_weapon > KNEE_WEAPON)
|
||||
{
|
||||
|
@ -369,7 +315,7 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (PlayerInput(snum, SKB_HOLODUKE) && (isRR() || p->newowner == -1))
|
||||
if (PlayerUseItem(snum, ICON_HOLODUKE) && (isRR() || p->newowner == -1))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_HOLODUKEON, -1, snum, -1);
|
||||
|
@ -425,7 +371,7 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (isRR() && PlayerInput(snum, SKB_NIGHTVISION) && p->newowner == -1)
|
||||
if (isRR() && PlayerUseItem(snum, ICON_HEATS) && p->newowner == -1)
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_USENIGHTVISION, -1, snum, -1);
|
||||
|
@ -457,7 +403,7 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (PlayerInput(snum, SKB_MEDKIT))
|
||||
if (PlayerUseItem(snum, ICON_FIRSTAID))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_USEMEDKIT, -1, snum, -1);
|
||||
|
@ -467,7 +413,7 @@ void hud_input(int snum)
|
|||
{
|
||||
if (!isRR())
|
||||
{
|
||||
j = max_player_health - sprite[p->i].extra;
|
||||
int j = max_player_health - sprite[p->i].extra;
|
||||
|
||||
if ((unsigned int)p->firstaid_amount > j)
|
||||
{
|
||||
|
@ -485,7 +431,7 @@ void hud_input(int snum)
|
|||
}
|
||||
else
|
||||
{
|
||||
j = 10;
|
||||
int j = 10;
|
||||
if (p->firstaid_amount > j)
|
||||
{
|
||||
p->firstaid_amount -= j;
|
||||
|
@ -510,7 +456,7 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (PlayerInput(snum, SKB_JETPACK) && (isRR() || p->newowner == -1))
|
||||
if (PlayerUseItem(snum, ICON_JETPACK) && (isRR() || p->newowner == -1))
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_USEJETPACK, -1, snum, -1);
|
||||
|
@ -578,7 +524,7 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (PlayerInput(snum, SKB_TURNAROUND) && p->one_eighty_count == 0)
|
||||
if (PlayerInput(snum, SB_TURNAROUND) && p->one_eighty_count == 0)
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, -1, snum);
|
||||
OnEvent(EVENT_TURNAROUND, -1, snum, -1);
|
||||
|
@ -622,63 +568,27 @@ enum
|
|||
|
||||
static void processInputBits(player_struct *p, ControlInfo &info)
|
||||
{
|
||||
bool onVehicle = p->OnMotorcycle || p->OnBoat;
|
||||
if (buttonMap.ButtonDown(gamefunc_Fire)) loc.sbits |= SKB_FIRE;
|
||||
if (buttonMap.ButtonDown(gamefunc_Open)) loc.sbits |= SKB_OPEN;
|
||||
ApplyGlobalInput(loc, &info);
|
||||
if (isRR() && (loc.actions & SB_CROUCH)) loc.actions &= ~SB_JUMP;
|
||||
|
||||
// These 3 bits are only available when not riding a bike or boat.
|
||||
if (onVehicle) BitsToSend &= ~(SKB_HOLSTER|SKB_TURNAROUND|SKB_CENTER_VIEW);
|
||||
loc.sbits |= BitsToSend;
|
||||
BitsToSend = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
if (p->OnMotorcycle || p->OnBoat)
|
||||
{
|
||||
if (info.dx < 0 || info.dyaw < 0) loc.sbits |= SKB_INV_LEFT;
|
||||
if (info.dx > 0 || info.dyaw < 0) loc.sbits |= SKB_INV_RIGHT;
|
||||
// mask out all actions not compatible with vehicles.
|
||||
loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH | SB_RUN |
|
||||
SB_AIM_UP | SB_AIM_DOWN | SB_AIMMODE | SB_LOOK_UP | SB_LOOK_DOWN | SB_LOOK_LEFT | SB_LOOK_RIGHT);
|
||||
}
|
||||
|
||||
if (gamequit) loc.sbits |= SKB_GAMEQUIT;
|
||||
|
||||
if (!onVehicle)
|
||||
else
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Jump)) loc.sbits |= SKB_JUMP;
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || p->crouch_toggle)
|
||||
if (buttonMap.ButtonDown(gamefunc_Quick_Kick)) // this shares a bit with another function so cannot be in the common code.
|
||||
loc.actions |= SB_QUICK_KICK;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || p->crouch_toggle)
|
||||
{
|
||||
loc.sbits |= SKB_CROUCH;
|
||||
if (isRR()) loc.sbits &= ~SKB_JUMP;
|
||||
loc.actions |= SB_CROUCH;
|
||||
}
|
||||
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz > 0)) loc.sbits |= SKB_AIM_UP;
|
||||
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz < 0))) loc.sbits |= SKB_AIM_DOWN;
|
||||
if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run))) loc.sbits |= SKB_RUN;
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Left) || (isRR() && p->drink_amt > 88)) loc.sbits |= SKB_LOOK_LEFT;
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Right)) loc.sbits |= SKB_LOOK_RIGHT;
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Up)) loc.sbits |= SKB_LOOK_UP;
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Down) || (isRR() && p->drink_amt > 99)) loc.sbits |= SKB_LOOK_DOWN;
|
||||
if (buttonMap.ButtonDown(gamefunc_Quick_Kick)) loc.sbits |= SKB_QUICK_KICK;
|
||||
if (in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming)) loc.sbits |= SKB_AIMMODE;
|
||||
|
||||
int j = WeaponToSend;
|
||||
WeaponToSend = 0;
|
||||
if (VOLUMEONE && (j >= 7 && j <= 10)) j = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select) && info.dz > 0) j = 11;
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select) && info.dz < 0) j = 12;
|
||||
|
||||
if (j && (loc.sbits & SKB_WEAPONMASK_BITS) == 0)
|
||||
loc.sbits |= ESyncBits::FromInt(j * SKB_FIRST_WEAPON_BIT);
|
||||
|
||||
if ((isRR() && p->drink_amt > 88)) loc.actions |= SB_LOOK_LEFT;
|
||||
if ((isRR() && p->drink_amt > 99)) loc.actions |= SB_LOOK_DOWN;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
{
|
||||
// This eats the controller input for regular use
|
||||
info.dx = 0;
|
||||
info.dz = 0;
|
||||
info.dyaw = 0;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
info.dz = 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -725,10 +635,10 @@ int getticssincelastupdate()
|
|||
|
||||
static void processMovement(player_struct *p, InputPacket &input, ControlInfo &info, double scaleFactor)
|
||||
{
|
||||
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
||||
bool mouseaim = !!(loc.actions & SB_AIMMODE);
|
||||
|
||||
// JBF: Run key behaviour is selectable
|
||||
int running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||
int running = !!(loc.actions & SB_RUN);
|
||||
int turnamount = NORMALTURN << running;
|
||||
int keymove = NORMALKEYMOVE << running;
|
||||
|
||||
|
@ -1019,17 +929,17 @@ static void processVehicleInput(player_struct *p, ControlInfo& info, InputPacket
|
|||
if (p->OnBoat || !p->moto_underwater)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
loc.sbits |= SKB_JUMP;
|
||||
loc.actions |= SB_JUMP;
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
loc.sbits |= SKB_AIM_UP;
|
||||
if (buttonMap.ButtonDown(gamefunc_Run))
|
||||
loc.sbits |= SKB_CROUCH;
|
||||
loc.actions |= SB_AIM_UP;
|
||||
if (loc.actions & SB_RUN)
|
||||
loc.actions |= SB_CROUCH;
|
||||
}
|
||||
|
||||
if (turnl)
|
||||
loc.sbits |= SKB_AIM_DOWN;
|
||||
loc.actions |= SB_AIM_DOWN;
|
||||
if (turnr)
|
||||
loc.sbits |= SKB_LOOK_LEFT;
|
||||
loc.actions |= SB_LOOK_LEFT;
|
||||
|
||||
double turnvel;
|
||||
|
||||
|
@ -1124,7 +1034,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GetInput()
|
||||
static void GetInputInternal(InputPacket &locInput)
|
||||
{
|
||||
double elapsedInputTicks;
|
||||
auto const p = &ps[myconnectindex];
|
||||
|
@ -1139,7 +1049,6 @@ void GetInput()
|
|||
if (paused)
|
||||
{
|
||||
loc = {};
|
||||
if (gamequit) loc.sbits |= SKB_GAMEQUIT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1167,9 +1076,9 @@ void GetInput()
|
|||
}
|
||||
else
|
||||
{
|
||||
processInputBits(p, info);
|
||||
processMovement(p, input, info, scaleAdjust);
|
||||
checkCrouchToggle(p);
|
||||
processInputBits(p, info);
|
||||
FinalizeInput(myconnectindex, input, false);
|
||||
}
|
||||
|
||||
|
@ -1178,60 +1087,51 @@ void GetInput()
|
|||
// Do these in the same order as the old code.
|
||||
calcviewpitch(p, scaleAdjust);
|
||||
applylook(myconnectindex, scaleAdjust, input.q16avel);
|
||||
sethorizon(myconnectindex, loc.sbits, scaleAdjust, input.q16horz);
|
||||
sethorizon(myconnectindex, loc.actions, scaleAdjust, input.q16horz);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic
|
||||
// registration to only have the commands active when this game module runs.
|
||||
// External entry point
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static int ccmd_slot(CCmdFuncPtr parm)
|
||||
void GameInterface::GetInput(InputPacket* packet)
|
||||
{
|
||||
if (parm->numparms != 1) return CCMD_SHOWHELP;
|
||||
GetInputInternal(loc);
|
||||
if (packet)
|
||||
{
|
||||
auto const pPlayer = &ps[myconnectindex];
|
||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||
|
||||
auto slot = atoi(parm->parms[0]);
|
||||
if (slot >= 1 && slot <= 10)
|
||||
{
|
||||
WeaponToSend = slot;
|
||||
return CCMD_OK;
|
||||
*packet = loc;
|
||||
auto fvel = loc.fvel;
|
||||
auto svel = loc.svel;
|
||||
packet->fvel = mulscale9(fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||
mulscale9(svel, sintable[(q16ang + 2048) & 2047]) +
|
||||
pPlayer->fric.x;
|
||||
packet->svel = mulscale9(fvel, sintable[(q16ang + 2048) & 2047]) +
|
||||
mulscale9(svel, sintable[(q16ang + 1536) & 2047]) +
|
||||
pPlayer->fric.y;
|
||||
loc = {};
|
||||
}
|
||||
return CCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
void registerinputcommands()
|
||||
{
|
||||
C_RegisterFunction("slot", "slot <weaponslot>: select a weapon from the given slot (1-10)", ccmd_slot);
|
||||
C_RegisterFunction("weapprev", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 11; return CCMD_OK; });
|
||||
C_RegisterFunction("weapnext", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 12; return CCMD_OK; });
|
||||
C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_PAUSE; sendPause = true; return CCMD_OK; });
|
||||
C_RegisterFunction("steroids", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_STEROIDS; return CCMD_OK; });
|
||||
C_RegisterFunction("nightvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_NIGHTVISION; return CCMD_OK; });
|
||||
C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_MEDKIT; return CCMD_OK; });
|
||||
C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_CENTER_VIEW; return CCMD_OK; });
|
||||
C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLSTER; return CCMD_OK; });
|
||||
C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INV_LEFT; return CCMD_OK; });
|
||||
C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INV_RIGHT; return CCMD_OK; });
|
||||
C_RegisterFunction("holoduke", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLODUKE; return CCMD_OK; });
|
||||
C_RegisterFunction("jetpack", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_JETPACK; return CCMD_OK; });
|
||||
C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_TURNAROUND; return CCMD_OK; });
|
||||
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INVENTORY; return CCMD_OK; });
|
||||
C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_ESCAPE; return CCMD_OK; });
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::clearlocalinputstate()
|
||||
{
|
||||
WeaponToSend = 0;
|
||||
BitsToSend = 0;
|
||||
loc = {};
|
||||
nonsharedtimer = 0;
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
lastCheck = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -968,13 +968,13 @@ void playerweaponsway(player_struct* p, spritetype* s)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void checklook(int snum, int sb_snum)
|
||||
void checklook(int snum, ESyncBits actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
|
||||
p->lookLeft = false;
|
||||
p->lookRight = false;
|
||||
if ((sb_snum & SKB_LOOK_LEFT) && !p->OnMotorcycle)
|
||||
if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle)
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
|
||||
OnEvent(EVENT_LOOKLEFT, p->i, snum, -1);
|
||||
|
@ -984,7 +984,7 @@ void checklook(int snum, int sb_snum)
|
|||
}
|
||||
}
|
||||
|
||||
if ((sb_snum & SKB_LOOK_RIGHT) && !p->OnMotorcycle)
|
||||
if ((actions & SB_LOOK_RIGHT) && !p->OnMotorcycle)
|
||||
{
|
||||
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
|
||||
OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1);
|
||||
|
@ -1002,14 +1002,14 @@ void checklook(int snum, int sb_snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void sethorizon(int snum, int sb_snum, double factor, fixed_t adjustment)
|
||||
void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
|
||||
// Calculate adjustment as true pitch (Fixed point math really sucks...)
|
||||
double horizAngle = clamp2(atan2(p->q16horiz - F16(100), F16(128)) * (512. / pi::pi()) + (factor * p->pitchAdjust) + (adjustment / 65536.), -180, 180);
|
||||
|
||||
if (p->return_to_center > 0 && (sb_snum & (SKB_LOOK_UP | SKB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed.
|
||||
if (p->return_to_center > 0 && (actions & (SB_LOOK_UP | SB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed.
|
||||
{
|
||||
p->return_to_center += -factor * (p->return_to_center / 2);
|
||||
horizAngle += -factor * (horizAngle / 2);
|
||||
|
@ -1050,7 +1050,7 @@ void playerCenterView(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
void playerLookUp(int snum, ESyncBits sb_snum)
|
||||
void playerLookUp(int snum, ESyncBits actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
|
||||
|
@ -1058,11 +1058,11 @@ void playerLookUp(int snum, ESyncBits sb_snum)
|
|||
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
|
||||
{
|
||||
p->return_to_center = 9;
|
||||
p->pitchAdjust += (sb_snum & SKB_RUN) ? 12 : 24;
|
||||
p->pitchAdjust += (actions & SB_RUN) ? 12 : 24;
|
||||
}
|
||||
}
|
||||
|
||||
void playerLookDown(int snum, ESyncBits sb_snum)
|
||||
void playerLookDown(int snum, ESyncBits actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
|
||||
|
@ -1070,29 +1070,29 @@ void playerLookDown(int snum, ESyncBits sb_snum)
|
|||
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
|
||||
{
|
||||
p->return_to_center = 9;
|
||||
p->pitchAdjust -= (sb_snum & SKB_RUN) ? 12 : 24;
|
||||
p->pitchAdjust -= (actions & SB_RUN) ? 12 : 24;
|
||||
}
|
||||
}
|
||||
|
||||
void playerAimUp(int snum, ESyncBits sb_snum)
|
||||
void playerAimUp(int snum, ESyncBits actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
|
||||
OnEvent(EVENT_AIMUP, p->i, snum, -1);
|
||||
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
|
||||
{
|
||||
p->pitchAdjust += (sb_snum & SKB_RUN) ? 6 : 12;
|
||||
p->pitchAdjust += (actions & SB_RUN) ? 6 : 12;
|
||||
}
|
||||
}
|
||||
|
||||
void playerAimDown(int snum, ESyncBits sb_snum)
|
||||
void playerAimDown(int snum, ESyncBits actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
|
||||
OnEvent(EVENT_AIMDOWN, p->i, snum, -1);
|
||||
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
|
||||
{
|
||||
p->pitchAdjust -= (sb_snum & SKB_RUN) ? 6 : 12;
|
||||
p->pitchAdjust -= (actions & SB_RUN) ? 6 : 12;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ source as it is released.
|
|||
BEGIN_DUKE_NS
|
||||
|
||||
void fireweapon_ww(int snum);
|
||||
void operateweapon_ww(int snum, ESyncBits sb_snum, int psect);
|
||||
void operateweapon_ww(int snum, ESyncBits actions, int psect);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -1099,18 +1099,39 @@ void shoot_d(int i, int atwith)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void selectweapon_d(int snum, int j) // playernum, weaponnum
|
||||
void selectweapon_d(int snum, int weap) // playernum, weaponnum
|
||||
{
|
||||
int i, k;
|
||||
int i, j, k;
|
||||
auto p = &ps[snum];
|
||||
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && sprite[p->i].xrepeat > 32 && p->access_incs == 0 && p->knee_incs == 0)
|
||||
{
|
||||
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))
|
||||
{
|
||||
if (j == 10 || j == 11)
|
||||
if (weap == WeaponSel_Alt)
|
||||
{
|
||||
switch (p->curr_weapon)
|
||||
{
|
||||
case SHRINKER_WEAPON:
|
||||
j = PLUTOPAK ? GROW_WEAPON : p->curr_weapon;
|
||||
break;
|
||||
case GROW_WEAPON:
|
||||
j = SHRINKER_WEAPON;
|
||||
break;
|
||||
case FREEZE_WEAPON:
|
||||
j = isWorldTour() ? FLAMETHROWER_WEAPON : p->curr_weapon;
|
||||
break;
|
||||
case FLAMETHROWER_WEAPON:
|
||||
j = FREEZE_WEAPON;
|
||||
break;
|
||||
default:
|
||||
j = p->curr_weapon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (weap == WeaponSel_Next || weap == WeaponSel_Prev)
|
||||
{
|
||||
k = p->curr_weapon;
|
||||
j = (j == 10 ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice
|
||||
j = (weap == WeaponSel_Prev ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice
|
||||
i = 0;
|
||||
|
||||
while ((k >= 0 && k < 10) || (PLUTOPAK && k == GROW_WEAPON && (p->subweapon & (1 << GROW_WEAPON)) != 0)
|
||||
|
@ -1186,10 +1207,10 @@ void selectweapon_d(int snum, int j) // playernum, weaponnum
|
|||
}
|
||||
}
|
||||
}
|
||||
else j = weap - 1;
|
||||
|
||||
k = -1;
|
||||
|
||||
|
||||
if (j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0)
|
||||
{
|
||||
k = headspritestat[1];
|
||||
|
@ -1260,7 +1281,7 @@ void selectweapon_d(int snum, int j) // playernum, weaponnum
|
|||
|
||||
if (p->holster_weapon)
|
||||
{
|
||||
PlayerSetInput(snum, SKB_HOLSTER);
|
||||
PlayerSetInput(snum, SB_HOLSTER);
|
||||
p->weapon_pos = -9;
|
||||
}
|
||||
else if (j >= MIN_WEAPON && p->gotweapon[j] && (unsigned int)p->curr_weapon != j) switch (j)
|
||||
|
@ -1318,8 +1339,6 @@ int doincrements_d(struct player_struct* p)
|
|||
int snum;
|
||||
|
||||
snum = sprite[p->i].yvel;
|
||||
// j = sync[snum].avel;
|
||||
// p->weapon_ang = -(j/5);
|
||||
|
||||
p->player_par++;
|
||||
|
||||
|
@ -1494,7 +1513,7 @@ int doincrements_d(struct player_struct* p)
|
|||
}
|
||||
S_PlayActorSound(DUKE_CRACK_FIRST, p->i);
|
||||
}
|
||||
else if (p->knuckle_incs == 22 || PlayerInput(snum, SKB_FIRE))
|
||||
else if (p->knuckle_incs == 22 || PlayerInput(snum, SB_FIRE))
|
||||
p->knuckle_incs = 0;
|
||||
|
||||
return 1;
|
||||
|
@ -1548,7 +1567,7 @@ void checkweapons_d(struct player_struct* p)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void operateJetpack(int snum, ESyncBits sb_snum, int psectlotag, int fz, int cz, int shrunk)
|
||||
static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, int cz, int shrunk)
|
||||
{
|
||||
int j;
|
||||
auto p = &ps[snum];
|
||||
|
@ -1578,7 +1597,7 @@ static void operateJetpack(int snum, ESyncBits sb_snum, int psectlotag, int fz,
|
|||
if (shrunk) j = 512;
|
||||
else j = 2048;
|
||||
|
||||
if (sb_snum & SKB_JUMP) //A (soar high)
|
||||
if (actions & SB_JUMP) //A (soar high)
|
||||
{
|
||||
// jump
|
||||
SetGameVarID(g_iReturnVarID, 0, pi, snum);
|
||||
|
@ -1590,7 +1609,7 @@ static void operateJetpack(int snum, ESyncBits sb_snum, int psectlotag, int fz,
|
|||
}
|
||||
}
|
||||
|
||||
if (sb_snum & SKB_CROUCH) //Z (soar low)
|
||||
if (actions & SB_CROUCH) //Z (soar low)
|
||||
{
|
||||
// crouch
|
||||
SetGameVarID(g_iReturnVarID, 0, pi, snum);
|
||||
|
@ -1622,7 +1641,7 @@ static void operateJetpack(int snum, ESyncBits sb_snum, int psectlotag, int fz,
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag)
|
||||
static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag)
|
||||
{
|
||||
int j;
|
||||
auto p = &ps[snum];
|
||||
|
@ -1671,7 +1690,7 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
{
|
||||
|
||||
// not jumping or crouching
|
||||
if ((sb_snum & (SKB_JUMP|SKB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8)))
|
||||
if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8)))
|
||||
p->posz = fz - (i << 8);
|
||||
else
|
||||
{
|
||||
|
@ -1747,27 +1766,27 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
|
||||
p->on_warping_sector = 0;
|
||||
|
||||
if (sb_snum & SKB_CROUCH)
|
||||
if (actions & SB_CROUCH)
|
||||
{
|
||||
playerCrouch(snum);
|
||||
}
|
||||
|
||||
// jumping
|
||||
if ((sb_snum & SKB_JUMP) == 0 && p->jumping_toggle == 1)
|
||||
if ((actions & SB_JUMP) == 0 && p->jumping_toggle == 1)
|
||||
p->jumping_toggle = 0;
|
||||
|
||||
else if ((sb_snum & SKB_JUMP))
|
||||
else if ((actions & SB_JUMP))
|
||||
{
|
||||
playerJump(snum, fz, cz);
|
||||
}
|
||||
|
||||
if (p->jumping_counter && (sb_snum & SKB_JUMP) == 0)
|
||||
if (p->jumping_counter && (actions & SB_JUMP) == 0)
|
||||
p->jumping_toggle = 0;
|
||||
}
|
||||
|
||||
if (p->jumping_counter)
|
||||
{
|
||||
if ((sb_snum & SKB_JUMP) == 0 && p->jumping_toggle == 1)
|
||||
if ((actions & SB_JUMP) == 0 && p->jumping_toggle == 1)
|
||||
p->jumping_toggle = 0;
|
||||
|
||||
if (p->jumping_counter < (1024 + 256))
|
||||
|
@ -1809,7 +1828,7 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void underwater(int snum, ESyncBits sb_snum, int psect, int fz, int cz)
|
||||
static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz)
|
||||
{
|
||||
int j;
|
||||
auto p = &ps[snum];
|
||||
|
@ -1826,14 +1845,14 @@ static void underwater(int snum, ESyncBits sb_snum, int psect, int fz, int cz)
|
|||
if (!S_CheckActorSoundPlaying(pi, DUKE_UNDERWATER))
|
||||
S_PlayActorSound(DUKE_UNDERWATER, pi);
|
||||
|
||||
if (sb_snum & SKB_JUMP)
|
||||
if (actions & SB_JUMP)
|
||||
{
|
||||
// jump
|
||||
if (p->poszv > 0) p->poszv = 0;
|
||||
p->poszv -= 348;
|
||||
if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6);
|
||||
}
|
||||
else if (sb_snum & SKB_CROUCH)
|
||||
else if (actions & SB_CROUCH)
|
||||
{
|
||||
// crouch
|
||||
if (p->poszv < 0) p->poszv = 0;
|
||||
|
@ -2058,7 +2077,7 @@ static void fireweapon(int snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
||||
static void operateweapon(int snum, ESyncBits actions, int psect)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
int pi = p->i;
|
||||
|
@ -2069,7 +2088,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
switch (p->curr_weapon)
|
||||
{
|
||||
case HANDBOMB_WEAPON: // grenade in NAM
|
||||
if (p->kickback_pic == 6 && (sb_snum & SKB_FIRE))
|
||||
if (p->kickback_pic == 6 && (actions & SB_FIRE))
|
||||
{
|
||||
p->rapid_fire_hold = 1;
|
||||
break;
|
||||
|
@ -2079,7 +2098,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
{
|
||||
p->ammo_amount[HANDBOMB_WEAPON]--;
|
||||
|
||||
if (p->on_ground && (sb_snum & SKB_CROUCH))
|
||||
if (p->on_ground && (actions & SB_CROUCH))
|
||||
{
|
||||
k = 15;
|
||||
i = ((p->gethorizsum() - 100) * 20);
|
||||
|
@ -2118,7 +2137,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
p->hbomb_on = 1;
|
||||
|
||||
}
|
||||
else if (p->kickback_pic < 12 && (sb_snum & SKB_FIRE))
|
||||
else if (p->kickback_pic < 12 && (actions & SB_FIRE))
|
||||
p->hbomb_hold_delay++;
|
||||
else if (p->kickback_pic > 19)
|
||||
{
|
||||
|
@ -2278,7 +2297,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
p->visibility = 0;
|
||||
checkavailweapon(p);
|
||||
|
||||
if ((sb_snum & SKB_FIRE) == 0)
|
||||
if ((actions & SB_FIRE) == 0)
|
||||
{
|
||||
p->okickback_pic = p->kickback_pic = 0;
|
||||
break;
|
||||
|
@ -2287,7 +2306,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
else if (p->kickback_pic > 10)
|
||||
{
|
||||
if (sb_snum & SKB_FIRE) p->okickback_pic = p->kickback_pic = 1;
|
||||
if (actions & SB_FIRE) p->okickback_pic = p->kickback_pic = 1;
|
||||
else p->okickback_pic = p->kickback_pic = 0;
|
||||
}
|
||||
|
||||
|
@ -2425,7 +2444,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (sb_snum & SKB_FIRE)
|
||||
if (actions & SB_FIRE)
|
||||
{
|
||||
p->okickback_pic = p->kickback_pic = 1;
|
||||
S_PlayActorSound(CAT_FIRE, pi);
|
||||
|
@ -2451,7 +2470,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
else if (p->kickback_pic == 16)
|
||||
{
|
||||
if ((sb_snum & SKB_FIRE) != 0)
|
||||
if ((actions & SB_FIRE) != 0)
|
||||
{
|
||||
p->okickback_pic = p->kickback_pic = 1;
|
||||
S_PlayActorSound(FLAMETHROWER_INTRO, pi);
|
||||
|
@ -2483,7 +2502,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
if (p->kickback_pic == 7) fi.shoot(pi, KNEE);
|
||||
else if (p->kickback_pic == 14)
|
||||
{
|
||||
if (sb_snum & SKB_FIRE)
|
||||
if (actions & SB_FIRE)
|
||||
p->okickback_pic = p->kickback_pic = 1 + (krand() & 3);
|
||||
else p->okickback_pic = p->kickback_pic = 0;
|
||||
}
|
||||
|
@ -2514,7 +2533,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
||||
static void processweapon(int snum, ESyncBits actions, int psect)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
int pi = p->i;
|
||||
|
@ -2542,7 +2561,7 @@ static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
max_ammo_amount[PISTOL_WEAPON] = pistolNewMaximum;
|
||||
}
|
||||
|
||||
if (isNamWW2GI() && (sb_snum & SKB_HOLSTER)) // 'Holster Weapon
|
||||
if (isNamWW2GI() && (actions & SB_HOLSTER)) // 'Holster Weapon
|
||||
{
|
||||
if (isWW2GI())
|
||||
{
|
||||
|
@ -2564,7 +2583,7 @@ static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum];
|
||||
// p->kickback_pic = aplWeaponFireDelay[p->curr_weapon][snum]+1; // animate, but don't shoot...
|
||||
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum] + 1; // animate, but don't shoot...
|
||||
sb_snum &= ~SKB_FIRE; // not firing...
|
||||
actions &= ~SB_FIRE; // not firing...
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2577,7 +2596,7 @@ static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
// throw away the remaining clip
|
||||
p->ammo_amount[PISTOL_WEAPON] -= p->ammo_amount[PISTOL_WEAPON] % 20;
|
||||
p->kickback_pic = 3; // animate, but don't shoot...
|
||||
sb_snum &= ~SKB_FIRE; // not firing...
|
||||
actions &= ~SB_FIRE; // not firing...
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2592,13 +2611,13 @@ static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
|
||||
if (p->rapid_fire_hold == 1)
|
||||
{
|
||||
if (sb_snum & SKB_FIRE) return;
|
||||
if (actions & SB_FIRE) return;
|
||||
p->rapid_fire_hold = 0;
|
||||
}
|
||||
|
||||
if (shrunk || p->tipincs || p->access_incs)
|
||||
sb_snum &= ~SKB_FIRE;
|
||||
else if (shrunk == 0 && (sb_snum & SKB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 &&
|
||||
actions &= ~SB_FIRE;
|
||||
else if (shrunk == 0 && (actions & SB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 &&
|
||||
p->last_weapon == -1 && (p->weapon_pos == 0 || p->holster_weapon == 1))
|
||||
{
|
||||
if (!isWW2GI()) fireweapon(snum);
|
||||
|
@ -2606,8 +2625,8 @@ static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
else if (p->kickback_pic)
|
||||
{
|
||||
if (!isWW2GI()) operateweapon(snum, sb_snum, psect);
|
||||
else operateweapon_ww(snum, sb_snum, psect);
|
||||
if (!isWW2GI()) operateweapon(snum, actions, psect);
|
||||
else operateweapon_ww(snum, actions, psect);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -2620,7 +2639,7 @@ void processinput_d(int snum)
|
|||
{
|
||||
int j, i, k, doubvel, fz, cz, hz, lz, truefdist;
|
||||
char shrunk;
|
||||
ESyncBits sb_snum;
|
||||
ESyncBits actions;
|
||||
short psect, psectlotag, pi;
|
||||
struct player_struct* p;
|
||||
spritetype* s;
|
||||
|
@ -2631,7 +2650,7 @@ void processinput_d(int snum)
|
|||
|
||||
resetinputhelpers(p);
|
||||
|
||||
sb_snum = PlayerInputBits(snum, SKB_ALL);
|
||||
actions = PlayerInputBits(snum, SB_ALL);
|
||||
|
||||
auto sb_fvel = PlayerInputForwardVel(snum);
|
||||
auto sb_svel = PlayerInputSideVel(snum);
|
||||
|
@ -2754,14 +2773,14 @@ void processinput_d(int snum)
|
|||
|
||||
fi.doincrements(p);
|
||||
|
||||
if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, sb_snum, psect);
|
||||
if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, sb_snum, psect);
|
||||
if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, actions, psect);
|
||||
if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions, psect);
|
||||
return;
|
||||
}
|
||||
|
||||
doubvel = TICSPERFRAME;
|
||||
|
||||
checklook(snum,sb_snum);
|
||||
checklook(snum,actions);
|
||||
|
||||
if (p->on_crane >= 0)
|
||||
goto HORIZONLY;
|
||||
|
@ -2779,16 +2798,16 @@ void processinput_d(int snum)
|
|||
|
||||
if (psectlotag == ST_2_UNDERWATER)
|
||||
{
|
||||
underwater(snum, sb_snum, psect, fz, cz);
|
||||
underwater(snum, actions, psect, fz, cz);
|
||||
}
|
||||
|
||||
else if (p->jetpack_on)
|
||||
{
|
||||
operateJetpack(snum, sb_snum, psectlotag, fz, cz, shrunk);
|
||||
operateJetpack(snum, actions, psectlotag, fz, cz, shrunk);
|
||||
}
|
||||
else if (psectlotag != ST_2_UNDERWATER)
|
||||
{
|
||||
movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
movement(snum, actions, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
}
|
||||
|
||||
p->psectlotag = psectlotag;
|
||||
|
@ -2895,8 +2914,8 @@ void processinput_d(int snum)
|
|||
|
||||
bool check;
|
||||
|
||||
if (!isWW2GI()) check = ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (sb_snum & SKB_CROUCH)));
|
||||
else check = ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (sb_snum & SKB_CROUCH)));
|
||||
if (!isWW2GI()) check = ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)));
|
||||
else check = ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)));
|
||||
if (check)
|
||||
{
|
||||
p->posxv = mulscale(p->posxv, dukefriction - 0x2000, 16);
|
||||
|
@ -3016,30 +3035,30 @@ HORIZONLY:
|
|||
}
|
||||
|
||||
// center_view
|
||||
if (sb_snum & SKB_CENTER_VIEW || p->hard_landing)
|
||||
if (actions & SB_CENTERVIEW || p->hard_landing)
|
||||
{
|
||||
playerCenterView(snum);
|
||||
}
|
||||
else if (sb_snum & SKB_LOOK_UP)
|
||||
else if (actions & SB_LOOK_UP)
|
||||
{
|
||||
playerLookUp(snum, sb_snum);
|
||||
playerLookUp(snum, actions);
|
||||
}
|
||||
else if (sb_snum & SKB_LOOK_DOWN)
|
||||
else if (actions & SB_LOOK_DOWN)
|
||||
{
|
||||
playerLookDown(snum, sb_snum);
|
||||
playerLookDown(snum, actions);
|
||||
}
|
||||
else if (sb_snum & SKB_AIM_UP)
|
||||
else if (actions & SB_AIM_UP)
|
||||
{
|
||||
playerAimUp(snum, sb_snum);
|
||||
playerAimUp(snum, actions);
|
||||
}
|
||||
else if (sb_snum & SKB_AIM_DOWN)
|
||||
else if (actions & SB_AIM_DOWN)
|
||||
{ // aim_down
|
||||
playerAimDown(snum, sb_snum);
|
||||
playerAimDown(snum, actions);
|
||||
}
|
||||
|
||||
if (cl_syncinput)
|
||||
{
|
||||
sethorizon(snum, sb_snum, 1, sync[snum].q16horz);
|
||||
sethorizon(snum, actions, 1, PlayerHorizon(snum));
|
||||
}
|
||||
|
||||
checkhardlanding(p);
|
||||
|
@ -3081,30 +3100,25 @@ HORIZONLY:
|
|||
}
|
||||
|
||||
// HACKS
|
||||
processweapon(snum, sb_snum, psect);
|
||||
processweapon(snum, actions, psect);
|
||||
}
|
||||
|
||||
void processweapon_d(int s, ESyncBits ss, int p)
|
||||
{
|
||||
processweapon(s, ss, p);
|
||||
}
|
||||
|
||||
void processmove_d(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist)
|
||||
void processmove_d(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist)
|
||||
{
|
||||
int psectlotag = sector[psect].lotag;
|
||||
auto p = &ps[snum];
|
||||
if (psectlotag == 2)
|
||||
{
|
||||
underwater(snum, sb_snum, psect, fz, cz);
|
||||
underwater(snum, actions, psect, fz, cz);
|
||||
}
|
||||
|
||||
else if (p->jetpack_on)
|
||||
{
|
||||
operateJetpack(snum, sb_snum, psectlotag, fz, cz, shrunk);
|
||||
operateJetpack(snum, actions, psectlotag, fz, cz, shrunk);
|
||||
}
|
||||
else if (psectlotag != 2)
|
||||
{
|
||||
movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
movement(snum, actions, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
}
|
||||
}
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -947,15 +947,48 @@ void shoot_r(int i, int atwith)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void selectweapon_r(int snum, int j)
|
||||
void selectweapon_r(int snum, int weap)
|
||||
{
|
||||
int i, k;
|
||||
int i, j, k;
|
||||
auto p = &ps[snum];
|
||||
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && sprite[p->i].xrepeat > 8 && p->access_incs == 0 && p->knee_incs == 0)
|
||||
{
|
||||
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))
|
||||
{
|
||||
if (j == 10 || j == 11)
|
||||
if (weap == WeaponSel_Alt)
|
||||
{
|
||||
switch (p->curr_weapon)
|
||||
{
|
||||
case THROWSAW_WEAPON:
|
||||
j = BUZZSAW_WEAPON;
|
||||
break;
|
||||
case BUZZSAW_WEAPON:
|
||||
j = THROWSAW_WEAPON;
|
||||
break;
|
||||
case POWDERKEG_WEAPON:
|
||||
j = BOWLING_WEAPON;
|
||||
break;
|
||||
case BOWLING_WEAPON:
|
||||
j = POWDERKEG_WEAPON;
|
||||
break;
|
||||
case KNEE_WEAPON:
|
||||
j = isRRRA() ? SLINGBLADE_WEAPON : p->curr_weapon;
|
||||
break;
|
||||
case SLINGBLADE_WEAPON:
|
||||
j = KNEE_WEAPON;
|
||||
break;
|
||||
case DYNAMITE_WEAPON:
|
||||
j = isRRRA() ? CHICKEN_WEAPON : p->curr_weapon;
|
||||
break;
|
||||
case CHICKEN_WEAPON:
|
||||
j = DYNAMITE_WEAPON;
|
||||
break;
|
||||
default:
|
||||
j = p->curr_weapon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (weap == WeaponSel_Next || weap == WeaponSel_Prev)
|
||||
{
|
||||
k = p->curr_weapon;
|
||||
if (isRRRA())
|
||||
|
@ -964,7 +997,7 @@ void selectweapon_r(int snum, int j)
|
|||
else if (k == BUZZSAW_WEAPON) k = THROWSAW_WEAPON;
|
||||
else if (k == SLINGBLADE_WEAPON) k = KNEE_WEAPON;
|
||||
}
|
||||
j = (j == 10 ? -1 : 1);
|
||||
j = (weap == WeaponSel_Prev ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice
|
||||
i = 0;
|
||||
|
||||
while (k >= 0 && k < 10)
|
||||
|
@ -987,10 +1020,10 @@ void selectweapon_r(int snum, int j)
|
|||
}
|
||||
}
|
||||
}
|
||||
else j = weap - 1;
|
||||
|
||||
k = -1;
|
||||
|
||||
|
||||
if (j == DYNAMITE_WEAPON && p->ammo_amount[DYNAMITE_WEAPON] == 0)
|
||||
{
|
||||
k = headspritestat[1];
|
||||
|
@ -1063,7 +1096,7 @@ void selectweapon_r(int snum, int j)
|
|||
|
||||
if (p->holster_weapon)
|
||||
{
|
||||
PlayerSetInput(snum, SKB_HOLSTER);
|
||||
PlayerSetInput(snum, SB_HOLSTER);
|
||||
p->weapon_pos = -9;
|
||||
}
|
||||
else if (j >= MIN_WEAPON && p->gotweapon[j] && p->curr_weapon != j) switch (j)
|
||||
|
@ -1174,8 +1207,6 @@ int doincrements_r(struct player_struct* p)
|
|||
}
|
||||
|
||||
snum = sprite[p->i].yvel;
|
||||
// j = sync[snum].avel;
|
||||
// p->weapon_ang = -(j/5);
|
||||
|
||||
p->player_par++;
|
||||
if (p->yehaa_timer)
|
||||
|
@ -1407,7 +1438,7 @@ int doincrements_r(struct player_struct* p)
|
|||
else S_PlayActorSound(DUKE_CRACK2, p->i);
|
||||
}
|
||||
}
|
||||
else if (p->knuckle_incs == 22 || PlayerInput(snum, SKB_FIRE))
|
||||
else if (p->knuckle_incs == 22 || PlayerInput(snum, SB_FIRE))
|
||||
p->knuckle_incs = 0;
|
||||
|
||||
return 1;
|
||||
|
@ -1509,7 +1540,7 @@ void checkweapons_r(struct player_struct* p)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void onMotorcycle(int snum, ESyncBits &sb_snum)
|
||||
static void onMotorcycle(int snum, ESyncBits &actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
auto pi = p->i;
|
||||
|
@ -1519,18 +1550,18 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
|
|||
short var84;
|
||||
if (p->MotoSpeed < 0)
|
||||
p->MotoSpeed = 0;
|
||||
if (sb_snum & SKB_CROUCH)
|
||||
if (actions & SB_CROUCH)
|
||||
{
|
||||
var64 = 1;
|
||||
sb_snum &= ~SKB_CROUCH;
|
||||
actions &= ~SB_CROUCH;
|
||||
}
|
||||
else
|
||||
var64 = 0;
|
||||
|
||||
if (sb_snum & SKB_JUMP)
|
||||
if (actions & SB_JUMP)
|
||||
{
|
||||
var68 = 1;
|
||||
sb_snum &= ~SKB_JUMP;
|
||||
actions &= ~SB_JUMP;
|
||||
if (p->on_ground)
|
||||
{
|
||||
if (p->MotoSpeed == 0 && var64)
|
||||
|
@ -1572,29 +1603,29 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
|
|||
if (!S_CheckActorSoundPlaying(pi, 189) && !S_CheckActorSoundPlaying(pi, 187))
|
||||
S_PlayActorSound(187, pi);
|
||||
}
|
||||
if (sb_snum & SKB_AIM_UP)
|
||||
if (actions & SB_AIM_UP)
|
||||
{
|
||||
var6c = 1;
|
||||
sb_snum &= ~SKB_AIM_UP;
|
||||
actions &= ~SB_AIM_UP;
|
||||
}
|
||||
else
|
||||
var6c = 0;
|
||||
if (sb_snum & SKB_AIM_DOWN)
|
||||
if (actions & SB_AIM_DOWN)
|
||||
{
|
||||
var70 = 1;
|
||||
var74 = 1;
|
||||
sb_snum &= ~SKB_AIM_DOWN;
|
||||
actions &= ~SB_AIM_DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
var70 = 0;
|
||||
var74 = 0;
|
||||
}
|
||||
if (sb_snum & SKB_LOOK_LEFT)
|
||||
if (actions & SB_LOOK_LEFT)
|
||||
{
|
||||
var78 = 1;
|
||||
var7c = 1;
|
||||
sb_snum &= ~SKB_LOOK_LEFT;
|
||||
actions &= ~SB_LOOK_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1802,7 +1833,7 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void onBoat(int snum, ESyncBits& sb_snum)
|
||||
static void onBoat(int snum, ESyncBits &actions)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
auto pi = p->i;
|
||||
|
@ -1825,19 +1856,19 @@ static void onBoat(int snum, ESyncBits& sb_snum)
|
|||
}
|
||||
if (p->MotoSpeed < 0)
|
||||
p->MotoSpeed = 0;
|
||||
if ((sb_snum & SKB_CROUCH) && (sb_snum & SKB_JUMP))
|
||||
if ((actions & SB_CROUCH) && (actions & SB_JUMP))
|
||||
{
|
||||
vara8 = 1;
|
||||
varac = 0;
|
||||
varb0 = 0;
|
||||
sb_snum &= ~(SKB_JUMP|SKB_CROUCH);
|
||||
actions &= ~(SB_JUMP|SB_CROUCH);
|
||||
}
|
||||
else
|
||||
vara8 = 0;
|
||||
if (sb_snum & SKB_JUMP)
|
||||
if (actions & SB_JUMP)
|
||||
{
|
||||
varac = 1;
|
||||
sb_snum &= ~SKB_JUMP;
|
||||
actions &= ~SB_JUMP;
|
||||
if (p->MotoSpeed == 0 && !S_CheckActorSoundPlaying(pi, 89))
|
||||
{
|
||||
if (S_CheckActorSoundPlaying(pi, 87))
|
||||
|
@ -1868,24 +1899,24 @@ static void onBoat(int snum, ESyncBits& sb_snum)
|
|||
S_PlayActorSound(87, pi);
|
||||
}
|
||||
|
||||
if (sb_snum & SKB_CROUCH)
|
||||
if (actions & SB_CROUCH)
|
||||
{
|
||||
varb0 = 1;
|
||||
sb_snum &= ~SKB_CROUCH;
|
||||
actions &= ~SB_CROUCH;
|
||||
}
|
||||
else
|
||||
varb0 = 0;
|
||||
if (sb_snum & SKB_AIM_UP)
|
||||
if (actions & SB_AIM_UP)
|
||||
{
|
||||
varb4 = 1;
|
||||
sb_snum &= ~SKB_AIM_UP;
|
||||
actions &= ~SB_AIM_UP;
|
||||
}
|
||||
else varb4 = 0;
|
||||
if (sb_snum & SKB_AIM_DOWN)
|
||||
if (actions & SB_AIM_DOWN)
|
||||
{
|
||||
varb8 = 1;
|
||||
varbc = 1;
|
||||
sb_snum &= ~SKB_AIM_DOWN;
|
||||
actions &= ~SB_AIM_DOWN;
|
||||
if (!S_CheckActorSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater)
|
||||
S_PlayActorSound(91, pi);
|
||||
}
|
||||
|
@ -1894,11 +1925,11 @@ static void onBoat(int snum, ESyncBits& sb_snum)
|
|||
varb8 = 0;
|
||||
varbc = 0;
|
||||
}
|
||||
if (sb_snum & SKB_LOOK_LEFT)
|
||||
if (actions & SB_LOOK_LEFT)
|
||||
{
|
||||
varc0 = 1;
|
||||
varc4 = 1;
|
||||
sb_snum &= ~SKB_LOOK_LEFT;
|
||||
actions &= ~SB_LOOK_LEFT;
|
||||
if (!S_CheckActorSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater)
|
||||
S_PlayActorSound(91, pi);
|
||||
}
|
||||
|
@ -2086,7 +2117,7 @@ static void onBoat(int snum, ESyncBits& sb_snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag)
|
||||
static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
auto pi = p->i;
|
||||
|
@ -2144,7 +2175,7 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
|
||||
if (p->posz < (fz - (i << 8))) //falling
|
||||
{
|
||||
if ((sb_snum & (SKB_JUMP|SKB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8)))
|
||||
if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8)))
|
||||
p->posz = fz - (i << 8);
|
||||
else
|
||||
{
|
||||
|
@ -2258,15 +2289,15 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
|
||||
p->on_warping_sector = 0;
|
||||
|
||||
if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle)
|
||||
if ((actions & SB_CROUCH) && !p->OnMotorcycle)
|
||||
{
|
||||
playerCrouch(snum);
|
||||
}
|
||||
|
||||
if ((sb_snum & SKB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1)
|
||||
if ((actions & SB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1)
|
||||
p->jumping_toggle = 0;
|
||||
|
||||
else if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle && p->jumping_toggle == 0)
|
||||
else if ((actions & SB_JUMP) && !p->OnMotorcycle && p->jumping_toggle == 0)
|
||||
{
|
||||
playerJump(snum, fz, cz);
|
||||
}
|
||||
|
@ -2274,7 +2305,7 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
|
||||
if (p->jumping_counter)
|
||||
{
|
||||
if ((sb_snum & SKB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1)
|
||||
if ((actions & SB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1)
|
||||
p->jumping_toggle = 0;
|
||||
|
||||
if (p->jumping_counter < 768)
|
||||
|
@ -2316,7 +2347,7 @@ static void movement(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void underwater(int snum, ESyncBits sb_snum, int psect, int fz, int cz)
|
||||
static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz)
|
||||
{
|
||||
int j;
|
||||
auto p = &ps[snum];
|
||||
|
@ -2332,13 +2363,13 @@ static void underwater(int snum, ESyncBits sb_snum, int psect, int fz, int cz)
|
|||
if (!S_CheckActorSoundPlaying(pi, DUKE_UNDERWATER))
|
||||
S_PlayActorSound(DUKE_UNDERWATER, pi);
|
||||
|
||||
if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle)
|
||||
if ((actions & SB_JUMP) && !p->OnMotorcycle)
|
||||
{
|
||||
if (p->poszv > 0) p->poszv = 0;
|
||||
p->poszv -= 348;
|
||||
if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6);
|
||||
}
|
||||
else if ((sb_snum & SKB_CROUCH) || p->OnMotorcycle)
|
||||
else if ((actions & SB_CROUCH) || p->OnMotorcycle)
|
||||
{
|
||||
if (p->poszv < 0) p->poszv = 0;
|
||||
p->poszv += 348;
|
||||
|
@ -2740,7 +2771,7 @@ static void fireweapon(int snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
||||
static void operateweapon(int snum, ESyncBits actions, int psect)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
int pi = p->i;
|
||||
|
@ -2754,7 +2785,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
|
||||
if (p->kickback_pic == 1)
|
||||
S_PlaySound(401);
|
||||
if (p->kickback_pic == 6 && (sb_snum & SKB_FIRE))
|
||||
if (p->kickback_pic == 6 && (actions & SB_FIRE))
|
||||
p->rapid_fire_hold = 1;
|
||||
p->kickback_pic++;
|
||||
if (p->kickback_pic > 19)
|
||||
|
@ -2791,7 +2822,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
p->ammo_amount[DYNAMITE_WEAPON]--;
|
||||
if (p->ammo_amount[CROSSBOW_WEAPON])
|
||||
p->ammo_amount[CROSSBOW_WEAPON]--;
|
||||
if (p->on_ground && (sb_snum & SKB_CROUCH) && !p->OnMotorcycle)
|
||||
if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle)
|
||||
{
|
||||
k = 15;
|
||||
i = ((p->gethorizsum() - 100) * 20);
|
||||
|
@ -2824,7 +2855,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
|
||||
p->hbomb_on = 1;
|
||||
}
|
||||
else if (p->kickback_pic < 12 && (sb_snum & SKB_FIRE))
|
||||
else if (p->kickback_pic < 12 && (actions & SB_FIRE))
|
||||
p->hbomb_hold_delay++;
|
||||
|
||||
if (p->kickback_pic == 40)
|
||||
|
@ -2907,7 +2938,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
if (p->kickback_pic == 6)
|
||||
if (p->shotgun_state[0] == 0)
|
||||
if (p->ammo_amount[SHOTGUN_WEAPON] > 1)
|
||||
if (sb_snum & SKB_FIRE)
|
||||
if (actions & SB_FIRE)
|
||||
p->shotgun_state[1] = 1;
|
||||
|
||||
if (p->kickback_pic == 4)
|
||||
|
@ -3051,7 +3082,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
checkavailweapon(p);
|
||||
|
||||
if ((sb_snum & SKB_FIRE) == 0)
|
||||
if ((actions & SB_FIRE) == 0)
|
||||
{
|
||||
p->kickback_pic = 0;
|
||||
break;
|
||||
|
@ -3060,7 +3091,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
else if (p->kickback_pic > 10)
|
||||
{
|
||||
if (sb_snum & SKB_FIRE) p->kickback_pic = 1;
|
||||
if (actions & SB_FIRE) p->kickback_pic = 1;
|
||||
else p->kickback_pic = 0;
|
||||
}
|
||||
|
||||
|
@ -3115,7 +3146,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
if (p->kickback_pic > 4)
|
||||
p->kickback_pic = 1;
|
||||
if (!(sb_snum & SKB_FIRE))
|
||||
if (!(actions & SB_FIRE))
|
||||
p->kickback_pic = 0;
|
||||
break;
|
||||
|
||||
|
@ -3145,7 +3176,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
}
|
||||
if (p->kickback_pic > 4)
|
||||
p->kickback_pic = 1;
|
||||
if (!(sb_snum & SKB_FIRE))
|
||||
if (!(actions & SB_FIRE))
|
||||
p->kickback_pic = 0;
|
||||
break;
|
||||
case BOAT_WEAPON:
|
||||
|
@ -3201,7 +3232,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
{
|
||||
p->ammo_amount[POWDERKEG_WEAPON]--;
|
||||
p->gotweapon.Clear(POWDERKEG_WEAPON);
|
||||
if (p->on_ground && (sb_snum & SKB_CROUCH) && !p->OnMotorcycle)
|
||||
if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle)
|
||||
{
|
||||
k = 15;
|
||||
i = ((p->gethorizsum() - 100) * 20);
|
||||
|
@ -3332,14 +3363,14 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
||||
static void processweapon(int snum, ESyncBits actions, int psect)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
int pi = p->i;
|
||||
auto s = &sprite[pi];
|
||||
int shrunk = (s->yrepeat < 8);
|
||||
|
||||
if (sb_snum & SKB_FIRE)
|
||||
if (actions & SB_FIRE)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
|
@ -3370,20 +3401,20 @@ static void processweapon(int snum, ESyncBits sb_snum, int psect)
|
|||
|
||||
if (p->rapid_fire_hold == 1)
|
||||
{
|
||||
if (sb_snum & SKB_FIRE) return;
|
||||
if (actions & SB_FIRE) return;
|
||||
p->rapid_fire_hold = 0;
|
||||
}
|
||||
|
||||
if (shrunk || p->tipincs || p->access_incs)
|
||||
sb_snum &= ~SKB_FIRE;
|
||||
else if (shrunk == 0 && (sb_snum & SKB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 &&
|
||||
actions &= ~SB_FIRE;
|
||||
else if (shrunk == 0 && (actions & SB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 &&
|
||||
p->last_weapon == -1 && (p->weapon_pos == 0 || p->holster_weapon == 1))
|
||||
{
|
||||
fireweapon(snum);
|
||||
}
|
||||
else if (p->kickback_pic)
|
||||
{
|
||||
operateweapon(snum, sb_snum, psect);
|
||||
operateweapon(snum, actions, psect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3397,7 +3428,7 @@ void processinput_r(int snum)
|
|||
{
|
||||
int j, i, k, doubvel, fz, cz, hz, lz, truefdist, var60;
|
||||
char shrunk;
|
||||
ESyncBits sb_snum;
|
||||
ESyncBits actions;
|
||||
short psect, psectlotag, pi;
|
||||
struct player_struct* p;
|
||||
spritetype* s;
|
||||
|
@ -3408,7 +3439,7 @@ void processinput_r(int snum)
|
|||
|
||||
resetinputhelpers(p);
|
||||
|
||||
sb_snum = PlayerInputBits(snum, SKB_ALL);
|
||||
actions = PlayerInputBits(snum, SB_ALL);
|
||||
|
||||
auto sb_fvel = PlayerInputForwardVel(snum);
|
||||
auto sb_svel = PlayerInputSideVel(snum);
|
||||
|
@ -3417,11 +3448,11 @@ void processinput_r(int snum)
|
|||
psect = p->cursectnum;
|
||||
if (p->OnMotorcycle && s->extra > 0)
|
||||
{
|
||||
onMotorcycle(snum, sb_snum);
|
||||
onMotorcycle(snum, actions);
|
||||
}
|
||||
else if (p->OnBoat && s->extra > 0)
|
||||
{
|
||||
onBoat(snum, sb_snum);
|
||||
onBoat(snum, actions);
|
||||
}
|
||||
if (psect == -1)
|
||||
{
|
||||
|
@ -3504,7 +3535,7 @@ void processinput_r(int snum)
|
|||
if (!p->stairs)
|
||||
{
|
||||
p->stairs = 10;
|
||||
if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle)
|
||||
if ((actions & SB_JUMP) && !p->OnMotorcycle)
|
||||
{
|
||||
hz = 0;
|
||||
cz = p->truecz;
|
||||
|
@ -3554,7 +3585,7 @@ void processinput_r(int snum)
|
|||
if (!p->stairs)
|
||||
{
|
||||
p->stairs = 10;
|
||||
if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle)
|
||||
if ((actions & SB_CROUCH) && !p->OnMotorcycle)
|
||||
{
|
||||
cz = sprite[j].z;
|
||||
hz = 0;
|
||||
|
@ -3566,7 +3597,7 @@ void processinput_r(int snum)
|
|||
}
|
||||
else if (sprite[j].picnum == TOILET || sprite[j].picnum == RRTILE2121)
|
||||
{
|
||||
if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle)
|
||||
if ((actions & SB_CROUCH) && !p->OnMotorcycle)
|
||||
//if (Sound[436].num == 0)
|
||||
{
|
||||
S_PlayActorSound(436, p->i);
|
||||
|
@ -3628,13 +3659,13 @@ void processinput_r(int snum)
|
|||
|
||||
fi.doincrements(p);
|
||||
|
||||
if (p->curr_weapon == THROWINGDYNAMITE_WEAPON) processweapon(snum, sb_snum, psect);
|
||||
if (p->curr_weapon == THROWINGDYNAMITE_WEAPON) processweapon(snum, actions, psect);
|
||||
return;
|
||||
}
|
||||
|
||||
doubvel = TICSPERFRAME;
|
||||
|
||||
checklook(snum, sb_snum);
|
||||
checklook(snum, actions);
|
||||
|
||||
if (p->on_crane >= 0)
|
||||
goto HORIZONLY;
|
||||
|
@ -3674,11 +3705,11 @@ void processinput_r(int snum)
|
|||
|
||||
if (psectlotag == ST_2_UNDERWATER)
|
||||
{
|
||||
underwater(snum, sb_snum, psect, fz, cz);
|
||||
underwater(snum, actions, psect, fz, cz);
|
||||
}
|
||||
else
|
||||
{
|
||||
movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
movement(snum, actions, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
}
|
||||
|
||||
p->psectlotag = psectlotag;
|
||||
|
@ -3772,7 +3803,7 @@ void processinput_r(int snum)
|
|||
p->posxv += ((sb_fvel * doubvel) << 6);
|
||||
p->posyv += ((sb_svel * doubvel) << 6);
|
||||
|
||||
if (!isRRRA() && ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (sb_snum & SKB_CROUCH))))
|
||||
if (!isRRRA() && ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH))))
|
||||
{
|
||||
p->posxv = mulscale(p->posxv, dukefriction - 0x2000, 16);
|
||||
p->posyv = mulscale(p->posyv, dukefriction - 0x2000, 16);
|
||||
|
@ -4021,25 +4052,25 @@ HORIZONLY:
|
|||
return;
|
||||
}
|
||||
|
||||
if (sb_snum & SKB_CENTER_VIEW || p->hard_landing)
|
||||
if (actions & SB_CENTERVIEW || p->hard_landing)
|
||||
{
|
||||
playerCenterView(snum);
|
||||
}
|
||||
else if (sb_snum & SKB_LOOK_UP)
|
||||
else if (actions & SB_LOOK_UP)
|
||||
{
|
||||
playerLookUp(snum, sb_snum);
|
||||
playerLookUp(snum, actions);
|
||||
}
|
||||
else if (sb_snum & SKB_LOOK_DOWN)
|
||||
else if (actions & SB_LOOK_DOWN)
|
||||
{
|
||||
playerLookDown(snum, sb_snum);
|
||||
playerLookDown(snum, actions);
|
||||
}
|
||||
else if ((sb_snum & SKB_AIM_UP) && !p->OnMotorcycle)
|
||||
else if ((actions & SB_AIM_UP) && !p->OnMotorcycle)
|
||||
{
|
||||
playerAimUp(snum, sb_snum);
|
||||
playerAimUp(snum, actions);
|
||||
}
|
||||
else if ((sb_snum & SKB_AIM_DOWN) && !p->OnMotorcycle)
|
||||
else if ((actions & SB_AIM_DOWN) && !p->OnMotorcycle)
|
||||
{
|
||||
playerAimDown(snum, sb_snum);
|
||||
playerAimDown(snum, actions);
|
||||
}
|
||||
if (p->recoil && p->kickback_pic == 0)
|
||||
{
|
||||
|
@ -4052,7 +4083,7 @@ HORIZONLY:
|
|||
|
||||
if (cl_syncinput)
|
||||
{
|
||||
sethorizon(snum, sb_snum, 1, sync[snum].q16horz);
|
||||
sethorizon(snum, actions, 1, PlayerHorizon(snum));
|
||||
}
|
||||
|
||||
checkhardlanding(p);
|
||||
|
@ -4088,7 +4119,7 @@ HORIZONLY:
|
|||
else p->weapon_pos--;
|
||||
}
|
||||
|
||||
processweapon(snum, sb_snum, psect);
|
||||
processweapon(snum, actions, psect);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -4097,22 +4128,17 @@ HORIZONLY:
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void processweapon_r(int s, ESyncBits ss, int p)
|
||||
{
|
||||
processweapon(s, ss, p);
|
||||
}
|
||||
|
||||
void processmove_r(int snum, ESyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist)
|
||||
void processmove_r(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist)
|
||||
{
|
||||
int psectlotag = sector[psect].lotag;
|
||||
auto p = &ps[snum];
|
||||
if (psectlotag == ST_2_UNDERWATER)
|
||||
{
|
||||
underwater(snum, sb_snum, psect, fz, cz);
|
||||
underwater(snum, actions, psect, fz, cz);
|
||||
}
|
||||
else
|
||||
{
|
||||
movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
movement(snum, actions, psect, fz, cz, shrunk, truefdist, psectlotag);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ void fireweapon_ww(int snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void operateweapon_ww(int snum, ESyncBits sb_snum, int psect)
|
||||
void operateweapon_ww(int snum, ESyncBits actions, int psect)
|
||||
{
|
||||
auto p = &ps[snum];
|
||||
int pi = p->i;
|
||||
|
@ -318,7 +318,7 @@ void operateweapon_ww(int snum, ESyncBits sb_snum, int psect)
|
|||
{
|
||||
if (aplWeaponHoldDelay[p->curr_weapon][snum] // there is a hold delay
|
||||
&& (p->kickback_pic == aplWeaponFireDelay[p->curr_weapon][snum]) // and we are 'at' hold
|
||||
&& (sb_snum & SKB_FIRE) // and 'fire' button is still down
|
||||
&& (actions & SB_FIRE) // and 'fire' button is still down
|
||||
)
|
||||
// just hold here...
|
||||
{
|
||||
|
@ -330,7 +330,7 @@ void operateweapon_ww(int snum, ESyncBits sb_snum, int psect)
|
|||
{
|
||||
p->ammo_amount[p->curr_weapon]--;
|
||||
|
||||
if (p->on_ground && (sb_snum & SKB_CROUCH))
|
||||
if (p->on_ground && (actions & SB_CROUCH))
|
||||
{
|
||||
k = 15;
|
||||
i = ((p->gethorizsum() - 100) * 20);
|
||||
|
@ -374,7 +374,7 @@ void operateweapon_ww(int snum, ESyncBits sb_snum, int psect)
|
|||
|
||||
}
|
||||
else if (p->kickback_pic < aplWeaponHoldDelay[p->curr_weapon][snum] &&
|
||||
(sb_snum & SKB_CROUCH))
|
||||
(actions & SB_CROUCH))
|
||||
{
|
||||
p->hbomb_hold_delay++;
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ void operateweapon_ww(int snum, ESyncBits sb_snum, int psect)
|
|||
|
||||
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC)
|
||||
{ // an 'automatic'
|
||||
if ((sb_snum & SKB_FIRE) == 0)
|
||||
if ((actions & SB_FIRE) == 0)
|
||||
{
|
||||
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum];
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ void operateweapon_ww(int snum, ESyncBits sb_snum, int psect)
|
|||
{
|
||||
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC)
|
||||
{ // an 'automatic'
|
||||
if (sb_snum & SKB_FIRE)
|
||||
if (actions & SB_FIRE)
|
||||
{
|
||||
// we are an AUTOMATIC. Fire again...
|
||||
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART)
|
||||
|
|
|
@ -98,14 +98,15 @@ void fakedomovethingscorrect(void)
|
|||
|
||||
}
|
||||
|
||||
// This still needs fixing for the magic numbers in the input bits
|
||||
void fakedomovethings(void)
|
||||
{
|
||||
input *syn;
|
||||
struct player_struct *p;
|
||||
int i, j, k, doubvel, fz, cz, hz, lz, x, y;
|
||||
ESyncBits sb_snum;
|
||||
short psect, psectlotag, tempsect, backcstat;
|
||||
uint8_t shrunk, spritebridge;
|
||||
ESyncBits actions;
|
||||
|
||||
syn = (input *)&inputfifo[fakemovefifoplc&(MOVEFIFOSIZ-1)][myconnectindex];
|
||||
|
||||
|
@ -114,7 +115,7 @@ void fakedomovethings(void)
|
|||
backcstat = sprite[p->i].cstat;
|
||||
sprite[p->i].cstat &= ~257;
|
||||
|
||||
sb_snum = syn->bits;
|
||||
actions = syn->actions;
|
||||
|
||||
psect = mycursectnum;
|
||||
psectlotag = sector[psect].lotag;
|
||||
|
|
|
@ -756,12 +756,8 @@ void prelevel_common(int g)
|
|||
|
||||
void resettimevars(void)
|
||||
{
|
||||
I_ResetTime();
|
||||
lastTic = -1;
|
||||
gameclock = 0;
|
||||
cloudclock = 0;
|
||||
resetGameClock();
|
||||
levelTextTime = 85;
|
||||
lockclock = 0;
|
||||
ready2send = 1;
|
||||
if (camsprite >= 0)
|
||||
hittype[camsprite].temp_data[0] = 0;
|
||||
|
@ -1017,7 +1013,7 @@ int enterlevel(MapRecord *mi, int gamemode)
|
|||
global_random = 0;
|
||||
|
||||
ud.last_level = currentLevel->levelNumber;
|
||||
clearfifo();
|
||||
Net_ClearFifo();
|
||||
for (int i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i];
|
||||
ps[myconnectindex].over_shoulder_on = 0;
|
||||
clearfrags();
|
||||
|
|
|
@ -443,7 +443,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
("mirrorcnt", mirrorcnt)
|
||||
.Array("mirrorsector", mirrorsector, mirrorcnt)
|
||||
.Array("mirrorwall", mirrorwall, mirrorcnt)
|
||||
("lockclock", lockclock)
|
||||
("wupass", wupass)
|
||||
("chickenplant", chickenplant)
|
||||
("thunderon", thunderon)
|
||||
|
@ -482,8 +481,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
// Todo: move to backend
|
||||
("gameclock", gameclock)
|
||||
|
||||
("lockclock", lockclock)
|
||||
|
||||
.Array("po", po, ud.multimode)
|
||||
.EndObject();
|
||||
|
||||
|
@ -523,7 +520,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
recreateinterpolations();
|
||||
show_shareware = 0;
|
||||
everyothertime = 0;
|
||||
clearfifo();
|
||||
Net_ClearFifo();
|
||||
|
||||
// should be unnecessary with the sounds getting serialized as well.
|
||||
#if 0
|
||||
|
|
|
@ -133,11 +133,10 @@ public:
|
|||
{
|
||||
int s = -8;
|
||||
if (althud_flashing && p->last_extra > max_player_health)
|
||||
s += (sintable[(gameclock << 5) & 2047] >> 10);
|
||||
int intens = clamp(255 - 4 * s, 0, 255);
|
||||
auto pe = PalEntry(255, intens, intens, intens);
|
||||
s += (sintable[(gameclock << 6) & 2047] >> 10);
|
||||
int intens = clamp(255 - 6 * s, 0, 255);
|
||||
format.Format("%d", p->last_extra);
|
||||
SBar_DrawString(this, &numberFont, format, 25, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||
SBar_DrawString(this, &numberFont, format, 25, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -106,15 +106,16 @@ public:
|
|||
imgScale = baseScale / img->GetDisplayHeight();
|
||||
DrawGraphic(img, 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale);
|
||||
|
||||
int gameclock = I_GetBuildTime();
|
||||
|
||||
if (!althud_flashing || p->last_extra > (max_player_health >> 2) || (gameclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2))
|
||||
{
|
||||
int s = -8;
|
||||
if (althud_flashing && p->last_extra > max_player_health)
|
||||
s += (sintable[(gameclock << 5) & 2047] >> 10);
|
||||
int intens = clamp(255 - 4 * s, 0, 255);
|
||||
auto pe = PalEntry(255, intens, intens, intens);
|
||||
s += (sintable[(gameclock << 6) & 2047] >> 10);
|
||||
int intens = clamp(255 - 6 * s, 0, 255);
|
||||
format.Format("%d", p->last_extra);
|
||||
SBar_DrawString(this, &numberFont, format, 26.5, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||
SBar_DrawString(this, &numberFont, format, 26.5, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, scale, scale);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1520,7 +1520,7 @@ void checksectors_d(int snum)
|
|||
|
||||
if (chatmodeon || sprite[p->i].extra <= 0) return;
|
||||
|
||||
if (ud.cashman && PlayerInput(snum, SKB_OPEN))
|
||||
if (ud.cashman && PlayerInput(snum, SB_OPEN))
|
||||
fi.lotsofmoney(&sprite[p->i], 2);
|
||||
|
||||
if (p->newowner >= 0)
|
||||
|
@ -1532,13 +1532,13 @@ void checksectors_d(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (!(PlayerInput(snum, SKB_OPEN)) && !PlayerInput(snum, SKB_ESCAPE))
|
||||
if (!(PlayerInput(snum, SB_OPEN)))
|
||||
p->toggle_key_flag = 0;
|
||||
|
||||
else if (!p->toggle_key_flag)
|
||||
{
|
||||
|
||||
if (PlayerInput(snum, SKB_ESCAPE))
|
||||
if (PlayerInput(snum, SB_ESCAPE))
|
||||
{
|
||||
if (p->newowner >= 0)
|
||||
{
|
||||
|
@ -1740,7 +1740,7 @@ void checksectors_d(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (!PlayerInput(snum, SKB_OPEN)) return;
|
||||
if (!PlayerInput(snum, SB_OPEN)) return;
|
||||
else if (p->newowner >= 0) { i = -1; goto CLEARCAMERAS; }
|
||||
|
||||
if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1)
|
||||
|
|
|
@ -2484,11 +2484,11 @@ void checksectors_r(int snum)
|
|||
|
||||
if (chatmodeon || sprite[p->i].extra <= 0) return;
|
||||
|
||||
if (ud.cashman && PlayerInput(snum, SKB_OPEN))
|
||||
if (ud.cashman && PlayerInput(snum, SB_OPEN))
|
||||
fi.lotsofmoney(&sprite[p->i], 2);
|
||||
|
||||
|
||||
if (!(PlayerInput(snum, SKB_OPEN)) && !PlayerInput(snum, SKB_ESCAPE))
|
||||
if (!(PlayerInput(snum, SB_OPEN)))
|
||||
p->toggle_key_flag = 0;
|
||||
|
||||
else if (!p->toggle_key_flag)
|
||||
|
@ -2709,7 +2709,7 @@ void checksectors_r(int snum)
|
|||
}
|
||||
}
|
||||
|
||||
if (!PlayerInput(snum, SKB_OPEN)) return;
|
||||
if (!PlayerInput(snum, SB_OPEN)) return;
|
||||
|
||||
if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1)
|
||||
if (abs(hits(p->i)) < 512)
|
||||
|
|
|
@ -318,7 +318,7 @@ void DukeSoundEngine::CalcPosVel(int type, const void* source, const float pt[3]
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void S_Update(void)
|
||||
void GameInterface::UpdateSounds(void)
|
||||
{
|
||||
SoundListener listener;
|
||||
vec3_t* c;
|
||||
|
|
|
@ -36,7 +36,6 @@ enum esound_t
|
|||
};
|
||||
|
||||
void S_InitSound();
|
||||
void S_Update(void);
|
||||
void S_CacheAllSounds(void);
|
||||
int S_DefineSound(unsigned index, const char* filename, int ps, int pe, int pr, int m, int vo, float vol);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include "names.h"
|
||||
#include "packet.h"
|
||||
#include "d_net.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
|
|
@ -489,13 +489,18 @@ void videoShowFrame(int32_t w)
|
|||
});
|
||||
screen->Update();
|
||||
screen->mVertexData->Reset();
|
||||
videoSetBrightness(0); // immediately reset this after rendering so that the value doesn't stick around in the backend.
|
||||
|
||||
// After finishing the frame, reset everything for the next frame. This needs to be done better.
|
||||
if (!w)
|
||||
{
|
||||
screen->BeginFrame();
|
||||
bool useSSAO = (gl_ssao != 0);
|
||||
screen->SetSceneRenderTarget(useSSAO);
|
||||
twodpsp.Clear();
|
||||
twod->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
TMap<int64_t, bool> cachemap;
|
||||
|
||||
|
|
|
@ -355,6 +355,7 @@ public:
|
|||
};
|
||||
|
||||
extern GLInstance GLInterface;
|
||||
extern F2DDrawer twodpsp;
|
||||
|
||||
void renderSetProjectionMatrix(const float* p);
|
||||
void renderSetViewMatrix(const float* p);
|
||||
|
|
|
@ -230,7 +230,7 @@ void GameInterface::StartGame(FNewGameStartup& gs)
|
|||
|
||||
while (soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE))
|
||||
{
|
||||
DoUpdateSounds();
|
||||
gi->UpdateSounds();
|
||||
soundEngine->UpdateSounds(I_GetTime());
|
||||
I_GetEvent();
|
||||
}
|
||||
|
|
|
@ -616,9 +616,6 @@ int DoEelMove(short SpriteNum)
|
|||
else
|
||||
(*u->ActorActionFunc)(SpriteNum);
|
||||
|
||||
//if (TEST_SYNC_KEY((Player+myconnectindex), SK_OPERATE))
|
||||
// CON_Message("Stop");
|
||||
|
||||
DoEelMatchPlayerZ(SpriteNum);
|
||||
|
||||
DoActorSectorDamage(SpriteNum);
|
||||
|
|
|
@ -171,46 +171,10 @@ void SybexScreen(void);
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static const char* actions[] = {
|
||||
"Move_Forward",
|
||||
"Move_Backward",
|
||||
"Turn_Left",
|
||||
"Turn_Right",
|
||||
"Strafe",
|
||||
"Fire",
|
||||
"Open",
|
||||
"Run",
|
||||
"Alt_Fire", // Duke3D", Blood
|
||||
"Jump",
|
||||
"Crouch",
|
||||
"Look_Up",
|
||||
"Look_Down",
|
||||
"Look_Left",
|
||||
"Look_Right",
|
||||
"Strafe_Left",
|
||||
"Strafe_Right",
|
||||
"Aim_Up",
|
||||
"Aim_Down",
|
||||
"SendMessage",
|
||||
"Shrink_Screen",
|
||||
"Enlarge_Screen",
|
||||
"Show_Opponents_Weapon",
|
||||
"See_Coop_View",
|
||||
"Mouse_Aiming",
|
||||
"Dpad_Select",
|
||||
"Dpad_Aiming",
|
||||
"Last_Weapon",
|
||||
"Alt_Weapon",
|
||||
"Third_Person_View",
|
||||
"Toggle_Crouch", // This is the last one used by EDuke32"",
|
||||
|
||||
};
|
||||
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
GameTicRate = 40;
|
||||
InitCheats();
|
||||
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
||||
automapping = 1;
|
||||
|
||||
gs = gs_defaults;
|
||||
|
@ -230,7 +194,6 @@ void GameInterface::app_init()
|
|||
Printf("Copyright (c) 1997 3D Realms Entertainment\n");
|
||||
|
||||
registerosdcommands();
|
||||
registerinputcommands();
|
||||
|
||||
engineInit();
|
||||
auto pal = fileSystem.LoadFile("3drealms.pal", 0);
|
||||
|
@ -274,8 +237,6 @@ void GameInterface::app_init()
|
|||
|
||||
if (!loaddefinitionsfile(G_DefFile())) Printf(PRINT_NONOTIFY, "Definitions file loaded.\n");
|
||||
userConfig.AddDefs.reset();
|
||||
enginePostInit();
|
||||
videoInit();
|
||||
InitFX();
|
||||
}
|
||||
|
||||
|
@ -767,7 +728,7 @@ void GameTicker(void)
|
|||
ready2send = 1;
|
||||
|
||||
int const currentTic = I_GetTime();
|
||||
gameclock = I_GetBuildTime();
|
||||
gameclock = I_GetBuildTime() - gameclockstart;
|
||||
|
||||
if (paused)
|
||||
{
|
||||
|
@ -811,20 +772,23 @@ void GameTicker(void)
|
|||
}
|
||||
|
||||
|
||||
void GameInterface::RunGameFrame()
|
||||
void resetGameClock()
|
||||
{
|
||||
try
|
||||
I_SetFrameTime();
|
||||
gameclockstart = I_GetBuildTime();
|
||||
ogameclock = gameclock = 0;
|
||||
}
|
||||
|
||||
void GameInterface::RunGameFrame()
|
||||
{
|
||||
// if the menu initiazed a new game or loaded a savegame, switch to play mode.
|
||||
if (SavegameLoaded || NextLevel) gamestate = GS_LEVEL;
|
||||
DoUpdateSounds();
|
||||
gi->UpdateSounds();
|
||||
switch (gamestate)
|
||||
{
|
||||
default:
|
||||
case GS_STARTUP:
|
||||
I_ResetTime();
|
||||
lastTic = -1;
|
||||
ogameclock = gameclock = 0;
|
||||
resetGameClock();
|
||||
|
||||
if (userConfig.CommandMap.IsNotEmpty())
|
||||
{
|
||||
|
@ -852,7 +816,9 @@ void GameInterface::RunGameFrame()
|
|||
|
||||
}
|
||||
}
|
||||
catch (CRecoverableError&)
|
||||
|
||||
|
||||
void GameInterface::ErrorCleanup()
|
||||
{
|
||||
// Make sure we do not leave the game in an unstable state
|
||||
TerminateLevel();
|
||||
|
@ -861,11 +827,7 @@ void GameInterface::RunGameFrame()
|
|||
ExitLevel = false;
|
||||
FinishAnim = 0;
|
||||
FinishedLevel = false;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
|
|
@ -73,42 +73,6 @@ typedef struct
|
|||
extern const GAME_SET gs_defaults;
|
||||
extern GAME_SET gs;
|
||||
|
||||
enum GameFunction_t
|
||||
{
|
||||
gamefunc_Move_Forward,
|
||||
gamefunc_Move_Backward,
|
||||
gamefunc_Turn_Left,
|
||||
gamefunc_Turn_Right,
|
||||
gamefunc_Strafe,
|
||||
gamefunc_Fire,
|
||||
gamefunc_Open,
|
||||
gamefunc_Run,
|
||||
gamefunc_Alt_Fire, // Duke3D, Blood
|
||||
gamefunc_Jump,
|
||||
gamefunc_Crouch,
|
||||
gamefunc_Look_Up,
|
||||
gamefunc_Look_Down,
|
||||
gamefunc_Look_Left,
|
||||
gamefunc_Look_Right,
|
||||
gamefunc_Strafe_Left,
|
||||
gamefunc_Strafe_Right,
|
||||
gamefunc_Aim_Up,
|
||||
gamefunc_Aim_Down,
|
||||
gamefunc_SendMessage,
|
||||
gamefunc_Shrink_Screen,
|
||||
gamefunc_Enlarge_Screen,
|
||||
gamefunc_Show_Opponents_Weapon,
|
||||
gamefunc_See_Coop_View,
|
||||
gamefunc_Mouse_Aiming,
|
||||
gamefunc_Dpad_Select,
|
||||
gamefunc_Dpad_Aiming,
|
||||
gamefunc_Last_Weapon,
|
||||
gamefunc_Alt_Weapon,
|
||||
gamefunc_Third_Person_View,
|
||||
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
|
||||
NUM_ACTIONS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DREALMSPAL = 1,
|
||||
|
@ -287,17 +251,6 @@ extern SWBOOL MenuInputMode;
|
|||
#define SectorIsDiveArea(sect) (TEST(sector[sect].extra, SECTFX_DIVE_AREA) ? TRUE : FALSE)
|
||||
#define SectorIsUnderwaterArea(sect) (TEST(sector[sect].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? TRUE : FALSE)
|
||||
|
||||
// Key Press Flags macros
|
||||
#define FLAG_KEY_PRESSED(pp,sync_key) TEST(pp->KeyPressFlags,1<<sync_key)
|
||||
#define FLAG_KEY_RELEASE(pp,sync_key) RESET(pp->KeyPressFlags,1<<sync_key)
|
||||
#define FLAG_KEY_RESET(pp,sync_key) SET(pp->KeyPressFlags,1<<sync_key)
|
||||
|
||||
// syncbit manipulation macros
|
||||
// key_test MUST be a boolean - force it to be
|
||||
#define SET_SYNC_KEY(player, sync_num, key_test) SET((player)->input.bits, ((!!(key_test)) << (sync_num)))
|
||||
#define TEST_SYNC_KEY(player, sync_num) TEST((player)->input.bits, (1 << (sync_num)))
|
||||
#define RESET_SYNC_KEY(player, sync_num) RESET((player)->input.bits, (1 << (sync_num)))
|
||||
|
||||
#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritesect[o], (o) != -1; (o) = (n))
|
||||
#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritestat[o], (o) != -1; (o) = (n))
|
||||
#define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i])
|
||||
|
@ -948,6 +901,7 @@ struct PLAYERstruct
|
|||
|
||||
// variables that do not fit into sprite structure
|
||||
int hvel,tilt,tilt_dest;
|
||||
bool centering;
|
||||
fix16_t q16horiz, q16horizbase, q16horizoff, q16ang;
|
||||
fix16_t camq16horiz, camq16ang;
|
||||
short recoil_amt;
|
||||
|
@ -998,7 +952,7 @@ struct PLAYERstruct
|
|||
|
||||
PLAYER_ACTION_FUNCp DoPlayerAction;
|
||||
int Flags, Flags2;
|
||||
int KeyPressFlags;
|
||||
ESyncBits KeyPressBits;
|
||||
|
||||
SECTOR_OBJECTp sop_control; // sector object pointer
|
||||
SECTOR_OBJECTp sop_riding; // sector object pointer
|
||||
|
@ -2100,7 +2054,6 @@ extern short numplayers, myconnectindex;
|
|||
extern short connecthead, connectpoint2[MAXPLAYERS];
|
||||
*/
|
||||
extern int *lastpacket2clock;
|
||||
extern char username[MAXPLAYERS][50];
|
||||
|
||||
// save player info when moving to a new level
|
||||
extern USER puser[MAX_SW_PLAYERS_REG];
|
||||
|
@ -2255,7 +2208,6 @@ void LoadSaveMsg(const char *msg);
|
|||
void UpdateStatusBar(int arg);
|
||||
void InitFonts();
|
||||
int32_t registerosdcommands(void);
|
||||
void registerinputcommands();
|
||||
void SW_InitMultiPsky(void);
|
||||
|
||||
extern int PlayClock;
|
||||
|
@ -2301,9 +2253,10 @@ struct GameInterface : ::GameInterface
|
|||
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
|
||||
FString GetCoordString() override;
|
||||
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
||||
void clearlocalinputstate() override;
|
||||
void QuitToTitle() override;
|
||||
void ResetFollowPos(bool message) override;
|
||||
void UpdateSounds() override;
|
||||
void ErrorCleanup() override;
|
||||
|
||||
GameStats getStats() override;
|
||||
};
|
||||
|
|
|
@ -34,43 +34,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
|
||||
BEGIN_SW_NS
|
||||
|
||||
SWBOOL MultiPlayQuitFlag = FALSE;
|
||||
|
||||
int WeaponToSend = 0;
|
||||
int BitsToSend = 0;
|
||||
int inv_hotkey = 0;
|
||||
|
||||
|
||||
void
|
||||
FunctionKeys(PLAYERp pp)
|
||||
{
|
||||
// F7 VIEW control
|
||||
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Third_Person_View);
|
||||
|
||||
if (inputState.ShiftPressed())
|
||||
{
|
||||
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
||||
pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
||||
{
|
||||
RESET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
|
||||
pp->camera_dist = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
double elapsedInputTicks;
|
||||
double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000.0 / elapsedInputTicks); }
|
||||
|
||||
|
@ -120,10 +83,37 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
|
||||
lastInputTicks = currentHiTicks;
|
||||
|
||||
// MAKE SURE THIS WILL GET SET
|
||||
SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag);
|
||||
ControlInfo info;
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
// If in 2D follow mode, scroll around using glob vars
|
||||
// Tried calling this in domovethings, but key response it too poor, skips key presses
|
||||
// Note: this get called only during follow mode
|
||||
if (!tied && automapFollow && automapMode != am_off && pp == Player + myconnectindex && !Prediction)
|
||||
MoveScrollMode2D(Player + myconnectindex);
|
||||
|
||||
// !JIM! Added M_Active() so that you don't move at all while using menus
|
||||
if (M_Active() || automapFollow)
|
||||
return;
|
||||
|
||||
int32_t turnamount;
|
||||
int32_t keymove;
|
||||
|
||||
// The function DoPlayerTurn() scales the player's q16angvel by 1.40625, so store as constant
|
||||
// and use to scale back player's aim and ang values for a consistent feel between games.
|
||||
float const angvelScale = 1.40625f;
|
||||
float const aimvelScale = 1.203125f;
|
||||
|
||||
// Shadow Warrior has a ticrate of 40, 25% more than the other games, so store below constant
|
||||
// for dividing controller input to match speed input speed of other games.
|
||||
float const ticrateScale = 0.75f;
|
||||
|
||||
ApplyGlobalInput(*loc, &info);
|
||||
|
||||
bool mouseaim = !!(loc->actions & SB_AIMMODE);
|
||||
|
||||
if (!CommEnabled)
|
||||
{
|
||||
|
@ -141,38 +131,13 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
RESET(Player[myconnectindex].Flags, PF_AUTO_AIM);
|
||||
}
|
||||
|
||||
ControlInfo info;
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
// If in 2D follow mode, scroll around using glob vars
|
||||
// Tried calling this in domovethings, but key response it too poor, skips key presses
|
||||
// Note: this get called only during follow mode
|
||||
if (!tied && automapFollow && automapMode != am_off && pp == Player + myconnectindex && !Prediction)
|
||||
MoveScrollMode2D(Player + myconnectindex);
|
||||
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch)) // this shares a bit with another function so cannot be in the common code.
|
||||
loc->actions |= SB_CROUCH_LOCK;
|
||||
|
||||
// !JIM! Added M_Active() so that you don't move at all while using menus
|
||||
if (M_Active() || automapFollow)
|
||||
return;
|
||||
|
||||
SET_LOC_KEY(loc->bits, SK_SPACE_BAR, buttonMap.ButtonDown(gamefunc_Open));
|
||||
|
||||
int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||
int32_t turnamount;
|
||||
int32_t keymove;
|
||||
|
||||
// The function DoPlayerTurn() scales the player's q16angvel by 1.40625, so store as constant
|
||||
// and use to scale back player's aim and ang values for a consistent feel between games.
|
||||
float const angvelScale = 1.40625f;
|
||||
float const aimvelScale = 1.203125f;
|
||||
|
||||
// Shadow Warrior has a ticrate of 40, 25% more than the other games, so store below constant
|
||||
// for dividing controller input to match speed input speed of other games.
|
||||
float const ticrateScale = 0.75f;
|
||||
|
||||
if (running)
|
||||
if (loc->actions & SB_RUN)
|
||||
{
|
||||
if (pp->sop_control)
|
||||
turnamount = RUNTURN * 3;
|
||||
|
@ -317,43 +282,13 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
loc->q16avel += q16angvel;
|
||||
loc->q16horz += q16horz;
|
||||
|
||||
if (!CommEnabled)
|
||||
{
|
||||
// What a mess...:?
|
||||
#if 0
|
||||
if (MenuButtonAutoAim)
|
||||
{
|
||||
MenuButtonAutoAim = FALSE;
|
||||
if ((!!TEST(pp->Flags, PF_AUTO_AIM)) != !!cl_autoaim)
|
||||
SET_LOC_KEY(loc->bits, SK_AUTO_AIM, TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SET_LOC_KEY(loc->bits, SK_RUN, buttonMap.ButtonDown(gamefunc_Run));
|
||||
SET_LOC_KEY(loc->bits, SK_SHOOT, buttonMap.ButtonDown(gamefunc_Fire));
|
||||
|
||||
// actually snap
|
||||
SET_LOC_KEY(loc->bits, SK_SNAP_UP, buttonMap.ButtonDown(gamefunc_Aim_Up));
|
||||
SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down));
|
||||
|
||||
// actually just look
|
||||
SET_LOC_KEY(loc->bits, SK_LOOK_UP, buttonMap.ButtonDown(gamefunc_Look_Up));
|
||||
SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, buttonMap.ButtonDown(gamefunc_Look_Down));
|
||||
|
||||
if (WeaponToSend > 0)
|
||||
{
|
||||
loc->bits &= ~SK_WEAPON_MASK;
|
||||
loc->bits |= WeaponToSend;
|
||||
WeaponToSend = 0;
|
||||
}
|
||||
else if (WeaponToSend == -1)
|
||||
if (loc->getNewWeapon() == WeaponSel_Next)
|
||||
{
|
||||
USERp u = User[pp->PlayerSprite];
|
||||
short next_weapon = u->WeaponNum + 1;
|
||||
short start_weapon;
|
||||
|
||||
WeaponToSend = 0;
|
||||
start_weapon = u->WeaponNum + 1;
|
||||
|
||||
if (u->WeaponNum == WPN_SWORD)
|
||||
|
@ -382,16 +317,14 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
}
|
||||
}
|
||||
|
||||
SET(loc->bits, next_weapon + 1);
|
||||
loc->setNewWeapon(next_weapon + 1);
|
||||
}
|
||||
else if (WeaponToSend == -2)
|
||||
else if (loc->getNewWeapon() == WeaponSel_Prev)
|
||||
{
|
||||
USERp u = User[pp->PlayerSprite];
|
||||
short prev_weapon = u->WeaponNum - 1;
|
||||
short start_weapon;
|
||||
|
||||
WeaponToSend = 0;
|
||||
|
||||
start_weapon = u->WeaponNum - 1;
|
||||
|
||||
if (u->WeaponNum == WPN_SWORD)
|
||||
|
@ -417,111 +350,14 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
SET(loc->bits, prev_weapon + 1);
|
||||
loc->setNewWeapon(prev_weapon + 1);
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Alt_Weapon))
|
||||
else if (loc->getNewWeapon() == WeaponSel_Alt)
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Alt_Weapon);
|
||||
USERp u = User[pp->PlayerSprite];
|
||||
short const which_weapon = u->WeaponNum + 1;
|
||||
SET(loc->bits, which_weapon);
|
||||
loc->setNewWeapon(which_weapon);
|
||||
}
|
||||
|
||||
|
||||
loc->bits |= BitsToSend;
|
||||
BitsToSend = 0;
|
||||
|
||||
SET(loc->bits, inv_hotkey<<SK_INV_HOTKEY_BIT0);
|
||||
inv_hotkey = 0;
|
||||
|
||||
SET_LOC_KEY(loc->bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open));
|
||||
SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump));
|
||||
SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch));
|
||||
|
||||
// need BUTTON
|
||||
SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, buttonMap.ButtonDown(gamefunc_Toggle_Crouch));
|
||||
|
||||
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_See_Coop_View);
|
||||
|
||||
screenpeek = connectpoint2[screenpeek];
|
||||
|
||||
if (screenpeek < 0)
|
||||
screenpeek = connecthead;
|
||||
|
||||
if (screenpeek == myconnectindex)
|
||||
{
|
||||
// JBF: figure out what's going on here
|
||||
DoPlayerDivePalette(pp); // Check Dive again
|
||||
DoPlayerNightVisionPalette(pp); // Check Night Vision again
|
||||
}
|
||||
else
|
||||
{
|
||||
PLAYERp tp = Player+screenpeek;
|
||||
DoPlayerDivePalette(tp);
|
||||
DoPlayerNightVisionPalette(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tied)
|
||||
FunctionKeys(pp);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic
|
||||
// registration to only have the commands active when this game module runs.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static int ccmd_slot(CCmdFuncPtr parm)
|
||||
{
|
||||
if (parm->numparms != 1) return CCMD_SHOWHELP;
|
||||
|
||||
auto slot = atoi(parm->parms[0]);
|
||||
if (slot >= 1 && slot <= 10)
|
||||
{
|
||||
WeaponToSend = slot;
|
||||
return CCMD_OK;
|
||||
}
|
||||
return CCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
|
||||
void registerinputcommands()
|
||||
{
|
||||
C_RegisterFunction("slot", "slot <weaponslot>: select a weapon from the given slot (1-10)", ccmd_slot);
|
||||
C_RegisterFunction("weapprev", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = -2; return CCMD_OK; });
|
||||
C_RegisterFunction("weapnext", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = -1; return CCMD_OK; });
|
||||
C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_PAUSE); sendPause = true; return CCMD_OK; });
|
||||
C_RegisterFunction("smoke_bomb", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_CLOAK + 1; return CCMD_OK; });
|
||||
C_RegisterFunction("nightvision", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_NIGHT_VISION + 1; return CCMD_OK; });
|
||||
C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_MEDKIT + 1; return CCMD_OK; });
|
||||
C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_CENTER_VIEW); return CCMD_OK; });
|
||||
C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_HIDE_WEAPON); return CCMD_OK; });
|
||||
C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_INV_LEFT); return CCMD_OK; });
|
||||
C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_INV_RIGHT); return CCMD_OK; });
|
||||
C_RegisterFunction("gas_bomb", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_CHEMBOMB + 1; return CCMD_OK; });
|
||||
C_RegisterFunction("flash_bomb", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_FLASHBOMB + 1; return CCMD_OK; });
|
||||
C_RegisterFunction("caltrops", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_CALTROPS + 1; return CCMD_OK; });
|
||||
C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_TURN_180); return CCMD_OK; });
|
||||
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_INV_USE); return CCMD_OK; });
|
||||
}
|
||||
|
||||
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
||||
void GameInterface::clearlocalinputstate()
|
||||
{
|
||||
WeaponToSend = 0;
|
||||
BitsToSend = 0;
|
||||
inv_hotkey = 0;
|
||||
|
||||
}
|
||||
|
||||
END_SW_NS
|
||||
|
|
|
@ -367,8 +367,6 @@ DoPlayerNightVisionPalette(PLAYERp pp)
|
|||
void
|
||||
UseInventoryNightVision(PLAYERp pp)
|
||||
{
|
||||
#define NIGHT_INVENTORY_TIME 30
|
||||
|
||||
if (pp->InventoryActive[pp->InventoryNum])
|
||||
{
|
||||
StopInventoryNightVision(pp, pp->InventoryNum);
|
||||
|
@ -414,14 +412,12 @@ StopInventoryNightVision(PLAYERp pp, short InventoryNum)
|
|||
|
||||
void InventoryKeys(PLAYERp pp)
|
||||
{
|
||||
short inv_hotkey;
|
||||
|
||||
// scroll SPELLs left
|
||||
if (TEST_SYNC_KEY(pp, SK_INV_LEFT))
|
||||
if (pp->input.actions & SB_INVPREV)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_INV_LEFT))
|
||||
if (pp->KeyPressBits & SB_INVPREV)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_INV_LEFT);
|
||||
pp->KeyPressBits &= ~SB_INVPREV;
|
||||
pp->InventoryBarTics = SEC(2);
|
||||
PlayerUpdateInventory(pp, pp->InventoryNum - 1);
|
||||
PutStringInfo(pp, InventoryData[pp->InventoryNum].Name);
|
||||
|
@ -429,15 +425,15 @@ void InventoryKeys(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_INV_LEFT);
|
||||
pp->KeyPressBits |= SB_INVPREV;
|
||||
}
|
||||
|
||||
// scroll SPELLs right
|
||||
if (TEST_SYNC_KEY(pp, SK_INV_RIGHT))
|
||||
if (pp->input.actions & SB_INVNEXT)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_INV_RIGHT))
|
||||
if (pp->KeyPressBits & SB_INVNEXT)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_INV_RIGHT);
|
||||
pp->KeyPressBits &= ~SB_INVNEXT;
|
||||
pp->InventoryBarTics = SEC(2);
|
||||
PlayerUpdateInventory(pp, pp->InventoryNum + 1);
|
||||
PutStringInfo(pp, InventoryData[pp->InventoryNum].Name);
|
||||
|
@ -445,15 +441,14 @@ void InventoryKeys(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_INV_RIGHT);
|
||||
pp->KeyPressBits |= SB_INVNEXT;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_INV_USE))
|
||||
if (pp->input.actions & SB_INVUSE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_INV_USE))
|
||||
if (pp->KeyPressBits & SB_INVUSE)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_INV_USE);
|
||||
|
||||
pp->KeyPressBits &= ~SB_INVUSE;
|
||||
if (InventoryData[pp->InventoryNum].Init)
|
||||
{
|
||||
if (pp->InventoryAmount[pp->InventoryNum])
|
||||
|
@ -470,22 +465,21 @@ void InventoryKeys(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_INV_USE);
|
||||
pp->KeyPressBits |= SB_INVUSE;
|
||||
}
|
||||
|
||||
// get hotkey number out of input bits
|
||||
inv_hotkey = TEST(pp->input.bits, SK_INV_HOTKEY_MASK) >> SK_INV_HOTKEY_BIT0;
|
||||
|
||||
if (inv_hotkey)
|
||||
// test all 7 items
|
||||
for (int i = 0; i <= 7; i++)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_INV_HOTKEY_BIT0))
|
||||
ESyncBits bit = ESyncBits::FromInt(SB_ITEM_BIT_1 << i);
|
||||
if (pp->input.isItemUsed(i))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_INV_HOTKEY_BIT0);
|
||||
|
||||
inv_hotkey -= 1;
|
||||
if (pp->KeyPressBits & bit)
|
||||
{
|
||||
pp->KeyPressBits &= ~bit;
|
||||
|
||||
// switches you to this inventory item
|
||||
pp->InventoryNum = inv_hotkey;
|
||||
pp->InventoryNum = i;
|
||||
|
||||
if (InventoryData[pp->InventoryNum].Init && !TEST(pp->Flags, PF_CLIMBING))
|
||||
{
|
||||
|
@ -498,7 +492,8 @@ void InventoryKeys(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_INV_HOTKEY_BIT0);
|
||||
pp->KeyPressBits |= bit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
BEGIN_SW_NS
|
||||
|
||||
void getinput(InputPacket *, SWBOOL);
|
||||
void resetGameClock();
|
||||
|
||||
static uint8_t tempbuf[576], packbuf[576];
|
||||
int PlayClock;
|
||||
|
@ -82,7 +83,7 @@ typedef struct
|
|||
fix16_t q16horz;
|
||||
fix16_t q16ang;
|
||||
fix16_t q16horiz;
|
||||
int32_t bits;
|
||||
ESyncBits actions;
|
||||
} SW_AVERAGE_PACKET;
|
||||
|
||||
int MovesPerPacket = 1;
|
||||
|
@ -163,9 +164,7 @@ InitTimingVars(void)
|
|||
|
||||
// resettiming();
|
||||
totalsynctics = 0;
|
||||
I_ResetTime();
|
||||
lastTic = -1;
|
||||
ogameclock = gameclock = 0;
|
||||
resetGameClock();
|
||||
randomseed = 17L;
|
||||
|
||||
MoveSkip8 = 2;
|
||||
|
@ -202,9 +201,12 @@ UpdateInputs(void)
|
|||
AveragePacket.q16horz += loc.q16horz;
|
||||
AveragePacket.q16ang = Player[myconnectindex].camq16ang;
|
||||
AveragePacket.q16horiz = Player[myconnectindex].camq16horiz;
|
||||
SET(AveragePacket.bits, loc.bits);
|
||||
SET(AveragePacket.actions, loc.actions);
|
||||
// The above would or the weapon numbers together. Undo that now. The last one should win.
|
||||
AveragePacket.actions &= ~SB_WEAPONMASK_BITS;
|
||||
AveragePacket.actions |= ESyncBits::FromInt(loc.getNewWeapon()) & SB_WEAPONMASK_BITS;
|
||||
|
||||
Bmemset(&loc, 0, sizeof(loc));
|
||||
memset(&loc, 0, sizeof(loc));
|
||||
|
||||
pp = Player + myconnectindex;
|
||||
|
||||
|
@ -224,7 +226,7 @@ UpdateInputs(void)
|
|||
loc.q16horz = fix16_div(AveragePacket.q16horz, fix16_from_int(MovesPerPacket));
|
||||
loc.q16ang = AveragePacket.q16ang;
|
||||
loc.q16horiz = AveragePacket.q16horiz;
|
||||
loc.bits = AveragePacket.bits;
|
||||
loc.actions = AveragePacket.actions;
|
||||
|
||||
memset(&AveragePacket, 0, sizeof(AveragePacket));
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "jsector.h"
|
||||
#include "network.h"
|
||||
#include "gamestate.h"
|
||||
#include "player.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
|
@ -237,6 +238,62 @@ static int osdcmd_mirror(CCmdFuncPtr parm)
|
|||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_third_person_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
auto pp = &Player[myconnectindex];
|
||||
if (inputState.ShiftPressed())
|
||||
{
|
||||
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
||||
pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
||||
{
|
||||
RESET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
|
||||
pp->camera_dist = 0;
|
||||
}
|
||||
}
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_coop_view(CCmdFuncPtr parm)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
|
||||
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
|
||||
{
|
||||
screenpeek = connectpoint2[screenpeek];
|
||||
|
||||
if (screenpeek < 0)
|
||||
screenpeek = connecthead;
|
||||
|
||||
if (screenpeek == myconnectindex)
|
||||
{
|
||||
// JBF: figure out what's going on here
|
||||
auto pp = &Player[myconnectindex];
|
||||
DoPlayerDivePalette(pp); // Check Dive again
|
||||
DoPlayerNightVisionPalette(pp); // Check Night Vision again
|
||||
}
|
||||
else
|
||||
{
|
||||
PLAYERp tp = Player + screenpeek;
|
||||
DoPlayerDivePalette(tp);
|
||||
DoPlayerNightVisionPalette(tp);
|
||||
}
|
||||
}
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_noop(CCmdFuncPtr parm)
|
||||
{
|
||||
// this is for silencing key bindings only.
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
int32_t registerosdcommands(void)
|
||||
{
|
||||
|
@ -244,17 +301,14 @@ int32_t registerosdcommands(void)
|
|||
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
|
||||
C_RegisterFunction("god","god: toggles god mode", osdcmd_god);
|
||||
C_RegisterFunction("bunny", "bunny: toggles bunny rocket mode", osdcmd_bunny);
|
||||
C_RegisterFunction("mirror", "mirror [mirrornum]: print mirror debug info", osdcmd_mirror);
|
||||
|
||||
C_RegisterFunction("mirror_debug", "mirror [mirrornum]: print mirror debug info", osdcmd_mirror);
|
||||
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
|
||||
|
||||
C_RegisterFunction("levelwarp", "levelwarp <num>: warp to level", osdcmd_levelwarp);
|
||||
|
||||
C_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
|
||||
|
||||
// C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
|
||||
|
||||
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
|
||||
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
|
||||
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_coop_view);
|
||||
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_noop);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -191,15 +191,8 @@ void pToggleCrosshair(void)
|
|||
void DoPlayerChooseYell(PLAYERp pp)
|
||||
{
|
||||
int choose_snd = 0;
|
||||
short weapon;
|
||||
|
||||
weapon = TEST(pp->input.bits, SK_WEAPON_MASK);
|
||||
|
||||
if (weapon == WPN_FIST)
|
||||
{
|
||||
if (RANDOM_RANGE(1000) < 900) return;
|
||||
}
|
||||
else if (RANDOM_RANGE(1000) < 990) return;
|
||||
if (RANDOM_RANGE(1000) < 990) return;
|
||||
|
||||
choose_snd = STD_RANDOM_RANGE(MAX_YELLSOUNDS);
|
||||
|
||||
|
@ -472,9 +465,9 @@ int WeaponOperate(PLAYERp pp)
|
|||
if (!TEST(pp->sop->flags, SOBJ_HAS_WEAPON))
|
||||
break;
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_SHOOT))
|
||||
if (pp->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_SHOOT))
|
||||
if (pp->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
if (!pp->FirePause)
|
||||
{
|
||||
|
@ -487,13 +480,13 @@ int WeaponOperate(PLAYERp pp)
|
|||
}
|
||||
}
|
||||
|
||||
weapon = TEST(pp->input.bits, SK_WEAPON_MASK);
|
||||
weapon = pp->input.getNewWeapon();
|
||||
|
||||
if (weapon)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_WEAPON_BIT0))
|
||||
if (pp->KeyPressBits & SB_FIRST_WEAPON_BIT)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_WEAPON_BIT0);
|
||||
pp->KeyPressBits &= ~SB_FIRST_WEAPON_BIT;
|
||||
|
||||
weapon -= 1;
|
||||
|
||||
|
@ -640,7 +633,7 @@ int WeaponOperate(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_WEAPON_BIT0);
|
||||
pp->KeyPressBits |= SB_FIRST_WEAPON_BIT;
|
||||
}
|
||||
|
||||
// Shut that computer chick up if weapon has changed!
|
||||
|
@ -700,7 +693,7 @@ WeaponOK(PLAYERp pp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
FLAG_KEY_RELEASE(pp, SK_SHOOT);
|
||||
pp->KeyPressBits &= ~SB_FIRE;
|
||||
|
||||
FindWeaponNum = WPN_SHOTGUN; // Start at the top
|
||||
|
||||
|
@ -991,8 +984,7 @@ InitWeaponSword(PLAYERp pp)
|
|||
PlayerSound(DIGI_ILIKESWORD, v3df_follow|v3df_dontpan,pp);
|
||||
}
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1072,9 +1064,9 @@ pSwordSlideDown(PANEL_SPRITEp psp)
|
|||
if (psp->x < -40)
|
||||
{
|
||||
// if still holding down the fire key - continue swinging
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
DoPlayerChooseYell(psp->PlayerP);
|
||||
// continue to next state to swing right
|
||||
|
@ -1157,9 +1149,9 @@ pSwordSlideDownR(PANEL_SPRITEp psp)
|
|||
if (psp->x > 350)
|
||||
{
|
||||
// if still holding down the fire key - continue swinging
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
DoPlayerChooseYell(psp->PlayerP);
|
||||
// back to action state
|
||||
|
@ -1234,9 +1226,9 @@ pSwordRest(PANEL_SPRITEp psp)
|
|||
|
||||
force = !!TEST(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -1368,9 +1360,9 @@ PANEL_STATE ps_RetractStar[] =
|
|||
void
|
||||
pStarRestTest(PANEL_SPRITEp psp)
|
||||
{
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
if (!WeaponOK(psp->PlayerP))
|
||||
return;
|
||||
|
@ -1446,8 +1438,7 @@ InitWeaponStar(PLAYERp pp)
|
|||
PlayerSound(DIGI_ILIKESHURIKEN, v3df_follow|v3df_dontpan,pp);
|
||||
}
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1525,9 +1516,9 @@ pStarRest(PANEL_SPRITEp psp)
|
|||
pStarBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -2163,8 +2154,7 @@ InitWeaponUzi(PLAYERp pp)
|
|||
|
||||
PlaySound(DIGI_UZI_UP, pp, v3df_follow);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
PANEL_SPRITEp
|
||||
|
@ -2372,7 +2362,7 @@ pUziRest(PANEL_SPRITEp psp)
|
|||
|
||||
SetVisNorm();
|
||||
|
||||
shooting = TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) && FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT);
|
||||
shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE);
|
||||
shooting |= force;
|
||||
|
||||
pUziBobSetup(psp);
|
||||
|
@ -2397,7 +2387,7 @@ pUziAction(PANEL_SPRITEp psp)
|
|||
char shooting;
|
||||
static SWBOOL alternate = FALSE;
|
||||
|
||||
shooting = TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) && FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT);
|
||||
shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE);
|
||||
|
||||
if (shooting)
|
||||
{
|
||||
|
@ -2817,8 +2807,7 @@ InitWeaponShotgun(PLAYERp pp)
|
|||
|
||||
PlaySound(DIGI_SHOTGUN_UP, pp, v3df_follow);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3072,9 +3061,9 @@ pShotgunRest(PANEL_SPRITEp psp)
|
|||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -3116,9 +3105,9 @@ pShotgunRestTest(PANEL_SPRITEp psp)
|
|||
pShotgunBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -3331,8 +3320,7 @@ InitWeaponRail(PLAYERp pp)
|
|||
PlaySound(DIGI_RAILREADY, pp, v3df_follow | v3df_dontpan, CHAN_ITEM); // this one needs to be on a dedicated channel to allow switching it off without too many checks.
|
||||
Set3DSoundOwner(psp->PlayerP->PlayerSprite);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3476,9 +3464,9 @@ pRailRest(PANEL_SPRITEp psp)
|
|||
pRailBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -3509,9 +3497,9 @@ pRailRestTest(PANEL_SPRITEp psp)
|
|||
pRailBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -3789,8 +3777,7 @@ InitWeaponHothead(PLAYERp pp)
|
|||
psp->ang = 768;
|
||||
psp->vel = 512;
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
pHotHeadOverlays(psp, pp->WpnFlameType);
|
||||
psp->over[0].xoff = HOTHEAD_FINGER_XOFF;
|
||||
psp->over[0].yoff = HOTHEAD_FINGER_YOFF;
|
||||
|
@ -3801,9 +3788,9 @@ InitWeaponHothead(PLAYERp pp)
|
|||
void
|
||||
pHotheadRestTest(PANEL_SPRITEp psp)
|
||||
{
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
//if (!TEST(psp->PlayerP->Flags,PF_DIVING))
|
||||
{
|
||||
|
@ -3899,9 +3886,9 @@ pHotheadRest(PANEL_SPRITEp psp)
|
|||
pHotheadBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -3933,7 +3920,7 @@ pHotheadAction(PANEL_SPRITEp psp)
|
|||
{
|
||||
char shooting;
|
||||
|
||||
shooting = TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) && FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT);
|
||||
shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE);
|
||||
|
||||
if (shooting)
|
||||
{
|
||||
|
@ -4232,8 +4219,7 @@ InitWeaponMicro(PLAYERp pp)
|
|||
|
||||
PlaySound(DIGI_ROCKET_UP, pp, v3df_follow);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
|
||||
}
|
||||
|
||||
|
@ -4483,9 +4469,9 @@ pMicroRest(PANEL_SPRITEp psp)
|
|||
}
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -4745,8 +4731,7 @@ InitWeaponHeart(PLAYERp pp)
|
|||
psp->RestState = ps_HeartRest;
|
||||
pSetState(psp, psp->PresentState);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4814,11 +4799,11 @@ pHeartRest(PANEL_SPRITEp psp)
|
|||
pHeartBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits &= ~SB_FIRE;
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
if (!WeaponOK(psp->PlayerP))
|
||||
|
@ -4830,7 +4815,7 @@ pHeartRest(PANEL_SPRITEp psp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
WeaponOK(psp->PlayerP);
|
||||
}
|
||||
}
|
||||
|
@ -5248,8 +5233,7 @@ InitWeaponGrenade(PLAYERp pp)
|
|||
|
||||
PlaySound(DIGI_GRENADE_UP, pp, v3df_follow);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5396,9 +5380,9 @@ pGrenadeRest(PANEL_SPRITEp psp)
|
|||
pGrenadeBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -5546,8 +5530,7 @@ InitWeaponMine(PLAYERp pp)
|
|||
|
||||
PlaySound(DIGI_PULL, pp, v3df_follow|v3df_dontpan);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5646,9 +5629,9 @@ pMineRest(PANEL_SPRITEp psp)
|
|||
pMineBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -6213,8 +6196,7 @@ InitWeaponFist(PLAYERp pp)
|
|||
else if (rnd_num > 700)
|
||||
PlaySound(DIGI_PLAYERYELL2, pp, v3df_follow|v3df_dontpan);
|
||||
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT);
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT);
|
||||
psp->PlayerP->KeyPressBits |= SB_FIRE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6314,9 +6296,9 @@ pFistSlideDown(PANEL_SPRITEp psp)
|
|||
if (psp->y > 440)
|
||||
{
|
||||
// if still holding down the fire key - continue swinging
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
DoPlayerChooseYell(psp->PlayerP);
|
||||
|
||||
|
@ -6433,9 +6415,9 @@ pFistSlideDownR(PANEL_SPRITEp psp)
|
|||
if (psp->y > 440)
|
||||
{
|
||||
// if still holding down the fire key - continue swinging
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
DoPlayerChooseYell(psp->PlayerP);
|
||||
|
||||
|
@ -6536,11 +6518,9 @@ pFistRest(PANEL_SPRITEp psp)
|
|||
// Reset move to default
|
||||
psp->PlayerP->WpnKungFuMove = 0;
|
||||
|
||||
//if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force || TEST_SYNC_KEY(psp->PlayerP, SK_OPERATE))
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->input.actions & SB_FIRE) || force)
|
||||
{
|
||||
//if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force || FLAG_KEY_PRESSED(psp->PlayerP, SK_OPERATE))
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force)
|
||||
if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force)
|
||||
{
|
||||
RESET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
|
||||
|
@ -6601,7 +6581,7 @@ pFistBlock(PANEL_SPRITEp psp)
|
|||
pFistBobSetup(psp);
|
||||
pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP));
|
||||
|
||||
if (!TEST_SYNC_KEY(psp->PlayerP, SK_OPERATE))
|
||||
if (!(psp->PlayerP->input.actions & SB_OPEN))
|
||||
{
|
||||
pStatePlusOne(psp);
|
||||
}
|
||||
|
@ -6643,23 +6623,23 @@ pWeaponUnHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_HIDE_WEAPON))
|
||||
if (psp->PlayerP->input.actions & SB_HOLSTER)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_HIDE_WEAPON))
|
||||
if (psp->PlayerP->KeyPressBits & SB_HOLSTER)
|
||||
{
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_HIDE_WEAPON);
|
||||
psp->PlayerP->KeyPressBits &= ~SB_HOLSTER;
|
||||
pSetState(psp, state);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_HIDE_WEAPON);
|
||||
psp->PlayerP->KeyPressBits |= SB_HOLSTER;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT))
|
||||
if (psp->PlayerP->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
SET(psp->flags, PANF_UNHIDE_SHOOT);
|
||||
pSetState(psp, state);
|
||||
|
@ -6687,19 +6667,19 @@ pWeaponHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(psp->PlayerP, SK_HIDE_WEAPON))
|
||||
if (psp->PlayerP->input.actions & SB_HOLSTER)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(psp->PlayerP, SK_HIDE_WEAPON))
|
||||
if (psp->PlayerP->KeyPressBits & SB_HOLSTER)
|
||||
{
|
||||
psp->PlayerP->KeyPressBits &= ~SB_HOLSTER;
|
||||
PutStringInfo(psp->PlayerP,"Weapon Holstered");
|
||||
FLAG_KEY_RELEASE(psp->PlayerP, SK_HIDE_WEAPON);
|
||||
pSetState(psp, state);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(psp->PlayerP, SK_HIDE_WEAPON);
|
||||
psp->PlayerP->KeyPressBits |= SB_HOLSTER;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
@ -1566,13 +1566,13 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
|
|||
|
||||
if (!TEST(pp->Flags, PF_TURN_180))
|
||||
{
|
||||
if (TEST_SYNC_KEY(pp, SK_TURN_180))
|
||||
if (pp->input.actions & SB_TURNAROUND)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_TURN_180))
|
||||
if (pp->KeyPressBits & SB_TURNAROUND)
|
||||
{
|
||||
short delta_ang;
|
||||
|
||||
FLAG_KEY_RELEASE(pp, SK_TURN_180);
|
||||
pp->KeyPressBits &= ~SB_TURNAROUND;
|
||||
|
||||
pp->turn180_target = NORM_ANGLE(fix16_to_int(*pq16ang) + 1024);
|
||||
|
||||
|
@ -1591,7 +1591,7 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_TURN_180);
|
||||
pp->KeyPressBits |= SB_TURNAROUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1938,7 +1938,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_CENTER_VIEW))
|
||||
if ((pp->input.actions & SB_CENTERVIEW) || pp->centering)
|
||||
{
|
||||
if (PedanticMode)
|
||||
pp->q16horizbase = fix16_from_int(100);
|
||||
|
@ -1952,18 +1952,19 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED*6))));
|
||||
pp->q16horizbase = fix16_min(pp->q16horizbase, fix16_from_int(100));
|
||||
}
|
||||
pp->centering = pp->q16horizbase != fix16_from_int(100);
|
||||
*pq16horiz = pp->q16horizbase;
|
||||
pp->q16horizoff = 0;
|
||||
}
|
||||
|
||||
// this is the locked type
|
||||
if (TEST_SYNC_KEY(pp, SK_SNAP_UP) || TEST_SYNC_KEY(pp, SK_SNAP_DOWN))
|
||||
if (pp->input.actions & (SB_AIM_UP|SB_AIM_DOWN))
|
||||
{
|
||||
// set looking because player is manually looking
|
||||
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
|
||||
|
||||
// adjust *pq16horiz negative
|
||||
if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN))
|
||||
if (pp->input.actions & SB_AIM_DOWN)
|
||||
{
|
||||
if (PedanticMode)
|
||||
pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2));
|
||||
|
@ -1972,23 +1973,24 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
}
|
||||
|
||||
// adjust *pq16horiz positive
|
||||
if (TEST_SYNC_KEY(pp, SK_SNAP_UP))
|
||||
if (pp->input.actions & SB_AIM_UP)
|
||||
{
|
||||
if (PedanticMode)
|
||||
pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2));
|
||||
else
|
||||
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED/2))));
|
||||
}
|
||||
pp->centering = false;
|
||||
}
|
||||
|
||||
// this is the unlocked type
|
||||
if (TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
|
||||
if (pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN))
|
||||
{
|
||||
RESET(pp->Flags, PF_LOCK_HORIZ);
|
||||
SET(pp->Flags, PF_LOOKING);
|
||||
|
||||
// adjust *pq16horiz negative
|
||||
if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
|
||||
if (pp->input.actions & SB_LOOK_DOWN)
|
||||
{
|
||||
if (PedanticMode)
|
||||
pp->q16horizbase -= fix16_from_int(HORIZ_SPEED);
|
||||
|
@ -1997,18 +1999,19 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
}
|
||||
|
||||
// adjust *pq16horiz positive
|
||||
if (TEST_SYNC_KEY(pp, SK_LOOK_UP))
|
||||
if (pp->input.actions & SB_LOOK_UP)
|
||||
{
|
||||
if (PedanticMode)
|
||||
pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
|
||||
else
|
||||
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED)));
|
||||
}
|
||||
pp->centering = false;
|
||||
}
|
||||
|
||||
if (!TEST(pp->Flags, PF_LOCK_HORIZ))
|
||||
{
|
||||
if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN)))
|
||||
if (!(pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||
{
|
||||
// not pressing the *pq16horiz keys
|
||||
if (pp->q16horizbase != fix16_from_int(100))
|
||||
|
@ -2043,9 +2046,6 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
|
||||
pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MAX) - pp->q16horizbase;
|
||||
|
||||
////DSPRINTF(ds,"base %d, off %d, base + off %d",fix16_to_int(pp->q16horizbase), fix16_to_int(pp->q16horizoff), fix16_to_int(pp->q16horizbase + pp->q16horizoff));
|
||||
//MONO_PRINT(ds);
|
||||
|
||||
// add base and offsets
|
||||
*pq16horiz = pp->q16horizbase + pp->q16horizoff;
|
||||
#else
|
||||
|
@ -2073,7 +2073,7 @@ DoPlayerBob(PLAYERp pp)
|
|||
dist = 0;
|
||||
|
||||
// if running make a longer stride
|
||||
if (G_CheckAutorun(TEST_SYNC_KEY(pp, SK_RUN)))
|
||||
if (pp->input.actions & SB_RUN)
|
||||
{
|
||||
//amt = 10;
|
||||
amt = 12;
|
||||
|
@ -2464,31 +2464,12 @@ MoveScrollMode2D(PLAYERp pp)
|
|||
if (M_Active())
|
||||
return;
|
||||
|
||||
#if 0
|
||||
// Recenter view if told
|
||||
if (buttonMap.ButtonDown(gamefunc_Center_View))
|
||||
{
|
||||
Follow_posx = pp->posx;
|
||||
Follow_posy = pp->posy;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
mfsvel -= scrl_input.dyaw / 4;
|
||||
mfsvel -= scrl_input.dx / 4;
|
||||
mfvel = -scrl_input.dz /4;
|
||||
|
||||
#if 0
|
||||
int const running = !!BUTTON(gamefunc_Run) ^ !!TEST(pp->Flags, PF_LOCK_RUN);
|
||||
if (running)
|
||||
{
|
||||
keymove = NORMALKEYMOVE << 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
keymove = NORMALKEYMOVE;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
{
|
||||
|
@ -3485,16 +3466,16 @@ DoPlayerJump(PLAYERp pp)
|
|||
short i;
|
||||
|
||||
// reset flag key for double jumps
|
||||
if (!TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (!(pp->input.actions & SB_JUMP))
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_JUMP);
|
||||
pp->KeyPressBits |= SB_JUMP;
|
||||
}
|
||||
|
||||
// instead of multiplying by synctics, use a loop for greater accuracy
|
||||
for (i = 0; i < synctics; i++)
|
||||
{
|
||||
// PlayerGravity += synctics; // See how increase gravity as we go?
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
if (pp->JumpDuration > 0)
|
||||
{
|
||||
|
@ -3650,9 +3631,9 @@ DoPlayerFall(PLAYERp pp)
|
|||
int depth;
|
||||
|
||||
// reset flag key for double jumps
|
||||
if (!TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (!(pp->input.actions & SB_JUMP))
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_JUMP);
|
||||
pp->KeyPressBits |= SB_JUMP;
|
||||
}
|
||||
|
||||
if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
|
||||
|
@ -3727,7 +3708,7 @@ DoPlayerFall(PLAYERp pp)
|
|||
StopPlayerSound(pp, DIGI_FALLSCREAM);
|
||||
|
||||
// i any kind of crawl key get rid of recoil
|
||||
if (DoPlayerTestCrawl(pp) || TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
if (DoPlayerTestCrawl(pp) || (pp->input.actions & SB_CROUCH))
|
||||
{
|
||||
pp->posz = pp->loz - PLAYER_CRAWL_HEIGHT;
|
||||
}
|
||||
|
@ -3767,7 +3748,7 @@ DoPlayerFall(PLAYERp pp)
|
|||
return;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
if (pp->input.actions & SB_CROUCH)
|
||||
{
|
||||
StackedWaterSplash(pp);
|
||||
DoPlayerBeginCrawl(pp);
|
||||
|
@ -3856,7 +3837,7 @@ DoPlayerClimb(PLAYERp pp)
|
|||
// need to rewrite this for FAF stuff
|
||||
|
||||
// Jump off of the ladder
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
RESET(pp->Flags, PF_CLIMBING|PF_WEAPON_DOWN);
|
||||
RESET(sp->cstat, CSTAT_SPRITE_YCENTER);
|
||||
|
@ -4167,14 +4148,14 @@ DoPlayerCrawl(PLAYERp pp)
|
|||
|
||||
if (TEST(pp->Flags, PF_LOCK_CRAWL))
|
||||
{
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL_LOCK))
|
||||
if (pp->input.actions & SB_CROUCH_LOCK)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_CRAWL_LOCK))
|
||||
if (pp->KeyPressBits & SB_CROUCH_LOCK)
|
||||
{
|
||||
//if (pp->hiz < PLAYER_STANDING_ROOM(pp))
|
||||
if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_CRAWL_LOCK);
|
||||
pp->KeyPressBits&= ~SB_CROUCH_LOCK;
|
||||
|
||||
RESET(pp->Flags, PF_CRAWLING);
|
||||
DoPlayerBeginRun(pp);
|
||||
|
@ -4184,11 +4165,11 @@ DoPlayerCrawl(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_CRAWL_LOCK);
|
||||
pp->KeyPressBits |= SB_CROUCH_LOCK;
|
||||
}
|
||||
|
||||
// Jump to get up
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
{
|
||||
|
@ -4204,7 +4185,7 @@ DoPlayerCrawl(PLAYERp pp)
|
|||
else
|
||||
{
|
||||
// Let off of crawl to get up
|
||||
if (!TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
if (!(pp->input.actions & SB_CROUCH))
|
||||
{
|
||||
if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
{
|
||||
|
@ -4331,7 +4312,7 @@ DoPlayerFly(PLAYERp pp)
|
|||
return;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
if (pp->input.actions & SB_CROUCH)
|
||||
{
|
||||
pp->z_speed += PLAYER_FLY_INC;
|
||||
|
||||
|
@ -4339,7 +4320,7 @@ DoPlayerFly(PLAYERp pp)
|
|||
pp->z_speed = PLAYER_FLY_MAX_SPEED;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
pp->z_speed -= PLAYER_FLY_INC;
|
||||
|
||||
|
@ -4550,7 +4531,7 @@ PlayerCanDive(PLAYERp pp)
|
|||
return FALSE;
|
||||
|
||||
// Crawl - check for diving
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL) || pp->jump_speed > 0)
|
||||
if ((pp->input.actions & SB_CROUCH) || pp->jump_speed > 0)
|
||||
{
|
||||
if (PlayerInDiveArea(pp))
|
||||
{
|
||||
|
@ -5183,7 +5164,7 @@ DoPlayerDive(PLAYERp pp)
|
|||
}
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
if (pp->input.actions & SB_CROUCH)
|
||||
{
|
||||
pp->z_speed += PLAYER_DIVE_INC;
|
||||
|
||||
|
@ -5191,7 +5172,7 @@ DoPlayerDive(PLAYERp pp)
|
|||
pp->z_speed = PLAYER_DIVE_MAX_SPEED;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
pp->z_speed -= PLAYER_DIVE_INC;
|
||||
|
||||
|
@ -5456,13 +5437,13 @@ DoPlayerWade(PLAYERp pp)
|
|||
|
||||
if (DebugOperate)
|
||||
{
|
||||
if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_OPERATE))
|
||||
if (pp->KeyPressBits & SB_OPEN)
|
||||
{
|
||||
if (TEST(sector[pp->cursectnum].extra, SECTFX_OPERATIONAL))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
DoPlayerBeginOperate(pp);
|
||||
pp->bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
|
@ -5472,7 +5453,7 @@ DoPlayerWade(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_OPERATE);
|
||||
pp->KeyPressBits |= SB_OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5484,17 +5465,17 @@ DoPlayerWade(PLAYERp pp)
|
|||
}
|
||||
|
||||
// Crawl Commanded
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL) && pp->WadeDepth <= PLAYER_CRAWL_WADE_DEPTH)
|
||||
if ((pp->input.actions & SB_CROUCH) && pp->WadeDepth <= PLAYER_CRAWL_WADE_DEPTH)
|
||||
{
|
||||
DoPlayerBeginCrawl(pp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_JUMP))
|
||||
if (pp->KeyPressBits & SB_JUMP)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_JUMP);
|
||||
pp->KeyPressBits &= ~SB_JUMP;
|
||||
//DoPlayerHeight(pp);
|
||||
//DoPlayerHeight(pp);
|
||||
//DoPlayerHeight(pp);
|
||||
|
@ -5507,7 +5488,7 @@ DoPlayerWade(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_JUMP);
|
||||
pp->KeyPressBits |= SB_JUMP;
|
||||
}
|
||||
|
||||
if (PlayerFlyKey())
|
||||
|
@ -5980,18 +5961,18 @@ DoPlayerOperateTurret(PLAYERp pp)
|
|||
{
|
||||
short save_sectnum;
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_OPERATE))
|
||||
if (pp->KeyPressBits & SB_OPEN)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
DoPlayerStopOperate(pp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_OPERATE);
|
||||
pp->KeyPressBits |= SB_OPEN;
|
||||
}
|
||||
|
||||
if (pp->sop->max_damage != -9999 && pp->sop->max_damage <= 0)
|
||||
|
@ -6020,18 +6001,18 @@ DoPlayerOperateBoat(PLAYERp pp)
|
|||
{
|
||||
short save_sectnum;
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_OPERATE))
|
||||
if (pp->KeyPressBits & SB_OPEN)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
DoPlayerStopOperate(pp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_OPERATE);
|
||||
pp->KeyPressBits |= SB_OPEN;
|
||||
}
|
||||
|
||||
if (pp->sop->max_damage != -9999 && pp->sop->max_damage <= 0)
|
||||
|
@ -6059,19 +6040,18 @@ DoPlayerOperateTank(PLAYERp pp)
|
|||
{
|
||||
short save_sectnum;
|
||||
|
||||
//ASSERT(!TEST_SYNC_KEY(pp, SK_OPERATE));
|
||||
if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_OPERATE))
|
||||
if (pp->KeyPressBits & SB_OPEN)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
DoPlayerStopOperate(pp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_OPERATE);
|
||||
pp->KeyPressBits |= SB_OPEN;
|
||||
}
|
||||
|
||||
if (pp->sop->max_damage != -9999 && pp->sop->max_damage <= 0)
|
||||
|
@ -6574,9 +6554,9 @@ void DoPlayerDeathHurl(PLAYERp pp)
|
|||
{
|
||||
if (numplayers > 1)
|
||||
{
|
||||
if (TEST_SYNC_KEY(pp, SK_SHOOT))
|
||||
if (pp->input.actions & SB_FIRE)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_SHOOT))
|
||||
if (pp->KeyPressBits & SB_FIRE)
|
||||
{
|
||||
|
||||
|
||||
|
@ -6637,8 +6617,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
|
|||
SPRITEp sp = pp->SpriteP;
|
||||
USERp u = User[pp->PlayerSprite];
|
||||
|
||||
//if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (TEST_SYNC_KEY(pp, SK_SPACE_BAR))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
// Spawn a dead LoWang body for non-head deaths
|
||||
// Hey Frank, if you think of a better check, go ahead and put it in.
|
||||
|
@ -7139,18 +7118,18 @@ DoPlayerRun(PLAYERp pp)
|
|||
}
|
||||
|
||||
// Crawl Commanded
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
if (pp->input.actions & SB_CROUCH)
|
||||
{
|
||||
DoPlayerBeginCrawl(pp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Jump
|
||||
if (TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
if (pp->input.actions & SB_JUMP)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_JUMP))
|
||||
if (pp->KeyPressBits & SB_JUMP)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_JUMP);
|
||||
pp->KeyPressBits &= ~SB_JUMP;
|
||||
// make sure you stand at full heights for jumps/double jumps
|
||||
//DoPlayerHeight(pp);
|
||||
//DoPlayerHeight(pp);
|
||||
|
@ -7164,15 +7143,15 @@ DoPlayerRun(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_JUMP);
|
||||
pp->KeyPressBits |= SB_JUMP;
|
||||
}
|
||||
|
||||
// Crawl lock
|
||||
if (TEST_SYNC_KEY(pp, SK_CRAWL_LOCK))
|
||||
if (pp->input.actions & SB_CROUCH_LOCK)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_CRAWL_LOCK))
|
||||
if (pp->KeyPressBits & SB_CROUCH_LOCK)
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_CRAWL_LOCK);
|
||||
pp->KeyPressBits &= ~SB_CROUCH_LOCK;
|
||||
SET(pp->Flags, PF_LOCK_CRAWL);
|
||||
DoPlayerBeginCrawl(pp);
|
||||
return;
|
||||
|
@ -7180,7 +7159,7 @@ DoPlayerRun(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_CRAWL_LOCK);
|
||||
pp->KeyPressBits |= SB_CROUCH_LOCK;
|
||||
}
|
||||
|
||||
if (PlayerFlyKey())
|
||||
|
@ -7193,13 +7172,13 @@ DoPlayerRun(PLAYERp pp)
|
|||
{
|
||||
if (!TEST(pp->Flags, PF_DEAD) && !Prediction)
|
||||
{
|
||||
if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_OPERATE) && pp->cursectnum >= 0)
|
||||
if ((pp->KeyPressBits & SB_OPEN) && pp->cursectnum >= 0)
|
||||
{
|
||||
if (TEST(sector[pp->cursectnum].extra, SECTFX_OPERATIONAL))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
DoPlayerBeginOperate(pp);
|
||||
return;
|
||||
}
|
||||
|
@ -7211,7 +7190,7 @@ DoPlayerRun(PLAYERp pp)
|
|||
if (sp && SP_TAG5(sp) == TRIGGER_TYPE_REMOTE_SO)
|
||||
{
|
||||
pp->remote_sprite = sp;
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
ASSERT(pp->remote_sprite);
|
||||
DoPlayerBeginRemoteOperate(pp, &SectorObject[SP_TAG7(pp->remote_sprite)]);
|
||||
return;
|
||||
|
@ -7221,7 +7200,7 @@ DoPlayerRun(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
FLAG_KEY_RESET(pp, SK_OPERATE);
|
||||
pp->KeyPressBits |= SB_OPEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7426,7 +7405,7 @@ void ChopsCheck(PLAYERp pp)
|
|||
{
|
||||
if (!M_Active() && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1)
|
||||
{
|
||||
if ((pp->input.bits|pp->input.fvel|pp->input.svel|pp->input.q16avel|pp->input.q16horz) ||
|
||||
if (pp->input.actions || pp->input.fvel || pp->input.svel || pp->input.q16avel || pp->input.q16horz ||
|
||||
TEST(pp->Flags, PF_CLIMBING | PF_FALLING | PF_DIVING))
|
||||
{
|
||||
// Hit a input key or other reason to stop chops
|
||||
|
@ -7753,7 +7732,7 @@ domovethings(void)
|
|||
MultiPlayLimits();
|
||||
|
||||
//if (MoveSkip8 == 0) // 8=5x 4=10x, 2=20x, 0=40x per second
|
||||
DoUpdateSounds();
|
||||
gi->UpdateSounds();
|
||||
|
||||
thinktime.Unclock();
|
||||
|
||||
|
@ -7813,7 +7792,7 @@ InitAllPlayers(void)
|
|||
|
||||
pp->WpnGotOnceFlags = 0;
|
||||
pp->DoPlayerAction = DoPlayerBeginRun;
|
||||
pp->KeyPressFlags = 0xFFFFFFFF;
|
||||
pp->KeyPressBits = ESyncBits::FromInt(0xFFFFFFFF);
|
||||
memset(pp->KilledPlayer,0,sizeof(pp->KilledPlayer));
|
||||
|
||||
if (NewGame)
|
||||
|
|
|
@ -83,23 +83,8 @@ DoPrediction(PLAYERp ppp)
|
|||
|
||||
// get rid of input bits so it doesn't go into other code branches that would
|
||||
// get it out of sync
|
||||
RESET(ppp->input.bits,
|
||||
BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_INV_LEFT)|BIT(SK_INV_RIGHT)|
|
||||
BIT(SK_INV_USE)|BIT(SK_HIDE_WEAPON)|
|
||||
BIT(SK_AUTO_AIM)|
|
||||
BIT(SK_CENTER_VIEW)|
|
||||
SK_WEAPON_MASK|
|
||||
SK_INV_HOTKEY_MASK
|
||||
);
|
||||
|
||||
SET(ppp->KeyPressFlags,
|
||||
BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_INV_LEFT)|BIT(SK_INV_RIGHT)|
|
||||
BIT(SK_INV_USE)|BIT(SK_HIDE_WEAPON)|
|
||||
BIT(SK_AUTO_AIM)|
|
||||
BIT(SK_CENTER_VIEW)|
|
||||
SK_WEAPON_MASK|
|
||||
SK_INV_HOTKEY_MASK
|
||||
);
|
||||
ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW|SB_FIRE|SB_OPEN);;
|
||||
ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW|SB_FIRE|SB_OPEN);
|
||||
|
||||
// back up things so they won't get stepped on
|
||||
bakrandomseed = randomseed;
|
||||
|
|
|
@ -2585,9 +2585,9 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
// Switch & door activations
|
||||
//
|
||||
|
||||
if (TEST_SYNC_KEY(pp, SK_OPERATE))
|
||||
if (pp->input.actions & SB_OPEN)
|
||||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_OPERATE))
|
||||
if (pp->KeyPressBits & SB_OPEN)
|
||||
{
|
||||
// if space bar pressed
|
||||
short nt_ndx;
|
||||
|
@ -2595,7 +2595,7 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
|
||||
if (DoPlayerGrabStar(pp))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2613,7 +2613,7 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
{
|
||||
if (OperateSprite(nti[nt_ndx].spritenum, TRUE))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -2642,7 +2642,7 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
{
|
||||
if (OperateSprite(nti[nt_ndx].spritenum, TRUE))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2663,7 +2663,7 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
if (OperateSector(neartagsector, TRUE))
|
||||
{
|
||||
// Release the key
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2671,7 +2671,7 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
{
|
||||
if (OperateWall(neartagwall, TRUE))
|
||||
{
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2690,11 +2690,11 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
break;
|
||||
case TAG_SPRING_BOARD:
|
||||
DoSpringBoard(pp/*, pp->cursectnum*/);
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
break;
|
||||
case TAG_DOOR_ROTATE:
|
||||
if (OperateSector(pp->cursectnum, TRUE))
|
||||
FLAG_KEY_RELEASE(pp, SK_OPERATE);
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2702,7 +2702,7 @@ PlayerOperateEnv(PLAYERp pp)
|
|||
else
|
||||
{
|
||||
// Reset the key when syncbit key is not in use
|
||||
FLAG_KEY_RESET(pp, SK_OPERATE);
|
||||
pp->KeyPressBits |= SB_OPEN;
|
||||
}
|
||||
|
||||
// ////////////////////////////
|
||||
|
|
|
@ -585,7 +585,7 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void DoUpdateSounds(void)
|
||||
void GameInterface::UpdateSounds(void)
|
||||
{
|
||||
PLAYERp pp = Player + screenpeek;
|
||||
SoundListener listener;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue