1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #if !defined(__INCLUDE_StatsLoggerDatabaseh_INCLUDE__)
22 #define __INCLUDE_StatsLoggerDatabaseh_INCLUDE__
24 #include <common/StatsLogger.h>
31 class StatsLoggerDatabase
: public StatsLogger
34 StatsLoggerDatabase();
35 virtual ~StatsLoggerDatabase();
37 virtual int getKillCount(const char *uniqueId
);
38 virtual void gameStart(std::list
<Tank
*> &tanks
);
39 virtual void roundStart(std::list
<Tank
*> &tanks
);
41 virtual std::list
<std::string
> getAliases(const char *unqiueId
);
42 virtual std::list
<std::string
> getIpAliases(const char *unqiueId
);
43 virtual TankRank
tankRank(Tank
*tank
);
44 virtual void updateStats(Tank
*tank
);
45 virtual void periodicUpdate();
46 virtual std::string
allocateId();
47 virtual unsigned int getStatsId(const char *uniqueId
);
48 virtual std::string
getTopRanks();
49 virtual std::string
getPlayerInfo(const char *player
);
50 virtual void combinePlayers(unsigned int player1
, unsigned int player2
);
52 virtual void tankConnected(Tank
*tank
);
53 virtual void tankDisconnected(Tank
*tank
);
54 virtual void tankJoined(Tank
*tank
);
56 virtual void tankFired(Tank
*firedTank
, Weapon
*weapon
);
57 virtual void tankResigned(Tank
*resignedTank
);
59 virtual void tankKilled(Tank
*firedTank
, Tank
*deadTank
, Weapon
*weapon
);
60 virtual void tankTeamKilled(Tank
*firedTank
, Tank
*deadTank
, Weapon
*weapon
);
61 virtual void tankSelfKilled(Tank
*firedTank
, Weapon
*weapon
);
63 virtual void tankWon(Tank
*tank
);
64 virtual void tankOverallWinner(Tank
*tank
);
66 virtual void weaponFired(Weapon
*weapon
, bool deathAni
);
67 virtual void weaponKilled(Weapon
*weapon
, bool deathAni
);
72 std::vector
<std::string
> columns
;
73 std::map
<std::string
, unsigned int> names
;
75 const char *getValue(const char *name
);
78 // Overridden by new implementations
79 virtual bool runQuery(const char *, ...) = 0;
80 virtual std::list
<RowResult
> runSelectQuery(const char *, ...) = 0;
81 virtual bool connectDatabase(const char *host
, const char *port
,
82 const char *user
, const char *passwd
,
85 virtual int getLastInsertId() = 0;
86 virtual void escapeString(char *to
, const char *from
, unsigned long length
) = 0;
96 std::map
<std::string
, int> playerId_
;
97 std::map
<std::string
, int> weaponId_
;
100 int getPlayerId(const char *uniqueId
);
102 void addInfo(Tank
*tank
);
103 void addAliases(int playerId
,
104 std::list
<std::string
> &results
);
105 void addIpAliases(int playerId
,
106 std::set
<int> ¤tPlayers
, std::list
<std::string
> &result
);