jachoo 2012-02-21 13:42:46 +01:00
commit c5ba5c6f50
9 changed files with 17 additions and 29 deletions

View File

@ -114,10 +114,10 @@ u64 stringToPrivs(std::string str)
}
AuthManager::AuthManager(Database* database, const std::string& authfilepath):
m_database(database),
m_authtable( NULL ),
m_authfilepath(authfilepath),
m_modified(false),
m_authfilepath(authfilepath)
m_database(database),
m_authtable( NULL )
{
m_mutex.Init();

View File

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <jmutex.h>
#include "irrlichttypes.h"
#include "exceptions.h"
#include "db.h"
// Player privileges. These form a bitmask stored in the privs field
// of the player, and define things they're allowed to do. See also
@ -80,11 +81,6 @@ public:
{}
};
//#include "db.h"
class Database;
template<class Key, class Data> class Table;
typedef std::string binary_t;
class AuthManager
{
public:
@ -108,8 +104,7 @@ private:
core::map<std::string, AuthData> m_authdata;
bool m_modified;
Database* m_database;
Table<std::string,std::string>* m_authtable;
Table<std::string,std::string>* m_authtable;
};
#endif

View File

@ -27,8 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "db.h"
BanManager::BanManager(Database* database, const std::string& file):
m_modified(false),
m_banfilepath(file),
m_modified(false),
m_database(database),
m_bantable(NULL)
{

View File

@ -26,11 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <jmutex.h>
#include "common_irrlicht.h"
#include "exceptions.h"
//#include "db.h"
class Database;
template<class Key, class Data> class Table;
typedef std::string binary_t;
#include "db.h"
class BanManager
{

View File

@ -179,11 +179,11 @@ template<> void DBTypeTraits<double>::bind(sqlite3_stmt* stmt, int num, const do
ITable::ITable(sqlite3* database, const std::string& name, const std::string& key, const std::string& data, bool old_names):
m_database(database),
name(name),
key_name(key),
data_name(data),
old_names(old_names)
old_names(old_names),
m_database(database)
{
assert(database);

View File

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef DB_HEADER
#define DB_HEADER
#include <typeinfo>
#include <jmutex.h>
#include <jmutexautolock.h>
#include <jthread.h>

View File

@ -1902,11 +1902,11 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
Map(dout_server, gamedef),
m_seed(0),
//m_map_metadata_changed(true),
m_savedir(savedir),
m_database( new Database(savedir + DIR_DELIM "map.sqlite") ),
m_blocks( m_database->getTable<v3s16,binary_t>("blocks",true) ),
m_map_meta( m_database->getTable<std::string>("map_meta") ),
m_sectors_meta( m_database->getTable<v2s16,binary_t>("sectors_meta") ),
m_savedir(savedir)
m_sectors_meta( m_database->getTable<v2s16,binary_t>("sectors_meta") )
{
infostream<<__FUNCTION_NAME<<std::endl;

View File

@ -34,11 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "utility.h" // Needed for UniqueQueue, a member of Map
#include "modifiedstate.h"
//#include "db.h"
class Database;
class ITable;
template<class Key, class Data = void> class Table;
typedef std::string binary_t;
#include "db.h"
class MapSector;
class ServerMapSector;

View File

@ -3690,7 +3690,7 @@ struct Databases {
Database& get_db(int i)
{
if(i<=0 || i>dbs.size()) throw DatabaseException("Wrong database number");
if(i<=0 || i>(int)dbs.size()) throw DatabaseException("Wrong database number");
return *dbs[ i-1 ];
}
@ -3702,7 +3702,7 @@ struct Databases {
int get_db_i(const std::string& file)
{
int i = db_names[file];
assert(i<=dbs.size());
assert(i<=(int)dbs.size());
if( i > 0 ) return i;
dbs.push_back( new Database(file) );
@ -3722,14 +3722,14 @@ struct Databases {
ITable& get_table(int i)
{
if(i<=0 || i>tables.size()) throw DatabaseException("Wrong table number");
if(i<=0 || i>(int)tables.size()) throw DatabaseException("Wrong table number");
return *tables[ i-1 ];
}
int get_table_i(int database, const std::string& name)
{
int i = table_names[database][name];
assert(i<=tables.size());
assert(i<=(int)tables.size());
if( i > 0 ) return i;
Database& db = get_db(database);