mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
This commit is contained in:
parent
c4e94f4e23
commit
166d3b0119
654 changed files with 69396 additions and 92092 deletions
|
|
@ -1,8 +1,5 @@
|
|||
// HTML Template
|
||||
|
||||
// Code added to update when shutting down -avtotar (16/09/02)
|
||||
// Slight modification on avotars fix (19/09/02)
|
||||
|
||||
#include "uox3.h"
|
||||
#include "cHTMLSystem.h"
|
||||
#include "cVersionClass.h"
|
||||
|
|
@ -15,8 +12,6 @@
|
|||
#include "scriptc.h"
|
||||
#include "CPacketSend.h"
|
||||
#include "ObjectFactory.h"
|
||||
namespace UOX
|
||||
{
|
||||
|
||||
cHTMLTemplates *HTMLTemplates;
|
||||
|
||||
|
|
@ -44,14 +39,14 @@ UString GetUptime( void )
|
|||
total = 0;
|
||||
UString builtString = "";
|
||||
if( ho < 10 )
|
||||
builtString += "0";
|
||||
builtString += UString::number( ho ) + ":";
|
||||
builtString += std::string("0");
|
||||
builtString += str_number( ho ) + ":";
|
||||
if( mi < 10 )
|
||||
builtString += "0";
|
||||
builtString += UString::number( mi ) + ":";
|
||||
builtString += std::string("0");
|
||||
builtString += str_number( mi ) + std::string(":");
|
||||
if( se < 10 )
|
||||
builtString += "0";
|
||||
builtString += UString::number( se );
|
||||
builtString += std::string("0");
|
||||
builtString += str_number( se );
|
||||
return builtString;
|
||||
}
|
||||
|
||||
|
|
@ -70,12 +65,10 @@ bool CountNPCFunctor( CBaseObject *a, UI32 &b, void *extraData )
|
|||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void cHTMLTemplate::Process( void )
|
||||
//| Date - 1/18/2003 4:43:17 AM
|
||||
//| Programmer - DarkStorm / EviLDeD
|
||||
//| Org/Team - UOX3 DevTeam
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose -
|
||||
//|
|
||||
//| Changes - 08062003 - EviLDeD - For the record this is some of the
|
||||
//| Purpose -
|
||||
//|
|
||||
//| Changes - 08062003 - For the record this is some of the
|
||||
//| most fucked up shit I have EVER SEEN!! Written to truely
|
||||
//| handle multiple Templates.
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -95,8 +88,8 @@ void cHTMLTemplate::Process( void )
|
|||
// Replacing Placeholders
|
||||
|
||||
// Account-Count
|
||||
UString AccountCount = UString::number( (SI32)(Accounts->size()) );
|
||||
size_t Pos = ParsedContent.find( "%accounts" );
|
||||
UString AccountCount = str_number( (Accounts->size()) );
|
||||
size_t Pos = ParsedContent.find( "%accounts" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
ParsedContent.replace( Pos, 9, AccountCount );
|
||||
|
|
@ -111,15 +104,15 @@ void cHTMLTemplate::Process( void )
|
|||
Version += OS_STR;
|
||||
Version += "]";
|
||||
|
||||
Pos = ParsedContent.find( "%version" );
|
||||
Pos = ParsedContent.find( "%version" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
ParsedContent.replace( Pos, 8, Version );
|
||||
Pos = ParsedContent.find( "%version" );
|
||||
}
|
||||
// Character Count
|
||||
UString CharacterCount = UString::number( (SI32)ObjectFactory::getSingleton().CountOfObjects( OT_CHAR ) );
|
||||
Pos = ParsedContent.find( "%charcount" );
|
||||
UString CharacterCount = str_number( ObjectFactory::getSingleton().CountOfObjects( OT_CHAR ) );
|
||||
Pos = ParsedContent.find( "%charcount" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
ParsedContent.replace( Pos, 10, CharacterCount );
|
||||
|
|
@ -127,7 +120,7 @@ void cHTMLTemplate::Process( void )
|
|||
}
|
||||
|
||||
// Item Count
|
||||
UString ItemCount = UString::number( (SI32)ObjectFactory::getSingleton().CountOfObjects( OT_ITEM ) );
|
||||
UString ItemCount = str_number( ObjectFactory::getSingleton().CountOfObjects( OT_ITEM ) );
|
||||
Pos = ParsedContent.find( "%itemcount" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
|
|
@ -137,28 +130,31 @@ void cHTMLTemplate::Process( void )
|
|||
|
||||
// Connection Count (GMs, Counselors, Player)
|
||||
UI32 gm = 0, cns = 0, ccount = 0;
|
||||
|
||||
// Get all Network Connections
|
||||
Network->PushConn();
|
||||
CSocket *tSock = NULL;
|
||||
CChar *tChar = NULL;
|
||||
for( tSock = Network->FirstSocket(); !Network->FinishedSockets(); tSock = Network->NextSocket() )
|
||||
{
|
||||
tChar = tSock->CurrcharObj();
|
||||
if( !ValidateObject( tChar ) )
|
||||
continue;
|
||||
|
||||
if( tChar->IsGM() )
|
||||
++gm;
|
||||
else if( tChar->IsCounselor() )
|
||||
++cns;
|
||||
else
|
||||
++ccount;
|
||||
// Get all Network Connections
|
||||
{
|
||||
std::scoped_lock lock(Network->internallock);
|
||||
Network->pushConn();
|
||||
for( tSock = Network->FirstSocket(); !Network->FinishedSockets(); tSock = Network->NextSocket() )
|
||||
{
|
||||
tChar = tSock->CurrcharObj();
|
||||
if( !ValidateObject( tChar ) )
|
||||
continue;
|
||||
|
||||
if( tChar->IsGM() )
|
||||
++gm;
|
||||
else if( tChar->IsCounselor() )
|
||||
++cns;
|
||||
else
|
||||
++ccount;
|
||||
}
|
||||
Network->popConn();
|
||||
}
|
||||
Network->PopConn();
|
||||
|
||||
// GMs
|
||||
UString GMCount = UString::number( gm );
|
||||
UString GMCount = str_number( gm );
|
||||
Pos = ParsedContent.find( "%online_gms" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
|
|
@ -167,8 +163,8 @@ void cHTMLTemplate::Process( void )
|
|||
}
|
||||
|
||||
// Counselor
|
||||
UString CounsiCount = UString::number( cns );
|
||||
Pos = ParsedContent.find( "%online_couns" );
|
||||
UString CounsiCount = str_number( cns );
|
||||
Pos = ParsedContent.find( "%online_couns" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 13, CounsiCount ):ParsedContent.replace( Pos, 13, "0");
|
||||
|
|
@ -176,8 +172,8 @@ void cHTMLTemplate::Process( void )
|
|||
}
|
||||
|
||||
// Player
|
||||
UString PlayerCount = UString::number( ccount );
|
||||
Pos = ParsedContent.find( "%online_player" );
|
||||
UString PlayerCount = str_number( ccount );
|
||||
Pos = ParsedContent.find( "%online_player" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 14, PlayerCount ):ParsedContent.replace( Pos, 14, "0" );
|
||||
|
|
@ -185,18 +181,18 @@ void cHTMLTemplate::Process( void )
|
|||
}
|
||||
|
||||
// Total
|
||||
UString AllCount = UString::number( (ccount + gm + cns) );
|
||||
Pos = ParsedContent.find( "%online_all" );
|
||||
UString AllCount = str_number( (ccount + gm + cns) );
|
||||
Pos = ParsedContent.find( "%online_all" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 11, AllCount ):ParsedContent.replace( Pos, 11, "0" );
|
||||
Pos = ParsedContent.find( "%online_all" );
|
||||
}
|
||||
|
||||
|
||||
// Time
|
||||
char time_str[80];
|
||||
RealTime( time_str );
|
||||
Pos = ParsedContent.find( "%time" );
|
||||
Pos = ParsedContent.find( "%time" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 5, time_str ):ParsedContent.replace( Pos, 5, "Down" );
|
||||
|
|
@ -205,7 +201,7 @@ void cHTMLTemplate::Process( void )
|
|||
|
||||
// 24Time
|
||||
RealTime24( time_str );
|
||||
Pos = ParsedContent.find( "%24time" );
|
||||
Pos = ParsedContent.find( "%24time" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 7, time_str ):ParsedContent.replace( Pos, 7, "Down" );
|
||||
|
|
@ -216,8 +212,8 @@ void cHTMLTemplate::Process( void )
|
|||
time_t currTime;
|
||||
time( &currTime );
|
||||
currTime = mktime( gmtime( &currTime ) );
|
||||
UString timestamp = UString::number( (SI32)currTime );
|
||||
Pos = ParsedContent.find( "%tstamp" );
|
||||
UString timestamp = str_number( currTime );
|
||||
Pos = ParsedContent.find( "%tstamp" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 7, timestamp ):ParsedContent.replace( Pos, 7, "Down" );
|
||||
|
|
@ -231,48 +227,58 @@ void cHTMLTemplate::Process( void )
|
|||
for( UI16 i = 0; i < ServerCount; ++i )
|
||||
{
|
||||
physicalServer *mServ = cwmWorldState->ServerData()->ServerEntry( i );
|
||||
char ipToken[8]; // i think we'll never get higher than 2 digits, anyway...
|
||||
sprintf( ipToken, "%%ip%i", i+1 );
|
||||
auto ipToken = format( "%%ip%i", i+1 );
|
||||
|
||||
if( mServ != NULL )
|
||||
{
|
||||
Pos = ParsedContent.find( ipToken );
|
||||
Pos = ParsedContent.find( ipToken );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, strlen(ipToken), mServ->getIP().c_str()):ParsedContent.replace( Pos, strlen(ipToken), "Down" );
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, ipToken.size(), mServ->getIP().c_str()):ParsedContent.replace( Pos, ipToken.size(), "Down" );
|
||||
Pos = ParsedContent.find( ipToken );
|
||||
}
|
||||
}
|
||||
|
||||
char portToken[10]; // i think we'll never get higher than 2 digits, anyway...
|
||||
sprintf( portToken, "%%port%i", i+1 );
|
||||
// i think we'll never get higher than 2 digits, anyway...
|
||||
auto portToken = format( "%%port%i", i+1 );
|
||||
|
||||
if( mServ != NULL )
|
||||
{
|
||||
Pos = ParsedContent.find( portToken );
|
||||
Pos = ParsedContent.find( portToken );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
UString myPort = UString::number( mServ->getPort() );
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, strlen( portToken ), myPort ):ParsedContent.replace( Pos, strlen( portToken ), "NA" );
|
||||
|
||||
auto myPort = std::to_string(mServ->getPort());
|
||||
if (cwmWorldState->GetKeepRun()){
|
||||
ParsedContent.replace(Pos, portToken.size(), myPort);
|
||||
}
|
||||
else {
|
||||
ParsedContent.replace(Pos, portToken.size(), myPort);
|
||||
}
|
||||
Pos = ParsedContent.find( portToken );
|
||||
}
|
||||
}
|
||||
char serverToken[10]; // i think we'll never get higher than 2 digits, anyway...
|
||||
sprintf( serverToken, "%%server%i", i+1 );
|
||||
|
||||
auto serverToken= format( "%%server%i", i+1 );
|
||||
|
||||
if( mServ != NULL )
|
||||
{
|
||||
Pos = ParsedContent.find( serverToken );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, strlen( serverToken ), mServ->getName().c_str() ):ParsedContent.replace( Pos, strlen( serverToken ), "Down" );
|
||||
if (cwmWorldState->GetKeepRun()) {
|
||||
ParsedContent.replace(Pos, serverToken.size(), mServ->getName());
|
||||
}
|
||||
else {
|
||||
ParsedContent.replace(Pos, serverToken.size(), "Down");
|
||||
}
|
||||
Pos = ParsedContent.find( serverToken );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// PLAYERLIST
|
||||
Pos = ParsedContent.find( "%playerlist%" );
|
||||
Pos = ParsedContent.find( "%playerlist%" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
size_t SecondPos = ParsedContent.find( "%playerlist%", Pos+1 );
|
||||
|
|
@ -280,134 +286,137 @@ void cHTMLTemplate::Process( void )
|
|||
break;
|
||||
std::string myInline = ParsedContent.substr( Pos, SecondPos - Pos + 12 );
|
||||
std::string PlayerList;
|
||||
|
||||
Network->PushConn();
|
||||
for( tSock = Network->FirstSocket(); !Network->FinishedSockets(); tSock = Network->NextSocket() )
|
||||
{
|
||||
try
|
||||
std::scoped_lock lock(Network->internallock);
|
||||
|
||||
Network->pushConn();
|
||||
for( tSock = Network->FirstSocket(); !Network->FinishedSockets(); tSock = Network->NextSocket() )
|
||||
{
|
||||
if( tSock != NULL )
|
||||
try
|
||||
{
|
||||
CChar *tChar = tSock->CurrcharObj();
|
||||
if( ValidateObject( tChar ) )
|
||||
if( tSock != NULL )
|
||||
{
|
||||
std::string parsedInline = myInline;
|
||||
parsedInline.replace( 0, 12, "" );
|
||||
parsedInline.replace( parsedInline.length()-12, 12, "" );
|
||||
|
||||
// Tokens for the PlayerList
|
||||
// %playername
|
||||
// %playertitle
|
||||
// %playerip
|
||||
// %playeraccount
|
||||
// %playerx
|
||||
// %playery
|
||||
// %playerz
|
||||
// %playerrace
|
||||
// %playerregion
|
||||
|
||||
// PlayerName
|
||||
size_t sPos = parsedInline.find( "%playername" );
|
||||
while( sPos != std::string::npos )
|
||||
CChar *tChar = tSock->CurrcharObj();
|
||||
if( ValidateObject( tChar ) )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 11, tChar->GetName() ):parsedInline.replace( sPos, 11, "" );
|
||||
sPos = parsedInline.find( "%playername" );
|
||||
}
|
||||
std::string parsedInline = myInline;
|
||||
parsedInline.replace( 0, 12, "" );
|
||||
parsedInline.replace( parsedInline.length()-12, 12, "" );
|
||||
|
||||
// PlayerTitle
|
||||
sPos = parsedInline.find( "%playertitle" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 12, tChar->GetTitle() ):parsedInline.replace( sPos, 12, "" );
|
||||
// Tokens for the PlayerList
|
||||
// %playername
|
||||
// %playertitle
|
||||
// %playerip
|
||||
// %playeraccount
|
||||
// %playerx
|
||||
// %playery
|
||||
// %playerz
|
||||
// %playerrace
|
||||
// %playerregion
|
||||
|
||||
// PlayerName
|
||||
size_t sPos = parsedInline.find( "%playername" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 11, tChar->GetName() ):parsedInline.replace( sPos, 11, "" );
|
||||
sPos = parsedInline.find( "%playername" );
|
||||
}
|
||||
|
||||
// PlayerTitle
|
||||
sPos = parsedInline.find( "%playertitle" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 12, tChar->GetTitle() ):parsedInline.replace( sPos, 12, "" );
|
||||
sPos = parsedInline.find( "%playertitle" );
|
||||
}
|
||||
|
||||
// PlayerIP
|
||||
sPos = parsedInline.find( "%playerip" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
CSocket *mySock = tChar->GetSocket();
|
||||
char ClientIP[32];
|
||||
sprintf( ClientIP, "%i.%i.%i.%i", mySock->ClientIP4(), mySock->ClientIP3(), mySock->ClientIP3(), mySock->ClientIP1() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 9, ClientIP ):parsedInline.replace( sPos, 9, "" );
|
||||
// PlayerIP
|
||||
sPos = parsedInline.find( "%playerip" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
CSocket *mySock = tChar->GetSocket();
|
||||
|
||||
// PlayerAccount
|
||||
sPos = parsedInline.find( "%playeraccount" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
CAccountBlock& toScan = tChar->GetAccount();
|
||||
if( toScan.wAccountIndex != AB_INVALID_ID )
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 14, toScan.sUsername):parsedInline.replace( sPos, 14, "" );
|
||||
auto ClientIP = format("%i.%i.%i.%i", mySock->ClientIP4(), mySock->ClientIP3(), mySock->ClientIP3(), mySock->ClientIP1() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 9, ClientIP ):parsedInline.replace( sPos, 9, "" );
|
||||
sPos = parsedInline.find( "%playerip" );
|
||||
}
|
||||
|
||||
// PlayerAccount
|
||||
sPos = parsedInline.find( "%playeraccount" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
CAccountBlock& toScan = tChar->GetAccount();
|
||||
if( toScan.wAccountIndex != AB_INVALID_ID )
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 14, toScan.sUsername):parsedInline.replace( sPos, 14, "" );
|
||||
sPos = parsedInline.find( "%playeraccount" );
|
||||
}
|
||||
|
||||
// PlayerX
|
||||
sPos = parsedInline.find( "%playerx" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
UString myX = UString::number( tChar->GetX() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, myX ):parsedInline.replace( sPos, 8, "" );
|
||||
// PlayerX
|
||||
sPos = parsedInline.find( "%playerx" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
UString myX = str_number( tChar->GetX() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, myX ):parsedInline.replace( sPos, 8, "" );
|
||||
sPos = parsedInline.find( "%playerx" );
|
||||
}
|
||||
|
||||
// PlayerY
|
||||
sPos = parsedInline.find( "%playery" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
UString myY = UString::number( tChar->GetY() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, myY ):parsedInline.replace( sPos, 8, "" );
|
||||
// PlayerY
|
||||
sPos = parsedInline.find( "%playery" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
UString myY = str_number( tChar->GetY() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, myY ):parsedInline.replace( sPos, 8, "" );
|
||||
sPos = parsedInline.find( "%playery" );
|
||||
}
|
||||
|
||||
// PlayerZ
|
||||
sPos = parsedInline.find( "%playerz" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
UString myZ = UString::number( tChar->GetZ() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, myZ ):parsedInline.replace( sPos, 8, "" );
|
||||
// PlayerZ
|
||||
sPos = parsedInline.find( "%playerz" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
UString myZ = str_number( tChar->GetZ() );
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, myZ ):parsedInline.replace( sPos, 8, "" );
|
||||
sPos = parsedInline.find( "%playerz" );
|
||||
}
|
||||
|
||||
// PlayerRace -- needs testing
|
||||
sPos = parsedInline.find( "%playerrace" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
RACEID myRace = tChar->GetRace();
|
||||
const std::string rName = Races->Name( myRace );
|
||||
size_t raceLenName = rName.length();
|
||||
|
||||
if( raceLenName > 0 )
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 11, rName ):parsedInline.replace( sPos, 11, "");
|
||||
// PlayerRace -- needs testing
|
||||
sPos = parsedInline.find( "%playerrace" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
RACEID myRace = tChar->GetRace();
|
||||
const std::string rName = Races->Name( myRace );
|
||||
size_t raceLenName = rName.length();
|
||||
|
||||
// PlayerRegion
|
||||
sPos = parsedInline.find( "%playerregion" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 13, tChar->GetRegion()->GetName() ):parsedInline.replace( sPos, 13, "");
|
||||
if( raceLenName > 0 )
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 11, rName ):parsedInline.replace( sPos, 11, "");
|
||||
sPos = parsedInline.find( "%playerrace" );
|
||||
}
|
||||
|
||||
// PlayerRegion
|
||||
sPos = parsedInline.find( "%playerregion" );
|
||||
}
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 13, tChar->GetRegion()->GetName() ):parsedInline.replace( sPos, 13, "");
|
||||
sPos = parsedInline.find( "%playerregion" );
|
||||
}
|
||||
|
||||
PlayerList += parsedInline;
|
||||
PlayerList += parsedInline;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
Console << "| EXCEPTION: Invalid character/socket pointer found. Ignored." << myendl;
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
Console << "| EXCEPTION: Invalid character/socket pointer found. Ignored." << myendl;
|
||||
}
|
||||
Network->popConn();
|
||||
}
|
||||
Network->PopConn();
|
||||
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, myInline.length(), PlayerList ):ParsedContent.replace( Pos, myInline.length(), "");
|
||||
Pos = ParsedContent.find( "%playerlist%" );
|
||||
}
|
||||
|
||||
// GuildCount
|
||||
UString GuildCount = UString::number( (SI32)GuildSys->NumGuilds() );
|
||||
UString GuildCount = str_number( (SI32)GuildSys->NumGuilds() );
|
||||
Pos = ParsedContent.find( "%guildcount" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
|
|
@ -431,16 +440,16 @@ void cHTMLTemplate::Process( void )
|
|||
parsedInline.replace( 0, 11, "" );
|
||||
parsedInline.replace( parsedInline.length()-11, 11, "" );
|
||||
|
||||
// Tokens for the GuildList
|
||||
// %guildid
|
||||
// %guildname
|
||||
// Tokens for the GuildList
|
||||
// %guildid
|
||||
// %guildname
|
||||
|
||||
// GuildID
|
||||
size_t sPos;
|
||||
CGuild *myGuild = GuildSys->Guild( i );
|
||||
|
||||
UString GuildID = UString::number( i );
|
||||
sPos = parsedInline.find( "%guildid" );
|
||||
UString GuildID = str_number( i );
|
||||
sPos = parsedInline.find( "%guildid" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 8, GuildID ):parsedInline.replace( sPos, 8, "" );
|
||||
|
|
@ -448,7 +457,7 @@ void cHTMLTemplate::Process( void )
|
|||
}
|
||||
|
||||
// GuildName
|
||||
sPos = parsedInline.find( "%guildname" );
|
||||
sPos = parsedInline.find( "%guildname" );
|
||||
while( sPos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?parsedInline.replace( sPos, 10, myGuild->Name() ):parsedInline.replace( sPos, 10, "" );
|
||||
|
|
@ -468,8 +477,8 @@ void cHTMLTemplate::Process( void )
|
|||
ObjectFactory::getSingleton().IterateOver( OT_CHAR, b, NULL, &CountNPCFunctor );
|
||||
npccount = b;
|
||||
|
||||
UString npcs = UString::number( npccount );
|
||||
Pos = ParsedContent.find( "%npcs" );
|
||||
UString npcs = str_number( npccount );
|
||||
Pos = ParsedContent.find( "%npcs" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 5, npcs ):ParsedContent.replace( Pos, 5, "0" );
|
||||
|
|
@ -478,7 +487,7 @@ void cHTMLTemplate::Process( void )
|
|||
|
||||
// Performance Dump
|
||||
R64 eps = 0.00000000001;
|
||||
Pos = ParsedContent.find( "%performance" );
|
||||
Pos = ParsedContent.find( "%performance" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
std::string performance;
|
||||
|
|
@ -542,10 +551,10 @@ void cHTMLTemplate::Process( void )
|
|||
}
|
||||
|
||||
// Update Time in SECONDS
|
||||
Pos = ParsedContent.find( "%updatetime" );
|
||||
Pos = ParsedContent.find( "%updatetime" );
|
||||
while( Pos != std::string::npos )
|
||||
{
|
||||
UString strUpdateTimer = UString::number( UpdateTimer );
|
||||
UString strUpdateTimer = str_number( UpdateTimer );
|
||||
(cwmWorldState->GetKeepRun())?ParsedContent.replace( Pos, 11, strUpdateTimer ):ParsedContent.replace( Pos, 11, "0" );
|
||||
Pos = ParsedContent.find( "%updatetime" );
|
||||
}
|
||||
|
|
@ -561,12 +570,11 @@ void cHTMLTemplate::Process( void )
|
|||
Output.close();
|
||||
}
|
||||
else
|
||||
Console.Error( " Couldn't open the template file %s for writing", OutputFile.c_str() );
|
||||
Console.error( format(" Couldn't open the template file %s for writing", OutputFile.c_str()) );
|
||||
}
|
||||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void Poll( void )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Updates the page if needed
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -581,7 +589,6 @@ void cHTMLTemplate::Poll( void )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void LoadTemplate( void )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Loads the Template into memory
|
||||
//|
|
||||
|
|
@ -596,7 +603,7 @@ void cHTMLTemplate::LoadTemplate( void )
|
|||
|
||||
if( !InputFile1.is_open() )
|
||||
{
|
||||
Console.Error( "Couldn't open HTML Template File %s", InputFile.c_str() );
|
||||
Console.error( format("Couldn't open HTML Template File %s", InputFile.c_str()) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -614,11 +621,10 @@ void cHTMLTemplate::LoadTemplate( void )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void UnloadTemplate( void )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Unloads the Template (i.e. for reloading)
|
||||
//|
|
||||
//| Changes - 08062003 - EviLDeD - Updated to properly unload a template
|
||||
//|
|
||||
//| Changes - 08062003 - Updated to properly unload a template
|
||||
//| and to unload the correect template, instead of just the
|
||||
//| status template.
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -630,7 +636,6 @@ void cHTMLTemplate::UnloadTemplate( void )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void Load( ScriptSection *found )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Loads the HTML Template from a ScriptSection
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -662,12 +667,14 @@ void cHTMLTemplate::Load( ScriptSection *found )
|
|||
else if( UTag == "INPUT" )
|
||||
{
|
||||
fullPath = cwmWorldState->ServerData()->Directory( CSDDP_DEFS ) + "html/" + data;
|
||||
InputFile = fullPath.stripWhiteSpace().substr( 0, MAX_PATH - 1 );
|
||||
//LOOKATME
|
||||
InputFile = trim(fullPath).substr( 0, MAX_PATH - 1 );
|
||||
}
|
||||
else if( UTag == "OUTPUT" )
|
||||
{
|
||||
fullPath = cwmWorldState->ServerData()->Directory( CSDDP_HTML ) + data;
|
||||
OutputFile = fullPath.stripWhiteSpace().substr( 0, MAX_PATH - 1 );
|
||||
//LOOKATME
|
||||
OutputFile = trim(fullPath).substr( 0, MAX_PATH - 1 );
|
||||
}
|
||||
else if( UTag == "NAME" )
|
||||
Name = data;
|
||||
|
|
@ -689,7 +696,6 @@ cHTMLTemplates::~cHTMLTemplates()
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void Load( void )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Loads the HTML Templates from the scripts
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -715,7 +721,6 @@ void cHTMLTemplates::Load( void )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void Unload( void )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Unloads all Templates
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -734,7 +739,6 @@ void cHTMLTemplates::Unload( void )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void Poll( ETemplateType nTemplateID )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Polls the templates for updates
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -754,7 +758,6 @@ void cHTMLTemplates::Poll( ETemplateType nTemplateID )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - void TemplateInfoGump( CSocket *mySocket )
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Shows an information gump about current templates
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -792,10 +795,8 @@ void cHTMLTemplates::TemplateInfoGump( CSocket *mySocket )
|
|||
++Entries;
|
||||
|
||||
// ~25 pixel per entry
|
||||
char tmpName[256];
|
||||
sprintf( tmpName, "%s (%i)", Templates[ i ]->GetName().c_str(), i );
|
||||
|
||||
InfoGump.AddText( 40, static_cast<UI16>( 40 + (Entries-1)*25 ), cwmWorldState->ServerData()->LeftTextColour(), tmpName );
|
||||
InfoGump.AddText( 40, static_cast<UI16>( 40 + (Entries-1)*25 ), cwmWorldState->ServerData()->LeftTextColour(), format( "%s (%i)", Templates[ i ]->GetName().c_str(), i ) );
|
||||
|
||||
if( Entries == 5 )
|
||||
Entries = 0;
|
||||
|
|
@ -806,29 +807,26 @@ void cHTMLTemplates::TemplateInfoGump( CSocket *mySocket )
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - std::string GetName( void ) const
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Returns the name of the Template
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
std::string cHTMLTemplate::GetName( void ) const
|
||||
{
|
||||
return Name;
|
||||
return Name;
|
||||
}
|
||||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - std::string GetOutput( void ) const
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Gets the Output Filename
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
std::string cHTMLTemplate::GetOutput( void ) const
|
||||
{
|
||||
return OutputFile;
|
||||
return OutputFile;
|
||||
}
|
||||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - std::string GetInput( void ) const
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Gets the Input Filename
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -839,18 +837,16 @@ std::string cHTMLTemplate::GetInput( void ) const
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - UI32 GetScheduledUpdate( void ) const
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Gets the next scheduled Update time
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
UI32 cHTMLTemplate::GetScheduledUpdate( void ) const
|
||||
{
|
||||
return ScheduledUpdate;
|
||||
return ScheduledUpdate;
|
||||
}
|
||||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - UI32 GetUpdateTimer( void ) const
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Gets the Update timer
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
|
|
@ -861,14 +857,11 @@ UI32 cHTMLTemplate::GetUpdateTimer( void ) const
|
|||
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Function - ETemplateType GetTemplateType( void ) const
|
||||
//| Programmer - Dark-Storm
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
//| Purpose - Gets the Template Type
|
||||
//o-----------------------------------------------------------------------------------------------o
|
||||
ETemplateType cHTMLTemplate::GetTemplateType( void ) const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue