Merge remote-tracking branch 'local/testing'

This commit is contained in:
DarthArgus
2019-03-03 21:35:12 +00:00
114 changed files with 14597 additions and 14758 deletions
+3 -3
View File
@@ -29,8 +29,8 @@ find_package(Threads)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(CURL REQUIRED) find_package(CURL REQUIRED)
# c++14 yeah! # c++17 yeah!
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
@@ -105,7 +105,7 @@ elseif (UNIX)
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program-vtables") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program-vtables")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# O3 and Ofast include one or more flags that cause java to crash when using gcc6 # O3 and Ofast include one or more flags that cause java to crash when using gcc6
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize -fno-plt")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
+3 -2
View File
@@ -1,2 +1,3 @@
if (DEFINED _MIFF OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_subdirectory(application) add_subdirectory(application)
endif()
@@ -1,3 +1,5 @@
#include <signal.h>
#include "sharedFoundation/FirstSharedFoundation.h" #include "sharedFoundation/FirstSharedFoundation.h"
#include "ConfigCentralServer.h" #include "ConfigCentralServer.h"
@@ -12,17 +14,29 @@
#include "sharedRandom/SetupSharedRandom.h" #include "sharedRandom/SetupSharedRandom.h"
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
#ifndef STELLA_INTERNAL #ifdef ENABLE_PROFILING
#include "webAPIHeartbeat.h" extern "C" int __llvm_profile_write_file(void);
#endif #endif
inline void signalHandler(int s){
printf("PlanetServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
// ====================================================================== // ======================================================================
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
#ifndef STELLA_INTERNAL struct sigaction sigIntHandler;
StellaBellum::webAPIHeartbeat(); sigIntHandler.sa_handler = signalHandler;
#endif sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -60,6 +74,7 @@ int main(int argc, char ** argv)
SetupSharedFoundation::remove(); SetupSharedFoundation::remove();
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0); exit(0);
#endif #endif
@@ -1233,7 +1233,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons
DEBUG_REPORT_LOG(true, ("Pending character %lu is logging in or dropping\n", m.getAccountNumber())); DEBUG_REPORT_LOG(true, ("Pending character %lu is logging in or dropping\n", m.getAccountNumber()));
// Once they're logged in, Central doesn't need to know about them anymore: // Once they're logged in, Central doesn't need to know about them anymore:
removeSuidFromAccountConnectionMap(m.getAccountNumber()); removeFromAccountConnectionMap(m.getAccountNumber());
break; break;
} }
case constcrc("CharacterListMessage") : { case constcrc("CharacterListMessage") : {
@@ -1998,7 +1998,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons
break; break;
} }
case constcrc("DatabaseSaveStart") : { case constcrc("DatabaseSaveStart") : {
LOG("CentralServer", ("Received DatabaseSaveStart network message.")); //LOG("CentralServer", ("Received DatabaseSaveStart network message."));
if (m_shutdownPhase == 4) { if (m_shutdownPhase == 4) {
LOG("CentralServerShutdown", ("Shutdown Phase %d: Setting indicator for receipt of DatabaseSaveStart.", m_shutdownPhase)); LOG("CentralServerShutdown", ("Shutdown Phase %d: Setting indicator for receipt of DatabaseSaveStart.", m_shutdownPhase));
m_shutdownHaveDatabaseSaveStart = true; m_shutdownHaveDatabaseSaveStart = true;
@@ -2014,7 +2014,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons
case constcrc("DatabaseSaveComplete") : { case constcrc("DatabaseSaveComplete") : {
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin(); Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
GenericValueTypeMessage<int> msg(ri); GenericValueTypeMessage<int> msg(ri);
LOG("CentralServer", ("Received DatabaseSaveComplete network message.")); //LOG("CentralServer", ("Received DatabaseSaveComplete network message."));
// tell all the Planet Servers that the save finished // tell all the Planet Servers that the save finished
sendToAllPlanetServers(msg, true); sendToAllPlanetServers(msg, true);
@@ -3419,7 +3419,7 @@ void CentralServer::addToAccountConnectionMap(StationId suid, ConnectionServerCo
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void CentralServer::removeSuidFromAccountConnectionMap(StationId suid) void CentralServer::removeFromAccountConnectionMap(StationId suid)
{ {
ConnectionServerSUIDMap::iterator i=m_accountConnectionMap.find(suid); ConnectionServerSUIDMap::iterator i=m_accountConnectionMap.find(suid);
if (i!=m_accountConnectionMap.end()) if (i!=m_accountConnectionMap.end())
@@ -169,7 +169,7 @@ public:
void getCharacterMatchStatistics(int & numberOfCharacterMatchRequests, int & numberOfCharacterMatchResultsPerRequest, int & timeSpentPerCharacterMatchRequestMs); void getCharacterMatchStatistics(int & numberOfCharacterMatchRequests, int & numberOfCharacterMatchResultsPerRequest, int & timeSpentPerCharacterMatchRequestMs);
void removeSuidFromAccountConnectionMap(StationId suid); void removeFromAccountConnectionMap(StationId suid);
private: private:
void handleRequestGameServerForLoginMessage (const RequestGameServerForLoginMessage & msg); void handleRequestGameServerForLoginMessage (const RequestGameServerForLoginMessage & msg);
@@ -254,7 +254,7 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message)
s_pseudoClientConnectionMap[info.getValue().first] = std::make_pair(static_cast<TransferRequestMoveValidation::TransferRequestSource>(info.getValue().second), this); s_pseudoClientConnectionMap[info.getValue().first] = std::make_pair(static_cast<TransferRequestMoveValidation::TransferRequestSource>(info.getValue().second), this);
// remove corresponding "non pseudo client connection" // remove corresponding "non pseudo client connection"
CentralServer::getInstance().removeSuidFromAccountConnectionMap(static_cast<StationId>(info.getValue().first)); CentralServer::getInstance().removeFromAccountConnectionMap(static_cast<StationId>(info.getValue().first));
break; break;
} }
case constcrc("DestroyPseudoClientConnection") : case constcrc("DestroyPseudoClientConnection") :
@@ -12,10 +12,31 @@
#include "sharedRandom/SetupSharedRandom.h" #include "sharedRandom/SetupSharedRandom.h"
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
#ifdef ENABLE_PROFILING
extern "C" int __llvm_profile_write_file(void);
#endif
inline void signalHandler(int s){
printf("PlanetServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
// ====================================================================== // ======================================================================
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = signalHandler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -40,6 +61,7 @@ int main(int argc, char ** argv)
SetupSharedFoundation::remove(); SetupSharedFoundation::remove();
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0); exit(0);
#endif #endif
@@ -3,6 +3,7 @@
// Author: Justin Randall // Author: Justin Randall
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
#include <signal.h>
#include "FirstCommodityServer.h" #include "FirstCommodityServer.h"
@@ -27,10 +28,30 @@
#include "LocalizationManager.h" #include "LocalizationManager.h"
#include "UnicodeUtils.h" #include "UnicodeUtils.h"
#ifdef ENABLE_PROFILING
extern "C" int __llvm_profile_write_file(void);
#endif
inline void signalHandler(int s){
printf("CommoditiesServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = signalHandler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -74,6 +95,10 @@ int main(int argc, char ** argv)
SetupSharedFoundation::remove(); SetupSharedFoundation::remove();
SetupSharedThread::remove(); SetupSharedThread::remove();
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0);
#endif
return 0; return 0;
} }
@@ -1,3 +1,5 @@
#include <signal.h>
#include "FirstConnectionServer.h" #include "FirstConnectionServer.h"
#include "ConfigConnectionServer.h" #include "ConfigConnectionServer.h"
#include "ConnectionServer.h" #include "ConnectionServer.h"
@@ -12,10 +14,20 @@
#include "sharedRandom/SetupSharedRandom.h" #include "sharedRandom/SetupSharedRandom.h"
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
#ifndef STELLA_INTERNAL #ifdef ENABLE_PROFILING
#include "webAPIHeartbeat.h" extern "C" int __llvm_profile_write_file(void);
#endif #endif
inline void signalHandler(int s){
printf("ConnectionServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
// ====================================================================== // ======================================================================
void dumpPid(const char * argv) void dumpPid(const char * argv)
@@ -29,9 +41,11 @@ void dumpPid(const char * argv)
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
#ifndef STELLA_INTERNAL struct sigaction sigIntHandler;
StellaBellum::webAPIHeartbeat(); sigIntHandler.sa_handler = signalHandler;
#endif sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -63,7 +77,7 @@ int main(int argc, char ** argv)
SetupSharedThread::remove(); SetupSharedThread::remove();
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
exit(0); __llvm_profile_write_file();
#endif #endif
return 0; return 0;
@@ -161,7 +161,7 @@ void ConnectionServer::addGameConnection(unsigned long gameServerId, GameConnect
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
bool bool
ConnectionServer::decryptToken(const KeyShare::Token &token, StationId &stationUserId, bool &secure, std::string &accountName) { ConnectionServer::decryptToken(const KeyShare::Token &token, uint32 &stationUserId, bool &secure, std::string &accountName) {
static ConnectionServer &cs = instance(); static ConnectionServer &cs = instance();
//Also the sizeof(int) is likewise magic from the session api //Also the sizeof(int) is likewise magic from the session api
@@ -179,7 +179,7 @@ ConnectionServer::decryptToken(const KeyShare::Token &token, StationId &stationU
char *tmpBuffer = new char[MAX_ACCOUNT_NAME_LENGTH + 1]; char *tmpBuffer = new char[MAX_ACCOUNT_NAME_LENGTH + 1];
memset(tmpBuffer, 0, MAX_ACCOUNT_NAME_LENGTH + 1); memset(tmpBuffer, 0, MAX_ACCOUNT_NAME_LENGTH + 1);
memcpy(&stationUserId, keyBufferPointer, sizeof(StationId)); memcpy(&stationUserId, keyBufferPointer, sizeof(uint32));
keyBufferPointer += sizeof(uint32); keyBufferPointer += sizeof(uint32);
memcpy(&secure, keyBufferPointer, sizeof(bool)); memcpy(&secure, keyBufferPointer, sizeof(bool));
keyBufferPointer += sizeof(bool); keyBufferPointer += sizeof(bool);
@@ -48,7 +48,7 @@ class ConnectionServer : public MessageDispatch::Receiver
static void addNewClient(ClientConnection* cconn, const NetworkId &oid, GameConnection* gconn, const std::string &sceneName, bool sendToStarport ); static void addNewClient(ClientConnection* cconn, const NetworkId &oid, GameConnection* gconn, const std::string &sceneName, bool sendToStarport );
static void addConnectedClient(uint32 suid, ClientConnection* conn); static void addConnectedClient(uint32 suid, ClientConnection* conn);
static void addGameConnection(unsigned long gameServerId, GameConnection* gc); static void addGameConnection(unsigned long gameServerId, GameConnection* gc);
static bool decryptToken(const KeyShare::Token & token, StationId & stationUserId, bool & secure, std::string & accountName); static bool decryptToken(const KeyShare::Token & token, uint32 & stationUserId, bool & secure, std::string & accountName);
static bool decryptToken(const KeyShare::Token & token, char* sessionKey, StationId & stationId); static bool decryptToken(const KeyShare::Token & token, char* sessionKey, StationId & stationId);
static CentralConnection * getCentralConnection(); static CentralConnection * getCentralConnection();
static void dropClient(ClientConnection * conn, const std::string &description); static void dropClient(ClientConnection * conn, const std::string &description);
@@ -6,6 +6,8 @@
// //
// ====================================================================== // ======================================================================
#include <signal.h>
#include "sharedFoundation/FirstSharedFoundation.h" #include "sharedFoundation/FirstSharedFoundation.h"
#include "LogServer.h" #include "LogServer.h"
@@ -17,16 +19,30 @@
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" #include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
#ifndef STELLA_INTERNAL #ifdef ENABLE_PROFILING
#include "webAPIHeartbeat.h" extern "C" int __llvm_profile_write_file(void);
#endif #endif
inline void signalHandler(int s){
printf("LogServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
// ====================================================================== // ======================================================================
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifndef STELLA_INTERNAL struct sigaction sigIntHandler;
StellaBellum::webAPIHeartbeat(); sigIntHandler.sa_handler = signalHandler;
#endif sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -55,9 +71,9 @@ int main(int argc, char **argv)
SetupSharedThread::remove(); SetupSharedThread::remove();
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0); exit(0);
#endif #endif
return 0; return 0;
} }
@@ -1,9 +1,6 @@
#include "sharedFoundation/FirstSharedFoundation.h"
#ifdef ENABLE_PROFILING
#include <signal.h> #include <signal.h>
#endif
#include "sharedFoundation/FirstSharedFoundation.h"
#include "ConfigLoginServer.h" #include "ConfigLoginServer.h"
#include "LoginServer.h" #include "LoginServer.h"
@@ -17,23 +14,28 @@
#include "sharedRandom/SetupSharedRandom.h" #include "sharedRandom/SetupSharedRandom.h"
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
// ======================================================================
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
inline void signalHandler(int s){ extern "C" int __llvm_profile_write_file(void);
printf("LoginServer terminating, signal %d\n",s);
exit(0);
}
#endif #endif
int main(int argc, char **argv) { // ======================================================================
inline void signalHandler(int s){
printf("LoginServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
int main(int argc, char **argv) {
struct sigaction sigIntHandler; struct sigaction sigIntHandler;
sigIntHandler.sa_handler = signalHandler; sigIntHandler.sa_handler = signalHandler;
sigemptyset(&sigIntHandler.sa_mask); sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0; sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL); sigaction(SIGINT, &sigIntHandler, NULL);
#endif
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -63,5 +65,9 @@ int main(int argc, char **argv) {
SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run); SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run);
SetupSharedFoundation::remove(); SetupSharedFoundation::remove();
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0);
#endif
return 0; return 0;
} }
@@ -154,6 +154,7 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
bool authOK = false; bool authOK = false;
bool testMode = false; bool testMode = false;
static const std::string authURL(ConfigLoginServer::getExternalAuthUrl()); static const std::string authURL(ConfigLoginServer::getExternalAuthUrl());
static const bool useSimpleAuth = ConfigLoginServer::getUseSimpleAuth();
std::string uname; std::string uname;
std::string parentAccount; std::string parentAccount;
@@ -161,55 +162,90 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
StationId user_id; StationId user_id;
StationId parent_id; StationId parent_id;
std::unordered_map<StationId, std::string> childAccounts; std::unordered_map<int, std::string> childAccounts;
if (!authURL.empty()) { if (!authURL.empty()) {
// create the object // create the object
webAPI api(authURL); webAPI api(authURL);
// add our data if (useSimpleAuth) {
api.addJsonData<std::string>("user_name", id); if (!user_id) {
api.addJsonData<std::string>("user_password", key); uname = id;
api.addJsonData<std::string>("ip", getRemoteAddress());
if (api.submit()) { if (uname.length() > MAX_ACCOUNT_NAME_LENGTH) {
bool status = api.getNullableValue<bool>("status"); uname.resize(MAX_ACCOUNT_NAME_LENGTH);
uname = api.getString("username"); }
sessionID = api.getString("session_key");
if (status && !sessionID.empty() && !uname.empty()) { user_id = std::hash < std::string > {}(uname.c_str());
authOK = true; }
parentAccount = api.getString("mainAccount"); std::ostringstream postBuf;
childAccounts = api.getStringMap64("subAccounts"); postBuf << "user_name=" << id << "&user_password=" << key << "&stationID=" << user_id << "&ip=" << getRemoteAddress();
std::string postData = postBuf.str();
if (!ConfigLoginServer::getUseOldSuidGenerator()) { bool done = api.setData(postData);
user_id = static_cast<StationId>(api.getNullableValue<StationId>("user_id")); if (done) {
parent_id = static_cast<StationId>(api.getNullableValue<StationId>("parent_id")); done = api.submit(1,1,1);
}
if (done) {
std::string response = api.getRaw();
if (response == "success") {
authOK = true;
} else { } else {
if (parentAccount.length() > MAX_ACCOUNT_NAME_LENGTH) { ErrorMessage err("Login Failed", response);
parentAccount.resize(MAX_ACCOUNT_NAME_LENGTH); this->send(err, true);
}
if (uname.length() > MAX_ACCOUNT_NAME_LENGTH) {
uname.resize(MAX_ACCOUNT_NAME_LENGTH);
}
parent_id = std::hash < std::string > {}(parentAccount.c_str());
user_id = std::hash < std::string > {}(uname.c_str());
} }
} else { } else {
std::string msg(api.getString("message")); ErrorMessage err("Failed to contact auth provider", "Please contact a server admin");
if (msg.empty()) {
msg = "Invalid username or password.";
}
ErrorMessage err("Login Failed", msg);
this->send(err, true); this->send(err, true);
} }
} else { } else {
ErrorMessage err("Login Failed", "Could not connect to remote."); // add our data
this->send(err, true); api.addJsonData<std::string>("user_name", id);
api.addJsonData<std::string>("user_password", key);
api.addJsonData<std::string>("ip", getRemoteAddress());
if (api.submit()) {
bool status = api.getNullableValue<bool>("status");
uname = api.getString("username");
sessionID = api.getString("session_key");
if (status && !sessionID.empty() && !uname.empty()) {
authOK = true;
parentAccount = api.getString("mainAccount");
childAccounts = api.getStringMap("subAccounts");
if (!ConfigLoginServer::getUseOldSuidGenerator()) {
user_id = static_cast<StationId>(api.getNullableValue<StationId>("user_id"));
parent_id = static_cast<StationId>(api.getNullableValue<StationId>("parent_id"));
} else {
if (parentAccount.length() > MAX_ACCOUNT_NAME_LENGTH) {
parentAccount.resize(MAX_ACCOUNT_NAME_LENGTH);
}
if (uname.length() > MAX_ACCOUNT_NAME_LENGTH) {
uname.resize(MAX_ACCOUNT_NAME_LENGTH);
}
parent_id = std::hash < std::string > {}(parentAccount.c_str());
user_id = std::hash < std::string > {}(uname.c_str());
}
} else {
std::string msg(api.getString("message"));
if (msg.empty()) {
msg = "Invalid username or password.";
}
ErrorMessage err("Login Failed", msg);
this->send(err, true);
}
} else {
ErrorMessage err("Login Failed", "Could not connect to remote.");
this->send(err, true);
}
} }
} else { } else {
// test mode // test mode
@@ -230,36 +266,41 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
if (!testMode) { if (!testMode) {
REPORT_LOG(true, ("Client connected. Username: %s (%i) \n", uname.c_str(), user_id)); REPORT_LOG(true, ("Client connected. Username: %s (%i) \n", uname.c_str(), user_id));
if (!parentAccount.empty()) { if (!useSimpleAuth) {
if (parentAccount != uname) { if (!parentAccount.empty()) {
REPORT_LOG(true, ("\t%s's parent is %s (%i) \n", uname.c_str(), parentAccount.c_str(), parent_id)); if (parentAccount != uname) {
} REPORT_LOG(true,
} else { ("\t%s's parent is %s (%i) \n", uname.c_str(), parentAccount.c_str(), parent_id));
parentAccount = "(Empty Parent!) " + uname;
}
for (auto i : childAccounts) {
StationId child_id = static_cast<StationId>(i.first);
std::string child(i.second);
if (!child.empty() && i.first > 0) {
if (ConfigLoginServer::getUseOldSuidGenerator()) {
if (child.length() > MAX_ACCOUNT_NAME_LENGTH) {
child.resize(MAX_ACCOUNT_NAME_LENGTH);
}
child_id = std::hash < std::string > {}(child.c_str());
}
REPORT_LOG((parent_id !=
child_id), ("\tchild of %s (%i) is %s (%i) \n", parentAccount.c_str(), parent_id, child.c_str(), child_id));
// insert all related accounts, if not already there, into the db
if (parent_id != child_id) {
DatabaseConnection::getInstance().upsertAccountRelationship(parent_id, child_id);
} }
} else { } else {
WARNING(true, ("Login API returned empty child account(s).")); parentAccount = "(Empty Parent!) " + uname;
}
for (auto i : childAccounts) {
StationId child_id = static_cast<StationId>(i.first);
std::string child(i.second);
if (!child.empty() && i.first > 0) {
if (ConfigLoginServer::getUseOldSuidGenerator()) {
if (child.length() > MAX_ACCOUNT_NAME_LENGTH) {
child.resize(MAX_ACCOUNT_NAME_LENGTH);
}
child_id = std::hash < std::string > {}(child.c_str());
}
REPORT_LOG((parent_id !=
child_id),
("\tchild of %s (%i) is %s (%i) \n", parentAccount.c_str(), parent_id, child.c_str(), child_id));
// insert all related accounts, if not already there, into the db
if (parent_id != child_id) {
DatabaseConnection::getInstance().upsertAccountRelationship(parent_id, child_id);
}
} else {
WARNING(true, ("Login API returned empty child account(s)."));
}
} }
} }
@@ -74,20 +74,6 @@ private:
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// stolen from http://www.codeproject.com/Articles/10880/A-trim-implementation-for-std-string
// i'm rusty and haven't gotten to lambdas yet
inline const std::string trim(std::string str)
{
str.erase(str.begin(), std::find_if(str.begin(), str.end(),
[](char& ch)->bool { return !isspace(ch); }));
str.erase(std::find_if(str.rbegin(), str.rend(),
[](char& ch)->bool { return !isspace(ch); }).base(), str.end());
return str;
}
//-----------------------------------------------------------------------
inline const StationId ClientConnection::getStationId() const inline const StationId ClientConnection::getStationId() const
{ {
return m_stationId; return m_stationId;
@@ -87,6 +87,7 @@ void ConfigLoginServer::install(void)
KEY_INT (maxCharactersPerAccount, 20); KEY_INT (maxCharactersPerAccount, 20);
KEY_BOOL (validateClientVersion, true); KEY_BOOL (validateClientVersion, true);
KEY_BOOL (validateStationKey, false); KEY_BOOL (validateStationKey, false);
KEY_BOOL (easyExternalAccess, false);
KEY_BOOL (doSessionLogin, false); KEY_BOOL (doSessionLogin, false);
KEY_BOOL (doConsumption, false); KEY_BOOL (doConsumption, false);
KEY_STRING (sessionServers, "localhost:3004"); KEY_STRING (sessionServers, "localhost:3004");
@@ -116,6 +117,7 @@ void ConfigLoginServer::install(void)
KEY_BOOL(requireSecureLoginForCsTool, true); KEY_BOOL(requireSecureLoginForCsTool, true);
KEY_BOOL(useExternalAuth, false); KEY_BOOL(useExternalAuth, false);
KEY_STRING(externalAuthURL, ""); KEY_STRING(externalAuthURL, "");
KEY_BOOL(useSimpleAuth, true);
KEY_BOOL(useOldSuidGenerator, false); KEY_BOOL(useOldSuidGenerator, false);
int index = 0; int index = 0;
@@ -20,6 +20,7 @@ class ConfigLoginServer
int httpServicePort; int httpServicePort;
bool validateClientVersion; bool validateClientVersion;
bool validateStationKey; bool validateStationKey;
bool easyExternalAccess;
bool doSessionLogin; bool doSessionLogin;
bool doConsumption; bool doConsumption;
const char * sessionServers; const char * sessionServers;
@@ -64,12 +65,13 @@ class ConfigLoginServer
int populationLightThresholdPercent; int populationLightThresholdPercent;
int csToolPort; int csToolPort;
bool requireSecureLoginForCsTool; bool requireSecureLoginForCsTool;
bool useExternalAuth; bool useExternalAuth;
bool useSimpleAuth;
const char * externalAuthURL; const char * externalAuthURL;
bool useOldSuidGenerator; bool useOldSuidGenerator;
}; };
static const uint16 getCentralServicePort(); static const uint16 getCentralServicePort();
@@ -80,6 +82,7 @@ class ConfigLoginServer
static const uint16 getHttpServicePort(); static const uint16 getHttpServicePort();
static const bool getValidateClientVersion(); static const bool getValidateClientVersion();
static const bool getValidateStationKey(); static const bool getValidateStationKey();
static const bool getEasyExternalAccess();
static const bool getDoSessionLogin(); static const bool getDoSessionLogin();
static const bool getDoConsumption(); static const bool getDoConsumption();
static const char * getSessionServers(); static const char * getSessionServers();
@@ -132,8 +135,9 @@ class ConfigLoginServer
static int getPopulationMediumThresholdPercent(); static int getPopulationMediumThresholdPercent();
static int getPopulationLightThresholdPercent(); static int getPopulationLightThresholdPercent();
static bool getUseExternalAuth(); static bool getUseExternalAuth();
static const char * getExternalAuthUrl(); static const char * getExternalAuthUrl();
static const bool getUseSimpleAuth();
static bool getUseOldSuidGenerator(); static bool getUseOldSuidGenerator();
// has character creation for this cluster been disabled through config option // has character creation for this cluster been disabled through config option
@@ -217,6 +221,13 @@ inline const bool ConfigLoginServer::getValidateStationKey()
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
inline const bool ConfigLoginServer::getEasyExternalAccess()
{
return (data->easyExternalAccess);
}
// ----------------------------------------------------------------------
inline const bool ConfigLoginServer::getDoSessionLogin() inline const bool ConfigLoginServer::getDoSessionLogin()
{ {
return (data->doSessionLogin); return (data->doSessionLogin);
@@ -487,6 +498,10 @@ inline const char * ConfigLoginServer::getExternalAuthUrl()
return data->externalAuthURL; return data->externalAuthURL;
} }
inline const bool ConfigLoginServer::getUseSimpleAuth()
{
return data->useSimpleAuth;
}
inline bool ConfigLoginServer::getUseOldSuidGenerator() inline bool ConfigLoginServer::getUseOldSuidGenerator()
{ {
@@ -1438,7 +1438,11 @@ void LoginServer::sendClusterStatus(ClientConnection &conn) const {
// size_t connectionServerChoice = Random::random(cle->m_connectionServers.size() - 1); //lint !e713 !e732 // loss of precision (arg no 1) // size_t connectionServerChoice = Random::random(cle->m_connectionServers.size() - 1); //lint !e713 !e732 // loss of precision (arg no 1)
ConnectionServerEntry &connServer = cle->m_connectionServers[0]; ConnectionServerEntry &connServer = cle->m_connectionServers[0];
item.m_connectionServerAddress = connServer.clientServiceAddress; if (ConfigLoginServer::getEasyExternalAccess()) {
item.m_connectionServerAddress = cle->m_address;
} else {
item.m_connectionServerAddress = connServer.clientServiceAddress;
}
if (clientIsPrivate) { if (clientIsPrivate) {
item.m_connectionServerPort = connServer.clientServicePortPrivate; item.m_connectionServerPort = connServer.clientServicePortPrivate;
} else { } else {
@@ -1,3 +1,5 @@
#include <signal.h>
#include "FirstPlanetServer.h" #include "FirstPlanetServer.h"
#include "ConfigPlanetServer.h" #include "ConfigPlanetServer.h"
#include "PlanetServer.h" #include "PlanetServer.h"
@@ -14,10 +16,20 @@
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
#include "sharedUtility/SetupSharedUtility.h" #include "sharedUtility/SetupSharedUtility.h"
#ifndef STELLA_INTERNAL #ifdef ENABLE_PROFILING
#include "webAPIHeartbeat.h" extern "C" int __llvm_profile_write_file(void);
#endif #endif
inline void signalHandler(int s){
printf("PlanetServer terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
// ====================================================================== // ======================================================================
void dumpPid(const char * argv) void dumpPid(const char * argv)
@@ -31,9 +43,11 @@ void dumpPid(const char * argv)
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
#ifndef STELLA_INTERNAL struct sigaction sigIntHandler;
StellaBellum::webAPIHeartbeat(); sigIntHandler.sa_handler = signalHandler;
#endif sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
// dumpPid(argv[0]); // dumpPid(argv[0]);
@@ -75,8 +89,8 @@ int main(int argc, char ** argv)
SetupSharedThread::remove(); SetupSharedThread::remove();
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0); exit(0);
#endif #endif
return 0; return 0;
} }
@@ -152,7 +152,7 @@ bool ProcessSpawner::isProcessActive(uint32 pid)
void ProcessSpawner::kill(uint32 pid) void ProcessSpawner::kill(uint32 pid)
{ {
IGNORE_RETURN(::kill(static_cast<int>(pid), SIGKILL)); IGNORE_RETURN(::kill(static_cast<int>(pid), SIGTERM));
int status; int status;
IGNORE_RETURN(waitpid(static_cast<int>(pid), &status, 0)); IGNORE_RETURN(waitpid(static_cast<int>(pid), &status, 0));
} }
@@ -1,3 +1,5 @@
#include <signal.h>
#include "sharedFoundation/FirstSharedFoundation.h" #include "sharedFoundation/FirstSharedFoundation.h"
#include "ConfigTaskManager.h" #include "ConfigTaskManager.h"
@@ -13,10 +15,30 @@
#include "sharedRandom/SetupSharedRandom.h" #include "sharedRandom/SetupSharedRandom.h"
#include "sharedThread/SetupSharedThread.h" #include "sharedThread/SetupSharedThread.h"
#ifdef ENABLE_PROFILING
extern "C" int __llvm_profile_write_file(void);
#endif
inline void signalHandler(int s){
printf("TaskManager terminating, signal %d\n",s);
#ifdef ENABLE_PROFILING
__llvm_profile_write_file();
#endif
exit(0);
}
// ====================================================================== // ======================================================================
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = signalHandler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
SetupSharedThread::install(); SetupSharedThread::install();
SetupSharedDebug::install(1024); SetupSharedDebug::install(1024);
@@ -42,6 +64,7 @@ int main(int argc, char ** argv)
SetupSharedFoundation::remove(); SetupSharedFoundation::remove();
#ifdef ENABLE_PROFILING #ifdef ENABLE_PROFILING
__llvm_profile_write_file();
exit(0); exit(0);
#endif #endif
@@ -39,7 +39,7 @@ bool CharacterNameLocator::locateObjects(DB::Session *session, const std::string
break; break;
m_characterIds.push_back(i->character_id.getValue()); m_characterIds.push_back(i->character_id.getValue());
m_stationIds.push_back(i->character_station_id.getValue()); m_stationIds.push_back(static_cast<int>(i->character_station_id.getValue()));
m_characterNames.push_back(i->character_name.getValueASCII()); m_characterNames.push_back(i->character_name.getValueASCII());
m_characterFullNames.push_back(i->character_full_name.getValueASCII()); m_characterFullNames.push_back(i->character_full_name.getValueASCII());
m_characterCreateTime.push_back(i->character_create_time.getValue() + (7 * 60 * 60)); m_characterCreateTime.push_back(i->character_create_time.getValue() + (7 * 60 * 60));
@@ -14,7 +14,6 @@
#include "sharedDatabaseInterface/BindableNetworkId.h" #include "sharedDatabaseInterface/BindableNetworkId.h"
#include "sharedDatabaseInterface/DbQuery.h" #include "sharedDatabaseInterface/DbQuery.h"
#include "serverDatabase/ObjectLocator.h" #include "serverDatabase/ObjectLocator.h"
#include "sharedFoundation/StationId.h"
#include <vector> #include <vector>
// ====================================================================== // ======================================================================
@@ -33,11 +32,11 @@ class CharacterNameLocator : public ObjectLocator
struct CharacterNameRow struct CharacterNameRow
{ {
DB::BindableNetworkId character_id; DB::BindableNetworkId character_id;
DB::BindableInt64 character_station_id; DB::BindableLong character_station_id;
DB::BindableString<127> character_name; DB::BindableString<127> character_name;
DB::BindableString<127> character_full_name; DB::BindableString<127> character_full_name;
DB::BindableInt64 character_create_time; DB::BindableLong character_create_time;
DB::BindableInt64 character_last_login_time; DB::BindableLong character_last_login_time;
}; };
class CharacterNameQuery : public DB::Query class CharacterNameQuery : public DB::Query
@@ -64,11 +63,11 @@ class CharacterNameLocator : public ObjectLocator
private: private:
std::vector<NetworkId> m_characterIds; std::vector<NetworkId> m_characterIds;
std::vector<StationId> m_stationIds; std::vector<int> m_stationIds;
std::vector<std::string> m_characterNames; std::vector<std::string> m_characterNames;
std::vector<std::string> m_characterFullNames; std::vector<std::string> m_characterFullNames;
std::vector<int64> m_characterCreateTime; std::vector<int> m_characterCreateTime;
std::vector<int64> m_characterLastLoginTime; std::vector<int> m_characterLastLoginTime;
}; };
// ====================================================================== // ======================================================================
@@ -290,10 +290,10 @@ void Persister::onFrameBarrierReached()
void Persister::startSave(void) void Persister::startSave(void)
{ {
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("Starting save with data for %i objects (%i new)\n",m_objectSnapshotMap.size(), m_newObjectCount)); //DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("Starting save with data for %i objects (%i new)\n",m_objectSnapshotMap.size(), m_newObjectCount));
LOG("SaveTimes",("Starting save with data for %i objects (%i new)",m_objectSnapshotMap.size(), m_newObjectCount)); //LOG("SaveTimes",("Starting save with data for %i objects (%i new)",m_objectSnapshotMap.size(), m_newObjectCount));
// notify Central that a save is starting. It needs this to determine when it can perform graceful shutdowns // notify Central that a save is starting. It needs this to determine when it can perform graceful shutdowns
LOG("Database",("Sending DatabaseSaveStart network message to Central.")); //LOG("Database",("Sending DatabaseSaveStart network message to Central."));
DatabaseSaveStart const startSaveMessage; DatabaseSaveStart const startSaveMessage;
DatabaseProcess::getInstance().sendToCentralServer(startSaveMessage, true); DatabaseProcess::getInstance().sendToCentralServer(startSaveMessage, true);
@@ -347,7 +347,7 @@ void Persister::startSave(void)
{ {
GenericValueTypeMessage<int> const saveCompleteMessage("DatabaseSaveComplete", ++m_saveCounter); GenericValueTypeMessage<int> const saveCompleteMessage("DatabaseSaveComplete", ++m_saveCounter);
DatabaseProcess::getInstance().sendToCentralServer(saveCompleteMessage, true); DatabaseProcess::getInstance().sendToCentralServer(saveCompleteMessage, true);
LOG("Database",("Sending DatabaseSaveComplete network message to Central.")); //LOG("Database",("Sending DatabaseSaveComplete network message to Central."));
} }
// clear the buffers // clear the buffers
@@ -619,19 +619,19 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
if (saveTime > m_maxSaveTime) if (saveTime > m_maxSaveTime)
m_maxSaveTime = saveTime; m_maxSaveTime = saveTime;
DEBUG_REPORT_LOG(true,("Save completed in %i. (Average %i, max %i)\n", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime)); //DEBUG_REPORT_LOG(true,("Save completed in %i. (Average %i, max %i)\n", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime));
LOG("SaveTimes",("Save completed in %i. (Average %i, max %i)", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime)); //LOG("SaveTimes",("Save completed in %i. (Average %i, max %i)", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime));
m_lastSaveTime = saveTime; m_lastSaveTime = saveTime;
} }
LOG("Database",("Sending DatabaseSaveComplete network message to Central.")); //LOG("Database",("Sending DatabaseSaveComplete network message to Central."));
// TODO: so do we send this for the other snapshot type or not? hrmph // TODO: so do we send this for the other snapshot type or not? hrmph
// message Central Server that the current save cycle is complete // message Central Server that the current save cycle is complete
GenericValueTypeMessage<int> const saveCompleteMessage("DatabaseSaveComplete", ++m_saveCounter); GenericValueTypeMessage<int> const saveCompleteMessage("DatabaseSaveComplete", ++m_saveCounter);
DatabaseProcess::getInstance().sendToCentralServer(saveCompleteMessage, true); DatabaseProcess::getInstance().sendToCentralServer(saveCompleteMessage, true);
LOG("Database",("Sending DatabaseSaveComplete network message to Central.")); //LOG("Database",("Sending DatabaseSaveComplete network message to Central."));
} }
if (!found) { if (!found) {
@@ -644,7 +644,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
} }
} }
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); //DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n"));
} }
if (found && completedSnapshot != nullptr) { if (found && completedSnapshot != nullptr) {
@@ -716,7 +716,7 @@ void Persister::receiveMessage(const MessageDispatch::Emitter & source, const Me
{ {
auto ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin(); auto ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
AddCharacterMessage ocm(ri); AddCharacterMessage ocm(ri);
DEBUG_REPORT_LOG(true, ("Got AddCharacterMessage for object %s.\n",ocm.getObjectId().getValueString().c_str())); //DEBUG_REPORT_LOG(true, ("Got AddCharacterMessage for object %s.\n",ocm.getObjectId().getValueString().c_str()));
addCharacter(ocm.getAccountNumber(), ocm.getObjectId(), ocm.getProcess(), ocm.getName(), ocm.getSpecial()); addCharacter(ocm.getAccountNumber(), ocm.getObjectId(), ocm.getProcess(), ocm.getName(), ocm.getSpecial());
break; break;
@@ -31,7 +31,7 @@ Snapshot::Snapshot(DB::ModeQuery::Mode mode, bool useGoldDatabase) :
m_mode(mode), m_mode(mode),
m_timestamp(0) m_timestamp(0)
{ {
LOG("Snapshot",("Created snapshot")); //LOG("Snapshot",("Created snapshot"));
++ms_creationCount; ++ms_creationCount;
} }
@@ -54,7 +54,7 @@ Snapshot::~Snapshot()
m_customStepList.clear(); m_customStepList.clear();
++ms_deletionCount; ++ms_deletionCount;
LOG("Snapshot",("Deleted snapshot. %i outstanding, %i created, %i deleted", ms_creationCount-ms_deletionCount,ms_creationCount,ms_deletionCount)); //LOG("Snapshot",("Deleted snapshot. %i outstanding, %i created, %i deleted", ms_creationCount-ms_deletionCount,ms_creationCount,ms_deletionCount));
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@@ -574,7 +574,7 @@ float AICreatureController::realAlter(float time)
setRetreating(false); setRetreating(false);
WARNING(true, ("AICreatureController::realAlter() owner(%s) inCombat(%s) Retreating has lasted(%d) > %d seconds. Auto-releasing retreat.", getDebugInformation().c_str(), getCreature()->isInCombat() ? "yes" : "no", retreatingTime, maxRetreatTime)); DEBUG_WARNING(true, ("AICreatureController::realAlter() owner(%s) inCombat(%s) Retreating has lasted(%d) > %d seconds. Auto-releasing retreat.", getDebugInformation().c_str(), getCreature()->isInCombat() ? "yes" : "no", retreatingTime, maxRetreatTime));
} }
} }
} }
@@ -685,7 +685,7 @@ float AICreatureController::realAlter(float time)
std::string warningString; std::string warningString;
m_movement->getDebugInfo(warningString); m_movement->getDebugInfo(warningString);
WARNING(true, (FormattedString<4096>().sprintf("AICreatureController::realAlter() owner(%s) movement(%s) alter took %.0fms. Dumping movement info - %s\n", getDebugInformation().c_str(), AiMovementBase::getMovementString(m_movement->getType()), msec, warningString.c_str()))); DEBUG_WARNING(true, (FormattedString<4096>().sprintf("AICreatureController::realAlter() owner(%s) movement(%s) alter took %.0fms. Dumping movement info - %s\n", getDebugInformation().c_str(), AiMovementBase::getMovementString(m_movement->getType()), msec, warningString.c_str())));
} }
} }
} }
@@ -751,7 +751,7 @@ bool AICreatureController::suspendMovement()
else if (m_movement != AiMovementBaseNullPtr) else if (m_movement != AiMovementBaseNullPtr)
{ {
result = false; result = false;
WARNING(true, ("AICreatureController::suspendMovement called for creature %s when there is already a suspended movement type %d", DEBUG_WARNING(true, ("AICreatureController::suspendMovement called for creature %s when there is already a suspended movement type %d",
getOwner()->getNetworkId().getValueString().c_str(), static_cast<int>(m_movement->getType()))); getOwner()->getNetworkId().getValueString().c_str(), static_cast<int>(m_movement->getType())));
} }
return result; return result;
@@ -1117,7 +1117,7 @@ bool AICreatureController::faceTo( NetworkId const & targetId )
if (!target) if (!target)
{ {
WARNING(true, ("AICreatureController::faceTo() owner(%s) Unable to resolve target(%s) to a ServerObject", getDebugInformation().c_str(), targetId.getValueString().c_str())); DEBUG_WARNING(true, ("AICreatureController::faceTo() owner(%s) Unable to resolve target(%s) to a ServerObject", getDebugInformation().c_str(), targetId.getValueString().c_str()));
return false; return false;
} }
@@ -1162,7 +1162,7 @@ bool AICreatureController::follow( NetworkId const & targetId, float minDistance
if (!target) if (!target)
{ {
WARNING(true, ("AICreatureController::follow() owner(%s) distance[%.2f...%.2f] Unable to resolve target(%s) to a ServerObject", getDebugInformation().c_str(), minDistance, maxDistance, targetId.getValueString().c_str())); DEBUG_WARNING(true, ("AICreatureController::follow() owner(%s) distance[%.2f...%.2f] Unable to resolve target(%s) to a ServerObject", getDebugInformation().c_str(), minDistance, maxDistance, targetId.getValueString().c_str()));
return false; return false;
} }
@@ -1210,7 +1210,7 @@ bool AICreatureController::follow( NetworkId const & targetId, Vector const & of
if (!target) if (!target)
{ {
WARNING(true, ("AICreatureController::follow() owner(%s) offset(%.0f, %.0f, %.0f) Unable to resolve target(%s) to a ServerObject", getDebugInformation().c_str(), offset.x, offset.y, offset.z, targetId.getValueString().c_str())); DEBUG_WARNING(true, ("AICreatureController::follow() owner(%s) offset(%.0f, %.0f, %.0f) Unable to resolve target(%s) to a ServerObject", getDebugInformation().c_str(), offset.x, offset.y, offset.z, targetId.getValueString().c_str()));
return false; return false;
} }
@@ -1905,7 +1905,7 @@ float AICreatureController::getRespectRadius(NetworkId const & target) const
} }
else else
{ {
WARNING(true, ("AICreatureController::getRespectRadius() owner(%s) master(%s) The owner has a master who is not a player. Why does this happen?", getDebugInformation().c_str(), (respectCreatureObject != nullptr) ? respectCreatureObject->getDebugInformation().c_str() : masterId.getValueString().c_str())); DEBUG_WARNING(true, ("AICreatureController::getRespectRadius() owner(%s) master(%s) The owner has a master who is not a player. Why does this happen?", getDebugInformation().c_str(), (respectCreatureObject != nullptr) ? respectCreatureObject->getDebugInformation().c_str() : masterId.getValueString().c_str()));
} }
} }
@@ -2402,7 +2402,7 @@ NetworkId AICreatureController::createWeapon(char const * const functionName, Cr
if (inventory == nullptr) if (inventory == nullptr)
{ {
WARNING(true, ("AICreatureController::%s() Unable to find inventory for (%s) to place a weapon(%s)", functionName, getDebugInformation().c_str(), weaponName.getString())); DEBUG_WARNING(true, ("AICreatureController::%s() Unable to find inventory for (%s) to place a weapon(%s)", functionName, getDebugInformation().c_str(), weaponName.getString()));
} }
else else
{ {
@@ -2432,7 +2432,7 @@ NetworkId AICreatureController::createWeapon(char const * const functionName, Cr
if (weaponCrcName.getCrc() == 0) if (weaponCrcName.getCrc() == 0)
{ {
WARNING(true, ("AICreatureController::%s() Unable to resolve a weapon(%s) crc for (%s)", functionName, weaponTemplateName.c_str(), getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::%s() Unable to resolve a weapon(%s) crc for (%s)", functionName, weaponTemplateName.c_str(), getDebugInformation().c_str()));
} }
else else
{ {
@@ -2445,7 +2445,7 @@ NetworkId AICreatureController::createWeapon(char const * const functionName, Cr
} }
else else
{ {
WARNING(true, ("AICreatureController::%s() Unable to create a WeaponObject(%s) for (%s)", functionName, weaponTemplateName.c_str(), getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::%s() Unable to create a WeaponObject(%s) for (%s)", functionName, weaponTemplateName.c_str(), getDebugInformation().c_str()));
} }
} }
} }
@@ -2484,7 +2484,7 @@ void AICreatureController::equipPrimaryWeapon()
{ {
if (!isCombatAi()) if (!isCombatAi())
{ {
WARNING(true, ("AICreatureController::equipPrimaryWeapon() owner(%s) A non-combat AI is trying to equip a weapon", getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::equipPrimaryWeapon() owner(%s) A non-combat AI is trying to equip a weapon", getDebugInformation().c_str()));
return; return;
} }
@@ -2524,13 +2524,13 @@ void AICreatureController::equipPrimaryWeapon()
} }
else else
{ {
WARNING(true, ("AICreatureController::equipPrimaryWeapon() owner(%s) Transfer of primaryWeapon(%s) to the visible equipped slot failed(%d).", getDebugInformation().c_str(), primaryWeaponServerObject->getDebugInformation().c_str(), errorCode)); DEBUG_WARNING(true, ("AICreatureController::equipPrimaryWeapon() owner(%s) Transfer of primaryWeapon(%s) to the visible equipped slot failed(%d).", getDebugInformation().c_str(), primaryWeaponServerObject->getDebugInformation().c_str(), errorCode));
} }
} }
} }
else else
{ {
WARNING(true, ("AICreatureController::equipPrimaryWeapon() owner(%s) Unable to resolve primaryWeapon(%s:%s) to a WeaponObject.", getDebugInformation().c_str(), m_primaryWeapon.get().getValueString().c_str(), m_aiCreatureData->m_primaryWeapon.getString())); DEBUG_WARNING(true, ("AICreatureController::equipPrimaryWeapon() owner(%s) Unable to resolve primaryWeapon(%s:%s) to a WeaponObject.", getDebugInformation().c_str(), m_primaryWeapon.get().getValueString().c_str(), m_aiCreatureData->m_primaryWeapon.getString()));
} }
} }
} }
@@ -2549,7 +2549,7 @@ void AICreatureController::equipSecondaryWeapon()
{ {
if (!isCombatAi()) if (!isCombatAi())
{ {
WARNING(true, ("AICreatureController::equipSecondaryWeapon() owner(%s) A non-combat AI is trying to equip a weapon", getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::equipSecondaryWeapon() owner(%s) A non-combat AI is trying to equip a weapon", getDebugInformation().c_str()));
return; return;
} }
@@ -2589,13 +2589,13 @@ void AICreatureController::equipSecondaryWeapon()
} }
else else
{ {
WARNING(true, ("AICreatureController::equipSecondaryWeapon() owner(%s) Transfer of secondaryWeapon(%s) to the visible equipped slot failed(%d).", getDebugInformation().c_str(), secondaryWeaponServerObject->getDebugInformation().c_str(), errorCode)); DEBUG_WARNING(true, ("AICreatureController::equipSecondaryWeapon() owner(%s) Transfer of secondaryWeapon(%s) to the visible equipped slot failed(%d).", getDebugInformation().c_str(), secondaryWeaponServerObject->getDebugInformation().c_str(), errorCode));
} }
} }
} }
else else
{ {
WARNING(true, ("AICreatureController::equipSecondaryWeapon() owner(%s) Unable to resolve secondaryWeapon(%s:%s) to a WeaponObject.", getDebugInformation().c_str(), m_secondaryWeapon.get().getValueString().c_str(), m_aiCreatureData->m_secondaryWeapon.getString())); DEBUG_WARNING(true, ("AICreatureController::equipSecondaryWeapon() owner(%s) Unable to resolve secondaryWeapon(%s:%s) to a WeaponObject.", getDebugInformation().c_str(), m_secondaryWeapon.get().getValueString().c_str(), m_aiCreatureData->m_secondaryWeapon.getString()));
} }
} }
} }
@@ -2614,7 +2614,7 @@ void AICreatureController::unEquipWeapons()
{ {
if (!isCombatAi()) if (!isCombatAi())
{ {
WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) A non-combat AI is trying to unequip a weapon", getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) A non-combat AI is trying to unequip a weapon", getDebugInformation().c_str()));
return; return;
} }
@@ -2636,12 +2636,12 @@ void AICreatureController::unEquipWeapons()
if (!ContainerInterface::transferItemToVolumeContainer(*inventory, *currentWeaponObject, creatureOwner, error)) if (!ContainerInterface::transferItemToVolumeContainer(*inventory, *currentWeaponObject, creatureOwner, error))
{ {
WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) Transfer of the currentWeapon(%s) to the inventory failed(%d).", getDebugInformation().c_str(), currentWeaponObject->getDebugInformation().c_str(), error)); DEBUG_WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) Transfer of the currentWeapon(%s) to the inventory failed(%d).", getDebugInformation().c_str(), currentWeaponObject->getDebugInformation().c_str(), error));
} }
} }
else else
{ {
WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) Unable to find an inventory.", getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) Unable to find an inventory.", getDebugInformation().c_str()));
} }
} }
@@ -2653,7 +2653,7 @@ void AICreatureController::unEquipWeapons()
} }
else else
{ {
WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) nullptr default weapon", getDebugInformation().c_str())); DEBUG_WARNING(true, ("AICreatureController::unEquipWeapons() owner(%s) nullptr default weapon", getDebugInformation().c_str()));
} }
} }
} }
@@ -2822,7 +2822,7 @@ void AICreatureController::setRetreating(bool const retreating)
} }
else else
{ {
WARNING(true, ("AICreatureController::setRetreating() ai(%s) Unable to resolve the cellId(%s) to a CellObject", creatureOwner->getDebugInformation().c_str(), cellId.getValueString().c_str())); DEBUG_WARNING(true, ("AICreatureController::setRetreating() ai(%s) Unable to resolve the cellId(%s) to a CellObject", creatureOwner->getDebugInformation().c_str(), cellId.getValueString().c_str()));
} }
} }
else else
@@ -189,7 +189,7 @@ int NameManager::getTotalPlayerCount() const
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void NameManager::addPlayer(const NetworkId &id, StationId stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers) void NameManager::addPlayer(const NetworkId &id, uint32 stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers)
{ {
std::string normalizedName(normalizeName(name)); std::string normalizedName(normalizeName(name));
@@ -221,18 +221,18 @@ void NameManager::addPlayer(const NetworkId &id, StationId stationId, const std:
if (notifyOtherServers) if (notifyOtherServers)
{ {
std::vector<NetworkId> ids; std::vector<NetworkId> ids;
std::vector<StationId> stationIds; std::vector<int> stationIds;
std::vector<std::string> characterNames; std::vector<std::string> characterNames;
std::vector<std::string> characterFullNames; std::vector<std::string> characterFullNames;
std::vector<int64> characterCreateTimes; std::vector<int> characterCreateTimes;
std::vector<int64> characterLastLoginTimes; std::vector<int> characterLastLoginTimes;
ids.push_back(id); ids.push_back(id);
stationIds.push_back(stationId); stationIds.push_back(static_cast<int>(stationId));
characterNames.push_back(normalizedName); characterNames.push_back(normalizedName);
characterFullNames.push_back(fullName); characterFullNames.push_back(fullName);
characterCreateTimes.push_back(static_cast<int64>(createTime)); characterCreateTimes.push_back(static_cast<int>(createTime));
characterLastLoginTimes.push_back(static_cast<int64>(lastLoginTime)); characterLastLoginTimes.push_back(static_cast<int>(lastLoginTime));
ServerMessageForwarding::beginBroadcast(); ServerMessageForwarding::beginBroadcast();
@@ -247,7 +247,7 @@ void NameManager::addPlayer(const NetworkId &id, StationId stationId, const std:
void NameManager::renamePlayer(const NetworkId &id, const Unicode::String &name, const Unicode::String &fullName) void NameManager::renamePlayer(const NetworkId &id, const Unicode::String &name, const Unicode::String &fullName)
{ {
StationId stationId = 0; uint32 stationId = 0;
time_t createTime = 0; time_t createTime = 0;
time_t lastLoginTime = 0; time_t lastLoginTime = 0;
@@ -279,7 +279,7 @@ const NetworkId & NameManager::getPlayerId(const std::string &name) const
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
StationId NameManager::getPlayerStationId(const NetworkId &id) const uint32 NameManager::getPlayerStationId(const NetworkId &id) const
{ {
IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id); IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id);
if (i==m_idToCharacterDataMap->end()) if (i==m_idToCharacterDataMap->end())
@@ -316,24 +316,24 @@ const std::string & NameManager::getPlayerFullName(const NetworkId &id) const
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
int64 NameManager::getPlayerCreateTime(const NetworkId &id) const int NameManager::getPlayerCreateTime(const NetworkId &id) const
{ {
IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id); IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id);
if (i==m_idToCharacterDataMap->end()) if (i==m_idToCharacterDataMap->end())
return -1; return -1;
else else
return static_cast<int64>(i->second.createTime); return static_cast<int>(i->second.createTime);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
int64 NameManager::getPlayerLastLoginTime(const NetworkId &id) const int NameManager::getPlayerLastLoginTime(const NetworkId &id) const
{ {
IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id); IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id);
if (i==m_idToCharacterDataMap->end()) if (i==m_idToCharacterDataMap->end())
return -1; return -1;
else else
return static_cast<int64>(i->second.lastLoginTime); return static_cast<int>(i->second.lastLoginTime);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@@ -464,7 +464,7 @@ void NameManager::releasePlayerName(const NetworkId &id)
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void NameManager::addPlayers(const std::vector<NetworkId> &ids, const std::vector<StationId> &stationIds, const std::vector<std::string> &names, const std::vector<std::string> &fullNames, const std::vector<int64> &createTimes, const std::vector<int64> &lastLoginTimes) void NameManager::addPlayers(const std::vector<NetworkId> &ids, const std::vector<int> &stationIds, const std::vector<std::string> &names, const std::vector<std::string> &fullNames, const std::vector<int> &createTimes, const std::vector<int> &lastLoginTimes)
{ {
DEBUG_FATAL(ids.size() != stationIds.size(),("Programmer bug: Vectors ids and stationIds must be the same size.\n")); DEBUG_FATAL(ids.size() != stationIds.size(),("Programmer bug: Vectors ids and stationIds must be the same size.\n"));
DEBUG_FATAL(ids.size() != names.size(),("Programmer bug: Vectors ids and names must be the same size.\n")); DEBUG_FATAL(ids.size() != names.size(),("Programmer bug: Vectors ids and names must be the same size.\n"));
@@ -483,20 +483,20 @@ void NameManager::addPlayers(const std::vector<NetworkId> &ids, const std::vecto
void NameManager::sendAllNamesToServer (std::vector<uint32> const & servers) const void NameManager::sendAllNamesToServer (std::vector<uint32> const & servers) const
{ {
std::vector<NetworkId> ids; std::vector<NetworkId> ids;
std::vector<StationId> stationIds; std::vector<int> stationIds;
std::vector<std::string> characterNames; std::vector<std::string> characterNames;
std::vector<std::string> characterFullNames; std::vector<std::string> characterFullNames;
std::vector<int64> characterCreateTimes; std::vector<int> characterCreateTimes;
std::vector<int64> characterLastLoginTimes; std::vector<int> characterLastLoginTimes;
for (IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->begin(); i!=m_idToCharacterDataMap->end(); ++i) for (IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->begin(); i!=m_idToCharacterDataMap->end(); ++i)
{ {
ids.push_back(i->first); ids.push_back(i->first);
stationIds.push_back(i->second.stationId); stationIds.push_back(static_cast<int>(i->second.stationId));
characterNames.push_back(i->second.characterName); characterNames.push_back(i->second.characterName);
characterFullNames.push_back(i->second.characterFullName); characterFullNames.push_back(i->second.characterFullName);
characterCreateTimes.push_back(static_cast<int64>(i->second.createTime)); characterCreateTimes.push_back(static_cast<int>(i->second.createTime));
characterLastLoginTimes.push_back(static_cast<int64>(i->second.lastLoginTime)); characterLastLoginTimes.push_back(static_cast<int>(i->second.lastLoginTime));
} }
ServerMessageForwarding::begin(servers); ServerMessageForwarding::begin(servers);
@@ -8,8 +8,6 @@
#ifndef INCLUDED_NameManager_H #ifndef INCLUDED_NameManager_H
#define INCLUDED_NameManager_H #define INCLUDED_NameManager_H
#include "sharedFoundation/StationId.h"
// ====================================================================== // ======================================================================
class NameGenerator; class NameGenerator;
@@ -34,17 +32,17 @@ class NameManager
public: public:
int getTotalPlayerCount () const; int getTotalPlayerCount () const;
void addPlayer (const NetworkId &id, StationId stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers); void addPlayer (const NetworkId &id, uint32 stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers);
void addPlayers (const std::vector<NetworkId> &ids, const std::vector<StationId> &stationIds, const std::vector<std::string> &names, const std::vector<std::string> &fullNames, const std::vector<int64> &createTimes, const std::vector<int64> &lastLoginTimes); void addPlayers (const std::vector<NetworkId> &ids, const std::vector<int> &stationIds, const std::vector<std::string> &names, const std::vector<std::string> &fullNames, const std::vector<int> &createTimes, const std::vector<int> &lastLoginTimes);
void renamePlayer (const NetworkId &id, const Unicode::String &name, const Unicode::String &fullName); void renamePlayer (const NetworkId &id, const Unicode::String &name, const Unicode::String &fullName);
std::string debugGetNameList () const; std::string debugGetNameList () const;
bool isPlayer (NetworkId const & possiblePlayer) const; bool isPlayer (NetworkId const & possiblePlayer) const;
const NetworkId & getPlayerId (const std::string &name) const; const NetworkId & getPlayerId (const std::string &name) const;
StationId getPlayerStationId (const NetworkId &id) const; uint32 getPlayerStationId (const NetworkId &id) const;
const std::string & getPlayerName (const NetworkId &id) const; const std::string & getPlayerName (const NetworkId &id) const;
const std::string & getPlayerFullName (const NetworkId &id) const; const std::string & getPlayerFullName (const NetworkId &id) const;
int64 getPlayerCreateTime (const NetworkId &id) const; int getPlayerCreateTime (const NetworkId &id) const;
int64 getPlayerLastLoginTime (const NetworkId &id) const; int getPlayerLastLoginTime (const NetworkId &id) const;
void getPlayerWithLastLoginTimeAfter (time_t time, std::multimap<time_t, std::pair<std::pair<NetworkId, uint32>, std::string> > &result) const; void getPlayerWithLastLoginTimeAfter (time_t time, std::multimap<time_t, std::pair<std::pair<NetworkId, uint32>, std::string> > &result) const;
void getPlayerWithLastLoginTimeBefore (time_t time, std::multimap<time_t, std::pair<std::pair<NetworkId, uint32>, std::string> > &result) const; void getPlayerWithLastLoginTimeBefore (time_t time, std::multimap<time_t, std::pair<std::pair<NetworkId, uint32>, std::string> > &result) const;
void getPlayerWithLastLoginTimeBetween (time_t timeLowerRange, time_t timeUpperRange, std::multimap<time_t, std::pair<std::pair<NetworkId, uint32>, std::string> > &result) const; void getPlayerWithLastLoginTimeBetween (time_t timeLowerRange, time_t timeUpperRange, std::multimap<time_t, std::pair<std::pair<NetworkId, uint32>, std::string> > &result) const;
@@ -80,7 +78,7 @@ class NameManager
struct CharacterData struct CharacterData
{ {
StationId stationId; uint32 stationId;
std::string characterName; std::string characterName;
std::string characterFullName; std::string characterFullName;
time_t createTime; time_t createTime;
@@ -570,8 +570,8 @@ void ServerUniverse::updateAndValidateData()
m_masterCityObject->addToWorld(); m_masterCityObject->addToWorld();
} }
if (!m_thisPlanet) { // this entire section of code is fucking stupid but less fucking stupid than before, since this loop ran EVERY TIME
//-- create planet objects if they don't exist //-- create planet objects if they don't exist
{
//-- load planet table //-- load planet table
Iff iff; Iff iff;
if (iff.open ("universe/planets.iff", true)) if (iff.open ("universe/planets.iff", true))
@@ -605,11 +605,7 @@ void ServerUniverse::updateAndValidateData()
} }
else else
DEBUG_WARNING (true, ("universe/planets.iff not found")); DEBUG_WARNING (true, ("universe/planets.iff not found"));
}
//-- create this planet, in case it's not in the table
if (!m_thisPlanet)
{
FATAL(!ConfigServerGame::getAllowMasterObjectCreation(), ("Planet object %s was not found!", ServerWorld::getSceneId().c_str())); FATAL(!ConfigServerGame::getAllowMasterObjectCreation(), ("Planet object %s was not found!", ServerWorld::getSceneId().c_str()));
DEBUG_WARNING(true,("Spawning planet %s, which was not listed in planets.iff", ServerWorld::getSceneId().c_str())); DEBUG_WARNING(true,("Spawning planet %s, which was not listed in planets.iff", ServerWorld::getSceneId().c_str()));
IGNORE_RETURN(createPlanetObject(ServerWorld::getSceneId())); IGNORE_RETURN(createPlanetObject(ServerWorld::getSceneId()));
@@ -398,7 +398,7 @@ GuildInfo const * GuildObject::getGuildInfo(int guildId) const
GuildMemberInfo const * GuildObject::getGuildMemberInfo(int guildId, NetworkId const &memberId) const GuildMemberInfo const * GuildObject::getGuildMemberInfo(int guildId, NetworkId const &memberId) const
{ {
std::map<std::pair<int, NetworkId>, GuildMemberInfo, GuildObject>::const_iterator const iterFind = m_membersInfo.find(std::make_pair(guildId, memberId)); const auto iterFind = m_membersInfo.find(std::make_pair(guildId, memberId));
if (iterFind != m_membersInfo.end()) if (iterFind != m_membersInfo.end())
return &(iterFind->second); return &(iterFind->second);
@@ -486,7 +486,7 @@ void GuildObject::getGuildMemberIds(int guildId, std::vector<NetworkId> &results
{ {
results.clear(); results.clear();
for (std::map<std::pair<int, NetworkId>, GuildMemberInfo, GuildObject>::const_iterator iter = m_membersInfo.lower_bound(std::make_pair(guildId, NetworkId::cms_invalid)); iter != m_membersInfo.end(); ++iter) for (auto iter = m_membersInfo.lower_bound(std::make_pair(guildId, NetworkId::cms_invalid)); iter != m_membersInfo.end(); ++iter)
{ {
if (iter->first.first != guildId) if (iter->first.first != guildId)
break; break;
@@ -501,7 +501,7 @@ void GuildObject::getMemberIdsWithPermissions(int guildId, int permissions, std:
{ {
results.clear(); results.clear();
for (std::map<std::pair<int, NetworkId>, GuildMemberInfo, GuildObject>::const_iterator iter = m_membersInfo.lower_bound(std::make_pair(guildId, NetworkId::cms_invalid)); iter != m_membersInfo.end(); ++iter) for (auto iter = m_membersInfo.lower_bound(std::make_pair(guildId, NetworkId::cms_invalid)); iter != m_membersInfo.end(); ++iter)
{ {
if (iter->first.first != guildId) if (iter->first.first != guildId)
break; break;
@@ -635,7 +635,7 @@ void GuildObject::disbandGuild(int guildId)
// remove all members // remove all members
{ {
std::vector<NetworkId> memberIds; std::vector<NetworkId> memberIds;
for (std::map<std::pair<int, NetworkId>, GuildMemberInfo, GuildObject>::const_iterator iter = m_membersInfo.lower_bound(std::make_pair(guildId, NetworkId::cms_invalid)); iter != m_membersInfo.end(); ++iter) for (auto iter = m_membersInfo.lower_bound(std::make_pair(guildId, NetworkId::cms_invalid)); iter != m_membersInfo.end(); ++iter)
{ {
if (iter->first.first != guildId) if (iter->first.first != guildId)
break; break;
@@ -647,7 +647,7 @@ void GuildObject::disbandGuild(int guildId)
m_members.erase(memberSpec); m_members.erase(memberSpec);
} }
for (std::vector<NetworkId>::const_iterator iterMemberId = memberIds.begin(); iterMemberId != memberIds.end(); ++iterMemberId) for (auto iterMemberId = memberIds.begin(); iterMemberId != memberIds.end(); ++iterMemberId)
{ {
std::map<NetworkId, int>::const_iterator iterFind = m_fullMembers.find(*iterMemberId); std::map<NetworkId, int>::const_iterator iterFind = m_fullMembers.find(*iterMemberId);
if ((iterFind != m_fullMembers.end()) && (iterFind->second == guildId)) if ((iterFind != m_fullMembers.end()) && (iterFind->second == guildId))
@@ -16,6 +16,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -1101,46 +1104,55 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "rating") == 0)
m_rating.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "integrity") == 0) case constcrc("rating"):
m_integrity.loadFromIff(file); m_rating.loadFromIff(file);
else if (strcmp(paramName, "effectiveness") == 0) break;
m_effectiveness.loadFromIff(file); case constcrc("integrity"):
else if (strcmp(paramName, "specialProtection") == 0) m_integrity.loadFromIff(file);
{ break;
std::vector<StructParamOT *>::iterator iter; case constcrc("effectiveness"):
for (iter = m_specialProtection.begin(); iter != m_specialProtection.end(); ++iter) m_effectiveness.loadFromIff(file);
break;
case constcrc("specialProtection"):
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_specialProtection.begin(); iter != m_specialProtection.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
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;
} }
m_specialProtection.clear(); break;
m_specialProtectionAppend = file.read_bool8(); case constcrc("vulnerability"):
int listCount = file.read_int32(); m_vulnerability.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
case constcrc("encumbrance"):
{ {
StructParamOT * newData = new StructParamOT; int listCount = file.read_int32();
newData->loadFromIff(file); DEBUG_WARNING(listCount != 3, ("Template %s: read array size of %d for array \"encumbrance\" of size 3, reading values anyway", file.getFileName(), listCount));
m_specialProtection.push_back(newData); int j;
} for (j = 0; j < 3 && j < listCount; ++j)
m_specialProtectionLoaded = true; m_encumbrance[j].loadFromIff(file);
} // if there are more params for encumbrance read and dump them
else if (strcmp(paramName, "vulnerability") == 0) for (; j < listCount; ++j)
m_vulnerability.loadFromIff(file); {
else if (strcmp(paramName, "encumbrance") == 0) IntegerParam dummy;
{ dummy.loadFromIff(file);
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)
{
IntegerParam dummy;
dummy.loadFromIff(file);
} }
break;
} }
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1462,10 +1474,16 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "type") == 0)
m_type.loadFromIff(file); switch (runtimeCrc(paramName)) {
else if (strcmp(paramName, "effectiveness") == 0) case constcrc("type"):
m_effectiveness.loadFromIff(file); m_type.loadFromIff(file);
break;
case constcrc("effectiveness"):
m_effectiveness.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -414,10 +417,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "maintenanceCost") == 0)
m_maintenanceCost.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "isPublic") == 0) case constcrc("maintenanceCost"):
m_isPublic.loadFromIff(file); m_maintenanceCost.loadFromIff(file);
break;
case constcrc("isPublic"):
m_isPublic.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -19,6 +19,9 @@
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedUtility/NameGenerator.h" #include "sharedUtility/NameGenerator.h"
#include "sharedNetworkMessages/NameErrors.h" #include "sharedNetworkMessages/NameErrors.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
#include "ServerWeaponObjectTemplate.h" #include "ServerWeaponObjectTemplate.h"
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
@@ -2372,112 +2375,129 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "defaultWeapon") == 0) switch(runtimeCrc(paramName)) {
m_defaultWeapon.loadFromIff(file); case constcrc("defaultWeapon"):
else if (strcmp(paramName, "attributes") == 0) m_defaultWeapon.loadFromIff(file);
{ break;
int listCount = file.read_int32(); case constcrc("attributes"):
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)
{ {
IntegerParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); 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)
{
IntegerParam dummy;
dummy.loadFromIff(file);
}
} }
} break;
else if (strcmp(paramName, "minAttributes") == 0) case constcrc("minAttributes"):
{
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)
{ {
IntegerParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); 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)
{
IntegerParam dummy;
dummy.loadFromIff(file);
}
} }
} break;
else if (strcmp(paramName, "maxAttributes") == 0) case constcrc("maxAttributes"):
{
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)
{ {
IntegerParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); 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)
{
IntegerParam dummy;
dummy.loadFromIff(file);
}
} }
} break;
else if (strcmp(paramName, "minDrainModifier") == 0) case constcrc("minDrainModifier"):
m_minDrainModifier.loadFromIff(file); m_minDrainModifier.loadFromIff(file);
else if (strcmp(paramName, "maxDrainModifier") == 0) break;
m_maxDrainModifier.loadFromIff(file); case constcrc("maxDrainModifier"):
else if (strcmp(paramName, "minFaucetModifier") == 0) m_maxDrainModifier.loadFromIff(file);
m_minFaucetModifier.loadFromIff(file); break;
else if (strcmp(paramName, "maxFaucetModifier") == 0) case constcrc("minFaucetModifier"):
m_maxFaucetModifier.loadFromIff(file); m_minFaucetModifier.loadFromIff(file);
else if (strcmp(paramName, "attribMods") == 0) break;
{ case constcrc("maxFaucetModifier"):
std::vector<StructParamOT *>::iterator iter; m_maxFaucetModifier.loadFromIff(file);
for (iter = m_attribMods.begin(); iter != m_attribMods.end(); ++iter) break;
case constcrc("attribMods"):
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_attribMods.begin(); iter != m_attribMods.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
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;
} }
m_attribMods.clear(); break;
m_attribModsAppend = file.read_bool8(); case constcrc("shockWounds"):
int listCount = file.read_int32(); m_shockWounds.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
case constcrc("canCreateAvatar"):
m_canCreateAvatar.loadFromIff(file);
break;
case constcrc("nameGeneratorType"):
m_nameGeneratorType.loadFromIff(file);
break;
case constcrc("approachTriggerRange"):
m_approachTriggerRange.loadFromIff(file);
break;
case constcrc("maxMentalStates"):
{ {
StructParamOT * newData = new StructParamOT; int listCount = file.read_int32();
newData->loadFromIff(file); DEBUG_WARNING(listCount != 4, ("Template %s: read array size of %d for array \"maxMentalStates\" of size 4, reading values anyway", file.getFileName(), listCount));
m_attribMods.push_back(newData); 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);
}
} }
m_attribModsLoaded = true; break;
} case constcrc("mentalStatesDecay"):
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; int listCount = file.read_int32();
dummy.loadFromIff(file); 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)
else if (strcmp(paramName, "mentalStatesDecay") == 0) m_mentalStatesDecay[j].loadFromIff(file);
{ // if there are more params for mentalStatesDecay read and dump them
int listCount = file.read_int32(); for (; j < listCount; ++j)
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; FloatParam dummy;
for (j = 0; j < 4 && j < listCount; ++j) dummy.loadFromIff(file);
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);
} }
break;
} }
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
#include "ServerFactoryObjectTemplate.h" #include "ServerFactoryObjectTemplate.h"
#include "ServerObjectTemplate.h" #include "ServerObjectTemplate.h"
@@ -1280,77 +1283,90 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "category") == 0)
m_category.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "craftedObjectTemplate") == 0) case constcrc("category"):
m_craftedObjectTemplate.loadFromIff(file); m_category.loadFromIff(file);
else if (strcmp(paramName, "crateObjectTemplate") == 0) break;
m_crateObjectTemplate.loadFromIff(file); case constcrc("craftedObjectTemplate"):
else if (strcmp(paramName, "slots") == 0) m_craftedObjectTemplate.loadFromIff(file);
{ break;
std::vector<StructParamOT *>::iterator iter; case constcrc("crateObjectTemplate"):
for (iter = m_slots.begin(); iter != m_slots.end(); ++iter) m_crateObjectTemplate.loadFromIff(file);
break;
case constcrc("slots"):
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_slots.begin(); iter != m_slots.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_slots.clear();
m_slotsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_slots.push_back(newData);
}
m_slotsLoaded = true;
} }
m_slots.clear(); break;
m_slotsAppend = file.read_bool8(); case constcrc("skillCommands"):
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{ {
StructParamOT * newData = new StructParamOT; std::vector<StringParam *>::iterator iter;
newData->loadFromIff(file); for (iter = m_skillCommands.begin(); iter != m_skillCommands.end(); ++iter)
m_slots.push_back(newData); {
delete *iter;
*iter = nullptr;
}
m_skillCommands.clear();
m_skillCommandsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_skillCommands.push_back(newData);
}
m_skillCommandsLoaded = true;
} }
m_slotsLoaded = true; break;
case constcrc("destroyIngredients"):
m_destroyIngredients.loadFromIff(file);
break;
case constcrc("manufactureScripts"):
{
std::vector<StringParam *>::iterator iter;
for (iter = m_manufactureScripts.begin(); iter != m_manufactureScripts.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_manufactureScripts.clear();
m_manufactureScriptsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_manufactureScripts.push_back(newData);
}
m_manufactureScriptsLoaded = true;
}
break;
case constcrc("itemsPerContainer"):
m_itemsPerContainer.loadFromIff(file);
break;
case constcrc("manufactureTime"):
m_manufactureTime.loadFromIff(file);
break;
case constcrc("prototypeTime"):
m_prototypeTime.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "skillCommands") == 0)
{
std::vector<StringParam *>::iterator iter;
for (iter = m_skillCommands.begin(); iter != m_skillCommands.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_skillCommands.clear();
m_skillCommandsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_skillCommands.push_back(newData);
}
m_skillCommandsLoaded = true;
}
else if (strcmp(paramName, "destroyIngredients") == 0)
m_destroyIngredients.loadFromIff(file);
else if (strcmp(paramName, "manufactureScripts") == 0)
{
std::vector<StringParam *>::iterator iter;
for (iter = m_manufactureScripts.begin(); iter != m_manufactureScripts.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_manufactureScripts.clear();
m_manufactureScriptsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_manufactureScripts.push_back(newData);
}
m_manufactureScriptsLoaded = true;
}
else if (strcmp(paramName, "itemsPerContainer") == 0)
m_itemsPerContainer.loadFromIff(file);
else if (strcmp(paramName, "manufactureTime") == 0)
m_manufactureTime.loadFromIff(file);
else if (strcmp(paramName, "prototypeTime") == 0)
m_prototypeTime.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1990,35 +2006,44 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "optional") == 0)
m_optional.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "name") == 0) case constcrc("optional"):
m_name.loadFromIff(file); m_optional.loadFromIff(file);
else if (strcmp(paramName, "options") == 0) break;
{ case constcrc("name"):
std::vector<StructParamOT *>::iterator iter; m_name.loadFromIff(file);
for (iter = m_options.begin(); iter != m_options.end(); ++iter) break;
case constcrc("options"):
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_options.begin(); iter != m_options.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_options.clear();
m_optionsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_options.push_back(newData);
}
m_optionsLoaded = true;
} }
m_options.clear(); break;
m_optionsAppend = file.read_bool8(); case constcrc("optionalSkillCommand"):
int listCount = file.read_int32(); m_optionalSkillCommand.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
{ case constcrc("complexity"):
StructParamOT * newData = new StructParamOT; m_complexity.loadFromIff(file);
newData->loadFromIff(file); break;
m_options.push_back(newData); case constcrc("appearance"):
} m_appearance.loadFromIff(file);
m_optionsLoaded = true; break;
} }
else if (strcmp(paramName, "optionalSkillCommand") == 0)
m_optionalSkillCommand.loadFromIff(file);
else if (strcmp(paramName, "complexity") == 0)
m_complexity.loadFromIff(file);
else if (strcmp(paramName, "appearance") == 0)
m_appearance.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -802,14 +805,21 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "maxExtractionRate") == 0)
m_maxExtractionRate.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "currentExtractionRate") == 0) case constcrc("maxExtractionRate"):
m_currentExtractionRate.loadFromIff(file); m_maxExtractionRate.loadFromIff(file);
else if (strcmp(paramName, "maxHopperSize") == 0) break;
m_maxHopperSize.loadFromIff(file); case constcrc("currentExtractionRate"):
else if (strcmp(paramName, "masterClassName") == 0) m_currentExtractionRate.loadFromIff(file);
m_masterClassName.loadFromIff(file); break;
case constcrc("maxHopperSize"):
m_maxHopperSize.loadFromIff(file);
break;
case constcrc("masterClassName"):
m_masterClassName.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -371,7 +374,7 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "count") == 0) if (strcmp(paramName, "count"))
m_count.loadFromIff(file); m_count.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -905,31 +908,38 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "ingredientType") == 0)
m_ingredientType.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "ingredients") == 0) case constcrc("ingredientType"):
{ m_ingredientType.loadFromIff(file);
std::vector<StructParamOT *>::iterator iter; break;
for (iter = m_ingredients.begin(); iter != m_ingredients.end(); ++iter) case constcrc("ingredients"):
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
for (iter = m_ingredients.begin(); iter != m_ingredients.end(); ++iter)
{
delete *iter;
*iter = nullptr; *iter = nullptr;
}
m_ingredients.clear();
m_ingredientsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_ingredients.push_back(newData);
}
m_ingredientsLoaded = true;
} }
m_ingredients.clear(); break;
m_ingredientsAppend = file.read_bool8(); case constcrc("complexity"):
int listCount = file.read_int32(); m_complexity.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
{ case constcrc("skillCommand"):
StructParamOT * newData = new StructParamOT; m_skillCommand.loadFromIff(file);
newData->loadFromIff(file); break;
m_ingredients.push_back(newData);
}
m_ingredientsLoaded = true;
} }
else if (strcmp(paramName, "complexity") == 0)
m_complexity.loadFromIff(file);
else if (strcmp(paramName, "skillCommand") == 0)
m_skillCommand.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1250,10 +1260,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "name") == 0)
m_name.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "value") == 0) case constcrc("name"):
m_value.loadFromIff(file); m_name.loadFromIff(file);
break;
case constcrc("value"):
m_value.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1617,12 +1632,18 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "name") == 0)
m_name.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "ingredient") == 0) case constcrc("name"):
m_ingredient.loadFromIff(file); m_name.loadFromIff(file);
else if (strcmp(paramName, "count") == 0) break;
m_count.loadFromIff(file); case constcrc("ingredient"):
m_ingredient.loadFromIff(file);
break;
case constcrc("count"):
m_count.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -821,49 +824,57 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "draftSchematic") == 0)
m_draftSchematic.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "creator") == 0) case constcrc("draftSchematic"):
m_creator.loadFromIff(file); m_draftSchematic.loadFromIff(file);
else if (strcmp(paramName, "ingredients") == 0) break;
{ case constcrc("creator"):
std::vector<StructParamOT *>::iterator iter; m_creator.loadFromIff(file);
for (iter = m_ingredients.begin(); iter != m_ingredients.end(); ++iter) break;
case constcrc("ingredients"):
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_ingredients.begin(); iter != m_ingredients.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_ingredients.clear();
m_ingredientsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_ingredients.push_back(newData);
}
m_ingredientsLoaded = true;
} }
m_ingredients.clear(); break;
m_ingredientsAppend = file.read_bool8(); case constcrc("itemCount"):
int listCount = file.read_int32(); m_itemCount.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
case constcrc("attributes"):
{ {
StructParamOT * newData = new StructParamOT; std::vector<StructParamOT *>::iterator iter;
newData->loadFromIff(file); for (iter = m_attributes.begin(); iter != m_attributes.end(); ++iter)
m_ingredients.push_back(newData); {
delete *iter;
*iter = nullptr;
}
m_attributes.clear();
m_attributesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_attributes.push_back(newData);
}
m_attributesLoaded = true;
} }
m_ingredientsLoaded = true; break;
}
else if (strcmp(paramName, "itemCount") == 0)
m_itemCount.loadFromIff(file);
else if (strcmp(paramName, "attributes") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_attributes.begin(); iter != m_attributes.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_attributes.clear();
m_attributesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_attributes.push_back(newData);
}
m_attributesLoaded = true;
} }
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1110,10 +1121,16 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "name") == 0)
m_name.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "ingredient") == 0) case constcrc("name"):
m_ingredient.loadFromIff(file); m_name.loadFromIff(file);
break;
case constcrc("ingredient"):
m_ingredient.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
#include "ServerObjectTemplate.h" #include "ServerObjectTemplate.h"
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
@@ -1900,150 +1903,168 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "sharedTemplate") == 0)
m_sharedTemplate.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "scripts") == 0) case constcrc("sharedTemplate"):
{ m_sharedTemplate.loadFromIff(file);
std::vector<StringParam *>::iterator iter; break;
for (iter = m_scripts.begin(); iter != m_scripts.end(); ++iter) case constcrc("scripts"):
{ {
delete *iter; std::vector<StringParam *>::iterator iter;
*iter = nullptr; for (iter = m_scripts.begin(); iter != m_scripts.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_scripts.clear();
m_scriptsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_scripts.push_back(newData);
}
m_scriptsLoaded = true;
} }
m_scripts.clear(); break;
m_scriptsAppend = file.read_bool8(); case constcrc("objvars"):
int listCount = file.read_int32(); m_objvars.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
case constcrc("volume"):
m_volume.loadFromIff(file);
break;
case constcrc("visibleFlags"):
{ {
StringParam * newData = new StringParam; std::vector<IntegerParam *>::iterator iter;
newData->loadFromIff(file); for (iter = m_visibleFlags.begin(); iter != m_visibleFlags.end(); ++iter)
m_scripts.push_back(newData); {
delete *iter;
*iter = nullptr;
}
m_visibleFlags.clear();
m_visibleFlagsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_visibleFlags.push_back(newData);
}
m_visibleFlagsLoaded = true;
} }
m_scriptsLoaded = true; break;
case constcrc("deleteFlags"):
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_deleteFlags.begin(); iter != m_deleteFlags.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_deleteFlags.clear();
m_deleteFlagsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_deleteFlags.push_back(newData);
}
m_deleteFlagsLoaded = true;
}
break;
case constcrc("moveFlags"):
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_moveFlags.begin(); iter != m_moveFlags.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_moveFlags.clear();
m_moveFlagsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_moveFlags.push_back(newData);
}
m_moveFlagsLoaded = true;
}
break;
case constcrc("invulnerable"):
m_invulnerable.loadFromIff(file);
break;
case constcrc("complexity"):
m_complexity.loadFromIff(file);
break;
case constcrc("tintIndex"):
m_tintIndex.loadFromIff(file);
break;
case constcrc("updateRanges"):
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 3, ("Template %s: read array size of %d for array \"updateRanges\" of size 3, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 3 && j < listCount; ++j)
m_updateRanges[j].loadFromIff(file);
// if there are more params for updateRanges read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
}
break;
case constcrc("contents"):
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_contents.begin(); iter != m_contents.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_contents.clear();
m_contentsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_contents.push_back(newData);
}
m_contentsLoaded = true;
}
break;
case constcrc("xpPoints"):
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_xpPoints.begin(); iter != m_xpPoints.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_xpPoints.clear();
m_xpPointsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_xpPoints.push_back(newData);
}
m_xpPointsLoaded = true;
}
break;
case constcrc("persistByDefault"):
m_persistByDefault.loadFromIff(file);
break;
case constcrc("persistContents"):
m_persistContents.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "objvars") == 0)
m_objvars.loadFromIff(file);
else if (strcmp(paramName, "volume") == 0)
m_volume.loadFromIff(file);
else if (strcmp(paramName, "visibleFlags") == 0)
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_visibleFlags.begin(); iter != m_visibleFlags.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_visibleFlags.clear();
m_visibleFlagsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_visibleFlags.push_back(newData);
}
m_visibleFlagsLoaded = true;
}
else if (strcmp(paramName, "deleteFlags") == 0)
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_deleteFlags.begin(); iter != m_deleteFlags.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_deleteFlags.clear();
m_deleteFlagsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_deleteFlags.push_back(newData);
}
m_deleteFlagsLoaded = true;
}
else if (strcmp(paramName, "moveFlags") == 0)
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_moveFlags.begin(); iter != m_moveFlags.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_moveFlags.clear();
m_moveFlagsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_moveFlags.push_back(newData);
}
m_moveFlagsLoaded = true;
}
else if (strcmp(paramName, "invulnerable") == 0)
m_invulnerable.loadFromIff(file);
else if (strcmp(paramName, "complexity") == 0)
m_complexity.loadFromIff(file);
else if (strcmp(paramName, "tintIndex") == 0)
m_tintIndex.loadFromIff(file);
else if (strcmp(paramName, "updateRanges") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 3, ("Template %s: read array size of %d for array \"updateRanges\" of size 3, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 3 && j < listCount; ++j)
m_updateRanges[j].loadFromIff(file);
// if there are more params for updateRanges read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
}
else if (strcmp(paramName, "contents") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_contents.begin(); iter != m_contents.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_contents.clear();
m_contentsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_contents.push_back(newData);
}
m_contentsLoaded = true;
}
else if (strcmp(paramName, "xpPoints") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_xpPoints.begin(); iter != m_xpPoints.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_xpPoints.clear();
m_xpPointsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_xpPoints.push_back(newData);
}
m_xpPointsLoaded = true;
}
else if (strcmp(paramName, "persistByDefault") == 0)
m_persistByDefault.loadFromIff(file);
else if (strcmp(paramName, "persistContents") == 0)
m_persistContents.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -2946,16 +2967,24 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "target") == 0)
m_target.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "value") == 0) case constcrc("target"):
m_value.loadFromIff(file); m_target.loadFromIff(file);
else if (strcmp(paramName, "time") == 0) break;
m_time.loadFromIff(file); case constcrc("value"):
else if (strcmp(paramName, "timeAtValue") == 0) m_value.loadFromIff(file);
m_timeAtValue.loadFromIff(file); break;
else if (strcmp(paramName, "decay") == 0) case constcrc("time"):
m_decay.loadFromIff(file); m_time.loadFromIff(file);
break;
case constcrc("timeAtValue"):
m_timeAtValue.loadFromIff(file);
break;
case constcrc("decay"):
m_decay.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -3205,12 +3234,18 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "slotName") == 0)
m_slotName.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "equipObject") == 0) case constcrc("slotName"):
m_equipObject.loadFromIff(file); m_slotName.loadFromIff(file);
else if (strcmp(paramName, "content") == 0) break;
m_content.loadFromIff(file); case constcrc("equipObject"):
m_equipObject.loadFromIff(file);
break;
case constcrc("content"):
m_content.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -4113,16 +4148,24 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "target") == 0)
m_target.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "value") == 0) case constcrc("target"):
m_value.loadFromIff(file); m_target.loadFromIff(file);
else if (strcmp(paramName, "time") == 0) break;
m_time.loadFromIff(file); case constcrc("value"):
else if (strcmp(paramName, "timeAtValue") == 0) m_value.loadFromIff(file);
m_timeAtValue.loadFromIff(file); break;
else if (strcmp(paramName, "decay") == 0) case constcrc("time"):
m_decay.loadFromIff(file); m_time.loadFromIff(file);
break;
case constcrc("timeAtValue"):
m_timeAtValue.loadFromIff(file);
break;
case constcrc("decay"):
m_decay.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -4637,12 +4680,18 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "type") == 0)
m_type.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "level") == 0) case constcrc("type"):
m_level.loadFromIff(file); m_type.loadFromIff(file);
else if (strcmp(paramName, "value") == 0) break;
m_value.loadFromIff(file); case constcrc("level"):
m_level.loadFromIff(file);
break;
case constcrc("value"):
m_value.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
#include "ServerArmorTemplate.h" #include "ServerArmorTemplate.h"
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
@@ -1143,39 +1146,50 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "triggerVolumes") == 0)
{ switch(runtimeCrc(paramName)) {
std::vector<TriggerVolumeParam *>::iterator iter; case constcrc("triggerVolumes"):
for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter)
{ {
delete *iter; std::vector<TriggerVolumeParam *>::iterator iter;
*iter = nullptr; for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_triggerVolumes.clear();
m_triggerVolumesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
TriggerVolumeParam * newData = new TriggerVolumeParam;
newData->loadFromIff(file);
m_triggerVolumes.push_back(newData);
}
m_triggerVolumesLoaded = true;
} }
m_triggerVolumes.clear(); break;
m_triggerVolumesAppend = file.read_bool8(); case constcrc("combatSkeleton"):
int listCount = file.read_int32(); m_combatSkeleton.loadFromIff(file);
for (int j = 0; j < listCount; ++j) break;
{ case constcrc("maxHitPoints"):
TriggerVolumeParam * newData = new TriggerVolumeParam; m_maxHitPoints.loadFromIff(file);
newData->loadFromIff(file); break;
m_triggerVolumes.push_back(newData); case constcrc("armor"):
} m_armor.loadFromIff(file);
m_triggerVolumesLoaded = true; break;
case constcrc("interestRadius"):
m_interestRadius.loadFromIff(file);
break;
case constcrc("count"):
m_count.loadFromIff(file);
break;
case constcrc("condition"):
m_condition.loadFromIff(file);
break;
case constcrc("wantSawAttackTriggers"):
m_wantSawAttackTriggers.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "combatSkeleton") == 0)
m_combatSkeleton.loadFromIff(file);
else if (strcmp(paramName, "maxHitPoints") == 0)
m_maxHitPoints.loadFromIff(file);
else if (strcmp(paramName, "armor") == 0)
m_armor.loadFromIff(file);
else if (strcmp(paramName, "interestRadius") == 0)
m_interestRadius.loadFromIff(file);
else if (strcmp(paramName, "count") == 0)
m_count.loadFromIff(file);
else if (strcmp(paramName, "condition") == 0)
m_condition.loadFromIff(file);
else if (strcmp(paramName, "wantSawAttackTriggers") == 0)
m_wantSawAttackTriggers.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -802,14 +805,21 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "fuelType") == 0)
m_fuelType.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "currentFuel") == 0) case constcrc("fuelType"):
m_currentFuel.loadFromIff(file); m_fuelType.loadFromIff(file);
else if (strcmp(paramName, "maxFuel") == 0) break;
m_maxFuel.loadFromIff(file); case constcrc("currentFuel"):
else if (strcmp(paramName, "consumpsion") == 0) m_currentFuel.loadFromIff(file);
m_consumpsion.loadFromIff(file); break;
case constcrc("maxFuel"):
m_maxFuel.loadFromIff(file);
break;
case constcrc("consumpsion"):
m_consumpsion.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <stdio.h> #include <stdio.h>
@@ -2483,36 +2486,54 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "weaponType") == 0)
m_weaponType.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "attackType") == 0) case constcrc("weaponType"):
m_attackType.loadFromIff(file); m_weaponType.loadFromIff(file);
else if (strcmp(paramName, "damageType") == 0) break;
m_damageType.loadFromIff(file); case constcrc("attackType"):
else if (strcmp(paramName, "elementalType") == 0) m_attackType.loadFromIff(file);
m_elementalType.loadFromIff(file); break;
else if (strcmp(paramName, "elementalValue") == 0) case constcrc("damageType"):
m_elementalValue.loadFromIff(file); m_damageType.loadFromIff(file);
else if (strcmp(paramName, "minDamageAmount") == 0) break;
m_minDamageAmount.loadFromIff(file); case constcrc("elementalType"):
else if (strcmp(paramName, "maxDamageAmount") == 0) m_elementalType.loadFromIff(file);
m_maxDamageAmount.loadFromIff(file); break;
else if (strcmp(paramName, "attackSpeed") == 0) case constcrc("elementalValue"):
m_attackSpeed.loadFromIff(file); m_elementalValue.loadFromIff(file);
else if (strcmp(paramName, "audibleRange") == 0) break;
m_audibleRange.loadFromIff(file); case constcrc("minDamageAmount"):
else if (strcmp(paramName, "minRange") == 0) m_minDamageAmount.loadFromIff(file);
m_minRange.loadFromIff(file); break;
else if (strcmp(paramName, "maxRange") == 0) case constcrc("maxDamageAmount"):
m_maxRange.loadFromIff(file); m_maxDamageAmount.loadFromIff(file);
else if (strcmp(paramName, "damageRadius") == 0) break;
m_damageRadius.loadFromIff(file); case constcrc("attackSpeed"):
else if (strcmp(paramName, "woundChance") == 0) m_attackSpeed.loadFromIff(file);
m_woundChance.loadFromIff(file); break;
else if (strcmp(paramName, "attackCost") == 0) case constcrc("audibleRange"):
m_attackCost.loadFromIff(file); m_audibleRange.loadFromIff(file);
else if (strcmp(paramName, "accuracy") == 0) break;
m_accuracy.loadFromIff(file); case constcrc("minRange"):
m_minRange.loadFromIff(file);
break;
case constcrc("maxRange"):
m_maxRange.loadFromIff(file);
break;
case constcrc("damageRadius"):
m_damageRadius.loadFromIff(file);
break;
case constcrc("woundChance"):
m_woundChance.loadFromIff(file);
break;
case constcrc("attackCost"):
m_attackCost.loadFromIff(file);
break;
case constcrc("accuracy"):
m_accuracy.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -116,43 +116,43 @@ bool ShipComponentDataEngine::readDataFromComponent (TangibleObject const & comp
DynamicVariableList const & objvars = component.getObjVars (); DynamicVariableList const & objvars = component.getObjVars ();
if (!objvars.getItem (Objvars::engineAccelerationRate, m_engineAccelerationRate)) if (!objvars.getItem (Objvars::engineAccelerationRate, m_engineAccelerationRate))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineAccelerationRate.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineAccelerationRate.c_str ()));
if (!objvars.getItem (Objvars::engineDecelerationRate, m_engineDecelerationRate)) if (!objvars.getItem (Objvars::engineDecelerationRate, m_engineDecelerationRate))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineDecelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineDecelerationRate.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineDecelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineDecelerationRate.c_str ()));
if (!objvars.getItem (Objvars::enginePitchAccelerationRate, m_enginePitchAccelerationRate)) if (!objvars.getItem (Objvars::enginePitchAccelerationRate, m_enginePitchAccelerationRate))
WARNING (true, ("ShipComponentDataEngine [%s] has no enginePitchAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::enginePitchAccelerationRate.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no enginePitchAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::enginePitchAccelerationRate.c_str ()));
else else
m_enginePitchAccelerationRate = convertDegreesToRadians(m_enginePitchAccelerationRate); m_enginePitchAccelerationRate = convertDegreesToRadians(m_enginePitchAccelerationRate);
if (!objvars.getItem (Objvars::engineYawAccelerationRate, m_engineYawAccelerationRate)) if (!objvars.getItem (Objvars::engineYawAccelerationRate, m_engineYawAccelerationRate))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineYawAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineYawAccelerationRate.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineYawAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineYawAccelerationRate.c_str ()));
else else
m_engineYawAccelerationRate = convertDegreesToRadians(m_engineYawAccelerationRate); m_engineYawAccelerationRate = convertDegreesToRadians(m_engineYawAccelerationRate);
if (!objvars.getItem (Objvars::engineRollAccelerationRate, m_engineRollAccelerationRate)) if (!objvars.getItem (Objvars::engineRollAccelerationRate, m_engineRollAccelerationRate))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineRollAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineRollAccelerationRate.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineRollAccelerationRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineRollAccelerationRate.c_str ()));
else else
m_engineRollAccelerationRate = convertDegreesToRadians(m_engineRollAccelerationRate); m_engineRollAccelerationRate = convertDegreesToRadians(m_engineRollAccelerationRate);
if (!objvars.getItem (Objvars::enginePitchRateMaximum, m_enginePitchRateMaximum)) if (!objvars.getItem (Objvars::enginePitchRateMaximum, m_enginePitchRateMaximum))
WARNING (true, ("ShipComponentDataEngine [%s] has no enginePitchRateMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::enginePitchRateMaximum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no enginePitchRateMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::enginePitchRateMaximum.c_str ()));
else else
m_enginePitchRateMaximum = convertDegreesToRadians(m_enginePitchRateMaximum); m_enginePitchRateMaximum = convertDegreesToRadians(m_enginePitchRateMaximum);
if (!objvars.getItem (Objvars::engineYawRateMaximum, m_engineYawRateMaximum)) if (!objvars.getItem (Objvars::engineYawRateMaximum, m_engineYawRateMaximum))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineYawRateMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineYawRateMaximum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineYawRateMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineYawRateMaximum.c_str ()));
else else
m_engineYawRateMaximum = convertDegreesToRadians(m_engineYawRateMaximum); m_engineYawRateMaximum = convertDegreesToRadians(m_engineYawRateMaximum);
if (!objvars.getItem (Objvars::engineRollRateMaximum, m_engineRollRateMaximum)) if (!objvars.getItem (Objvars::engineRollRateMaximum, m_engineRollRateMaximum))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineRollRateMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineRollRateMaximum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineRollRateMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineRollRateMaximum.c_str ()));
else else
m_engineRollRateMaximum = convertDegreesToRadians(m_engineRollRateMaximum); m_engineRollRateMaximum = convertDegreesToRadians(m_engineRollRateMaximum);
if (!objvars.getItem (Objvars::engineSpeedMaximum, m_engineSpeedMaximum)) if (!objvars.getItem (Objvars::engineSpeedMaximum, m_engineSpeedMaximum))
WARNING (true, ("ShipComponentDataEngine [%s] has no engineSpeedMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineSpeedMaximum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataEngine [%s] has no engineSpeedMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::engineSpeedMaximum.c_str ()));
if (!objvars.getItem(Objvars::engineSpeedRotationFactorMaximum, m_engineSpeedRotationFactorMaximum)) if (!objvars.getItem(Objvars::engineSpeedRotationFactorMaximum, m_engineSpeedRotationFactorMaximum))
{ {
@@ -104,32 +104,32 @@ bool ShipComponentDataWeapon::readDataFromComponent (TangibleObject const & comp
DynamicVariableList const & objvars = component.getObjVars (); DynamicVariableList const & objvars = component.getObjVars ();
if (!objvars.getItem (Objvars::weaponDamageMaximum, m_weaponDamageMaximum)) if (!objvars.getItem (Objvars::weaponDamageMaximum, m_weaponDamageMaximum))
WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponDamageMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponDamageMaximum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponDamageMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponDamageMaximum.c_str ()));
if (!objvars.getItem (Objvars::weaponDamageMinimum, m_weaponDamageMinimum)) if (!objvars.getItem (Objvars::weaponDamageMinimum, m_weaponDamageMinimum))
WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponDamageMinimum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponDamageMinimum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponDamageMinimum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponDamageMinimum.c_str ()));
if (!objvars.getItem (Objvars::weaponEffectivenessShields, m_weaponEffectivenessShields)) if (!objvars.getItem (Objvars::weaponEffectivenessShields, m_weaponEffectivenessShields))
WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponEffectivenessShields [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponEffectivenessShields.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponEffectivenessShields [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponEffectivenessShields.c_str ()));
if (!objvars.getItem (Objvars::weaponEffectivenessArmor, m_weaponEffectivenessArmor)) if (!objvars.getItem (Objvars::weaponEffectivenessArmor, m_weaponEffectivenessArmor))
WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponEffectivenessArmor [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponEffectivenessArmor.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponEffectivenessArmor [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponEffectivenessArmor.c_str ()));
if (!objvars.getItem (Objvars::weaponEnergyPerShot, m_weaponEnergyPerShot)) if (!objvars.getItem (Objvars::weaponEnergyPerShot, m_weaponEnergyPerShot))
WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponEnergyPerShot [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponEnergyPerShot.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponEnergyPerShot [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponEnergyPerShot.c_str ()));
if (!objvars.getItem (Objvars::weaponRefireRate, m_weaponRefireRate)) if (!objvars.getItem (Objvars::weaponRefireRate, m_weaponRefireRate))
WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponRefireRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponRefireRate.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no weaponRefireRate [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponRefireRate.c_str ()));
if (!objvars.getItem (Objvars::weaponAmmoCurrent, m_weaponAmmoCurrent)) if (!objvars.getItem (Objvars::weaponAmmoCurrent, m_weaponAmmoCurrent))
WARNING (true, ("ShipComponentDataWeapon [%s] has no m_weaponAmmoCurrent [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponAmmoCurrent.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no m_weaponAmmoCurrent [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponAmmoCurrent.c_str ()));
if (!objvars.getItem (Objvars::weaponAmmoMaximum, m_weaponAmmoMaximum)) if (!objvars.getItem (Objvars::weaponAmmoMaximum, m_weaponAmmoMaximum))
WARNING (true, ("ShipComponentDataWeapon [%s] has no m_weaponAmmoMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponAmmoMaximum.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no m_weaponAmmoMaximum [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponAmmoMaximum.c_str ()));
int ammoType = 0; int ammoType = 0;
if (!objvars.getItem (Objvars::weaponAmmoType, ammoType)) if (!objvars.getItem (Objvars::weaponAmmoType, ammoType))
WARNING (true, ("ShipComponentDataWeapon [%s] has no m_weaponAmmoType [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponAmmoType.c_str ())); DEBUG_WARNING (true, ("ShipComponentDataWeapon [%s] has no m_weaponAmmoType [%s]", component.getNetworkId ().getValueString ().c_str (), Objvars::weaponAmmoType.c_str ()));
else else
m_weaponAmmoType = static_cast<uint32>(ammoType); m_weaponAmmoType = static_cast<uint32>(ammoType);
@@ -10,7 +10,7 @@
// ====================================================================== // ======================================================================
CharacterNamesMessage::CharacterNamesMessage(const std::vector<NetworkId> &ids, const std::vector<StationId> &stationIds, const std::vector<std::string> &characterNames, const std::vector<std::string> &characterFullNames, const std::vector<int64> &createTimes, const std::vector<int64> &loginTimes) : CharacterNamesMessage::CharacterNamesMessage(const std::vector<NetworkId> &ids, const std::vector<int> &stationIds, const std::vector<std::string> &characterNames, const std::vector<std::string> &characterFullNames, const std::vector<int> &createTimes, const std::vector<int> &loginTimes) :
GameNetworkMessage("CharacterNamesMessage"), GameNetworkMessage("CharacterNamesMessage"),
m_ids(), m_ids(),
m_stationIds(), m_stationIds(),
@@ -8,7 +8,6 @@
#ifndef INCLUDED_CharacterNamesMessage_H #ifndef INCLUDED_CharacterNamesMessage_H
#define INCLUDED_CharacterNamesMessage_H #define INCLUDED_CharacterNamesMessage_H
#include "sharedFoundation/StationId.h"
#include "sharedNetworkMessages/GameNetworkMessage.h" #include "sharedNetworkMessages/GameNetworkMessage.h"
// ====================================================================== // ======================================================================
@@ -22,24 +21,24 @@
class CharacterNamesMessage : public GameNetworkMessage class CharacterNamesMessage : public GameNetworkMessage
{ {
public: public:
CharacterNamesMessage(const std::vector<NetworkId> &ids, const std::vector<StationId> &stationIds, const std::vector<std::string> &characterNames, const std::vector<std::string> &characterFullNames, const std::vector<int64> &createTimes, const std::vector<int64> &loginTimes); CharacterNamesMessage(const std::vector<NetworkId> &ids, const std::vector<int> &stationIds, const std::vector<std::string> &characterNames, const std::vector<std::string> &characterFullNames, const std::vector<int> &createTimes, const std::vector<int> &loginTimes);
CharacterNamesMessage(Archive::ReadIterator & source); CharacterNamesMessage(Archive::ReadIterator & source);
~CharacterNamesMessage(); ~CharacterNamesMessage();
const std::vector<NetworkId> &getIds() const; const std::vector<NetworkId> &getIds() const;
const std::vector<StationId> &getStationIds() const; const std::vector<int> &getStationIds() const;
const std::vector<std::string> &getNames() const; const std::vector<std::string> &getNames() const;
const std::vector<std::string> &getFullNames() const; const std::vector<std::string> &getFullNames() const;
const std::vector<int64> &getCreateTimes() const; const std::vector<int> &getCreateTimes() const;
const std::vector<int64> &getLoginTimes() const; const std::vector<int> &getLoginTimes() const;
private: private:
Archive::AutoArray<NetworkId> m_ids; Archive::AutoArray<NetworkId> m_ids;
Archive::AutoArray<StationId> m_stationIds; Archive::AutoArray<int> m_stationIds;
Archive::AutoArray<std::string> m_names; Archive::AutoArray<std::string> m_names;
Archive::AutoArray<std::string> m_fullNames; Archive::AutoArray<std::string> m_fullNames;
Archive::AutoArray<int64> m_createTimes; Archive::AutoArray<int> m_createTimes;
Archive::AutoArray<int64> m_loginTimes; Archive::AutoArray<int> m_loginTimes;
private: private:
//disabled functions: //disabled functions:
@@ -58,7 +57,7 @@ inline const std::vector<NetworkId> & CharacterNamesMessage::getIds() const
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
inline const std::vector<StationId> & CharacterNamesMessage::getStationIds() const inline const std::vector<int> & CharacterNamesMessage::getStationIds() const
{ {
return m_stationIds.get(); return m_stationIds.get();
} }
@@ -79,14 +78,14 @@ inline const std::vector<std::string> & CharacterNamesMessage::getFullNames() co
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
inline const std::vector<int64> & CharacterNamesMessage::getCreateTimes() const inline const std::vector<int> & CharacterNamesMessage::getCreateTimes() const
{ {
return m_createTimes.get(); return m_createTimes.get();
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
inline const std::vector<int64> & CharacterNamesMessage::getLoginTimes() const inline const std::vector<int> & CharacterNamesMessage::getLoginTimes() const
{ {
return m_loginTimes.get(); return m_loginTimes.get();
} }
@@ -424,12 +424,12 @@ bool CityPathNode::sanityCheck ( bool doWarnings ) const
{ {
DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has an edge to a non-existent node\n")); DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has an edge to a non-existent node\n"));
insaneCount++; insaneCount++;
} } else {
if(!neighborNode->hasEdge(getIndex()))
if(!neighborNode->hasEdge(getIndex())) {
{ DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has a one-way edge to another node\n"));
DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has a one-way edge to another node\n")); insaneCount++;
insaneCount++; }
} }
} }
@@ -1141,30 +1141,31 @@ void ServerPathBuilder::addPathNode ( CellProperty const * cell, PathNode const
float dist2 = REAL_MAX; float dist2 = REAL_MAX;
if(m_path && !m_path->empty()) dist2 = m_path->back().getPosition_w().magnitudeBetweenSquared(loc.getPosition_w()); if(m_path && !m_path->empty()) {
dist2 = m_path->back().getPosition_w().magnitudeBetweenSquared(loc.getPosition_w());
if(dist2 > 0.01) if(dist2 > 0.01)
{
// jitter the node if it's a city waypoint
if(m_enableJitter && (node->getType() == PNT_CityWaypoint))
{ {
Vector offset = Vector::zero; // jitter the node if it's a city waypoint
if(m_enableJitter && (node->getType() == PNT_CityWaypoint))
do
{ {
offset = Vector( Random::randomReal(-1.0f,1.0f), 0.0f, Random::randomReal(-1.0f,1.0f) ); Vector offset = Vector::zero;
do
{
offset = Vector( Random::randomReal(-1.0f,1.0f), 0.0f, Random::randomReal(-1.0f,1.0f) );
}
while(offset.magnitudeSquared() > 1.0f);
static float tweakValue = 1.0f;
offset *= tweakValue;
loc.setPosition_p( loc.getPosition_p() + offset );
} }
while(offset.magnitudeSquared() > 1.0f);
static float tweakValue = 1.0f; m_path->push_back(loc);
offset *= tweakValue;
loc.setPosition_p( loc.getPosition_p() + offset );
} }
m_path->push_back(loc);
} }
} }
@@ -954,13 +954,13 @@ void JavaLibrary::install(void)
if (ms_instance == nullptr) if (ms_instance == nullptr)
{ {
JavaLibrary *lib = new JavaLibrary; JavaLibrary *lib = new JavaLibrary;
if (lib != ms_instance) if (lib)
{ {
if (ms_instance == nullptr) ms_instance = lib;
{ } else {
delete lib; delete lib;
if (ms_javaVmType != JV_none) if (ms_javaVmType != JV_none) {
FATAL(true, ("Unable to initialize Java")); FATAL(true, ("Unable to initialize Java"));
} }
} }
} }
@@ -975,7 +975,7 @@ void JavaLibrary::install(void)
*/ */
void JavaLibrary::remove(void) void JavaLibrary::remove(void)
{ {
if (ms_instance != nullptr) if (ms_instance)
{ {
JavaLibrary * temp = ms_instance; JavaLibrary * temp = ms_instance;
ms_instance = nullptr; ms_instance = nullptr;
@@ -1065,7 +1065,7 @@ void JavaLibrary::initializeJavaThread()
} }
// initial and minimum jvm allocation size // initial and minimum jvm allocation size
tempOption.optionString = "-Xms128m"; tempOption.optionString = "-Xms1m";
options.push_back(tempOption); options.push_back(tempOption);
// maximum jvm allocation - max 512m on 32-bit // maximum jvm allocation - max 512m on 32-bit
@@ -3985,6 +3985,7 @@ void JavaLibrary::alterScriptParams(jobjectArray jparams, const std::string& arg
else else
{ {
WARNING_STRICT_FATAL(true, ("Error getting back string id param on script return")); WARNING_STRICT_FATAL(true, ("Error getting back string id param on script return"));
delete value;
} }
} }
break; break;
@@ -118,13 +118,10 @@ File fp;
return; return;
File temp_fp; File temp_fp;
char tmpname[] = "/tmp/templatecompXXXXXX"; if (!temp_fp.open(tmpnam(nullptr), "wt"))
int tmpfd = mkstemp(tmpname);
if (tmpfd >= 0 && temp_fp.open(tmpname, "wt"))
{ {
fprintf(stderr, "error opening temp file for template header " fprintf(stderr, "error opening temp file for template header "
"replacement [%s]\n", fp.getFilename().getFullFilename().c_str()); "replacement [%s]\n", temp_fp.getFilename().getFullFilename().c_str());
return; return;
} }
@@ -175,7 +172,7 @@ File fp;
} }
else if (temp_fp.puts(buffer) < 0) else if (temp_fp.puts(buffer) < 0)
{ {
fprintf(stderr, "error writing to temp header file [%s]\n", fp.getFilename().getFullFilename().c_str()); fprintf(stderr, "error writing to temp header file [%s]\n", temp_fp.getFilename().getFullFilename().c_str());
return; return;
} }
} }
@@ -246,11 +243,8 @@ int result;
return -1; return -1;
} }
File temp_fp; File temp_fp;
char tmpname[] = "/tmp/templatecompXXXXXX"; if (!temp_fp.open(tmpnam(nullptr), "wt"))
int tmpfd = mkstemp(tmpname);
if (tmpfd >= 0 && temp_fp.open(tmpname, "wt"))
{ {
fprintf(stderr, "error opening temp file for template source " fprintf(stderr, "error opening temp file for template source "
"replacement [%s]\n", temp_fp.getFilename().getFullFilename().c_str()); "replacement [%s]\n", temp_fp.getFilename().getFullFilename().c_str());
@@ -29,14 +29,10 @@ namespace DB {
void setValue(const long int rhs); void setValue(const long int rhs);
BindableLong &operator=(const long int rhs); BindableLong &operator=(const long int rhs);
// following alternate getValue's are provided for convenience, particularly in template <typename T>
// the auto-generated code: inline void getValue(T &buffer) const {
void getValue(unsigned int &buffer) const; buffer = static_cast<T>(getValue());
void getValue(uint32 &buffer) const; // for some reason, our compiler is convinced that uint32 != unsigned int }
void getValue(long int &buffer) const;
void getValue(int &buffer) const;
void getValue(int8 &buffer) const;
void getValue(uint8 &buffer) const;
void *getBuffer(); void *getBuffer();
@@ -48,48 +44,4 @@ namespace DB {
} }
// ----------------------------------------------------------------------
inline void DB::BindableLong::getValue(unsigned int &buffer) const
{
buffer=static_cast<unsigned int>(getValue());
}
// ----------------------------------------------------------------------
inline void DB::BindableLong::getValue(uint32 &buffer) const
{
buffer=static_cast<uint32>(getValue());
}
// ----------------------------------------------------------------------
inline void DB::BindableLong::getValue(long int &buffer) const
{
buffer=getValue();
}
// ----------------------------------------------------------------------
inline void DB::BindableLong::getValue(int &buffer) const
{
buffer=getValue();
}
// ----------------------------------------------------------------------
inline void DB::BindableLong::getValue(int8 &buffer) const
{
buffer=static_cast<int8>(getValue());
}
// ----------------------------------------------------------------------
inline void DB::BindableLong::getValue(uint8 &buffer) const
{
buffer=static_cast<uint8>(getValue());
}
// ======================================================================
#endif #endif
@@ -68,18 +68,17 @@ bool DB::OCIServer::checkerr(OCISession const & session, int status)
WARNING(true,("Database error: %.*s",512,errbuf)); WARNING(true,("Database error: %.*s",512,errbuf));
LOG("DatabaseError",("Database error: %.*s",512,errbuf)); LOG("DatabaseError",("Database error: %.*s",512,errbuf));
FATAL(DB::Server::getFatalOnError() || session.getFatalOnError(),("Database error: %.*s",512,errbuf));
switch ((int) errcode) switch ((int) errcode)
{ {
case 1013: case 1013:
FATAL(true,("Cancelled by user request (ctrl-c or kill signal).\n")); FATAL(DB::Server::getFatalOnError() || session.getFatalOnError(),("Cancelled by user request (ctrl-c or kill signal).\n"));
break; break;
case 12541: case 12541:
REPORT_LOG(true,("Database Error - %.*s\n", 512, errbuf)); REPORT_LOG(true,("Database Error - %.*s\n", 512, errbuf));
return false; return false;
default: default:
FATAL(true,("Unhandled Database Error - %.*s\n", 512, errbuf)); FATAL(DB::Server::getFatalOnError() || session.getFatalOnError(),("Unhandled Database Error - %.*s\n", 512, errbuf));
break; break;
} }
@@ -81,7 +81,13 @@ char SymbolCache::ms_memPool[SymbolCache::cms_memPoolMaxBytes];
char *SymbolCache::ms_memPoolFreeList; char *SymbolCache::ms_memPoolFreeList;
Mutex SymbolCache::ms_memPoolMutex; Mutex SymbolCache::ms_memPoolMutex;
SymbolCache::SymbolInfo SymbolCache::ms_nullSym; SymbolCache::SymbolInfo SymbolCache::ms_nullSym;
typedef std::map<void const *, SymbolCache::SymbolInfo, std::less<void const *>, SymbolCacheAllocator<std::pair<void const *, SymbolCache::SymbolInfo> > > SymbolMap;
typedef std::map<
void const *,
SymbolCache::SymbolInfo
> SymbolMap;
typedef std::vector<char const *, SymbolCacheAllocator<char const *> > UniqueStringVector; typedef std::vector<char const *, SymbolCacheAllocator<char const *> > UniqueStringVector;
static SymbolMap ms_cacheMap; static SymbolMap ms_cacheMap;
static UniqueStringVector ms_uniqueStringVector; static UniqueStringVector ms_uniqueStringVector;
@@ -567,7 +573,7 @@ static bool stabsFind(void const *addr, Dl_info const &info, char const *& retSr
SymbolCache::SymbolInfo const &SymbolCache::lookup(void const *addr) SymbolCache::SymbolInfo const &SymbolCache::lookup(void const *addr)
{ {
SymbolMap::const_iterator i = ms_cacheMap.find(addr); auto i = ms_cacheMap.find(addr);
if (i != ms_cacheMap.end()) if (i != ms_cacheMap.end())
return (*i).second; return (*i).second;
@@ -3,6 +3,7 @@
// CrcConstexpr.hpp // CrcConstexpr.hpp
// //
// adapted from Ross Williams' public domain crc code. // adapted from Ross Williams' public domain crc code.
// copied and modified to work as a constexpr by Darth
// //
// Portions copyright 1998 Bootprint Entertainment // Portions copyright 1998 Bootprint Entertainment
// Portions copyright 2002 Sony Online Entertainment // Portions copyright 2002 Sony Online Entertainment
@@ -54,16 +55,27 @@ constexpr uint32 CRC_INIT = 0xFFFFFFFF;
constexpr const uint32 constcrc(const char *string) constexpr const uint32 constcrc(const char *string)
{ {
uint32 crc = 0;
if (!string) if (!string)
return 0; return 0;
uint32 crc = 0;
for (crc = CRC_INIT; *string; ++string) for (crc = CRC_INIT; *string; ++string)
crc = crctable[((crc>>24) ^ static_cast<byte>(*string)) & 0xFF] ^ (crc << 8); crc = crctable[((crc>>24) ^ static_cast<byte>(*string)) & 0xFF] ^ (crc << 8);
return (crc ^ CRC_INIT); return (crc ^ CRC_INIT);
} }
inline const uint32 runtimeCrc(const char *string)
{
if (!string)
return 0;
uint32 crc = 0;
for (crc = CRC_INIT; *string; ++string)
crc = crctable[((crc>>24) ^ static_cast<byte>(*string)) & 0xFF] ^ (crc << 8);
return (crc ^ CRC_INIT);
}
// ====================================================================== // ======================================================================
@@ -57,7 +57,6 @@ static const uint32 crctable[256] =
}; };
const uint32 CRC_INIT = 0xFFFFFFFF; const uint32 CRC_INIT = 0xFFFFFFFF;
const uint32 Crc::crcInit = CRC_INIT; const uint32 Crc::crcInit = CRC_INIT;
@@ -65,11 +64,10 @@ const uint32 Crc::crcInit = CRC_INIT;
uint32 Crc::calculate(const char *string) uint32 Crc::calculate(const char *string)
{ {
uint32 crc;
if (!string) if (!string)
return 0; return 0;
uint32 crc = 0;
for (crc = CRC_INIT; *string; ++string) for (crc = CRC_INIT; *string; ++string)
crc = crctable[((crc>>24) ^ static_cast<byte>(*string)) & 0xFF] ^ (crc << 8); crc = crctable[((crc>>24) ^ static_cast<byte>(*string)) & 0xFF] ^ (crc << 8);
@@ -10,7 +10,8 @@
// ====================================================================== // ======================================================================
typedef int64 StationId; // if this is per the SOE provided types header, this is acutally an unsigned long and not a uint32_t
typedef uint32 StationId;
// ====================================================================== // ======================================================================
@@ -10,8 +10,6 @@
#define PLATFORM_LINUX #define PLATFORM_LINUX
#include <cstdio> #include <cstdio>
#include <sys/bitypes.h>
// ====================================================================== // ======================================================================
// basic types that we assume to be around // basic types that we assume to be around
@@ -22,12 +20,11 @@ typedef unsigned long uint32;
typedef signed char int8; typedef signed char int8;
typedef signed short int16; typedef signed short int16;
typedef signed long int32; typedef signed long int32;
typedef signed long long int int64;
typedef unsigned long long int uint64;
typedef float real; typedef float real;
typedef FILE* FILE_HANDLE; typedef FILE* FILE_HANDLE;
typedef int64_t int64;
typedef u_int64_t uint64;
#endif #endif
@@ -7,8 +7,6 @@
// //
// ====================================================================== // ======================================================================
#include <sys/bitypes.h>
#ifndef INCLUDED_FoundationTypesWin32_H #ifndef INCLUDED_FoundationTypesWin32_H
#define INCLUDED_FoundationTypesWin32_H #define INCLUDED_FoundationTypesWin32_H
@@ -30,10 +28,6 @@ typedef signed long int32;
typedef signed __int64 int64; typedef signed __int64 int64;
typedef int FILE_HANDLE; typedef int FILE_HANDLE;
typedef int64_t int64;
typedef u_int64_t uint64;
// ====================================================================== // ======================================================================
#endif #endif
@@ -17,6 +17,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -557,10 +560,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "numberOfPoles") == 0)
m_numberOfPoles.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "radius") == 0) case constcrc("numberOfPoles"):
m_radius.loadFromIff(file); m_numberOfPoles.loadFromIff(file);
break;
case constcrc("radius"):
m_radius.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -254,10 +257,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "terrainModificationFileName") == 0)
m_terrainModificationFileName.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "interiorLayoutFileName") == 0) case constcrc("terrainModificationFileName"):
m_interiorLayoutFileName.loadFromIff(file); m_terrainModificationFileName.loadFromIff(file);
break;
case constcrc("interiorLayoutFileName"):
m_interiorLayoutFileName.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -22,6 +22,9 @@
#include "sharedObject/Object.h" #include "sharedObject/Object.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedObject/BasicRangedIntCustomizationVariable.h" #include "sharedObject/BasicRangedIntCustomizationVariable.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -3286,98 +3289,123 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "gender") == 0)
m_gender.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "niche") == 0) case constcrc("gender"):
m_niche.loadFromIff(file); m_gender.loadFromIff(file);
else if (strcmp(paramName, "species") == 0) break;
m_species.loadFromIff(file); case constcrc("niche"):
else if (strcmp(paramName, "race") == 0) m_niche.loadFromIff(file);
m_race.loadFromIff(file); break;
else if (strcmp(paramName, "acceleration") == 0) case constcrc("species"):
{ m_species.loadFromIff(file);
int listCount = file.read_int32(); break;
DEBUG_WARNING(listCount != 2, ("Template %s: read array size of %d for array \"acceleration\" of size 2, reading values anyway", file.getFileName(), listCount)); case constcrc("race"):
int j; m_race.loadFromIff(file);
for (j = 0; j < 2 && j < listCount; ++j) break;
m_acceleration[j].loadFromIff(file); case constcrc("acceleration"):
// if there are more params for acceleration read and dump them
for (; j < listCount; ++j)
{ {
FloatParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); DEBUG_WARNING(listCount != 2, ("Template %s: read array size of %d for array \"acceleration\" of size 2, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 2 && j < listCount; ++j)
m_acceleration[j].loadFromIff(file);
// if there are more params for acceleration read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
} }
} break;
else if (strcmp(paramName, "speed") == 0) case constcrc("speed"):
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 2, ("Template %s: read array size of %d for array \"speed\" of size 2, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 2 && j < listCount; ++j)
m_speed[j].loadFromIff(file);
// if there are more params for speed read and dump them
for (; j < listCount; ++j)
{ {
FloatParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); DEBUG_WARNING(listCount != 2, ("Template %s: read array size of %d for array \"speed\" of size 2, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 2 && j < listCount; ++j)
m_speed[j].loadFromIff(file);
// if there are more params for speed read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
} }
} break;
else if (strcmp(paramName, "turnRate") == 0) case constcrc("turnRate"):
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 2, ("Template %s: read array size of %d for array \"turnRate\" of size 2, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 2 && j < listCount; ++j)
m_turnRate[j].loadFromIff(file);
// if there are more params for turnRate read and dump them
for (; j < listCount; ++j)
{ {
FloatParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); DEBUG_WARNING(listCount != 2, ("Template %s: read array size of %d for array \"turnRate\" of size 2, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 2 && j < listCount; ++j)
m_turnRate[j].loadFromIff(file);
// if there are more params for turnRate read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
} }
} break;
else if (strcmp(paramName, "animationMapFilename") == 0) case constcrc("animationMapFilename"):
m_animationMapFilename.loadFromIff(file); m_animationMapFilename.loadFromIff(file);
else if (strcmp(paramName, "slopeModAngle") == 0) break;
m_slopeModAngle.loadFromIff(file); case constcrc("slopeModAngle"):
else if (strcmp(paramName, "slopeModPercent") == 0) m_slopeModAngle.loadFromIff(file);
m_slopeModPercent.loadFromIff(file); break;
else if (strcmp(paramName, "waterModPercent") == 0) case constcrc("slopeModPercent"):
m_waterModPercent.loadFromIff(file); m_slopeModPercent.loadFromIff(file);
else if (strcmp(paramName, "stepHeight") == 0) break;
m_stepHeight.loadFromIff(file); case constcrc("waterModPercent"):
else if (strcmp(paramName, "collisionHeight") == 0) m_waterModPercent.loadFromIff(file);
m_collisionHeight.loadFromIff(file); break;
else if (strcmp(paramName, "collisionRadius") == 0) case constcrc("stepHeight"):
m_collisionRadius.loadFromIff(file); m_stepHeight.loadFromIff(file);
else if (strcmp(paramName, "movementDatatable") == 0) break;
m_movementDatatable.loadFromIff(file); case constcrc("collisionHeight"):
else if (strcmp(paramName, "postureAlignToTerrain") == 0) m_collisionHeight.loadFromIff(file);
{ break;
int listCount = file.read_int32(); case constcrc("collisionRadius"):
DEBUG_WARNING(listCount != 15, ("Template %s: read array size of %d for array \"postureAlignToTerrain\" of size 15, reading values anyway", file.getFileName(), listCount)); m_collisionRadius.loadFromIff(file);
int j; break;
for (j = 0; j < 15 && j < listCount; ++j) case constcrc("movementDatatable"):
m_postureAlignToTerrain[j].loadFromIff(file); m_movementDatatable.loadFromIff(file);
// if there are more params for postureAlignToTerrain read and dump them break;
for (; j < listCount; ++j) case constcrc("postureAlignToTerrain"):
{ {
BoolParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); DEBUG_WARNING(listCount != 15, ("Template %s: read array size of %d for array \"postureAlignToTerrain\" of size 15, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 15 && j < listCount; ++j)
m_postureAlignToTerrain[j].loadFromIff(file);
// if there are more params for postureAlignToTerrain read and dump them
for (; j < listCount; ++j)
{
BoolParam dummy;
dummy.loadFromIff(file);
}
} }
break;
case constcrc("swimHeight"):
m_swimHeight.loadFromIff(file);
break;
case constcrc("warpTolerance"):
m_warpTolerance.loadFromIff(file);
break;
case constcrc("collisionOffsetX"):
m_collisionOffsetX.loadFromIff(file);
break;
case constcrc("collisionOffsetZ"):
m_collisionOffsetZ.loadFromIff(file);
break;
case constcrc("collisionLength"):
m_collisionLength.loadFromIff(file);
break;
case constcrc("cameraHeight"):
m_cameraHeight.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "swimHeight") == 0)
m_swimHeight.loadFromIff(file);
else if (strcmp(paramName, "warpTolerance") == 0)
m_warpTolerance.loadFromIff(file);
else if (strcmp(paramName, "collisionOffsetX") == 0)
m_collisionOffsetX.loadFromIff(file);
else if (strcmp(paramName, "collisionOffsetZ") == 0)
m_collisionOffsetZ.loadFromIff(file);
else if (strcmp(paramName, "collisionLength") == 0)
m_collisionLength.loadFromIff(file);
else if (strcmp(paramName, "cameraHeight") == 0)
m_cameraHeight.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -542,46 +545,52 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "slots") == 0)
{ switch(runtimeCrc(paramName)) {
std::vector<StructParamOT *>::iterator iter; case constcrc("slots"):
for (iter = m_slots.begin(); iter != m_slots.end(); ++iter)
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_slots.begin(); iter != m_slots.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_slots.clear();
m_slotsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_slots.push_back(newData);
}
m_slotsLoaded = true;
} }
m_slots.clear(); break;
m_slotsAppend = file.read_bool8(); case constcrc("attributes"):
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{ {
StructParamOT * newData = new StructParamOT; std::vector<StructParamOT *>::iterator iter;
newData->loadFromIff(file); for (iter = m_attributes.begin(); iter != m_attributes.end(); ++iter)
m_slots.push_back(newData); {
delete *iter;
*iter = nullptr;
}
m_attributes.clear();
m_attributesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_attributes.push_back(newData);
}
m_attributesLoaded = true;
} }
m_slotsLoaded = true; break;
case constcrc("craftedSharedTemplate"):
m_craftedSharedTemplate.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "attributes") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_attributes.begin(); iter != m_attributes.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_attributes.clear();
m_attributesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_attributes.push_back(newData);
}
m_attributesLoaded = true;
}
else if (strcmp(paramName, "craftedSharedTemplate") == 0)
m_craftedSharedTemplate.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -753,10 +762,14 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "name") == 0)
m_name.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "hardpoint") == 0) case constcrc("name"):
m_hardpoint.loadFromIff(file); m_name.loadFromIff(file);
break;
case constcrc("hardpoint"):
m_hardpoint.loadFromIff(file);
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1120,12 +1133,18 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "name") == 0)
m_name.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "experiment") == 0) case constcrc("name"):
m_experiment.loadFromIff(file); m_name.loadFromIff(file);
else if (strcmp(paramName, "value") == 0) break;
m_value.loadFromIff(file); case constcrc("experiment"):
m_experiment.loadFromIff(file);
break;
case constcrc("value"):
m_value.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -26,6 +26,9 @@
#include "sharedObject/PortalPropertyTemplateList.h" #include "sharedObject/PortalPropertyTemplateList.h"
#include "sharedObject/SlotDescriptor.h" #include "sharedObject/SlotDescriptor.h"
#include "sharedObject/SlotDescriptorList.h" #include "sharedObject/SlotDescriptorList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -2135,8 +2138,8 @@ void SharedObjectTemplate::testValues(void) const
*/ */
void SharedObjectTemplate::load(Iff &file) void SharedObjectTemplate::load(Iff &file)
{ {
static const int MAX_NAME_SIZE = 256; static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE]; char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != SharedObjectTemplate_tag) if (file.getCurrentName() != SharedObjectTemplate_tag)
{ {
@@ -2177,54 +2180,81 @@ char paramName[MAX_NAME_SIZE];
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i)
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "objectName") == 0)
switch (runtimeCrc(paramName)) {
case constcrc("objectName"):
m_objectName.loadFromIff(file); m_objectName.loadFromIff(file);
else if (strcmp(paramName, "detailedDescription") == 0) break;
case constcrc("detailedDescription"):
m_detailedDescription.loadFromIff(file); m_detailedDescription.loadFromIff(file);
else if (strcmp(paramName, "lookAtText") == 0) break;
case constcrc("lookAtText"):
m_lookAtText.loadFromIff(file); m_lookAtText.loadFromIff(file);
else if (strcmp(paramName, "snapToTerrain") == 0) break;
case constcrc("snapToTerrain"):
m_snapToTerrain.loadFromIff(file); m_snapToTerrain.loadFromIff(file);
else if (strcmp(paramName, "containerType") == 0) break;
case constcrc("containerType"):
m_containerType.loadFromIff(file); m_containerType.loadFromIff(file);
else if (strcmp(paramName, "containerVolumeLimit") == 0) break;
case constcrc("containerVolumeLimit"):
m_containerVolumeLimit.loadFromIff(file); m_containerVolumeLimit.loadFromIff(file);
else if (strcmp(paramName, "tintPalette") == 0) break;
case constcrc("tintPalette"):
m_tintPalette.loadFromIff(file); m_tintPalette.loadFromIff(file);
else if (strcmp(paramName, "slotDescriptorFilename") == 0) break;
case constcrc("slotDescriptorFilename"):
m_slotDescriptorFilename.loadFromIff(file); m_slotDescriptorFilename.loadFromIff(file);
else if (strcmp(paramName, "arrangementDescriptorFilename") == 0) break;
case constcrc("arrangementDescriptorFilename"):
m_arrangementDescriptorFilename.loadFromIff(file); m_arrangementDescriptorFilename.loadFromIff(file);
else if (strcmp(paramName, "appearanceFilename") == 0) break;
case constcrc("appearanceFilename"):
m_appearanceFilename.loadFromIff(file); m_appearanceFilename.loadFromIff(file);
else if (strcmp(paramName, "portalLayoutFilename") == 0) break;
case constcrc("portalLayoutFilename"):
m_portalLayoutFilename.loadFromIff(file); m_portalLayoutFilename.loadFromIff(file);
else if (strcmp(paramName, "clientDataFile") == 0) break;
case constcrc("clientDataFile"):
m_clientDataFile.loadFromIff(file); m_clientDataFile.loadFromIff(file);
else if (strcmp(paramName, "scale") == 0) break;
case constcrc("scale"):
m_scale.loadFromIff(file); m_scale.loadFromIff(file);
else if (strcmp(paramName, "gameObjectType") == 0) break;
case constcrc("gameObjectType"):
m_gameObjectType.loadFromIff(file); m_gameObjectType.loadFromIff(file);
else if (strcmp(paramName, "sendToClient") == 0) break;
case constcrc("sendToClient"):
m_sendToClient.loadFromIff(file); m_sendToClient.loadFromIff(file);
else if (strcmp(paramName, "scaleThresholdBeforeExtentTest") == 0) break;
case constcrc("scaleThresholdBeforeExtentTest"):
m_scaleThresholdBeforeExtentTest.loadFromIff(file); m_scaleThresholdBeforeExtentTest.loadFromIff(file);
else if (strcmp(paramName, "clearFloraRadius") == 0) break;
case constcrc("clearFloraRadius"):
m_clearFloraRadius.loadFromIff(file); m_clearFloraRadius.loadFromIff(file);
else if (strcmp(paramName, "surfaceType") == 0) break;
case constcrc("surfaceType"):
m_surfaceType.loadFromIff(file); m_surfaceType.loadFromIff(file);
else if (strcmp(paramName, "noBuildRadius") == 0) break;
case constcrc("noBuildRadius"):
m_noBuildRadius.loadFromIff(file); m_noBuildRadius.loadFromIff(file);
else if (strcmp(paramName, "onlyVisibleInTools") == 0) break;
case constcrc("onlyVisibleInTools"):
m_onlyVisibleInTools.loadFromIff(file); m_onlyVisibleInTools.loadFromIff(file);
else if (strcmp(paramName, "locationReservationRadius") == 0) break;
case constcrc("locationReservationRadius"):
m_locationReservationRadius.loadFromIff(file); m_locationReservationRadius.loadFromIff(file);
else if (strcmp(paramName, "forceNoCollision") == 0) break;
case constcrc("forceNoCollision"):
m_forceNoCollision.loadFromIff(file); m_forceNoCollision.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -23,6 +23,8 @@
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -384,14 +386,21 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "cockpitFilename") == 0)
m_cockpitFilename.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "hasWings") == 0) case constcrc("cockpitFilename"):
m_hasWings.loadFromIff(file); m_cockpitFilename.loadFromIff(file);
else if (strcmp(paramName, "playerControlled") == 0) break;
m_playerControlled.loadFromIff(file); case constcrc("hasWings"):
else if (strcmp(paramName, "interiorLayoutFileName") == 0) m_hasWings.loadFromIff(file);
m_interiorLayoutFileName.loadFromIff(file); break;
case constcrc("playerControlled"):
m_playerControlled.loadFromIff(file);
break;
case constcrc("interiorLayoutFileName"):
m_interiorLayoutFileName.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -25,6 +25,9 @@
#include "sharedObject/PaletteColorCustomizationVariable.h" #include "sharedObject/PaletteColorCustomizationVariable.h"
#include "sharedObject/StructureFootprint.h" #include "sharedObject/StructureFootprint.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -1328,128 +1331,141 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "paletteColorCustomizationVariables") == 0)
{ switch(runtimeCrc(paramName)) {
std::vector<StructParamOT *>::iterator iter; case constcrc("paletteColorCustomizationVariables"):
for (iter = m_paletteColorCustomizationVariables.begin(); iter != m_paletteColorCustomizationVariables.end(); ++iter)
{ {
delete *iter; std::vector<StructParamOT *>::iterator iter;
*iter = nullptr; for (iter = m_paletteColorCustomizationVariables.begin(); iter != m_paletteColorCustomizationVariables.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_paletteColorCustomizationVariables.clear();
m_paletteColorCustomizationVariablesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_paletteColorCustomizationVariables.push_back(newData);
}
m_paletteColorCustomizationVariablesLoaded = true;
} }
m_paletteColorCustomizationVariables.clear(); break;
m_paletteColorCustomizationVariablesAppend = file.read_bool8(); case constcrc("rangedIntCustomizationVariables"):
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{ {
StructParamOT * newData = new StructParamOT; std::vector<StructParamOT *>::iterator iter;
newData->loadFromIff(file); for (iter = m_rangedIntCustomizationVariables.begin(); iter != m_rangedIntCustomizationVariables.end(); ++iter)
m_paletteColorCustomizationVariables.push_back(newData); {
delete *iter;
*iter = nullptr;
}
m_rangedIntCustomizationVariables.clear();
m_rangedIntCustomizationVariablesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_rangedIntCustomizationVariables.push_back(newData);
}
m_rangedIntCustomizationVariablesLoaded = true;
} }
m_paletteColorCustomizationVariablesLoaded = true; break;
case constcrc("constStringCustomizationVariables"):
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_constStringCustomizationVariables.begin(); iter != m_constStringCustomizationVariables.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_constStringCustomizationVariables.clear();
m_constStringCustomizationVariablesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_constStringCustomizationVariables.push_back(newData);
}
m_constStringCustomizationVariablesLoaded = true;
}
break;
case constcrc("socketDestinations"):
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_socketDestinations.begin(); iter != m_socketDestinations.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_socketDestinations.clear();
m_socketDestinationsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_socketDestinations.push_back(newData);
}
m_socketDestinationsLoaded = true;
}
break;
case constcrc("structureFootprintFileName"):
m_structureFootprintFileName.loadFromIff(file);
break;
case constcrc("useStructureFootprintOutline"):
m_useStructureFootprintOutline.loadFromIff(file);
break;
case constcrc("targetable"):
m_targetable.loadFromIff(file);
break;
case constcrc("certificationsRequired"):
{
std::vector<StringParam *>::iterator iter;
for (iter = m_certificationsRequired.begin(); iter != m_certificationsRequired.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_certificationsRequired.clear();
m_certificationsRequiredAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_certificationsRequired.push_back(newData);
}
m_certificationsRequiredLoaded = true;
}
break;
case constcrc("customizationVariableMapping"):
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_customizationVariableMapping.begin(); iter != m_customizationVariableMapping.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_customizationVariableMapping.clear();
m_customizationVariableMappingAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_customizationVariableMapping.push_back(newData);
}
m_customizationVariableMappingLoaded = true;
}
break;
case constcrc("clientVisabilityFlag"):
m_clientVisabilityFlag.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "rangedIntCustomizationVariables") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_rangedIntCustomizationVariables.begin(); iter != m_rangedIntCustomizationVariables.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_rangedIntCustomizationVariables.clear();
m_rangedIntCustomizationVariablesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_rangedIntCustomizationVariables.push_back(newData);
}
m_rangedIntCustomizationVariablesLoaded = true;
}
else if (strcmp(paramName, "constStringCustomizationVariables") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_constStringCustomizationVariables.begin(); iter != m_constStringCustomizationVariables.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_constStringCustomizationVariables.clear();
m_constStringCustomizationVariablesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_constStringCustomizationVariables.push_back(newData);
}
m_constStringCustomizationVariablesLoaded = true;
}
else if (strcmp(paramName, "socketDestinations") == 0)
{
std::vector<IntegerParam *>::iterator iter;
for (iter = m_socketDestinations.begin(); iter != m_socketDestinations.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_socketDestinations.clear();
m_socketDestinationsAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
IntegerParam * newData = new IntegerParam;
newData->loadFromIff(file);
m_socketDestinations.push_back(newData);
}
m_socketDestinationsLoaded = true;
}
else if (strcmp(paramName, "structureFootprintFileName") == 0)
m_structureFootprintFileName.loadFromIff(file);
else if (strcmp(paramName, "useStructureFootprintOutline") == 0)
m_useStructureFootprintOutline.loadFromIff(file);
else if (strcmp(paramName, "targetable") == 0)
m_targetable.loadFromIff(file);
else if (strcmp(paramName, "certificationsRequired") == 0)
{
std::vector<StringParam *>::iterator iter;
for (iter = m_certificationsRequired.begin(); iter != m_certificationsRequired.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_certificationsRequired.clear();
m_certificationsRequiredAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StringParam * newData = new StringParam;
newData->loadFromIff(file);
m_certificationsRequired.push_back(newData);
}
m_certificationsRequiredLoaded = true;
}
else if (strcmp(paramName, "customizationVariableMapping") == 0)
{
std::vector<StructParamOT *>::iterator iter;
for (iter = m_customizationVariableMapping.begin(); iter != m_customizationVariableMapping.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_customizationVariableMapping.clear();
m_customizationVariableMappingAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
StructParamOT * newData = new StructParamOT;
newData->loadFromIff(file);
m_customizationVariableMapping.push_back(newData);
}
m_customizationVariableMappingLoaded = true;
}
else if (strcmp(paramName, "clientVisabilityFlag") == 0)
m_clientVisabilityFlag.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1621,10 +1637,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "variableName") == 0)
m_variableName.loadFromIff(file); switch(runtimeCrc(paramName)){
else if (strcmp(paramName, "constValue") == 0) case constcrc("variableName"):
m_constValue.loadFromIff(file); m_variableName.loadFromIff(file);
break;
case constcrc("constValue"):
m_constValue.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -1794,10 +1815,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "sourceVariable") == 0)
m_sourceVariable.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "dependentVariable") == 0) case constcrc("sourceVariable"):
m_dependentVariable.loadFromIff(file); m_sourceVariable.loadFromIff(file);
break;
case constcrc("dependentVariable"):
m_dependentVariable.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -2161,12 +2187,18 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "variableName") == 0)
m_variableName.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "palettePathName") == 0) case constcrc("variableName"):
m_palettePathName.loadFromIff(file); m_variableName.loadFromIff(file);
else if (strcmp(paramName, "defaultPaletteIndex") == 0) break;
m_defaultPaletteIndex.loadFromIff(file); case constcrc("palettePathName"):
m_palettePathName.loadFromIff(file);
break;
case constcrc("defaultPaletteIndex"):
m_defaultPaletteIndex.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -2875,14 +2907,21 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "variableName") == 0)
m_variableName.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "minValueInclusive") == 0) case constcrc("variableName"):
m_minValueInclusive.loadFromIff(file); m_variableName.loadFromIff(file);
else if (strcmp(paramName, "defaultValue") == 0) break;
m_defaultValue.loadFromIff(file); case constcrc("minValueInclusive"):
else if (strcmp(paramName, "maxValueExclusive") == 0) m_minValueInclusive.loadFromIff(file);
m_maxValueExclusive.loadFromIff(file); break;
case constcrc("defaultValue"):
m_defaultValue.loadFromIff(file);
break;
case constcrc("maxValueExclusive"):
m_maxValueExclusive.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedFile/Iff.h" #include "sharedFile/Iff.h"
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -403,10 +406,15 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "cover") == 0)
m_cover.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "surfaceType") == 0) case constcrc("cover"):
m_surfaceType.loadFromIff(file); m_cover.loadFromIff(file);
break;
case constcrc("surfaceType"):
m_surfaceType.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -1479,32 +1482,42 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "speed") == 0)
{ switch(runtimeCrc(paramName)) {
int listCount = file.read_int32(); case constcrc("speed"):
DEBUG_WARNING(listCount != 5, ("Template %s: read array size of %d for array \"speed\" of size 5, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 5 && j < listCount; ++j)
m_speed[j].loadFromIff(file);
// if there are more params for speed read and dump them
for (; j < listCount; ++j)
{ {
FloatParam dummy; int listCount = file.read_int32();
dummy.loadFromIff(file); DEBUG_WARNING(listCount != 5, ("Template %s: read array size of %d for array \"speed\" of size 5, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 5 && j < listCount; ++j)
m_speed[j].loadFromIff(file);
// if there are more params for speed read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
} }
break;
case constcrc("slopeAversion"):
m_slopeAversion.loadFromIff(file);
break;
case constcrc("hoverValue"):
m_hoverValue.loadFromIff(file);
break;
case constcrc("turnRate"):
m_turnRate.loadFromIff(file);
break;
case constcrc("maxVelocity"):
m_maxVelocity.loadFromIff(file);
break;
case constcrc("acceleration"):
m_acceleration.loadFromIff(file);
break;
case constcrc("braking"):
m_braking.loadFromIff(file);
break;
} }
else if (strcmp(paramName, "slopeAversion") == 0)
m_slopeAversion.loadFromIff(file);
else if (strcmp(paramName, "hoverValue") == 0)
m_hoverValue.loadFromIff(file);
else if (strcmp(paramName, "turnRate") == 0)
m_turnRate.loadFromIff(file);
else if (strcmp(paramName, "maxVelocity") == 0)
m_maxVelocity.loadFromIff(file);
else if (strcmp(paramName, "acceleration") == 0)
m_acceleration.loadFromIff(file);
else if (strcmp(paramName, "braking") == 0)
m_braking.loadFromIff(file);
file.exitChunk(true); file.exitChunk(true);
} }
@@ -16,6 +16,9 @@
#include "sharedMath/Vector.h" #include "sharedMath/Vector.h"
#include "sharedObject/ObjectTemplate.h" #include "sharedObject/ObjectTemplate.h"
#include "sharedObject/ObjectTemplateList.h" #include "sharedObject/ObjectTemplateList.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//@BEGIN TFD TEMPLATE REFS //@BEGIN TFD TEMPLATE REFS
//@END TFD TEMPLATE REFS //@END TFD TEMPLATE REFS
#include <algorithm> #include <algorithm>
@@ -448,12 +451,18 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "weaponEffect") == 0)
m_weaponEffect.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "weaponEffectIndex") == 0) case constcrc("weaponEffect"):
m_weaponEffectIndex.loadFromIff(file); m_weaponEffect.loadFromIff(file);
else if (strcmp(paramName, "attackType") == 0) break;
m_attackType.loadFromIff(file); case constcrc("weaponEffectIndex"):
m_weaponEffectIndex.loadFromIff(file);
break;
case constcrc("attackType"):
m_attackType.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
@@ -258,7 +258,7 @@ void LogManager::registerObserverType(std::string const &name, LogObserverCreate
// run through SharedLog keys looking for logTarget#=name: // run through SharedLog keys looking for logTarget#=name:
{ {
char key[16]; char key[25];
strcpy(key, "logTarget"); strcpy(key, "logTarget");
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
@@ -765,16 +765,16 @@ void Connection::receive(const Archive::ByteStream & bs)
m_recvAverageBytesPerSecond = m_bytesReceived / lifeTime; m_recvAverageBytesPerSecond = m_bytesReceived / lifeTime;
std::string logChan = "Network:ConnectionStatsRecv:" + getRemoteAddress() + ":"; //std::string logChan = "Network:ConnectionStatsRecv:" + getRemoteAddress() + ":";
char portBuf[7] = {"\0"}; char portBuf[7] = {"\0"};
snprintf(portBuf, sizeof(portBuf), "%d", getRemotePort()); snprintf(portBuf, sizeof(portBuf), "%d", getRemotePort());
logChan += portBuf; //logChan += portBuf;
LOG(logChan, ("Current(%d/sec), Average(%d/sec), Peak(%d/sec) Total Bytes(%d) Total Time(%lu)", bytesPerSecond, m_recvAverageBytesPerSecond, m_recvPeakBytesPerSecond, m_bytesReceived, lifeTime)); //LOG(logChan, ("Current(%d/sec), Average(%d/sec), Peak(%d/sec) Total Bytes(%d) Total Time(%lu)", bytesPerSecond, m_recvAverageBytesPerSecond, m_recvPeakBytesPerSecond, m_bytesReceived, lifeTime));
m_lastRecvReportTime = m_lastRecvTime; m_lastRecvReportTime = m_lastRecvTime;
m_recvBytesReportInterval = 0; m_recvBytesReportInterval = 0;
if (m_managerHandler->getRecvCompressedByteCount() > 0) //if (m_managerHandler->getRecvCompressedByteCount() > 0)
LOG(logChan, ("Compression Ratio: %.2f : 1.0 - Recv(%d / %d)", m_managerHandler->getCompressionRatio(), m_managerHandler->getRecvUncompressedByteCount(), m_managerHandler->getRecvCompressedByteCount())); // LOG(logChan, ("Compression Ratio: %.2f : 1.0 - Recv(%d / %d)", m_managerHandler->getCompressionRatio(), m_managerHandler->getRecvUncompressedByteCount(), m_managerHandler->getRecvCompressedByteCount()));
} }
} }
} }
@@ -833,16 +833,16 @@ void Connection::reportSend(const int sendSize)
m_sendAverageBytesPerSecond = m_bytesSent / lifeTime; m_sendAverageBytesPerSecond = m_bytesSent / lifeTime;
std::string logChan = "Network:ConnectionStatsSend:" + getRemoteAddress() + ":"; //std::string logChan = "Network:ConnectionStatsSend:" + getRemoteAddress() + ":";
char portBuf[7] = {"\0"}; char portBuf[7] = {"\0"};
snprintf(portBuf, sizeof(portBuf), "%d", getRemotePort()); snprintf(portBuf, sizeof(portBuf), "%d", getRemotePort());
logChan += portBuf; //logChan += portBuf;
LOG(logChan, ("Current(%d/sec), Average(%d/sec), Peak(%d/sec) Total Bytes(%d) Total Time(%lu)", bytesPerSecond, m_sendAverageBytesPerSecond, m_sendPeakBytesPerSecond, m_bytesSent, lifeTime)); //LOG(logChan, ("Current(%d/sec), Average(%d/sec), Peak(%d/sec) Total Bytes(%d) Total Time(%lu)", bytesPerSecond, m_sendAverageBytesPerSecond, m_sendPeakBytesPerSecond, m_bytesSent, lifeTime));
m_lastSendReportTime = m_lastSendTime; m_lastSendReportTime = m_lastSendTime;
m_sendBytesReportInterval = 0; m_sendBytesReportInterval = 0;
if (m_managerHandler->getSendCompressedByteCount() > 0) // if (m_managerHandler->getSendCompressedByteCount() > 0)
LOG(logChan, ("Compression Ratio: %.2f : 1.0 Send(%d / %d)", m_managerHandler->getCompressionRatio(), m_managerHandler->getSendUncompressedByteCount(), m_managerHandler->getSendCompressedByteCount())); // LOG(logChan, ("Compression Ratio: %.2f : 1.0 Send(%d / %d)", m_managerHandler->getCompressionRatio(), m_managerHandler->getSendUncompressedByteCount(), m_managerHandler->getSendCompressedByteCount()));
} }
} }
} }
@@ -600,7 +600,7 @@ AppearanceTemplate *AppearanceTemplateListNamespace::create(const char *const fi
{ {
char tagString[5]; char tagString[5];
ConvertTagToString(tag, tagString); ConvertTagToString(tag, tagString);
WARNING(true, ("AppearanceTemplate binding %s not found for file %s", tagString, actualFileName.getString())); DEBUG_WARNING(true, ("AppearanceTemplate binding %s not found for file %s", tagString, actualFileName.getString()));
} }
} }
File diff suppressed because it is too large Load Diff
@@ -20,62 +20,56 @@
#include <stdio.h> #include <stdio.h>
/** /**
* Class constructor. * Class constructor.
*/ */
ServerBuildingObjectTemplate::ServerBuildingObjectTemplate(const std::string & filename) ServerBuildingObjectTemplate::ServerBuildingObjectTemplate(const std::string &filename)
//@BEGIN TFD INIT //@BEGIN TFD INIT
: ServerTangibleObjectTemplate(filename) : ServerTangibleObjectTemplate(filename)
//@END TFD INIT //@END TFD INIT
{ {
} // ServerBuildingObjectTemplate::ServerBuildingObjectTemplate } // ServerBuildingObjectTemplate::ServerBuildingObjectTemplate
/** /**
* Class destructor. * Class destructor.
*/ */
ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate() ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate() {
{
//@BEGIN TFD CLEANUP //@BEGIN TFD CLEANUP
//@END TFD CLEANUP //@END TFD CLEANUP
} // ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate } // ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate
/** /**
* Static function used to register this template. * Static function used to register this template.
*/ */
void ServerBuildingObjectTemplate::registerMe(void) void ServerBuildingObjectTemplate::registerMe(void) {
{ ObjectTemplateList::registerTemplate(ServerBuildingObjectTemplate_tag, create);
ObjectTemplateList::registerTemplate(ServerBuildingObjectTemplate_tag, create); } // ServerBuildingObjectTemplate::registerMe
} // ServerBuildingObjectTemplate::registerMe
/** /**
* Creates a ServerBuildingObjectTemplate template. * Creates a ServerBuildingObjectTemplate template.
* *
* @return a new instance of the template * @return a new instance of the template
*/ */
ObjectTemplate * ServerBuildingObjectTemplate::create(const std::string & filename) ObjectTemplate *ServerBuildingObjectTemplate::create(const std::string &filename) {
{ return new ServerBuildingObjectTemplate(filename);
return new ServerBuildingObjectTemplate(filename); } // ServerBuildingObjectTemplate::create
} // ServerBuildingObjectTemplate::create
/** /**
* Returns the template id. * Returns the template id.
* *
* @return the template id * @return the template id
*/ */
Tag ServerBuildingObjectTemplate::getId(void) const Tag ServerBuildingObjectTemplate::getId(void) const {
{ return ServerBuildingObjectTemplate_tag;
return ServerBuildingObjectTemplate_tag; } // ServerBuildingObjectTemplate::getId
} // ServerBuildingObjectTemplate::getId
/** /**
* Returns this template's version. * Returns this template's version.
* *
* @return the version * @return the version
*/ */
Tag ServerBuildingObjectTemplate::getTemplateVersion(void) const Tag ServerBuildingObjectTemplate::getTemplateVersion(void) const {
{ return m_templateVersion;
return m_templateVersion;
} // ServerBuildingObjectTemplate::getTemplateVersion } // ServerBuildingObjectTemplate::getTemplateVersion
/** /**
@@ -83,121 +77,100 @@ Tag ServerBuildingObjectTemplate::getTemplateVersion(void) const
* *
* @return the highest version * @return the highest version
*/ */
Tag ServerBuildingObjectTemplate::getHighestTemplateVersion(void) const Tag ServerBuildingObjectTemplate::getHighestTemplateVersion(void) const {
{ if (m_baseData == NULL)
if (m_baseData == NULL) return m_templateVersion;
return m_templateVersion; const ServerBuildingObjectTemplate *base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData);
const ServerBuildingObjectTemplate * base = dynamic_cast<const ServerBuildingObjectTemplate *>(m_baseData); if (base == NULL)
if (base == NULL) return m_templateVersion;
return m_templateVersion; return std::max(m_templateVersion, base->getHighestTemplateVersion());
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerBuildingObjectTemplate::getHighestTemplateVersion } // ServerBuildingObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD //@BEGIN TFD
CompilerIntegerParam * ServerBuildingObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) CompilerIntegerParam *
{ ServerBuildingObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) {
if (strcmp(name, "maintenanceCost") == 0) if (strcmp(name, "maintenanceCost") == 0) {
{ if (index == 0) {
if (index == 0) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != nullptr)
if (deepCheck && !isParamLoaded(name, false, 0)) return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
{ return nullptr;
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); return &m_maintenanceCost;
return nullptr; }
} fprintf(stderr, "trying to access single-parameter \"maintenanceCost\" as an array\n");
return &m_maintenanceCost; } else
} return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
fprintf(stderr, "trying to access single-parameter \"maintenanceCost\" as an array\n"); return nullptr;
} } //ServerBuildingObjectTemplate::getCompilerIntegerParam
else
return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return nullptr;
} //ServerBuildingObjectTemplate::getCompilerIntegerParam
FloatParam * ServerBuildingObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) FloatParam *ServerBuildingObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index); } //ServerBuildingObjectTemplate::getFloatParam
} //ServerBuildingObjectTemplate::getFloatParam
BoolParam * ServerBuildingObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) BoolParam *ServerBuildingObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) {
{ if (strcmp(name, "isPublic") == 0) {
if (strcmp(name, "isPublic") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getBoolParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_isPublic;
return getBaseTemplate()->getBoolParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"isPublic\" as an array\n");
} } else
return &m_isPublic; return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
} return nullptr;
fprintf(stderr, "trying to access single-parameter \"isPublic\" as an array\n"); } //ServerBuildingObjectTemplate::getBoolParam
}
else
return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
return nullptr;
} //ServerBuildingObjectTemplate::getBoolParam
StringParam * ServerBuildingObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) StringParam *ServerBuildingObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index); } //ServerBuildingObjectTemplate::getStringParam
} //ServerBuildingObjectTemplate::getStringParam
StringIdParam * ServerBuildingObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) StringIdParam *ServerBuildingObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index); } //ServerBuildingObjectTemplate::getStringIdParam
} //ServerBuildingObjectTemplate::getStringIdParam
VectorParam * ServerBuildingObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) VectorParam *ServerBuildingObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index); } //ServerBuildingObjectTemplate::getVectorParam
} //ServerBuildingObjectTemplate::getVectorParam
DynamicVariableParam * ServerBuildingObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) DynamicVariableParam *
{ ServerBuildingObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) {
return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index); return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerBuildingObjectTemplate::getDynamicVariableParam } //ServerBuildingObjectTemplate::getDynamicVariableParam
StructParamOT * ServerBuildingObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) StructParamOT *ServerBuildingObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index); } //ServerBuildingObjectTemplate::getStructParamOT
} //ServerBuildingObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerBuildingObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) TriggerVolumeParam *ServerBuildingObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index); } //ServerBuildingObjectTemplate::getTriggerVolumeParam
} //ServerBuildingObjectTemplate::getTriggerVolumeParam
void ServerBuildingObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) void ServerBuildingObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) {
{ if (param.isInitialized())
if (param.isInitialized()) return;
return; ServerTangibleObjectTemplate::initStructParamOT(param, name);
ServerTangibleObjectTemplate::initStructParamOT(param, name); } // ServerBuildingObjectTemplate::initStructParamOT
} // ServerBuildingObjectTemplate::initStructParamOT
void ServerBuildingObjectTemplate::setAsEmptyList(const char *name) void ServerBuildingObjectTemplate::setAsEmptyList(const char *name) {
{ ServerTangibleObjectTemplate::setAsEmptyList(name);
ServerTangibleObjectTemplate::setAsEmptyList(name); } // ServerBuildingObjectTemplate::setAsEmptyList
} // ServerBuildingObjectTemplate::setAsEmptyList
void ServerBuildingObjectTemplate::setAppend(const char *name) void ServerBuildingObjectTemplate::setAppend(const char *name) {
{ ServerTangibleObjectTemplate::setAppend(name);
ServerTangibleObjectTemplate::setAppend(name); } // ServerBuildingObjectTemplate::setAppend
} // ServerBuildingObjectTemplate::setAppend
bool ServerBuildingObjectTemplate::isAppend(const char *name) const bool ServerBuildingObjectTemplate::isAppend(const char *name) const {
{ return ServerTangibleObjectTemplate::isAppend(name);
return ServerTangibleObjectTemplate::isAppend(name); } // ServerBuildingObjectTemplate::isAppend
} // ServerBuildingObjectTemplate::isAppend
int ServerBuildingObjectTemplate::getListLength(const char *name) const int ServerBuildingObjectTemplate::getListLength(const char *name) const {
{ return ServerTangibleObjectTemplate::getListLength(name);
return ServerTangibleObjectTemplate::getListLength(name); } // ServerBuildingObjectTemplate::getListLength
} // ServerBuildingObjectTemplate::getListLength
/** /**
* Loads the template data from an iff file. We should already be in the form * Loads the template data from an iff file. We should already be in the form
@@ -205,66 +178,60 @@ int ServerBuildingObjectTemplate::getListLength(const char *name) const
* *
* @param file file to load from * @param file file to load from
*/ */
void ServerBuildingObjectTemplate::load(Iff &file) void ServerBuildingObjectTemplate::load(Iff &file) {
{ static const int MAX_NAME_SIZE = 256;
static const int MAX_NAME_SIZE = 256; char paramName[MAX_NAME_SIZE];
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerBuildingObjectTemplate_tag) if (file.getCurrentName() != ServerBuildingObjectTemplate_tag) {
{ ServerTangibleObjectTemplate::load(file);
ServerTangibleObjectTemplate::load(file); return;
return; }
}
file.enterForm(); file.enterForm();
m_templateVersion = file.getCurrentName(); m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V)) if (m_templateVersion == TAG(D, E, R, V)) {
{ file.enterForm();
file.enterForm(); file.enterChunk();
file.enterChunk(); std::string baseFilename;
std::string baseFilename; file.read_string(baseFilename);
file.read_string(baseFilename); file.exitChunk();
file.exitChunk(); const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str()));
DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str())); if (m_baseData == base && base != nullptr)
if (m_baseData == base && base != nullptr) base->releaseReference();
base->releaseReference(); else {
else if (m_baseData != nullptr)
{ m_baseData->releaseReference();
if (m_baseData != nullptr) m_baseData = base;
m_baseData->releaseReference(); }
m_baseData = base; file.exitForm();
} m_templateVersion = file.getCurrentName();
file.exitForm(); }
m_templateVersion = file.getCurrentName(); if (getHighestTemplateVersion() != TAG(0, 0, 0, 1)) {
} if (DataLint::isEnabled())
if (getHighestTemplateVersion() != TAG(0,0,0,1)) DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
{ }
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
file.enterForm(); file.enterForm();
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i) {
{ file.enterChunk();
file.enterChunk(); file.read_string(paramName, MAX_NAME_SIZE);
file.read_string(paramName, MAX_NAME_SIZE); if (strcmp(paramName, "isPublic") == 0)
if (strcmp(paramName, "maintenanceCost") == 0) m_isPublic.loadFromIff(file);
m_maintenanceCost.loadFromIff(file); else if (strcmp(paramName, "maintenanceCost") == 0)
else if (strcmp(paramName, "isPublic") == 0) m_maintenanceCost.loadFromIff(file);
m_isPublic.loadFromIff(file); file.exitChunk(true);
file.exitChunk(true); }
}
file.exitForm(); file.exitForm();
ServerTangibleObjectTemplate::load(file); ServerTangibleObjectTemplate::load(file);
file.exitForm(); file.exitForm();
return; return;
} // ServerBuildingObjectTemplate::load } // ServerBuildingObjectTemplate::load
/** /**
* Saves the template data to an iff file. * Saves the template data to an iff file.
@@ -272,47 +239,45 @@ char paramName[MAX_NAME_SIZE];
* @param file file to save to * @param file file to save to
* @param location file type (client or server) * @param location file type (client or server)
*/ */
void ServerBuildingObjectTemplate::save(Iff &file) void ServerBuildingObjectTemplate::save(Iff &file) {
{ int count;
int count;
file.insertForm(ServerBuildingObjectTemplate_tag); file.insertForm(ServerBuildingObjectTemplate_tag);
if (m_baseTemplateName.size() != 0) if (m_baseTemplateName.size() != 0) {
{ file.insertForm(TAG(D, E, R, V));
file.insertForm(TAG(D,E,R,V)); file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1); file.exitChunk();
file.exitChunk(); file.exitForm();
file.exitForm(); }
} file.insertForm(TAG(0, 0, 0, 1));
file.insertForm(TAG(0,0,0,1)); file.allowNonlinearFunctions();
file.allowNonlinearFunctions();
int paramCount = 0; int paramCount = 0;
// save maintenanceCost // save maintenanceCost
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maintenanceCost"); file.insertChunkString("maintenanceCost");
m_maintenanceCost.saveToIff(file); m_maintenanceCost.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save isPublic // save isPublic
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("isPublic"); file.insertChunkString("isPublic");
m_isPublic.saveToIff(file); m_isPublic.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// write number of parameters // write number of parameters
file.goToTopOfForm(); file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T)); file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount)); file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk(); file.exitChunk();
file.exitForm(true); file.exitForm(true);
ServerTangibleObjectTemplate::save(file); ServerTangibleObjectTemplate::save(file);
file.exitForm(); file.exitForm();
UNREF(count); UNREF(count);
} // ServerBuildingObjectTemplate::save } // ServerBuildingObjectTemplate::save
//@END TFD //@END TFD
@@ -19,63 +19,59 @@
#include "sharedTemplateDefinition/ObjectTemplate.h" #include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h> #include <stdio.h>
#include "sharedFoundation/CrcConstexpr.hpp"
/** /**
* Class constructor. * Class constructor.
*/ */
ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate(const std::string & filename) ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate(const std::string &filename)
//@BEGIN TFD INIT //@BEGIN TFD INIT
: ServerInstallationObjectTemplate(filename) : ServerInstallationObjectTemplate(filename)
//@END TFD INIT //@END TFD INIT
{ {
} // ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate } // ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate
/** /**
* Class destructor. * Class destructor.
*/ */
ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate() ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate() {
{
//@BEGIN TFD CLEANUP //@BEGIN TFD CLEANUP
//@END TFD CLEANUP //@END TFD CLEANUP
} // ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate } // ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate
/** /**
* Static function used to register this template. * Static function used to register this template.
*/ */
void ServerHarvesterInstallationObjectTemplate::registerMe(void) void ServerHarvesterInstallationObjectTemplate::registerMe(void) {
{ ObjectTemplateList::registerTemplate(ServerHarvesterInstallationObjectTemplate_tag, create);
ObjectTemplateList::registerTemplate(ServerHarvesterInstallationObjectTemplate_tag, create); } // ServerHarvesterInstallationObjectTemplate::registerMe
} // ServerHarvesterInstallationObjectTemplate::registerMe
/** /**
* Creates a ServerHarvesterInstallationObjectTemplate template. * Creates a ServerHarvesterInstallationObjectTemplate template.
* *
* @return a new instance of the template * @return a new instance of the template
*/ */
ObjectTemplate * ServerHarvesterInstallationObjectTemplate::create(const std::string & filename) ObjectTemplate *ServerHarvesterInstallationObjectTemplate::create(const std::string &filename) {
{ return new ServerHarvesterInstallationObjectTemplate(filename);
return new ServerHarvesterInstallationObjectTemplate(filename); } // ServerHarvesterInstallationObjectTemplate::create
} // ServerHarvesterInstallationObjectTemplate::create
/** /**
* Returns the template id. * Returns the template id.
* *
* @return the template id * @return the template id
*/ */
Tag ServerHarvesterInstallationObjectTemplate::getId(void) const Tag ServerHarvesterInstallationObjectTemplate::getId(void) const {
{ return ServerHarvesterInstallationObjectTemplate_tag;
return ServerHarvesterInstallationObjectTemplate_tag; } // ServerHarvesterInstallationObjectTemplate::getId
} // ServerHarvesterInstallationObjectTemplate::getId
/** /**
* Returns this template's version. * Returns this template's version.
* *
* @return the version * @return the version
*/ */
Tag ServerHarvesterInstallationObjectTemplate::getTemplateVersion(void) const Tag ServerHarvesterInstallationObjectTemplate::getTemplateVersion(void) const {
{ return m_templateVersion;
return m_templateVersion;
} // ServerHarvesterInstallationObjectTemplate::getTemplateVersion } // ServerHarvesterInstallationObjectTemplate::getTemplateVersion
/** /**
@@ -83,149 +79,132 @@ Tag ServerHarvesterInstallationObjectTemplate::getTemplateVersion(void) const
* *
* @return the highest version * @return the highest version
*/ */
Tag ServerHarvesterInstallationObjectTemplate::getHighestTemplateVersion(void) const Tag ServerHarvesterInstallationObjectTemplate::getHighestTemplateVersion(void) const {
{ if (m_baseData == NULL)
if (m_baseData == NULL) return m_templateVersion;
return m_templateVersion; const ServerHarvesterInstallationObjectTemplate *base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData);
const ServerHarvesterInstallationObjectTemplate * base = dynamic_cast<const ServerHarvesterInstallationObjectTemplate *>(m_baseData); if (base == NULL)
if (base == NULL) return m_templateVersion;
return m_templateVersion; return std::max(m_templateVersion, base->getHighestTemplateVersion());
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerHarvesterInstallationObjectTemplate::getHighestTemplateVersion } // ServerHarvesterInstallationObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD //@BEGIN TFD
CompilerIntegerParam * ServerHarvesterInstallationObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) CompilerIntegerParam *
{ ServerHarvesterInstallationObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) {
if (strcmp(name, "maxExtractionRate") == 0) switch (runtimeCrc(name)) {
{ case constcrc("maxExtractionRate"): {
if (index == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (deepCheck && !isParamLoaded(name, false, 0)) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (getBaseTemplate() != nullptr) return nullptr;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return nullptr; return &m_maxExtractionRate;
} }
return &m_maxExtractionRate; fprintf(stderr, "trying to access single-parameter \"maxExtractionRate\" as an array\n");
} }
fprintf(stderr, "trying to access single-parameter \"maxExtractionRate\" as an array\n"); break;
} case constcrc("currentExtractionRate"): {
else if (strcmp(name, "currentExtractionRate") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_currentExtractionRate;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"currentExtractionRate\" as an array\n");
} }
return &m_currentExtractionRate; break;
} case constcrc("maxHopperSize"): {
fprintf(stderr, "trying to access single-parameter \"currentExtractionRate\" as an array\n"); if (index == 0) {
} if (deepCheck && !isParamLoaded(name, false, 0)) {
else if (strcmp(name, "maxHopperSize") == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (index == 0) return nullptr;
{ }
if (deepCheck && !isParamLoaded(name, false, 0)) return &m_maxHopperSize;
{ }
if (getBaseTemplate() != nullptr) fprintf(stderr, "trying to access single-parameter \"maxHopperSize\" as an array\n");
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return nullptr; break;
} default:
return &m_maxHopperSize; return ServerInstallationObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} break;
fprintf(stderr, "trying to access single-parameter \"maxHopperSize\" as an array\n"); }
} return nullptr;
else } //ServerHarvesterInstallationObjectTemplate::getCompilerIntegerParam
return ServerInstallationObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return nullptr;
} //ServerHarvesterInstallationObjectTemplate::getCompilerIntegerParam
FloatParam * ServerHarvesterInstallationObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) FloatParam *ServerHarvesterInstallationObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) {
{ return ServerInstallationObjectTemplate::getFloatParam(name, deepCheck, index);
return ServerInstallationObjectTemplate::getFloatParam(name, deepCheck, index); } //ServerHarvesterInstallationObjectTemplate::getFloatParam
} //ServerHarvesterInstallationObjectTemplate::getFloatParam
BoolParam * ServerHarvesterInstallationObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) BoolParam *ServerHarvesterInstallationObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) {
{ return ServerInstallationObjectTemplate::getBoolParam(name, deepCheck, index);
return ServerInstallationObjectTemplate::getBoolParam(name, deepCheck, index); } //ServerHarvesterInstallationObjectTemplate::getBoolParam
} //ServerHarvesterInstallationObjectTemplate::getBoolParam
StringParam * ServerHarvesterInstallationObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) StringParam *ServerHarvesterInstallationObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) {
{ if (strcmp(name, "masterClassName") == 0) {
if (strcmp(name, "masterClassName") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getStringParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_masterClassName;
return getBaseTemplate()->getStringParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"masterClassName\" as an array\n");
} } else
return &m_masterClassName; return ServerInstallationObjectTemplate::getStringParam(name, deepCheck, index);
} return nullptr;
fprintf(stderr, "trying to access single-parameter \"masterClassName\" as an array\n"); } //ServerHarvesterInstallationObjectTemplate::getStringParam
}
else
return ServerInstallationObjectTemplate::getStringParam(name, deepCheck, index);
return nullptr;
} //ServerHarvesterInstallationObjectTemplate::getStringParam
StringIdParam * ServerHarvesterInstallationObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) StringIdParam *
{ ServerHarvesterInstallationObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) {
return ServerInstallationObjectTemplate::getStringIdParam(name, deepCheck, index); return ServerInstallationObjectTemplate::getStringIdParam(name, deepCheck, index);
} //ServerHarvesterInstallationObjectTemplate::getStringIdParam } //ServerHarvesterInstallationObjectTemplate::getStringIdParam
VectorParam * ServerHarvesterInstallationObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) VectorParam *ServerHarvesterInstallationObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) {
{ return ServerInstallationObjectTemplate::getVectorParam(name, deepCheck, index);
return ServerInstallationObjectTemplate::getVectorParam(name, deepCheck, index); } //ServerHarvesterInstallationObjectTemplate::getVectorParam
} //ServerHarvesterInstallationObjectTemplate::getVectorParam
DynamicVariableParam * ServerHarvesterInstallationObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) DynamicVariableParam *
{ ServerHarvesterInstallationObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) {
return ServerInstallationObjectTemplate::getDynamicVariableParam(name, deepCheck, index); return ServerInstallationObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerHarvesterInstallationObjectTemplate::getDynamicVariableParam } //ServerHarvesterInstallationObjectTemplate::getDynamicVariableParam
StructParamOT * ServerHarvesterInstallationObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) StructParamOT *
{ ServerHarvesterInstallationObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) {
return ServerInstallationObjectTemplate::getStructParamOT(name, deepCheck, index); return ServerInstallationObjectTemplate::getStructParamOT(name, deepCheck, index);
} //ServerHarvesterInstallationObjectTemplate::getStructParamOT } //ServerHarvesterInstallationObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerHarvesterInstallationObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) TriggerVolumeParam *
{ ServerHarvesterInstallationObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) {
return ServerInstallationObjectTemplate::getTriggerVolumeParam(name, deepCheck, index); return ServerInstallationObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerHarvesterInstallationObjectTemplate::getTriggerVolumeParam } //ServerHarvesterInstallationObjectTemplate::getTriggerVolumeParam
void ServerHarvesterInstallationObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) void ServerHarvesterInstallationObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) {
{ if (param.isInitialized())
if (param.isInitialized()) return;
return; ServerInstallationObjectTemplate::initStructParamOT(param, name);
ServerInstallationObjectTemplate::initStructParamOT(param, name); } // ServerHarvesterInstallationObjectTemplate::initStructParamOT
} // ServerHarvesterInstallationObjectTemplate::initStructParamOT
void ServerHarvesterInstallationObjectTemplate::setAsEmptyList(const char *name) void ServerHarvesterInstallationObjectTemplate::setAsEmptyList(const char *name) {
{ ServerInstallationObjectTemplate::setAsEmptyList(name);
ServerInstallationObjectTemplate::setAsEmptyList(name); } // ServerHarvesterInstallationObjectTemplate::setAsEmptyList
} // ServerHarvesterInstallationObjectTemplate::setAsEmptyList
void ServerHarvesterInstallationObjectTemplate::setAppend(const char *name) void ServerHarvesterInstallationObjectTemplate::setAppend(const char *name) {
{ ServerInstallationObjectTemplate::setAppend(name);
ServerInstallationObjectTemplate::setAppend(name); } // ServerHarvesterInstallationObjectTemplate::setAppend
} // ServerHarvesterInstallationObjectTemplate::setAppend
bool ServerHarvesterInstallationObjectTemplate::isAppend(const char *name) const bool ServerHarvesterInstallationObjectTemplate::isAppend(const char *name) const {
{ return ServerInstallationObjectTemplate::isAppend(name);
return ServerInstallationObjectTemplate::isAppend(name); } // ServerHarvesterInstallationObjectTemplate::isAppend
} // ServerHarvesterInstallationObjectTemplate::isAppend
int ServerHarvesterInstallationObjectTemplate::getListLength(const char *name) const int ServerHarvesterInstallationObjectTemplate::getListLength(const char *name) const {
{ return ServerInstallationObjectTemplate::getListLength(name);
return ServerInstallationObjectTemplate::getListLength(name); } // ServerHarvesterInstallationObjectTemplate::getListLength
} // ServerHarvesterInstallationObjectTemplate::getListLength
/** /**
* Loads the template data from an iff file. We should already be in the form * Loads the template data from an iff file. We should already be in the form
@@ -233,70 +212,64 @@ int ServerHarvesterInstallationObjectTemplate::getListLength(const char *name) c
* *
* @param file file to load from * @param file file to load from
*/ */
void ServerHarvesterInstallationObjectTemplate::load(Iff &file) void ServerHarvesterInstallationObjectTemplate::load(Iff &file) {
{ static const int MAX_NAME_SIZE = 256;
static const int MAX_NAME_SIZE = 256; char paramName[MAX_NAME_SIZE];
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerHarvesterInstallationObjectTemplate_tag) if (file.getCurrentName() != ServerHarvesterInstallationObjectTemplate_tag) {
{ ServerInstallationObjectTemplate::load(file);
ServerInstallationObjectTemplate::load(file); return;
return; }
}
file.enterForm(); file.enterForm();
m_templateVersion = file.getCurrentName(); m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V)) if (m_templateVersion == TAG(D, E, R, V)) {
{ file.enterForm();
file.enterForm(); file.enterChunk();
file.enterChunk(); std::string baseFilename;
std::string baseFilename; file.read_string(baseFilename);
file.read_string(baseFilename); file.exitChunk();
file.exitChunk(); const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str()));
DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str())); if (m_baseData == base && base != nullptr)
if (m_baseData == base && base != nullptr) base->releaseReference();
base->releaseReference(); else {
else if (m_baseData != nullptr)
{ m_baseData->releaseReference();
if (m_baseData != nullptr) m_baseData = base;
m_baseData->releaseReference(); }
m_baseData = base; file.exitForm();
} m_templateVersion = file.getCurrentName();
file.exitForm(); }
m_templateVersion = file.getCurrentName(); if (getHighestTemplateVersion() != TAG(0, 0, 0, 0)) {
} if (DataLint::isEnabled())
if (getHighestTemplateVersion() != TAG(0,0,0,0)) DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
{ }
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
file.enterForm(); file.enterForm();
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i) {
{ file.enterChunk();
file.enterChunk(); file.read_string(paramName, MAX_NAME_SIZE);
file.read_string(paramName, MAX_NAME_SIZE); if (strcmp(paramName, "maxExtractionRate") == 0)
if (strcmp(paramName, "maxExtractionRate") == 0) m_maxExtractionRate.loadFromIff(file);
m_maxExtractionRate.loadFromIff(file); else if (strcmp(paramName, "currentExtractionRate") == 0)
else if (strcmp(paramName, "currentExtractionRate") == 0) m_currentExtractionRate.loadFromIff(file);
m_currentExtractionRate.loadFromIff(file); else if (strcmp(paramName, "maxHopperSize") == 0)
else if (strcmp(paramName, "maxHopperSize") == 0) m_maxHopperSize.loadFromIff(file);
m_maxHopperSize.loadFromIff(file); else if (strcmp(paramName, "masterClassName") == 0)
else if (strcmp(paramName, "masterClassName") == 0) m_masterClassName.loadFromIff(file);
m_masterClassName.loadFromIff(file); file.exitChunk(true);
file.exitChunk(true); }
}
file.exitForm(); file.exitForm();
ServerInstallationObjectTemplate::load(file); ServerInstallationObjectTemplate::load(file);
file.exitForm(); file.exitForm();
return; return;
} // ServerHarvesterInstallationObjectTemplate::load } // ServerHarvesterInstallationObjectTemplate::load
/** /**
* Saves the template data to an iff file. * Saves the template data to an iff file.
@@ -304,59 +277,57 @@ char paramName[MAX_NAME_SIZE];
* @param file file to save to * @param file file to save to
* @param location file type (client or server) * @param location file type (client or server)
*/ */
void ServerHarvesterInstallationObjectTemplate::save(Iff &file) void ServerHarvesterInstallationObjectTemplate::save(Iff &file) {
{ int count;
int count;
file.insertForm(ServerHarvesterInstallationObjectTemplate_tag); file.insertForm(ServerHarvesterInstallationObjectTemplate_tag);
if (m_baseTemplateName.size() != 0) if (m_baseTemplateName.size() != 0) {
{ file.insertForm(TAG(D, E, R, V));
file.insertForm(TAG(D,E,R,V)); file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1); file.exitChunk();
file.exitChunk(); file.exitForm();
file.exitForm(); }
} file.insertForm(TAG(0, 0, 0, 0));
file.insertForm(TAG(0,0,0,0)); file.allowNonlinearFunctions();
file.allowNonlinearFunctions();
int paramCount = 0; int paramCount = 0;
// save maxExtractionRate // save maxExtractionRate
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxExtractionRate"); file.insertChunkString("maxExtractionRate");
m_maxExtractionRate.saveToIff(file); m_maxExtractionRate.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save currentExtractionRate // save currentExtractionRate
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("currentExtractionRate"); file.insertChunkString("currentExtractionRate");
m_currentExtractionRate.saveToIff(file); m_currentExtractionRate.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save maxHopperSize // save maxHopperSize
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxHopperSize"); file.insertChunkString("maxHopperSize");
m_maxHopperSize.saveToIff(file); m_maxHopperSize.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save masterClassName // save masterClassName
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("masterClassName"); file.insertChunkString("masterClassName");
m_masterClassName.saveToIff(file); m_masterClassName.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// write number of parameters // write number of parameters
file.goToTopOfForm(); file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T)); file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount)); file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk(); file.exitChunk();
file.exitForm(true); file.exitForm(true);
ServerInstallationObjectTemplate::save(file); ServerInstallationObjectTemplate::save(file);
file.exitForm(); file.exitForm();
UNREF(count); UNREF(count);
} // ServerHarvesterInstallationObjectTemplate::save } // ServerHarvesterInstallationObjectTemplate::save
//@END TFD //@END TFD
File diff suppressed because it is too large Load Diff
@@ -19,63 +19,59 @@
#include "sharedTemplateDefinition/ObjectTemplate.h" #include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h> #include <stdio.h>
#include "sharedFoundation/CrcConstexpr.hpp"
/** /**
* Class constructor. * Class constructor.
*/ */
ServerResourceClassObjectTemplate::ServerResourceClassObjectTemplate(const std::string & filename) ServerResourceClassObjectTemplate::ServerResourceClassObjectTemplate(const std::string &filename)
//@BEGIN TFD INIT //@BEGIN TFD INIT
: ServerUniverseObjectTemplate(filename) : ServerUniverseObjectTemplate(filename)
//@END TFD INIT //@END TFD INIT
{ {
} // ServerResourceClassObjectTemplate::ServerResourceClassObjectTemplate } // ServerResourceClassObjectTemplate::ServerResourceClassObjectTemplate
/** /**
* Class destructor. * Class destructor.
*/ */
ServerResourceClassObjectTemplate::~ServerResourceClassObjectTemplate() ServerResourceClassObjectTemplate::~ServerResourceClassObjectTemplate() {
{
//@BEGIN TFD CLEANUP //@BEGIN TFD CLEANUP
//@END TFD CLEANUP //@END TFD CLEANUP
} // ServerResourceClassObjectTemplate::~ServerResourceClassObjectTemplate } // ServerResourceClassObjectTemplate::~ServerResourceClassObjectTemplate
/** /**
* Static function used to register this template. * Static function used to register this template.
*/ */
void ServerResourceClassObjectTemplate::registerMe(void) void ServerResourceClassObjectTemplate::registerMe(void) {
{ ObjectTemplateList::registerTemplate(ServerResourceClassObjectTemplate_tag, create);
ObjectTemplateList::registerTemplate(ServerResourceClassObjectTemplate_tag, create); } // ServerResourceClassObjectTemplate::registerMe
} // ServerResourceClassObjectTemplate::registerMe
/** /**
* Creates a ServerResourceClassObjectTemplate template. * Creates a ServerResourceClassObjectTemplate template.
* *
* @return a new instance of the template * @return a new instance of the template
*/ */
ObjectTemplate * ServerResourceClassObjectTemplate::create(const std::string & filename) ObjectTemplate *ServerResourceClassObjectTemplate::create(const std::string &filename) {
{ return new ServerResourceClassObjectTemplate(filename);
return new ServerResourceClassObjectTemplate(filename); } // ServerResourceClassObjectTemplate::create
} // ServerResourceClassObjectTemplate::create
/** /**
* Returns the template id. * Returns the template id.
* *
* @return the template id * @return the template id
*/ */
Tag ServerResourceClassObjectTemplate::getId(void) const Tag ServerResourceClassObjectTemplate::getId(void) const {
{ return ServerResourceClassObjectTemplate_tag;
return ServerResourceClassObjectTemplate_tag; } // ServerResourceClassObjectTemplate::getId
} // ServerResourceClassObjectTemplate::getId
/** /**
* Returns this template's version. * Returns this template's version.
* *
* @return the version * @return the version
*/ */
Tag ServerResourceClassObjectTemplate::getTemplateVersion(void) const Tag ServerResourceClassObjectTemplate::getTemplateVersion(void) const {
{ return m_templateVersion;
return m_templateVersion;
} // ServerResourceClassObjectTemplate::getTemplateVersion } // ServerResourceClassObjectTemplate::getTemplateVersion
/** /**
@@ -83,163 +79,147 @@ Tag ServerResourceClassObjectTemplate::getTemplateVersion(void) const
* *
* @return the highest version * @return the highest version
*/ */
Tag ServerResourceClassObjectTemplate::getHighestTemplateVersion(void) const Tag ServerResourceClassObjectTemplate::getHighestTemplateVersion(void) const {
{ if (m_baseData == NULL)
if (m_baseData == NULL) return m_templateVersion;
return m_templateVersion; const ServerResourceClassObjectTemplate *base = dynamic_cast<const ServerResourceClassObjectTemplate *>(m_baseData);
const ServerResourceClassObjectTemplate * base = dynamic_cast<const ServerResourceClassObjectTemplate *>(m_baseData); if (base == NULL)
if (base == NULL) return m_templateVersion;
return m_templateVersion; return std::max(m_templateVersion, base->getHighestTemplateVersion());
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerResourceClassObjectTemplate::getHighestTemplateVersion } // ServerResourceClassObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD //@BEGIN TFD
CompilerIntegerParam * ServerResourceClassObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) CompilerIntegerParam *
{ ServerResourceClassObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) {
if (strcmp(name, "numTypes") == 0) switch (runtimeCrc(name)) {
{ case constcrc("numTypes"): {
if (index == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (deepCheck && !isParamLoaded(name, false, 0)) if (getBaseTemplate() != NULL)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (getBaseTemplate() != NULL) return NULL;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return NULL; return &m_numTypes;
} }
return &m_numTypes; fprintf(stderr, "trying to access single-parameter \"numTypes\" as an array\n");
} }
fprintf(stderr, "trying to access single-parameter \"numTypes\" as an array\n"); break;
} case constcrc("minTypes"): {
else if (strcmp(name, "minTypes") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != NULL)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return NULL;
{ }
if (getBaseTemplate() != NULL) return &m_minTypes;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return NULL; fprintf(stderr, "trying to access single-parameter \"minTypes\" as an array\n");
} }
return &m_minTypes; break;
} case constcrc("maxTypes"): {
fprintf(stderr, "trying to access single-parameter \"minTypes\" as an array\n"); if (index == 0) {
} if (deepCheck && !isParamLoaded(name, false, 0)) {
else if (strcmp(name, "maxTypes") == 0) if (getBaseTemplate() != NULL)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (index == 0) return NULL;
{ }
if (deepCheck && !isParamLoaded(name, false, 0)) return &m_maxTypes;
{ }
if (getBaseTemplate() != NULL) fprintf(stderr, "trying to access single-parameter \"maxTypes\" as an array\n");
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return NULL; break;
} default:
return &m_maxTypes; return ServerUniverseObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} break;
fprintf(stderr, "trying to access single-parameter \"maxTypes\" as an array\n"); }
} return NULL;
else } //ServerResourceClassObjectTemplate::getCompilerIntegerParam
return ServerUniverseObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return NULL;
} //ServerResourceClassObjectTemplate::getCompilerIntegerParam
FloatParam * ServerResourceClassObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) FloatParam *ServerResourceClassObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) {
{ return ServerUniverseObjectTemplate::getFloatParam(name, deepCheck, index);
return ServerUniverseObjectTemplate::getFloatParam(name, deepCheck, index); } //ServerResourceClassObjectTemplate::getFloatParam
} //ServerResourceClassObjectTemplate::getFloatParam
BoolParam * ServerResourceClassObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) BoolParam *ServerResourceClassObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) {
{ return ServerUniverseObjectTemplate::getBoolParam(name, deepCheck, index);
return ServerUniverseObjectTemplate::getBoolParam(name, deepCheck, index); } //ServerResourceClassObjectTemplate::getBoolParam
} //ServerResourceClassObjectTemplate::getBoolParam
StringParam * ServerResourceClassObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) StringParam *ServerResourceClassObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) {
{ switch (runtimeCrc(name)) {
if (strcmp(name, "resourceClassName") == 0) case constcrc("resourceClassName"): {
{ if (index == 0) {
if (index == 0) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != NULL)
if (deepCheck && !isParamLoaded(name, false, 0)) return getBaseTemplate()->getStringParam(name, deepCheck, index);
{ return NULL;
if (getBaseTemplate() != NULL) }
return getBaseTemplate()->getStringParam(name, deepCheck, index); return &m_resourceClassName;
return NULL; }
} fprintf(stderr, "trying to access single-parameter \"resourceClassName\" as an array\n");
return &m_resourceClassName; }
} break;
fprintf(stderr, "trying to access single-parameter \"resourceClassName\" as an array\n"); case constcrc("parentClass"): {
} if (index == 0) {
else if (strcmp(name, "parentClass") == 0) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != NULL)
if (index == 0) return getBaseTemplate()->getStringParam(name, deepCheck, index);
{ return NULL;
if (deepCheck && !isParamLoaded(name, false, 0)) }
{ return &m_parentClass;
if (getBaseTemplate() != NULL) }
return getBaseTemplate()->getStringParam(name, deepCheck, index); fprintf(stderr, "trying to access single-parameter \"parentClass\" as an array\n");
return NULL; }
} break;
return &m_parentClass; default:
} return ServerUniverseObjectTemplate::getStringParam(name, deepCheck, index);
fprintf(stderr, "trying to access single-parameter \"parentClass\" as an array\n"); break;
} }
else return NULL;
return ServerUniverseObjectTemplate::getStringParam(name, deepCheck, index); } //ServerResourceClassObjectTemplate::getStringParam
return NULL;
} //ServerResourceClassObjectTemplate::getStringParam
StringIdParam * ServerResourceClassObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) StringIdParam *ServerResourceClassObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) {
{ return ServerUniverseObjectTemplate::getStringIdParam(name, deepCheck, index);
return ServerUniverseObjectTemplate::getStringIdParam(name, deepCheck, index); } //ServerResourceClassObjectTemplate::getStringIdParam
} //ServerResourceClassObjectTemplate::getStringIdParam
VectorParam * ServerResourceClassObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) VectorParam *ServerResourceClassObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) {
{ return ServerUniverseObjectTemplate::getVectorParam(name, deepCheck, index);
return ServerUniverseObjectTemplate::getVectorParam(name, deepCheck, index); } //ServerResourceClassObjectTemplate::getVectorParam
} //ServerResourceClassObjectTemplate::getVectorParam
DynamicVariableParam * ServerResourceClassObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) DynamicVariableParam *
{ ServerResourceClassObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) {
return ServerUniverseObjectTemplate::getDynamicVariableParam(name, deepCheck, index); return ServerUniverseObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerResourceClassObjectTemplate::getDynamicVariableParam } //ServerResourceClassObjectTemplate::getDynamicVariableParam
StructParamOT * ServerResourceClassObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) StructParamOT *ServerResourceClassObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) {
{ return ServerUniverseObjectTemplate::getStructParamOT(name, deepCheck, index);
return ServerUniverseObjectTemplate::getStructParamOT(name, deepCheck, index); } //ServerResourceClassObjectTemplate::getStructParamOT
} //ServerResourceClassObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerResourceClassObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) TriggerVolumeParam *
{ ServerResourceClassObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) {
return ServerUniverseObjectTemplate::getTriggerVolumeParam(name, deepCheck, index); return ServerUniverseObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
} //ServerResourceClassObjectTemplate::getTriggerVolumeParam } //ServerResourceClassObjectTemplate::getTriggerVolumeParam
void ServerResourceClassObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) void ServerResourceClassObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) {
{ if (param.isInitialized())
if (param.isInitialized()) return;
return; ServerUniverseObjectTemplate::initStructParamOT(param, name);
ServerUniverseObjectTemplate::initStructParamOT(param, name); } // ServerResourceClassObjectTemplate::initStructParamOT
} // ServerResourceClassObjectTemplate::initStructParamOT
void ServerResourceClassObjectTemplate::setAsEmptyList(const char *name) void ServerResourceClassObjectTemplate::setAsEmptyList(const char *name) {
{ ServerUniverseObjectTemplate::setAsEmptyList(name);
ServerUniverseObjectTemplate::setAsEmptyList(name); } // ServerResourceClassObjectTemplate::setAsEmptyList
} // ServerResourceClassObjectTemplate::setAsEmptyList
void ServerResourceClassObjectTemplate::setAppend(const char *name) void ServerResourceClassObjectTemplate::setAppend(const char *name) {
{ ServerUniverseObjectTemplate::setAppend(name);
ServerUniverseObjectTemplate::setAppend(name); } // ServerResourceClassObjectTemplate::setAppend
} // ServerResourceClassObjectTemplate::setAppend
bool ServerResourceClassObjectTemplate::isAppend(const char *name) const bool ServerResourceClassObjectTemplate::isAppend(const char *name) const {
{ return ServerUniverseObjectTemplate::isAppend(name);
return ServerUniverseObjectTemplate::isAppend(name); } // ServerResourceClassObjectTemplate::isAppend
} // ServerResourceClassObjectTemplate::isAppend
int ServerResourceClassObjectTemplate::getListLength(const char *name) const int ServerResourceClassObjectTemplate::getListLength(const char *name) const {
{ return ServerUniverseObjectTemplate::getListLength(name);
return ServerUniverseObjectTemplate::getListLength(name); } // ServerResourceClassObjectTemplate::getListLength
} // ServerResourceClassObjectTemplate::getListLength
/** /**
* Loads the template data from an iff file. We should already be in the form * Loads the template data from an iff file. We should already be in the form
@@ -247,72 +227,74 @@ int ServerResourceClassObjectTemplate::getListLength(const char *name) const
* *
* @param file file to load from * @param file file to load from
*/ */
void ServerResourceClassObjectTemplate::load(Iff &file) void ServerResourceClassObjectTemplate::load(Iff &file) {
{ static const int MAX_NAME_SIZE = 256;
static const int MAX_NAME_SIZE = 256; char paramName[MAX_NAME_SIZE];
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerResourceClassObjectTemplate_tag) if (file.getCurrentName() != ServerResourceClassObjectTemplate_tag) {
{ ServerUniverseObjectTemplate::load(file);
ServerUniverseObjectTemplate::load(file); return;
return; }
}
file.enterForm(); file.enterForm();
m_templateVersion = file.getCurrentName(); m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V)) if (m_templateVersion == TAG(D, E, R, V)) {
{ file.enterForm();
file.enterForm(); file.enterChunk();
file.enterChunk(); std::string baseFilename;
std::string baseFilename; file.read_string(baseFilename);
file.read_string(baseFilename); file.exitChunk();
file.exitChunk(); const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str())); if (m_baseData == base && base != NULL)
if (m_baseData == base && base != NULL) base->releaseReference();
base->releaseReference(); else {
else if (m_baseData != NULL)
{ m_baseData->releaseReference();
if (m_baseData != NULL) m_baseData = base;
m_baseData->releaseReference(); }
m_baseData = base; file.exitForm();
} m_templateVersion = file.getCurrentName();
file.exitForm(); }
m_templateVersion = file.getCurrentName(); if (getHighestTemplateVersion() != TAG(0, 0, 0, 0)) {
} if (DataLint::isEnabled())
if (getHighestTemplateVersion() != TAG(0,0,0,0)) DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
{ }
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
file.enterForm(); file.enterForm();
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i) {
{ file.enterChunk();
file.enterChunk(); file.read_string(paramName, MAX_NAME_SIZE);
file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "resourceClassName") == 0)
m_resourceClassName.loadFromIff(file);
else if (strcmp(paramName, "numTypes") == 0)
m_numTypes.loadFromIff(file);
else if (strcmp(paramName, "minTypes") == 0)
m_minTypes.loadFromIff(file);
else if (strcmp(paramName, "maxTypes") == 0)
m_maxTypes.loadFromIff(file);
else if (strcmp(paramName, "parentClass") == 0)
m_parentClass.loadFromIff(file);
file.exitChunk(true);
}
file.exitForm(); switch (runtimeCrc(paramName)) {
ServerUniverseObjectTemplate::load(file); case constcrc("resourceClassName"):
file.exitForm(); m_resourceClassName.loadFromIff(file);
return; break;
} // ServerResourceClassObjectTemplate::load case constcrc("numTypes"):
m_numTypes.loadFromIff(file);
break;
case constcrc("minTypes") :
m_minTypes.loadFromIff(file);
break;
case constcrc("maxTypes") :
m_maxTypes.loadFromIff(file);
break;
case constcrc("parentClass") :
m_parentClass.loadFromIff(file);
break;
}
file.exitChunk(true);
}
file.exitForm();
ServerUniverseObjectTemplate::load(file);
file.exitForm();
return;
} // ServerResourceClassObjectTemplate::load
/** /**
* Saves the template data to an iff file. * Saves the template data to an iff file.
@@ -320,65 +302,63 @@ char paramName[MAX_NAME_SIZE];
* @param file file to save to * @param file file to save to
* @param location file type (client or server) * @param location file type (client or server)
*/ */
void ServerResourceClassObjectTemplate::save(Iff &file) void ServerResourceClassObjectTemplate::save(Iff &file) {
{ int count;
int count;
file.insertForm(ServerResourceClassObjectTemplate_tag); file.insertForm(ServerResourceClassObjectTemplate_tag);
if (m_baseTemplateName.size() != 0) if (m_baseTemplateName.size() != 0) {
{ file.insertForm(TAG(D, E, R, V));
file.insertForm(TAG(D,E,R,V)); file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1); file.exitChunk();
file.exitChunk(); file.exitForm();
file.exitForm(); }
} file.insertForm(TAG(0, 0, 0, 0));
file.insertForm(TAG(0,0,0,0)); file.allowNonlinearFunctions();
file.allowNonlinearFunctions();
int paramCount = 0; int paramCount = 0;
// save resourceClassName // save resourceClassName
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("resourceClassName"); file.insertChunkString("resourceClassName");
m_resourceClassName.saveToIff(file); m_resourceClassName.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save numTypes // save numTypes
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("numTypes"); file.insertChunkString("numTypes");
m_numTypes.saveToIff(file); m_numTypes.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save minTypes // save minTypes
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("minTypes"); file.insertChunkString("minTypes");
m_minTypes.saveToIff(file); m_minTypes.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save maxTypes // save maxTypes
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxTypes"); file.insertChunkString("maxTypes");
m_maxTypes.saveToIff(file); m_maxTypes.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save parentClass // save parentClass
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("parentClass"); file.insertChunkString("parentClass");
m_parentClass.saveToIff(file); m_parentClass.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// write number of parameters // write number of parameters
file.goToTopOfForm(); file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T)); file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount)); file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk(); file.exitChunk();
file.exitForm(true); file.exitForm(true);
ServerUniverseObjectTemplate::save(file); ServerUniverseObjectTemplate::save(file);
file.exitForm(); file.exitForm();
UNREF(count); UNREF(count);
} // ServerResourceClassObjectTemplate::save } // ServerResourceClassObjectTemplate::save
//@END TFD //@END TFD
@@ -19,74 +19,67 @@
#include "sharedTemplateDefinition/ObjectTemplate.h" #include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h> #include <stdio.h>
#include "sharedFoundation/CrcConstexpr.hpp"
/** /**
* Class constructor. * Class constructor.
*/ */
ServerTangibleObjectTemplate::ServerTangibleObjectTemplate(const std::string & filename) ServerTangibleObjectTemplate::ServerTangibleObjectTemplate(const std::string &filename)
//@BEGIN TFD INIT //@BEGIN TFD INIT
: ServerObjectTemplate(filename) : ServerObjectTemplate(filename), m_triggerVolumesLoaded(false), m_triggerVolumesAppend(false)
,m_triggerVolumesLoaded(false)
,m_triggerVolumesAppend(false)
//@END TFD INIT //@END TFD INIT
{ {
} // ServerTangibleObjectTemplate::ServerTangibleObjectTemplate } // ServerTangibleObjectTemplate::ServerTangibleObjectTemplate
/** /**
* Class destructor. * Class destructor.
*/ */
ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate() ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate() {
{
//@BEGIN TFD CLEANUP //@BEGIN TFD CLEANUP
{ {
std::vector<TriggerVolumeParam *>::iterator iter; std::vector<TriggerVolumeParam *>::iterator iter;
for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter) for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter) {
{ delete *iter;
delete *iter; *iter = nullptr;
*iter = nullptr; }
} m_triggerVolumes.clear();
m_triggerVolumes.clear(); }
}
//@END TFD CLEANUP //@END TFD CLEANUP
} // ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate } // ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate
/** /**
* Static function used to register this template. * Static function used to register this template.
*/ */
void ServerTangibleObjectTemplate::registerMe(void) void ServerTangibleObjectTemplate::registerMe(void) {
{ ObjectTemplateList::registerTemplate(ServerTangibleObjectTemplate_tag, create);
ObjectTemplateList::registerTemplate(ServerTangibleObjectTemplate_tag, create); } // ServerTangibleObjectTemplate::registerMe
} // ServerTangibleObjectTemplate::registerMe
/** /**
* Creates a ServerTangibleObjectTemplate template. * Creates a ServerTangibleObjectTemplate template.
* *
* @return a new instance of the template * @return a new instance of the template
*/ */
ObjectTemplate * ServerTangibleObjectTemplate::create(const std::string & filename) ObjectTemplate *ServerTangibleObjectTemplate::create(const std::string &filename) {
{ return new ServerTangibleObjectTemplate(filename);
return new ServerTangibleObjectTemplate(filename); } // ServerTangibleObjectTemplate::create
} // ServerTangibleObjectTemplate::create
/** /**
* Returns the template id. * Returns the template id.
* *
* @return the template id * @return the template id
*/ */
Tag ServerTangibleObjectTemplate::getId(void) const Tag ServerTangibleObjectTemplate::getId(void) const {
{ return ServerTangibleObjectTemplate_tag;
return ServerTangibleObjectTemplate_tag; } // ServerTangibleObjectTemplate::getId
} // ServerTangibleObjectTemplate::getId
/** /**
* Returns this template's version. * Returns this template's version.
* *
* @return the version * @return the version
*/ */
Tag ServerTangibleObjectTemplate::getTemplateVersion(void) const Tag ServerTangibleObjectTemplate::getTemplateVersion(void) const {
{ return m_templateVersion;
return m_templateVersion;
} // ServerTangibleObjectTemplate::getTemplateVersion } // ServerTangibleObjectTemplate::getTemplateVersion
/** /**
@@ -94,224 +87,189 @@ Tag ServerTangibleObjectTemplate::getTemplateVersion(void) const
* *
* @return the highest version * @return the highest version
*/ */
Tag ServerTangibleObjectTemplate::getHighestTemplateVersion(void) const Tag ServerTangibleObjectTemplate::getHighestTemplateVersion(void) const {
{ if (m_baseData == NULL)
if (m_baseData == NULL) return m_templateVersion;
return m_templateVersion; const ServerTangibleObjectTemplate *base = dynamic_cast<const ServerTangibleObjectTemplate *>(m_baseData);
const ServerTangibleObjectTemplate * base = dynamic_cast<const ServerTangibleObjectTemplate *>(m_baseData); if (base == NULL)
if (base == NULL) return m_templateVersion;
return m_templateVersion; return std::max(m_templateVersion, base->getHighestTemplateVersion());
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerTangibleObjectTemplate::getHighestTemplateVersion } // ServerTangibleObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD //@BEGIN TFD
CompilerIntegerParam * ServerTangibleObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) CompilerIntegerParam *
{ ServerTangibleObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) {
if (strcmp(name, "combatSkeleton") == 0) switch (runtimeCrc(name)) {
{ case constcrc("combatSkeleton"): {
if (index == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (deepCheck && !isParamLoaded(name, false, 0)) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (getBaseTemplate() != nullptr) return nullptr;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return nullptr; return &m_combatSkeleton;
} }
return &m_combatSkeleton; fprintf(stderr, "trying to access single-parameter \"combatSkeleton\" as an array\n");
} }
fprintf(stderr, "trying to access single-parameter \"combatSkeleton\" as an array\n"); break;
} case constcrc("maxHitPoints"): {
else if (strcmp(name, "maxHitPoints") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_maxHitPoints;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"maxHitPoints\" as an array\n");
} }
return &m_maxHitPoints; break;
} case constcrc("interestRadius"): {
fprintf(stderr, "trying to access single-parameter \"maxHitPoints\" as an array\n"); if (index == 0) {
} if (deepCheck && !isParamLoaded(name, false, 0)) {
else if (strcmp(name, "interestRadius") == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
if (index == 0) return nullptr;
{ }
if (deepCheck && !isParamLoaded(name, false, 0)) return &m_interestRadius;
{ }
if (getBaseTemplate() != nullptr) fprintf(stderr, "trying to access single-parameter \"interestRadius\" as an array\n");
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); }
return nullptr; break;
} case constcrc("count"): {
return &m_interestRadius; if (index == 0) {
} if (deepCheck && !isParamLoaded(name, false, 0)) {
fprintf(stderr, "trying to access single-parameter \"interestRadius\" as an array\n"); if (getBaseTemplate() != nullptr)
} return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
else if (strcmp(name, "count") == 0) return nullptr;
{ }
if (index == 0) return &m_count;
{ }
if (deepCheck && !isParamLoaded(name, false, 0)) fprintf(stderr, "trying to access single-parameter \"count\" as an array\n");
{ }
if (getBaseTemplate() != nullptr) break;
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); case constcrc("condition"): {
return nullptr; if (index == 0) {
} if (deepCheck && !isParamLoaded(name, false, 0)) {
return &m_count; if (getBaseTemplate() != nullptr)
} return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index);
fprintf(stderr, "trying to access single-parameter \"count\" as an array\n"); return nullptr;
} }
else if (strcmp(name, "condition") == 0) return &m_condition;
{ }
if (index == 0) fprintf(stderr, "trying to access single-parameter \"condition\" as an array\n");
{ }
if (deepCheck && !isParamLoaded(name, false, 0)) break;
{ default:
if (getBaseTemplate() != nullptr) return ServerObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return getBaseTemplate()->getCompilerIntegerParam(name, deepCheck, index); break;
return nullptr; }
} return nullptr;
return &m_condition; } //ServerTangibleObjectTemplate::getCompilerIntegerParam
}
fprintf(stderr, "trying to access single-parameter \"condition\" as an array\n");
}
else
return ServerObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
return nullptr;
} //ServerTangibleObjectTemplate::getCompilerIntegerParam
FloatParam * ServerTangibleObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) FloatParam *ServerTangibleObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) {
{ return ServerObjectTemplate::getFloatParam(name, deepCheck, index);
return ServerObjectTemplate::getFloatParam(name, deepCheck, index); } //ServerTangibleObjectTemplate::getFloatParam
} //ServerTangibleObjectTemplate::getFloatParam
BoolParam * ServerTangibleObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) BoolParam *ServerTangibleObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) {
{ if (strcmp(name, "wantSawAttackTriggers") == 0) {
if (strcmp(name, "wantSawAttackTriggers") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getBoolParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_wantSawAttackTriggers;
return getBaseTemplate()->getBoolParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"wantSawAttackTriggers\" as an array\n");
} } else
return &m_wantSawAttackTriggers; return ServerObjectTemplate::getBoolParam(name, deepCheck, index);
} return nullptr;
fprintf(stderr, "trying to access single-parameter \"wantSawAttackTriggers\" as an array\n"); } //ServerTangibleObjectTemplate::getBoolParam
}
else
return ServerObjectTemplate::getBoolParam(name, deepCheck, index);
return nullptr;
} //ServerTangibleObjectTemplate::getBoolParam
StringParam * ServerTangibleObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) StringParam *ServerTangibleObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) {
{ if (strcmp(name, "armor") == 0) {
if (strcmp(name, "armor") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getStringParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_armor;
return getBaseTemplate()->getStringParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"armor\" as an array\n");
} } else
return &m_armor; return ServerObjectTemplate::getStringParam(name, deepCheck, index);
} return nullptr;
fprintf(stderr, "trying to access single-parameter \"armor\" as an array\n"); } //ServerTangibleObjectTemplate::getStringParam
}
else
return ServerObjectTemplate::getStringParam(name, deepCheck, index);
return nullptr;
} //ServerTangibleObjectTemplate::getStringParam
StringIdParam * ServerTangibleObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) StringIdParam *ServerTangibleObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) {
{ return ServerObjectTemplate::getStringIdParam(name, deepCheck, index);
return ServerObjectTemplate::getStringIdParam(name, deepCheck, index); } //ServerTangibleObjectTemplate::getStringIdParam
} //ServerTangibleObjectTemplate::getStringIdParam
VectorParam * ServerTangibleObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) VectorParam *ServerTangibleObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) {
{ return ServerObjectTemplate::getVectorParam(name, deepCheck, index);
return ServerObjectTemplate::getVectorParam(name, deepCheck, index); } //ServerTangibleObjectTemplate::getVectorParam
} //ServerTangibleObjectTemplate::getVectorParam
DynamicVariableParam * ServerTangibleObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) DynamicVariableParam *
{ ServerTangibleObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) {
return ServerObjectTemplate::getDynamicVariableParam(name, deepCheck, index); return ServerObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerTangibleObjectTemplate::getDynamicVariableParam } //ServerTangibleObjectTemplate::getDynamicVariableParam
StructParamOT * ServerTangibleObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) StructParamOT *ServerTangibleObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) {
{ return ServerObjectTemplate::getStructParamOT(name, deepCheck, index);
return ServerObjectTemplate::getStructParamOT(name, deepCheck, index); } //ServerTangibleObjectTemplate::getStructParamOT
} //ServerTangibleObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerTangibleObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) TriggerVolumeParam *ServerTangibleObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) {
{ if (strcmp(name, "triggerVolumes") == 0) {
if (strcmp(name, "triggerVolumes") == 0) if (index >= 0 && index < static_cast<int>(m_triggerVolumes.size()))
{ return m_triggerVolumes[index];
if (index >= 0 && index < static_cast<int>(m_triggerVolumes.size())) if (index == static_cast<int>(m_triggerVolumes.size())) {
return m_triggerVolumes[index]; TriggerVolumeParam *temp = new TriggerVolumeParam();
if (index == static_cast<int>(m_triggerVolumes.size())) m_triggerVolumes.push_back(temp);
{ return temp;
TriggerVolumeParam *temp = new TriggerVolumeParam(); }
m_triggerVolumes.push_back(temp); fprintf(stderr, "index for parameter \"triggerVolumes\" out of bounds\n");
return temp; } else
} return ServerObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
fprintf(stderr, "index for parameter \"triggerVolumes\" out of bounds\n"); return nullptr;
} } //ServerTangibleObjectTemplate::getTriggerVolumeParam
else
return ServerObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
return nullptr;
} //ServerTangibleObjectTemplate::getTriggerVolumeParam
void ServerTangibleObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) void ServerTangibleObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) {
{ if (param.isInitialized())
if (param.isInitialized()) return;
return; ServerObjectTemplate::initStructParamOT(param, name);
ServerObjectTemplate::initStructParamOT(param, name); } // ServerTangibleObjectTemplate::initStructParamOT
} // ServerTangibleObjectTemplate::initStructParamOT
void ServerTangibleObjectTemplate::setAsEmptyList(const char *name) void ServerTangibleObjectTemplate::setAsEmptyList(const char *name) {
{ if (strcmp(name, "triggerVolumes") == 0) {
if (strcmp(name, "triggerVolumes") == 0) m_triggerVolumes.clear();
{ m_triggerVolumesLoaded = true;
m_triggerVolumes.clear(); } else
m_triggerVolumesLoaded = true; ServerObjectTemplate::setAsEmptyList(name);
} } // ServerTangibleObjectTemplate::setAsEmptyList
else
ServerObjectTemplate::setAsEmptyList(name);
} // ServerTangibleObjectTemplate::setAsEmptyList
void ServerTangibleObjectTemplate::setAppend(const char *name) void ServerTangibleObjectTemplate::setAppend(const char *name) {
{ if (strcmp(name, "triggerVolumes") == 0)
if (strcmp(name, "triggerVolumes") == 0) m_triggerVolumesAppend = true;
m_triggerVolumesAppend = true; else
else ServerObjectTemplate::setAppend(name);
ServerObjectTemplate::setAppend(name); } // ServerTangibleObjectTemplate::setAppend
} // ServerTangibleObjectTemplate::setAppend
bool ServerTangibleObjectTemplate::isAppend(const char *name) const bool ServerTangibleObjectTemplate::isAppend(const char *name) const {
{ if (strcmp(name, "triggerVolumes") == 0)
if (strcmp(name, "triggerVolumes") == 0) return m_triggerVolumesAppend;
return m_triggerVolumesAppend; else
else return ServerObjectTemplate::isAppend(name);
return ServerObjectTemplate::isAppend(name); } // ServerTangibleObjectTemplate::isAppend
} // ServerTangibleObjectTemplate::isAppend
int ServerTangibleObjectTemplate::getListLength(const char *name) const int ServerTangibleObjectTemplate::getListLength(const char *name) const {
{ if (strcmp(name, "triggerVolumes") == 0) {
if (strcmp(name, "triggerVolumes") == 0) return m_triggerVolumes.size();
{ } else
return m_triggerVolumes.size(); return ServerObjectTemplate::getListLength(name);
} } // ServerTangibleObjectTemplate::getListLength
else
return ServerObjectTemplate::getListLength(name);
} // ServerTangibleObjectTemplate::getListLength
/** /**
* Loads the template data from an iff file. We should already be in the form * Loads the template data from an iff file. We should already be in the form
@@ -319,95 +277,97 @@ int ServerTangibleObjectTemplate::getListLength(const char *name) const
* *
* @param file file to load from * @param file file to load from
*/ */
void ServerTangibleObjectTemplate::load(Iff &file) void ServerTangibleObjectTemplate::load(Iff &file) {
{ static const int MAX_NAME_SIZE = 256;
static const int MAX_NAME_SIZE = 256; char paramName[MAX_NAME_SIZE];
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerTangibleObjectTemplate_tag) if (file.getCurrentName() != ServerTangibleObjectTemplate_tag) {
{ ServerObjectTemplate::load(file);
ServerObjectTemplate::load(file); return;
return; }
}
file.enterForm(); file.enterForm();
m_templateVersion = file.getCurrentName(); m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V)) if (m_templateVersion == TAG(D, E, R, V)) {
{ file.enterForm();
file.enterForm(); file.enterChunk();
file.enterChunk(); std::string baseFilename;
std::string baseFilename; file.read_string(baseFilename);
file.read_string(baseFilename); file.exitChunk();
file.exitChunk(); const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str()));
DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str())); if (m_baseData == base && base != nullptr)
if (m_baseData == base && base != nullptr) base->releaseReference();
base->releaseReference(); else {
else if (m_baseData != nullptr)
{ m_baseData->releaseReference();
if (m_baseData != nullptr) m_baseData = base;
m_baseData->releaseReference(); }
m_baseData = base; file.exitForm();
} m_templateVersion = file.getCurrentName();
file.exitForm(); }
m_templateVersion = file.getCurrentName(); if (getHighestTemplateVersion() != TAG(0, 0, 0, 4)) {
} if (DataLint::isEnabled())
if (getHighestTemplateVersion() != TAG(0,0,0,4)) DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
{ }
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
file.enterForm(); file.enterForm();
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i) {
{ file.enterChunk();
file.enterChunk(); file.read_string(paramName, MAX_NAME_SIZE);
file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "triggerVolumes") == 0)
{
std::vector<TriggerVolumeParam *>::iterator iter;
for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter)
{
delete *iter;
*iter = nullptr;
}
m_triggerVolumes.clear();
m_triggerVolumesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j)
{
TriggerVolumeParam * newData = new TriggerVolumeParam;
newData->loadFromIff(file);
m_triggerVolumes.push_back(newData);
}
m_triggerVolumesLoaded = true;
}
else if (strcmp(paramName, "combatSkeleton") == 0)
m_combatSkeleton.loadFromIff(file);
else if (strcmp(paramName, "maxHitPoints") == 0)
m_maxHitPoints.loadFromIff(file);
else if (strcmp(paramName, "armor") == 0)
m_armor.loadFromIff(file);
else if (strcmp(paramName, "interestRadius") == 0)
m_interestRadius.loadFromIff(file);
else if (strcmp(paramName, "count") == 0)
m_count.loadFromIff(file);
else if (strcmp(paramName, "condition") == 0)
m_condition.loadFromIff(file);
else if (strcmp(paramName, "wantSawAttackTriggers") == 0)
m_wantSawAttackTriggers.loadFromIff(file);
file.exitChunk(true);
}
file.exitForm(); switch (runtimeCrc(paramName)) {
ServerObjectTemplate::load(file); case constcrc("triggerVolumes"): {
file.exitForm(); std::vector<TriggerVolumeParam *>::iterator iter;
return; for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter) {
} // ServerTangibleObjectTemplate::load delete *iter;
*iter = nullptr;
}
m_triggerVolumes.clear();
m_triggerVolumesAppend = file.read_bool8();
int listCount = file.read_int32();
for (int j = 0; j < listCount; ++j) {
TriggerVolumeParam *newData = new TriggerVolumeParam;
newData->loadFromIff(file);
m_triggerVolumes.push_back(newData);
}
m_triggerVolumesLoaded = true;
}
break;
case constcrc("combatSkeleton"):
m_combatSkeleton.loadFromIff(file);
break;
case constcrc("maxHitPoints"):
m_maxHitPoints.loadFromIff(file);
break;
case constcrc("armor"):
m_armor.loadFromIff(file);
break;
case constcrc("interestRadius"):
m_interestRadius.loadFromIff(file);
break;
case constcrc("count"):
m_count.loadFromIff(file);
break;
case constcrc("condition"):
m_condition.loadFromIff(file);
break;
case constcrc("wantSawAttackTriggers"):
m_wantSawAttackTriggers.loadFromIff(file);
break;
}
file.exitChunk(true);
}
file.exitForm();
ServerObjectTemplate::load(file);
file.exitForm();
return;
} // ServerTangibleObjectTemplate::load
/** /**
* Saves the template data to an iff file. * Saves the template data to an iff file.
@@ -415,91 +375,90 @@ char paramName[MAX_NAME_SIZE];
* @param file file to save to * @param file file to save to
* @param location file type (client or server) * @param location file type (client or server)
*/ */
void ServerTangibleObjectTemplate::save(Iff &file) void ServerTangibleObjectTemplate::save(Iff &file) {
{ int count;
int count;
file.insertForm(ServerTangibleObjectTemplate_tag); file.insertForm(ServerTangibleObjectTemplate_tag);
if (m_baseTemplateName.size() != 0) if (m_baseTemplateName.size() != 0) {
{ file.insertForm(TAG(D, E, R, V));
file.insertForm(TAG(D,E,R,V)); file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1); file.exitChunk();
file.exitChunk(); file.exitForm();
file.exitForm(); }
} file.insertForm(TAG(0, 0, 0, 4));
file.insertForm(TAG(0,0,0,4)); file.allowNonlinearFunctions();
file.allowNonlinearFunctions();
int paramCount = 0; int paramCount = 0;
if (!m_triggerVolumesLoaded) if (!m_triggerVolumesLoaded) {
{ // mark the list as empty and extending the base list
// mark the list as empty and extending the base list m_triggerVolumesAppend = true;
m_triggerVolumesAppend = true; }
} // save triggerVolumes
// save triggerVolumes file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkString("triggerVolumes");
file.insertChunkString("triggerVolumes"); file.insertChunkData(&m_triggerVolumesAppend, sizeof(bool));
file.insertChunkData(&m_triggerVolumesAppend, sizeof(bool)); count = m_triggerVolumes.size();
count = m_triggerVolumes.size(); file.insertChunkData(&count, sizeof(count));
file.insertChunkData(&count, sizeof(count)); {
{for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
m_triggerVolumes[i]->saveToIff(file);} m_triggerVolumes[i]->saveToIff(file);
file.exitChunk(); }
++paramCount; file.exitChunk();
// save combatSkeleton ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save combatSkeleton
file.insertChunkString("combatSkeleton"); file.insertChunk(TAG(X, X, X, X));
m_combatSkeleton.saveToIff(file); file.insertChunkString("combatSkeleton");
file.exitChunk(); m_combatSkeleton.saveToIff(file);
++paramCount; file.exitChunk();
// save maxHitPoints ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save maxHitPoints
file.insertChunkString("maxHitPoints"); file.insertChunk(TAG(X, X, X, X));
m_maxHitPoints.saveToIff(file); file.insertChunkString("maxHitPoints");
file.exitChunk(); m_maxHitPoints.saveToIff(file);
++paramCount; file.exitChunk();
// save armor ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save armor
file.insertChunkString("armor"); file.insertChunk(TAG(X, X, X, X));
m_armor.saveToIff(file); file.insertChunkString("armor");
file.exitChunk(); m_armor.saveToIff(file);
++paramCount; file.exitChunk();
// save interestRadius ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save interestRadius
file.insertChunkString("interestRadius"); file.insertChunk(TAG(X, X, X, X));
m_interestRadius.saveToIff(file); file.insertChunkString("interestRadius");
file.exitChunk(); m_interestRadius.saveToIff(file);
++paramCount; file.exitChunk();
// save count ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save count
file.insertChunkString("count"); file.insertChunk(TAG(X, X, X, X));
m_count.saveToIff(file); file.insertChunkString("count");
file.exitChunk(); m_count.saveToIff(file);
++paramCount; file.exitChunk();
// save condition ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save condition
file.insertChunkString("condition"); file.insertChunk(TAG(X, X, X, X));
m_condition.saveToIff(file); file.insertChunkString("condition");
file.exitChunk(); m_condition.saveToIff(file);
++paramCount; file.exitChunk();
// save wantSawAttackTriggers ++paramCount;
file.insertChunk(TAG(X, X, X, X)); // save wantSawAttackTriggers
file.insertChunkString("wantSawAttackTriggers"); file.insertChunk(TAG(X, X, X, X));
m_wantSawAttackTriggers.saveToIff(file); file.insertChunkString("wantSawAttackTriggers");
file.exitChunk(); m_wantSawAttackTriggers.saveToIff(file);
++paramCount; file.exitChunk();
++paramCount;
// write number of parameters // write number of parameters
file.goToTopOfForm(); file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T)); file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount)); file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk(); file.exitChunk();
file.exitForm(true); file.exitForm(true);
ServerObjectTemplate::save(file); ServerObjectTemplate::save(file);
file.exitForm(); file.exitForm();
} // ServerTangibleObjectTemplate::save } // ServerTangibleObjectTemplate::save
//@END TFD //@END TFD
File diff suppressed because it is too large Load Diff
@@ -19,63 +19,59 @@
#include "sharedTemplateDefinition/ObjectTemplate.h" #include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h> #include <stdio.h>
#include "sharedFoundation/CrcConstexpr.hpp"
/** /**
* Class constructor. * Class constructor.
*/ */
ServerVehicleObjectTemplate::ServerVehicleObjectTemplate(const std::string & filename) ServerVehicleObjectTemplate::ServerVehicleObjectTemplate(const std::string &filename)
//@BEGIN TFD INIT //@BEGIN TFD INIT
: ServerTangibleObjectTemplate(filename) : ServerTangibleObjectTemplate(filename)
//@END TFD INIT //@END TFD INIT
{ {
} // ServerVehicleObjectTemplate::ServerVehicleObjectTemplate } // ServerVehicleObjectTemplate::ServerVehicleObjectTemplate
/** /**
* Class destructor. * Class destructor.
*/ */
ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate() ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate() {
{
//@BEGIN TFD CLEANUP //@BEGIN TFD CLEANUP
//@END TFD CLEANUP //@END TFD CLEANUP
} // ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate } // ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate
/** /**
* Static function used to register this template. * Static function used to register this template.
*/ */
void ServerVehicleObjectTemplate::registerMe(void) void ServerVehicleObjectTemplate::registerMe(void) {
{ ObjectTemplateList::registerTemplate(ServerVehicleObjectTemplate_tag, create);
ObjectTemplateList::registerTemplate(ServerVehicleObjectTemplate_tag, create); } // ServerVehicleObjectTemplate::registerMe
} // ServerVehicleObjectTemplate::registerMe
/** /**
* Creates a ServerVehicleObjectTemplate template. * Creates a ServerVehicleObjectTemplate template.
* *
* @return a new instance of the template * @return a new instance of the template
*/ */
ObjectTemplate * ServerVehicleObjectTemplate::create(const std::string & filename) ObjectTemplate *ServerVehicleObjectTemplate::create(const std::string &filename) {
{ return new ServerVehicleObjectTemplate(filename);
return new ServerVehicleObjectTemplate(filename); } // ServerVehicleObjectTemplate::create
} // ServerVehicleObjectTemplate::create
/** /**
* Returns the template id. * Returns the template id.
* *
* @return the template id * @return the template id
*/ */
Tag ServerVehicleObjectTemplate::getId(void) const Tag ServerVehicleObjectTemplate::getId(void) const {
{ return ServerVehicleObjectTemplate_tag;
return ServerVehicleObjectTemplate_tag; } // ServerVehicleObjectTemplate::getId
} // ServerVehicleObjectTemplate::getId
/** /**
* Returns this template's version. * Returns this template's version.
* *
* @return the version * @return the version
*/ */
Tag ServerVehicleObjectTemplate::getTemplateVersion(void) const Tag ServerVehicleObjectTemplate::getTemplateVersion(void) const {
{ return m_templateVersion;
return m_templateVersion;
} // ServerVehicleObjectTemplate::getTemplateVersion } // ServerVehicleObjectTemplate::getTemplateVersion
/** /**
@@ -83,149 +79,129 @@ Tag ServerVehicleObjectTemplate::getTemplateVersion(void) const
* *
* @return the highest version * @return the highest version
*/ */
Tag ServerVehicleObjectTemplate::getHighestTemplateVersion(void) const Tag ServerVehicleObjectTemplate::getHighestTemplateVersion(void) const {
{ if (m_baseData == NULL)
if (m_baseData == NULL) return m_templateVersion;
return m_templateVersion; const ServerVehicleObjectTemplate *base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData);
const ServerVehicleObjectTemplate * base = dynamic_cast<const ServerVehicleObjectTemplate *>(m_baseData); if (base == NULL)
if (base == NULL) return m_templateVersion;
return m_templateVersion; return std::max(m_templateVersion, base->getHighestTemplateVersion());
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // ServerVehicleObjectTemplate::getHighestTemplateVersion } // ServerVehicleObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD //@BEGIN TFD
CompilerIntegerParam * ServerVehicleObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) CompilerIntegerParam *
{ ServerVehicleObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) {
return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index); return ServerTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //ServerVehicleObjectTemplate::getCompilerIntegerParam } //ServerVehicleObjectTemplate::getCompilerIntegerParam
FloatParam * ServerVehicleObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) FloatParam *ServerVehicleObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) {
{ switch (runtimeCrc(name)) {
if (strcmp(name, "currentFuel") == 0) case constcrc("currentFuel"): {
{ if (index == 0) {
if (index == 0) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != nullptr)
if (deepCheck && !isParamLoaded(name, false, 0)) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
{ return nullptr;
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getFloatParam(name, deepCheck, index); return &m_currentFuel;
return nullptr; }
} fprintf(stderr, "trying to access single-parameter \"currentFuel\" as an array\n");
return &m_currentFuel; }
} break;
fprintf(stderr, "trying to access single-parameter \"currentFuel\" as an array\n"); case constcrc("maxFuel"): {
} if (index == 0) {
else if (strcmp(name, "maxFuel") == 0) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != nullptr)
if (index == 0) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
{ return nullptr;
if (deepCheck && !isParamLoaded(name, false, 0)) }
{ return &m_maxFuel;
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getFloatParam(name, deepCheck, index); fprintf(stderr, "trying to access single-parameter \"maxFuel\" as an array\n");
return nullptr; }
} break;
return &m_maxFuel; case constcrc("consumpsion"): {
} if (index == 0) {
fprintf(stderr, "trying to access single-parameter \"maxFuel\" as an array\n"); if (deepCheck && !isParamLoaded(name, false, 0)) {
} if (getBaseTemplate() != nullptr)
else if (strcmp(name, "consumpsion") == 0) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
{ return nullptr;
if (index == 0) }
{ return &m_consumpsion;
if (deepCheck && !isParamLoaded(name, false, 0)) }
{ fprintf(stderr, "trying to access single-parameter \"consumpsion\" as an array\n");
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getFloatParam(name, deepCheck, index); break;
return nullptr; default:
} return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
return &m_consumpsion; break;
} }
fprintf(stderr, "trying to access single-parameter \"consumpsion\" as an array\n"); return nullptr;
} } //ServerVehicleObjectTemplate::getFloatParam
else
return ServerTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
return nullptr;
} //ServerVehicleObjectTemplate::getFloatParam
BoolParam * ServerVehicleObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) BoolParam *ServerVehicleObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getBoolParam(name, deepCheck, index); } //ServerVehicleObjectTemplate::getBoolParam
} //ServerVehicleObjectTemplate::getBoolParam
StringParam * ServerVehicleObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) StringParam *ServerVehicleObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) {
{ if (strcmp(name, "fuelType") == 0) {
if (strcmp(name, "fuelType") == 0) if (index == 0) {
{ if (deepCheck && !isParamLoaded(name, false, 0)) {
if (index == 0) if (getBaseTemplate() != nullptr)
{ return getBaseTemplate()->getStringParam(name, deepCheck, index);
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ }
if (getBaseTemplate() != nullptr) return &m_fuelType;
return getBaseTemplate()->getStringParam(name, deepCheck, index); }
return nullptr; fprintf(stderr, "trying to access single-parameter \"fuelType\" as an array\n");
} } else
return &m_fuelType; return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
} return nullptr;
fprintf(stderr, "trying to access single-parameter \"fuelType\" as an array\n"); } //ServerVehicleObjectTemplate::getStringParam
}
else
return ServerTangibleObjectTemplate::getStringParam(name, deepCheck, index);
return nullptr;
} //ServerVehicleObjectTemplate::getStringParam
StringIdParam * ServerVehicleObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) StringIdParam *ServerVehicleObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getStringIdParam(name, deepCheck, index); } //ServerVehicleObjectTemplate::getStringIdParam
} //ServerVehicleObjectTemplate::getStringIdParam
VectorParam * ServerVehicleObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) VectorParam *ServerVehicleObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getVectorParam(name, deepCheck, index); } //ServerVehicleObjectTemplate::getVectorParam
} //ServerVehicleObjectTemplate::getVectorParam
DynamicVariableParam * ServerVehicleObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) DynamicVariableParam *
{ ServerVehicleObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) {
return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index); return ServerTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //ServerVehicleObjectTemplate::getDynamicVariableParam } //ServerVehicleObjectTemplate::getDynamicVariableParam
StructParamOT * ServerVehicleObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) StructParamOT *ServerVehicleObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
return ServerTangibleObjectTemplate::getStructParamOT(name, deepCheck, index); } //ServerVehicleObjectTemplate::getStructParamOT
} //ServerVehicleObjectTemplate::getStructParamOT
TriggerVolumeParam * ServerVehicleObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) TriggerVolumeParam *ServerVehicleObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) {
{ return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
return ServerTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index); } //ServerVehicleObjectTemplate::getTriggerVolumeParam
} //ServerVehicleObjectTemplate::getTriggerVolumeParam
void ServerVehicleObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) void ServerVehicleObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) {
{ if (param.isInitialized())
if (param.isInitialized()) return;
return; ServerTangibleObjectTemplate::initStructParamOT(param, name);
ServerTangibleObjectTemplate::initStructParamOT(param, name); } // ServerVehicleObjectTemplate::initStructParamOT
} // ServerVehicleObjectTemplate::initStructParamOT
void ServerVehicleObjectTemplate::setAsEmptyList(const char *name) void ServerVehicleObjectTemplate::setAsEmptyList(const char *name) {
{ ServerTangibleObjectTemplate::setAsEmptyList(name);
ServerTangibleObjectTemplate::setAsEmptyList(name); } // ServerVehicleObjectTemplate::setAsEmptyList
} // ServerVehicleObjectTemplate::setAsEmptyList
void ServerVehicleObjectTemplate::setAppend(const char *name) void ServerVehicleObjectTemplate::setAppend(const char *name) {
{ ServerTangibleObjectTemplate::setAppend(name);
ServerTangibleObjectTemplate::setAppend(name); } // ServerVehicleObjectTemplate::setAppend
} // ServerVehicleObjectTemplate::setAppend
bool ServerVehicleObjectTemplate::isAppend(const char *name) const bool ServerVehicleObjectTemplate::isAppend(const char *name) const {
{ return ServerTangibleObjectTemplate::isAppend(name);
return ServerTangibleObjectTemplate::isAppend(name); } // ServerVehicleObjectTemplate::isAppend
} // ServerVehicleObjectTemplate::isAppend
int ServerVehicleObjectTemplate::getListLength(const char *name) const int ServerVehicleObjectTemplate::getListLength(const char *name) const {
{ return ServerTangibleObjectTemplate::getListLength(name);
return ServerTangibleObjectTemplate::getListLength(name); } // ServerVehicleObjectTemplate::getListLength
} // ServerVehicleObjectTemplate::getListLength
/** /**
* Loads the template data from an iff file. We should already be in the form * Loads the template data from an iff file. We should already be in the form
@@ -233,70 +209,71 @@ int ServerVehicleObjectTemplate::getListLength(const char *name) const
* *
* @param file file to load from * @param file file to load from
*/ */
void ServerVehicleObjectTemplate::load(Iff &file) void ServerVehicleObjectTemplate::load(Iff &file) {
{ static const int MAX_NAME_SIZE = 256;
static const int MAX_NAME_SIZE = 256; char paramName[MAX_NAME_SIZE];
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerVehicleObjectTemplate_tag) if (file.getCurrentName() != ServerVehicleObjectTemplate_tag) {
{ ServerTangibleObjectTemplate::load(file);
ServerTangibleObjectTemplate::load(file); return;
return; }
}
file.enterForm(); file.enterForm();
m_templateVersion = file.getCurrentName(); m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V)) if (m_templateVersion == TAG(D, E, R, V)) {
{ file.enterForm();
file.enterForm(); file.enterChunk();
file.enterChunk(); std::string baseFilename;
std::string baseFilename; file.read_string(baseFilename);
file.read_string(baseFilename); file.exitChunk();
file.exitChunk(); const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str()));
DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str())); if (m_baseData == base && base != nullptr)
if (m_baseData == base && base != nullptr) base->releaseReference();
base->releaseReference(); else {
else if (m_baseData != nullptr)
{ m_baseData->releaseReference();
if (m_baseData != nullptr) m_baseData = base;
m_baseData->releaseReference(); }
m_baseData = base; file.exitForm();
} m_templateVersion = file.getCurrentName();
file.exitForm(); }
m_templateVersion = file.getCurrentName(); if (getHighestTemplateVersion() != TAG(0, 0, 0, 0)) {
} if (DataLint::isEnabled())
if (getHighestTemplateVersion() != TAG(0,0,0,0)) DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
{ }
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
file.enterForm(); file.enterForm();
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i) {
{ file.enterChunk();
file.enterChunk(); file.read_string(paramName, MAX_NAME_SIZE);
file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "fuelType") == 0)
m_fuelType.loadFromIff(file);
else if (strcmp(paramName, "currentFuel") == 0)
m_currentFuel.loadFromIff(file);
else if (strcmp(paramName, "maxFuel") == 0)
m_maxFuel.loadFromIff(file);
else if (strcmp(paramName, "consumpsion") == 0)
m_consumpsion.loadFromIff(file);
file.exitChunk(true);
}
file.exitForm(); switch (runtimeCrc(paramName)) {
ServerTangibleObjectTemplate::load(file); case constcrc("fuelType"):
file.exitForm(); m_fuelType.loadFromIff(file);
return; break;
} // ServerVehicleObjectTemplate::load case constcrc("currentFuel"):
m_currentFuel.loadFromIff(file);
break;
case constcrc("maxFuel"):
m_maxFuel.loadFromIff(file);
break;
case constcrc("consumpsion"):
m_consumpsion.loadFromIff(file);
break;
}
file.exitChunk(true);
}
file.exitForm();
ServerTangibleObjectTemplate::load(file);
file.exitForm();
return;
} // ServerVehicleObjectTemplate::load
/** /**
* Saves the template data to an iff file. * Saves the template data to an iff file.
@@ -304,59 +281,57 @@ char paramName[MAX_NAME_SIZE];
* @param file file to save to * @param file file to save to
* @param location file type (client or server) * @param location file type (client or server)
*/ */
void ServerVehicleObjectTemplate::save(Iff &file) void ServerVehicleObjectTemplate::save(Iff &file) {
{ int count;
int count;
file.insertForm(ServerVehicleObjectTemplate_tag); file.insertForm(ServerVehicleObjectTemplate_tag);
if (m_baseTemplateName.size() != 0) if (m_baseTemplateName.size() != 0) {
{ file.insertForm(TAG(D, E, R, V));
file.insertForm(TAG(D,E,R,V)); file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1); file.exitChunk();
file.exitChunk(); file.exitForm();
file.exitForm(); }
} file.insertForm(TAG(0, 0, 0, 0));
file.insertForm(TAG(0,0,0,0)); file.allowNonlinearFunctions();
file.allowNonlinearFunctions();
int paramCount = 0; int paramCount = 0;
// save fuelType // save fuelType
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("fuelType"); file.insertChunkString("fuelType");
m_fuelType.saveToIff(file); m_fuelType.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save currentFuel // save currentFuel
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("currentFuel"); file.insertChunkString("currentFuel");
m_currentFuel.saveToIff(file); m_currentFuel.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save maxFuel // save maxFuel
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("maxFuel"); file.insertChunkString("maxFuel");
m_maxFuel.saveToIff(file); m_maxFuel.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// save consumpsion // save consumpsion
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("consumpsion"); file.insertChunkString("consumpsion");
m_consumpsion.saveToIff(file); m_consumpsion.saveToIff(file);
file.exitChunk(); file.exitChunk();
++paramCount; ++paramCount;
// write number of parameters // write number of parameters
file.goToTopOfForm(); file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T)); file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount)); file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk(); file.exitChunk();
file.exitForm(true); file.exitForm(true);
ServerTangibleObjectTemplate::save(file); ServerTangibleObjectTemplate::save(file);
file.exitForm(); file.exitForm();
UNREF(count); UNREF(count);
} // ServerVehicleObjectTemplate::save } // ServerVehicleObjectTemplate::save
//@END TFD //@END TFD
File diff suppressed because it is too large Load Diff
@@ -19,7 +19,7 @@
#include "sharedTemplateDefinition/ObjectTemplate.h" #include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h> #include <stdio.h>
#include "sharedFoundation/CrcConstexpr.hpp"
/** /**
* Class constructor. * Class constructor.
@@ -281,14 +281,21 @@ char paramName[MAX_NAME_SIZE];
{ {
file.enterChunk(); file.enterChunk();
file.read_string(paramName, MAX_NAME_SIZE); file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "cockpitFilename") == 0)
m_cockpitFilename.loadFromIff(file); switch(runtimeCrc(paramName)) {
else if (strcmp(paramName, "hasWings") == 0) case constcrc("cockpitFilename"):
m_hasWings.loadFromIff(file); m_cockpitFilename.loadFromIff(file);
else if (strcmp(paramName, "playerControlled") == 0) break;
m_playerControlled.loadFromIff(file); case constcrc("hasWings"):
else if (strcmp(paramName, "interiorLayoutFileName") == 0) m_hasWings.loadFromIff(file);
m_interiorLayoutFileName.loadFromIff(file); break;
case constcrc("playerControlled"):
m_playerControlled.loadFromIff(file);
break;
case constcrc("interiorLayoutFileName"):
m_interiorLayoutFileName.loadFromIff(file);
break;
}
file.exitChunk(true); file.exitChunk(true);
} }
File diff suppressed because it is too large Load Diff
@@ -19,63 +19,58 @@
#include "sharedTemplateDefinition/ObjectTemplate.h" #include "sharedTemplateDefinition/ObjectTemplate.h"
#include <stdio.h> #include <stdio.h>
#include "sharedFoundation/CrcConstexpr.hpp"
/** /**
* Class constructor. * Class constructor.
*/ */
SharedVehicleObjectTemplate::SharedVehicleObjectTemplate(const std::string & filename) SharedVehicleObjectTemplate::SharedVehicleObjectTemplate(const std::string &filename)
//@BEGIN TFD INIT //@BEGIN TFD INIT
: SharedTangibleObjectTemplate(filename) : SharedTangibleObjectTemplate(filename)
//@END TFD INIT //@END TFD INIT
{ {
} // SharedVehicleObjectTemplate::SharedVehicleObjectTemplate } // SharedVehicleObjectTemplate::SharedVehicleObjectTemplate
/** /**
* Class destructor. * Class destructor.
*/ */
SharedVehicleObjectTemplate::~SharedVehicleObjectTemplate() SharedVehicleObjectTemplate::~SharedVehicleObjectTemplate() {
{
//@BEGIN TFD CLEANUP //@BEGIN TFD CLEANUP
//@END TFD CLEANUP //@END TFD CLEANUP
} // SharedVehicleObjectTemplate::~SharedVehicleObjectTemplate } // SharedVehicleObjectTemplate::~SharedVehicleObjectTemplate
/** /**
* Static function used to register this template. * Static function used to register this template.
*/ */
void SharedVehicleObjectTemplate::registerMe(void) void SharedVehicleObjectTemplate::registerMe(void) {
{ ObjectTemplateList::registerTemplate(SharedVehicleObjectTemplate_tag, create);
ObjectTemplateList::registerTemplate(SharedVehicleObjectTemplate_tag, create); } // SharedVehicleObjectTemplate::registerMe
} // SharedVehicleObjectTemplate::registerMe
/** /**
* Creates a SharedVehicleObjectTemplate template. * Creates a SharedVehicleObjectTemplate template.
* *
* @return a new instance of the template * @return a new instance of the template
*/ */
ObjectTemplate * SharedVehicleObjectTemplate::create(const std::string & filename) ObjectTemplate *SharedVehicleObjectTemplate::create(const std::string &filename) {
{ return new SharedVehicleObjectTemplate(filename);
return new SharedVehicleObjectTemplate(filename); } // SharedVehicleObjectTemplate::create
} // SharedVehicleObjectTemplate::create
/** /**
* Returns the template id. * Returns the template id.
* *
* @return the template id * @return the template id
*/ */
Tag SharedVehicleObjectTemplate::getId(void) const Tag SharedVehicleObjectTemplate::getId(void) const {
{ return SharedVehicleObjectTemplate_tag;
return SharedVehicleObjectTemplate_tag; } // SharedVehicleObjectTemplate::getId
} // SharedVehicleObjectTemplate::getId
/** /**
* Returns this template's version. * Returns this template's version.
* *
* @return the version * @return the version
*/ */
Tag SharedVehicleObjectTemplate::getTemplateVersion(void) const Tag SharedVehicleObjectTemplate::getTemplateVersion(void) const {
{ return m_templateVersion;
return m_templateVersion;
} // SharedVehicleObjectTemplate::getTemplateVersion } // SharedVehicleObjectTemplate::getTemplateVersion
/** /**
@@ -83,194 +78,168 @@ Tag SharedVehicleObjectTemplate::getTemplateVersion(void) const
* *
* @return the highest version * @return the highest version
*/ */
Tag SharedVehicleObjectTemplate::getHighestTemplateVersion(void) const Tag SharedVehicleObjectTemplate::getHighestTemplateVersion(void) const {
{ if (m_baseData == NULL)
if (m_baseData == NULL) return m_templateVersion;
return m_templateVersion; const SharedVehicleObjectTemplate *base = dynamic_cast<const SharedVehicleObjectTemplate *>(m_baseData);
const SharedVehicleObjectTemplate * base = dynamic_cast<const SharedVehicleObjectTemplate *>(m_baseData); if (base == NULL)
if (base == NULL) return m_templateVersion;
return m_templateVersion; return std::max(m_templateVersion, base->getHighestTemplateVersion());
return std::max(m_templateVersion, base->getHighestTemplateVersion());
} // SharedVehicleObjectTemplate::getHighestTemplateVersion } // SharedVehicleObjectTemplate::getHighestTemplateVersion
//@BEGIN TFD //@BEGIN TFD
CompilerIntegerParam * SharedVehicleObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) CompilerIntegerParam *
{ SharedVehicleObjectTemplate::getCompilerIntegerParam(const char *name, bool deepCheck, int index) {
return SharedTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index); return SharedTangibleObjectTemplate::getCompilerIntegerParam(name, deepCheck, index);
} //SharedVehicleObjectTemplate::getCompilerIntegerParam } //SharedVehicleObjectTemplate::getCompilerIntegerParam
FloatParam * SharedVehicleObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) FloatParam *SharedVehicleObjectTemplate::getFloatParam(const char *name, bool deepCheck, int index) {
{ switch (runtimeCrc(name)) {
if (strcmp(name, "speed") == 0) case constcrc("speed"): {
{ if (index >= 0 && index < 5) {
if (index >= 0 && index < 5) if (deepCheck && !isParamLoaded(name, false, index)) {
{ if (getBaseTemplate() != nullptr)
if (deepCheck && !isParamLoaded(name, false, index)) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
{ return nullptr;
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getFloatParam(name, deepCheck, index); return &m_speed[index];
return nullptr; }
} fprintf(stderr, "index for parameter \"speed\" out of bounds\n");
return &m_speed[index]; }
} break;
fprintf(stderr, "index for parameter \"speed\" out of bounds\n"); case constcrc("slopeAversion"): {
} if (index == 0) {
else if (strcmp(name, "slopeAversion") == 0) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != nullptr)
if (index == 0) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
{ return nullptr;
if (deepCheck && !isParamLoaded(name, false, 0)) }
{ return &m_slopeAversion;
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getFloatParam(name, deepCheck, index); fprintf(stderr, "trying to access single-parameter \"slopeAversion\" as an array\n");
return nullptr; }
} break;
return &m_slopeAversion; case constcrc("hoverValue"): {
} if (index == 0) {
fprintf(stderr, "trying to access single-parameter \"slopeAversion\" as an array\n"); if (deepCheck && !isParamLoaded(name, false, 0)) {
} if (getBaseTemplate() != nullptr)
else if (strcmp(name, "hoverValue") == 0) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
{ return nullptr;
if (index == 0) }
{ return &m_hoverValue;
if (deepCheck && !isParamLoaded(name, false, 0)) }
{ fprintf(stderr, "trying to access single-parameter \"hoverValue\" as an array\n");
if (getBaseTemplate() != nullptr) }
return getBaseTemplate()->getFloatParam(name, deepCheck, index); break;
return nullptr; case constcrc("turnRate"): {
} if (index == 0) {
return &m_hoverValue; if (deepCheck && !isParamLoaded(name, false, 0)) {
} if (getBaseTemplate() != nullptr)
fprintf(stderr, "trying to access single-parameter \"hoverValue\" as an array\n"); return getBaseTemplate()->getFloatParam(name, deepCheck, index);
} return nullptr;
else if (strcmp(name, "turnRate") == 0) }
{ return &m_turnRate;
if (index == 0) }
{ fprintf(stderr, "trying to access single-parameter \"turnRate\" as an array\n");
if (deepCheck && !isParamLoaded(name, false, 0)) }
{ break;
if (getBaseTemplate() != nullptr) case constcrc("maxVelocity"): {
return getBaseTemplate()->getFloatParam(name, deepCheck, index); if (index == 0) {
return nullptr; if (deepCheck && !isParamLoaded(name, false, 0)) {
} if (getBaseTemplate() != nullptr)
return &m_turnRate; return getBaseTemplate()->getFloatParam(name, deepCheck, index);
} return nullptr;
fprintf(stderr, "trying to access single-parameter \"turnRate\" as an array\n"); }
} return &m_maxVelocity;
else if (strcmp(name, "maxVelocity") == 0) }
{ fprintf(stderr, "trying to access single-parameter \"maxVelocity\" as an array\n");
if (index == 0) }
{ break;
if (deepCheck && !isParamLoaded(name, false, 0)) case constcrc("acceleration"): {
{ if (index == 0) {
if (getBaseTemplate() != nullptr) if (deepCheck && !isParamLoaded(name, false, 0)) {
return getBaseTemplate()->getFloatParam(name, deepCheck, index); if (getBaseTemplate() != nullptr)
return nullptr; return getBaseTemplate()->getFloatParam(name, deepCheck, index);
} return nullptr;
return &m_maxVelocity; }
} return &m_acceleration;
fprintf(stderr, "trying to access single-parameter \"maxVelocity\" as an array\n"); }
} fprintf(stderr, "trying to access single-parameter \"acceleration\" as an array\n");
else if (strcmp(name, "acceleration") == 0) }
{ break;
if (index == 0) case constcrc("braking"): {
{ if (index == 0) {
if (deepCheck && !isParamLoaded(name, false, 0)) if (deepCheck && !isParamLoaded(name, false, 0)) {
{ if (getBaseTemplate() != nullptr)
if (getBaseTemplate() != nullptr) return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return getBaseTemplate()->getFloatParam(name, deepCheck, index); return nullptr;
return nullptr; }
} return &m_braking;
return &m_acceleration; }
} fprintf(stderr, "trying to access single-parameter \"braking\" as an array\n");
fprintf(stderr, "trying to access single-parameter \"acceleration\" as an array\n"); }
} break;
else if (strcmp(name, "braking") == 0) default:
{ return SharedTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
if (index == 0) break;
{ }
if (deepCheck && !isParamLoaded(name, false, 0)) return nullptr;
{ } //SharedVehicleObjectTemplate::getFloatParam
if (getBaseTemplate() != nullptr)
return getBaseTemplate()->getFloatParam(name, deepCheck, index);
return nullptr;
}
return &m_braking;
}
fprintf(stderr, "trying to access single-parameter \"braking\" as an array\n");
}
else
return SharedTangibleObjectTemplate::getFloatParam(name, deepCheck, index);
return nullptr;
} //SharedVehicleObjectTemplate::getFloatParam
BoolParam * SharedVehicleObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) BoolParam *SharedVehicleObjectTemplate::getBoolParam(const char *name, bool deepCheck, int index) {
{ return SharedTangibleObjectTemplate::getBoolParam(name, deepCheck, index);
return SharedTangibleObjectTemplate::getBoolParam(name, deepCheck, index); } //SharedVehicleObjectTemplate::getBoolParam
} //SharedVehicleObjectTemplate::getBoolParam
StringParam * SharedVehicleObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) StringParam *SharedVehicleObjectTemplate::getStringParam(const char *name, bool deepCheck, int index) {
{ return SharedTangibleObjectTemplate::getStringParam(name, deepCheck, index);
return SharedTangibleObjectTemplate::getStringParam(name, deepCheck, index); } //SharedVehicleObjectTemplate::getStringParam
} //SharedVehicleObjectTemplate::getStringParam
StringIdParam * SharedVehicleObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) StringIdParam *SharedVehicleObjectTemplate::getStringIdParam(const char *name, bool deepCheck, int index) {
{ return SharedTangibleObjectTemplate::getStringIdParam(name, deepCheck, index);
return SharedTangibleObjectTemplate::getStringIdParam(name, deepCheck, index); } //SharedVehicleObjectTemplate::getStringIdParam
} //SharedVehicleObjectTemplate::getStringIdParam
VectorParam * SharedVehicleObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) VectorParam *SharedVehicleObjectTemplate::getVectorParam(const char *name, bool deepCheck, int index) {
{ return SharedTangibleObjectTemplate::getVectorParam(name, deepCheck, index);
return SharedTangibleObjectTemplate::getVectorParam(name, deepCheck, index); } //SharedVehicleObjectTemplate::getVectorParam
} //SharedVehicleObjectTemplate::getVectorParam
DynamicVariableParam * SharedVehicleObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) DynamicVariableParam *
{ SharedVehicleObjectTemplate::getDynamicVariableParam(const char *name, bool deepCheck, int index) {
return SharedTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index); return SharedTangibleObjectTemplate::getDynamicVariableParam(name, deepCheck, index);
} //SharedVehicleObjectTemplate::getDynamicVariableParam } //SharedVehicleObjectTemplate::getDynamicVariableParam
StructParamOT * SharedVehicleObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) StructParamOT *SharedVehicleObjectTemplate::getStructParamOT(const char *name, bool deepCheck, int index) {
{ return SharedTangibleObjectTemplate::getStructParamOT(name, deepCheck, index);
return SharedTangibleObjectTemplate::getStructParamOT(name, deepCheck, index); } //SharedVehicleObjectTemplate::getStructParamOT
} //SharedVehicleObjectTemplate::getStructParamOT
TriggerVolumeParam * SharedVehicleObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) TriggerVolumeParam *SharedVehicleObjectTemplate::getTriggerVolumeParam(const char *name, bool deepCheck, int index) {
{ return SharedTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index);
return SharedTangibleObjectTemplate::getTriggerVolumeParam(name, deepCheck, index); } //SharedVehicleObjectTemplate::getTriggerVolumeParam
} //SharedVehicleObjectTemplate::getTriggerVolumeParam
void SharedVehicleObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) void SharedVehicleObjectTemplate::initStructParamOT(StructParamOT &param, const char *name) {
{ if (param.isInitialized())
if (param.isInitialized()) return;
return; SharedTangibleObjectTemplate::initStructParamOT(param, name);
SharedTangibleObjectTemplate::initStructParamOT(param, name); } // SharedVehicleObjectTemplate::initStructParamOT
} // SharedVehicleObjectTemplate::initStructParamOT
void SharedVehicleObjectTemplate::setAsEmptyList(const char *name) void SharedVehicleObjectTemplate::setAsEmptyList(const char *name) {
{ SharedTangibleObjectTemplate::setAsEmptyList(name);
SharedTangibleObjectTemplate::setAsEmptyList(name); } // SharedVehicleObjectTemplate::setAsEmptyList
} // SharedVehicleObjectTemplate::setAsEmptyList
void SharedVehicleObjectTemplate::setAppend(const char *name) void SharedVehicleObjectTemplate::setAppend(const char *name) {
{ SharedTangibleObjectTemplate::setAppend(name);
SharedTangibleObjectTemplate::setAppend(name); } // SharedVehicleObjectTemplate::setAppend
} // SharedVehicleObjectTemplate::setAppend
bool SharedVehicleObjectTemplate::isAppend(const char *name) const bool SharedVehicleObjectTemplate::isAppend(const char *name) const {
{ return SharedTangibleObjectTemplate::isAppend(name);
return SharedTangibleObjectTemplate::isAppend(name); } // SharedVehicleObjectTemplate::isAppend
} // SharedVehicleObjectTemplate::isAppend
int SharedVehicleObjectTemplate::getListLength(const char *name) const int SharedVehicleObjectTemplate::getListLength(const char *name) const {
{ if (strcmp(name, "speed") == 0) {
if (strcmp(name, "speed") == 0) return sizeof(m_speed) / sizeof(FloatParam);
{ } else
return sizeof(m_speed) / sizeof(FloatParam); return SharedTangibleObjectTemplate::getListLength(name);
} } // SharedVehicleObjectTemplate::getListLength
else
return SharedTangibleObjectTemplate::getListLength(name);
} // SharedVehicleObjectTemplate::getListLength
/** /**
* Loads the template data from an iff file. We should already be in the form * Loads the template data from an iff file. We should already be in the form
@@ -278,88 +247,91 @@ int SharedVehicleObjectTemplate::getListLength(const char *name) const
* *
* @param file file to load from * @param file file to load from
*/ */
void SharedVehicleObjectTemplate::load(Iff &file) void SharedVehicleObjectTemplate::load(Iff &file) {
{ static const int MAX_NAME_SIZE = 256;
static const int MAX_NAME_SIZE = 256; char paramName[MAX_NAME_SIZE];
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != SharedVehicleObjectTemplate_tag) if (file.getCurrentName() != SharedVehicleObjectTemplate_tag) {
{ SharedTangibleObjectTemplate::load(file);
SharedTangibleObjectTemplate::load(file); return;
return; }
}
file.enterForm(); file.enterForm();
m_templateVersion = file.getCurrentName(); m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V)) if (m_templateVersion == TAG(D, E, R, V)) {
{ file.enterForm();
file.enterForm(); file.enterChunk();
file.enterChunk(); std::string baseFilename;
std::string baseFilename; file.read_string(baseFilename);
file.read_string(baseFilename); file.exitChunk();
file.exitChunk(); const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename); DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str()));
DEBUG_WARNING(base == nullptr, ("was unable to load base template %s", baseFilename.c_str())); if (m_baseData == base && base != nullptr)
if (m_baseData == base && base != nullptr) base->releaseReference();
base->releaseReference(); else {
else if (m_baseData != nullptr)
{ m_baseData->releaseReference();
if (m_baseData != nullptr) m_baseData = base;
m_baseData->releaseReference(); }
m_baseData = base; file.exitForm();
} m_templateVersion = file.getCurrentName();
file.exitForm(); }
m_templateVersion = file.getCurrentName(); if (getHighestTemplateVersion() != TAG(0, 0, 0, 0)) {
} if (DataLint::isEnabled())
if (getHighestTemplateVersion() != TAG(0,0,0,0)) DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
{ }
if (DataLint::isEnabled())
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
}
file.enterForm(); file.enterForm();
file.enterChunk(); file.enterChunk();
int paramCount = file.read_int32(); int paramCount = file.read_int32();
file.exitChunk(); file.exitChunk();
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i) {
{ file.enterChunk();
file.enterChunk(); file.read_string(paramName, MAX_NAME_SIZE);
file.read_string(paramName, MAX_NAME_SIZE);
if (strcmp(paramName, "speed") == 0)
{
int listCount = file.read_int32();
DEBUG_WARNING(listCount != 5, ("Template %s: read array size of %d for array \"speed\" of size 5, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 5 && j < listCount; ++j)
m_speed[j].loadFromIff(file);
// if there are more params for speed read and dump them
for (; j < listCount; ++j)
{
FloatParam dummy;
dummy.loadFromIff(file);
}
}
else if (strcmp(paramName, "slopeAversion") == 0)
m_slopeAversion.loadFromIff(file);
else if (strcmp(paramName, "hoverValue") == 0)
m_hoverValue.loadFromIff(file);
else if (strcmp(paramName, "turnRate") == 0)
m_turnRate.loadFromIff(file);
else if (strcmp(paramName, "maxVelocity") == 0)
m_maxVelocity.loadFromIff(file);
else if (strcmp(paramName, "acceleration") == 0)
m_acceleration.loadFromIff(file);
else if (strcmp(paramName, "braking") == 0)
m_braking.loadFromIff(file);
file.exitChunk(true);
}
file.exitForm(); switch (runtimeCrc(paramName)) {
SharedTangibleObjectTemplate::load(file); case constcrc("speed"): {
file.exitForm(); int listCount = file.read_int32();
return; DEBUG_WARNING(listCount != 5,
} // SharedVehicleObjectTemplate::load ("Template %s: read array size of %d for array \"speed\" of size 5, reading values anyway", file.getFileName(), listCount));
int j;
for (j = 0; j < 5 && j < listCount; ++j)
m_speed[j].loadFromIff(file);
// if there are more params for speed read and dump them
for (; j < listCount; ++j) {
FloatParam dummy;
dummy.loadFromIff(file);
}
}
break;
case constcrc("slopeAversion"):
m_slopeAversion.loadFromIff(file);
break;
case constcrc("hoverValue"):
m_hoverValue.loadFromIff(file);
break;
case constcrc("turnRate"):
m_turnRate.loadFromIff(file);
break;
case constcrc("maxVelocity"):
m_maxVelocity.loadFromIff(file);
break;
case constcrc("acceleration"):
m_acceleration.loadFromIff(file);
break;
case constcrc("braking"):
m_braking.loadFromIff(file);
break;
}
file.exitChunk(true);
}
file.exitForm();
SharedTangibleObjectTemplate::load(file);
file.exitForm();
return;
} // SharedVehicleObjectTemplate::load
/** /**
* Saves the template data to an iff file. * Saves the template data to an iff file.
@@ -367,79 +339,79 @@ char paramName[MAX_NAME_SIZE];
* @param file file to save to * @param file file to save to
* @param location file type (client or server) * @param location file type (client or server)
*/ */
void SharedVehicleObjectTemplate::save(Iff &file) void SharedVehicleObjectTemplate::save(Iff &file) {
{ int count;
int count;
file.insertForm(SharedVehicleObjectTemplate_tag); file.insertForm(SharedVehicleObjectTemplate_tag);
if (m_baseTemplateName.size() != 0) if (m_baseTemplateName.size() != 0) {
{ file.insertForm(TAG(D, E, R, V));
file.insertForm(TAG(D,E,R,V)); file.insertChunk(TAG(X, X, X, X));
file.insertChunk(TAG(X, X, X, X)); file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1);
file.insertChunkData(m_baseTemplateName.c_str(), m_baseTemplateName.size() + 1); file.exitChunk();
file.exitChunk(); file.exitForm();
file.exitForm(); }
} file.insertForm(TAG(0, 0, 0, 0));
file.insertForm(TAG(0,0,0,0)); file.allowNonlinearFunctions();
file.allowNonlinearFunctions();
int paramCount = 0; int paramCount = 0;
// save speed // save speed
file.insertChunk(TAG(X, X, X, X)); file.insertChunk(TAG(X, X, X, X));
file.insertChunkString("speed"); file.insertChunkString("speed");
count = 5; count = 5;
file.insertChunkData(&count, sizeof(count)); file.insertChunkData(&count, sizeof(count));
{for (int i = 0; i < 5; ++i) {
m_speed[i].saveToIff(file);} for (int i = 0; i < 5; ++i)
file.exitChunk(); m_speed[i].saveToIff(file);
++paramCount; }
// save slopeAversion file.exitChunk();
file.insertChunk(TAG(X, X, X, X)); ++paramCount;
file.insertChunkString("slopeAversion"); // save slopeAversion
m_slopeAversion.saveToIff(file); file.insertChunk(TAG(X, X, X, X));
file.exitChunk(); file.insertChunkString("slopeAversion");
++paramCount; m_slopeAversion.saveToIff(file);
// save hoverValue file.exitChunk();
file.insertChunk(TAG(X, X, X, X)); ++paramCount;
file.insertChunkString("hoverValue"); // save hoverValue
m_hoverValue.saveToIff(file); file.insertChunk(TAG(X, X, X, X));
file.exitChunk(); file.insertChunkString("hoverValue");
++paramCount; m_hoverValue.saveToIff(file);
// save turnRate file.exitChunk();
file.insertChunk(TAG(X, X, X, X)); ++paramCount;
file.insertChunkString("turnRate"); // save turnRate
m_turnRate.saveToIff(file); file.insertChunk(TAG(X, X, X, X));
file.exitChunk(); file.insertChunkString("turnRate");
++paramCount; m_turnRate.saveToIff(file);
// save maxVelocity file.exitChunk();
file.insertChunk(TAG(X, X, X, X)); ++paramCount;
file.insertChunkString("maxVelocity"); // save maxVelocity
m_maxVelocity.saveToIff(file); file.insertChunk(TAG(X, X, X, X));
file.exitChunk(); file.insertChunkString("maxVelocity");
++paramCount; m_maxVelocity.saveToIff(file);
// save acceleration file.exitChunk();
file.insertChunk(TAG(X, X, X, X)); ++paramCount;
file.insertChunkString("acceleration"); // save acceleration
m_acceleration.saveToIff(file); file.insertChunk(TAG(X, X, X, X));
file.exitChunk(); file.insertChunkString("acceleration");
++paramCount; m_acceleration.saveToIff(file);
// save braking file.exitChunk();
file.insertChunk(TAG(X, X, X, X)); ++paramCount;
file.insertChunkString("braking"); // save braking
m_braking.saveToIff(file); file.insertChunk(TAG(X, X, X, X));
file.exitChunk(); file.insertChunkString("braking");
++paramCount; m_braking.saveToIff(file);
file.exitChunk();
++paramCount;
// write number of parameters // write number of parameters
file.goToTopOfForm(); file.goToTopOfForm();
file.insertChunk(TAG(P, C, N, T)); file.insertChunk(TAG(P, C, N, T));
file.insertChunkData(&paramCount, sizeof(paramCount)); file.insertChunkData(&paramCount, sizeof(paramCount));
file.exitChunk(); file.exitChunk();
file.exitForm(true); file.exitForm(true);
SharedTangibleObjectTemplate::save(file); SharedTangibleObjectTemplate::save(file);
file.exitForm(); file.exitForm();
} // SharedVehicleObjectTemplate::save } // SharedVehicleObjectTemplate::save
//@END TFD //@END TFD
@@ -1942,8 +1942,10 @@ std::string name;
{ {
// we need to read the next line to continue parsing // we need to read the next line to continue parsing
line = goToNextLine(); line = goToNextLine();
if (line == CHAR_ERROR) if (line == CHAR_ERROR) {
delete newData;
return line; return line;
}
} }
line = parseDynamicVariableParameterList(*newData, line); line = parseDynamicVariableParameterList(*newData, line);
} }
@@ -1202,6 +1202,7 @@ void ProceduralTerrainAppearance::_legacyCreateFlora(const Chunk* const chunk)
IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object))); IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object)));
} else { } else {
DEBUG_WARNING(true, ("FIX ME: Appearance template in ProceduralTerrainAppearance::_legacyCreateFlora is not found")); DEBUG_WARNING(true, ("FIX ME: Appearance template in ProceduralTerrainAppearance::_legacyCreateFlora is not found"));
delete object;
} }
} //lint !e429 //-- collisionProperty has not been freed or returned } //lint !e429 //-- collisionProperty has not been freed or returned
} }
@@ -1361,6 +1362,7 @@ void ProceduralTerrainAppearance::createFlora (const Chunk* const chunk)
IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object))); IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object)));
} else { } else {
DEBUG_WARNING(true, ("FIX ME: Appearance template in ProceduralTerrainAppearance::createFlora is not found")); DEBUG_WARNING(true, ("FIX ME: Appearance template in ProceduralTerrainAppearance::createFlora is not found"));
delete object;
} }
} //lint !e429 //-- collisionProperty has not been freed or returned } //lint !e429 //-- collisionProperty has not been freed or returned
@@ -206,7 +206,6 @@ bool CMonitorData::processHierarchyRequestBlock(UdpConnection *con, short & sequ
send(con, sequence, MON_MSG_REPLY_HIERARCHY_BLOCK, m_buffer, size + 1); send(con, sequence, MON_MSG_REPLY_HIERARCHY_BLOCK, m_buffer, size + 1);
memset(m_buffer, 0, 16); memset(m_buffer, 0, 16);
count++; count++;
size = 0;
} }
memset(m_buffer, 0, 16); memset(m_buffer, 0, 16);
send(con, sequence, MON_MSG_REPLY_HIERARCHY_BLOCK_END, m_buffer); send(con, sequence, MON_MSG_REPLY_HIERARCHY_BLOCK_END, m_buffer);
+3 -3
View File
@@ -21,7 +21,7 @@ namespace Base
bool CConfig::LoadFile(char * file) bool CConfig::LoadFile(char * file)
//----------------------------------- //-----------------------------------
{ {
char ch; char ch;
FILE * fp; FILE * fp;
UnloadFile(); UnloadFile();
@@ -31,7 +31,7 @@ bool CConfig::LoadFile(char * file)
if (fp == nullptr || fp == (FILE *)-1) if (fp == nullptr || fp == (FILE *)-1)
{ {
//fprintf(stderr,"Failed to open config file %s!",file); //fprintf(stderr,"Failed to open config file %s!",file);
delete fp; fclose(fp);
return false; return false;
} }
@@ -63,7 +63,7 @@ bool CConfig::LoadFile(char * file)
} }
pConfig[i] = 0; // mark end of file buffer pConfig[i] = 0; // mark end of file buffer
fclose(fp); fclose(fp);
return true; return true;
} }

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