diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 808462fd3..800995c39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -621,7 +621,6 @@ set( PLAT_WIN32_SOURCES win32/i_rawps2.cpp win32/i_xinput.cpp win32/i_main.cpp - win32/i_movie.cpp win32/i_system.cpp win32/i_specialpaths.cpp win32/st_start.cpp @@ -629,7 +628,6 @@ set( PLAT_WIN32_SOURCES win32/win32video.cpp ) set( PLAT_POSIX_SOURCES posix/i_cd.cpp - posix/i_movie.cpp posix/i_steam.cpp ) set( PLAT_SDL_SOURCES posix/sdl/crashcatcher.c diff --git a/src/actor.h b/src/actor.h index 08684bde1..00532fb65 100644 --- a/src/actor.h +++ b/src/actor.h @@ -424,6 +424,7 @@ enum ActorRenderFlag RF_MASKROTATION = 0x00200000, // [MC] Only draw the actor when viewed from a certain angle range. RF_ABSMASKANGLE = 0x00400000, // [MC] The mask rotation does not offset by the actor's angle. RF_ABSMASKPITCH = 0x00800000, // [MC] The mask rotation does not offset by the actor's pitch. + RF_INTERPOLATEANGLES = 0x01000000, // [MC] Allow interpolation of the actor's angle, pitch and roll. RF_FORCEYBILLBOARD = 0x10000, // [BB] OpenGL only: draw with y axis billboard, i.e. anchored to the floor (overrides gl_billboard_mode setting) RF_FORCEXYBILLBOARD = 0x20000, // [BB] OpenGL only: draw with xy axis billboard, i.e. unanchored (overrides gl_billboard_mode setting) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 46ab072f2..7428fceea 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1190,7 +1190,7 @@ static void PrintSecretString(const char *string, bool thislevel) { if (string[1] == 'S' || string[1] == 's') { - auto secnum = strtoul(string+2, (char**)&string, 10); + auto secnum = (unsigned)strtoull(string+2, (char**)&string, 10); if (*string == ';') string++; if (thislevel && secnum < level.sectors.Size()) { @@ -1201,7 +1201,7 @@ static void PrintSecretString(const char *string, bool thislevel) } else if (string[1] == 'T' || string[1] == 't') { - long tid = strtol(string+2, (char**)&string, 10); + long tid = (long)strtoll(string+2, (char**)&string, 10); if (*string == ';') string++; FActorIterator it(tid); AActor *actor; diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index fe859cb49..82be8663e 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -200,7 +200,7 @@ bool FBaseCVar::ToBool (UCVarValue value, ECVarType type) else if (stricmp (value.String, "false") == 0) return false; else - return !!strtol (value.String, NULL, 0); + return !!strtoll (value.String, NULL, 0); case CVAR_GUID: return false; @@ -233,7 +233,7 @@ int FBaseCVar::ToInt (UCVarValue value, ECVarType type) else if (stricmp (value.String, "false") == 0) res = 0; else - res = strtol (value.String, NULL, 0); + res = (int)strtoll (value.String, NULL, 0); break; } case CVAR_GUID: res = 0; break; @@ -458,7 +458,7 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) else if (stricmp (value, "false") == 0) ret.Bool = false; else - ret.Bool = strtol (value, NULL, 0) != 0; + ret.Bool = strtoll (value, NULL, 0) != 0; break; case CVAR_Int: @@ -467,7 +467,7 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) else if (stricmp (value, "false") == 0) ret.Int = 0; else - ret.Int = strtol (value, NULL, 0); + ret.Int = (int)strtoll (value, NULL, 0); break; case CVAR_Float: @@ -1617,8 +1617,16 @@ void C_ArchiveCVars (FConfigFile *f, uint32 filter) } } +EXTERN_CVAR(Bool, sv_cheats); + void FBaseCVar::CmdSet (const char *newval) { + if ((GetFlags() & CVAR_CHEAT) && !sv_cheats) + { + Printf("sv_cheats must be true to set this console variable.\n"); + return; + } + UCVarValue val; // Casting away the const is safe in this case. diff --git a/src/c_cvars.h b/src/c_cvars.h index cf6975b86..98dc71915 100644 --- a/src/c_cvars.h +++ b/src/c_cvars.h @@ -63,6 +63,7 @@ enum CVAR_NOSAVE = 4096, // when used with CVAR_SERVERINFO, do not save var to savegame CVAR_MOD = 8192, // cvar was defined by a mod CVAR_IGNORE = 16384,// do not send cvar across the network/inaccesible from ACS (dummy mod cvar) + CVAR_CHEAT = 32768,// can be set only when sv_cheats is enabled }; union UCVarValue diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 296697ee7..52ea3d63a 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -705,7 +705,7 @@ void AddCommandString (char *cmd, int keynum) if (cmd[4] == ' ') { - tics = strtol (cmd + 5, NULL, 0); + tics = (int)strtoll (cmd + 5, NULL, 0); } else { diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 312333676..7fecec550 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -885,7 +885,7 @@ static int PatchThing (int thingy) while ((result = GetLine ()) == 1) { char *endptr; - unsigned long val = strtoul (Line2, &endptr, 10); + unsigned long val = (unsigned long)strtoull (Line2, &endptr, 10); size_t linelen = strlen (Line1); if (linelen == 10 && stricmp (Line1, "Hit points") == 0) @@ -1064,11 +1064,7 @@ static int PatchThing (int thingy) { if (IsNum (strval)) { - // I have no idea why everyone insists on using strtol here even though it fails - // dismally if a value is parsed where the highest bit it set. Do people really - // use negative values here? Let's better be safe and check both. - if (strchr(strval, '-')) value[0] |= (unsigned long)strtol(strval, NULL, 10); - else value[0] |= (unsigned long)strtoul(strval, NULL, 10); + value[0] |= (unsigned long)strtoll(strval, NULL, 10); vchanged[0] = true; } else diff --git a/src/d_main.cpp b/src/d_main.cpp index a0456d6a0..5b091a6ac 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1069,6 +1069,7 @@ void D_PageTicker (void) void D_PageDrawer (void) { + screen->Clear(0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0); if (Page != NULL) { screen->DrawTexture (Page, 0, 0, @@ -1076,11 +1077,9 @@ void D_PageDrawer (void) DTA_Masked, false, DTA_BilinearFilter, true, TAG_DONE); - screen->FillBorder (NULL); } else { - screen->Clear (0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0); if (!PageBlank) { screen->DrawText (SmallFont, CR_WHITE, 0, 0, "Page graphic goes here", TAG_DONE); @@ -1405,6 +1404,10 @@ void ParseCVarInfo() { cvarflags &= ~CVAR_ARCHIVE; } + else if (stricmp(sc.String, "cheat") == 0) + { + cvarflags |= CVAR_CHEAT; + } else { sc.ScriptError("Unknown cvar attribute '%s'", sc.String); @@ -2714,6 +2717,7 @@ void D_DoomMain (void) S_Shutdown(); // free all channels and delete playlist C_ClearAliases(); // CCMDs won't be reinitialized so these need to be deleted here DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods + FS_Close(); // destroy the global FraggleScript. GC::FullGC(); // clean up before taking down the object list. diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 313ee7389..7468b6dab 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -69,6 +69,7 @@ FNamespaceManager Namespaces; FTypeTable TypeTable; TArray PClass::AllClasses; +TArray PClass::FunctionPtrList; bool PClass::bShutdown; bool PClass::bVMOperational; @@ -2840,6 +2841,12 @@ void PClass::StaticShutdown () TArray uniqueFPs(64); unsigned int i, j; + // delete all variables containing pointers to script functions. + for (auto p : FunctionPtrList) + { + *p = nullptr; + } + FunctionPtrList.Clear(); // Make a full garbage collection here so that all destroyed but uncollected higher level objects that still exist can be properly taken down. GC::FullGC(); @@ -3547,6 +3554,16 @@ VMFunction *PClass::FindFunction(FName clsname, FName funcname) return func->Variants[0].Implementation; } +void PClass::FindFunction(VMFunction **pptr, FName clsname, FName funcname) +{ + auto cls = PClass::FindActor(clsname); + if (!cls) return; + auto func = dyn_cast(cls->Symbols.FindSymbol(funcname, true)); + if (!func) return; + *pptr = func->Variants[0].Implementation; + FunctionPtrList.Push(pptr); +} + /* FTypeTable **************************************************************/ diff --git a/src/dobjtype.h b/src/dobjtype.h index 632ef96bb..2726ebff1 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -848,9 +848,11 @@ public: static PClassActor *FindActor(ENamedName name) { return FindActor(FName(name)); } static PClassActor *FindActor(FName name); static VMFunction *FindFunction(FName cls, FName func); + static void FindFunction(VMFunction **pptr, FName cls, FName func); PClass *FindClassTentative(FName name); static TArray AllClasses; + static TArray FunctionPtrList; static bool bShutdown; static bool bVMOperational; diff --git a/src/fragglescript/t_cmd.cpp b/src/fragglescript/t_cmd.cpp index 691740024..5101d0034 100644 --- a/src/fragglescript/t_cmd.cpp +++ b/src/fragglescript/t_cmd.cpp @@ -192,7 +192,7 @@ void FS_EmulateCmd(char * string) else if (sc.Compare("gr_fogcolor")) { sc.MustGetString(); - level.fadeto = strtol(sc.String, NULL, 16); + level.fadeto = (uint32_t)strtoull(sc.String, NULL, 16); } else diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index cd4d02f04..fc35d2da4 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -522,7 +522,7 @@ DEFINE_ACTION_FUNCTION(AInventory, DoRespawn) bool AInventory::CallTryPickup(AActor *toucher, AActor **toucher_return) { static VMFunction *func = nullptr; - if (func == nullptr) func = PClass::FindFunction(NAME_Inventory, NAME_CallTryPickup); + if (func == nullptr) PClass::FindFunction(&func, NAME_Inventory, NAME_CallTryPickup); VMValue params[2] = { (DObject*)this, toucher }; VMReturn ret[2]; int res; diff --git a/src/g_level.cpp b/src/g_level.cpp index 8b9e8d37e..c34a80bb7 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1114,7 +1114,7 @@ void G_WorldDone (void) if (strncmp (nextlevel, "enDSeQ", 6) == 0) { - FName endsequence = ENamedName(strtol(nextlevel.GetChars()+6, NULL, 16)); + FName endsequence = ENamedName(strtoll(nextlevel.GetChars()+6, NULL, 16)); // Strife needs a special case here to choose between good and sad ending. Bad is handled elsewhere. if (endsequence == NAME_Inter_Strife) { diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index 5e12bf9d0..c3950571f 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -1437,7 +1437,7 @@ class CommandDrawNumber : public CommandDrawString { // num = statusBar.CPlayer.mo.GetEffectTicsForItem(inventoryItem) / TICRATE + 1; static VMFunction *func = nullptr; - if (func == nullptr) func = PClass::FindFunction(NAME_PlayerPawn, "GetEffectTicsForItem"); + if (func == nullptr) PClass::FindFunction(&func, NAME_PlayerPawn, "GetEffectTicsForItem"); VMValue params[] = { statusBar->CPlayer->mo, inventoryItem }; int retv; VMReturn ret(&retv); @@ -2830,7 +2830,7 @@ class CommandDrawBar : public SBarInfoCommand // [value, max] = statusBar.CPlayer.mo.GetEffectTicsForItem(inventoryItem); // value++; max++; static VMFunction *func = nullptr; - if (func == nullptr) func = PClass::FindFunction(NAME_PlayerPawn, "GetEffectTicsForItem"); + if (func == nullptr) PClass::FindFunction(&func, NAME_PlayerPawn, "GetEffectTicsForItem"); VMValue params[] = { statusBar->CPlayer->mo, data.inventoryItem }; VMReturn ret[2]; int ival; diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index d386428a2..bb73ad3ae 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -413,7 +413,7 @@ void InitGLRMapinfoData() if (opt != NULL) { - gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog); + gl_SetFogParams(clamp(opt->fogdensity, 0, 255), level.info->outsidefog, clamp(opt->outsidefogdensity, 0, 255), opt->skyfog); glset.map_lightmode = opt->lightmode; glset.map_lightadditivesurfaces = opt->lightadditivesurfaces; glset.map_attenuate = opt->attenuate; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 770ea1e50..1255401ae 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -266,7 +266,7 @@ void ADynamicLight::Tick() case FlickerLight: { - BYTE rnd = randLight(); + int rnd = randLight(); float pct = specialf1 / 360.f; m_currentRadius = float(args[LIGHT_INTENSITY + (rnd >= pct * 255)]); @@ -293,7 +293,7 @@ void ADynamicLight::Tick() // These need some more work elsewhere case ColorFlickerLight: { - BYTE rnd = randLight(); + int rnd = randLight(); float pct = specialf1/360.f; m_currentRadius = m_Radius[rnd >= pct * 255]; @@ -391,7 +391,7 @@ void ADynamicLight::UpdateLocation() intensity = m_currentRadius; } radius = intensity * 2.0f; - assert(radius >= m_currentRadius * 2); + if (radius < m_currentRadius * 2) radius = m_currentRadius * 2; if (X() != oldx || Y() != oldy || radius != oldradius) { diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index c4bef2051..7a548eaa2 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -126,8 +126,8 @@ public: void ApplyProperties(ADynamicLight * light) const; FName GetName() const { return m_Name; } void SetParameter(double p) { m_Param = p; } - void SetArg(int arg, BYTE val) { m_Args[arg] = val; } - BYTE GetArg(int arg) { return m_Args[arg]; } + void SetArg(int arg, int val) { m_Args[arg] = val; } + int GetArg(int arg) { return m_Args[arg]; } uint8_t GetAttenuate() const { return m_attenuate; } void SetOffset(float* ft) { m_Pos.X = ft[0]; m_Pos.Z = ft[1]; m_Pos.Y = ft[2]; } void SetSubtractive(bool subtract) { m_subtractive = subtract; } @@ -648,7 +648,7 @@ void gl_ParseFlickerLight2(FScanner &sc) } if (defaults->GetArg(LIGHT_SECONDARY_INTENSITY) < defaults->GetArg(LIGHT_INTENSITY)) { - BYTE v = defaults->GetArg(LIGHT_SECONDARY_INTENSITY); + int v = defaults->GetArg(LIGHT_SECONDARY_INTENSITY); defaults->SetArg(LIGHT_SECONDARY_INTENSITY, defaults->GetArg(LIGHT_INTENSITY)); defaults->SetArg(LIGHT_INTENSITY, v); } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index ce6b22ee8..47283b51a 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -38,6 +38,7 @@ #include "r_state.h" #include "d_player.h" #include "g_levellocals.h" +#include "r_utility.h" //#include "resources/voxels.h" //#include "gl/gl_intern.h" @@ -1010,6 +1011,13 @@ void gl_RenderModel(GLSprite * spr) // Model space => World space gl_RenderState.mModelMatrix.translate(spr->x, spr->z, spr->y ); + + if (spr->actor->renderflags & RF_INTERPOLATEANGLES) + { + // [Nash] use interpolated angles + DRotator Angles = spr->actor->InterpolatedAngles(r_TicFracF); + angle = Angles.Yaw.Degrees; + } // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index ae7f2a80d..b4912f825 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -552,7 +552,7 @@ CCMD(skyfog) { if (argv.argc()>1) { - skyfog=strtol(argv[1],NULL,0); + skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0)); } } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2de711398..5e8bdb560 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -738,7 +738,11 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) int clipres = GLRenderer->mClipPortal->ClipPoint(thingpos); if (clipres == GLPortal::PClip_InFront) return; } - Angles = thing->InterpolatedAngles(r_TicFracF); + // disabled because almost none of the actual game code is even remotely prepared for this. If desired, use the INTERPOLATE flag. + if (thing->renderflags & RF_INTERPOLATEANGLES) + Angles = thing->InterpolatedAngles(r_TicFracF); + else + Angles = thing->Angles; player_t *player = &players[consoleplayer]; FloatRect r; diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 68a2b06e5..2377029c2 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -40,6 +40,8 @@ #include #define USE_WINDOWS_DWORD +#elif defined __APPLE__ +#include #endif #include "i_system.h" @@ -114,6 +116,15 @@ void gl_CalculateCPUSpeed () gl_SecondsPerCycle = 1.0 / CyclesPerSecond; gl_MillisecPerCycle = 1000.0 / CyclesPerSecond; } + #elif defined __APPLE__ + long long frequency; + size_t size = sizeof frequency; + + if (0 == sysctlbyname("machdep.tsc.frequency", &frequency, &size, nullptr, 0) && 0 != frequency) + { + gl_SecondsPerCycle = 1.0 / frequency; + gl_MillisecPerCycle = 1000.0 / frequency; + } #endif } diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h index 4d5163d86..2ccda639a 100644 --- a/src/gl/utility/gl_clock.h +++ b/src/gl/utility/gl_clock.h @@ -7,11 +7,11 @@ extern bool gl_benching; -#ifdef _MSC_VER - extern double gl_SecondsPerCycle; extern double gl_MillisecPerCycle; +#ifdef _MSC_VER + __forceinline long long GetClockCycle () { #if _M_X64 @@ -21,10 +21,14 @@ __forceinline long long GetClockCycle () #endif } -#elif defined(__GNUG__) && defined(__i386__) +#elif defined __APPLE__ && (defined __i386__ || defined __x86_64__) -extern double gl_SecondsPerCycle; -extern double gl_MillisecPerCycle; +inline long long GetClockCycle() +{ + return __builtin_ia32_rdtsc(); +} + +#elif defined(__GNUG__) && defined(__i386__) inline long long GetClockCycle() { @@ -42,21 +46,12 @@ inline long long GetClockCycle() #else -extern double gl_SecondsPerCycle; -extern double gl_MillisecPerCycle; - inline long long GetClockCycle () { return 0; } #endif -#if defined (__APPLE__) - -typedef cycle_t glcycle_t; - -#else // !__APPLE__ - class glcycle_t { public: @@ -100,8 +95,6 @@ private: long long Counter; }; -#endif // __APPLE__ - extern glcycle_t RenderWall,SetupWall,ClipWall; extern glcycle_t RenderFlat,SetupFlat; extern glcycle_t RenderSprite,SetupSprite; @@ -122,4 +115,4 @@ void CheckBench(); void checkBenchActive(); -#endif \ No newline at end of file +#endif diff --git a/src/i_movie.h b/src/i_movie.h deleted file mode 100644 index 9aa375d35..000000000 --- a/src/i_movie.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** i_movie.h -** Defines the movie-related stuff -** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** 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. -**--------------------------------------------------------------------------- -** -*/ - -#ifndef __I_MOVIE_H__ -#define __I_MOVIE_H__ - -#ifdef _MSC_VER -#pragma once -#endif - -int I_PlayMovie (const char *movieName); - -enum -{ - MOVIE_Played = 0, - MOVIE_Played_NoVideo = 1, - MOVIE_Played_Aborted = 2, - MOVIE_Failed = -1, -}; - -#endif //__I_MOVIE_H__ diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 958f1a168..820e7539f 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -485,7 +485,7 @@ void cht_DoCheat (player_t *player, int cheat) if (player->mo != NULL && player->health >= 0) { static VMFunction *gsp = nullptr; - if (gsp == nullptr) gsp = PClass::FindFunction(NAME_Sigil, NAME_GiveSigilPiece); + if (gsp == nullptr) PClass::FindFunction(&gsp, NAME_Sigil, NAME_GiveSigilPiece); if (gsp) { VMValue params[1] = { player->mo }; diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 0c6019a5f..a3e7532f9 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -65,7 +65,7 @@ CVAR (Bool, show_obituaries, true, CVAR_ARCHIVE) CVAR (Float, snd_menuvolume, 0.6f, CVAR_ARCHIVE) -CVAR(Int, m_use_mouse, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Int, m_use_mouse, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Int, m_show_backbutton, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) DMenu *DMenu::CurrentMenu; diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index d09cb40b6..f684a8bab 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -666,7 +666,7 @@ static EColorRange ParseOptionColor(FScanner &sc, FOptionMenuDescriptor *desc) cr = V_FindFontColor(sc.String); if (cr == CR_UNTRANSLATED && !sc.Compare("untranslated") && isdigit(sc.String[0])) { - if (strtol(sc.String, NULL, 0)) cr = OptionSettings.mFontColorHeader; + if (strtoll(sc.String, NULL, 0)) cr = OptionSettings.mFontColorHeader; } } return cr; diff --git a/src/menu/videomenu.cpp b/src/menu/videomenu.cpp index d8edee8f1..29192a60b 100644 --- a/src/menu/videomenu.cpp +++ b/src/menu/videomenu.cpp @@ -366,8 +366,8 @@ static bool GetSelectedSize (int *width, int *height) char *breakpt; if (it->GetString(FOptionMenuScreenResolutionLine::SRL_INDEX+hsel, buffer, sizeof(buffer))) { - *width = strtol (buffer, &breakpt, 10); - *height = strtol (breakpt+1, NULL, 10); + *width = (int)strtoll (buffer, &breakpt, 10); + *height = (int)strtoll (breakpt+1, NULL, 10); return true; } } diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 77e34adba..f367c4637 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -982,7 +982,12 @@ CCMD (dump3df) { if (argv.argc() > 1) { - int sec = strtol(argv[1], NULL, 10); + int sec = (int)strtoll(argv[1], NULL, 10); + if ((unsigned)sec >= level.sectors.Size()) + { + Printf("Sector %d does not exist.\n", sec); + return; + } sector_t *sector = &level.sectors[sec]; TArray & ffloors=sector->e->XFloor.ffloors; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 24142e0ec..bddcd7f95 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -54,7 +54,6 @@ #include "c_dispatch.h" #include "s_sndseq.h" #include "i_system.h" -#include "i_movie.h" #include "sbar.h" #include "m_swap.h" #include "a_sharedglobal.h" @@ -1086,12 +1085,12 @@ static void ReadArrayVars (FSerializer &file, FWorldGlobalArray *vars, size_t co const char *arraykey; while ((arraykey = file.GetKey())) { - int i = (int)strtol(arraykey, nullptr, 10); + int i = (int)strtoll(arraykey, nullptr, 10); if (file.BeginObject(nullptr)) { while ((arraykey = file.GetKey())) { - int k = (int)strtol(arraykey, nullptr, 10); + int k = (int)strtoll(arraykey, nullptr, 10); int val; file(nullptr, val); vars[i].Insert(k, val); @@ -6203,7 +6202,7 @@ static bool CharArrayParms(int &capacity, int &offset, int &a, int *Stack, int & static void SetMarineWeapon(AActor *marine, int weapon) { static VMFunction *smw = nullptr; - if (smw == nullptr) smw = PClass::FindFunction(NAME_ScriptedMarine, NAME_SetWeapon); + if (smw == nullptr) PClass::FindFunction(&smw, NAME_ScriptedMarine, NAME_SetWeapon); if (smw) { VMValue params[2] = { marine, weapon }; @@ -6214,7 +6213,7 @@ static void SetMarineWeapon(AActor *marine, int weapon) static void SetMarineSprite(AActor *marine, PClassActor *source) { static VMFunction *sms = nullptr; - if (sms == nullptr) sms = PClass::FindFunction(NAME_ScriptedMarine, NAME_SetSprite); + if (sms == nullptr) PClass::FindFunction(&sms, NAME_ScriptedMarine, NAME_SetSprite); if (sms) { VMValue params[2] = { marine, source }; @@ -8801,7 +8800,7 @@ scriptwait: break; case PCD_PLAYMOVIE: - STACK(1) = I_PlayMovie (FBehavior::StaticLookupString (STACK(1))); + STACK(1) = -1; break; case PCD_SETACTORPOSITION: diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index e93f41ce5..2926e4e8c 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2049,7 +2049,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) } } - if (self->target) + if (self->target && self->SeeState) { self->SetState (self->SeeState); } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index ce2662513..875d3fbc0 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2541,7 +2541,7 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps case Sector_Set3DFloor: if (msd->toptexture[0]=='#') { - sd->SetTexture(side_t::top, FNullTextureID() +(-strtol(&msd->toptexture[1], NULL, 10))); // store the alpha as a negative texture index + sd->SetTexture(side_t::top, FNullTextureID() +(int)(-strtoll(&msd->toptexture[1], NULL, 10))); // store the alpha as a negative texture index // This will be sorted out by the 3D-floor code later. } else @@ -2979,6 +2979,15 @@ static bool P_VerifyBlockMap(int count) break; } + // there's some node builder which carelessly removed the initial 0-entry. + // Rather than second-guessing the intent, let's just discard such blockmaps entirely + // to be on the safe side. + if (*list != 0) + { + Printf(PRINT_HIGH, "P_VerifyBlockMap: first entry is not 0.\n"); + return false; + } + // scan the list for out-of-range linedef indicies in list for(tmplist = list; *tmplist != -1; tmplist++) { @@ -3426,6 +3435,17 @@ void P_FreeLevelData () { // [ZZ] delete per-map event handlers E_Shutdown(true); + MapThingsConverted.Clear(); + MapThingsUserDataIndex.Clear(); + MapThingsUserData.Clear(); + linemap.Clear(); + FCanvasTextureInfo::EmptyList(); + R_FreePastViewers(); + P_ClearUDMFKeys(); + + // [RH] Clear all ThingID hash chains. + AActor::ClearTIDHashes(); + P_FreeMapDataBackup(); interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level. Renderer->CleanLevelData(); @@ -3578,14 +3598,6 @@ void P_SetupLevel (const char *lumpname, int position) level.maptype = MAPTYPE_UNKNOWN; wminfo.partime = 180; - MapThingsConverted.Clear(); - MapThingsUserDataIndex.Clear(); - MapThingsUserData.Clear(); - linemap.Clear(); - FCanvasTextureInfo::EmptyList (); - R_FreePastViewers (); - P_ClearUDMFKeys(); - if (!savegamerestore) { for (i = 0; i < MAXPLAYERS; ++i) @@ -3615,8 +3627,6 @@ void P_SetupLevel (const char *lumpname, int position) // Make sure all sounds are stopped before Z_FreeTags. S_Start (); - // [RH] Clear all ThingID hash chains. - AActor::ClearTIDHashes (); // [RH] clear out the mid-screen message C_MidPrint (NULL, NULL); diff --git a/src/p_states.cpp b/src/p_states.cpp index 09591d70f..221ff6ced 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -731,7 +731,7 @@ FState *FStateDefinitions::ResolveGotoLabel (AActor *actor, PClassActor *mytype, *pt = '\0'; offset = pt + 1; } - v = offset ? strtol (offset, NULL, 0) : 0; + v = offset ? (int)strtoll (offset, NULL, 0) : 0; // Get the state's address. if (type == mytype) diff --git a/src/parsecontext.cpp b/src/parsecontext.cpp index 2cfaafa29..cdc28c15a 100644 --- a/src/parsecontext.cpp +++ b/src/parsecontext.cpp @@ -103,7 +103,7 @@ loop: c = *sourcep++; if (c == 'x' || c == 'X') { - yylval->val = (int)strtol(sourcep, &sourcep, 16); + yylval->val = (int)strtoll(sourcep, &sourcep, 16); return TokenTrans[NUM]; } else @@ -114,7 +114,7 @@ loop: char *endp; sourcep--; - yylval->val = (int)strtol(sourcep, &endp, 10); + yylval->val = (int)strtoll(sourcep, &endp, 10); if (*endp == '.') { // It's a float diff --git a/src/posix/cocoa/i_system.mm b/src/posix/cocoa/i_system.mm index 2e27a8002..35b71c64b 100644 --- a/src/posix/cocoa/i_system.mm +++ b/src/posix/cocoa/i_system.mm @@ -36,6 +36,7 @@ #include #include #include +#include #include "d_ticcmd.h" #include "doomdef.h" @@ -98,9 +99,29 @@ void SetLanguageIDs() void I_InitTimer(); void I_ShutdownTimer(); +double PerfToSec, PerfToMillisec; + +static void CalculateCPUSpeed() +{ + long long frequency; + size_t size = sizeof frequency; + + if (0 == sysctlbyname("machdep.tsc.frequency", &frequency, &size, nullptr, 0) && 0 != frequency) + { + PerfToSec = 1.0 / frequency; + PerfToMillisec = 1000.0 / frequency; + + if (!batchrun) + { + Printf("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec); + } + } +} + void I_Init(void) { CheckCPUID(&CPU); + CalculateCPUSpeed(); DumpCPUInfo(&CPU); atterm(I_ShutdownSound); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 2ee7458a8..637ca0d7f 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -534,6 +534,9 @@ CocoaVideo::CocoaVideo() { memset(&m_modeIterator, 0, sizeof m_modeIterator); + extern void gl_CalculateCPUSpeed(); + gl_CalculateCPUSpeed(); + // Create OpenGL pixel format NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(OpenGLProfile::Core); diff --git a/src/posix/i_movie.cpp b/src/posix/i_movie.cpp deleted file mode 100644 index 8aea4b500..000000000 --- a/src/posix/i_movie.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "i_movie.h" - -int I_PlayMovie (const char *movie) -{ - return MOVIE_Failed; -} - diff --git a/src/r_defs.h b/src/r_defs.h index b888864b4..08c27bfd3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -239,7 +239,7 @@ struct FUDMFKey FUDMFKey& operator =(const FString &val) { Type = UDMF_String; - IntVal = strtol(val.GetChars(), NULL, 0); + IntVal = (int)strtoll(val.GetChars(), NULL, 0); FloatVal = strtod(val.GetChars(), NULL); StringVal = val; return *this; diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 5f944735a..70bdabd76 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -554,12 +554,12 @@ bool FScanner::GetToken () String[StringLen - 2] == 'u' || String[StringLen - 2] == 'U') { TokenType = TK_UIntConst; - Number = strtoul(String, &stopper, 0); + Number = (int)strtoull(String, &stopper, 0); Float = (unsigned)Number; } else { - Number = strtol(String, &stopper, 0); + Number = (int)strtoll(String, &stopper, 0); Float = Number; } } @@ -660,7 +660,7 @@ bool FScanner::GetNumber () } else { - Number = strtol (String, &stopper, 0); + Number = (int)strtoll (String, &stopper, 0); if (*stopper != 0) { ScriptError ("SC_GetNumber: Bad numeric constant \"%s\".", String); @@ -715,7 +715,7 @@ bool FScanner::CheckNumber () } else { - Number = strtol (String, &stopper, 0); + Number = (int)strtoll (String, &stopper, 0); if (*stopper != 0) { UnGet(); diff --git a/src/scripting/decorate/olddecorations.cpp b/src/scripting/decorate/olddecorations.cpp index 1eeed5796..5861138d6 100644 --- a/src/scripting/decorate/olddecorations.cpp +++ b/src/scripting/decorate/olddecorations.cpp @@ -635,7 +635,7 @@ static void ParseSpriteFrames (PClassActor *info, TArray &states, TArray char *stop; *colon = 0; - rate = strtol (token, &stop, 10); + rate = (int)strtoll (token, &stop, 10); if (stop == token || rate < 1 || rate > 65534) { sc.ScriptError ("Rates must be in the range [0,65534]"); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index d349691c6..e15792df6 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -326,6 +326,7 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, ABSMASKPITCH, AActor, renderflags), DEFINE_FLAG(RF, XFLIP, AActor, renderflags), DEFINE_FLAG(RF, YFLIP, AActor, renderflags), + DEFINE_FLAG(RF, INTERPOLATEANGLES, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), diff --git a/src/scripting/zscript/ast.cpp b/src/scripting/zscript/ast.cpp index 586601890..c4c8a12a5 100644 --- a/src/scripting/zscript/ast.cpp +++ b/src/scripting/zscript/ast.cpp @@ -346,6 +346,16 @@ static void PrintProperty(FLispString &out, ZCC_TreeNode *node) out.Close(); } +static void PrintStaticArrayState(FLispString &out, ZCC_TreeNode *node) +{ + auto *snode = (ZCC_StaticArrayStatement *)node; + out.Break(); + out.Open("static-array"); + out.AddName(snode->Id); + PrintNodes(out, snode->Values, false, true); + out.Close(); +} + static void PrintEnum(FLispString &out, ZCC_TreeNode *node) { ZCC_Enum *enode = (ZCC_Enum *)node; @@ -944,6 +954,7 @@ void (* const TreeNodePrinter[NUM_AST_NODE_TYPES])(FLispString &, ZCC_TreeNode * PrintVectorInitializer, PrintDeclFlags, PrintExprClassCast, + PrintStaticArrayState, PrintProperty, }; diff --git a/src/stats.cpp b/src/stats.cpp index c57b32640..237436c41 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -42,15 +42,6 @@ #include "m_swap.h" #include "sbar.h" - -#if defined (__APPLE__) - -mach_timebase_info_data_t cycle_t::s_info; -bool cycle_t::s_initialized; - -#endif // __APPLE__ - - FStat *FStat::FirstStat; FStat::FStat (const char *name) diff --git a/src/stats.h b/src/stats.h index d90efa7e4..f18159616 100644 --- a/src/stats.h +++ b/src/stats.h @@ -36,78 +36,7 @@ #include "zstring.h" -#ifndef _WIN32 - -#if defined (__APPLE__) - - -#include - - -class cycle_t -{ -public: - cycle_t() - { - if ( !s_initialized ) - { - mach_timebase_info( &s_info ); - s_initialized = true; - } - - Reset(); - } - - cycle_t &operator=( const cycle_t &other ) - { - if ( &other != this ) - { - m_seconds = other.m_seconds; - - } - - return *this; - } - - void Reset() - { - m_seconds = 0; - } - - void Clock() - { - m_seconds -= Nanoseconds() * 1e-9; - } - - void Unclock() - { - m_seconds += Nanoseconds() * 1e-9; - } - - double Time() - { - return m_seconds; - } - - double TimeMS() - { - return m_seconds * 1e3; - } - -private: - double m_seconds; - - static mach_timebase_info_data_t s_info; - static bool s_initialized; - - uint64_t Nanoseconds() const - { - return mach_absolute_time() * s_info.numer / s_info.denom; - } - -}; - -#else // !__APPLE__ +#if !defined _WIN32 && !defined __APPLE__ #ifdef NO_CLOCK_GETTIME class cycle_t @@ -171,11 +100,9 @@ private: #endif -#endif // __APPLE__ - #else -// Windows +// Windows and macOS #include "x86.h" extern double PerfToSec, PerfToMillisec; @@ -199,15 +126,19 @@ inline unsigned __int64 rdtsc() #else inline unsigned long long rdtsc() { -#ifndef __amd64__ +#ifdef __amd64__ + unsigned long long tsc; + asm volatile ("rdtsc; shlq $32, %%rdx; orq %%rdx, %%rax" : "=a" (tsc) :: "%rdx"); + return tsc; +#else // i386 if (CPU.bRDTSC) -#endif { - register unsigned long long tsc; + unsigned long long tsc; asm volatile ("\trdtsc\n" : "=A" (tsc)); return tsc; } return 0; +#endif // __amd64__ } #endif diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 4d758783e..789eacd98 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1706,7 +1706,6 @@ void D3DFB::NewRefreshRate () void D3DFB::Blank () { - // Only used by movie player, which isn't working with D3D9 yet. } void D3DFB::SetBlendingRect(int x1, int y1, int x2, int y2) diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index 4a0a1b160..5c1678c5c 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -2731,7 +2731,7 @@ static bool ReadResponse (HWND hDlg, char *header, SOCKET sock, char *buf, int b char *lenhead = strstr (header, "content-length: "); if (lenhead != 0) { - len = strtol (lenhead + 16, NULL, 10); + len = (int)strtoll (lenhead + 16, NULL, 10); if (file != INVALID_HANDLE_VALUE) { ShowWindow (GetDlgItem (hDlg, IDC_BOINGPROGRESS), SW_SHOW); diff --git a/src/win32/i_input.cpp b/src/win32/i_input.cpp index 0788e9415..8e1f62306 100644 --- a/src/win32/i_input.cpp +++ b/src/win32/i_input.cpp @@ -595,11 +595,9 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WTS_CONSOLE_DISCONNECT: SessionState |= 2; - //I_MovieDisableSound (); break; case WTS_CONSOLE_CONNECT: SessionState &= ~2; - //I_MovieResumeSound (); break; } } @@ -624,10 +622,6 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { GSnd->SuspendSound (); } - else if (oldstate && !SessionState) - { - GSnd->MovieResumeSound (); - } #endif } #ifdef _DEBUG @@ -953,18 +947,6 @@ FString I_GetFromClipboard (bool return_nothing) return retstr; } -#include "i_movie.h" - -CCMD (playmovie) -{ - if (argv.argc() != 2) - { - Printf ("Usage: playmovie \n"); - return; - } - I_PlayMovie (argv[1]); -} - //========================================================================== // // FInputDevice - Destructor diff --git a/src/win32/i_movie.cpp b/src/win32/i_movie.cpp deleted file mode 100644 index 66ffc8434..000000000 --- a/src/win32/i_movie.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* -** i_movie.cpp -** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** 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. -**--------------------------------------------------------------------------- -** -*/ - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * If you do not have dshow.h, either download the latest DirectX SDK - * or #define I_DO_NOT_LIKE_BIG_DOWNLOADS - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ - -#ifndef I_DO_NOT_LIKE_BIG_DOWNLOADS -#define I_DO_NOT_LIKE_BIG_DOWNLOADS -#endif - -#define WIN32_LEAN_AND_MEAN -#include -#define USE_WINDOWS_DWORD - -#include "c_cvars.h" - -CUSTOM_CVAR (Float, snd_movievolume, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (self < 0.f) - self = 0.f; - else if (self > 1.f) - self = 1.f; -} - -#ifdef I_DO_NOT_LIKE_BIG_DOWNLOADS - -#include "i_movie.h" - -int I_PlayMovie (const char *movie) -{ - return MOVIE_Failed; -} - -#else - -#include -#include "i_movie.h" -#include "i_sound.h" -#include "v_video.h" -#include "c_console.h" -#include "win32iface.h" -#include "sbar.h" - -EXTERN_CVAR (String, language) - -#define WM_GRAPHNOTIFY (WM_APP+321) - -#ifdef _DEBUG -#define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS -#else -//#define INGAME_PRIORITY_CLASS HIGH_PRIORITY_CLASS -#define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS -#endif - -extern HWND Window; -extern IVideo *Video; -extern LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); -extern void I_CheckNativeMouse (bool preferNative); - -static bool MovieNotDone; -static bool MovieInterrupted; -static bool MovieDestroyed; -static bool FullVideo; -static bool NoVideo; -static IVideoWindow *vidwin; -static IMediaEventEx *event; -static IGraphBuilder *graph; -static IMediaControl *control; -static IBasicAudio *audio; -static IBasicVideo *video; - -static void CheckIfVideo (); -static void SetMovieSize (); -static void SetTheVolume (); -static void SizeWindowForVideo (); - -LRESULT CALLBACK MovieWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_GRAPHNOTIFY: - { - long code; - LONG_PTR parm1, parm2; - - while (event->GetEvent (&code, &parm1, &parm2, 0) == S_OK) - { - if (code == EC_COMPLETE) - { - MovieNotDone = false; - } - event->FreeEventParams (code, parm1, parm2); - } - } - break; - - case WM_SIZE: - if (vidwin == NULL) - { - InvalidateRect (Window, NULL, FALSE); - } - else if ((wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED) && !FullVideo) - { - SetMovieSize (); - return 0; - } - break; - - case WM_PAINT: - if (vidwin == NULL) - { - if (screen != NULL) - { - static_cast (screen)->PaintToWindow (); - } - } - else if (!FullVideo) - { - PAINTSTRUCT ps; - HBRUSH br; - HDC dc; - long left, top, width, height; - - if (S_OK == vidwin->GetWindowPosition (&left, &top, &width, &height)) - { - dc = BeginPaint (Window, &ps); - if (dc != NULL) - { - RECT rect = { left, top, left+width, top+height }; - ScreenToClient (hWnd, (LPPOINT)&rect.left); - ScreenToClient (hWnd, (LPPOINT)&rect.right); - br = (HBRUSH)GetStockObject (BLACK_BRUSH); - switch (ExcludeClipRect (dc, rect.left, rect.top, rect.right, rect.bottom)) - { - case SIMPLEREGION: - case COMPLEXREGION: - FillRect (dc, &ps.rcPaint, br); - break; - default: - break; - } - EndPaint (Window, &ps); - //return 0; - } - } - } - break; - - case WM_DESTROY: - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - /* - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - */ - if (MovieNotDone) - { - if (wParam == VK_ESCAPE || message == WM_CANCELMODE || message == WM_DESTROY) - { - control->Stop (); - MovieNotDone = false; - MovieInterrupted = true; - } - } - if (message == WM_DESTROY) - { - MovieDestroyed = true; - } - return 0; - - case WM_GETMINMAXINFO: - if (screen && !FullVideo) - { - LPMINMAXINFO mmi = (LPMINMAXINFO)lParam; - RECT rect = { 0, 0, screen->GetWidth(), screen->GetHeight() }; - AdjustWindowRectEx(&rect, WS_VISIBLE|WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW); - mmi->ptMinTrackSize.x = rect.right - rect.left; - mmi->ptMinTrackSize.y = rect.bottom - rect.top; - return 0; - } - break; - - case WM_SETTINGCHANGE: - // In case regional settings were changed, reget preferred languages - language.Callback (); - return 0; - } - return DefWindowProc (hWnd, message, wParam, lParam); -} - -int I_PlayMovie (const char *name) -{ - HRESULT hr; - int returnval = MOVIE_Failed; - size_t namelen = strlen (name) + 1; - wchar_t *uniname = new wchar_t[namelen]; - bool returnSound = false; - bool runningFull = false; - bool hotkey = false; - size_t i; - MSG msg; - - MovieNotDone = true; - - if (MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, name, -1, uniname, (int)namelen) == 0) - { // Could not convert name to Unicode - goto bomb1; - } - - // Convert slashes to backslashes because IGraphBuilder cannot deal with them - for (i = 0; i < namelen; ++i) - { - if (uniname[i] == L'/') - uniname[i] = L'\\'; - } - - if (FAILED(hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, - IID_IGraphBuilder, (void **)&graph))) - { - goto bomb1; - } - - control = NULL; - event = NULL; - vidwin = NULL; - audio = NULL; - video = NULL; - - if (FAILED(hr = graph->RenderFile (uniname, NULL))) - { - goto bomb2; - } - - graph->QueryInterface (IID_IMediaControl, (void **)&control); - graph->QueryInterface (IID_IMediaEventEx, (void **)&event); - graph->QueryInterface (IID_IVideoWindow, (void **)&vidwin); - graph->QueryInterface (IID_IBasicAudio, (void **)&audio); - graph->QueryInterface (IID_IBasicVideo, (void **)&video); - - if (control == NULL || event == NULL) - { - goto bomb3; - } - - GSnd->MovieDisableSound (); - returnSound = true; - - CheckIfVideo (); - SetTheVolume (); - - FullVideo = false; - - if (vidwin != NULL) - { - FullVideo = runningFull = screen->IsFullscreen (); - - // If the message drain cannot be set, then we simply won't be able - // to catch mouse button presses in the video window. - HRESULT drainhr = vidwin->put_MessageDrain ((OAHWND)Window); - - if (FullVideo) - { - // Try to avoid nasty palette flashes by clearing the screen to black. - // Does not always work. :-( - static_cast (Video)->BlankForGDI (); - static_cast (Video)->GoFullscreen (false); - static_cast (screen)->ReleaseResources (); - if (FAILED (drainhr) || FAILED(hr = vidwin->put_FullScreenMode (OATRUE))) - { - SizeWindowForVideo (); - FullVideo = false; - } - } - if (!FullVideo) - { - vidwin->put_Owner ((OAHWND)Window); - vidwin->put_WindowStyle (WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); - SetMovieSize (); - } - else - { - RegisterHotKey (Window, 0, MOD_ALT, VK_TAB); - hotkey = true; - } - } - - if (FAILED (hr = event->SetNotifyWindow ((OAHWND)Window, WM_GRAPHNOTIFY, 0))) - { - goto bomb3; - } - - SetPriorityClass (GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - - I_CheckNativeMouse (true); - SetWindowLongPtr (Window, GWLP_WNDPROC, (LONG_PTR)MovieWndProc); - - if (FAILED (hr = control->Run ())) - { - goto bomb4; - } - - MovieInterrupted = false; - MovieDestroyed = false; - - while (MovieNotDone && GetMessage (&msg, NULL, 0, 0)) - { - TranslateMessage (&msg); - DispatchMessage (&msg); - } - - returnval = MovieInterrupted ? MOVIE_Played_Aborted : - NoVideo ? MOVIE_Played_NoVideo : - MOVIE_Played; - -bomb4: - SetWindowLongPtr (Window, GWLP_WNDPROC, (LONG_PTR)WndProc); - SetPriorityClass (GetCurrentProcess(), INGAME_PRIORITY_CLASS); - -bomb3: - if (hotkey) - { - UnregisterHotKey (Window, 0); - } - if (vidwin != NULL) - { - if (!FullVideo) - { - vidwin->put_Visible (OAFALSE); - vidwin->put_Owner (NULL); - } - vidwin->Release (); - } - if (video != NULL) - { - video->Release (); - } - if (audio != NULL) - { - audio->Release (); - } - if (event != NULL) - { - event->Release (); - } - if (control != NULL) - { - control->Release (); - } - - SetActiveWindow (Window); - -bomb2: - graph->Release (); - - if (returnSound) - { - GSnd->MovieResumeSound (); - C_FlushDisplay (); - } - if (runningFull) - { - static_cast (Video)->GoFullscreen (true); - static_cast (screen)->CreateResources (); - } - -bomb1: - delete[] uniname; - - if (MovieDestroyed) - { - exit (0); - } - - return returnval; -} - -static void CheckIfVideo () -{ - long visible; - - if (vidwin == NULL || video == NULL) - { - NoVideo = true; - return; - } - else if (vidwin->get_Visible (&visible) == E_NOINTERFACE) - { - NoVideo = true; - } - else - { - NoVideo = false; - } - - if (NoVideo) - { - if (vidwin != NULL) - { - vidwin->Release (); - vidwin = NULL; - } - - DHUDMessage *message = new DHUDMessage ( - "This movie either does not contain a video stream " - "or no suitable decompressor could be found.", - 1.5f, 0.375f, 0, 0, CR_RED, 1.f); - StatusBar->AttachMessage (message); - screen->Lock (false); - StatusBar->Draw (HUD_None); - StatusBar->DrawTopStuff (HUD_None); - screen->Update (); - StatusBar->DetachMessage (message); - delete message; - } -} - -static void SetTheVolume () -{ - if (audio != NULL) - { - // Convert snd_movievolume from a linear range to 1/100th - // decibels and pass that to the IBasicAudio interface. - long volume; - - if (snd_movievolume == 0.f) - { - volume = -10000; - } - else - { - volume = (long)(log10 (snd_movievolume) * 10000.0); - } - audio->put_Volume (volume); - } -} - -static void SizeWindowForVideo () -{ - LONG width, height; - - if (video == NULL || FAILED (video->GetVideoSize (&width, &height))) - return; - - SetWindowPos (Window, NULL, 0, 0, - width + 2*GetSystemMetrics(SM_CXBORDER), - height + GetSystemMetrics(SM_CYCAPTION) + 2*GetSystemMetrics(SM_CYBORDER), - SWP_NOMOVE|SWP_NOOWNERZORDER); -} - -static void SetMovieSize () -{ - LONG width, height, left, top; - RECT grc; - HRESULT hr; - - GetClientRect (Window, &grc); - - hr = video->GetVideoSize (&width, &height); - if (FAILED (hr)) - { - vidwin->SetWindowPosition (0, 0, grc.right, grc.bottom); - return; - } - - double aspect = (double)height / (double)width; - - // Calculate size of video window that fits in our window - if (grc.right > grc.bottom) - { - height = grc.bottom; - width = (LONG)((double)height / aspect); - } - if (grc.right <= grc.bottom || width > grc.right) - { - width = grc.right; - height = (LONG)((double)width * aspect); - } - - // Then center it - left = (grc.right - width) / 2; - top = (grc.bottom - height) / 2; - - // And use it - vidwin->SetWindowPosition (left, top, width, height); - - InvalidateRect (Window, NULL, FALSE); -} - -#endif // I_DO_NOT_LIKE_BIG_DOWNLOADS diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index a92672ad7..13cf603fa 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -136,7 +136,6 @@ protected: bool Windowed; - friend int I_PlayMovie (const char *name); friend class Win32Video; BaseWinFB() {} diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 015a344e0..0a32edc02 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -336,7 +336,7 @@ bool Win32Video::GoFullscreen (bool yes) HRESULT hr[2]; int count; - // FIXME: Do this right for D3D. (This function is only called by the movie player when using D3D.) + // FIXME: Do this right for D3D. if (D3D != NULL) { return yes; @@ -372,7 +372,7 @@ bool Win32Video::GoFullscreen (bool yes) return false; } -// Flips to the GDI surface and clears it; used by the movie player +// Flips to the GDI surface and clears it void Win32Video::BlankForGDI () { static_cast (screen)->Blank (); diff --git a/src/zstring.cpp b/src/zstring.cpp index d17348bd3..665b9312e 100644 --- a/src/zstring.cpp +++ b/src/zstring.cpp @@ -1104,12 +1104,12 @@ digits = [0-9]; long FString::ToLong (int base) const { - return strtol (Chars, NULL, base); + return (long)strtoll (Chars, NULL, base); } unsigned long FString::ToULong (int base) const { - return strtoul (Chars, NULL, base); + return (unsigned long)strtoull (Chars, NULL, base); } double FString::ToDouble () const diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index d8259c845..52ea9791b 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -1,5 +1,4 @@ in vec4 pixelpos; -in vec2 glowdist; out vec4 FragColor; //=========================================================================== diff --git a/wadsrc/static/zscript/shared/movingcamera.txt b/wadsrc/static/zscript/shared/movingcamera.txt index 0fc50f3e2..15fdd0836 100644 --- a/wadsrc/static/zscript/shared/movingcamera.txt +++ b/wadsrc/static/zscript/shared/movingcamera.txt @@ -287,7 +287,7 @@ class PathFollower : Actor if (Interpolate ()) { - Time += (8. / (CurrNode.args[1] * TICRATE)); + Time += (8. / (max(1, CurrNode.args[1]) * TICRATE)); if (Time > 1.) { Time -= 1.; diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index d4992e97f..0a7798ace 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -126,7 +126,7 @@ class PlayerPawn : Actor native let powerup = Powerup(FindInventory(powerupType)); if(powerup != null) { - let maxtics = GetDefaultByType(powerupType).EffectTics; + let maxtics = GetDefaultByType(pg).EffectTics; if (maxtics == 0) maxtics = powerup.default.EffectTics; return powerup.EffectTics, maxtics; } diff --git a/wadsrc_lights/static/filter/hexen/gldefs.txt b/wadsrc_lights/static/filter/hexen/gldefs.txt index d72b9c76f..cc9513d97 100644 --- a/wadsrc_lights/static/filter/hexen/gldefs.txt +++ b/wadsrc_lights/static/filter/hexen/gldefs.txt @@ -1345,7 +1345,7 @@ flickerlight2 FIREBULL attenuate 1 color 1.0 0.7 0.0 size 96 - secondarysize - 105 + secondarysize 130 interval 0.1 offset 0 40 0 }