- use CCMDs for input in Blood where appropriate.

This commit is contained in:
Christoph Oelckers 2020-08-02 20:44:37 +02:00
parent 4a049c1a4d
commit 00ecea47aa
8 changed files with 82 additions and 156 deletions

View file

@ -752,7 +752,7 @@ void ClockStrobe()
void ReadAllRFS(); void ReadAllRFS();
static const char* actions[] = { static const char* actions[] = {
"Move_Forward", "Move_Forward",
"Move_Backward", "Move_Backward",
"Turn_Left", "Turn_Left",
"Turn_Right", "Turn_Right",
@ -771,43 +771,19 @@ static const char* actions[] = {
"Strafe_Right", "Strafe_Right",
"Aim_Up", "Aim_Up",
"Aim_Down", "Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"Nightvision",
"MedKit",
"TurnAround",
"SendMessage", "SendMessage",
"Map", "Map",
"Shrink_Screen", "Shrink_Screen",
"Enlarge_Screen", "Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon", "Show_Opponents_Weapon",
"Map_Follow_Mode", "Map_Follow_Mode",
"See_Coop_View", "See_Coop_View",
"Mouse_Aiming", "Mouse_Aiming",
"Toggle_Crosshair", "Toggle_Crosshair",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select", "Dpad_Select",
"Dpad_Aiming", "Dpad_Aiming",
"Third_Person_View", "Third_Person_View",
"Toggle_Crouch", "Toggle_Crouch",
"CrystalBall",
"ProximityBombs",
"RemoteBombs",
"Jetpack"
}; };
static void app_init() static void app_init()
@ -863,6 +839,7 @@ static void app_init()
Printf("Initializing sound system\n"); Printf("Initializing sound system\n");
sndInit(); sndInit();
registerosdcommands(); registerosdcommands();
registerinputcommands();
gChoke.sub_83ff0(518, sub_84230); gChoke.sub_83ff0(518, sub_84230);
if (bAddUserMap) if (bAddUserMap)

View file

@ -50,43 +50,19 @@ enum GameFunction_t
gamefunc_Strafe_Right, gamefunc_Strafe_Right,
gamefunc_Aim_Up, gamefunc_Aim_Up,
gamefunc_Aim_Down, gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_BeastVision, //Nightvision
gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage, gamefunc_SendMessage,
gamefunc_Map, gamefunc_Map,
gamefunc_Shrink_Screen, gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen, gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon, gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode, gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View, gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming, gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair, gamefunc_Toggle_Crosshair,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Dpad_Select, gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming, gamefunc_Dpad_Aiming,
gamefunc_Third_Person_View, gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch, gamefunc_Toggle_Crouch,
gamefunc_CrystalBall,
gamefunc_ProximityBombs,
gamefunc_RemoteBombs,
gamefunc_JumpBoots,
NUM_ACTIONS NUM_ACTIONS
}; };
@ -149,6 +125,7 @@ struct GameInterface : ::GameInterface
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override; void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
void QuitToTitle() override; void QuitToTitle() override;
FString GetCoordString() override; FString GetCoordString() override;
void clearlocalinputstate() override;
GameStats getStats() override; GameStats getStats() override;
}; };

View file

