mirror of
https://github.com/SWG-Source/src.git
synced 2026-10-17 09:03:06 -04:00
mostly template initializations to prevent undefined behavior in the
(unlikely) chance some of these properties are used
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
|
||||
#include "LoggingServerApi.h"
|
||||
|
||||
|
||||
|
||||
LoggingServerApi::LoggingServerApi(LoggingServerHandler *handler, int queueSize)
|
||||
{
|
||||
mHandler = handler;
|
||||
@@ -18,6 +16,7 @@ LoggingServerApi::LoggingServerApi(LoggingServerHandler *handler, int queueSize)
|
||||
mQueue = new QueueEntry[mQueueSize];
|
||||
mQueuePosition = 0;
|
||||
mQueueCount = 0;
|
||||
mLoginSent = 0;
|
||||
|
||||
mAuthenticated = false;
|
||||
mLoginName[0] = 0;
|
||||
@@ -117,22 +116,22 @@ void LoggingServerApi::Flush(int timeout)
|
||||
UdpMisc::Sleep(20);
|
||||
}
|
||||
|
||||
LoggingServerApi::Status LoggingServerApi::GetStatus() const
|
||||
LoggingServerApi::Status LoggingServerApi::GetStatus() const
|
||||
{
|
||||
if (mConnection != nullptr)
|
||||
{
|
||||
switch (mConnection->GetStatus())
|
||||
{
|
||||
case UdpConnection::cStatusConnected:
|
||||
if (mAuthenticated)
|
||||
return(cStatusConnected);
|
||||
else
|
||||
return(cStatusAuthenticating);
|
||||
break;
|
||||
case UdpConnection::cStatusNegotiating:
|
||||
return(cStatusNegotiating);
|
||||
default:
|
||||
break;
|
||||
case UdpConnection::cStatusConnected:
|
||||
if (mAuthenticated)
|
||||
return(cStatusConnected);
|
||||
else
|
||||
return(cStatusAuthenticating);
|
||||
break;
|
||||
case UdpConnection::cStatusNegotiating:
|
||||
return(cStatusNegotiating);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(cStatusDisconnected);
|
||||
@@ -140,57 +139,57 @@ LoggingServerApi::Status LoggingServerApi::GetStatus() const
|
||||
|
||||
void LoggingServerApi::OnRoutePacket(UdpConnection *, const uchar *data, int)
|
||||
{
|
||||
switch(data[0])
|
||||
switch (data[0])
|
||||
{
|
||||
case cS2CPacketLoginConfirm:
|
||||
case cS2CPacketLoginConfirm:
|
||||
{
|
||||
mAuthenticated = data[1] ? true : false;
|
||||
if (mAuthenticated)
|
||||
{
|
||||
mAuthenticated = data[1] ? true : false;
|
||||
if (mAuthenticated)
|
||||
{
|
||||
// flush the queue on authentication. This sends not only any data that was queued before connecting
|
||||
// but also any data that was sent in the last 3 minutes, just to ensure that it didn't get lost on the
|
||||
// server side of things
|
||||
FlushQueue();
|
||||
}
|
||||
// flush the queue on authentication. This sends not only any data that was queued before connecting
|
||||
// but also any data that was sent in the last 3 minutes, just to ensure that it didn't get lost on the
|
||||
// server side of things
|
||||
FlushQueue();
|
||||
}
|
||||
|
||||
if (mHandler != nullptr)
|
||||
mHandler->LshOnLoginConfirm(mAuthenticated);
|
||||
break;
|
||||
}
|
||||
case cS2CPacketMonitor:
|
||||
{
|
||||
char *ptr = (char *)(data + 1);
|
||||
int sessionId = UdpMisc::GetValue32(ptr);
|
||||
ptr += 4;
|
||||
int sequenceNumber = UdpMisc::GetValue32(ptr);
|
||||
ptr += 4;
|
||||
int typeCode = UdpMisc::GetValue32(ptr);
|
||||
ptr += 4;
|
||||
char *name = ptr;
|
||||
ptr += strlen(ptr) + 1;
|
||||
char *filename = ptr;
|
||||
ptr += strlen(ptr) + 1;
|
||||
char *message = ptr;
|
||||
if (mHandler != nullptr)
|
||||
mHandler->LshOnMonitor(sessionId, sequenceNumber, name, filename, typeCode, message);
|
||||
break;
|
||||
}
|
||||
case cS2CPacketFileList:
|
||||
{
|
||||
if (mHandler != nullptr)
|
||||
mHandler->LshOnFileList((char *)(data + 1));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
if (mHandler != nullptr)
|
||||
mHandler->LshOnLoginConfirm(mAuthenticated);
|
||||
break;
|
||||
}
|
||||
case cS2CPacketMonitor:
|
||||
{
|
||||
char *ptr = (char *)(data + 1);
|
||||
int sessionId = UdpMisc::GetValue32(ptr);
|
||||
ptr += 4;
|
||||
int sequenceNumber = UdpMisc::GetValue32(ptr);
|
||||
ptr += 4;
|
||||
int typeCode = UdpMisc::GetValue32(ptr);
|
||||
ptr += 4;
|
||||
char *name = ptr;
|
||||
ptr += strlen(ptr) + 1;
|
||||
char *filename = ptr;
|
||||
ptr += strlen(ptr) + 1;
|
||||
char *message = ptr;
|
||||
if (mHandler != nullptr)
|
||||
mHandler->LshOnMonitor(sessionId, sequenceNumber, name, filename, typeCode, message);
|
||||
break;
|
||||
}
|
||||
case cS2CPacketFileList:
|
||||
{
|
||||
if (mHandler != nullptr)
|
||||
mHandler->LshOnFileList((char *)(data + 1));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LoggingServerApi::OnTerminated(UdpConnection *con)
|
||||
{
|
||||
if(mHandler != nullptr)
|
||||
if (mHandler != nullptr)
|
||||
{
|
||||
mHandler->LshOnTerminated( con->GetDisconnectReason() );
|
||||
mHandler->LshOnTerminated(con->GetDisconnectReason());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +201,7 @@ void LoggingServerApi::GiveTime()
|
||||
{
|
||||
mLoginSent = true;
|
||||
|
||||
// send login packet
|
||||
// send login packet
|
||||
char buf[1024];
|
||||
char *ptr = buf;
|
||||
*ptr++ = cC2SPacketLogin;
|
||||
@@ -221,8 +220,8 @@ void LoggingServerApi::GiveTime()
|
||||
{
|
||||
int spot = mQueuePosition % mQueueSize;
|
||||
|
||||
// if entry was actually sent and it has been sitting in the queue long enough to be deleted
|
||||
if (mQueue[spot].sentTime != 0 && UdpMisc::ClockElapsed(mQueue[spot].sentTime) > cSafetyQueueTime)
|
||||
// if entry was actually sent and it has been sitting in the queue long enough to be deleted
|
||||
if (mQueue[spot].sentTime != 0 && UdpMisc::ClockElapsed(mQueue[spot].sentTime) > cSafetyQueueTime)
|
||||
{
|
||||
mQueue[spot].packet->Release();
|
||||
mQueue[spot].packet = nullptr;
|
||||
@@ -259,7 +258,7 @@ void LoggingServerApi::StopTransaction()
|
||||
|
||||
void LoggingServerApi::PacketSend(LogicalPacket *lp)
|
||||
{
|
||||
// make room in queue
|
||||
// make room in queue
|
||||
if (mQueueCount == mQueueSize)
|
||||
{
|
||||
int spot = mQueuePosition % mQueueSize;
|
||||
@@ -269,14 +268,14 @@ void LoggingServerApi::PacketSend(LogicalPacket *lp)
|
||||
mQueueCount--;
|
||||
}
|
||||
|
||||
// queue it
|
||||
// queue it
|
||||
int spot = (mQueuePosition + mQueueCount) % mQueueSize;
|
||||
lp->AddRef();
|
||||
mQueue[spot].packet = lp;
|
||||
mQueue[spot].sentTime = 0;
|
||||
mQueueCount++;
|
||||
|
||||
// if possible, send it
|
||||
// if possible, send it
|
||||
if (GetStatus() == cStatusConnected)
|
||||
{
|
||||
mQueue[spot].sentTime = UdpMisc::Clock();
|
||||
@@ -284,7 +283,6 @@ void LoggingServerApi::PacketSend(LogicalPacket *lp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoggingServerApi::Log16(const char *filename, int typeCode, const unsigned short *ucs2String)
|
||||
{
|
||||
char buffer[32768];
|
||||
@@ -376,7 +374,7 @@ void LoggingServerApi::LogPacket(char *data, int len)
|
||||
{
|
||||
if (mTransaction != nullptr)
|
||||
{
|
||||
// add it to the transaction
|
||||
// add it to the transaction
|
||||
mTransaction->AddPacket(data, len);
|
||||
}
|
||||
else
|
||||
@@ -437,12 +435,12 @@ void LoggingServerApi::RequestFileList()
|
||||
|
||||
void LoggingServerApi::GetStatistics(LoggingServerApiStatistics *stats)
|
||||
{
|
||||
memset( stats, 0, sizeof( *stats) );
|
||||
memset(stats, 0, sizeof(*stats));
|
||||
UdpConnectionStatistics udpConnectionStats;
|
||||
memset( &udpConnectionStats, 0, sizeof( udpConnectionStats ) );
|
||||
if( mConnection != nullptr )
|
||||
memset(&udpConnectionStats, 0, sizeof(udpConnectionStats));
|
||||
if (mConnection != nullptr)
|
||||
{
|
||||
mConnection->GetStats( &udpConnectionStats );
|
||||
mConnection->GetStats(&udpConnectionStats);
|
||||
stats->applicationPacketsReceived = udpConnectionStats.applicationPacketsReceived;
|
||||
stats->applicationPacketsSent = udpConnectionStats.applicationPacketsSent;
|
||||
stats->totalBytesReceived = udpConnectionStats.totalBytesReceived;
|
||||
@@ -454,25 +452,25 @@ void LoggingServerApi::GetStatistics(LoggingServerApiStatistics *stats)
|
||||
}
|
||||
|
||||
UdpManagerStatistics managerStats;
|
||||
if( mUdpManager != nullptr )
|
||||
if (mUdpManager != nullptr)
|
||||
{
|
||||
mUdpManager->GetStats( &managerStats );
|
||||
mUdpManager->GetStats(&managerStats);
|
||||
udp_int64 iterations = managerStats.iterations;
|
||||
int elapseTime = managerStats.elapsedTime;
|
||||
|
||||
if( elapseTime != 0 )
|
||||
if (elapseTime != 0)
|
||||
{
|
||||
stats->iterationsPerSecond = (double)((iterations * 1000 )/(double)elapseTime);
|
||||
stats->iterationsPerSecond = (double)((iterations * 1000) / (double)elapseTime);
|
||||
}
|
||||
mUdpManager->ResetStats();
|
||||
}
|
||||
}
|
||||
|
||||
void LoggingServerHandler::LshOnLoginConfirm(bool )
|
||||
void LoggingServerHandler::LshOnLoginConfirm(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void LoggingServerHandler::LshOnMonitor(int , int , const char * const, const char * const, int , const char * const)
|
||||
void LoggingServerHandler::LshOnMonitor(int, int, const char * const, const char * const, int, const char * const)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -482,4 +480,4 @@ void LoggingServerHandler::LshOnFileList(const char * const)
|
||||
|
||||
void LoggingServerHandler::LshOnTerminated(UdpConnection::DisconnectReason)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// LoggingServerApiObserver.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -15,7 +15,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
LoggingServerApiObserver::LoggingServerApiObserver() :
|
||||
m_loggingServerApi(new LoggingServerApi(0, ConfigLogServer::getLoggingServerApiQueueSize()))
|
||||
m_loggingServerApi(new LoggingServerApi(0, ConfigLogServer::getLoggingServerApiQueueSize()))
|
||||
{
|
||||
m_loggingServerApi->Connect(ConfigLogServer::getLoggingServerApiAddress(), LoggingServerApi::cDefaultPort, ConfigLogServer::getLoggingServerApiLoginName(), ConfigLogServer::getLoggingServerApiPassword(), ConfigLogServer::getLoggingServerApiDefaultDirectory());
|
||||
}
|
||||
@@ -47,30 +47,30 @@ LogObserver * LoggingServerApiObserver::create(const std::string &)
|
||||
void LoggingServerApiObserver::log(const LogMessage & msg)
|
||||
{
|
||||
std::string fileName = "misc.txt";
|
||||
|
||||
|
||||
std::string msgText;
|
||||
|
||||
if(! msg.getText().empty())
|
||||
if (!msg.getText().empty())
|
||||
{
|
||||
time_t now;
|
||||
tm t;
|
||||
|
||||
IGNORE_RETURN( time(&now) );
|
||||
IGNORE_RETURN( gmtime_r(&now, &t) );
|
||||
char dirBuf[128] = {"\0"};
|
||||
IGNORE_RETURN(time(&now));
|
||||
IGNORE_RETURN(gmtime_r(&now, &t));
|
||||
char dirBuf[128] = { "\0" };
|
||||
snprintf(dirBuf, sizeof(dirBuf), "%d/%d/%d/", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday);
|
||||
fileName = ConfigLogServer::getClusterName();
|
||||
fileName += "/";
|
||||
fileName += dirBuf;
|
||||
|
||||
|
||||
std::string splittext = msg.getText();
|
||||
if(splittext.find(":") != splittext.npos)
|
||||
if (splittext.find(":") != splittext.npos)
|
||||
{
|
||||
fileName += splittext.substr(0, splittext.find(":")) + ".txt";
|
||||
}
|
||||
|
||||
msgText = splittext.substr(splittext.find(":") + 1);
|
||||
|
||||
|
||||
// If there is ANY Unicode, send the whole log as Unicode. If there is ONLY non-Unicode, then send the log non-Unicode.
|
||||
|
||||
if (!msg.getUnicodeAttach().empty())
|
||||
@@ -106,7 +106,7 @@ void LoggingServerApiObserver::flush()
|
||||
|
||||
void LoggingServerApiObserver::update()
|
||||
{
|
||||
if(m_loggingServerApi->GetStatus() == LoggingServerApi::cStatusDisconnected)
|
||||
if (m_loggingServerApi->GetStatus() == LoggingServerApi::cStatusDisconnected)
|
||||
{
|
||||
m_loggingServerApi->Connect(ConfigLogServer::getLoggingServerApiAddress(), LoggingServerApi::cDefaultPort, ConfigLogServer::getLoggingServerApiLoginName(), ConfigLogServer::getLoggingServerApiPassword(), ConfigLogServer::getLoggingServerApiDefaultDirectory());
|
||||
}
|
||||
@@ -114,5 +114,4 @@ void LoggingServerApiObserver::update()
|
||||
m_loggingServerApi->GiveTime();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -14,9 +14,9 @@
|
||||
#include "sharedLog/Log.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <winsock.h>
|
||||
#include <winsock.h>
|
||||
#else // for non-windows platforms (linux)
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
namespace CSToolConnectionNamespace
|
||||
@@ -28,9 +28,9 @@ uint32 CSToolConnection::m_curToolID = 0;
|
||||
|
||||
// statics
|
||||
|
||||
CSToolConnection * CSToolConnection::getCSToolConnectionByToolId( uint32 id )
|
||||
CSToolConnection * CSToolConnection::getCSToolConnectionByToolId(uint32 id)
|
||||
{
|
||||
std::map< uint32, CSToolConnection * >::iterator it = CSToolConnectionNamespace::toolsByID.find( id );
|
||||
std::map< uint32, CSToolConnection * >::iterator it = CSToolConnectionNamespace::toolsByID.find(id);
|
||||
return it == CSToolConnectionNamespace::toolsByID.end() ? 0 : it->second;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ void CSToolConnection::validateCSTool(uint32 toolId, apiResult result, const api
|
||||
CSToolConnection * p_connection = getCSToolConnectionByToolId(toolId);
|
||||
if (!p_connection)
|
||||
return; // no connection, they must have bailed.
|
||||
|
||||
|
||||
// check the result
|
||||
if(result == RESULT_SUCCESS)
|
||||
if (result == RESULT_SUCCESS)
|
||||
{
|
||||
// if we're valid, set to logged in
|
||||
p_connection->m_bLoggedIn = true;
|
||||
@@ -50,24 +50,23 @@ void CSToolConnection::validateCSTool(uint32 toolId, apiResult result, const api
|
||||
{
|
||||
p_connection->m_bSecure = true;
|
||||
}
|
||||
|
||||
|
||||
// if we have a nullptr session type, then we aren't connected to the
|
||||
// Session Server and are in debug mode.
|
||||
//
|
||||
// if we *do* have a good session, then check the admin table for access level.
|
||||
int accessLevel = 100;
|
||||
|
||||
|
||||
bool sessionNull = (session.GetType() == SESSION_TYPE_NULL);
|
||||
bool isAdmin = AdminAccountManager::isAdminAccount(p_connection->m_sUserName, accessLevel);
|
||||
bool needSecure = ConfigLoginServer::getRequireSecureLoginForCsTool();
|
||||
bool isInternal = AdminAccountManager::isInternalIp(p_connection->getRemoteAddress());
|
||||
DEBUG_REPORT_LOG( true, ("CS Tool login for %s, admin=%s, access=%d, internal=%s\n",
|
||||
p_connection->m_sUserName.c_str(),
|
||||
isAdmin ? "true" : "false",
|
||||
accessLevel,
|
||||
isInternal ? "true" : "false"));
|
||||
DEBUG_REPORT_LOG(true, ("CS Tool login for %s, admin=%s, access=%d, internal=%s\n",
|
||||
p_connection->m_sUserName.c_str(),
|
||||
isAdmin ? "true" : "false",
|
||||
accessLevel,
|
||||
isInternal ? "true" : "false"));
|
||||
|
||||
|
||||
bool canLogin = isInternal; // we always have to be internal.
|
||||
if (sessionNull)
|
||||
{
|
||||
@@ -78,10 +77,10 @@ void CSToolConnection::validateCSTool(uint32 toolId, apiResult result, const api
|
||||
else
|
||||
{
|
||||
// if we don't have a session, we need to be on the admin table
|
||||
if(isAdmin)
|
||||
if (isAdmin)
|
||||
{
|
||||
// allow login if we either don't need to be secure, or if we are.
|
||||
if((!needSecure) || p_connection->m_bSecure)
|
||||
if ((!needSecure) || p_connection->m_bSecure)
|
||||
{
|
||||
canLogin = canLogin && true;
|
||||
}
|
||||
@@ -94,58 +93,57 @@ void CSToolConnection::validateCSTool(uint32 toolId, apiResult result, const api
|
||||
{
|
||||
canLogin = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(canLogin)
|
||||
}
|
||||
|
||||
if (canLogin)
|
||||
{
|
||||
// and inform
|
||||
std::string response = "Logged in successfully.";
|
||||
|
||||
response += "\r\n";
|
||||
p_connection->sendToTool(response);
|
||||
|
||||
|
||||
p_connection->m_ui32PrivilegeLevel = (uint32)accessLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_connection->sendToTool("Invalid name/password.\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
// otherwise, give the appropriate response
|
||||
else if( result == RESULT_INVALID_NAME_OR_PASSWORD )
|
||||
// otherwise, give the appropriate response
|
||||
else if (result == RESULT_INVALID_NAME_OR_PASSWORD)
|
||||
{
|
||||
p_connection->sendToTool("Invalid name/password.\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Could not log in CS Tool for user %s, reason %d\n", p_connection->m_sUserName.c_str(), result));
|
||||
DEBUG_REPORT_LOG(true, ("Could not log in CS Tool for user %s, reason %d\n", p_connection->m_sUserName.c_str(), result));
|
||||
p_connection->sendToTool("Invalid name/password.\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// members
|
||||
|
||||
CSToolConnection::CSToolConnection( UdpConnectionMT * pUdpConn, TcpClient * pTcpConn ) :
|
||||
Connection( pUdpConn, pTcpConn ),
|
||||
m_ui32StationID( 0 ),
|
||||
m_bSecure( false ),
|
||||
m_bLoggedIn( false ),
|
||||
m_ui32PrivilegeLevel( 0 )
|
||||
CSToolConnection::CSToolConnection(UdpConnectionMT * pUdpConn, TcpClient * pTcpConn) :
|
||||
Connection(pUdpConn, pTcpConn),
|
||||
m_ui32StationID(0),
|
||||
m_bSecure(false),
|
||||
m_bLoggedIn(false),
|
||||
m_ui32PrivilegeLevel(0),
|
||||
m_toolID(0)
|
||||
{
|
||||
if( pTcpConn ) // it'd better be!
|
||||
setRawTCP( true );
|
||||
if (pTcpConn) // it'd better be!
|
||||
setRawTCP(true);
|
||||
}
|
||||
|
||||
CSToolConnection::~CSToolConnection()
|
||||
{
|
||||
}
|
||||
|
||||
void CSToolConnection::onReceive( const Archive::ByteStream & message )
|
||||
void CSToolConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
// for testing purposes, just echo back to the user.
|
||||
|
||||
|
||||
// add to buffer
|
||||
std::string input;
|
||||
const unsigned char * uc = message.getBuffer();
|
||||
@@ -156,242 +154,234 @@ void CSToolConnection::onReceive( const Archive::ByteStream & message )
|
||||
++uc;
|
||||
}
|
||||
m_sInputBuffer += input;
|
||||
|
||||
|
||||
|
||||
// while we've got an EOL signifier
|
||||
std::string::size_type pos;
|
||||
while( ( pos = m_sInputBuffer.find( '\r' ) ) != std::string::npos )
|
||||
while ((pos = m_sInputBuffer.find('\r')) != std::string::npos)
|
||||
{
|
||||
// rebuild message buffer properly.
|
||||
std::string command = m_sInputBuffer.substr( 0, pos );
|
||||
std::string command = m_sInputBuffer.substr(0, pos);
|
||||
// should dispatch here, for now we're echoing back for debug.
|
||||
|
||||
|
||||
//command = command + "\r\n";
|
||||
//sendToTool( command );
|
||||
this->parse( command );
|
||||
this->parse(command);
|
||||
// then we have additional data. Otherwise, we don't.
|
||||
if( m_sInputBuffer.size() >= pos + 2 )
|
||||
if (m_sInputBuffer.size() >= pos + 2)
|
||||
{
|
||||
m_sInputBuffer = m_sInputBuffer.substr( pos + 2, m_sInputBuffer.length() - ( pos + 2 ) );
|
||||
m_sInputBuffer = m_sInputBuffer.substr(pos + 2, m_sInputBuffer.length() - (pos + 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sInputBuffer.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CSToolConnection::parse( const std::string command )
|
||||
void CSToolConnection::parse(const std::string command)
|
||||
{
|
||||
// grab the first word of the command.
|
||||
std::string first;
|
||||
std::string args;
|
||||
std::string::size_type pos;
|
||||
if( ( pos = command.find( ' ' ) ) == std::string::npos )
|
||||
if ((pos = command.find(' ')) == std::string::npos)
|
||||
{
|
||||
first = command;
|
||||
}
|
||||
else
|
||||
{
|
||||
first = command.substr( 0, pos );
|
||||
args = command.substr( pos + 1, command.size() - ( pos + 1 ) );
|
||||
first = command.substr(0, pos);
|
||||
args = command.substr(pos + 1, command.size() - (pos + 1));
|
||||
}
|
||||
// test for empty commands.
|
||||
if( first.length() == 0 || first[ 0 ] == ' ' )
|
||||
if (first.length() == 0 || first[0] == ' ')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::string response = "ls:";
|
||||
|
||||
|
||||
if( first == "clusters" )
|
||||
|
||||
if (first == "clusters")
|
||||
{
|
||||
response += "Active clusters:\r\n";
|
||||
std::map< std::string, uint32 > data;
|
||||
LoginServer::getInstance().getAllClusterNamesAndIDs( data );
|
||||
for( std::map< std::string, uint32 >::iterator it = data.begin();
|
||||
it != data.end();
|
||||
++it )
|
||||
std::map< std::string, uint32 > data;
|
||||
LoginServer::getInstance().getAllClusterNamesAndIDs(data);
|
||||
for (std::map< std::string, uint32 >::iterator it = data.begin();
|
||||
it != data.end();
|
||||
++it)
|
||||
{
|
||||
response += it->first + "\r\n";
|
||||
}
|
||||
sendToTool( response );
|
||||
sendToTool(response);
|
||||
}
|
||||
else if ( first == "select" )
|
||||
else if (first == "select")
|
||||
{
|
||||
// see if we're adding, removing, or exclusive-adding.
|
||||
if( args[ 0 ] == '+' )
|
||||
if (args[0] == '+')
|
||||
{
|
||||
if( args.size() > 1 )
|
||||
if (args.size() > 1)
|
||||
{
|
||||
if( args[ 1 ] == '+' )
|
||||
if (args[1] == '+')
|
||||
{
|
||||
m_selectedClusters.clear();
|
||||
sendToTool( "ls:deselected all servers\r\n" );
|
||||
sendToTool("ls:deselected all servers\r\n");
|
||||
}
|
||||
pos = args.find_first_not_of( "+" );
|
||||
if( pos == std::string::npos )
|
||||
pos = args.find_first_not_of("+");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string cluster = args.substr( pos, args.size() - pos );
|
||||
response += selectCluster( cluster );
|
||||
sendToTool( response );
|
||||
std::string cluster = args.substr(pos, args.size() - pos);
|
||||
response += selectCluster(cluster);
|
||||
sendToTool(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( args[ 0 ] == '-' )
|
||||
else if (args[0] == '-')
|
||||
{
|
||||
if( args.size() > 1 )
|
||||
if (args.size() > 1)
|
||||
{
|
||||
std::string cluster = args.substr( 1, args.size() - 1 );
|
||||
if( m_selectedClusters.find( cluster ) != m_selectedClusters.end() )
|
||||
std::string cluster = args.substr(1, args.size() - 1);
|
||||
if (m_selectedClusters.find(cluster) != m_selectedClusters.end())
|
||||
{
|
||||
response += deselectCluster( cluster );
|
||||
sendToTool( response );
|
||||
response += deselectCluster(cluster);
|
||||
sendToTool(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendToTool( "Error! Bad select format!\r\n" );
|
||||
sendToTool("Error! Bad select format!\r\n");
|
||||
}
|
||||
}
|
||||
else if ( first == "showselected" )
|
||||
else if (first == "showselected")
|
||||
{
|
||||
response += "Currently selected clusters:\r\n";
|
||||
for( std::set< std::string >::iterator it = m_selectedClusters.begin();
|
||||
it != m_selectedClusters.end();
|
||||
++it )
|
||||
for (std::set< std::string >::iterator it = m_selectedClusters.begin();
|
||||
it != m_selectedClusters.end();
|
||||
++it)
|
||||
{
|
||||
response += *it + "\r\n";
|
||||
}
|
||||
sendToTool( response );
|
||||
|
||||
sendToTool(response);
|
||||
}
|
||||
else if( first == "login" )
|
||||
else if (first == "login")
|
||||
{
|
||||
// assume name/pw do not have spaces.
|
||||
std::string name;
|
||||
std::string pw;
|
||||
|
||||
|
||||
// split apart
|
||||
unsigned pos = args.find( " " );
|
||||
if( pos != std::string::npos )
|
||||
unsigned pos = args.find(" ");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
name = args.substr( 0, pos );
|
||||
pw = args.substr( pos + 1, args.length() - pos - 1 );
|
||||
name = args.substr(0, pos);
|
||||
pw = args.substr(pos + 1, args.length() - pos - 1);
|
||||
m_sUserName = name;
|
||||
if( !LoginServer::getInstance().getSessionApiClient() )
|
||||
if (!LoginServer::getInstance().getSessionApiClient())
|
||||
{
|
||||
apiSession session;
|
||||
validateCSTool( m_toolID, RESULT_SUCCESS, session );
|
||||
validateCSTool(m_toolID, RESULT_SUCCESS, session);
|
||||
return;
|
||||
}
|
||||
LoginServer::getInstance().getSessionApiClient()->
|
||||
SessionLogin(name.c_str(),
|
||||
pw.c_str(),
|
||||
SessionLogin(name.c_str(),
|
||||
pw.c_str(),
|
||||
SESSION_TYPE_STARWARS,
|
||||
inet_addr( getRemoteAddress().c_str() ),
|
||||
inet_addr(getRemoteAddress().c_str()),
|
||||
0,
|
||||
_defaultNamespace,
|
||||
( void * )m_toolID );
|
||||
_defaultNamespace,
|
||||
(void *)m_toolID);
|
||||
}
|
||||
|
||||
|
||||
// pass to session.
|
||||
}
|
||||
// default command handler.
|
||||
else
|
||||
{
|
||||
if( m_bLoggedIn )
|
||||
if (m_bLoggedIn)
|
||||
{
|
||||
sendToClusters( first, command );
|
||||
sendToClusters(first, command);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendToTool( "Not logged in.\r\n" );
|
||||
sendToTool("Not logged in.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSToolConnection::sendToClusters( const std::string & sCommand, const std::string & sCommandLine )
|
||||
void CSToolConnection::sendToClusters(const std::string & sCommand, const std::string & sCommandLine)
|
||||
{
|
||||
// build the message
|
||||
CSToolRequest msg( m_ui32StationID, m_ui32PrivilegeLevel, sCommandLine, sCommand, m_toolID, m_sUserName );
|
||||
|
||||
CSToolRequest msg(m_ui32StationID, m_ui32PrivilegeLevel, sCommandLine, sCommand, m_toolID, m_sUserName);
|
||||
|
||||
// send to all currently selected clusters.
|
||||
for( std::set< std::string >::iterator it = m_selectedClusters.begin();
|
||||
it != m_selectedClusters.end();
|
||||
++it )
|
||||
for (std::set< std::string >::iterator it = m_selectedClusters.begin();
|
||||
it != m_selectedClusters.end();
|
||||
++it)
|
||||
{
|
||||
LoginServer::getInstance().sendToCluster( LoginServer::getInstance().getClusterIDByName( *it ), msg );
|
||||
LoginServer::getInstance().sendToCluster(LoginServer::getInstance().getClusterIDByName(*it), msg);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CSToolConnection::selectCluster( const std::string & cluster )
|
||||
std::string CSToolConnection::selectCluster(const std::string & cluster)
|
||||
{
|
||||
std::string response;
|
||||
// see if we have a valid cluster.
|
||||
uint32 cluster_id = LoginServer::getInstance().getClusterIDByName( cluster );
|
||||
if( cluster_id == 0 )
|
||||
uint32 cluster_id = LoginServer::getInstance().getClusterIDByName(cluster);
|
||||
if (cluster_id == 0)
|
||||
{
|
||||
response += "Cluster " + cluster + " does not exist.\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedClusters.insert( cluster );
|
||||
m_selectedClusters.insert(cluster);
|
||||
response += "Cluster " + cluster + " added to active list\r\n";
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
std::string CSToolConnection::deselectCluster( const std::string & cluster )
|
||||
std::string CSToolConnection::deselectCluster(const std::string & cluster)
|
||||
{
|
||||
std::string response;
|
||||
|
||||
|
||||
// see if we are currently talking to that cluster.
|
||||
std::set< std::string >::iterator it = m_selectedClusters.find( cluster );
|
||||
if( it == m_selectedClusters.end() )
|
||||
std::set< std::string >::iterator it = m_selectedClusters.find(cluster);
|
||||
if (it == m_selectedClusters.end())
|
||||
{
|
||||
response += "Cluster " + cluster + " is not currently selected.\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedClusters.erase( it );
|
||||
m_selectedClusters.erase(it);
|
||||
response += "Cluster " + cluster + " removed from active list.\r\n";
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
void CSToolConnection::sendToTool( const std::string & message )
|
||||
void CSToolConnection::sendToTool(const std::string & message)
|
||||
{
|
||||
// convert to ByteStream
|
||||
std::string temp = message;
|
||||
temp += "\r\n*\r\n";
|
||||
Archive::ByteStream bs;
|
||||
bs.put( temp.c_str(), temp.size() );
|
||||
bs.put(temp.c_str(), temp.size());
|
||||
// send.
|
||||
this->send( bs, true );
|
||||
}
|
||||
this->send(bs, true);
|
||||
}
|
||||
|
||||
void CSToolConnection::onConnectionOpened()
|
||||
{
|
||||
LOG( "CSTool", ("Connection opened") );
|
||||
LOG("CSTool", ("Connection opened"));
|
||||
// assign an ID, and stick it in our map.
|
||||
m_curToolID++;
|
||||
m_toolID = m_curToolID;
|
||||
CSToolConnectionNamespace::toolsByID[ m_toolID ] = this;
|
||||
|
||||
CSToolConnectionNamespace::toolsByID[m_toolID] = this;
|
||||
}
|
||||
|
||||
void CSToolConnection::onConnectionClosed()
|
||||
{
|
||||
LOG( "CSTool", ("Connection closed") );
|
||||
CSToolConnectionNamespace::toolsByID.erase( m_toolID );
|
||||
|
||||
}
|
||||
LOG("CSTool", ("Connection closed"));
|
||||
CSToolConnectionNamespace::toolsByID.erase(m_toolID);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,12 +18,13 @@
|
||||
// ======================================================================
|
||||
|
||||
TaskEnableCharacter::TaskEnableCharacter(StationId &stationId, const NetworkId &characterId, const std::string &whoRequested, bool enabled, uint32 clusterId) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_characterId(characterId),
|
||||
m_whoRequested(whoRequested),
|
||||
m_enabled(enabled),
|
||||
m_clusterId(clusterId)
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_characterId(characterId),
|
||||
m_whoRequested(whoRequested),
|
||||
m_enabled(enabled),
|
||||
m_clusterId(clusterId),
|
||||
m_result(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,16 +33,15 @@ TaskEnableCharacter::TaskEnableCharacter(StationId &stationId, const NetworkId &
|
||||
bool TaskEnableCharacter::process(DB::Session *session)
|
||||
{
|
||||
EnableCharacterQuery qry;
|
||||
qry.station_id=static_cast<long>(m_stationId);
|
||||
qry.character_id=m_characterId;
|
||||
qry.station_id = static_cast<long>(m_stationId);
|
||||
qry.character_id = m_characterId;
|
||||
qry.enabled.setValue(m_enabled);
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
|
||||
|
||||
qry.done();
|
||||
m_result = qry.result.getValue();
|
||||
return rval;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -51,34 +51,34 @@ void TaskEnableCharacter::onComplete()
|
||||
std::string message;
|
||||
switch (m_result)
|
||||
{
|
||||
case 1:
|
||||
if (m_enabled)
|
||||
message = "Character enabled.";
|
||||
else
|
||||
message = "Character disabled.";
|
||||
break;
|
||||
case 1:
|
||||
if (m_enabled)
|
||||
message = "Character enabled.";
|
||||
else
|
||||
message = "Character disabled.";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
message = "Could not find Character";
|
||||
break;
|
||||
case 2:
|
||||
message = "Could not find Character";
|
||||
break;
|
||||
|
||||
default:
|
||||
message = "The database returned an unknown error code";
|
||||
break;
|
||||
default:
|
||||
message = "The database returned an unknown error code";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
GenericValueTypeMessage<std::pair<std::string, std::string> > reply("EnableCharacterReplyMessage",
|
||||
std::make_pair(m_whoRequested, message));
|
||||
std::make_pair(m_whoRequested, message));
|
||||
LoginServer::getInstance().sendToCluster(m_clusterId, reply);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskEnableCharacter::EnableCharacterQuery::EnableCharacterQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
character_id(),
|
||||
enabled()
|
||||
Query(),
|
||||
station_id(),
|
||||
character_id(),
|
||||
enabled()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -87,7 +87,6 @@ TaskEnableCharacter::EnableCharacterQuery::EnableCharacterQuery() :
|
||||
void TaskEnableCharacter::EnableCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.enable_disable_character(:station_id, :character_id, :enabled); end;";
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -116,4 +115,4 @@ DB::Query::QueryMode TaskEnableCharacter::EnableCharacterQuery::getExecutionMode
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
@@ -30,7 +30,7 @@ namespace TaskGetAccountForPurgeNamespace
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
StationId getAccount() const;
|
||||
|
||||
|
||||
private:
|
||||
DB::BindableLong m_account;
|
||||
DB::BindableLong m_min_age;
|
||||
@@ -46,8 +46,9 @@ using namespace TaskGetAccountForPurgeNamespace;
|
||||
// ======================================================================
|
||||
|
||||
TaskGetAccountForPurge::TaskGetAccountForPurge(int purgePhase) :
|
||||
DB::TaskRequest(),
|
||||
m_purgePhase(purgePhase)
|
||||
DB::TaskRequest(),
|
||||
m_purgePhase(purgePhase),
|
||||
m_account(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,12 +72,11 @@ void TaskGetAccountForPurge::onComplete()
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
GetAccountForPurgeQuery::GetAccountForPurgeQuery(int purgePhase, int minAge) :
|
||||
Query(),
|
||||
m_account(),
|
||||
m_min_age(minAge),
|
||||
m_purge_phase(purgePhase)
|
||||
Query(),
|
||||
m_account(),
|
||||
m_min_age(minAge),
|
||||
m_purge_phase(purgePhase)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ GetAccountForPurgeQuery::GetAccountForPurgeQuery(int purgePhase, int minAge) :
|
||||
|
||||
void GetAccountForPurgeQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql=std::string("begin :account := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"purge_process.get_account_for_purge(:purge_phase, :min_age); end;";
|
||||
sql = std::string("begin :account := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "purge_process.get_account_for_purge(:purge_phase, :min_age); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -121,4 +121,4 @@ StationId GetAccountForPurgeQuery::getAccount() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
@@ -46,8 +46,8 @@ namespace TaskGetValidationDataNamespace
|
||||
public:
|
||||
GetCompletedTutorialQuery(StationId stationId);
|
||||
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableBool completed_tutorial;
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableBool completed_tutorial;
|
||||
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
@@ -72,13 +72,13 @@ namespace TaskGetValidationDataNamespace
|
||||
std::string getEventId() const;
|
||||
uint32 getClusterId() const;
|
||||
NetworkId const getCharacterId() const;
|
||||
|
||||
|
||||
private:
|
||||
DB::BindableLong station_id;
|
||||
DB::BindableString<100> event_id;
|
||||
DB::BindableLong cluster_id;
|
||||
DB::BindableNetworkId character_id;
|
||||
|
||||
|
||||
private: //disable
|
||||
GetConsumedRewardEventsQuery();
|
||||
GetConsumedRewardEventsQuery(const GetConsumedRewardEventsQuery&);
|
||||
@@ -119,13 +119,13 @@ namespace TaskGetValidationDataNamespace
|
||||
DB::BindableLong cluster_id; //lint !e1925 // public data member
|
||||
DB::BindableLong result; //lint !e1925 // public data member
|
||||
|
||||
virtual void getSQL (std::string &sql);
|
||||
virtual bool bindParameters ();
|
||||
virtual bool bindColumns ();
|
||||
virtual QueryMode getExecutionMode () const;
|
||||
virtual void getSQL(std::string &sql);
|
||||
virtual bool bindParameters();
|
||||
virtual bool bindColumns();
|
||||
virtual QueryMode getExecutionMode() const;
|
||||
|
||||
private: //disable
|
||||
IsClusterAtLimitQuery (const IsClusterAtLimitQuery&);
|
||||
IsClusterAtLimitQuery(const IsClusterAtLimitQuery&);
|
||||
IsClusterAtLimitQuery &operator= (const IsClusterAtLimitQuery&);
|
||||
};
|
||||
}
|
||||
@@ -134,36 +134,37 @@ using namespace TaskGetValidationDataNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskGetValidationData::TaskGetValidationData (StationId stationId, int clusterGroupId, uint32 clusterId, unsigned int track, uint32 subscriptionBits) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_openCharacterSlots(4,0),
|
||||
m_canSkipTutorial(false),
|
||||
m_track(track),
|
||||
m_subscriptionBits(subscriptionBits),
|
||||
m_transferRequest(0),
|
||||
m_transferRequestSourceCharacterTemplateId(0),
|
||||
m_consumedRewardEvents(),
|
||||
m_claimedRewardItems()
|
||||
TaskGetValidationData::TaskGetValidationData(StationId stationId, int clusterGroupId, uint32 clusterId, unsigned int track, uint32 subscriptionBits) :
|
||||
TaskRequest(),
|
||||
m_stationId(stationId),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_openCharacterSlots(4, 0),
|
||||
m_canSkipTutorial(false),
|
||||
m_track(track),
|
||||
m_subscriptionBits(subscriptionBits),
|
||||
m_transferRequest(0),
|
||||
m_transferRequestSourceCharacterTemplateId(0),
|
||||
m_consumedRewardEvents(),
|
||||
m_claimedRewardItems()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TaskGetValidationData::TaskGetValidationData(const TransferRequestMoveValidation & request, int clusterGroupId, uint32 clusterId) :
|
||||
TaskRequest(),
|
||||
m_stationId(request.getDestinationStationId()),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_openCharacterSlots(4,0),
|
||||
m_canSkipTutorial(true),
|
||||
m_track(request.getTrack()),
|
||||
m_transferRequest(0),
|
||||
m_transferRequestSourceCharacterTemplateId(request.getSourceCharacterTemplateId()),
|
||||
m_consumedRewardEvents(),
|
||||
m_claimedRewardItems()
|
||||
TaskRequest(),
|
||||
m_stationId(request.getDestinationStationId()),
|
||||
m_clusterGroupId(clusterGroupId),
|
||||
m_clusterId(clusterId),
|
||||
m_openCharacterSlots(4, 0),
|
||||
m_canSkipTutorial(true),
|
||||
m_track(request.getTrack()),
|
||||
m_transferRequest(0),
|
||||
m_transferRequestSourceCharacterTemplateId(request.getSourceCharacterTemplateId()),
|
||||
m_consumedRewardEvents(),
|
||||
m_claimedRewardItems(),
|
||||
m_subscriptionBits(0)
|
||||
{
|
||||
Archive::ByteStream bs;
|
||||
request.pack(bs);
|
||||
@@ -205,10 +206,10 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
|
||||
int rowsFetched;
|
||||
if (! (session->exec(&qry)))
|
||||
if (!(session->exec(&qry)))
|
||||
return false;
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
m_openCharacterSlots[static_cast<unsigned long>(qry.character_type_id.getValue())]=qry.num_open_slots.getValue();
|
||||
m_openCharacterSlots[static_cast<unsigned long>(qry.character_type_id.getValue())] = qry.num_open_slots.getValue();
|
||||
qry.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
@@ -219,12 +220,12 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
GetValidationDataQuery qry;
|
||||
qry.station_id = static_cast<long>(m_stationId);
|
||||
qry.cluster_id = static_cast<long>(m_clusterId);
|
||||
|
||||
|
||||
int rowsFetched;
|
||||
if (! (session->exec(&qry)))
|
||||
if (!(session->exec(&qry)))
|
||||
return false;
|
||||
while ((rowsFetched = qry.fetch()) > 0)
|
||||
m_openCharacterSlots[static_cast<unsigned long>(qry.character_type_id.getValue())]=qry.num_open_slots.getValue();
|
||||
m_openCharacterSlots[static_cast<unsigned long>(qry.character_type_id.getValue())] = qry.num_open_slots.getValue();
|
||||
qry.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
@@ -254,7 +255,7 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
qryGetCharacters.character_name.getValue(characterName);
|
||||
if (characterName == m_transferRequest->getSourceCharacter())
|
||||
{
|
||||
qryGetCharacters.object_template_id.getValue(m_transferRequestSourceCharacterTemplateId);
|
||||
qryGetCharacters.object_template_id.getValue(m_transferRequestSourceCharacterTemplateId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -267,13 +268,13 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
{
|
||||
GetConsumedRewardEventsQuery eventQuery(m_stationId);
|
||||
int rowsFetched;
|
||||
if (! (session->exec(&eventQuery)))
|
||||
if (!(session->exec(&eventQuery)))
|
||||
return false;
|
||||
while ((rowsFetched = eventQuery.fetch()) > 0)
|
||||
{
|
||||
// If the event was claimed on this cluster, tell the cluster the network ID of the character that claimed it.
|
||||
// If claimed on another cluster, hide the network ID because it's not meaningful
|
||||
NetworkId const characterId = eventQuery.getClusterId()==m_clusterId ? eventQuery.getCharacterId() : NetworkId::cms_invalid;
|
||||
// If claimed on another cluster, hide the network ID because it's not meaningful
|
||||
NetworkId const characterId = eventQuery.getClusterId() == m_clusterId ? eventQuery.getCharacterId() : NetworkId::cms_invalid;
|
||||
m_consumedRewardEvents.push_back(std::make_pair(characterId, eventQuery.getEventId()));
|
||||
}
|
||||
eventQuery.done();
|
||||
@@ -281,11 +282,11 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
return false;
|
||||
|
||||
GetClaimedRewardItemsQuery itemQuery(m_stationId);
|
||||
if (! (session->exec(&itemQuery)))
|
||||
if (!(session->exec(&itemQuery)))
|
||||
return false;
|
||||
while ((rowsFetched = itemQuery.fetch()) > 0)
|
||||
{
|
||||
NetworkId const characterId = itemQuery.getClusterId()==m_clusterId ? itemQuery.getCharacterId() : NetworkId::cms_invalid;
|
||||
NetworkId const characterId = itemQuery.getClusterId() == m_clusterId ? itemQuery.getCharacterId() : NetworkId::cms_invalid;
|
||||
m_claimedRewardItems.push_back(std::make_pair(characterId, itemQuery.getItemId()));
|
||||
}
|
||||
itemQuery.done();
|
||||
@@ -294,12 +295,12 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
|
||||
// check to see if the account can skip the tutorial or not
|
||||
GetCompletedTutorialQuery tutorialQuery(m_stationId);
|
||||
if (! (session->exec(&tutorialQuery)))
|
||||
if (!(session->exec(&tutorialQuery)))
|
||||
return false;
|
||||
while ((rowsFetched = tutorialQuery.fetch()) > 0)
|
||||
{
|
||||
tutorialQuery.completed_tutorial.getValue(m_canSkipTutorial);
|
||||
}
|
||||
}
|
||||
tutorialQuery.done();
|
||||
if (rowsFetched < 0)
|
||||
return false;
|
||||
@@ -311,21 +312,21 @@ bool TaskGetValidationData::process(DB::Session *session)
|
||||
|
||||
void TaskGetValidationData::onComplete()
|
||||
{
|
||||
bool canCreateNormal=false;
|
||||
bool canCreateJedi=false;
|
||||
bool canCreateNormal = false;
|
||||
bool canCreateJedi = false;
|
||||
if (m_openCharacterSlots[1] > 0)
|
||||
canCreateNormal=true;
|
||||
canCreateNormal = true;
|
||||
if (m_openCharacterSlots[2] > 0 && m_openCharacterSlots[3] > 0)
|
||||
canCreateJedi=true;
|
||||
canCreateJedi = true;
|
||||
|
||||
// check to see if character creation has been disabled for the cluster
|
||||
if (ConfigLoginServer::isCharacterCreationDisabled(LoginServer::getInstance().getClusterNameById(m_clusterId)))
|
||||
{
|
||||
canCreateNormal=false;
|
||||
canCreateJedi=false;
|
||||
canCreateNormal = false;
|
||||
canCreateJedi = false;
|
||||
}
|
||||
|
||||
if(m_transferRequest)
|
||||
if (m_transferRequest)
|
||||
{
|
||||
LoginServer::getInstance().validateAccountForTransfer(*m_transferRequest, m_clusterId, m_transferRequestSourceCharacterTemplateId, canCreateNormal, false);
|
||||
}
|
||||
@@ -339,7 +340,7 @@ void TaskGetValidationData::onComplete()
|
||||
|
||||
void GetValidationDataQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :rc := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_open_character_slots(:station_id,:cluster_id); end;";
|
||||
sql = std::string("begin :rc := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.get_open_character_slots(:station_id,:cluster_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -347,9 +348,9 @@ void GetValidationDataQuery::getSQL(std::string &sql)
|
||||
bool GetValidationDataQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
if (!bindParameter(cluster_id)) return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -372,11 +373,11 @@ DB::Query::QueryMode GetValidationDataQuery::getExecutionMode() const
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GetValidationDataQuery::GetValidationDataQuery() :
|
||||
Query(),
|
||||
station_id(),
|
||||
cluster_id(),
|
||||
character_type_id(),
|
||||
num_open_slots()
|
||||
Query(),
|
||||
station_id(),
|
||||
cluster_id(),
|
||||
character_type_id(),
|
||||
num_open_slots()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -384,7 +385,7 @@ GetValidationDataQuery::GetValidationDataQuery() :
|
||||
|
||||
void GetCompletedTutorialQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :rc := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_completed_tutorial(:station_id); end;";
|
||||
sql = std::string("begin :rc := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.get_completed_tutorial(:station_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -393,7 +394,7 @@ bool GetCompletedTutorialQuery::bindParameters()
|
||||
{
|
||||
if (!bindParameter(station_id)) return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -415,20 +416,20 @@ DB::Query::QueryMode GetCompletedTutorialQuery::getExecutionMode() const
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GetCompletedTutorialQuery::GetCompletedTutorialQuery(StationId stationId) :
|
||||
DB::Query(),
|
||||
station_id(stationId),
|
||||
completed_tutorial(false)
|
||||
DB::Query(),
|
||||
station_id(stationId),
|
||||
completed_tutorial(false)
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GetConsumedRewardEventsQuery::GetConsumedRewardEventsQuery(StationId stationId) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
event_id(),
|
||||
cluster_id(),
|
||||
character_id()
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
event_id(),
|
||||
cluster_id(),
|
||||
character_id()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -436,7 +437,7 @@ GetConsumedRewardEventsQuery::GetConsumedRewardEventsQuery(StationId stationId)
|
||||
|
||||
void GetConsumedRewardEventsQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_consumed_reward_events(:station_id); end;";
|
||||
sql = std::string("begin :result := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.get_consumed_reward_events(:station_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -488,11 +489,11 @@ NetworkId const GetConsumedRewardEventsQuery::getCharacterId() const
|
||||
// ======================================================================
|
||||
|
||||
GetClaimedRewardItemsQuery::GetClaimedRewardItemsQuery(StationId stationId) :
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
item_id(),
|
||||
cluster_id(),
|
||||
character_id()
|
||||
DB::Query(),
|
||||
station_id(static_cast<long>(stationId)),
|
||||
item_id(),
|
||||
cluster_id(),
|
||||
character_id()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -500,7 +501,7 @@ GetClaimedRewardItemsQuery::GetClaimedRewardItemsQuery(StationId stationId) :
|
||||
|
||||
void GetClaimedRewardItemsQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.get_claimed_reward_items(:station_id); end;";
|
||||
sql = std::string("begin :result := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.get_claimed_reward_items(:station_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -552,9 +553,9 @@ NetworkId const GetClaimedRewardItemsQuery::getCharacterId() const
|
||||
// ======================================================================
|
||||
|
||||
IsClusterAtLimitQuery::IsClusterAtLimitQuery() :
|
||||
Query(),
|
||||
cluster_id(),
|
||||
result()
|
||||
Query(),
|
||||
cluster_id(),
|
||||
result()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -562,7 +563,7 @@ result()
|
||||
|
||||
void IsClusterAtLimitQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql = std::string("begin :result := ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.is_cluster_at_limit(:cluster_id); end;";
|
||||
sql = std::string("begin :result := ") + DatabaseConnection::getInstance().getSchemaQualifier() + "login.is_cluster_at_limit(:cluster_id); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -588,4 +589,4 @@ DB::Query::QueryMode IsClusterAtLimitQuery::getExecutionMode() const
|
||||
return MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
@@ -32,42 +32,43 @@ MemoryBlockManager* PlanetProxyObject::memoryBlockManager;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
PlanetProxyObject::PlanetProxyObject (const NetworkId &objectId) :
|
||||
m_objectId(objectId),
|
||||
m_containedBy(NetworkId::cms_invalid),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_z(0),
|
||||
m_authoritativeServer(0),
|
||||
m_lastReportedServer(0),
|
||||
m_interestRadius(0),
|
||||
m_quadtreeNode(nullptr),
|
||||
m_authTransferTimeMs(Clock::timeMs()),
|
||||
m_contents(nullptr),
|
||||
m_level(0),
|
||||
m_hibernating(false),
|
||||
m_templateCrc(0),
|
||||
m_aiActivity(-1),
|
||||
m_creationType(-1)
|
||||
PlanetProxyObject::PlanetProxyObject(const NetworkId &objectId) :
|
||||
m_objectId(objectId),
|
||||
m_containedBy(NetworkId::cms_invalid),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_z(0),
|
||||
m_authoritativeServer(0),
|
||||
m_lastReportedServer(0),
|
||||
m_interestRadius(0),
|
||||
m_quadtreeNode(nullptr),
|
||||
m_authTransferTimeMs(Clock::timeMs()),
|
||||
m_contents(nullptr),
|
||||
m_level(0),
|
||||
m_hibernating(false),
|
||||
m_templateCrc(0),
|
||||
m_aiActivity(-1),
|
||||
m_creationType(-1),
|
||||
m_objectTypeTag(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
PlanetProxyObject::~PlanetProxyObject ()
|
||||
PlanetProxyObject::~PlanetProxyObject()
|
||||
{
|
||||
if (PlanetServer::getInstance().isWatcherPresent())
|
||||
{
|
||||
outputStatusToAll(true);
|
||||
}
|
||||
m_quadtreeNode=0;
|
||||
m_quadtreeNode = 0;
|
||||
|
||||
if (m_contents)
|
||||
{
|
||||
for (std::vector<NetworkId>::const_iterator i=m_contents->begin(); i!=m_contents->end(); ++i)
|
||||
WARNING(true,("Object %s was deleted without removing contained object %s first",m_objectId.getValueString().c_str(), i->getValueString().c_str()));
|
||||
for (std::vector<NetworkId>::const_iterator i = m_contents->begin(); i != m_contents->end(); ++i)
|
||||
WARNING(true, ("Object %s was deleted without removing contained object %s first", m_objectId.getValueString().c_str(), i->getValueString().c_str()));
|
||||
delete m_contents;
|
||||
m_contents=0;
|
||||
m_contents = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ PlanetProxyObject::~PlanetProxyObject ()
|
||||
*/
|
||||
void PlanetProxyObject::update(int x, int y, int z, NetworkId containedBy, uint32 authoritativeServer, int interestRadius, int objectTypeTag, int const level, bool const hibernating, uint32 const templateCrc, int const aiActivity, int const creationType)
|
||||
{
|
||||
WARNING_DEBUG_FATAL(m_objectId==NetworkId::cms_invalid,("Object ID was 0."));
|
||||
WARNING_DEBUG_FATAL(m_objectId == NetworkId::cms_invalid, ("Object ID was 0."));
|
||||
bool watcherUpdateNeeded = false;
|
||||
|
||||
m_level = level;
|
||||
@@ -88,64 +89,64 @@ void PlanetProxyObject::update(int x, int y, int z, NetworkId containedBy, uint3
|
||||
m_aiActivity = aiActivity;
|
||||
m_creationType = creationType;
|
||||
|
||||
if ((m_authoritativeServer != 0 ) && (authoritativeServer != m_authoritativeServer) && (containedBy == NetworkId::cms_invalid))
|
||||
if ((m_authoritativeServer != 0) && (authoritativeServer != m_authoritativeServer) && (containedBy == NetworkId::cms_invalid))
|
||||
{
|
||||
static unsigned long authTransferSanityCheckTimeMs = ConfigPlanetServer::getAuthTransferSanityCheckTimeMs();
|
||||
if (Clock::timeMs()-m_authTransferTimeMs > authTransferSanityCheckTimeMs)
|
||||
if (Clock::timeMs() - m_authTransferTimeMs > authTransferSanityCheckTimeMs)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Resending auth transfer for %s to %lu due to receiving a stale position update.", m_objectId.getValueString().c_str(), authoritativeServer));
|
||||
sendAuthorityChange(authoritativeServer, m_authoritativeServer, false);
|
||||
return;
|
||||
}
|
||||
if (ConfigPlanetServer::getLogObjectLoading())
|
||||
LOG("ObjectLoading",("Ignoring update for %s from %lu because server was not authoritative.",m_objectId.getValueString().c_str(),authoritativeServer));
|
||||
LOG("ObjectLoading", ("Ignoring update for %s from %lu because server was not authoritative.", m_objectId.getValueString().c_str(), authoritativeServer));
|
||||
return;
|
||||
}
|
||||
|
||||
if (interestRadius>ConfigPlanetServer::getMaxInterestRadius())
|
||||
|
||||
if (interestRadius > ConfigPlanetServer::getMaxInterestRadius())
|
||||
interestRadius = ConfigPlanetServer::getMaxInterestRadius();
|
||||
|
||||
if (interestRadius>0 && PlanetServer::getInstance().isInTutorialMode())
|
||||
|
||||
if (interestRadius > 0 && PlanetServer::getInstance().isInTutorialMode())
|
||||
interestRadius = 1;
|
||||
|
||||
if (containedBy!=NetworkId::cms_invalid)
|
||||
if (containedBy != NetworkId::cms_invalid)
|
||||
{
|
||||
// get coordinates from container
|
||||
PlanetProxyObject *container = Scene::getInstance().findObjectByID(containedBy);
|
||||
if (container)
|
||||
{
|
||||
x=container->getX();
|
||||
y=container->getY();
|
||||
z=container->getZ();
|
||||
x = container->getX();
|
||||
y = container->getY();
|
||||
z = container->getZ();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("PlanetUpdate",("Game server said object %s was contained by object %s, but we could not find the container.",m_objectId.getValueString().c_str(),containedBy.getValueString().c_str()));
|
||||
LOG("PlanetUpdate", ("Game server said object %s was contained by object %s, but we could not find the container.", m_objectId.getValueString().c_str(), containedBy.getValueString().c_str()));
|
||||
containedBy = NetworkId::cms_invalid; // so that we'll try again when the object moves again, in case we just got objects out-of-order from the game server
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<uint32> oldProxyList;
|
||||
|
||||
Node *newNode=Scene::getInstance().findNodeByPosition(x,z);
|
||||
Node *newNode = Scene::getInstance().findNodeByPosition(x, z);
|
||||
NOT_NULL(newNode);
|
||||
if (newNode!=m_quadtreeNode || m_interestRadius != interestRadius || m_authoritativeServer != authoritativeServer || m_containedBy != containedBy)
|
||||
if (newNode != m_quadtreeNode || m_interestRadius != interestRadius || m_authoritativeServer != authoritativeServer || m_containedBy != containedBy)
|
||||
{
|
||||
watcherUpdateNeeded = true;
|
||||
|
||||
// For debugging, update the contents of the containers
|
||||
if (ConfigPlanetServer::getEnableContentsChecking() && (m_containedBy!=containedBy))
|
||||
if (ConfigPlanetServer::getEnableContentsChecking() && (m_containedBy != containedBy))
|
||||
updateContentsTracking(containedBy);
|
||||
|
||||
|
||||
bool const firstUpdate = (m_quadtreeNode == nullptr);
|
||||
|
||||
if (m_quadtreeNode!=nullptr) // if this is the first update for this object, m_quadtreeNode will be nullptr because it hasn't been placed anywhere yet
|
||||
if (m_quadtreeNode != nullptr) // if this is the first update for this object, m_quadtreeNode will be nullptr because it hasn't been placed anywhere yet
|
||||
{
|
||||
removeServerStatistics();
|
||||
|
||||
// remember old list of proxies
|
||||
getServers(oldProxyList);
|
||||
|
||||
|
||||
// remove from the old location
|
||||
m_quadtreeNode->removeObject(this);
|
||||
|
||||
@@ -153,34 +154,34 @@ void PlanetProxyObject::update(int x, int y, int z, NetworkId containedBy, uint3
|
||||
LOG("ObjectLoading", ("unsubscribing nodes for object id=[%s]", m_objectId.getValueString().c_str()));
|
||||
unsubscribeSurroundingNodes(false);
|
||||
}
|
||||
|
||||
|
||||
// update data
|
||||
m_quadtreeNode=newNode;
|
||||
m_x=x;
|
||||
m_y=y;
|
||||
m_z=z;
|
||||
m_interestRadius=interestRadius;
|
||||
m_quadtreeNode = newNode;
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_z = z;
|
||||
m_interestRadius = interestRadius;
|
||||
m_objectTypeTag = objectTypeTag;
|
||||
m_authoritativeServer=authoritativeServer;
|
||||
m_containedBy=containedBy;
|
||||
m_authoritativeServer = authoritativeServer;
|
||||
m_containedBy = containedBy;
|
||||
|
||||
// make sure the destination is loaded
|
||||
if (!newNode->isLoaded())
|
||||
{
|
||||
if (ConfigPlanetServer::getLogObjectLoading())
|
||||
LOG("ObjectLoading",("Loading node %s because object %s entered it.",newNode->getDebugNodeString().c_str(), m_objectId.getValueString().c_str()));
|
||||
LOG("ObjectLoading", ("Loading node %s because object %s entered it.", newNode->getDebugNodeString().c_str(), m_objectId.getValueString().c_str()));
|
||||
newNode->load();
|
||||
}
|
||||
|
||||
|
||||
// check if we're on the right server
|
||||
if (!isAuthorityOk())
|
||||
{
|
||||
uint32 preferredServer = m_quadtreeNode->getPreferredServer();
|
||||
if (m_containedBy==NetworkId::cms_invalid)
|
||||
if (m_containedBy == NetworkId::cms_invalid)
|
||||
{
|
||||
if (ConfigPlanetServer::getLogObjectLoading())
|
||||
LOG("ObjectLoading",("Changing authority for object %s from %lu to %lu because node %s is authoritative on that server.",
|
||||
m_objectId.getValueString().c_str(),m_authoritativeServer,preferredServer,m_quadtreeNode->getDebugNodeString().c_str()));
|
||||
LOG("ObjectLoading", ("Changing authority for object %s from %lu to %lu because node %s is authoritative on that server.",
|
||||
m_objectId.getValueString().c_str(), m_authoritativeServer, preferredServer, m_quadtreeNode->getDebugNodeString().c_str()));
|
||||
changeAuthority(preferredServer, false, false); // changes m_authoritativeServer and sends message
|
||||
|
||||
// we received the object for the first time, and we had to
|
||||
@@ -192,8 +193,8 @@ void PlanetProxyObject::update(int x, int y, int z, NetworkId containedBy, uint3
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING(true,("Programmer bug: Object %s is in container %s, which is node %s. The object should be authoritative on server %i but it is authoritative on server %i.",
|
||||
m_objectId.getValueString().c_str(),m_containedBy.getValueString().c_str(),m_quadtreeNode->getDebugNodeString().c_str(), m_authoritativeServer, preferredServer));
|
||||
WARNING(true, ("Programmer bug: Object %s is in container %s, which is node %s. The object should be authoritative on server %i but it is authoritative on server %i.",
|
||||
m_objectId.getValueString().c_str(), m_containedBy.getValueString().c_str(), m_quadtreeNode->getDebugNodeString().c_str(), m_authoritativeServer, preferredServer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,30 +205,30 @@ void PlanetProxyObject::update(int x, int y, int z, NetworkId containedBy, uint3
|
||||
{
|
||||
if (ConfigPlanetServer::getLogObjectLoading())
|
||||
LOG("ObjectLoading", ("subscribing nodes for object id=[%s]", m_objectId.getValueString().c_str()));
|
||||
subscribeSurroundingNodes();
|
||||
subscribeSurroundingNodes();
|
||||
}
|
||||
|
||||
|
||||
// check against new interested servers, and send proxy/unproxy as needed
|
||||
if (m_containedBy==NetworkId::cms_invalid) // we don't manage proxies for containers
|
||||
if (m_containedBy == NetworkId::cms_invalid) // we don't manage proxies for containers
|
||||
{
|
||||
std::vector<uint32> newProxyList;
|
||||
getServers(newProxyList);
|
||||
changeProxies(oldProxyList,newProxyList);
|
||||
changeProxies(oldProxyList, newProxyList);
|
||||
}
|
||||
|
||||
|
||||
addServerStatistics();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_interestRadius > 0 || (abs(m_x - x) > 25) || (abs(m_z - z) > 25))
|
||||
watcherUpdateNeeded = true;
|
||||
}
|
||||
|
||||
|
||||
if (PlanetServer::getInstance().isWatcherPresent() && watcherUpdateNeeded)
|
||||
{
|
||||
m_x=x;
|
||||
m_y=y;
|
||||
m_z=z;
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_z = z;
|
||||
m_objectTypeTag = objectTypeTag;
|
||||
|
||||
outputStatusToAll(false);
|
||||
@@ -240,11 +241,11 @@ void PlanetProxyObject::unsubscribeSurroundingNodes(bool clearZeroSubscriptions)
|
||||
{
|
||||
if (m_interestRadius <= 0)
|
||||
return;
|
||||
|
||||
|
||||
Scene::NodeListType nodelist;
|
||||
Scene::getInstance().findIntersection(nodelist,m_x,m_z,m_interestRadius);
|
||||
|
||||
for (Scene::NodeListType::iterator i=nodelist.begin(); i!=nodelist.end(); ++i)
|
||||
Scene::getInstance().findIntersection(nodelist, m_x, m_z, m_interestRadius);
|
||||
|
||||
for (Scene::NodeListType::iterator i = nodelist.begin(); i != nodelist.end(); ++i)
|
||||
{
|
||||
(*i)->unsubscribeServer(m_authoritativeServer, 1, clearZeroSubscriptions);
|
||||
}
|
||||
@@ -253,20 +254,20 @@ void PlanetProxyObject::unsubscribeSurroundingNodes(bool clearZeroSubscriptions)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PlanetProxyObject::subscribeSurroundingNodes()
|
||||
{
|
||||
{
|
||||
if (m_interestRadius <= 0)
|
||||
return;
|
||||
|
||||
NOT_NULL(m_quadtreeNode);
|
||||
Scene::NodeListType nodelist;
|
||||
Scene::getInstance().findIntersection(nodelist,m_x,m_z,m_interestRadius);
|
||||
|
||||
for (Scene::NodeListType::iterator i=nodelist.begin(); i!=nodelist.end(); ++i)
|
||||
Scene::getInstance().findIntersection(nodelist, m_x, m_z, m_interestRadius);
|
||||
|
||||
for (Scene::NodeListType::iterator i = nodelist.begin(); i != nodelist.end(); ++i)
|
||||
{
|
||||
(*i)->subscribeServer(m_authoritativeServer, 1);
|
||||
uint32 serverId = (*i)->getPreferredServer();
|
||||
if (serverId != m_authoritativeServer)
|
||||
m_quadtreeNode->subscribeServer(serverId,0); // make sure if we can see them, they can see us
|
||||
m_quadtreeNode->subscribeServer(serverId, 0); // make sure if we can see them, they can see us
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,22 +333,22 @@ void PlanetProxyObject::unload(bool tellGameServer)
|
||||
if (m_quadtreeNode)
|
||||
m_quadtreeNode->removeObject(this);
|
||||
|
||||
Scene::getInstance().removeObjectFromMap(m_objectId,tellGameServer);
|
||||
Scene::getInstance().removeObjectFromMap(m_objectId, tellGameServer);
|
||||
|
||||
if (tellGameServer)
|
||||
{
|
||||
PlanetServer::getInstance().unloadObject(m_objectId,m_authoritativeServer);
|
||||
PlanetServer::getInstance().unloadObject(m_objectId, m_authoritativeServer);
|
||||
}
|
||||
|
||||
removeServerStatistics();
|
||||
|
||||
if (ConfigPlanetServer::getEnableContentsChecking() && m_containedBy!=NetworkId::cms_invalid)
|
||||
if (ConfigPlanetServer::getEnableContentsChecking() && m_containedBy != NetworkId::cms_invalid)
|
||||
{
|
||||
PlanetProxyObject *container = Scene::getInstance().findObjectByID(m_containedBy);
|
||||
if (container)
|
||||
container->removeContainedObject(m_objectId);
|
||||
else
|
||||
WARNING(true,("Unloading object %s in container %s, but the container could not be found.",m_objectId.getValueString().c_str(), m_containedBy.getValueString().c_str()));
|
||||
WARNING(true, ("Unloading object %s in container %s, but the container could not be found.", m_objectId.getValueString().c_str(), m_containedBy.getValueString().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +369,7 @@ void PlanetProxyObject::outputStatus(WatcherConnection &conn, bool deleteObject)
|
||||
void PlanetProxyObject::outputStatusToAll(bool deleteObject) const
|
||||
{
|
||||
const PlanetServer::WatcherList &connections = PlanetServer::getInstance().getWatchers();
|
||||
for (PlanetServer::WatcherList::const_iterator i= connections.begin(); i!=connections.end(); ++i)
|
||||
for (PlanetServer::WatcherList::const_iterator i = connections.begin(); i != connections.end(); ++i)
|
||||
{
|
||||
outputStatus(**i, deleteObject);
|
||||
}
|
||||
@@ -376,21 +377,21 @@ void PlanetProxyObject::outputStatusToAll(bool deleteObject) const
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
/**
|
||||
* Update the GameServerData with statistics about this object.
|
||||
*/
|
||||
void PlanetProxyObject::addServerStatistics() const
|
||||
{
|
||||
GameServerData *data=PlanetServer::getInstance().getGameServerData(m_authoritativeServer);
|
||||
GameServerData *data = PlanetServer::getInstance().getGameServerData(m_authoritativeServer);
|
||||
if (data)
|
||||
{
|
||||
data->adjustObjectCount(1);
|
||||
if (m_interestRadius!=0)
|
||||
if (m_interestRadius != 0)
|
||||
{
|
||||
data->adjustInterestObjectCount(1);
|
||||
if (isCreature())
|
||||
data->adjustInterestCreatureObjectCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,15 +403,15 @@ void PlanetProxyObject::addServerStatistics() const
|
||||
*/
|
||||
void PlanetProxyObject::removeServerStatistics() const
|
||||
{
|
||||
GameServerData *data=PlanetServer::getInstance().getGameServerData(m_authoritativeServer);
|
||||
GameServerData *data = PlanetServer::getInstance().getGameServerData(m_authoritativeServer);
|
||||
if (data)
|
||||
{
|
||||
data->adjustObjectCount(-1);
|
||||
if (m_interestRadius!=0)
|
||||
if (m_interestRadius != 0)
|
||||
{
|
||||
data->adjustInterestObjectCount(-1);
|
||||
if (isCreature())
|
||||
data->adjustInterestCreatureObjectCount(-1);
|
||||
data->adjustInterestCreatureObjectCount(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,7 +424,7 @@ void PlanetProxyObject::removeServerStatistics() const
|
||||
void PlanetProxyObject::install()
|
||||
{
|
||||
memoryBlockManager = new MemoryBlockManager("PlanetProxyObject::memoryBlockManager", true, sizeof(PlanetProxyObject), 0, 0, 0);
|
||||
ExitChain::add(&remove, "PlanetProxyObject::remove");
|
||||
ExitChain::add(&remove, "PlanetProxyObject::remove");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -461,7 +462,7 @@ void PlanetProxyObject::operator delete(void* pointer)
|
||||
|
||||
void PlanetProxyObject::sendAuthorityChange(uint32 currentAuthServer, uint32 newAuthServer, bool handlingCrash)
|
||||
{
|
||||
DEBUG_WARNING(!isAuthorityClean(), ("Object %s attempted to change authority before previous authority change was complete.",getObjectId().getValueString().c_str()));
|
||||
DEBUG_WARNING(!isAuthorityClean(), ("Object %s attempted to change authority before previous authority change was complete.", getObjectId().getValueString().c_str()));
|
||||
|
||||
SetAuthoritativeMessage const auth(getObjectId(), newAuthServer, false, handlingCrash, NetworkId::cms_invalid, Transform::identity, false);
|
||||
PlanetServer::getInstance().sendToGameServer(currentAuthServer, auth);
|
||||
@@ -473,7 +474,7 @@ void PlanetProxyObject::sendAuthorityChange(uint32 currentAuthServer, uint32 new
|
||||
void PlanetProxyObject::sendAddProxy(uint32 proxyServer)
|
||||
{
|
||||
if (ConfigPlanetServer::getLogObjectLoading())
|
||||
LOG("ObjectLoading",("Gameserver %lu needs a proxy of object %s",proxyServer,m_objectId.getValueString().c_str()));
|
||||
LOG("ObjectLoading", ("Gameserver %lu needs a proxy of object %s", proxyServer, m_objectId.getValueString().c_str()));
|
||||
if (isAuthorityClean())
|
||||
{
|
||||
LoadObjectMessage const loadMsg(getObjectId(), proxyServer);
|
||||
@@ -491,15 +492,15 @@ void PlanetProxyObject::sendAddProxy(uint32 proxyServer)
|
||||
void PlanetProxyObject::sendRemoveProxy(uint32 proxyServer)
|
||||
{
|
||||
if (ConfigPlanetServer::getLogObjectLoading())
|
||||
LOG("ObjectLoading",("Gameserver %lu no longer needs a proxy of object %s",proxyServer,m_objectId.getValueString().c_str()));
|
||||
LOG("ObjectLoading", ("Gameserver %lu no longer needs a proxy of object %s", proxyServer, m_objectId.getValueString().c_str()));
|
||||
if (isAuthorityClean())
|
||||
{
|
||||
UnloadProxyMessage msg(getObjectId(),proxyServer);
|
||||
UnloadProxyMessage msg(getObjectId(), proxyServer);
|
||||
PlanetServer::getInstance().sendToGameServer(m_authoritativeServer, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnloadProxyMessage *msg = new UnloadProxyMessage(getObjectId(),proxyServer);
|
||||
UnloadProxyMessage *msg = new UnloadProxyMessage(getObjectId(), proxyServer);
|
||||
PlanetServer::getInstance().queueMessageForObject(getObjectId(), msg);
|
||||
}
|
||||
}
|
||||
@@ -516,7 +517,7 @@ void PlanetProxyObject::onReceivedMessageFromServer(uint32 server)
|
||||
if (m_lastReportedServer != m_authoritativeServer && server == m_authoritativeServer)
|
||||
// we've received a message from the new authoritative server. Send queued messages:
|
||||
PlanetServer::getInstance().sendQueuedMessagesForObject(*this);
|
||||
|
||||
|
||||
m_lastReportedServer = server;
|
||||
}
|
||||
|
||||
@@ -534,8 +535,8 @@ void PlanetProxyObject::getServers(std::vector<uint32> &serverList) const
|
||||
}
|
||||
else
|
||||
{
|
||||
PlanetProxyObject *container=Scene::getInstance().findObjectByID(m_containedBy);
|
||||
WARNING_STRICT_FATAL(!container,("Object %s is in container %s, which couldn't be found",m_objectId.getValueString().c_str(),m_containedBy.getValueString().c_str()));
|
||||
PlanetProxyObject *container = Scene::getInstance().findObjectByID(m_containedBy);
|
||||
WARNING_STRICT_FATAL(!container, ("Object %s is in container %s, which couldn't be found", m_objectId.getValueString().c_str(), m_containedBy.getValueString().c_str()));
|
||||
if (container)
|
||||
effectiveNode = container->getNode();
|
||||
else
|
||||
@@ -557,12 +558,12 @@ void PlanetProxyObject::getServers(std::vector<uint32> &serverList) const
|
||||
void PlanetProxyObject::changeProxies(const std::vector<uint32> &oldServers, const std::vector<uint32> &newServers)
|
||||
{
|
||||
{
|
||||
for (std::vector<uint32>::const_iterator i=oldServers.begin(); i!=oldServers.end(); ++i)
|
||||
for (std::vector<uint32>::const_iterator i = oldServers.begin(); i != oldServers.end(); ++i)
|
||||
{
|
||||
if (*i != m_authoritativeServer)
|
||||
{
|
||||
bool removeNeeded = true;
|
||||
for (std::vector<uint32>::const_iterator j=newServers.begin(); j!=newServers.end(); ++j)
|
||||
for (std::vector<uint32>::const_iterator j = newServers.begin(); j != newServers.end(); ++j)
|
||||
{
|
||||
if (*i == *j)
|
||||
{
|
||||
@@ -576,12 +577,12 @@ void PlanetProxyObject::changeProxies(const std::vector<uint32> &oldServers, con
|
||||
}
|
||||
}
|
||||
{
|
||||
for (std::vector<uint32>::const_iterator i=newServers.begin(); i!=newServers.end(); ++i)
|
||||
for (std::vector<uint32>::const_iterator i = newServers.begin(); i != newServers.end(); ++i)
|
||||
{
|
||||
if (*i != m_authoritativeServer)
|
||||
{
|
||||
bool addNeeded = true;
|
||||
for (std::vector<uint32>::const_iterator j=oldServers.begin(); j!=oldServers.end(); ++j)
|
||||
for (std::vector<uint32>::const_iterator j = oldServers.begin(); j != oldServers.end(); ++j)
|
||||
{
|
||||
if (*i == *j)
|
||||
{
|
||||
@@ -638,10 +639,10 @@ void PlanetProxyObject::addContainedObject(const NetworkId &theObject)
|
||||
{
|
||||
m_contents = new std::vector<NetworkId>;
|
||||
}
|
||||
for (std::vector<NetworkId>::const_iterator i=m_contents->begin(); i!=m_contents->end(); ++i)
|
||||
for (std::vector<NetworkId>::const_iterator i = m_contents->begin(); i != m_contents->end(); ++i)
|
||||
{
|
||||
if (*i==theObject)
|
||||
WARNING(true,("Object %s was placed in container %s twice.", theObject.getValueString().c_str(), m_objectId.getValueString().c_str()));
|
||||
if (*i == theObject)
|
||||
WARNING(true, ("Object %s was placed in container %s twice.", theObject.getValueString().c_str(), m_objectId.getValueString().c_str()));
|
||||
}
|
||||
m_contents->push_back(theObject);
|
||||
}
|
||||
@@ -652,13 +653,13 @@ void PlanetProxyObject::removeContainedObject(const NetworkId &theObject)
|
||||
{
|
||||
if (!m_contents)
|
||||
{
|
||||
WARNING(true,("Attempted to remove object %s from object %s, but that object has no contents.", theObject.getValueString().c_str(), m_objectId.getValueString().c_str()));
|
||||
WARNING(true, ("Attempted to remove object %s from object %s, but that object has no contents.", theObject.getValueString().c_str(), m_objectId.getValueString().c_str()));
|
||||
return;
|
||||
}
|
||||
std::vector<NetworkId>::iterator newEnd=std::remove(m_contents->begin(), m_contents->end(), theObject);
|
||||
if (newEnd==m_contents->end())
|
||||
std::vector<NetworkId>::iterator newEnd = std::remove(m_contents->begin(), m_contents->end(), theObject);
|
||||
if (newEnd == m_contents->end())
|
||||
{
|
||||
WARNING(true,("Attempted to remove object %s from object %s, but it was not in the container.", theObject.getValueString().c_str(), m_objectId.getValueString().c_str()));
|
||||
WARNING(true, ("Attempted to remove object %s from object %s, but it was not in the container.", theObject.getValueString().c_str(), m_objectId.getValueString().c_str()));
|
||||
return;
|
||||
}
|
||||
m_contents->erase(newEnd, m_contents->end());
|
||||
@@ -672,22 +673,22 @@ void PlanetProxyObject::removeContainedObject(const NetworkId &theObject)
|
||||
*/
|
||||
void PlanetProxyObject::updateContentsTracking(const NetworkId &newContainedBy)
|
||||
{
|
||||
if (m_containedBy!=NetworkId::cms_invalid)
|
||||
if (m_containedBy != NetworkId::cms_invalid)
|
||||
{
|
||||
PlanetProxyObject *container = Scene::getInstance().findObjectByID(m_containedBy);
|
||||
if (container)
|
||||
container->removeContainedObject(m_objectId);
|
||||
else
|
||||
WARNING(true,("Removing object %s from container %s, but the container could not be found.",m_objectId.getValueString().c_str(), m_containedBy.getValueString().c_str()));
|
||||
WARNING(true, ("Removing object %s from container %s, but the container could not be found.", m_objectId.getValueString().c_str(), m_containedBy.getValueString().c_str()));
|
||||
}
|
||||
|
||||
if (newContainedBy!=NetworkId::cms_invalid)
|
||||
if (newContainedBy != NetworkId::cms_invalid)
|
||||
{
|
||||
PlanetProxyObject *container = Scene::getInstance().findObjectByID(newContainedBy);
|
||||
if (container)
|
||||
container->addContainedObject(m_objectId);
|
||||
else
|
||||
WARNING(true,("Adding object %s to container %s, but the container could not be found.",m_objectId.getValueString().c_str(), newContainedBy.getValueString().c_str()));
|
||||
WARNING(true, ("Adding object %s to container %s, but the container could not be found.", m_objectId.getValueString().c_str(), newContainedBy.getValueString().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +696,7 @@ void PlanetProxyObject::updateContentsTracking(const NetworkId &newContainedBy)
|
||||
|
||||
bool PlanetProxyObject::isCreature() const
|
||||
{
|
||||
return m_objectTypeTag==TAG(C,R,E,O);
|
||||
return m_objectTypeTag == TAG(C, R, E, O);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
+14
-13
@@ -16,8 +16,9 @@
|
||||
// ======================================================================
|
||||
|
||||
DeleteCharacterCustomPersistStep::DeleteCharacterCustomPersistStep(uint32 stationId, const NetworkId &characterId) :
|
||||
m_characterId(characterId),
|
||||
m_stationId(stationId)
|
||||
m_characterId(characterId),
|
||||
m_stationId(stationId),
|
||||
m_resultCode(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,12 +34,12 @@ bool DeleteCharacterCustomPersistStep::beforePersist(DB::Session *)
|
||||
bool DeleteCharacterCustomPersistStep::afterPersist(DB::Session *session)
|
||||
{
|
||||
DeleteCharacterQuery qry(m_stationId, m_characterId);
|
||||
|
||||
if (! (session->exec(&qry)))
|
||||
|
||||
if (!(session->exec(&qry)))
|
||||
return false;
|
||||
qry.done();
|
||||
|
||||
m_resultCode=qry.result.getValue();
|
||||
m_resultCode = qry.result.getValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,18 +49,18 @@ void DeleteCharacterCustomPersistStep::onComplete()
|
||||
{
|
||||
if (m_resultCode == 2)
|
||||
{
|
||||
GenericValueTypeMessage<NetworkId> msg("ReleaseCharacterNameByIdMessage",m_characterId);
|
||||
DatabaseProcess::getInstance().sendToAllGameServers(msg,true);
|
||||
GenericValueTypeMessage<NetworkId> msg("ReleaseCharacterNameByIdMessage", m_characterId);
|
||||
DatabaseProcess::getInstance().sendToAllGameServers(msg, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
DeleteCharacterCustomPersistStep::DeleteCharacterQuery::DeleteCharacterQuery(uint32 stationId, const NetworkId &characterId) :
|
||||
station_id(stationId),
|
||||
character_id(characterId),
|
||||
delete_minutes(ConfigServerDatabase::getCharacterImmediateDeleteMinutes()),
|
||||
result()
|
||||
station_id(stationId),
|
||||
character_id(characterId),
|
||||
delete_minutes(ConfigServerDatabase::getCharacterImmediateDeleteMinutes()),
|
||||
result()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ DeleteCharacterCustomPersistStep::DeleteCharacterQuery::DeleteCharacterQuery(uin
|
||||
|
||||
void DeleteCharacterCustomPersistStep::DeleteCharacterQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql="begin :result := " + DatabaseProcess::getInstance().getSchemaQualifier() + "persister.delete_character (:station_id, :character_id, :delete_minutes); end;";
|
||||
sql = "begin :result := " + DatabaseProcess::getInstance().getSchemaQualifier() + "persister.delete_character (:station_id, :character_id, :delete_minutes); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -95,4 +96,4 @@ DB::Query::QueryMode DeleteCharacterCustomPersistStep::DeleteCharacterQuery::get
|
||||
return DB::Query::MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
@@ -16,8 +16,9 @@
|
||||
// ======================================================================
|
||||
|
||||
TaskCheckCharacterName::TaskCheckCharacterName(uint32 stationId, const Unicode::String &name) :
|
||||
m_name(name),
|
||||
m_stationId(stationId)
|
||||
m_name(name),
|
||||
m_stationId(stationId),
|
||||
m_resultCode(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,11 +27,11 @@ TaskCheckCharacterName::TaskCheckCharacterName(uint32 stationId, const Unicode::
|
||||
bool TaskCheckCharacterName::process(DB::Session *session)
|
||||
{
|
||||
CheckCharacterNameQuery qry(Unicode::wideToNarrow(m_name));
|
||||
|
||||
|
||||
bool rval = session->exec(&qry);
|
||||
qry.done();
|
||||
|
||||
m_resultCode=qry.result.getValue();
|
||||
m_resultCode = qry.result.getValue();
|
||||
return rval;
|
||||
}
|
||||
|
||||
@@ -38,14 +39,14 @@ bool TaskCheckCharacterName::process(DB::Session *session)
|
||||
|
||||
void TaskCheckCharacterName::onComplete()
|
||||
{
|
||||
DataLookup::getInstance().onCharacterNameChecked(m_stationId, m_name,m_resultCode);
|
||||
DataLookup::getInstance().onCharacterNameChecked(m_stationId, m_name, m_resultCode);
|
||||
LOG("TraceCharacterCreation", ("%d TaskCheckCharacterName(%s) complete with result code %d", m_stationId, Unicode::wideToNarrow(m_name).c_str(), m_resultCode));
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskCheckCharacterName::CheckCharacterNameQuery::CheckCharacterNameQuery(const std::string &name) :
|
||||
character_name(name)
|
||||
character_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ TaskCheckCharacterName::CheckCharacterNameQuery::CheckCharacterNameQuery(const s
|
||||
|
||||
void TaskCheckCharacterName::CheckCharacterNameQuery::getSQL(std::string &sql)
|
||||
{
|
||||
sql="begin :result := " + DatabaseProcess::getInstance().getSchemaQualifier() + "datalookup.check_character_name (:name); end;";
|
||||
sql = "begin :result := " + DatabaseProcess::getInstance().getSchemaQualifier() + "datalookup.check_character_name (:name); end;";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -79,4 +80,4 @@ DB::Query::QueryMode TaskCheckCharacterName::CheckCharacterNameQuery::getExecuti
|
||||
return DB::Query::MODE_PROCEXEC;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,6 @@
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/CommandQueueEntry.h"
|
||||
#include "serverGame/CreatureObject.h"
|
||||
@@ -14,15 +13,15 @@
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedGame/CommandTable.h"
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
CommandQueueEntry::CommandQueueEntry() :
|
||||
m_command(&CommandTable::getNullCommand ()),
|
||||
m_command(&CommandTable::getNullCommand()),
|
||||
m_targetId(NetworkId::cms_invalid),
|
||||
m_params(),
|
||||
m_sequenceId(0),
|
||||
m_clearable(true)
|
||||
m_clearable(true),
|
||||
m_priority()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,8 +34,8 @@ CommandQueueEntry::CommandQueueEntry(
|
||||
uint32 sequenceId,
|
||||
bool clearable,
|
||||
Command::Priority priority,
|
||||
bool autoAttack ) :
|
||||
|
||||
bool autoAttack) :
|
||||
|
||||
m_command(&command),
|
||||
m_targetId(targetId),
|
||||
m_params(params),
|
||||
@@ -64,12 +63,12 @@ CommandQueueEntry &CommandQueueEntry::operator=(CommandQueueEntry const &rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
m_command = rhs.m_command; //lint !e1555
|
||||
m_targetId = rhs.m_targetId;
|
||||
m_params = rhs.m_params;
|
||||
m_command = rhs.m_command; //lint !e1555
|
||||
m_targetId = rhs.m_targetId;
|
||||
m_params = rhs.m_params;
|
||||
m_sequenceId = rhs.m_sequenceId;
|
||||
m_clearable = rhs.m_clearable;
|
||||
m_priority = rhs.m_priority;
|
||||
m_clearable = rhs.m_clearable;
|
||||
m_priority = rhs.m_priority;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -78,35 +77,30 @@ CommandQueueEntry &CommandQueueEntry::operator=(CommandQueueEntry const &rhs)
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
void get(ReadIterator &source, CommandQueueEntry &target)
|
||||
{
|
||||
uint32 commandHash;
|
||||
|
||||
void get(ReadIterator &source, CommandQueueEntry &target)
|
||||
{
|
||||
uint32 commandHash;
|
||||
Archive::get(source, commandHash);
|
||||
Archive::get(source, target.m_targetId);
|
||||
Archive::get(source, target.m_params);
|
||||
Archive::get(source, target.m_sequenceId);
|
||||
Archive::get(source, target.m_clearable);
|
||||
target.m_command = &CommandTable::getCommand(commandHash);
|
||||
}
|
||||
|
||||
Archive::get(source, commandHash);
|
||||
Archive::get(source, target.m_targetId);
|
||||
Archive::get(source, target.m_params);
|
||||
Archive::get(source, target.m_sequenceId);
|
||||
Archive::get(source, target.m_clearable);
|
||||
target.m_command = &CommandTable::getCommand(commandHash);
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
void put(ByteStream &target, CommandQueueEntry const &source)
|
||||
{
|
||||
Archive::put(target, source.m_command->m_commandHash);
|
||||
Archive::put(target, source.m_targetId);
|
||||
Archive::put(target, source.m_params);
|
||||
Archive::put(target, source.m_sequenceId);
|
||||
Archive::put(target, source.m_clearable);
|
||||
}
|
||||
|
||||
void put(ByteStream &target, CommandQueueEntry const &source)
|
||||
{
|
||||
Archive::put(target, source.m_command->m_commandHash);
|
||||
Archive::put(target, source.m_targetId);
|
||||
Archive::put(target, source.m_params);
|
||||
Archive::put(target, source.m_sequenceId);
|
||||
Archive::put(target, source.m_clearable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace Archive
|
||||
// ----------------------------------------------------------------------
|
||||
} // namespace Archive
|
||||
@@ -136,7 +136,7 @@ AiShipController * AiShipController::asAiShipController(Controller * const contr
|
||||
{
|
||||
ShipController * const shipController = (controller != nullptr) ? controller->asShipController() : nullptr;
|
||||
AiShipController * const aiShipController = (shipController != nullptr) ? shipController->asAiShipController() : nullptr;
|
||||
|
||||
|
||||
return aiShipController;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ AiShipController const * AiShipController::asAiShipController(Controller const *
|
||||
{
|
||||
ShipController const * const shipController = (controller != nullptr) ? controller->asShipController() : nullptr;
|
||||
AiShipController const * const aiShipController = (shipController != nullptr) ? shipController->asAiShipController() : nullptr;
|
||||
|
||||
|
||||
return aiShipController;
|
||||
}
|
||||
|
||||
@@ -253,8 +253,8 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
#ifdef _DEBUG
|
||||
|
||||
AiDebugString * aiDebugString = nullptr;
|
||||
if ( s_spaceAiClientDebugEnabled
|
||||
&& !getShipOwner()->getObservers().empty())
|
||||
if (s_spaceAiClientDebugEnabled
|
||||
&& !getShipOwner()->getObservers().empty())
|
||||
{
|
||||
aiDebugString = new AiDebugString;
|
||||
}
|
||||
@@ -277,8 +277,8 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
m_pendingDockingBehavior = nullptr;
|
||||
}
|
||||
|
||||
if ( (m_dockingBehavior != nullptr)
|
||||
&& (m_dockingBehavior->isDockFinished()))
|
||||
if ((m_dockingBehavior != nullptr)
|
||||
&& (m_dockingBehavior->isDockFinished()))
|
||||
{
|
||||
delete m_dockingBehavior;
|
||||
m_dockingBehavior = nullptr;
|
||||
@@ -319,8 +319,8 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
m_dockingBehavior->unDock();
|
||||
}
|
||||
|
||||
if ( isAttackSquadLeader()
|
||||
|| !getAttackSquad().isInFormation())
|
||||
if (isAttackSquadLeader()
|
||||
|| !getAttackSquad().isInFormation())
|
||||
{
|
||||
m_attackBehavior->alter(elapsedTime);
|
||||
|
||||
@@ -394,8 +394,8 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
|
||||
// Check for enemies periodically
|
||||
|
||||
if ( !m_enemyCheckQueued
|
||||
&& shouldCheckForEnemies())
|
||||
if (!m_enemyCheckQueued
|
||||
&& shouldCheckForEnemies())
|
||||
{
|
||||
m_enemyCheckQueued = true;
|
||||
ShipAiEnemySearchManager::add(*shipOwner);
|
||||
@@ -435,7 +435,7 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
{
|
||||
ShipController * const followedUnitShipController = squadLeader->getController()->asShipController();
|
||||
AiShipController * const followedUnitAiShipController = (followedUnitShipController != nullptr) ? followedUnitShipController->asAiShipController() : nullptr;
|
||||
|
||||
|
||||
if (followedUnitAiShipController != nullptr)
|
||||
{
|
||||
followedUnitAiShipController->requestSlowDown();
|
||||
@@ -485,8 +485,8 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
if (isSquadLeader())
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("check squadLeader");
|
||||
if ( isAttacking()
|
||||
|| !hasFunctionalEngines())
|
||||
if (isAttacking()
|
||||
|| !hasFunctionalEngines())
|
||||
{
|
||||
getSquad().assignNewLeader();
|
||||
}
|
||||
@@ -508,28 +508,28 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
PROFILER_AUTO_BLOCK_DEFINE("Manage countermeasures");
|
||||
switch (m_countermeasureState)
|
||||
{
|
||||
case CS_reacting:
|
||||
if (m_reactToMissileTimer->updateZero(elapsedTime))
|
||||
m_countermeasureState = CS_launching;
|
||||
break;
|
||||
case CS_reacting:
|
||||
if (m_reactToMissileTimer->updateZero(elapsedTime))
|
||||
m_countermeasureState = CS_launching;
|
||||
break;
|
||||
|
||||
case CS_launching:
|
||||
if (MissileManager::getInstance().isTargetedByMissile(getOwner()->getNetworkId()))
|
||||
case CS_launching:
|
||||
if (MissileManager::getInstance().isTargetedByMissile(getOwner()->getNetworkId()))
|
||||
{
|
||||
for (int weaponIndex = 0; weaponIndex < ShipChassisSlotType::cms_numWeaponIndices; ++weaponIndex)
|
||||
{
|
||||
for (int weaponIndex = 0; weaponIndex < ShipChassisSlotType::cms_numWeaponIndices; ++weaponIndex)
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("countermeasures missile loop");
|
||||
if (NON_NULL(getShipOwner())->isCountermeasure(weaponIndex))
|
||||
getShipOwner()->fireShotNonTurretServer(weaponIndex, NetworkId::cms_invalid, ShipChassisSlotType::SCST_invalid);
|
||||
}
|
||||
PROFILER_AUTO_BLOCK_DEFINE("countermeasures missile loop");
|
||||
if (NON_NULL(getShipOwner())->isCountermeasure(weaponIndex))
|
||||
getShipOwner()->fireShotNonTurretServer(weaponIndex, NetworkId::cms_invalid, ShipChassisSlotType::SCST_invalid);
|
||||
}
|
||||
else
|
||||
m_countermeasureState = CS_none;
|
||||
break;
|
||||
|
||||
case CS_none:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else
|
||||
m_countermeasureState = CS_none;
|
||||
break;
|
||||
|
||||
case CS_none:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,8 +551,8 @@ float AiShipController::realAlter(float const elapsedTime)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if ( (m_attackBehavior != nullptr)
|
||||
&& (aiDebugString != nullptr))
|
||||
if ((m_attackBehavior != nullptr)
|
||||
&& (aiDebugString != nullptr))
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("sendDebugAiToClients");
|
||||
sendDebugAiToClients(*aiDebugString);
|
||||
@@ -574,9 +574,9 @@ void AiShipController::moveTo(Vector const & position_w, float const throttle, f
|
||||
|
||||
// If we are not following a unit, see if we need to slow down for someone
|
||||
|
||||
if ( (m_nonAttackBehavior != nullptr)
|
||||
&& (m_nonAttackBehavior->getBehaviorType() != ASBT_follow)
|
||||
&& m_requestedSlowDown
|
||||
if ((m_nonAttackBehavior != nullptr)
|
||||
&& (m_nonAttackBehavior->getBehaviorType() != ASBT_follow)
|
||||
&& m_requestedSlowDown
|
||||
&& !isAttacking())
|
||||
{
|
||||
slowDown = true;
|
||||
@@ -599,7 +599,7 @@ void AiShipController::moveTo(Vector const & position_w, float const throttle, f
|
||||
|
||||
Vector resultAvoidancePosition_w;
|
||||
Vector const & shipVelocity = getShipOwner()->getCurrentVelocity_p();
|
||||
|
||||
|
||||
if (SpaceAvoidanceManager::getAvoidancePosition(*getOwner(), shipVelocity, position_w, resultAvoidancePosition_w))
|
||||
{
|
||||
IGNORE_RETURN(face(resultAvoidancePosition_w, deltaTime));
|
||||
@@ -649,7 +649,7 @@ bool AiShipController::addDamageTaken(NetworkId const & attackingUnit, float con
|
||||
{
|
||||
CreatureObject const * const attackingPilotCreatureObject = attackingShipObject->getPilot();
|
||||
|
||||
if ( (attackingPilotCreatureObject != nullptr)
|
||||
if ((attackingPilotCreatureObject != nullptr)
|
||||
&& attackingPilotCreatureObject->isPlayerControlled())
|
||||
{
|
||||
GroupObject * const groupObject = attackingPilotCreatureObject->getGroup();
|
||||
@@ -760,7 +760,7 @@ void AiShipController::follow(NetworkId const & followedUnit, Vector const & dir
|
||||
|
||||
CollisionProperty const * const ownerCollisionProperty = getOwner()->getCollisionProperty();
|
||||
CollisionProperty const * const followedObjectCollisionProperty = followedObject->getCollisionProperty();
|
||||
|
||||
|
||||
if (ownerCollisionProperty != nullptr)
|
||||
{
|
||||
appearanceRadius += ownerCollisionProperty->getBoundingSphere_l().getRadius();
|
||||
@@ -768,7 +768,7 @@ void AiShipController::follow(NetworkId const & followedUnit, Vector const & dir
|
||||
|
||||
if (followedObjectCollisionProperty != nullptr)
|
||||
{
|
||||
appearanceRadius += followedObjectCollisionProperty ->getBoundingSphere_l().getRadius();
|
||||
appearanceRadius += followedObjectCollisionProperty->getBoundingSphere_l().getRadius();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ int AiShipController::getBehaviorType() const
|
||||
{
|
||||
result = m_nonAttackBehavior->getBehaviorType();
|
||||
}
|
||||
|
||||
|
||||
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "debug_ai", ("AiShipController::getBehaviorType() owner(%s) behavior(%s)", getOwner()->getNetworkId().getValueString().c_str(), AiShipBehaviorBase::getBehaviorString(static_cast<AiShipBehaviorType>(result))));
|
||||
|
||||
return static_cast<int>(result);
|
||||
@@ -831,7 +831,7 @@ void AiShipController::track(Object const & target)
|
||||
void AiShipController::moveTo(SpacePath * const path)
|
||||
{
|
||||
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "debug_ai", ("AiShipController::moveTo() owner(%s) path(0x%p)", getOwner()->getNetworkId().getValueString().c_str(), path));
|
||||
|
||||
|
||||
if (path != m_path)
|
||||
{
|
||||
SpacePathManager::release(m_path, getOwner());
|
||||
@@ -959,7 +959,7 @@ void AiShipController::setPilotType(std::string const & pilotType)
|
||||
|
||||
if (pilotType.empty())
|
||||
{
|
||||
DEBUG_WARNING(true, ("AiShipController::setPilotType empty pilotType for ship [%s]",
|
||||
DEBUG_WARNING(true, ("AiShipController::setPilotType empty pilotType for ship [%s]",
|
||||
shipObject ? shipObject->getDebugInformation().c_str() : "NONE"));
|
||||
return;
|
||||
}
|
||||
@@ -992,23 +992,23 @@ void AiShipController::setPilotType(std::string const & pilotType)
|
||||
|
||||
switch (m_shipClass)
|
||||
{
|
||||
case ShipAiReactionManager::SC_invalid:
|
||||
default: { FATAL(true, ("Invalid ship name(%s)", m_shipName.getString())); }
|
||||
case ShipAiReactionManager::SC_fighter: { m_attackBehavior = new AiShipBehaviorAttackFighter(*this); } break;
|
||||
case ShipAiReactionManager::SC_bomber: { m_attackBehavior = new AiShipBehaviorAttackBomber(*this); } break;
|
||||
case ShipAiReactionManager::SC_capitalShip: { m_attackBehavior = new AiShipBehaviorAttackCapitalShip(*this); } break;
|
||||
case ShipAiReactionManager::SC_transport: { m_attackBehavior = new AiShipBehaviorAttackFighter(*this); } break;
|
||||
case ShipAiReactionManager::SC_invalid:
|
||||
default: { FATAL(true, ("Invalid ship name(%s)", m_shipName.getString())); }
|
||||
case ShipAiReactionManager::SC_fighter: { m_attackBehavior = new AiShipBehaviorAttackFighter(*this); } break;
|
||||
case ShipAiReactionManager::SC_bomber: { m_attackBehavior = new AiShipBehaviorAttackBomber(*this); } break;
|
||||
case ShipAiReactionManager::SC_capitalShip: { m_attackBehavior = new AiShipBehaviorAttackCapitalShip(*this); } break;
|
||||
case ShipAiReactionManager::SC_transport: { m_attackBehavior = new AiShipBehaviorAttackFighter(*this); } break;
|
||||
}
|
||||
|
||||
// Create the turreting target system, if appropriate
|
||||
|
||||
|
||||
if (shipObject && shipObject->hasTurrets())
|
||||
addTurretTargetingSystem(new AiShipTurretTargetingSystem(*this));
|
||||
|
||||
// Set the default aggro distance
|
||||
|
||||
setAggroRadius(m_pilotData->m_aggroRadius);
|
||||
|
||||
|
||||
FATAL((m_attackBehavior == nullptr), ("The attack behavior can not be nullptr."));
|
||||
}
|
||||
|
||||
@@ -1097,8 +1097,8 @@ void AiShipController::setSquad(SpaceSquad * const squad)
|
||||
{
|
||||
// Remove the unit from its previous squad
|
||||
|
||||
if ( (m_squad != nullptr)
|
||||
&& !m_squad->isEmpty())
|
||||
if ((m_squad != nullptr)
|
||||
&& !m_squad->isEmpty())
|
||||
{
|
||||
m_squad->removeUnit(getOwner()->getNetworkId());
|
||||
}
|
||||
@@ -1209,7 +1209,7 @@ float AiShipController::getShipRadius() const
|
||||
float result = 1.0f;
|
||||
ShipObject const * const shipObject = getShipOwner();
|
||||
CollisionProperty const * const shipCollision = shipObject->getCollisionProperty();
|
||||
|
||||
|
||||
if (shipCollision != nullptr)
|
||||
{
|
||||
result = shipCollision->getBoundingSphere_l().getRadius();
|
||||
@@ -1280,7 +1280,7 @@ bool AiShipController::shouldCheckForEnemies() const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1290,8 +1290,8 @@ void AiShipController::setCurrentPathIndex(unsigned int const index)
|
||||
{
|
||||
//LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "debug_ai", ("AiShipController::setCurrentPathIndex() unit(%s) pathIndex(%u) pathSize(%u)", getOwner()->getNetworkId().getValueString().c_str(), index, (m_path != nullptr) ? m_path->getTransformList().size() : 0));
|
||||
|
||||
if ( (m_path != nullptr)
|
||||
&& !m_path->isEmpty())
|
||||
if ((m_path != nullptr)
|
||||
&& !m_path->isEmpty())
|
||||
{
|
||||
m_currentPathIndex = index;
|
||||
}
|
||||
@@ -1314,21 +1314,21 @@ unsigned int AiShipController::getCurrentPathIndex() const
|
||||
float AiShipController::calculateThrottleToPosition_w(Vector const & position_w, float const slowDownDistance) const
|
||||
{
|
||||
float result = 0.0f;
|
||||
|
||||
|
||||
Object const * const object = getOwner();
|
||||
|
||||
if (object != nullptr)
|
||||
{
|
||||
float const distanceToGoalSquared = object->getPosition_w().magnitudeBetweenSquared(position_w);
|
||||
|
||||
if ( (distanceToGoalSquared < sqr(slowDownDistance))
|
||||
if ((distanceToGoalSquared < sqr(slowDownDistance))
|
||||
&& (slowDownDistance > 0.0f))
|
||||
{
|
||||
static float scale = 0.5f;
|
||||
float const distanceToGoal = sqrt(distanceToGoalSquared);
|
||||
result = clamp(0.0f, (distanceToGoal / slowDownDistance) * scale, 1.0f);
|
||||
|
||||
if ( (result < 0.5f)
|
||||
if ((result < 0.5f)
|
||||
&& (distanceToGoal < getGoalStopDistance()))
|
||||
{
|
||||
result = 0.0f;
|
||||
@@ -1397,7 +1397,7 @@ float AiShipController::getPilotAggression() const
|
||||
*/
|
||||
void AiShipController::switchToFighterAttack()
|
||||
{
|
||||
DEBUG_FATAL(dynamic_cast<AiShipBehaviorAttackFighter*>(m_attackBehavior),("Programmer bug: called switchToFighterAttack() when already using a fighter attack"));
|
||||
DEBUG_FATAL(dynamic_cast<AiShipBehaviorAttackFighter*>(m_attackBehavior), ("Programmer bug: called switchToFighterAttack() when already using a fighter attack"));
|
||||
delete m_pendingAttackBehavior; // in case we tried to switch twice
|
||||
m_pendingAttackBehavior = new AiShipBehaviorAttackFighter(*NON_NULL(m_attackBehavior));
|
||||
}
|
||||
@@ -1410,7 +1410,7 @@ void AiShipController::switchToFighterAttack()
|
||||
*/
|
||||
void AiShipController::switchToBomberAttack()
|
||||
{
|
||||
DEBUG_FATAL(dynamic_cast<AiShipBehaviorAttackBomber*>(m_attackBehavior),("Programmer bug: called switchToBomberAttack() when already using a bomber attack"));
|
||||
DEBUG_FATAL(dynamic_cast<AiShipBehaviorAttackBomber*>(m_attackBehavior), ("Programmer bug: called switchToBomberAttack() when already using a bomber attack"));
|
||||
delete m_pendingAttackBehavior; // in case we tried to switch twice
|
||||
m_pendingAttackBehavior = new AiShipBehaviorAttackBomber(*NON_NULL(m_attackBehavior));
|
||||
}
|
||||
@@ -1496,8 +1496,8 @@ void AiShipController::onAttackTargetListEmpty()
|
||||
|
||||
SpaceSquad::SpaceSquadList const & guardedByList = getSquad().getGuardedByList();
|
||||
|
||||
if ( !guardedByList.empty()
|
||||
&& getSquad().isAttackTargetListEmpty())
|
||||
if (!guardedByList.empty()
|
||||
&& getSquad().isAttackTargetListEmpty())
|
||||
{
|
||||
SpaceSquad::SpaceSquadList::const_iterator iterGuardedByList = guardedByList.begin();
|
||||
|
||||
@@ -1561,7 +1561,7 @@ void AiShipController::sendDebugAiToClients(AiDebugString & aiDebugString)
|
||||
//
|
||||
// aiDebugString.addText(guardString, PackedRgb::solidYellow);
|
||||
//}
|
||||
|
||||
|
||||
// Are my engines functional?
|
||||
|
||||
if (!shipOwner->isComponentFunctional(ShipChassisSlotType::SCST_engine))
|
||||
@@ -1651,14 +1651,14 @@ void AiShipController::sendDebugAiToClients(AiDebugString & aiDebugString)
|
||||
aiDebugString.addText(formattedString.sprintf("turret miss(%.0f%% @ %.0f)\n", turretMissChance, turretMissAngleDegrees));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//int ammoCurrent = 0;
|
||||
//int ammoMax = 0;
|
||||
//
|
||||
//for (int chassisSlot = ShipChassisSlotType::SCST_weapon_first; chassisSlot < ShipChassisSlotType::SCST_weapon_last; ++chassisSlot)
|
||||
//{
|
||||
// int const weaponIndex = ShipChassisSlotType::getWeaponIndex(chassisSlot);
|
||||
//
|
||||
//
|
||||
// if (parentShipObject->isMissile(weaponIndex))
|
||||
// {
|
||||
// ammoCurrent += parentShipObject->getWeaponAmmoCurrent(static_cast<int>(chassisSlot));
|
||||
@@ -1687,14 +1687,14 @@ void AiShipController::sendDebugAiToClients(AiDebugString & aiDebugString)
|
||||
// Only send to the client if the objvar is set
|
||||
|
||||
int temp = 0;
|
||||
if ( (characterObject != nullptr)
|
||||
&& characterObject->getObjVars().getItem("ai_debug_string", temp))
|
||||
if ((characterObject != nullptr)
|
||||
&& characterObject->getObjVars().getItem("ai_debug_string", temp))
|
||||
{
|
||||
if (temp > 0)
|
||||
{
|
||||
bool const reliable = true;
|
||||
GenericValueTypeMessage<std::pair<NetworkId, std::string> > message("AiDebugString", std::make_pair(getOwner()->getNetworkId(), finalString));
|
||||
|
||||
|
||||
client->send(message, reliable);
|
||||
}
|
||||
}
|
||||
@@ -1714,7 +1714,7 @@ bool AiShipController::debug_forceFighterAttackManeuver(int const maneuverType)
|
||||
{
|
||||
aiFighterBehavior->debug_forceManeuver(maneuverType);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -1741,11 +1741,11 @@ char const * AiShipController::getAttackOrdersString(AttackOrders const attackOr
|
||||
{
|
||||
switch (attackOrders)
|
||||
{
|
||||
case AO_holdFire: { return "HOLD FIRE"; }
|
||||
case AO_returnFire: { return "RETURN FIRE"; }
|
||||
case AO_attackFreely: { return "ATTACK FREELY"; }
|
||||
case AO_count:
|
||||
default: break;
|
||||
case AO_holdFire: { return "HOLD FIRE"; }
|
||||
case AO_returnFire: { return "RETURN FIRE"; }
|
||||
case AO_attackFreely: { return "ATTACK FREELY"; }
|
||||
case AO_count:
|
||||
default: break;
|
||||
}
|
||||
|
||||
return "INVALID ATTACK ORDER";
|
||||
@@ -1771,8 +1771,8 @@ void AiShipController::addExclusiveAggro(NetworkId const & unit)
|
||||
ServerObject * const unitServerObject = (unitObject != nullptr) ? unitObject->asServerObject() : nullptr;
|
||||
CreatureObject * const unitCreatureObject = (unitServerObject != nullptr) ? unitServerObject->asCreatureObject() : nullptr;
|
||||
|
||||
if ( !unitCreatureObject
|
||||
|| !unitCreatureObject->isPlayerControlled())
|
||||
if (!unitCreatureObject
|
||||
|| !unitCreatureObject->isPlayerControlled())
|
||||
{
|
||||
DEBUG_WARNING(true, ("debug_ai: AiShipController::addExclusiveAggro() owner(%s) ERROR: The unit(%s) must be a player.", getOwner()->getDebugInformation().c_str(), unit.getValueString().c_str()));
|
||||
return;
|
||||
@@ -1922,4 +1922,4 @@ float AiShipController::getTurretMissAngle() const
|
||||
return m_pilotData->m_turretMissAngle;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
@@ -1,5 +1,5 @@
|
||||
// CellController.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -12,7 +12,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CellController::CellController(CellObject * newOwner) :
|
||||
ServerController(newOwner)
|
||||
ServerController(newOwner)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,50 +24,49 @@ CellController::~CellController()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
void CellController::handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags)
|
||||
void CellController::handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags)
|
||||
{
|
||||
CellObject * owner = dynamic_cast<CellObject *>(getOwner());
|
||||
NOT_NULL(owner);
|
||||
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case CM_addAllowed:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if (msg)
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if(msg)
|
||||
{
|
||||
owner->addAllowed(msg->getValue());
|
||||
}
|
||||
owner->addAllowed(msg->getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CM_removeAllowed:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if (msg)
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if(msg)
|
||||
{
|
||||
owner->removeAllowed(msg->getValue());
|
||||
}
|
||||
owner->removeAllowed(msg->getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CM_addBanned:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if (msg)
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if(msg)
|
||||
{
|
||||
owner->addBanned(msg->getValue());
|
||||
}
|
||||
owner->addBanned(msg->getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CM_removeBanned:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if (msg)
|
||||
{
|
||||
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
|
||||
if(msg)
|
||||
{
|
||||
owner->removeBanned(msg->getValue());
|
||||
}
|
||||
owner->removeBanned(msg->getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ServerController::handleMessage(message, value, data, flags);
|
||||
break;
|
||||
@@ -76,9 +75,9 @@ void CellController::handleMessage (int message, float value, const MessageQueue
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CellController::setGoal(Transform const & , ServerObject * )
|
||||
void CellController::setGoal(Transform const &, ServerObject *, bool teleport = false)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Cell setGoal was called for CellObject %s. Cells may not have goals!",getOwner()->getNetworkId().getValueString().c_str()));
|
||||
DEBUG_WARNING(true, ("Cell setGoal was called for CellObject %s. Cells may not have goals!", getOwner()->getNetworkId().getValueString().c_str()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -1,5 +1,5 @@
|
||||
// CellController.h
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_CellController_H
|
||||
@@ -20,13 +20,12 @@ public:
|
||||
~CellController();
|
||||
|
||||
protected:
|
||||
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
|
||||
virtual void setGoal (Transform const & newGoal, ServerObject * goalCellObject );
|
||||
|
||||
virtual void handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags);
|
||||
virtual void setGoal(Transform const & newGoal, ServerObject * goalCellObject, bool teleport);
|
||||
|
||||
private:
|
||||
CellController & operator = (const CellController & rhs);
|
||||
CellController(const CellController & source);
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,7 +45,6 @@
|
||||
|
||||
namespace ServerBuildoutManagerNamespace
|
||||
{
|
||||
|
||||
const int cs_buildingObjIdOffset = 2000;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -80,23 +79,21 @@ namespace ServerBuildoutManagerNamespace
|
||||
|
||||
struct ServerEventAreaInfo
|
||||
{
|
||||
ServerEventAreaInfo():
|
||||
buildOut(nullptr),
|
||||
loadedObject(nullptr)
|
||||
ServerEventAreaInfo() :
|
||||
buildOut(nullptr),
|
||||
loadedObject(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
ServerEventAreaInfo(BuildoutRow const * _buildOut, ServerObject* _loadedObject):
|
||||
buildOut(_buildOut),
|
||||
loadedObject(_loadedObject)
|
||||
ServerEventAreaInfo(BuildoutRow const * _buildOut, ServerObject* _loadedObject) :
|
||||
buildOut(_buildOut),
|
||||
loadedObject(_loadedObject)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BuildoutRow const * buildOut;
|
||||
ServerObject* loadedObject;
|
||||
};
|
||||
|
||||
|
||||
typedef std::map< std::string, std::list< ServerEventAreaInfo > > ServerEventMap;
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -120,7 +117,6 @@ namespace ServerBuildoutManagerNamespace
|
||||
#else
|
||||
const int64 cs_dataBitStripMask = 0x80000000ffffffffLL;
|
||||
#endif
|
||||
|
||||
}
|
||||
using namespace ServerBuildoutManagerNamespace;
|
||||
|
||||
@@ -152,10 +148,10 @@ void ServerBuildoutManager::onChunkComplete(int nodeX, int nodeZ)
|
||||
for (std::vector<AreaInfo>::iterator i = s_areas.begin(); i != s_areas.end(); ++i)
|
||||
{
|
||||
AreaInfo &areaInfo = *i;
|
||||
if ( nodeX < areaInfo.buildoutArea.rect.x1
|
||||
&& nodeX+100 > areaInfo.buildoutArea.rect.x0
|
||||
&& nodeZ < areaInfo.buildoutArea.rect.y1
|
||||
&& nodeZ+100 > areaInfo.buildoutArea.rect.y0)
|
||||
if (nodeX < areaInfo.buildoutArea.rect.x1
|
||||
&& nodeX + 100 > areaInfo.buildoutArea.rect.x0
|
||||
&& nodeZ < areaInfo.buildoutArea.rect.y1
|
||||
&& nodeZ + 100 > areaInfo.buildoutArea.rect.y0)
|
||||
{
|
||||
if (!areaInfo.loaded)
|
||||
loadArea(areaInfo);
|
||||
@@ -168,7 +164,7 @@ void ServerBuildoutManager::onChunkComplete(int nodeX, int nodeZ)
|
||||
|
||||
void ServerBuildoutManager::saveArea(std::string const &serverFileName, std::string const &clientFileName, float x1, float z1, float x2, float z2)
|
||||
{
|
||||
FATAL( true, ( "ServerBuildoutManager::saveArea\n" ) );
|
||||
FATAL(true, ("ServerBuildoutManager::saveArea\n"));
|
||||
|
||||
if (!ConfigServerGame::getBuildoutAreaEditingEnabled())
|
||||
{
|
||||
@@ -214,12 +210,12 @@ void ServerBuildoutManager::saveArea(std::string const &serverFileName, std::str
|
||||
{
|
||||
ConstCharCrcString const &serverTemplateName = ObjectTemplateList::lookUp((*i).serverTemplateCrc);
|
||||
char buf[512];
|
||||
IGNORE_RETURN(snprintf(buf, sizeof(buf)-1, "%s\t%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t",
|
||||
IGNORE_RETURN(snprintf(buf, sizeof(buf) - 1, "%s\t%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t",
|
||||
serverTemplateName.getString(),
|
||||
(*i).cellIndex,
|
||||
(*i).position.x, (*i).position.y, (*i).position.z,
|
||||
(*i).orientation.w, (*i).orientation.x, (*i).orientation.y, (*i).orientation.z));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
serverOutputFile.write(strlen(buf), buf);
|
||||
serverOutputFile.write((*i).scripts.length(), (*i).scripts.c_str());
|
||||
serverOutputFile.write(1, "\t");
|
||||
@@ -234,14 +230,14 @@ void ServerBuildoutManager::saveArea(std::string const &serverFileName, std::str
|
||||
{
|
||||
ConstCharCrcString const &sharedTemplateName = ObjectTemplateList::lookUp((*i).sharedTemplateCrc);
|
||||
char buf[512];
|
||||
IGNORE_RETURN(snprintf(buf, sizeof(buf)-1, "%s\t%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%d\n",
|
||||
IGNORE_RETURN(snprintf(buf, sizeof(buf) - 1, "%s\t%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%d\n",
|
||||
sharedTemplateName.getString(),
|
||||
(*i).cellIndex,
|
||||
(*i).position.x, (*i).position.y, (*i).position.z,
|
||||
(*i).orientation.w, (*i).orientation.x, (*i).orientation.y, (*i).orientation.z,
|
||||
(*i).radius,
|
||||
static_cast<int>((*i).portalLayoutCrc)));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
clientOutputFile.write(strlen(buf), buf);
|
||||
}
|
||||
}
|
||||
@@ -262,14 +258,13 @@ void ServerBuildoutManager::clientSaveArea(Client &client, std::string const &ar
|
||||
std::vector<ClientBuildoutAreaRow> clientRows;
|
||||
generateBuildoutData(x1, z1, x2, z2, serverRows, clientRows);
|
||||
|
||||
|
||||
// pass them to the client
|
||||
GenericValueTypeMessage<
|
||||
std::pair<
|
||||
std::pair<std::string, std::string>, // scene, area
|
||||
std::pair<std::vector<ServerBuildoutAreaRow>, std::vector<ClientBuildoutAreaRow> > // serverRows, clientRows
|
||||
>
|
||||
> const message(
|
||||
std::pair<std::string, std::string>, // scene, area
|
||||
std::pair<std::vector<ServerBuildoutAreaRow>, std::vector<ClientBuildoutAreaRow> > // serverRows, clientRows
|
||||
>
|
||||
> const message(
|
||||
"GodClientSaveBuildoutArea",
|
||||
std::make_pair(
|
||||
std::make_pair(std::string(ConfigServerGame::getSceneID()), areaName),
|
||||
@@ -317,12 +312,12 @@ void ServerBuildoutManager::destroyPersistedDuplicates()
|
||||
for (std::vector<ServerObject *>::const_iterator k = objectsToTest.begin(); k != objectsToTest.end(); ++k)
|
||||
{
|
||||
ServerObject * const so = *k;
|
||||
if ( so
|
||||
&& so->getNetworkId().getValue() != buildoutRow.m_id
|
||||
&& so->isPersisted()
|
||||
&& so->getTemplateCrc() == buildoutRow.m_serverTemplate->getCrcName().getCrc()
|
||||
&& so->getPosition_p().magnitudeBetweenSquared(buildoutRow.m_transform_p.getPosition_p()) < 0.005f
|
||||
&& ContainerInterface::getContainedByObject(*so) == container)
|
||||
if (so
|
||||
&& so->getNetworkId().getValue() != buildoutRow.m_id
|
||||
&& so->isPersisted()
|
||||
&& so->getTemplateCrc() == buildoutRow.m_serverTemplate->getCrcName().getCrc()
|
||||
&& so->getPosition_p().magnitudeBetweenSquared(buildoutRow.m_transform_p.getPosition_p()) < 0.005f
|
||||
&& ContainerInterface::getContainedByObject(*so) == container)
|
||||
so->permanentlyDestroy(DeleteReasons::Replaced);
|
||||
}
|
||||
}
|
||||
@@ -377,12 +372,12 @@ void ServerBuildoutManagerNamespace::remove()
|
||||
|
||||
void ServerBuildoutManagerNamespace::generateBuildoutData(float x1, float z1, float x2, float z2, std::vector<ServerBuildoutAreaRow> &serverRows, std::vector<ClientBuildoutAreaRow> &clientRows)
|
||||
{
|
||||
// int objIdBase = -1;
|
||||
// int objIdBase = -1;
|
||||
|
||||
typedef std::map<NetworkId::NetworkIdType,int> ObjIdMap;
|
||||
typedef std::map<NetworkId::NetworkIdType, int> ObjIdMap;
|
||||
|
||||
ObjIdMap objIdMap;
|
||||
|
||||
|
||||
std::vector<ServerObject const *> objectsToSave;
|
||||
|
||||
// build vector of objects we need to save, in the appropriate order
|
||||
@@ -408,9 +403,8 @@ void ServerBuildoutManagerNamespace::generateBuildoutData(float x1, float z1, fl
|
||||
{
|
||||
ServerObject const * const obj = *i;
|
||||
|
||||
|
||||
// check for unexported gold data
|
||||
if ( obj->getIncludeInBuildout() == false && obj->getNetworkId().getValue() < 10000000 )
|
||||
if (obj->getIncludeInBuildout() == false && obj->getNetworkId().getValue() < 10000000)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -428,7 +422,6 @@ void ServerBuildoutManagerNamespace::generateBuildoutData(float x1, float z1, fl
|
||||
serverOnly = false;
|
||||
}
|
||||
|
||||
|
||||
Quaternion const q(obj->getTransform_o2p());
|
||||
Vector p(obj->getPosition_p());
|
||||
int cellIndex = 0;
|
||||
@@ -461,30 +454,29 @@ void ServerBuildoutManagerNamespace::generateBuildoutData(float x1, float z1, fl
|
||||
serverRows.push_back(ServerBuildoutAreaRow());
|
||||
ServerBuildoutAreaRow &serverRow = serverRows.back();
|
||||
|
||||
serverRow.id = static_cast< int >( obj->getNetworkId().getValue() );
|
||||
serverRow.container = containingObject ? static_cast< int >( containingObject->getNetworkId().getValue() ) : 0;
|
||||
serverRow.id = static_cast<int>(obj->getNetworkId().getValue());
|
||||
serverRow.container = containingObject ? static_cast<int>(containingObject->getNetworkId().getValue()) : 0;
|
||||
serverRow.serverTemplateCrc = obj->getTemplateCrc();
|
||||
serverRow.cellIndex = cellIndex;
|
||||
serverRow.position = p;
|
||||
serverRow.orientation = q;
|
||||
serverRow.scripts = packedScriptList;
|
||||
serverRow.objvars = obj->getPackedObjVars(std::string());
|
||||
serverRow.cellIndex = cellIndex;
|
||||
serverRow.position = p;
|
||||
serverRow.orientation = q;
|
||||
serverRow.scripts = packedScriptList;
|
||||
serverRow.objvars = obj->getPackedObjVars(std::string());
|
||||
|
||||
|
||||
if ( serverRow.id >= 10000000 )
|
||||
if (serverRow.id >= 10000000)
|
||||
{
|
||||
serverRow.id = Random::random() | 0x80000000; // generate a negative random number.
|
||||
objIdMap[ obj->getNetworkId().getValue() ] = serverRow.id;
|
||||
objIdMap[obj->getNetworkId().getValue()] = serverRow.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
serverRow.id &= cs_dataBitStripMask; // strip data bits
|
||||
}
|
||||
|
||||
if ( serverRow.container >= 10000000 )
|
||||
if (serverRow.container >= 10000000)
|
||||
{
|
||||
ObjIdMap::const_iterator it = objIdMap.find( serverRow.container );
|
||||
FATAL( it == objIdMap.end(), ( "Unable to find the container relative objid for object %d\n", serverRow.id ) );
|
||||
ObjIdMap::const_iterator it = objIdMap.find(serverRow.container);
|
||||
FATAL(it == objIdMap.end(), ("Unable to find the container relative objid for object %d\n", serverRow.id));
|
||||
serverRow.container = it->second;
|
||||
}
|
||||
else
|
||||
@@ -497,17 +489,17 @@ void ServerBuildoutManagerNamespace::generateBuildoutData(float x1, float z1, fl
|
||||
clientRows.push_back(ClientBuildoutAreaRow());
|
||||
ClientBuildoutAreaRow &clientRow = clientRows.back();
|
||||
|
||||
clientRow.id = serverRow.id;
|
||||
clientRow.container = serverRow.container;
|
||||
clientRow.type = serverTemplate ? serverTemplate->getId() : 0;
|
||||
clientRow.id = serverRow.id;
|
||||
clientRow.container = serverRow.container;
|
||||
clientRow.type = serverTemplate ? serverTemplate->getId() : 0;
|
||||
clientRow.sharedTemplateCrc = ConstCharCrcString(obj->getSharedTemplateName()).getCrc();
|
||||
clientRow.cellIndex = cellIndex;
|
||||
clientRow.position = p;
|
||||
clientRow.orientation = q;
|
||||
clientRow.radius = serverTemplate->getUpdateRanges(ServerObjectTemplate::UR_far);
|
||||
clientRow.cellIndex = cellIndex;
|
||||
clientRow.position = p;
|
||||
clientRow.orientation = q;
|
||||
clientRow.radius = serverTemplate->getUpdateRanges(ServerObjectTemplate::UR_far);
|
||||
int portalLayoutCrc = 0;
|
||||
obj->getObjVars().getItem("portalProperty.crc", portalLayoutCrc);
|
||||
clientRow.portalLayoutCrc = static_cast<uint32>(portalLayoutCrc);
|
||||
clientRow.portalLayoutCrc = static_cast<uint32>(portalLayoutCrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -549,49 +541,50 @@ void ServerBuildoutManagerNamespace::buildObjectsToSave(std::vector<ServerObject
|
||||
|
||||
bool ServerBuildoutManagerNamespace::isNotObjectForBuildout(ServerObject const *obj)
|
||||
{
|
||||
const ServerObject * const containingObject = safe_cast<const ServerObject *>(ContainerInterface::getContainedByObject(*obj));
|
||||
|
||||
// make sure that cells that should be included in the buildout have all their
|
||||
// children included too!
|
||||
if ( obj->getObjectTemplate()->getId() == ServerCellObjectTemplate::ServerCellObjectTemplate_tag && containingObject && containingObject->getIncludeInBuildout() )
|
||||
if (obj)
|
||||
{
|
||||
ServerObject *tmpObj = const_cast< ServerObject * >( obj );
|
||||
tmpObj->setIncludeInBuildout( true );
|
||||
}
|
||||
const ServerObject * const containingObject = safe_cast<const ServerObject *>(ContainerInterface::getContainedByObject(*obj));
|
||||
|
||||
if ( !obj || !obj->isInWorld() || (!obj->isPersisted() && !obj->getIncludeInBuildout() ) || obj->isPlayerControlled() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// make sure that cells that should be included in the buildout have all their
|
||||
// children included too!
|
||||
if (obj->getObjectTemplate()->getId() == ServerCellObjectTemplate::ServerCellObjectTemplate_tag && containingObject && containingObject->getIncludeInBuildout())
|
||||
{
|
||||
ServerObject *tmpObj = const_cast<ServerObject *>(obj);
|
||||
tmpObj->setIncludeInBuildout(true);
|
||||
}
|
||||
|
||||
if (!obj || !obj->isInWorld() || (!obj->isPersisted() && !obj->getIncludeInBuildout()) || obj->isPlayerControlled())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
{
|
||||
int64 buildingObjId = areaInfo.buildoutArea.getSharedBaseId();
|
||||
int64 objIdBase = buildingObjId + cs_buildingObjIdOffset;
|
||||
int64 currentBuilding = 0;
|
||||
int64 currentCell = 0;
|
||||
int64 buildingObjId = areaInfo.buildoutArea.getSharedBaseId();
|
||||
int64 objIdBase = buildingObjId + cs_buildingObjIdOffset;
|
||||
int64 currentBuilding = 0;
|
||||
int64 currentCell = 0;
|
||||
|
||||
int serverIdBase = areaInfo.buildoutArea.getServerBaseId();
|
||||
int serverIdBase = areaInfo.buildoutArea.getServerBaseId();
|
||||
|
||||
const bool isBuildoutEditingEnabled = ConfigServerGame::getBuildoutAreaEditingEnabled();
|
||||
UNREF( isBuildoutEditingEnabled );
|
||||
UNREF(isBuildoutEditingEnabled);
|
||||
|
||||
char filename[256];
|
||||
snprintf(filename, sizeof(filename)-1, "datatables/buildout/%s/%s.iff", ConfigServerGame::getSceneID(), areaInfo.buildoutArea.areaName.c_str());
|
||||
filename[sizeof(filename)-1] = '\0';
|
||||
snprintf(filename, sizeof(filename) - 1, "datatables/buildout/%s/%s.iff", ConfigServerGame::getSceneID(), areaInfo.buildoutArea.areaName.c_str());
|
||||
filename[sizeof(filename) - 1] = '\0';
|
||||
|
||||
std::string const & eventRequired = areaInfo.buildoutArea.getRequiredEventName();
|
||||
|
||||
if(!eventRequired.empty())
|
||||
if (!eventRequired.empty())
|
||||
{
|
||||
ServerEventMap::iterator iter = s_eventObjects.find(eventRequired);
|
||||
if(iter != s_eventObjects.end())
|
||||
if (iter != s_eventObjects.end())
|
||||
{
|
||||
// Nothing to do here. We've already setup a list for this event.
|
||||
//eventObjList = &(*iter).second;
|
||||
@@ -600,11 +593,10 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
{
|
||||
s_eventObjects.insert(std::pair<std::string, std::list<ServerEventAreaInfo> >(eventRequired, std::list<ServerEventAreaInfo>()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Iff iff;
|
||||
if (!areaInfo.buildoutArea.areaName.empty() && iff.open(filename, true) && !iff.atEndOfForm() )
|
||||
if (!areaInfo.buildoutArea.areaName.empty() && iff.open(filename, true) && !iff.atEndOfForm())
|
||||
{
|
||||
DataTable areaBuildoutTable;
|
||||
areaBuildoutTable.load(iff);
|
||||
@@ -614,19 +606,19 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
{
|
||||
areaInfo.buildoutRows.reserve(buildoutRowCount);
|
||||
|
||||
int const objIdColumn = areaBuildoutTable.findColumnNumber( "objid" );
|
||||
int const containerColumn = areaBuildoutTable.findColumnNumber( "container" );
|
||||
int const objIdColumn = areaBuildoutTable.findColumnNumber("objid");
|
||||
int const containerColumn = areaBuildoutTable.findColumnNumber("container");
|
||||
int const serverTemplateCrcColumn = areaBuildoutTable.findColumnNumber("server_template_crc");
|
||||
int const cellIndexColumn = areaBuildoutTable.findColumnNumber("cell_index");
|
||||
int const pxColumn = areaBuildoutTable.findColumnNumber("px");
|
||||
int const pyColumn = areaBuildoutTable.findColumnNumber("py");
|
||||
int const pzColumn = areaBuildoutTable.findColumnNumber("pz");
|
||||
int const qwColumn = areaBuildoutTable.findColumnNumber("qw");
|
||||
int const qxColumn = areaBuildoutTable.findColumnNumber("qx");
|
||||
int const qyColumn = areaBuildoutTable.findColumnNumber("qy");
|
||||
int const qzColumn = areaBuildoutTable.findColumnNumber("qz");
|
||||
int const scriptsColumn = areaBuildoutTable.findColumnNumber("scripts");
|
||||
int const objvarsColumn = areaBuildoutTable.findColumnNumber("objvars");
|
||||
int const cellIndexColumn = areaBuildoutTable.findColumnNumber("cell_index");
|
||||
int const pxColumn = areaBuildoutTable.findColumnNumber("px");
|
||||
int const pyColumn = areaBuildoutTable.findColumnNumber("py");
|
||||
int const pzColumn = areaBuildoutTable.findColumnNumber("pz");
|
||||
int const qwColumn = areaBuildoutTable.findColumnNumber("qw");
|
||||
int const qxColumn = areaBuildoutTable.findColumnNumber("qx");
|
||||
int const qyColumn = areaBuildoutTable.findColumnNumber("qy");
|
||||
int const qzColumn = areaBuildoutTable.findColumnNumber("qz");
|
||||
int const scriptsColumn = areaBuildoutTable.findColumnNumber("scripts");
|
||||
int const objvarsColumn = areaBuildoutTable.findColumnNumber("objvars");
|
||||
|
||||
FATAL(serverTemplateCrcColumn < 0, ("Unable to find serverTemplateCrcColumn in [%s]", filename));
|
||||
FATAL(cellIndexColumn < 0, ("Unable to find cellIndexColumn in [%s]", filename));
|
||||
@@ -642,20 +634,18 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
|
||||
int buildOutFileVersion = 1;
|
||||
|
||||
if ( objIdColumn != -1 )
|
||||
if (objIdColumn != -1)
|
||||
{
|
||||
buildOutFileVersion = 2;
|
||||
}
|
||||
|
||||
|
||||
std::set< int64 > objects;
|
||||
|
||||
for (int buildoutRow = 0; buildoutRow < buildoutRowCount; ++buildoutRow)
|
||||
{
|
||||
|
||||
int64 objId = 0;
|
||||
int64 objId = 0;
|
||||
int64 containerId = 0;
|
||||
|
||||
|
||||
uint32 const serverTemplateCrc = static_cast<uint32>(areaBuildoutTable.getIntValue(serverTemplateCrcColumn, buildoutRow));
|
||||
unsigned int const cellIndex = areaBuildoutTable.getIntValue(cellIndexColumn, buildoutRow);
|
||||
|
||||
@@ -673,7 +663,7 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
FATAL(!sharedTemplate, ("Bad shared template [%s] for [%s] in buildout table %s, row %d (line %d)", sharedTemplateName.c_str(), serverTemplateBase->getName(), areaInfo.buildoutArea.areaName.c_str(), buildoutRow, buildoutRow + 3));
|
||||
bool const isPob = !sharedTemplate->getPortalLayoutFilename().empty();
|
||||
sharedTemplateBase->releaseReference();
|
||||
|
||||
|
||||
bool serverOnly = false;
|
||||
if (!isPob && dynamic_cast<ServerTangibleObjectTemplate const *>(serverTemplate))
|
||||
{
|
||||
@@ -684,26 +674,25 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
serverOnly = false;
|
||||
}
|
||||
|
||||
|
||||
if ( buildOutFileVersion == 1 )
|
||||
if (buildOutFileVersion == 1)
|
||||
{
|
||||
if ( isPob ) // if ( is a building )
|
||||
if (isPob) // if ( is a building )
|
||||
{
|
||||
objId = buildingObjId++;
|
||||
currentBuilding = objId;
|
||||
}
|
||||
else if ( serverTemplate->getId() == ServerCellObjectTemplate::ServerCellObjectTemplate_tag ) // if ( is a cell )
|
||||
else if (serverTemplate->getId() == ServerCellObjectTemplate::ServerCellObjectTemplate_tag) // if ( is a cell )
|
||||
{
|
||||
objId = buildingObjId++;
|
||||
currentCell = objId;
|
||||
containerId = currentBuilding;
|
||||
}
|
||||
else if ( cellIndex > 0 ) // if ( is an object in a cell )
|
||||
else if (cellIndex > 0) // if ( is an object in a cell )
|
||||
{
|
||||
objId = objIdBase++;
|
||||
containerId = currentCell;
|
||||
}
|
||||
else if ( serverOnly )
|
||||
else if (serverOnly)
|
||||
{
|
||||
objId = serverIdBase++;
|
||||
}
|
||||
@@ -712,34 +701,32 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
objId = objIdBase++;
|
||||
}
|
||||
|
||||
FATAL( buildingObjId >= areaInfo.buildoutArea.getSharedBaseId() + cs_buildingObjIdOffset, ( "building object id overflow" ) );
|
||||
FATAL(buildingObjId >= areaInfo.buildoutArea.getSharedBaseId() + cs_buildingObjIdOffset, ("building object id overflow"));
|
||||
}
|
||||
else
|
||||
{
|
||||
objId = areaBuildoutTable.getIntValue(objIdColumn, buildoutRow);
|
||||
objId = areaBuildoutTable.getIntValue(objIdColumn, buildoutRow);
|
||||
containerId = areaBuildoutTable.getIntValue(containerColumn, buildoutRow);
|
||||
|
||||
|
||||
// with new buildout files, the object id is a random 31-bit negative value
|
||||
// then we give the area index some bits in the upper part of the number
|
||||
// by shifting the area index value left 48 bits.
|
||||
|
||||
const int64 areaIndex = areaInfo.buildoutArea.areaIndex + 1;
|
||||
|
||||
if ( objId < 0 )
|
||||
if (objId < 0)
|
||||
{
|
||||
|
||||
objId ^= areaIndex << 48;
|
||||
}
|
||||
|
||||
if ( containerId < 0 )
|
||||
if (containerId < 0)
|
||||
{
|
||||
containerId ^= areaIndex << 48;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FATAL( isPob && ( cellIndex != 0 || containerId != 0 ), ( "tried to add a pob to a cell or other container. %s (objId=%d cellIndex=%d containerId=%d)",
|
||||
serverTemplateBase->getName(), objId, cellIndex,containerId ) );
|
||||
FATAL(isPob && (cellIndex != 0 || containerId != 0), ("tried to add a pob to a cell or other container. %s (objId=%d cellIndex=%d containerId=%d)",
|
||||
serverTemplateBase->getName(), objId, cellIndex, containerId));
|
||||
|
||||
Quaternion const q(
|
||||
areaBuildoutTable.getFloatValue(qwColumn, buildoutRow),
|
||||
@@ -751,7 +738,7 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
|
||||
q.getTransform(&transform_p);
|
||||
|
||||
if ( cellIndex == 0 )
|
||||
if (cellIndex == 0)
|
||||
{
|
||||
transform_p.setPosition_p(
|
||||
areaBuildoutTable.getFloatValue(pxColumn, buildoutRow) + areaInfo.buildoutArea.rect.x0,
|
||||
@@ -766,7 +753,7 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
areaBuildoutTable.getFloatValue(pzColumn, buildoutRow));
|
||||
}
|
||||
|
||||
if ( containerId == 0 || objects.find ( containerId ) != objects.end() )
|
||||
if (containerId == 0 || objects.find(containerId) != objects.end())
|
||||
{
|
||||
areaInfo.buildoutRows.push_back(
|
||||
BuildoutRow(
|
||||
@@ -780,7 +767,7 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
eventRequired));
|
||||
}
|
||||
|
||||
objects.insert( objId );
|
||||
objects.insert(objId);
|
||||
|
||||
serverTemplateBase->releaseReference();
|
||||
}
|
||||
@@ -810,13 +797,12 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
UNREF(nodeZ);
|
||||
UNREF(nodeX);
|
||||
|
||||
|
||||
std::vector<ServerObject *> newObjects;
|
||||
int buildingId = 0;
|
||||
int cellIndex = 0;
|
||||
UNREF(cellIndex);
|
||||
|
||||
UNREF( buildingId );
|
||||
UNREF(buildingId);
|
||||
|
||||
NetworkId controllerObjectId;
|
||||
|
||||
@@ -824,8 +810,8 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
|
||||
PlanetObject * const planetObject = ServerUniverse::getInstance().getTatooinePlanet();
|
||||
std::vector<std::string> events;
|
||||
|
||||
if(planetObject)
|
||||
|
||||
if (planetObject)
|
||||
planetObject->parseCurrentEventsList(events);
|
||||
|
||||
for (std::vector<BuildoutRow>::const_iterator rowIter = areaInfo.buildoutRows.begin(); rowIter != areaInfo.buildoutRows.end(); ++rowIter)
|
||||
@@ -836,7 +822,7 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
|
||||
int64 const containerId = buildoutRow.m_containerId;
|
||||
|
||||
if ( containerId && discardContainedObjects )
|
||||
if (containerId && discardContainedObjects)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -860,21 +846,21 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
}
|
||||
|
||||
// reject object if it is out of bounds and is not the controller
|
||||
if ( !containerId && objectId != controllerObjectId )
|
||||
if (!containerId && objectId != controllerObjectId)
|
||||
{
|
||||
const Vector &position_w = buildoutRow.m_transform_p.getPosition_p();
|
||||
|
||||
if ( position_w.x < nodeX || position_w.x >= nodeX+100 || position_w.z < nodeZ || position_w.z >= nodeZ+100 )
|
||||
if (position_w.x < nodeX || position_w.x >= nodeX + 100 || position_w.z < nodeZ || position_w.z >= nodeZ + 100)
|
||||
{
|
||||
discardContainedObjects = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!buildoutRow.m_eventRequired.empty())
|
||||
if (!buildoutRow.m_eventRequired.empty())
|
||||
{
|
||||
ServerEventMap::iterator searchIter = s_eventObjects.find(buildoutRow.m_eventRequired);
|
||||
if(searchIter != s_eventObjects.end())
|
||||
if (searchIter != s_eventObjects.end())
|
||||
{
|
||||
ServerEventAreaInfo newEventObj(&buildoutRow, nullptr);
|
||||
(*searchIter).second.push_back(newEventObj);
|
||||
@@ -883,28 +869,27 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("ServerBuildoutManager: Tried to load an unknown event object. Event name: %s\n", buildoutRow.m_eventRequired.c_str()));
|
||||
}
|
||||
|
||||
if(planetObject) // We have a valid Tatooine Planet Object which keeps track of our universe wide events.
|
||||
|
||||
if (planetObject) // We have a valid Tatooine Planet Object which keeps track of our universe wide events.
|
||||
{
|
||||
bool eventCurrentlyRunning = false;
|
||||
|
||||
|
||||
std::vector<std::string>::size_type i = 0;
|
||||
for(; i < events.size(); ++i)
|
||||
for (; i < events.size(); ++i)
|
||||
{
|
||||
if(events[i] == buildoutRow.m_eventRequired) // Is our required event already running?
|
||||
if (events[i] == buildoutRow.m_eventRequired) // Is our required event already running?
|
||||
eventCurrentlyRunning = true;
|
||||
}
|
||||
|
||||
if(!eventCurrentlyRunning)
|
||||
if (!eventCurrentlyRunning)
|
||||
continue; // We found an event object but their event isn't started yet. Hold off on Object creation.
|
||||
}
|
||||
else
|
||||
continue; // No planet object. This should NEVER happen. Better hold off on any event object creation for now.
|
||||
|
||||
}
|
||||
|
||||
|
||||
ServerObject * const containingObject = containerId ? safe_cast<ServerObject *>(NetworkIdManager::getObjectById(NetworkId(static_cast<NetworkId::NetworkIdType>(containerId)))) : 0;
|
||||
FATAL(containerId && !containingObject, ("could not find containing object obj=%d container=%d", (int)objectId.getValue(), containerId ));
|
||||
FATAL(containerId && !containingObject, ("could not find containing object obj=%d container=%d", (int)objectId.getValue(), containerId));
|
||||
|
||||
//-- object has already been created
|
||||
//-- this must be the controller object or one of its contents.
|
||||
@@ -921,7 +906,7 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
|
||||
if (newCellObject)
|
||||
{
|
||||
newCellObject->setCell( buildoutRow.m_cellIndex );
|
||||
newCellObject->setCell(buildoutRow.m_cellIndex);
|
||||
}
|
||||
|
||||
if (!newObject->getController())
|
||||
@@ -940,15 +925,15 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
// to client-cache any objects otherwise we will not be able to
|
||||
// move them around or delete them, etc.
|
||||
//
|
||||
|
||||
|
||||
const bool isEditing = ConfigServerGame::getBuildoutAreaEditingEnabled();
|
||||
|
||||
if ( isEditing == false )
|
||||
|
||||
if (isEditing == false)
|
||||
{
|
||||
//
|
||||
// cells and their parents should NOT BE CLIENT CACHED
|
||||
//
|
||||
if ( newObject->asCellObject() )
|
||||
if (newObject->asCellObject())
|
||||
{
|
||||
// by the time we get here the cache version on the POB has
|
||||
// already been set to non-zero, so we need to reset it back
|
||||
@@ -970,12 +955,12 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
// them in god mode!!!
|
||||
//
|
||||
const int vfCount = buildoutRow.m_serverTemplate->getVisibleFlagsCount();
|
||||
|
||||
for ( int index = 0; index < vfCount ; ++index )
|
||||
|
||||
for (int index = 0; index < vfCount; ++index)
|
||||
{
|
||||
const ServerObjectTemplate::VisibleFlags vf = buildoutRow.m_serverTemplate->getVisibleFlags( index );
|
||||
|
||||
if ( vf == ServerObjectTemplate::VF_player && buildoutRow.m_eventRequired.empty()) // Event objects can never be client cached currently.
|
||||
const ServerObjectTemplate::VisibleFlags vf = buildoutRow.m_serverTemplate->getVisibleFlags(index);
|
||||
|
||||
if (vf == ServerObjectTemplate::VF_player && buildoutRow.m_eventRequired.empty()) // Event objects can never be client cached currently.
|
||||
{
|
||||
newObject->setCacheVersion(s_buildoutCacheVersion);
|
||||
break;
|
||||
@@ -983,8 +968,7 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (buildoutRow.m_transform_p != Transform::identity)
|
||||
{
|
||||
newObject->setTransform_o2p(buildoutRow.m_transform_p);
|
||||
@@ -1005,7 +989,7 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
{
|
||||
newObject->setPackedObjVars(buildoutRow.m_objvars);
|
||||
}
|
||||
|
||||
|
||||
int const count = buildoutRow.m_serverTemplate->getScriptsCount();
|
||||
|
||||
for (int j = 0; j < count; ++j)
|
||||
@@ -1027,7 +1011,7 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
while (scripts[pos] && scripts[pos] != ':')
|
||||
++pos;
|
||||
|
||||
std::string const & scriptName = scripts.substr(oldPos, pos-oldPos);
|
||||
std::string const & scriptName = scripts.substr(oldPos, pos - oldPos);
|
||||
if (!gso->hasScript(scriptName))
|
||||
IGNORE_RETURN(gso->attachScript(scriptName, false));
|
||||
|
||||
@@ -1038,10 +1022,10 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
}
|
||||
newObjects.push_back(newObject);
|
||||
|
||||
if(!buildoutRow.m_eventRequired.empty())
|
||||
if (!buildoutRow.m_eventRequired.empty())
|
||||
{
|
||||
ServerEventMap::iterator searchIter = s_eventObjects.find(buildoutRow.m_eventRequired);
|
||||
if(searchIter != s_eventObjects.end())
|
||||
if (searchIter != s_eventObjects.end())
|
||||
{
|
||||
ServerEventAreaInfo & newEventObj = (*searchIter).second.back();
|
||||
newEventObj.loadedObject = newObject;
|
||||
@@ -1058,7 +1042,7 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
}
|
||||
|
||||
// run through newly instantiated objects and notify the controller object
|
||||
if ( controllerObjectId.isValid() )
|
||||
if (controllerObjectId.isValid())
|
||||
{
|
||||
ServerObject * const controllerObject = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(controllerObjectId));
|
||||
if (nullptr != controllerObject)
|
||||
@@ -1070,12 +1054,12 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
ServerObject * const obj = *it;
|
||||
if (obj == controllerObject)
|
||||
continue;
|
||||
|
||||
|
||||
int registerWithController = 0;
|
||||
if (obj->getObjVars().getItem("registerWithController", registerWithController))
|
||||
{
|
||||
if (registerWithController)
|
||||
{
|
||||
{
|
||||
if (nullptr != script)
|
||||
{
|
||||
ScriptParams p;
|
||||
@@ -1090,36 +1074,33 @@ void ServerBuildoutManagerNamespace::instantiateAreaNode(AreaInfo const &areaInf
|
||||
|
||||
// initialize any theaters
|
||||
{
|
||||
|
||||
for (std::vector<ServerObject *>::reverse_iterator it = newObjects.rbegin(); it != newObjects.rend(); ++it)
|
||||
{
|
||||
ServerObject *obj = *it;
|
||||
|
||||
if ( obj && obj->isAuthoritative() )
|
||||
if (obj && obj->isAuthoritative())
|
||||
{
|
||||
GameScriptObject *scripts = obj->getScriptObject();
|
||||
|
||||
if ( scripts ) //&& scripts->hasScript( "poi.template.scene.base.base_theater" ) )
|
||||
|
||||
if (scripts) //&& scripts->hasScript( "poi.template.scene.base.base_theater" ) )
|
||||
{
|
||||
scripts->handleMessage( "startTheaterFromBuildout", std::vector<int8>() );
|
||||
scripts->handleMessage("startTheaterFromBuildout", std::vector<int8>());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ServerBuildoutManagerNamespace::BuildoutRow::BuildoutRow() :
|
||||
m_id(0),
|
||||
m_containerId(0),
|
||||
m_transform_p(),
|
||||
m_serverTemplate(0),
|
||||
m_scripts(),
|
||||
m_objvars(),
|
||||
m_cellIndex(0)
|
||||
m_id(0),
|
||||
m_containerId(0),
|
||||
m_transform_p(),
|
||||
m_serverTemplate(0),
|
||||
m_scripts(),
|
||||
m_objvars(),
|
||||
m_cellIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1190,12 +1171,12 @@ ServerBuildoutManagerNamespace::BuildoutRow &ServerBuildoutManagerNamespace::Bui
|
||||
|
||||
void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
{
|
||||
if(s_eventObjects.empty())
|
||||
if (s_eventObjects.empty())
|
||||
return;
|
||||
|
||||
ServerEventMap::iterator iter = s_eventObjects.find(eventName);
|
||||
|
||||
if(iter == s_eventObjects.end())
|
||||
|
||||
if (iter == s_eventObjects.end())
|
||||
return; // Perhaps we should print a warning here? Would we ever have an event with no server side event objects?
|
||||
|
||||
std::list< ServerEventAreaInfo >* eventList = &(*iter).second;
|
||||
@@ -1204,7 +1185,7 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
NetworkId controllerObjectId;
|
||||
|
||||
std::list< ServerEventAreaInfo >::iterator objIter = eventList->begin();
|
||||
for(; objIter != eventList->end(); ++objIter)
|
||||
for (; objIter != eventList->end(); ++objIter)
|
||||
{
|
||||
// Object Creation
|
||||
|
||||
@@ -1232,7 +1213,7 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
}
|
||||
|
||||
ServerObject * const containingObject = containerId ? safe_cast<ServerObject *>(NetworkIdManager::getObjectById(NetworkId(static_cast<NetworkId::NetworkIdType>(containerId)))) : 0;
|
||||
FATAL(containerId && !containingObject, ("could not find containing object obj=%d container=%d", (int)objectId.getValue(), containerId ));
|
||||
FATAL(containerId && !containingObject, ("could not find containing object obj=%d container=%d", (int)objectId.getValue(), containerId));
|
||||
|
||||
//-- object has already been created
|
||||
//-- this must be the controller object or one of its contents.
|
||||
@@ -1242,9 +1223,9 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
ServerObject * const newObject = safe_cast<ServerObject *>(buildoutRow.m_serverTemplate->createObject());
|
||||
FATAL(!newObject, ("could not create buildout object"));
|
||||
|
||||
LOGC(ConfigServerGame::getLogEventObjectCreation(),"EventBuildout", ("Loading Object for Event [%s].\nTemplate Name[%s]\nNetwork ID[%s]\nCell[%d]\nPosition[%-4.3f %-4.3f %-4.3f]\n\n",
|
||||
eventName.c_str(), buildoutRow.m_serverTemplate->getName(), objectId.getValueString().c_str(),buildoutRow.m_cellIndex,
|
||||
buildoutRow.m_transform_p.getPosition_p().x, buildoutRow.m_transform_p.getPosition_p().y, buildoutRow.m_transform_p.getPosition_p().z));
|
||||
LOGC(ConfigServerGame::getLogEventObjectCreation(), "EventBuildout", ("Loading Object for Event [%s].\nTemplate Name[%s]\nNetwork ID[%s]\nCell[%d]\nPosition[%-4.3f %-4.3f %-4.3f]\n\n",
|
||||
eventName.c_str(), buildoutRow.m_serverTemplate->getName(), objectId.getValueString().c_str(), buildoutRow.m_cellIndex,
|
||||
buildoutRow.m_transform_p.getPosition_p().x, buildoutRow.m_transform_p.getPosition_p().y, buildoutRow.m_transform_p.getPosition_p().z));
|
||||
|
||||
newObject->setNetworkId(objectId);
|
||||
newObject->setIncludeInBuildout(true);
|
||||
@@ -1253,7 +1234,7 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
|
||||
if (newCellObject)
|
||||
{
|
||||
newCellObject->setCell( buildoutRow.m_cellIndex );
|
||||
newCellObject->setCell(buildoutRow.m_cellIndex);
|
||||
}
|
||||
|
||||
if (!newObject->getController())
|
||||
@@ -1275,12 +1256,12 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
|
||||
const bool isEditing = ConfigServerGame::getBuildoutAreaEditingEnabled();
|
||||
|
||||
if ( isEditing == false )
|
||||
if (isEditing == false)
|
||||
{
|
||||
//
|
||||
// cells and their parents should NOT BE CLIENT CACHED
|
||||
//
|
||||
if ( newObject->asCellObject() )
|
||||
if (newObject->asCellObject())
|
||||
{
|
||||
// by the time we get here the cache version on the POB has
|
||||
// already been set to non-zero, so we need to reset it back
|
||||
@@ -1303,11 +1284,11 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
//
|
||||
const int vfCount = buildoutRow.m_serverTemplate->getVisibleFlagsCount();
|
||||
|
||||
for ( int index = 0; index < vfCount ; ++index )
|
||||
for (int index = 0; index < vfCount; ++index)
|
||||
{
|
||||
const ServerObjectTemplate::VisibleFlags vf = buildoutRow.m_serverTemplate->getVisibleFlags( index );
|
||||
const ServerObjectTemplate::VisibleFlags vf = buildoutRow.m_serverTemplate->getVisibleFlags(index);
|
||||
|
||||
if ( vf == ServerObjectTemplate::VF_player )
|
||||
if (vf == ServerObjectTemplate::VF_player)
|
||||
{
|
||||
// Removing this code temporarily since we don't have a proper way to do client side, cached event build out objects.
|
||||
// All event objects are objects that are streamed down from the server. Until we have a way for the client to know
|
||||
@@ -1320,7 +1301,6 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (buildoutRow.m_transform_p != Transform::identity)
|
||||
{
|
||||
newObject->setTransform_o2p(buildoutRow.m_transform_p);
|
||||
@@ -1363,7 +1343,7 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
while (scripts[pos] && scripts[pos] != ':')
|
||||
++pos;
|
||||
|
||||
std::string const & scriptName = scripts.substr(oldPos, pos-oldPos);
|
||||
std::string const & scriptName = scripts.substr(oldPos, pos - oldPos);
|
||||
if (!gso->hasScript(scriptName))
|
||||
IGNORE_RETURN(gso->attachScript(scriptName, false));
|
||||
|
||||
@@ -1373,12 +1353,11 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
}
|
||||
}
|
||||
|
||||
(*objIter).loadedObject = newObject;
|
||||
(*objIter).loadedObject = newObject;
|
||||
|
||||
newObjects.push_back(newObject);
|
||||
}
|
||||
|
||||
|
||||
// run through newly instantiated objects and initialize them
|
||||
{
|
||||
for (std::vector<ServerObject *>::reverse_iterator it = newObjects.rbegin(); it != newObjects.rend(); ++it)
|
||||
@@ -1388,7 +1367,7 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
}
|
||||
|
||||
// run through newly instantiated objects and notify the controller object
|
||||
if ( controllerObjectId.isValid() )
|
||||
if (controllerObjectId.isValid())
|
||||
{
|
||||
ServerObject * const controllerObject = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(controllerObjectId));
|
||||
if (nullptr != controllerObject)
|
||||
@@ -1405,7 +1384,7 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
if (obj->getObjVars().getItem("registerWithController", registerWithController))
|
||||
{
|
||||
if (registerWithController)
|
||||
{
|
||||
{
|
||||
if (nullptr != script)
|
||||
{
|
||||
ScriptParams p;
|
||||
@@ -1420,20 +1399,18 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
|
||||
// initialize any theaters
|
||||
{
|
||||
|
||||
for (std::vector<ServerObject *>::reverse_iterator it = newObjects.rbegin(); it != newObjects.rend(); ++it)
|
||||
{
|
||||
ServerObject *obj = *it;
|
||||
|
||||
if ( obj && obj->isAuthoritative() )
|
||||
if (obj && obj->isAuthoritative())
|
||||
{
|
||||
GameScriptObject *scripts = obj->getScriptObject();
|
||||
|
||||
if ( scripts ) //&& scripts->hasScript( "poi.template.scene.base.base_theater" ) )
|
||||
if (scripts) //&& scripts->hasScript( "poi.template.scene.base.base_theater" ) )
|
||||
{
|
||||
scripts->handleMessage( "startTheaterFromBuildout", std::vector<int8>() );
|
||||
scripts->handleMessage("startTheaterFromBuildout", std::vector<int8>());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1443,33 +1420,32 @@ void ServerBuildoutManager::onEventStarted(std::string const & eventName)
|
||||
|
||||
void ServerBuildoutManager::onEventStopped(std::string const & eventName)
|
||||
{
|
||||
if(s_eventObjects.empty())
|
||||
if (s_eventObjects.empty())
|
||||
return;
|
||||
|
||||
ServerEventMap::iterator iter = s_eventObjects.find(eventName);
|
||||
|
||||
if(iter == s_eventObjects.end())
|
||||
if (iter == s_eventObjects.end())
|
||||
return; // We stopped an event with no objects? Warning?
|
||||
|
||||
std::list< ServerEventAreaInfo >* eventList = &(*iter).second;
|
||||
|
||||
std::list< ServerEventAreaInfo >::iterator objIter = eventList->begin();
|
||||
for(; objIter != eventList->end(); ++objIter)
|
||||
for (; objIter != eventList->end(); ++objIter)
|
||||
{
|
||||
// Object clean up.
|
||||
if((*objIter).loadedObject)
|
||||
if ((*objIter).loadedObject)
|
||||
{
|
||||
ServerObject* object = (*objIter).loadedObject;
|
||||
|
||||
|
||||
LOGC(ConfigServerGame::getLogEventObjectDestruction(), "EventBuildout", ("Unloading Object for Event [%s].\nTemplate Name[%s]\nNetwork ID[%s]\nPosition[%-4.3f %-4.3f %-4.3f]\n\n",
|
||||
eventName.c_str(), object->getTemplateName(), object->getNetworkId().getValueString().c_str(),
|
||||
object->getTransform_o2p().getPosition_p().x, object->getTransform_o2p().getPosition_p().y, object->getTransform_o2p().getPosition_p().z));
|
||||
|
||||
|
||||
object->unload();
|
||||
|
||||
|
||||
(*objIter).loadedObject = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ======================================================================
|
||||
|
||||
// ======================================================================
|
||||
@@ -56,7 +56,7 @@ void LineOfSightCache::update()
|
||||
while (!s_lineOfSightCacheExpireQueue.empty())
|
||||
{
|
||||
LineOfSightCacheExpireQueueEntry const &entry = s_lineOfSightCacheExpireQueue.front();
|
||||
if (static_cast<int>(entry.second-frameStartTime) > 0)
|
||||
if (static_cast<int>(entry.second - frameStartTime) > 0)
|
||||
break;
|
||||
IGNORE_RETURN(s_lineOfSightCacheMap.erase(entry.first));
|
||||
s_lineOfSightCacheExpireQueue.pop();
|
||||
@@ -64,7 +64,7 @@ void LineOfSightCache::update()
|
||||
while (!s_lineOfSightLocationCacheExpireQueue.empty())
|
||||
{
|
||||
LineOfSightLocationCacheExpireQueueEntry const &entry = s_lineOfSightLocationCacheExpireQueue.front();
|
||||
if (static_cast<int>(entry.second-frameStartTime) > 0)
|
||||
if (static_cast<int>(entry.second - frameStartTime) > 0)
|
||||
break;
|
||||
IGNORE_RETURN(s_lineOfSightLocationCacheMap.erase(entry.first));
|
||||
s_lineOfSightLocationCacheExpireQueue.pop();
|
||||
@@ -435,5 +435,4 @@ bool LineOfSightCache::checkLOS(Object const &a, Location const &b)
|
||||
return (*result.first).second;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
// ======================================================================
|
||||
+30
-63
@@ -23,22 +23,22 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerArmorTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerArmorTemplate::ServerArmorTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ObjectTemplate(filename)
|
||||
,m_specialProtectionLoaded(false)
|
||||
,m_specialProtectionAppend(false)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_specialProtectionLoaded(false)
|
||||
, m_specialProtectionAppend(false)
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerArmorTemplate::ServerArmorTemplate
|
||||
|
||||
@@ -47,7 +47,7 @@ ServerArmorTemplate::ServerArmorTemplate(const std::string & filename)
|
||||
*/
|
||||
ServerArmorTemplate::~ServerArmorTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
{
|
||||
std::vector<StructParamOT *>::iterator iter;
|
||||
for (iter = m_specialProtection.begin(); iter != m_specialProtection.end(); ++iter)
|
||||
@@ -57,7 +57,7 @@ ServerArmorTemplate::~ServerArmorTemplate()
|
||||
}
|
||||
m_specialProtection.clear();
|
||||
}
|
||||
//@END TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerArmorTemplate::~ServerArmorTemplate
|
||||
|
||||
/**
|
||||
@@ -116,8 +116,6 @@ Tag ServerArmorTemplate::getHighestTemplateVersion(void) const
|
||||
//@BEGIN TFD
|
||||
ServerArmorTemplate::ArmorRating ServerArmorTemplate::getRating() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -145,8 +143,6 @@ ServerArmorTemplate::ArmorRating ServerArmorTemplate::getRating() const
|
||||
|
||||
int ServerArmorTemplate::getIntegrity() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -196,8 +192,6 @@ int ServerArmorTemplate::getIntegrity() const
|
||||
|
||||
int ServerArmorTemplate::getIntegrityMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -247,8 +241,6 @@ int ServerArmorTemplate::getIntegrityMin() const
|
||||
|
||||
int ServerArmorTemplate::getIntegrityMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -298,8 +290,6 @@ int ServerArmorTemplate::getIntegrityMax() const
|
||||
|
||||
int ServerArmorTemplate::getEffectiveness() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -349,8 +339,6 @@ int ServerArmorTemplate::getEffectiveness() const
|
||||
|
||||
int ServerArmorTemplate::getEffectivenessMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -400,8 +388,6 @@ int ServerArmorTemplate::getEffectivenessMin() const
|
||||
|
||||
int ServerArmorTemplate::getEffectivenessMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -462,7 +448,7 @@ void ServerArmorTemplate::getSpecialProtection(SpecialProtection &data, int inde
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter specialProtection in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -476,10 +462,10 @@ void ServerArmorTemplate::getSpecialProtection(SpecialProtection &data, int inde
|
||||
{
|
||||
int baseCount = base->getSpecialProtectionCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getSpecialProtection(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getSpecialProtection(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -505,7 +491,7 @@ void ServerArmorTemplate::getSpecialProtectionMin(SpecialProtection &data, int i
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter specialProtection in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -519,10 +505,10 @@ void ServerArmorTemplate::getSpecialProtectionMin(SpecialProtection &data, int i
|
||||
{
|
||||
int baseCount = base->getSpecialProtectionCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getSpecialProtectionMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getSpecialProtectionMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -548,7 +534,7 @@ void ServerArmorTemplate::getSpecialProtectionMax(SpecialProtection &data, int i
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter specialProtection in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -562,10 +548,10 @@ void ServerArmorTemplate::getSpecialProtectionMax(SpecialProtection &data, int i
|
||||
{
|
||||
int baseCount = base->getSpecialProtectionCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getSpecialProtectionMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getSpecialProtectionMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -604,8 +590,6 @@ size_t ServerArmorTemplate::getSpecialProtectionCount(void) const
|
||||
|
||||
int ServerArmorTemplate::getVulnerability() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -655,8 +639,6 @@ int ServerArmorTemplate::getVulnerability() const
|
||||
|
||||
int ServerArmorTemplate::getVulnerabilityMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -706,8 +688,6 @@ int ServerArmorTemplate::getVulnerabilityMin() const
|
||||
|
||||
int ServerArmorTemplate::getVulnerabilityMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -902,7 +882,6 @@ int ServerArmorTemplate::getEncumbranceMax(int index) const
|
||||
return value;
|
||||
} // ServerArmorTemplate::getEncumbranceMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -911,8 +890,8 @@ int ServerArmorTemplate::getEncumbranceMax(int index) const
|
||||
*/
|
||||
void ServerArmorTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerArmorTemplate_tag)
|
||||
{
|
||||
@@ -921,7 +900,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -941,10 +920,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -1005,7 +982,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerArmorTemplate::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerArmorTemplate::_SpecialProtection
|
||||
|
||||
@@ -1054,8 +1030,6 @@ Tag ServerArmorTemplate::_SpecialProtection::getId(void) const
|
||||
|
||||
ServerArmorTemplate::DamageType ServerArmorTemplate::_SpecialProtection::getType(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate::_SpecialProtection * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1083,8 +1057,6 @@ ServerArmorTemplate::DamageType ServerArmorTemplate::_SpecialProtection::getType
|
||||
|
||||
int ServerArmorTemplate::_SpecialProtection::getEffectiveness(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate::_SpecialProtection * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1134,8 +1106,6 @@ int ServerArmorTemplate::_SpecialProtection::getEffectiveness(bool versionOk) co
|
||||
|
||||
int ServerArmorTemplate::_SpecialProtection::getEffectivenessMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate::_SpecialProtection * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1185,8 +1155,6 @@ int ServerArmorTemplate::_SpecialProtection::getEffectivenessMin(bool versionOk)
|
||||
|
||||
int ServerArmorTemplate::_SpecialProtection::getEffectivenessMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerArmorTemplate::_SpecialProtection * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1234,7 +1202,6 @@ int ServerArmorTemplate::_SpecialProtection::getEffectivenessMax(bool versionOk)
|
||||
return value;
|
||||
} // ServerArmorTemplate::_SpecialProtection::getEffectivenessMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1243,8 +1210,8 @@ int ServerArmorTemplate::_SpecialProtection::getEffectivenessMax(bool versionOk)
|
||||
*/
|
||||
void ServerArmorTemplate::_SpecialProtection::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -1266,4 +1233,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerArmorTemplate::_SpecialProtection::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -23,20 +23,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerBattlefieldMarkerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerBattlefieldMarkerObjectTemplate::ServerBattlefieldMarkerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerBattlefieldMarkerObjectTemplate::ServerBattlefieldMarkerObjectTemplate
|
||||
|
||||
@@ -45,8 +45,8 @@ ServerBattlefieldMarkerObjectTemplate::ServerBattlefieldMarkerObjectTemplate(con
|
||||
*/
|
||||
ServerBattlefieldMarkerObjectTemplate::~ServerBattlefieldMarkerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerBattlefieldMarkerObjectTemplate::~ServerBattlefieldMarkerObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -122,8 +122,8 @@ Object * ServerBattlefieldMarkerObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerBattlefieldMarkerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerBattlefieldMarkerObjectTemplate_tag)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -153,10 +153,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -174,4 +172,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerBattlefieldMarkerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-22
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerBuildingObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerBuildingObjectTemplate::ServerBuildingObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerBuildingObjectTemplate::ServerBuildingObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerBuildingObjectTemplate::ServerBuildingObjectTemplate(const std::string & f
|
||||
*/
|
||||
ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerBuildingObjectTemplate::~ServerBuildingObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerBuildingObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
int ServerBuildingObjectTemplate::getMaintenanceCost() const
|
||||
{
|
||||
|
||||
|
||||
const ServerBuildingObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -165,8 +163,6 @@ int ServerBuildingObjectTemplate::getMaintenanceCost() const
|
||||
|
||||
int ServerBuildingObjectTemplate::getMaintenanceCostMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerBuildingObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -216,8 +212,6 @@ int ServerBuildingObjectTemplate::getMaintenanceCostMin() const
|
||||
|
||||
int ServerBuildingObjectTemplate::getMaintenanceCostMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerBuildingObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -267,8 +261,6 @@ int ServerBuildingObjectTemplate::getMaintenanceCostMax() const
|
||||
|
||||
bool ServerBuildingObjectTemplate::getIsPublic() const
|
||||
{
|
||||
|
||||
|
||||
const ServerBuildingObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -294,7 +286,6 @@ bool ServerBuildingObjectTemplate::getIsPublic() const
|
||||
return value;
|
||||
} // ServerBuildingObjectTemplate::getIsPublic
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -303,8 +294,8 @@ bool ServerBuildingObjectTemplate::getIsPublic() const
|
||||
*/
|
||||
void ServerBuildingObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerBuildingObjectTemplate_tag)
|
||||
{
|
||||
@@ -314,7 +305,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -334,10 +325,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -363,4 +352,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerBuildingObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+13
-15
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerCellObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerCellObjectTemplate::ServerCellObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerCellObjectTemplate::ServerCellObjectTemplate
|
||||
|
||||
@@ -46,12 +46,12 @@ ServerCellObjectTemplate::~ServerCellObjectTemplate()
|
||||
{
|
||||
if (m_baseData)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Released m_baseData.\n"));
|
||||
DEBUG_REPORT_LOG(true, ("Released m_baseData.\n"));
|
||||
m_baseData->releaseReference();
|
||||
m_baseData=0;
|
||||
m_baseData = 0;
|
||||
}
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerCellObjectTemplate::~ServerCellObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -127,8 +127,8 @@ Object * ServerCellObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerCellObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerCellObjectTemplate_tag)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -158,10 +158,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -179,4 +177,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerCellObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -24,20 +24,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerCityObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerCityObjectTemplate::ServerCityObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerCityObjectTemplate::ServerCityObjectTemplate
|
||||
|
||||
@@ -46,8 +46,8 @@ ServerCityObjectTemplate::ServerCityObjectTemplate(const std::string & filename)
|
||||
*/
|
||||
ServerCityObjectTemplate::~ServerCityObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerCityObjectTemplate::~ServerCityObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ Object * ServerCityObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerCityObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerCityObjectTemplate_tag)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -154,10 +154,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -175,4 +173,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerCityObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -23,20 +23,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerConstructionContractObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerConstructionContractObjectTemplate::ServerConstructionContractObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerConstructionContractObjectTemplate::ServerConstructionContractObjectTemplate
|
||||
|
||||
@@ -45,8 +45,8 @@ ServerConstructionContractObjectTemplate::ServerConstructionContractObjectTempla
|
||||
*/
|
||||
ServerConstructionContractObjectTemplate::~ServerConstructionContractObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerConstructionContractObjectTemplate::~ServerConstructionContractObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -112,8 +112,8 @@ Tag ServerConstructionContractObjectTemplate::getId(void) const
|
||||
*/
|
||||
void ServerConstructionContractObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerConstructionContractObjectTemplate_tag)
|
||||
{
|
||||
@@ -123,7 +123,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -143,10 +143,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -164,4 +162,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerConstructionContractObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+29
-72
@@ -26,22 +26,22 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerCreatureObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerCreatureObjectTemplate::ServerCreatureObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_attribModsLoaded(false)
|
||||
,m_attribModsAppend(false)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_attribModsLoaded(false)
|
||||
, m_attribModsAppend(false)
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerCreatureObjectTemplate::ServerCreatureObjectTemplate
|
||||
|
||||
@@ -50,7 +50,7 @@ ServerCreatureObjectTemplate::ServerCreatureObjectTemplate(const std::string & f
|
||||
*/
|
||||
ServerCreatureObjectTemplate::~ServerCreatureObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
{
|
||||
std::vector<StructParamOT *>::iterator iter;
|
||||
for (iter = m_attribMods.begin(); iter != m_attribMods.end(); ++iter)
|
||||
@@ -60,7 +60,7 @@ ServerCreatureObjectTemplate::~ServerCreatureObjectTemplate()
|
||||
}
|
||||
m_attribMods.clear();
|
||||
}
|
||||
//@END TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerCreatureObjectTemplate::~ServerCreatureObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ const ServerWeaponObjectTemplate * ServerCreatureObjectTemplate::getDefaultWeapo
|
||||
{
|
||||
returnValue = dynamic_cast<const ServerWeaponObjectTemplate *>(ObjectTemplateList::fetch(templateName));
|
||||
if (returnValue == nullptr)
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s",templateName.c_str()));
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s", templateName.c_str()));
|
||||
}
|
||||
return returnValue;
|
||||
} // ServerCreatureObjectTemplate::getDefaultWeapon
|
||||
@@ -603,8 +603,6 @@ int ServerCreatureObjectTemplate::getMaxAttributesMax(Attributes index) const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMinDrainModifier() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -654,8 +652,6 @@ float ServerCreatureObjectTemplate::getMinDrainModifier() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMinDrainModifierMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -705,8 +701,6 @@ float ServerCreatureObjectTemplate::getMinDrainModifierMin() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMinDrainModifierMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -756,8 +750,6 @@ float ServerCreatureObjectTemplate::getMinDrainModifierMax() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMaxDrainModifier() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -807,8 +799,6 @@ float ServerCreatureObjectTemplate::getMaxDrainModifier() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMaxDrainModifierMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -858,8 +848,6 @@ float ServerCreatureObjectTemplate::getMaxDrainModifierMin() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMaxDrainModifierMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -909,8 +897,6 @@ float ServerCreatureObjectTemplate::getMaxDrainModifierMax() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMinFaucetModifier() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -960,8 +946,6 @@ float ServerCreatureObjectTemplate::getMinFaucetModifier() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMinFaucetModifierMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1011,8 +995,6 @@ float ServerCreatureObjectTemplate::getMinFaucetModifierMin() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMinFaucetModifierMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1062,8 +1044,6 @@ float ServerCreatureObjectTemplate::getMinFaucetModifierMax() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMaxFaucetModifier() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1113,8 +1093,6 @@ float ServerCreatureObjectTemplate::getMaxFaucetModifier() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMaxFaucetModifierMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1164,8 +1142,6 @@ float ServerCreatureObjectTemplate::getMaxFaucetModifierMin() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getMaxFaucetModifierMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1226,7 +1202,7 @@ void ServerCreatureObjectTemplate::getAttribMods(AttribMod &data, int index) con
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter attribMods in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1240,10 +1216,10 @@ void ServerCreatureObjectTemplate::getAttribMods(AttribMod &data, int index) con
|
||||
{
|
||||
int baseCount = base->getAttribModsCount();
|
||||
if (static_cast<int>(index) < baseCount)
|
||||
{
|
||||
base->getAttribMods(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getAttribMods(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1272,7 +1248,7 @@ void ServerCreatureObjectTemplate::getAttribModsMin(AttribMod &data, int index)
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter attribMods in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1286,10 +1262,10 @@ void ServerCreatureObjectTemplate::getAttribModsMin(AttribMod &data, int index)
|
||||
{
|
||||
int baseCount = base->getAttribModsCount();
|
||||
if (static_cast<int>(index) < baseCount)
|
||||
{
|
||||
base->getAttribModsMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getAttribModsMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1318,7 +1294,7 @@ void ServerCreatureObjectTemplate::getAttribModsMax(AttribMod &data, int index)
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter attribMods in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1332,10 +1308,10 @@ void ServerCreatureObjectTemplate::getAttribModsMax(AttribMod &data, int index)
|
||||
{
|
||||
int baseCount = base->getAttribModsCount();
|
||||
if (static_cast<int>(index) < baseCount)
|
||||
{
|
||||
base->getAttribModsMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getAttribModsMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1377,8 +1353,6 @@ size_t ServerCreatureObjectTemplate::getAttribModsCount(void) const
|
||||
|
||||
int ServerCreatureObjectTemplate::getShockWounds() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1428,8 +1402,6 @@ int ServerCreatureObjectTemplate::getShockWounds() const
|
||||
|
||||
int ServerCreatureObjectTemplate::getShockWoundsMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1479,8 +1451,6 @@ int ServerCreatureObjectTemplate::getShockWoundsMin() const
|
||||
|
||||
int ServerCreatureObjectTemplate::getShockWoundsMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1530,8 +1500,6 @@ int ServerCreatureObjectTemplate::getShockWoundsMax() const
|
||||
|
||||
bool ServerCreatureObjectTemplate::getCanCreateAvatar() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1559,8 +1527,6 @@ bool ServerCreatureObjectTemplate::getCanCreateAvatar() const
|
||||
|
||||
const std::string & ServerCreatureObjectTemplate::getNameGeneratorType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1588,8 +1554,6 @@ const std::string & ServerCreatureObjectTemplate::getNameGeneratorType() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getApproachTriggerRange() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1639,8 +1603,6 @@ float ServerCreatureObjectTemplate::getApproachTriggerRange() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getApproachTriggerRangeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1690,8 +1652,6 @@ float ServerCreatureObjectTemplate::getApproachTriggerRangeMin() const
|
||||
|
||||
float ServerCreatureObjectTemplate::getApproachTriggerRangeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerCreatureObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2033,7 +1993,6 @@ float ServerCreatureObjectTemplate::getMentalStatesDecayMax(MentalStates index)
|
||||
return value;
|
||||
} // ServerCreatureObjectTemplate::getMentalStatesDecayMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -2042,8 +2001,8 @@ float ServerCreatureObjectTemplate::getMentalStatesDecayMax(MentalStates index)
|
||||
*/
|
||||
void ServerCreatureObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerCreatureObjectTemplate_tag)
|
||||
{
|
||||
@@ -2053,7 +2012,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -2073,10 +2032,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,5))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 5))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -2226,4 +2183,4 @@ const StringId &ServerCreatureObjectTemplate::verifyName(const Unicode::String &
|
||||
void ServerCreatureObjectTemplate::postLoad()
|
||||
{
|
||||
ServerTangibleObjectTemplate::postLoad();
|
||||
}
|
||||
}
|
||||
+54
-96
@@ -24,26 +24,26 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerDraftSchematicObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerDraftSchematicObjectTemplate::ServerDraftSchematicObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_slotsLoaded(false)
|
||||
,m_slotsAppend(false)
|
||||
,m_skillCommandsLoaded(false)
|
||||
,m_skillCommandsAppend(false)
|
||||
,m_manufactureScriptsLoaded(false)
|
||||
,m_manufactureScriptsAppend(false)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_slotsLoaded(false)
|
||||
, m_slotsAppend(false)
|
||||
, m_skillCommandsLoaded(false)
|
||||
, m_skillCommandsAppend(false)
|
||||
, m_manufactureScriptsLoaded(false)
|
||||
, m_manufactureScriptsAppend(false)
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerDraftSchematicObjectTemplate::ServerDraftSchematicObjectTemplate
|
||||
|
||||
@@ -52,7 +52,7 @@ ServerDraftSchematicObjectTemplate::ServerDraftSchematicObjectTemplate(const std
|
||||
*/
|
||||
ServerDraftSchematicObjectTemplate::~ServerDraftSchematicObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
{
|
||||
std::vector<StructParamOT *>::iterator iter;
|
||||
for (iter = m_slots.begin(); iter != m_slots.end(); ++iter)
|
||||
@@ -80,7 +80,7 @@ ServerDraftSchematicObjectTemplate::~ServerDraftSchematicObjectTemplate()
|
||||
}
|
||||
m_manufactureScripts.clear();
|
||||
}
|
||||
//@END TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerDraftSchematicObjectTemplate::~ServerDraftSchematicObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -143,14 +143,13 @@ Tag ServerDraftSchematicObjectTemplate::getHighestTemplateVersion(void) const
|
||||
*/
|
||||
Object * ServerDraftSchematicObjectTemplate::createObject(void) const
|
||||
{
|
||||
|
||||
WARNING(true, ("Trying to create a draft schematic %s outside the draft "
|
||||
"schematic factory!\n", getName()));
|
||||
return nullptr;
|
||||
} // ServerDraftSchematicObjectTemplate::createObject
|
||||
|
||||
/**
|
||||
* Called after the template data has been loaded. Verifies that the schematic has
|
||||
* Called after the template data has been loaded. Verifies that the schematic has
|
||||
* good data.
|
||||
*/
|
||||
void ServerDraftSchematicObjectTemplate::postLoad()
|
||||
@@ -160,8 +159,6 @@ void ServerDraftSchematicObjectTemplate::postLoad()
|
||||
//@BEGIN TFD
|
||||
ServerDraftSchematicObjectTemplate::CraftingType ServerDraftSchematicObjectTemplate::getCategory() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -212,7 +209,7 @@ const ServerObjectTemplate * ServerDraftSchematicObjectTemplate::getCraftedObjec
|
||||
const std::string & templateName = m_craftedObjectTemplate.getValue();
|
||||
const ServerObjectTemplate * returnValue = dynamic_cast<const ServerObjectTemplate *>(ObjectTemplateList::fetch(templateName));
|
||||
if (returnValue == nullptr)
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s",templateName.c_str()));
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s", templateName.c_str()));
|
||||
return returnValue;
|
||||
} // ServerDraftSchematicObjectTemplate::getCraftedObjectTemplate
|
||||
|
||||
@@ -241,7 +238,7 @@ const ServerFactoryObjectTemplate * ServerDraftSchematicObjectTemplate::getCrate
|
||||
const std::string & templateName = m_crateObjectTemplate.getValue();
|
||||
const ServerFactoryObjectTemplate * returnValue = dynamic_cast<const ServerFactoryObjectTemplate *>(ObjectTemplateList::fetch(templateName));
|
||||
if (returnValue == nullptr)
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s",templateName.c_str()));
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s", templateName.c_str()));
|
||||
return returnValue;
|
||||
} // ServerDraftSchematicObjectTemplate::getCrateObjectTemplate
|
||||
|
||||
@@ -258,7 +255,7 @@ void ServerDraftSchematicObjectTemplate::getSlots(IngredientSlot &data, int inde
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter slots in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -272,10 +269,10 @@ void ServerDraftSchematicObjectTemplate::getSlots(IngredientSlot &data, int inde
|
||||
{
|
||||
int baseCount = base->getSlotsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getSlots(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getSlots(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -311,7 +308,7 @@ void ServerDraftSchematicObjectTemplate::getSlotsMin(IngredientSlot &data, int i
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter slots in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -325,10 +322,10 @@ void ServerDraftSchematicObjectTemplate::getSlotsMin(IngredientSlot &data, int i
|
||||
{
|
||||
int baseCount = base->getSlotsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getSlotsMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getSlotsMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -364,7 +361,7 @@ void ServerDraftSchematicObjectTemplate::getSlotsMax(IngredientSlot &data, int i
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter slots in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -378,10 +375,10 @@ void ServerDraftSchematicObjectTemplate::getSlotsMax(IngredientSlot &data, int i
|
||||
{
|
||||
int baseCount = base->getSlotsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getSlotsMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getSlotsMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -489,8 +486,6 @@ size_t ServerDraftSchematicObjectTemplate::getSkillCommandsCount(void) const
|
||||
|
||||
bool ServerDraftSchematicObjectTemplate::getDestroyIngredients() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -577,8 +572,6 @@ size_t ServerDraftSchematicObjectTemplate::getManufactureScriptsCount(void) cons
|
||||
|
||||
int ServerDraftSchematicObjectTemplate::getItemsPerContainer() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -628,8 +621,6 @@ int ServerDraftSchematicObjectTemplate::getItemsPerContainer() const
|
||||
|
||||
int ServerDraftSchematicObjectTemplate::getItemsPerContainerMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -679,8 +670,6 @@ int ServerDraftSchematicObjectTemplate::getItemsPerContainerMin() const
|
||||
|
||||
int ServerDraftSchematicObjectTemplate::getItemsPerContainerMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -730,8 +719,6 @@ int ServerDraftSchematicObjectTemplate::getItemsPerContainerMax() const
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::getManufactureTime() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -781,8 +768,6 @@ float ServerDraftSchematicObjectTemplate::getManufactureTime() const
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::getManufactureTimeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -832,8 +817,6 @@ float ServerDraftSchematicObjectTemplate::getManufactureTimeMin() const
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::getManufactureTimeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -883,8 +866,6 @@ float ServerDraftSchematicObjectTemplate::getManufactureTimeMax() const
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::getPrototypeTime() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -934,8 +915,6 @@ float ServerDraftSchematicObjectTemplate::getPrototypeTime() const
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::getPrototypeTimeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -985,8 +964,6 @@ float ServerDraftSchematicObjectTemplate::getPrototypeTimeMin() const
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::getPrototypeTimeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1034,7 +1011,6 @@ float ServerDraftSchematicObjectTemplate::getPrototypeTimeMax() const
|
||||
return value;
|
||||
} // ServerDraftSchematicObjectTemplate::getPrototypeTimeMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1043,8 +1019,8 @@ float ServerDraftSchematicObjectTemplate::getPrototypeTimeMax() const
|
||||
*/
|
||||
void ServerDraftSchematicObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerDraftSchematicObjectTemplate_tag)
|
||||
{
|
||||
@@ -1054,7 +1030,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -1074,10 +1050,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,7))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 7))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -1170,7 +1144,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerDraftSchematicObjectTemplate::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerDraftSchematicObjectTemplate::_IngredientSlot
|
||||
|
||||
@@ -1179,8 +1152,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
*/
|
||||
ServerDraftSchematicObjectTemplate::_IngredientSlot::_IngredientSlot(const std::string & filename)
|
||||
: ObjectTemplate(filename)
|
||||
,m_optionsLoaded(false)
|
||||
,m_optionsAppend(false)
|
||||
, m_optionsLoaded(false)
|
||||
, m_optionsAppend(false)
|
||||
{
|
||||
} // ServerDraftSchematicObjectTemplate::_IngredientSlot::_IngredientSlot
|
||||
|
||||
@@ -1230,8 +1203,6 @@ Tag ServerDraftSchematicObjectTemplate::_IngredientSlot::getId(void) const
|
||||
|
||||
bool ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptional(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1259,8 +1230,6 @@ bool ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptional(bool versi
|
||||
|
||||
const StringId ServerDraftSchematicObjectTemplate::_IngredientSlot::getName(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1299,7 +1268,7 @@ void ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptions(Ingredient
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter options in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1313,10 +1282,10 @@ void ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptions(Ingredient
|
||||
{
|
||||
int baseCount = base->getOptionsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getOptions(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getOptions(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1350,7 +1319,7 @@ void ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptionsMin(Ingredie
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter options in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1364,10 +1333,10 @@ void ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptionsMin(Ingredie
|
||||
{
|
||||
int baseCount = base->getOptionsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getOptionsMin(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getOptionsMin(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1401,7 +1370,7 @@ void ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptionsMax(Ingredie
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter options in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1415,10 +1384,10 @@ void ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptionsMax(Ingredie
|
||||
{
|
||||
int baseCount = base->getOptionsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getOptionsMax(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getOptionsMax(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1465,8 +1434,6 @@ size_t ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptionsCount(void
|
||||
|
||||
const std::string & ServerDraftSchematicObjectTemplate::_IngredientSlot::getOptionalSkillCommand(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1494,8 +1461,6 @@ const std::string & ServerDraftSchematicObjectTemplate::_IngredientSlot::getOpti
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::_IngredientSlot::getComplexity(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1545,8 +1510,6 @@ float ServerDraftSchematicObjectTemplate::_IngredientSlot::getComplexity(bool ve
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::_IngredientSlot::getComplexityMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1596,8 +1559,6 @@ float ServerDraftSchematicObjectTemplate::_IngredientSlot::getComplexityMin(bool
|
||||
|
||||
float ServerDraftSchematicObjectTemplate::_IngredientSlot::getComplexityMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1647,8 +1608,6 @@ float ServerDraftSchematicObjectTemplate::_IngredientSlot::getComplexityMax(bool
|
||||
|
||||
const std::string & ServerDraftSchematicObjectTemplate::_IngredientSlot::getAppearance(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerDraftSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1674,7 +1633,6 @@ const std::string & ServerDraftSchematicObjectTemplate::_IngredientSlot::getAppe
|
||||
return value;
|
||||
} // ServerDraftSchematicObjectTemplate::_IngredientSlot::getAppearance
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1683,8 +1641,8 @@ const std::string & ServerDraftSchematicObjectTemplate::_IngredientSlot::getAppe
|
||||
*/
|
||||
void ServerDraftSchematicObjectTemplate::_IngredientSlot::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -1731,4 +1689,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerDraftSchematicObjectTemplate::_IngredientSlot::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerFactoryObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerFactoryObjectTemplate::ServerFactoryObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerFactoryObjectTemplate::ServerFactoryObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerFactoryObjectTemplate::ServerFactoryObjectTemplate(const std::string & fil
|
||||
*/
|
||||
ServerFactoryObjectTemplate::~ServerFactoryObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerFactoryObjectTemplate::~ServerFactoryObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -121,8 +121,8 @@ Object * ServerFactoryObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerFactoryObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerFactoryObjectTemplate_tag)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -152,10 +152,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -173,4 +171,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerFactoryObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -24,20 +24,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerGroupObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerGroupObjectTemplate::ServerGroupObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerGroupObjectTemplate::ServerGroupObjectTemplate
|
||||
|
||||
@@ -46,8 +46,8 @@ ServerGroupObjectTemplate::ServerGroupObjectTemplate(const std::string & filenam
|
||||
*/
|
||||
ServerGroupObjectTemplate::~ServerGroupObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerGroupObjectTemplate::~ServerGroupObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ Object * ServerGroupObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerGroupObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerGroupObjectTemplate_tag)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -154,10 +154,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -175,4 +173,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerGroupObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -24,20 +24,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerGuildObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerGuildObjectTemplate::ServerGuildObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerGuildObjectTemplate::ServerGuildObjectTemplate
|
||||
|
||||
@@ -46,8 +46,8 @@ ServerGuildObjectTemplate::ServerGuildObjectTemplate(const std::string & filenam
|
||||
*/
|
||||
ServerGuildObjectTemplate::~ServerGuildObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerGuildObjectTemplate::~ServerGuildObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ Object * ServerGuildObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerGuildObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerGuildObjectTemplate_tag)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -154,10 +154,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -175,4 +173,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerGuildObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-34
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerHarvesterInstallationObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerInstallationObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerHarvesterInstallationObjectTemplate::ServerHarvesterInstallationObjectTemp
|
||||
*/
|
||||
ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerHarvesterInstallationObjectTemplate::~ServerHarvesterInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerHarvesterInstallationObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRate() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -165,8 +163,6 @@ int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRate() const
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -216,8 +212,6 @@ int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMin() const
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -267,8 +261,6 @@ int ServerHarvesterInstallationObjectTemplate::getMaxExtractionRateMax() const
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRate() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -318,8 +310,6 @@ int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRate() const
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -369,8 +359,6 @@ int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMin() con
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -420,8 +408,6 @@ int ServerHarvesterInstallationObjectTemplate::getCurrentExtractionRateMax() con
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxHopperSize() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -471,8 +457,6 @@ int ServerHarvesterInstallationObjectTemplate::getMaxHopperSize() const
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -522,8 +506,6 @@ int ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMin() const
|
||||
|
||||
int ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -573,8 +555,6 @@ int ServerHarvesterInstallationObjectTemplate::getMaxHopperSizeMax() const
|
||||
|
||||
const std::string & ServerHarvesterInstallationObjectTemplate::getMasterClassName() const
|
||||
{
|
||||
|
||||
|
||||
const ServerHarvesterInstallationObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -600,7 +580,6 @@ const std::string & ServerHarvesterInstallationObjectTemplate::getMasterClassNam
|
||||
return value;
|
||||
} // ServerHarvesterInstallationObjectTemplate::getMasterClassName
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -609,8 +588,8 @@ const std::string & ServerHarvesterInstallationObjectTemplate::getMasterClassNam
|
||||
*/
|
||||
void ServerHarvesterInstallationObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerHarvesterInstallationObjectTemplate_tag)
|
||||
{
|
||||
@@ -620,7 +599,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -640,10 +619,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -673,4 +650,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerHarvesterInstallationObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -23,20 +23,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerInstallationObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerInstallationObjectTemplate::ServerInstallationObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerInstallationObjectTemplate::ServerInstallationObjectTemplate
|
||||
|
||||
@@ -45,8 +45,8 @@ ServerInstallationObjectTemplate::ServerInstallationObjectTemplate(const std::st
|
||||
*/
|
||||
ServerInstallationObjectTemplate::~ServerInstallationObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerInstallationObjectTemplate::~ServerInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -122,8 +122,8 @@ Object * ServerInstallationObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerInstallationObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerInstallationObjectTemplate_tag)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -153,10 +153,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -174,4 +172,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerInstallationObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+34
-77
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerIntangibleObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerIntangibleObjectTemplate::ServerIntangibleObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerIntangibleObjectTemplate::ServerIntangibleObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerIntangibleObjectTemplate::ServerIntangibleObjectTemplate(const std::string
|
||||
*/
|
||||
ServerIntangibleObjectTemplate::~ServerIntangibleObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerIntangibleObjectTemplate::~ServerIntangibleObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerIntangibleObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
int ServerIntangibleObjectTemplate::getCount() const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -165,8 +163,6 @@ int ServerIntangibleObjectTemplate::getCount() const
|
||||
|
||||
int ServerIntangibleObjectTemplate::getCountMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -216,8 +212,6 @@ int ServerIntangibleObjectTemplate::getCountMin() const
|
||||
|
||||
int ServerIntangibleObjectTemplate::getCountMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -265,7 +259,6 @@ int ServerIntangibleObjectTemplate::getCountMax() const
|
||||
return value;
|
||||
} // ServerIntangibleObjectTemplate::getCountMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -274,8 +267,8 @@ int ServerIntangibleObjectTemplate::getCountMax() const
|
||||
*/
|
||||
void ServerIntangibleObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerIntangibleObjectTemplate_tag)
|
||||
{
|
||||
@@ -285,7 +278,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -305,10 +298,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -332,7 +323,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerIntangibleObjectTemplate::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerIntangibleObjectTemplate::_Ingredient
|
||||
|
||||
@@ -341,8 +331,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
*/
|
||||
ServerIntangibleObjectTemplate::_Ingredient::_Ingredient(const std::string & filename)
|
||||
: ObjectTemplate(filename)
|
||||
,m_ingredientsLoaded(false)
|
||||
,m_ingredientsAppend(false)
|
||||
, m_ingredientsLoaded(false)
|
||||
, m_ingredientsAppend(false)
|
||||
{
|
||||
} // ServerIntangibleObjectTemplate::_Ingredient::_Ingredient
|
||||
|
||||
@@ -392,8 +382,6 @@ Tag ServerIntangibleObjectTemplate::_Ingredient::getId(void) const
|
||||
|
||||
ServerIntangibleObjectTemplate::IngredientType ServerIntangibleObjectTemplate::_Ingredient::getIngredientType(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_Ingredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -432,7 +420,7 @@ void ServerIntangibleObjectTemplate::_Ingredient::getIngredients(SimpleIngredien
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -446,10 +434,10 @@ void ServerIntangibleObjectTemplate::_Ingredient::getIngredients(SimpleIngredien
|
||||
{
|
||||
int baseCount = base->getIngredientsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getIngredients(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getIngredients(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -476,7 +464,7 @@ void ServerIntangibleObjectTemplate::_Ingredient::getIngredientsMin(SimpleIngred
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -490,10 +478,10 @@ void ServerIntangibleObjectTemplate::_Ingredient::getIngredientsMin(SimpleIngred
|
||||
{
|
||||
int baseCount = base->getIngredientsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getIngredientsMin(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getIngredientsMin(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -520,7 +508,7 @@ void ServerIntangibleObjectTemplate::_Ingredient::getIngredientsMax(SimpleIngred
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -534,10 +522,10 @@ void ServerIntangibleObjectTemplate::_Ingredient::getIngredientsMax(SimpleIngred
|
||||
{
|
||||
int baseCount = base->getIngredientsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getIngredientsMax(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getIngredientsMax(data, index, versionOk);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -577,8 +565,6 @@ size_t ServerIntangibleObjectTemplate::_Ingredient::getIngredientsCount(void) co
|
||||
|
||||
float ServerIntangibleObjectTemplate::_Ingredient::getComplexity(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_Ingredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -628,8 +614,6 @@ float ServerIntangibleObjectTemplate::_Ingredient::getComplexity(bool versionOk)
|
||||
|
||||
float ServerIntangibleObjectTemplate::_Ingredient::getComplexityMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_Ingredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -679,8 +663,6 @@ float ServerIntangibleObjectTemplate::_Ingredient::getComplexityMin(bool version
|
||||
|
||||
float ServerIntangibleObjectTemplate::_Ingredient::getComplexityMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_Ingredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -730,8 +712,6 @@ float ServerIntangibleObjectTemplate::_Ingredient::getComplexityMax(bool version
|
||||
|
||||
const std::string & ServerIntangibleObjectTemplate::_Ingredient::getSkillCommand(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_Ingredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -757,7 +737,6 @@ const std::string & ServerIntangibleObjectTemplate::_Ingredient::getSkillCommand
|
||||
return value;
|
||||
} // ServerIntangibleObjectTemplate::_Ingredient::getSkillCommand
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -766,8 +745,8 @@ const std::string & ServerIntangibleObjectTemplate::_Ingredient::getSkillCommand
|
||||
*/
|
||||
void ServerIntangibleObjectTemplate::_Ingredient::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -810,7 +789,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerIntangibleObjectTemplate::_Ingredient::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerIntangibleObjectTemplate::_SchematicAttribute
|
||||
|
||||
@@ -859,8 +837,6 @@ Tag ServerIntangibleObjectTemplate::_SchematicAttribute::getId(void) const
|
||||
|
||||
const StringId ServerIntangibleObjectTemplate::_SchematicAttribute::getName(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SchematicAttribute * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -888,8 +864,6 @@ const StringId ServerIntangibleObjectTemplate::_SchematicAttribute::getName(bool
|
||||
|
||||
int ServerIntangibleObjectTemplate::_SchematicAttribute::getValue(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SchematicAttribute * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -939,8 +913,6 @@ int ServerIntangibleObjectTemplate::_SchematicAttribute::getValue(bool versionOk
|
||||
|
||||
int ServerIntangibleObjectTemplate::_SchematicAttribute::getValueMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SchematicAttribute * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -990,8 +962,6 @@ int ServerIntangibleObjectTemplate::_SchematicAttribute::getValueMin(bool versio
|
||||
|
||||
int ServerIntangibleObjectTemplate::_SchematicAttribute::getValueMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SchematicAttribute * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1039,7 +1009,6 @@ int ServerIntangibleObjectTemplate::_SchematicAttribute::getValueMax(bool versio
|
||||
return value;
|
||||
} // ServerIntangibleObjectTemplate::_SchematicAttribute::getValueMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1048,8 +1017,8 @@ int ServerIntangibleObjectTemplate::_SchematicAttribute::getValueMax(bool versio
|
||||
*/
|
||||
void ServerIntangibleObjectTemplate::_SchematicAttribute::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -1071,7 +1040,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerIntangibleObjectTemplate::_SchematicAttribute::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerIntangibleObjectTemplate::_SimpleIngredient
|
||||
|
||||
@@ -1120,8 +1088,6 @@ Tag ServerIntangibleObjectTemplate::_SimpleIngredient::getId(void) const
|
||||
|
||||
const StringId ServerIntangibleObjectTemplate::_SimpleIngredient::getName(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SimpleIngredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1149,8 +1115,6 @@ const StringId ServerIntangibleObjectTemplate::_SimpleIngredient::getName(bool v
|
||||
|
||||
const std::string & ServerIntangibleObjectTemplate::_SimpleIngredient::getIngredient(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SimpleIngredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1178,8 +1142,6 @@ const std::string & ServerIntangibleObjectTemplate::_SimpleIngredient::getIngred
|
||||
|
||||
int ServerIntangibleObjectTemplate::_SimpleIngredient::getCount(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SimpleIngredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1229,8 +1191,6 @@ int ServerIntangibleObjectTemplate::_SimpleIngredient::getCount(bool versionOk)
|
||||
|
||||
int ServerIntangibleObjectTemplate::_SimpleIngredient::getCountMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SimpleIngredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1280,8 +1240,6 @@ int ServerIntangibleObjectTemplate::_SimpleIngredient::getCountMin(bool versionO
|
||||
|
||||
int ServerIntangibleObjectTemplate::_SimpleIngredient::getCountMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerIntangibleObjectTemplate::_SimpleIngredient * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1329,7 +1287,6 @@ int ServerIntangibleObjectTemplate::_SimpleIngredient::getCountMax(bool versionO
|
||||
return value;
|
||||
} // ServerIntangibleObjectTemplate::_SimpleIngredient::getCountMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1338,8 +1295,8 @@ int ServerIntangibleObjectTemplate::_SimpleIngredient::getCountMax(bool versionO
|
||||
*/
|
||||
void ServerIntangibleObjectTemplate::_SimpleIngredient::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -1363,4 +1320,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerIntangibleObjectTemplate::_SimpleIngredient::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerManufactureInstallationObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerManufactureInstallationObjectTemplate::ServerManufactureInstallationObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerInstallationObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerManufactureInstallationObjectTemplate::ServerManufactureInstallationObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerManufactureInstallationObjectTemplate::ServerManufactureInstallationObject
|
||||
*/
|
||||
ServerManufactureInstallationObjectTemplate::~ServerManufactureInstallationObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerManufactureInstallationObjectTemplate::~ServerManufactureInstallationObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -121,8 +121,8 @@ Object * ServerManufactureInstallationObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerManufactureInstallationObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerManufactureInstallationObjectTemplate_tag)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -152,10 +152,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -173,4 +171,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerManufactureInstallationObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+55
-72
@@ -22,24 +22,24 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerManufactureSchematicObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerManufactureSchematicObjectTemplate::ServerManufactureSchematicObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_ingredientsLoaded(false)
|
||||
,m_ingredientsAppend(false)
|
||||
,m_attributesLoaded(false)
|
||||
,m_attributesAppend(false)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_ingredientsLoaded(false)
|
||||
, m_ingredientsAppend(false)
|
||||
, m_attributesLoaded(false)
|
||||
, m_attributesAppend(false)
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerManufactureSchematicObjectTemplate::ServerManufactureSchematicObjectTemplate
|
||||
|
||||
@@ -48,7 +48,7 @@ ServerManufactureSchematicObjectTemplate::ServerManufactureSchematicObjectTempla
|
||||
*/
|
||||
ServerManufactureSchematicObjectTemplate::~ServerManufactureSchematicObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
{
|
||||
std::vector<StructParamOT *>::iterator iter;
|
||||
for (iter = m_ingredients.begin(); iter != m_ingredients.end(); ++iter)
|
||||
@@ -67,7 +67,7 @@ ServerManufactureSchematicObjectTemplate::~ServerManufactureSchematicObjectTempl
|
||||
}
|
||||
m_attributes.clear();
|
||||
}
|
||||
//@END TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerManufactureSchematicObjectTemplate::~ServerManufactureSchematicObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -131,8 +131,8 @@ Tag ServerManufactureSchematicObjectTemplate::getHighestTemplateVersion(void) co
|
||||
*/
|
||||
Object * ServerManufactureSchematicObjectTemplate::createObject(void) const
|
||||
{
|
||||
// WARNING(true, ("Someone is trying to create a manf schematic without a "
|
||||
// "draft schematic source!"));
|
||||
// WARNING(true, ("Someone is trying to create a manf schematic without a "
|
||||
// "draft schematic source!"));
|
||||
return new ManufactureSchematicObject(this);
|
||||
} // ServerManufactureSchematicObjectTemplate::createObject
|
||||
|
||||
@@ -147,12 +147,12 @@ Object * ServerManufactureSchematicObjectTemplate::createObject(const char *cons
|
||||
if (objectTemplate)
|
||||
{
|
||||
Object * object = nullptr;
|
||||
const ServerManufactureSchematicObjectTemplate * const manfTemplate =
|
||||
const ServerManufactureSchematicObjectTemplate * const manfTemplate =
|
||||
dynamic_cast<const ServerManufactureSchematicObjectTemplate *const>(
|
||||
objectTemplate);
|
||||
objectTemplate);
|
||||
if (manfTemplate != nullptr)
|
||||
object = manfTemplate->createObject(schematic);
|
||||
objectTemplate->releaseReference ();
|
||||
objectTemplate->releaseReference();
|
||||
|
||||
return object;
|
||||
}
|
||||
@@ -172,8 +172,6 @@ Object * ServerManufactureSchematicObjectTemplate::createObject(const DraftSchem
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerManufactureSchematicObjectTemplate::getDraftSchematic() const
|
||||
{
|
||||
|
||||
|
||||
const ServerManufactureSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -201,8 +199,6 @@ const std::string & ServerManufactureSchematicObjectTemplate::getDraftSchematic(
|
||||
|
||||
const std::string & ServerManufactureSchematicObjectTemplate::getCreator() const
|
||||
{
|
||||
|
||||
|
||||
const ServerManufactureSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -241,7 +237,7 @@ void ServerManufactureSchematicObjectTemplate::getIngredients(IngredientSlot &da
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -255,10 +251,10 @@ void ServerManufactureSchematicObjectTemplate::getIngredients(IngredientSlot &da
|
||||
{
|
||||
int baseCount = base->getIngredientsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getIngredients(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getIngredients(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -284,7 +280,7 @@ void ServerManufactureSchematicObjectTemplate::getIngredientsMin(IngredientSlot
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -298,10 +294,10 @@ void ServerManufactureSchematicObjectTemplate::getIngredientsMin(IngredientSlot
|
||||
{
|
||||
int baseCount = base->getIngredientsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getIngredientsMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getIngredientsMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -327,7 +323,7 @@ void ServerManufactureSchematicObjectTemplate::getIngredientsMax(IngredientSlot
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -341,10 +337,10 @@ void ServerManufactureSchematicObjectTemplate::getIngredientsMax(IngredientSlot
|
||||
{
|
||||
int baseCount = base->getIngredientsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getIngredientsMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getIngredientsMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -383,8 +379,6 @@ size_t ServerManufactureSchematicObjectTemplate::getIngredientsCount(void) const
|
||||
|
||||
int ServerManufactureSchematicObjectTemplate::getItemCount() const
|
||||
{
|
||||
|
||||
|
||||
const ServerManufactureSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -434,8 +428,6 @@ int ServerManufactureSchematicObjectTemplate::getItemCount() const
|
||||
|
||||
int ServerManufactureSchematicObjectTemplate::getItemCountMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerManufactureSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -485,8 +477,6 @@ int ServerManufactureSchematicObjectTemplate::getItemCountMin() const
|
||||
|
||||
int ServerManufactureSchematicObjectTemplate::getItemCountMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerManufactureSchematicObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -547,7 +537,7 @@ void ServerManufactureSchematicObjectTemplate::getAttributes(SchematicAttribute
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter attributes in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -561,10 +551,10 @@ void ServerManufactureSchematicObjectTemplate::getAttributes(SchematicAttribute
|
||||
{
|
||||
int baseCount = base->getAttributesCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getAttributes(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getAttributes(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -590,7 +580,7 @@ void ServerManufactureSchematicObjectTemplate::getAttributesMin(SchematicAttribu
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter attributes in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -604,10 +594,10 @@ void ServerManufactureSchematicObjectTemplate::getAttributesMin(SchematicAttribu
|
||||
{
|
||||
int baseCount = base->getAttributesCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getAttributesMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getAttributesMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -633,7 +623,7 @@ void ServerManufactureSchematicObjectTemplate::getAttributesMax(SchematicAttribu
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter attributes in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -647,10 +637,10 @@ void ServerManufactureSchematicObjectTemplate::getAttributesMax(SchematicAttribu
|
||||
{
|
||||
int baseCount = base->getAttributesCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getAttributesMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getAttributesMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -687,7 +677,6 @@ size_t ServerManufactureSchematicObjectTemplate::getAttributesCount(void) const
|
||||
return count;
|
||||
} // ServerManufactureSchematicObjectTemplate::getAttributesCount
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -696,8 +685,8 @@ size_t ServerManufactureSchematicObjectTemplate::getAttributesCount(void) const
|
||||
*/
|
||||
void ServerManufactureSchematicObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerManufactureSchematicObjectTemplate_tag)
|
||||
{
|
||||
@@ -707,7 +696,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -727,10 +716,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -796,7 +783,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerManufactureSchematicObjectTemplate::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerManufactureSchematicObjectTemplate::_IngredientSlot
|
||||
|
||||
@@ -845,8 +831,6 @@ Tag ServerManufactureSchematicObjectTemplate::_IngredientSlot::getId(void) const
|
||||
|
||||
const StringId ServerManufactureSchematicObjectTemplate::_IngredientSlot::getName(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerManufactureSchematicObjectTemplate::_IngredientSlot * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -885,7 +869,7 @@ void ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredient(In
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredient in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -924,7 +908,7 @@ void ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredientMin
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredient in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -963,7 +947,7 @@ void ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredientMax
|
||||
if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter ingredient in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -989,7 +973,6 @@ void ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredientMax
|
||||
data.skillCommand = param->getSkillCommand(versionOk);
|
||||
} // ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredientMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -998,8 +981,8 @@ void ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredientMax
|
||||
*/
|
||||
void ServerManufactureSchematicObjectTemplate::_IngredientSlot::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -1021,4 +1004,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerManufactureSchematicObjectTemplate::_IngredientSlot::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerMissionObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerMissionObjectTemplate::ServerMissionObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerMissionObjectTemplate::ServerMissionObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerMissionObjectTemplate::ServerMissionObjectTemplate(const std::string & fil
|
||||
*/
|
||||
ServerMissionObjectTemplate::~ServerMissionObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerMissionObjectTemplate::~ServerMissionObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -121,8 +121,8 @@ Object * ServerMissionObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerMissionObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerMissionObjectTemplate_tag)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -152,10 +152,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -173,4 +171,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerMissionObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+71
-179
@@ -26,35 +26,35 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
typedef std::unordered_map<ServerObjectTemplate::XpTypes, std::string, std::hash<int> > XP_MAP;
|
||||
typedef std::unordered_map<ServerObjectTemplate::XpTypes, std::string, std::hash<int> > XP_MAP;
|
||||
static XP_MAP * XpMap = nullptr;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerObjectTemplate::ServerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ObjectTemplate(filename)
|
||||
,m_scriptsLoaded(false)
|
||||
,m_scriptsAppend(false)
|
||||
,m_visibleFlagsLoaded(false)
|
||||
,m_visibleFlagsAppend(false)
|
||||
,m_deleteFlagsLoaded(false)
|
||||
,m_deleteFlagsAppend(false)
|
||||
,m_moveFlagsLoaded(false)
|
||||
,m_moveFlagsAppend(false)
|
||||
,m_contentsLoaded(false)
|
||||
,m_contentsAppend(false)
|
||||
,m_xpPointsLoaded(false)
|
||||
,m_xpPointsAppend(false)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_scriptsLoaded(false)
|
||||
, m_scriptsAppend(false)
|
||||
, m_visibleFlagsLoaded(false)
|
||||
, m_visibleFlagsAppend(false)
|
||||
, m_deleteFlagsLoaded(false)
|
||||
, m_deleteFlagsAppend(false)
|
||||
, m_moveFlagsLoaded(false)
|
||||
, m_moveFlagsAppend(false)
|
||||
, m_contentsLoaded(false)
|
||||
, m_contentsAppend(false)
|
||||
, m_xpPointsLoaded(false)
|
||||
, m_xpPointsAppend(false)
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerObjectTemplate::ServerObjectTemplate
|
||||
|
||||
@@ -66,9 +66,9 @@ ServerObjectTemplate::~ServerObjectTemplate()
|
||||
if (m_baseData)
|
||||
{
|
||||
m_baseData->releaseReference();
|
||||
m_baseData=0;
|
||||
m_baseData = 0;
|
||||
}
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
{
|
||||
std::vector<StringParam *>::iterator iter;
|
||||
for (iter = m_scripts.begin(); iter != m_scripts.end(); ++iter)
|
||||
@@ -123,7 +123,7 @@ ServerObjectTemplate::~ServerObjectTemplate()
|
||||
}
|
||||
m_xpPoints.clear();
|
||||
}
|
||||
//@END TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerObjectTemplate::~ServerObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -299,11 +299,11 @@ const std::string & ServerObjectTemplate::getXpString(XpTypes type)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
const std::string & ServerObjectTemplate::getDamageTypeString (DamageType type)
|
||||
const std::string & ServerObjectTemplate::getDamageTypeString(DamageType type)
|
||||
{
|
||||
static const std::string emptyString;
|
||||
|
||||
static const std::string DAMAGE_TYPE_NAMES[] =
|
||||
static const std::string DAMAGE_TYPE_NAMES[] =
|
||||
{
|
||||
"kinetic",
|
||||
"energy",
|
||||
@@ -329,7 +329,7 @@ const std::string & ServerObjectTemplate::getDamageTypeString (DamageType type)
|
||||
for (int index = 0; index < DAMAGE_TYPE_NAMES_SIZE; ++index)
|
||||
{
|
||||
if ((i_damage & (1 << index)) != 0)
|
||||
return DAMAGE_TYPE_NAMES [index];
|
||||
return DAMAGE_TYPE_NAMES[index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,11 +338,11 @@ const std::string & ServerObjectTemplate::getDamageTypeString (DamageType type)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
const std::string & ServerObjectTemplate::getArmorRatingString (ArmorRating type)
|
||||
const std::string & ServerObjectTemplate::getArmorRatingString(ArmorRating type)
|
||||
{
|
||||
static const std::string emptyString;
|
||||
|
||||
static const std::string ARMOR_RATING_NAMES[] =
|
||||
static const std::string ARMOR_RATING_NAMES[] =
|
||||
{
|
||||
"none",
|
||||
"light",
|
||||
@@ -357,7 +357,7 @@ const std::string & ServerObjectTemplate::getArmorRatingString (ArmorRating type
|
||||
if (i_type < 0 || i_type >= ARMOR_RATING_NAMES_SIZE)
|
||||
return emptyString;
|
||||
|
||||
return ARMOR_RATING_NAMES [i_type];
|
||||
return ARMOR_RATING_NAMES[i_type];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -365,8 +365,6 @@ const std::string & ServerObjectTemplate::getArmorRatingString (ArmorRating type
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerObjectTemplate::getSharedTemplate() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -464,7 +462,7 @@ void ServerObjectTemplate::getObjvars(DynamicVariableList &list) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter objvars in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -481,8 +479,6 @@ void ServerObjectTemplate::getObjvars(DynamicVariableList &list) const
|
||||
|
||||
int ServerObjectTemplate::getVolume() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -532,8 +528,6 @@ int ServerObjectTemplate::getVolume() const
|
||||
|
||||
int ServerObjectTemplate::getVolumeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -583,8 +577,6 @@ int ServerObjectTemplate::getVolumeMin() const
|
||||
|
||||
int ServerObjectTemplate::getVolumeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -808,8 +800,6 @@ size_t ServerObjectTemplate::getMoveFlagsCount(void) const
|
||||
|
||||
bool ServerObjectTemplate::getInvulnerable() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -837,8 +827,6 @@ bool ServerObjectTemplate::getInvulnerable() const
|
||||
|
||||
float ServerObjectTemplate::getComplexity() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -888,8 +876,6 @@ float ServerObjectTemplate::getComplexity() const
|
||||
|
||||
float ServerObjectTemplate::getComplexityMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -939,8 +925,6 @@ float ServerObjectTemplate::getComplexityMin() const
|
||||
|
||||
float ServerObjectTemplate::getComplexityMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -990,8 +974,6 @@ float ServerObjectTemplate::getComplexityMax() const
|
||||
|
||||
int ServerObjectTemplate::getTintIndex() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1041,8 +1023,6 @@ int ServerObjectTemplate::getTintIndex() const
|
||||
|
||||
int ServerObjectTemplate::getTintIndexMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1092,8 +1072,6 @@ int ServerObjectTemplate::getTintIndexMin() const
|
||||
|
||||
int ServerObjectTemplate::getTintIndexMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1301,7 +1279,7 @@ void ServerObjectTemplate::getContents(Contents &data, int index) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter contents in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1315,10 +1293,10 @@ void ServerObjectTemplate::getContents(Contents &data, int index) const
|
||||
{
|
||||
int baseCount = base->getContentsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getContents(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getContents(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1345,7 +1323,7 @@ void ServerObjectTemplate::getContentsMin(Contents &data, int index) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter contents in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1359,10 +1337,10 @@ void ServerObjectTemplate::getContentsMin(Contents &data, int index) const
|
||||
{
|
||||
int baseCount = base->getContentsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getContentsMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getContentsMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1389,7 +1367,7 @@ void ServerObjectTemplate::getContentsMax(Contents &data, int index) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter contents in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1403,10 +1381,10 @@ void ServerObjectTemplate::getContentsMax(Contents &data, int index) const
|
||||
{
|
||||
int baseCount = base->getContentsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getContentsMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getContentsMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1457,7 +1435,7 @@ void ServerObjectTemplate::getXpPoints(Xp &data, int index) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter xpPoints in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1471,10 +1449,10 @@ void ServerObjectTemplate::getXpPoints(Xp &data, int index) const
|
||||
{
|
||||
int baseCount = base->getXpPointsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getXpPoints(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getXpPoints(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1501,7 +1479,7 @@ void ServerObjectTemplate::getXpPointsMin(Xp &data, int index) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter xpPoints in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1515,10 +1493,10 @@ void ServerObjectTemplate::getXpPointsMin(Xp &data, int index) const
|
||||
{
|
||||
int baseCount = base->getXpPointsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getXpPointsMin(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getXpPointsMin(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1545,7 +1523,7 @@ void ServerObjectTemplate::getXpPointsMax(Xp &data, int index) const
|
||||
if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == nullptr)
|
||||
{
|
||||
DEBUG_WARNING(true, ("Returning default value for missing parameter xpPoints in template %s", DataResource::getName()));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1559,10 +1537,10 @@ void ServerObjectTemplate::getXpPointsMax(Xp &data, int index) const
|
||||
{
|
||||
int baseCount = base->getXpPointsCount();
|
||||
if (index < baseCount)
|
||||
{
|
||||
base->getXpPointsMax(data, index);
|
||||
return;
|
||||
}
|
||||
{
|
||||
base->getXpPointsMax(data, index);
|
||||
return;
|
||||
}
|
||||
index -= baseCount;
|
||||
}
|
||||
|
||||
@@ -1602,8 +1580,6 @@ size_t ServerObjectTemplate::getXpPointsCount(void) const
|
||||
|
||||
bool ServerObjectTemplate::getPersistByDefault() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1631,8 +1607,6 @@ bool ServerObjectTemplate::getPersistByDefault() const
|
||||
|
||||
bool ServerObjectTemplate::getPersistContents() const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1658,7 +1632,6 @@ bool ServerObjectTemplate::getPersistContents() const
|
||||
return value;
|
||||
} // ServerObjectTemplate::getPersistContents
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1667,8 +1640,8 @@ bool ServerObjectTemplate::getPersistContents() const
|
||||
*/
|
||||
void ServerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerObjectTemplate_tag)
|
||||
{
|
||||
@@ -1677,7 +1650,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -1697,10 +1670,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,1,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 1, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -1864,7 +1835,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerObjectTemplate::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerObjectTemplate::_AttribMod
|
||||
|
||||
@@ -1913,8 +1883,6 @@ Tag ServerObjectTemplate::_AttribMod::getId(void) const
|
||||
|
||||
ServerObjectTemplate::Attributes ServerObjectTemplate::_AttribMod::getTarget(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1942,8 +1910,6 @@ ServerObjectTemplate::Attributes ServerObjectTemplate::_AttribMod::getTarget(boo
|
||||
|
||||
int ServerObjectTemplate::_AttribMod::getValue(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1993,8 +1959,6 @@ int ServerObjectTemplate::_AttribMod::getValue(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_AttribMod::getValueMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2044,8 +2008,6 @@ int ServerObjectTemplate::_AttribMod::getValueMin(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_AttribMod::getValueMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2095,8 +2057,6 @@ int ServerObjectTemplate::_AttribMod::getValueMax(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getTime(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2146,8 +2106,6 @@ float ServerObjectTemplate::_AttribMod::getTime(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getTimeMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2197,8 +2155,6 @@ float ServerObjectTemplate::_AttribMod::getTimeMin(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getTimeMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2248,8 +2204,6 @@ float ServerObjectTemplate::_AttribMod::getTimeMax(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getTimeAtValue(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2299,8 +2253,6 @@ float ServerObjectTemplate::_AttribMod::getTimeAtValue(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getTimeAtValueMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2350,8 +2302,6 @@ float ServerObjectTemplate::_AttribMod::getTimeAtValueMin(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getTimeAtValueMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2401,8 +2351,6 @@ float ServerObjectTemplate::_AttribMod::getTimeAtValueMax(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getDecay(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2452,8 +2400,6 @@ float ServerObjectTemplate::_AttribMod::getDecay(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getDecayMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2503,8 +2449,6 @@ float ServerObjectTemplate::_AttribMod::getDecayMin(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_AttribMod::getDecayMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_AttribMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2552,7 +2496,6 @@ float ServerObjectTemplate::_AttribMod::getDecayMax(bool versionOk) const
|
||||
return value;
|
||||
} // ServerObjectTemplate::_AttribMod::getDecayMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -2561,8 +2504,8 @@ float ServerObjectTemplate::_AttribMod::getDecayMax(bool versionOk) const
|
||||
*/
|
||||
void ServerObjectTemplate::_AttribMod::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -2590,7 +2533,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerObjectTemplate::_AttribMod::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// struct ServerObjectTemplate::Contents
|
||||
|
||||
@@ -2637,7 +2579,6 @@ ServerObjectTemplate::Contents & ServerObjectTemplate::Contents::operator =(cons
|
||||
} // ServerObjectTemplate::Contents::operator =
|
||||
#endif
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerObjectTemplate::_Contents
|
||||
|
||||
@@ -2686,8 +2627,6 @@ Tag ServerObjectTemplate::_Contents::getId(void) const
|
||||
|
||||
const std::string & ServerObjectTemplate::_Contents::getSlotName(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Contents * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2715,8 +2654,6 @@ const std::string & ServerObjectTemplate::_Contents::getSlotName(bool versionOk)
|
||||
|
||||
bool ServerObjectTemplate::_Contents::getEquipObject(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Contents * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2770,12 +2707,11 @@ const ServerObjectTemplate * ServerObjectTemplate::_Contents::getContent(bool ve
|
||||
{
|
||||
returnValue = dynamic_cast<const ServerObjectTemplate *>(ObjectTemplateList::fetch(templateName));
|
||||
if (returnValue == nullptr)
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s",templateName.c_str()));
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s", templateName.c_str()));
|
||||
}
|
||||
return returnValue;
|
||||
} // ServerObjectTemplate::_Contents::getContent
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -2784,8 +2720,8 @@ const ServerObjectTemplate * ServerObjectTemplate::_Contents::getContent(bool ve
|
||||
*/
|
||||
void ServerObjectTemplate::_Contents::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -2809,7 +2745,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerObjectTemplate::_Contents::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerObjectTemplate::_MentalStateMod
|
||||
|
||||
@@ -2858,8 +2793,6 @@ Tag ServerObjectTemplate::_MentalStateMod::getId(void) const
|
||||
|
||||
ServerObjectTemplate::MentalStates ServerObjectTemplate::_MentalStateMod::getTarget(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2887,8 +2820,6 @@ ServerObjectTemplate::MentalStates ServerObjectTemplate::_MentalStateMod::getTar
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getValue(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2938,8 +2869,6 @@ float ServerObjectTemplate::_MentalStateMod::getValue(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getValueMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -2989,8 +2918,6 @@ float ServerObjectTemplate::_MentalStateMod::getValueMin(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getValueMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3040,8 +2967,6 @@ float ServerObjectTemplate::_MentalStateMod::getValueMax(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getTime(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3091,8 +3016,6 @@ float ServerObjectTemplate::_MentalStateMod::getTime(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getTimeMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3142,8 +3065,6 @@ float ServerObjectTemplate::_MentalStateMod::getTimeMin(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getTimeMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3193,8 +3114,6 @@ float ServerObjectTemplate::_MentalStateMod::getTimeMax(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getTimeAtValue(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3244,8 +3163,6 @@ float ServerObjectTemplate::_MentalStateMod::getTimeAtValue(bool versionOk) cons
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getTimeAtValueMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3295,8 +3212,6 @@ float ServerObjectTemplate::_MentalStateMod::getTimeAtValueMin(bool versionOk) c
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getTimeAtValueMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3346,8 +3261,6 @@ float ServerObjectTemplate::_MentalStateMod::getTimeAtValueMax(bool versionOk) c
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getDecay(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3397,8 +3310,6 @@ float ServerObjectTemplate::_MentalStateMod::getDecay(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getDecayMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3448,8 +3359,6 @@ float ServerObjectTemplate::_MentalStateMod::getDecayMin(bool versionOk) const
|
||||
|
||||
float ServerObjectTemplate::_MentalStateMod::getDecayMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_MentalStateMod * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3497,7 +3406,6 @@ float ServerObjectTemplate::_MentalStateMod::getDecayMax(bool versionOk) const
|
||||
return value;
|
||||
} // ServerObjectTemplate::_MentalStateMod::getDecayMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -3506,8 +3414,8 @@ float ServerObjectTemplate::_MentalStateMod::getDecayMax(bool versionOk) const
|
||||
*/
|
||||
void ServerObjectTemplate::_MentalStateMod::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -3535,7 +3443,6 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerObjectTemplate::_MentalStateMod::load
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// class ServerObjectTemplate::_Xp
|
||||
|
||||
@@ -3584,8 +3491,6 @@ Tag ServerObjectTemplate::_Xp::getId(void) const
|
||||
|
||||
ServerObjectTemplate::XpTypes ServerObjectTemplate::_Xp::getType(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3613,8 +3518,6 @@ ServerObjectTemplate::XpTypes ServerObjectTemplate::_Xp::getType(bool versionOk)
|
||||
|
||||
int ServerObjectTemplate::_Xp::getLevel(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3664,8 +3567,6 @@ int ServerObjectTemplate::_Xp::getLevel(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_Xp::getLevelMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3715,8 +3616,6 @@ int ServerObjectTemplate::_Xp::getLevelMin(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_Xp::getLevelMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3766,8 +3665,6 @@ int ServerObjectTemplate::_Xp::getLevelMax(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_Xp::getValue(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3817,8 +3714,6 @@ int ServerObjectTemplate::_Xp::getValue(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_Xp::getValueMin(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3868,8 +3763,6 @@ int ServerObjectTemplate::_Xp::getValueMin(bool versionOk) const
|
||||
|
||||
int ServerObjectTemplate::_Xp::getValueMax(bool versionOk) const
|
||||
{
|
||||
|
||||
|
||||
const ServerObjectTemplate::_Xp * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -3917,7 +3810,6 @@ int ServerObjectTemplate::_Xp::getValueMax(bool versionOk) const
|
||||
return value;
|
||||
} // ServerObjectTemplate::_Xp::getValueMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -3926,8 +3818,8 @@ int ServerObjectTemplate::_Xp::getValueMax(bool versionOk) const
|
||||
*/
|
||||
void ServerObjectTemplate::_Xp::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
|
||||
@@ -3951,4 +3843,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
UNREF(file);
|
||||
} // ServerObjectTemplate::_Xp::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-16
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerPlanetObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerPlanetObjectTemplate::ServerPlanetObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerPlanetObjectTemplate::ServerPlanetObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerPlanetObjectTemplate::ServerPlanetObjectTemplate(const std::string & filen
|
||||
*/
|
||||
ServerPlanetObjectTemplate::~ServerPlanetObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerPlanetObjectTemplate::~ServerPlanetObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerPlanetObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerPlanetObjectTemplate::getPlanetName() const
|
||||
{
|
||||
|
||||
|
||||
const ServerPlanetObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -141,7 +139,6 @@ const std::string & ServerPlanetObjectTemplate::getPlanetName() const
|
||||
return value;
|
||||
} // ServerPlanetObjectTemplate::getPlanetName
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -150,8 +147,8 @@ const std::string & ServerPlanetObjectTemplate::getPlanetName() const
|
||||
*/
|
||||
void ServerPlanetObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerPlanetObjectTemplate_tag)
|
||||
{
|
||||
@@ -161,7 +158,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -181,10 +178,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -208,4 +203,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerPlanetObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -24,20 +24,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerPlayerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerPlayerObjectTemplate::ServerPlayerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerIntangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerPlayerObjectTemplate::ServerPlayerObjectTemplate
|
||||
|
||||
@@ -46,8 +46,8 @@ ServerPlayerObjectTemplate::ServerPlayerObjectTemplate(const std::string & filen
|
||||
*/
|
||||
ServerPlayerObjectTemplate::~ServerPlayerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerPlayerObjectTemplate::~ServerPlayerObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ Object * ServerPlayerObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerPlayerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerPlayerObjectTemplate_tag)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -154,10 +154,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -175,4 +173,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerPlayerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-14
@@ -24,20 +24,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerPlayerQuestObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerPlayerQuestObjectTemplate::ServerPlayerQuestObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerPlayerQuestObjectTemplate::ServerPlayerQuestObjectTemplate
|
||||
|
||||
@@ -46,8 +46,8 @@ ServerPlayerQuestObjectTemplate::ServerPlayerQuestObjectTemplate(const std::stri
|
||||
*/
|
||||
ServerPlayerQuestObjectTemplate::~ServerPlayerQuestObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerPlayerQuestObjectTemplate::~ServerPlayerQuestObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,6 @@ Object * ServerPlayerQuestObjectTemplate::createObject(void) const
|
||||
return new PlayerQuestObject(this);
|
||||
} // ServerMissionObjectTemplate::createObject
|
||||
|
||||
|
||||
//@BEGIN TFD
|
||||
|
||||
/**
|
||||
@@ -124,8 +123,8 @@ Object * ServerPlayerQuestObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerPlayerQuestObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerPlayerQuestObjectTemplate_tag)
|
||||
{
|
||||
@@ -135,7 +134,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -155,10 +154,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -176,4 +173,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerPlayerQuestObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-20
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerResourceContainerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerResourceContainerObjectTemplate::ServerResourceContainerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerResourceContainerObjectTemplate::ServerResourceContainerObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerResourceContainerObjectTemplate::ServerResourceContainerObjectTemplate(con
|
||||
*/
|
||||
ServerResourceContainerObjectTemplate::~ServerResourceContainerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerResourceContainerObjectTemplate::~ServerResourceContainerObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerResourceContainerObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
int ServerResourceContainerObjectTemplate::getMaxResources() const
|
||||
{
|
||||
|
||||
|
||||
const ServerResourceContainerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -165,8 +163,6 @@ int ServerResourceContainerObjectTemplate::getMaxResources() const
|
||||
|
||||
int ServerResourceContainerObjectTemplate::getMaxResourcesMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerResourceContainerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -216,8 +212,6 @@ int ServerResourceContainerObjectTemplate::getMaxResourcesMin() const
|
||||
|
||||
int ServerResourceContainerObjectTemplate::getMaxResourcesMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerResourceContainerObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -265,7 +259,6 @@ int ServerResourceContainerObjectTemplate::getMaxResourcesMax() const
|
||||
return value;
|
||||
} // ServerResourceContainerObjectTemplate::getMaxResourcesMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -274,8 +267,8 @@ int ServerResourceContainerObjectTemplate::getMaxResourcesMax() const
|
||||
*/
|
||||
void ServerResourceContainerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerResourceContainerObjectTemplate_tag)
|
||||
{
|
||||
@@ -285,7 +278,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -305,10 +298,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -332,4 +323,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerResourceContainerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-16
@@ -23,20 +23,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerShipObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerShipObjectTemplate::ServerShipObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerShipObjectTemplate::ServerShipObjectTemplate
|
||||
|
||||
@@ -45,8 +45,8 @@ ServerShipObjectTemplate::ServerShipObjectTemplate(const std::string & filename)
|
||||
*/
|
||||
ServerShipObjectTemplate::~ServerShipObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerShipObjectTemplate::~ServerShipObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -115,8 +115,6 @@ Object * ServerShipObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerShipObjectTemplate::getShipType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerShipObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -142,7 +140,6 @@ const std::string & ServerShipObjectTemplate::getShipType() const
|
||||
return value;
|
||||
} // ServerShipObjectTemplate::getShipType
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -151,8 +148,8 @@ const std::string & ServerShipObjectTemplate::getShipType() const
|
||||
*/
|
||||
void ServerShipObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerShipObjectTemplate_tag)
|
||||
{
|
||||
@@ -162,7 +159,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -182,10 +179,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -209,4 +204,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerShipObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-16
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerStaticObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerStaticObjectTemplate::ServerStaticObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerStaticObjectTemplate::ServerStaticObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerStaticObjectTemplate::ServerStaticObjectTemplate(const std::string & filen
|
||||
*/
|
||||
ServerStaticObjectTemplate::~ServerStaticObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerStaticObjectTemplate::~ServerStaticObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerStaticObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
bool ServerStaticObjectTemplate::getClientOnlyBuildout() const
|
||||
{
|
||||
|
||||
|
||||
const ServerStaticObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -141,7 +139,6 @@ bool ServerStaticObjectTemplate::getClientOnlyBuildout() const
|
||||
return value;
|
||||
} // ServerStaticObjectTemplate::getClientOnlyBuildout
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -150,8 +147,8 @@ bool ServerStaticObjectTemplate::getClientOnlyBuildout() const
|
||||
*/
|
||||
void ServerStaticObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerStaticObjectTemplate_tag)
|
||||
{
|
||||
@@ -161,7 +158,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -181,10 +178,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -208,4 +203,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerStaticObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+14
-45
@@ -23,22 +23,22 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerTangibleObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerTangibleObjectTemplate::ServerTangibleObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_triggerVolumesLoaded(false)
|
||||
,m_triggerVolumesAppend(false)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_triggerVolumesLoaded(false)
|
||||
, m_triggerVolumesAppend(false)
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerTangibleObjectTemplate::ServerTangibleObjectTemplate
|
||||
|
||||
@@ -47,7 +47,7 @@ ServerTangibleObjectTemplate::ServerTangibleObjectTemplate(const std::string & f
|
||||
*/
|
||||
ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
{
|
||||
std::vector<TriggerVolumeParam *>::iterator iter;
|
||||
for (iter = m_triggerVolumes.begin(); iter != m_triggerVolumes.end(); ++iter)
|
||||
@@ -57,7 +57,7 @@ ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate()
|
||||
}
|
||||
m_triggerVolumes.clear();
|
||||
}
|
||||
//@END TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerTangibleObjectTemplate::~ServerTangibleObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -186,8 +186,6 @@ size_t ServerTangibleObjectTemplate::getTriggerVolumesCount(void) const
|
||||
|
||||
ServerTangibleObjectTemplate::CombatSkeleton ServerTangibleObjectTemplate::getCombatSkeleton() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -215,8 +213,6 @@ ServerTangibleObjectTemplate::CombatSkeleton ServerTangibleObjectTemplate::getCo
|
||||
|
||||
int ServerTangibleObjectTemplate::getMaxHitPoints() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -266,8 +262,6 @@ int ServerTangibleObjectTemplate::getMaxHitPoints() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getMaxHitPointsMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -317,8 +311,6 @@ int ServerTangibleObjectTemplate::getMaxHitPointsMin() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getMaxHitPointsMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -394,15 +386,13 @@ const ServerArmorTemplate * ServerTangibleObjectTemplate::getArmor() const
|
||||
{
|
||||
returnValue = dynamic_cast<const ServerArmorTemplate *>(ObjectTemplateList::fetch(templateName));
|
||||
if (returnValue == nullptr)
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s",templateName.c_str()));
|
||||
WARNING_STRICT_FATAL(true, ("Error loading template %s", templateName.c_str()));
|
||||
}
|
||||
return returnValue;
|
||||
} // ServerTangibleObjectTemplate::getArmor
|
||||
|
||||
int ServerTangibleObjectTemplate::getInterestRadius() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -452,8 +442,6 @@ int ServerTangibleObjectTemplate::getInterestRadius() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getInterestRadiusMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -503,8 +491,6 @@ int ServerTangibleObjectTemplate::getInterestRadiusMin() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getInterestRadiusMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -554,8 +540,6 @@ int ServerTangibleObjectTemplate::getInterestRadiusMax() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getCount() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -605,8 +589,6 @@ int ServerTangibleObjectTemplate::getCount() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getCountMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -656,8 +638,6 @@ int ServerTangibleObjectTemplate::getCountMin() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getCountMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -707,8 +687,6 @@ int ServerTangibleObjectTemplate::getCountMax() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getCondition() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -758,8 +736,6 @@ int ServerTangibleObjectTemplate::getCondition() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getConditionMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -809,8 +785,6 @@ int ServerTangibleObjectTemplate::getConditionMin() const
|
||||
|
||||
int ServerTangibleObjectTemplate::getConditionMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -860,8 +834,6 @@ int ServerTangibleObjectTemplate::getConditionMax() const
|
||||
|
||||
bool ServerTangibleObjectTemplate::getWantSawAttackTriggers() const
|
||||
{
|
||||
|
||||
|
||||
const ServerTangibleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -887,7 +859,6 @@ bool ServerTangibleObjectTemplate::getWantSawAttackTriggers() const
|
||||
return value;
|
||||
} // ServerTangibleObjectTemplate::getWantSawAttackTriggers
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -896,8 +867,8 @@ bool ServerTangibleObjectTemplate::getWantSawAttackTriggers() const
|
||||
*/
|
||||
void ServerTangibleObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerTangibleObjectTemplate_tag)
|
||||
{
|
||||
@@ -907,7 +878,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -927,10 +898,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,4))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 4))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -985,4 +954,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerTangibleObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-13
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerUniverseObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerUniverseObjectTemplate::ServerUniverseObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerUniverseObjectTemplate::ServerUniverseObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerUniverseObjectTemplate::ServerUniverseObjectTemplate(const std::string & f
|
||||
*/
|
||||
ServerUniverseObjectTemplate::~ServerUniverseObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerUniverseObjectTemplate::~ServerUniverseObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -121,8 +121,8 @@ Object * ServerUniverseObjectTemplate::createObject(void) const
|
||||
*/
|
||||
void ServerUniverseObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerUniverseObjectTemplate_tag)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -152,10 +152,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -173,4 +171,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerUniverseObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-34
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerVehicleObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerVehicleObjectTemplate::ServerVehicleObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerVehicleObjectTemplate::ServerVehicleObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerVehicleObjectTemplate::ServerVehicleObjectTemplate(const std::string & fil
|
||||
*/
|
||||
ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerVehicleObjectTemplate::~ServerVehicleObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerVehicleObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
const std::string & ServerVehicleObjectTemplate::getFuelType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -143,8 +141,6 @@ const std::string & ServerVehicleObjectTemplate::getFuelType() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getCurrentFuel() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -194,8 +190,6 @@ float ServerVehicleObjectTemplate::getCurrentFuel() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getCurrentFuelMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -245,8 +239,6 @@ float ServerVehicleObjectTemplate::getCurrentFuelMin() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getCurrentFuelMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -296,8 +288,6 @@ float ServerVehicleObjectTemplate::getCurrentFuelMax() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getMaxFuel() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -347,8 +337,6 @@ float ServerVehicleObjectTemplate::getMaxFuel() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getMaxFuelMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -398,8 +386,6 @@ float ServerVehicleObjectTemplate::getMaxFuelMin() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getMaxFuelMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -449,8 +435,6 @@ float ServerVehicleObjectTemplate::getMaxFuelMax() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getConsumpsion() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -500,8 +484,6 @@ float ServerVehicleObjectTemplate::getConsumpsion() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getConsumpsionMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -551,8 +533,6 @@ float ServerVehicleObjectTemplate::getConsumpsionMin() const
|
||||
|
||||
float ServerVehicleObjectTemplate::getConsumpsionMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerVehicleObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -600,7 +580,6 @@ float ServerVehicleObjectTemplate::getConsumpsionMax() const
|
||||
return value;
|
||||
} // ServerVehicleObjectTemplate::getConsumpsionMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -609,8 +588,8 @@ float ServerVehicleObjectTemplate::getConsumpsionMax() const
|
||||
*/
|
||||
void ServerVehicleObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerVehicleObjectTemplate_tag)
|
||||
{
|
||||
@@ -620,7 +599,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -640,10 +619,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -673,4 +650,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerVehicleObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+11
-88
@@ -22,20 +22,20 @@
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const Vector DefaultVector(0, 0, 0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerWeaponObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerWeaponObjectTemplate::ServerWeaponObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerTangibleObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
, m_versionOk(true)
|
||||
, m_templateVersion(0)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerWeaponObjectTemplate::ServerWeaponObjectTemplate
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerWeaponObjectTemplate::ServerWeaponObjectTemplate(const std::string & filen
|
||||
*/
|
||||
ServerWeaponObjectTemplate::~ServerWeaponObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerWeaponObjectTemplate::~ServerWeaponObjectTemplate
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,6 @@ Object * ServerWeaponObjectTemplate::createObject(void) const
|
||||
//@BEGIN TFD
|
||||
ServerWeaponObjectTemplate::WeaponType ServerWeaponObjectTemplate::getWeaponType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -143,8 +141,6 @@ ServerWeaponObjectTemplate::WeaponType ServerWeaponObjectTemplate::getWeaponType
|
||||
|
||||
ServerWeaponObjectTemplate::AttackType ServerWeaponObjectTemplate::getAttackType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -172,8 +168,6 @@ ServerWeaponObjectTemplate::AttackType ServerWeaponObjectTemplate::getAttackType
|
||||
|
||||
ServerWeaponObjectTemplate::DamageType ServerWeaponObjectTemplate::getDamageType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -201,8 +195,6 @@ ServerWeaponObjectTemplate::DamageType ServerWeaponObjectTemplate::getDamageType
|
||||
|
||||
ServerWeaponObjectTemplate::DamageType ServerWeaponObjectTemplate::getElementalType() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -230,8 +222,6 @@ ServerWeaponObjectTemplate::DamageType ServerWeaponObjectTemplate::getElementalT
|
||||
|
||||
int ServerWeaponObjectTemplate::getElementalValue() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -281,8 +271,6 @@ int ServerWeaponObjectTemplate::getElementalValue() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getElementalValueMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -332,8 +320,6 @@ int ServerWeaponObjectTemplate::getElementalValueMin() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getElementalValueMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -383,8 +369,6 @@ int ServerWeaponObjectTemplate::getElementalValueMax() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getMinDamageAmount() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -434,8 +418,6 @@ int ServerWeaponObjectTemplate::getMinDamageAmount() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getMinDamageAmountMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -485,8 +467,6 @@ int ServerWeaponObjectTemplate::getMinDamageAmountMin() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getMinDamageAmountMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -536,8 +516,6 @@ int ServerWeaponObjectTemplate::getMinDamageAmountMax() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getMaxDamageAmount() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -587,8 +565,6 @@ int ServerWeaponObjectTemplate::getMaxDamageAmount() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getMaxDamageAmountMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -638,8 +614,6 @@ int ServerWeaponObjectTemplate::getMaxDamageAmountMin() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getMaxDamageAmountMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -689,8 +663,6 @@ int ServerWeaponObjectTemplate::getMaxDamageAmountMax() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getAttackSpeed() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -740,8 +712,6 @@ float ServerWeaponObjectTemplate::getAttackSpeed() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getAttackSpeedMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -791,8 +761,6 @@ float ServerWeaponObjectTemplate::getAttackSpeedMin() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getAttackSpeedMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -842,8 +810,6 @@ float ServerWeaponObjectTemplate::getAttackSpeedMax() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getAudibleRange() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -893,8 +859,6 @@ float ServerWeaponObjectTemplate::getAudibleRange() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getAudibleRangeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -944,8 +908,6 @@ float ServerWeaponObjectTemplate::getAudibleRangeMin() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getAudibleRangeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -995,8 +957,6 @@ float ServerWeaponObjectTemplate::getAudibleRangeMax() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getMinRange() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1046,8 +1006,6 @@ float ServerWeaponObjectTemplate::getMinRange() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getMinRangeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1097,8 +1055,6 @@ float ServerWeaponObjectTemplate::getMinRangeMin() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getMinRangeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1148,8 +1104,6 @@ float ServerWeaponObjectTemplate::getMinRangeMax() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getMaxRange() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1199,8 +1153,6 @@ float ServerWeaponObjectTemplate::getMaxRange() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getMaxRangeMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1250,8 +1202,6 @@ float ServerWeaponObjectTemplate::getMaxRangeMin() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getMaxRangeMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1301,8 +1251,6 @@ float ServerWeaponObjectTemplate::getMaxRangeMax() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getDamageRadius() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1352,8 +1300,6 @@ float ServerWeaponObjectTemplate::getDamageRadius() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getDamageRadiusMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1403,8 +1349,6 @@ float ServerWeaponObjectTemplate::getDamageRadiusMin() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getDamageRadiusMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1454,8 +1398,6 @@ float ServerWeaponObjectTemplate::getDamageRadiusMax() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getWoundChance() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1505,8 +1447,6 @@ float ServerWeaponObjectTemplate::getWoundChance() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getWoundChanceMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1556,8 +1496,6 @@ float ServerWeaponObjectTemplate::getWoundChanceMin() const
|
||||
|
||||
float ServerWeaponObjectTemplate::getWoundChanceMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1607,8 +1545,6 @@ float ServerWeaponObjectTemplate::getWoundChanceMax() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getAttackCost() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1658,8 +1594,6 @@ int ServerWeaponObjectTemplate::getAttackCost() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getAttackCostMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1709,8 +1643,6 @@ int ServerWeaponObjectTemplate::getAttackCostMin() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getAttackCostMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1760,8 +1692,6 @@ int ServerWeaponObjectTemplate::getAttackCostMax() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getAccuracy() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1811,8 +1741,6 @@ int ServerWeaponObjectTemplate::getAccuracy() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getAccuracyMin() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1862,8 +1790,6 @@ int ServerWeaponObjectTemplate::getAccuracyMin() const
|
||||
|
||||
int ServerWeaponObjectTemplate::getAccuracyMax() const
|
||||
{
|
||||
|
||||
|
||||
const ServerWeaponObjectTemplate * base = nullptr;
|
||||
if (m_baseData != nullptr)
|
||||
{
|
||||
@@ -1911,7 +1837,6 @@ int ServerWeaponObjectTemplate::getAccuracyMax() const
|
||||
return value;
|
||||
} // ServerWeaponObjectTemplate::getAccuracyMax
|
||||
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
@@ -1920,8 +1845,8 @@ int ServerWeaponObjectTemplate::getAccuracyMax() const
|
||||
*/
|
||||
void ServerWeaponObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerWeaponObjectTemplate_tag)
|
||||
{
|
||||
@@ -1931,7 +1856,7 @@ char paramName[MAX_NAME_SIZE];
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
if (m_templateVersion == TAG(D, E, R, V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
@@ -1951,10 +1876,8 @@ char paramName[MAX_NAME_SIZE];
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,1,1))
|
||||
if (getHighestTemplateVersion() != TAG(0, 0, 1, 1))
|
||||
{
|
||||
|
||||
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
@@ -2006,4 +1929,4 @@ char paramName[MAX_NAME_SIZE];
|
||||
return;
|
||||
} // ServerWeaponObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
//@END TFD
|
||||
+22
-24
@@ -7,7 +7,6 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
|
||||
#ifndef INCLUDED_MessageQueueDraftSlots_H
|
||||
#define INCLUDED_MessageQueueDraftSlots_H
|
||||
|
||||
@@ -40,17 +39,17 @@ public:
|
||||
const Slot & getSlot(int index) const;
|
||||
|
||||
typedef stdvector<Slot>::fwd SlotVector;
|
||||
const SlotVector & getSlots () const;
|
||||
void setSlots (const SlotVector & sv);
|
||||
const SlotVector & getSlots() const;
|
||||
void setSlots(const SlotVector & sv);
|
||||
|
||||
void setManfSchemId (const NetworkId & id);
|
||||
const NetworkId & getManfSchemId () const;
|
||||
void setManfSchemId(const NetworkId & id);
|
||||
const NetworkId & getManfSchemId() const;
|
||||
|
||||
void setPrototypeId (const NetworkId & id);
|
||||
const NetworkId & getPrototypeId () const;
|
||||
void setPrototypeId(const NetworkId & id);
|
||||
const NetworkId & getPrototypeId() const;
|
||||
|
||||
void setVolume (int volume);
|
||||
int getVolume () const;
|
||||
void setVolume(int volume);
|
||||
int getVolume() const;
|
||||
|
||||
void setCanManufacture(bool canManufacture);
|
||||
bool canManufacture() const;
|
||||
@@ -64,15 +63,15 @@ private:
|
||||
bool m_canManufacture;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline MessageQueueDraftSlots::MessageQueueDraftSlots(const NetworkId & toolId, const NetworkId & manfSchemId) :
|
||||
m_slots (),
|
||||
m_toolId (toolId),
|
||||
m_manfSchemId (manfSchemId),
|
||||
m_prototypeId (),
|
||||
m_volume (1)
|
||||
m_slots(),
|
||||
m_toolId(toolId),
|
||||
m_manfSchemId(manfSchemId),
|
||||
m_prototypeId(),
|
||||
m_volume(1),
|
||||
m_canManufacture()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -107,56 +106,56 @@ inline const MessageQueueDraftSlots::Slot & MessageQueueDraftSlots::getSlot(int
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline void MessageQueueDraftSlots::setSlots (const SlotVector & sv)
|
||||
inline void MessageQueueDraftSlots::setSlots(const SlotVector & sv)
|
||||
{
|
||||
m_slots = sv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline const MessageQueueDraftSlots::SlotVector & MessageQueueDraftSlots::getSlots () const
|
||||
inline const MessageQueueDraftSlots::SlotVector & MessageQueueDraftSlots::getSlots() const
|
||||
{
|
||||
return m_slots;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline void MessageQueueDraftSlots::setManfSchemId (const NetworkId & id)
|
||||
inline void MessageQueueDraftSlots::setManfSchemId(const NetworkId & id)
|
||||
{
|
||||
m_manfSchemId = id;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline const NetworkId & MessageQueueDraftSlots::getManfSchemId () const
|
||||
inline const NetworkId & MessageQueueDraftSlots::getManfSchemId() const
|
||||
{
|
||||
return m_manfSchemId;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline void MessageQueueDraftSlots::setPrototypeId (const NetworkId & id)
|
||||
inline void MessageQueueDraftSlots::setPrototypeId(const NetworkId & id)
|
||||
{
|
||||
m_prototypeId = id;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline const NetworkId & MessageQueueDraftSlots::getPrototypeId () const
|
||||
inline const NetworkId & MessageQueueDraftSlots::getPrototypeId() const
|
||||
{
|
||||
return m_prototypeId;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline void MessageQueueDraftSlots::setVolume (int volume)
|
||||
inline void MessageQueueDraftSlots::setVolume(int volume)
|
||||
{
|
||||
m_volume = volume;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline int MessageQueueDraftSlots::getVolume () const
|
||||
inline int MessageQueueDraftSlots::getVolume() const
|
||||
{
|
||||
return m_volume;
|
||||
}
|
||||
@@ -177,5 +176,4 @@ inline bool MessageQueueDraftSlots::canManufacture() const
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // INCLUDED_MessageQueueDraftSlots_H
|
||||
|
||||
+199
-216
@@ -10,46 +10,45 @@
|
||||
// ********************************** DO NOT EDIT THIS FILE ***********************************
|
||||
// **********************************************************************************************
|
||||
// **********************************************************************************************
|
||||
void set_bit( unsigned char p[], int bit){ p[bit >> 3] |= 1 << (bit & 0x7); }
|
||||
void unset_bit(unsigned char p[], int bit){ p[bit >> 3] &= ~(1 << (bit & 0x7)); }
|
||||
int get_bit( unsigned char p[], int bit){ return (p[bit >> 3] >> (bit & 0x7)) & 1; }
|
||||
int ZEXPORT uncompress2( Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
|
||||
|
||||
void set_bit(unsigned char p[], int bit) { p[bit >> 3] |= 1 << (bit & 0x7); }
|
||||
void unset_bit(unsigned char p[], int bit) { p[bit >> 3] &= ~(1 << (bit & 0x7)); }
|
||||
int get_bit(unsigned char p[], int bit) { return (p[bit >> 3] >> (bit & 0x7)) & 1; }
|
||||
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
|
||||
|
||||
////////////////////////////////////////
|
||||
// Player implementation
|
||||
////////////////////////////////////////
|
||||
MonitorObject::MonitorObject(UdpConnection *con,CMonitorData *_gamedata, char *passwd, char **addressList,bool _bprint)
|
||||
MonitorObject::MonitorObject(UdpConnection *con, CMonitorData *_gamedata, char *passwd, char **addressList, bool _bprint)
|
||||
{
|
||||
mbprint = _bprint;
|
||||
mMonitorData = _gamedata;
|
||||
mbAuthenticated = false;
|
||||
mPasswd = passwd;
|
||||
mAddressList = addressList;
|
||||
mHierarchySent = false;
|
||||
mSequence = 1;
|
||||
mbprint = _bprint;
|
||||
mMonitorData = _gamedata;
|
||||
mbAuthenticated = false;
|
||||
mPasswd = passwd;
|
||||
mAddressList = addressList;
|
||||
mHierarchySent = false;
|
||||
mSequence = 1;
|
||||
mlastUpdateTime = 0;
|
||||
mConnection = con;
|
||||
mConnection = con;
|
||||
mConnection->AddRef();
|
||||
mConnection->SetHandler(this);
|
||||
|
||||
// Flag all the descriptions
|
||||
mMark = new unsigned char [ (mMonitorData->DataMax()/8)+2];
|
||||
memset(mMark,0,(mMonitorData->DataMax()/8)+2);
|
||||
mMark = new unsigned char[(mMonitorData->DataMax() / 8) + 2];
|
||||
memset(mMark, 0, (mMonitorData->DataMax() / 8) + 2);
|
||||
char hold[256];
|
||||
if( mbprint )
|
||||
if (mbprint)
|
||||
{
|
||||
fprintf(stderr,"MONITOR API CONNECTED: %s:%d\n",
|
||||
mConnection->GetDestinationIp().GetAddress(hold),
|
||||
fprintf(stderr, "MONITOR API CONNECTED: %s:%d\n",
|
||||
mConnection->GetDestinationIp().GetAddress(hold),
|
||||
mConnection->GetDestinationPort());
|
||||
}
|
||||
}
|
||||
|
||||
MonitorObject::~MonitorObject()
|
||||
{
|
||||
delete [] mMark;
|
||||
delete[] mMark;
|
||||
|
||||
if( mConnection )
|
||||
if (mConnection)
|
||||
{
|
||||
mConnection->SetHandler(nullptr);
|
||||
mConnection->Disconnect();
|
||||
@@ -57,22 +56,22 @@ MonitorObject::~MonitorObject()
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorObject::OnTerminated( UdpConnection * /* con */)
|
||||
void MonitorObject::OnTerminated(UdpConnection * /* con */)
|
||||
{
|
||||
char hold[214];
|
||||
char hold[214];
|
||||
|
||||
if( mConnection )
|
||||
if (mConnection)
|
||||
{
|
||||
if( mbprint )
|
||||
if (mbprint)
|
||||
{
|
||||
mConnection->GetDestinationIp().GetAddress(hold);
|
||||
if( mbprint )
|
||||
if (mbprint)
|
||||
{
|
||||
fprintf(stderr,"MONITOR API TERMINATE %s:%d %s - %s\n",
|
||||
hold,
|
||||
fprintf(stderr, "MONITOR API TERMINATE %s:%d %s - %s\n",
|
||||
hold,
|
||||
mConnection->GetDestinationPort(),
|
||||
UdpConnection::DisconnectReasonText( mConnection->GetDisconnectReason()),
|
||||
UdpConnection::DisconnectReasonText( mConnection->GetOtherSideDisconnectReason()));
|
||||
UdpConnection::DisconnectReasonText(mConnection->GetDisconnectReason()),
|
||||
UdpConnection::DisconnectReasonText(mConnection->GetOtherSideDisconnectReason()));
|
||||
}
|
||||
}
|
||||
mConnection->SetHandler(nullptr);
|
||||
@@ -82,32 +81,30 @@ char hold[214];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MonitorObject::OnRoutePacket( UdpConnection * con, const unsigned char *data, int dataLen)
|
||||
void MonitorObject::OnRoutePacket(UdpConnection * con, const unsigned char *data, int dataLen)
|
||||
{
|
||||
|
||||
if( dataLen < 6 )
|
||||
if (dataLen < 6)
|
||||
{
|
||||
if( mbprint )
|
||||
fprintf(stderr,"MONITOR API: This should not happen, line %d\n",__LINE__);
|
||||
if (mbprint)
|
||||
fprintf(stderr, "MONITOR API: This should not happen, line %d\n", __LINE__);
|
||||
}
|
||||
|
||||
simpleMessage msg(data);
|
||||
|
||||
if( con == nullptr )
|
||||
if (con == nullptr)
|
||||
{
|
||||
if( mbprint)
|
||||
fprintf(stderr,"MONITOR API: MonitorObject.OnRoutePacket, recived a nullptr connection.?\n");
|
||||
if (mbprint)
|
||||
fprintf(stderr, "MONITOR API: MonitorObject.OnRoutePacket, recived a nullptr connection.?\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// ************************* Login Process ***************************
|
||||
if ( mbAuthenticated == false )
|
||||
{
|
||||
if ( msg.getCommand() != MON_MSG_AUTH )
|
||||
return;
|
||||
if (mbAuthenticated == false)
|
||||
{
|
||||
if (msg.getCommand() != MON_MSG_AUTH)
|
||||
return;
|
||||
|
||||
if( processAuthRequest(data, dataLen) == false )
|
||||
if (processAuthRequest(data, dataLen) == false)
|
||||
return;
|
||||
|
||||
mbAuthenticated = true;
|
||||
@@ -115,21 +112,20 @@ void MonitorObject::OnRoutePacket( UdpConnection * con, const unsigned char *da
|
||||
}
|
||||
|
||||
// ************************* Process Commands ***********************
|
||||
switch(msg.getCommand())
|
||||
switch (msg.getCommand())
|
||||
{
|
||||
|
||||
// *********************** Game Server Processing ******************
|
||||
// *********************** Game Server Processing ******************
|
||||
case MON_MSG_QUERY_ELEMENTS:
|
||||
if( mHierarchySent == true )
|
||||
{
|
||||
mMonitorData->processElementsRequest(con,mSequence,(char *)&data[6],dataLen,mlastUpdateTime );
|
||||
if (mHierarchySent == true)
|
||||
{
|
||||
mMonitorData->processElementsRequest(con, mSequence, (char *)&data[6], dataLen, mlastUpdateTime);
|
||||
mlastUpdateTime = (long)time(nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
// When the hierarchy has changed, fall through
|
||||
case MON_MSG_QUERY_HIERARCHY_BLOCK:
|
||||
if( mMonitorData->processHierarchyRequestBlock(con,mSequence) == false)
|
||||
if (mMonitorData->processHierarchyRequestBlock(con, mSequence) == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -137,7 +133,7 @@ void MonitorObject::OnRoutePacket( UdpConnection * con, const unsigned char *da
|
||||
break;
|
||||
|
||||
case MON_MSG_QUERY_DESCRIPTION:
|
||||
mMonitorData->processDescriptionRequest(con,mSequence,(char *)&data[6], dataLen,mMark);
|
||||
mMonitorData->processDescriptionRequest(con, mSequence, (char *)&data[6], dataLen, mMark);
|
||||
break;
|
||||
|
||||
case MON_MSG_ERROR:
|
||||
@@ -145,43 +141,41 @@ void MonitorObject::OnRoutePacket( UdpConnection * con, const unsigned char *da
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"MONITOR API: unknown message type received from client [%x]\n",msg.getCommand());
|
||||
fprintf(stderr, "MONITOR API: unknown message type received from client [%x]\n", msg.getCommand());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MonitorObject::checkAddress(const char * address)
|
||||
{
|
||||
int x = 0;
|
||||
while( mAddressList[x] )
|
||||
int x = 0;
|
||||
while (mAddressList[x])
|
||||
{
|
||||
if (strncmp(mAddressList[x], address, strlen(mAddressList[x]))== 0)
|
||||
if (strncmp(mAddressList[x], address, strlen(mAddressList[x])) == 0)
|
||||
return true;
|
||||
x++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MonitorObject::checkPasswd( const char *passwd)
|
||||
bool MonitorObject::checkPasswd(const char *passwd)
|
||||
{
|
||||
if (strcmp(mPasswd,passwd)== 0 )
|
||||
if (strcmp(mPasswd, passwd) == 0)
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MonitorObject::processAuthRequest(const unsigned char * data, int /* dataLen */)
|
||||
{
|
||||
char reply;
|
||||
stringMessage strMsg(data);
|
||||
char addBuff[16] = {0};
|
||||
char sendBuf[32];
|
||||
int len;
|
||||
|
||||
char reply;
|
||||
stringMessage strMsg(data);
|
||||
char addBuff[16] = { 0 };
|
||||
char sendBuf[32];
|
||||
int len;
|
||||
|
||||
reply = '1';
|
||||
|
||||
if ( checkAddress(mConnection->GetDestinationIp().GetAddress(addBuff)) == false)
|
||||
|
||||
if (checkAddress(mConnection->GetDestinationIp().GetAddress(addBuff)) == false)
|
||||
{
|
||||
reply = '3';
|
||||
}
|
||||
@@ -191,21 +185,21 @@ int len;
|
||||
}
|
||||
|
||||
memset(sendBuf, 0, sizeof(sendBuf));
|
||||
|
||||
|
||||
len = 0;
|
||||
packShort( sendBuf + len, len,(short)MON_MSG_AUTHREPLY);
|
||||
packShort( sendBuf + len, len, mSequence);
|
||||
packShort( sendBuf + len, len,(short)3);
|
||||
packShort( sendBuf + len, len,(short)CURRENT_API_VERSION);
|
||||
packByte( sendBuf + len, len, reply);
|
||||
|
||||
mConnection->Send(cUdpChannelReliable1, sendBuf, 9 );
|
||||
packShort(sendBuf + len, len, (short)MON_MSG_AUTHREPLY);
|
||||
packShort(sendBuf + len, len, mSequence);
|
||||
packShort(sendBuf + len, len, (short)3);
|
||||
packShort(sendBuf + len, len, (short)CURRENT_API_VERSION);
|
||||
packByte(sendBuf + len, len, reply);
|
||||
|
||||
mConnection->Send(cUdpChannelReliable1, sendBuf, 9);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MonitorObject::DescriptionMark(int x,int mode)
|
||||
void MonitorObject::DescriptionMark(int x, int mode)
|
||||
{
|
||||
if( mode == 0 ) set_bit(mMark,x); else unset_bit(mMark,x);
|
||||
if (mode == 0) set_bit(mMark, x); else unset_bit(mMark, x);
|
||||
}
|
||||
|
||||
char * getErrorString(unsigned short errorCode)
|
||||
@@ -240,7 +234,6 @@ char * getErrorString(unsigned short errorCode)
|
||||
|
||||
case INVALID_ERROR_CODE:
|
||||
return "Received invalid error message";
|
||||
|
||||
}
|
||||
}
|
||||
return "Undefined error code";
|
||||
@@ -250,7 +243,7 @@ bool MonitorObject::processError(const unsigned char * data)
|
||||
{
|
||||
stringMessage strMsg(data);
|
||||
unsigned short errCode = (unsigned short)atoi(strMsg.getData());
|
||||
fprintf(stderr,"MONITOR API Error: %s\n", getErrorString(errCode));
|
||||
fprintf(stderr, "MONITOR API Error: %s\n", getErrorString(errCode));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -261,46 +254,46 @@ MonitorManager::MonitorManager(const char *configFile, CMonitorData *_gamedata,
|
||||
{
|
||||
mManager = manager;
|
||||
mbprint = _bprint;
|
||||
passString = nullptr;
|
||||
passString = nullptr;
|
||||
mMonitorData = _gamedata;
|
||||
mObjectCount = 0;
|
||||
|
||||
for(int x=0;x<AUTHADDRESS_MAX;x++)
|
||||
for (int x = 0; x < AUTHADDRESS_MAX; x++)
|
||||
allowedAddressList[x] = 0;
|
||||
|
||||
|
||||
loadAuthData(configFile);
|
||||
}
|
||||
|
||||
MonitorManager::~MonitorManager()
|
||||
{
|
||||
int x;
|
||||
int x;
|
||||
|
||||
x=0;
|
||||
while( allowedAddressList[x])
|
||||
x = 0;
|
||||
while (allowedAddressList[x])
|
||||
free(allowedAddressList[x++]);
|
||||
|
||||
free( passString );
|
||||
free(passString);
|
||||
|
||||
for (int i =0; i < mObjectCount; i++ )
|
||||
for (int i = 0; i < mObjectCount; i++)
|
||||
delete mObject[i];
|
||||
}
|
||||
|
||||
void MonitorManager::OnConnectRequest(UdpConnection *con)
|
||||
{
|
||||
if( mObjectCount == CONNECTION_MAX )
|
||||
if (mObjectCount == CONNECTION_MAX)
|
||||
{
|
||||
if( con )
|
||||
if (con)
|
||||
{
|
||||
con->SetHandler(nullptr);
|
||||
con->Disconnect();
|
||||
con->Release();
|
||||
}
|
||||
if( mbprint )
|
||||
fprintf(stderr,"MonitorAPI: Collector connection reached max (%d).\n",CONNECTION_MAX);
|
||||
if (mbprint)
|
||||
fprintf(stderr, "MonitorAPI: Collector connection reached max (%d).\n", CONNECTION_MAX);
|
||||
return;
|
||||
}
|
||||
|
||||
AddObject(new MonitorObject(con,mMonitorData,passString,allowedAddressList,mbprint));
|
||||
|
||||
AddObject(new MonitorObject(con, mMonitorData, passString, allowedAddressList, mbprint));
|
||||
}
|
||||
|
||||
void MonitorManager::AddObject(MonitorObject *Object)
|
||||
@@ -313,8 +306,8 @@ void MonitorManager::GiveTime()
|
||||
// check if the monitor object is no longer connected
|
||||
for (int i = 0; i < mObjectCount; i++)
|
||||
{
|
||||
if( mObject[i]->mConnection == nullptr ||
|
||||
mObject[i]->mConnection->GetStatus() == UdpConnection::cStatusDisconnected )
|
||||
if (mObject[i]->mConnection == nullptr ||
|
||||
mObject[i]->mConnection->GetStatus() == UdpConnection::cStatusDisconnected)
|
||||
{
|
||||
MonitorObject *o = mObject[i];
|
||||
mObjectCount--;
|
||||
@@ -331,32 +324,31 @@ void MonitorManager::HierarchyChanged()
|
||||
mObject[i]->HeirarchyChanged();
|
||||
}
|
||||
|
||||
void MonitorManager::DescriptionMark(int x ,int mode)
|
||||
void MonitorManager::DescriptionMark(int x, int mode)
|
||||
{
|
||||
for (int i = 0; i < mObjectCount; i++)
|
||||
mObject[i]->DescriptionMark(x,mode);
|
||||
mObject[i]->DescriptionMark(x, mode);
|
||||
}
|
||||
|
||||
bool MonitorManager::loadAuthData(const char * filename)
|
||||
{
|
||||
int nline;
|
||||
int len;
|
||||
int x;
|
||||
char buffer[1024];
|
||||
int nline;
|
||||
int len;
|
||||
int x;
|
||||
char buffer[1024];
|
||||
|
||||
FILE *fp = fopen(filename,"r");
|
||||
FILE *fp = fopen(filename, "r");
|
||||
if (fp == nullptr)
|
||||
{
|
||||
fprintf(stderr,"Monitor API: could not open %s file\nTHIS FILE IS REQUIRED.\n", filename);
|
||||
fprintf(stderr, "Monitor API: could not open %s file\nTHIS FILE IS REQUIRED.\n", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
free(passString);
|
||||
|
||||
|
||||
for(x=0;x<AUTHADDRESS_MAX;x++)
|
||||
for (x = 0; x < AUTHADDRESS_MAX; x++)
|
||||
{
|
||||
if( allowedAddressList[x] )
|
||||
if (allowedAddressList[x])
|
||||
{
|
||||
free(allowedAddressList[x]);
|
||||
allowedAddressList[x] = 0;
|
||||
@@ -365,28 +357,28 @@ char buffer[1024];
|
||||
|
||||
nline = 0;
|
||||
x = 0;
|
||||
while(!feof(fp))
|
||||
while (!feof(fp))
|
||||
{
|
||||
if (fgets( buffer, 1023, fp) != nullptr) {
|
||||
if (fgets(buffer, 1023, fp) != nullptr) {
|
||||
// get rid of '\n' and '\r' for comparisons
|
||||
strtok(buffer,"\r\n");
|
||||
strtok(buffer, "\r\n");
|
||||
len = (int)strlen(buffer);
|
||||
if( len > 0 )
|
||||
if (len > 0)
|
||||
{
|
||||
if( nline == 0 )
|
||||
if (nline == 0)
|
||||
{
|
||||
passString = (char *)malloc( len + 1 );
|
||||
strcpy(passString,buffer);
|
||||
passString = (char *)malloc(len + 1);
|
||||
strcpy(passString, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
allowedAddressList[x] = (char *)malloc( len + 1 );
|
||||
strcpy(allowedAddressList[x],buffer);
|
||||
allowedAddressList[x] = (char *)malloc(len + 1);
|
||||
strcpy(allowedAddressList[x], buffer);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
nline++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// clean up
|
||||
fclose(fp);
|
||||
@@ -398,40 +390,40 @@ char buffer[1024];
|
||||
// ******************************************************************************************************
|
||||
// ******************************************************************************************************
|
||||
|
||||
CMonitorAPI::CMonitorAPI( const char *configFile, unsigned short Port, bool _bprint , char *address, UdpManager * mang )
|
||||
CMonitorAPI::CMonitorAPI(const char *configFile, unsigned short Port, bool _bprint, char *address, UdpManager * mang)
|
||||
{
|
||||
mbprint = _bprint;
|
||||
mPort = Port;
|
||||
|
||||
mAddress = nullptr;
|
||||
if( address )
|
||||
if (address)
|
||||
{
|
||||
mAddress = (char *)malloc(strlen(address)+1);
|
||||
strcpy(mAddress,address);
|
||||
mAddress = (char *)malloc(strlen(address) + 1);
|
||||
strcpy(mAddress, address);
|
||||
}
|
||||
|
||||
if( mang == nullptr )
|
||||
if (mang == nullptr)
|
||||
{
|
||||
UdpManager::Params params;
|
||||
params.handler = nullptr;
|
||||
params.maxConnections = CONNECTION_MAX;
|
||||
params.handler = nullptr;
|
||||
params.maxConnections = CONNECTION_MAX;
|
||||
params.outgoingBufferSize = 1000000;
|
||||
params.noDataTimeout = 130000;
|
||||
params.noDataTimeout = 130000;
|
||||
params.oldestUnacknowledgedTimeout = 120000;
|
||||
params.processIcmpErrors = false;
|
||||
params.port = mPort;
|
||||
mManager = new UdpManager(¶ms);
|
||||
mMonitorData = new CMonitorData();
|
||||
params.port = mPort;
|
||||
mManager = new UdpManager(¶ms);
|
||||
mMonitorData = new CMonitorData();
|
||||
}
|
||||
|
||||
mObjectManager = new MonitorManager(configFile,mMonitorData,mManager,mbprint);
|
||||
|
||||
mObjectManager = new MonitorManager(configFile, mMonitorData, mManager, mbprint);
|
||||
|
||||
mManager->SetHandler(mObjectManager);
|
||||
|
||||
if( mbprint )
|
||||
fprintf(stderr,"MonitorAPI: started on port->%d\n",mPort);
|
||||
if (mbprint)
|
||||
fprintf(stderr, "MonitorAPI: started on port->%d\n", mPort);
|
||||
}
|
||||
|
||||
|
||||
CMonitorAPI::~CMonitorAPI()
|
||||
{
|
||||
free(mAddress);
|
||||
@@ -441,127 +433,123 @@ CMonitorAPI::~CMonitorAPI()
|
||||
mManager->Release();
|
||||
|
||||
delete mMonitorData;
|
||||
|
||||
}
|
||||
|
||||
void CMonitorAPI::Update()
|
||||
{
|
||||
if( mManager )
|
||||
if (mManager)
|
||||
mManager->GiveTime();
|
||||
if( mObjectManager )
|
||||
if (mObjectManager)
|
||||
mObjectManager->GiveTime();
|
||||
}
|
||||
|
||||
int CMonitorAPI::add(const char *label, int id, int ping, const char *des )
|
||||
{
|
||||
int rnt;
|
||||
int CMonitorAPI::add(const char *label, int id, int ping, const char *des)
|
||||
{
|
||||
int rnt;
|
||||
|
||||
rnt = mMonitorData->add(label,id,ping,des);
|
||||
if( rnt )
|
||||
rnt = mMonitorData->add(label, id, ping, des);
|
||||
if (rnt)
|
||||
mObjectManager->HierarchyChanged();
|
||||
return rnt;
|
||||
return rnt;
|
||||
}
|
||||
|
||||
void CMonitorAPI::remove(int Id)
|
||||
{
|
||||
mMonitorData->remove(Id);
|
||||
{
|
||||
mMonitorData->remove(Id);
|
||||
mObjectManager->HierarchyChanged();
|
||||
}
|
||||
|
||||
void CMonitorAPI::setDescription( int Id, const char *Description )
|
||||
void CMonitorAPI::setDescription(int Id, const char *Description)
|
||||
{
|
||||
int x;
|
||||
int mode;
|
||||
|
||||
x = mMonitorData->setDescription(Id,Description,mode);
|
||||
if( x == -1 )
|
||||
int x;
|
||||
int mode;
|
||||
|
||||
x = mMonitorData->setDescription(Id, Description, mode);
|
||||
if (x == -1)
|
||||
return;
|
||||
mObjectManager->DescriptionMark(x,mode);
|
||||
mObjectManager->DescriptionMark(x, mode);
|
||||
}
|
||||
|
||||
void CMonitorAPI::dump(){ mMonitorData->dump(); }
|
||||
void CMonitorAPI::dump() { mMonitorData->dump(); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
monMessage::monMessage():command(0),sequence(0),size(0){}
|
||||
monMessage::monMessage() :command(0), sequence(0), size(0) {}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
monMessage::monMessage(short cmd,short seq,short s):command(cmd),sequence(seq),size(s){}
|
||||
monMessage::monMessage(short cmd, short seq, short s) : command(cmd), sequence(seq), size(s) {}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
monMessage::monMessage(const unsigned char * source):command(0),sequence(0),size(0)
|
||||
{
|
||||
int len;
|
||||
monMessage::monMessage(const unsigned char * source) : command(0), sequence(0), size(0)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
unpackShort( (char *)source + len, len,command);
|
||||
unpackShort( (char *)source + len, len,sequence);
|
||||
unpackShort( (char *)source + len, len,size);
|
||||
unpackShort((char *)source + len, len, command);
|
||||
unpackShort((char *)source + len, len, sequence);
|
||||
unpackShort((char *)source + len, len, size);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// monMessage::monMessage(const monMessage ©):command(copy.command),sequence(copy.sequence),size(copy.size){}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
stringMessage::stringMessage(const unsigned char * source):monMessage(source)
|
||||
stringMessage::stringMessage(const unsigned char * source) :monMessage(source)
|
||||
{
|
||||
int size;
|
||||
int size;
|
||||
|
||||
size = (int)strlen((char *)source+6) +1;
|
||||
data = new char [ size ];
|
||||
strcpy(data,(char *)source+6); // Add six for the size of the header
|
||||
size = (int)strlen((char *)source + 6) + 1;
|
||||
data = new char[size];
|
||||
strcpy(data, (char *)source + 6); // Add six for the size of the header
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
stringMessage::stringMessage(const unsigned short command,const unsigned short sequence,const unsigned short size,char * newData):
|
||||
monMessage(command, sequence, size)
|
||||
stringMessage::stringMessage(const unsigned short command, const unsigned short sequence, const unsigned short size, char * newData) :
|
||||
monMessage(command, sequence, size)
|
||||
{
|
||||
data = new char [strlen(newData) + 1];
|
||||
data = new char[strlen(newData) + 1];
|
||||
strncpy(data, newData, strlen(newData + 1));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
stringMessage::~stringMessage()
|
||||
{
|
||||
delete [] data;
|
||||
delete[] data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
authReplyMessage::authReplyMessage(const unsigned char * source) :
|
||||
monMessage(source)
|
||||
monMessage(source)
|
||||
{
|
||||
int len = 6;
|
||||
unpackShort((char *)source+len,len,version);
|
||||
unpackByte((char *)source+len,len,data);
|
||||
unpackShort((char *)source + len, len, version);
|
||||
unpackByte((char *)source + len, len, data);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
authReplyMessage::authReplyMessage(const unsigned short command,
|
||||
const unsigned short sequence,
|
||||
const unsigned short size,
|
||||
unsigned char newData):
|
||||
monMessage(command, sequence, size),data(newData){}
|
||||
|
||||
authReplyMessage::authReplyMessage(const unsigned short command,
|
||||
const unsigned short sequence,
|
||||
const unsigned short size,
|
||||
unsigned char newData) :
|
||||
monMessage(command, sequence, size), data(newData), version() {}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
dataReplyMessage::dataReplyMessage(const unsigned char * source) :
|
||||
monMessage(source)
|
||||
monMessage(source)
|
||||
{
|
||||
data = new unsigned char[getSize()+1];
|
||||
data = new unsigned char[getSize() + 1];
|
||||
|
||||
memcpy(data, source + 6, getSize());
|
||||
data[getSize()] = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
dataReplyMessage::dataReplyMessage(const unsigned short command,
|
||||
const unsigned short sequence,
|
||||
const unsigned short size,
|
||||
unsigned char * newData,
|
||||
int newDataLen):
|
||||
monMessage(command, sequence, size)
|
||||
dataReplyMessage::dataReplyMessage(const unsigned short command,
|
||||
const unsigned short sequence,
|
||||
const unsigned short size,
|
||||
unsigned char * newData,
|
||||
int newDataLen) :
|
||||
monMessage(command, sequence, size)
|
||||
{
|
||||
data = new unsigned char[newDataLen];
|
||||
memcpy(data, newData, newDataLen);
|
||||
@@ -570,51 +558,46 @@ monMessage(command, sequence, size)
|
||||
//----------------------------------------------------------------
|
||||
dataReplyMessage::~dataReplyMessage()
|
||||
{
|
||||
delete [] data;
|
||||
delete[] data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
simpleMessage::simpleMessage(const unsigned char * source):monMessage(source){}
|
||||
simpleMessage::simpleMessage(const unsigned char * source) :monMessage(source) {}
|
||||
//----------------------------------------------------------------
|
||||
simpleMessage::simpleMessage(const unsigned short command,
|
||||
const unsigned short sequence,
|
||||
const unsigned short size):
|
||||
monMessage(command, sequence, size){}
|
||||
simpleMessage::simpleMessage(const unsigned short command,
|
||||
const unsigned short sequence,
|
||||
const unsigned short size) :
|
||||
monMessage(command, sequence, size) {}
|
||||
//----------------------------------------------------------------
|
||||
simpleMessage::~simpleMessage(){}
|
||||
simpleMessage::~simpleMessage() {}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
dataBlockReplyMessage::dataBlockReplyMessage(const unsigned char * source) :
|
||||
monMessage(source)
|
||||
monMessage(source)
|
||||
{
|
||||
int err;
|
||||
unsigned long S = 4000000;
|
||||
unsigned char *p;
|
||||
int err;
|
||||
unsigned long S = 4000000;
|
||||
unsigned char *p;
|
||||
|
||||
data = nullptr;
|
||||
p = (unsigned char *)malloc(4000000);
|
||||
memset(p,0,4000000);
|
||||
err = uncompress(p,&S,(source+6),(long)getSize());
|
||||
if( Z_OK != err ) { free(p);return; }
|
||||
data = new unsigned char[S+1];
|
||||
memcpy(data,p,S);
|
||||
memset(p, 0, 4000000);
|
||||
err = uncompress(p, &S, (source + 6), (long)getSize());
|
||||
if (Z_OK != err) { free(p); return; }
|
||||
data = new unsigned char[S + 1];
|
||||
memcpy(data, p, S);
|
||||
setSize((unsigned short)S);
|
||||
free(p);
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
dataBlockReplyMessage::~dataBlockReplyMessage()
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
delete [] data;
|
||||
data = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (data)
|
||||
{
|
||||
delete[] data;
|
||||
data = 0;
|
||||
}
|
||||
}
|
||||
+83
-84
@@ -6,110 +6,109 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
namespace Base
|
||||
{
|
||||
namespace Base
|
||||
{
|
||||
class CAutoLog
|
||||
{
|
||||
public:
|
||||
enum eLogLevel {
|
||||
eLOG_NONE = 0, // log entries are discarded
|
||||
eLOG_ERROR = 1, // log errors only
|
||||
eLOG_ALERT = 2, // log alerts and errors only
|
||||
eLOG_NORMAL = 3, // log all normal events, no debug
|
||||
eLOG_DEBUG = 4 // log everything
|
||||
};
|
||||
|
||||
class CAutoLog
|
||||
{
|
||||
public:
|
||||
enum eLogLevel {
|
||||
eLOG_NONE = 0, // log entries are discarded
|
||||
eLOG_ERROR = 1, // log errors only
|
||||
eLOG_ALERT = 2, // log alerts and errors only
|
||||
eLOG_NORMAL = 3, // log all normal events, no debug
|
||||
eLOG_DEBUG = 4 // log everything
|
||||
};
|
||||
// Global setting for all AutoLog instances for this application. Can be set on the fly. Default is eLOG_NORMAL.
|
||||
void SetLogLevel(eLogLevel loglevel);
|
||||
|
||||
// Global setting for all AutoLog instances for this application. Can be set on the fly. Default is eLOG_NORMAL.
|
||||
void SetLogLevel(eLogLevel loglevel);
|
||||
// Global setting for all AutoLog instances for this application. Can be set on the fly. Default is eLOG_ERROR.
|
||||
void SetPrintLevel(eLogLevel printlevel);
|
||||
|
||||
// Global setting for all AutoLog instances for this application. Can be set on the fly. Default is eLOG_ERROR.
|
||||
void SetPrintLevel(eLogLevel printlevel);
|
||||
// Global setting for all AutoLog instances for this application. Can be set on the fly. Default is eLOG_ERROR.
|
||||
void SetFlushLevel(eLogLevel flushlevel);
|
||||
|
||||
// Global setting for all AutoLog instances for this application. Can be set on the fly. Default is eLOG_ERROR.
|
||||
void SetFlushLevel(eLogLevel flushlevel);
|
||||
// constructor, no file loaded
|
||||
CAutoLog();
|
||||
|
||||
// constructor, no file loaded
|
||||
CAutoLog();
|
||||
// version of constructor that calls Open(file)
|
||||
CAutoLog(const char * file);
|
||||
|
||||
// version of constructor that calls Open(file)
|
||||
CAutoLog(const char * file);
|
||||
// destructor, will close file if opened
|
||||
~CAutoLog();
|
||||
|
||||
// destructor, will close file if opened
|
||||
~CAutoLog();
|
||||
// Open log file. If a file is already open, function will fail.
|
||||
// returns true if no error
|
||||
bool Open(const char * file);
|
||||
|
||||
// Open log file. If a file is already open, function will fail.
|
||||
// returns true if no error
|
||||
bool Open(const char * file);
|
||||
// Close log file if opened.
|
||||
void Close(void);
|
||||
|
||||
// Close log file if opened.
|
||||
void Close(void);
|
||||
// Make an entry in the log. Format and variable arguments are identical to printf.
|
||||
// severity will be compared to master log level to determine if the log entry will be made
|
||||
// severity will be compared to master print level to determine if the log entry will be printed to stdout
|
||||
void Log(eLogLevel severity, char * format, ...);
|
||||
|
||||
// Make an entry in the log. Format and variable arguments are identical to printf.
|
||||
// severity will be compared to master log level to determine if the log entry will be made
|
||||
// severity will be compared to master print level to determine if the log entry will be printed to stdout
|
||||
void Log(eLogLevel severity, char * format, ...);
|
||||
// Equivalent to the above with the approriate severity argument
|
||||
void LogError(char * format, ...);
|
||||
void LogAlert(char * format, ...);
|
||||
void Log(char * format, ...);
|
||||
void LogDebug(char * format, ...);
|
||||
|
||||
// Equivalent to the above with the approriate severity argument
|
||||
void LogError(char * format, ...);
|
||||
void LogAlert(char * format, ...);
|
||||
void Log(char * format, ...);
|
||||
void LogDebug(char * format, ...);
|
||||
private:
|
||||
FILE * pFile; // current log file opened
|
||||
char * pFilename; // current log file opened
|
||||
int nTodaysDayOfYear; // remember the current day to detect change of day
|
||||
void Archive(void); // archives current log
|
||||
|
||||
private:
|
||||
FILE * pFile; // current log file opened
|
||||
char * pFilename; // current log file opened
|
||||
int nTodaysDayOfYear; // remember the current day to detect change of day
|
||||
void Archive(void); // archives current log
|
||||
static eLogLevel nLogMask; // master severity level
|
||||
static eLogLevel nPrintMask; // master severity level
|
||||
static eLogLevel nFlushMask; // master severity level
|
||||
};
|
||||
|
||||
static eLogLevel nLogMask; // master severity level
|
||||
static eLogLevel nPrintMask; // master severity level
|
||||
static eLogLevel nFlushMask; // master severity level
|
||||
};
|
||||
//-------------------------------------
|
||||
inline void CAutoLog::SetLogLevel(eLogLevel loglevel)
|
||||
{
|
||||
nLogMask = loglevel;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
inline void CAutoLog::SetLogLevel(eLogLevel loglevel)
|
||||
{
|
||||
nLogMask = loglevel;
|
||||
}
|
||||
//-------------------------------------
|
||||
inline void CAutoLog::SetPrintLevel(eLogLevel printlevel)
|
||||
{
|
||||
nPrintMask = printlevel;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
inline void CAutoLog::SetPrintLevel(eLogLevel printlevel)
|
||||
{
|
||||
nPrintMask = printlevel;
|
||||
}
|
||||
//-------------------------------------
|
||||
inline void CAutoLog::SetFlushLevel(eLogLevel flushlevel)
|
||||
{
|
||||
nFlushMask = flushlevel;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
inline void CAutoLog::SetFlushLevel(eLogLevel flushlevel)
|
||||
{
|
||||
nFlushMask = flushlevel;
|
||||
}
|
||||
//-------------------------------------
|
||||
inline CAutoLog::CAutoLog()
|
||||
{
|
||||
pFilename = nullptr;
|
||||
pFile = (FILE *)-1;
|
||||
nTodaysDayOfYear = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
inline CAutoLog::CAutoLog()
|
||||
{
|
||||
pFilename = nullptr;
|
||||
pFile = (FILE *)-1;
|
||||
}
|
||||
//-------------------------------------
|
||||
inline CAutoLog::CAutoLog(const char * file)
|
||||
{
|
||||
pFilename = nullptr;
|
||||
pFile = (FILE *)-1;
|
||||
Open(file);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
inline CAutoLog::CAutoLog(const char * file)
|
||||
{
|
||||
pFilename = nullptr;
|
||||
pFile = (FILE *)-1;
|
||||
Open(file);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
inline CAutoLog::~CAutoLog()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
};
|
||||
//-------------------------------------
|
||||
inline CAutoLog::~CAutoLog()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
};
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
|
||||
+634
-658
File diff suppressed because it is too large
Load Diff
+163
-162
@@ -12,198 +12,199 @@
|
||||
//----------------------------------------
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
namespace NAMESPACE
|
||||
{
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace Base;
|
||||
using namespace std;
|
||||
using namespace Base;
|
||||
|
||||
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned noAckTimeoutSecs, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB)
|
||||
: m_bConnected(CON_NONE),
|
||||
m_apiCore(apiCore),
|
||||
m_con(nullptr),
|
||||
m_host(host),
|
||||
m_port(port),
|
||||
m_lastTrack(123455), //random choice != 1
|
||||
m_conState(CON_DISCONNECT),
|
||||
m_reconnectTimeout(reconnectTimeout)
|
||||
{
|
||||
TcpManager::TcpParams params;
|
||||
|
||||
params.incomingBufferSize = incomingBufSizeInKB * 1024;
|
||||
params.outgoingBufferSize = outgoingBufSizeInKB * 1024;
|
||||
params.maxConnections = 1;
|
||||
params.port = 0;
|
||||
params.maxRecvMessageSize = maxRecvMessageSizeInKB*1024;
|
||||
params.keepAliveDelay = keepAlive * 1000;
|
||||
params.noDataTimeout = noDataTimeoutSecs * 1000;
|
||||
//params.oldestUnacknowledgedTimeout = noAckTimeoutSecs * 1000;
|
||||
|
||||
m_manager = new TcpManager(params);
|
||||
}
|
||||
|
||||
GenericConnection::~GenericConnection()
|
||||
{
|
||||
if(m_con)
|
||||
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned noAckTimeoutSecs, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB)
|
||||
: m_bConnected(CON_NONE),
|
||||
m_apiCore(apiCore),
|
||||
m_con(nullptr),
|
||||
m_host(host),
|
||||
m_port(port),
|
||||
m_lastTrack(123455), //random choice != 1
|
||||
m_conState(CON_DISCONNECT),
|
||||
m_reconnectTimeout(reconnectTimeout),
|
||||
m_conTimeout(100)
|
||||
{
|
||||
m_con->SetHandler(nullptr);
|
||||
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to nullptr, so it wont
|
||||
m_con->Release();
|
||||
TcpManager::TcpParams params;
|
||||
|
||||
params.incomingBufferSize = incomingBufSizeInKB * 1024;
|
||||
params.outgoingBufferSize = outgoingBufSizeInKB * 1024;
|
||||
params.maxConnections = 1;
|
||||
params.port = 0;
|
||||
params.maxRecvMessageSize = maxRecvMessageSizeInKB * 1024;
|
||||
params.keepAliveDelay = keepAlive * 1000;
|
||||
params.noDataTimeout = noDataTimeoutSecs * 1000;
|
||||
//params.oldestUnacknowledgedTimeout = noAckTimeoutSecs * 1000;
|
||||
|
||||
m_manager = new TcpManager(params);
|
||||
}
|
||||
|
||||
m_manager->Release();
|
||||
}
|
||||
|
||||
void GenericConnection::disconnect()
|
||||
{
|
||||
if (m_con)
|
||||
GenericConnection::~GenericConnection()
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->SetHandler(nullptr);
|
||||
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to nullptr, so it wont
|
||||
m_con->Release();
|
||||
}
|
||||
|
||||
m_manager->Release();
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
|
||||
void GenericConnection::OnTerminated(TcpConnection *con)
|
||||
{
|
||||
// m_apiCore->OnDisconnect(m_host.c_str(), m_port);
|
||||
m_apiCore->OnDisconnect(this);
|
||||
if(m_con)
|
||||
void GenericConnection::disconnect()
|
||||
{
|
||||
m_con->Release();
|
||||
m_con = nullptr;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
|
||||
void GenericConnection::OnRoutePacket(TcpConnection *con, const unsigned char *data, int dataLen)
|
||||
{
|
||||
short type;
|
||||
unsigned track;
|
||||
|
||||
ByteStream msg(data, dataLen);
|
||||
ByteStream::ReadIterator iter = msg.begin();
|
||||
|
||||
get(iter, type);
|
||||
get(iter, track);
|
||||
GenericResponse *res = nullptr;
|
||||
|
||||
// the following if block is a temporary fix that prevents
|
||||
// a crash with a game team in which they occasionally find
|
||||
// themselves receiving a dupe track in consecutive calls to
|
||||
// OnRoutePacket (which then leads to a callback being called
|
||||
// twice and data being invalid on the second call -> crash!).
|
||||
if (track != 0 &&
|
||||
track == m_lastTrack)
|
||||
void GenericConnection::OnTerminated(TcpConnection *con)
|
||||
{
|
||||
printf("!!! ERROR !!! Got a duplicate track ID %u\n", track);
|
||||
return;
|
||||
// m_apiCore->OnDisconnect(m_host.c_str(), m_port);
|
||||
m_apiCore->OnDisconnect(this);
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Release();
|
||||
m_con = nullptr;
|
||||
}
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
m_lastTrack = track;
|
||||
|
||||
// end temporary fix.
|
||||
|
||||
if(track == 0) // notification message from the server, not as a response to a request from this API
|
||||
void GenericConnection::OnRoutePacket(TcpConnection *con, const unsigned char *data, int dataLen)
|
||||
{
|
||||
if (type == CTService::CTGAME_REQUEST_CONNECT)
|
||||
{ // this is a special case, for when we have identified our game code to server
|
||||
m_bConnected = CON_IDENTIFIED;
|
||||
m_apiCore->OnConnect(this);
|
||||
short type;
|
||||
unsigned track;
|
||||
|
||||
ByteStream msg(data, dataLen);
|
||||
ByteStream::ReadIterator iter = msg.begin();
|
||||
|
||||
get(iter, type);
|
||||
get(iter, track);
|
||||
GenericResponse *res = nullptr;
|
||||
|
||||
// the following if block is a temporary fix that prevents
|
||||
// a crash with a game team in which they occasionally find
|
||||
// themselves receiving a dupe track in consecutive calls to
|
||||
// OnRoutePacket (which then leads to a callback being called
|
||||
// twice and data being invalid on the second call -> crash!).
|
||||
if (track != 0 &&
|
||||
track == m_lastTrack)
|
||||
{
|
||||
printf("!!! ERROR !!! Got a duplicate track ID %u\n", track);
|
||||
return;
|
||||
}
|
||||
m_lastTrack = track;
|
||||
|
||||
// end temporary fix.
|
||||
|
||||
if (track == 0) // notification message from the server, not as a response to a request from this API
|
||||
{
|
||||
if (type == CTService::CTGAME_REQUEST_CONNECT)
|
||||
{ // this is a special case, for when we have identified our game code to server
|
||||
m_bConnected = CON_IDENTIFIED;
|
||||
m_apiCore->OnConnect(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_apiCore->responseCallback(type, iter, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_apiCore->responseCallback(type, iter, this);
|
||||
map<unsigned, GenericResponse *>::iterator mapIter = m_apiCore->m_pending.find(track);
|
||||
|
||||
if (mapIter != m_apiCore->m_pending.end())
|
||||
{
|
||||
res = (*mapIter).second;
|
||||
iter = msg.begin();
|
||||
res->unpack(iter);
|
||||
m_apiCore->responseCallback(res);
|
||||
m_apiCore->m_pendingCount--;
|
||||
m_apiCore->m_pending.erase(mapIter);
|
||||
delete res;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
void GenericConnection::process()
|
||||
{
|
||||
map<unsigned, GenericResponse *>::iterator mapIter = m_apiCore->m_pending.find(track);
|
||||
switch (m_conState)
|
||||
{
|
||||
case CON_DISCONNECT:
|
||||
// create connection object, attempting to connect and
|
||||
// checking for connection in next state, CON_NEGOTIATE
|
||||
m_con = m_manager->EstablishConnection(m_host.c_str(), m_port);
|
||||
if (m_con)
|
||||
{
|
||||
m_con->SetHandler(this);
|
||||
m_conState = CON_NEGOTIATE;
|
||||
m_conTimeout = time(nullptr) + m_reconnectTimeout;
|
||||
}
|
||||
break;
|
||||
case CON_NEGOTIATE:
|
||||
// check for connection
|
||||
|
||||
if(mapIter != m_apiCore->m_pending.end())
|
||||
{
|
||||
res = (*mapIter).second;
|
||||
iter = msg.begin();
|
||||
res->unpack(iter);
|
||||
m_apiCore->responseCallback(res);
|
||||
m_apiCore->m_pendingCount--;
|
||||
m_apiCore->m_pending.erase(mapIter);
|
||||
delete res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenericConnection::process()
|
||||
{
|
||||
switch(m_conState)
|
||||
{
|
||||
case CON_DISCONNECT:
|
||||
// create connection object, attempting to connect and
|
||||
// checking for connection in next state, CON_NEGOTIATE
|
||||
m_con = m_manager->EstablishConnection(m_host.c_str(), m_port);
|
||||
if(m_con)
|
||||
{
|
||||
m_con->SetHandler(this);
|
||||
m_conState = CON_NEGOTIATE;
|
||||
m_conTimeout = time(nullptr) + m_reconnectTimeout;
|
||||
}
|
||||
break;
|
||||
case CON_NEGOTIATE:
|
||||
// check for connection
|
||||
|
||||
if(m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
{
|
||||
// we're connected
|
||||
m_conState = CON_CONNECT;
|
||||
m_bConnected = CON_CONNECTED;
|
||||
// instead of calling OnConnect() right now, we are going to submit a connection packet
|
||||
// identifying us
|
||||
// m_apiCore->OnConnect(this);
|
||||
Base::ByteStream msg;
|
||||
put(msg, (short)CTService::CTGAME_REQUEST_CONNECT);
|
||||
put(msg, (unsigned)0); // track
|
||||
put(msg, (unsigned)API_VERSION_CODE);
|
||||
put(msg, m_apiCore->getGameCode());
|
||||
Send(msg);
|
||||
}
|
||||
else if(time(nullptr) > m_conTimeout)
|
||||
{
|
||||
// we did not connect
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
if (m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
{
|
||||
// we're connected
|
||||
m_conState = CON_CONNECT;
|
||||
m_bConnected = CON_CONNECTED;
|
||||
// instead of calling OnConnect() right now, we are going to submit a connection packet
|
||||
// identifying us
|
||||
// m_apiCore->OnConnect(this);
|
||||
Base::ByteStream msg;
|
||||
put(msg, (short)CTService::CTGAME_REQUEST_CONNECT);
|
||||
put(msg, (unsigned)0); // track
|
||||
put(msg, (unsigned)API_VERSION_CODE);
|
||||
put(msg, m_apiCore->getGameCode());
|
||||
Send(msg);
|
||||
}
|
||||
else if (time(nullptr) > m_conTimeout)
|
||||
{
|
||||
// we did not connect
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
break;
|
||||
case CON_CONNECT:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
// this should not occur, but we revert to CON_DISCONNECT if it does
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
}
|
||||
break;
|
||||
case CON_CONNECT:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
// this should not occur, but we revert to CON_DISCONNECT if it does
|
||||
m_conState = CON_DISCONNECT;
|
||||
m_bConnected = CON_NONE;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
m_bConnected = CON_NONE;
|
||||
if (m_con)
|
||||
{
|
||||
m_con->Disconnect();
|
||||
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
|
||||
m_con = nullptr;
|
||||
}
|
||||
}
|
||||
m_manager->GiveTime();
|
||||
}
|
||||
m_manager->GiveTime();
|
||||
}
|
||||
|
||||
void GenericConnection::Send(Base::ByteStream &msg)
|
||||
{
|
||||
if(m_con && m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
void GenericConnection::Send(Base::ByteStream &msg)
|
||||
{
|
||||
m_con->Send((const char *)msg.getBuffer(), msg.getSize());
|
||||
if (m_con && m_con->GetStatus() == TcpConnection::StatusConnected)
|
||||
{
|
||||
m_con->Send((const char *)msg.getBuffer(), msg.getSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
+23
-24
@@ -9,36 +9,35 @@
|
||||
//----------------------------------------
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
namespace NAMESPACE
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
using namespace Base;
|
||||
using namespace Base;
|
||||
|
||||
//-------------------------------------------
|
||||
GenericRequest::GenericRequest(short type, unsigned server_track)
|
||||
: m_type(type), m_server_track(server_track)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
//-------------------------------------------
|
||||
GenericRequest::GenericRequest(short type, unsigned server_track)
|
||||
: m_type(type), m_server_track(server_track), m_track(0), m_timeout(100)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------
|
||||
GenericResponse::GenericResponse(short type, unsigned result, void *user)
|
||||
: m_type(type), m_result(result), m_user(user)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
//-------------------------------------------
|
||||
GenericResponse::GenericResponse(short type, unsigned result, void *user)
|
||||
: m_type(type), m_result(result), m_user(user), m_track(0), m_timeout(100)
|
||||
//-------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
void GenericResponse::unpack(ByteStream::ReadIterator &iter)
|
||||
//-----------------------------------------
|
||||
{
|
||||
get(iter, m_type);
|
||||
get(iter, m_track);
|
||||
get(iter, m_result);
|
||||
}
|
||||
//-----------------------------------------
|
||||
void GenericResponse::unpack(ByteStream::ReadIterator &iter)
|
||||
//-----------------------------------------
|
||||
{
|
||||
get(iter, m_type);
|
||||
get(iter, m_track);
|
||||
get(iter, m_result);
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
+634
-658
File diff suppressed because it is too large
Load Diff
+34
-34
@@ -17,16 +17,16 @@ public:
|
||||
next = 0;
|
||||
}
|
||||
|
||||
inline unsigned int MaxSize() const {return buf.size;}
|
||||
inline unsigned int MaxSize() const { return buf.size; }
|
||||
|
||||
inline unsigned int CurrentSize() const
|
||||
{
|
||||
return m_tail-m_head;
|
||||
return m_tail - m_head;
|
||||
}
|
||||
|
||||
inline bool UsedUp() const
|
||||
{
|
||||
return (m_head==MaxSize());
|
||||
return (m_head == MaxSize());
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
@@ -36,48 +36,48 @@ public:
|
||||
|
||||
inline unsigned int Put(byte inByte)
|
||||
{
|
||||
if (MaxSize()==m_tail)
|
||||
if (MaxSize() == m_tail)
|
||||
return 0;
|
||||
|
||||
buf[m_tail++]=inByte;
|
||||
buf[m_tail++] = inByte;
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int Put(const byte *inString, unsigned int length)
|
||||
{
|
||||
unsigned int l = STDMIN(length, MaxSize()-m_tail);
|
||||
memcpy(buf+m_tail, inString, l);
|
||||
unsigned int l = STDMIN(length, MaxSize() - m_tail);
|
||||
memcpy(buf + m_tail, inString, l);
|
||||
m_tail += l;
|
||||
return l;
|
||||
}
|
||||
|
||||
inline unsigned int Peek(byte &outByte) const
|
||||
{
|
||||
if (m_tail==m_head)
|
||||
if (m_tail == m_head)
|
||||
return 0;
|
||||
|
||||
outByte=buf[m_head];
|
||||
outByte = buf[m_head];
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int Peek(byte *target, unsigned int copyMax) const
|
||||
{
|
||||
unsigned int len = STDMIN(copyMax, m_tail-m_head);
|
||||
memcpy(target, buf+m_head, len);
|
||||
unsigned int len = STDMIN(copyMax, m_tail - m_head);
|
||||
memcpy(target, buf + m_head, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
inline unsigned int CopyTo(BufferedTransformation &target) const
|
||||
{
|
||||
unsigned int len = m_tail-m_head;
|
||||
target.Put(buf+m_head, len);
|
||||
unsigned int len = m_tail - m_head;
|
||||
target.Put(buf + m_head, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
inline unsigned int CopyTo(BufferedTransformation &target, unsigned int copyMax) const
|
||||
{
|
||||
unsigned int len = STDMIN(copyMax, m_tail-m_head);
|
||||
target.Put(buf+m_head, len);
|
||||
unsigned int len = STDMIN(copyMax, m_tail - m_head);
|
||||
target.Put(buf + m_head, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -111,14 +111,14 @@ public:
|
||||
|
||||
inline unsigned int Skip(unsigned int skipMax)
|
||||
{
|
||||
unsigned int len = STDMIN(skipMax, m_tail-m_head);
|
||||
unsigned int len = STDMIN(skipMax, m_tail - m_head);
|
||||
m_head += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
inline byte operator[](unsigned int i) const
|
||||
{
|
||||
return buf[m_head+i];
|
||||
return buf[m_head + i];
|
||||
}
|
||||
|
||||
ByteQueueNode *next;
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
// ********************************************************
|
||||
|
||||
ByteQueue::ByteQueue(unsigned int m_nodeSize)
|
||||
: m_nodeSize(0), m_lazyLength(0)
|
||||
: m_nodeSize(0), m_lazyLength(0), m_lazyString(nullptr)
|
||||
{
|
||||
m_head = m_tail = new ByteQueueNode(m_nodeSize);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ void ByteQueue::CopyFrom(const ByteQueue ©)
|
||||
m_nodeSize = copy.m_nodeSize;
|
||||
m_head = m_tail = new ByteQueueNode(*copy.m_head);
|
||||
|
||||
for (ByteQueueNode *current=copy.m_head->next; current; current=current->next)
|
||||
for (ByteQueueNode *current = copy.m_head->next; current; current = current->next)
|
||||
{
|
||||
m_tail->next = new ByteQueueNode(*current);
|
||||
m_tail = m_tail->next;
|
||||
@@ -166,18 +166,18 @@ void ByteQueue::Destroy()
|
||||
{
|
||||
ByteQueueNode *next;
|
||||
|
||||
for (ByteQueueNode *current=m_head; current; current=next)
|
||||
for (ByteQueueNode *current = m_head; current; current = next)
|
||||
{
|
||||
next=current->next;
|
||||
next = current->next;
|
||||
delete current;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long ByteQueue::CurrentSize() const
|
||||
{
|
||||
unsigned long size=0;
|
||||
unsigned long size = 0;
|
||||
|
||||
for (ByteQueueNode *current=m_head; current; current=current->next)
|
||||
for (ByteQueueNode *current = m_head; current; current = current->next)
|
||||
size += current->CurrentSize();
|
||||
|
||||
return size + m_lazyLength;
|
||||
@@ -185,7 +185,7 @@ unsigned long ByteQueue::CurrentSize() const
|
||||
|
||||
bool ByteQueue::IsEmpty() const
|
||||
{
|
||||
return m_head==m_tail && m_head->CurrentSize()==0 && m_lazyLength==0;
|
||||
return m_head == m_tail && m_head->CurrentSize() == 0 && m_lazyLength == 0;
|
||||
}
|
||||
|
||||
void ByteQueue::Clear()
|
||||
@@ -214,7 +214,7 @@ void ByteQueue::Put(const byte *inString, unsigned int length)
|
||||
FinalizeLazyPut();
|
||||
|
||||
unsigned int len;
|
||||
while ((len=m_tail->Put(inString, length)) < length)
|
||||
while ((len = m_tail->Put(inString, length)) < length)
|
||||
{
|
||||
m_tail->next = new ByteQueueNode(m_nodeSize);
|
||||
m_tail = m_tail->next;
|
||||
@@ -227,8 +227,8 @@ void ByteQueue::CleanupUsedNodes()
|
||||
{
|
||||
while (m_head != m_tail && m_head->UsedUp())
|
||||
{
|
||||
ByteQueueNode *temp=m_head;
|
||||
m_head=m_head->next;
|
||||
ByteQueueNode *temp = m_head;
|
||||
m_head = m_head->next;
|
||||
delete temp;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ unsigned long ByteQueue::Skip(unsigned long skipMax)
|
||||
unsigned long ByteQueue::TransferTo(BufferedTransformation &target, unsigned long transferMax)
|
||||
{
|
||||
unsigned long bytesLeft = transferMax;
|
||||
for (ByteQueueNode *current=m_head; bytesLeft && current; current=current->next)
|
||||
for (ByteQueueNode *current = m_head; bytesLeft && current; current = current->next)
|
||||
bytesLeft -= current->TransferTo(target, bytesLeft);
|
||||
CleanupUsedNodes();
|
||||
|
||||
@@ -320,7 +320,7 @@ unsigned long ByteQueue::TransferTo(BufferedTransformation &target, unsigned lon
|
||||
unsigned long ByteQueue::CopyTo(BufferedTransformation &target, unsigned long copyMax) const
|
||||
{
|
||||
unsigned long bytesLeft = copyMax;
|
||||
for (ByteQueueNode *current=m_head; bytesLeft && current; current=current->next)
|
||||
for (ByteQueueNode *current = m_head; bytesLeft && current; current = current->next)
|
||||
bytesLeft -= current->CopyTo(target, bytesLeft);
|
||||
if (bytesLeft && m_lazyLength)
|
||||
{
|
||||
@@ -409,11 +409,11 @@ bool ByteQueue::operator==(const ByteQueue &rhs) const
|
||||
|
||||
byte ByteQueue::operator[](unsigned long i) const
|
||||
{
|
||||
for (ByteQueueNode *current=m_head; current; current=current->next)
|
||||
for (ByteQueueNode *current = m_head; current; current = current->next)
|
||||
{
|
||||
if (i < current->CurrentSize())
|
||||
return (*current)[i];
|
||||
|
||||
|
||||
i -= current->CurrentSize();
|
||||
}
|
||||
|
||||
@@ -461,8 +461,8 @@ unsigned long ByteQueue::Walker::TransferTo(BufferedTransformation &target, unsi
|
||||
unsigned long bytesLeft = transferMax;
|
||||
while (m_node)
|
||||
{
|
||||
unsigned int len = STDMIN(bytesLeft, (unsigned long)m_node->CurrentSize()-m_offset);
|
||||
target.Put(m_node->buf+m_node->m_head+m_offset, len);
|
||||
unsigned int len = STDMIN(bytesLeft, (unsigned long)m_node->CurrentSize() - m_offset);
|
||||
target.Put(m_node->buf + m_node->m_head + m_offset, len);
|
||||
m_position += len;
|
||||
bytesLeft -= len;
|
||||
|
||||
@@ -497,4 +497,4 @@ unsigned long ByteQueue::Walker::CopyTo(BufferedTransformation &target, unsigned
|
||||
return Walker(*this).TransferTo(target, copyMax);
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
NAMESPACE_END
|
||||
+217
-226
@@ -20,64 +20,64 @@
|
||||
|
||||
namespace LocalizedStringTableReaderWriterNamespace
|
||||
{
|
||||
void unfubarMicrosoftInvalidTextCharacters (Unicode::String & str)
|
||||
void unfubarMicrosoftInvalidTextCharacters(Unicode::String & str)
|
||||
{
|
||||
typedef std::pair <Unicode::unicode_char_t, Unicode::unicode_char_t> FubarCharacterInfo;
|
||||
typedef std::pair <Unicode::unicode_char_t, Unicode::String> FubarStringInfo;
|
||||
|
||||
static const FubarCharacterInfo FubarCharactersCourtesyMicrosoft [] =
|
||||
static const FubarCharacterInfo FubarCharactersCourtesyMicrosoft[] =
|
||||
{
|
||||
FubarCharacterInfo (139, '<'),
|
||||
FubarCharacterInfo (155, '>'),
|
||||
FubarCharacterInfo(139, '<'),
|
||||
FubarCharacterInfo(155, '>'),
|
||||
|
||||
FubarCharacterInfo (8216, '\''),
|
||||
FubarCharacterInfo (8217, '\''),
|
||||
FubarCharacterInfo (8221, '"'),
|
||||
FubarCharacterInfo (8220, '"'),
|
||||
FubarCharacterInfo (149, '-'),
|
||||
FubarCharacterInfo (150, '-'),
|
||||
FubarCharacterInfo (151, '-'),
|
||||
FubarCharacterInfo (152, '~')
|
||||
FubarCharacterInfo(8216, '\''),
|
||||
FubarCharacterInfo(8217, '\''),
|
||||
FubarCharacterInfo(8221, '"'),
|
||||
FubarCharacterInfo(8220, '"'),
|
||||
FubarCharacterInfo(149, '-'),
|
||||
FubarCharacterInfo(150, '-'),
|
||||
FubarCharacterInfo(151, '-'),
|
||||
FubarCharacterInfo(152, '~')
|
||||
};
|
||||
|
||||
static const int FubarCharactersCourtesyMicrosoftLength = sizeof (FubarCharactersCourtesyMicrosoft) / sizeof (FubarCharactersCourtesyMicrosoft[0]);
|
||||
|
||||
static const FubarStringInfo FubarStringsCourtesyMicrosoft [] =
|
||||
|
||||
static const int FubarCharactersCourtesyMicrosoftLength = sizeof(FubarCharactersCourtesyMicrosoft) / sizeof(FubarCharactersCourtesyMicrosoft[0]);
|
||||
|
||||
static const FubarStringInfo FubarStringsCourtesyMicrosoft[] =
|
||||
{
|
||||
FubarStringInfo (133, Unicode::narrowToWide ("...")),
|
||||
//-- carriage return
|
||||
FubarStringInfo (13, Unicode::narrowToWide (""))
|
||||
FubarStringInfo(133, Unicode::narrowToWide("...")),
|
||||
//-- carriage return
|
||||
FubarStringInfo(13, Unicode::narrowToWide(""))
|
||||
};
|
||||
|
||||
static const int FubarStringsCourtesyMicrosoftLength = sizeof (FubarStringsCourtesyMicrosoft) / sizeof (FubarStringsCourtesyMicrosoft[0]);
|
||||
|
||||
|
||||
static const int FubarStringsCourtesyMicrosoftLength = sizeof(FubarStringsCourtesyMicrosoft) / sizeof(FubarStringsCourtesyMicrosoft[0]);
|
||||
|
||||
{
|
||||
for (int i = 0; i < FubarCharactersCourtesyMicrosoftLength; ++i)
|
||||
{
|
||||
const Unicode::unicode_char_t correctCharacter = FubarCharactersCourtesyMicrosoft [i].second;
|
||||
const Unicode::unicode_char_t fubarCharacter = FubarCharactersCourtesyMicrosoft [i].first;
|
||||
|
||||
const Unicode::unicode_char_t correctCharacter = FubarCharactersCourtesyMicrosoft[i].second;
|
||||
const Unicode::unicode_char_t fubarCharacter = FubarCharactersCourtesyMicrosoft[i].first;
|
||||
|
||||
size_t pos = 0;
|
||||
while ((pos = str.find (fubarCharacter, pos)) != Unicode::String::npos)
|
||||
while ((pos = str.find(fubarCharacter, pos)) != Unicode::String::npos)
|
||||
{
|
||||
str [pos] = correctCharacter;
|
||||
str[pos] = correctCharacter;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
for (int i = 0; i < FubarStringsCourtesyMicrosoftLength; ++i)
|
||||
{
|
||||
const Unicode::unicode_char_t fubarCharacter = FubarStringsCourtesyMicrosoft [i].first;
|
||||
const Unicode::String & correctString = FubarStringsCourtesyMicrosoft [i].second;
|
||||
|
||||
const Unicode::unicode_char_t fubarCharacter = FubarStringsCourtesyMicrosoft[i].first;
|
||||
const Unicode::String & correctString = FubarStringsCourtesyMicrosoft[i].second;
|
||||
|
||||
size_t pos = 0;
|
||||
|
||||
while ((pos = str.find (fubarCharacter, pos)) != Unicode::String::npos)
|
||||
|
||||
while ((pos = str.find(fubarCharacter, pos)) != Unicode::String::npos)
|
||||
{
|
||||
str.replace (pos, 1, correctString);
|
||||
pos += correctString.size ();
|
||||
str.replace(pos, 1, correctString);
|
||||
pos += correctString.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,20 +88,18 @@ using namespace LocalizedStringTableReaderWriterNamespace;
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
LocalizedStringTableRW::LocalizedStringTableRW (const Unicode::NarrowString & filename) :
|
||||
LocalizedStringTable (filename),
|
||||
m_idNameMap ()
|
||||
LocalizedStringTableRW::LocalizedStringTableRW(const Unicode::NarrowString & filename) :
|
||||
LocalizedStringTable(filename),
|
||||
m_idNameMap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
LocalizedStringTableRW::LocalizedStringTableRW (const LocalizedStringTable & rhs) :
|
||||
LocalizedStringTable (rhs),
|
||||
m_idNameMap ()
|
||||
LocalizedStringTableRW::LocalizedStringTableRW(const LocalizedStringTable & rhs) :
|
||||
LocalizedStringTable(rhs),
|
||||
m_idNameMap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
@@ -112,26 +110,26 @@ bool LocalizedStringTableRW::str_write(AbstractFile & fl, LocalizedString & locs
|
||||
|
||||
LocalizedString::id_type id = locstr.m_id;
|
||||
LocalizedString::crc_type crcSource = locstr.m_sourceCrc;
|
||||
LocalizedString::id_type buflen = locstr.m_str.length ();
|
||||
LocalizedString::id_type buflen = locstr.m_str.length();
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::id_type), &id))
|
||||
if (!fl.write(sizeof(LocalizedString::id_type), &id))
|
||||
return false;
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::crc_type), &crcSource))
|
||||
if (!fl.write(sizeof(LocalizedString::crc_type), &crcSource))
|
||||
return false;
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::id_type), &buflen))
|
||||
if (!fl.write(sizeof(LocalizedString::id_type), &buflen))
|
||||
return false;
|
||||
|
||||
// TODO: swab this buffer
|
||||
Unicode::unicode_char_t * buf = new Unicode::unicode_char_t [buflen+1];
|
||||
Unicode::unicode_char_t * buf = new Unicode::unicode_char_t[buflen + 1];
|
||||
|
||||
assert (buf != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
assert(buf != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
buf [buflen] = 0;
|
||||
memcpy (buf, locstr.m_str.c_str (), sizeof (Unicode::unicode_char_t) * buflen);
|
||||
buf[buflen] = 0;
|
||||
memcpy(buf, locstr.m_str.c_str(), sizeof(Unicode::unicode_char_t) * buflen);
|
||||
|
||||
if (buflen && !fl.write (buflen * sizeof (Unicode::unicode_char_t), buf))
|
||||
if (buflen && !fl.write(buflen * sizeof(Unicode::unicode_char_t), buf))
|
||||
{
|
||||
delete[] buf;
|
||||
return false;
|
||||
@@ -148,48 +146,47 @@ bool LocalizedStringTableRW::write(AbstractFile & fl) const
|
||||
{
|
||||
// TODO: swab these values on big endian systems
|
||||
LocalizedString::id_type next_unique = m_nextUniqueId;
|
||||
LocalizedString::id_type num_entries = m_map.size ();
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::id_type), &next_unique))
|
||||
LocalizedString::id_type num_entries = m_map.size();
|
||||
|
||||
if (!fl.write(sizeof(LocalizedString::id_type), &next_unique))
|
||||
return false;
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::id_type), &num_entries))
|
||||
|
||||
if (!fl.write(sizeof(LocalizedString::id_type), &num_entries))
|
||||
return false;
|
||||
|
||||
// write the string table
|
||||
|
||||
|
||||
{
|
||||
for (Map_t::const_iterator iter = m_map.begin (); iter != m_map.end (); ++iter)
|
||||
for (Map_t::const_iterator iter = m_map.begin(); iter != m_map.end(); ++iter)
|
||||
{
|
||||
if (str_write(fl, *((*iter).second)) == false)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write the string/id map
|
||||
{
|
||||
for (NameMap_t::const_iterator iter = m_nameMap.begin (); iter != m_nameMap.end (); ++iter)
|
||||
for (NameMap_t::const_iterator iter = m_nameMap.begin(); iter != m_nameMap.end(); ++iter)
|
||||
{
|
||||
|
||||
// TODO: swab all these values on big endian systems
|
||||
LocalizedString::id_type id = (*iter).second;
|
||||
LocalizedString::id_type buflen = (*iter).first.length ();
|
||||
LocalizedString::id_type id = (*iter).second;
|
||||
LocalizedString::id_type buflen = (*iter).first.length();
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::id_type), &id))
|
||||
return false;
|
||||
|
||||
if (!fl.write (sizeof (LocalizedString::id_type), &buflen))
|
||||
if (!fl.write(sizeof(LocalizedString::id_type), &id))
|
||||
return false;
|
||||
|
||||
char * buf = new char [buflen + 1];
|
||||
if (!fl.write(sizeof(LocalizedString::id_type), &buflen))
|
||||
return false;
|
||||
|
||||
assert (buf != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
char * buf = new char[buflen + 1];
|
||||
|
||||
buf [buflen] = 0;
|
||||
assert(buf != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
memcpy (buf, (*iter).first.c_str (), buflen);
|
||||
buf[buflen] = 0;
|
||||
|
||||
if (buflen && !fl.write (sizeof (char) * buflen, buf))
|
||||
memcpy(buf, (*iter).first.c_str(), buflen);
|
||||
|
||||
if (buflen && !fl.write(sizeof(char) * buflen, buf))
|
||||
{
|
||||
delete[] buf;
|
||||
buf = 0;
|
||||
@@ -204,75 +201,73 @@ bool LocalizedStringTableRW::write(AbstractFile & fl) const
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
|
||||
LocalizedStringTableRW *LocalizedStringTableRW::loadRW (AbstractFileFactory & fileFactory, const Unicode::NarrowString & filename)
|
||||
LocalizedStringTableRW *LocalizedStringTableRW::loadRW(AbstractFileFactory & fileFactory, const Unicode::NarrowString & filename)
|
||||
{
|
||||
char version = -1;
|
||||
|
||||
AbstractFile * const fl = openLoadFile (fileFactory, filename, version);
|
||||
|
||||
|
||||
AbstractFile * const fl = openLoadFile(fileFactory, filename, version);
|
||||
|
||||
if (fl == 0)
|
||||
return 0;
|
||||
|
||||
LocalizedStringTableRW * table = 0;
|
||||
|
||||
if (!fl->isOpen ())
|
||||
LocalizedStringTableRW * table = nullptr;
|
||||
|
||||
if (!fl->isOpen())
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
table = new LocalizedStringTableRW (filename);
|
||||
assert (table != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
if (table->load_0000 (*fl) == false)
|
||||
table = new LocalizedStringTableRW(filename);
|
||||
assert(table != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
if (table->load_0000(*fl) == false)
|
||||
{
|
||||
delete table;
|
||||
table = 0;
|
||||
table = nullptr;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
table = new LocalizedStringTableRW (filename);
|
||||
assert (table != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
if (table->load_0001 (*fl) == false)
|
||||
table = new LocalizedStringTableRW(filename);
|
||||
assert(table != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
if (table->load_0001(*fl) == false)
|
||||
{
|
||||
delete table;
|
||||
table = 0;
|
||||
table = nullptr;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert (true); //lint !e1924 // c-style cast. MSVC bug
|
||||
assert(true); //lint !e1924 // c-style cast. MSVC bug
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete fl;
|
||||
|
||||
//Go through all the strings and un-microsoft-fubar them
|
||||
for(Map_t::iterator mapIter = table->m_map.begin(); mapIter != table->m_map.end(); ++mapIter)
|
||||
{
|
||||
LocalizedString *str = (*mapIter).second;
|
||||
Unicode::String & strRef = str->m_str;
|
||||
LocalizedStringTableReaderWriterNamespace::unfubarMicrosoftInvalidTextCharacters(strRef);
|
||||
}
|
||||
|
||||
// populate idNameMap
|
||||
delete fl;
|
||||
|
||||
if (table)
|
||||
{
|
||||
table->m_idNameMap.clear ();
|
||||
|
||||
for (NameMap_t::const_iterator iter = table->m_nameMap.begin (); iter != table->m_nameMap.end (); ++iter)
|
||||
//Go through all the strings and un-microsoft-fubar them
|
||||
for (Map_t::iterator mapIter = table->m_map.begin(); mapIter != table->m_map.end(); ++mapIter)
|
||||
{
|
||||
table->m_idNameMap.insert (IdNameMap_t::value_type ((*iter).second, (*iter).first));
|
||||
LocalizedString *str = (*mapIter).second;
|
||||
Unicode::String & strRef = str->m_str;
|
||||
LocalizedStringTableReaderWriterNamespace::unfubarMicrosoftInvalidTextCharacters(strRef);
|
||||
}
|
||||
|
||||
// populate idNameMap
|
||||
table->m_idNameMap.clear();
|
||||
|
||||
for (NameMap_t::const_iterator iter = table->m_nameMap.begin(); iter != table->m_nameMap.end(); ++iter)
|
||||
{
|
||||
table->m_idNameMap.insert(IdNameMap_t::value_type((*iter).second, (*iter).first));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,71 +278,71 @@ LocalizedStringTableRW *LocalizedStringTableRW::loadRW (AbstractFileFactory & fi
|
||||
/**
|
||||
*/
|
||||
|
||||
bool LocalizedStringTableRW::writeRW (AbstractFileFactory & fileFactory, const Unicode::NarrowString & filename) const
|
||||
bool LocalizedStringTableRW::writeRW(AbstractFileFactory & fileFactory, const Unicode::NarrowString & filename) const
|
||||
{
|
||||
//Go through all the strings and un-microsoft-fubar them
|
||||
for(Map_t::const_iterator mapIter = m_map.begin(); mapIter != m_map.end(); ++mapIter)
|
||||
for (Map_t::const_iterator mapIter = m_map.begin(); mapIter != m_map.end(); ++mapIter)
|
||||
{
|
||||
LocalizedString *str = (*mapIter).second;
|
||||
Unicode::String & strRef = str->m_str;
|
||||
LocalizedStringTableReaderWriterNamespace::unfubarMicrosoftInvalidTextCharacters(strRef);
|
||||
}
|
||||
|
||||
AbstractFile * const fl = fileFactory.createFile (filename.c_str (), "wb");
|
||||
|
||||
|
||||
AbstractFile * const fl = fileFactory.createFile(filename.c_str(), "wb");
|
||||
|
||||
if (fl == 0)
|
||||
return false;
|
||||
|
||||
|
||||
bool retval = false;
|
||||
|
||||
if (!fl->isOpen ())
|
||||
|
||||
if (!fl->isOpen())
|
||||
{
|
||||
retval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: swab magic if big endian
|
||||
|
||||
|
||||
magic_type local_magic = LocalizedStringTable::ms_MAGIC;
|
||||
|
||||
if (!fl->write (sizeof (magic_type), &local_magic))
|
||||
|
||||
if (!fl->write(sizeof(magic_type), &local_magic))
|
||||
{
|
||||
delete fl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
char currentVersion = LocalizedStringTable::getCurrentVersion();
|
||||
if (!fl->write(sizeof (char), ¤tVersion))
|
||||
if (!fl->write(sizeof(char), ¤tVersion))
|
||||
{
|
||||
delete fl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
retval = write(*fl);
|
||||
}
|
||||
|
||||
delete fl;
|
||||
|
||||
delete fl;
|
||||
return retval;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
LocalizedString * LocalizedStringTableRW::addString (const Unicode::String & str, Unicode::NarrowString & theNameResult)
|
||||
LocalizedString * LocalizedStringTableRW::addString(const Unicode::String & str, Unicode::NarrowString & theNameResult)
|
||||
{
|
||||
LocalizedString * const locstr = (m_map [m_nextUniqueId] = new LocalizedString (m_nextUniqueId, int(time(0)), str));
|
||||
LocalizedString * const locstr = (m_map[m_nextUniqueId] = new LocalizedString(m_nextUniqueId, int(time(0)), str));
|
||||
|
||||
assert (locstr != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
assert(locstr != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
char buf[64];
|
||||
sprintf (buf, "%03ld_default", m_nextUniqueId);
|
||||
sprintf(buf, "%03ld_default", m_nextUniqueId);
|
||||
|
||||
Unicode::NarrowString name(buf);
|
||||
|
||||
const std::pair<NameMap_t::const_iterator, bool> retval = m_nameMap.insert (NameMap_t::value_type (name, m_nextUniqueId));
|
||||
const std::pair<NameMap_t::const_iterator, bool> retval = m_nameMap.insert(NameMap_t::value_type(name, m_nextUniqueId));
|
||||
|
||||
assert (retval.second == true); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
m_idNameMap [locstr->getId ()] = name;
|
||||
assert(retval.second == true); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
m_idNameMap[locstr->getId()] = name;
|
||||
|
||||
theNameResult = name;
|
||||
|
||||
@@ -358,197 +353,193 @@ LocalizedString * LocalizedStringTableRW::addString (const Unicode::String & st
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
LocalizedString * LocalizedStringTableRW::addString (LocalizedString * locstr, const Unicode::NarrowString & name, std::string & resultStr)
|
||||
LocalizedString * LocalizedStringTableRW::addString(LocalizedString * locstr, const Unicode::NarrowString & name, std::string & resultStr)
|
||||
{
|
||||
char buf [1024];
|
||||
const size_t id = locstr->getId ();
|
||||
|
||||
char buf[1024];
|
||||
const size_t id = locstr->getId();
|
||||
|
||||
{
|
||||
Map_t::const_iterator it = m_map.find (id);
|
||||
if (it != m_map.end ())
|
||||
Map_t::const_iterator it = m_map.find(id);
|
||||
if (it != m_map.end())
|
||||
{
|
||||
const std::string * old_name = getNameById (id);
|
||||
const std::string * old_name = getNameById(id);
|
||||
const LocalizedString * old_locstr = (*it).second;
|
||||
const std::string old_str = old_locstr ? Unicode::wideToNarrow (old_locstr->getString ()) : std::string ();
|
||||
|
||||
sprintf (buf,
|
||||
const std::string old_str = old_locstr ? Unicode::wideToNarrow(old_locstr->getString()) : std::string();
|
||||
|
||||
sprintf(buf,
|
||||
"LocalizedStringTableRW::addString failed inserting duplicate id [%d]\n"
|
||||
"Existing string name=[%s], str=[%s]\n",
|
||||
id,
|
||||
old_name ? old_name->c_str () : "",
|
||||
old_str.c_str ());
|
||||
id,
|
||||
old_name ? old_name->c_str() : "",
|
||||
old_str.c_str());
|
||||
resultStr += buf;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
NameMap_t::const_iterator it = m_nameMap.find (name);
|
||||
if (it != m_nameMap.end ())
|
||||
NameMap_t::const_iterator it = m_nameMap.find(name);
|
||||
if (it != m_nameMap.end())
|
||||
{
|
||||
const size_t old_id = (*it).second;
|
||||
const std::string * old_name = getNameById (old_id);
|
||||
const LocalizedString * old_locstr = getLocalizedString (old_id);
|
||||
const std::string old_str = old_locstr ? Unicode::wideToNarrow (old_locstr->getString ()) : std::string ();
|
||||
|
||||
sprintf (buf,
|
||||
const size_t old_id = (*it).second;
|
||||
const std::string * old_name = getNameById(old_id);
|
||||
const LocalizedString * old_locstr = getLocalizedString(old_id);
|
||||
const std::string old_str = old_locstr ? Unicode::wideToNarrow(old_locstr->getString()) : std::string();
|
||||
|
||||
sprintf(buf,
|
||||
"LocalizedStringTableRW::addString failed inserting duplicate name [%s]\n"
|
||||
"Existing string id=[%d] name=[%s], str=[%s]\n",
|
||||
name.c_str (),
|
||||
id,
|
||||
old_name ? old_name->c_str () : "",
|
||||
old_str.c_str ());
|
||||
name.c_str(),
|
||||
id,
|
||||
old_name ? old_name->c_str() : "",
|
||||
old_str.c_str());
|
||||
resultStr += buf;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
IdNameMap_t::const_iterator it = m_idNameMap.find (id);
|
||||
if (it != m_idNameMap.end ())
|
||||
IdNameMap_t::const_iterator it = m_idNameMap.find(id);
|
||||
if (it != m_idNameMap.end())
|
||||
{
|
||||
const std::string & old_name = (*it).second;
|
||||
const LocalizedString * old_locstr = getLocalizedString (id);
|
||||
const std::string old_str = old_locstr ? Unicode::wideToNarrow (old_locstr->getString ()) : std::string ();
|
||||
|
||||
sprintf (buf,
|
||||
const std::string & old_name = (*it).second;
|
||||
const LocalizedString * old_locstr = getLocalizedString(id);
|
||||
const std::string old_str = old_locstr ? Unicode::wideToNarrow(old_locstr->getString()) : std::string();
|
||||
|
||||
sprintf(buf,
|
||||
"LocalizedStringTableRW::addString failed inserting duplicate name [%s]\n"
|
||||
"Existing string name=[%s], str=[%s]\n",
|
||||
name.c_str (),
|
||||
old_name.c_str (),
|
||||
old_str.c_str ());
|
||||
name.c_str(),
|
||||
old_name.c_str(),
|
||||
old_str.c_str());
|
||||
resultStr += buf;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_map [id] = locstr;
|
||||
m_nameMap [name] = locstr->getId ();
|
||||
m_idNameMap [id] = name;
|
||||
m_map[id] = locstr;
|
||||
m_nameMap[name] = locstr->getId();
|
||||
m_idNameMap[id] = name;
|
||||
|
||||
m_nextUniqueId = std::max(m_nextUniqueId, locstr->getId () + 1);
|
||||
m_nextUniqueId = std::max(m_nextUniqueId, locstr->getId() + 1);
|
||||
|
||||
return locstr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
LocalizedString * LocalizedStringTableRW::addString (LocalizedString * locstr, const Unicode::String & name, std::string & resultStr)
|
||||
LocalizedString * LocalizedStringTableRW::addString(LocalizedString * locstr, const Unicode::String & name, std::string & resultStr)
|
||||
{
|
||||
return addString (locstr, Unicode::wideToNarrow (name), resultStr);
|
||||
return addString(locstr, Unicode::wideToNarrow(name), resultStr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
bool LocalizedStringTableRW::removeStringByName (const Unicode::NarrowString & name)
|
||||
bool LocalizedStringTableRW::removeStringByName(const Unicode::NarrowString & name)
|
||||
{
|
||||
NameMap_t::iterator find_iter_id = m_nameMap.find(name);
|
||||
|
||||
NameMap_t::iterator find_iter_id = m_nameMap.find (name);
|
||||
|
||||
if (find_iter_id == m_nameMap.end ())
|
||||
if (find_iter_id == m_nameMap.end())
|
||||
return false;
|
||||
|
||||
const size_t id = (*find_iter_id).second;
|
||||
|
||||
Map_t::iterator find_iter_string = m_map.find (id);
|
||||
Map_t::iterator find_iter_string = m_map.find(id);
|
||||
|
||||
assert (find_iter_string != m_map.end ()); //lint !e1924 // c-style cast. MSVC bug
|
||||
assert(find_iter_string != m_map.end()); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
IdNameMap_t::iterator find_iter_id_map = m_idNameMap.find (id);
|
||||
IdNameMap_t::iterator find_iter_id_map = m_idNameMap.find(id);
|
||||
|
||||
assert (find_iter_id_map != m_idNameMap.end ()); //lint !e1924 // c-style cast. MSVC bug
|
||||
assert(find_iter_id_map != m_idNameMap.end()); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
m_nameMap.erase (find_iter_id);
|
||||
m_map.erase (find_iter_string);
|
||||
m_idNameMap.erase (find_iter_id_map);
|
||||
m_nameMap.erase(find_iter_id);
|
||||
m_map.erase(find_iter_string);
|
||||
m_idNameMap.erase(find_iter_id_map);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
bool LocalizedStringTableRW::rename (const Unicode::NarrowString & name, const Unicode::NarrowString & newName)
|
||||
bool LocalizedStringTableRW::rename(const Unicode::NarrowString & name, const Unicode::NarrowString & newName)
|
||||
{
|
||||
//
|
||||
if (name == newName)
|
||||
return false;
|
||||
|
||||
// names that start with numerals are special
|
||||
if (isdigit (newName [0]))
|
||||
if (isdigit(newName[0]))
|
||||
return false;
|
||||
|
||||
NameMap_t::iterator find_iter_id = m_nameMap.find (newName);
|
||||
|
||||
// newName already exists
|
||||
if (find_iter_id != m_nameMap.end ())
|
||||
{
|
||||
|
||||
NameMap_t::iterator find_iter_id = m_nameMap.find(newName);
|
||||
|
||||
// newName already exists
|
||||
if (find_iter_id != m_nameMap.end())
|
||||
{
|
||||
LocalizedString::id_type id = (*find_iter_id).second;
|
||||
|
||||
LocalizedString * locstr = getLocalizedString (id);
|
||||
LocalizedString * locstr = getLocalizedString(id);
|
||||
|
||||
static_cast<void>(locstr);
|
||||
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
find_iter_id = m_nameMap.find (name);
|
||||
|
||||
|
||||
find_iter_id = m_nameMap.find(name);
|
||||
|
||||
// old name does not exist
|
||||
if (find_iter_id == m_nameMap.end ())
|
||||
return false;
|
||||
|
||||
if (find_iter_id == m_nameMap.end())
|
||||
return false;
|
||||
|
||||
size_t id = (*find_iter_id).second;
|
||||
|
||||
m_nameMap.erase (find_iter_id);
|
||||
|
||||
const std::pair<NameMap_t::const_iterator, bool> retval = m_nameMap.insert (NameMap_t::value_type (newName, id));
|
||||
|
||||
assert (retval.second == true); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
m_idNameMap [id] = newName;
|
||||
|
||||
|
||||
m_nameMap.erase(find_iter_id);
|
||||
|
||||
const std::pair<NameMap_t::const_iterator, bool> retval = m_nameMap.insert(NameMap_t::value_type(newName, id));
|
||||
|
||||
assert(retval.second == true); //lint !e1924 // c-style cast. MSVC bug
|
||||
|
||||
m_idNameMap[id] = newName;
|
||||
|
||||
return retval.second == true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
void LocalizedStringTableRW::setName (const Unicode::NarrowString & name)
|
||||
void LocalizedStringTableRW::setName(const Unicode::NarrowString & name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
void LocalizedStringTableRW::prepareTable (const LocalizedStringTableRW & rhs)
|
||||
void LocalizedStringTableRW::prepareTable(const LocalizedStringTableRW & rhs)
|
||||
{
|
||||
m_idNameMap.clear ();
|
||||
m_nameMap.clear ();
|
||||
m_map.clear ();
|
||||
m_idNameMap.clear();
|
||||
m_nameMap.clear();
|
||||
m_map.clear();
|
||||
|
||||
m_idNameMap = rhs.m_idNameMap;
|
||||
m_nameMap = rhs.m_nameMap;
|
||||
m_idNameMap = rhs.m_idNameMap;
|
||||
m_nameMap = rhs.m_nameMap;
|
||||
m_nextUniqueId = rhs.m_nextUniqueId;
|
||||
m_name = rhs.m_name;
|
||||
m_name = rhs.m_name;
|
||||
|
||||
for (Map_t::const_iterator iter = rhs.m_map.begin (); iter != rhs.m_map.end (); ++iter)
|
||||
for (Map_t::const_iterator iter = rhs.m_map.begin(); iter != rhs.m_map.end(); ++iter)
|
||||
{
|
||||
const LocalizedString * rhs_locstr = (*iter).second;
|
||||
|
||||
LocalizedString * locstr = new LocalizedString (rhs_locstr->m_id, 0, rhs_locstr->m_str);
|
||||
LocalizedString * locstr = new LocalizedString(rhs_locstr->m_id, 0, rhs_locstr->m_str);
|
||||
|
||||
assert (locstr != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
m_map.insert (Map_t::value_type (locstr->getId (), locstr ));
|
||||
assert(locstr != nullptr); //lint !e1924 // c-style cast. MSVC bug
|
||||
m_map.insert(Map_t::value_type(locstr->getId(), locstr));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
LocalizedString * LocalizedStringTableRW::getLocalizedStringByName (const Unicode::String & name)
|
||||
LocalizedString * LocalizedStringTableRW::getLocalizedStringByName(const Unicode::String & name)
|
||||
{
|
||||
return getLocalizedStringByName(Unicode::wideToNarrow (name));
|
||||
return getLocalizedStringByName(Unicode::wideToNarrow(name));
|
||||
}
|
||||
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
Reference in New Issue
Block a user