git repos / oastat

commit 95297dc7

sago007 · 2011-08-06 16:24
95297dc7f4da2c78f7cd4a6f22575b21404c629d patch · browse files
parent c59f2dada9c7c473f3b891afbca12f87e7c08774

Added serial to player table and hopefully fixed a memory leak


git-svn-id: http://oastat.googlecode.com/svn/trunk@24 a36be8df-c75f-1e49-46ad-4f0ee64bdc62

Changed files

M sql/create_tables/oastat_create_tables_common.sql before
M src/oastat.cpp before
diff --git a/sql/create_tables/oastat_create_tables_common.sql b/sql/create_tables/oastat_create_tables_common.sql index 1c1ca73..0863211 100644 --- a/sql/create_tables/oastat_create_tables_common.sql +++ b/sql/create_tables/oastat_create_tables_common.sql
@@ -71,6 +71,7 @@ CREATE TABLE oastat_kills (
CREATE TABLE oastat_players (
guid character varying(64) NOT NULL,
+ playerid SERIAL NOT NULL,
lastseen DATETIME NOT NULL,
isbot char(1) DEFAULT 'n' NOT NULL,
model character varying(64) NOT NULL,
diff --git a/src/oastat.cpp b/src/oastat.cpp index 2360688..4ab6209 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp
@@ -149,54 +149,56 @@ int main (int argc, const char* argv[])
}
static int processStdIn(istream* in_p) {
- string line;
- OaStatStruct oss;
- list<OaStatStruct> osslist;
bool done = true;
- try{
- while( getline(*in_p,line) )
- {
- oss.clear();
- oss.parseLine(line);
- osslist.push_back(oss);
- if(oss.command=="ShutdownGame")
+ do
+ {
+ string line = "";
+ OaStatStruct oss;
+ list<OaStatStruct> osslist;
+ try{
+ while( getline(*in_p,line) )
{
- while(!osslist.empty())
+ oss.clear();
+ oss.parseLine(line);
+ osslist.push_back(oss);
+ if(oss.command=="ShutdownGame")
{
- //cout << "next: " << oss.command << endl;
- oss = osslist.front();
- //cout << "gotten, now popping" << endl;
- osslist.pop_front();
- //cout << "popping complete" << endl;
- for(int i=0;i<commands.size();i++)
+ while(!osslist.empty())
{
- //try {
- //cout << "checking " << commands.at(i)->getCommand() << endl;
- if(commands.at(i)->canProcess(oss)) {
- //cout << "Exectured by " << commands.at(i)->getCommand();
- commands.at(i)->process(oss);
- }
- /*} catch (exception &e)
+ //cout << "next: " << oss.command << endl;
+ oss = osslist.front();
+ //cout << "gotten, now popping" << endl;
+ osslist.pop_front();
+ //cout << "popping complete" << endl;
+ for(int i=0;i<commands.size();i++)
{
- cerr << "oastat: Sql_error at line: \"" << line << "\"" << endl <<
- "oastat: Error is: " << e.what() <<
- "oastat: Last error will be ignored" << endl;
- }*/
+ //try {
+ //cout << "checking " << commands.at(i)->getCommand() << endl;
+ if(commands.at(i)->canProcess(oss)) {
+ //cout << "Exectured by " << commands.at(i)->getCommand();
+ commands.at(i)->process(oss);
+ }
+ /*} catch (exception &e)
+ {
+ cerr << "oastat: Sql_error at line: \"" << line << "\"" << endl <<
+ "oastat: Error is: " << e.what() <<
+ "oastat: Last error will be ignored" << endl;
+ }*/
+ }
+ //cout << "returned" << endl;
}
- //cout << "returned" << endl;
}
}
+ } catch (exception &e2) {
+ /*
+ If there is an error write it in the log and try again continue
+ */
+ osslist.clear();
+ cerr << "oastat: Crashed (NEAR FATAL EXCEPTION) at line: \"" << line << "\"" << endl <<
+ "oastat: Error is: " << e2.what() << endl;
+ done = false;
}
- } catch (exception &e2) {
- /*
- If there is an error write it in the log and try again continue
- */
- cerr << "oastat: Crashed (NEAR FATAL EXCEPTION) at line: \"" << line << "\"" << endl <<
- "oastat: Error is: " << e2.what() << endl;
- done = false;
- }
- if (!done)
- return processStdIn(in_p);
+ } while (!done);
return 0;
}