diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index db0fd2efb..86ec78abf 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -735,7 +735,11 @@ void M_Ticker (void) if (CurrentMenu != nullptr && menuactive != MENU_Off) { CurrentMenu->CallTicker(); + } + // Check again because menu could be closed from Ticker() + if (CurrentMenu != nullptr && menuactive != MENU_Off) + { for (int i = 0; i < NUM_MKEYS; ++i) { if (MenuButtons[i].bDown) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index de9c8bc92..39be1eea9 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -542,7 +542,7 @@ static bool FindMatchingItem(DMenuItemBase *desc) { // Check for presence of menu auto menu = MenuDescriptors.CheckKey(name); - if (menu == nullptr) return true; + if (menu == nullptr) return false; } else if (grp == 4) { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 19f9de486..eccfb48af 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -761,35 +761,6 @@ protected: private: DLevelScript(); - int getbyte(int *&pc) - { - CheckInstructionPointer(pc); - - int res = *(uint8_t *)pc; - pc = (int *)((uint8_t *)pc+1); - return res; - } - - int getshort(int *&pc) - { - CheckInstructionPointer(pc); - - int res = LittleShort( *(int16_t *)pc); - pc = (int *)((uint8_t *)pc+2); - return res; - } - - void CheckInstructionPointer(int *pc) const - { - const uint32_t offset = activeBehavior->PC2Ofs(pc); - const uint32_t size = activeBehavior->GetDataSize(); - - if (offset >= size) - { - I_Error("Out of bounds instruction pointer in ACS VM"); - } - } - friend class DACSThinker; }; @@ -844,7 +815,7 @@ TArray ACS_StringBuilderStack; // //============================================================================ -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__x86_64__) inline int uallong(const int &foo) { return foo; @@ -6925,7 +6896,7 @@ enum }; -#define NEXTWORD (CheckInstructionPointer(pc), LittleLong(*pc++)) +#define NEXTWORD (LittleLong(*pc++)) #define NEXTBYTE (fmt==ACS_LittleEnhanced?getbyte(pc):NEXTWORD) #define NEXTSHORT (fmt==ACS_LittleEnhanced?getshort(pc):NEXTWORD) #define STACK(a) (Stack[sp - (a)]) @@ -6933,6 +6904,20 @@ enum // Direct instructions that take strings need to have the tag applied. #define TAGSTR(a) (a|activeBehavior->GetLibraryID()) +inline int getbyte (int *&pc) +{ + int res = *(uint8_t *)pc; + pc = (int *)((uint8_t *)pc+1); + return res; +} + +inline int getshort (int *&pc) +{ + int res = LittleShort( *(int16_t *)pc); + pc = (int *)((uint8_t *)pc+2); + return res; +} + static bool CharArrayParms(int &capacity, int &offset, int &a, FACSStackMemory& Stack, int &sp, bool ranged) { if (ranged) diff --git a/src/posix/cocoa/i_main.mm b/src/posix/cocoa/i_main.mm index 5d30341b4..f5c49eaaf 100644 --- a/src/posix/cocoa/i_main.mm +++ b/src/posix/cocoa/i_main.mm @@ -226,14 +226,7 @@ void OriginalMainTry(int argc, char** argv) namespace { -const int ARGC_MAX = 64; - -int s_argc; -char* s_argv[ARGC_MAX]; - -TArray s_argvStorage; - -bool s_restartedFromWADPicker; +TArray s_argv; void NewFailure() @@ -348,7 +341,17 @@ ApplicationController* appCtrl; FConsoleWindow::CreateInstance(); atterm(FConsoleWindow::DeleteInstance); - exit(OriginalMain(s_argc, s_argv)); + const size_t argc = s_argv.Size(); + TArray argv(argc + 1, true); + + for (size_t i = 0; i < argc; ++i) + { + argv[i] = s_argv[i].LockBuffer(); + } + + argv[argc] = nullptr; + + exit(OriginalMain(argc, &argv[0])); } @@ -356,20 +359,13 @@ ApplicationController* appCtrl; { ZD_UNUSED(theApplication); - if (s_restartedFromWADPicker - || 0 == [filename length] - || s_argc + 2 >= ARGC_MAX) - { - return FALSE; - } - // Some parameters from command line are passed to this function // These parameters need to be skipped to avoid duplication // Note: SDL has different approach to fix this issue, see the same method in SDLMain.m const char* const charFileName = [filename UTF8String]; - for (int i = 0; i < s_argc; ++i) + for (size_t i = 0, count = s_argv.Size(); i < count; ++i) { if (0 == strcmp(s_argv[i], charFileName)) { @@ -377,11 +373,8 @@ ApplicationController* appCtrl; } } - s_argvStorage.Push("-file"); - s_argv[s_argc++] = s_argvStorage.Last().LockBuffer(); - - s_argvStorage.Push([filename UTF8String]); - s_argv[s_argc++] = s_argvStorage.Last().LockBuffer(); + s_argv.Push("-file"); + s_argv.Push([filename UTF8String]); return TRUE; } @@ -539,21 +532,12 @@ void ReleaseApplicationController() int main(int argc, char** argv) { - for (int i = 0; i <= argc; ++i) + for (int i = 0; i < argc; ++i) { const char* const argument = argv[i]; - if (NULL == argument || '\0' == argument[0]) - { - continue; - } - - if (0 == strcmp(argument, "-wad_picker_restart")) - { - s_restartedFromWADPicker = true; - } #if _DEBUG - else if (0 == strcmp(argument, "-wait_for_debugger")) + if (0 == strcmp(argument, "-wait_for_debugger")) { NSAlert* alert = [[NSAlert alloc] init]; [alert setMessageText:@GAMENAME]; @@ -562,11 +546,8 @@ int main(int argc, char** argv) [alert runModal]; } #endif // _DEBUG - else - { - s_argvStorage.Push(argument); - s_argv[s_argc++] = s_argvStorage.Last().LockBuffer(); - } + + s_argv.Push(argument); } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; diff --git a/src/posix/osx/iwadpicker_cocoa.mm b/src/posix/osx/iwadpicker_cocoa.mm index 6b8a10b6a..2d8b2057c 100644 --- a/src/posix/osx/iwadpicker_cocoa.mm +++ b/src/posix/osx/iwadpicker_cocoa.mm @@ -418,7 +418,6 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters) executablePath = @"/usr/bin/arch"; } - [arguments addObject:@"-wad_picker_restart"]; [arguments addObject:@"-iwad"]; [arguments addObject:[NSString stringWithUTF8String:wad.Path]]; diff --git a/src/r_defs.h b/src/r_defs.h index 02da2ac0e..6a3dfac76 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -394,7 +394,7 @@ public: } // Moves a plane up/down by hdiff units - double GetChangedHeight(double hdiff) + double GetChangedHeight(double hdiff) const { return D - hdiff * normal.Z; } diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index d504282d1..a8aa1a897 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -8935,7 +8935,7 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) else { bool writable; - ArgList[i] = ArgList[i]->Resolve(ctx); // nust be resolved before the address is requested. + ArgList[i] = ArgList[i]->Resolve(ctx); // must be resolved before the address is requested. if (ArgList[i] != nullptr && ArgList[i]->ValueType != TypeNullPtr) { if (type == ArgList[i]->ValueType && type->isRealPointer() && type->toPointer()->PointedType->isStruct()) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 597180605..ab8bef5f0 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1627,7 +1627,7 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n } else { - Error(field, "%s: Base type for dynamic array types nust be integral, but got %s", name.GetChars(), ftype->DescriptiveName()); + Error(field, "%s: Base type for dynamic array types must be integral, but got %s", name.GetChars(), ftype->DescriptiveName()); } } else diff --git a/src/sound/mididevices/music_win_mididevice.cpp b/src/sound/mididevices/music_win_mididevice.cpp index d794c7df3..d75a20de2 100644 --- a/src/sound/mididevices/music_win_mididevice.cpp +++ b/src/sound/mididevices/music_win_mididevice.cpp @@ -649,18 +649,11 @@ void CALLBACK WinMIDIDevice::CallbackFunc(HMIDIOUT hOut, UINT uMsg, DWORD_PTR dw // are done by sending MIDI channel volume messages to the stream, not // through midiOutSetVolume().) // -// This is using VC++'s __uuidof extension instead of the the CLSID_ and -// IID_ definitions because I couldn't figure out why it wasn't finding them -// when linking, and __uuidof circumvents that problem. I'd also be -// surprised if w32api includes any WASAPI stuff any time soon, so it's no -// big loss making this VC++-specific for the time being -// //========================================================================== static bool IgnoreMIDIVolume(UINT id) { MIDIOUTCAPS caps; - bool mustcheck = false; if (MMSYSERR_NOERROR == midiOutGetDevCaps(id, &caps, sizeof(caps))) { @@ -668,7 +661,7 @@ static bool IgnoreMIDIVolume(UINT id) { // We cannot determine what this is so we have to assume the worst, as the default // devive's volume control is irreparably broken. - mustcheck = true; + return true; } // The Microsoft GS Wavetable Synth advertises itself as MIDIDEV_SWSYNTH with a VOLUME control. // If the one we're using doesn't match that, we don't need to bother checking the name. @@ -676,28 +669,8 @@ static bool IgnoreMIDIVolume(UINT id) { if (strncmp(caps.szPname, "Microsoft GS", 12) == 0) { - mustcheck = true; - } - } - if (mustcheck) - { -#ifndef __GNUC__ - IMMDeviceEnumerator *enumerator; - - // Now try to create an IMMDeviceEnumerator interface. If it succeeds, - // we know we're using the new audio stack introduced with Vista and - // should ignore this MIDI device's volume control. - if (SUCCEEDED(CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, - __uuidof(IMMDeviceEnumerator), (void**)&enumerator)) - && enumerator != nullptr) - { - enumerator->Release(); return true; } -#else - // assume the worst and consider volume control broken. - return true; -#endif } } return false; diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index a765d2d41..46b652e29 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -175,15 +175,14 @@ protected: struct TexPart { - int16_t OriginX, OriginY; - uint8_t Rotate; - uint8_t op; - FRemapTable *Translation; - PalEntry Blend; - FTexture *Texture; - blend_t Alpha; - - TexPart(); + FRemapTable *Translation = nullptr; + FTexture *Texture = nullptr; + PalEntry Blend = 0; + blend_t Alpha = FRACUNIT; + int16_t OriginX = 0; + int16_t OriginY = 0; + uint8_t Rotate = 0; + uint8_t op = OP_COPY; }; struct TexInit @@ -797,23 +796,6 @@ FTexture *FMultiPatchTexture::GetRawTexture() return NumParts == 1 ? Parts->Texture : this; } -//========================================================================== -// -// FMultiPatchTexture :: TexPart :: TexPart -// -//========================================================================== - -FMultiPatchTexture::TexPart::TexPart() -{ - OriginX = OriginY = 0; - Rotate = 0; - Texture = NULL; - Translation = NULL; - Blend = 0; - Alpha = FRACUNIT; - op = OP_COPY; -} - //========================================================================== // // FTextureManager :: AddTexturesLump @@ -1369,7 +1351,7 @@ void FMultiPatchTexture::ResolvePatches() { if (Parts[i].Texture == nullptr) { - memcpy(&Parts[i], &Parts[i + 1], NumParts - i - 1); + memcpy(&Parts[i], &Parts[i + 1], (NumParts - i - 1) * sizeof(TexPart)); i--; NumParts--; } diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 8914fd405..99134a70a 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -184,7 +184,7 @@ struct SecPlane native play native bool isEqual(Secplane other) const; native void ChangeHeight(double hdiff); native double GetChangedHeight(double hdiff) const; - native double HeightDiff(double oldd, double newd = 0.0); + native double HeightDiff(double oldd, double newd = 0.0) const; native double PointToDist(Vector2 xy, double z) const; } diff --git a/wadsrc/static/zscript/menu/conversationmenu.txt b/wadsrc/static/zscript/menu/conversationmenu.txt index abda3dee2..8d05ee4ba 100644 --- a/wadsrc/static/zscript/menu/conversationmenu.txt +++ b/wadsrc/static/zscript/menu/conversationmenu.txt @@ -46,6 +46,8 @@ struct StrifeDialogueNode native version("2.4") native String Goodbye; native StrifeDialogueReply Children; + native Name MenuClassName; + native String UserData; } // FStrifeDialogueReply holds responses the player can give to the NPC diff --git a/wadsrc/static/zscript/shared/movingcamera.txt b/wadsrc/static/zscript/shared/movingcamera.txt index 6ed206d4b..2bce93608 100644 --- a/wadsrc/static/zscript/shared/movingcamera.txt +++ b/wadsrc/static/zscript/shared/movingcamera.txt @@ -62,6 +62,8 @@ class InterpolationPoint : Actor Next = null; } + override void Tick () {} // Nodes do no thinking + void FormChain () { let me = self;