mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-20 03:11:43 +00:00
e5572a1c4e
- Added .txt files to the list of types (wad, zip, and pk3) that can be loaded without listing them after -file. - Fonts that are created by the ACS setfont command to wrap a texture now support animated textures. - FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn with the hardware 2D path instead of being restricted to the game palette. - Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1 on a Radeon 9000. - Added back the off-by-one palette handling, but in a much more limited scope than before. The skipped entry is assumed to always be at 248, and it is assumed that all Shader Model 1.4 cards suffer from this. That's because all SM1.4 cards are based on variants of the ATI R200 core, and the RV250 in a Radeon 9000 craps up like this. I see no reason to assume that other flavors of the R200 are any different. (Interesting note: With the Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the debug Direct3D 9 runtime, but it works perfectly fine with the retail Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its math inside pixel shaders. That would explain perfectly why I can't use constants greater than 1 with PS1.4 and why it can't do an exact mapping to every entry in the color palette. - Fixed: The software shaded drawer did not work for 2D, because its selected "color"map was replaced with the identitymap before being used. - Fixed: I cannot use Printf to output messages before the framebuffer was completely setup, meaning that Shader Model 1.4 cards could not change resolution. - I have decided to let remap palettes specify variable alpha values for their colors. D3DFB no longer forces them to 255. - Updated re2c to version 0.12.3. - Fixed: A_Wander used threshold as a timer, when it should have used reactiontime. - Fixed: A_CustomRailgun would not fire at all for actors without a target when the aim parameter was disabled. - Made the warp command work in multiplayer, again courtesy of Karate Chris. - Fixed: Trying to spawn a bot while not in a game made for a crashing time. (Patch courtesy of Karate Chris.) - Removed some floating point math from hu_scores.cpp that somebody's GCC gave warnings for (not mine, though). - Fixed: The SBarInfo drawbar command crashed if the sprite image was unavailable. - Fixed: FString::operator=(const char *) did not release its old buffer when being assigned to the null string. - The scanner no longer has an upper limit on the length of strings it accepts, though short strings will be faster than long ones. - Moved all the text scanning functions into a class. Mainly, this means that multiple script scanner states can be stored without being forced to do so recursively. I think I might be taking advantage of that in the near future. Possibly. Maybe. - Removed some potential buffer overflows from the decal parser. - Applied Blzut3's SBARINFO update #9: * Fixed: When using even length values in drawnumber it would cap to a 98 value instead of a 99 as intended. * The SBarInfo parser can now accept negatives for coordinates. This doesn't allow much right now, but later I plan to add better fullscreen hud support in which the negatives will be more useful. This also cleans up the source a bit since all calls for (x, y) coordinates are with the function getCoordinates(). - Added support for stencilling actors. - Added support for non-black colors specified with DTA_ColorOverlay to the software renderer. - Fixed: The inverse, gold, red, and green fixed colormaps each allocated space for 32 different colormaps, even though each only used the first one. - Added two new blending flags to make reverse subtract blending more useful: STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that gets blended with the background, since that seems like a good idea for reverse subtraction. They also work with the other two blending operations. - Added subtract and reverse subtract blending operations to the renderer. Since the ERenderStyle enumeration was getting rather unwieldy, I converted it into a new FRenderStyle structure that lets each parameter of the blending equation be set separately. This simplified the set up for the blend quite a bit, and it means a number of new combinations are available by setting the parameters properly. SVN r710 (trunk)
686 lines
18 KiB
C++
686 lines
18 KiB
C++
/*
|
|
** thingdef.cpp
|
|
**
|
|
** Actor definitions
|
|
**
|
|
**---------------------------------------------------------------------------
|
|
** Copyright 2002-2007 Christoph Oelckers
|
|
** Copyright 2004-2007 Randy Heit
|
|
** All rights reserved.
|
|
**
|
|
** Redistribution and use in source and binary forms, with or without
|
|
** modification, are permitted provided that the following conditions
|
|
** are met:
|
|
**
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
** notice, this list of conditions and the following disclaimer.
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
** documentation and/or other materials provided with the distribution.
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
** derived from this software without specific prior written permission.
|
|
** 4. When not used as part of ZDoom or a ZDoom derivative, this code will be
|
|
** covered by the terms of the GNU General Public License as published by
|
|
** the Free Software Foundation; either version 2 of the License, or (at
|
|
** your option) any later version.
|
|
**
|
|
** 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 "gi.h"
|
|
#include "actor.h"
|
|
#include "info.h"
|
|
#include "sc_man.h"
|
|
#include "tarray.h"
|
|
#include "w_wad.h"
|
|
#include "templates.h"
|
|
#include "r_defs.h"
|
|
#include "r_draw.h"
|
|
#include "a_pickups.h"
|
|
#include "s_sound.h"
|
|
#include "cmdlib.h"
|
|
#include "p_lnspec.h"
|
|
#include "p_enemy.h"
|
|
#include "a_action.h"
|
|
#include "decallib.h"
|
|
#include "m_random.h"
|
|
#include "autosegs.h"
|
|
#include "i_system.h"
|
|
#include "p_local.h"
|
|
#include "p_effect.h"
|
|
#include "v_palette.h"
|
|
#include "doomerrors.h"
|
|
#include "a_doomglobal.h"
|
|
#include "a_hexenglobal.h"
|
|
#include "a_weaponpiece.h"
|
|
#include "p_conversation.h"
|
|
#include "v_text.h"
|
|
#include "thingdef.h"
|
|
#include "a_sharedglobal.h"
|
|
|
|
|
|
const PClass *QuestItemClasses[31];
|
|
|
|
|
|
|
|
//==========================================================================
|
|
//
|
|
// ActorConstDef
|
|
//
|
|
// Parses a constant definition.
|
|
//
|
|
//==========================================================================
|
|
|
|
void ParseConstant (FScanner &sc, PSymbolTable * symt, PClass *cls)
|
|
{
|
|
// Read the type and make sure it's int.
|
|
// (Maybe there will be other types later.)
|
|
sc.MustGetToken(TK_Int);
|
|
sc.MustGetToken(TK_Identifier);
|
|
FName symname = sc.String;
|
|
sc.MustGetToken('=');
|
|
int expr = ParseExpression (sc, false, cls);
|
|
sc.MustGetToken(';');
|
|
|
|
int val = EvalExpressionI (expr, NULL, cls);
|
|
PSymbolConst *sym = new PSymbolConst;
|
|
sym->SymbolName = symname;
|
|
sym->SymbolType = SYM_Const;
|
|
sym->Value = val;
|
|
if (symt->AddSymbol (sym) == NULL)
|
|
{
|
|
delete sym;
|
|
sc.ScriptError ("'%s' is already defined in class '%s'.",
|
|
symname.GetChars(), cls->TypeName.GetChars());
|
|
}
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// ActorEnumDef
|
|
//
|
|
// Parses an enum definition.
|
|
//
|
|
//==========================================================================
|
|
|
|
void ParseEnum (FScanner &sc, PSymbolTable *symt, PClass *cls)
|
|
{
|
|
int currvalue = 0;
|
|
|
|
sc.MustGetToken('{');
|
|
while (!sc.CheckToken('}'))
|
|
{
|
|
sc.MustGetToken(TK_Identifier);
|
|
FName symname = sc.String;
|
|
if (sc.CheckToken('='))
|
|
{
|
|
int expr = ParseExpression(sc, false, cls);
|
|
currvalue = EvalExpressionI(expr, NULL, cls);
|
|
}
|
|
PSymbolConst *sym = new PSymbolConst;
|
|
sym->SymbolName = symname;
|
|
sym->SymbolType = SYM_Const;
|
|
sym->Value = currvalue;
|
|
if (symt->AddSymbol (sym) == NULL)
|
|
{
|
|
delete sym;
|
|
sc.ScriptError ("'%s' is already defined in class '%s'.",
|
|
symname.GetChars(), cls->TypeName.GetChars());
|
|
}
|
|
// This allows a comma after the last value but doesn't enforce it.
|
|
if (sc.CheckToken('}')) break;
|
|
sc.MustGetToken(',');
|
|
currvalue++;
|
|
}
|
|
sc.MustGetToken(';');
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// ActorActionDef
|
|
//
|
|
// Parses an action function definition. A lot of this is essentially
|
|
// documentation in the declaration for when I have a proper language
|
|
// ready.
|
|
//
|
|
//==========================================================================
|
|
|
|
static void ParseActionDef (FScanner &sc, PClass *cls)
|
|
{
|
|
#define OPTIONAL 1
|
|
#define EVAL 2
|
|
#define EVALNOT 4
|
|
|
|
AFuncDesc *afd;
|
|
FName funcname;
|
|
FString args;
|
|
|
|
sc.MustGetToken(TK_Native);
|
|
sc.MustGetToken(TK_Identifier);
|
|
funcname = sc.String;
|
|
afd = FindFunction(sc.String);
|
|
if (afd == NULL)
|
|
{
|
|
sc.ScriptError ("The function '%s' has not been exported from the executable.", sc.String);
|
|
}
|
|
sc.MustGetToken('(');
|
|
if (!sc.CheckToken(')'))
|
|
{
|
|
while (sc.TokenType != ')')
|
|
{
|
|
int flags = 0;
|
|
char type = '@';
|
|
|
|
// Retrieve flags before type name
|
|
for (;;)
|
|
{
|
|
if (sc.CheckToken(TK_Optional))
|
|
{
|
|
flags |= OPTIONAL;
|
|
}
|
|
else if (sc.CheckToken(TK_Eval))
|
|
{
|
|
flags |= EVAL;
|
|
}
|
|
else if (sc.CheckToken(TK_EvalNot))
|
|
{
|
|
flags |= EVALNOT;
|
|
}
|
|
else if (sc.CheckToken(TK_Coerce) || sc.CheckToken(TK_Native))
|
|
{
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
// Read the variable type
|
|
sc.MustGetAnyToken();
|
|
switch (sc.TokenType)
|
|
{
|
|
case TK_Bool: type = 'i'; break;
|
|
case TK_Int: type = 'i'; break;
|
|
case TK_Float: type = 'f'; break;
|
|
case TK_Sound: type = 's'; break;
|
|
case TK_String: type = 't'; break;
|
|
case TK_Name: type = 't'; break;
|
|
case TK_State: type = 'l'; break;
|
|
case TK_Color: type = 'c'; break;
|
|
case TK_Class:
|
|
sc.MustGetToken('<');
|
|
sc.MustGetToken(TK_Identifier); // Skip class name, since the parser doesn't care
|
|
sc.MustGetToken('>');
|
|
type = 'm';
|
|
break;
|
|
case TK_Ellipsis:
|
|
type = '+';
|
|
sc.MustGetToken(')');
|
|
sc.UnGet();
|
|
break;
|
|
default:
|
|
sc.ScriptError ("Unknown variable type %s", sc.TokenName(sc.TokenType, sc.String).GetChars());
|
|
break;
|
|
}
|
|
// Read the optional variable name
|
|
if (!sc.CheckToken(',') && !sc.CheckToken(')'))
|
|
{
|
|
sc.MustGetToken(TK_Identifier);
|
|
}
|
|
else
|
|
{
|
|
sc.UnGet();
|
|
}
|
|
// If eval or evalnot were a flag, hey the decorate parser doesn't actually care about the type.
|
|
if (flags & EVALNOT)
|
|
{
|
|
type = 'y';
|
|
}
|
|
else if (flags & EVAL)
|
|
{
|
|
type = 'x';
|
|
}
|
|
if (!(flags & OPTIONAL) && type != '+')
|
|
{
|
|
type -= 'a' - 'A';
|
|
}
|
|
#undef OPTIONAL
|
|
#undef EVAL
|
|
#undef EVALNOT
|
|
args += type;
|
|
sc.MustGetAnyToken();
|
|
if (sc.TokenType != ',' && sc.TokenType != ')')
|
|
{
|
|
sc.ScriptError ("Expected ',' or ')' but got %s instead", sc.TokenName(sc.TokenType, sc.String).GetChars());
|
|
}
|
|
}
|
|
}
|
|
sc.MustGetToken(';');
|
|
PSymbolActionFunction *sym = new PSymbolActionFunction;
|
|
sym->SymbolName = funcname;
|
|
sym->SymbolType = SYM_ActionFunction;
|
|
sym->Arguments = args;
|
|
sym->Function = afd->Function;
|
|
if (cls->Symbols.AddSymbol (sym) == NULL)
|
|
{
|
|
delete sym;
|
|
sc.ScriptError ("'%s' is already defined in class '%s'.",
|
|
funcname.GetChars(), cls->TypeName.GetChars());
|
|
}
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// Starts a new actor definition
|
|
//
|
|
//==========================================================================
|
|
static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *bag)
|
|
{
|
|
FName typeName;
|
|
|
|
// Get actor name
|
|
sc.MustGetString();
|
|
|
|
char *colon = strchr(sc.String, ':');
|
|
if (colon != NULL)
|
|
{
|
|
*colon++ = 0;
|
|
}
|
|
|
|
if (PClass::FindClass (sc.String) != NULL)
|
|
{
|
|
sc.ScriptError ("Actor %s is already defined.", sc.String);
|
|
}
|
|
|
|
typeName = sc.String;
|
|
|
|
PClass *parent = RUNTIME_CLASS(AActor);
|
|
if (parentc)
|
|
{
|
|
*parentc = NULL;
|
|
|
|
// Do some tweaking so that a definition like 'Actor:Parent' which is read as a single token is recognized as well
|
|
// without having resort to C-mode (which disallows periods in actor names.)
|
|
if (colon == NULL)
|
|
{
|
|
sc.MustGetString ();
|
|
if (sc.String[0]==':')
|
|
{
|
|
colon = sc.String + 1;
|
|
}
|
|
}
|
|
|
|
if (colon != NULL)
|
|
{
|
|
if (colon[0] == 0)
|
|
{
|
|
sc.MustGetString ();
|
|
colon = sc.String;
|
|
}
|
|
}
|
|
|
|
if (colon != NULL)
|
|
{
|
|
parent = const_cast<PClass *> (PClass::FindClass (colon));
|
|
|
|
if (parent == NULL)
|
|
{
|
|
sc.ScriptError ("Parent type '%s' not found", colon);
|
|
}
|
|
else if (parent->ActorInfo == NULL)
|
|
{
|
|
sc.ScriptError ("Parent type '%s' is not an actor", colon);
|
|
}
|
|
else
|
|
{
|
|
*parentc = parent->ActorInfo;
|
|
}
|
|
}
|
|
else sc.UnGet();
|
|
}
|
|
|
|
PClass *ti = parent->CreateDerivedClass (typeName, parent->Size);
|
|
FActorInfo *info = ti->ActorInfo;
|
|
|
|
MakeStateDefines(parent->ActorInfo->StateList);
|
|
|
|
ResetBaggage (bag);
|
|
bag->Info = info;
|
|
|
|
info->DoomEdNum = -1;
|
|
if (parent->ActorInfo->DamageFactors != NULL)
|
|
{
|
|
// copy damage factors from parent
|
|
info->DamageFactors = new DmgFactors;
|
|
*info->DamageFactors = *parent->ActorInfo->DamageFactors;
|
|
}
|
|
if (parent->ActorInfo->PainChances != NULL)
|
|
{
|
|
// copy pain chances from parent
|
|
info->PainChances = new PainChanceList;
|
|
*info->PainChances = *parent->ActorInfo->PainChances;
|
|
}
|
|
|
|
// Check for "replaces"
|
|
sc.MustGetString ();
|
|
if (sc.Compare ("replaces"))
|
|
{
|
|
const PClass *replacee;
|
|
|
|
// Get actor name
|
|
sc.MustGetString ();
|
|
replacee = PClass::FindClass (sc.String);
|
|
|
|
if (replacee == NULL)
|
|
{
|
|
sc.ScriptError ("Replaced type '%s' not found", sc.String);
|
|
}
|
|
else if (replacee->ActorInfo == NULL)
|
|
{
|
|
sc.ScriptError ("Replaced type '%s' is not an actor", sc.String);
|
|
}
|
|
replacee->ActorInfo->Replacement = ti->ActorInfo;
|
|
ti->ActorInfo->Replacee = replacee->ActorInfo;
|
|
}
|
|
else
|
|
{
|
|
sc.UnGet();
|
|
}
|
|
|
|
// Now, after the actor names have been parsed, it is time to switch to C-mode
|
|
// for the rest of the actor definition.
|
|
sc.SetCMode (true);
|
|
if (sc.CheckNumber())
|
|
{
|
|
if (sc.Number>=-1 && sc.Number<32768) info->DoomEdNum = sc.Number;
|
|
else sc.ScriptError ("DoomEdNum must be in the range [-1,32767]");
|
|
}
|
|
if (parent == RUNTIME_CLASS(AWeapon))
|
|
{
|
|
// preinitialize kickback to the default for the game
|
|
((AWeapon*)(info->Class->Defaults))->Kickback=gameinfo.defKickback;
|
|
}
|
|
|
|
return info;
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// Reads an actor definition
|
|
//
|
|
//==========================================================================
|
|
void ParseActor(FScanner &sc)
|
|
{
|
|
FActorInfo * info=NULL;
|
|
Baggage bag;
|
|
|
|
try
|
|
{
|
|
FActorInfo * parent;
|
|
|
|
info = CreateNewActor(sc, &parent, &bag);
|
|
sc.MustGetToken('{');
|
|
while (sc.MustGetAnyToken(), sc.TokenType != '}')
|
|
{
|
|
switch (sc.TokenType)
|
|
{
|
|
case TK_Action:
|
|
ParseActionDef (sc, info->Class);
|
|
break;
|
|
|
|
case TK_Const:
|
|
ParseConstant (sc, &info->Class->Symbols, info->Class);
|
|
break;
|
|
|
|
case TK_Enum:
|
|
ParseEnum (sc, &info->Class->Symbols, info->Class);
|
|
break;
|
|
|
|
case TK_Identifier:
|
|
// other identifier related checks here
|
|
case TK_Projectile: // special case: both keyword and property name
|
|
ParseActorProperty(sc, bag);
|
|
break;
|
|
|
|
case '+':
|
|
case '-':
|
|
ParseActorFlag(sc, bag, sc.TokenType);
|
|
break;
|
|
|
|
default:
|
|
sc.ScriptError("Unexpected '%s' in definition of '%s'", sc.String, bag.Info->Class->TypeName.GetChars());
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
FinishActor(sc, info, bag);
|
|
}
|
|
|
|
catch(CRecoverableError & e)
|
|
{
|
|
throw e;
|
|
}
|
|
// I think this is better than a crash log.
|
|
#ifndef _DEBUG
|
|
catch (...)
|
|
{
|
|
if (info)
|
|
sc.ScriptError("Unexpected error during parsing of actor %s", info->Class->TypeName.GetChars());
|
|
else
|
|
sc.ScriptError("Unexpected error during parsing of actor definitions");
|
|
}
|
|
#endif
|
|
|
|
sc.SetCMode (false);
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// Do some postprocessing after everything has been defined
|
|
// This also processes all the internal actors to adjust the type
|
|
// fields in the weapons
|
|
//
|
|
//==========================================================================
|
|
void FinishThingdef()
|
|
{
|
|
unsigned int i;
|
|
bool isRuntimeActor=false;
|
|
|
|
for (i = 0;i < PClass::m_Types.Size(); i++)
|
|
{
|
|
PClass * ti = PClass::m_Types[i];
|
|
|
|
// Skip non-actors
|
|
if (!ti->IsDescendantOf(RUNTIME_CLASS(AActor))) continue;
|
|
|
|
// Everything coming after the first runtime actor is also a runtime actor
|
|
// so this check is sufficient
|
|
if (ti == PClass::m_RuntimeActors[0])
|
|
{
|
|
isRuntimeActor=true;
|
|
}
|
|
|
|
// Friendlies never count as kills!
|
|
if (GetDefaultByType(ti)->flags & MF_FRIENDLY)
|
|
{
|
|
GetDefaultByType(ti)->flags &=~MF_COUNTKILL;
|
|
}
|
|
|
|
// the typeinfo properties of weapons have to be fixed here after all actors have been declared
|
|
if (ti->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
|
{
|
|
AWeapon * defaults=(AWeapon *)ti->Defaults;
|
|
fuglyname v;
|
|
|
|
v = defaults->AmmoType1;
|
|
if (v != NAME_None && v.IsValidName())
|
|
{
|
|
defaults->AmmoType1 = PClass::FindClass(v);
|
|
if (isRuntimeActor)
|
|
{
|
|
if (!defaults->AmmoType1)
|
|
{
|
|
I_Error("Unknown ammo type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
else if (defaults->AmmoType1->ParentClass != RUNTIME_CLASS(AAmmo))
|
|
{
|
|
I_Error("Invalid ammo type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
}
|
|
}
|
|
|
|
v = defaults->AmmoType2;
|
|
if (v != NAME_None && v.IsValidName())
|
|
{
|
|
defaults->AmmoType2 = PClass::FindClass(v);
|
|
if (isRuntimeActor)
|
|
{
|
|
if (!defaults->AmmoType2)
|
|
{
|
|
I_Error("Unknown ammo type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
else if (defaults->AmmoType2->ParentClass != RUNTIME_CLASS(AAmmo))
|
|
{
|
|
I_Error("Invalid ammo type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
}
|
|
}
|
|
|
|
v = defaults->SisterWeaponType;
|
|
if (v != NAME_None && v.IsValidName())
|
|
{
|
|
defaults->SisterWeaponType = PClass::FindClass(v);
|
|
if (isRuntimeActor)
|
|
{
|
|
if (!defaults->SisterWeaponType)
|
|
{
|
|
I_Error("Unknown sister weapon type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
else if (!defaults->SisterWeaponType->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
|
{
|
|
I_Error("Invalid sister weapon type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
}
|
|
}
|
|
|
|
if (isRuntimeActor)
|
|
{
|
|
FState * ready = ti->ActorInfo->FindState(NAME_Ready);
|
|
FState * select = ti->ActorInfo->FindState(NAME_Select);
|
|
FState * deselect = ti->ActorInfo->FindState(NAME_Deselect);
|
|
FState * fire = ti->ActorInfo->FindState(NAME_Fire);
|
|
|
|
// Consider any weapon without any valid state abstract and don't output a warning
|
|
// This is for creating base classes for weapon groups that only set up some properties.
|
|
if (ready || select || deselect || fire)
|
|
{
|
|
// Do some consistency checks. If these states are undefined the weapon cannot work!
|
|
if (!ready) I_Error("Weapon %s doesn't define a ready state.\n", ti->TypeName.GetChars());
|
|
if (!select) I_Error("Weapon %s doesn't define a select state.\n", ti->TypeName.GetChars());
|
|
if (!deselect) I_Error("Weapon %s doesn't define a deselect state.\n", ti->TypeName.GetChars());
|
|
if (!fire) I_Error("Weapon %s doesn't define a fire state.\n", ti->TypeName.GetChars());
|
|
}
|
|
}
|
|
|
|
}
|
|
// same for the weapon type of weapon pieces.
|
|
else if (ti->IsDescendantOf(RUNTIME_CLASS(AWeaponPiece)))
|
|
{
|
|
AWeaponPiece * defaults=(AWeaponPiece *)ti->Defaults;
|
|
fuglyname v;
|
|
|
|
v = defaults->WeaponClass;
|
|
if (v != NAME_None && v.IsValidName())
|
|
{
|
|
defaults->WeaponClass = PClass::FindClass(v);
|
|
if (!defaults->WeaponClass)
|
|
{
|
|
I_Error("Unknown weapon type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
else if (!defaults->WeaponClass->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
|
{
|
|
I_Error("Invalid weapon type '%s' in '%s'\n", v.GetChars(), ti->TypeName.GetChars());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Since these are defined in DECORATE now the table has to be initialized here.
|
|
for(int i=0;i<31;i++)
|
|
{
|
|
char fmt[20];
|
|
sprintf(fmt, "QuestItem%d", i+1);
|
|
QuestItemClasses[i]=PClass::FindClass(fmt);
|
|
}
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// ParseClass
|
|
//
|
|
// A minimal placeholder so that I can assign properties to some native
|
|
// classes. Please, no end users use this until it's finalized.
|
|
//
|
|
//==========================================================================
|
|
|
|
void ParseClass(FScanner &sc)
|
|
{
|
|
Baggage bag;
|
|
PClass *cls;
|
|
FName classname;
|
|
FName supername;
|
|
|
|
sc.MustGetToken(TK_Identifier); // class name
|
|
classname = sc.String;
|
|
sc.MustGetToken(TK_Extends); // because I'm not supporting Object
|
|
sc.MustGetToken(TK_Identifier); // superclass name
|
|
supername = sc.String;
|
|
sc.MustGetToken(TK_Native); // use actor definitions for your own stuff
|
|
sc.MustGetToken('{');
|
|
|
|
cls = const_cast<PClass*>(PClass::FindClass (classname));
|
|
if (cls == NULL)
|
|
{
|
|
sc.ScriptError ("'%s' is not a native class", classname.GetChars());
|
|
}
|
|
if (cls->ParentClass == NULL || cls->ParentClass->TypeName != supername)
|
|
{
|
|
sc.ScriptError ("'%s' does not extend '%s'", classname.GetChars(), supername.GetChars());
|
|
}
|
|
bag.Info = cls->ActorInfo;
|
|
|
|
sc.MustGetAnyToken();
|
|
while (sc.TokenType != '}')
|
|
{
|
|
if (sc.TokenType == TK_Action)
|
|
{
|
|
ParseActionDef(sc, cls);
|
|
}
|
|
else if (sc.TokenType == TK_Const)
|
|
{
|
|
ParseConstant(sc, &cls->Symbols, cls);
|
|
}
|
|
else if (sc.TokenType == TK_Enum)
|
|
{
|
|
ParseEnum(sc, &cls->Symbols, cls);
|
|
}
|
|
else
|
|
{
|
|
FString tokname = sc.TokenName(sc.TokenType, sc.String);
|
|
sc.ScriptError ("Expected 'action', 'const' or 'enum' but got %s", tokname.GetChars());
|
|
}
|
|
sc.MustGetAnyToken();
|
|
}
|
|
}
|