From bf577916ec417991d17b70a8e625086066f7f5f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 Jan 2023 18:22:08 +0100 Subject: [PATCH] - made the is*** checkers compiler intrinsics. With the exception of isWorldTour, isPlutoPak and isShareware when playing Duke these are always constant and this way can be used to completely eliminate unneeded code. --- source/CMakeLists.txt | 1 + source/core/codegen_raze.cpp | 599 ++++++++++++++++++ source/core/codegen_raze.h | 114 ++++ source/core/gamecontrol.h | 10 + source/core/namedef_custom.h | 20 + source/core/zcompile.cpp | 2 + wadsrc/static/zscript/alt_hud.zs | 12 +- .../zscript/games/duke/actors/controllers.zs | 4 +- .../games/duke/actors/dukecstuff/bloodpool.zs | 2 +- .../games/duke/actors/dukecstuff/cactus.zs | 2 +- .../duke/actors/dukecstuff/frameeffect.zs | 2 +- .../games/duke/actors/dukecstuff/jibs.zs | 10 +- .../games/duke/actors/dukecstuff/ooz.zs | 2 +- .../games/duke/actors/dukecstuff/rat.zs | 2 +- .../games/duke/actors/dukecstuff/shell.zs | 2 +- .../games/duke/actors/dukecstuff/toilet.zs | 2 +- .../games/duke/actors/dukecstuff/waterdrip.zs | 2 +- .../games/duke/actors/dukeenemies/boss1.zs | 2 +- .../duke/actors/dukeweapons/heavyhbomb.zs | 8 +- .../games/duke/actors/dukeweapons/mortar.zs | 6 +- .../duke/actors/dukeweapons/projectilebase.zs | 2 +- .../games/duke/actors/dukeweapons/rpg.zs | 10 +- .../duke/actors/redneckcstuff/chickenplant.zs | 2 +- .../games/duke/actors/redneckenemies/coot.zs | 4 +- .../duke/actors/redneckenemies/minion.zs | 2 +- .../games/duke/actors/redneckstuff/items.zs | 4 +- .../games/duke/actors/respawncontroller.zs | 2 +- .../zscript/games/duke/actors/touchplate.zs | 2 +- wadsrc/static/zscript/games/duke/dukeactor.zs | 2 +- wadsrc/static/zscript/games/duke/dukegame.zs | 4 +- .../static/zscript/games/duke/ui/cutscenes.zs | 10 +- wadsrc/static/zscript/games/duke/ui/sbar.zs | 12 +- wadsrc/static/zscript/games/duke/ui/sbar_d.zs | 16 +- wadsrc/static/zscript/games/duke/ui/sbar_r.zs | 2 +- .../static/zscript/games/duke/ui/screens.zs | 26 +- wadsrc/static/zscript/games/sw/ui/screens.zs | 2 +- wadsrc/static/zscript/razebase.zs | 67 -- wadsrc/static/zscript/statusbar.zs | 2 +- 38 files changed, 827 insertions(+), 148 deletions(-) create mode 100644 source/core/codegen_raze.cpp create mode 100644 source/core/codegen_raze.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2cb487983..6b0f6fe9a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -938,6 +938,7 @@ set (PCH_SOURCES core/actorinfo.cpp core/zcc_compile_raze.cpp + core/codegen_raze.cpp core/vmexports.cpp core/thingdef_data.cpp core/thingdef_properties.cpp diff --git a/source/core/codegen_raze.cpp b/source/core/codegen_raze.cpp new file mode 100644 index 000000000..92952f617 --- /dev/null +++ b/source/core/codegen_raze.cpp @@ -0,0 +1,599 @@ +/* +** codegen.cpp +** +** Compiler backend / code generation for ZScript +** +**--------------------------------------------------------------------------- +** Copyright 2008-2022 Christoph Oelckers +** 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. +**--------------------------------------------------------------------------- +** +*/ + +#include +#include "cmdlib.h" +#include "codegen.h" +#include "codegen_raze.h" +#include "v_text.h" +#include "filesystem.h" +#include "v_video.h" +#include "utf8.h" +#include "texturemanager.h" +#include "m_random.h" +#include "v_font.h" +#include "gamecontrol.h" +#include "gi.h" + +PFunction* FindBuiltinFunction(FName funcname); + +//========================================================================== +// +// +// +//========================================================================== + +bool isActor(PContainerType* type) +{ + auto cls = PType::toClass(type); + return cls ? cls->Descriptor->IsDescendantOf(RUNTIME_CLASS(DCoreActor)) : false; +} + +//========================================================================== +// +// +// +//========================================================================== + +static FxExpression* CheckForDefault(FxIdentifier* func, FCompileContext& ctx) +{ + auto& ScriptPosition = func->ScriptPosition; + + if (func->Identifier == NAME_Default) + { + if (ctx.Function == nullptr) + { + ScriptPosition.Message(MSG_ERROR, "Unable to access class defaults from constant declaration"); + delete func; + return nullptr; + } + if (ctx.Function->Variants[0].SelfClass == nullptr) + { + ScriptPosition.Message(MSG_ERROR, "Unable to access class defaults from static function"); + delete func; + return nullptr; + } + if (!isActor(ctx.Function->Variants[0].SelfClass)) + { + ScriptPosition.Message(MSG_ERROR, "'Default' requires an actor type."); + delete func; + return nullptr; + } + + FxExpression* x = new FxClassDefaults(new FxSelf(ScriptPosition), ScriptPosition); + delete func; + return x->Resolve(ctx); + } + return func; +} + +//========================================================================== +// +// +// +//========================================================================== + +static FxExpression *ResolveForDefault(FxIdentifier *expr, FxExpression*& object, PContainerType* objtype, FCompileContext &ctx) +{ + + if (expr->Identifier == NAME_Default) + { + if (!isActor(objtype)) + { + expr->ScriptPosition.Message(MSG_ERROR, "'Default' requires an actor type."); + delete object; + object = nullptr; + return nullptr; + } + + FxExpression * x = new FxClassDefaults(object, expr->ScriptPosition); + object = nullptr; + delete expr; + return x->Resolve(ctx); + } + return expr; +} + + +//========================================================================== +// +// +// +//========================================================================== + +FxExpression* CheckForMemberDefault(FxStructMember *func, FCompileContext &ctx) +{ + auto& membervar = func->membervar; + auto& classx = func->classx; + auto& ScriptPosition = func->ScriptPosition; + + if (membervar->SymbolName == NAME_Default) + { + if (!classx->ValueType->isObjectPointer() + || !static_cast(classx->ValueType)->PointedClass()->IsDescendantOf(RUNTIME_CLASS(DCoreActor))) + { + ScriptPosition.Message(MSG_ERROR, "'Default' requires an actor type"); + delete func; + return nullptr; + } + FxExpression * x = new FxClassDefaults(classx, ScriptPosition); + classx = nullptr; + delete func; + return x->Resolve(ctx); + } + return func; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool CheckArgSize(FName fname, FArgumentList &args, int min, int max, FScriptPosition &sc); + +static FxExpression *ResolveGlobalCustomFunction(FxFunctionCall *func, FCompileContext &ctx) +{ + auto& ScriptPosition = func->ScriptPosition; + if (func->MethodName == NAME_GetDefaultByType) + { + if (CheckArgSize(NAME_GetDefaultByType, func->ArgList, 1, 1, ScriptPosition)) + { + auto newfunc = new FxGetDefaultByType(func->ArgList[0]); + func->ArgList[0] = nullptr; + delete func; + return newfunc->Resolve(ctx); + } + } + else if (func->MethodName == NAME_SetAction && isDukeEngine()) + { + } + else if (func->MethodName == NAME_SetAI && isDukeEngine()) + { + } + else if (func->MethodName == NAME_SetMove && isDukeEngine()) + { + } + // most of these can be resolved right here. Only isWorldTour, isPlutoPak and isShareware can not if Duke is being played. + else if (func->MethodName == NAME_isDuke) + { + return new FxConstant(isDuke(), ScriptPosition); + } + else if (func->MethodName == NAME_isNam) + { + return new FxConstant(isNam(), ScriptPosition); + } + else if (func->MethodName == NAME_isNamWW2GI) + { + return new FxConstant(isNamWW2GI(), ScriptPosition); + } + else if (func->MethodName == NAME_isWW2GI) + { + return new FxConstant(isWW2GI(), ScriptPosition); + } + else if (func->MethodName == NAME_isRR) + { + return new FxConstant(isRR(), ScriptPosition); + } + else if (func->MethodName == NAME_isRRRA) + { + return new FxConstant(isRRRA(), ScriptPosition); + } + else if (func->MethodName == NAME_isRoute66) + { + return new FxConstant(isRoute66(), ScriptPosition); + } + else if (func->MethodName == NAME_isWorldTour) + { + if (!isDuke()) return new FxConstant(false, ScriptPosition); + else return new FxIsGameType(GAMEFLAG_WORLDTOUR, ScriptPosition); + } + else if (func->MethodName == NAME_isPlutoPak) + { + if (!isDuke()) return new FxConstant(false, ScriptPosition); + else return new FxIsGameType(GAMEFLAG_PLUTOPAK, ScriptPosition); + } + else if (func->MethodName == NAME_isShareware) + { + if (!isDuke()) return new FxConstant(isShareware(), ScriptPosition); + else return new FxIsGameType(GAMEFLAG_SHAREWARE, ScriptPosition); + } + else if (func->MethodName == NAME_isVacation) + { + return new FxConstant(isVacation(), ScriptPosition); + } + else if (func->MethodName == NAME_isDukeLike) + { + return new FxConstant(isDukeLike(), ScriptPosition); + } + else if (func->MethodName == NAME_isDukeEngine) + { + return new FxConstant(isDukeEngine(), ScriptPosition); + } + else if (func->MethodName == NAME_isBlood) + { + return new FxConstant(isBlood(), ScriptPosition); + } + else if (func->MethodName == NAME_isSW) + { + return new FxConstant(isSWALL(), ScriptPosition); + } + else if (func->MethodName == NAME_isExhumed) + { + return new FxConstant(isExhumed(), ScriptPosition); + } + + return func; +} + + + +//========================================================================== +// +// FxSetActionCall +// +//========================================================================== + +FxSetActionCall::FxSetActionCall(FxExpression *self, FxExpression* arg, const FScriptPosition &pos) +: FxExpression(EFX_ActionSpecialCall, pos) +{ + Self = self; + Arg = arg; +} + +//========================================================================== +// +// +// +//========================================================================== + +FxSetActionCall::~FxSetActionCall() +{ + SAFE_DELETE(Self); +} + +//========================================================================== +// +// +// +//========================================================================== + +FxExpression *FxSetActionCall::Resolve(FCompileContext& ctx) +{ + CHECKRESOLVED(); + return this; +} + + +//========================================================================== +// +// +// +//========================================================================== + +ExpEmit FxSetActionCall::Emit(VMFunctionBuilder *build) +{ + return ExpEmit(); +} + +//========================================================================== +// +// FxSetAICall +// +//========================================================================== + +FxSetAICall::FxSetAICall(FxExpression *self, FxExpression* arg, const FScriptPosition &pos) +: FxExpression(EFX_ActionSpecialCall, pos) +{ + Self = self; + Arg = arg; +} + +//========================================================================== +// +// +// +//========================================================================== + +FxSetAICall::~FxSetAICall() +{ + SAFE_DELETE(Self); +} + +//========================================================================== +// +// +// +//========================================================================== + +FxExpression *FxSetAICall::Resolve(FCompileContext& ctx) +{ + CHECKRESOLVED(); + return this; +} + + +//========================================================================== +// +// +// +//========================================================================== + +ExpEmit FxSetAICall::Emit(VMFunctionBuilder *build) +{ + return ExpEmit(); +} + +//========================================================================== +// +// FxSetMoveCall +// +//========================================================================== + +FxSetMoveCall::FxSetMoveCall(FxExpression *self, FxExpression* arg, const FScriptPosition &pos) +: FxExpression(EFX_ActionSpecialCall, pos) +{ + Self = self; + Arg = arg; +} + +//========================================================================== +// +// +// +//========================================================================== + +FxSetMoveCall::~FxSetMoveCall() +{ + SAFE_DELETE(Self); +} + +//========================================================================== +// +// +// +//========================================================================== + +FxExpression *FxSetMoveCall::Resolve(FCompileContext& ctx) +{ + CHECKRESOLVED(); + return this; +} + + +//========================================================================== +// +// +// +//========================================================================== + +ExpEmit FxSetMoveCall::Emit(VMFunctionBuilder *build) +{ + return ExpEmit(); +} + +//========================================================================== +// +// code generation is only performed for some Duke checks that depend on CON +// which cannot be resolved at compile time. +// +//========================================================================== + +FxIsGameType::FxIsGameType(int arg, const FScriptPosition &pos) +: FxExpression(EFX_ActionSpecialCall, pos) +{ + state = arg; +} + +//========================================================================== +// +// +// +//========================================================================== + +FxIsGameType::~FxIsGameType() +{ +} + +//========================================================================== +// +// +// +//========================================================================== + +FxExpression *FxIsGameType::Resolve(FCompileContext& ctx) +{ + CHECKRESOLVED(); + ValueType = TypeBool; + return this; +} + + +//========================================================================== +// +// +// +//========================================================================== + +ExpEmit FxIsGameType::Emit(VMFunctionBuilder *build) +{ + ExpEmit obj(build, REGT_POINTER); + + auto addr = (intptr_t)&gameinfo.gametype; + assert(state != 0); + while (state >= 256) + { + state >>= 8; + addr++; + } + build->Emit(OP_LKP, obj.RegNum, build->GetConstantAddress((void*)addr)); + ExpEmit loc(build, REGT_INT); + build->Emit(OP_LBIT, loc.RegNum, obj.RegNum, state); + obj.Free(build); + return loc; +} + +//========================================================================== +// +// +// +//========================================================================== + +FxClassDefaults::FxClassDefaults(FxExpression *X, const FScriptPosition &pos) + : FxExpression(EFX_ClassDefaults, pos) +{ + obj = X; +} + +FxClassDefaults::~FxClassDefaults() +{ + SAFE_DELETE(obj); +} + + +//========================================================================== +// +// +// +//========================================================================== + +FxExpression *FxClassDefaults::Resolve(FCompileContext& ctx) +{ + CHECKRESOLVED(); + SAFE_RESOLVE(obj, ctx); + assert(obj->ValueType->isRealPointer()); + ValueType = NewPointer(obj->ValueType->toPointer()->PointedType, true); + return this; +} + +//========================================================================== +// +// +// +//========================================================================== + +ExpEmit FxClassDefaults::Emit(VMFunctionBuilder *build) +{ + ExpEmit ob = obj->Emit(build); + ob.Free(build); + ExpEmit meta(build, REGT_POINTER); + build->Emit(OP_CLSS, meta.RegNum, ob.RegNum); + build->Emit(OP_LP, meta.RegNum, meta.RegNum, build->GetConstantInt(myoffsetof(PClass, Defaults))); + return meta; + +} + +//========================================================================== +// +// +//========================================================================== + +FxGetDefaultByType::FxGetDefaultByType(FxExpression *self) + :FxExpression(EFX_GetDefaultByType, self->ScriptPosition) +{ + Self = self; +} + +FxGetDefaultByType::~FxGetDefaultByType() +{ + SAFE_DELETE(Self); +} + +FxExpression *FxGetDefaultByType::Resolve(FCompileContext &ctx) +{ + SAFE_RESOLVE(Self, ctx); + PClass *cls = nullptr; + + if (Self->ValueType == TypeString || Self->ValueType == TypeName) + { + if (Self->isConstant()) + { + cls = PClass::FindActor(static_cast(Self)->GetValue().GetName()); + if (cls == nullptr) + { + ScriptPosition.Message(MSG_ERROR, "GetDefaultByType() requires an actor class type, but got %s", static_cast(Self)->GetValue().GetString().GetChars()); + delete this; + return nullptr; + } + Self = new FxConstant(cls, NewClassPointer(cls), ScriptPosition); + } + else + { + // this is the ugly case. We do not know what we have and cannot do proper type casting. + // For now error out and let this case require explicit handling on the user side. + ScriptPosition.Message(MSG_ERROR, "GetDefaultByType() requires an actor class type, but got %s", static_cast(Self)->GetValue().GetString().GetChars()); + delete this; + return nullptr; + } + } + else + { + auto cp = PType::toClassPointer(Self->ValueType); + if (cp == nullptr || !cp->ClassRestriction->IsDescendantOf(RUNTIME_CLASS(DCoreActor))) + { + ScriptPosition.Message(MSG_ERROR, "GetDefaultByType() requires an actor class type"); + delete this; + return nullptr; + } + cls = cp->ClassRestriction; + } + ValueType = NewPointer(cls, true); + return this; +} + +ExpEmit FxGetDefaultByType::Emit(VMFunctionBuilder *build) +{ + ExpEmit op = Self->Emit(build); + op.Free(build); + ExpEmit to(build, REGT_POINTER); + if (op.Konst) + { + build->Emit(OP_LKP, to.RegNum, op.RegNum); + op = to; + } + build->Emit(OP_LP, to.RegNum, op.RegNum, build->GetConstantInt(myoffsetof(PClass, Defaults))); + return to; +} + + + + +void SetRazeCompileEnvironment() +{ + compileEnvironment.CheckSpecialIdentifier = CheckForDefault; + compileEnvironment.ResolveSpecialIdentifier = ResolveForDefault; + compileEnvironment.CheckSpecialMember = CheckForMemberDefault; + compileEnvironment.CheckCustomGlobalFunctions = ResolveGlobalCustomFunction; +} diff --git a/source/core/codegen_raze.h b/source/core/codegen_raze.h new file mode 100644 index 000000000..1a02a4324 --- /dev/null +++ b/source/core/codegen_raze.h @@ -0,0 +1,114 @@ +#pragma once +#include "codegen.h" +#include "coreactor.h" + +//========================================================================== +// +// +// +//========================================================================== + +class FxSetActionCall : public FxExpression +{ + FxExpression *Self; + FxExpression *Arg; + +public: + + FxSetActionCall(FxExpression *self, FxExpression* arg, const FScriptPosition &pos); + ~FxSetActionCall(); + FxExpression *Resolve(FCompileContext&); + ExpEmit Emit(VMFunctionBuilder *build); +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FxSetAICall : public FxExpression +{ + FxExpression *Self; + FxExpression *Arg; + +public: + + FxSetAICall(FxExpression *self, FxExpression* arg, const FScriptPosition &pos); + ~FxSetAICall(); + FxExpression *Resolve(FCompileContext&); + ExpEmit Emit(VMFunctionBuilder *build); +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FxSetMoveCall : public FxExpression +{ + FxExpression *Self; + FxExpression *Arg; + +public: + + FxSetMoveCall(FxExpression *self, FxExpression* arg, const FScriptPosition &pos); + ~FxSetMoveCall(); + FxExpression *Resolve(FCompileContext&); + ExpEmit Emit(VMFunctionBuilder *build); +}; + +//========================================================================== +// +// FxClassDefaults +// +//========================================================================== + +class FxClassDefaults : public FxExpression +{ + FxExpression *obj; + +public: + FxClassDefaults(FxExpression *, const FScriptPosition &); + ~FxClassDefaults(); + FxExpression *Resolve(FCompileContext&); + ExpEmit Emit(VMFunctionBuilder *build); +}; + +//========================================================================== +// +// FxGetDefaultByType +// +//========================================================================== + +class FxGetDefaultByType : public FxExpression +{ + FxExpression *Self; + +public: + + FxGetDefaultByType(FxExpression *self); + ~FxGetDefaultByType(); + FxExpression *Resolve(FCompileContext&); + ExpEmit Emit(VMFunctionBuilder *build); +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FxIsGameType : public FxExpression +{ + int state; + +public: + + FxIsGameType(int arg, const FScriptPosition& pos); + ~FxIsGameType(); + FxExpression *Resolve(FCompileContext&); + ExpEmit Emit(VMFunctionBuilder *build); +}; + diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 64af92d4d..3e3cf7f72 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -180,6 +180,11 @@ inline bool isRRRA() return g_gameType & (GAMEFLAG_RRRA); } +inline bool isRoute66() +{ + return g_gameType & (GAMEFLAG_ROUTE66); +} + inline bool isWorldTour() { return g_gameType & GAMEFLAG_WORLDTOUR; @@ -190,6 +195,11 @@ inline bool isPlutoPak() return g_gameType & GAMEFLAG_PLUTOPAK; } +inline bool isVacation() +{ + return g_gameType & GAMEFLAG_DUKEVACA; +} + inline bool isShareware() { return g_gameType & GAMEFLAG_SHAREWARE; diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index 6c7f605e2..4e5359367 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -33,3 +33,23 @@ xx(landmovefactor) xx(watermovefactor) xx(gravityfactor) xx(minhitscale) + +xx(SetAction) +xx(SetAI) +xx(SetMove) +xx(isNam) +xx(isNamWW2GI) +xx(isWW2GI) +xx(isDuke) +xx(isRR) +xx(isRRRA) +xx(isRoute66) +xx(isWorldTour) +xx(isPlutoPak) +xx(isVacation) +xx(isShareware) +xx(isDukeLike) +xx(isDukeEngine) +xx(isBlood) +xx(isSW) +xx(isExhumed) diff --git a/source/core/zcompile.cpp b/source/core/zcompile.cpp index 63eff2ed3..ab262fd65 100644 --- a/source/core/zcompile.cpp +++ b/source/core/zcompile.cpp @@ -46,6 +46,7 @@ void InitThingdef(); void SynthesizeFlagFields(); +void SetRazeCompileEnvironment(); void ParseScripts() { @@ -82,6 +83,7 @@ void LoadScripts() cycle_t timer; PType::StaticInit(); + SetRazeCompileEnvironment(); InitThingdef(); timer.Reset(); timer.Clock(); FScriptPosition::ResetErrorCounter(); diff --git a/wadsrc/static/zscript/alt_hud.zs b/wadsrc/static/zscript/alt_hud.zs index de0320935..4976d3bad 100644 --- a/wadsrc/static/zscript/alt_hud.zs +++ b/wadsrc/static/zscript/alt_hud.zs @@ -106,12 +106,12 @@ class AltHud ui virtual void Init() { - HudFont = BigFont; // Strife doesn't have anything nice so use the standard font - if (Raze.isBlood()) HudFont = Font.GetFont("HUDFONT_BLOOD"); - else if (Raze.isDuke()) HudFontOffset = 6; + HudFont = BigFont; + if (isBlood()) HudFont = Font.GetFont("HUDFONT_BLOOD"); + else if (isDuke()) HudFontOffset = 6; IndexFont = Font.GetFont("HUDINDEXFONT"); if (IndexFont == NULL) IndexFont = ConFont; // Emergency fallback - if (!Raze.isNamWW2GI()) + if (!isNamWW2GI()) StatFont = SmallFont; else StatFont = ConFont; @@ -277,7 +277,7 @@ class AltHud ui Font.CR_BLUE; DrawImageToBox(TexMan.CheckForTexture(currentStats.healthicon), x, y, 31, 17, 0.75, true); - if (Raze.isSW()) y -= 4; // still need to figure out why the font is misaligned this much. + if (isSW()) y -= 4; // still need to figure out why the font is misaligned this much. DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17, fontscale:fontscale); } @@ -304,7 +304,7 @@ class AltHud ui Font.CR_BLUE; DrawImageToBox(TexMan.CheckForTexture(currentStats.armoricons[i]), x, y, 31, 17, 0.75, true); - if (Raze.isSW()) y -= 4; // still need to figure out why the font is misaligned. + if (isSW()) y -= 4; // still need to figure out why the font is misaligned. if (ap >= 0) DrawHudNumber(HudFont, fontcolor, ap, x + 33, y + 17, fontscale:fontscale); x += 35 + spacing; } diff --git a/wadsrc/static/zscript/games/duke/actors/controllers.zs b/wadsrc/static/zscript/games/duke/actors/controllers.zs index 0dc0d9099..17508e0d7 100644 --- a/wadsrc/static/zscript/games/duke/actors/controllers.zs +++ b/wadsrc/static/zscript/games/duke/actors/controllers.zs @@ -37,7 +37,7 @@ class DukeActivator : DukeActor if (a2.statnum == STAT_EFFECTOR) switch (a2.lotag) { case SE_18_INCREMENTAL_SECTOR_RISE_FALL: - if (Raze.isRRRA()) break; + if (isRRRA()) break; case SE_36_PROJ_SHOOTER: case SE_31_FLOOR_RISE_FALL: @@ -71,7 +71,7 @@ class DukeActivatorLocked : DukeActor override void Initialize() { self.cstat = CSTAT_SPRITE_INVISIBLE; - if (!Raze.IsRR()) self.sector.lotag |= 16384; + if (!isRR()) self.sector.lotag |= 16384; else self.sector.lotag ^= 16384; self.ChangeStat(STAT_ACTIVATOR); } diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/bloodpool.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/bloodpool.zs index bf1f4d86b..e76fd5591 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/bloodpool.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/bloodpool.zs @@ -50,7 +50,7 @@ class DukeBloodPool : DukeActor } else self.insertspriteq(); } - if (Raze.isRR() && self.sector.lotag == 800) + if (isRR() && self.sector.lotag == 800) { self.Destroy(); return; diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/cactus.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/cactus.zs index 5f3fc9249..e516acdc9 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/cactus.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/cactus.zs @@ -26,7 +26,7 @@ class DukeCactus : DukeCactusBroke { if (self.spritesetindex == 0 && hitter.bINFLAME) { - let scrap = Raze.isRR()? DukeScrap.Scrap6 : DukeScrap.Scrap3; + let scrap = isRR()? DukeScrap.Scrap6 : DukeScrap.Scrap3; for (int k = 0; k < 64; k++) { diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/frameeffect.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/frameeffect.zs index 34fc036e6..315daeef5 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/frameeffect.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/frameeffect.zs @@ -53,7 +53,7 @@ class DukeFrameEffect : DukeActor } if ((OwnerAc.cstat & CSTAT_SPRITE_INVISIBLE) == 0) { - if (!OwnerAc.isPlayer() || !Raze.isRR()) t.SetSpritePic(OwnerAc, -1); + if (!OwnerAc.isPlayer() || !isRR()) t.SetSpritePic(OwnerAc, -1); else t.SetSpritePic(OwnerAc, 0); t.pal = OwnerAc.pal; t.shade = OwnerAc.shade; diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/jibs.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/jibs.zs index 9d58300d7..1d031566d 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/jibs.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/jibs.zs @@ -63,7 +63,7 @@ class DukeJibs1 : DukeActor if(self.vel.X > 0) self.vel.X -= 1/16.; else self.vel.X = 0; - if (!Raze.IsRR()) + if (!isRR()) { if (self.temp_data[0] < 30 * 10) self.temp_data[0]++; @@ -126,7 +126,7 @@ class DukeJibs1 : DukeActor self.pos += self.angle.ToVector() * self.vel.X; self.pos.Z += self.vel.Z; - if (Raze.IsRR() && self.pos.Z >= self.sector.floorz) + if (isRR() && self.pos.Z >= self.sector.floorz) { self.Destroy(); return; @@ -175,7 +175,7 @@ class DukeJibs1 : DukeActor return; } } - if (Raze.IsRR() && self.sector.lotag == 800 && self.pos.Z >= self.sector.floorz - 8) + if (isRR() && self.sector.lotag == 800 && self.pos.Z >= self.sector.floorz - 8) { self.Destroy(); return; @@ -186,7 +186,7 @@ class DukeJibs1 : DukeActor override bool animate(tspritetype tspr) { - if (Raze.isRRRA() && tspr.pal == 19) + if (isRRRA() && tspr.pal == 19) tspr.shade = -127; if (spritesetindex == 1) @@ -264,7 +264,7 @@ class DukeJibs6 : DukeJibs1 override void Initialize() { - if (Raze.isRR()) self.scale *= 0.5; // only RR needs this. + if (isRR()) self.scale *= 0.5; // only RR needs this. self.setSpriteSetImage(1); } } diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/ooz.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/ooz.zs index 010593fdd..34d9c1f0d 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/ooz.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/ooz.zs @@ -13,7 +13,7 @@ class DukeOoz : DukeActor { if (self.bPAL8OOZ) self.pal = 8; - if (!Raze.IsRR()) self.insertspriteq(); + if (!isRR()) self.insertspriteq(); } self.getglobalz(); diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/rat.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/rat.zs index 5a3919197..39debbad0 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/rat.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/rat.zs @@ -33,7 +33,7 @@ class DukeRat : DukeActor self.makeitfall(); if (self.DoMove(CLIPMASK0)) { - if (!Raze.isRRRA() && random(0, 255) == 0) self.PlayActorSound("RATTY"); + if (!isRRRA() && random(0, 255) == 0) self.PlayActorSound("RATTY"); self.angle += Raze.BAngToDegree * (random(-15, 15) + Raze.BobVal(self.counter << 8) * 8); } else diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/shell.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/shell.zs index 49a930ee7..90b4ab8fb 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/shell.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/shell.zs @@ -44,7 +44,7 @@ class DukeShell : DukeActor self.vel.X = -direction; } - double scale = Raze.isRR() && isshell ? 0.03125 : 0.0625; + double scale = isRR() && isshell ? 0.03125 : 0.0625; self.scale = (scale, scale); } self.shade = -8; diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/toilet.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/toilet.zs index 7472924ef..92791ffea 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/toilet.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/toilet.zs @@ -68,7 +68,7 @@ class DukeToilet : DukeStall override void StandingOn(DukePlayer p) { - if (Raze.isRR() && p.PlayerInput(Duke.SB_CROUCH) && !p.OnMotorcycle) + if (isRR() && p.PlayerInput(Duke.SB_CROUCH) && !p.OnMotorcycle) { p.actor.PlayActorSound("CRAP"); p.last_pissed_time = 4000; diff --git a/wadsrc/static/zscript/games/duke/actors/dukecstuff/waterdrip.zs b/wadsrc/static/zscript/games/duke/actors/dukecstuff/waterdrip.zs index 843b19d90..dfda72ce8 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukecstuff/waterdrip.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukecstuff/waterdrip.zs @@ -49,7 +49,7 @@ class DukeWaterDrip : DukeActor { self.cstat |= CSTAT_SPRITE_INVISIBLE; - if (self.pal != 2 && (self.hitag == 0 || Raze.isRR())) + if (self.pal != 2 && (self.hitag == 0 || isRR())) self.PlayActorSound("SOMETHING_DRIPPING"); if (!self.mapSpawned) diff --git a/wadsrc/static/zscript/games/duke/actors/dukeenemies/boss1.zs b/wadsrc/static/zscript/games/duke/actors/dukeenemies/boss1.zs index 8ce33904a..152f32fc2 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeenemies/boss1.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeenemies/boss1.zs @@ -18,7 +18,7 @@ class DukeBossBase : DukeActor if (owner && owner is 'DukeRespawnController') self.pal = owner.pal; - if (self.pal != 0 && (!Raze.isWorldTour() || !(currentLevel.gameflags & MapRecord.LEVEL_WT_BOSSSPAWN) || self.pal != 22)) + if (self.pal != 0 && (!isWorldTour() || !(currentLevel.gameflags & MapRecord.LEVEL_WT_BOSSSPAWN) || self.pal != 22)) { self.clipdist = 20; self.scale = (0.625, 0.625); diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/heavyhbomb.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/heavyhbomb.zs index 6572a7a59..1f39fd44b 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/heavyhbomb.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/heavyhbomb.zs @@ -74,7 +74,7 @@ class DukePipeBomb : DukeActor self.makeitfall(); // Feature check later needs to be map controlled, not game controlled. - if (sectp.lotag != ST_1_ABOVE_WATER && (!Raze.isRRRA() || sectp.lotag != ST_160_FLOOR_TELEPORT) && self.pos.Z >= self.floorz - 1 && self.yint < 3) + if (sectp.lotag != ST_1_ABOVE_WATER && (!isRRRA() || sectp.lotag != ST_160_FLOOR_TELEPORT) && self.pos.Z >= self.floorz - 1 && self.yint < 3) { if (self.yint > 0 || (self.yint == 0 && self.floorz == sectp.floorz)) { @@ -129,7 +129,7 @@ class DukePipeBomb : DukeActor bool bBoom = false; if (Owner && Owner.isPlayer()) { - if (Raze.isNamWW2GI()) + if (isNamWW2GI()) { self.extra--; if (self.extra <= 0) @@ -153,11 +153,11 @@ class DukePipeBomb : DukeActor int x = self.extra; int m = gs.pipebombblastradius; - if (self.sector.lotag != 800 || !Raze.isRR()) // this line is RR only + if (self.sector.lotag != 800 || !isRR()) // this line is RR only { self.hitradius(m, x >> 2, x >> 1, x - (x >> 2), x); self.spawn("DukeExplosion2"); - if (self.vel.Z == 0 && !Raze.isRR()) self.spawn("DukeExplosion2Bot"); // this line is Duke only + if (self.vel.Z == 0 && !isRR()) self.spawn("DukeExplosion2Bot"); // this line is Duke only self.PlayActorSound("PIPEBOMB_EXPLODE"); for (x = 0; x < 8; x++) self.RANDOMSCRAP(); diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/mortar.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/mortar.zs index d1af75290..15b15fc56 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/mortar.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/mortar.zs @@ -91,7 +91,7 @@ class DukeMortar : DukeActor self.vel.Z *= 0.25; self.yint++; } - if (itemmode != 2 && self.pos.Z < self.ceilingz + self.ceilingdist && (!Raze.isRR() || sectp.lotag != ST_2_UNDERWATER)) // underwater check only for RR + if (itemmode != 2 && self.pos.Z < self.ceilingz + self.ceilingdist && (!isRR() || sectp.lotag != ST_2_UNDERWATER)) // underwater check only for RR { self.pos.Z = self.ceilingz + self.ceilingdist; self.vel.Z = 0; @@ -147,11 +147,11 @@ class DukeMortar : DukeActor int x = self.extra; int m = itemmode == 0? gs.bouncemineblastradius : gs.morterblastradius; - if (self.sector.lotag != 800 || !Raze.isRR()) // this line is RR only + if (self.sector.lotag != 800 || !isRR()) // this line is RR only { self.hitradius(m, x >> 2, x >> 1, x - (x >> 2), x); self.spawn("DukeExplosion2"); - if (self.vel.Z == 0 && !Raze.isRR()) self.spawn("DukeExplosion2Bot"); // this line is Duke only + if (self.vel.Z == 0 && !isRR()) self.spawn("DukeExplosion2Bot"); // this line is Duke only if (itemmode == 2) self.spawn("DukeBurning"); self.PlayActorSound("PIPEBOMB_EXPLODE"); for (x = 0; x < 8; x++) diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/projectilebase.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/projectilebase.zs index 37dcb6025..4e67c02c7 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/projectilebase.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/projectilebase.zs @@ -258,7 +258,7 @@ class DukeFirelaserTrail : DukeActor override bool animate(tspritetype tspr) { self.extra = 999; - if (Raze.isRR()) tspr.setSpritePic(self, ((PlayClock >> 2) % 6)); + if (isRR()) tspr.setSpritePic(self, ((PlayClock >> 2) % 6)); return true; } diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs index 9f0c4d5b6..9d7509e34 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs @@ -144,7 +144,7 @@ class DukeRPG : DukeProjectile if (actor is 'DukeBoss3') { double zoffs = 32; - if (Raze.isWorldTour()) // Twentieth Anniversary World Tour + if (isWorldTour()) // Twentieth Anniversary World Tour zoffs *= (actor.scale.Y * 0.8); pos.Z -= zoffs; } @@ -152,7 +152,7 @@ class DukeRPG : DukeProjectile { vel += 8; double zoffs = 24; - if (Raze.isWorldTour()) // Twentieth Anniversary World Tour + if (isWorldTour()) // Twentieth Anniversary World Tour zoffs *= (actor.scale.Y * 0.8); pos.Z += zoffs; } @@ -201,7 +201,7 @@ class DukeRPG : DukeProjectile aoffs = -aoffs; } - if (Raze.isWorldTour()) // Twentieth Anniversary World Tour + if (isWorldTour()) // Twentieth Anniversary World Tour { double siz = actor.scale.Y * 0.8; spawnofs *= siz; @@ -218,7 +218,7 @@ class DukeRPG : DukeProjectile Vector2 spawnofs = (sin(ang) * (1024. / 56.), cos(ang) * -(1024. / 56.)); let aoffs = 22.5 / 16. - frandom(-45, 45); - if (Raze.isWorldTour()) // Twentieth Anniversary World Tour + if (isWorldTour()) // Twentieth Anniversary World Tour { double siz = actor.scale.Y * 0.9143; spawnofs *= siz; @@ -236,7 +236,7 @@ class DukeRPG : DukeProjectile spawned.extra >>= 2; } } - else if (p.curr_weapon == DukeWpn.DEVISTATOR_WEAPON && !Raze.isRR()) + else if (p.curr_weapon == DukeWpn.DEVISTATOR_WEAPON && !isRR()) { spawned.extra >>= 2; spawned.Angle += frandom(-22.5 / 8, 22.5 / 8); diff --git a/wadsrc/static/zscript/games/duke/actors/redneckcstuff/chickenplant.zs b/wadsrc/static/zscript/games/duke/actors/redneckcstuff/chickenplant.zs index 7aff3ec58..1a5293cb3 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckcstuff/chickenplant.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckcstuff/chickenplant.zs @@ -77,7 +77,7 @@ class RedneckChickenHeadSpawner : RedneckChickenSpawner1 { let spawned = self.spawn('RedneckChickenHead'); self.lotag = 96; - if (spawned && !Raze.isRRRA()) self.PlayActorSound("POOLBUD"); + if (spawned && !isRRRA()) self.PlayActorSound("POOLBUD"); } } } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckenemies/coot.zs b/wadsrc/static/zscript/games/duke/actors/redneckenemies/coot.zs index b50fd3b4a..b4eea33c2 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckenemies/coot.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckenemies/coot.zs @@ -16,7 +16,7 @@ class RedneckCoot : DukeActor override void PlayFTASound(int mode) { - if (!Raze.isRRRA() && (random(0, 3)) == 2) + if (!isRRRA() && (random(0, 3)) == 2) self.PlayActorSound("CT_GET"); } @@ -25,7 +25,7 @@ class RedneckCoot : DukeActor self.scale = (0.375, 0.28125); self.setClipDistFromTile(); self.clipdist *= 4; - if (Raze.isRRRA()) bLookAllaround = true; + if (isRRRA()) bLookAllaround = true; } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckenemies/minion.zs b/wadsrc/static/zscript/games/duke/actors/redneckenemies/minion.zs index 4af22c8fd..58cbfd305 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckenemies/minion.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckenemies/minion.zs @@ -29,7 +29,7 @@ class RedneckMinion : DukeActor override bool animate(tspritetype t) { - if (Raze.isRRRA() && t.pal == 19) + if (isRRRA() && t.pal == 19) t.shade = -127; return false; } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckstuff/items.zs b/wadsrc/static/zscript/games/duke/actors/redneckstuff/items.zs index 45c8d08ac..ec3378a19 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckstuff/items.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckstuff/items.zs @@ -125,7 +125,7 @@ class RedneckShotgunammo : DukeItemBase override void Initialize() { commonItemSetup((0.28125, 0.265625)); - if (Raze.isRRRA()) self.cstat = CSTAT_SPRITE_BLOCK_HITSCAN; + if (isRRRA()) self.cstat = CSTAT_SPRITE_BLOCK_HITSCAN; } } @@ -238,7 +238,7 @@ class RedneckPorkRinds : DukeItemBase override void Initialize() { commonItemSetup((0.203125, 0.140625)); - if (Raze.isRRRA()) self.cstat = CSTAT_SPRITE_BLOCK_HITSCAN; + if (isRRRA()) self.cstat = CSTAT_SPRITE_BLOCK_HITSCAN; } } class RedneckGoogooCluster : DukeItemBase diff --git a/wadsrc/static/zscript/games/duke/actors/respawncontroller.zs b/wadsrc/static/zscript/games/duke/actors/respawncontroller.zs index c152c1b67..717a665f6 100644 --- a/wadsrc/static/zscript/games/duke/actors/respawncontroller.zs +++ b/wadsrc/static/zscript/games/duke/actors/respawncontroller.zs @@ -20,7 +20,7 @@ class DukeRespawnController : DukeActor if (self.extra == 66) { let newact = self.spawnsprite(self.hitag); - if (Raze.isRRRA() && newact) + if (isRRRA() && newact) { newact.pal = self.pal; diff --git a/wadsrc/static/zscript/games/duke/actors/touchplate.zs b/wadsrc/static/zscript/games/duke/actors/touchplate.zs index 148245780..641c0753b 100644 --- a/wadsrc/static/zscript/games/duke/actors/touchplate.zs +++ b/wadsrc/static/zscript/games/duke/actors/touchplate.zs @@ -3,7 +3,7 @@ class DukeTouchPlate : DukeActor { private bool checkspawn() { - if (!Raze.isWorldTour()) + if (!isWorldTour()) { if (self.pal && ud.multimode > 1) return false; } diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index da9c20398..2123fbd41 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -464,7 +464,7 @@ class DukeActor : CoreActor native } // RR defaults to using the floor shade here, let's make this configurable. - if (usefloorshade == 1 || (usefloorshade == -1 && Raze.isRR())) + if (usefloorshade == 1 || (usefloorshade == -1 && isRR())) { self.shade = self.sector.floorshade; } diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index d95da109a..8077712e7 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -203,7 +203,7 @@ struct Duke native static void BigText(double x, double y, String text, int align = -1, double alpha = 1.) { let myfont = Raze.PickBigFont(); - if (!Raze.isRR()) + if (!isRR()) { if (align != -1) x -= myfont.StringWidth(text) * (align == 0 ? 0.5 : 1); Screen.DrawText(myfont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Alpha, alpha); @@ -219,7 +219,7 @@ struct Duke native { let myfont = Raze.PickSmallFont(); int fsmode = FSMode_Fit320x200; - if (Raze.isRR()) + if (isRR()) { x *= 2; y *= 2; diff --git a/wadsrc/static/zscript/games/duke/ui/cutscenes.zs b/wadsrc/static/zscript/games/duke/ui/cutscenes.zs index 6b4cb6653..35fdc36f4 100644 --- a/wadsrc/static/zscript/games/duke/ui/cutscenes.zs +++ b/wadsrc/static/zscript/games/duke/ui/cutscenes.zs @@ -38,7 +38,7 @@ class DukeCutscenes ui // Note: must be class, not struct, otherwise we cannot e { if (!userConfig.nologo) { - if (!Raze.isShareware()) + if (!isShareware()) { Array soundinfo; soundinfo.Pushv( @@ -46,7 +46,7 @@ class DukeCutscenes ui // Note: must be class, not struct, otherwise we cannot e 19, int(Sound("PIPEBOMB_EXPLODE"))); runner.Append(MoviePlayerJob.CreateWithSoundinfo("logo.anm", soundinfo, 0, 9, 9, 9)); } - if (!Raze.isNam()) runner.Append(new("DRealmsScreen").Init()); + if (!isNam()) runner.Append(new("DRealmsScreen").Init()); } runner.Append(new("DukeTitleScreen").Init()); } @@ -116,7 +116,7 @@ class DukeCutscenes ui // Note: must be class, not struct, otherwise we cannot e runner.Append(MoviePlayerJob.CreateWithSoundinfo("cineov3.anm", soundinfo, 0, 10, 10, 10)); runner.Append(BlackScreen.Create(200, ScreenJob.stopsound)); runner.Append(new("Episode3End").Init()); - if (!Raze.isPlutoPak()) runner.Append(ImageScreen.CreateNamed("DUKETEAM.ANM", ScreenJob.fadein | ScreenJob.fadeout | ScreenJob.stopsound, 0x7fffffff)); + if (!isPlutoPak()) runner.Append(ImageScreen.CreateNamed("DUKETEAM.ANM", ScreenJob.fadein | ScreenJob.fadeout | ScreenJob.stopsound, 0x7fffffff)); } } @@ -310,7 +310,7 @@ class RRCutscenes ui static void BuildE1End(ScreenJobRunner runner) { - if (!Raze.isRRRA()) + if (!isRRRA()) { Array soundinfo; soundinfo.Pushv(1, int(Sound("CHKAMMO"))); @@ -352,7 +352,7 @@ class RRCutscenes ui static void BuildSPSummary(ScreenJobRunner runner, MapRecord map, SummaryInfo stats) { - runner.Append(new("RRLevelSummaryScreen").Init(map, stats, !Raze.isRRRA() || stats.endOfGame)); + runner.Append(new("RRLevelSummaryScreen").Init(map, stats, !isRRRA() || stats.endOfGame)); } //--------------------------------------------------------------------------- diff --git a/wadsrc/static/zscript/games/duke/ui/sbar.zs b/wadsrc/static/zscript/games/duke/ui/sbar.zs index 06a0e9616..fa9ef739c 100644 --- a/wadsrc/static/zscript/games/duke/ui/sbar.zs +++ b/wadsrc/static/zscript/games/duke/ui/sbar.zs @@ -147,7 +147,7 @@ class DukeCommonStatusBar : RazeStatusBar int select = 1 << (p.inven_icon - 1); double alpha = select == i ? 1.0 : 0.7; DrawImage(item_icons[bit+1], (x, y), align, alpha, scale:(scale, scale)); - if (select == i) DrawImage("ARROW", (Raze.isWW2GI()? x + 7.5 : x, Raze.isWW2GI()? y + 0.5 : y), align, alpha, scale:(scale, scale)); + if (select == i) DrawImage("ARROW", (isWW2GI()? x + 7.5 : x, isWW2GI()? y + 0.5 : y), align, alpha, scale:(scale, scale)); x += 22; } } @@ -162,7 +162,7 @@ class DukeCommonStatusBar : RazeStatusBar void DoLevelStats(int bottomy, SummaryInfo info) { StatsPrintInfo stats; - stats.fontscale = Raze.isRR() ? 0.5 : 1.; + stats.fontscale = isRR() ? 0.5 : 1.; stats.screenbottomspace = bottomy; int y = -1; @@ -171,8 +171,8 @@ class DukeCommonStatusBar : RazeStatusBar { stats.statfont = SmallFont2; stats.spacing = 6; - if (Raze.isNamWW2GI()) stats.altspacing = 10; - else if (!Raze.isRR()) stats.altspacing = 11; + if (isNamWW2GI()) stats.altspacing = 10; + else if (!isRR()) stats.altspacing = 11; else stats.altspacing = 14; stats.standardColor = Font.TEXTCOLOR_UNTRANSLATED; @@ -184,14 +184,14 @@ class DukeCommonStatusBar : RazeStatusBar { stats.statfont = SmallFont; stats.letterColor = Font.TEXTCOLOR_ORANGE; - if (Raze.isNamWW2GI()) + if (isNamWW2GI()) { stats.statfont = ConFont; stats.spacing = 8; stats.standardColor = Font.TEXTCOLOR_YELLOW; stats.completeColor = Font.TEXTCOLOR_FIRE; } - else if (!Raze.isRR()) + else if (!isRR()) { stats.spacing = 7; stats.standardColor = Font.TEXTCOLOR_CREAM; diff --git a/wadsrc/static/zscript/games/duke/ui/sbar_d.zs b/wadsrc/static/zscript/games/duke/ui/sbar_d.zs index bb25d91ba..50bf3d24d 100644 --- a/wadsrc/static/zscript/games/duke/ui/sbar_d.zs +++ b/wadsrc/static/zscript/games/duke/ui/sbar_d.zs @@ -149,7 +149,7 @@ class DukeStatusBar : DukeCommonStatusBar // // Health // - img = TexMan.CheckForTexture(Raze.isNamWW2GI()? "FIRSTAID_ICON" : "COLA"); + img = TexMan.CheckForTexture(isNamWW2GI()? "FIRSTAID_ICON" : "COLA"); let siz = TexMan.GetScaledSize(img); imgScale = baseScale / siz.Y; DrawTexture(img, (2, -1.5), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); @@ -191,7 +191,7 @@ class DukeStatusBar : DukeCommonStatusBar } else { - int clip = CalcMagazineAmount(ammo, Raze.isNam() ? 20 : 12, p.kickback_pic >= 1); + int clip = CalcMagazineAmount(ammo, isNam() ? 20 : 12, p.kickback_pic >= 1); format = String.Format("%d/%d", clip, ammo - clip); } img = TexMan.CheckForTexture(wicon, TexMan.TYPE_Any); @@ -209,7 +209,7 @@ class DukeStatusBar : DukeCommonStatusBar { DrawString(numberFont, format, (-3, texty), DI_TEXT_ALIGN_RIGHT, Font.CR_UNTRANSLATED); } - if (weapon != 7 || !Raze.isNam()) + if (weapon != 7 || !isNam()) DrawTexture(img, (-imgX, -1.5), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); } @@ -505,7 +505,7 @@ class DukeStatusBar : DukeCommonStatusBar stats.info.statfont = SmallFont; stats.info.letterColor = Font.TEXTCOLOR_ORANGE; - if (Raze.isNamWW2GI()) + if (isNamWW2GI()) { stats.info.statfont = ConFont; stats.info.spacing = 8; @@ -520,7 +520,7 @@ class DukeStatusBar : DukeCommonStatusBar } let p = Duke.GetViewPlayer(); - stats.healthicon = Raze.isNamWW2GI()? "FIRSTAID_ICON" : "COLA"; + stats.healthicon = isNamWW2GI()? "FIRSTAID_ICON" : "COLA"; stats.healthvalue = p.last_extra; let armorval = GetMoraleOrShield(p); @@ -544,7 +544,7 @@ class DukeStatusBar : DukeCommonStatusBar static const String weaponIcons[] = { "", "FIRSTGUNSPRITE", "SHOTGUNSPRITE", "CHAINGUNSPRITE", "RPGSPRITE", "" /*pipe bomb*/, "SHRINKERSPRITE", "DEVISTATORSPRITE", "" /*trip bomb*/, "FREEZESPRITE", "" /*handremote*/, "" /*grower*/, "FLAMETHROWERSPRITE" }; - int maxweap = Raze.IsWorldTour()? 12 : 10; + int maxweap = isWorldTour()? 12 : 10; for(int i = 0; i <= maxweap; i++) { @@ -562,12 +562,12 @@ class DukeStatusBar : DukeCommonStatusBar static const int ammoOrder[] = { DukeWpn.PISTOL_WEAPON, DukeWpn.SHOTGUN_WEAPON, DukeWpn.CHAINGUN_WEAPON, DukeWpn.RPG_WEAPON, DukeWpn.HANDBOMB_WEAPON, DukeWpn.SHRINKER_WEAPON, DukeWpn.GROW_WEAPON, DukeWpn.DEVISTATOR_WEAPON, DukeWpn.TRIPBOMB_WEAPON, DukeWpn.FREEZE_WEAPON, DukeWpn.FLAMETHROWER_WEAPON }; - int maxammo = Raze.IsWorldTour()? 11 : 10; + int maxammo = isWorldTour()? 11 : 10; for(int i = 0; i < maxammo; i++) { int ammonum = ammoorder[i]; - if (ammonum == DukeWpn.GROW_WEAPON && !Raze.isPlutoPak()) continue; + if (ammonum == DukeWpn.GROW_WEAPON && !isPlutoPak()) continue; if (p.curr_weapon == ammonum || (p.curr_weapon == DukeWpn.HANDREMOTE_WEAPON && ammonum == DukeWpn.HANDBOMB_WEAPON)) { stats.ammoselect = stats.ammoicons.Size(); diff --git a/wadsrc/static/zscript/games/duke/ui/sbar_r.zs b/wadsrc/static/zscript/games/duke/ui/sbar_r.zs index e51f8b656..d2e128a1c 100644 --- a/wadsrc/static/zscript/games/duke/ui/sbar_r.zs +++ b/wadsrc/static/zscript/games/duke/ui/sbar_r.zs @@ -519,7 +519,7 @@ class RedneckStatusBar : DukeCommonStatusBar for(int i = 0; i < ammoOrder.Size(); i++) { int ammonum = ammoorder[i]; - if (ammonum == RRWpn.CHICKEN_WEAPON && !Raze.isRRRA()) continue; + if (ammonum == RRWpn.CHICKEN_WEAPON && !isRRRA()) continue; if (ammonum == RRWpn.MOTORCYCLE_WEAPON && !p.OnMotorcycle) continue; if (ammonum == RRWpn.BOAT_WEAPON && !p.OnBoat) continue; // dynamite and crossbow dynamite ammo types are coupled. diff --git a/wadsrc/static/zscript/games/duke/ui/screens.zs b/wadsrc/static/zscript/games/duke/ui/screens.zs index 64fd5bb16..295108823 100644 --- a/wadsrc/static/zscript/games/duke/ui/screens.zs +++ b/wadsrc/static/zscript/games/duke/ui/screens.zs @@ -80,7 +80,7 @@ class DukeTitleScreen : SkippableScreenJob override void Start() { - if (Raze.isNam() || userConfig.nologo) Duke.PlaySpecialMusic(Duke.MUS_INTRO); + if (isNam() || userConfig.nologo) Duke.PlaySpecialMusic(Duke.MUS_INTRO); } override void OnTick() @@ -99,12 +99,12 @@ class DukeTitleScreen : SkippableScreenJob if (soundanm == 2 && clock >= 280 && clock < 395) { soundanm = 3; - if (Raze.isPlutoPak()) Duke.PlaySound("FLY_BY", CHAN_AUTO, CHANF_UI); + if (isPlutoPak()) Duke.PlaySound("FLY_BY", CHAN_AUTO, CHANF_UI); } else if (soundanm == 3 && clock >= 395) { soundanm = 4; - if (Raze.isPlutoPak()) Duke.PlaySound("PIPEBOMB_EXPLODE", CHAN_AUTO, CHANF_UI); + if (isPlutoPak()) Duke.PlaySound("PIPEBOMB_EXPLODE", CHAN_AUTO, CHANF_UI); } if (clock > (860 + 120)) @@ -143,7 +143,7 @@ class DukeTitleScreen : SkippableScreenJob DTA_CenterOffsetRel, true, DTA_TranslationIndex, trans, DTA_ScaleX, scale, DTA_ScaleY, scale); } - if (Raze.isPlutoPak()) + if (isPlutoPak()) { scale = (410 - clamp(clock, 280, 395)) / 16.; if (scale > 0. && clock > 280) @@ -373,7 +373,7 @@ class Episode3End : ImageScreen break; case 6: - if (Raze.isPlutoPak()) + if (isPlutoPak()) { if (ticks > finishtime) jobstate = finished; } @@ -388,7 +388,7 @@ class Episode3End : ImageScreen override void OnDestroy() { - if (!Raze.isPlutoPak()) Duke.PlaySound("ENDSEQVOL3SND4", CHAN_AUTO, CHANF_UI); + if (!isPlutoPak()) Duke.PlaySound("ENDSEQVOL3SND4", CHAN_AUTO, CHANF_UI); } } @@ -461,19 +461,19 @@ class DukeMultiplayerBonusScreen : SkippableScreenJob override void Start() { - if (!Raze.isRR()) Duke.PlayBonusMusic(); + if (!isRR()) Duke.PlayBonusMusic(); } override void Draw(double smoothratio) { - bool isRR = Raze.isRR(); + bool isRR = isRR(); double titlescale = isRR? 0.36 : 1; String tempbuf; int currentclock = int((ticks + smoothratio) * 120 / GameTicRate); Screen.DrawTexture(TexMan.CheckForTexture("MENUSCREEN"), false, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal); Screen.DrawTexture(TexMan.CheckForTexture("INGAMEDUKETHREEDEE"), true, 160, 34, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, DTA_ScaleX, titlescale, DTA_ScaleY, titlescale); - if (Raze.isPlutoPak()) Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), true, 260, 36, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true); + if (isPlutoPak()) Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), true, 260, 36, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true); Raze.DrawScoreboard(60); } @@ -647,7 +647,7 @@ class DukeLevelSummaryScreen : SummaryScreenBase String tempbuf; Duke.GameText(text_x, 59 + 9, "$TXT_YourTime", 0); Duke.GameText(text_x, 69 + 9, "$TXT_ParTime", 0); - if (!Raze.isNamWW2GI()) + if (!isNamWW2GI()) Duke.GameText(text_x, 79 + 9, "$TXT_3DRTIME", 0); if (displaystate & printTimeVal) @@ -658,7 +658,7 @@ class DukeLevelSummaryScreen : SummaryScreenBase tempbuf = FormatTime(level.parTime); Duke.GameText(val_x, 69 + 9, tempbuf, 0); - if (!Raze.isNamWW2GI()) + if (!isNamWW2GI()) { tempbuf = FormatTime(level.designerTime); Duke.GameText(val_x, 79 + 9, tempbuf, 0); @@ -1084,14 +1084,14 @@ class DukeLoadScreen : ScreenJob { Screen.DrawTexture(TexMan.CheckForTexture("LOADSCREEN"), false, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal); - if (!Raze.IsRR()) + if (!isRR()) { Duke.BigText(160, 90, (rec.flags & MapRecord.USERMAP)? "$TXT_LOADUM" : "$TXT_LOADING", 0); Duke.BigText(160, 114, rec.DisplayName(), 0); } else { - int y = Raze.isRRRA()? 140 : 90; + int y = isRRRA()? 140 : 90; Duke.BigText(160, y, (rec.flags & MapRecord.USERMAP)? "$TXT_ENTRUM" : "$TXT_ENTERIN", 0); Duke.BigText(160, y+24, rec.DisplayName(), 0); } diff --git a/wadsrc/static/zscript/games/sw/ui/screens.zs b/wadsrc/static/zscript/games/sw/ui/screens.zs index 56add9809..91a9803c3 100644 --- a/wadsrc/static/zscript/games/sw/ui/screens.zs +++ b/wadsrc/static/zscript/games/sw/ui/screens.zs @@ -458,7 +458,7 @@ class SWCutscenes ui static void BuildSybexScreen(ScreenJobRunner runner) { - if (Raze.isShareware() && !netgame) + if (isShareware() && !netgame) runner.Append(ImageScreen.CreateNamed("SYBEXSCREEN", TexMan.Type_Any)); } diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index ca8d671ae..5d382de46 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -222,73 +222,6 @@ struct Raze native static bool cansee(Vector3 start, sectortype startsec, Vector3 end, sectortype endsec); native static int hitscan(Vector3 start, sectortype startsect, Vector3 vect, HitInfo hitinfo, uint cliptype, double maxrange = -1); - // game check shortcuts (todo: meake these compile time constant intrinsics) - - static bool isDuke() - { - return gameinfo.gametype & GAMEFLAG_DUKE; - } - - static bool isNam() - { - return gameinfo.gametype & (GAMEFLAG_NAM | GAMEFLAG_NAPALM); - } - - static bool isNamWW2GI() - { - return gameinfo.gametype & (GAMEFLAG_NAM | GAMEFLAG_NAPALM |GAMEFLAG_WW2GI); - } - - static bool isWW2GI() - { - return gameinfo.gametype & (GAMEFLAG_WW2GI); - } - - static bool isRR() - { - return gameinfo.gametype & (GAMEFLAG_RRALL); - } - - static bool isRoute66() - { - return gameinfo.gametype & (GAMEFLAG_ROUTE66); - } - - static bool isRRRA() - { - return gameinfo.gametype & (GAMEFLAG_RRRA); - } - - static bool isWorldTour() - { - return gameinfo.gametype & GAMEFLAG_WORLDTOUR; - } - - static bool isPlutoPak() - { - return gameinfo.gametype & GAMEFLAG_PLUTOPAK; - } - - static bool isVacation() - { - return gameinfo.gametype & GAMEFLAG_DUKEVACA; - } - - static bool isShareware() - { - return gameinfo.gametype & GAMEFLAG_SHAREWARE; - } - - static bool isBlood() - { - return gameinfo.gametype & GAMEFLAG_BLOOD; - } - - static bool isSW() - { - return gameinfo.gametype & GAMEFLAG_SW; - } - // Dont know yet how to best export this, so for now these are just placeholders as MP is not operational anyway. static int playerPalette(int i) { diff --git a/wadsrc/static/zscript/statusbar.zs b/wadsrc/static/zscript/statusbar.zs index e248aea46..cb9073e51 100644 --- a/wadsrc/static/zscript/statusbar.zs +++ b/wadsrc/static/zscript/statusbar.zs @@ -143,7 +143,7 @@ class RazeStatusBar : StatusBarCore { scale = info.fontscale * hud_statscale; spacing = info.altspacing * hud_statscale; - myfont = Raze.isNamWW2GI()? ConFont : Raze.PickSmallFont(allname); + myfont = isNamWW2GI()? ConFont : Raze.PickSmallFont(allname); } String mapname;