Added TemplateCompiler project and sharedTemplate/sharedTemplateDefinition libraries

This commit is contained in:
Anonymous
2014-01-21 10:31:25 -07:00
parent 232bcc82dc
commit 9ecd34c0ab
249 changed files with 49504 additions and 0 deletions
+1
View File
@@ -1,2 +1,3 @@
add_subdirectory(application)
add_subdirectory(library)
+2
View File
@@ -0,0 +1,2 @@
add_subdirectory(TemplateCompiler)
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.8)
project(TemplateCompiler)
add_subdirectory(src)
@@ -0,0 +1,73 @@
set(SHARED_SOURCES
shared/TemplateCompiler.cpp
)
if(WIN32)
set(PLATFORM_SOURCES
win32/FirstTemplateCompiler.cpp
win32/FirstTemplateCompiler.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/win32)
else()
set(PLATFORM_SOURCES
linux/FirstTemplateCompiler.cpp
linux/FirstTemplateCompiler.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/linux)
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/shared
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCompression/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTemplate/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTemplateDefinition/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
)
add_executable(TemplateCompiler
${SHARED_SOURCES}
${PLATFORM_SOURCES}
)
target_link_libraries(TemplateCompiler
sharedCompression
sharedDebug
sharedFile
sharedFoundation
#sharedLog
#sharedMath
sharedMemoryManager
#sharedMessageDispatch
#sharedNetwork
#sharedNetworkMessages
sharedObject
sharedRandom
sharedRegex
sharedTemplate
sharedTemplateDefinition
sharedThread
sharedUtility
#serverNetworkMessages
#serverUtility
archive
#fileInterface
localization
localizationArchive
unicode
unicodeArchive
${STLPORT_LIBRARIES}
${CMAKE_DL_LIBS}
)
@@ -0,0 +1 @@
#include "FirstTemplateCompiler.h"
@@ -0,0 +1,9 @@
#include "sharedFoundationTypes/FoundationTypes.h"
#include "sharedDebug/FirstSharedDebug.h"
#include "sharedFoundation/FirstSharedFoundation.h"
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
@@ -0,0 +1,634 @@
//========================================================================
//
// TemplateCompiler.cpp - entry point for templateCompiler
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "FirstTemplateCompiler.h"
#include "sharedCompression/SetupSharedCompression.h"
#include "sharedDebug/SetupSharedDebug.h"
#include "sharedFile/SetupSharedFile.h"
#include "sharedFoundation/PerThreadData.h"
#include "sharedFoundation/SetupSharedFoundation.h"
#include "sharedObject/SetupSharedObject.h"
#include "sharedRandom/SetupSharedRandom.h"
#include "sharedRegex/SetupSharedRegex.h"
#include "sharedThread/SetupSharedThread.h"
#include "sharedUtility/TemplateParameter.h"
#include "sharedTemplateDefinition/File.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include "sharedTemplateDefinition/TemplateDefinitionFile.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "sharedTemplateDefinition/TpfFile.h"
#include "sharedTemplate/SetupSharedTemplate.h"
#pragma warning (disable:4100) // unreferenced formal parameters abound in the perforce clientAPI
//#include "clientapi.h"
#pragma warning (default:4100)
#include <ctime>
//==============================================================================
// subclass Perforce API class ClientUser in order to trap errors
static const int SUBMIT_NO_FILE_ERR = 17; // need to add file before submitting
//class MyPerforceUser : public ClientUser
//{
//public:
// MyPerforceUser(void) : ClientUser(), m_errorOccurred(false) {}
// virtual ~MyPerforceUser() {}
// virtual void HandleError( Error *err )
// {
// if (err != NULL && err->Test())
// {
// m_errorOccurred = true;
// m_lastError = err->GetGeneric();
// // test for filtered errors
// for (size_t i = 0; i < m_filteredErrors.size(); ++i)
// {
// if (m_lastError == m_filteredErrors[i])
// return;
// }
// }
// ClientUser::HandleError(err);
// }
//
// bool errorOccurred(void) const
// {
// return m_errorOccurred;
// }
//
// int getLastError(void) const
// {
// return m_lastError;
// }
//
// void clearLastError(void)
// {
// m_errorOccurred = false;
// m_lastError = 0;
// }
//
// void addFilteredError(int error)
// {
// m_filteredErrors.push_back(error);
// }
//
// void clearFilteredErrors(void)
// {
// m_filteredErrors.clear();
// }
//
//private:
// bool m_errorOccurred;
// int m_lastError;
// std::vector<int> m_filteredErrors;
//};
//==============================================================================
// subclass of the PerforceAPI StrBuf class, to workaround a bug
// in the destructor. We can't fix the bug because it's an external library
//class StrBufFixed : public StrBuf
//{
//public:
// ~StrBufFixed()
// {
// delete buffer;
// StringInit();
// }
//};
//==============================================================================
// functions
/**
* Appends an extension to the end of a filename.
*
* @param filename the failename to append to
* @param extension the extension to extend
*/
void appendExtension(std::string & filename, const char *extension)
{
// see if the filename already has the extension
std::string::size_type matchPos = filename.rfind(extension);
if (matchPos != std::string::npos && filename[matchPos - 1] == '.')
return;
filename.append(".");
filename.append(extension);
} // appendExtension
/**
* Creates a default template file from a template definition file.
*
* @param definitionFp template definition file to read from
* @param templateFile template file to write to
*
* @return 0 on success, error code on fail
*/
int generateTemplate(File &definitionFp, File &templateFp)
{
// parse the template definition file
TemplateDefinitionFile TemplateDefinitionFile;
int result = TemplateDefinitionFile.parse(definitionFp);
if (result != 0)
return result;
// get the latest version
const TemplateData *currentTemplate = TemplateDefinitionFile.getTemplateData(
TemplateDefinitionFile.getHighestVersion());
NOT_NULL(currentTemplate);
templateFp.print("@class %s %d\n\n", TemplateDefinitionFile.getTemplateFilename().c_str(),
TemplateDefinitionFile.getHighestVersion());
currentTemplate->writeDefaultTemplateFile(templateFp);
// we now need to move down the template definition heiarchy and write the
// parameters of the base class
Filename basename(NULL, definitionFp.getFilename().getPath().c_str(),
TemplateDefinitionFile.getBaseFilename().c_str(), TEMPLATE_DEFINITION_EXTENSION);
if (basename.getName().size() == 0)
return 0;
// basename.setExtension(TEMPLATE_DEFINITION_EXTENSION);
File baseFp;
if (!baseFp.open(basename, "rt"))
{
fprintf(stderr, "Cannot open template definition file %s\n",
baseFp.getFilename().getFullFilename().c_str());
return -1;
}
templateFp.print("\n\n");
result = generateTemplate(baseFp, templateFp);
return result;
} // generateTemplate(File &, File &)
/**
* Creates a default template file from a template definition file.
*
* @param definitionFile the filename of the definition
* @param templateFile the filename of the template
*
* @return 0 on success, error code on fail
*/
int generateTemplate(const char *definitionFile, const char *templateFile)
{
// check filename extensions
Filename defFile(NULL, NULL, definitionFile, TEMPLATE_DEFINITION_EXTENSION);
Filename temFile(NULL, NULL, templateFile, TEMPLATE_EXTENSION);
File definitionFp;
int i = 0;
while (!definitionFp.exists(defFile) && i < MAX_DIRECTORY_DEPTH)
{
defFile.appendPath(NEXT_HIGHER_PATH);
++i;
}
if (i == MAX_DIRECTORY_DEPTH)
{
fprintf(stderr, "Cannot find template definition file %s\n",
defFile.getName().c_str());
return -1;
}
if (!definitionFp.open(defFile, "rt"))
{
fprintf(stderr, "Cannot open template definition file %s\n",
defFile.getName().c_str());
return -1;
}
File templateFp;
if (!templateFp.open(temFile, "wt"))
{
fprintf(stderr, "Cannot open template file %s\n",
templateFp.getFilename().getFullFilename().c_str());
return -1;
}
int result = generateTemplate(definitionFp, templateFp);
return result;
} // generateTemplate(const char *, const char *)
/**
* Derives a default template file from another template file.
*
* @param baseFile the filename of the source template
* @param templateFile the filename of the destination template
*
* @return 0 on success, error code on fail
*/
int deriveTemplate(const char *baseFile, const char *templateFile)
{
// check filename extensions
Filename basFile(NULL, NULL, baseFile, TEMPLATE_EXTENSION);
Filename temFile(NULL, NULL, templateFile, TEMPLATE_EXTENSION);
File basFp;
if (!basFp.open(basFile, "rt"))
{
fprintf(stderr, "Cannot open base template file %s\n",
basFp.getFilename().getFullFilename().c_str());
return -1;
}
File temFp;
if (!temFp.open(temFile, "wt"))
{
fprintf(stderr, "Cannot open derived template file %s\n",
temFp.getFilename().getFullFilename().c_str());
return -1;
}
return 0;
} // deriveTemplate
/**
* Compiles a template file into an iff file.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*/
int compileTemplate(const char *filename)
{
TpfFile templateFile;
Filename templateFileName(NULL, NULL, filename, TEMPLATE_EXTENSION);
return templateFile.makeIffFiles(templateFileName);
} // compileTemplate
/**
* Tests to see if a template file is valid. Does not generate an iff file.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*/
int verifyTemplate(const char *filename)
{
TpfFile templateFile;
printf("Verifying %s: ", filename);
Filename templateFileName(NULL, NULL, filename, TEMPLATE_EXTENSION);
int result = templateFile.loadTemplate(templateFileName);
if (result == 0)
printf("file ok");
printf("\n");
return result;
} // verifyTemplate
/**
* Adds or removes parameters from a template based on the current template
* definition.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*
int updateTemplate(const char *filename)
{
TpfFile templateFile;
Filename templateFileName(NULL, NULL, filename, TEMPLATE_EXTENSION);
return templateFile.updateTemplate(templateFileName);
} // updateTemplate
*/
/**
* Checks out a template file and the iff files associated with it from Perforce.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*/
//int checkOut(const char *filename)
//{
//MyPerforceUser ui;
//ClientApi client;
//Error e;
//
// // check filename extensions
// Filename templateFileName(NULL, NULL, filename, TEMPLATE_EXTENSION);
// Filename iffFileName = templateFileName;
// iffFileName.setExtension(IFF_EXTENSION);
//
// // Connect to Perforce server
// client.Init( &e );
// if (e.Test())
// {
// StrBufFixed msg;
// e.Fmt(&msg);
// fprintf(stderr, msg.Text());
// return -1;
// }
//
// // check out the template file
// const char * commands[2];
// commands[0] = "edit";
// commands[1] = templateFileName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
//
// // find the client and server paths
// TpfFile templateFile;
// IGNORE_RETURN(templateFile.loadTemplate(templateFileName));
//
// // check out the client template iff file
// Filename iffName(NULL, templateFile.getIffPath().c_str(), iffFileName, IFF_EXTENSION);
// commands[1] = iffName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
//
// // Close connection
// return client.Final( &e );
//} // checkOut
/**
* Checks in a template file and the iff files associated with it to Perforce.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*/
//int checkIn(const char *filename)
//{
//MyPerforceUser ui;
//ClientApi client;
//Error e;
//
// // check filename extensions
// Filename templateFileName(NULL, NULL, filename, TEMPLATE_EXTENSION);
// Filename iffFileName = templateFileName;
// iffFileName.setExtension(IFF_EXTENSION);
//
// // find the client and server paths
// TpfFile templateFile;
// int result = templateFile.loadTemplate(templateFileName);
// if (result != 0)
// {
// // don't allow check-in if there are errors
// return result;
// }
//
// // Connect to Perforce server
// client.Init( &e );
// if (e.Test())
// {
// StrBufFixed msg;
// e.Fmt(&msg);
// fprintf(stderr, msg.Text());
// return -1;
// }
//
// // try to submit the files
// const char * commands[4];
// char param1[256];
// for (;;)
// {
// sprintf(param1, "//depot/.../%s.*", templateFileName.getName().c_str());
// commands[0] = "submit";
// commands[1] = param1;
//
// // don't report an error if the files need to be added before submitting
// ui.addFilteredError(SUBMIT_NO_FILE_ERR);
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (!ui.errorOccurred())
// break;
// if (ui.getLastError() != SUBMIT_NO_FILE_ERR)
// return -1;
// ui.clearLastError();
// ui.clearFilteredErrors();
//
// // we need to add the files to Perforce before submitting
// commands[0] = "add";
//
// // add the template file
// commands[1] = templateFileName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
//
// // add the client iff file
// Filename iffName(NULL, templateFile.getIffPath().c_str(), iffFileName, NULL);
// commands[1] = iffName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
// }
//
// // Close connection
// return client.Final( &e );
//} // checkIn
/**
* Prints the command syntax to the console.
*/
void printSyntax(void)
{
printf("TemplateCompiler " __DATE__ " " __TIME__ "\n\n");
printf("Compiler commands:\n");
printf("-generate <defname>[.tdf] <templatename>[.tpf]\n");
// printf("-update <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
// printf("-derive <basename>[.tpf] <derivedname>[.tpf]\n");
printf("-compile <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
printf("-verify <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
// printf("Perforce commands:\n");
// printf("-edit <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
// printf("-submit <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
} // printSyntax
/**
* Processes the args sent to main.
*/
int processArgs(int argc, char *argv[ ])
{
if (argc < 3)
{
printSyntax();
return 0;
}
if (strcmp(argv[1], "-generate") == 0)
{
if (argc != 4)
{
printSyntax();
return 0;
}
return generateTemplate(argv[2], argv[3]);
}
// else if (strcmp(argv[1], "-update") == 0)
// {
// if (argc < 3)
// {
// printSyntax();
// return 0;
// }
// for (int i = 2; i < argc; ++i)
// {
// int result = updateTemplate(argv[i]);
// if (result != 0)
// return result;
// }
// }
else if (strcmp(argv[1], "-derive") == 0)
{
if (argc != 4)
{
printSyntax();
return 0;
}
return deriveTemplate(argv[2], argv[3]);
}
else if (strcmp(argv[1], "-compile") == 0)
{
if (argc < 3)
{
printSyntax();
return 0;
}
for (int i = 2; i < argc; ++i)
{
int result = compileTemplate(argv[i]);
if (result != 0)
return result;
}
}
else if (strcmp(argv[1], "-compileeditor") == 0)
{
if (argc < 3)
{
printSyntax();
return 0;
}
for (int i = 2; i < argc; ++i)
{
int result = compileTemplate(argv[i]);
if (result != 0)
return result;
}
printf ("%s compiled successfully.\n", argv [2]);
}
else if (strcmp(argv[1], "-verify") == 0)
{
if (argc < 3)
{
printSyntax();
return 0;
}
int result = 0;
for (int i = 2; i < argc; ++i)
{
int tempResult = verifyTemplate(argv[i]);
if (tempResult != 0)
result = tempResult;
}
return result;
}
//else if (strcmp(argv[1], "-edit") == 0)
//{
// if (argc < 3)
// {
// printSyntax();
// return 0;
// }
// for (int i = 2; i < argc; ++i)
// {
// int result = checkOut(argv[i]);
// if (result != 0)
// return result;
// }
//}
//else if (strcmp(argv[1], "-submit") == 0)
//{
// if (argc < 3)
// {
// printSyntax();
// return 0;
// }
// for (int i = 2; i < argc; ++i)
// {
// int result = checkIn(argv[i]);
// if (result != 0)
// return result;
// }
//}
else
{
printSyntax();
return 0;
}
return 0;
} // processArgs
/**
* Program entry point.
*/
int main(int argc, char *argv[ ])
{
SetupSharedThread::install();
SetupSharedDebug::install(4096);
{
SetupSharedFoundation::Data data(SetupSharedFoundation::Data::D_console);
#ifdef WIN32
char buffer[1024];
GetModuleFileName(GetModuleHandle(NULL), buffer, 1024);
Filename configName;
configName.setName(buffer);
configName.setName("templateCompiler.cfg");
data.configFile = configName.getFullFilename().c_str();
#endif
SetupSharedFoundation::install (data);
}
SetupSharedRegex::install();
SetupSharedCompression::install();
SetupSharedFile::install(false);
// setup the random number generator
// @todo need a better seed
SetupSharedRandom::install(static_cast<uint32>(time(NULL)));
// install templates
SetupSharedTemplate::install();
#ifdef WIN32
// find out what platform we are running on
DWORD version = GetVersion();
if (version & 0x80000000)
WindowsUnicode = false;
else
WindowsUnicode = true;
#endif
int result = processArgs(argc, argv);
// cleanup
SetupSharedFoundation::remove();
PerThreadData::threadRemove();
return result;
} // main
// ======================================================================
@@ -0,0 +1 @@
#include "FirstTemplateCompiler.h"
@@ -0,0 +1,8 @@
#include "sharedFoundationTypes/FoundationTypes.h"
#include "sharedDebug/FirstSharedDebug.h"
#include "sharedFoundation/FirstSharedFoundation.h"
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
+2
View File
@@ -25,6 +25,8 @@ add_subdirectory(sharedRegex)
add_subdirectory(sharedRemoteDebugServer)
add_subdirectory(sharedSkillSystem)
add_subdirectory(sharedSynchronization)
add_subdirectory(sharedTemplate)
add_subdirectory(sharedTemplateDefinition)
add_subdirectory(sharedTerrain)
add_subdirectory(sharedThread)
add_subdirectory(sharedUtility)
@@ -170,4 +170,8 @@ add_library(sharedFoundation STATIC
target_link_libraries(sharedFoundation
sharedFile
archive
localization
localizationArchive
unicode
unicodeArchive
)
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(sharedTemplate)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public)
add_subdirectory(src)
@@ -0,0 +1,2 @@
#include "../../src/shared/core/FirstSharedTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerArmorTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerBattlefieldMarkerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerBuildingObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerCellObjectTemplate.h"
@@ -0,0 +1,2 @@
#include "../../src/shared/template/ServerCityObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerConstructionContractObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerCreatureObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerDraftSchematicObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerFactoryObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerGroupObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerGuildObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerHarvesterInstallationObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerInstallationObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerIntangibleObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerJediManagerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerManufactureInstallationObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerManufactureSchematicObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerMissionObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerPlanetObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerPlayerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerPlayerQuestObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerResourceClassObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerResourceContainerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerResourcePoolObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerResourceTypeObjectTemplate.h"
@@ -0,0 +1,2 @@
#include "../../src/shared/template/ServerShipObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerStaticObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerTangibleObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerTokenObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerUberObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerUniverseObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerVehicleObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerWaypointObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerWeaponObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/ServerXpManagerObjectTemplate.h"
@@ -0,0 +1,2 @@
#include "../../src/shared/core/SetupSharedTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedBattlefieldMarkerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedBuildingObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedCellObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedConstructionContractObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedCreatureObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedDraftSchematicObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedFactoryObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedGroupObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedGuildObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedInstallationObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedIntangibleObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedJediManagerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedManufactureSchematicObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedMissionObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedPlayerObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedPlayerQuestObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedResourceContainerObjectTemplate.h"
@@ -0,0 +1,2 @@
#include "../../src/shared/template/SharedShipObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedStaticObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedTangibleObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedTerrainSurfaceObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedTokenObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedUniverseObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedVehicleObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedWaypointObjectTemplate.h"
@@ -0,0 +1 @@
#include "../../src/shared/template/SharedWeaponObjectTemplate.h"
@@ -0,0 +1,161 @@
set(SHARED_SOURCES
shared/core/FirstSharedTemplate.h
shared/core/SetupSharedTemplate.cpp
shared/core/SetupSharedTemplate.h
shared/template/ServerArmorTemplate.cpp
shared/template/ServerArmorTemplate.h
shared/template/ServerBattlefieldMarkerObjectTemplate.cpp
shared/template/ServerBattlefieldMarkerObjectTemplate.h
shared/template/ServerBuildingObjectTemplate.cpp
shared/template/ServerBuildingObjectTemplate.h
shared/template/ServerCellObjectTemplate.cpp
shared/template/ServerCellObjectTemplate.h
shared/template/ServerCityObjectTemplate.cpp
shared/template/ServerCityObjectTemplate.h
shared/template/ServerConstructionContractObjectTemplate.cpp
shared/template/ServerConstructionContractObjectTemplate.h
shared/template/ServerCreatureObjectTemplate.cpp
shared/template/ServerCreatureObjectTemplate.h
shared/template/ServerDraftSchematicObjectTemplate.cpp
shared/template/ServerDraftSchematicObjectTemplate.h
shared/template/ServerFactoryObjectTemplate.cpp
shared/template/ServerFactoryObjectTemplate.h
shared/template/ServerGroupObjectTemplate.cpp
shared/template/ServerGroupObjectTemplate.h
shared/template/ServerGuildObjectTemplate.cpp
shared/template/ServerGuildObjectTemplate.h
shared/template/ServerHarvesterInstallationObjectTemplate.cpp
shared/template/ServerHarvesterInstallationObjectTemplate.h
shared/template/ServerInstallationObjectTemplate.cpp
shared/template/ServerInstallationObjectTemplate.h
shared/template/ServerIntangibleObjectTemplate.cpp
shared/template/ServerIntangibleObjectTemplate.h
shared/template/ServerJediManagerObjectTemplate.cpp
shared/template/ServerJediManagerObjectTemplate.h
shared/template/ServerManufactureInstallationObjectTemplate.cpp
shared/template/ServerManufactureInstallationObjectTemplate.h
shared/template/ServerManufactureSchematicObjectTemplate.cpp
shared/template/ServerManufactureSchematicObjectTemplate.h
shared/template/ServerMissionObjectTemplate.cpp
shared/template/ServerMissionObjectTemplate.h
shared/template/ServerObjectTemplate.cpp
shared/template/ServerObjectTemplate.h
shared/template/ServerPlanetObjectTemplate.cpp
shared/template/ServerPlanetObjectTemplate.h
shared/template/ServerPlayerQuestObjectTemplate.cpp
shared/template/ServerPlayerQuestObjectTemplate.h
shared/template/ServerPlayerObjectTemplate.cpp
shared/template/ServerPlayerObjectTemplate.h
shared/template/ServerResourceClassObjectTemplate.cpp
shared/template/ServerResourceClassObjectTemplate.h
shared/template/ServerResourceContainerObjectTemplate.cpp
shared/template/ServerResourceContainerObjectTemplate.h
shared/template/ServerResourcePoolObjectTemplate.cpp
shared/template/ServerResourcePoolObjectTemplate.h
shared/template/ServerResourceTypeObjectTemplate.cpp
shared/template/ServerResourceTypeObjectTemplate.h
shared/template/ServerShipObjectTemplate.cpp
shared/template/ServerShipObjectTemplate.h
shared/template/ServerStaticObjectTemplate.cpp
shared/template/ServerStaticObjectTemplate.h
shared/template/ServerTangibleObjectTemplate.cpp
shared/template/ServerTangibleObjectTemplate.h
shared/template/ServerTokenObjectTemplate.cpp
shared/template/ServerTokenObjectTemplate.h
shared/template/ServerUberObjectTemplate.cpp
shared/template/ServerUberObjectTemplate.h
shared/template/ServerUniverseObjectTemplate.cpp
shared/template/ServerUniverseObjectTemplate.h
shared/template/ServerVehicleObjectTemplate.cpp
shared/template/ServerVehicleObjectTemplate.h
shared/template/ServerWaypointObjectTemplate.cpp
shared/template/ServerWaypointObjectTemplate.h
shared/template/ServerWeaponObjectTemplate.cpp
shared/template/ServerWeaponObjectTemplate.h
shared/template/ServerXpManagerObjectTemplate.cpp
shared/template/ServerXpManagerObjectTemplate.h
shared/template/SharedBattlefieldMarkerObjectTemplate.cpp
shared/template/SharedBattlefieldMarkerObjectTemplate.h
shared/template/SharedBuildingObjectTemplate.cpp
shared/template/SharedBuildingObjectTemplate.h
shared/template/SharedCellObjectTemplate.cpp
shared/template/SharedCellObjectTemplate.h
shared/template/SharedConstructionContractObjectTemplate.cpp
shared/template/SharedConstructionContractObjectTemplate.h
shared/template/SharedCreatureObjectTemplate.cpp
shared/template/SharedCreatureObjectTemplate.h
shared/template/SharedDraftSchematicObjectTemplate.cpp
shared/template/SharedDraftSchematicObjectTemplate.h
shared/template/SharedFactoryObjectTemplate.cpp
shared/template/SharedFactoryObjectTemplate.h
shared/template/SharedGroupObjectTemplate.cpp
shared/template/SharedGroupObjectTemplate.h
shared/template/SharedGuildObjectTemplate.cpp
shared/template/SharedGuildObjectTemplate.h
shared/template/SharedInstallationObjectTemplate.cpp
shared/template/SharedInstallationObjectTemplate.h
shared/template/SharedIntangibleObjectTemplate.cpp
shared/template/SharedIntangibleObjectTemplate.h
shared/template/SharedJediManagerObjectTemplate.cpp
shared/template/SharedJediManagerObjectTemplate.h
shared/template/SharedManufactureSchematicObjectTemplate.cpp
shared/template/SharedManufactureSchematicObjectTemplate.h
shared/template/SharedMissionObjectTemplate.cpp
shared/template/SharedMissionObjectTemplate.h
shared/template/SharedObjectTemplate.cpp
shared/template/SharedObjectTemplate.h
shared/template/SharedPlayerObjectTemplate.cpp
shared/template/SharedPlayerObjectTemplate.h
shared/template/SharedPlayerQuestObjectTemplate.cpp
shared/template/SharedPlayerQuestObjectTemplate.h
shared/template/SharedResourceContainerObjectTemplate.cpp
shared/template/SharedResourceContainerObjectTemplate.h
shared/template/SharedShipObjectTemplate.cpp
shared/template/SharedShipObjectTemplate.h
shared/template/SharedStaticObjectTemplate.cpp
shared/template/SharedStaticObjectTemplate.h
shared/template/SharedTangibleObjectTemplate.cpp
shared/template/SharedTangibleObjectTemplate.h
shared/template/SharedTerrainSurfaceObjectTemplate.cpp
shared/template/SharedTerrainSurfaceObjectTemplate.h
shared/template/SharedTokenObjectTemplate.cpp
shared/template/SharedTokenObjectTemplate.h
shared/template/SharedUniverseObjectTemplate.cpp
shared/template/SharedUniverseObjectTemplate.h
shared/template/SharedVehicleObjectTemplate.cpp
shared/template/SharedVehicleObjectTemplate.h
shared/template/SharedWaypointObjectTemplate.cpp
shared/template/SharedWaypointObjectTemplate.h
shared/template/SharedWeaponObjectTemplate.cpp
shared/template/SharedWeaponObjectTemplate.h
)
if(WIN32)
set(PLATFORM_SOURCES
win32/FirstSharedTemplate.cpp
)
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/shared/core
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTemplateDefinition/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
${PCRE_INCLUDE_DIR}
)
add_library(sharedTemplate STATIC
${SHARED_SOURCES}
${PLATFORM_SOURCES}
)
@@ -0,0 +1,10 @@
#include "sharedFoundationTypes/FoundationTypes.h"
#include "sharedDebug/FirstSharedDebug.h"
#include "sharedFoundation/FirstSharedFoundation.h"
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <list>
@@ -0,0 +1,148 @@
//========================================================================
//
// SetupSharedTemplate.cpp - installs all the templates for the template
// editor/compiler
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplate/SetupSharedTemplate.h"
#include "sharedTemplate/ServerArmorTemplate.h"
#include "sharedTemplate/ServerBattlefieldMarkerObjectTemplate.h"
#include "sharedTemplate/ServerBuildingObjectTemplate.h"
#include "sharedTemplate/ServerCellObjectTemplate.h"
#include "sharedTemplate/ServerCityObjectTemplate.h"
#include "sharedTemplate/ServerConstructionContractObjectTemplate.h"
#include "sharedTemplate/ServerCreatureObjectTemplate.h"
#include "sharedTemplate/ServerDraftSchematicObjectTemplate.h"
#include "sharedTemplate/ServerFactoryObjectTemplate.h"
#include "sharedTemplate/ServerGroupObjectTemplate.h"
#include "sharedTemplate/ServerGuildObjectTemplate.h"
#include "sharedTemplate/ServerHarvesterInstallationObjectTemplate.h"
#include "sharedTemplate/ServerInstallationObjectTemplate.h"
#include "sharedTemplate/ServerIntangibleObjectTemplate.h"
#include "sharedTemplate/ServerJediManagerObjectTemplate.h"
#include "sharedTemplate/ServerManufactureInstallationObjectTemplate.h"
#include "sharedTemplate/ServerManufactureSchematicObjectTemplate.h"
#include "sharedTemplate/ServerMissionObjectTemplate.h"
#include "sharedTemplate/ServerTangibleObjectTemplate.h"
#include "sharedTemplate/ServerTokenObjectTemplate.h"
#include "sharedTemplate/ServerVehicleObjectTemplate.h"
#include "sharedTemplate/ServerWaypointObjectTemplate.h"
#include "sharedTemplate/ServerWeaponObjectTemplate.h"
#include "sharedTemplate/ServerPlanetObjectTemplate.h"
#include "sharedTemplate/ServerPlayerQuestObjectTempate.h"
#include "sharedTemplate/ServerPlayerObjectTemplate.h"
#include "sharedTemplate/ServerResourceClassObjectTemplate.h"
#include "sharedTemplate/ServerResourceContainerObjectTemplate.h"
#include "sharedTemplate/ServerResourcePoolObjectTemplate.h"
#include "sharedTemplate/ServerResourceTypeObjectTemplate.h"
#include "sharedTemplate/ServerShipObjectTemplate.h"
#include "sharedTemplate/ServerStaticObjectTemplate.h"
#include "sharedTemplate/ServerUniverseObjectTemplate.h"
#include "sharedTemplate/ServerXpManagerObjectTemplate.h"
#include "sharedTemplate/SharedBattlefieldMarkerObjectTemplate.h"
#include "sharedTemplate/SharedBuildingObjectTemplate.h"
#include "sharedTemplate/SharedCellObjectTemplate.h"
#include "sharedTemplate/SharedConstructionContractObjectTemplate.h"
#include "sharedTemplate/SharedCreatureObjectTemplate.h"
#include "sharedTemplate/SharedDraftSchematicObjectTemplate.h"
#include "sharedTemplate/SharedFactoryObjectTemplate.h"
#include "sharedTemplate/SharedGroupObjectTemplate.h"
#include "sharedTemplate/SharedGuildObjectTemplate.h"
#include "sharedTemplate/SharedInstallationObjectTemplate.h"
#include "sharedTemplate/SharedIntangibleObjectTemplate.h"
#include "sharedTemplate/SharedJediManagerObjectTemplate.h"
#include "sharedTemplate/SharedManufactureSchematicObjectTemplate.h"
#include "sharedTemplate/SharedMissionObjectTemplate.h"
#include "sharedTemplate/SharedObjectTemplate.h"
#include "sharedTemplate/SharedPlayerQuestObjectTemplate.h"
#include "sharedTemplate/SharedPlayerObjectTemplate.h"
#include "sharedTemplate/SharedShipObjectTemplate.h"
#include "sharedTemplate/SharedStaticObjectTemplate.h"
#include "sharedTemplate/SharedTangibleObjectTemplate.h"
#include "sharedTemplate/SharedTerrainSurfaceObjectTemplate.h"
#include "sharedTemplate/SharedTokenObjectTemplate.h"
#include "sharedTemplate/SharedUniverseObjectTemplate.h"
#include "sharedTemplate/SharedVehicleObjectTemplate.h"
#include "sharedTemplate/SharedWaypointObjectTemplate.h"
#include "sharedTemplate/SharedWeaponObjectTemplate.h"
#include "sharedTemplate/SharedResourceContainerObjectTemplate.h"
/**
* Installs all the templates.
*/
void SetupSharedTemplate::install(void)
{
// install templates
ServerArmorTemplate::install();
ServerBattlefieldMarkerObjectTemplate::install();
ServerBuildingObjectTemplate::install();
ServerCellObjectTemplate::install();
ServerCityObjectTemplate::install();
ServerConstructionContractObjectTemplate::install();
ServerCreatureObjectTemplate::install();
ServerDraftSchematicObjectTemplate::install();
ServerFactoryObjectTemplate::install();
ServerGroupObjectTemplate::install();
ServerGuildObjectTemplate::install();
ServerHarvesterInstallationObjectTemplate::install();
ServerInstallationObjectTemplate::install();
ServerIntangibleObjectTemplate::install();
ServerJediManagerObjectTemplate::install();
ServerManufactureInstallationObjectTemplate::install();
ServerManufactureSchematicObjectTemplate::install();
ServerMissionObjectTemplate::install();
ServerObjectTemplate::install();
ServerTangibleObjectTemplate::install();
ServerTokenObjectTemplate::install();
ServerVehicleObjectTemplate::install();
ServerWeaponObjectTemplate::install();
ServerPlanetObjectTemplate::install();
ServerPlayerQuestObjectTemplate::install();
ServerPlayerObjectTemplate::install();
ServerResourceClassObjectTemplate::install();
ServerResourceContainerObjectTemplate::install();
ServerResourcePoolObjectTemplate::install();
ServerResourceTypeObjectTemplate::install();
ServerShipObjectTemplate::install();
ServerStaticObjectTemplate::install();
ServerUniverseObjectTemplate::install();
ServerWaypointObjectTemplate::install();
ServerXpManagerObjectTemplate::install();
SharedBattlefieldMarkerObjectTemplate::install();
SharedBuildingObjectTemplate::install();
SharedCellObjectTemplate::install();
SharedConstructionContractObjectTemplate::install();
SharedCreatureObjectTemplate::install();
SharedDraftSchematicObjectTemplate::install();
SharedFactoryObjectTemplate::install();
SharedGroupObjectTemplate::install();
SharedGuildObjectTemplate::install();
SharedInstallationObjectTemplate::install();
SharedIntangibleObjectTemplate::install();
SharedJediManagerObjectTemplate::install();
SharedManufactureSchematicObjectTemplate::install();
SharedMissionObjectTemplate::install();
SharedObjectTemplate::install();
SharedPlayerQuestObjectTemplate::install();
SharedPlayerObjectTemplate::install();
SharedShipObjectTemplate::install();
SharedStaticObjectTemplate::install();
SharedTangibleObjectTemplate::install();
SharedTerrainSurfaceObjectTemplate::install();
SharedTokenObjectTemplate::install();
SharedUniverseObjectTemplate::install();
SharedVehicleObjectTemplate::install();
SharedWaypointObjectTemplate::install();
SharedWeaponObjectTemplate::install();
SharedResourceContainerObjectTemplate::install();
} // SetupSharedTemplate::install
//==============================================================================
@@ -0,0 +1,19 @@
//========================================================================
//
// SetupSharedTemplate.h - installs all the templates for the template
// editor/compiler
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
class SetupSharedTemplate
{
public:
static void install(void);
};
//==============================================================================
@@ -0,0 +1,697 @@
//========================================================================
//
// ServerArmorTemplate.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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerArmorTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerArmorTemplate::ServerArmorTemplate(const std::string & filename)
//@BEGIN TFD INIT
: TpfTemplate(filename)
,m_specialProtectionLoaded(false)
,m_specialProtectionAppend(false)
//@END TFD INIT
{
} // ServerArmorTemplate::ServerArmorTemplate
/**
* Class destructor.
*/
ServerArmorTemplate::~ServerArmorTemplate()
{
//@BEGIN TFD CLEANUP
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_specialProtection.begin(); iter != m_specialProtection.end(); ++iter)
{
delete *iter;
*iter = NULL;
}
m_specialProtection.clear();
}
//@END TFD CLEANUP
} // ServerArmorTemplate::~ServerArmorTemplate
/**
* Static function used to register this template.
*/
void ServerArmorTemplate::registerMe(void)
{
ObjectTemplateList::registerTemplate(ServerArmorTemplate_tag, create);
} // ServerArmorTemplate::registerMe
/**
* Creates a ServerArmorTemplate template.
*
* @return a new instance of the template
*/
ObjectTemplate * ServerArmorTemplate::create(const std::string & filename)
{
return new ServerArmorTemplate(filename);
} // ServerArmorTemplate::create
/**
* Returns the template id.
*
* @return the template id
*/
Tag ServerArmorTemplate::getId(void) const
{
return ServerArmorTemplate_tag;
} // ServerArmorTemplate::getId
/**
* Returns this template's version.
*
* @return the version
*/
Tag ServerArmorTemplate::getTemplateVersion(void) const
{
return m_templateVersion;
} // ServerArmorTemplate::getTemplateVersion
/**
* Returns the highest version of this template or it's base templates.
*
* @return the highest version
*/
Tag ServerArmorTemplate::getHighestTemplateVersion(void) const
{
if (m_baseData == NULL)
return m_templateVersion;
const ServerArmorTemplate * base = dynamic_cast<const ServerArmorTemplate *>(m_baseData);
if (base == NULL)
return m_templateVersion;
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerArmorTemplate::getHighestTemplateVersion
//@BEGIN TFD
CompilerIntegerParam * ServerArmorTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "rating") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_rating;
}
fprintf(stderr, "trying to access single-parameter \"rating\" as an array\n");
}
else if (strcmp(name, "integrity") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_integrity;
}
fprintf(stderr, "trying to access single-parameter \"integrity\" as an array\n");
}
else if (strcmp(name, "effectiveness") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_effectiveness;
}
fprintf(stderr, "trying to access single-parameter \"effectiveness\" as an array\n");
}
else if (strcmp(name, "vulnerability") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_vulnerability;
}
fprintf(stderr, "trying to access single-parameter \"vulnerability\" as an array\n");
}
else if (strcmp(name, "encumbrance") == 0)
{
if (index >= 0 && index < 3)
{
if (deepCheck && !isParamLoaded(name, false, index))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_encumbrance[index];
}
fprintf(stderr, "index for parameter \"encumbrance\" out of bounds\n");
}
else
return TpfTemplate::getCompilerIntegerParam(name, deepCheck, index);
return NULL;
} //ServerArmorTemplate::getCompilerIntegerParam
FloatParam * ServerArmorTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getFloatParam(name, deepCheck, index);
} //ServerArmorTemplate::getFloatParam
BoolParam * ServerArmorTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getBoolParam(name, deepCheck, index);
} //ServerArmorTemplate::getBoolParam
StringParam * ServerArmorTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getStringParam(name, deepCheck, index);
} //ServerArmorTemplate::getStringParam
StringIdParam * ServerArmorTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getStringIdParam(name, deepCheck, index);
} //ServerArmorTemplate::getStringIdParam
VectorParam * ServerArmorTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getVectorParam(name, deepCheck, index);
} //ServerArmorTemplate::getVectorParam
DynamicVariableParam * ServerArmorTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerArmorTemplate::getDynamicVariableParam
StructParamOT * ServerArmorTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "specialProtection") == 0)
{
if (index >= 0 && index < static_cast<int>(m_specialProtection.size()))
return m_specialProtection[index];
if (index == static_cast<int>(m_specialProtection.size()))
{
StructParamOT *temp = new StructParamOT();
m_specialProtection.push_back(temp);
return temp;
}
fprintf(stderr, "index for parameter \"specialProtection\" out of bounds\n");
}
else
return TpfTemplate::getStructParamOT(name, deepCheck, index);
return NULL;
} //ServerArmorTemplate::getStructParamOT
TriggerVolumeParam * ServerArmorTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerArmorTemplate::getTriggerVolumeParam
void ServerArmorTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
if (strcmp(name, "specialProtection") == 0)
param.setValue(new _SpecialProtection(""));
else
TpfTemplate::initStructParamOT(param, name);
} // ServerArmorTemplate::initStructParamOT
void ServerArmorTemplate::setAsEmptyList(const char *name)
{
if (strcmp(name, "specialProtection") == 0)
{
m_specialProtection.clear();
m_specialProtectionLoaded = true;
}
else
TpfTemplate::setAsEmptyList(name);
} // ServerArmorTemplate::setAsEmptyList
void ServerArmorTemplate::setAppend(const char *name)
{
if (strcmp(name, "specialProtection") == 0)
m_specialProtectionAppend = true;
else
TpfTemplate::setAppend(name);
} // ServerArmorTemplate::setAppend
bool ServerArmorTemplate::isAppend(const char *name) const
{
if (strcmp(name, "specialProtection") == 0)
return m_specialProtectionAppend;
else
return TpfTemplate::isAppend(name);
} // ServerArmorTemplate::isAppend
int ServerArmorTemplate::getListLength(const char *name) const
{
if (strcmp(name, "specialProtection") == 0)
{
return m_specialProtection.size();
}
else if (strcmp(name, "encumbrance") == 0)
{
return sizeof(m_encumbrance) / sizeof(CompilerIntegerParam);
}
else
return TpfTemplate::getListLength(name);
} // ServerArmorTemplate::getListLength
/**
* 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 ServerArmorTemplate::load(Iff &file)
{
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerArmorTemplate_tag)
{
TpfTemplate::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()));
}
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, "rating") == 0)
m_rating.loadFromIff(file);
else if (strcmp(paramName, "integrity") == 0)
m_integrity.loadFromIff(file);
else if (strcmp(paramName, "effectiveness") == 0)
m_effectiveness.loadFromIff(file);
else if (strcmp(paramName, "specialProtection") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_specialProtection.begin(); iter != m_specialProtection.end(); ++iter)
{
delete *iter;
*iter = NULL;
}
m_specialProtection.clear();
m_specialProtectionAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_specialProtection.push_back(newData);
}
m_specialProtectionLoaded = true;
}
else if (strcmp(paramName, "vulnerability") == 0)
m_vulnerability.loadFromIff(file);
else if (strcmp(paramName, "encumbrance") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 3, ("Template %s: read array size of %d for array \"encumbrance\" of size 3, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 3 && j < listCount; ++j)
m_encumbrance[j].loadFromIff(file);
// if there are more params for encumbrance read and dump them
for (; j < listCount; ++j)
{
CompilerIntegerParam dummy;
dummy.loadFromIff(file);
}
}
file.exitChunk(true);
}
file.exitForm();
TpfTemplate::load(file);
file.exitForm();
return;
} // ServerArmorTemplate::load
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerArmorTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerArmorTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,1));
file.allowNonlinearFunctions();
int paramCount = 0;
// save rating
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("rating");
m_rating.saveToIff(file);
file.exitChunk();
++paramCount;
// save integrity
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("integrity");
m_integrity.saveToIff(file);
file.exitChunk();
++paramCount;
// save effectiveness
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("effectiveness");
m_effectiveness.saveToIff(file);
file.exitChunk();
++paramCount;
if (!m_specialProtectionLoaded)
{
// mark the list as empty and extending the base list
m_specialProtectionAppend = true;
}
// save specialProtection
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("specialProtection");
file.insertChunkData(&m_specialProtectionAppend, sizeof(bool));
count = m_specialProtection.size();
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < count; ++i)
m_specialProtection[i]->saveToIff(file);}
file.exitChunk();
++paramCount;
// save vulnerability
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("vulnerability");
m_vulnerability.saveToIff(file);
file.exitChunk();
++paramCount;
// save encumbrance
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("encumbrance");
count = 3;
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 3; ++i)
m_encumbrance[i].saveToIff(file);}
file.exitChunk();
++paramCount;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
TpfTemplate::save(file);
file.exitForm();
} // ServerArmorTemplate::save
//=============================================================================
// class ServerArmorTemplate::_SpecialProtection
/**
* Class constructor.
*/
ServerArmorTemplate::_SpecialProtection::_SpecialProtection(const std::string & filename)
: TpfTemplate(filename)
{
} // ServerArmorTemplate::_SpecialProtection::_SpecialProtection
/**
* Class destructor.
*/
ServerArmorTemplate::_SpecialProtection::~_SpecialProtection()
{
} // ServerArmorTemplate::_SpecialProtection::~_SpecialProtection
/**
* Static function used to register this template.
*/
void ServerArmorTemplate::_SpecialProtection::registerMe(void)
{
ObjectTemplateList::registerTemplate(_SpecialProtection_tag, create);
} // ServerArmorTemplate::_SpecialProtection::registerMe
/**
* Creates a ServerArmorTemplate::_SpecialProtection template.
*
* @return a new instance of the template
*/
ObjectTemplate * ServerArmorTemplate::_SpecialProtection::create(const std::string & filename)
{
return new ServerArmorTemplate::_SpecialProtection(filename);
} // ServerArmorTemplate::_SpecialProtection::create
/**
* Returns the template id.
*
* @return the template id
*/
Tag ServerArmorTemplate::_SpecialProtection::getId(void) const
{
return _SpecialProtection_tag;
} // ServerArmorTemplate::_SpecialProtection::getId
CompilerIntegerParam * ServerArmorTemplate::_SpecialProtection::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "type") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_type;
}
fprintf(stderr, "trying to access single-parameter \"type\" as an array\n");
}
else if (strcmp(name, "effectiveness") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_effectiveness;
}
fprintf(stderr, "trying to access single-parameter \"effectiveness\" as an array\n");
}
else
return TpfTemplate::getCompilerIntegerParam(name, deepCheck, index);
return NULL;
} //ServerArmorTemplate::_SpecialProtection::getCompilerIntegerParam
FloatParam * ServerArmorTemplate::_SpecialProtection::getFloatParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getFloatParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getFloatParam
BoolParam * ServerArmorTemplate::_SpecialProtection::getBoolParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getBoolParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getBoolParam
StringParam * ServerArmorTemplate::_SpecialProtection::getStringParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getStringParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getStringParam
StringIdParam * ServerArmorTemplate::_SpecialProtection::getStringIdParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getStringIdParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getStringIdParam
VectorParam * ServerArmorTemplate::_SpecialProtection::getVectorParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getVectorParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getVectorParam
DynamicVariableParam * ServerArmorTemplate::_SpecialProtection::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getDynamicVariableParam
StructParamOT * ServerArmorTemplate::_SpecialProtection::getStructParamOT(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getStructParamOT(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getStructParamOT
TriggerVolumeParam * ServerArmorTemplate::_SpecialProtection::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return TpfTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerArmorTemplate::_SpecialProtection::getTriggerVolumeParam
void ServerArmorTemplate::_SpecialProtection::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
TpfTemplate::initStructParamOT(param, name);
} // ServerArmorTemplate::_SpecialProtection::initStructParamOT
void ServerArmorTemplate::_SpecialProtection::setAsEmptyList(const char *name)
{
TpfTemplate::setAsEmptyList(name);
} // ServerArmorTemplate::_SpecialProtection::setAsEmptyList
void ServerArmorTemplate::_SpecialProtection::setAppend(const char *name)
{
TpfTemplate::setAppend(name);
} // ServerArmorTemplate::_SpecialProtection::setAppend
bool ServerArmorTemplate::_SpecialProtection::isAppend(const char *name) const
{
return TpfTemplate::isAppend(name);
} // ServerArmorTemplate::_SpecialProtection::isAppend
int ServerArmorTemplate::_SpecialProtection::getListLength(const char *name) const
{
return TpfTemplate::getListLength(name);
} // ServerArmorTemplate::_SpecialProtection::getListLength
/**
* 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 ServerArmorTemplate::_SpecialProtection::load(Iff &file)
{
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];
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, "type") == 0)
m_type.loadFromIff(file);
else if (strcmp(paramName, "effectiveness") == 0)
m_effectiveness.loadFromIff(file);
file.exitChunk(true);
}
file.exitForm();
UNREF(file);
} // ServerArmorTemplate::_SpecialProtection::load
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerArmorTemplate::_SpecialProtection::save(Iff &file)
{
int count;
file.insertForm(_SpecialProtection_tag);
int paramCount = 0;
// save type
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("type");
m_type.saveToIff(file);
file.exitChunk();
++paramCount;
// save effectiveness
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("effectiveness");
m_effectiveness.saveToIff(file);
file.exitChunk();
++paramCount;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
UNREF(count);
} // ServerArmorTemplate::_SpecialProtection::save
//@END TFD
@@ -0,0 +1,182 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
#include "sharedFoundation/DynamicVariable.h"
#include "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
class ServerArmorTemplate : public TpfTemplate
{
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(void);
//@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 TpfTemplate
{
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:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(Iff &file);
private:
CompilerIntegerParam m_type; // specific damage being protected from
CompilerIntegerParam 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:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(Iff &file);
private:
CompilerIntegerParam m_rating; // armor rating
CompilerIntegerParam m_integrity; // integrity
CompilerIntegerParam m_effectiveness; // default effectiveness (0 = only use special protection)
stdvector<StructParamOT *>::fwd m_specialProtection; // damage-type specific protection
bool m_specialProtectionLoaded;
bool m_specialProtectionAppend;
CompilerIntegerParam m_vulnerability; // damaga types that this armor doesn't protect against
CompilerIntegerParam m_encumbrance[3]; // reduction to attributes from wearing this armor
//@END TFD
private:
Tag m_templateVersion; // the template version
bool m_versionOk; // flag that the template version loaded is the one we expect
static void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerArmorTemplate(const ServerArmorTemplate &);
ServerArmorTemplate & operator =(const ServerArmorTemplate &);
};
inline void ServerArmorTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerArmorTemplate::registerMe();
ServerArmorTemplate::_SpecialProtection::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerArmorTemplate_H
@@ -0,0 +1,266 @@
//========================================================================
//
// 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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerBattlefieldMarkerObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerBattlefieldMarkerObjectTemplate::ServerBattlefieldMarkerObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerTangibleObjectTemplate(filename)
//@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
//@BEGIN TFD
CompilerIntegerParam * ServerBattlefieldMarkerObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getCompilerIntegerParam
FloatParam * ServerBattlefieldMarkerObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getFloatParam
BoolParam * ServerBattlefieldMarkerObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getBoolParam
StringParam * ServerBattlefieldMarkerObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getStringParam
StringIdParam * ServerBattlefieldMarkerObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getStringIdParam
VectorParam * ServerBattlefieldMarkerObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getVectorParam
DynamicVariableParam * ServerBattlefieldMarkerObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getDynamicVariableParam
StructParamOT * ServerBattlefieldMarkerObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerBattlefieldMarkerObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerBattlefieldMarkerObjectTemplate::getTriggerVolumeParam
void ServerBattlefieldMarkerObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
ServerTangibleObjectTemplate::initStructParamOT(param, name);
} // ServerBattlefieldMarkerObjectTemplate::initStructParamOT
void ServerBattlefieldMarkerObjectTemplate::setAsEmptyList(const char *name)
{
ServerTangibleObjectTemplate::setAsEmptyList(name);
} // ServerBattlefieldMarkerObjectTemplate::setAsEmptyList
void ServerBattlefieldMarkerObjectTemplate::setAppend(const char *name)
{
ServerTangibleObjectTemplate::setAppend(name);
} // ServerBattlefieldMarkerObjectTemplate::setAppend
bool ServerBattlefieldMarkerObjectTemplate::isAppend(const char *name) const
{
return ServerTangibleObjectTemplate::isAppend(name);
} // ServerBattlefieldMarkerObjectTemplate::isAppend
int ServerBattlefieldMarkerObjectTemplate::getListLength(const char *name) const
{
return ServerTangibleObjectTemplate::getListLength(name);
} // ServerBattlefieldMarkerObjectTemplate::getListLength
/**
* 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()));
}
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
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerBattlefieldMarkerObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerBattlefieldMarkerObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,0));
file.allowNonlinearFunctions();
int paramCount = 0;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerTangibleObjectTemplate::save(file);
file.exitForm();
UNREF(count);
} // ServerBattlefieldMarkerObjectTemplate::save
//@END TFD
@@ -0,0 +1,88 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@BEGIN TFD
public:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(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 void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerBattlefieldMarkerObjectTemplate(const ServerBattlefieldMarkerObjectTemplate &);
ServerBattlefieldMarkerObjectTemplate & operator =(const ServerBattlefieldMarkerObjectTemplate &);
};
inline void ServerBattlefieldMarkerObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerBattlefieldMarkerObjectTemplate::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerBattlefieldMarkerObjectTemplate_H
@@ -0,0 +1,318 @@
//========================================================================
//
// 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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerBuildingObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerBuildingObjectTemplate::ServerBuildingObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerTangibleObjectTemplate(filename)
//@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
//@BEGIN TFD
CompilerIntegerParam * ServerBuildingObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "maintenanceCost") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_maintenanceCost;
}
fprintf(stderr, "trying to access single-parameter \"maintenanceCost\" as an array\n");
}
else
return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return NULL;
} //ServerBuildingObjectTemplate::getCompilerIntegerParam
FloatParam * ServerBuildingObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getFloatParam
BoolParam * ServerBuildingObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "isPublic") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getBoolParam(name, deepCheck, index);
return NULL;
}
return &m_isPublic;
}
fprintf(stderr, "trying to access single-parameter \"isPublic\" as an array\n");
}
else
return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
return NULL;
} //ServerBuildingObjectTemplate::getBoolParam
StringParam * ServerBuildingObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getStringParam
StringIdParam * ServerBuildingObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getStringIdParam
VectorParam * ServerBuildingObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getVectorParam
DynamicVariableParam * ServerBuildingObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getDynamicVariableParam
StructParamOT * ServerBuildingObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerBuildingObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getTriggerVolumeParam
void ServerBuildingObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
ServerTangibleObjectTemplate::initStructParamOT(param, name);
} // ServerBuildingObjectTemplate::initStructParamOT
void ServerBuildingObjectTemplate::setAsEmptyList(const char *name)
{
ServerTangibleObjectTemplate::setAsEmptyList(name);
} // ServerBuildingObjectTemplate::setAsEmptyList
void ServerBuildingObjectTemplate::setAppend(const char *name)
{
ServerTangibleObjectTemplate::setAppend(name);
} // ServerBuildingObjectTemplate::setAppend
bool ServerBuildingObjectTemplate::isAppend(const char *name) const
{
return ServerTangibleObjectTemplate::isAppend(name);
} // ServerBuildingObjectTemplate::isAppend
int ServerBuildingObjectTemplate::getListLength(const char *name) const
{
return ServerTangibleObjectTemplate::getListLength(name);
} // ServerBuildingObjectTemplate::getListLength
/**
* 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()));
}
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
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerBuildingObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerBuildingObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,1));
file.allowNonlinearFunctions();
int paramCount = 0;
// save maintenanceCost
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maintenanceCost");
m_maintenanceCost.saveToIff(file);
file.exitChunk();
++paramCount;
// save isPublic
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("isPublic");
m_isPublic.saveToIff(file);
file.exitChunk();
++paramCount;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerTangibleObjectTemplate::save(file);
file.exitForm();
UNREF(count);
} // ServerBuildingObjectTemplate::save
//@END TFD
@@ -0,0 +1,90 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@BEGIN TFD
public:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(Iff &file);
private:
CompilerIntegerParam m_maintenanceCost; // The weekly cost (in credits) of maintaining this Building.
BoolParam m_isPublic; // Whether by default the building is flagged public.
//@END TFD
private:
Tag m_templateVersion; // the template version
bool m_versionOk; // flag that the template version loaded is the one we expect
static void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerBuildingObjectTemplate(const ServerBuildingObjectTemplate &);
ServerBuildingObjectTemplate & operator =(const ServerBuildingObjectTemplate &);
};
inline void ServerBuildingObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerBuildingObjectTemplate::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerBuildingObjectTemplate_H
@@ -0,0 +1,266 @@
//========================================================================
//
// 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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerCellObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerCellObjectTemplate::ServerCellObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerObjectTemplate(filename)
//@END TFD INIT
{
} // ServerCellObjectTemplate::ServerCellObjectTemplate
/**
* Class destructor.
*/
ServerCellObjectTemplate::~ServerCellObjectTemplate()
{
//@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
//@BEGIN TFD
CompilerIntegerParam * ServerCellObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getCompilerIntegerParam
FloatParam * ServerCellObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getFloatParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getFloatParam
BoolParam * ServerCellObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getBoolParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getBoolParam
StringParam * ServerCellObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getStringParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getStringParam
StringIdParam * ServerCellObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getStringIdParam
VectorParam * ServerCellObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getVectorParam
DynamicVariableParam * ServerCellObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getDynamicVariableParam
StructParamOT * ServerCellObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerCellObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerCellObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerCellObjectTemplate::getTriggerVolumeParam
void ServerCellObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
ServerObjectTemplate::initStructParamOT(param, name);
} // ServerCellObjectTemplate::initStructParamOT
void ServerCellObjectTemplate::setAsEmptyList(const char *name)
{
ServerObjectTemplate::setAsEmptyList(name);
} // ServerCellObjectTemplate::setAsEmptyList
void ServerCellObjectTemplate::setAppend(const char *name)
{
ServerObjectTemplate::setAppend(name);
} // ServerCellObjectTemplate::setAppend
bool ServerCellObjectTemplate::isAppend(const char *name) const
{
return ServerObjectTemplate::isAppend(name);
} // ServerCellObjectTemplate::isAppend
int ServerCellObjectTemplate::getListLength(const char *name) const
{
return ServerObjectTemplate::getListLength(name);
} // ServerCellObjectTemplate::getListLength
/**
* 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()));
}
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
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerCellObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerCellObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,0));
file.allowNonlinearFunctions();
int paramCount = 0;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerObjectTemplate::save(file);
file.exitForm();
UNREF(count);
} // ServerCellObjectTemplate::save
//@END TFD
@@ -0,0 +1,88 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@BEGIN TFD
public:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(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 void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerCellObjectTemplate(const ServerCellObjectTemplate &);
ServerCellObjectTemplate & operator =(const ServerCellObjectTemplate &);
};
inline void ServerCellObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerCellObjectTemplate::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerCellObjectTemplate_H
@@ -0,0 +1,266 @@
//========================================================================
//
// 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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerCityObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerCityObjectTemplate::ServerCityObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerUniverseObjectTemplate(filename)
//@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
//@BEGIN TFD
CompilerIntegerParam * ServerCityObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getCompilerIntegerParam
FloatParam * ServerCityObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getFloatParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getFloatParam
BoolParam * ServerCityObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getBoolParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getBoolParam
StringParam * ServerCityObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getStringParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getStringParam
StringIdParam * ServerCityObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getStringIdParam
VectorParam * ServerCityObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getVectorParam
DynamicVariableParam * ServerCityObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getDynamicVariableParam
StructParamOT * ServerCityObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerCityObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerCityObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerUniverseObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerCityObjectTemplate::getTriggerVolumeParam
void ServerCityObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
ServerUniverseObjectTemplate::initStructParamOT(param, name);
} // ServerCityObjectTemplate::initStructParamOT
void ServerCityObjectTemplate::setAsEmptyList(const char *name)
{
ServerUniverseObjectTemplate::setAsEmptyList(name);
} // ServerCityObjectTemplate::setAsEmptyList
void ServerCityObjectTemplate::setAppend(const char *name)
{
ServerUniverseObjectTemplate::setAppend(name);
} // ServerCityObjectTemplate::setAppend
bool ServerCityObjectTemplate::isAppend(const char *name) const
{
return ServerUniverseObjectTemplate::isAppend(name);
} // ServerCityObjectTemplate::isAppend
int ServerCityObjectTemplate::getListLength(const char *name) const
{
return ServerUniverseObjectTemplate::getListLength(name);
} // ServerCityObjectTemplate::getListLength
/**
* 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()));
}
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
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerCityObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerCityObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,0));
file.allowNonlinearFunctions();
int paramCount = 0;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerUniverseObjectTemplate::save(file);
file.exitForm();
UNREF(count);
} // ServerCityObjectTemplate::save
//@END TFD
@@ -0,0 +1,88 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@BEGIN TFD
public:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(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 void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerCityObjectTemplate(const ServerCityObjectTemplate &);
ServerCityObjectTemplate & operator =(const ServerCityObjectTemplate &);
};
inline void ServerCityObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerCityObjectTemplate::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerCityObjectTemplate_H
@@ -0,0 +1,266 @@
//========================================================================
//
// 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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerConstructionContractObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerConstructionContractObjectTemplate::ServerConstructionContractObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerIntangibleObjectTemplate(filename)
//@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 the template id.
*
* @return the template id
*/
Tag ServerConstructionContractObjectTemplate::getId(void) const
{
return ServerConstructionContractObjectTemplate_tag;
} // ServerConstructionContractObjectTemplate::getId
/**
* 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
//@BEGIN TFD
CompilerIntegerParam * ServerConstructionContractObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getCompilerIntegerParam
FloatParam * ServerConstructionContractObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getFloatParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getFloatParam
BoolParam * ServerConstructionContractObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getBoolParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getBoolParam
StringParam * ServerConstructionContractObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getStringParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getStringParam
StringIdParam * ServerConstructionContractObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getStringIdParam
VectorParam * ServerConstructionContractObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getVectorParam
DynamicVariableParam * ServerConstructionContractObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getDynamicVariableParam
StructParamOT * ServerConstructionContractObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerConstructionContractObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerIntangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerConstructionContractObjectTemplate::getTriggerVolumeParam
void ServerConstructionContractObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
ServerIntangibleObjectTemplate::initStructParamOT(param, name);
} // ServerConstructionContractObjectTemplate::initStructParamOT
void ServerConstructionContractObjectTemplate::setAsEmptyList(const char *name)
{
ServerIntangibleObjectTemplate::setAsEmptyList(name);
} // ServerConstructionContractObjectTemplate::setAsEmptyList
void ServerConstructionContractObjectTemplate::setAppend(const char *name)
{
ServerIntangibleObjectTemplate::setAppend(name);
} // ServerConstructionContractObjectTemplate::setAppend
bool ServerConstructionContractObjectTemplate::isAppend(const char *name) const
{
return ServerIntangibleObjectTemplate::isAppend(name);
} // ServerConstructionContractObjectTemplate::isAppend
int ServerConstructionContractObjectTemplate::getListLength(const char *name) const
{
return ServerIntangibleObjectTemplate::getListLength(name);
} // ServerConstructionContractObjectTemplate::getListLength
/**
* 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()));
}
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
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerConstructionContractObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerConstructionContractObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,0));
file.allowNonlinearFunctions();
int paramCount = 0;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerIntangibleObjectTemplate::save(file);
file.exitForm();
UNREF(count);
} // ServerConstructionContractObjectTemplate::save
//@END TFD
@@ -0,0 +1,88 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@BEGIN TFD
public:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(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 void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerConstructionContractObjectTemplate(const ServerConstructionContractObjectTemplate &);
ServerConstructionContractObjectTemplate & operator =(const ServerConstructionContractObjectTemplate &);
};
inline void ServerConstructionContractObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerConstructionContractObjectTemplate::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerConstructionContractObjectTemplate_H
@@ -0,0 +1,759 @@
//========================================================================
//
// ServerCreatureObjectTemplate.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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerCreatureObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerCreatureObjectTemplate::ServerCreatureObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerTangibleObjectTemplate(filename)
,m_attribModsLoaded(false)
,m_attribModsAppend(false)
//@END TFD INIT
{
} // ServerCreatureObjectTemplate::ServerCreatureObjectTemplate
/**
* Class destructor.
*/
ServerCreatureObjectTemplate::~ServerCreatureObjectTemplate()
{
//@BEGIN TFD CLEANUP
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_attribMods.begin(); iter != m_attribMods.end(); ++iter)
{
delete *iter;
*iter = NULL;
}
m_attribMods.clear();
}
//@END TFD CLEANUP
} // ServerCreatureObjectTemplate::~ServerCreatureObjectTemplate
/**
* Static function used to register this template.
*/
void ServerCreatureObjectTemplate::registerMe(void)
{
ObjectTemplateList::registerTemplate(ServerCreatureObjectTemplate_tag, create);
} // ServerCreatureObjectTemplate::registerMe
/**
* Creates a ServerCreatureObjectTemplate template.
*
* @return a new instance of the template
*/
ObjectTemplate * ServerCreatureObjectTemplate::create(const std::string & filename)
{
return new ServerCreatureObjectTemplate(filename);
} // ServerCreatureObjectTemplate::create
/**
* Returns the template id.
*
* @return the template id
*/
Tag ServerCreatureObjectTemplate::getId(void) const
{
return ServerCreatureObjectTemplate_tag;
} // ServerCreatureObjectTemplate::getId
/**
* Returns this template's version.
*
* @return the version
*/
Tag ServerCreatureObjectTemplate::getTemplateVersion(void) const
{
return m_templateVersion;
} // ServerCreatureObjectTemplate::getTemplateVersion
/**
* Returns the highest version of this template or it's base templates.
*
* @return the highest version
*/
Tag ServerCreatureObjectTemplate::getHighestTemplateVersion(void) const
{
if (m_baseData == NULL)
return m_templateVersion;
const ServerCreatureObjectTemplate * base = dynamic_cast<const ServerCreatureObjectTemplate *>(m_baseData);
if (base == NULL)
return m_templateVersion;
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerCreatureObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD
CompilerIntegerParam * ServerCreatureObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "attributes") == 0)
{
if (index >= 0 && index < 6)
{
if (deepCheck && !isParamLoaded(name, false, index))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_attributes[index];
}
fprintf(stderr, "index for parameter \"attributes\" out of bounds\n");
}
else if (strcmp(name, "minAttributes") == 0)
{
if (index >= 0 && index < 6)
{
if (deepCheck && !isParamLoaded(name, false, index))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_minAttributes[index];
}
fprintf(stderr, "index for parameter \"minAttributes\" out of bounds\n");
}
else if (strcmp(name, "maxAttributes") == 0)
{
if (index >= 0 && index < 6)
{
if (deepCheck && !isParamLoaded(name, false, index))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_maxAttributes[index];
}
fprintf(stderr, "index for parameter \"maxAttributes\" out of bounds\n");
}
else if (strcmp(name, "shockWounds") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
return NULL;
}
return &m_shockWounds;
}
fprintf(stderr, "trying to access single-parameter \"shockWounds\" as an array\n");
}
else
return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return NULL;
} //ServerCreatureObjectTemplate::getCompilerIntegerParam
FloatParam * ServerCreatureObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "minDrainModifier") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_minDrainModifier;
}
fprintf(stderr, "trying to access single-parameter \"minDrainModifier\" as an array\n");
}
else if (strcmp(name, "maxDrainModifier") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_maxDrainModifier;
}
fprintf(stderr, "trying to access single-parameter \"maxDrainModifier\" as an array\n");
}
else if (strcmp(name, "minFaucetModifier") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_minFaucetModifier;
}
fprintf(stderr, "trying to access single-parameter \"minFaucetModifier\" as an array\n");
}
else if (strcmp(name, "maxFaucetModifier") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_maxFaucetModifier;
}
fprintf(stderr, "trying to access single-parameter \"maxFaucetModifier\" as an array\n");
}
else if (strcmp(name, "approachTriggerRange") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_approachTriggerRange;
}
fprintf(stderr, "trying to access single-parameter \"approachTriggerRange\" as an array\n");
}
else if (strcmp(name, "maxMentalStates") == 0)
{
if (index >= 0 && index < 4)
{
if (deepCheck && !isParamLoaded(name, false, index))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_maxMentalStates[index];
}
fprintf(stderr, "index for parameter \"maxMentalStates\" out of bounds\n");
}
else if (strcmp(name, "mentalStatesDecay") == 0)
{
if (index >= 0 && index < 4)
{
if (deepCheck && !isParamLoaded(name, false, index))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return NULL;
}
return &m_mentalStatesDecay[index];
}
fprintf(stderr, "index for parameter \"mentalStatesDecay\" out of bounds\n");
}
else
return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
return NULL;
} //ServerCreatureObjectTemplate::getFloatParam
BoolParam * ServerCreatureObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "canCreateAvatar") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getBoolParam(name, deepCheck, index);
return NULL;
}
return &m_canCreateAvatar;
}
fprintf(stderr, "trying to access single-parameter \"canCreateAvatar\" as an array\n");
}
else
return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
return NULL;
} //ServerCreatureObjectTemplate::getBoolParam
StringParam * ServerCreatureObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "defaultWeapon") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getStringParam(name, deepCheck, index);
return NULL;
}
return &m_defaultWeapon;
}
fprintf(stderr, "trying to access single-parameter \"defaultWeapon\" as an array\n");
}
else if (strcmp(name, "nameGeneratorType") == 0)
{
if (index == 0)
{
if (deepCheck && !isParamLoaded(name, false, 0))
{
if (getBaseTemplate() != NULL)
return getBaseTemplate()->getStringParam(name, deepCheck, index);
return NULL;
}
return &m_nameGeneratorType;
}
fprintf(stderr, "trying to access single-parameter \"nameGeneratorType\" as an array\n");
}
else
return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
return NULL;
} //ServerCreatureObjectTemplate::getStringParam
StringIdParam * ServerCreatureObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerCreatureObjectTemplate::getStringIdParam
VectorParam * ServerCreatureObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerCreatureObjectTemplate::getVectorParam
DynamicVariableParam * ServerCreatureObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerCreatureObjectTemplate::getDynamicVariableParam
StructParamOT * ServerCreatureObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
if (strcmp(name, "attribMods") == 0)
{
if (index >= 0 && index < static_cast<int>(m_attribMods.size()))
return m_attribMods[index];
if (index == static_cast<int>(m_attribMods.size()))
{
StructParamOT *temp = new StructParamOT();
m_attribMods.push_back(temp);
return temp;
}
fprintf(stderr, "index for parameter \"attribMods\" out of bounds\n");
}
else
return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
return NULL;
} //ServerCreatureObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerCreatureObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerCreatureObjectTemplate::getTriggerVolumeParam
void ServerCreatureObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
if (strcmp(name, "attribMods") == 0)
param.setValue(new _AttribMod(""));
else
ServerTangibleObjectTemplate::initStructParamOT(param, name);
} // ServerCreatureObjectTemplate::initStructParamOT
void ServerCreatureObjectTemplate::setAsEmptyList(const char *name)
{
if (strcmp(name, "attribMods") == 0)
{
m_attribMods.clear();
m_attribModsLoaded = true;
}
else
ServerTangibleObjectTemplate::setAsEmptyList(name);
} // ServerCreatureObjectTemplate::setAsEmptyList
void ServerCreatureObjectTemplate::setAppend(const char *name)
{
if (strcmp(name, "attribMods") == 0)
m_attribModsAppend = true;
else
ServerTangibleObjectTemplate::setAppend(name);
} // ServerCreatureObjectTemplate::setAppend
bool ServerCreatureObjectTemplate::isAppend(const char *name) const
{
if (strcmp(name, "attribMods") == 0)
return m_attribModsAppend;
else
return ServerTangibleObjectTemplate::isAppend(name);
} // ServerCreatureObjectTemplate::isAppend
int ServerCreatureObjectTemplate::getListLength(const char *name) const
{
if (strcmp(name, "attributes") == 0)
{
return sizeof(m_attributes) / sizeof(CompilerIntegerParam);
}
else if (strcmp(name, "minAttributes") == 0)
{
return sizeof(m_minAttributes) / sizeof(CompilerIntegerParam);
}
else if (strcmp(name, "maxAttributes") == 0)
{
return sizeof(m_maxAttributes) / sizeof(CompilerIntegerParam);
}
else if (strcmp(name, "attribMods") == 0)
{
return m_attribMods.size();
}
else if (strcmp(name, "maxMentalStates") == 0)
{
return sizeof(m_maxMentalStates) / sizeof(FloatParam);
}
else if (strcmp(name, "mentalStatesDecay") == 0)
{
return sizeof(m_mentalStatesDecay) / sizeof(FloatParam);
}
else
return ServerTangibleObjectTemplate::getListLength(name);
} // ServerCreatureObjectTemplate::getListLength
/**
* 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 ServerCreatureObjectTemplate::load(Iff &file)
{
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerCreatureObjectTemplate_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,5))
{
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
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, "defaultWeapon") == 0)
m_defaultWeapon.loadFromIff(file);
else if (strcmp(paramName, "attributes") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 6, ("Template %s: read array size of %d for array \"attributes\" of size 6, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 6 && j < listCount; ++j)
m_attributes[j].loadFromIff(file);
// if there are more params for attributes read and dump them
for (; j < listCount; ++j)
{
CompilerIntegerParam dummy;
dummy.loadFromIff(file);
}
}
else if (strcmp(paramName, "minAttributes") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 6, ("Template %s: read array size of %d for array \"minAttributes\" of size 6, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 6 && j < listCount; ++j)
m_minAttributes[j].loadFromIff(file);
// if there are more params for minAttributes read and dump them
for (; j < listCount; ++j)
{
CompilerIntegerParam dummy;
dummy.loadFromIff(file);
}
}
else if (strcmp(paramName, "maxAttributes") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 6, ("Template %s: read array size of %d for array \"maxAttributes\" of size 6, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 6 && j < listCount; ++j)
m_maxAttributes[j].loadFromIff(file);
// if there are more params for maxAttributes read and dump them
for (; j < listCount; ++j)
{
CompilerIntegerParam dummy;
dummy.loadFromIff(file);
}
}
else if (strcmp(paramName, "minDrainModifier") == 0)
m_minDrainModifier.loadFromIff(file);
else if (strcmp(paramName, "maxDrainModifier") == 0)
m_maxDrainModifier.loadFromIff(file);
else if (strcmp(paramName, "minFaucetModifier") == 0)
m_minFaucetModifier.loadFromIff(file);
else if (strcmp(paramName, "maxFaucetModifier") == 0)
m_maxFaucetModifier.loadFromIff(file);
else if (strcmp(paramName, "attribMods") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_attribMods.begin(); iter != m_attribMods.end(); ++iter)
{
delete *iter;
*iter = NULL;
}
m_attribMods.clear();
m_attribModsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_attribMods.push_back(newData);
}
m_attribModsLoaded = true;
}
else if (strcmp(paramName, "shockWounds") == 0)
m_shockWounds.loadFromIff(file);
else if (strcmp(paramName, "canCreateAvatar") == 0)
m_canCreateAvatar.loadFromIff(file);
else if (strcmp(paramName, "nameGeneratorType") == 0)
m_nameGeneratorType.loadFromIff(file);
else if (strcmp(paramName, "approachTriggerRange") == 0)
m_approachTriggerRange.loadFromIff(file);
else if (strcmp(paramName, "maxMentalStates") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 4, ("Template %s: read array size of %d for array \"maxMentalStates\" of size 4, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 4 && j < listCount; ++j)
m_maxMentalStates[j].loadFromIff(file);
// if there are more params for maxMentalStates read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
}
else if (strcmp(paramName, "mentalStatesDecay") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 4, ("Template %s: read array size of %d for array \"mentalStatesDecay\" of size 4, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 4 && j < listCount; ++j)
m_mentalStatesDecay[j].loadFromIff(file);
// if there are more params for mentalStatesDecay read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
}
file.exitChunk(true);
}
file.exitForm();
ServerTangibleObjectTemplate::load(file);
file.exitForm();
return;
} // ServerCreatureObjectTemplate::load
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerCreatureObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerCreatureObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,5));
file.allowNonlinearFunctions();
int paramCount = 0;
// save defaultWeapon
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("defaultWeapon");
m_defaultWeapon.saveToIff(file);
file.exitChunk();
++paramCount;
// save attributes
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("attributes");
count = 6;
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 6; ++i)
m_attributes[i].saveToIff(file);}
file.exitChunk();
++paramCount;
// save minAttributes
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("minAttributes");
count = 6;
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 6; ++i)
m_minAttributes[i].saveToIff(file);}
file.exitChunk();
++paramCount;
// save maxAttributes
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxAttributes");
count = 6;
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 6; ++i)
m_maxAttributes[i].saveToIff(file);}
file.exitChunk();
++paramCount;
// save minDrainModifier
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("minDrainModifier");
m_minDrainModifier.saveToIff(file);
file.exitChunk();
++paramCount;
// save maxDrainModifier
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxDrainModifier");
m_maxDrainModifier.saveToIff(file);
file.exitChunk();
++paramCount;
// save minFaucetModifier
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("minFaucetModifier");
m_minFaucetModifier.saveToIff(file);
file.exitChunk();
++paramCount;
// save maxFaucetModifier
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxFaucetModifier");
m_maxFaucetModifier.saveToIff(file);
file.exitChunk();
++paramCount;
if (!m_attribModsLoaded)
{
// mark the list as empty and extending the base list
m_attribModsAppend = true;
}
// save attribMods
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("attribMods");
file.insertChunkData(&m_attribModsAppend, sizeof(bool));
count = m_attribMods.size();
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < count; ++i)
m_attribMods[i]->saveToIff(file);}
file.exitChunk();
++paramCount;
// save shockWounds
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("shockWounds");
m_shockWounds.saveToIff(file);
file.exitChunk();
++paramCount;
// save canCreateAvatar
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("canCreateAvatar");
m_canCreateAvatar.saveToIff(file);
file.exitChunk();
++paramCount;
// save nameGeneratorType
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("nameGeneratorType");
m_nameGeneratorType.saveToIff(file);
file.exitChunk();
++paramCount;
// save approachTriggerRange
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("approachTriggerRange");
m_approachTriggerRange.saveToIff(file);
file.exitChunk();
++paramCount;
// save maxMentalStates
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxMentalStates");
count = 4;
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 4; ++i)
m_maxMentalStates[i].saveToIff(file);}
file.exitChunk();
++paramCount;
// save mentalStatesDecay
file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("mentalStatesDecay");
count = 4;
file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 4; ++i)
m_mentalStatesDecay[i].saveToIff(file);}
file.exitChunk();
++paramCount;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerTangibleObjectTemplate::save(file);
file.exitForm();
} // ServerCreatureObjectTemplate::save
//@END TFD
@@ -0,0 +1,122 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@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:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(Iff &file);
private:
//Creature Attributes
StringParam m_defaultWeapon; // //weapon to use if none is equipped
CompilerIntegerParam m_attributes[6]; // //initial value for attributes
CompilerIntegerParam m_minAttributes[6]; // //minimum value for attributes
CompilerIntegerParam 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;
CompilerIntegerParam 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
private:
Tag m_templateVersion; // the template version
bool m_versionOk; // flag that the template version loaded is the one we expect
static void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerCreatureObjectTemplate(const ServerCreatureObjectTemplate &);
ServerCreatureObjectTemplate & operator =(const ServerCreatureObjectTemplate &);
};
inline void ServerCreatureObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerCreatureObjectTemplate::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerCreatureObjectTemplate_H
@@ -0,0 +1,170 @@
//========================================================================
//
// 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 "sharedTemplateDefinition/TpfTemplate.h"
class Vector;
typedef StructParam<ObjectTemplate> StructParamOT;
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(void);
//@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 TpfTemplate
{
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:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(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:
virtual CompilerIntegerParam *getCompilerIntegerParam(const char *name, bool deepCheck = true, int index = 0);
virtual FloatParam *getFloatParam(const char *name, bool deepCheck = true, int index = 0);
virtual BoolParam *getBoolParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringParam *getStringParam(const char *name, bool deepCheck = true, int index = 0);
virtual StringIdParam *getStringIdParam(const char *name, bool deepCheck = true, int index = 0);
virtual VectorParam *getVectorParam(const char *name, bool deepCheck = true, int index = 0);
virtual DynamicVariableParam *getDynamicVariableParam(const char *name, bool deepCheck = true, int index = 0);
virtual StructParamOT *getStructParamOT(const char *name, bool deepCheck = true, int index = 0);
virtual TriggerVolumeParam *getTriggerVolumeParam(const char *name, bool deepCheck = true, int index = 0);
virtual void initStructParamOT(StructParamOT &param, const char *name);
virtual void setAsEmptyList(const char *name);
virtual void setAppend(const char *name);
virtual bool isAppend(const char *name) const;
virtual int getListLength(const char *name) const;
protected:
virtual void load(Iff &file);
virtual void save(Iff &file);
private:
CompilerIntegerParam 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;
CompilerIntegerParam 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
private:
Tag m_templateVersion; // the template version
bool m_versionOk; // flag that the template version loaded is the one we expect
static void registerMe(void);
static ObjectTemplate * create(const std::string & filename);
// no copying
ServerDraftSchematicObjectTemplate(const ServerDraftSchematicObjectTemplate &);
ServerDraftSchematicObjectTemplate & operator =(const ServerDraftSchematicObjectTemplate &);
};
inline void ServerDraftSchematicObjectTemplate::install(void)
{
//@BEGIN TFD INSTALL
ServerDraftSchematicObjectTemplate::registerMe();
ServerDraftSchematicObjectTemplate::_IngredientSlot::registerMe();
//@END TFD INSTALL
}
#endif // _INCLUDED_ServerDraftSchematicObjectTemplate_H
@@ -0,0 +1,266 @@
//========================================================================
//
// 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 "sharedTemplate/FirstSharedTemplate.h"
#include "sharedTemplateDefinition/TemplateData.h"
#include "sharedTemplateDefinition/TemplateGlobals.h"
#include "ServerFactoryObjectTemplate.h"
#include "sharedDebug/DataLint.h"
#include "sharedFile/Iff.h"
#include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h>
/**
* Class constructor.
*/
ServerFactoryObjectTemplate::ServerFactoryObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerTangibleObjectTemplate(filename)
//@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
//@BEGIN TFD
CompilerIntegerParam * ServerFactoryObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getCompilerIntegerParam
FloatParam * ServerFactoryObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getFloatParam
BoolParam * ServerFactoryObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getBoolParam
StringParam * ServerFactoryObjectTemplate::getStringParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getStringParam
StringIdParam * ServerFactoryObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getStringIdParam
VectorParam * ServerFactoryObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getVectorParam
DynamicVariableParam * ServerFactoryObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getDynamicVariableParam
StructParamOT * ServerFactoryObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerFactoryObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index)
{
return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerFactoryObjectTemplate::getTriggerVolumeParam
void ServerFactoryObjectTemplate::initStructParamOT(StructParamOT &param, const char *name)
{
if (param.isInitialized())
return;
ServerTangibleObjectTemplate::initStructParamOT(param, name);
} // ServerFactoryObjectTemplate::initStructParamOT
void ServerFactoryObjectTemplate::setAsEmptyList(const char *name)
{
ServerTangibleObjectTemplate::setAsEmptyList(name);
} // ServerFactoryObjectTemplate::setAsEmptyList
void ServerFactoryObjectTemplate::setAppend(const char *name)
{
ServerTangibleObjectTemplate::setAppend(name);
} // ServerFactoryObjectTemplate::setAppend
bool ServerFactoryObjectTemplate::isAppend(const char *name) const
{
return ServerTangibleObjectTemplate::isAppend(name);
} // ServerFactoryObjectTemplate::isAppend
int ServerFactoryObjectTemplate::getListLength(const char *name) const
{
return ServerTangibleObjectTemplate::getListLength(name);
} // ServerFactoryObjectTemplate::getListLength
/**
* 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()));
}
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
/**
* Saves the template data to an iff file.
*
* @param file file to save to
* @param location file type (client or server)
*/
void ServerFactoryObjectTemplate::save(Iff &file)
{
int count;
file.insertForm(ServerFactoryObjectTemplate_tag);
if (m_baseTemplateName.size() != 0)
{
file.insertForm(TAG(D,E,R,V));
file.insertChunk(TAG(X, X, X, X));
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.exitChunk();
file.exitForm();
}
file.insertForm(TAG(0,0,0,0));
file.allowNonlinearFunctions();
int paramCount = 0;
// write number of parameters
file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk();
file.exitForm(true);
ServerTangibleObjectTemplate::save(file);
file.exitForm();
UNREF(count);
} // ServerFactoryObjectTemplate::save
//@END TFD

Some files were not shown because too many files have changed in this diff Show More