summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Globals.h9
-rw-r--r--source/ManualBindings.cpp78
-rw-r--r--source/StringUtils.cpp129
-rw-r--r--source/StringUtils.h51
-rw-r--r--source/cGroupManager.cpp10
-rw-r--r--source/cLuaCommandBinder.cpp8
-rw-r--r--source/cMonsterConfig.cpp6
-rw-r--r--source/cPiston.h79
-rw-r--r--source/cPlayer.cpp24
-rw-r--r--source/cPluginManager.cpp11
-rw-r--r--source/cServer.cpp56
-rw-r--r--source/cWebAdmin.cpp13
-rw-r--r--source/cWebPlugin_Lua.cpp15
13 files changed, 384 insertions, 105 deletions
diff --git a/source/Globals.h b/source/Globals.h
index d4484e4c9..02559647d 100644
--- a/source/Globals.h
+++ b/source/Globals.h
@@ -28,6 +28,7 @@
#include <semaphore.h>
#include <errno.h>
#include <fcntl.h>
+ #include <memory.h>
#endif
@@ -42,6 +43,13 @@
+// Compatibility:
+#define ASSERT assert
+
+
+
+
+
// STL stuff:
#include <vector>
#include <list>
@@ -54,6 +62,7 @@
// Common headers:
+#include "StringUtils.h"
#include "cSleep.h"
#include "cCriticalSection.h"
#include "cSemaphore.h"
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 7e2e45855..ba844b702 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -15,7 +15,9 @@
#include "cStringMap.h"
#include "md5/md5.h"
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+
+
/****************************
* Lua bound functions with special return types
@@ -26,7 +28,7 @@ static int tolua_StringSplit(lua_State* tolua_S)
std::string str = ((std::string) tolua_tocppstring(tolua_S,1,0));
std::string delim = ((std::string) tolua_tocppstring(tolua_S,2,0));
- std::vector<std::string> Split = StringSplit( str, delim );
+ AStringVector Split = StringSplit( str, delim );
lua_createtable(tolua_S, Split.size(), 0);
int newTable = lua_gettop(tolua_S);
@@ -41,6 +43,10 @@ static int tolua_StringSplit(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_LOG(lua_State* tolua_S)
{
const char* str = tolua_tocppstring(tolua_S,1,0);
@@ -48,6 +54,10 @@ static int tolua_LOG(lua_State* tolua_S)
return 0;
}
+
+
+
+
static int tolua_LOGINFO(lua_State* tolua_S)
{
const char* str = tolua_tocppstring(tolua_S,1,0);
@@ -55,6 +65,10 @@ static int tolua_LOGINFO(lua_State* tolua_S)
return 0;
}
+
+
+
+
static int tolua_LOGWARN(lua_State* tolua_S)
{
const char* str = tolua_tocppstring(tolua_S,1,0);
@@ -62,6 +76,10 @@ static int tolua_LOGWARN(lua_State* tolua_S)
return 0;
}
+
+
+
+
static int tolua_LOGERROR(lua_State* tolua_S)
{
const char* str = tolua_tocppstring(tolua_S,1,0);
@@ -69,6 +87,10 @@ static int tolua_LOGERROR(lua_State* tolua_S)
return 0;
}
+
+
+
+
static int tolua_cWorld_GetAllPlayers(lua_State* tolua_S)
{
cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
@@ -79,6 +101,10 @@ static int tolua_cWorld_GetAllPlayers(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_cPlugin_GetCommands(lua_State* tolua_S)
{
cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
@@ -100,6 +126,10 @@ static int tolua_cPlugin_GetCommands(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_cPluginManager_GetAllPlugins(lua_State* tolua_S)
{
cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
@@ -121,6 +151,10 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
@@ -142,6 +176,10 @@ static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_cPlayer_GetResolvedPermissions(lua_State* tolua_S)
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
@@ -163,6 +201,10 @@ static int tolua_cPlayer_GetResolvedPermissions(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_cPlugin_BindCommand(lua_State* tolua_S)
{
cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
@@ -217,6 +259,10 @@ static int tolua_cPlugin_BindCommand(lua_State* tolua_S)
return 0;
}
+
+
+
+
static int tolua_cWebPlugin_Lua_AddTab(lua_State* tolua_S)
{
cWebPlugin_Lua* self = (cWebPlugin_Lua*) tolua_tousertype(tolua_S,1,0);
@@ -260,6 +306,10 @@ static int tolua_cWebPlugin_Lua_AddTab(lua_State* tolua_S)
return 0;
}
+
+
+
+
static int tolua_md5(lua_State* tolua_S)
{
std::string SourceString = tolua_tostring(tolua_S, 1, 0);
@@ -268,6 +318,10 @@ static int tolua_md5(lua_State* tolua_S)
return 1;
}
+
+
+
+
static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap )
{
lua_newtable(tolua_S);
@@ -285,18 +339,30 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
return 1;
}
+
+
+
+
static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
{
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
return tolua_push_StringStringMap(tolua_S, self->Params);
}
+
+
+
+
static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
{
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
return tolua_push_StringStringMap(tolua_S, self->PostParams);
}
+
+
+
+
static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
{
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
@@ -316,6 +382,10 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
return 1;
}
+
+
+
+
void ManualBindings::Bind( lua_State* tolua_S )
{
tolua_beginmodule(tolua_S,NULL);
@@ -357,3 +427,7 @@ void ManualBindings::Bind( lua_State* tolua_S )
tolua_endmodule(tolua_S);
}
+
+
+
+
diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp
new file mode 100644
index 000000000..7a9350ca8
--- /dev/null
+++ b/source/StringUtils.cpp
@@ -0,0 +1,129 @@
+
+// StringUtils.cpp
+
+// Implements the various string helper functions:
+
+#include "Globals.h"
+
+
+
+
+
+AString & AppendVPrintf(AString & str, const char *format, va_list args)
+{
+ ASSERT(format != NULL);
+
+ char buffer[2048];
+ size_t len;
+ if ((len = _vsnprintf_s(buffer, ARRAYCOUNT(buffer), _TRUNCATE, format, args)) != -1)
+ {
+ str.append(buffer, len);
+ return str;
+ }
+ len = _vscprintf(format, args);
+ if (len == -1)
+ {
+ return str;
+ }
+ std::auto_ptr<char> tmp(new char[len + 1]);
+ ASSERT(tmp.get() != NULL); // Why not alloced? Is the length reasonable?
+ if (tmp.get() == NULL)
+ {
+ throw std::bad_alloc();
+ }
+ if ((len = vsprintf_s(tmp.get(), len + 1, format, args)) != -1)
+ {
+ str.append(tmp.get(), len);
+ }
+ ASSERT(len != -1);
+ return str;
+}
+
+
+
+
+
+AString & Printf(AString & str, const char *format, ...)
+{
+ str.clear();
+ va_list args;
+ va_start(args, format);
+ std::string &retval = AppendVPrintf(str, format, args);
+ va_end(args);
+ return retval;
+}
+
+
+
+
+
+AString & AppendPrintf(AString &str, const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ std::string &retval = AppendVPrintf(str, format, args);
+ va_end(args);
+ return retval;
+}
+
+
+
+
+
+AStringVector StringSplit(const AString & str, const AString & delim)
+{
+ AStringVector results;
+ size_t cutAt = 0;
+ size_t Prev = 0;
+ while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
+ {
+ if (cutAt > 0)
+ {
+ results.push_back(str.substr(0, cutAt));
+ }
+ Prev = cutAt + delim.length();
+ }
+ if (Prev < str.length())
+ {
+ results.push_back(str.substr(Prev));
+ }
+ return results;
+}
+
+
+
+
+AString & StrToUpper(AString & s)
+{
+ AString::iterator i = s.begin();
+ AString::iterator end = s.end();
+
+ while (i != end)
+ {
+ *i = (char)toupper(*i);
+ ++i;
+ }
+ return s;
+}
+
+
+
+
+
+int NoCaseCompare(const AString & s1, const AString & s2)
+{
+ #ifdef _MSC_VER
+ // MSVC has stricmp that compares case-insensitive:
+ return stricmp(s1.c_str(), s2.c_str());
+ #else
+ // Do it the hard way:
+ AString s1Copy(s1);
+ AString s2Copy(s2);
+ return StrToUpper(s1Copy).compare(StrToUpper(s2Copy));
+ #endif // else _MSC_VER
+}
+
+
+
+
+
diff --git a/source/StringUtils.h b/source/StringUtils.h
new file mode 100644
index 000000000..97e42f5f5
--- /dev/null
+++ b/source/StringUtils.h
@@ -0,0 +1,51 @@
+
+// StringUtils.h
+
+// Interfaces to various string helper functions
+
+
+
+
+#ifndef STRINGUTILS_H_INCLUDED
+#define STRINGUTILS_H_INCLUDED
+
+
+
+
+
+typedef std::string AString;
+typedef std::vector<AString> AStringVector;
+
+
+
+
+
+/// Add the formated string to the existing data in the string
+extern AString & AppendVPrintf(AString & str, const char * format, va_list args);
+
+/// Output the formatted text into the string
+extern AString & Printf (AString & str, const char * format, ...);
+
+/// Add the formatted string to the existing data in the string
+extern AString & AppendPrintf (AString & str, const char * format, ...);
+
+/// Split the string at delimiters, return as a stringvector
+extern AStringVector StringSplit(const AString & str, const AString & delim);
+
+/// In-place string conversion to uppercase; returns the same string
+extern AString & StrToUpper(AString & s);
+
+/// Case-insensitive string comparison; returns 0 if the strings are the same
+extern int NoCaseCompare(const AString & s1, const AString & s2);
+
+
+// If you have any other string helper functions, declare them here
+
+
+
+
+#endif // STRINGUTILS_H_INCLUDED
+
+
+
+
diff --git a/source/cGroupManager.cpp b/source/cGroupManager.cpp
index a67e79418..30d70171c 100644
--- a/source/cGroupManager.cpp
+++ b/source/cGroupManager.cpp
@@ -7,7 +7,9 @@
#include "cChatColor.h"
#include "cRoot.h"
-extern std::vector< std::string > StringSplit( std::string str, std::string delim);
+
+
+
typedef std::map< std::string, cGroup* > GroupMap;
struct cGroupManager::sGroupManagerState
@@ -57,7 +59,7 @@ cGroupManager::cGroupManager()
std::string Commands = IniFile.GetValue( KeyName, "Commands", "" );
if( Commands.size() > 0 )
{
- std::vector< std::string > Split = StringSplit( Commands, "," );
+ AStringVector Split = StringSplit( Commands, "," );
for( unsigned int i = 0; i < Split.size(); i++)
{
Group->AddCommand( Split[i] );
@@ -68,7 +70,7 @@ cGroupManager::cGroupManager()
std::string Permissions = IniFile.GetValue( KeyName, "Permissions", "" );
if( Permissions.size() > 0 )
{
- std::vector< std::string > Split = StringSplit( Permissions, "," );
+ AStringVector Split = StringSplit( Permissions, "," );
for( unsigned int i = 0; i < Split.size(); i++)
{
Group->AddPermission( Split[i] );
@@ -79,7 +81,7 @@ cGroupManager::cGroupManager()
std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" );
if( Groups.size() > 0 )
{
- std::vector< std::string > Split = StringSplit( Groups, "," );
+ AStringVector Split = StringSplit( Groups, "," );
for( unsigned int i = 0; i < Split.size(); i++)
{
Group->InheritFrom( GetGroup( Split[i].c_str() ) );
diff --git a/source/cLuaCommandBinder.cpp b/source/cLuaCommandBinder.cpp
index 5ed3515ca..2e1d504b1 100644
--- a/source/cLuaCommandBinder.cpp
+++ b/source/cLuaCommandBinder.cpp
@@ -11,7 +11,6 @@
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
extern bool report_errors(lua_State* lua, int status);
cLuaCommandBinder::cLuaCommandBinder()
@@ -58,8 +57,11 @@ bool cLuaCommandBinder::BindCommand( const std::string & a_Command, const std::s
bool cLuaCommandBinder::HandleCommand( const std::string & a_Command, cPlayer* a_Player )
{
- std::vector<std::string> Split = StringSplit( a_Command, " ");
- if( Split.size() == 0 ) return false;
+ AStringVector Split = StringSplit(a_Command, " ");
+ if (Split.size() == 0)
+ {
+ return false;
+ }
CommandMap::iterator FoundCommand = m_BoundCommands.find( Split[0] );
if( FoundCommand != m_BoundCommands.end() )
diff --git a/source/cMonsterConfig.cpp b/source/cMonsterConfig.cpp
index 1c3a38fea..c37641f2f 100644
--- a/source/cMonsterConfig.cpp
+++ b/source/cMonsterConfig.cpp
@@ -13,7 +13,9 @@
using namespace std;
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+
+
struct cMonsterConfig::sAttributesStruct
{
@@ -61,7 +63,7 @@ void cMonsterConfig::Initialize() {
return;
}
- vector<string> SplitList = StringSplit(m_pState->MonsterTypes,",");
+ AStringVector SplitList = StringSplit(m_pState->MonsterTypes,",");
for(unsigned int i = 0; i < SplitList.size(); ++i) {
if(!SplitList[i].empty()) {
printf("Getting Attributes for: %s \n",SplitList[i].c_str());
diff --git a/source/cPiston.h b/source/cPiston.h
index e976c24a3..afb5780fb 100644
--- a/source/cPiston.h
+++ b/source/cPiston.h
@@ -1,45 +1,60 @@
+
#pragma once
-#include <cstdio>
+
+
+
+
+
+// fwd: "cWorld.h"
class cWorld;
+
+
+
+
+
class cPiston
{
public:
-cPiston( cWorld* a_World );
-
-static char RotationPitchToMetaData( float a_Rotation, float a_Pitch )
-{
- std::printf("pre:a_Rotation %f \n",a_Rotation);
- std::printf("a_Pitch %f \n",a_Pitch);
-
- if (a_Pitch >= 50.f ){
- return 0x1;
- } else if ( a_Pitch <= -50.f ) {
- return 0x0;
- } else {
-
- a_Rotation += 90 + 45; // So its not aligned with axis
- std::printf("a_Rotation %f \n",a_Rotation);
-
- if( a_Rotation > 360.f ) a_Rotation -= 360.f;
- if( a_Rotation >= 0.f && a_Rotation < 90.f )
- { std::printf("1111\n");return 0x4;}
- else if( a_Rotation >= 180 && a_Rotation < 270 )
- { std::printf("2222\n");return 0x5;}
- else if( a_Rotation >= 90 && a_Rotation < 180 )
- { std::printf("3333\n");return 0x2;}
- else
- { std::printf("4444\n");return 0x3;}
+ cPiston( cWorld* a_World );
+
+ static char RotationPitchToMetaData( float a_Rotation, float a_Pitch )
+ {
+ std::printf("pre:a_Rotation %f \n",a_Rotation);
+ std::printf("a_Pitch %f \n",a_Pitch);
+
+ if (a_Pitch >= 50.f ){
+ return 0x1;
+ } else if ( a_Pitch <= -50.f ) {
+ return 0x0;
+ } else {
+
+ a_Rotation += 90 + 45; // So its not aligned with axis
+ std::printf("a_Rotation %f \n",a_Rotation);
+
+ if( a_Rotation > 360.f ) a_Rotation -= 360.f;
+ if( a_Rotation >= 0.f && a_Rotation < 90.f )
+ { std::printf("1111\n");return 0x4;}
+ else if( a_Rotation >= 180 && a_Rotation < 270 )
+ { std::printf("2222\n");return 0x5;}
+ else if( a_Rotation >= 90 && a_Rotation < 180 )
+ { std::printf("3333\n");return 0x2;}
+ else
+ { std::printf("4444\n");return 0x3;}
+ }
}
-}
-void ExtendPiston( int, int, int );
-void RetractPiston( int, int, int );
+ void ExtendPiston( int, int, int );
+ void RetractPiston( int, int, int );
-cWorld* m_World;
+ cWorld* m_World;
private:
-void ChainMove( int, int, int, char, unsigned short * );
-unsigned short FirstPassthroughBlock( int, int, int, char );
+ void ChainMove( int, int, int, char, unsigned short * );
+ unsigned short FirstPassthroughBlock( int, int, int, char );
};
+
+
+
+
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 23c43ae25..0dd5695a4 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -43,13 +43,11 @@
#include "../iniFile/iniFile.h"
#include <json/json.h>
-#ifndef _WIN32 // for mkdir
-#include <sys/stat.h>
-#include <sys/types.h>
-#define sprintf_s(dst, size, format, ...) sprintf(dst, format, __VA_ARGS__ )
-#endif
#define float2int(x) ((x)<0 ? ((int)(x))-1 : (int)(x))
-extern std::vector< std::string > StringSplit( std::string str, std::string delim);
+
+
+
+
CLASS_DEFINITION( cPlayer, cPawn );
@@ -557,9 +555,13 @@ bool cPlayer::CanUseCommand( const char* a_Command )
return false;
}
+
+
+
+
bool cPlayer::HasPermission( const char* a_Permission )
{
- std::vector< std::string > Split = StringSplit( a_Permission, "." );
+ AStringVector Split = StringSplit( a_Permission, "." );
PermissionMap Possibilities = m_pState->ResolvedPermissions;
// Now search the namespaces
while( Possibilities.begin() != Possibilities.end() )
@@ -567,7 +569,7 @@ bool cPlayer::HasPermission( const char* a_Permission )
PermissionMap::iterator itr = Possibilities.begin();
if( itr->second )
{
- std::vector< std::string > OtherSplit = StringSplit( itr->first, "." );
+ AStringVector OtherSplit = StringSplit( itr->first, "." );
if( OtherSplit.size() <= Split.size() )
{
unsigned int i;
@@ -589,6 +591,10 @@ bool cPlayer::HasPermission( const char* a_Permission )
return false;
}
+
+
+
+
bool cPlayer::IsInGroup( const char* a_Group )
{
for( GroupList::iterator itr = m_pState->ResolvedGroups.begin(); itr != m_pState->ResolvedGroups.end(); ++itr )
@@ -743,7 +749,7 @@ void cPlayer::LoadPermissionsFromDisk()
std::string Groups = IniFile.GetValue(m_pState->PlayerName, "Groups", "");
if( Groups.size() > 0 )
{
- std::vector< std::string > Split = StringSplit( Groups, "," );
+ AStringVector Split = StringSplit( Groups, "," );
for( unsigned int i = 0; i < Split.size(); i++ )
{
AddToGroup( Split[i].c_str() );
diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp
index f7d8ad7dc..de49d81e9 100644
--- a/source/cPluginManager.cpp
+++ b/source/cPluginManager.cpp
@@ -5,7 +5,6 @@
#include "cPlugin.h"
#include "cPlugin_Lua.h"
#include "cPlugin_NewLua.h"
-#include "cMCLogger.h"
#include "cWebAdmin.h"
#include "cItem.h"
#include "cRoot.h"
@@ -15,17 +14,15 @@
#include "SquirrelBindings.h"
#if USE_SQUIRREL
-#pragma warning(disable:4100;disable:4127;disable:4510;disable:4610;disable:4244;disable:4512) // Getting A LOT of these warnings from SqPlus
-#include <sqplus/sqplus.h>
-#pragma warning(default:4100;default:4127;default:4510;default:4610;default:4244;default:4512)
+ #pragma warning(disable:4100;disable:4127;disable:4510;disable:4610;disable:4244;disable:4512) // Getting A LOT of these warnings from SqPlus
+ #include <sqplus/sqplus.h>
+ #pragma warning(default:4100;default:4127;default:4510;default:4610;default:4244;default:4512)
#endif
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
-
typedef std::list< cPlugin_Lua* > LuaPluginList;
typedef std::map< cPluginManager::PluginHook, cPluginManager::PluginList > HookMap;
@@ -96,7 +93,7 @@ void cPluginManager::ReloadPluginsNow()
// allow for comma separated plugin list
// degrades and works fine for the plugin
// per line
- std::vector< std::string > split = StringSplit( PluginFile, "," );
+ AStringVector split = StringSplit( PluginFile, "," );
for (unsigned int j = 0; j < split.size(); j++) {
cPlugin_Lua* Plugin = new cPlugin_Lua( (split[j] + std::string(".lua") ).c_str() );
if( !AddLuaPlugin( Plugin ) )
diff --git a/source/cServer.cpp b/source/cServer.cpp
index f13fc50dd..826de3bb3 100644
--- a/source/cServer.cpp
+++ b/source/cServer.cpp
@@ -347,6 +347,10 @@ void ServerTickThread( void * a_Param )
LOG("TICK THREAD STOPPED");
}
+
+
+
+
void cServer::StartListenThread()
{
m_pState->pListenThread = new cThread( ServerListenThread, this, "cServer::ServerListenThread" );
@@ -355,50 +359,24 @@ void cServer::StartListenThread()
m_pState->pTickThread->Start( true );
}
-std::vector< std::string > StringSplit(std::string str, std::string delim)
-{
- std::vector< std::string > results;
- size_t cutAt;
- while( (cutAt = str.find_first_of(delim)) != str.npos )
- {
- if(cutAt > 0)
- {
- results.push_back(str.substr(0,cutAt));
- }
- str = str.substr(cutAt+1);
- }
- if(str.length() > 0)
- {
- results.push_back(str);
- }
- return results;
-}
+
+
+
template <class T>
-bool from_string(T& t,
- const std::string& s,
- std::ios_base& (*f)(std::ios_base&))
+bool from_string(
+ T& t,
+ const std::string& s,
+ std::ios_base& (*f)(std::ios_base&)
+)
{
std::istringstream iss(s);
return !(iss >> f >> t).fail();
}
-std::string & StrToUpper(std::string& s)
-{
- std::string::iterator i = s.begin();
- std::string::iterator end = s.end();
- while (i != end) {
- *i = (char)toupper(*i);
- ++i;
- }
- return s;
-}
-int NoCaseCompare( std::string s1, std::string s2 )
-{
- return StrToUpper( s1 ).compare( StrToUpper( s2 ) );
-}
+
bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
{
@@ -410,11 +388,11 @@ bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
if( Command.length() <= 0 ) return false;
if( Command[0] != '/' ) return false;
- std::vector< std::string > split = StringSplit( Command, " " );
+ AStringVector split = StringSplit( Command, " " );
if( split.size() == 0 )
return false;
- if( split[0].compare("/coords") == 0 )
+ if (split[0].compare("/coords") == 0)
{
char c_Str[128];
sprintf_s( c_Str, 128, "[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", a_Client.GetPlayer()->GetPosX(), a_Client.GetPlayer()->GetPosY(), a_Client.GetPlayer()->GetPosZ() );
@@ -426,8 +404,8 @@ bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
void cServer::ServerCommand( const char* a_Cmd )
{
- std::string Command( a_Cmd );
- std::vector< std::string > split = StringSplit( Command, " " );
+ AString Command( a_Cmd );
+ AStringVector split = StringSplit( Command, " " );
if( split.size() > 0 )
{
if( split[0].compare( "help" ) == 0 )
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp
index 901e24cd7..ff4ef8a96 100644
--- a/source/cWebAdmin.cpp
+++ b/source/cWebAdmin.cpp
@@ -21,16 +21,17 @@
#include <psapi.h>
#else
#include <sys/resource.h>
- #include <memory> // auto_ptr
#endif
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+cWebAdmin * WebAdmin = 0;
+
+
+
-cWebAdmin* WebAdmin = 0;
cWebAdmin::cWebAdmin( int a_Port /* = 8080 */ )
: m_Port( a_Port )
@@ -75,12 +76,16 @@ void cWebAdmin::RemovePlugin( cWebPlugin* a_Plugin )
m_Plugins.remove( a_Plugin );
}
+
+
+
+
void cWebAdmin::Request_Handler(webserver::http_request* r)
{
if( WebAdmin == 0 ) return;
LOG("Path: %s", r->path_.c_str() );
- std::vector< std::string > Split = StringSplit( r->path_, "/" );
+ AStringVector Split = StringSplit( r->path_, "/" );
if(r->path_ == "/")
{
diff --git a/source/cWebPlugin_Lua.cpp b/source/cWebPlugin_Lua.cpp
index bb3f79226..ab397173e 100644
--- a/source/cWebPlugin_Lua.cpp
+++ b/source/cWebPlugin_Lua.cpp
@@ -8,6 +8,15 @@
#include "cWebAdmin.h"
+
+
+
+extern bool report_errors(lua_State* lua, int status);
+
+
+
+
+
static std::string SafeString( const std::string& a_String )
{
std::string RetVal;
@@ -24,8 +33,8 @@ static std::string SafeString( const std::string& a_String )
}
-extern bool report_errors(lua_State* lua, int status);
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
+
struct cWebPlugin_Lua::sWebPluginTab
{
@@ -130,7 +139,7 @@ void cWebPlugin_Lua::Initialize()
std::pair< std::string, std::string > cWebPlugin_Lua::GetTabNameForRequest( HTTPRequest* a_Request )
{
std::pair< std::string, std::string > Names;
- std::vector<std::string> Split = StringSplit( a_Request->Path, "/" );
+ AStringVector Split = StringSplit(a_Request->Path, "/");
if( Split.size() > 1 )
{