mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-21 19:21:44 +00:00
- allow entering cheats in the chat editor without using '#'.
This commit is contained in:
parent
de70e802ec
commit
e2d0cbf772
5 changed files with 19 additions and 33 deletions
|
@ -101,9 +101,9 @@ static bool CheatAddKey (cheatseq_t *cheat, uint8_t key, bool *eat)
|
|||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
bool Cheat_Responder (event_t *ev)
|
||||
int Cheat_Responder (event_t *ev)
|
||||
{
|
||||
bool eat = false;
|
||||
bool eat = false, done = false;
|
||||
|
||||
if (nocheats)
|
||||
{
|
||||
|
@ -120,11 +120,11 @@ bool Cheat_Responder (event_t *ev)
|
|||
{
|
||||
if (cheats->DontCheck || !CheckCheatmode ())
|
||||
{
|
||||
done = true;
|
||||
if (cheats->Handler)
|
||||
eat |= cheats->Handler (cheats);
|
||||
else if (cheats->ccmd)
|
||||
{
|
||||
eat = true;
|
||||
C_DoCommand(cheats->ccmd);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ bool Cheat_Responder (event_t *ev)
|
|||
}
|
||||
}
|
||||
}
|
||||
return eat;
|
||||
return done? -1 : eat? 1 : 0;
|
||||
}
|
||||
|
||||
bool SendGenericCheat(cheatseq_t* cheat)
|
||||
|
@ -146,8 +146,9 @@ bool SendGenericCheat(cheatseq_t* cheat)
|
|||
return true;
|
||||
}
|
||||
|
||||
void PlaybackCheat(const char *p)
|
||||
bool PlaybackCheat(const char *p)
|
||||
{
|
||||
bool success = false;
|
||||
if (!CheckCheatmode(true))
|
||||
{
|
||||
event_t ev = { EV_KeyDown, 0, 0, -1 };
|
||||
|
@ -156,11 +157,17 @@ void PlaybackCheat(const char *p)
|
|||
{
|
||||
// just play the cheat command through the event parser
|
||||
ev.data2 = *p;
|
||||
Cheat_Responder(&ev);
|
||||
int result = Cheat_Responder(&ev);
|
||||
if (result == -1)
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ev.data2 = -1;
|
||||
Cheat_Responder(&ev);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
CCMD(activatecheat)
|
||||
|
|
|
@ -14,8 +14,8 @@ struct cheatseq_t
|
|||
};
|
||||
struct event_t;
|
||||
|
||||
bool Cheat_Responder(event_t* ev);
|
||||
int Cheat_Responder(event_t* ev);
|
||||
void SetCheats(cheatseq_t *cht, int count);
|
||||
void PlaybackCheat(const char* p);
|
||||
bool PlaybackCheat(const char* p);
|
||||
bool SendGenericCheat(cheatseq_t* cheat);
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "gamestruct.h"
|
||||
#include "gamecvars.h"
|
||||
#include "menustate.h"
|
||||
#include "cheathandler.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -326,10 +327,11 @@ static void ShoveChatStr (const char *str, uint8_t who)
|
|||
|
||||
if (*str == '#')
|
||||
{
|
||||
C_DoCommand(FStringf("activatecheat \"%s\"", str + 1));
|
||||
PlaybackCheat(str + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlaybackCheat(str)) return;
|
||||
#if 0
|
||||
FString substBuff;
|
||||
|
||||
|
|
|
@ -8,5 +8,5 @@ struct event;
|
|||
void CT_Init (void);
|
||||
bool CT_Responder (event_t* ev);
|
||||
void CT_Drawer (void);
|
||||
bool Cheat_Responder (event_t* ev);
|
||||
int Cheat_Responder (event_t* ev);
|
||||
|
|
@ -359,30 +359,7 @@ static bool cheatGary(cheatseq_t *)
|
|||
}
|
||||
|
||||
static cheatseq_t dukecheats[] = {
|
||||
{ "dncornholio", nullptr, SendGenericCheat, 0, CHT_GOD },
|
||||
{ "dnstuff", "give all", },
|
||||
{ "dnscotty###", nullptr, cheatLevel }, // -> levelwarp
|
||||
{ "dncoords", "stat coord", nullptr, 1 },
|
||||
{ "dnview", "third_person_view",nullptr, 1 },
|
||||
{ "dntime", "stat fps", nullptr, 1 },
|
||||
{ "dnunlock", nullptr, SendGenericCheat, 0, CHT_UNLOCK },
|
||||
{ "dncashman", nullptr, SendGenericCheat, 0, CHT_CASHMAN },
|
||||
{ "dnitems", "give items", },
|
||||
{ "dnrate", "toggle vid_fps", nullptr, 1 },
|
||||
{ "dnskill#", nullptr, cheatSkill }, // restartmap <skill>
|
||||
{ "dnbeta", nullptr, cheatBeta },
|
||||
{ "dnhyper", nullptr, SendGenericCheat, 0, CHT_HYPER },
|
||||
{ "dnmonsters", nullptr, SendGenericCheat, 0, CHT_MONSTERS },
|
||||
{ "dntodd", nullptr, cheatTodd },
|
||||
{ "dnshowmap", nullptr, cheatMap },
|
||||
{ "dnkroz", nullptr, SendGenericCheat, 0, CHT_GOD },
|
||||
{ "dnallen", nullptr, cheatAllen },
|
||||
{ "dnclip", nullptr, SendGenericCheat, 0, CHT_NOCLIP },
|
||||
{ "dnweapons", "give weapons" },
|
||||
{ "dninventory", "give inventory" },
|
||||
{ "dnkeys", "give keys" },
|
||||
{ "dndebug", nullptr, cheatDebug, 1 },
|
||||
{ "dncgs", nullptr, SendGenericCheat, 0, CHT_KILL },
|
||||
};
|
||||
|
||||
static cheatseq_t ww2cheats[] =
|
||||
|
|
Loading…
Reference in a new issue