diff --git a/src/Makefile b/src/Makefile index 9c6095c..da1f4ec 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ USEDBIXX=1 BASE_LIBS=-lgcrypt -BASE_CFLAGS=-c -g -O0 +BASE_CFLAGS=-c -g -O2 -Wall O_FILES=build/oastat.o build/oastatstruct.o build/kill2db.o build/init2db.o build/shutdown2db.o build/userinfo2db.o build/disconnect2db.o build/award2db.o build/ctf2db.o build/point2db.o build/ctf1f2db.o build/elimination2db.o build/ctfelim2db.o build/harvester2db.o build/challenge2db.o build/warmup2db.o build/accuracy2db.o @@ -30,11 +30,19 @@ clean: build/oastat: $(O_FILES) g++ -O -o build/oastat $(O_FILES) $(BASE_LIBS) -build/oastat.o: oastat.cpp +build/oastat.o: oastat.cpp pstream.h db/database.hpp db/../oastatstruct.h \ + db/Db2Xml.hpp db/database.hpp oastatstruct.h oss2db/struct2db.h \ + oss2db/../oastatstruct.h oss2db/../db/database.hpp local.h \ + oss2db/kill2db.h oss2db/struct2db.h oss2db/../local.h oss2db/init2db.h \ + oss2db/shutdown2db.h oss2db/userinfo2db.h oss2db/Disconnect2Db.h \ + oss2db/Accuracy2Db.hpp oss2db/Award2Db.h oss2db/Ctf2Db.hpp \ + oss2db/Ctf1f2Db.hpp oss2db/Point2Db.hpp oss2db/Elimination2Db.hpp \ + oss2db/CtfElimination2Db.hpp oss2db/Harvester2Db.hpp \ + oss2db/Challenge2Db.hpp oss2db/Warmup2Db.hpp g++ $(BASE_CFLAGS) oastat.cpp -o build/oastat.o ifeq ($(USEDBIXX),1) -build/db2dbixx.o: db/Db2DbiXX.cpp db/Db2DbiXX.hpp db/database.hpp +build/db2dbixx.o: db/Db2DbiXX.cpp db/Db2DbiXX.hpp db/database.hpp db/../oastatstruct.h g++ $(BASE_CFLAGS) db/Db2DbiXX.cpp -o build/db2dbixx.o endif diff --git a/src/db/Db2DbiXX.cpp b/src/db/Db2DbiXX.cpp index 4222e40..99b4ef6 100644 --- a/src/db/Db2DbiXX.cpp +++ b/src/db/Db2DbiXX.cpp @@ -171,7 +171,7 @@ void Db2DbiXX::createTables() } -void Db2DbiXX::startGame(int gametype, string mapname, string basegame, string servername, OaStatStruct *oss) +void Db2DbiXX::startGame(int gametype, string mapname, string basegame, string servername, const OaStatStruct *oss) { sql->reconnect(); Rollback(); //in case there was some garbage that could be comitted (like warmup or an unfinished game) @@ -233,7 +233,7 @@ int Db2DbiXX::getGameNumber() return gamenumber; } -void Db2DbiXX::setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, OaStatStruct *oss) +void Db2DbiXX::setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, const OaStatStruct *oss) { if(!isok) return; diff --git a/src/db/Db2DbiXX.hpp b/src/db/Db2DbiXX.hpp index 8bb282d..8b3f04f 100644 --- a/src/db/Db2DbiXX.hpp +++ b/src/db/Db2DbiXX.hpp @@ -42,11 +42,11 @@ public: Db2DbiXX(const Db2DbiXX& orig); virtual ~Db2DbiXX(); void createTables(); - void startGame(int gametype, string mapname, string basegame, string servername, OaStatStruct *oss); + void startGame(int gametype, string mapname, string basegame, string servername, const OaStatStruct *oss); void addGameCvar(string cvar, string value); void endGame(int second); int getGameNumber(); - void setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, OaStatStruct *oss); + void setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, const OaStatStruct *oss); void addKill(int second, string attackerID, string targetID, int type); //void addCapture(int second, string player, int team); void addAward(int second, string player, int award); diff --git a/src/db/Db2Xml.cpp b/src/db/Db2Xml.cpp index e454402..98874d8 100644 --- a/src/db/Db2Xml.cpp +++ b/src/db/Db2Xml.cpp @@ -33,7 +33,9 @@ Db2Xml::Db2Xml() p_output_dir = path.str(); boost::format fmkdir("mkdir -p %1%"); fmkdir % p_output_dir; - system(fmkdir.str().c_str()); + int fmkdir_ret = system(fmkdir.str().c_str()); + if(fmkdir_ret) + cout << "Attemting to create \"" << path << "\" with \"" << fmkdir.str() << "\", but return code was: " << fmkdir_ret << endl; } Db2Xml::Db2Xml(string dbargs) { @@ -64,7 +66,9 @@ Db2Xml::Db2Xml(string dbargs) } boost::format fmkdir("mkdir -p %1%"); fmkdir % p_output_dir; - system(fmkdir.str().c_str()); + int fmkdir_ret = system(fmkdir.str().c_str()); + if(fmkdir_ret) + cout << "Attemting to create \"" << path << "\" with \"" << fmkdir.str() << "\", but return code was: " << fmkdir_ret << endl; } Db2Xml::Db2Xml(const Db2Xml& orig) { @@ -74,7 +78,7 @@ Db2Xml::~Db2Xml() { } -void Db2Xml::startGame(int gametype, string mapname, string basegame, string servername, OaStatStruct *oss) +void Db2Xml::startGame(int gametype, string mapname, string basegame, string servername, const OaStatStruct *oss) { isOk = true; p_xmlcontent = ""; @@ -120,7 +124,7 @@ int Db2Xml::getGameNumber() { return 1; } -void Db2Xml::setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, OaStatStruct *oss) +void Db2Xml::setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, const OaStatStruct *oss) { if(!isOk) return; diff --git a/src/db/Db2Xml.hpp b/src/db/Db2Xml.hpp index 54eb8c3..f88ba26 100644 --- a/src/db/Db2Xml.hpp +++ b/src/db/Db2Xml.hpp @@ -44,11 +44,11 @@ public: Db2Xml(const Db2Xml& orig); virtual ~Db2Xml(); void createTables(); - void startGame(int gametype, string mapname, string basegame, string servername, OaStatStruct *oss); + void startGame(int gametype, string mapname, string basegame, string servername, const OaStatStruct *oss); void addGameCvar(string cvar, string value); void endGame(int second); int getGameNumber(); - void setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, OaStatStruct *oss); + void setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, const OaStatStruct *oss); void addKill(int second, string attackerID, string targetID, int type); //void addCapture(int second, string player, int team); void addAward(int second, string player, int award); diff --git a/src/db/database.hpp b/src/db/database.hpp index 72fd4f2..9713006 100644 --- a/src/db/database.hpp +++ b/src/db/database.hpp @@ -45,7 +45,7 @@ public: * @param mapname - the mapname used for this game * @param basegame - the mod... normally baseoa */ - virtual void startGame(int gametype, string mapname, string basegame, string servername, OaStatStruct *oss) = 0; + virtual void startGame(int gametype, std::string mapname, std::string basegame, std::string servername, const OaStatStruct *oss) = 0; /** * Adds information about a cvar to the last started game @@ -53,7 +53,7 @@ public: * @param cvar - The name of the cvar (limited to 100 chars) * @param value - The value of the cvar as a string */ - virtual void addGameCvar(string cvar, string value) = 0; + virtual void addGameCvar(std::string cvar, std::string value) = 0; /** * Called then a game ends. @@ -86,7 +86,7 @@ public: * @param headmodel - headmodel used * @param skill - bot skill, bots only */ - virtual void setPlayerInfo(string guid, string nickname, bool isBot, int second, int team, string model, string headmodel, int skill, OaStatStruct *oss) = 0; + virtual void setPlayerInfo(std::string guid, std::string nickname, bool isBot, int second, int team, std::string model, std::string headmodel, int skill, const OaStatStruct *oss) = 0; /** * Represents a kill @@ -96,7 +96,7 @@ public: * @param targetID hashed guid of the victim * @param type weapon number */ - virtual void addKill(int second, string attackerID, string targetID, int type) = 0; + virtual void addKill(int second, std::string attackerID, std::string targetID, int type) = 0; /** * A flag/skull capture or obelisk destruction @@ -114,7 +114,7 @@ public: * @param player hashed guid of the player * @param award the award, numbers must be found in code */ - virtual void addAward(int second, string player, int award) = 0; + virtual void addAward(int second, std::string player, int award) = 0; /** * Adds information about a players score that is changing. @@ -125,7 +125,7 @@ public: * @param player hashed guid of the player * @param score the Total */ - virtual void addScoreInfo(int second, string player, int score) = 0; + virtual void addScoreInfo(int second, std::string player, int score) = 0; /** * Adds an event from a CTF-game. @@ -141,7 +141,7 @@ public: * @param team * @param event */ - virtual void addCtf(int second, string player, int team, int event) = 0; + virtual void addCtf(int second, std::string player, int team, int event) = 0; /** * Adds an event from a 1FCTF-game. @@ -157,7 +157,7 @@ public: * @param team * @param event */ - virtual void addCtf1f(int second, string player, int team, int event) = 0; + virtual void addCtf1f(int second, std::string player, int team, int event) = 0; virtual void addElimination(int second, int roundnumber, int team, int event) = 0; @@ -170,7 +170,7 @@ public: * @param team the team the event is about * @param event the event type */ - virtual void addCtfElimination(int second, int roundnumber, string player, int team, int event) = 0; + virtual void addCtfElimination(int second, int roundnumber, std::string player, int team, int event) = 0; /** * Document addHarvester(int,string,string,int,int,int) here... @@ -182,7 +182,7 @@ public: * @param event the event number * @param score number of skulls brought in in one capture */ - virtual void addHarvester(int second, string player1, string player2, int team, int event, int score) = 0; + virtual void addHarvester(int second, std::string player1, std::string player2, int team, int event, int score) = 0; /** * Add information about a scored challenge @@ -192,7 +192,7 @@ public: * @param challenge the challenge gotten (see challenges.h) * @param amount normally 1 */ - virtual void addChallenge(int second, string player, int challenge, int amount) = 0; + virtual void addChallenge(int second, std::string player, int challenge, int amount) = 0; /** * adds accuracy information. @@ -202,7 +202,7 @@ public: * @param shotsFired Number of shots fired in the match * @param shotsHit Number of hits */ - virtual void addAccuracy(int secind, string player, int type, int shotsFired, int shotsHit) = 0; + virtual void addAccuracy(int secind, std::string player, int type, int shotsFired, int shotsHit) = 0; }; #endif //_DATABASE_H diff --git a/src/local.h b/src/local.h index 66d8e41..ee83574 100644 --- a/src/local.h +++ b/src/local.h @@ -29,10 +29,10 @@ http://code.google.com/p/oastat/ #include "oastatstruct.h" /* This array contains all the guid hashes of the players in a game */ -extern vector clientIdMap; +extern std::vector clientIdMap; /* returns the SHA-1 code of the parameter */ -extern string getHashedId(string unhashedID); +extern std::string getHashedId(std::string unhashedID); #endif /* _LOCAL_H */ diff --git a/src/oastat.cpp b/src/oastat.cpp index 493a067..07443cb 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp @@ -99,100 +99,8 @@ void addCommands() } } -int main (int argc, const char* argv[]) -{ - string dbargs = ""; - string filename = ""; - string backend = "Xml"; - bool useTail = false; - ///////////// - //dbargs = "mysql dbname oastat"; - boost::format f("%1%/.openarena/baseoa/games.log"); - f % getenv("HOME"); - filename = f.str(); - //////////// - for(int i=1; i0) - { - if(useTail) - { - redi::ipstream in("tail -s 1 -f "+filename); - processStdIn(&in); - } - else - { - ifstream in(filename.c_str(),ifstream::in); - processStdIn(&in); - } - } - else - processStdIn(&cin); - - } - catch (const char *s) - { - cout << "Crashed: " << s << endl; - return -1; - } - - return 0; -} - static int processStdIn(istream* in_p) { bool done = true; @@ -286,3 +194,97 @@ string getHashedId(string unhashedID) //free(out); return unhashedID; //Replace with md5 at some point } + +int main (int argc, const char* argv[]) +{ + string dbargs = ""; + string filename = ""; + string backend = "Xml"; + bool useTail = false; + ///////////// + //dbargs = "mysql dbname oastat"; + boost::format f("%1%/.openarena/baseoa/games.log"); + f % getenv("HOME"); + filename = f.str(); + //////////// + for(int i=1; i0) + { + if(useTail) + { + redi::ipstream in("tail -s 1 -f "+filename); + processStdIn(&in); + } + else + { + ifstream in(filename.c_str(),ifstream::in); + processStdIn(&in); + } + } + else + processStdIn(&cin); + + } + catch (const char *s) + { + cout << "Crashed: " << s << endl; + return -1; + } + + return 0; +} diff --git a/src/oastatstruct.cpp b/src/oastatstruct.cpp index 1c0fc8e..42be033 100644 --- a/src/oastatstruct.cpp +++ b/src/oastatstruct.cpp @@ -29,7 +29,22 @@ using namespace std; #include #include -tm OaStatStruct::_datetime; +using namespace std; + +namespace { + +void makeLower(string &x) +{ + for(int i=0; i= 'A' && x[i] <= 'X') + x[i] = x[i]-'A'+'a'; + } +} + +} + +//tm OaStatStruct::_datetime; OaStatStruct::OaStatStruct() { @@ -112,16 +127,8 @@ void OaStatStruct::parseLine(string line) restOfLine = line; } -void makeLower(string &x) -{ - for(int i=0; i= 'A' && x[i] <= 'X') - x[i] = x[i]-'A'+'a'; - } -} -map OaStatStruct::GetInfostring(string restOfLine) +map OaStatStruct::GetInfostring(string restOfLine) const { map list; int curPos = 0, lastPos = 0; @@ -153,12 +160,12 @@ map OaStatStruct::GetInfostring(string restOfLine) return list; } -map OaStatStruct::GetInfostring() +map OaStatStruct::GetInfostring() const { return GetInfostring(restOfLine); } -tm OaStatStruct::getDateTime() +const tm OaStatStruct::getDateTime() const { return _datetime; } @@ -171,7 +178,7 @@ string ZeroPadNumber(int num, int size = 2) return ss.str(); } -string OaStatStruct::getTimeStamp() +string OaStatStruct::getTimeStamp() const { string s; s = "TIMESTAMP \'" + ZeroPadNumber(_datetime.tm_year+1900,4) + "-" + ZeroPadNumber(_datetime.tm_mon+1) + "-" @@ -180,7 +187,7 @@ string OaStatStruct::getTimeStamp() return s; } -void OaStatStruct::setTimeStamp(string timestring) +void OaStatStruct::setTimeStamp(const string ×tring) { std::stringstream ss(timestring); string tmp; diff --git a/src/oastatstruct.h b/src/oastatstruct.h index f2fbe71..59c81ca 100644 --- a/src/oastatstruct.h +++ b/src/oastatstruct.h @@ -29,7 +29,6 @@ http://code.google.com/p/oastat/ #include #include -using namespace std; /* * This is the most important class in oastat. This takes a line and stores all @@ -44,36 +43,36 @@ public: //There are no reason to make any variables private. int second; //number of seconds - string command; //Like 'ClientConnect', 'Award' and 'Kill' - vector parameters; //The parameters for the command. - string restOfLine; - tm getDateTime(); + std::string command; //Like 'ClientConnect', 'Award' and 'Kill' + std::vector parameters; //The parameters for the command. + std::string restOfLine; + const tm getDateTime() const; - void parseLine(string line); + void parseLine(std::string line); void clear(); /* *Parses the rest of the line to an info string */ - map GetInfostring(string restOfLine); + std::map GetInfostring(std::string restOfLine) const; /* *Same but uses this.restOfLine */ - map GetInfostring(); + std::map GetInfostring() const; /* Returns a string with the time in the format: * TIMESTAMP 'YYYY-MM- */ - string getTimeStamp(); + std::string getTimeStamp() const; /* Sets _datetime. Requires input in the format: "YYYY-MM-DD HH:MM:SS" */ - void setTimeStamp(string timestring); + void setTimeStamp(const std::string ×tring); private: - static tm _datetime; + tm _datetime; }; #endif /* _OASTATSTRUCT_H */ diff --git a/src/oss2db/Accuracy2Db.cpp b/src/oss2db/Accuracy2Db.cpp index ad17958..a7c9003 100644 --- a/src/oss2db/Accuracy2Db.cpp +++ b/src/oss2db/Accuracy2Db.cpp @@ -30,14 +30,14 @@ string Accuracy2Db::getCommand() return "Accuracy"; } -bool Accuracy2Db::canProcess(OaStatStruct oss) +bool Accuracy2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand()) return false; return true; } -void Accuracy2Db::process(OaStatStruct oss) +void Accuracy2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Accuracy2Db.hpp b/src/oss2db/Accuracy2Db.hpp index af77c7b..409bf0c 100644 --- a/src/oss2db/Accuracy2Db.hpp +++ b/src/oss2db/Accuracy2Db.hpp @@ -30,9 +30,9 @@ http://code.google.com/p/oastat/ class Accuracy2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Award2Db.cpp b/src/oss2db/Award2Db.cpp index fba3643..7deab6c 100644 --- a/src/oss2db/Award2Db.cpp +++ b/src/oss2db/Award2Db.cpp @@ -30,14 +30,14 @@ string Award2Db::getCommand() return "Award"; } -bool Award2Db::canProcess(OaStatStruct oss) +bool Award2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<2 || oss.parameters.at(0)<0) return false; return true; } -void Award2Db::process(OaStatStruct oss) +void Award2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Award2Db.h b/src/oss2db/Award2Db.h index 407a38c..1b3a470 100644 --- a/src/oss2db/Award2Db.h +++ b/src/oss2db/Award2Db.h @@ -32,9 +32,9 @@ class Award2Db : public Struct2Db public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Challenge2Db.cpp b/src/oss2db/Challenge2Db.cpp index 7eb1025..a84b987 100644 --- a/src/oss2db/Challenge2Db.cpp +++ b/src/oss2db/Challenge2Db.cpp @@ -29,14 +29,14 @@ string Challenge2Db::getCommand() } -bool Challenge2Db::canProcess(OaStatStruct oss) +bool Challenge2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<3) return false; return true; } -void Challenge2Db::process(OaStatStruct oss) +void Challenge2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Challenge2Db.hpp b/src/oss2db/Challenge2Db.hpp index 6f49b13..78eee34 100644 --- a/src/oss2db/Challenge2Db.hpp +++ b/src/oss2db/Challenge2Db.hpp @@ -31,9 +31,9 @@ class Challenge2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Ctf1f2Db.cpp b/src/oss2db/Ctf1f2Db.cpp index b1180be..e1c5b81 100644 --- a/src/oss2db/Ctf1f2Db.cpp +++ b/src/oss2db/Ctf1f2Db.cpp @@ -29,14 +29,14 @@ string Ctf1f2Db::getCommand() return "1FCTF"; } -bool Ctf1f2Db::canProcess(OaStatStruct oss) +bool Ctf1f2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<3) return false; return true; } -void Ctf1f2Db::process(OaStatStruct oss) +void Ctf1f2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Ctf1f2Db.hpp b/src/oss2db/Ctf1f2Db.hpp index 2de61f4..bf6bdc0 100644 --- a/src/oss2db/Ctf1f2Db.hpp +++ b/src/oss2db/Ctf1f2Db.hpp @@ -32,9 +32,9 @@ class Ctf1f2Db : public Struct2Db public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Ctf2Db.cpp b/src/oss2db/Ctf2Db.cpp index 54200e8..39c2c48 100644 --- a/src/oss2db/Ctf2Db.cpp +++ b/src/oss2db/Ctf2Db.cpp @@ -29,14 +29,14 @@ string Ctf2Db::getCommand() return "CTF"; } -bool Ctf2Db::canProcess(OaStatStruct oss) +bool Ctf2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<3) return false; return true; } -void Ctf2Db::process(OaStatStruct oss) +void Ctf2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Ctf2Db.hpp b/src/oss2db/Ctf2Db.hpp index 6ef1a99..fd1bc66 100644 --- a/src/oss2db/Ctf2Db.hpp +++ b/src/oss2db/Ctf2Db.hpp @@ -32,9 +32,9 @@ class Ctf2Db : public Struct2Db public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/CtfElimination2Db.cpp b/src/oss2db/CtfElimination2Db.cpp index 218b684..b732f1c 100644 --- a/src/oss2db/CtfElimination2Db.cpp +++ b/src/oss2db/CtfElimination2Db.cpp @@ -28,14 +28,14 @@ string CtfElimination2Db::getCommand() return "ELIMINATION"; } -bool CtfElimination2Db::canProcess(OaStatStruct oss) +bool CtfElimination2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<3 ) return false; return true; } -void CtfElimination2Db::process(OaStatStruct oss) +void CtfElimination2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/CtfElimination2Db.hpp b/src/oss2db/CtfElimination2Db.hpp index ef86787..539f005 100644 --- a/src/oss2db/CtfElimination2Db.hpp +++ b/src/oss2db/CtfElimination2Db.hpp @@ -32,9 +32,9 @@ class CtfElimination2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: diff --git a/src/oss2db/Disconnect2Db.cpp b/src/oss2db/Disconnect2Db.cpp index cde26f3..3985392 100644 --- a/src/oss2db/Disconnect2Db.cpp +++ b/src/oss2db/Disconnect2Db.cpp @@ -29,14 +29,14 @@ string Disconnect2Db::getCommand() return "ClientDisconnect"; } -bool Disconnect2Db::canProcess(OaStatStruct oss) +bool Disconnect2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<1) return false; return true; } -void Disconnect2Db::process(OaStatStruct oss) +void Disconnect2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Disconnect2Db.h b/src/oss2db/Disconnect2Db.h index 34089c3..2f9649a 100644 --- a/src/oss2db/Disconnect2Db.h +++ b/src/oss2db/Disconnect2Db.h @@ -32,9 +32,9 @@ class Disconnect2Db : public Struct2Db public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Elimination2Db.cpp b/src/oss2db/Elimination2Db.cpp index 0d20cba..190918b 100644 --- a/src/oss2db/Elimination2Db.cpp +++ b/src/oss2db/Elimination2Db.cpp @@ -29,14 +29,14 @@ string Elimination2Db::getCommand() return "ELIMINATION"; } -bool Elimination2Db::canProcess(OaStatStruct oss) +bool Elimination2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<3 ) return false; return true; } -void Elimination2Db::process(OaStatStruct oss) +void Elimination2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Elimination2Db.hpp b/src/oss2db/Elimination2Db.hpp index a32a390..d6af478 100644 --- a/src/oss2db/Elimination2Db.hpp +++ b/src/oss2db/Elimination2Db.hpp @@ -31,9 +31,9 @@ class Elimination2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Harvester2Db.cpp b/src/oss2db/Harvester2Db.cpp index e4c9d52..486a388 100644 --- a/src/oss2db/Harvester2Db.cpp +++ b/src/oss2db/Harvester2Db.cpp @@ -28,14 +28,14 @@ string Harvester2Db::getCommand() return "HARVESTER"; } -bool Harvester2Db::canProcess(OaStatStruct oss) +bool Harvester2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<5 ) return false; return true; } -void Harvester2Db::process(OaStatStruct oss) +void Harvester2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Harvester2Db.hpp b/src/oss2db/Harvester2Db.hpp index 8bfd0f6..38858e1 100644 --- a/src/oss2db/Harvester2Db.hpp +++ b/src/oss2db/Harvester2Db.hpp @@ -31,9 +31,9 @@ class Harvester2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Point2Db.cpp b/src/oss2db/Point2Db.cpp index a0e424c..bc70174 100644 --- a/src/oss2db/Point2Db.cpp +++ b/src/oss2db/Point2Db.cpp @@ -29,14 +29,14 @@ string Point2Db::getCommand() return "PlayerScore"; } -bool Point2Db::canProcess(OaStatStruct oss) +bool Point2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<2 || oss.parameters.at(0)<0) return false; return true; } -void Point2Db::process(OaStatStruct oss) +void Point2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Point2Db.hpp b/src/oss2db/Point2Db.hpp index 722f9b3..20ac659 100644 --- a/src/oss2db/Point2Db.hpp +++ b/src/oss2db/Point2Db.hpp @@ -31,9 +31,9 @@ class Point2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/Warmup2Db.cpp b/src/oss2db/Warmup2Db.cpp index 2ba3e3d..b81a71e 100644 --- a/src/oss2db/Warmup2Db.cpp +++ b/src/oss2db/Warmup2Db.cpp @@ -28,14 +28,14 @@ string Warmup2Db::getCommand() return "Warmup"; } -bool Warmup2Db::canProcess(OaStatStruct oss) +bool Warmup2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand()) return false; return true; } -void Warmup2Db::process(OaStatStruct oss) +void Warmup2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/Warmup2Db.hpp b/src/oss2db/Warmup2Db.hpp index cfc31e3..29e8911 100644 --- a/src/oss2db/Warmup2Db.hpp +++ b/src/oss2db/Warmup2Db.hpp @@ -31,9 +31,9 @@ class Warmup2Db : public Struct2Db { public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/init2db.cpp b/src/oss2db/init2db.cpp index 6e33e80..0153027 100644 --- a/src/oss2db/init2db.cpp +++ b/src/oss2db/init2db.cpp @@ -30,25 +30,26 @@ string Init2Db::getCommand() return "InitGame"; } -bool Init2Db::canProcess(OaStatStruct oss) +bool Init2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand()) return false; return true; } -void Init2Db::process(OaStatStruct oss) +void Init2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss - map arguments = oss.GetInfostring(); + OaStatStruct oss_copy(oss); + map arguments = oss_copy.GetInfostring(); int gametype = atoi(arguments["g_gametype"].c_str()); string basegame = arguments["gamename"]; string mapname = arguments["mapname"]; string servername = arguments["sv_hostname"]; - oss.setTimeStamp(arguments["g_timestamp"]); + oss_copy.setTimeStamp(arguments["g_timestamp"]); - dp->startGame(gametype,mapname,basegame,servername,&oss); + dp->startGame(gametype,mapname,basegame,servername,&oss_copy); map::iterator it; for(it = arguments.begin(); it != arguments.end(); it++) { diff --git a/src/oss2db/init2db.h b/src/oss2db/init2db.h index c7404a7..0b078d6 100644 --- a/src/oss2db/init2db.h +++ b/src/oss2db/init2db.h @@ -32,9 +32,9 @@ class Init2Db : public Struct2Db public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: }; diff --git a/src/oss2db/kill2db.cpp b/src/oss2db/kill2db.cpp index 90360cf..6177f27 100644 --- a/src/oss2db/kill2db.cpp +++ b/src/oss2db/kill2db.cpp @@ -29,14 +29,14 @@ string Kill2Db::getCommand() return "Kill"; } -bool Kill2Db::canProcess(OaStatStruct oss) +bool Kill2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<=3) return false; return true; } -void Kill2Db::process(OaStatStruct oss) +void Kill2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/kill2db.h b/src/oss2db/kill2db.h index df0c0cc..08cd0d2 100644 --- a/src/oss2db/kill2db.h +++ b/src/oss2db/kill2db.h @@ -31,9 +31,9 @@ class Kill2Db : public Struct2Db { string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); }; diff --git a/src/oss2db/shutdown2db.cpp b/src/oss2db/shutdown2db.cpp index d13f67b..37598d6 100644 --- a/src/oss2db/shutdown2db.cpp +++ b/src/oss2db/shutdown2db.cpp @@ -30,14 +30,14 @@ string Shutdown2Db::getCommand() return "ShutdownGame"; } -bool Shutdown2Db::canProcess(OaStatStruct oss) +bool Shutdown2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand()) return false; return true; } -void Shutdown2Db::process(OaStatStruct oss) +void Shutdown2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; diff --git a/src/oss2db/shutdown2db.h b/src/oss2db/shutdown2db.h index 23d16ee..5ca5fc5 100644 --- a/src/oss2db/shutdown2db.h +++ b/src/oss2db/shutdown2db.h @@ -32,9 +32,9 @@ class Shutdown2Db : public Struct2Db public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); bool shouldCommit(); private: diff --git a/src/oss2db/struct2db.h b/src/oss2db/struct2db.h index fbee2e1..9fb16d9 100644 --- a/src/oss2db/struct2db.h +++ b/src/oss2db/struct2db.h @@ -57,12 +57,12 @@ public: * This is better than the last getCommand, because it can check for multiple commands at once, and can * discard subevents for supported commands. */ - virtual bool canProcess(OaStatStruct oss) = 0; + virtual bool canProcess(const OaStatStruct &oss) = 0; /* * Parses s OaStatStruct to the object to process */ - virtual void process(OaStatStruct oss) = 0; + virtual void process(const OaStatStruct &oss) = 0; virtual bool shouldCommit() { diff --git a/src/oss2db/userinfo2db.cpp b/src/oss2db/userinfo2db.cpp index 7562abb..0290701 100644 --- a/src/oss2db/userinfo2db.cpp +++ b/src/oss2db/userinfo2db.cpp @@ -32,14 +32,14 @@ string Userinfo2Db::getCommand() return "ClientUserinfoChanged"; } -bool Userinfo2Db::canProcess(OaStatStruct oss) +bool Userinfo2Db::canProcess(const OaStatStruct &oss) { if(oss.command != getCommand() || oss.parameters.size()<1) return false; return true; } -void Userinfo2Db::process(OaStatStruct oss) +void Userinfo2Db::process(const OaStatStruct &oss) { if(!canProcess(oss)) return; //Invalid oss diff --git a/src/oss2db/userinfo2db.h b/src/oss2db/userinfo2db.h index 3b2ed22..b8baec7 100644 --- a/src/oss2db/userinfo2db.h +++ b/src/oss2db/userinfo2db.h @@ -33,9 +33,9 @@ public: string getCommand(); - bool canProcess(OaStatStruct oss); + bool canProcess(const OaStatStruct &oss); - void process(OaStatStruct oss); + void process(const OaStatStruct &oss); private: };