This commit is contained in:
Christoph Oelckers 2020-01-07 01:11:33 +01:00
commit b8ac5aea84
6 changed files with 19 additions and 23 deletions

View file

@ -17,9 +17,7 @@ class CompositeSavegameWriter
public: public:
void Clear() void Clear()
{ {
subfiles.Reset(); subfiles.DeleteAndClear();
subfilenames.Reset();
isCompressed.Reset();
} }
void SetFileName(const char* fn) void SetFileName(const char* fn)
{ {

View file

@ -717,7 +717,6 @@ class DTextEnterMenu : public DMenu
FString mEnterString; FString mEnterString;
int mEnterSize; int mEnterSize;
int mEnterPos;
bool mInputGridOkay; bool mInputGridOkay;
int InputGridX; int InputGridX;
int InputGridY; int InputGridY;

View file

@ -67,7 +67,7 @@ DTextEnterMenu::DTextEnterMenu(DMenu *parent, FFont *dpf, FString textbuffer, in
: DMenu(parent) : DMenu(parent)
{ {
mEnterString = textbuffer; mEnterString = textbuffer;
mEnterPos = maxlen; mEnterSize = maxlen;
mInputGridOkay = (showgrid && (m_showinputgrid == 0)) || (m_showinputgrid >= 1); mInputGridOkay = (showgrid && (m_showinputgrid == 0)) || (m_showinputgrid >= 1);
if (mEnterString.Len() > 0) if (mEnterString.Len() > 0)
{ {
@ -116,7 +116,7 @@ bool DTextEnterMenu::Responder(event_t *ev)
char ch = (char)ev->data1; char ch = (char)ev->data1;
if ((ev->subtype == EV_GUI_KeyDown || ev->subtype == EV_GUI_KeyRepeat) && ch == '\b') if ((ev->subtype == EV_GUI_KeyDown || ev->subtype == EV_GUI_KeyRepeat) && ch == '\b')
{ {
if (mEnterPos > 0) if (mEnterString.Len() > 0)
{ {
mEnterString.DeleteLastCharacter(); mEnterString.DeleteLastCharacter();
} }

View file

@ -979,6 +979,13 @@ void mysetbrightness(char nBrightness)
g_visibility = 2048 - (nBrightness << 9); g_visibility = 2048 - (nBrightness << 9);
} }
// Replicate original DOS EXE behaviour when pointer is null
static const char *safeStrtok(char *s, const char *d)
{
const char *r = strtok(s, d);
return r ? r : "";
}
void CheckKeys() void CheckKeys()
{ {
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
@ -1074,21 +1081,16 @@ void CheckKeys()
if (ch == asc_Enter) if (ch == asc_Enter)
{ {
char *pToken = strtok(sHollyStr, " "); const char *pToken = safeStrtok(sHollyStr, " ");
if (nStringLen == 0 || pToken == NULL) // bjd - added this check. watcom allows passing NULL to strcmp so the below checks will all fail OK on DOS but will cause a crash on Windows if (!strcmp(pToken, "GOTO"))
{
bHolly = kFalse;
StatusMessage(1, " ");
}
else if (!strcmp(pToken, "GOTO"))
{ {
// move player to X, Y coordinates // move player to X, Y coordinates
int nSprite = PlayerList[0].nSprite; int nSprite = PlayerList[0].nSprite;
pToken = strtok(NULL, ","); pToken = safeStrtok(NULL, ",");
sprite[nSprite].x = atoi(pToken); sprite[nSprite].x = atoi(pToken);
pToken = strtok(NULL, ","); pToken = safeStrtok(NULL, ",");
sprite[nSprite].y = atoi(pToken); sprite[nSprite].y = atoi(pToken);
setsprite(nSprite, &sprite[nSprite].pos); setsprite(nSprite, &sprite[nSprite].pos);
@ -1096,13 +1098,8 @@ void CheckKeys()
} }
else if (!strcmp(pToken, "LEVEL")) else if (!strcmp(pToken, "LEVEL"))
{ {
pToken = strtok(NULL, " "); pToken = safeStrtok(NULL, " ");
if (pToken) { levelnew = atoi(pToken);
levelnew = atoi(pToken);
}
else {
levelnew = 0; // replicate original DOS EXE behaviour when no level number is specified.
}
} }
else if (!strcmp(pToken, "DOORS")) else if (!strcmp(pToken, "DOORS"))
{ {
@ -1126,7 +1123,7 @@ void CheckKeys()
// i = nNetPlayerCount; // i = nNetPlayerCount;
if (!nNetPlayerCount) if (!nNetPlayerCount)
{ {
pToken = strtok(NULL, " "); pToken = safeStrtok(NULL, " ");
switch (atoi(pToken)) switch (atoi(pToken))
{ {
// TODO - enums? // TODO - enums?

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 129 KiB

View file

@ -2605,11 +2605,13 @@ static saveable_data saveable_ninja_data[] =
SAVE_DATA(sg_NinjaGrabThroat), SAVE_DATA(sg_NinjaGrabThroat),
SAVE_DATA(s_NinjaDie), SAVE_DATA(s_NinjaDie),
SAVE_DATA(s_NinjaDieSliced), SAVE_DATA(s_NinjaDieSliced),
SAVE_DATA(s_NinjaDieSlicedHack),
SAVE_DATA(s_NinjaDead), SAVE_DATA(s_NinjaDead),
SAVE_DATA(s_NinjaDeathJump), SAVE_DATA(s_NinjaDeathJump),
SAVE_DATA(s_NinjaDeathFall), SAVE_DATA(s_NinjaDeathFall),
SAVE_DATA(sg_NinjaDie), SAVE_DATA(sg_NinjaDie),
SAVE_DATA(sg_NinjaDieSliced), SAVE_DATA(sg_NinjaDieSliced),
SAVE_DATA(sg_NinjaDieSlicedHack),
SAVE_DATA(sg_NinjaDead), SAVE_DATA(sg_NinjaDead),
SAVE_DATA(sg_NinjaDeathJump), SAVE_DATA(sg_NinjaDeathJump),
SAVE_DATA(sg_NinjaDeathFall), SAVE_DATA(sg_NinjaDeathFall),