git repos / oastat

commit b6d80a63

sago007 · 2013-12-08 23:02
b6d80a6319287ece8dc04cdb5ae83760c0bf3730 patch · browse files
parent 9399fb8790009d90bdc1a1ba02049c89890b0766

I forgot to save before the last changes

Changed files

M src/oastat.cpp before
M src/oastatstruct.cpp before
M src/oss2db/Accuracy2Db.cpp before
M src/oss2db/Award2Db.cpp before
M src/oss2db/Challenge2Db.cpp before
M src/oss2db/Ctf1f2Db.cpp before
M src/oss2db/Ctf2Db.cpp before
M src/oss2db/CtfElimination2Db.cpp before
M src/oss2db/Disconnect2Db.cpp before
M src/oss2db/Elimination2Db.cpp before
M src/oss2db/Harvester2Db.cpp before
M src/oss2db/Point2Db.cpp before
M src/oss2db/Warmup2Db.cpp before
M src/oss2db/init2db.cpp before
M src/oss2db/kill2db.cpp before
M src/oss2db/shutdown2db.cpp before
diff --git a/src/oastat.cpp b/src/oastat.cpp index 0130f50..ceb42ee 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp
@@ -76,7 +76,7 @@ static int processStdIn(istream &in_p,vector<shared_ptr<Struct2Db> > &commands);
*/
static void addCommands(shared_ptr<Database> &db,vector<shared_ptr<Struct2Db> > &commands)
{
- if(!db) {
+ if (!db) {
throw runtime_error("db was uninizialized in addCommands");
}
@@ -98,7 +98,7 @@ static void addCommands(shared_ptr<Database> &db,vector<shared_ptr<Struct2Db> >
commands.push_back(shared_ptr<Struct2Db>(new Accuracy2Db()) );
//Add more commands just above here
- for(unsigned int i=0; i<commands.size(); i++) {
+ for (unsigned int i=0; i<commands.size(); i++) {
commands.at(i)->setDb(db);
}
}
@@ -115,20 +115,20 @@ static int processStdIn(istream &in_p,vector<shared_ptr<Struct2Db> > &commands)
OaStatStruct oss;
list<OaStatStruct> osslist;
try {
- while( getline(in_p,line) ) {
+ while ( getline(in_p,line) ) {
oss.clear();
oss.parseLine(line);
osslist.push_back(oss);
- if(oss.command=="InitGame") {
+ if (oss.command=="InitGame") {
startstruct = &osslist.back();
}
- if(oss.command=="Warmup" && startstruct) {
+ if (oss.command=="Warmup" && startstruct) {
//Workaround to stop warmup
//If we spot a warmup command we add a cvar to the start struct
//Warmup is a attribute that affect he whole game
startstruct->restOfLine += "\\isWarmup\\1";
}
- if(oss.command=="ShutdownGame") {
+ if (oss.command=="ShutdownGame") {
while(!osslist.empty()) {
oss = osslist.front();
osslist.pop_front();
@@ -204,7 +204,7 @@ int main (int argc, const char* argv[])
f % getenv("HOME");
filename = f.str();
////////////
- for(int i=1; i<argc; i++) {
+ for (int i=1; i<argc; i++) {
bool onemore = i+1<argc;
if (string(argv[i]) == "-dbarg" && onemore ) {
i++;
@@ -229,25 +229,25 @@ int main (int argc, const char* argv[])
shared_ptr<Database> db;
#if USEDBIXX
- if(backend == "DbiXX") {
+ if (backend == "DbiXX") {
cout << "Using DBI" << endl;
- if(dbargs.length()<1) {
+ if (dbargs.length()<1) {
db = shared_ptr<Database>(new Db2DbiXX() );
} else {
db = shared_ptr<Database>(new Db2DbiXX(dbargs) );
}
}
#endif
- if(backend == "Xml") {
+ if (backend == "Xml") {
cout << "Using XML" << endl;
- if(dbargs.length()<1) {
+ if (dbargs.length()<1) {
db = shared_ptr<Database>(new Db2Xml() );
} else {
db = shared_ptr<Database>(new Db2Xml(dbargs) );
}
}
- if(!db) {
+ if (!db) {
string error("Failed to find backend: ");
error += backend;
throw runtime_error(error);
@@ -264,8 +264,8 @@ int main (int argc, const char* argv[])
return 1;
}
- if(filename.length()>0) {
- if(useTail) {
+ if (filename.length()>0) {
+ if (useTail) {
redi::ipstream in("tail -s 1 -f "+filename);
processStdIn(in,commands);
} else {
diff --git a/src/oastatstruct.cpp b/src/oastatstruct.cpp index eabdd3b..5df6f7c 100644 --- a/src/oastatstruct.cpp +++ b/src/oastatstruct.cpp
@@ -36,8 +36,8 @@ namespace
void makeLower(string &x)
{
- for(unsigned int i=0; i<x.length(); i++) {
- if(x[i] >= 'A' && x[i] <= 'X') {
+ for (unsigned int i=0; i<x.length(); i++) {
+ if (x[i] >= 'A' && x[i] <= 'X') {
x[i] = x[i]-'A'+'a';
}
}
@@ -100,21 +100,21 @@ void OaStatStruct::parseLine(string line)
stringstream ss;
ss << line.substr(0,posColon);
int counter = 0; //to ensure that we don't go on forever
- while(ss && counter++<10) {
+ while (ss && counter++<10) {
int value;
ss >> value;
parameters.push_back(value);
}
- if(line.at(posColon) == ':') {
+ if (line.at(posColon) == ':') {
posColon++; //There is some inconsistensy about then there is a colon here
if(line.at(posColon) == ' ') {
posColon++; //If there is a colon there is likely a space
}
}
line = line.substr(posColon,line.length());
- } catch(exception &e) {
+ } catch (exception &e) {
//The last part does not always exist... ignore it
restOfLine = "";
return;
@@ -132,21 +132,21 @@ map<string,string> OaStatStruct::GetInfostring(string restOfLine) const
unsigned int lastPos = 0;
bool iskey = true;
string key, value;
- if(restOfLine[0] == '\\') {
+ if (restOfLine[0] == '\\') {
lastPos++;
}
- while(lastPos<restOfLine.length()) {
+ while (lastPos<restOfLine.length()) {
curPos = restOfLine.find_first_of("\\", lastPos);
- if(curPos<0) {
+ if (curPos<0) {
curPos = restOfLine.length();
}
- if(iskey) {
+ if (iskey) {
key = restOfLine.substr(lastPos,curPos-lastPos);
} else {
value = restOfLine.substr(lastPos,curPos-lastPos);
//list.insert(pair<string,string>(key,value));
makeLower(key);
- if(key.length()>0) {
+ if (key.length()>0) {
list[key] = value;
}
//cout << key << ":" << value << endl;
diff --git a/src/oss2db/Accuracy2Db.cpp b/src/oss2db/Accuracy2Db.cpp index 78b4689..505ac02 100644 --- a/src/oss2db/Accuracy2Db.cpp +++ b/src/oss2db/Accuracy2Db.cpp
@@ -32,7 +32,7 @@ string Accuracy2Db::getCommand() const
bool Accuracy2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand()) {
+ if (oss.command != getCommand()) {
return false;
}
return true;
@@ -40,11 +40,11 @@ bool Accuracy2Db::canProcess(const OaStatStruct &oss) const
void Accuracy2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
- if(oss.parameters.at(0)==-1) {
+ if (oss.parameters.at(0)==-1) {
return; //Not valid player
}
@@ -55,10 +55,10 @@ void Accuracy2Db::process(const OaStatStruct &oss)
boost::format hformat("h%1%");
boost::format fformat("f%1%");
- for(int i=0; i<100; ++i) {
+ for (int i=0; i<100; ++i) {
unsigned int hits = atoi(arguments[boost::str(hformat % i)].c_str());
unsigned int fired = atoi(arguments[boost::str(fformat % i)].c_str());
- if(hits || fired) {
+ if (hits || fired) {
dp->addAccuracy(oss.second,player,i,fired,hits);
}
}
diff --git a/src/oss2db/Award2Db.cpp b/src/oss2db/Award2Db.cpp index 9821fee..3edb23b 100644 --- a/src/oss2db/Award2Db.cpp +++ b/src/oss2db/Award2Db.cpp
@@ -32,7 +32,7 @@ string Award2Db::getCommand() const
bool Award2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<2 || oss.parameters.at(0)<0) {
+ if (oss.command != getCommand() || oss.parameters.size()<2 || oss.parameters.at(0)<0) {
return false;
}
return true;
@@ -40,11 +40,11 @@ bool Award2Db::canProcess(const OaStatStruct &oss) const
void Award2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
- if(oss.parameters.at(0)==-1) {
+ if (oss.parameters.at(0)==-1) {
return; //Not valid player
}
diff --git a/src/oss2db/Challenge2Db.cpp b/src/oss2db/Challenge2Db.cpp index 55494b6..d6e0142 100644 --- a/src/oss2db/Challenge2Db.cpp +++ b/src/oss2db/Challenge2Db.cpp
@@ -31,7 +31,7 @@ string Challenge2Db::getCommand() const
bool Challenge2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<3) {
+ if (oss.command != getCommand() || oss.parameters.size()<3) {
return false;
}
return true;
@@ -39,11 +39,11 @@ bool Challenge2Db::canProcess(const OaStatStruct &oss) const
void Challenge2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
- if(oss.parameters.at(0)==-1) {
+ if (oss.parameters.at(0)==-1) {
return; //Not valid player
}
diff --git a/src/oss2db/Ctf1f2Db.cpp b/src/oss2db/Ctf1f2Db.cpp index 396b32a..c5460b2 100644 --- a/src/oss2db/Ctf1f2Db.cpp +++ b/src/oss2db/Ctf1f2Db.cpp
@@ -31,7 +31,7 @@ string Ctf1f2Db::getCommand() const
bool Ctf1f2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<3) {
+ if (oss.command != getCommand() || oss.parameters.size()<3) {
return false;
}
return true;
@@ -39,12 +39,12 @@ bool Ctf1f2Db::canProcess(const OaStatStruct &oss) const
void Ctf1f2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
string player = "";
- if(oss.parameters.at(0)!=-1) {
+ if (oss.parameters.at(0)!=-1) {
player= clientIdMap.at(oss.parameters.at(0));
}
diff --git a/src/oss2db/Ctf2Db.cpp b/src/oss2db/Ctf2Db.cpp index d28973e..51eb73a 100644 --- a/src/oss2db/Ctf2Db.cpp +++ b/src/oss2db/Ctf2Db.cpp
@@ -31,7 +31,7 @@ string Ctf2Db::getCommand() const
bool Ctf2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<3) {
+ if (oss.command != getCommand() || oss.parameters.size()<3) {
return false;
}
return true;
@@ -39,12 +39,12 @@ bool Ctf2Db::canProcess(const OaStatStruct &oss) const
void Ctf2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
string player = "";
- if(oss.parameters.at(0)!=-1) {
+ if (oss.parameters.at(0)!=-1) {
player= clientIdMap.at(oss.parameters.at(0));
}
diff --git a/src/oss2db/CtfElimination2Db.cpp b/src/oss2db/CtfElimination2Db.cpp index 96ebd32..84d9aa2 100644 --- a/src/oss2db/CtfElimination2Db.cpp +++ b/src/oss2db/CtfElimination2Db.cpp
@@ -30,7 +30,7 @@ string CtfElimination2Db::getCommand() const
bool CtfElimination2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<3 ) {
+ if (oss.command != getCommand() || oss.parameters.size()<3 ) {
return false;
}
return true;
@@ -38,12 +38,12 @@ bool CtfElimination2Db::canProcess(const OaStatStruct &oss) const
void CtfElimination2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
string player = "";
- if(oss.parameters.at(1)!=-1) {
+ if (oss.parameters.at(1)!=-1) {
player= clientIdMap.at(oss.parameters.at(1));
}
diff --git a/src/oss2db/Disconnect2Db.cpp b/src/oss2db/Disconnect2Db.cpp index 212a97d..c63e63b 100644 --- a/src/oss2db/Disconnect2Db.cpp +++ b/src/oss2db/Disconnect2Db.cpp
@@ -31,7 +31,7 @@ string Disconnect2Db::getCommand() const
bool Disconnect2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<1) {
+ if (oss.command != getCommand() || oss.parameters.size()<1) {
return false;
}
return true;
@@ -39,7 +39,7 @@ bool Disconnect2Db::canProcess(const OaStatStruct &oss) const
void Disconnect2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
diff --git a/src/oss2db/Elimination2Db.cpp b/src/oss2db/Elimination2Db.cpp index 5dfc520..2774045 100644 --- a/src/oss2db/Elimination2Db.cpp +++ b/src/oss2db/Elimination2Db.cpp
@@ -31,7 +31,7 @@ string Elimination2Db::getCommand() const
bool Elimination2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<3 ) {
+ if (oss.command != getCommand() || oss.parameters.size()<3 ) {
return false;
}
return true;
@@ -39,7 +39,7 @@ bool Elimination2Db::canProcess(const OaStatStruct &oss) const
void Elimination2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
diff --git a/src/oss2db/Harvester2Db.cpp b/src/oss2db/Harvester2Db.cpp index 6543bba..c1a93a7 100644 --- a/src/oss2db/Harvester2Db.cpp +++ b/src/oss2db/Harvester2Db.cpp
@@ -30,7 +30,7 @@ string Harvester2Db::getCommand() const
bool Harvester2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<5 ) {
+ if (oss.command != getCommand() || oss.parameters.size()<5 ) {
return false;
}
return true;
@@ -38,20 +38,20 @@ bool Harvester2Db::canProcess(const OaStatStruct &oss) const
void Harvester2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
string player1 = ""; //Parameter 0
string player2 = ""; //Parameter 3
- if(oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=1022) {
+ if (oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=1022) {
player1 = clientIdMap.at(oss.parameters.at(0));
} else {
player1 = "WORLD";
}
- if(oss.parameters.at(3)>-1 && oss.parameters.at(3)<(int)clientIdMap.size() && oss.parameters.at(3)!=1022) {
+ if (oss.parameters.at(3)>-1 && oss.parameters.at(3)<(int)clientIdMap.size() && oss.parameters.at(3)!=1022) {
player2 = clientIdMap.at(oss.parameters.at(3));
} else {
player2 = "WORLD";
diff --git a/src/oss2db/Point2Db.cpp b/src/oss2db/Point2Db.cpp index 84544e8..c3a1a34 100644 --- a/src/oss2db/Point2Db.cpp +++ b/src/oss2db/Point2Db.cpp
@@ -31,7 +31,7 @@ string Point2Db::getCommand() const
bool Point2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<2 || oss.parameters.at(0)<0) {
+ if (oss.command != getCommand() || oss.parameters.size()<2 || oss.parameters.at(0)<0) {
return false;
}
return true;
@@ -39,7 +39,7 @@ bool Point2Db::canProcess(const OaStatStruct &oss) const
void Point2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
diff --git a/src/oss2db/Warmup2Db.cpp b/src/oss2db/Warmup2Db.cpp index 14df5b9..4683f5b 100644 --- a/src/oss2db/Warmup2Db.cpp +++ b/src/oss2db/Warmup2Db.cpp
@@ -30,7 +30,7 @@ string Warmup2Db::getCommand() const
bool Warmup2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand()) {
+ if (oss.command != getCommand()) {
return false;
}
return true;
@@ -38,7 +38,7 @@ bool Warmup2Db::canProcess(const OaStatStruct &oss) const
void Warmup2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
diff --git a/src/oss2db/init2db.cpp b/src/oss2db/init2db.cpp index 34732bf..f75b379 100644 --- a/src/oss2db/init2db.cpp +++ b/src/oss2db/init2db.cpp
@@ -32,7 +32,7 @@ string Init2Db::getCommand() const
bool Init2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand()) {
+ if (oss.command != getCommand()) {
return false;
}
return true;
@@ -40,7 +40,7 @@ bool Init2Db::canProcess(const OaStatStruct &oss) const
void Init2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
OaStatStruct oss_copy(oss);
@@ -53,7 +53,7 @@ void Init2Db::process(const OaStatStruct &oss)
dp->startGame(gametype,mapname,basegame,servername,oss_copy);
map<string,string>::iterator it;
- for(it = arguments.begin(); it != arguments.end(); it++) {
+ for (it = arguments.begin(); it != arguments.end(); it++) {
if(
it->first == "g_gametype" ||
it->first == "gamename" ||
diff --git a/src/oss2db/kill2db.cpp b/src/oss2db/kill2db.cpp index 60742d8..b14f1f3 100644 --- a/src/oss2db/kill2db.cpp +++ b/src/oss2db/kill2db.cpp
@@ -31,7 +31,7 @@ string Kill2Db::getCommand() const
bool Kill2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand() || oss.parameters.size()<=3) {
+ if (oss.command != getCommand() || oss.parameters.size()<=3) {
return false;
}
return true;
@@ -39,19 +39,19 @@ bool Kill2Db::canProcess(const OaStatStruct &oss) const
void Kill2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return; //Invalid oss
}
string target = ""; //Parameter 1
string killer = ""; //Parameter 0
//mod is parameter 2
- if(oss.parameters.at(1)>-1 && oss.parameters.at(1)<(int)clientIdMap.size() && oss.parameters.at(1)!=1022 ) {
+ if (oss.parameters.at(1)>-1 && oss.parameters.at(1)<(int)clientIdMap.size() && oss.parameters.at(1)!=1022 ) {
target = clientIdMap.at(oss.parameters.at(1));
} else {
target ="WORLD"; //Should not be possible... except maybe for NPC-creatures
}
- if(oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=1022) {
+ if (oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=1022) {
killer = clientIdMap.at(oss.parameters.at(0));
} else {
killer ="WORLD";
diff --git a/src/oss2db/shutdown2db.cpp b/src/oss2db/shutdown2db.cpp index 182ece2..38585a3 100644 --- a/src/oss2db/shutdown2db.cpp +++ b/src/oss2db/shutdown2db.cpp
@@ -32,7 +32,7 @@ string Shutdown2Db::getCommand() const
bool Shutdown2Db::canProcess(const OaStatStruct &oss) const
{
- if(oss.command != getCommand()) {
+ if (oss.command != getCommand()) {
return false;
}
return true;
@@ -40,7 +40,7 @@ bool Shutdown2Db::canProcess(const OaStatStruct &oss) const
void Shutdown2Db::process(const OaStatStruct &oss)
{
- if(!canProcess(oss)) {
+ if (!canProcess(oss)) {
return;
}
dp->endGame(oss.second);