@ -43,6 +43,9 @@ GINPUT gInput, gNetInput;
bool bSilentAim = false; bool bSilentAim = false;
int iTurnCount = 0; int iTurnCount = 0;
static int WeaponToSend;
static KEYFLAGS BitsToSend;
static USEFLAGS UsesToSend;
void ctrlInit(void) void ctrlInit(void)
{ {
@ -116,6 +119,14 @@ void ctrlGetInput(void)
if (gQuitRequest) if (gQuitRequest)
gInput.keyFlags.quit = 1; gInput.keyFlags.quit = 1;
gInput.keyFlags.word |= BitsToSend.word;
gInput.useFlags.byte |= UsesToSend.byte;
gInput.newWeapon = WeaponToSend;
BitsToSend.word = 0;
UsesToSend.byte = 0;
WeaponToSend = 0;
if (buttonMap.ButtonDown(gamefunc_Map)) if (buttonMap.ButtonDown(gamefunc_Map))
{ {
buttonMap.ClearButton(gamefunc_Map); buttonMap.ClearButton(gamefunc_Map);
@ -179,17 +190,6 @@ void ctrlGetInput(void)
if (gPlayer[myconnectindex].nextWeapon == 0) if (gPlayer[myconnectindex].nextWeapon == 0)
{ {
if (buttonMap.ButtonPressed(gamefunc_Next_Weapon))
{
buttonMap.ClearButton(gamefunc_Next_Weapon);
gInput.keyFlags.nextWeapon = 1;
}
if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon))
{
buttonMap.ClearButton(gamefunc_Previous_Weapon);
gInput.keyFlags.prevWeapon = 1;
}
} }
if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon)) if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
@ -227,83 +227,6 @@ void ctrlGetInput(void)
gInput.buttonFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down); gInput.buttonFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down);
} }
if (buttonMap.ButtonDown(gamefunc_Center_View))
{
buttonMap.ClearButton(gamefunc_Center_View);
gInput.keyFlags.lookCenter = 1;
}
gInput.keyFlags.spin180 |= buttonMap.ButtonDown(gamefunc_TurnAround);
if (buttonMap.ButtonDown(gamefunc_Inventory_Left))
{
buttonMap.ClearButton(gamefunc_Inventory_Left);
gInput.keyFlags.prevItem = 1;
}
if (buttonMap.ButtonDown(gamefunc_Inventory_Right))
{
buttonMap.ClearButton(gamefunc_Inventory_Right);
gInput.keyFlags.nextItem = 1;
}
if (buttonMap.ButtonDown(gamefunc_Inventory))
{
buttonMap.ClearButton(gamefunc_Inventory);
gInput.keyFlags.useItem = 1;
}
if (buttonMap.ButtonDown(gamefunc_BeastVision))
{
buttonMap.ClearButton(gamefunc_BeastVision);
gInput.useFlags.useBeastVision = 1;
}
if (buttonMap.ButtonDown(gamefunc_CrystalBall))
{
buttonMap.ClearButton(gamefunc_CrystalBall);
gInput.useFlags.useCrystalBall = 1;
}
if (buttonMap.ButtonDown(gamefunc_JumpBoots))
{
buttonMap.ClearButton(gamefunc_JumpBoots);
gInput.useFlags.useJumpBoots = 1;
}
if (buttonMap.ButtonDown(gamefunc_MedKit))
{
buttonMap.ClearButton(gamefunc_MedKit);
gInput.useFlags.useMedKit = 1;
}
for (int i = 0; i < 10; i++)
{
if (buttonMap.ButtonDown(gamefunc_Weapon_1 + i))
{
buttonMap.ClearButton(gamefunc_Weapon_1 + i);
gInput.newWeapon = 1 + i;
}
}
if (buttonMap.ButtonDown(gamefunc_ProximityBombs))
{
buttonMap.ClearButton(gamefunc_ProximityBombs);
gInput.newWeapon = 11;
}
if (buttonMap.ButtonDown(gamefunc_RemoteBombs))
{
buttonMap.ClearButton(gamefunc_RemoteBombs);
gInput.newWeapon = 12;
}
if (buttonMap.ButtonDown(gamefunc_Holster_Weapon))
{
buttonMap.ClearButton(gamefunc_Holster_Weapon);
gInput.keyFlags.holsterWeapon = 1;
}
int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int const run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run); int const run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run);
int const keyMove = (1 + run) << 10; int const keyMove = (1 + run) << 10;
@ -429,4 +352,53 @@ 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; 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 { UsesToSend.useJumpBoots = 1; return CCMD_OK; });
C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { UsesToSend.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 { UsesToSend.useCrystalBall = 1; return CCMD_OK; });
C_RegisterFunction("beastvision", nullptr, [](CCmdFuncPtr)->int { UsesToSend.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.word = 0;
UsesToSend.byte = 0;
}
END_BLD_NS END_BLD_NS

View file

@ -42,6 +42,7 @@ void sub_5571C(char mode);
void sub_557C4(int x, int y, int interpolation); 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); void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int viewPlayer);
int32_t registerosdcommands(void); int32_t registerosdcommands(void);
void registerinputcommands(void);
int qanimateoffs(int a1, int a2); int qanimateoffs(int a1, int a2);
int32_t qgetpalookup(int32_t a1, int32_t a2); int32_t qgetpalookup(int32_t a1, int32_t a2);
void HookReplaceFunctions(); void HookReplaceFunctions();

View file

@ -165,7 +165,6 @@ void viewInit(void);
void viewResizeView(int size); void viewResizeView(int size);
void UpdateFrame(void); void UpdateFrame(void);
void viewDrawInterface(ClockTicks arg); void viewDrawInterface(ClockTicks arg);
tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect);
void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth); void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm); void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm);
void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm); void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm);

View file

@ -1,11 +1,11 @@
U "+Mouse_Aiming" U "+Mouse_Aiming"
I "+Toggle_Crosshair" I "+Toggle_Crosshair"
Scroll "+Holster_Weapon" Scroll "+Holster_Weapon"
B "+BeastVision" B "BeastVision"
C "+CrystalBall" C "CrystalBall"
P "+ProximityBombs" P "ProximityBombs"
R "+RemoteBombs" R "RemoteBombs"
X "+Alt_Fire" X "+Alt_Fire"
J "+Jetpack" J "jumpboots"
M "+MedKit" M "MedKit"
Mouse2 "+Alt_Fire" Mouse2 "+Alt_Fire"

View file

@ -1,9 +1,9 @@
// //
W "+Show_Opponents_Weapon" W "+Show_Opponents_Weapon"
B "+BeastVision" B "BeastVision"
C "+CrystalBall" C "CrystalBall"
P "+ProximityBombs" P "ProximityBombs"
R "+RemoteBombs" R "RemoteBombs"
X "+Alt_Fire" X "+Alt_Fire"
J "+Jetpack" J "jumpboots"
M "+MedKit" M "MedKit"

View file

@ -1,10 +1,10 @@
// //
X "+Alt_Fire" X "+Alt_Fire"
W "+Show_Opponents_Weapon" W "+Show_Opponents_Weapon"
B "+BeastVision" B "BeastVision"
C "+CrystalBall" C "CrystalBall"
J "+JetPack" J "jumpboots"
M "+MedKit" M "MedKit"
P "+ProximityBombs" P "ProximityBombs"
R "+RemoteBombs" R "RemoteBombs"
Mouse2 "+Alt_Fire" Mouse2 "+Alt_Fire"