mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-10-18 08:03:11 -04:00
Added serverGame library
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerArmorTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerArmorTemplate_H
|
||||
#define _INCLUDED_ServerArmorTemplate_H
|
||||
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Armor;
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerArmorTemplate : public ObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerArmorTemplate_tag = TAG(A,R,M,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerArmorTemplate(const std::string & filename);
|
||||
virtual ~ServerArmorTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
enum ArmorRating
|
||||
{
|
||||
AR_armorRealNone = -1, // needed for internal reasons, do not use in templates! This means you!
|
||||
AR_armorNone = 0,
|
||||
AR_armorLight,
|
||||
AR_armorMedium,
|
||||
AR_armorHeavy,
|
||||
ArmorRating_Last = AR_armorHeavy,
|
||||
};
|
||||
|
||||
enum DamageType
|
||||
{
|
||||
DT_none = 0x00000000,
|
||||
DT_kinetic = 0x00000001,
|
||||
DT_energy = 0x00000002,
|
||||
DT_blast = 0x00000004,
|
||||
DT_stun = 0x00000008,
|
||||
DT_restraint = 0x00000010,
|
||||
DT_elemental_heat = 0x00000020,
|
||||
DT_elemental_cold = 0x00000040,
|
||||
DT_elemental_acid = 0x00000080,
|
||||
DT_elemental_electrical = 0x00000100,
|
||||
DT_environmental_heat = 0x00000200,
|
||||
DT_environmental_cold = 0x00000400,
|
||||
DT_environmental_acid = 0x00000800,
|
||||
DT_environmental_electrical = 0x00001000,
|
||||
DamageType_Last = DT_environmental_electrical,
|
||||
};
|
||||
|
||||
public:
|
||||
struct SpecialProtection
|
||||
{
|
||||
enum DamageType type;
|
||||
int effectiveness;
|
||||
};
|
||||
|
||||
protected:
|
||||
class _SpecialProtection : public ObjectTemplate
|
||||
{
|
||||
friend class ServerArmorTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_SpecialProtection_tag = TAG(A,R,S,P)
|
||||
};
|
||||
|
||||
public:
|
||||
_SpecialProtection(const std::string & filename);
|
||||
virtual ~_SpecialProtection();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
DamageType getType(bool versionOk, bool testData = false) const;
|
||||
int getEffectiveness(bool versionOk, bool testData = false) const;
|
||||
int getEffectivenessMin(bool versionOk, bool testData = false) const;
|
||||
int getEffectivenessMax(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_type; // specific damage being protected from
|
||||
IntegerParam m_effectiveness; // armor effectiveness ( <0 = no protection for this damage type, default protection will be ignored)
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_SpecialProtection(const _SpecialProtection &);
|
||||
_SpecialProtection & operator =(const _SpecialProtection &);
|
||||
};
|
||||
friend class ServerArmorTemplate::_SpecialProtection;
|
||||
|
||||
public:
|
||||
ArmorRating getRating(bool testData = false) const;
|
||||
int getIntegrity(bool testData = false) const;
|
||||
int getIntegrityMin(bool testData = false) const;
|
||||
int getIntegrityMax(bool testData = false) const;
|
||||
int getEffectiveness(bool testData = false) const;
|
||||
int getEffectivenessMin(bool testData = false) const;
|
||||
int getEffectivenessMax(bool testData = false) const;
|
||||
void getSpecialProtection(SpecialProtection &data, int index) const;
|
||||
void getSpecialProtectionMin(SpecialProtection &data, int index) const;
|
||||
void getSpecialProtectionMax(SpecialProtection &data, int index) const;
|
||||
size_t getSpecialProtectionCount(void) const;
|
||||
int getVulnerability(bool testData = false) const;
|
||||
int getVulnerabilityMin(bool testData = false) const;
|
||||
int getVulnerabilityMax(bool testData = false) const;
|
||||
int getEncumbrance(int index) const;
|
||||
int getEncumbranceMin(int index) const;
|
||||
int getEncumbranceMax(int index) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_rating; // armor rating
|
||||
IntegerParam m_integrity; // integrity
|
||||
IntegerParam m_effectiveness; // default effectiveness (0 = only use special protection)
|
||||
stdvector<StructParamOT *>::fwd m_specialProtection; // damage-type specific protection
|
||||
bool m_specialProtectionLoaded;
|
||||
bool m_specialProtectionAppend;
|
||||
IntegerParam m_vulnerability; // damaga types that this armor doesn't protect against
|
||||
IntegerParam m_encumbrance[3]; // reduction to attributes from wearing this armor
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerArmorTemplate(const ServerArmorTemplate &);
|
||||
ServerArmorTemplate & operator =(const ServerArmorTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerArmorTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerArmorTemplate::registerMe();
|
||||
ServerArmorTemplate::_SpecialProtection::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerArmorTemplate_H
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerBattlefieldMarkerObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerBattlefieldMarkerObjectTemplate.h"
|
||||
#include "serverGame/BattlefieldMarkerObject.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerBattlefieldMarkerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerBattlefieldMarkerObjectTemplate::ServerBattlefieldMarkerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerBattlefieldMarkerObjectTemplate::ServerBattlefieldMarkerObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerBattlefieldMarkerObjectTemplate::~ServerBattlefieldMarkerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerBattlefieldMarkerObjectTemplate::~ServerBattlefieldMarkerObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerBattlefieldMarkerObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerBattlefieldMarkerObjectTemplate_tag, create);
|
||||
} // ServerBattlefieldMarkerObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerBattlefieldMarkerObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerBattlefieldMarkerObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerBattlefieldMarkerObjectTemplate(filename);
|
||||
} // ServerBattlefieldMarkerObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerBattlefieldMarkerObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerBattlefieldMarkerObjectTemplate_tag;
|
||||
} // ServerBattlefieldMarkerObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerBattlefieldMarkerObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerBattlefieldMarkerObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerBattlefieldMarkerObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerBattlefieldMarkerObjectTemplate * base = dynamic_cast<const ServerBattlefieldMarkerObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerBattlefieldMarkerObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerBattlefieldMarkerObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new BattlefieldMarkerObject(this);
|
||||
} // ServerBattlefieldMarkerObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerBattlefieldMarkerObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerBattlefieldMarkerObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerBattlefieldMarkerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerBattlefieldMarkerObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerBattlefieldMarkerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerBattlefieldMarkerObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerBattlefieldMarkerObjectTemplate_H
|
||||
#define _INCLUDED_ServerBattlefieldMarkerObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerBattlefieldMarkerObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerBattlefieldMarkerObjectTemplate_tag = TAG(B,M,R,K)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerBattlefieldMarkerObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerBattlefieldMarkerObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerBattlefieldMarkerObjectTemplate(const ServerBattlefieldMarkerObjectTemplate &);
|
||||
ServerBattlefieldMarkerObjectTemplate & operator =(const ServerBattlefieldMarkerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerBattlefieldMarkerObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerBattlefieldMarkerObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerBattlefieldMarkerObjectTemplate_H
|
||||
+430
@@ -0,0 +1,430 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerBuildingObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerBuildingObjectTemplate.h"
|
||||
#include "serverGame/BuildingObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerBuildingObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerBuildingObjectTemplate::ServerBuildingObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerBuildingObjectTemplate::ServerBuildingObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerBuildingObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerBuildingObjectTemplate_tag, create);
|
||||
} // ServerBuildingObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerBuildingObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerBuildingObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerBuildingObjectTemplate(filename);
|
||||
} // ServerBuildingObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerBuildingObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerBuildingObjectTemplate_tag;
|
||||
} // ServerBuildingObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerBuildingObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerBuildingObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerBuildingObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerBuildingObjectTemplate * base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerBuildingObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerBuildingObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new BuildingObject(this);
|
||||
} // ServerBuildingObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
int ServerBuildingObjectTemplate::getMaintenanceCost(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerBuildingObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaintenanceCost(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maintenanceCost.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maintenanceCost in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maintenanceCost has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaintenanceCost();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maintenanceCost.getValue();
|
||||
char delta = m_maintenanceCost.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaintenanceCost();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerBuildingObjectTemplate::getMaintenanceCost
|
||||
|
||||
int ServerBuildingObjectTemplate::getMaintenanceCostMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerBuildingObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaintenanceCostMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maintenanceCost.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maintenanceCost in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maintenanceCost has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaintenanceCostMin();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maintenanceCost.getMinValue();
|
||||
char delta = m_maintenanceCost.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaintenanceCostMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerBuildingObjectTemplate::getMaintenanceCostMin
|
||||
|
||||
int ServerBuildingObjectTemplate::getMaintenanceCostMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerBuildingObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaintenanceCostMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maintenanceCost.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maintenanceCost in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maintenanceCost has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaintenanceCostMax();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maintenanceCost.getMaxValue();
|
||||
char delta = m_maintenanceCost.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaintenanceCostMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerBuildingObjectTemplate::getMaintenanceCostMax
|
||||
|
||||
bool ServerBuildingObjectTemplate::getIsPublic(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
bool testDataValue = false;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerBuildingObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getIsPublic(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_isPublic.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter isPublic in template %s", DataResource::getName()));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter isPublic has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getIsPublic();
|
||||
}
|
||||
}
|
||||
|
||||
bool value = m_isPublic.getValue();
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerBuildingObjectTemplate::getIsPublic
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerBuildingObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getMaintenanceCostMin(true));
|
||||
IGNORE_RETURN(getMaintenanceCostMax(true));
|
||||
IGNORE_RETURN(getIsPublic(true));
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerBuildingObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerBuildingObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerBuildingObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "maintenanceCost") == 0)
|
||||
m_maintenanceCost.loadFromIff(file);
|
||||
else if (strcmp(paramName, "isPublic") == 0)
|
||||
m_isPublic.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerBuildingObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerBuildingObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerBuildingObjectTemplate_H
|
||||
#define _INCLUDED_ServerBuildingObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerBuildingObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerBuildingObjectTemplate_tag = TAG(B,U,I,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerBuildingObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerBuildingObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
int getMaintenanceCost(bool testData = false) const;
|
||||
int getMaintenanceCostMin(bool testData = false) const;
|
||||
int getMaintenanceCostMax(bool testData = false) const;
|
||||
bool getIsPublic(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_maintenanceCost; // The weekly cost (in credits) of maintaining this Building.
|
||||
BoolParam m_isPublic; // Whether by default the building is flagged public.
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerBuildingObjectTemplate(const ServerBuildingObjectTemplate &);
|
||||
ServerBuildingObjectTemplate & operator =(const ServerBuildingObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerBuildingObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerBuildingObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerBuildingObjectTemplate_H
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerCellObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerCellObjectTemplate.h"
|
||||
#include "serverGame/CellObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerCellObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerCellObjectTemplate::ServerCellObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerCellObjectTemplate::ServerCellObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerCellObjectTemplate::~ServerCellObjectTemplate()
|
||||
{
|
||||
if (m_baseData)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Released m_baseData.\n"));
|
||||
m_baseData->releaseReference();
|
||||
m_baseData=0;
|
||||
}
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerCellObjectTemplate::~ServerCellObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerCellObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerCellObjectTemplate_tag, create);
|
||||
} // ServerCellObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerCellObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerCellObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerCellObjectTemplate(filename);
|
||||
} // ServerCellObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerCellObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerCellObjectTemplate_tag;
|
||||
} // ServerCellObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerCellObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerCellObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerCellObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerCellObjectTemplate * base = dynamic_cast<const ServerCellObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerCellObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerCellObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new CellObject(this);
|
||||
} // ServerCellObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerCellObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerObjectTemplate::testValues();
|
||||
} // ServerCellObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerCellObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerCellObjectTemplate_tag)
|
||||
{
|
||||
ServerObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerCellObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerCellObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerCellObjectTemplate_H
|
||||
#define _INCLUDED_ServerCellObjectTemplate_H
|
||||
|
||||
#include "ServerObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerCellObjectTemplate : public ServerObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerCellObjectTemplate_tag = TAG(S,C,L,T)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerCellObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerCellObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerCellObjectTemplate(const ServerCellObjectTemplate &);
|
||||
ServerCellObjectTemplate & operator =(const ServerCellObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerCellObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerCellObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerCellObjectTemplate_H
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerCityObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerCityObjectTemplate.h"
|
||||
|
||||
#include "serverGame/CityObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerCityObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerCityObjectTemplate::ServerCityObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerCityObjectTemplate::ServerCityObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerCityObjectTemplate::~ServerCityObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerCityObjectTemplate::~ServerCityObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerCityObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerCityObjectTemplate_tag, create);
|
||||
} // ServerCityObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerCityObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerCityObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerCityObjectTemplate(filename);
|
||||
} // ServerCityObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerCityObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerCityObjectTemplate_tag;
|
||||
} // ServerCityObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerCityObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerCityObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerCityObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerCityObjectTemplate * base = dynamic_cast<const ServerCityObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerCityObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerCityObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new CityObject(this);
|
||||
} // ServerCityObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerCityObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerUniverseObjectTemplate::testValues();
|
||||
} // ServerCityObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerCityObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerCityObjectTemplate_tag)
|
||||
{
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerCityObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerCityObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerCityObjectTemplate_H
|
||||
#define _INCLUDED_ServerCityObjectTemplate_H
|
||||
|
||||
#include "ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerCityObjectTemplate : public ServerUniverseObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerCityObjectTemplate_tag = TAG(C,I,T,Y)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerCityObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerCityObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerCityObjectTemplate(const ServerCityObjectTemplate &);
|
||||
ServerCityObjectTemplate & operator =(const ServerCityObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerCityObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerCityObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerCityObjectTemplate_H
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerConstructionContractObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerConstructionContractObjectTemplate.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedMath/Vector.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerConstructionContractObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerConstructionContractObjectTemplate::ServerConstructionContractObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerConstructionContractObjectTemplate::ServerConstructionContractObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerConstructionContractObjectTemplate::~ServerConstructionContractObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerConstructionContractObjectTemplate::~ServerConstructionContractObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerConstructionContractObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerConstructionContractObjectTemplate_tag, create);
|
||||
} // ServerConstructionContractObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerConstructionContractObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerConstructionContractObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerConstructionContractObjectTemplate(filename);
|
||||
} // ServerConstructionContractObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerConstructionContractObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerConstructionContractObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerConstructionContractObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerConstructionContractObjectTemplate * base = dynamic_cast<const ServerConstructionContractObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerConstructionContractObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerConstructionContractObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerConstructionContractObjectTemplate_tag;
|
||||
} // ServerConstructionContractObjectTemplate::getId
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerConstructionContractObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerIntangibleObjectTemplate::testValues();
|
||||
} // ServerConstructionContractObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerConstructionContractObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerConstructionContractObjectTemplate_tag)
|
||||
{
|
||||
ServerIntangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerIntangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerConstructionContractObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerConstructionContractObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerConstructionContractObjectTemplate_H
|
||||
#define _INCLUDED_ServerConstructionContractObjectTemplate_H
|
||||
|
||||
#include "ServerIntangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerConstructionContractObjectTemplate : public ServerIntangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerConstructionContractObjectTemplate_tag = TAG(C,O,N,C)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerConstructionContractObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerConstructionContractObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerConstructionContractObjectTemplate(const ServerConstructionContractObjectTemplate &);
|
||||
ServerConstructionContractObjectTemplate & operator =(const ServerConstructionContractObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerConstructionContractObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerConstructionContractObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerConstructionContractObjectTemplate_H
|
||||
+2512
File diff suppressed because it is too large
Load Diff
+162
@@ -0,0 +1,162 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerCreatureObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerCreatureObjectTemplate_H
|
||||
#define _INCLUDED_ServerCreatureObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
class ServerWeaponObjectTemplate;
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerCreatureObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerCreatureObjectTemplate_tag = TAG(C,R,E,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerCreatureObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerCreatureObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
void postLoad();
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
enum PathNodeType
|
||||
{
|
||||
PN_Open, // //grasslands
|
||||
PN_SparseCover, // //light forests, vaporator farms
|
||||
PN_DenseCover, // //dense forests etc.
|
||||
PN_NaturalInterior, // //caves
|
||||
PN_ArtificialInterior, // //buildings
|
||||
PN_NaturalPath, // //paths and trails
|
||||
PN_ArtificialPath, // //roads
|
||||
PN_PassableWater, // //rivers, ponds, shorelines
|
||||
PN_ImpassableWater, // //big lakes and oceans
|
||||
PathNodeType_Last = PN_ImpassableWater,
|
||||
};
|
||||
|
||||
public:
|
||||
const ServerWeaponObjectTemplate * getDefaultWeapon() const;
|
||||
int getAttributes(Attributes index) const;
|
||||
int getAttributesMin(Attributes index) const;
|
||||
int getAttributesMax(Attributes index) const;
|
||||
int getMinAttributes(Attributes index) const;
|
||||
int getMinAttributesMin(Attributes index) const;
|
||||
int getMinAttributesMax(Attributes index) const;
|
||||
int getMaxAttributes(Attributes index) const;
|
||||
int getMaxAttributesMin(Attributes index) const;
|
||||
int getMaxAttributesMax(Attributes index) const;
|
||||
float getMinDrainModifier(bool testData = false) const;
|
||||
float getMinDrainModifierMin(bool testData = false) const;
|
||||
float getMinDrainModifierMax(bool testData = false) const;
|
||||
float getMaxDrainModifier(bool testData = false) const;
|
||||
float getMaxDrainModifierMin(bool testData = false) const;
|
||||
float getMaxDrainModifierMax(bool testData = false) const;
|
||||
float getMinFaucetModifier(bool testData = false) const;
|
||||
float getMinFaucetModifierMin(bool testData = false) const;
|
||||
float getMinFaucetModifierMax(bool testData = false) const;
|
||||
float getMaxFaucetModifier(bool testData = false) const;
|
||||
float getMaxFaucetModifierMin(bool testData = false) const;
|
||||
float getMaxFaucetModifierMax(bool testData = false) const;
|
||||
void getAttribMods(AttribMod &data, int index) const;
|
||||
void getAttribModsMin(AttribMod &data, int index) const;
|
||||
void getAttribModsMax(AttribMod &data, int index) const;
|
||||
size_t getAttribModsCount(void) const;
|
||||
int getShockWounds(bool testData = false) const;
|
||||
int getShockWoundsMin(bool testData = false) const;
|
||||
int getShockWoundsMax(bool testData = false) const;
|
||||
bool getCanCreateAvatar(bool testData = false) const;
|
||||
const std::string & getNameGeneratorType(bool testData = false) const;
|
||||
float getApproachTriggerRange(bool testData = false) const;
|
||||
float getApproachTriggerRangeMin(bool testData = false) const;
|
||||
float getApproachTriggerRangeMax(bool testData = false) const;
|
||||
float getMaxMentalStates(MentalStates index) const;
|
||||
float getMaxMentalStatesMin(MentalStates index) const;
|
||||
float getMaxMentalStatesMax(MentalStates index) const;
|
||||
float getMentalStatesDecay(MentalStates index) const;
|
||||
float getMentalStatesDecayMin(MentalStates index) const;
|
||||
float getMentalStatesDecayMax(MentalStates index) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//Creature Attributes
|
||||
StringParam m_defaultWeapon; // //weapon to use if none is equipped
|
||||
IntegerParam m_attributes[6]; // //initial value for attributes
|
||||
IntegerParam m_minAttributes[6]; // //minimum value for attributes
|
||||
IntegerParam m_maxAttributes[6]; // //maximum value for attributes
|
||||
FloatParam m_minDrainModifier; // //min drain rate in units/sec
|
||||
FloatParam m_maxDrainModifier; // //max drain rate in units/sec
|
||||
FloatParam m_minFaucetModifier; // //min regeneration rate in units/sec
|
||||
FloatParam m_maxFaucetModifier; // //max regeneration rate in units/sec
|
||||
stdvector<StructParamOT *>::fwd m_attribMods; // //(de)buffs the creature is created with
|
||||
bool m_attribModsLoaded;
|
||||
bool m_attribModsAppend;
|
||||
IntegerParam m_shockWounds; // //current shock wounds
|
||||
BoolParam m_canCreateAvatar; // //can a player create an avatar with this template
|
||||
StringParam m_nameGeneratorType; // //identifies which name generator to use
|
||||
// AI Behavioral Variables
|
||||
FloatParam m_approachTriggerRange;
|
||||
FloatParam m_maxMentalStates[4]; // //maximum value for the mental state
|
||||
FloatParam m_mentalStatesDecay[4]; // //time for the state to decay from 100 to 0
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerCreatureObjectTemplate(const ServerCreatureObjectTemplate &);
|
||||
ServerCreatureObjectTemplate & operator =(const ServerCreatureObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerCreatureObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerCreatureObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerCreatureObjectTemplate_H
|
||||
+2021
File diff suppressed because it is too large
Load Diff
+198
@@ -0,0 +1,198 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerDraftSchematicObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerDraftSchematicObjectTemplate_H
|
||||
#define _INCLUDED_ServerDraftSchematicObjectTemplate_H
|
||||
|
||||
#include "ServerIntangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
class ServerFactoryObjectTemplate;
|
||||
class ServerObjectTemplate;
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerDraftSchematicObjectTemplate : public ServerIntangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerDraftSchematicObjectTemplate_tag = TAG(D,S,C,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerDraftSchematicObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerDraftSchematicObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
struct IngredientSlot
|
||||
{
|
||||
bool optional;
|
||||
StringId name;
|
||||
stdvector<Ingredient>::fwd options;
|
||||
std::string optionalSkillCommand;
|
||||
float complexity;
|
||||
std::string appearance;
|
||||
};
|
||||
|
||||
protected:
|
||||
class _IngredientSlot : public ObjectTemplate
|
||||
{
|
||||
friend class ServerDraftSchematicObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_IngredientSlot_tag = TAG(D,I,N,S)
|
||||
};
|
||||
|
||||
public:
|
||||
_IngredientSlot(const std::string & filename);
|
||||
virtual ~_IngredientSlot();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
bool getOptional(bool versionOk, bool testData = false) const;
|
||||
const StringId getName(bool versionOk, bool testData = false) const;
|
||||
void getOptions(Ingredient &data, int index, bool versionOk) const;
|
||||
void getOptionsMin(Ingredient &data, int index, bool versionOk) const;
|
||||
void getOptionsMax(Ingredient &data, int index, bool versionOk) const;
|
||||
size_t getOptionsCount(void) const;
|
||||
const std::string & getOptionalSkillCommand(bool versionOk, bool testData = false) const;
|
||||
float getComplexity(bool versionOk, bool testData = false) const;
|
||||
float getComplexityMin(bool versionOk, bool testData = false) const;
|
||||
float getComplexityMax(bool versionOk, bool testData = false) const;
|
||||
const std::string & getAppearance(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
BoolParam m_optional; // is the slot optional
|
||||
StringIdParam m_name; // slot name
|
||||
stdvector<StructParamOT *>::fwd m_options; // possible ingredients that can be used to fill the slot
|
||||
bool m_optionsLoaded;
|
||||
bool m_optionsAppend;
|
||||
StringParam m_optionalSkillCommand; // skill commands needed to access this slot if it is optional (ignored for required slots)
|
||||
FloatParam m_complexity; // adjustment to complexity by using this slot
|
||||
StringParam m_appearance; // if the slot is a component, the name of the hardpoint associated with the slot; if the slot is a resource, a string used to build an appearance file name
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_IngredientSlot(const _IngredientSlot &);
|
||||
_IngredientSlot & operator =(const _IngredientSlot &);
|
||||
};
|
||||
friend class ServerDraftSchematicObjectTemplate::_IngredientSlot;
|
||||
|
||||
public:
|
||||
CraftingType getCategory(bool testData = false) const;
|
||||
const ServerObjectTemplate * getCraftedObjectTemplate() const;
|
||||
const ServerFactoryObjectTemplate * getCrateObjectTemplate() const;
|
||||
void getSlots(IngredientSlot &data, int index) const;
|
||||
void getSlotsMin(IngredientSlot &data, int index) const;
|
||||
void getSlotsMax(IngredientSlot &data, int index) const;
|
||||
size_t getSlotsCount(void) const;
|
||||
const std::string & getSkillCommands(int index) const;
|
||||
size_t getSkillCommandsCount(void) const;
|
||||
bool getDestroyIngredients(bool testData = false) const;
|
||||
const std::string & getManufactureScripts(int index) const;
|
||||
size_t getManufactureScriptsCount(void) const;
|
||||
int getItemsPerContainer(bool testData = false) const;
|
||||
int getItemsPerContainerMin(bool testData = false) const;
|
||||
int getItemsPerContainerMax(bool testData = false) const;
|
||||
float getManufactureTime(bool testData = false) const;
|
||||
float getManufactureTimeMin(bool testData = false) const;
|
||||
float getManufactureTimeMax(bool testData = false) const;
|
||||
float getPrototypeTime(bool testData = false) const;
|
||||
float getPrototypeTimeMin(bool testData = false) const;
|
||||
float getPrototypeTimeMax(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_category; // schematic category (food, weapon, etc)
|
||||
StringParam m_craftedObjectTemplate; // what object we create
|
||||
StringParam m_crateObjectTemplate; // the "crate" to use when manufacturing multiple copies of the object
|
||||
stdvector<StructParamOT *>::fwd m_slots; // ingredient slots
|
||||
bool m_slotsLoaded;
|
||||
bool m_slotsAppend;
|
||||
stdvector<StringParam *>::fwd m_skillCommands; // skill commands needed to access this schematic and required slots
|
||||
bool m_skillCommandsLoaded;
|
||||
bool m_skillCommandsAppend;
|
||||
BoolParam m_destroyIngredients; // flag that the ingredients used in the design stage should be destroyed
|
||||
stdvector<StringParam *>::fwd m_manufactureScripts; // scripts that will be attached to a manufacturing schematic created from this schematic
|
||||
bool m_manufactureScriptsLoaded;
|
||||
bool m_manufactureScriptsAppend;
|
||||
IntegerParam m_itemsPerContainer; // when manufacturing, how many items will be put in a container (1 = items not in a container)
|
||||
FloatParam m_manufactureTime; // time to manufacture an item (in secs) per complexity point
|
||||
FloatParam m_prototypeTime; // time to create a prototype (in secs) per complexity point
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
protected:
|
||||
// user functions
|
||||
virtual void postLoad();
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerDraftSchematicObjectTemplate(const ServerDraftSchematicObjectTemplate &);
|
||||
ServerDraftSchematicObjectTemplate & operator =(const ServerDraftSchematicObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerDraftSchematicObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerDraftSchematicObjectTemplate::registerMe();
|
||||
ServerDraftSchematicObjectTemplate::_IngredientSlot::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerDraftSchematicObjectTemplate_H
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerFactoryObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerFactoryObjectTemplate.h"
|
||||
#include "serverGame/FactoryObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerFactoryObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerFactoryObjectTemplate::ServerFactoryObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerFactoryObjectTemplate::ServerFactoryObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerFactoryObjectTemplate::~ServerFactoryObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerFactoryObjectTemplate::~ServerFactoryObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerFactoryObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerFactoryObjectTemplate_tag, create);
|
||||
} // ServerFactoryObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerFactoryObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerFactoryObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerFactoryObjectTemplate(filename);
|
||||
} // ServerFactoryObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerFactoryObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerFactoryObjectTemplate_tag;
|
||||
} // ServerFactoryObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerFactoryObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerFactoryObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerFactoryObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerFactoryObjectTemplate * base = dynamic_cast<const ServerFactoryObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerFactoryObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerFactoryObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new FactoryObject(this);
|
||||
} // ServerFactoryObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerFactoryObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerFactoryObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerFactoryObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerFactoryObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerFactoryObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerFactoryObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerFactoryObjectTemplate_H
|
||||
#define _INCLUDED_ServerFactoryObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerFactoryObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerFactoryObjectTemplate_tag = TAG(F,C,Y,T)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerFactoryObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerFactoryObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerFactoryObjectTemplate(const ServerFactoryObjectTemplate &);
|
||||
ServerFactoryObjectTemplate & operator =(const ServerFactoryObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerFactoryObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerFactoryObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerFactoryObjectTemplate_H
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerGroupObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerGroupObjectTemplate.h"
|
||||
|
||||
#include "serverGame/GroupObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerGroupObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerGroupObjectTemplate::ServerGroupObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerGroupObjectTemplate::ServerGroupObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerGroupObjectTemplate::~ServerGroupObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerGroupObjectTemplate::~ServerGroupObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerGroupObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerGroupObjectTemplate_tag, create);
|
||||
} // ServerGroupObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerGroupObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerGroupObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerGroupObjectTemplate(filename);
|
||||
} // ServerGroupObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerGroupObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerGroupObjectTemplate_tag;
|
||||
} // ServerGroupObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerGroupObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerGroupObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerGroupObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerGroupObjectTemplate * base = dynamic_cast<const ServerGroupObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerGroupObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerGroupObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new GroupObject(this);
|
||||
} // ServerGroupObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerGroupObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerUniverseObjectTemplate::testValues();
|
||||
} // ServerGroupObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerGroupObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerGroupObjectTemplate_tag)
|
||||
{
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerGroupObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerGroupObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerGroupObjectTemplate_H
|
||||
#define _INCLUDED_ServerGroupObjectTemplate_H
|
||||
|
||||
#include "ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerGroupObjectTemplate : public ServerUniverseObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerGroupObjectTemplate_tag = TAG(G,R,U,P)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerGroupObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerGroupObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerGroupObjectTemplate(const ServerGroupObjectTemplate &);
|
||||
ServerGroupObjectTemplate & operator =(const ServerGroupObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerGroupObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerGroupObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerGroupObjectTemplate_H
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerGuildObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerGuildObjectTemplate.h"
|
||||
|
||||
#include "serverGame/GuildObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerGuildObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerGuildObjectTemplate::ServerGuildObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerGuildObjectTemplate::ServerGuildObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerGuildObjectTemplate::~ServerGuildObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerGuildObjectTemplate::~ServerGuildObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerGuildObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerGuildObjectTemplate_tag, create);
|
||||
} // ServerGuildObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerGuildObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerGuildObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerGuildObjectTemplate(filename);
|
||||
} // ServerGuildObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerGuildObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerGuildObjectTemplate_tag;
|
||||
} // ServerGuildObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerGuildObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerGuildObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerGuildObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerGuildObjectTemplate * base = dynamic_cast<const ServerGuildObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerGuildObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerGuildObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new GuildObject(this);
|
||||
} // ServerGuildObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerGuildObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerUniverseObjectTemplate::testValues();
|
||||
} // ServerGuildObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerGuildObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerGuildObjectTemplate_tag)
|
||||
{
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerGuildObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerGuildObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerGuildObjectTemplate_H
|
||||
#define _INCLUDED_ServerGuildObjectTemplate_H
|
||||
|
||||
#include "ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerGuildObjectTemplate : public ServerUniverseObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerGuildObjectTemplate_tag = TAG(G,I,L,D)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerGuildObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerGuildObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerGuildObjectTemplate(const ServerGuildObjectTemplate &);
|
||||
ServerGuildObjectTemplate & operator =(const ServerGuildObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerGuildObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerGuildObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerGuildObjectTemplate_H
|
||||
+822
@@ -0,0 +1,822 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerHarvesterInstallationObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerHarvesterInstallationObjectTemplate.h"
|
||||
#include "serverGame/HarvesterInstallationObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerHarvesterInstallationObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerInstallationObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerHarvesterInstallationObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerHarvesterInstallationObjectTemplate_tag, create);
|
||||
} // ServerHarvesterInstallationObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerHarvesterInstallationObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerHarvesterInstallationObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerHarvesterInstallationObjectTemplate(filename);
|
||||
} // ServerHarvesterInstallationObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerHarvesterInstallationObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerHarvesterInstallationObjectTemplate_tag;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerHarvesterInstallationObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerHarvesterInstallationObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerHarvesterInstallationObjectTemplate * base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerHarvesterInstallationObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerHarvesterInstallationObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new HarvesterInstallationObject(this);
|
||||
} // ServerHarvesterInstallationObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRate(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxExtractionRate(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxExtractionRate.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxExtractionRate in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxExtractionRate has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxExtractionRate();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxExtractionRate.getValue();
|
||||
char delta = m_maxExtractionRate.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxExtractionRate();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMaxExtractionRate
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxExtractionRateMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxExtractionRate.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxExtractionRate in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxExtractionRate has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxExtractionRateMin();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxExtractionRate.getMinValue();
|
||||
char delta = m_maxExtractionRate.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxExtractionRateMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMin
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxExtractionRateMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxExtractionRate.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxExtractionRate in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxExtractionRate has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxExtractionRateMax();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxExtractionRate.getMaxValue();
|
||||
char delta = m_maxExtractionRate.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxExtractionRateMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMax
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRate(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getCurrentExtractionRate(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_currentExtractionRate.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter currentExtractionRate in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter currentExtractionRate has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getCurrentExtractionRate();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_currentExtractionRate.getValue();
|
||||
char delta = m_currentExtractionRate.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getCurrentExtractionRate();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRate
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getCurrentExtractionRateMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_currentExtractionRate.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter currentExtractionRate in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter currentExtractionRate has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getCurrentExtractionRateMin();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_currentExtractionRate.getMinValue();
|
||||
char delta = m_currentExtractionRate.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getCurrentExtractionRateMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMin
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getCurrentExtractionRateMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_currentExtractionRate.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter currentExtractionRate in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter currentExtractionRate has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getCurrentExtractionRateMax();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_currentExtractionRate.getMaxValue();
|
||||
char delta = m_currentExtractionRate.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getCurrentExtractionRateMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMax
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxHopperSize(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxHopperSize(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxHopperSize.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxHopperSize in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxHopperSize has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxHopperSize();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxHopperSize.getValue();
|
||||
char delta = m_maxHopperSize.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxHopperSize();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMaxHopperSize
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxHopperSizeMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxHopperSize.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxHopperSize in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxHopperSize has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxHopperSizeMin();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxHopperSize.getMinValue();
|
||||
char delta = m_maxHopperSize.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxHopperSizeMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMin
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxHopperSizeMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxHopperSize.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxHopperSize in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxHopperSize has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxHopperSizeMax();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxHopperSize.getMaxValue();
|
||||
char delta = m_maxHopperSize.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxHopperSizeMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMax
|
||||
|
||||
const std::string & ServerHarvesterInstallationObjectTemplate::getMasterClassName(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::string testDataValue = DefaultString;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMasterClassName(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_masterClassName.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter masterClassName in template %s", DataResource::getName()));
|
||||
return DefaultString;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter masterClassName has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMasterClassName();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string & value = m_masterClassName.getValue();
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMasterClassName
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerHarvesterInstallationObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getMaxExtractionRateMin(true));
|
||||
IGNORE_RETURN(getMaxExtractionRateMax(true));
|
||||
IGNORE_RETURN(getCurrentExtractionRateMin(true));
|
||||
IGNORE_RETURN(getCurrentExtractionRateMax(true));
|
||||
IGNORE_RETURN(getMaxHopperSizeMin(true));
|
||||
IGNORE_RETURN(getMaxHopperSizeMax(true));
|
||||
IGNORE_RETURN(getMasterClassName(true));
|
||||
ServerInstallationObjectTemplate::testValues();
|
||||
} // ServerHarvesterInstallationObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerHarvesterInstallationObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerHarvesterInstallationObjectTemplate_tag)
|
||||
{
|
||||
ServerInstallationObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "maxExtractionRate") == 0)
|
||||
m_maxExtractionRate.loadFromIff(file);
|
||||
else if (strcmp(paramName, "currentExtractionRate") == 0)
|
||||
m_currentExtractionRate.loadFromIff(file);
|
||||
else if (strcmp(paramName, "maxHopperSize") == 0)
|
||||
m_maxHopperSize.loadFromIff(file);
|
||||
else if (strcmp(paramName, "masterClassName") == 0)
|
||||
m_masterClassName.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerInstallationObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerHarvesterInstallationObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerHarvesterInstallationObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerHarvesterInstallationObjectTemplate_H
|
||||
#define _INCLUDED_ServerHarvesterInstallationObjectTemplate_H
|
||||
|
||||
#include "ServerInstallationObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerHarvesterInstallationObjectTemplate : public ServerInstallationObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerHarvesterInstallationObjectTemplate_tag = TAG(H,I,N,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerHarvesterInstallationObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerHarvesterInstallationObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
int getMaxExtractionRate(bool testData = false) const;
|
||||
int getMaxExtractionRateMin(bool testData = false) const;
|
||||
int getMaxExtractionRateMax(bool testData = false) const;
|
||||
int getCurrentExtractionRate(bool testData = false) const;
|
||||
int getCurrentExtractionRateMin(bool testData = false) const;
|
||||
int getCurrentExtractionRateMax(bool testData = false) const;
|
||||
int getMaxHopperSize(bool testData = false) const;
|
||||
int getMaxHopperSizeMin(bool testData = false) const;
|
||||
int getMaxHopperSizeMax(bool testData = false) const;
|
||||
const std::string & getMasterClassName(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_maxExtractionRate; // max extraction rate
|
||||
IntegerParam m_currentExtractionRate; // rate at which the machine could currently operate
|
||||
IntegerParam m_maxHopperSize; // max extracted resource storage capacity of the installation
|
||||
StringParam m_masterClassName; // highest level resource class that the harverster can extract
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerHarvesterInstallationObjectTemplate(const ServerHarvesterInstallationObjectTemplate &);
|
||||
ServerHarvesterInstallationObjectTemplate & operator =(const ServerHarvesterInstallationObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerHarvesterInstallationObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerHarvesterInstallationObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerHarvesterInstallationObjectTemplate_H
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerInstallationObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerInstallationObjectTemplate.h"
|
||||
#include "serverGame/InstallationObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerInstallationObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerInstallationObjectTemplate::ServerInstallationObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerInstallationObjectTemplate::ServerInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerInstallationObjectTemplate::~ServerInstallationObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerInstallationObjectTemplate::~ServerInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerInstallationObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerInstallationObjectTemplate_tag, create);
|
||||
} // ServerInstallationObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerInstallationObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerInstallationObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerInstallationObjectTemplate(filename);
|
||||
} // ServerInstallationObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerInstallationObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerInstallationObjectTemplate_tag;
|
||||
} // ServerInstallationObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerInstallationObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerInstallationObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerInstallationObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerInstallationObjectTemplate * base = dynamic_cast<const ServerInstallationObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerInstallationObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerInstallationObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new InstallationObject(this);
|
||||
} // ServerInstallationObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerInstallationObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerInstallationObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerInstallationObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerInstallationObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerInstallationObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerInstallationObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerInstallationObjectTemplate_H
|
||||
#define _INCLUDED_ServerInstallationObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerInstallationObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerInstallationObjectTemplate_tag = TAG(I,N,S,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerInstallationObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerInstallationObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerInstallationObjectTemplate(const ServerInstallationObjectTemplate &);
|
||||
ServerInstallationObjectTemplate & operator =(const ServerInstallationObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerInstallationObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerInstallationObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerInstallationObjectTemplate_H
|
||||
+1633
File diff suppressed because it is too large
Load Diff
+272
@@ -0,0 +1,272 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerIntangibleObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerIntangibleObjectTemplate_H
|
||||
#define _INCLUDED_ServerIntangibleObjectTemplate_H
|
||||
|
||||
#include "ServerObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerIntangibleObjectTemplate : public ServerObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerIntangibleObjectTemplate_tag = TAG(I,T,N,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerIntangibleObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerIntangibleObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
enum IngredientType
|
||||
{
|
||||
IT_none, // no item (for empty/unused slots)
|
||||
IT_item, // a specific item (Skywalker barrel mark V)
|
||||
IT_template, // any item created from a template (any small_blaster_barrel)
|
||||
IT_resourceType, // a specific resource type (iron type 5)
|
||||
IT_resourceClass, // any resource of a resource class (ferrous metal)
|
||||
IT_templateGeneric, // same as IT_template, but if multiple components are required, they don't have to be the same exact type as the first component used
|
||||
IT_schematic, // item crafted from a draft schematic
|
||||
IT_schematicGeneric, // same as IT_schematic, but if multiple components are required, they don't have to be the same exact type as the first component used
|
||||
IngredientType_Last = IT_schematicGeneric,
|
||||
};
|
||||
|
||||
public:
|
||||
struct SimpleIngredient
|
||||
{
|
||||
StringId name;
|
||||
std::string ingredient;
|
||||
int count;
|
||||
};
|
||||
|
||||
struct Ingredient
|
||||
{
|
||||
enum IngredientType ingredientType;
|
||||
stdvector<SimpleIngredient>::fwd ingredients;
|
||||
float complexity;
|
||||
std::string skillCommand;
|
||||
};
|
||||
|
||||
struct SchematicAttribute
|
||||
{
|
||||
StringId name;
|
||||
int value;
|
||||
};
|
||||
|
||||
protected:
|
||||
class _SimpleIngredient : public ObjectTemplate
|
||||
{
|
||||
friend class ServerIntangibleObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_SimpleIngredient_tag = TAG(S,I,N,G)
|
||||
};
|
||||
|
||||
public:
|
||||
_SimpleIngredient(const std::string & filename);
|
||||
virtual ~_SimpleIngredient();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
const StringId getName(bool versionOk, bool testData = false) const;
|
||||
const std::string & getIngredient(bool versionOk, bool testData = false) const;
|
||||
int getCount(bool versionOk, bool testData = false) const;
|
||||
int getCountMin(bool versionOk, bool testData = false) const;
|
||||
int getCountMax(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringIdParam m_name; // name of ingredient that is given to players
|
||||
StringParam m_ingredient; // name of ingredient used to match the resource/component name
|
||||
IntegerParam m_count; // number of ingredients
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_SimpleIngredient(const _SimpleIngredient &);
|
||||
_SimpleIngredient & operator =(const _SimpleIngredient &);
|
||||
};
|
||||
friend class ServerIntangibleObjectTemplate::_SimpleIngredient;
|
||||
|
||||
class _Ingredient : public ObjectTemplate
|
||||
{
|
||||
friend class ServerIntangibleObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_Ingredient_tag = TAG(I,N,G,R)
|
||||
};
|
||||
|
||||
public:
|
||||
_Ingredient(const std::string & filename);
|
||||
virtual ~_Ingredient();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
IngredientType getIngredientType(bool versionOk, bool testData = false) const;
|
||||
void getIngredients(SimpleIngredient &data, int index, bool versionOk) const;
|
||||
void getIngredientsMin(SimpleIngredient &data, int index, bool versionOk) const;
|
||||
void getIngredientsMax(SimpleIngredient &data, int index, bool versionOk) const;
|
||||
size_t getIngredientsCount(void) const;
|
||||
float getComplexity(bool versionOk, bool testData = false) const;
|
||||
float getComplexityMin(bool versionOk, bool testData = false) const;
|
||||
float getComplexityMax(bool versionOk, bool testData = false) const;
|
||||
const std::string & getSkillCommand(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_ingredientType; // type of ingredient required
|
||||
stdvector<StructParamOT *>::fwd m_ingredients; // ingredients to be used/being used
|
||||
bool m_ingredientsLoaded;
|
||||
bool m_ingredientsAppend;
|
||||
FloatParam m_complexity; // adjustment to complexity by using this ingredient
|
||||
StringParam m_skillCommand; // skill command needed to use this ingredient
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_Ingredient(const _Ingredient &);
|
||||
_Ingredient & operator =(const _Ingredient &);
|
||||
};
|
||||
friend class ServerIntangibleObjectTemplate::_Ingredient;
|
||||
|
||||
class _SchematicAttribute : public ObjectTemplate
|
||||
{
|
||||
friend class ServerIntangibleObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_SchematicAttribute_tag = TAG(I,T,A,T)
|
||||
};
|
||||
|
||||
public:
|
||||
_SchematicAttribute(const std::string & filename);
|
||||
virtual ~_SchematicAttribute();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
const StringId getName(bool versionOk, bool testData = false) const;
|
||||
int getValue(bool versionOk, bool testData = false) const;
|
||||
int getValueMin(bool versionOk, bool testData = false) const;
|
||||
int getValueMax(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringIdParam m_name; // name of the attribute
|
||||
IntegerParam m_value; // value of the attribute - a range for draft schematics and a single value for manufacture schematics
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_SchematicAttribute(const _SchematicAttribute &);
|
||||
_SchematicAttribute & operator =(const _SchematicAttribute &);
|
||||
};
|
||||
friend class ServerIntangibleObjectTemplate::_SchematicAttribute;
|
||||
|
||||
public:
|
||||
int getCount(bool testData = false) const;
|
||||
int getCountMin(bool testData = false) const;
|
||||
int getCountMax(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//
|
||||
// shared info needed by draft and manufacturing schematics
|
||||
//
|
||||
// this enum list must be reflected in MessageQueueIngredients.h
|
||||
IntegerParam m_count; // generic counter
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerIntangibleObjectTemplate(const ServerIntangibleObjectTemplate &);
|
||||
ServerIntangibleObjectTemplate & operator =(const ServerIntangibleObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerIntangibleObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerIntangibleObjectTemplate::registerMe();
|
||||
ServerIntangibleObjectTemplate::_Ingredient::registerMe();
|
||||
ServerIntangibleObjectTemplate::_SchematicAttribute::registerMe();
|
||||
ServerIntangibleObjectTemplate::_SimpleIngredient::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerIntangibleObjectTemplate_H
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerManufactureInstallationObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerManufactureInstallationObjectTemplate.h"
|
||||
#include "serverGame/ManufactureInstallationObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerManufactureInstallationObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerManufactureInstallationObjectTemplate::ServerManufactureInstallationObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerInstallationObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerManufactureInstallationObjectTemplate::ServerManufactureInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerManufactureInstallationObjectTemplate::~ServerManufactureInstallationObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerManufactureInstallationObjectTemplate::~ServerManufactureInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerManufactureInstallationObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerManufactureInstallationObjectTemplate_tag, create);
|
||||
} // ServerManufactureInstallationObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerManufactureInstallationObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerManufactureInstallationObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerManufactureInstallationObjectTemplate(filename);
|
||||
} // ServerManufactureInstallationObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerManufactureInstallationObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerManufactureInstallationObjectTemplate_tag;
|
||||
} // ServerManufactureInstallationObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerManufactureInstallationObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerManufactureInstallationObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerManufactureInstallationObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerManufactureInstallationObjectTemplate * base = dynamic_cast<const ServerManufactureInstallationObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerManufactureInstallationObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerManufactureInstallationObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new ManufactureInstallationObject(this);
|
||||
} // ServerManufactureInstallationObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerManufactureInstallationObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerInstallationObjectTemplate::testValues();
|
||||
} // ServerManufactureInstallationObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerManufactureInstallationObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerManufactureInstallationObjectTemplate_tag)
|
||||
{
|
||||
ServerInstallationObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerInstallationObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerManufactureInstallationObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerManufactureInstallationObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerManufactureInstallationObjectTemplate_H
|
||||
#define _INCLUDED_ServerManufactureInstallationObjectTemplate_H
|
||||
|
||||
#include "ServerInstallationObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerManufactureInstallationObjectTemplate : public ServerInstallationObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerManufactureInstallationObjectTemplate_tag = TAG(M,I,N,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerManufactureInstallationObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerManufactureInstallationObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerManufactureInstallationObjectTemplate(const ServerManufactureInstallationObjectTemplate &);
|
||||
ServerManufactureInstallationObjectTemplate & operator =(const ServerManufactureInstallationObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerManufactureInstallationObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerManufactureInstallationObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerManufactureInstallationObjectTemplate_H
|
||||
+1124
File diff suppressed because it is too large
Load Diff
+163
@@ -0,0 +1,163 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerManufactureSchematicObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerManufactureSchematicObjectTemplate_H
|
||||
#define _INCLUDED_ServerManufactureSchematicObjectTemplate_H
|
||||
|
||||
#include "ServerIntangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class DraftSchematicObject;
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerManufactureSchematicObjectTemplate : public ServerIntangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerManufactureSchematicObjectTemplate_tag = TAG(M,S,C,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerManufactureSchematicObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerManufactureSchematicObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
struct IngredientSlot
|
||||
{
|
||||
StringId name;
|
||||
Ingredient ingredient;
|
||||
};
|
||||
|
||||
protected:
|
||||
class _IngredientSlot : public ObjectTemplate
|
||||
{
|
||||
friend class ServerManufactureSchematicObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_IngredientSlot_tag = TAG(M,I,N,S)
|
||||
};
|
||||
|
||||
public:
|
||||
_IngredientSlot(const std::string & filename);
|
||||
virtual ~_IngredientSlot();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
const StringId getName(bool versionOk, bool testData = false) const;
|
||||
void getIngredient(Ingredient &data, bool versionOk) const;
|
||||
void getIngredientMin(Ingredient &data, bool versionOk) const;
|
||||
void getIngredientMax(Ingredient &data, bool versionOk) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringIdParam m_name; // slot name
|
||||
StructParamOT m_ingredient; // ingredient used to fill the slot
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_IngredientSlot(const _IngredientSlot &);
|
||||
_IngredientSlot & operator =(const _IngredientSlot &);
|
||||
};
|
||||
friend class ServerManufactureSchematicObjectTemplate::_IngredientSlot;
|
||||
|
||||
public:
|
||||
const std::string & getDraftSchematic(bool testData = false) const;
|
||||
const std::string & getCreator(bool testData = false) const;
|
||||
void getIngredients(IngredientSlot &data, int index) const;
|
||||
void getIngredientsMin(IngredientSlot &data, int index) const;
|
||||
void getIngredientsMax(IngredientSlot &data, int index) const;
|
||||
size_t getIngredientsCount(void) const;
|
||||
int getItemCount(bool testData = false) const;
|
||||
int getItemCountMin(bool testData = false) const;
|
||||
int getItemCountMax(bool testData = false) const;
|
||||
void getAttributes(SchematicAttribute &data, int index) const;
|
||||
void getAttributesMin(SchematicAttribute &data, int index) const;
|
||||
void getAttributesMax(SchematicAttribute &data, int index) const;
|
||||
size_t getAttributesCount(void) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringParam m_draftSchematic; // source draft schematic
|
||||
StringParam m_creator; // who created me
|
||||
stdvector<StructParamOT *>::fwd m_ingredients; // ingredients needed to create
|
||||
bool m_ingredientsLoaded;
|
||||
bool m_ingredientsAppend;
|
||||
IntegerParam m_itemCount; // number of items this schematic can make
|
||||
stdvector<StructParamOT *>::fwd m_attributes; // values for the attributes the schematic affects
|
||||
bool m_attributesLoaded;
|
||||
bool m_attributesAppend;
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
static Object * createObject(const char *const fileName, const DraftSchematicObject &);
|
||||
Object * createObject(const DraftSchematicObject &) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerManufactureSchematicObjectTemplate(const ServerManufactureSchematicObjectTemplate &);
|
||||
ServerManufactureSchematicObjectTemplate & operator =(const ServerManufactureSchematicObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerManufactureSchematicObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerManufactureSchematicObjectTemplate::registerMe();
|
||||
ServerManufactureSchematicObjectTemplate::_IngredientSlot::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerManufactureSchematicObjectTemplate_H
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerMissionObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerMissionObjectTemplate.h"
|
||||
#include "serverGame/MissionObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerMissionObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerMissionObjectTemplate::ServerMissionObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerMissionObjectTemplate::ServerMissionObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerMissionObjectTemplate::~ServerMissionObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerMissionObjectTemplate::~ServerMissionObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerMissionObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerMissionObjectTemplate_tag, create);
|
||||
} // ServerMissionObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerMissionObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerMissionObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerMissionObjectTemplate(filename);
|
||||
} // ServerMissionObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerMissionObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerMissionObjectTemplate_tag;
|
||||
} // ServerMissionObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerMissionObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerMissionObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerMissionObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerMissionObjectTemplate * base = dynamic_cast<const ServerMissionObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerMissionObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerMissionObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new MissionObject(this);
|
||||
} // ServerMissionObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerMissionObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerIntangibleObjectTemplate::testValues();
|
||||
} // ServerMissionObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerMissionObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerMissionObjectTemplate_tag)
|
||||
{
|
||||
ServerIntangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerIntangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerMissionObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerMissionObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerMissionObjectTemplate_H
|
||||
#define _INCLUDED_ServerMissionObjectTemplate_H
|
||||
|
||||
#include "ServerIntangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerMissionObjectTemplate : public ServerIntangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerMissionObjectTemplate_tag = TAG(M,I,S,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerMissionObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerMissionObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerMissionObjectTemplate(const ServerMissionObjectTemplate &);
|
||||
ServerMissionObjectTemplate & operator =(const ServerMissionObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerMissionObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerMissionObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerMissionObjectTemplate_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,615 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerObjectTemplate_H
|
||||
#define _INCLUDED_ServerObjectTemplate_H
|
||||
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
class ServerObjectTemplate;
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerObjectTemplate : public ObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerObjectTemplate_tag = TAG(S,W,O,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
|
||||
public:
|
||||
ServerObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
static void exit();
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
enum ArmorCategory
|
||||
{
|
||||
AC_reconnaissance,
|
||||
AC_battle,
|
||||
AC_assault,
|
||||
AC_psg, // // personal shield generator
|
||||
ArmorCategory_Last = AC_psg,
|
||||
};
|
||||
|
||||
enum ArmorLevel
|
||||
{
|
||||
AL_basic,
|
||||
AL_standard,
|
||||
AL_advanced,
|
||||
ArmorLevel_Last = AL_advanced,
|
||||
};
|
||||
|
||||
enum ArmorRating
|
||||
{
|
||||
AR_armorNone,
|
||||
AR_armorLight,
|
||||
AR_armorMedium,
|
||||
AR_armorHeavy,
|
||||
ArmorRating_Last = AR_armorHeavy,
|
||||
};
|
||||
|
||||
enum Attributes
|
||||
{
|
||||
AT_health,
|
||||
AT_constitution,
|
||||
AT_action,
|
||||
AT_stamina,
|
||||
AT_mind,
|
||||
AT_willpower,
|
||||
Attributes_Last = AT_willpower,
|
||||
};
|
||||
|
||||
enum CraftingType
|
||||
{
|
||||
CT_weapon = 0x00000001,
|
||||
CT_armor = 0x00000002,
|
||||
CT_food = 0x00000004,
|
||||
CT_clothing = 0x00000008,
|
||||
CT_vehicle = 0x00000010,
|
||||
CT_droid = 0x00000020,
|
||||
CT_chemical = 0x00000040,
|
||||
CT_plantBreeding = 0x00000080,
|
||||
CT_animalBreeding = 0x00000100,
|
||||
CT_furniture = 0x00000200,
|
||||
CT_installation = 0x00000400,
|
||||
CT_lightsaber = 0x00000800,
|
||||
CT_genericItem = 0x00001000,
|
||||
CT_genetics = 0x00002000,
|
||||
CT_mandalorianTailor = 0x00004000,
|
||||
CT_mandalorianArmorsmith = 0x00008000,
|
||||
CT_mandalorianDroidEngineer = 0x00010000,
|
||||
CT_space = 0x00020000,
|
||||
CT_reverseEngineering = 0x00040000,
|
||||
CT_misc = 0x00080000,
|
||||
CT_spaceComponent = 0x00100000,
|
||||
CT_mission = 0x80000000,
|
||||
CT_weaponMission = 0x80000001,
|
||||
CT_armorMission = 0x80000002,
|
||||
CT_foodMission = 0x80000004,
|
||||
CT_clothingMission = 0x80000008,
|
||||
CT_vehicleMission = 0x80000010,
|
||||
CT_droidMission = 0x80000020,
|
||||
CT_chemicalMission = 0x80000040,
|
||||
CT_plantBreedingMission = 0x80000080,
|
||||
CT_animalBreedingMission = 0x80000100,
|
||||
CT_furnitureMission = 0x80000200,
|
||||
CT_installationMission = 0x80000400,
|
||||
CT_lightsaberMission = 0x80000800,
|
||||
CT_genericItemMission = 0x80001000,
|
||||
CT_geneticsMission = 0x80002000,
|
||||
CT_mandalorianTailorMission = 0x80004000,
|
||||
CT_mandalorianArmorsmithMission = 0x80008000,
|
||||
CT_mandalorianDroidEngineerMission = 0x80010000,
|
||||
CT_spaceMission = 0x80020000,
|
||||
CT_reverseEngineeringMission = 0x80040000,
|
||||
CT_miscMission = 0x80080000,
|
||||
CT_spaceComponentMission = 0x80100000,
|
||||
CraftingType_Last = CT_spaceComponentMission,
|
||||
};
|
||||
|
||||
enum DamageType
|
||||
{
|
||||
DT_none = 0x00000000,
|
||||
DT_kinetic = 0x00000001,
|
||||
DT_energy = 0x00000002,
|
||||
DT_blast = 0x00000004,
|
||||
DT_stun = 0x00000008,
|
||||
DT_restraint = 0x00000010,
|
||||
DT_elemental_heat = 0x00000020,
|
||||
DT_elemental_cold = 0x00000040,
|
||||
DT_elemental_acid = 0x00000080,
|
||||
DT_elemental_electrical = 0x00000100,
|
||||
DT_environmental_heat = 0x00000200,
|
||||
DT_environmental_cold = 0x00000400,
|
||||
DT_environmental_acid = 0x00000800,
|
||||
DT_environmental_electrical = 0x00001000,
|
||||
DamageType_Last = DT_environmental_electrical,
|
||||
};
|
||||
|
||||
enum DeleteFlags
|
||||
{
|
||||
DF_gm,
|
||||
DF_player,
|
||||
DeleteFlags_Last = DF_player,
|
||||
};
|
||||
|
||||
enum MentalStates
|
||||
{
|
||||
MS_fear,
|
||||
MS_anger,
|
||||
MS_interest,
|
||||
MS_distress,
|
||||
MentalStates_Last = MS_distress,
|
||||
};
|
||||
|
||||
enum MoveFlags
|
||||
{
|
||||
MF_gm,
|
||||
MF_player,
|
||||
MoveFlags_Last = MF_player,
|
||||
};
|
||||
|
||||
enum UpdateRanges
|
||||
{
|
||||
UR_near,
|
||||
UR_normal,
|
||||
UR_far,
|
||||
UpdateRanges_Last = UR_far,
|
||||
};
|
||||
|
||||
enum VisibleFlags
|
||||
{
|
||||
VF_gm,
|
||||
VF_player,
|
||||
VisibleFlags_Last = VF_player,
|
||||
};
|
||||
|
||||
enum XpTypes
|
||||
{
|
||||
XP_rangedCombat,
|
||||
XP_meleeCombat,
|
||||
XP_tamingNoTime,
|
||||
XP_tamingShortTime,
|
||||
XP_tamingMediumTime,
|
||||
XP_tamingLargeTime,
|
||||
XP_architect,
|
||||
XP_botany,
|
||||
XP_bountyHunter,
|
||||
XP_chemist,
|
||||
XP_dancing,
|
||||
XP_facilityManagementSavings,
|
||||
XP_facilityManagementWearAndTear,
|
||||
XP_squadLeaderNoTime,
|
||||
XP_squadLeaderSmallTime,
|
||||
XP_squadLeaderMediumTime,
|
||||
XP_squadLeaderLargeTime,
|
||||
XP_hairdressing,
|
||||
XP_holonetSlicingPopularity,
|
||||
XP_holonetSlicingQuantity,
|
||||
XP_investigation,
|
||||
XP_medic,
|
||||
XP_military,
|
||||
XP_mining,
|
||||
XP_miningSavings,
|
||||
XP_musician,
|
||||
XP_musicanPopularity,
|
||||
XP_politics,
|
||||
XP_slicing,
|
||||
XP_smuggling,
|
||||
XP_surveyingNoMinimum,
|
||||
XP_surveyingLowMinimum,
|
||||
XP_surveyingMediumMinimum,
|
||||
XP_surveyingHighMinimum,
|
||||
XP_survivalHealing,
|
||||
XP_survivalTracking,
|
||||
XP_vehicularControl,
|
||||
XP_vehicularWearAndTear,
|
||||
XP_resourceHarvestingOrganic,
|
||||
XP_resourceHarvestingInorganic,
|
||||
XP_crafting,
|
||||
XP_craftingClothing,
|
||||
XP_craftingClothingArmor,
|
||||
XP_craftingDroid,
|
||||
XP_craftingFood,
|
||||
XP_craftingMedicine,
|
||||
XP_craftingStructure,
|
||||
XP_craftingWeapons,
|
||||
XP_craftingWeaponsMelee,
|
||||
XP_craftingWeaponsRanged,
|
||||
XP_craftingWeaponsMunition,
|
||||
XP_industrialist,
|
||||
XP_craftingScout,
|
||||
XP_craftingCreature,
|
||||
XP_craftingTissue,
|
||||
XP_craftingCamp,
|
||||
XP_craftingTrapping,
|
||||
XP_craftingSpice,
|
||||
XP_jediGeneral,
|
||||
XP_shipwright,
|
||||
XP_reverseEngineering,
|
||||
XpTypes_Last = XP_reverseEngineering,
|
||||
};
|
||||
|
||||
public:
|
||||
struct AttribMod
|
||||
{
|
||||
enum Attributes target;
|
||||
int value;
|
||||
float time;
|
||||
float timeAtValue;
|
||||
float decay;
|
||||
};
|
||||
|
||||
struct MentalStateMod
|
||||
{
|
||||
enum MentalStates target;
|
||||
float value;
|
||||
float time;
|
||||
float timeAtValue;
|
||||
float decay;
|
||||
};
|
||||
|
||||
struct Contents
|
||||
{
|
||||
std::string slotName;
|
||||
bool equipObject;
|
||||
const ObjectTemplate * content;
|
||||
|
||||
Contents(void);
|
||||
Contents(const Contents & source);
|
||||
~Contents();
|
||||
#ifdef WIN32
|
||||
Contents & operator =(const Contents &);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
|
||||
private:
|
||||
Contents & operator =(const Contents &);
|
||||
#endif
|
||||
};
|
||||
|
||||
struct Xp
|
||||
{
|
||||
enum XpTypes type;
|
||||
int level;
|
||||
int value;
|
||||
};
|
||||
|
||||
protected:
|
||||
class _AttribMod : public ObjectTemplate
|
||||
{
|
||||
friend class ServerObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_AttribMod_tag = TAG(A,T,T,S)
|
||||
};
|
||||
|
||||
public:
|
||||
_AttribMod(const std::string & filename);
|
||||
virtual ~_AttribMod();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
Attributes getTarget(bool versionOk, bool testData = false) const;
|
||||
int getValue(bool versionOk, bool testData = false) const;
|
||||
int getValueMin(bool versionOk, bool testData = false) const;
|
||||
int getValueMax(bool versionOk, bool testData = false) const;
|
||||
float getTime(bool versionOk, bool testData = false) const;
|
||||
float getTimeMin(bool versionOk, bool testData = false) const;
|
||||
float getTimeMax(bool versionOk, bool testData = false) const;
|
||||
float getTimeAtValue(bool versionOk, bool testData = false) const;
|
||||
float getTimeAtValueMin(bool versionOk, bool testData = false) const;
|
||||
float getTimeAtValueMax(bool versionOk, bool testData = false) const;
|
||||
float getDecay(bool versionOk, bool testData = false) const;
|
||||
float getDecayMin(bool versionOk, bool testData = false) const;
|
||||
float getDecayMax(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_target; // server //which attribute is affected
|
||||
IntegerParam m_value; // server //max strength of the modifier
|
||||
FloatParam m_time; // server //how long it takes for the modifier to reach full strength (in secs)
|
||||
FloatParam m_timeAtValue; // server //how long the modifier remains at full strength (in secs)
|
||||
FloatParam m_decay; // server //how long it takes for the modifier to go from full strength to 0 (in secs)
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_AttribMod(const _AttribMod &);
|
||||
_AttribMod & operator =(const _AttribMod &);
|
||||
};
|
||||
friend class ServerObjectTemplate::_AttribMod;
|
||||
|
||||
class _MentalStateMod : public ObjectTemplate
|
||||
{
|
||||
friend class ServerObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_MentalStateMod_tag = TAG(M,E,S,M)
|
||||
};
|
||||
|
||||
public:
|
||||
_MentalStateMod(const std::string & filename);
|
||||
virtual ~_MentalStateMod();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
MentalStates getTarget(bool versionOk, bool testData = false) const;
|
||||
float getValue(bool versionOk, bool testData = false) const;
|
||||
float getValueMin(bool versionOk, bool testData = false) const;
|
||||
float getValueMax(bool versionOk, bool testData = false) const;
|
||||
float getTime(bool versionOk, bool testData = false) const;
|
||||
float getTimeMin(bool versionOk, bool testData = false) const;
|
||||
float getTimeMax(bool versionOk, bool testData = false) const;
|
||||
float getTimeAtValue(bool versionOk, bool testData = false) const;
|
||||
float getTimeAtValueMin(bool versionOk, bool testData = false) const;
|
||||
float getTimeAtValueMax(bool versionOk, bool testData = false) const;
|
||||
float getDecay(bool versionOk, bool testData = false) const;
|
||||
float getDecayMin(bool versionOk, bool testData = false) const;
|
||||
float getDecayMax(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_target; // server //which mental state is affected
|
||||
FloatParam m_value; // server //max strength of the modifier
|
||||
FloatParam m_time; // server //how long it takes for the modifier to reach full strength (in secs)
|
||||
FloatParam m_timeAtValue; // server //how long the modifier remains at full strength (in secs)
|
||||
FloatParam m_decay; // server //how long it takes for the modifier to go from full strength to 0 (in secs)
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_MentalStateMod(const _MentalStateMod &);
|
||||
_MentalStateMod & operator =(const _MentalStateMod &);
|
||||
};
|
||||
friend class ServerObjectTemplate::_MentalStateMod;
|
||||
|
||||
class _Contents : public ObjectTemplate
|
||||
{
|
||||
friend class ServerObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_Contents_tag = TAG(C,O,N,T)
|
||||
};
|
||||
|
||||
public:
|
||||
_Contents(const std::string & filename);
|
||||
virtual ~_Contents();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
const std::string & getSlotName(bool versionOk, bool testData = false) const;
|
||||
bool getEquipObject(bool versionOk, bool testData = false) const;
|
||||
const ServerObjectTemplate * getContent(bool versionOk) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringParam m_slotName; // //slot name, as defined in the object's slotDescriptorFilename
|
||||
BoolParam m_equipObject; // //flag to put the contents in the slot, as opposed to adding it to the container in the slot
|
||||
StringParam m_content; // //the object to add
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_Contents(const _Contents &);
|
||||
_Contents & operator =(const _Contents &);
|
||||
};
|
||||
friend class ServerObjectTemplate::_Contents;
|
||||
|
||||
class _Xp : public ObjectTemplate
|
||||
{
|
||||
friend class ServerObjectTemplate;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
_Xp_tag = TAG(E,X,P,S)
|
||||
};
|
||||
|
||||
public:
|
||||
_Xp(const std::string & filename);
|
||||
virtual ~_Xp();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
|
||||
public:
|
||||
XpTypes getType(bool versionOk, bool testData = false) const;
|
||||
int getLevel(bool versionOk, bool testData = false) const;
|
||||
int getLevelMin(bool versionOk, bool testData = false) const;
|
||||
int getLevelMax(bool versionOk, bool testData = false) const;
|
||||
int getValue(bool versionOk, bool testData = false) const;
|
||||
int getValueMin(bool versionOk, bool testData = false) const;
|
||||
int getValueMax(bool versionOk, bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_type; // //type of experience earned
|
||||
IntegerParam m_level; // //difficulty level, 0 for leveless xp types
|
||||
IntegerParam m_value; // //amount of experience earned
|
||||
private:
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
private:
|
||||
_Xp(const _Xp &);
|
||||
_Xp & operator =(const _Xp &);
|
||||
};
|
||||
friend class ServerObjectTemplate::_Xp;
|
||||
|
||||
public:
|
||||
const std::string & getSharedTemplate(bool testData = false) const;
|
||||
const std::string & getScripts(int index) const;
|
||||
size_t getScriptsCount(void) const;
|
||||
void getObjvars(DynamicVariableList &list) const;
|
||||
int getVolume(bool testData = false) const;
|
||||
int getVolumeMin(bool testData = false) const;
|
||||
int getVolumeMax(bool testData = false) const;
|
||||
VisibleFlags getVisibleFlags(int index) const;
|
||||
size_t getVisibleFlagsCount(void) const;
|
||||
DeleteFlags getDeleteFlags(int index) const;
|
||||
size_t getDeleteFlagsCount(void) const;
|
||||
MoveFlags getMoveFlags(int index) const;
|
||||
size_t getMoveFlagsCount(void) const;
|
||||
bool getInvulnerable(bool testData = false) const;
|
||||
float getComplexity(bool testData = false) const;
|
||||
float getComplexityMin(bool testData = false) const;
|
||||
float getComplexityMax(bool testData = false) const;
|
||||
int getTintIndex(bool testData = false) const;
|
||||
int getTintIndexMin(bool testData = false) const;
|
||||
int getTintIndexMax(bool testData = false) const;
|
||||
float getUpdateRanges(UpdateRanges index) const;
|
||||
float getUpdateRangesMin(UpdateRanges index) const;
|
||||
float getUpdateRangesMax(UpdateRanges index) const;
|
||||
void getContents(Contents &data, int index) const;
|
||||
void getContentsMin(Contents &data, int index) const;
|
||||
void getContentsMax(Contents &data, int index) const;
|
||||
size_t getContentsCount(void) const;
|
||||
void getXpPoints(Xp &data, int index) const;
|
||||
void getXpPointsMin(Xp &data, int index) const;
|
||||
void getXpPointsMax(Xp &data, int index) const;
|
||||
size_t getXpPointsCount(void) const;
|
||||
bool getPersistByDefault(bool testData = false) const;
|
||||
bool getPersistContents(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
// crafting types also defined in base_class.java
|
||||
// NOTE: when you update this list, make sure to update the registerMe() function in ServerObjectTemplate.cpp
|
||||
// this enum is also defined in the shared draft_schematic_object_template.tdf file
|
||||
// this enum is also defined in the shared draft_schematic_object_template.tdf file
|
||||
StringParam m_sharedTemplate; // //template the client should associate with this template
|
||||
stdvector<StringParam *>::fwd m_scripts; // //scripts attached to the object
|
||||
bool m_scriptsLoaded;
|
||||
bool m_scriptsAppend;
|
||||
DynamicVariableParam m_objvars; // //default objvars added to the object
|
||||
IntegerParam m_volume; // //how much room does the object take up
|
||||
stdvector<IntegerParam *>::fwd m_visibleFlags; // //who can see this object
|
||||
bool m_visibleFlagsLoaded;
|
||||
bool m_visibleFlagsAppend;
|
||||
stdvector<IntegerParam *>::fwd m_deleteFlags; // //who can delete this object
|
||||
bool m_deleteFlagsLoaded;
|
||||
bool m_deleteFlagsAppend;
|
||||
stdvector<IntegerParam *>::fwd m_moveFlags; // //who can move this object
|
||||
bool m_moveFlagsLoaded;
|
||||
bool m_moveFlagsAppend;
|
||||
BoolParam m_invulnerable; // //can this object not be destroyed/killed
|
||||
FloatParam m_complexity; // //how hard this item is to craft (?)
|
||||
IntegerParam m_tintIndex; // //index into client tint palette
|
||||
FloatParam m_updateRanges[3]; // //distances for network updates
|
||||
stdvector<StructParamOT *>::fwd m_contents; // //what's in this object
|
||||
bool m_contentsLoaded;
|
||||
bool m_contentsAppend;
|
||||
stdvector<StructParamOT *>::fwd m_xpPoints; // //experience points for interacting with this object
|
||||
bool m_xpPointsLoaded;
|
||||
bool m_xpPointsAppend;
|
||||
BoolParam m_persistByDefault; // //flag to automatically persist this object on creation
|
||||
BoolParam m_persistContents; // //flag that this container persists its contents
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
|
||||
// user functions
|
||||
virtual ServerObjectTemplate * asServerObjectTemplate();
|
||||
virtual ServerObjectTemplate const * asServerObjectTemplate() const;
|
||||
|
||||
static const std::string & getXpString (XpTypes type);
|
||||
static const std::string & getDamageTypeString (DamageType type);
|
||||
static const std::string & getArmorRatingString (ArmorRating type);
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerObjectTemplate(const ServerObjectTemplate &);
|
||||
ServerObjectTemplate & operator =(const ServerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerObjectTemplate::registerMe();
|
||||
ServerObjectTemplate::_AttribMod::registerMe();
|
||||
ServerObjectTemplate::_Contents::registerMe();
|
||||
ServerObjectTemplate::_MentalStateMod::registerMe();
|
||||
ServerObjectTemplate::_Xp::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerObjectTemplate_H
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerPlanetObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerPlanetObjectTemplate.h"
|
||||
#include "serverGame/PlanetObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerPlanetObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerPlanetObjectTemplate::ServerPlanetObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerPlanetObjectTemplate::ServerPlanetObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerPlanetObjectTemplate::~ServerPlanetObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerPlanetObjectTemplate::~ServerPlanetObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerPlanetObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerPlanetObjectTemplate_tag, create);
|
||||
} // ServerPlanetObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerPlanetObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerPlanetObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerPlanetObjectTemplate(filename);
|
||||
} // ServerPlanetObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerPlanetObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerPlanetObjectTemplate_tag;
|
||||
} // ServerPlanetObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerPlanetObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerPlanetObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerPlanetObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerPlanetObjectTemplate * base = dynamic_cast<const ServerPlanetObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerPlanetObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerPlanetObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new PlanetObject(this);
|
||||
} // ServerPlanetObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerPlanetObjectTemplate::getPlanetName(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::string testDataValue = DefaultString;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerPlanetObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerPlanetObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getPlanetName(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_planetName.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter planetName in template %s", DataResource::getName()));
|
||||
return DefaultString;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter planetName has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getPlanetName();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string & value = m_planetName.getValue();
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerPlanetObjectTemplate::getPlanetName
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerPlanetObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getPlanetName(true));
|
||||
ServerUniverseObjectTemplate::testValues();
|
||||
} // ServerPlanetObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerPlanetObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerPlanetObjectTemplate_tag)
|
||||
{
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "planetName") == 0)
|
||||
m_planetName.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerPlanetObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerPlanetObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerPlanetObjectTemplate_H
|
||||
#define _INCLUDED_ServerPlanetObjectTemplate_H
|
||||
|
||||
#include "ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerPlanetObjectTemplate : public ServerUniverseObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerPlanetObjectTemplate_tag = TAG(P,L,A,N)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerPlanetObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerPlanetObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
const std::string & getPlanetName(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringParam m_planetName; // name of the planet
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerPlanetObjectTemplate(const ServerPlanetObjectTemplate &);
|
||||
ServerPlanetObjectTemplate & operator =(const ServerPlanetObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerPlanetObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerPlanetObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerPlanetObjectTemplate_H
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerPlayerObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerPlayerObjectTemplate.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "serverGame/PlayerObject.h"
|
||||
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerPlayerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerPlayerObjectTemplate::ServerPlayerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerPlayerObjectTemplate::ServerPlayerObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerPlayerObjectTemplate::~ServerPlayerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerPlayerObjectTemplate::~ServerPlayerObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerPlayerObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerPlayerObjectTemplate_tag, create);
|
||||
} // ServerPlayerObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerPlayerObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerPlayerObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerPlayerObjectTemplate(filename);
|
||||
} // ServerPlayerObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerPlayerObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerPlayerObjectTemplate_tag;
|
||||
} // ServerPlayerObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerPlayerObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerPlayerObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerPlayerObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerPlayerObjectTemplate * base = dynamic_cast<const ServerPlayerObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerPlayerObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerPlayerObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new PlayerObject(this);
|
||||
} // ServerPlayerObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerPlayerObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerIntangibleObjectTemplate::testValues();
|
||||
} // ServerPlayerObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerPlayerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerPlayerObjectTemplate_tag)
|
||||
{
|
||||
ServerIntangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerIntangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerPlayerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerPlayerObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerPlayerObjectTemplate_H
|
||||
#define _INCLUDED_ServerPlayerObjectTemplate_H
|
||||
|
||||
#include "ServerIntangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerPlayerObjectTemplate : public ServerIntangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerPlayerObjectTemplate_tag = TAG(P,L,A,Y)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerPlayerObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerPlayerObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
public:
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerPlayerObjectTemplate(const ServerPlayerObjectTemplate &);
|
||||
ServerPlayerObjectTemplate & operator =(const ServerPlayerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerPlayerObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerPlayerObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerPlayerObjectTemplate_H
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerPlayerQuestObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/PlayerQuestObject.h"
|
||||
#include "ServerPlayerQuestObjectTemplate.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedMath/Vector.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerPlayerQuestObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerPlayerQuestObjectTemplate::ServerPlayerQuestObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerPlayerQuestObjectTemplate::ServerPlayerQuestObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerPlayerQuestObjectTemplate::~ServerPlayerQuestObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerPlayerQuestObjectTemplate::~ServerPlayerQuestObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerPlayerQuestObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerPlayerQuestObjectTemplate_tag, create);
|
||||
} // ServerPlayerQuestObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerPlayerQuestObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerPlayerQuestObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerPlayerQuestObjectTemplate(filename);
|
||||
} // ServerPlayerQuestObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerPlayerQuestObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerPlayerQuestObjectTemplate_tag;
|
||||
} // ServerPlayerQuestObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerPlayerQuestObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerPlayerQuestObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerPlayerQuestObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerPlayerQuestObjectTemplate * base = dynamic_cast<const ServerPlayerQuestObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerPlayerQuestObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerPlayerQuestObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new PlayerQuestObject(this);
|
||||
} // ServerMissionObjectTemplate::createObject
|
||||
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerPlayerQuestObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerPlayerQuestObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerPlayerQuestObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerPlayerQuestObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerPlayerQuestObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerPlayerQuestObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerPlayerQuestObjectTemplate_H
|
||||
#define _INCLUDED_ServerPlayerQuestObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerPlayerQuestObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerPlayerQuestObjectTemplate_tag = TAG(P,Q,O,S)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerPlayerQuestObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerPlayerQuestObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerPlayerQuestObjectTemplate(const ServerPlayerQuestObjectTemplate &);
|
||||
ServerPlayerQuestObjectTemplate & operator =(const ServerPlayerQuestObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerPlayerQuestObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerPlayerQuestObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerPlayerQuestObjectTemplate_H
|
||||
+385
@@ -0,0 +1,385 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerResourceContainerObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerResourceContainerObjectTemplate.h"
|
||||
#include "serverGame/ResourceContainerObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerResourceContainerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerResourceContainerObjectTemplate::ServerResourceContainerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerResourceContainerObjectTemplate::ServerResourceContainerObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerResourceContainerObjectTemplate::~ServerResourceContainerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerResourceContainerObjectTemplate::~ServerResourceContainerObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerResourceContainerObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerResourceContainerObjectTemplate_tag, create);
|
||||
} // ServerResourceContainerObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerResourceContainerObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerResourceContainerObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerResourceContainerObjectTemplate(filename);
|
||||
} // ServerResourceContainerObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerResourceContainerObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerResourceContainerObjectTemplate_tag;
|
||||
} // ServerResourceContainerObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerResourceContainerObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerResourceContainerObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerResourceContainerObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerResourceContainerObjectTemplate * base = dynamic_cast<const ServerResourceContainerObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerResourceContainerObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerResourceContainerObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new ResourceContainerObject(this);
|
||||
} // ServerResourceContainerObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
int ServerResourceContainerObjectTemplate::getMaxResources(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerResourceContainerObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerResourceContainerObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxResources(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxResources.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxResources in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxResources has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxResources();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxResources.getValue();
|
||||
char delta = m_maxResources.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxResources();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerResourceContainerObjectTemplate::getMaxResources
|
||||
|
||||
int ServerResourceContainerObjectTemplate::getMaxResourcesMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerResourceContainerObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerResourceContainerObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxResourcesMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxResources.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxResources in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxResources has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxResourcesMin();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxResources.getMinValue();
|
||||
char delta = m_maxResources.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxResourcesMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerResourceContainerObjectTemplate::getMaxResourcesMin
|
||||
|
||||
int ServerResourceContainerObjectTemplate::getMaxResourcesMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
int testDataValue = 0;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerResourceContainerObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerResourceContainerObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxResourcesMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxResources.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxResources in template %s", DataResource::getName()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxResources has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxResourcesMax();
|
||||
}
|
||||
}
|
||||
|
||||
int value = m_maxResources.getMaxValue();
|
||||
char delta = m_maxResources.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
int baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxResourcesMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<int>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<int>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerResourceContainerObjectTemplate::getMaxResourcesMax
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerResourceContainerObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getMaxResourcesMin(true));
|
||||
IGNORE_RETURN(getMaxResourcesMax(true));
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerResourceContainerObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerResourceContainerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerResourceContainerObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "maxResources") == 0)
|
||||
m_maxResources.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerResourceContainerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerResourceContainerObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerResourceContainerObjectTemplate_H
|
||||
#define _INCLUDED_ServerResourceContainerObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerResourceContainerObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerResourceContainerObjectTemplate_tag = TAG(R,C,N,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerResourceContainerObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerResourceContainerObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
int getMaxResources(bool testData = false) const;
|
||||
int getMaxResourcesMin(bool testData = false) const;
|
||||
int getMaxResourcesMax(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_maxResources; // Maximum number of units of resource the container can hold.
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerResourceContainerObjectTemplate(const ServerResourceContainerObjectTemplate &);
|
||||
ServerResourceContainerObjectTemplate & operator =(const ServerResourceContainerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerResourceContainerObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerResourceContainerObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerResourceContainerObjectTemplate_H
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
//======================================================================
|
||||
//
|
||||
// ServerSharedObjectTemplateInterface.cpp
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
//======================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/ServerSharedObjectTemplateInterface.h"
|
||||
|
||||
#include "serverGame/ServerObject.h"
|
||||
#include "serverGame/ShipObject.h"
|
||||
|
||||
//======================================================================
|
||||
|
||||
ServerSharedObjectTemplateInterface::ServerSharedObjectTemplateInterface()
|
||||
: SharedObjectTemplateInterface()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
ServerSharedObjectTemplateInterface::~ServerSharedObjectTemplateInterface()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SharedObjectTemplate const * ServerSharedObjectTemplateInterface::getSharedTemplate(Object const * const object) const
|
||||
{
|
||||
ServerObject const * const serverObject = object->asServerObject();
|
||||
return static_cast<SharedObjectTemplate const *>(serverObject->getSharedTemplate());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
bool ServerSharedObjectTemplateInterface::isShipObject(Object const * const object) const
|
||||
{
|
||||
ServerObject const * const serverObject = (object != 0) ? object->asServerObject() : 0;
|
||||
ShipObject const * const shipObject = (serverObject != 0) ? serverObject->asShipObject() : 0;
|
||||
return shipObject != 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
uint32 ServerSharedObjectTemplateInterface::getShipChassisType(Object const * const object) const
|
||||
{
|
||||
ServerObject const * const serverObject = (object != 0) ? object->asServerObject() : 0;
|
||||
ShipObject const * const shipObject = (serverObject != 0) ? serverObject->asShipObject() : 0;
|
||||
return (shipObject != 0) ? shipObject->getChassisType() : 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
uint32 ServerSharedObjectTemplateInterface::getShipComponentCrc(Object const * const object, int chassisSlot) const
|
||||
{
|
||||
ServerObject const * const serverObject = (object != 0) ? object->asServerObject() : 0;
|
||||
ShipObject const * const shipObject = (serverObject != 0) ? serverObject->asShipObject() : 0;
|
||||
return (shipObject != 0) ? shipObject->getComponentCrc(chassisSlot) : 0;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
//======================================================================
|
||||
//
|
||||
// ServerSharedObjectTemplateInterface.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
//======================================================================
|
||||
|
||||
#ifndef INCLUDED_ServerSharedObjectTemplateInterface_H
|
||||
#define INCLUDED_ServerSharedObjectTemplateInterface_H
|
||||
|
||||
//======================================================================
|
||||
|
||||
#include "sharedGame/SharedObjectTemplateInterface.h"
|
||||
|
||||
class Object;
|
||||
class SharedObjectTemplate;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ServerSharedObjectTemplateInterface : public SharedObjectTemplateInterface
|
||||
{
|
||||
public:
|
||||
ServerSharedObjectTemplateInterface();
|
||||
virtual ~ServerSharedObjectTemplateInterface();
|
||||
|
||||
virtual SharedObjectTemplate const * getSharedTemplate(Object const * object) const;
|
||||
virtual bool isShipObject(Object const * object) const;
|
||||
virtual uint32 getShipChassisType(Object const * object) const;
|
||||
virtual uint32 getShipComponentCrc(Object const * object, int chassisSlot) const;
|
||||
|
||||
private:
|
||||
ServerSharedObjectTemplateInterface(ServerSharedObjectTemplateInterface const & copy);
|
||||
ServerSharedObjectTemplateInterface & operator=(ServerSharedObjectTemplateInterface const & copy);
|
||||
};
|
||||
|
||||
//======================================================================
|
||||
|
||||
#endif
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerShipObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerShipObjectTemplate.h"
|
||||
#include "serverGame/ShipObject.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerShipObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerShipObjectTemplate::ServerShipObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerShipObjectTemplate::ServerShipObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerShipObjectTemplate::~ServerShipObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerShipObjectTemplate::~ServerShipObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerShipObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerShipObjectTemplate_tag, create);
|
||||
} // ServerShipObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerShipObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerShipObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerShipObjectTemplate(filename);
|
||||
} // ServerShipObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerShipObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerShipObjectTemplate_tag;
|
||||
} // ServerShipObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerShipObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerShipObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerShipObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerShipObjectTemplate * base = dynamic_cast<const ServerShipObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerShipObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerShipObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new ShipObject(this);
|
||||
} // ServerShipObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerShipObjectTemplate::getShipType(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::string testDataValue = DefaultString;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerShipObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerShipObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getShipType(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_shipType.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter shipType in template %s", DataResource::getName()));
|
||||
return DefaultString;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter shipType has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getShipType();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string & value = m_shipType.getValue();
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerShipObjectTemplate::getShipType
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerShipObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getShipType(true));
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerShipObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerShipObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerShipObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "shipType") == 0)
|
||||
m_shipType.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerShipObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
@@ -0,0 +1,89 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerShipObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerShipObjectTemplate_H
|
||||
#define _INCLUDED_ServerShipObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerShipObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerShipObjectTemplate_tag = TAG(S,H,I,P)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerShipObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerShipObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
const std::string & getShipType(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringParam m_shipType;
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerShipObjectTemplate(const ServerShipObjectTemplate &);
|
||||
ServerShipObjectTemplate & operator =(const ServerShipObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerShipObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerShipObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerShipObjectTemplate_H
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerStaticObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerStaticObjectTemplate.h"
|
||||
#include "serverGame/StaticObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerStaticObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerStaticObjectTemplate::ServerStaticObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerStaticObjectTemplate::ServerStaticObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerStaticObjectTemplate::~ServerStaticObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerStaticObjectTemplate::~ServerStaticObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerStaticObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerStaticObjectTemplate_tag, create);
|
||||
} // ServerStaticObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerStaticObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerStaticObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerStaticObjectTemplate(filename);
|
||||
} // ServerStaticObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerStaticObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerStaticObjectTemplate_tag;
|
||||
} // ServerStaticObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerStaticObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerStaticObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerStaticObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerStaticObjectTemplate * base = dynamic_cast<const ServerStaticObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerStaticObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerStaticObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new StaticObject(this);
|
||||
} // ServerStaticObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
bool ServerStaticObjectTemplate::getClientOnlyBuildout(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
bool testDataValue = false;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerStaticObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerStaticObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getClientOnlyBuildout(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_clientOnlyBuildout.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter clientOnlyBuildout in template %s", DataResource::getName()));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter clientOnlyBuildout has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getClientOnlyBuildout();
|
||||
}
|
||||
}
|
||||
|
||||
bool value = m_clientOnlyBuildout.getValue();
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerStaticObjectTemplate::getClientOnlyBuildout
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerStaticObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getClientOnlyBuildout(true));
|
||||
ServerObjectTemplate::testValues();
|
||||
} // ServerStaticObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerStaticObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerStaticObjectTemplate_tag)
|
||||
{
|
||||
ServerObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "clientOnlyBuildout") == 0)
|
||||
m_clientOnlyBuildout.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerStaticObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerStaticObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerStaticObjectTemplate_H
|
||||
#define _INCLUDED_ServerStaticObjectTemplate_H
|
||||
|
||||
#include "ServerObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerStaticObjectTemplate : public ServerObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerStaticObjectTemplate_tag = TAG(S,T,A,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerStaticObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerStaticObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
bool getClientOnlyBuildout(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
BoolParam m_clientOnlyBuildout; // Whether we should be instantiated from buildout files on the server
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerStaticObjectTemplate(const ServerStaticObjectTemplate &);
|
||||
ServerStaticObjectTemplate & operator =(const ServerStaticObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerStaticObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerStaticObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerStaticObjectTemplate_H
|
||||
+1188
File diff suppressed because it is too large
Load Diff
+156
@@ -0,0 +1,156 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerTangibleObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerTangibleObjectTemplate_H
|
||||
#define _INCLUDED_ServerTangibleObjectTemplate_H
|
||||
|
||||
#include "ServerObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
class ServerArmorTemplate;
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerTangibleObjectTemplate : public ServerObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerTangibleObjectTemplate_tag = TAG(T,A,N,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerTangibleObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerTangibleObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
enum CombatSkeleton
|
||||
{
|
||||
CS_none, // // all "body" or not attackable
|
||||
CS_humanoid, // // head, body, 2 arms, 2 legs, standard human proportions/layout
|
||||
CombatSkeleton_Last = CS_humanoid,
|
||||
};
|
||||
|
||||
enum Conditions
|
||||
{
|
||||
C_onOff = 0x00000001,
|
||||
C_vendor = 0x00000002,
|
||||
C_insured = 0x00000004,
|
||||
C_conversable = 0x00000008,
|
||||
C_hibernating = 0x00000010,
|
||||
C_magicItem = 0x00000020,
|
||||
C_aggressive = 0x00000040,
|
||||
C_wantSawAttackTrigger = 0x00000080,
|
||||
C_invulnerable = 0x00000100,
|
||||
C_disabled = 0x00000200,
|
||||
C_uninsurable = 0x00000400,
|
||||
C_interesting = 0x00000800,
|
||||
C_mount = 0x00001000, // Set programmatically by mount system. Do not set this in the template.
|
||||
C_crafted = 0x00002000, // Set programmatically by crafting system. Do not set this in the template.
|
||||
C_wingsOpened = 0x00004000, // Set programmatically by wing system. Do not set this in the template.
|
||||
C_spaceInteresting = 0x00008000,
|
||||
C_docking = 0x00010000, // Set programmatically by docking system. Do not set this in the template.
|
||||
C_destroying = 0x00020000, // Set programmatically by destruction system. Do not set this in the template.
|
||||
C_commable = 0x00040000,
|
||||
C_dockable = 0x00080000,
|
||||
C_eject = 0x00100000,
|
||||
C_inspectable = 0x00200000,
|
||||
C_transferable = 0x00400000,
|
||||
C_inflightTutorial = 0x00800000,
|
||||
C_spaceCombatMusic = 0x01000000, // Set programmatically by the AI system. Do not set this in the template.
|
||||
C_encounterLocked = 0x02000000,
|
||||
Conditions_Last = C_encounterLocked,
|
||||
};
|
||||
|
||||
public:
|
||||
const TriggerVolumeData & getTriggerVolumes(int index) const;
|
||||
size_t getTriggerVolumesCount(void) const;
|
||||
CombatSkeleton getCombatSkeleton(bool testData = false) const;
|
||||
int getMaxHitPoints(bool testData = false) const;
|
||||
int getMaxHitPointsMin(bool testData = false) const;
|
||||
int getMaxHitPointsMax(bool testData = false) const;
|
||||
const ServerArmorTemplate * getArmor() const;
|
||||
int getInterestRadius(bool testData = false) const;
|
||||
int getInterestRadiusMin(bool testData = false) const;
|
||||
int getInterestRadiusMax(bool testData = false) const;
|
||||
int getCount(bool testData = false) const;
|
||||
int getCountMin(bool testData = false) const;
|
||||
int getCountMax(bool testData = false) const;
|
||||
int getCondition(bool testData = false) const;
|
||||
int getConditionMin(bool testData = false) const;
|
||||
int getConditionMax(bool testData = false) const;
|
||||
bool getWantSawAttackTriggers(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
// these MUST be reflected in clientGame/TangibleObject.h
|
||||
// these MUST be reflected in base_class.java
|
||||
stdvector<TriggerVolumeParam *>::fwd m_triggerVolumes; // trigger volume(s) attached to the object
|
||||
bool m_triggerVolumesLoaded;
|
||||
bool m_triggerVolumesAppend;
|
||||
IntegerParam m_combatSkeleton; // this should be fixed (not random) for any template type
|
||||
IntegerParam m_maxHitPoints; // hp for non-creature objects
|
||||
StringParam m_armor; // what kind of armor this object has (if any)
|
||||
IntegerParam m_interestRadius; // area of interest of the object
|
||||
IntegerParam m_count; // generic counter
|
||||
IntegerParam m_condition; // object condition
|
||||
BoolParam m_wantSawAttackTriggers; // whether we're interested in OnSawAttack triggers
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerTangibleObjectTemplate(const ServerTangibleObjectTemplate &);
|
||||
ServerTangibleObjectTemplate & operator =(const ServerTangibleObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerTangibleObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerTangibleObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerTangibleObjectTemplate_H
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerUniverseObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "serverGame/UniverseObject.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerUniverseObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerUniverseObjectTemplate::ServerUniverseObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerUniverseObjectTemplate::ServerUniverseObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerUniverseObjectTemplate::~ServerUniverseObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerUniverseObjectTemplate::~ServerUniverseObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerUniverseObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerUniverseObjectTemplate_tag, create);
|
||||
} // ServerUniverseObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerUniverseObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerUniverseObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerUniverseObjectTemplate(filename);
|
||||
} // ServerUniverseObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerUniverseObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerUniverseObjectTemplate_tag;
|
||||
} // ServerUniverseObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerUniverseObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerUniverseObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerUniverseObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerUniverseObjectTemplate * base = dynamic_cast<const ServerUniverseObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerUniverseObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerUniverseObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new UniverseObject(this);
|
||||
} // ServerUniverseObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerUniverseObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerObjectTemplate::testValues();
|
||||
} // ServerUniverseObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerUniverseObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerUniverseObjectTemplate_tag)
|
||||
{
|
||||
ServerObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerUniverseObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerUniverseObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerUniverseObjectTemplate_H
|
||||
#define _INCLUDED_ServerUniverseObjectTemplate_H
|
||||
|
||||
#include "ServerObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerUniverseObjectTemplate : public ServerObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerUniverseObjectTemplate_tag = TAG(U,N,I,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerUniverseObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerUniverseObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerUniverseObjectTemplate(const ServerUniverseObjectTemplate &);
|
||||
ServerUniverseObjectTemplate & operator =(const ServerUniverseObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerUniverseObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerUniverseObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerUniverseObjectTemplate_H
|
||||
+822
@@ -0,0 +1,822 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerVehicleObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerVehicleObjectTemplate.h"
|
||||
#include "serverGame/VehicleObject.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerVehicleObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerVehicleObjectTemplate::ServerVehicleObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerVehicleObjectTemplate::ServerVehicleObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerVehicleObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerVehicleObjectTemplate_tag, create);
|
||||
} // ServerVehicleObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerVehicleObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerVehicleObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerVehicleObjectTemplate(filename);
|
||||
} // ServerVehicleObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerVehicleObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerVehicleObjectTemplate_tag;
|
||||
} // ServerVehicleObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerVehicleObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerVehicleObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerVehicleObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerVehicleObjectTemplate * base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerVehicleObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerVehicleObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new VehicleObject(this);
|
||||
} // ServerVehicleObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerVehicleObjectTemplate::getFuelType(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::string testDataValue = DefaultString;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getFuelType(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_fuelType.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter fuelType in template %s", DataResource::getName()));
|
||||
return DefaultString;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter fuelType has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getFuelType();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string & value = m_fuelType.getValue();
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getFuelType
|
||||
|
||||
float ServerVehicleObjectTemplate::getCurrentFuel(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getCurrentFuel(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_currentFuel.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter currentFuel in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter currentFuel has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getCurrentFuel();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_currentFuel.getValue();
|
||||
char delta = m_currentFuel.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getCurrentFuel();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getCurrentFuel
|
||||
|
||||
float ServerVehicleObjectTemplate::getCurrentFuelMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getCurrentFuelMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_currentFuel.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter currentFuel in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter currentFuel has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getCurrentFuelMin();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_currentFuel.getMinValue();
|
||||
char delta = m_currentFuel.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getCurrentFuelMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getCurrentFuelMin
|
||||
|
||||
float ServerVehicleObjectTemplate::getCurrentFuelMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getCurrentFuelMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_currentFuel.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter currentFuel in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter currentFuel has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getCurrentFuelMax();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_currentFuel.getMaxValue();
|
||||
char delta = m_currentFuel.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getCurrentFuelMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getCurrentFuelMax
|
||||
|
||||
float ServerVehicleObjectTemplate::getMaxFuel(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxFuel(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxFuel.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxFuel in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxFuel has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxFuel();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_maxFuel.getValue();
|
||||
char delta = m_maxFuel.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxFuel();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getMaxFuel
|
||||
|
||||
float ServerVehicleObjectTemplate::getMaxFuelMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxFuelMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxFuel.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxFuel in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxFuel has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxFuelMin();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_maxFuel.getMinValue();
|
||||
char delta = m_maxFuel.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxFuelMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getMaxFuelMin
|
||||
|
||||
float ServerVehicleObjectTemplate::getMaxFuelMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getMaxFuelMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_maxFuel.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter maxFuel in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter maxFuel has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getMaxFuelMax();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_maxFuel.getMaxValue();
|
||||
char delta = m_maxFuel.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getMaxFuelMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getMaxFuelMax
|
||||
|
||||
float ServerVehicleObjectTemplate::getConsumpsion(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getConsumpsion(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_consumpsion.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter consumpsion in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter consumpsion has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getConsumpsion();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_consumpsion.getValue();
|
||||
char delta = m_consumpsion.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getConsumpsion();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getConsumpsion
|
||||
|
||||
float ServerVehicleObjectTemplate::getConsumpsionMin(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getConsumpsionMin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_consumpsion.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter consumpsion in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter consumpsion has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getConsumpsionMin();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_consumpsion.getMinValue();
|
||||
char delta = m_consumpsion.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getConsumpsionMin();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getConsumpsionMin
|
||||
|
||||
float ServerVehicleObjectTemplate::getConsumpsionMax(bool testData) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
float testDataValue = 0.0f;
|
||||
#else
|
||||
UNREF(testData);
|
||||
#endif
|
||||
|
||||
const ServerVehicleObjectTemplate * base = NULL;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
testDataValue = base->getConsumpsionMax(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!m_consumpsion.isLoaded())
|
||||
{
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter consumpsion in template %s", DataResource::getName()));
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FATAL(base == NULL, ("Template parameter consumpsion has not been defined in template %s!", DataResource::getName()));
|
||||
return base->getConsumpsionMax();
|
||||
}
|
||||
}
|
||||
|
||||
float value = m_consumpsion.getMaxValue();
|
||||
char delta = m_consumpsion.getDeltaType();
|
||||
if (delta == '+' || delta == '-' || delta == '_' || delta == '=')
|
||||
{
|
||||
float baseValue = 0;
|
||||
if (m_baseData != NULL)
|
||||
{
|
||||
if (base != NULL)
|
||||
baseValue = base->getConsumpsionMax();
|
||||
else if (ms_allowDefaultTemplateParams)
|
||||
DEBUG_WARNING(true, ("No base template for delta, using 0"));
|
||||
else
|
||||
NOT_NULL(base);
|
||||
}
|
||||
if (delta == '+')
|
||||
value = baseValue + value;
|
||||
else if (delta == '-')
|
||||
value = baseValue - value;
|
||||
else if (delta == '=')
|
||||
value = baseValue + static_cast<float>(baseValue * (value / 100.0f));
|
||||
else if (delta == '_')
|
||||
value = baseValue - static_cast<float>(baseValue * (value / 100.0f));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (testData && base != NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getConsumpsionMax
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerVehicleObjectTemplate::testValues(void) const
|
||||
{
|
||||
IGNORE_RETURN(getFuelType(true));
|
||||
IGNORE_RETURN(getCurrentFuelMin(true));
|
||||
IGNORE_RETURN(getCurrentFuelMax(true));
|
||||
IGNORE_RETURN(getMaxFuelMin(true));
|
||||
IGNORE_RETURN(getMaxFuelMax(true));
|
||||
IGNORE_RETURN(getConsumpsionMin(true));
|
||||
IGNORE_RETURN(getConsumpsionMax(true));
|
||||
ServerTangibleObjectTemplate::testValues();
|
||||
} // ServerVehicleObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerVehicleObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerVehicleObjectTemplate_tag)
|
||||
{
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
for (int i = 0; i < paramCount; ++i)
|
||||
{
|
||||
file.enterChunk();
|
||||
file.read_string(paramName, MAX_NAME_SIZE);
|
||||
if (strcmp(paramName, "fuelType") == 0)
|
||||
m_fuelType.loadFromIff(file);
|
||||
else if (strcmp(paramName, "currentFuel") == 0)
|
||||
m_currentFuel.loadFromIff(file);
|
||||
else if (strcmp(paramName, "maxFuel") == 0)
|
||||
m_maxFuel.loadFromIff(file);
|
||||
else if (strcmp(paramName, "consumpsion") == 0)
|
||||
m_consumpsion.loadFromIff(file);
|
||||
file.exitChunk(true);
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
ServerTangibleObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerVehicleObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerVehicleObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerVehicleObjectTemplate_H
|
||||
#define _INCLUDED_ServerVehicleObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerVehicleObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerVehicleObjectTemplate_tag = TAG(V,E,H,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerVehicleObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerVehicleObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
const std::string & getFuelType(bool testData = false) const;
|
||||
float getCurrentFuel(bool testData = false) const;
|
||||
float getCurrentFuelMin(bool testData = false) const;
|
||||
float getCurrentFuelMax(bool testData = false) const;
|
||||
float getMaxFuel(bool testData = false) const;
|
||||
float getMaxFuelMin(bool testData = false) const;
|
||||
float getMaxFuelMax(bool testData = false) const;
|
||||
float getConsumpsion(bool testData = false) const;
|
||||
float getConsumpsionMin(bool testData = false) const;
|
||||
float getConsumpsionMax(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
StringParam m_fuelType; // type of fuel used
|
||||
FloatParam m_currentFuel; // current amount of fuel the vehicle has
|
||||
FloatParam m_maxFuel; // max amount of fuel the vehicle can hold
|
||||
FloatParam m_consumpsion; // units/sec/speed(?) fuel used
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerVehicleObjectTemplate(const ServerVehicleObjectTemplate &);
|
||||
ServerVehicleObjectTemplate & operator =(const ServerVehicleObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerVehicleObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerVehicleObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerVehicleObjectTemplate_H
|
||||
+2525
File diff suppressed because it is too large
Load Diff
+173
@@ -0,0 +1,173 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerWeaponObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerWeaponObjectTemplate_H
|
||||
#define _INCLUDED_ServerWeaponObjectTemplate_H
|
||||
|
||||
#include "ServerTangibleObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerWeaponObjectTemplate : public ServerTangibleObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerWeaponObjectTemplate_tag = TAG(W,E,A,O)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerWeaponObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerWeaponObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
enum AttackType
|
||||
{
|
||||
AT_melee,
|
||||
AT_ranged,
|
||||
AT_thrown,
|
||||
AttackType_Last = AT_thrown,
|
||||
};
|
||||
|
||||
enum AttribModDecaySpecial
|
||||
{
|
||||
AMDS_pool = -1, // use the attribute pool recovery rate (normal recovery)
|
||||
AMDS_wound = -2, // can only be healed by skill/item use, heal difficulty adjusted by shock wound value
|
||||
AMDS_antidote = -3, // used to clear all attrib mods for a given attribute
|
||||
AttribModDecaySpecial_Last = AMDS_antidote,
|
||||
};
|
||||
|
||||
enum WeaponType
|
||||
{
|
||||
WT_rifle,
|
||||
WT_lightRifle,
|
||||
WT_pistol,
|
||||
WT_heavyWeapon,
|
||||
WT_1handMelee,
|
||||
WT_2handMelee,
|
||||
WT_unarmed,
|
||||
WT_polearm,
|
||||
WT_thrown,
|
||||
WT_1handLightsaber,
|
||||
WT_2handLightsaber,
|
||||
WT_polearmLightsaber,
|
||||
WeaponType_Last = WT_polearmLightsaber,
|
||||
};
|
||||
|
||||
public:
|
||||
WeaponType getWeaponType(bool testData = false) const;
|
||||
AttackType getAttackType(bool testData = false) const;
|
||||
DamageType getDamageType(bool testData = false) const;
|
||||
DamageType getElementalType(bool testData = false) const;
|
||||
int getElementalValue(bool testData = false) const;
|
||||
int getElementalValueMin(bool testData = false) const;
|
||||
int getElementalValueMax(bool testData = false) const;
|
||||
int getMinDamageAmount(bool testData = false) const;
|
||||
int getMinDamageAmountMin(bool testData = false) const;
|
||||
int getMinDamageAmountMax(bool testData = false) const;
|
||||
int getMaxDamageAmount(bool testData = false) const;
|
||||
int getMaxDamageAmountMin(bool testData = false) const;
|
||||
int getMaxDamageAmountMax(bool testData = false) const;
|
||||
float getAttackSpeed(bool testData = false) const;
|
||||
float getAttackSpeedMin(bool testData = false) const;
|
||||
float getAttackSpeedMax(bool testData = false) const;
|
||||
float getAudibleRange(bool testData = false) const;
|
||||
float getAudibleRangeMin(bool testData = false) const;
|
||||
float getAudibleRangeMax(bool testData = false) const;
|
||||
float getMinRange(bool testData = false) const;
|
||||
float getMinRangeMin(bool testData = false) const;
|
||||
float getMinRangeMax(bool testData = false) const;
|
||||
float getMaxRange(bool testData = false) const;
|
||||
float getMaxRangeMin(bool testData = false) const;
|
||||
float getMaxRangeMax(bool testData = false) const;
|
||||
float getDamageRadius(bool testData = false) const;
|
||||
float getDamageRadiusMin(bool testData = false) const;
|
||||
float getDamageRadiusMax(bool testData = false) const;
|
||||
float getWoundChance(bool testData = false) const;
|
||||
float getWoundChanceMin(bool testData = false) const;
|
||||
float getWoundChanceMax(bool testData = false) const;
|
||||
int getAttackCost(bool testData = false) const;
|
||||
int getAttackCostMin(bool testData = false) const;
|
||||
int getAttackCostMax(bool testData = false) const;
|
||||
int getAccuracy(bool testData = false) const;
|
||||
int getAccuracyMin(bool testData = false) const;
|
||||
int getAccuracyMax(bool testData = false) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
IntegerParam m_weaponType; // General type of weapon
|
||||
IntegerParam m_attackType; // Type of attack this weapon is used with.
|
||||
IntegerParam m_damageType; // The kind of damage this weapon deals.
|
||||
IntegerParam m_elementalType; // The kind of special elemental damage this weapon deals.
|
||||
IntegerParam m_elementalValue; // The amount of special elemental damage this weapon deals.
|
||||
IntegerParam m_minDamageAmount; // The amount of damage done by a weapon is between min-max evenly, randomly, distributed.
|
||||
IntegerParam m_maxDamageAmount; // The amount of damage done by a weapon is between min-max evenly, randomly, distributed.
|
||||
FloatParam m_attackSpeed; // The weapon's intrisic firing rate.
|
||||
FloatParam m_audibleRange; // Distance message gets sent to NPCs when fired.
|
||||
FloatParam m_minRange; // range where the min range mod is set
|
||||
FloatParam m_maxRange; // range where the max range mod is set
|
||||
FloatParam m_damageRadius; // Blast radius for area effect weapons
|
||||
FloatParam m_woundChance; // Base % chance for a wound to occur on a successful attack
|
||||
IntegerParam m_attackCost; // Amount of H/A/M drained by using the weapon
|
||||
IntegerParam m_accuracy; // Accuracy bonus/penalty for this weapon
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerWeaponObjectTemplate(const ServerWeaponObjectTemplate &);
|
||||
ServerWeaponObjectTemplate & operator =(const ServerWeaponObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerWeaponObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerWeaponObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerWeaponObjectTemplate_H
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerXpManagerObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "ServerXpManagerObjectTemplate.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
//#include "serverGame/XpManagerObject.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
//const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerXpManagerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerXpManagerObjectTemplate::ServerXpManagerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerXpManagerObjectTemplate::ServerXpManagerObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerXpManagerObjectTemplate::~ServerXpManagerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerXpManagerObjectTemplate::~ServerXpManagerObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerXpManagerObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerXpManagerObjectTemplate_tag, create);
|
||||
} // ServerXpManagerObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerXpManagerObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerXpManagerObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerXpManagerObjectTemplate(filename);
|
||||
} // ServerXpManagerObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerXpManagerObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerXpManagerObjectTemplate_tag;
|
||||
} // ServerXpManagerObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerXpManagerObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerXpManagerObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerXpManagerObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerXpManagerObjectTemplate * base = dynamic_cast<const ServerXpManagerObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerXpManagerObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerXpManagerObjectTemplate::createObject(void) const
|
||||
{
|
||||
// return new XpManagerObject(this);
|
||||
return NULL;
|
||||
} // ServerXpManagerObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerXpManagerObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerUniverseObjectTemplate::testValues();
|
||||
} // ServerXpManagerObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerXpManagerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerXpManagerObjectTemplate_tag)
|
||||
{
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerXpManagerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerXpManagerObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerXpManagerObjectTemplate_H
|
||||
#define _INCLUDED_ServerXpManagerObjectTemplate_H
|
||||
|
||||
#include "ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerXpManagerObjectTemplate : public ServerUniverseObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerXpManagerObjectTemplate_tag = TAG(X,P,M,G)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerXpManagerObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerXpManagerObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerXpManagerObjectTemplate(const ServerXpManagerObjectTemplate &);
|
||||
ServerXpManagerObjectTemplate & operator =(const ServerXpManagerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerXpManagerObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerXpManagerObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerXpManagerObjectTemplate_H
|
||||
Reference in New Issue
Block a user