mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-13 04:24:39 +00:00
- 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.
This commit is contained in:
parent
f1f1e54e04
commit
bf577916ec
38 changed files with 827 additions and 148 deletions
|
@ -938,6 +938,7 @@ set (PCH_SOURCES
|
||||||
|
|
||||||
core/actorinfo.cpp
|
core/actorinfo.cpp
|
||||||
core/zcc_compile_raze.cpp
|
core/zcc_compile_raze.cpp
|
||||||
|
core/codegen_raze.cpp
|
||||||
core/vmexports.cpp
|
core/vmexports.cpp
|
||||||
core/thingdef_data.cpp
|
core/thingdef_data.cpp
|
||||||
core/thingdef_properties.cpp
|
core/thingdef_properties.cpp
|
||||||
|
|
599
source/core/codegen_raze.cpp
Normal file
599
source/core/codegen_raze.cpp
Normal file
|
@ -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 <stdlib.h>
|
||||||
|
#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<PObjectPointer *>(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<FxConstant *>(Self)->GetValue().GetName());
|
||||||
|
if (cls == nullptr)
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "GetDefaultByType() requires an actor class type, but got %s", static_cast<FxConstant *>(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<FxConstant *>(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;
|
||||||
|
}
|
114
source/core/codegen_raze.h
Normal file
114
source/core/codegen_raze.h
Normal file
|
@ -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);
|
||||||
|
};
|
||||||
|
|
|
@ -180,6 +180,11 @@ inline bool isRRRA()
|
||||||
return g_gameType & (GAMEFLAG_RRRA);
|
return g_gameType & (GAMEFLAG_RRRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isRoute66()
|
||||||
|
{
|
||||||
|
return g_gameType & (GAMEFLAG_ROUTE66);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool isWorldTour()
|
inline bool isWorldTour()
|
||||||
{
|
{
|
||||||
return g_gameType & GAMEFLAG_WORLDTOUR;
|
return g_gameType & GAMEFLAG_WORLDTOUR;
|
||||||
|
@ -190,6 +195,11 @@ inline bool isPlutoPak()
|
||||||
return g_gameType & GAMEFLAG_PLUTOPAK;
|
return g_gameType & GAMEFLAG_PLUTOPAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isVacation()
|
||||||
|
{
|
||||||
|
return g_gameType & GAMEFLAG_DUKEVACA;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool isShareware()
|
inline bool isShareware()
|
||||||
{
|
{
|
||||||
return g_gameType & GAMEFLAG_SHAREWARE;
|
return g_gameType & GAMEFLAG_SHAREWARE;
|
||||||
|
|
|
@ -33,3 +33,23 @@ xx(landmovefactor)
|
||||||
xx(watermovefactor)
|
xx(watermovefactor)
|
||||||
xx(gravityfactor)
|
xx(gravityfactor)
|
||||||
xx(minhitscale)
|
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)
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
void InitThingdef();
|
void InitThingdef();
|
||||||
void SynthesizeFlagFields();
|
void SynthesizeFlagFields();
|
||||||
|
void SetRazeCompileEnvironment();
|
||||||
|
|
||||||
void ParseScripts()
|
void ParseScripts()
|
||||||
{
|
{
|
||||||
|
@ -82,6 +83,7 @@ void LoadScripts()
|
||||||
cycle_t timer;
|
cycle_t timer;
|
||||||
|
|
||||||
PType::StaticInit();
|
PType::StaticInit();
|
||||||
|
SetRazeCompileEnvironment();
|
||||||
InitThingdef();
|
InitThingdef();
|
||||||
timer.Reset(); timer.Clock();
|
timer.Reset(); timer.Clock();
|
||||||
FScriptPosition::ResetErrorCounter();
|
FScriptPosition::ResetErrorCounter();
|
||||||
|
|
|
@ -106,12 +106,12 @@ class AltHud ui
|
||||||
|
|
||||||
virtual void Init()
|
virtual void Init()
|
||||||
{
|
{
|
||||||
HudFont = BigFont; // Strife doesn't have anything nice so use the standard font
|
HudFont = BigFont;
|
||||||
if (Raze.isBlood()) HudFont = Font.GetFont("HUDFONT_BLOOD");
|
if (isBlood()) HudFont = Font.GetFont("HUDFONT_BLOOD");
|
||||||
else if (Raze.isDuke()) HudFontOffset = 6;
|
else if (isDuke()) HudFontOffset = 6;
|
||||||
IndexFont = Font.GetFont("HUDINDEXFONT");
|
IndexFont = Font.GetFont("HUDINDEXFONT");
|
||||||
if (IndexFont == NULL) IndexFont = ConFont; // Emergency fallback
|
if (IndexFont == NULL) IndexFont = ConFont; // Emergency fallback
|
||||||
if (!Raze.isNamWW2GI())
|
if (!isNamWW2GI())
|
||||||
StatFont = SmallFont;
|
StatFont = SmallFont;
|
||||||
else
|
else
|
||||||
StatFont = ConFont;
|
StatFont = ConFont;
|
||||||
|
@ -277,7 +277,7 @@ class AltHud ui
|
||||||
Font.CR_BLUE;
|
Font.CR_BLUE;
|
||||||
|
|
||||||
DrawImageToBox(TexMan.CheckForTexture(currentStats.healthicon), x, y, 31, 17, 0.75, true);
|
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);
|
DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17, fontscale:fontscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ class AltHud ui
|
||||||
Font.CR_BLUE;
|
Font.CR_BLUE;
|
||||||
|
|
||||||
DrawImageToBox(TexMan.CheckForTexture(currentStats.armoricons[i]), x, y, 31, 17, 0.75, true);
|
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);
|
if (ap >= 0) DrawHudNumber(HudFont, fontcolor, ap, x + 33, y + 17, fontscale:fontscale);
|
||||||
x += 35 + spacing;
|
x += 35 + spacing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class DukeActivator : DukeActor
|
||||||
if (a2.statnum == STAT_EFFECTOR) switch (a2.lotag)
|
if (a2.statnum == STAT_EFFECTOR) switch (a2.lotag)
|
||||||
{
|
{
|
||||||
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
||||||
if (Raze.isRRRA()) break;
|
if (isRRRA()) break;
|
||||||
|
|
||||||
case SE_36_PROJ_SHOOTER:
|
case SE_36_PROJ_SHOOTER:
|
||||||
case SE_31_FLOOR_RISE_FALL:
|
case SE_31_FLOOR_RISE_FALL:
|
||||||
|
@ -71,7 +71,7 @@ class DukeActivatorLocked : DukeActor
|
||||||
override void Initialize()
|
override void Initialize()
|
||||||
{
|
{
|
||||||
self.cstat = CSTAT_SPRITE_INVISIBLE;
|
self.cstat = CSTAT_SPRITE_INVISIBLE;
|
||||||
if (!Raze.IsRR()) self.sector.lotag |= 16384;
|
if (!isRR()) self.sector.lotag |= 16384;
|
||||||
else self.sector.lotag ^= 16384;
|
else self.sector.lotag ^= 16384;
|
||||||
self.ChangeStat(STAT_ACTIVATOR);
|
self.ChangeStat(STAT_ACTIVATOR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DukeBloodPool : DukeActor
|
||||||
}
|
}
|
||||||
else self.insertspriteq();
|
else self.insertspriteq();
|
||||||
}
|
}
|
||||||
if (Raze.isRR() && self.sector.lotag == 800)
|
if (isRR() && self.sector.lotag == 800)
|
||||||
{
|
{
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -26,7 +26,7 @@ class DukeCactus : DukeCactusBroke
|
||||||
{
|
{
|
||||||
if (self.spritesetindex == 0 && hitter.bINFLAME)
|
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++)
|
for (int k = 0; k < 64; k++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ class DukeFrameEffect : DukeActor
|
||||||
}
|
}
|
||||||
if ((OwnerAc.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
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);
|
else t.SetSpritePic(OwnerAc, 0);
|
||||||
t.pal = OwnerAc.pal;
|
t.pal = OwnerAc.pal;
|
||||||
t.shade = OwnerAc.shade;
|
t.shade = OwnerAc.shade;
|
||||||
|
|
|
@ -63,7 +63,7 @@ class DukeJibs1 : DukeActor
|
||||||
if(self.vel.X > 0) self.vel.X -= 1/16.;
|
if(self.vel.X > 0) self.vel.X -= 1/16.;
|
||||||
else self.vel.X = 0;
|
else self.vel.X = 0;
|
||||||
|
|
||||||
if (!Raze.IsRR())
|
if (!isRR())
|
||||||
{
|
{
|
||||||
if (self.temp_data[0] < 30 * 10)
|
if (self.temp_data[0] < 30 * 10)
|
||||||
self.temp_data[0]++;
|
self.temp_data[0]++;
|
||||||
|
@ -126,7 +126,7 @@ class DukeJibs1 : DukeActor
|
||||||
self.pos += self.angle.ToVector() * self.vel.X;
|
self.pos += self.angle.ToVector() * self.vel.X;
|
||||||
self.pos.Z += self.vel.Z;
|
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();
|
self.Destroy();
|
||||||
return;
|
return;
|
||||||
|
@ -175,7 +175,7 @@ class DukeJibs1 : DukeActor
|
||||||
return;
|
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();
|
self.Destroy();
|
||||||
return;
|
return;
|
||||||
|
@ -186,7 +186,7 @@ class DukeJibs1 : DukeActor
|
||||||
|
|
||||||
override bool animate(tspritetype tspr)
|
override bool animate(tspritetype tspr)
|
||||||
{
|
{
|
||||||
if (Raze.isRRRA() && tspr.pal == 19)
|
if (isRRRA() && tspr.pal == 19)
|
||||||
tspr.shade = -127;
|
tspr.shade = -127;
|
||||||
|
|
||||||
if (spritesetindex == 1)
|
if (spritesetindex == 1)
|
||||||
|
@ -264,7 +264,7 @@ class DukeJibs6 : DukeJibs1
|
||||||
|
|
||||||
override void Initialize()
|
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);
|
self.setSpriteSetImage(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DukeOoz : DukeActor
|
||||||
{
|
{
|
||||||
if (self.bPAL8OOZ)
|
if (self.bPAL8OOZ)
|
||||||
self.pal = 8;
|
self.pal = 8;
|
||||||
if (!Raze.IsRR()) self.insertspriteq();
|
if (!isRR()) self.insertspriteq();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.getglobalz();
|
self.getglobalz();
|
||||||
|
|
|
@ -33,7 +33,7 @@ class DukeRat : DukeActor
|
||||||
self.makeitfall();
|
self.makeitfall();
|
||||||
if (self.DoMove(CLIPMASK0))
|
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);
|
self.angle += Raze.BAngToDegree * (random(-15, 15) + Raze.BobVal(self.counter << 8) * 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -44,7 +44,7 @@ class DukeShell : DukeActor
|
||||||
self.vel.X = -direction;
|
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.scale = (scale, scale);
|
||||||
}
|
}
|
||||||
self.shade = -8;
|
self.shade = -8;
|
||||||
|
|
|
@ -68,7 +68,7 @@ class DukeToilet : DukeStall
|
||||||
|
|
||||||
override void StandingOn(DukePlayer p)
|
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.actor.PlayActorSound("CRAP");
|
||||||
p.last_pissed_time = 4000;
|
p.last_pissed_time = 4000;
|
||||||
|
|
|
@ -49,7 +49,7 @@ class DukeWaterDrip : DukeActor
|
||||||
{
|
{
|
||||||
self.cstat |= CSTAT_SPRITE_INVISIBLE;
|
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");
|
self.PlayActorSound("SOMETHING_DRIPPING");
|
||||||
|
|
||||||
if (!self.mapSpawned)
|
if (!self.mapSpawned)
|
||||||
|
|
|
@ -18,7 +18,7 @@ class DukeBossBase : DukeActor
|
||||||
if (owner && owner is 'DukeRespawnController')
|
if (owner && owner is 'DukeRespawnController')
|
||||||
self.pal = owner.pal;
|
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.clipdist = 20;
|
||||||
self.scale = (0.625, 0.625);
|
self.scale = (0.625, 0.625);
|
||||||
|
|
|
@ -74,7 +74,7 @@ class DukePipeBomb : DukeActor
|
||||||
self.makeitfall();
|
self.makeitfall();
|
||||||
|
|
||||||
// Feature check later needs to be map controlled, not game controlled.
|
// 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))
|
if (self.yint > 0 || (self.yint == 0 && self.floorz == sectp.floorz))
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ class DukePipeBomb : DukeActor
|
||||||
bool bBoom = false;
|
bool bBoom = false;
|
||||||
if (Owner && Owner.isPlayer())
|
if (Owner && Owner.isPlayer())
|
||||||
{
|
{
|
||||||
if (Raze.isNamWW2GI())
|
if (isNamWW2GI())
|
||||||
{
|
{
|
||||||
self.extra--;
|
self.extra--;
|
||||||
if (self.extra <= 0)
|
if (self.extra <= 0)
|
||||||
|
@ -153,11 +153,11 @@ class DukePipeBomb : DukeActor
|
||||||
int x = self.extra;
|
int x = self.extra;
|
||||||
int m = gs.pipebombblastradius;
|
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.hitradius(m, x >> 2, x >> 1, x - (x >> 2), x);
|
||||||
self.spawn("DukeExplosion2");
|
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");
|
self.PlayActorSound("PIPEBOMB_EXPLODE");
|
||||||
for (x = 0; x < 8; x++)
|
for (x = 0; x < 8; x++)
|
||||||
self.RANDOMSCRAP();
|
self.RANDOMSCRAP();
|
||||||
|
|
|
@ -91,7 +91,7 @@ class DukeMortar : DukeActor
|
||||||
self.vel.Z *= 0.25;
|
self.vel.Z *= 0.25;
|
||||||
self.yint++;
|
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.pos.Z = self.ceilingz + self.ceilingdist;
|
||||||
self.vel.Z = 0;
|
self.vel.Z = 0;
|
||||||
|
@ -147,11 +147,11 @@ class DukeMortar : DukeActor
|
||||||
int x = self.extra;
|
int x = self.extra;
|
||||||
int m = itemmode == 0? gs.bouncemineblastradius : gs.morterblastradius;
|
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.hitradius(m, x >> 2, x >> 1, x - (x >> 2), x);
|
||||||
self.spawn("DukeExplosion2");
|
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");
|
if (itemmode == 2) self.spawn("DukeBurning");
|
||||||
self.PlayActorSound("PIPEBOMB_EXPLODE");
|
self.PlayActorSound("PIPEBOMB_EXPLODE");
|
||||||
for (x = 0; x < 8; x++)
|
for (x = 0; x < 8; x++)
|
||||||
|
|
|
@ -258,7 +258,7 @@ class DukeFirelaserTrail : DukeActor
|
||||||
override bool animate(tspritetype tspr)
|
override bool animate(tspritetype tspr)
|
||||||
{
|
{
|
||||||
self.extra = 999;
|
self.extra = 999;
|
||||||
if (Raze.isRR()) tspr.setSpritePic(self, ((PlayClock >> 2) % 6));
|
if (isRR()) tspr.setSpritePic(self, ((PlayClock >> 2) % 6));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class DukeRPG : DukeProjectile
|
||||||
if (actor is 'DukeBoss3')
|
if (actor is 'DukeBoss3')
|
||||||
{
|
{
|
||||||
double zoffs = 32;
|
double zoffs = 32;
|
||||||
if (Raze.isWorldTour()) // Twentieth Anniversary World Tour
|
if (isWorldTour()) // Twentieth Anniversary World Tour
|
||||||
zoffs *= (actor.scale.Y * 0.8);
|
zoffs *= (actor.scale.Y * 0.8);
|
||||||
pos.Z -= zoffs;
|
pos.Z -= zoffs;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ class DukeRPG : DukeProjectile
|
||||||
{
|
{
|
||||||
vel += 8;
|
vel += 8;
|
||||||
double zoffs = 24;
|
double zoffs = 24;
|
||||||
if (Raze.isWorldTour()) // Twentieth Anniversary World Tour
|
if (isWorldTour()) // Twentieth Anniversary World Tour
|
||||||
zoffs *= (actor.scale.Y * 0.8);
|
zoffs *= (actor.scale.Y * 0.8);
|
||||||
pos.Z += zoffs;
|
pos.Z += zoffs;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ class DukeRPG : DukeProjectile
|
||||||
aoffs = -aoffs;
|
aoffs = -aoffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Raze.isWorldTour()) // Twentieth Anniversary World Tour
|
if (isWorldTour()) // Twentieth Anniversary World Tour
|
||||||
{
|
{
|
||||||
double siz = actor.scale.Y * 0.8;
|
double siz = actor.scale.Y * 0.8;
|
||||||
spawnofs *= siz;
|
spawnofs *= siz;
|
||||||
|
@ -218,7 +218,7 @@ class DukeRPG : DukeProjectile
|
||||||
Vector2 spawnofs = (sin(ang) * (1024. / 56.), cos(ang) * -(1024. / 56.));
|
Vector2 spawnofs = (sin(ang) * (1024. / 56.), cos(ang) * -(1024. / 56.));
|
||||||
let aoffs = 22.5 / 16. - frandom(-45, 45);
|
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;
|
double siz = actor.scale.Y * 0.9143;
|
||||||
spawnofs *= siz;
|
spawnofs *= siz;
|
||||||
|
@ -236,7 +236,7 @@ class DukeRPG : DukeProjectile
|
||||||
spawned.extra >>= 2;
|
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.extra >>= 2;
|
||||||
spawned.Angle += frandom(-22.5 / 8, 22.5 / 8);
|
spawned.Angle += frandom(-22.5 / 8, 22.5 / 8);
|
||||||
|
|
|
@ -77,7 +77,7 @@ class RedneckChickenHeadSpawner : RedneckChickenSpawner1
|
||||||
{
|
{
|
||||||
let spawned = self.spawn('RedneckChickenHead');
|
let spawned = self.spawn('RedneckChickenHead');
|
||||||
self.lotag = 96;
|
self.lotag = 96;
|
||||||
if (spawned && !Raze.isRRRA()) self.PlayActorSound("POOLBUD");
|
if (spawned && !isRRRA()) self.PlayActorSound("POOLBUD");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class RedneckCoot : DukeActor
|
||||||
|
|
||||||
override void PlayFTASound(int mode)
|
override void PlayFTASound(int mode)
|
||||||
{
|
{
|
||||||
if (!Raze.isRRRA() && (random(0, 3)) == 2)
|
if (!isRRRA() && (random(0, 3)) == 2)
|
||||||
self.PlayActorSound("CT_GET");
|
self.PlayActorSound("CT_GET");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class RedneckCoot : DukeActor
|
||||||
self.scale = (0.375, 0.28125);
|
self.scale = (0.375, 0.28125);
|
||||||
self.setClipDistFromTile();
|
self.setClipDistFromTile();
|
||||||
self.clipdist *= 4;
|
self.clipdist *= 4;
|
||||||
if (Raze.isRRRA()) bLookAllaround = true;
|
if (isRRRA()) bLookAllaround = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class RedneckMinion : DukeActor
|
||||||
|
|
||||||
override bool animate(tspritetype t)
|
override bool animate(tspritetype t)
|
||||||
{
|
{
|
||||||
if (Raze.isRRRA() && t.pal == 19)
|
if (isRRRA() && t.pal == 19)
|
||||||
t.shade = -127;
|
t.shade = -127;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ class RedneckShotgunammo : DukeItemBase
|
||||||
override void Initialize()
|
override void Initialize()
|
||||||
{
|
{
|
||||||
commonItemSetup((0.28125, 0.265625));
|
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()
|
override void Initialize()
|
||||||
{
|
{
|
||||||
commonItemSetup((0.203125, 0.140625));
|
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
|
class RedneckGoogooCluster : DukeItemBase
|
||||||
|
|
|
@ -20,7 +20,7 @@ class DukeRespawnController : DukeActor
|
||||||
if (self.extra == 66)
|
if (self.extra == 66)
|
||||||
{
|
{
|
||||||
let newact = self.spawnsprite(self.hitag);
|
let newact = self.spawnsprite(self.hitag);
|
||||||
if (Raze.isRRRA() && newact)
|
if (isRRRA() && newact)
|
||||||
{
|
{
|
||||||
newact.pal = self.pal;
|
newact.pal = self.pal;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class DukeTouchPlate : DukeActor
|
||||||
{
|
{
|
||||||
private bool checkspawn()
|
private bool checkspawn()
|
||||||
{
|
{
|
||||||
if (!Raze.isWorldTour())
|
if (!isWorldTour())
|
||||||
{
|
{
|
||||||
if (self.pal && ud.multimode > 1) return false;
|
if (self.pal && ud.multimode > 1) return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,7 +464,7 @@ class DukeActor : CoreActor native
|
||||||
}
|
}
|
||||||
|
|
||||||
// RR defaults to using the floor shade here, let's make this configurable.
|
// 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;
|
self.shade = self.sector.floorshade;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ struct Duke native
|
||||||
static void BigText(double x, double y, String text, int align = -1, double alpha = 1.)
|
static void BigText(double x, double y, String text, int align = -1, double alpha = 1.)
|
||||||
{
|
{
|
||||||
let myfont = Raze.PickBigFont();
|
let myfont = Raze.PickBigFont();
|
||||||
if (!Raze.isRR())
|
if (!isRR())
|
||||||
{
|
{
|
||||||
if (align != -1) x -= myfont.StringWidth(text) * (align == 0 ? 0.5 : 1);
|
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);
|
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();
|
let myfont = Raze.PickSmallFont();
|
||||||
int fsmode = FSMode_Fit320x200;
|
int fsmode = FSMode_Fit320x200;
|
||||||
if (Raze.isRR())
|
if (isRR())
|
||||||
{
|
{
|
||||||
x *= 2;
|
x *= 2;
|
||||||
y *= 2;
|
y *= 2;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class DukeCutscenes ui // Note: must be class, not struct, otherwise we cannot e
|
||||||
{
|
{
|
||||||
if (!userConfig.nologo)
|
if (!userConfig.nologo)
|
||||||
{
|
{
|
||||||
if (!Raze.isShareware())
|
if (!isShareware())
|
||||||
{
|
{
|
||||||
Array<int> soundinfo;
|
Array<int> soundinfo;
|
||||||
soundinfo.Pushv(
|
soundinfo.Pushv(
|
||||||
|
@ -46,7 +46,7 @@ class DukeCutscenes ui // Note: must be class, not struct, otherwise we cannot e
|
||||||
19, int(Sound("PIPEBOMB_EXPLODE")));
|
19, int(Sound("PIPEBOMB_EXPLODE")));
|
||||||
runner.Append(MoviePlayerJob.CreateWithSoundinfo("logo.anm", soundinfo, 0, 9, 9, 9));
|
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());
|
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(MoviePlayerJob.CreateWithSoundinfo("cineov3.anm", soundinfo, 0, 10, 10, 10));
|
||||||
runner.Append(BlackScreen.Create(200, ScreenJob.stopsound));
|
runner.Append(BlackScreen.Create(200, ScreenJob.stopsound));
|
||||||
runner.Append(new("Episode3End").Init());
|
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)
|
static void BuildE1End(ScreenJobRunner runner)
|
||||||
{
|
{
|
||||||
if (!Raze.isRRRA())
|
if (!isRRRA())
|
||||||
{
|
{
|
||||||
Array<int> soundinfo;
|
Array<int> soundinfo;
|
||||||
soundinfo.Pushv(1, int(Sound("CHKAMMO")));
|
soundinfo.Pushv(1, int(Sound("CHKAMMO")));
|
||||||
|
@ -352,7 +352,7 @@ class RRCutscenes ui
|
||||||
|
|
||||||
static void BuildSPSummary(ScreenJobRunner runner, MapRecord map, SummaryInfo stats)
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -147,7 +147,7 @@ class DukeCommonStatusBar : RazeStatusBar
|
||||||
int select = 1 << (p.inven_icon - 1);
|
int select = 1 << (p.inven_icon - 1);
|
||||||
double alpha = select == i ? 1.0 : 0.7;
|
double alpha = select == i ? 1.0 : 0.7;
|
||||||
DrawImage(item_icons[bit+1], (x, y), align, alpha, scale:(scale, scale));
|
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;
|
x += 22;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ class DukeCommonStatusBar : RazeStatusBar
|
||||||
void DoLevelStats(int bottomy, SummaryInfo info)
|
void DoLevelStats(int bottomy, SummaryInfo info)
|
||||||
{
|
{
|
||||||
StatsPrintInfo stats;
|
StatsPrintInfo stats;
|
||||||
stats.fontscale = Raze.isRR() ? 0.5 : 1.;
|
stats.fontscale = isRR() ? 0.5 : 1.;
|
||||||
stats.screenbottomspace = bottomy;
|
stats.screenbottomspace = bottomy;
|
||||||
|
|
||||||
int y = -1;
|
int y = -1;
|
||||||
|
@ -171,8 +171,8 @@ class DukeCommonStatusBar : RazeStatusBar
|
||||||
{
|
{
|
||||||
stats.statfont = SmallFont2;
|
stats.statfont = SmallFont2;
|
||||||
stats.spacing = 6;
|
stats.spacing = 6;
|
||||||
if (Raze.isNamWW2GI()) stats.altspacing = 10;
|
if (isNamWW2GI()) stats.altspacing = 10;
|
||||||
else if (!Raze.isRR()) stats.altspacing = 11;
|
else if (!isRR()) stats.altspacing = 11;
|
||||||
else stats.altspacing = 14;
|
else stats.altspacing = 14;
|
||||||
|
|
||||||
stats.standardColor = Font.TEXTCOLOR_UNTRANSLATED;
|
stats.standardColor = Font.TEXTCOLOR_UNTRANSLATED;
|
||||||
|
@ -184,14 +184,14 @@ class DukeCommonStatusBar : RazeStatusBar
|
||||||
{
|
{
|
||||||
stats.statfont = SmallFont;
|
stats.statfont = SmallFont;
|
||||||
stats.letterColor = Font.TEXTCOLOR_ORANGE;
|
stats.letterColor = Font.TEXTCOLOR_ORANGE;
|
||||||
if (Raze.isNamWW2GI())
|
if (isNamWW2GI())
|
||||||
{
|
{
|
||||||
stats.statfont = ConFont;
|
stats.statfont = ConFont;
|
||||||
stats.spacing = 8;
|
stats.spacing = 8;
|
||||||
stats.standardColor = Font.TEXTCOLOR_YELLOW;
|
stats.standardColor = Font.TEXTCOLOR_YELLOW;
|
||||||
stats.completeColor = Font.TEXTCOLOR_FIRE;
|
stats.completeColor = Font.TEXTCOLOR_FIRE;
|
||||||
}
|
}
|
||||||
else if (!Raze.isRR())
|
else if (!isRR())
|
||||||
{
|
{
|
||||||
stats.spacing = 7;
|
stats.spacing = 7;
|
||||||
stats.standardColor = Font.TEXTCOLOR_CREAM;
|
stats.standardColor = Font.TEXTCOLOR_CREAM;
|
||||||
|
|
|
@ -149,7 +149,7 @@ class DukeStatusBar : DukeCommonStatusBar
|
||||||
//
|
//
|
||||||
// Health
|
// Health
|
||||||
//
|
//
|
||||||
img = TexMan.CheckForTexture(Raze.isNamWW2GI()? "FIRSTAID_ICON" : "COLA");
|
img = TexMan.CheckForTexture(isNamWW2GI()? "FIRSTAID_ICON" : "COLA");
|
||||||
let siz = TexMan.GetScaledSize(img);
|
let siz = TexMan.GetScaledSize(img);
|
||||||
imgScale = baseScale / siz.Y;
|
imgScale = baseScale / siz.Y;
|
||||||
DrawTexture(img, (2, -1.5), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale));
|
DrawTexture(img, (2, -1.5), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale));
|
||||||
|
@ -191,7 +191,7 @@ class DukeStatusBar : DukeCommonStatusBar
|
||||||
}
|
}
|
||||||
else
|
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);
|
format = String.Format("%d/%d", clip, ammo - clip);
|
||||||
}
|
}
|
||||||
img = TexMan.CheckForTexture(wicon, TexMan.TYPE_Any);
|
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);
|
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));
|
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.statfont = SmallFont;
|
||||||
stats.info.letterColor = Font.TEXTCOLOR_ORANGE;
|
stats.info.letterColor = Font.TEXTCOLOR_ORANGE;
|
||||||
if (Raze.isNamWW2GI())
|
if (isNamWW2GI())
|
||||||
{
|
{
|
||||||
stats.info.statfont = ConFont;
|
stats.info.statfont = ConFont;
|
||||||
stats.info.spacing = 8;
|
stats.info.spacing = 8;
|
||||||
|
@ -520,7 +520,7 @@ class DukeStatusBar : DukeCommonStatusBar
|
||||||
}
|
}
|
||||||
|
|
||||||
let p = Duke.GetViewPlayer();
|
let p = Duke.GetViewPlayer();
|
||||||
stats.healthicon = Raze.isNamWW2GI()? "FIRSTAID_ICON" : "COLA";
|
stats.healthicon = isNamWW2GI()? "FIRSTAID_ICON" : "COLA";
|
||||||
stats.healthvalue = p.last_extra;
|
stats.healthvalue = p.last_extra;
|
||||||
|
|
||||||
let armorval = GetMoraleOrShield(p);
|
let armorval = GetMoraleOrShield(p);
|
||||||
|
@ -544,7 +544,7 @@ class DukeStatusBar : DukeCommonStatusBar
|
||||||
static const String weaponIcons[] = { "", "FIRSTGUNSPRITE", "SHOTGUNSPRITE", "CHAINGUNSPRITE", "RPGSPRITE", "" /*pipe bomb*/, "SHRINKERSPRITE",
|
static const String weaponIcons[] = { "", "FIRSTGUNSPRITE", "SHOTGUNSPRITE", "CHAINGUNSPRITE", "RPGSPRITE", "" /*pipe bomb*/, "SHRINKERSPRITE",
|
||||||
"DEVISTATORSPRITE", "" /*trip bomb*/, "FREEZESPRITE", "" /*handremote*/, "" /*grower*/, "FLAMETHROWERSPRITE" };
|
"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++)
|
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,
|
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 };
|
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++)
|
for(int i = 0; i < maxammo; i++)
|
||||||
{
|
{
|
||||||
int ammonum = ammoorder[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))
|
if (p.curr_weapon == ammonum || (p.curr_weapon == DukeWpn.HANDREMOTE_WEAPON && ammonum == DukeWpn.HANDBOMB_WEAPON))
|
||||||
{
|
{
|
||||||
stats.ammoselect = stats.ammoicons.Size();
|
stats.ammoselect = stats.ammoicons.Size();
|
||||||
|
|
|
@ -519,7 +519,7 @@ class RedneckStatusBar : DukeCommonStatusBar
|
||||||
for(int i = 0; i < ammoOrder.Size(); i++)
|
for(int i = 0; i < ammoOrder.Size(); i++)
|
||||||
{
|
{
|
||||||
int ammonum = ammoorder[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.MOTORCYCLE_WEAPON && !p.OnMotorcycle) continue;
|
||||||
if (ammonum == RRWpn.BOAT_WEAPON && !p.OnBoat) continue;
|
if (ammonum == RRWpn.BOAT_WEAPON && !p.OnBoat) continue;
|
||||||
// dynamite and crossbow dynamite ammo types are coupled.
|
// dynamite and crossbow dynamite ammo types are coupled.
|
||||||
|
|
|
@ -80,7 +80,7 @@ class DukeTitleScreen : SkippableScreenJob
|
||||||
|
|
||||||
override void Start()
|
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()
|
override void OnTick()
|
||||||
|
@ -99,12 +99,12 @@ class DukeTitleScreen : SkippableScreenJob
|
||||||
if (soundanm == 2 && clock >= 280 && clock < 395)
|
if (soundanm == 2 && clock >= 280 && clock < 395)
|
||||||
{
|
{
|
||||||
soundanm = 3;
|
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)
|
else if (soundanm == 3 && clock >= 395)
|
||||||
{
|
{
|
||||||
soundanm = 4;
|
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))
|
if (clock > (860 + 120))
|
||||||
|
@ -143,7 +143,7 @@ class DukeTitleScreen : SkippableScreenJob
|
||||||
DTA_CenterOffsetRel, true, DTA_TranslationIndex, trans, DTA_ScaleX, scale, DTA_ScaleY, scale);
|
DTA_CenterOffsetRel, true, DTA_TranslationIndex, trans, DTA_ScaleX, scale, DTA_ScaleY, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Raze.isPlutoPak())
|
if (isPlutoPak())
|
||||||
{
|
{
|
||||||
scale = (410 - clamp(clock, 280, 395)) / 16.;
|
scale = (410 - clamp(clock, 280, 395)) / 16.;
|
||||||
if (scale > 0. && clock > 280)
|
if (scale > 0. && clock > 280)
|
||||||
|
@ -373,7 +373,7 @@ class Episode3End : ImageScreen
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
if (Raze.isPlutoPak())
|
if (isPlutoPak())
|
||||||
{
|
{
|
||||||
if (ticks > finishtime) jobstate = finished;
|
if (ticks > finishtime) jobstate = finished;
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ class Episode3End : ImageScreen
|
||||||
|
|
||||||
override void OnDestroy()
|
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()
|
override void Start()
|
||||||
{
|
{
|
||||||
if (!Raze.isRR()) Duke.PlayBonusMusic();
|
if (!isRR()) Duke.PlayBonusMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
override void Draw(double smoothratio)
|
override void Draw(double smoothratio)
|
||||||
{
|
{
|
||||||
bool isRR = Raze.isRR();
|
bool isRR = isRR();
|
||||||
double titlescale = isRR? 0.36 : 1;
|
double titlescale = isRR? 0.36 : 1;
|
||||||
|
|
||||||
String tempbuf;
|
String tempbuf;
|
||||||
int currentclock = int((ticks + smoothratio) * 120 / GameTicRate);
|
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("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);
|
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);
|
Raze.DrawScoreboard(60);
|
||||||
}
|
}
|
||||||
|
@ -647,7 +647,7 @@ class DukeLevelSummaryScreen : SummaryScreenBase
|
||||||
String tempbuf;
|
String tempbuf;
|
||||||
Duke.GameText(text_x, 59 + 9, "$TXT_YourTime", 0);
|
Duke.GameText(text_x, 59 + 9, "$TXT_YourTime", 0);
|
||||||
Duke.GameText(text_x, 69 + 9, "$TXT_ParTime", 0);
|
Duke.GameText(text_x, 69 + 9, "$TXT_ParTime", 0);
|
||||||
if (!Raze.isNamWW2GI())
|
if (!isNamWW2GI())
|
||||||
Duke.GameText(text_x, 79 + 9, "$TXT_3DRTIME", 0);
|
Duke.GameText(text_x, 79 + 9, "$TXT_3DRTIME", 0);
|
||||||
|
|
||||||
if (displaystate & printTimeVal)
|
if (displaystate & printTimeVal)
|
||||||
|
@ -658,7 +658,7 @@ class DukeLevelSummaryScreen : SummaryScreenBase
|
||||||
tempbuf = FormatTime(level.parTime);
|
tempbuf = FormatTime(level.parTime);
|
||||||
Duke.GameText(val_x, 69 + 9, tempbuf, 0);
|
Duke.GameText(val_x, 69 + 9, tempbuf, 0);
|
||||||
|
|
||||||
if (!Raze.isNamWW2GI())
|
if (!isNamWW2GI())
|
||||||
{
|
{
|
||||||
tempbuf = FormatTime(level.designerTime);
|
tempbuf = FormatTime(level.designerTime);
|
||||||
Duke.GameText(val_x, 79 + 9, tempbuf, 0);
|
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);
|
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, 90, (rec.flags & MapRecord.USERMAP)? "$TXT_LOADUM" : "$TXT_LOADING", 0);
|
||||||
Duke.BigText(160, 114, rec.DisplayName(), 0);
|
Duke.BigText(160, 114, rec.DisplayName(), 0);
|
||||||
}
|
}
|
||||||
else
|
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, (rec.flags & MapRecord.USERMAP)? "$TXT_ENTRUM" : "$TXT_ENTERIN", 0);
|
||||||
Duke.BigText(160, y+24, rec.DisplayName(), 0);
|
Duke.BigText(160, y+24, rec.DisplayName(), 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,7 +458,7 @@ class SWCutscenes ui
|
||||||
|
|
||||||
static void BuildSybexScreen(ScreenJobRunner runner)
|
static void BuildSybexScreen(ScreenJobRunner runner)
|
||||||
{
|
{
|
||||||
if (Raze.isShareware() && !netgame)
|
if (isShareware() && !netgame)
|
||||||
runner.Append(ImageScreen.CreateNamed("SYBEXSCREEN", TexMan.Type_Any));
|
runner.Append(ImageScreen.CreateNamed("SYBEXSCREEN", TexMan.Type_Any));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,73 +222,6 @@ struct Raze
|
||||||
native static bool cansee(Vector3 start, sectortype startsec, Vector3 end, sectortype endsec);
|
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);
|
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.
|
// 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)
|
static int playerPalette(int i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,7 +143,7 @@ class RazeStatusBar : StatusBarCore
|
||||||
{
|
{
|
||||||
scale = info.fontscale * hud_statscale;
|
scale = info.fontscale * hud_statscale;
|
||||||
spacing = info.altspacing * hud_statscale;
|
spacing = info.altspacing * hud_statscale;
|
||||||
myfont = Raze.isNamWW2GI()? ConFont : Raze.PickSmallFont(allname);
|
myfont = isNamWW2GI()? ConFont : Raze.PickSmallFont(allname);
|
||||||
}
|
}
|
||||||
|
|
||||||
String mapname;
|
String mapname;
|
||||||
|
|
Loading…
Reference in a new issue