diff --git a/src/common/audio/sound/i_soundinternal.h b/src/common/audio/sound/i_soundinternal.h index 52dabeea3..d1db403d2 100644 --- a/src/common/audio/sound/i_soundinternal.h +++ b/src/common/audio/sound/i_soundinternal.h @@ -1,11 +1,11 @@ #ifndef __SNDINT_H #define __SNDINT_H -#include #include +#include -#include "vectors.h" #include "tflags.h" +#include "vectors.h" enum EChanFlag { @@ -146,5 +146,4 @@ struct FISoundChannel void S_SetSoundPaused(int state); - #endif diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index d8ae7fe00..341e0a519 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -5,6 +5,7 @@ **--------------------------------------------------------------------------- ** Copyright 1998-2016 Randy Heit ** Copyright 2002-2019 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -36,15 +37,14 @@ #include #include - -#include "s_soundinternal.h" -#include "m_swap.h" -#include "superfasthash.h" -#include "s_music.h" -#include "m_random.h" -#include "printf.h" #include "c_cvars.h" #include "gamestate.h" +#include "i_soundinternal.h" +#include "m_random.h" +#include "m_swap.h" +#include "printf.h" +#include "s_music.h" +#include "s_soundinternal.h" CVARD(Bool, snd_enabled, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enables/disables sound effects") CVAR(Bool, i_soundinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -1009,7 +1009,6 @@ void SoundEngine::RelinkSound (int sourcetype, const void *from, const void *to, } } - //========================================================================== // // S_ChangeSoundVolume @@ -1450,7 +1449,6 @@ void SoundEngine::Reset() RestoreEvictedChannels(); } - //========================================================================== // // S_FindSound @@ -1560,7 +1558,6 @@ FSoundID SoundEngine::AddSoundLump(const char* logicalname, int lump, int Curren return id; } - //========================================================================== // // S_FindSoundTentative @@ -1581,7 +1578,6 @@ FSoundID SoundEngine::FindSoundTentative(const char* name, int nearlimit) return id; } - //========================================================================== // // S_CacheRandomSound @@ -1694,7 +1690,6 @@ void SoundEngine::HashSounds() } S_rnd.ShrinkToFit(); - } void SoundEngine::AddRandomSound(FSoundID Owner, TArray list) @@ -1728,7 +1723,6 @@ void S_SoundReset() #include "i_net.h" #include "i_interface.h" - CCMD(cachesound) { if (argv.argc() < 2) @@ -1746,7 +1740,6 @@ CCMD(cachesound) } } - CCMD(listsoundchannels) { Printf("%s", soundEngine->ListSoundChannels().GetChars()); @@ -1844,8 +1837,6 @@ void S_SetSoundPaused(int state) } } - - CCMD(snd_status) { GSnd->PrintStatus(); @@ -1876,4 +1867,3 @@ ADD_STAT(sound) return GSnd->GatherStats(); } - diff --git a/src/common/engine/m_joy.cpp b/src/common/engine/m_joy.cpp index 1c8c58f64..bbd51e4e9 100644 --- a/src/common/engine/m_joy.cpp +++ b/src/common/engine/m_joy.cpp @@ -1,8 +1,11 @@ /* +** m_joy.cpp ** +** Cross-platform joystick/gamepad management ** **--------------------------------------------------------------------------- ** Copyright 2005-2016 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -30,17 +33,22 @@ **--------------------------------------------------------------------------- ** */ + // HEADER FILES ------------------------------------------------------------ -#include -#include "c_dispatch.h" -#include "vectors.h" #include "m_joy.h" -#include "configfile.h" -#include "i_interface.h" -#include "d_eventbase.h" +#include + +#include "c_cvars.h" +#include "c_dispatch.h" #include "cmdlib.h" +#include "configfile.h" +#include "d_eventbase.h" +#include "i_interface.h" +#include "name.h" #include "printf.h" +#include "vectors.h" +#include "zstring.h" // MACROS ------------------------------------------------------------------ diff --git a/src/common/engine/m_joy.h b/src/common/engine/m_joy.h index a1a237229..f8996e945 100644 --- a/src/common/engine/m_joy.h +++ b/src/common/engine/m_joy.h @@ -1,11 +1,9 @@ #ifndef M_JOY_H #define M_JOY_H -#include "basics.h" -#include "keydef.h" -#include "tarray.h" #include "c_cvars.h" #include "keydef.h" +#include "tarray.h" union CubicBezier { struct { diff --git a/src/common/menu/joystickmenu.cpp b/src/common/menu/joystickmenu.cpp index 39a58fded..1edec1e3b 100644 --- a/src/common/menu/joystickmenu.cpp +++ b/src/common/menu/joystickmenu.cpp @@ -1,9 +1,11 @@ /* ** joystickmenu.cpp +** ** The joystick configuration menus ** **--------------------------------------------------------------------------- ** Copyright 2010 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -32,8 +34,8 @@ ** */ -#include "menu.h" #include "m_joy.h" +#include "menu.h" #include "vm.h" static TArray Joysticks; @@ -187,7 +189,6 @@ DEFINE_ACTION_FUNCTION(IJoystickConfig, SetEnabledInBackground) return 0; } - DEFINE_ACTION_FUNCTION(IJoystickConfig, Reset) { PARAM_SELF_STRUCT_PROLOGUE(IJoystickConfig); @@ -195,7 +196,6 @@ DEFINE_ACTION_FUNCTION(IJoystickConfig, Reset) return 0; } - void UpdateJoystickMenu(IJoystickConfig *selected) { DMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_JoystickOptions); @@ -271,4 +271,3 @@ void UpdateJoystickMenu(IJoystickConfig *selected) } } } - diff --git a/src/common/platform/posix/sdl/i_input.cpp b/src/common/platform/posix/sdl/i_input.cpp index ef1c11e9d..d60c806a4 100644 --- a/src/common/platform/posix/sdl/i_input.cpp +++ b/src/common/platform/posix/sdl/i_input.cpp @@ -1,8 +1,11 @@ /* ** i_input.cpp ** +** Handles input from keyboard, mouse, and joystick +** **--------------------------------------------------------------------------- ** Copyright 2005-2016 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -30,25 +33,22 @@ **--------------------------------------------------------------------------- ** */ + #include #include -#include "i_input.h" -#include "c_cvars.h" -#include "dobject.h" -#include "m_argv.h" -#include "m_joy.h" -#include "v_video.h" -#include "d_gui.h" #include "c_buttons.h" #include "c_console.h" -#include "c_dispatch.h" +#include "c_cvars.h" +#include "d_gui.h" #include "dikeys.h" -#include "utf8.h" -#include "keydef.h" -#include "i_interface.h" #include "engineerrors.h" +#include "i_input.h" #include "i_interface.h" +#include "keydef.h" +#include "m_joy.h" +#include "utf8.h" +#include "v_video.h" bool GUICapture; static bool NativeMouse = true; diff --git a/src/common/platform/posix/sdl/i_joystick.cpp b/src/common/platform/posix/sdl/i_joystick.cpp index 8f1e97107..ce5ca9f9b 100644 --- a/src/common/platform/posix/sdl/i_joystick.cpp +++ b/src/common/platform/posix/sdl/i_joystick.cpp @@ -1,8 +1,11 @@ /* ** i_joystick.cpp ** +** Handles sdl joysticks and gamepads +** **--------------------------------------------------------------------------- ** Copyright 2005-2016 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -30,13 +33,14 @@ **--------------------------------------------------------------------------- ** */ + #include #include +#include #include #include "basics.h" #include "cmdlib.h" - #include "d_eventbase.h" #include "i_input.h" #include "m_joy.h" diff --git a/src/common/platform/win32/i_dijoy.cpp b/src/common/platform/win32/i_dijoy.cpp index 1a00aaaaf..0fcfe3a49 100644 --- a/src/common/platform/win32/i_dijoy.cpp +++ b/src/common/platform/win32/i_dijoy.cpp @@ -1,8 +1,11 @@ /* +** i_dijoy.cpp ** +** Handles direct input joysticks ** **--------------------------------------------------------------------------- ** Copyright 2005-2016 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -40,19 +43,19 @@ #ifndef __GNUC__ #include #endif + #include #include #include "i_input.h" #include "d_eventbase.h" - #include "gameconfigfile.h" #include "cmdlib.h" #include "v_text.h" #include "m_argv.h" #include "keydef.h" #include "printf.h" - +#include "m_joy.h" #include "i_mainwindow.h" #define SAFE_RELEASE(x) { if (x != NULL) { x->Release(); x = NULL; } } @@ -146,7 +149,6 @@ public: // MACROS ------------------------------------------------------------------ - // TYPES ------------------------------------------------------------------- class FDInputJoystick : public FInputDevice, IJoystickConfig diff --git a/src/common/platform/win32/i_input.cpp b/src/common/platform/win32/i_input.cpp index 6569ae8d3..db9fe40d5 100644 --- a/src/common/platform/win32/i_input.cpp +++ b/src/common/platform/win32/i_input.cpp @@ -1,9 +1,11 @@ /* ** i_input.cpp +** ** Handles input from keyboard, mouse, and joystick ** **--------------------------------------------------------------------------- ** Copyright 1998-2009 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -54,7 +56,6 @@ #define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff) #endif - #include "c_dispatch.h" #include "m_argv.h" #include "i_input.h" @@ -80,7 +81,6 @@ #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam)) #endif - #ifdef _DEBUG #define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS #else @@ -90,7 +90,6 @@ FJoystickCollection *JoyDevices[NUM_JOYDEVICES]; - extern HINSTANCE g_hInst; bool GUICapture; @@ -128,7 +127,6 @@ bool win32EnableInput = true; EXTERN_CVAR(Bool, i_pauseinbackground); - CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) static void I_CheckGUICapture () @@ -391,7 +389,6 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } - switch (message) { case WM_DESTROY: @@ -541,7 +538,6 @@ bool I_InitInput (void *hwnd) return TRUE; } - // Free all input resources void I_ShutdownInput () { @@ -591,7 +587,6 @@ void I_GetWindowEvent() } } - void I_GetEvent () { I_GetWindowEvent(); diff --git a/src/d_main.cpp b/src/d_main.cpp index 6f85fb062..30253cd5c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- +// // Copyright 1993-1996 id Software // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers @@ -46,11 +46,13 @@ #include "autosegs.h" #include "c_buttons.h" #include "c_console.h" +#include "c_cvars.h" #include "c_dispatch.h" #include "cmdlib.h" #include "common/scripting/dap/DebugServer.h" #include "d_buttons.h" #include "d_dehacked.h" +#include "d_event.h" #include "d_main.h" #include "d_net.h" #include "d_netinf.h" @@ -76,6 +78,7 @@ #include "hwrenderer/scene/hw_drawinfo.h" #include "i_interface.h" #include "i_sound.h" +#include "i_soundinternal.h" #include "i_system.h" #include "i_time.h" #include "i_video.h" @@ -224,7 +227,6 @@ CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL | CVAR_VIRTUAL) } } - // PUBLIC DATA DEFINITIONS ------------------------------------------------- #ifndef NO_SWRENDERER @@ -339,7 +341,6 @@ cycle_t FrameCycles; // [SP] Store the capabilities of the renderer in a global variable, to prevent excessive per-frame processing uint32_t r_renderercaps = 0; - // PRIVATE DATA DEFINITIONS ------------------------------------------------ static int demosequence; @@ -800,6 +801,7 @@ static void DrawPaletteTester(int paletteno) // Draws the fps counter, dot ticker, and palette debug. // //========================================================================== + uint64_t LastFPS, LastMSCount; void CalcFps() @@ -1088,7 +1090,6 @@ void D_Display () ScreenJobDraw(); break; - default: break; } @@ -1576,7 +1577,6 @@ void D_DoAdvanceDemo (void) break; } - if (pagename.IsNotEmpty()) { Page = TexMan.CheckForTexture(pagename.GetChars(), ETextureType::MiscPatch); @@ -1837,7 +1837,6 @@ static void GetCmdLineFiles(std::vector& wadfiles, bool optional) } } - static FString ParseGameInfo(std::vector &pwads, const char *fn, const char *data, int size) { FScanner sc; @@ -2296,7 +2295,6 @@ static void NewFailure () I_FatalError ("Failed to allocate memory from system heap"); } - //========================================================================== // // RenameSprites @@ -2477,6 +2475,7 @@ static void RenameSprites(FileSystem &fileSystem, const TArray& deletel // MD5 checksum for Unity version of NERVE.WAD: 4214c47651b63ee2257b1c2490a518c9 (3,821,966) // //========================================================================== + void RenameNerve(FileSystem& fileSystem) { if (gameinfo.gametype != GAME_Doom) @@ -2664,7 +2663,6 @@ static void FindStrifeTeaserVoices(FileSystem& fileSystem) } } - static const char *DoomButtons[] = { "am_panleft", @@ -2959,7 +2957,6 @@ void System_CrashInfo(char* buffer, size_t bufflen, const char *lfstr) void System_M_Dim(); - static void PatchTextures() { // The Hexen scripts use BLANK as a blank texture, even though it's really not. @@ -3062,7 +3059,6 @@ static void Doom_CastSpriteIDToString(FString* a, unsigned int b) *a = (b >= sprites.Size()) ? "TNT1" : sprites[b].name; } - extern DThinker* NextToThink; static void GC_MarkGameRoots() @@ -3158,6 +3154,7 @@ static int FileSystemPrintf(FSMessageLevel level, const char* fmt, ...) } return (int)text.Len(); } + //========================================================================== // // D_InitGame @@ -3256,8 +3253,6 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw lfi.gameTypeFilter.push_back(NewFilterName.GetChars()); } - - GetReserved(lfi); lfi.postprocessFunc = [&]() @@ -3492,7 +3487,6 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw M_Init(); M_CreateGameMenus(); - // clean up the compiler symbols which are not needed any longer. if (!dap_debugging) RemoveUnusedSymbols(); @@ -3688,6 +3682,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw staticEventManager.OnEngineInitialize(); return 0; } + //========================================================================== // // D_DoomMain diff --git a/src/doomdef.h b/src/doomdef.h index b40d7a7bd..d3095ced8 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -3,6 +3,7 @@ // Copyright 1993-1996 id Software // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -30,6 +31,8 @@ #include #include + +#include "gi.h" #include "i_net.h" // @@ -49,7 +52,6 @@ typedef enum } GameMode_t; - // If rangecheck is undefined, most parameter validation debugging code // will not be compiled #ifndef NORANGECHECKING @@ -73,8 +75,6 @@ inline int Tics2Seconds(int tics) return tics / TICRATE; } - - typedef float skill_t; /* @@ -88,8 +88,6 @@ enum ESkillLevels }; */ - - #define TELEFOGHEIGHT (gameinfo.telefogheight) // @@ -273,7 +271,6 @@ enum #define FRICTION_LOW (0xf900/65536.) #define FRICTION_FLY (0xeb00/65536.) - #define BLINKTHRESHOLD (4*32) #endif // __DOOMDEF_H__ diff --git a/src/gamedata/doomfont.h b/src/gamedata/doomfont.h index 02d37dea1..ac22180b7 100644 --- a/src/gamedata/doomfont.h +++ b/src/gamedata/doomfont.h @@ -63,7 +63,6 @@ void InitDoomFonts() OriginalSmallFont = new FFont("OriginalSmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1, -1, false, true, true); } - if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife { if (fileSystem.CheckNumForName("STBFN033", FileSys::ns_graphics) >= 0) diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 27d2646fa..5ae9c33cd 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -1,5 +1,5 @@ /* -** menu.cpp +** doommenu.cpp ** Menu base class and global interface ** **--------------------------------------------------------------------------- @@ -73,7 +73,6 @@ typedef void(*hfunc)(); DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr); bool OkForLocalization(FTextureID texnum, const char* substitute); - FNewGameStartup NewGameStartupInfo; int LastSkill = -1; @@ -290,7 +289,6 @@ bool M_SetSpecialMenu(FName& menu, int param) } } - // End of special checks return true; } @@ -318,7 +316,6 @@ void OnMenuOpen(bool makeSound) } } - //========================================================================== // // M_Dim @@ -360,7 +357,6 @@ void System_M_Dim() Dim(twod, dimmer, amount, 0, 0, twod->GetWidth(), twod->GetHeight()); } - static void M_Quit() { DeleteScreenJob(); @@ -425,12 +421,9 @@ CCMD (menu_quit) M_Quit(); }); - M_ActivateMenu(newmenu); } - - //============================================================================= // // @@ -566,9 +559,6 @@ CCMD (quickload) M_ActivateMenu(newmenu); } - - - // // Toggle messages on/off // @@ -634,7 +624,6 @@ CCMD(resetb2defaults) C_SetDefaultBindings (); } - //============================================================================= // // Creates the episode menu @@ -1028,7 +1017,6 @@ static void InitKeySections() } } - //============================================================================= // // Special menus will be created once all engine data is loaded @@ -1136,6 +1124,7 @@ DEFINE_ACTION_FUNCTION(DNewPlayerMenu, UpdateSkinOptions) // The skill menu must be refeshed each time it starts up // //============================================================================= + extern int restart; void M_StartupSkillMenu(FNewGameStartup *gs) diff --git a/src/playsim/mapthinkers/a_ceiling.h b/src/playsim/mapthinkers/a_ceiling.h index 92b0c22bb..8494678bb 100644 --- a/src/playsim/mapthinkers/a_ceiling.h +++ b/src/playsim/mapthinkers/a_ceiling.h @@ -1,5 +1,7 @@ #pragma once +#include "dsectoreffect.h" + // // P_CEILING // diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index 4c654f3e4..209a7bccf 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -5,6 +5,7 @@ // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -28,31 +29,28 @@ // //----------------------------------------------------------------------------- - #include - -#include "m_random.h" - +#include "a_ceiling.h" +#include "a_sharedglobal.h" +#include "actorinlines.h" +#include "d_player.h" #include "doomdef.h" +#include "g_game.h" +#include "g_levellocals.h" +#include "gi.h" +#include "i_soundinternal.h" +#include "m_random.h" +#include "p_blockmap.h" +#include "p_checkposition.h" +#include "p_enemy.h" +#include "p_lnspec.h" #include "p_local.h" #include "p_maputl.h" -#include "d_player.h" -#include "p_lnspec.h" -#include "g_game.h" -#include "p_enemy.h" -#include "a_sharedglobal.h" -#include "p_blockmap.h" -#include "teaminfo.h" #include "p_spec.h" -#include "p_checkposition.h" -#include "g_levellocals.h" -#include "vm.h" -#include "actorinlines.h" -#include "a_ceiling.h" #include "shadowinlines.h" - -#include "gi.h" +#include "teaminfo.h" +#include "vm.h" static FRandom pr_checkmissilerange ("CheckMissileRange"); static FRandom pr_opendoor ("OpenDoor"); @@ -111,7 +109,6 @@ double yspeed[8] = {0,SQRTHALF,1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF}; // but some can be made preaware // - //---------------------------------------------------------------------------- // // PROC P_RecursiveSound @@ -153,7 +150,6 @@ static void NoiseMarkSector(sector_t *sec, AActor *soundtarget, bool splash, AAc NoiseList.Push({ sec, soundblocks }); } - static void P_RecursiveSound(sector_t *sec, AActor *soundtarget, bool splash, AActor *emitter, int soundblocks, double maxdist) { bool checkabove = !sec->PortalBlocksSound(sector_t::ceiling); @@ -184,7 +180,6 @@ static void P_RecursiveSound(sector_t *sec, AActor *soundtarget, bool splash, AA } } - if (check->sidedef[1] == NULL || !(check->flags & ML_TWOSIDED)) { @@ -229,9 +224,6 @@ static void P_RecursiveSound(sector_t *sec, AActor *soundtarget, bool splash, AA } } - - - //---------------------------------------------------------------------------- // // PROC P_NoiseAlert @@ -366,7 +358,6 @@ static int P_CheckMissileRange (AActor *actor) if (actor->MeleeState == NULL) dist -= 128; // no melee attack, so fire more - if (actor->maxtargetrange > 0 && dist > actor->maxtargetrange) return false; // The Arch Vile's special behavior turned into a property @@ -673,7 +664,6 @@ static int P_Move (AActor *actor) else actor->AddZ(-actor->FloatSpeed); - // [RH] Check to make sure there's nothing in the way of the float if (P_TestMobjZ(actor)) { @@ -927,7 +917,6 @@ void P_DoNewChaseDir (AActor *actor, double deltax, double deltay) actor->movedir = DI_NODIR; // cannot move } - //============================================================================= // // killough 11/98: @@ -1763,7 +1752,6 @@ int P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params) return false; } - /* ================ = @@ -1832,7 +1820,6 @@ int P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) if (actor->FriendPlayer == 0 && (!teamplay || actor->GetTeam() == TEAM_NONE)) return result; if (result || !deathmatch) return true; - } // [SP] if false, and in deathmatch, intentional fall-through else if (actor->flags8 & MF8_SEEFRIENDLYMONSTERS) { @@ -2042,7 +2029,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) return 0; } - //========================================================================== // // A_LookEx (int flags, fixed minseedist, fixed maxseedist, fixed maxheardist, fixed fov, state wakestate) @@ -2254,6 +2240,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearLastHeard) // A_Wander // //========================================================================== + enum ChaseFlags { CHF_FASTCHASE = 1, @@ -2315,6 +2302,7 @@ void A_Wander(AActor *self, int flags) // A_Look2 // //========================================================================== + DEFINE_ACTION_FUNCTION(AActor, A_Look2) { PARAM_SELF_PROLOGUE(AActor); @@ -2379,6 +2367,7 @@ nosee: // enhancements. // //============================================================================= + #define CLASS_BOSS_STRAFE_RANGE 64*10 void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags) @@ -2743,6 +2732,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // functions to check. // //========================================================================== + // [MC] Code is almost a duplicate of CanCollideWith but with changes to // accommodate checking of just one actor. bool P_CanResurrect(AActor *raiser, AActor *thing) @@ -2942,7 +2932,6 @@ bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nu return false; } - // for internal use void A_Chase(AActor *self) { @@ -3007,6 +2996,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_DoChase, A_DoChaseNative) // A_FaceTracer // //============================================================================= + enum FAF_Flags { FAF_BOTTOM = 1, @@ -3122,6 +3112,7 @@ void A_FaceTarget(AActor *self) // New function to let monsters shoot a railgun // //=========================================================================== + DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) { PARAM_SELF_PROLOGUE(AActor); diff --git a/src/playsim/p_lnspec.cpp b/src/playsim/p_lnspec.cpp index be85ba44f..ae187f9ca 100644 --- a/src/playsim/p_lnspec.cpp +++ b/src/playsim/p_lnspec.cpp @@ -4,6 +4,7 @@ ** **--------------------------------------------------------------------------- ** Copyright 1998-2007 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -34,30 +35,29 @@ ** or false if it could not perform the desired action. */ -#include "doomstat.h" -#include "p_local.h" -#include "p_lnspec.h" -#include "p_enemy.h" -#include "g_level.h" -#include "v_palette.h" -#include "a_sharedglobal.h" -#include "a_lightning.h" #include "a_keys.h" -#include "gi.h" -#include "p_conversation.h" -#include "p_3dmidtex.h" -#include "d_net.h" +#include "a_sharedglobal.h" #include "d_event.h" -#include "gstrings.h" -#include "po_man.h" +#include "d_net.h" #include "d_player.h" -#include "r_utility.h" +#include "doomstat.h" #include "fragglescript/t_fs.h" -#include "p_spec.h" +#include "g_level.h" #include "g_levellocals.h" -#include "vm.h" +#include "gi.h" +#include "gstrings.h" +#include "p_3dmidtex.h" +#include "p_conversation.h" #include "p_destructible.h" +#include "p_enemy.h" +#include "p_lnspec.h" +#include "p_local.h" +#include "p_spec.h" +#include "po_man.h" +#include "r_utility.h" #include "s_sndseq.h" +#include "v_palette.h" +#include "vm.h" // Remaps EE sector change types to Generic_Floor values. According to the Eternity Wiki: /* @@ -71,7 +71,6 @@ */ static const uint8_t ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; - #define FUNC(a) static int a (FLevelLocals *Level, line_t *ln, AActor *it, bool backSide, \ int arg0, int arg1, int arg2, int arg3, int arg4) @@ -585,7 +584,6 @@ FUNC(LS_Floor_Stop) return Level->EV_StopFloor(arg0, ln); } - FUNC(LS_Stairs_BuildDown) // Stair_BuildDown (tag, speed, height, delay, reset) { @@ -649,7 +647,6 @@ FUNC(LS_Stairs_BuildUpDoomSync) arg2, SPEED(arg1), 0, arg3, 0, DFloor::stairSync); } - FUNC(LS_Generic_Stairs) // Generic_Stairs (tag, speed, step, dir/igntxt, reset) { @@ -896,7 +893,6 @@ FUNC(LS_Ceiling_Stop) return Level->EV_StopCeiling(arg0, ln); } - FUNC(LS_Generic_Ceiling) // Generic_Ceiling (tag, speed, height, target, change/model/direct/crush) { @@ -1038,7 +1034,6 @@ FUNC(LS_Plat_RaiseAndStayTx0) break; } - return Level->EV_DoPlat (arg0, ln, type, 0, SPEED(arg1), 0, 0, 1); } @@ -1824,7 +1819,6 @@ FUNC(LS_Thing_Stop) return ok; } - FUNC(LS_Thing_SetGoal) // Thing_SetGoal (tid, goal, delay, chasegoal) { @@ -2036,8 +2030,6 @@ FUNC(LS_FS_Execute) return T_RunScript(Level, arg0, it); } - - FUNC(LS_FloorAndCeiling_LowerByValue) // FloorAndCeiling_LowerByValue (tag, speed, height) { @@ -2242,9 +2234,6 @@ FUNC(LS_Sector_ChangeFlags) return rtn; } - - - FUNC(LS_Sector_SetWind) // Sector_SetWind (tag, amount, angle) { @@ -2306,7 +2295,6 @@ FUNC(LS_Sector_SetLink) void SetWallScroller(FLevelLocals *Level, int id, int sidechoice, double dx, double dy, EScrollPos Where); void SetScroller(FLevelLocals *Level, int tag, EScroll type, double dx, double dy); - FUNC(LS_Scroll_Texture_Both) // Scroll_Texture_Both (id, left, right, up, down) { @@ -2838,7 +2826,6 @@ FUNC(LS_Line_SetAutomapStyle) return false; } - FUNC(LS_ChangeCamera) // ChangeCamera (tid, who, revert?) { @@ -3458,7 +3445,6 @@ FUNC(LS_Sector_SetPlaneReflection) return true; } - FUNC(LS_SetGlobalFogParameter) // SetGlobalFogParameter (type, value) { @@ -3962,7 +3948,6 @@ int P_FindLineSpecial (const char *string, int *min_args, int *max_args) return 0; } - //========================================================================== // // P_ExecuteSpecial @@ -3991,6 +3976,7 @@ int P_ExecuteSpecial(FLevelLocals *Level, int num, // Execute a line special / script // //========================================================================== + DEFINE_ACTION_FUNCTION(FLevelLocals, ExecuteSpecial) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index c33d74310..fd507f12e 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -5,6 +5,7 @@ // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit // Copyright 2002-2017 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -57,45 +58,41 @@ ** */ -#include -#include #include - - - -#include "m_bbox.h" -#include "m_random.h" -#include "c_dispatch.h" - -#include "doomdef.h" -#include "p_local.h" -#include "p_spec.h" -#include "d_player.h" -#include "p_maputl.h" -#include "p_lnspec.h" -#include "p_effect.h" -#include "p_terrain.h" -#include "p_trace.h" -#include "p_checkposition.h" -#include "p_linetracedata.h" -#include "r_utility.h" -#include "p_blockmap.h" -#include "p_3dmidtex.h" -#include "events.h" -#include "vm.h" -#include "d_main.h" -#include "gi.h" - -#include "decallib.h" - -// State. +#include +#include #include "a_sharedglobal.h" -#include "p_conversation.h" -#include "r_sky.h" -#include "g_levellocals.h" #include "actorinlines.h" -#include +#include "c_cvars.h" +#include "c_dispatch.h" +#include "d_main.h" +#include "d_player.h" +#include "decallib.h" +#include "doomdef.h" +#include "events.h" +#include "g_levellocals.h" +#include "gi.h" +#include "m_bbox.h" +#include "m_random.h" +#include "p_3dmidtex.h" +#include "p_blockmap.h" +#include "p_checkposition.h" +#include "p_conversation.h" +#include "p_effect.h" +#include "p_linetracedata.h" +#include "p_lnspec.h" +#include "p_local.h" +#include "p_maputl.h" +#include "p_spec.h" +#include "p_terrain.h" +#include "p_trace.h" +#include "r_sky.h" +#include "r_utility.h" +#include "shadowinlines.h" +#include "vm.h" + +// State. CVAR(Bool, cl_bloodsplats, true, CVAR_ARCHIVE) CVAR(Int, sv_smartaim, 0, CVAR_ARCHIVE | CVAR_SERVERINFO) @@ -276,6 +273,7 @@ static DVector2 FindRefPoint(line_t *ld, const DVector2 &pos) // only3d set means to only check against 3D floors and midtexes. // //========================================================================== + bool ffcf_verbose; static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tmf, int flags) @@ -343,7 +341,6 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines return true; } - //========================================================================== // // calculates the actual floor and ceiling position at a given @@ -449,7 +446,6 @@ void P_FindFloorCeiling(AActor *actor, int flags) } } - // Debug CCMD for checking errors in the MultiBlockLinesIterator (needs to be removed when this code is complete) CCMD(ffcf) { @@ -481,7 +477,6 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi // kill anything occupying the position - // The base floor/ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. tmf.thing = thing; @@ -1225,7 +1220,6 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera return ret; } - //========================================================================== // // Isolated to keep the code readable and fix the logic @@ -1239,7 +1233,6 @@ static bool CheckRipLevel(AActor *victim, AActor *projectile) return true; } - //========================================================================== // // Isolated to keep the code readable and allow reuse in other attacks @@ -1386,6 +1379,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, DoMissileDamage, P_DoMissileDamage) P_DoMissileDamage(self, victim); return 0; } + //========================================================================== // // PIT_CheckThing @@ -1511,7 +1505,6 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (!P_CanCollideWith(tm.thing, thing)) return true; } - if (tm.thing->player == NULL || !(tm.thing->player->cheats & CF_PREDICTING)) { // touchy object is alive, toucher is solid @@ -1750,8 +1743,6 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch // return !(thing->flags & MF_SOLID); // old code -- killough } - - /* =============================================================================== @@ -1958,7 +1949,6 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo if (actorsonly || (thing->flags & MF_NOCLIP)) return (thing->BlockingMobj = thingblocker) == NULL; - FMultiBlockLinesIterator it(pcheck, thing->Level, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, newsec); FMultiBlockLinesIterator::CheckResult lcres; @@ -2013,7 +2003,6 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly) return P_CheckPosition(thing, pos, tm, actorsonly); } - //---------------------------------------------------------------------------- // // FUNC P_TestMobjLocation @@ -2217,7 +2206,6 @@ int P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) return onmobj == NULL; } - //============================================================================= // // P_FakeZMovement @@ -2496,7 +2484,6 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, dropoff = false; } - // killough 3/15/98: Allow certain objects to drop off if ((!dropoff && !(thing->flags & (MF_DROPOFF | MF_FLOAT | MF_MISSILE))) || (thing->flags5&MF5_NODROPOFF)) { @@ -2582,7 +2569,6 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, return false; } - // Check for crossed portals bool portalcrossed; portalcrossed = false; @@ -2698,8 +2684,6 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, break; } - - if (!portalcrossed) { // the move is ok, so link the thing into its new position @@ -2865,7 +2849,6 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, return P_TryMove(thing, pos, dropoff, onfloor, tm, missilecheck); } - //========================================================================== // // P_CheckMove @@ -2973,7 +2956,6 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) return P_CheckMove(thing, pos, tm, flags); } - //========================================================================== // // SLIDE MOVE @@ -3137,7 +3119,6 @@ void FSlide::HitSlideLine(line_t* ld) } // phares } - //========================================================================== // // PTR_SlideTraverse @@ -3218,8 +3199,6 @@ void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end) } } - - //========================================================================== // // P_SlideMove @@ -3518,7 +3497,6 @@ bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end) goto bounceblocking; } - P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom if (open.range < slidemo->Height) goto bounceblocking; // doesn't fit @@ -3988,7 +3966,6 @@ struct aim_t return result; } - //============================================================================ // // AimTraverse3DFloors @@ -4031,7 +4008,6 @@ struct aim_t double ff_bottom = rover->bottom.plane->ZatPoint(trX, trY); double ff_top = rover->top.plane->ZatPoint(trX, trY); - highpitch = -VecToAngle(dist, ff_top - shootz); lowpitch = -VecToAngle(dist, ff_bottom - shootz); @@ -4106,7 +4082,6 @@ struct aim_t else if (position == sector_t::floor && portalz > limitz) return; aim_t newtrace = Clone(); - newtrace.toppitch = newtoppitch; newtrace.bottompitch = newbottompitch; newtrace.aimdir = position == sector_t::ceiling? aim_t::aim_up : aim_t::aim_down; @@ -4302,7 +4277,6 @@ struct aim_t return; } - if (!(li->flags & ML_TWOSIDED) || (li->flags & ML_BLOCKEVERYTHING)) return; // stop @@ -4690,7 +4664,6 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, return nullptr; } - bool nointeract = !!(flags & LAF_NOINTERACT); DVector3 direction; double shootz; @@ -4705,7 +4678,6 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, if (flags & LAF_NORANDOMPUFFZ) puffFlags |= PF_NORANDOMZ; - if (victim != NULL) { memset(victim, 0, sizeof(*victim)); @@ -5037,6 +5009,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, // P_LineTrace // //========================================================================== + struct CheckLineData { AActor *Caller; @@ -5216,7 +5189,6 @@ void P_TraceBleed(int damage, const DVector3 &pos, AActor *actor, DAngle angle, int count; double noise; - if ((actor->flags & MF_NOBLOOD) || (actor->flags5 & MF5_NOBLOODDECALS) || (actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) || @@ -5297,7 +5269,6 @@ void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch) P_TraceBleed(damage, target->PosPlusZ(target->Height/2), target, angle, pitch); } - //========================================================================== // // @@ -5344,7 +5315,6 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff) P_TraceBleed(damage, t->linetarget->PosPlusZ(t->linetarget->Height/2), t->linetarget, t->angleFromSource, pitch); } - //========================================================================== // // @@ -5459,6 +5429,7 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) // // //========================================================================== + void P_RailAttack(FRailParams *p) { AActor *source = p->source; @@ -6066,7 +6037,6 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) // //========================================================================== - // [RH] Damage scale to apply to thing that shot the missile. static float selfthrustscale; @@ -6451,7 +6421,6 @@ int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, double // //========================================================================== - struct FChangePosition { sector_t *sector; @@ -7073,7 +7042,6 @@ bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, b unsigned i; sector_t* sec; - // Use different functions for the four different types of sector movement. // for 3D-floors the meaning of floor and ceiling is inverted!!! if (floorOrCeil == 1) diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 4e034ebff..94a9398cb 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -5,6 +5,7 @@ // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit // Copyright 2002-2017 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -57,52 +58,50 @@ */ // HEADER FILES ------------------------------------------------------------ + #include - -#include "m_random.h" -#include "doomdef.h" -#include "p_local.h" -#include "p_maputl.h" -#include "p_lnspec.h" -#include "p_effect.h" -#include "p_terrain.h" -#include "hu_stuff.h" -#include "v_video.h" -#include "c_dispatch.h" -#include "b_bot.h" //Added by MC: -#include "a_sharedglobal.h" -#include "gi.h" -#include "sbar.h" -#include "p_acs.h" -#include "cmdlib.h" -#include "decallib.h" -#include "a_keys.h" -#include "p_conversation.h" -#include "g_game.h" -#include "teaminfo.h" -#include "r_sky.h" -#include "d_event.h" -#include "p_enemy.h" -#include "gstrings.h" -#include "po_man.h" -#include "p_spec.h" -#include "p_checkposition.h" -#include "serializer_doom.h" -#include "serialize_obj.h" -#include "r_utility.h" -#include "thingdef.h" -#include "d_player.h" -#include "g_levellocals.h" -#include "a_morph.h" -#include "events.h" -#include "actorinlines.h" #include "a_dynlight.h" +#include "a_keys.h" +#include "a_morph.h" +#include "a_sharedglobal.h" +#include "actorinlines.h" +#include "b_bot.h" //Added by MC: +#include "c_dispatch.h" +#include "cmdlib.h" +#include "d_event.h" +#include "d_net.h" +#include "d_player.h" +#include "decallib.h" +#include "doomdef.h" +#include "events.h" #include "fragglescript/t_fs.h" -#include "shadowinlines.h" +#include "g_game.h" +#include "g_levellocals.h" +#include "gi.h" +#include "gstrings.h" +#include "hu_stuff.h" +#include "m_random.h" #include "model.h" #include "models.h" -#include "d_net.h" +#include "p_acs.h" +#include "p_checkposition.h" +#include "p_conversation.h" +#include "p_effect.h" +#include "p_enemy.h" +#include "p_lnspec.h" +#include "p_local.h" +#include "p_maputl.h" +#include "p_spec.h" +#include "p_terrain.h" +#include "r_sky.h" +#include "r_utility.h" +#include "sbar.h" +#include "serialize_obj.h" +#include "serializer_doom.h" +#include "shadowinlines.h" +#include "teaminfo.h" +#include "thingdef.h" // MACROS ------------------------------------------------------------------ @@ -437,7 +436,6 @@ void AActor::Serialize(FSerializer &arc) ("behaviors", Behaviors) A("decalgenerator", DecalGenerator); - SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain); SerializeArgs(arc, "args", args, def->args, special); @@ -838,7 +836,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(FState, InStateSequence, InStateSequence) ACTION_RETURN_BOOL(InStateSequence(self, basestate)); } - bool AActor::IsMapActor() { // [SP] Don't remove owned inventory objects. @@ -992,7 +989,6 @@ DEFINE_ACTION_FUNCTION(AActor, SetState) ACTION_RETURN_BOOL(self->SetState(state, nofunction)); }; - //============================================================================ // // DestroyAllInventory @@ -1035,6 +1031,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, DestroyAllInventory, DestroyAllInventory) DestroyAllInventory(self); return 0; } + //============================================================================ // // AActor :: UseInventory @@ -2103,7 +2100,6 @@ DEFINE_ACTION_FUNCTION(AActor, ExplodeMissile) return 0; } - void AActor::PlayBounceSound(bool onfloor, double volume) { if (!onfloor && (BounceFlags & BOUNCE_NoWallSound)) @@ -2410,7 +2406,6 @@ bool P_SeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax, bool precise return true; } - // // P_XYMovement // @@ -2926,7 +2921,6 @@ static double P_XYMovement (AActor *mo, DVector2 scroll) return Oldfloorz; } - static void P_MonsterFallingDamage (AActor *mo) { int damage; @@ -2983,7 +2977,6 @@ static void P_ZMovement (AActor *mo, double oldfloorz) mo->SetZ(mo->floorz + mo->specialf1); } - // // adjust height // @@ -3520,7 +3513,6 @@ void P_NightmareRespawn (AActor *mobj) mobj->Destroy (); } - // // P_AddMobjToHash // @@ -3588,7 +3580,6 @@ void AActor::SetTID (int newTID) AddToHash(); } - //========================================================================== // // P_IsTIDUsed @@ -3671,7 +3662,6 @@ int FLevelLocals::FindUniqueTID(int start_tid, int limit, bool clientside) return 0; } - CCMD(utid) { for (auto Level : AllLevels()) @@ -3799,8 +3789,6 @@ bool AActor::CallSlam(AActor *thing) else return Slam(thing); } - - // This virtual method only exists on the script side. int AActor::SpecialMissileHit (AActor *victim) { @@ -4188,7 +4176,6 @@ PClassActor *AActor::GetBloodType(int type) const return nullptr; } - DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec) { bool moved = false; @@ -4222,8 +4209,6 @@ DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec) return pos; } - - void AActor::CheckPortalTransition(bool islinked) { bool moved = false; @@ -4475,7 +4460,6 @@ void AActor::GetObjectToWorldMatrix(double *outMat) } } - // // P_MobjThinker // @@ -5559,7 +5543,6 @@ void ConstructActor(AActor *actor, const DVector3 &pos, bool SpawningMapThing) actor->flags8 |= MF8_INSCROLLSEC; } - AActor *AActor::StaticSpawn(FLevelLocals *Level, PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing) { if (type == NULL) @@ -5755,7 +5738,6 @@ void AActor::CallBeginPlay() else BeginPlay(); } - void AActor::PostBeginPlay () { PrevAngles = Angles; @@ -5830,7 +5812,6 @@ void AActor::CallActivate(AActor *activator) else Activate(activator); } - //=========================================================================== // // Deactivate @@ -6913,6 +6894,7 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position) // SpawnMapThing // //=========================================================================== + CVAR(Bool, dumpspawnedthings, false, 0) AActor *FLevelLocals::SpawnMapThing(int index, FMapThing *mt, int position) @@ -6928,13 +6910,10 @@ AActor *FLevelLocals::SpawnMapThing(int index, FMapThing *mt, int position) return spawned; } - - // // GAME SPAWN FUNCTIONS // - // // P_SpawnPuff // @@ -7150,7 +7129,6 @@ DEFINE_ACTION_FUNCTION(AActor, SpawnBlood) ACTION_RETURN_OBJECT(P_SpawnBlood(DVector3(x, y, z), dir, damage, self)); } - //--------------------------------------------------------------------------- // // PROC P_BloodSplatter @@ -7213,7 +7191,6 @@ void P_BloodSplatter2 (const DVector3 &pos, AActor *originator, DAngle hitangle) { AActor *mo; - mo = Spawn (originator->Level, bloodcls, pos + add, NO_REPLACE); // GetBloodType already performed the replacement mo->target = originator; @@ -7244,7 +7221,6 @@ DEFINE_ACTION_FUNCTION(AActor, BloodSplatter) return 0; } - //--------------------------------------------------------------------------- // // PROC P_RipperBlood @@ -7309,7 +7285,6 @@ int P_GetThingFloorType (AActor *thing) } } - //--------------------------------------------------------------------------- // // FUNC P_HitWater @@ -7486,7 +7461,6 @@ DEFINE_ACTION_FUNCTION(AActor, HitWater) ACTION_RETURN_BOOL(P_HitWater(self, sec, DVector3(x, y, z), checkabove, alert, force, flags)); } - //--------------------------------------------------------------------------- // // FUNC P_HitFloor @@ -7645,7 +7619,6 @@ DEFINE_ACTION_FUNCTION(AActor, CheckMissileSpawn) ACTION_RETURN_BOOL(P_CheckMissileSpawn(self, add)); } - //--------------------------------------------------------------------------- // // FUNC P_PlaySpawnSound @@ -7685,8 +7658,6 @@ DEFINE_ACTION_FUNCTION(AActor, PlaySpawnSound) return 0; } - - double GetDefaultSpeed(PClassActor *type) { if (type == NULL) @@ -7819,8 +7790,6 @@ DEFINE_ACTION_FUNCTION(AActor, SpawnMissileZ) ACTION_RETURN_OBJECT(P_SpawnMissileZ(self, z, dest, type)); } - - AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassActor *type) { if (source == nullptr || type == nullptr) @@ -7835,7 +7804,6 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct th->Angles.Yaw = source->AngleTo(dest); th->VelFromAngle(); - double dist = source->DistanceBySpeed(dest, max(1., th->Speed)); th->Vel.Z = (dest->Z() - source->Z()) / dist; @@ -7857,7 +7825,6 @@ DEFINE_ACTION_FUNCTION(AActor, OldSpawnMissile) ACTION_RETURN_OBJECT(P_OldSpawnMissile(self, owner, dest, type)); } - //--------------------------------------------------------------------------- // // FUNC P_SpawnMissileAngle @@ -7950,7 +7917,6 @@ DEFINE_ACTION_FUNCTION(AActor, SpawnMissileAngleZSpeed) ACTION_RETURN_OBJECT(P_SpawnMissileAngleZSpeed(self, z, type, angle, vz, speed, owner, checkspawn)); } - AActor *P_SpawnSubMissile(AActor *source, PClassActor *type, AActor *target) { AActor *other = Spawn(source->Level, type, source->Pos(), ALLOW_REPLACE); @@ -8114,7 +8080,6 @@ DEFINE_ACTION_FUNCTION(AActor, SpawnPlayerMissile) return numret; } - int AActor::GetTeam() { if (player) @@ -8351,7 +8316,6 @@ DEFINE_ACTION_FUNCTION(AActor, TakeSpecialDamage) ACTION_RETURN_INT(self->TakeSpecialDamage(inflictor, source, damage, damagetype)); } - int AActor::CallTakeSpecialDamage(AActor *inflictor, AActor *source, int damage, FName damagetype) { IFVIRTUAL(AActor, TakeSpecialDamage) @@ -8417,7 +8381,6 @@ void AActor::SetIdle(bool nofunction) SetState(idle, nofunction); } - int AActor::SpawnHealth() const { int defhealth = StartHealth ? StartHealth : GetDefault()->health; @@ -8533,7 +8496,6 @@ int AActor::GetGibHealth() const return -SpawnHealth(); } - // killough 11/98: // Whether an object is "sentient" or not. Used for environmental influences. // (left precisely the same as MBF even though it doesn't make much sense.) @@ -8542,7 +8504,6 @@ bool AActor::IsSentient() const return health > 0 && SeeState != NULL; } - FSharedStringArena AActor::mStringPropertyData; const char *AActor::GetTag(const char *def) const @@ -8626,7 +8587,6 @@ int AActor::GetModifiedDamage(FName damagetype, int damage, bool passive, AActor return damage; } - int AActor::ApplyDamageFactor(FName damagetype, int damage) const { damage = int(damage * DamageFactor); diff --git a/src/playsim/p_spec.cpp b/src/playsim/p_spec.cpp index 44730bf87..691947f02 100644 --- a/src/playsim/p_spec.cpp +++ b/src/playsim/p_spec.cpp @@ -5,6 +5,7 @@ // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -67,38 +68,30 @@ #include - +#include "a_keys.h" +#include "a_sharedglobal.h" +#include "actorinlines.h" +#include "d_event.h" +#include "d_player.h" +#include "doomdata.h" #include "doomdef.h" #include "doomstat.h" -#include "d_event.h" -#include "g_level.h" -#include "gstrings.h" #include "events.h" - +#include "g_game.h" +#include "g_levellocals.h" +#include "gstrings.h" +#include "i_soundinternal.h" #include "m_random.h" - -#include "p_local.h" -#include "p_spec.h" +#include "p_3dmidtex.h" +#include "p_acs.h" #include "p_blockmap.h" #include "p_lnspec.h" -#include "p_terrain.h" -#include "p_acs.h" -#include "p_3dmidtex.h" - -#include "g_game.h" - -#include "a_sharedglobal.h" -#include "a_keys.h" -#include "c_dispatch.h" -#include "r_sky.h" -#include "d_player.h" -#include "g_levellocals.h" -#include "actorinlines.h" -#include "vm.h" +#include "p_local.h" #include "p_setup.h" - -#include "c_console.h" -#include "p_spec_thinkers.h" +#include "p_spec.h" +#include "p_terrain.h" +#include "r_sky.h" +#include "vm.h" static FRandom pr_actorinspecialsector ("ActorInSpecialSector"); @@ -141,7 +134,6 @@ bool FLevelLocals::CheckIfExitIsGood (AActor *self, level_info_t *info) return true; } - // // UTILITIES // diff --git a/src/playsim/p_teleport.cpp b/src/playsim/p_teleport.cpp index f26bb6fcb..6e39daef2 100644 --- a/src/playsim/p_teleport.cpp +++ b/src/playsim/p_teleport.cpp @@ -5,6 +5,7 @@ // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -28,11 +29,10 @@ #include "d_player.h" #include "doomdef.h" -#include "vm.h" #include "g_levellocals.h" #include "p_maputl.h" -#include "gi.h" #include "r_utility.h" +#include "vm.h" #define FUDGEFACTOR 10 diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 8533abf38..34d481f26 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -5,6 +5,7 @@ // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -58,42 +59,38 @@ ** */ - -#include "doomdef.h" -#include "d_event.h" -#include "p_local.h" -#include "doomstat.h" -#include "s_sound.h" -#include "gi.h" -#include "m_random.h" -#include "p_pspr.h" -#include "p_enemy.h" -#include "a_sharedglobal.h" #include "a_keys.h" -#include "filesystem.h" -#include "cmdlib.h" -#include "sbar.h" -#include "intermission/intermission.h" -#include "c_console.h" -#include "c_dispatch.h" -#include "d_net.h" -#include "serializer_doom.h" -#include "serialize_obj.h" -#include "d_player.h" -#include "r_utility.h" -#include "p_blockmap.h" #include "a_morph.h" -#include "p_spec.h" -#include "vm.h" -#include "g_levellocals.h" #include "actorinlines.h" -#include "p_acs.h" -#include "events.h" -#include "g_game.h" -#include "v_video.h" -#include "gstrings.h" -#include "s_music.h" +#include "c_dispatch.h" +#include "cmdlib.h" +#include "d_event.h" #include "d_main.h" +#include "d_net.h" +#include "d_player.h" +#include "doomdef.h" +#include "doomstat.h" +#include "events.h" +#include "filesystem.h" +#include "g_game.h" +#include "g_levellocals.h" +#include "gi.h" +#include "gstrings.h" +#include "intermission/intermission.h" +#include "m_random.h" +#include "p_acs.h" +#include "p_blockmap.h" +#include "p_enemy.h" +#include "p_local.h" +#include "p_pspr.h" +#include "p_spec.h" +#include "r_utility.h" +#include "s_music.h" +#include "s_sound.h" +#include "sbar.h" +#include "serialize_obj.h" +#include "serializer_doom.h" +#include "vm.h" extern int paused; @@ -478,8 +475,6 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSubtitleNumber) return 0; } - - int player_t::GetSpawnClass() { const PClass * type = PlayerClasses[CurrentPlayerClass].Type; @@ -648,7 +643,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(APlayerPawn, GetPainFlashForType, GetPainFlash) EXTERN_CVAR(Float, maxviewpitch) EXTERN_CVAR(Bool, cl_oldfreelooklimit); - static int GetSoftPitch(bool down) { int MAX_DN_ANGLE = min(56, (int)maxviewpitch); // Max looking down angle @@ -685,7 +679,6 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SendPitchLimits) return 0; } - bool player_t::HasWeaponsInSlot(int slot) const { for (int i = 0; i < weapons.SlotSize(slot); i++) @@ -703,7 +696,6 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, HasWeaponsInSlot) ACTION_RETURN_BOOL(self->HasWeaponsInSlot(slot)); } - bool player_t::Resurrect() { if (mo == nullptr || mo->IsKindOf(NAME_PlayerChunk)) return false; @@ -885,7 +877,6 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetStillBob) ACTION_RETURN_FLOAT(self->userinfo.GetStillBob()); } - //=========================================================================== // // @@ -1035,7 +1026,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) return 0; } - //=========================================================================== // // P_CheckPlayerSprites @@ -1284,7 +1274,6 @@ void P_CheckUse(player_t *player) } } - DEFINE_ACTION_FUNCTION(APlayerPawn, CheckUse) { PARAM_SELF_PROLOGUE(AActor); @@ -1841,7 +1830,6 @@ bool P_IsPlayerTotallyFrozen(const player_t *player) player->mo->isFrozen(); } - //========================================================================== // // native members diff --git a/src/rendering/r_utility.cpp b/src/rendering/r_utility.cpp index d97de3e3d..4c3136211 100644 --- a/src/rendering/r_utility.cpp +++ b/src/rendering/r_utility.cpp @@ -4,6 +4,7 @@ // Copyright 1994-1996 Raven Software // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers +// Copyright 2017-2025 GZDoom Maintainers and Contributors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -32,41 +33,31 @@ #include #include - -#include "doomdef.h" -#include "d_net.h" -#include "doomstat.h" -#include "m_random.h" -#include "m_bbox.h" -#include "r_sky.h" -#include "st_stuff.h" -#include "c_dispatch.h" -#include "v_video.h" -#include "stats.h" -#include "i_video.h" #include "a_sharedglobal.h" -#include "p_3dmidtex.h" -#include "r_data/r_interpolate.h" -#include "po_man.h" -#include "p_effect.h" -#include "st_start.h" -#include "v_font.h" -#include "swrenderer/r_renderer.h" -#include "serializer.h" -#include "r_utility.h" -#include "d_player.h" -#include "p_local.h" -#include "g_levellocals.h" -#include "p_maputl.h" -#include "sbar.h" -#include "vm.h" -#include "i_time.h" #include "actorinlines.h" -#include "g_game.h" -#include "i_system.h" -#include "v_draw.h" -#include "i_interface.h" #include "d_main.h" +#include "d_net.h" +#include "d_player.h" +#include "doomstat.h" +#include "g_game.h" +#include "g_levellocals.h" +#include "i_interface.h" +#include "i_time.h" +#include "i_video.h" +#include "m_random.h" +#include "p_3dmidtex.h" +#include "p_effect.h" +#include "p_local.h" +#include "p_maputl.h" +#include "r_data/r_interpolate.h" +#include "r_sky.h" +#include "r_utility.h" +#include "sbar.h" +#include "serializer.h" +#include "swrenderer/r_renderer.h" +#include "v_draw.h" +#include "v_video.h" +#include "vm.h" const float MY_SQRT2 = float(1.41421356237309504880); // sqrt(2) // EXTERNAL DATA DECLARATIONS ---------------------------------------------- @@ -283,7 +274,6 @@ void R_SetWindow (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, int wind viewwindow.centerxwide = viewwindow.centerx * AspectMultiplier(viewwindow.WidescreenRatio) / 48; } - DAngle fov = viewpoint.FieldOfView; // For widescreen displays, increase the FOV so that the middle part of the @@ -855,7 +845,6 @@ bool R_GetViewInterpolationStatus() return NoInterpolateView; } - //========================================================================== // // R_ClearInterpolationPath @@ -1214,7 +1203,6 @@ void R_SetupFrame(FRenderViewpoint& viewPoint, const FViewWindow& viewWindow, AA viewPoint.ViewActor = viewPoint.showviewer ? nullptr : actor; } - CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE | CVAR_SERVERINFO) { if (self>90.f) self = 90.f; @@ -1266,5 +1254,4 @@ bool R_ShouldDrawSpriteShadow(AActor *thing) } return doit; - } diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index 8717c4b9e..55377525d 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1,9 +1,11 @@ /* ** s_advsound.cpp +** ** Routines for managing SNDINFO lumps and ambient sounds ** **--------------------------------------------------------------------------- ** Copyright 1998-2008 Randy Heit +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -34,22 +36,18 @@ // HEADER FILES ------------------------------------------------------------ - #include "actor.h" #include "c_dispatch.h" -#include "filesystem.h" -#include "gi.h" -#include "i_sound.h" #include "d_netinf.h" #include "d_player.h" -#include "serializer.h" -#include "v_text.h" -#include "g_levellocals.h" -#include "r_data/sprites.h" -#include "vm.h" -#include "i_system.h" -#include "s_music.h" +#include "filesystem.h" +#include "gi.h" #include "i_music.h" +#include "i_sound.h" +#include "r_data/sprites.h" +#include "s_music.h" +#include "serializer.h" +#include "vm.h" using namespace FileSys; @@ -249,7 +247,6 @@ static bool PlayerClassesIsSorted; static TArray PlayerClassLookups; static TArray PlayerSounds; - static FString DefPlayerClassName; static int DefPlayerClass; @@ -1404,7 +1401,6 @@ static FSoundID S_LookupPlayerSound (int classidx, int gender, FSoundID refid) return sndnum; } - //========================================================================== // // S_SavePlayerSound / S_RestorePlayerSounds @@ -1847,7 +1843,6 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Deactivate) return 0; } - //========================================================================== // // S_ParseMusInfo @@ -1889,7 +1884,6 @@ void S_ParseMusInfo() } } - DEFINE_ACTION_FUNCTION(DObject, MarkSound) { PARAM_PROLOGUE; diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index 525bb9b54..1a47aa619 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -1,5 +1,5 @@ /* -** doomspund.cpp +** s_doomsound.cpp ** ** Game dependent part of the sound engine. ** @@ -7,6 +7,7 @@ ** ** Copyright 1999-2016 Randy Heit ** Copyright 2002-2019 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions @@ -34,43 +35,41 @@ ** */ - +#include "v_font.h" #include #include + #ifdef _WIN32 #include #endif -#include "i_system.h" -#include "i_sound.h" -#include "i_music.h" -#include "s_sound.h" -#include "s_sndseq.h" -#include "s_playlist.h" -#include "c_dispatch.h" -#include "m_random.h" -#include "filesystem.h" -#include "p_local.h" -#include "doomstat.h" -#include "cmdlib.h" -#include "v_video.h" -#include "v_text.h" #include "a_sharedglobal.h" -#include "gstrings.h" -#include "gi.h" -#include "po_man.h" -#include "serializer_doom.h" +#include "c_dispatch.h" +#include "cmdlib.h" #include "d_player.h" -#include "g_levellocals.h" -#include "vm.h" +#include "doomstat.h" +#include "filesystem.h" #include "g_game.h" -#include "s_music.h" -#include "v_draw.h" +#include "g_levellocals.h" +#include "gi.h" +#include "gstrings.h" +#include "i_music.h" +#include "i_sound.h" +#include "i_soundinternal.h" #include "m_argv.h" +#include "m_random.h" +#include "p_local.h" +#include "po_man.h" +#include "printf.h" +#include "s_music.h" +#include "s_sndseq.h" +#include "s_sound.h" +#include "serializer_doom.h" +#include "v_draw.h" +#include "vm.h" // PUBLIC DATA DEFINITIONS ------------------------------------------------- - static FString LastLocalSndInfo; static FString LastLocalSndSeq; void S_AddLocalSndInfo(int lump); @@ -99,14 +98,12 @@ class DoomSoundEngine : public SoundEngine return SoundEngine::CheckSoundLimit(sfx, pos, near_limit, limit_range, sourcetype, actor, channel, attenuation); } - public: DoomSoundEngine() = default; void NoiseDebug(void); void PrintSoundList(); }; - //========================================================================== // // LookupMusic @@ -254,7 +251,6 @@ void S_Shutdown() } } - //========================================================================== // // S_Start @@ -356,7 +352,6 @@ void S_PrecacheLevel(FLevelLocals* Level) } } - //========================================================================== // // S_InitData @@ -370,7 +365,6 @@ void S_InitData() S_ParseSndSeq(-1); } - //========================================================================== // // S_Sound - Unpositioned version @@ -437,7 +431,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(DObject, S_StartSoundAt, S_StartSoundAt) return 0; } - //========================================================================== // // @@ -510,7 +503,6 @@ void DoomSoundEngine::StopChannel(FSoundChan* chan) SoundEngine::StopChannel(chan); } - //========================================================================== // // S_Sound - An actor is source @@ -636,7 +628,6 @@ void A_PlaySound(AActor* self, int soundid, int channel, double volume, int loop A_StartSound(self, soundid, channel & 7, channel & ~7, volume, attenuation, pitch, 0.0f); } - //========================================================================== // // S_StopSound @@ -1186,6 +1177,7 @@ TArray DoomSoundEngine::ReadSound(int lumpnum) // This is overridden to use a synchronized RNG. // //========================================================================== + static FCRandom pr_randsound("RandSound"); FSoundID DoomSoundEngine::PickReplacement(FSoundID refid) @@ -1234,7 +1226,6 @@ void DoomSoundEngine::NoiseDebug() return; } - listener = players[consoleplayer].camera->SoundPos(); // Display the oldest channel first. @@ -1318,7 +1309,6 @@ void DoomSoundEngine::NoiseDebug() mysnprintf(temp, countof(temp), "%u", GSnd->GetPosition(chan)); DrawText(twod, NewConsoleFont, color, 520, y, temp, TAG_DONE); - y += NewConsoleFont->GetHeight(); if (chan->PrevChan == &Channels) { @@ -1334,7 +1324,6 @@ ADD_STAT(sounddebug) return ""; } - //========================================================================== // // CCMD soundlist diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index d49e6acc0..7c3d56d9f 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1,3 +1,37 @@ +/* +** actor.zs +** +**--------------------------------------------------------------------------- +** Copyright 2010-2017 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors +** 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. +**--------------------------------------------------------------------------- +** +*/ + struct FCheckPosition { // in @@ -25,11 +59,11 @@ struct FCheckPosition native int portalgroup; native int PushTime; - + // These are internal helpers to properly initialize an object of this type. private native void _Constructor(); private native void _Destructor(); - + native void ClearLastRipped(); } @@ -110,7 +144,7 @@ class Actor : Thinker native const MELEEDELTA = 20; // flags are not defined here, the native fields for those get synthesized from the internal tables. - + // for some comments on these fields, see their native representations in actor.h. native readonly Actor snext; // next in sector list. native PlayerInfo Player; @@ -395,7 +429,7 @@ class Actor : Thinker native property ShadowPenaltyFactor: ShadowPenaltyFactor; property AutomapOffsets : AutomapOffsets; property LandingSpeed: LandingSpeed; - + // need some definition work first //FRenderStyle RenderStyle; native private int RenderStyle; // This is kept private until its real type has been implemented into the VM. But some code needs to copy this. @@ -415,11 +449,10 @@ class Actor : Thinker native native deprecated("2.3", "Use Scale.Y instead") double ScaleY; //FStrifeDialogueNode *Conversation; // [RH] The dialogue to show when this actor is used.; - - + Default { - LightLevel -1; + LightLevel -1; Scale 1; Health DEFAULT_HEALTH; Reactiontime 8; @@ -488,7 +521,7 @@ class Actor : Thinker native FriendlySeeBlocks 10; // 10 (blocks) * 128 (one map unit block) LandingSpeed -8; // landing speed from a jump with normal gravity (squats the player's view) } - + // Functions // 'parked' global functions. @@ -497,7 +530,7 @@ class Actor : Thinker native native clearscope static Vector2 AngleToVector(double angle, double length = 1); native clearscope static Vector2 RotateVector(Vector2 vec, double angle); native clearscope static double Normalize180(double ang); - + virtual void MarkPrecacheSounds() { MarkSound(SeeSound); @@ -518,7 +551,7 @@ class Actor : Thinker native { return GetPointer(ptr_select1) == GetPointer(ptr_select2); } - + clearscope static double BobSin(double fb) { return sin(fb * (180./32)) * 8; @@ -560,8 +593,8 @@ class Actor : Thinker native return true; } - // [AA] Called by inventory items in CallTryPickup to see if this actor needs - // to process them in some way before they're received. Gets called before + // [AA] Called by inventory items in CallTryPickup to see if this actor needs + // to process them in some way before they're received. Gets called before // the item's TryPickup, allowing fully customized handling of all items. virtual bool CanReceive(Inventory item) { @@ -627,7 +660,7 @@ class Actor : Thinker native { return false; } - + virtual class GetBloodType(int type) { Class bloodcls; @@ -654,7 +687,7 @@ class Actor : Thinker native } return bloodcls; } - + virtual int GetGibHealth() { if (GibHealth != int.min) @@ -666,7 +699,7 @@ class Actor : Thinker native return -int(GetSpawnHealth() * gameinfo.gibfactor); } } - + virtual double GetDeathHeight() { // [RH] Allow the death height to be overridden using metadata. @@ -688,7 +721,7 @@ class Actor : Thinker native return MAX(metaheight, 0); } } - + virtual String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { if (mod == 'Telefrag') @@ -706,7 +739,7 @@ class Actor : Thinker native { return SelfObituary; } - + virtual int OnDrain(Actor victim, int damage, Name dmgtype) { return damage; @@ -719,7 +752,7 @@ class Actor : Thinker native // return false in PreTeleport() to cancel the action early virtual bool PreTeleport( Vector3 destpos, double destangle, int flags ) { return true; } virtual void PostTeleport( Vector3 destpos, double destangle, int flags ) {} - + native virtual bool OkayToSwitchTarget(Actor other); native clearscope static class GetReplacement(class cls); native clearscope static class GetReplacee(class cls); @@ -765,7 +798,7 @@ class Actor : Thinker native native clearscope Vector3 PosRelative(sector sec) const; native void RailAttack(FRailParams p); native clearscope Name GetDecalName() const; - + native void HandleSpawnFlags(); native void ExplodeMissile(line lin = null, Actor target = null, bool onsky = false); native void RestoreDamage(); @@ -787,7 +820,7 @@ class Actor : Thinker native native bool CheckFor3DFloorHit(double z, bool trigger); native bool CheckFor3DCeilingHit(double z, bool trigger); native int CheckMonsterUseSpecials(Line blocking = null); - + native bool CheckMissileSpawn(double maxdist); native bool CheckPosition(Vector2 pos, bool actorsonly = false, FCheckPosition tm = null); native bool TestMobjLocation(); @@ -812,7 +845,7 @@ class Actor : Thinker native void A_Light1() { if (player) player.extralight = 1; } void A_Light2() { if (player) player.extralight = 2; } void A_LightInverse() { if (player) player.extralight = 0x80000000; } - + native Actor OldSpawnMissile(Actor dest, class type, Actor owner = null); native Actor SpawnPuff(class pufftype, vector3 pos, double hitdir, double particledir, int updown, int flags = 0, Actor victim = null); native Actor SpawnBlood (Vector3 pos1, double dir, int damage); @@ -820,7 +853,7 @@ class Actor : Thinker native native bool HitWater (sector sec, Vector3 pos, bool checkabove = false, bool alert = true, bool force = false, int flags = 0); native void PlaySpawnSound(Actor missile); native clearscope bool CountsAsKill() const; - + native bool Teleport(Vector3 pos, double angle, int flags); native void TraceBleed(int damage, Actor missile); native void TraceBleedAngle(int damage, double angle, double pitch); @@ -839,7 +872,7 @@ class Actor : Thinker native native bool, Actor, double PerformShadowChecks (Actor other, Vector3 pos); native bool HitFriend(); native bool MonsterMove(); - + native SeqNode StartSoundSequenceID (int sequence, int type, int modenum, bool nostop = false); native SeqNode StartSoundSequence (Name seqname, int modenum); native void StopSoundSequence(); @@ -848,7 +881,7 @@ class Actor : Thinker native native double, double GetFriction(); native bool, Actor TestMobjZ(bool quick = false); native clearscope static bool InStateSequence(State newstate, State basestate); - + bool TryWalk () { if (!MonsterMove ()) @@ -858,7 +891,7 @@ class Actor : Thinker native movecount = random[TryWalk](0, 15); return true; } - + native bool TryMove(vector2 newpos, int dropoff, bool missilecheck = false, FCheckPosition tm = null); native bool CheckMove(vector2 newpos, int flags = 0, FCheckPosition tm = null); native void NewChaseDir(); @@ -933,10 +966,11 @@ class Actor : Thinker native // // AActor :: GetLevelSpawnTime // - // Returns the time when this actor was spawned, + // Returns the time when this actor was spawned, // relative to the current level. // //========================================================================== + clearscope int GetLevelSpawnTime() const { return SpawnTime - level.totaltime + level.time; @@ -949,7 +983,7 @@ class Actor : Thinker native // Returns the number of ticks passed since this actor was spawned. // //========================================================================== - + clearscope int GetAge() const { return level.totaltime - SpawnTime; @@ -960,8 +994,6 @@ class Actor : Thinker native return 1. / (1 << (accuracy * 5 / 100)); } - - protected native void DestroyAllInventory(); // This is not supposed to be called by user code! native clearscope Inventory FindInventory(class itemtype, bool subclass = false) const; native Inventory GiveInventoryType(class itemtype); @@ -1015,7 +1047,7 @@ class Actor : Thinker native void A_SetRipMax(int maximum) { RipLevelMax = maximum; } void A_ScreamAndUnblock() { A_Scream(); A_NoBlocking(); } void A_ActiveAndUnblock() { A_ActiveSound(); A_NoBlocking(); } - + //--------------------------------------------------------------------------- // // FUNC P_SpawnMissileAngle @@ -1034,7 +1066,6 @@ class Actor : Thinker native { return SpawnMissileAngleZSpeed (z, type, angle, vz, GetDefaultSpeed (type), owner); } - void A_SetScale(double scalex, double scaley = 0, int ptr = AAPTR_DEFAULT, bool usezero = false) { @@ -1095,7 +1126,7 @@ class Actor : Thinker native } void A_ChangeLinkFlags(int blockmap = FLAG_NO_CHANGE, int sector = FLAG_NO_CHANGE) - { + { UnlinkFromWorld(); if (blockmap != FLAG_NO_CHANGE) bNoBlockmap = blockmap; if (sector != FLAG_NO_CHANGE) bNoSector = sector; @@ -1120,7 +1151,7 @@ class Actor : Thinker native mo.Vel.Z = random[Dirt]() / 64.; } } - + // // A_SinkMobj // Sink a mobj incrementally into the floor @@ -1138,8 +1169,8 @@ class Actor : Thinker native // // A_RaiseMobj - // Raise a mobj incrementally from the floor to - // + // Raise a mobj incrementally from the floor to + // bool RaiseMobj (double speed) { @@ -1159,14 +1190,14 @@ class Actor : Thinker native } return true; } - + Actor AimTarget() { FTranslatedLineTarget t; BulletSlope(t, ALF_PORTALRESTRICT); return t.linetarget; } - + void RestoreRenderStyle() { bShadow = default.bShadow; @@ -1174,7 +1205,7 @@ class Actor : Thinker native RenderStyle = default.RenderStyle; Alpha = default.Alpha; } - + virtual bool ShouldSpawn() { return true; @@ -1199,7 +1230,7 @@ class Actor : Thinker native // Meh, MBF redundant functions. Only for DeHackEd support. native bool A_LineEffect(int boomspecial = 0, int tag = 0); // End of MBF redundant functions. - + native void A_MonsterRail(); native void A_Pain(); native void A_NoBlocking(bool drop = true); @@ -1281,7 +1312,7 @@ class Actor : Thinker native native void A_CountdownArg(int argnum, statelabel targstate = null); native state A_MonsterRefire(int chance, statelabel label); native void A_LookEx(int flags = 0, double minseedist = 0, double maxseedist = 0, double maxheardist = 0, double fov = 0, statelabel label = null); - + native void A_Recoil(double xyvel); native int A_RadiusGive(class itemtype, double distance, int flags, int amount = 0, class filter = null, name species = "None", double mindist = 0, int limit = 0); native void A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true); @@ -1290,7 +1321,7 @@ class Actor : Thinker native native void A_RadiusDamageSelf(int damage = 128, double distance = 128.0, int flags = 0, class flashtype = null); native int GetRadiusDamage(Actor thing, int damage, double distance, double fulldmgdistance = 0.0, bool oldradiusdmg = false, bool circular = false); native int RadiusAttack(Actor bombsource, int bombdamage, double bombdistance, Name bombmod = 'none', int flags = RADF_HURTSOURCE, double fulldamagedistance = 0.0, name species = "None"); - + native void A_Respawn(int flags = 1); native void A_RestoreSpecialPosition(); native void A_QueueCorpse(); @@ -1361,15 +1392,15 @@ class Actor : Thinker native action native void A_OverlayAlpha(int layer, double alph); action native void A_OverlayRenderStyle(int layer, int style); action native void A_OverlayTranslation(int layer, name trname); - + native bool A_AttachLightDef(Name lightid, Name lightdef); native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags = 0, Vector3 ofs = (0,0,0), double param = 0, double spoti = 10, double spoto = 25, double spotp = 0, double intensity = 1.0); native bool A_RemoveLight(Name lightid); //================================================ - // + // // Bone Offset Setters - // + // //================================================ native version("4.15.1") void SetBoneRotation(int boneIndex, Quat rotation, int mode = SB_ADD, double interpolation_duration = 1.0); @@ -1424,9 +1455,9 @@ class Actor : Thinker native native version("4.15.1") void ClearBoneOffsets(); //================================================ - // + // // Bone Offset Getters - // + // //================================================ /* rotation, translation, scaling */ @@ -1434,58 +1465,58 @@ class Actor : Thinker native native version("4.15.1") Quat, Vector3, Vector3 GetNamedBoneOffset(Name boneName); //================================================ - // + // // Bone Info Getters - // + // //================================================ - + native version("4.15.1") void GetRootBones(out Array rootBones); - + native version("4.15.1") Name GetBoneName(int boneIndex); native version("4.15.1") int GetBoneIndex(Name boneName); - + native version("4.15.1") int GetBoneParent(int boneIndex); native version("4.15.1") int GetNamedBoneParent(Name boneName); // return value lower than 0 means it's a root bone, and as such has no parent - + native version("4.15.1") void GetBoneChildren(int boneIndex, out Array children); native version("4.15.1") void GetNamedBoneChildren(Name boneName, out Array children); - + /* rotation, translation, scaling */ native version("4.15.1") Quat, Vector3, Vector3 GetBoneBaseTRS(int boneIndex); native version("4.15.1") Quat, Vector3, Vector3 GetNamedBoneBaseTRS(Name boneName); - + native version("4.15.1") Vector3 GetBoneBasePosition(int boneIndex); native version("4.15.1") Vector3 GetNamedBoneBasePosition(Name boneName); - + native version("4.15.1") Quat GetBoneBaseRotation(int boneIndex); native version("4.15.1") Quat GetNamedBoneBaseRotation(Name boneName); native version("4.15.1") int GetBoneCount(); //================================================ - // + // // Bone Pose Getters - // + // //================================================ native version("4.15.1") int GetAnimStartFrame(Name animName); native version("4.15.1") int GetAnimEndFrame(Name animName); native version("4.15.1") double GetAnimFramerate(Name animName); - + /* rotation, translation, scaling */ native version("4.15.1") Quat, Vector3, Vector3 GetBoneFramePose(int boneIndex, int frame); native version("4.15.1") Quat, Vector3, Vector3 GetNamedBoneFramePose(Name boneName, int frame); //================================================ - // + // // Bone TRS Getters - // + // //================================================ - + /* rotation, translation, scaling, doesn't include parent bones */ native version("4.15.1") Quat, Vector3, Vector3 GetBoneTRS(int boneIndex, bool include_offsets = true); native version("4.15.1") Quat, Vector3, Vector3 GetNamedBoneTRS(Name boneName, bool include_offsets = true); - + /* angle, pitch, roll, includes parent bones */ native version("4.15.1") Vector3 GetBoneEulerAngles(int boneIndex, bool include_offsets = true); native version("4.15.1") Vector3 GetNamedBoneEulerAngles(Name boneName, bool include_offsets = true); @@ -1493,13 +1524,13 @@ class Actor : Thinker native //input position/direction vectors are in xzy, model space native version("4.15.1") Vector3, Vector3, Vector3 TransformByBone(int boneIndex, Vector3 position, Vector3 forward = (1,0,0), Vector3 up = (0,0,1), bool include_offsets = true); native version("4.15.1") Vector3, Vector3, Vector3 TransformByNamedBone(Name boneName, Vector3 position, Vector3 forward = (1,0,0), Vector3 up = (0,0,1), bool include_offsets = true); - + version("4.15.1") Vector3, Vector3, Vector3 GetBonePosition(int boneIndex, bool include_offsets = true) { let [a, b, c] = TransformByBone(boneIndex, GetBoneBasePosition(boneIndex), include_offsets:include_offsets); return a, b, c; } - + version("4.15.1") Vector3, Vector3, Vector3 GetNamedBonePosition(name boneName, bool include_offsets = true) { let [a, b, c] = GetBonePosition(GetBoneIndex(boneName), include_offsets); @@ -1507,11 +1538,11 @@ class Actor : Thinker native } //================================================ - // + // // Bone Matrix Getters - // + // //================================================ - + //outMatrix will be a 16-length array containing the raw matrix data native version("4.15.1") void GetBoneMatrixRaw(int boneIndex, out Array outMatrix, bool include_offsets = true); native version("4.15.1") void GetNamedBoneMatrixRaw(Name boneName, out Array outMatrix, bool include_offsets = true); @@ -1519,9 +1550,9 @@ class Actor : Thinker native native version("4.15.1") void GetObjectToWorldMatrixRaw(out Array outMatrix); //================================================ - // - // - // + // + // + // //================================================ native version("4.12") void SetAnimation(Name animName, double framerate = -1, int startFrame = -1, int loopFrame = -1, int endFrame = -1, int interpolateTics = -1, int flags = 0); @@ -1533,8 +1564,7 @@ class Actor : Thinker native native version("4.12") void SetModelFlag(int flag, int iqmFlags = 0); native version("4.12") void ClearModelFlag(int flag, int iqmFlags = 0); native version("4.12") void ResetModelFlags(bool resetModel = true, bool resetIqm = false); - - + action version("4.12") void A_SetAnimation(Name animName, double framerate = -1, int startFrame = -1, int loopFrame = -1, int endFrame = -1, int interpolateTics = -1, int flags = 0) { invoker.SetAnimation(animName, framerate, startFrame, loopFrame, endFrame, interpolateTics, flags); @@ -1549,20 +1579,16 @@ class Actor : Thinker native { invoker.SetModelFlag(flag); } - + action version("4.12") void A_ClearModelFlag(int flag) { invoker.ClearModelFlag(flag); } - + action version("4.12") void A_ResetModelFlags() { invoker.ResetModelFlags(); } - - - - int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0) { @@ -1596,7 +1622,7 @@ class Actor : Thinker native { return ACS_ExecuteWithResult(-int(script), arg1, arg2, arg3, arg4); } - + //=========================================================================== // // Sounds @@ -1694,8 +1720,6 @@ class Actor : Thinker native if (player == NULL) Destroy(); } - - States(Actor, Overlay, Weapon, Item) { Spawn: diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 6bc64929b..c32116b1e 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -1,3 +1,36 @@ +/* +** player.zs +** +**--------------------------------------------------------------------------- +** Copyright 2010-2017 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors +** 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. +**--------------------------------------------------------------------------- +** +*/ struct UserCmd native { @@ -17,7 +50,7 @@ class PlayerPawn : Actor const TURN180_TICKS = ((TICRATE / 4) + 1); // 16 pixels of bob const MAXBOB = 16.; - + int crouchsprite; int MaxHealth; int BonusHealth; @@ -61,7 +94,7 @@ class PlayerPawn : Actor meta int TeleportFreezeTime; meta int ColorRangeStart; // Skin color range meta int ColorRangeEnd; - + property prefix: Player; property HealRadiusType: HealingradiusType; property InvulnerabilityMode: InvulMode; @@ -83,7 +116,7 @@ class PlayerPawn : Actor property ViewBob: ViewBob; property ViewBobSpeed: ViewBobSpeed; property WaterClimbSpeed : WaterClimbSpeed; - + flagdef NoThrustWhenInvul: PlayerFlags, 0; flagdef CanSuperMorph: PlayerFlags, 1; flagdef CrouchableMorph: PlayerFlags, 2; @@ -95,7 +128,7 @@ class PlayerPawn : Actor { PF_VOODOO_ZOMBIE = 1<<4, } - + Default { Health 100; @@ -138,8 +171,7 @@ class PlayerPawn : Actor Player.TeleportFreezeTime 18; Obituary "$OB_MPDEFAULT"; } - - + //=========================================================================== // // PlayerPawn :: Tick @@ -176,7 +208,7 @@ class PlayerPawn : Actor //=========================================================================== // - // + // // //=========================================================================== @@ -190,7 +222,7 @@ class PlayerPawn : Actor FullHeight = Height; if (!SetupCrouchSprite(crouchsprite)) crouchsprite = 0; } - + //=========================================================================== // // PlayerPawn :: PostBeginPlay @@ -215,7 +247,6 @@ class PlayerPawn : Actor } } - //=========================================================================== // // PlayerPawn :: MarkPrecacheSounds @@ -227,10 +258,10 @@ class PlayerPawn : Actor Super.MarkPrecacheSounds(); MarkPlayerSounds(); } - + //---------------------------------------------------------------------------- // - // + // // //---------------------------------------------------------------------------- @@ -245,7 +276,7 @@ class PlayerPawn : Actor if (InStateSequence(CurState, SpawnState) && SeeState != NULL) SetState (SeeState); } - + virtual void PlayAttacking () { if (MissileState != null) SetState (MissileState); @@ -255,14 +286,14 @@ class PlayerPawn : Actor { if (MeleeState != null) SetState (MeleeState); } - + virtual void MorphPlayerThink() { } - + //---------------------------------------------------------------------------- // - // + // // //---------------------------------------------------------------------------- @@ -282,10 +313,10 @@ class PlayerPawn : Actor bRespawnInvul = true; // [RH] special effect } } - + //---------------------------------------------------------------------------- // - // + // // //---------------------------------------------------------------------------- @@ -334,21 +365,21 @@ class PlayerPawn : Actor return message; } - + //---------------------------------------------------------------------------- // // This is for SBARINFO. // //---------------------------------------------------------------------------- - clearscope int, int GetEffectTicsForItem(class item) const + clearscope int, int GetEffectTicsForItem(class item) const { let pg = (class)(item); if (pg != null) { let powerupType = (class)(GetDefaultByType(pg).PowerupType); let powerup = Powerup(FindInventory(powerupType)); - if(powerup != null) + if(powerup != null) { let maxtics = GetDefaultByType(pg).EffectTics; if (maxtics == 0) maxtics = powerup.default.EffectTics; @@ -357,7 +388,6 @@ class PlayerPawn : Actor } return -1, -1; } - //=========================================================================== // @@ -370,11 +400,11 @@ class PlayerPawn : Actor void CheckWeaponSwitch(Class ammotype) { let player = self.player; - if (!player.GetNeverSwitch() && player.PendingWeapon == WP_NOCHANGE && + if (!player.GetNeverSwitch() && player.PendingWeapon == WP_NOCHANGE && (player.ReadyWeapon == NULL || player.ReadyWeapon.bWimpy_Weapon)) { let best = BestWeapon (ammotype); - if (best != NULL && !best.bNoAutoSwitchTo && + if (best != NULL && !best.bNoAutoSwitchTo && (player.ReadyWeapon == NULL || best.SelectionOrder < player.ReadyWeapon.SelectionOrder)) { player.PendingWeapon = best; @@ -391,7 +421,7 @@ class PlayerPawn : Actor virtual void FireWeapon (State stat) { let player = self.player; - + let weapn = player.ReadyWeapon; if (weapn == null || !weapn.CheckAmmo (Weapon.PrimaryFire, true)) { @@ -497,7 +527,7 @@ class PlayerPawn : Actor virtual void CheckWeaponChange () { let player = self.player; - if (!player) return; + if (!player) return; if ((player.WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled. Alternative) // Morphed classes cannot change weapons. { // ...so throw away any pending weapon requests. @@ -512,7 +542,7 @@ class PlayerPawn : Actor DropWeapon(); } } - + //------------------------------------------------------------------------ // // PROC P_MovePsprites @@ -528,7 +558,7 @@ class PlayerPawn : Actor while (pspr) { // Destroy the psprite if it's from a weapon that isn't currently selected by the player - // or if it's from an inventory item that the player no longer owns. + // or if it's from an inventory item that the player no longer owns. if ((pspr.Caller == null || (pspr.Caller is "Inventory" && Inventory(pspr.Caller).Owner != pspr.Owner.mo) || (pspr.Caller is "Weapon" && pspr.Caller != pspr.Owner.ReadyWeapon))) @@ -562,7 +592,7 @@ class PlayerPawn : Actor } } } - + /* ================== = @@ -664,8 +694,8 @@ class PlayerPawn : Actor if (player.deltaviewheight <= 0) player.deltaviewheight = 1 / 65536.; } - - if (player.deltaviewheight) + + if (player.deltaviewheight) { player.deltaviewheight += 0.25; if (!player.deltaviewheight) @@ -694,7 +724,6 @@ class PlayerPawn : Actor } } - //========================================================================== // // P_DeathThink @@ -749,12 +778,12 @@ class PlayerPawn : Actor } } player.mo.CalcHeight (); - + if (player.attacker && player.attacker != self) { // Watch killer double diff = deltaangle(angle, AngleTo(player.attacker)); double delta = abs(diff); - + if (delta < 10) { // Looking at killer, so fade damage and poison counters if (player.damagecount) @@ -779,7 +808,7 @@ class PlayerPawn : Actor { player.poisoncount--; } - } + } if ((player.cmd.buttons & BT_USE || ((deathmatch || alwaysapplydmflags) && sv_forcerespawn)) && !sv_norespawn) @@ -807,7 +836,7 @@ class PlayerPawn : Actor Super.Die (source, inflictor, dmgflags, MeansOfDeath); if (player != NULL && player.mo == self) player.bonuscount = 0; - + // [RL0] To allow voodoo zombies, don't kill the player together with voodoo dolls if the compat flag is enabled if (player != NULL && player.mo != self && !(Level.compatflags2 & COMPATF2_VOODOO_ZOMBIES)) { // Make the real player die, too @@ -835,7 +864,7 @@ class PlayerPawn : Actor } di = di.Next; } - } + } else if (weap.SpawnState != NULL && weap.SpawnState != GetDefaultByType('Actor').SpawnState) { @@ -876,7 +905,7 @@ class PlayerPawn : Actor } } } - + //=========================================================================== // // PlayerPawn :: FilterCoopRespawnInventory @@ -994,7 +1023,6 @@ class PlayerPawn : Actor } } - //---------------------------------------------------------------------------- // // PROC P_CheckFOV @@ -1118,7 +1146,7 @@ class PlayerPawn : Actor virtual void CrouchMove(int direction) { let player = self.player; - + double defaultheight = FullHeight; double savedheight = Height; double crouchspeed = direction * CROUCHSPEED; @@ -1237,7 +1265,7 @@ class PlayerPawn : Actor } player.Vel += AngleToVector(angle, move); } - + //=========================================================================== // // PlayerPawn :: TweakSpeeds @@ -1378,7 +1406,7 @@ class PlayerPawn : Actor player.camera = player.mo; } } - } + } //---------------------------------------------------------------------------- // @@ -1531,7 +1559,6 @@ class PlayerPawn : Actor } } - //---------------------------------------------------------------------------- // // PROC P_HandleMovement @@ -1656,7 +1683,7 @@ class PlayerPawn : Actor // PROC P_PlayerThink // //---------------------------------------------------------------------------- - + virtual void PlayerThink() { let player = self.player; @@ -1667,7 +1694,7 @@ class PlayerPawn : Actor { PlayerFlags |= PF_VOODOO_ZOMBIE; } - + CheckFOV(); CheckCheats(); @@ -1818,7 +1845,7 @@ class PlayerPawn : Actor else if(Delay > 0) { // delay-based terrain footstepLength = 0; - + if(footstepCounter % Delay == 0) { DoFootstep(Ground); @@ -1856,7 +1883,7 @@ class PlayerPawn : Actor if (player.ReadyWeapon != null) { let psp = player.GetPSprite(PSP_WEAPON); - if (psp) + if (psp) { psp.y = WEAPONTOP; player.ReadyWeapon.ResetPSprite(psp); @@ -1896,7 +1923,7 @@ class PlayerPawn : Actor player.SetPsprite(PSP_WEAPON, weapon.GetUpState()); } } - + //=========================================================================== // // PlayerPawn :: BestWeapon @@ -1956,7 +1983,6 @@ class PlayerPawn : Actor return bestMatch; } - //--------------------------------------------------------------------------- // // PROC P_DropWeapon @@ -1981,7 +2007,7 @@ class PlayerPawn : Actor player.SetPsprite(PSP_WEAPON, weap.GetDownState()); } } - + //=========================================================================== // // PlayerPawn :: PickNewWeapon @@ -2127,7 +2153,7 @@ class PlayerPawn : Actor //=========================================================================== // - // + // // //=========================================================================== @@ -2137,10 +2163,10 @@ class PlayerPawn : Actor if (withupgrades) ret += stamina + BonusHealth; return ret; } - + //=========================================================================== // - // + // // //=========================================================================== @@ -2155,8 +2181,7 @@ class PlayerPawn : Actor } return TeleportFreezeTime; } - - + //=========================================================================== // // G_PlayerFinishLevel @@ -2274,7 +2299,7 @@ class PlayerPawn : Actor me.GiveDefaultInventory(); } } - + //=========================================================================== // // FWeaponSlot :: PickWeapon @@ -2359,7 +2384,7 @@ class PlayerPawn : Actor let ReadyWeapon = player.ReadyWeapon; if (player.PendingWeapon != WP_NOCHANGE) { - // Workaround for the current inability + // Workaround for the current inability bool found; int slot; int index; @@ -2619,10 +2644,10 @@ class PlayerPawn : Actor Vector2 oldBob = BobWeapon(ticfrac); return (0, 0, 0) , ( oldBob.x / 4, oldBob.y / -4, 0); } - + //---------------------------------------------------------------------------- // - // + // // //---------------------------------------------------------------------------- @@ -2632,7 +2657,7 @@ class PlayerPawn : Actor if (painFlash == 0) painFlash = DamageFade; return painFlash; } - + //=========================================================================== // // PlayerPawn :: ResetAirSupply @@ -2659,7 +2684,7 @@ class PlayerPawn : Actor //---------------------------------------------------------------------------- // - // + // // //---------------------------------------------------------------------------- @@ -2750,7 +2775,7 @@ class PSprite : Object native play TARGETRIGHT, }; - native readonly State CurState; + native readonly State CurState; native Actor Caller; native readonly PSprite Next; native readonly PlayerInfo Owner; @@ -2781,7 +2806,7 @@ class PSprite : Object native play native bool bAddBob; native bool bPowDouble; native bool bCVarFast; - native bool bFlip; + native bool bFlip; native bool bMirror; native bool bPlayerTranslated; native bool bPivotPercent; @@ -2819,13 +2844,13 @@ class PSprite : Object native play } } } - - void ResetInterpolation() - { - oldx = x; - oldy = y; + + void ResetInterpolation() + { + oldx = x; + oldy = y; } - + } enum EPlayerState @@ -2850,7 +2875,7 @@ struct PlayerInfo native play // self is what internally is known as player_t // technically engine constants but the only part of the playsim using them is the player. const NOFIXEDCOLORMAP = -1; const NUMCOLORMAPS = 32; - + native PlayerPawn mo; native uint8 playerstate; native readonly uint buttons; @@ -2971,7 +2996,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native clearscope bool GetClassicFlight() const; native void SendPitchLimits(); native clearscope bool HasWeaponsInSlot(int slot) const; - + native clearscope int GetAverageLatency() const; native clearscope static PlayerInfo GetNextPlayer(PlayerInfo p, bool noBots = false); @@ -2982,7 +3007,7 @@ struct PlayerInfo native play // self is what internally is known as player_t { return mo ? mo.MorphPlayer(activator, spawnType, duration, style, enterFlash, exitFlash) : false; } - + // This somehow got its arguments mixed up. 'self' should have been the player to be unmorphed, not the activator deprecated("3.7", "UndoPlayerMorph() should be used on a PlayerPawn object") bool UndoPlayerMorph(PlayerInfo player, EMorphFlags unmorphFlags = 0, bool force = false) { @@ -3001,7 +3026,7 @@ struct PlayerInfo native play // self is what internally is known as player_t { if (mo) mo.BringUpWeapon(); } - + clearscope bool IsTotallyFrozen() const { return @@ -3022,14 +3047,13 @@ struct PlayerInfo native play // self is what internally is known as player_t viewheight = mo.ViewHeight; } } - clearscope int fragSum () const { int i; int allfrags = 0; int playernum = mo.PlayerNumber(); - + for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] @@ -3038,17 +3062,17 @@ struct PlayerInfo native play // self is what internally is known as player_t allfrags += frags[i]; } } - + // JDC hack - negative frags. allfrags -= frags[playernum]; return allfrags; } - + double GetDeltaViewHeight() { return (mo.ViewHeight + crouchviewdelta - viewheight) / 8; } - + } struct PlayerClass native @@ -3056,7 +3080,7 @@ struct PlayerClass native native class Type; native uint Flags; native Array Skins; - + native bool CheckSkin(int skin); native void EnumColorsets(out Array data); native Name GetColorsetName(int setnum); diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index be0a40bdc..938125342 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -1,4 +1,36 @@ - +/* +** base.zs +** +**--------------------------------------------------------------------------- +** Copyright 2016-2017 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors +** 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. +**--------------------------------------------------------------------------- +** +*/ // constants for A_PlaySound enum ESoundFlags @@ -11,7 +43,7 @@ enum ESoundFlags CHAN_5 = 5, CHAN_6 = 6, CHAN_7 = 7, - + // modifier flags CHAN_LISTENERZ = 8, CHAN_MAYBE_LOCAL = 16, @@ -36,7 +68,6 @@ enum ESoundFlags CHANF_FORCE = 65536, // Start, even if sound is paused. CHANF_SINGULAR = 0x20000, // Only start if no sound of this name is already playing. - CHANF_LOOPING = CHANF_LOOP | CHANF_NOSTOP, // convenience value for replicating the old 'looping' boolean. }; @@ -46,7 +77,6 @@ const ATTN_NORM = 1; const ATTN_IDLE = 1.001; const ATTN_STATIC = 3; - enum ERenderStyle { STYLE_None, // Do not draw @@ -71,7 +101,6 @@ enum ERenderStyle }; - enum EGameState { GS_LEVEL, @@ -122,7 +151,6 @@ const TEXTCOLOR_BOLD = "\034+"; const TEXTCOLOR_CHAT = "\034*"; const TEXTCOLOR_TEAMCHAT = "\034!"; - enum EMonospacing { Mono_Off = 0, @@ -264,7 +292,6 @@ struct MusPlayingInfo native native int baseorder; native bool loop; native readonly voidptr handle; - }; struct TexMan @@ -300,7 +327,7 @@ struct TexMan ForceLookup = 128, NoAlias = 256 }; - + enum ETexReplaceFlags { NOT_BOTTOM = 1, @@ -375,7 +402,6 @@ enum EScaleMode FSMode_ScaleToFit43Bottom = 6, FSMode_ScaleToHeight = 7, - FSMode_Max, // These all use ScaleToFit43, their purpose is to cut down on verbosity because they imply the virtual screen size. @@ -621,7 +647,7 @@ struct Font native CR_TEAL, NUM_TEXT_COLORS }; - + const TEXTCOLOR_BRICK = "\034A"; const TEXTCOLOR_TAN = "\034B"; const TEXTCOLOR_GRAY = "\034C"; @@ -775,7 +801,7 @@ class Object native private native static Function BuiltinFunctionPtrCast(Function inptr, voidptr newtype); private native static void HandleDeprecatedFlags(Object obj, bool set, int index); private native static bool CheckDeprecatedFlags(Object obj, int index); - + native static Name ValidateNameIndex(int index); static class FindClass(Name cls, class baseType = null) { return BuiltinNameToClass(cls, baseType); } @@ -967,7 +993,7 @@ struct StringStruct native unsafe(internal) struct Translation version("2.4") { Color colors[256]; - + native TranslationID AddTranslation(); native static TranslationID MakeID(int group, int num); native static TranslationID GetID(Name transname); @@ -1037,7 +1063,7 @@ class ScriptScanner native native void MustGetString(); native void MustGetStringName(String name); native void MustGetBoolToken(); - + // This DOES NOT advance the parser! This returns the string the parser got. native String GetStringContents(); diff --git a/wadsrc/static/zscript/engine/ui/menu/joystickmenu.zs b/wadsrc/static/zscript/engine/ui/menu/joystickmenu.zs index bf03c073d..e93b0a475 100644 --- a/wadsrc/static/zscript/engine/ui/menu/joystickmenu.zs +++ b/wadsrc/static/zscript/engine/ui/menu/joystickmenu.zs @@ -1,9 +1,10 @@ /* -** joystickmenu.cpp +** joystickmenu.zs ** The joystick configuration menus ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -317,7 +318,7 @@ class OptionMenuItemJoyMap : OptionMenuItemOptionBase //============================================================================= // -// +// // //============================================================================= @@ -354,7 +355,6 @@ class OptionMenuItemInverter : OptionMenuItemOptionBase // //============================================================================= - class OptionMenuJoyEnable : OptionMenuItemOptionBase { JoystickConfig mJoy; @@ -377,7 +377,6 @@ class OptionMenuJoyEnable : OptionMenuItemOptionBase } } - class OptionMenuJoyEnableInBackground : OptionMenuItemOptionBase { JoystickConfig mJoy; diff --git a/wadsrc/static/zscript/engine/ui/menu/menu.zs b/wadsrc/static/zscript/engine/ui/menu/menu.zs index 9719474ec..7ea6cf28c 100644 --- a/wadsrc/static/zscript/engine/ui/menu/menu.zs +++ b/wadsrc/static/zscript/engine/ui/menu/menu.zs @@ -4,6 +4,7 @@ ** **--------------------------------------------------------------------------- ** Copyright 2010-2020 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -32,7 +33,6 @@ ** */ - struct KeyBindings native version("2.4") { native static String NameKeys(int k1, int k2); @@ -137,7 +137,7 @@ class Menu : Object native ui version("2.4") MKEY_Clear, NUM_MKEYS, - // These are not buttons but events sent from other menus + // These are not buttons but events sent from other menus MKEY_Input, MKEY_Abort, @@ -215,7 +215,6 @@ class Menu : Object native ui version("2.4") return false; } - //============================================================================= // // @@ -253,14 +252,14 @@ class Menu : Object native ui version("2.4") //============================================================================= virtual bool OnUIEvent(UIEvent ev) - { + { bool res = false; int y = ev.MouseY; if (ev.type == UIEvent.Type_LButtonDown) { res = MouseEventBack(MOUSE_Click, ev.MouseX, y); // make the menu's mouse handler believe that the current coordinate is outside the valid range - if (res) y = -1; + if (res) y = -1; res |= MouseEvent(MOUSE_Click, ev.MouseX, y); if (res) { @@ -274,7 +273,7 @@ class Menu : Object native ui version("2.4") if (mMouseCapture || m_use_mouse == 1) { res = MouseEventBack(MOUSE_Move, ev.MouseX, y); - if (res) y = -1; + if (res) y = -1; res |= MouseEvent(MOUSE_Move, ev.MouseX, y); } } @@ -284,15 +283,15 @@ class Menu : Object native ui version("2.4") { SetCapture(false); res = MouseEventBack(MOUSE_Release, ev.MouseX, y); - if (res) y = -1; + if (res) y = -1; res |= MouseEvent(MOUSE_Release, ev.MouseX, y); } } - return false; + return false; } virtual bool OnInputEvent(InputEvent ev) - { + { return false; } @@ -302,7 +301,7 @@ class Menu : Object native ui version("2.4") // //============================================================================= - virtual void Drawer () + virtual void Drawer () { if (self == GetCurrentMenu() && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse) { @@ -377,7 +376,7 @@ class Menu : Object native ui version("2.4") return NewSmallFont; } - static int OptionHeight() + static int OptionHeight() { return OptionFont().GetHeight(); } @@ -394,7 +393,6 @@ class Menu : Object native ui version("2.4") screen.DrawText (OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay, DTA_Localize, localize); } - } class MenuDescriptor : Object native ui version("2.4") diff --git a/wadsrc/static/zscript/ui/menu/conversationmenu.zs b/wadsrc/static/zscript/ui/menu/conversationmenu.zs index 96d24da00..40645b487 100644 --- a/wadsrc/static/zscript/ui/menu/conversationmenu.zs +++ b/wadsrc/static/zscript/ui/menu/conversationmenu.zs @@ -1,9 +1,10 @@ /* -** conversationmenu.txt +** conversationmenu.zs ** The Strife dialogue display ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -66,11 +67,10 @@ struct StrifeDialogueReply native version("2.4") native int LogNumber; native bool NeedsGold; native bool CloseDialog; - + native bool ShouldSkipReply(PlayerInfo player); } - class ConversationMenu : Menu { String mSpeaker; @@ -95,12 +95,12 @@ class ConversationMenu : Menu int refwidth; int refheight; Array ypositions; - + int SpeechWidth; int ReplyWidth; - + native static void SendConversationReply(int node, int reply); - + const NUM_RANDOM_LINES = 10; const NUM_RANDOM_GOODBYES = 3; @@ -117,11 +117,11 @@ class ConversationMenu : Menu mShowGold = false; ConversationPauseTic = gametic + 20; DontDim = true; - + let tex = TexMan.CheckForTexture (CurNode.Backdrop, TexMan.Type_MiscPatch); mHasBackdrop = tex.isValid(); DontBlur = !mHasBackdrop; - + if (!generic_ui && !dlg_vgafont) { displayFont = SmallFont; @@ -158,22 +158,21 @@ class ConversationMenu : Menu SpeechWidth = speechDisplayWidth - (24*3 * CleanXfac / fontScale); mConfineTextToBackdrop = true; } - + LineHeight = displayFont.GetHeight() + 2; ReplyLineHeight = LineHeight * fontScale / CleanYfac; } - FormatSpeakerMessage(); return FormatReplies(activereply); } - + //============================================================================= // // // //============================================================================= - + virtual int FormatReplies(int activereply) { mSelection = -1; @@ -206,7 +205,7 @@ class ConversationMenu : Menu { mResponseLines.Push(ReplyLines.StringAt(j)); } - + ++i; ReplyLines.Destroy(); } @@ -242,7 +241,7 @@ class ConversationMenu : Menu } return mYpos; } - + //============================================================================= // // @@ -270,7 +269,7 @@ class ConversationMenu : Menu } mDialogueLines = displayFont.BreakLines(toSay, SpeechWidth); } - + //============================================================================= // // @@ -364,7 +363,7 @@ class ConversationMenu : Menu // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture x = ((x - (screen.GetWidth() / 2)) / fontScale) + refWidth/2; - + if (x >= 24 && x <= refWidth-24) { for (int i = 0; i < ypositions.Size()-1; i++) @@ -384,7 +383,6 @@ class ConversationMenu : Menu return true; } - //============================================================================= // // @@ -404,7 +402,7 @@ class ConversationMenu : Menu } return Super.OnUIEvent(ev); } - + //============================================================================ // // Draw the backdrop, returns true if the text background should be dimmed @@ -444,7 +442,6 @@ class ConversationMenu : Menu speakerName = players[consoleplayer].ConversationNPC.GetTag("$TXT_PERSON"); } - // Dim the screen behind the dialogue (but only if there is no backdrop). if (dimbg) { @@ -472,7 +469,6 @@ class ConversationMenu : Menu } } - //============================================================================ // // Draw the replies @@ -485,7 +481,6 @@ class ConversationMenu : Menu screen.Dim(0, 0.45, (24 - 160) * CleanXfac + screen.GetWidth() / 2, (mYpos - 2 - 100) * CleanYfac + screen.GetHeight() / 2, 272 * CleanXfac, MIN(mResponseLines.Size() * ReplyLineHeight + 4, 200 - mYpos) * CleanYfac); - int y = mYpos; int response = 0; @@ -576,8 +571,7 @@ class ConversationMenu : Menu DrawReplies(); DrawGold(); } - - + //============================================================================ // // @@ -592,5 +586,5 @@ class ConversationMenu : Menu menuactive = Menu.On; } } - + } diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen.zs b/wadsrc/static/zscript/ui/statscreen/statscreen.zs index 6603c2e06..e36750d0b 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen.zs @@ -1,3 +1,37 @@ +/* +** statscreen.zs +** +**--------------------------------------------------------------------------- +** Copyright 2010-2017 Christoph Oelckers +** Copyright 2017-2025 GZDoom Maintainers and Contributors +** 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. +**--------------------------------------------------------------------------- +** +*/ + // Note that the status screen needs to run in 'play' scope! class InterBackground native ui version("2.5") @@ -39,7 +73,6 @@ struct PatchInfo ui version("2.5") } }; - class StatusScreen : ScreenJob abstract version("2.5") { enum EValues @@ -129,13 +162,12 @@ class StatusScreen : ScreenJob abstract version("2.5") int player_deaths[MAXPLAYERS]; int sp_state; - + int cWidth, cHeight; // size of the canvas int scalemode; int wrapwidth; // size used to word wrap level names int scaleFactorX, scaleFactorY; - //==================================================================== // // Set fixed size mode. @@ -165,7 +197,7 @@ class StatusScreen : ScreenJob abstract version("2.5") else screen.DrawChar(fnt, translation, x, y, charcode, DTA_FullscreenScale, scalemode, DTA_VirtualWidth, cwidth, DTA_VirtualHeight, cheight); return x - width; } - + //==================================================================== // // @@ -201,7 +233,7 @@ class StatusScreen : ScreenJob abstract version("2.5") int DrawName(int y, TextureID tex, String levelname) { - // draw + // draw if (tex.isValid()) { let size = TexMan.GetScaledSize(tex); @@ -236,16 +268,16 @@ class StatusScreen : ScreenJob abstract version("2.5") // Draws a level author's name with the given font // //==================================================================== - + int DrawAuthor(int y, String levelname) { if (levelname.Length() > 0) { int h = 0; int lumph = author.mFont.GetHeight() * scaleFactorY; - + BrokenLines lines = author.mFont.BreakLines(levelname, wrapwidth / scaleFactorX); - + int count = lines.Count(); for (int i = 0; i < count; i++) { @@ -256,7 +288,7 @@ class StatusScreen : ScreenJob abstract version("2.5") } return y; } - + //==================================================================== // // Only kept so that mods that were accessing it continue to compile @@ -277,12 +309,12 @@ class StatusScreen : ScreenJob abstract version("2.5") // Draws a text, either as patch or as string from the string table // //==================================================================== - + int DrawPatchOrText(int y, PatchInfo pinfo, TextureID patch, String stringname) { String string = Stringtable.Localize(stringname); int midx = cwidth / 2; - + if (TexMan.OkForLocalization(patch, stringname)) { let size = TexMan.GetScaledSize(patch); @@ -295,7 +327,7 @@ class StatusScreen : ScreenJob abstract version("2.5") return y + pinfo.mFont.GetHeight() * scaleFactorY; } } - + //==================================================================== // // Draws " Finished!" @@ -310,7 +342,7 @@ class StatusScreen : ScreenJob abstract version("2.5") bool ispatch = wbs.LName0.isValid(); int oldy = TITLEY * scaleFactorY; int h; - + if (!ispatch) { let asc = mapname.mFont.GetMaxAscender(lnametexts[1]); @@ -319,11 +351,11 @@ class StatusScreen : ScreenJob abstract version("2.5") oldy = (asc+2) * scaleFactorY; } } - + int y = DrawName(oldy, wbs.LName0, lnametexts[0]); // If the displayed info is made of patches we need some additional offsetting here. - if (ispatch) + if (ispatch) { int disp = 0; // The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps. @@ -332,7 +364,7 @@ class StatusScreen : ScreenJob abstract version("2.5") int h1 = BigFont.GetHeight() - BigFont.GetDisplacement(); int h2 = (y - oldy) / scaleFactorY / 4; disp = min(h1, h2); - + if (!TexMan.OkForLocalization(finishedPatch, "$WI_FINISHED")) { disp += finishedp.mFont.GetMaxAscender("$WI_FINISHED"); @@ -344,9 +376,9 @@ class StatusScreen : ScreenJob abstract version("2.5") } y += disp * scaleFactorY; } - + y = DrawAuthor(y, authortexts[0]); - + // draw "Finished!" int statsy = multiplayer? NG_STATSY : SP_STATSY * scaleFactorY; @@ -382,9 +414,9 @@ class StatusScreen : ScreenJob abstract version("2.5") } int y = DrawPatchOrText(oldy, entering, enteringPatch, "$WI_ENTERING"); - + // If the displayed info is made of patches we need some additional offsetting here. - + if (ispatch) { int h1 = BigFont.GetHeight() - BigFont.GetDisplacement(); @@ -401,12 +433,12 @@ class StatusScreen : ScreenJob abstract version("2.5") y = DrawName(y, wbs.LName1, lnametexts[1]); - if (wbs.LName1.isValid() && authortexts[1].length() > 0) + if (wbs.LName1.isValid() && authortexts[1].length() > 0) { // Consdider the ascender height of the following text. y += author.mFont.GetMaxAscender(authortexts[1]) * scaleFactorY; } - + DrawAuthor(y, authortexts[1]); } @@ -441,7 +473,7 @@ class StatusScreen : ScreenJob abstract version("2.5") } len = text.Length(); } - + for(int text_p = len-1; text_p >= 0; text_p--) { // Digits are centered in a box the width of the '3' character. @@ -505,7 +537,6 @@ class StatusScreen : ScreenJob abstract version("2.5") } } - //==================================================================== // // Display level completion time and par, or "sucks" message if overflow. @@ -693,7 +724,7 @@ class StatusScreen : ScreenJob abstract version("2.5") protected virtual void initShowNextLoc () { - if (wbs.next == "") + if (wbs.next == "") { // Last map in episode - there is no next location! jobstate = finished; @@ -731,7 +762,7 @@ class StatusScreen : ScreenJob abstract version("2.5") bg.drawBackground(CurState, true, snl_pointeron); // draws which level you are entering.. - drawEL (); + drawEL (); } @@ -746,7 +777,7 @@ class StatusScreen : ScreenJob abstract version("2.5") snl_pointeron = true; drawShowNextLoc(); } - + //==================================================================== // // @@ -757,7 +788,7 @@ class StatusScreen : ScreenJob abstract version("2.5") { int i; int frags = 0; - + for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] @@ -766,7 +797,7 @@ class StatusScreen : ScreenJob abstract version("2.5") frags += Plrs[playernum].frags[i]; } } - + // JDC hack - negative frags. frags -= Plrs[playernum].frags[playernum]; @@ -783,8 +814,7 @@ class StatusScreen : ScreenJob abstract version("2.5") { S_StartSound(snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHANF_UI, 1, ATTN_NONE); } - - + // ==================================================================== // // Purpose: See if the player has hit either the attack or use key @@ -814,7 +844,7 @@ class StatusScreen : ScreenJob abstract version("2.5") deprecated("4.8") void checkForAccelerate() { } - + // ==================================================================== // Ticker // Purpose: Do various updates every gametic, for stats, animation, @@ -823,7 +853,7 @@ class StatusScreen : ScreenJob abstract version("2.5") // Returns: void // // ==================================================================== - + virtual void StartMusic() { if (!bg.IsUsingMusic()) @@ -839,25 +869,25 @@ class StatusScreen : ScreenJob abstract version("2.5") protected virtual void Ticker() { // counter for general background animation - bcnt++; - + bcnt++; + if (bcnt == 1) { StartMusic(); } - + bg.updateAnimatedBack(); - + switch (CurState) { case StatCount: updateStats(); break; - + case ShowNextLoc: updateShowNextLoc(); break; - + case NoState: updateNoState(); break; @@ -866,7 +896,7 @@ class StatusScreen : ScreenJob abstract version("2.5") break; } } - + override void OnTick() { Ticker(); @@ -888,12 +918,12 @@ class StatusScreen : ScreenJob abstract version("2.5") bg.drawBackground(CurState, false, false); drawStats(); break; - + case ShowNextLoc: case LeavingIntermission: // this must still draw the screen once more for the wipe code to pick up. drawShowNextLoc(); break; - + default: drawNoState(); break; @@ -930,7 +960,7 @@ class StatusScreen : ScreenJob abstract version("2.5") wbs.partime = 0; wbs.sucktime = 0; } - + entering.Init(gameinfo.mStatscreenEnteringFont); finishedp.Init(gameinfo.mStatscreenFinishedFont); mapname.Init(gameinfo.mStatscreenMapNameFont); @@ -947,7 +977,7 @@ class StatusScreen : ScreenJob abstract version("2.5") enteringPatch = TexMan.CheckForTexture("WIENTER", TexMan.Type_MiscPatch); // "entering" finishedPatch = TexMan.CheckForTexture("WIF", TexMan.Type_MiscPatch); // "finished" - lnametexts[0] = StringTable.Localize(wbstartstruct.thisname); + lnametexts[0] = StringTable.Localize(wbstartstruct.thisname); lnametexts[1] = StringTable.Localize(wbstartstruct.nextname); authortexts[0] = StringTable.Localize(wbstartstruct.thisauthor); authortexts[1] = StringTable.Localize(wbstartstruct.nextauthor); @@ -955,14 +985,14 @@ class StatusScreen : ScreenJob abstract version("2.5") bg = InterBackground.Create(wbs); noautostartmap = bg.LoadBackground(false); initStats(); - + wrapwidth = cwidth = screen.GetWidth(); cheight = screen.GetHeight(); scalemode = -1; scaleFactorX = CleanXfac; scaleFactorY = CleanYfac; } - + protected virtual void initStats() {} protected virtual void updateStats() {} protected virtual void drawStats() {}