Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv2057/src
Modified Files:
basechar.cpp basechar.h books.cpp books.h dbdriver.cpp
dbdriver.h items.cpp items.h npc.cpp npc.h
persistentbroker.cpp persistentbroker.h player.cpp player.h
srvparams.cpp srvparams.h uobject.h wolf.dsp wolf.dsw
wolfpack.cpp world.cpp world.h
Removed Files:
basechar_flatstore.cpp flatstore_keys.h item_flatstore.cpp
npc_flatstore.cpp player_flatstore.cpp uobject_flatstore.cpp
Log Message:
Implemented SQLite support.
driver=sqlite
database name is the filename
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** basechar.cpp 26 Aug 2003 03:55:13 -0000 1.34
--- basechar.cpp 26 Aug 2003 15:01:05 -0000 1.35
***************
*** 249,253 ****
addStrField( "name", orgName_ );
addStrField( "title", title_ );
! addField( "creationdate", creationDate_.toString() );
addField( "body", bodyID_ );
addField( "orgbody", orgBodyID_ );
--- 249,253 ----
addStrField( "name", orgName_ );
addStrField( "title", title_ );
! addStrField( "creationdate", creationDate_.toString() );
addField( "body", bodyID_ );
addField( "orgbody", orgBodyID_ );
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** basechar.h 21 Aug 2003 01:02:41 -0000 1.23
--- basechar.h 26 Aug 2003 15:01:05 -0000 1.24
***************
*** 82,88 ****
void load( char **, ushort& );
void save();
- void save( FlatStore::OutputFile*, bool first = false ) throw();
- bool load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile* ) throw();
- bool postload() throw();
bool del();
--- 82,85 ----
Index: books.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/books.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** books.cpp 21 Aug 2003 01:02:41 -0000 1.41
--- books.cpp 26 Aug 2003 15:01:05 -0000 1.42
***************
*** 39,46 ****
#include "globals.h"
- // Flatstore
- #include "flatstore_keys.h"
- #include "flatstore/flatstore.h"
-
#include <qregexp.h>
#include <qsqlcursor.h>
--- 39,42 ----
***************
*** 62,66 ****
UObjectFactory::instance()->registerType( "cBook", productCreator );
- UObjectFactory::instance()->registerType( QString::number( CHUNK_BOOK ), productCreator );
}
--- 58,61 ----
***************
*** 120,216 ****
BOOK_PAGES, // unsigned short + count * utf8
};
-
- void cBook::save( FlatStore::OutputFile *output, bool first ) throw()
- {
- cItem::save( output, first );
- return;
-
- if( first )
- output->startObject( serial_, CHUNK_BOOK );
-
- cItem::save( output );
-
- output->startChunkGroup( CHUNK_BOOK );
-
- if( predefined_ )
- output->startChunk( BOOK_PREDEFINED );
-
- if( readonly_ )
- output->startChunk( BOOK_READONLY );
-
- if( !title_.isNull() && !title_.isEmpty() )
- output->chunkData( BOOK_TITLE, (const char*)title_.utf8().data() );
-
- if( !author_.isNull() && !author_.isEmpty() )
- output->chunkData( BOOK_AUTHOR, (const char*)author_.utf8().data() );
-
- if( !section_.isNull() && !section_.isEmpty() )
- output->chunkData( BOOK_SECTION, (const char*)section_.utf8().data() );
-
- // Write pages
- output->chunkData( BOOK_PAGES, (unsigned short)pages_ );
-
- unsigned int i;
- for( i = 0; i < pages_; ++i )
- {
- if( i >= content_.count() )
- output->writeString( "" );
- else
- output->writeString( content_[i].utf8().data() );
- }
-
- if( first )
- output->finishObject();
- }
-
- bool cBook::load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile *input ) throw()
- {
- // if( chunkGroup != CHUNK_BOOK )
- return cItem::load( chunkGroup, chunkType, input );
- /*
- unsigned int i;
-
- switch( chunkType )
- {
- case BOOK_PREDEFINED:
- predefined_ = true;
- break;
-
- case BOOK_READONLY:
- readonly_ = true;
- break;
-
- case BOOK_TITLE:
- title_ = QString::fromUtf8( input->readString() );
- break;
-
- case BOOK_AUTHOR:
- author_ = QString::fromUtf8( input->readString() );
- break;
-
- case BOOK_SECTION:
- section_ = QString::fromUtf8( input->readString() );
- break;
-
- case BOOK_PAGES:
- input->readUShort( pages_ );
- content_.clear();
-
- for( i = 0; i < pages_; ++i )
- content_.push_back( QString::fromUtf8( input->readString() ) );
-
- break;
-
- default:
- return false;
- };
-
- return true;*/
- }
-
- bool cBook::postload() throw()
- {
- return cItem::postload();
- }
void cBook::save()
--- 115,118 ----
Index: books.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/books.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** books.h 21 Aug 2003 05:04:35 -0000 1.27
--- books.h 26 Aug 2003 15:01:05 -0000 1.28
***************
*** 63,71 ****
virtual void flagUnchanged() { cBook::changed_ = false; cItem::flagUnchanged(); }
- // FlatStore
- void save( FlatStore::OutputFile*, bool first = false ) throw();
- bool load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile* ) throw();
- bool postload() throw();
-
// setters/getters
QString title( void ) const;
--- 63,66 ----
Index: dbdriver.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/dbdriver.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** dbdriver.cpp 9 May 2003 05:11:33 -0000 1.16
--- dbdriver.cpp 26 Aug 2003 15:01:05 -0000 1.17
***************
*** 44,47 ****
--- 44,48 ----
#include <errmsg.h>
#include <stdlib.h>
+ #include "sqlite/sqlite.h"
/*****************************************************************************
***************
*** 64,68 ****
cDBDriver::~cDBDriver()
{
! close();
}
--- 65,69 ----
cDBDriver::~cDBDriver()
{
! //close();
}
***************
*** 78,88 ****
if ( !connection )
throw QString("mysql_init(): insufficient memory to allocate a new object");
- connection->reconnect = 1;
! if ( !mysql_real_connect(connection, _host.latin1(), _username.latin1(), _password.latin1(), _dbname.latin1(), 0, 0, CLIENT_COMPRESS ) )
{ // Named pipes are acctually slower :(
! throw QString( "Connection to DB failed: %1" ).arg( mysql_error( connection ) );
}
! connections[ id ] = connection;
return true;
--- 79,90 ----
if ( !connection )
throw QString("mysql_init(): insufficient memory to allocate a new object");
! ( (MYSQL*)connection )->reconnect = 1;
!
! if ( !mysql_real_connect((MYSQL*)connection, _host.latin1(), _username.latin1(), _password.latin1(), _dbname.latin1(), 0, 0, CLIENT_COMPRESS ) )
{ // Named pipes are acctually slower :(
! throw QString( "Connection to DB failed: %1" ).arg( mysql_error( (MYSQL*)connection ) );
}
! connections[ id ] = (MYSQL*)connection;
return true;
***************
*** 94,98 ****
void cDBDriver::close()
{
! mysql_close( connection );
}
--- 96,100 ----
void cDBDriver::close()
{
! mysql_close( (MYSQL*)connection );
}
***************
*** 103,107 ****
cDBResult cDBDriver::query( const QString &query )
{
! MYSQL *mysql = connection;
if( !mysql )
--- 105,109 ----
cDBResult cDBDriver::query( const QString &query )
{
! MYSQL *mysql = (MYSQL*)connection;
if( !mysql )
***************
*** 121,139 ****
Returns true if executed successfully.
*/
! bool cDBDriver::exec( const QString &query ) const
{
if( !connection )
throw QString( "Not connected to mysql server. Unable to execute query." );
! bool ok = !mysql_query( connection, query.latin1() );
return ok;
}
! void cDBDriver::lockTable( const QString& table ) const
{
exec( QString("LOCK TABLES %1 WRITE;").arg(table) );
}
! void cDBDriver::unlockTable( const QString& table ) const
{
exec( QString("UNLOCK TABLES") );
--- 123,141 ----
Returns true if executed successfully.
*/
! bool cDBDriver::exec( const QString &query )
{
if( !connection )
throw QString( "Not connected to mysql server. Unable to execute query." );
! bool ok = !mysql_query( (MYSQL*)connection, query.latin1() );
return ok;
}
! void cDBDriver::lockTable( const QString& table )
{
exec( QString("LOCK TABLES %1 WRITE;").arg(table) );
}
! void cDBDriver::unlockTable( const QString& table )
{
exec( QString("UNLOCK TABLES") );
***************
*** 143,147 ****
QString cDBDriver::error()
{
! const char *error = mysql_error( connection );
if( error != 0 )
--- 145,149 ----
QString cDBDriver::error()
{
! const char *error = mysql_error( (MYSQL*)connection );
if( error != 0 )
***************
*** 178,183 ****
return false;
! _row = mysql_fetch_row( _result );
! return ( _row != 0 );
}
--- 180,195 ----
return false;
! if( mysql_type )
! {
! _row = mysql_fetch_row( (st_mysql_res*)_result );
! return ( _row != 0 );
! }
! else
! {
! int count;
! const char **columns;
!
! return ( sqlite_step( (sqlite_vm*)_result, &count, (const char***)&_row, &columns ) == SQLITE_ROW );
! }
}
***************
*** 185,189 ****
void cDBResult::free()
{
! mysql_free_result( _result );
_result = 0;
_row = 0;
--- 197,222 ----
void cDBResult::free()
{
! if( mysql_type )
! {
! mysql_free_result( (st_mysql_res*)_result );
! }
! else
! {
! char *error;
! if( sqlite_finalize( (sqlite_vm*)_result, &error ) != SQLITE_OK )
! {
! if( error )
! {
! QString err( error );
! sqlite_freemem( error );
! throw err;
! }
! else
! {
! throw QString( "Unknown SQLite error while finalizing query." );
! }
! }
! }
!
_result = 0;
_row = 0;
***************
*** 213,215 ****
--- 246,331 ----
return _row[offset];
+ }
+
+ /*****************************************************************************
+ cSQLiteDriver member functions
+ *****************************************************************************/
+
+ bool cSQLiteDriver::open( int id )
+ {
+ char *error = NULL;
+
+ close();
+
+ connection = sqlite_open( _dbname.latin1(), 0, &error );
+
+ if( !connection )
+ {
+ if( error )
+ {
+ QString err( error );
+ sqlite_freemem( error );
+ throw err;
+ }
+ else
+ {
+ throw QString( "Unknown SQLite error while opening database." );
+ }
+ }
+
+ return true;
+ }
+
+ void cSQLiteDriver::close()
+ {
+ if( connection != 0 )
+ {
+ sqlite_close( (sqlite*)connection );
+ connection = 0;
+ }
+ }
+
+ bool cSQLiteDriver::exec( const QString &query )
+ {
+ char *error;
+
+ if( sqlite_exec( (sqlite*)connection, query.latin1(), NULL, NULL, &error ) != SQLITE_OK )
+ {
+ if( error )
+ {
+ QString err( QString( error ) + " (" + query + ")" );
+ sqlite_freemem( error );
+ throw err;
+ }
+ else
+ {
+ throw QString( "Unknown SQLite error while executing: %1" ).arg( query );
+ }
+ }
+
+ return true;
+ }
+
+ cDBResult cSQLiteDriver::query( const QString &query )
+ {
+ char *error = NULL;
+ sqlite_vm *result;
+
+
+ // Compile a VM and pass it to cSQLiteResult
+ if( sqlite_compile( (sqlite*)connection, query.latin1(), NULL, &result, &error ) != SQLITE_OK )
+ {
+ if( error )
+ {
+ QString err( QString( error ) + " (" + query + ")" );
+ sqlite_freemem( error );
+ throw err;
+ }
+ else
+ {
+ throw QString( "Unknown SQLite error while querying: %1" ).arg( query );
+ }
+ }
+
+ return cDBResult( result, connection, false );
}
Index: dbdriver.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/dbdriver.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** dbdriver.h 30 Apr 2003 05:54:31 -0000 1.9
--- dbdriver.h 26 Aug 2003 15:01:05 -0000 1.10
***************
*** 35,38 ****
--- 35,40 ----
struct st_mysql;
struct st_mysql_res;
+ struct sqlite;
+ struct sqlite_vm;
#include <qstring.h>
***************
*** 41,51 ****
class cDBResult;
class cDBDriver
{
friend class cDBResult;
! private:
std::map< int, st_mysql* > connections;
! st_mysql *connection;
QString _host, _dbname, _username, _password;
QString lasterror_;
--- 43,55 ----
class cDBResult;
+ class cSQLiteResult;
class cDBDriver
{
friend class cDBResult;
! protected:
std::map< int, st_mysql* > connections;
! void *connection;
!
QString _host, _dbname, _username, _password;
QString lasterror_;
***************
*** 57,67 ****
virtual ~cDBDriver();
! bool open( int id = CONN_MAIN );
! void close();
! bool exec( const QString &query ) const; // Just execute some SQL code, no return!
! cDBResult query( const QString &query ); // Executes a query
! void lockTable( const QString& table ) const;
! void unlockTable( const QString& table ) const;
! QString error(); // Returns an error (if there is one), uses the current connection
// Setters + Getters
--- 61,71 ----
virtual ~cDBDriver();
! virtual bool open( int id = CONN_MAIN );
! virtual void close();
! virtual bool exec( const QString &query ); // Just execute some SQL code, no return!
! virtual cDBResult query( const QString &query ); // Executes a query
! virtual void lockTable( const QString& table );
! virtual void unlockTable( const QString& table );
! virtual QString error(); // Returns an error (if there is one), uses the current connection
// Setters + Getters
***************
*** 77,89 ****
};
class cDBResult
{
! private:
char **_row;
! st_mysql_res *_result;
! st_mysql *_connection; // Connection occupied by this query
public:
! cDBResult(): _row( 0 ), _result( 0 ), _connection( 0 ) {} // Standard Constructor
! cDBResult( st_mysql_res *result, st_mysql *connection ): _row( 0 ), _result( result ), _connection( connection ) {}; // MySQL Constructor
virtual ~cDBResult() {}
--- 81,111 ----
};
+ class cSQLiteDriver : public cDBDriver
+ {
+ public:
+ cSQLiteDriver() {}
+ virtual ~cSQLiteDriver() {}
+
+ bool open( int id = CONN_MAIN );
+ void close();
+
+ void lockTable( const QString &table ) {}
+ void unlockTable( const QString &table ) {}
+ QString error() { return QString::null; }
+
+ bool exec( const QString &query );
+ cDBResult query( const QString &query );
+ };
+
class cDBResult
{
! public:
char **_row;
! void *_result;
! void *_connection; // Connection occupied by this query
! bool mysql_type;
public:
! cDBResult(): _row( 0 ), _result( 0 ), _connection( 0 ), mysql_type( true ) {} // Standard Constructor
! cDBResult( void *result, void *connection, bool mysql_type = true ): _row( 0 ), _result( result ), _connection( connection ) { this->mysql_type = mysql_type; }; // MySQL Constructor
virtual ~cDBResult() {}
Index: items.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v
retrieving revision 1.334
retrieving revision 1.335
diff -C2 -d -r1.334 -r1.335
*** items.cpp 23 Aug 2003 15:20:29 -0000 1.334
--- items.cpp 26 Aug 2003 15:01:05 -0000 1.335
***************
*** 2002,2005 ****
--- 2002,2019 ----
}
+ static cUObject* productCreator()
+ {
+ return new cItem;
+ }
+
+ void cItem::registerInFactory()
+ {
+ QStringList fields, tables, conditions;
+ buildSqlString( fields, tables, conditions ); // Build our SQL string
+ QString sqlString = QString( "SELECT /*! STRAIGHT_JOIN SQL_SMALL_RESULT */ uobjectmap.serial,uobjectmap.type,%1 FROM uobjectmap,%2 WHERE uobjectmap.type = 'cItem' AND %3" ).arg( fields.join( "," ) ).arg( tables.join( "," ) ).arg( conditions.join( " AND " ) );
+ UObjectFactory::instance()->registerType("cItem", productCreator);
+ UObjectFactory::instance()->registerSqlQuery( "cItem", sqlString );
+ }
+
void cItem::load( char **result, UINT16 &offset )
{
Index: items.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.h,v
retrieving revision 1.169
retrieving revision 1.170
diff -C2 -d -r1.169 -r1.170
*** items.h 26 Aug 2003 03:55:13 -0000 1.169
--- items.h 26 Aug 2003 15:01:05 -0000 1.170
***************
*** 101,107 ****
void load( char **, UINT16& );
void save();
- void save( FlatStore::OutputFile*, bool first = false ) throw();
- bool load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile* ) throw();
- bool postload() throw();
bool del();
--- 101,104 ----
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** npc.cpp 21 Aug 2003 01:02:42 -0000 1.31
--- npc.cpp 26 Aug 2003 15:01:05 -0000 1.32
***************
*** 94,97 ****
--- 94,106 ----
}
+ void cNPC::registerInFactory()
+ {
+ QStringList fields, tables, conditions;
+ buildSqlString( fields, tables, conditions ); // Build our SQL string
+ QString sqlString = QString( "SELECT /*! STRAIGHT_JOIN SQL_SMALL_RESULT */ uobjectmap.serial,uobjectmap.type,%1 FROM uobjectmap,%2 WHERE uobjectmap.type = 'cNPC' AND %3" ).arg( fields.join( "," ) ).arg( tables.join( "," ) ).arg( conditions.join( " AND " ) );
+ UObjectFactory::instance()->registerType( "cNPC", productCreator );
+ UObjectFactory::instance()->registerSqlQuery( "cNPC", sqlString );
+ }
+
void cNPC::buildSqlString( QStringList &fields, QStringList &tables, QStringList &conditions )
{
Index: npc.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** npc.h 21 Aug 2003 05:04:35 -0000 1.19
--- npc.h 26 Aug 2003 15:01:05 -0000 1.20
***************
*** 83,89 ****
void load( char **, UINT16& );
void save();
- void save( FlatStore::OutputFile*, bool first = false ) throw();
- bool load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile* ) throw();
- bool postload() throw();
bool del();
--- 83,86 ----
Index: persistentbroker.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/persistentbroker.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** persistentbroker.cpp 11 May 2003 16:03:32 -0000 1.13
--- persistentbroker.cpp 26 Aug 2003 15:01:05 -0000 1.14
***************
*** 52,56 ****
bool PersistentBroker::openDriver( const QString& driver )
{
! connection = new cDBDriver();
if ( !connection )
return false;
--- 52,67 ----
bool PersistentBroker::openDriver( const QString& driver )
{
! if( connection != 0 )
! {
! connection->close();
! delete connection;
! connection = 0;
! }
!
! if( driver == "sqlite" )
! connection = new cSQLiteDriver();
! else
! connection = new cDBDriver;
!
if ( !connection )
return false;
***************
*** 75,78 ****
--- 86,95 ----
}
+ void PersistentBroker::disconnect()
+ {
+ if( connection )
+ connection->close();
+ }
+
bool PersistentBroker::saveObject( PersistentObject* object )
{
***************
*** 109,112 ****
--- 126,132 ----
bool PersistentBroker::executeQuery( const QString& query )
{
+ if( !connection )
+ throw QString( "PersistentBroker not connected to database." );
+
bool result = connection->exec(query);
if( !result )
***************
*** 129,133 ****
{
if( !connection )
! return cDBResult( 0, 0 );
return connection->query( query );
--- 149,153 ----
{
if( !connection )
! throw QString( "PersistentBroker not connected to database." );
return connection->query( query );
Index: persistentbroker.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/persistentbroker.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** persistentbroker.h 5 May 2003 11:59:13 -0000 1.16
--- persistentbroker.h 26 Aug 2003 15:01:05 -0000 1.17
***************
*** 57,61 ****
--- 57,64 ----
~PersistentBroker();
bool openDriver( const QString& driver );
+
bool connect( const QString& host, const QString& db, const QString& username, const QString& password );
+ void disconnect();
+
bool executeQuery( const QString& query );
cDBResult query( const QString& query );
***************
*** 78,82 ****
inline QString __escapeReservedCharacters( const QString& d )
{
! return QString(d).replace( QRegExp("'"), "\\'" );
}
--- 81,86 ----
inline QString __escapeReservedCharacters( const QString& d )
{
! //return QString(d).replace( QRegExp("'"), "\\'" );
! return QString(d).replace( QRegExp("'"), "''" );
}
***************
*** 141,146 ****
#endif
! #define initSave QStringList conditions; QStringList fields; QString table;
! #define clearFields conditions.clear(); fields.clear();
#define setTable( value ) table = value;
--- 145,150 ----
#endif
! #define initSave QStringList conditions, fields, values; QString table;
! #define clearFields conditions.clear(); fields.clear(); values.clear();
#define setTable( value ) table = value;
***************
*** 148,163 ****
// for inserting we use the faster VALUES() method
! #define addField( name, value ) fields.push_back( QString( "`%1` = '%2'" ).arg( name ).arg( value ) );
! #define addStrField( name, value ) fields.push_back( QString( "`%1` = '%2'" ).arg( name ).arg( __escapeReservedCharacters( value.isNull() ? QString( "" ) : value ) ) );
#define addCondition( name, value ) conditions.push_back( QString( "`%1` = '%2'" ).arg( name ).arg( value ) );
#define saveFields \
if( isPersistent ) \
! { \
! persistentBroker->executeQuery( QString( "UPDATE `%1` SET %2 WHERE %3" ).arg( table ).arg( fields.join(", ") ).arg( conditions.join(" AND ") ) ); \
! } \
else \
! { \
! persistentBroker->executeQuery( QString( "INSERT INTO `%1` SET %2" ).arg( table ).arg( fields.join( ", " ) ) ); \
! }
#endif // __PERSISTENTBROKER_H__
--- 152,163 ----
// for inserting we use the faster VALUES() method
! #define addField( name, value ) fields.push_back( name ); values.push_back( QString::number( value ) );
! #define addStrField( name, value ) fields.push_back( name ); values.push_back( "'" + ( value.isNull() ? QString( "" ) : __escapeReservedCharacters( value ) ) + "'" );
#define addCondition( name, value ) conditions.push_back( QString( "`%1` = '%2'" ).arg( name ).arg( value ) );
#define saveFields \
if( isPersistent ) \
! persistentBroker->executeQuery( QString( "UPDATE %1 (%2) VALUES(%3) WHERE %4" ).arg( table ).arg( fields.join( "," ) ).arg( values.join( "," ) ).arg( conditions.join( " AND " ) ) ); \
else \
! persistentBroker->executeQuery( QString( "INSERT INTO %1 (%2) VALUES(%3)" ).arg( table ).arg( fields.join( "," ) ).arg( values.join( "," ) ) );
#endif // __PERSISTENTBROKER_H__
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** player.cpp 21 Aug 2003 01:02:42 -0000 1.24
--- player.cpp 26 Aug 2003 15:01:05 -0000 1.25
***************
*** 87,90 ****
--- 87,99 ----
}
+ void cPlayer::registerInFactory()
+ {
+ QStringList fields, tables, conditions;
+ buildSqlString( fields, tables, conditions ); // Build our SQL string
+ QString sqlString = QString( "SELECT /*! STRAIGHT_JOIN SQL_SMALL_RESULT */ uobjectmap.serial,uobjectmap.type,%1 FROM uobjectmap,%2 WHERE uobjectmap.type = 'cPlayer' AND %3" ).arg( fields.join( "," ) ).arg( tables.join( "," ) ).arg( conditions.join( " AND " ) );
+ UObjectFactory::instance()->registerType( "cPlayer", productCreator );
+ UObjectFactory::instance()->registerSqlQuery( "cPlayer", sqlString );
+ }
+
void cPlayer::buildSqlString( QStringList &fields, QStringList &tables, QStringList &conditions )
{
Index: player.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** player.h 21 Aug 2003 05:04:35 -0000 1.16
--- player.h 26 Aug 2003 15:01:05 -0000 1.17
***************
*** 62,68 ****
void load( char **, UINT16& );
void save();
- void save( FlatStore::OutputFile*, bool first = false ) throw();
- bool load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile* ) throw();
- bool postload() throw();
bool del();
--- 62,65 ----
Index: srvparams.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** srvparams.cpp 21 Aug 2003 05:04:35 -0000 1.84
--- srvparams.cpp 26 Aug 2003 15:01:05 -0000 1.85
***************
*** 119,127 ****
databaseUsername_ = getString("Database", "username", "", true);
databaseHost_ = getString("Database", "host", "", true);
! databaseName_ = getString("Database", "name", "", true);
!
! // Remote Admin
! ra_port_ = getNumber("Remote Admin", "Port", 2594, true);
! EnableRA_ = getBool("Remote Admin", "Enable", false, true);
// Repsys
--- 119,124 ----
databaseUsername_ = getString("Database", "username", "", true);
databaseHost_ = getString("Database", "host", "", true);
! databaseHost_ = getString("Database", "driver", "sqlite", true);
! databaseName_ = getString("Database", "name", "world.db", true);
// Repsys
***************
*** 272,281 ****
walkDisturbsCast_ = getBool( "Magic", "Walking Disturbs Casting", true, true );
precasting_ = getBool( "Magic", "Precasting", true, true );
-
- // Worldsave
- saveModule_ = getString( "Worldsaves", "Saver", "sql", true );
- loadModule_ = getString( "Worldsaves", "Loader", "sql", true );
- savePrefix_ = getString( "Worldsaves", "Prefix", "", true );
- savePath_ = getString( "Worldsaves", "Path", "", true );
// Path Finding
--- 269,272 ----
Index: srvparams.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** srvparams.h 21 Aug 2003 05:04:35 -0000 1.53
--- srvparams.h 26 Aug 2003 15:01:05 -0000 1.54
***************
*** 145,148 ****
--- 145,149 ----
unsigned int beggingTime_;
unsigned char season_;
+ QString databaseDriver_;
QString databaseName_;
QString databaseUsername_;
***************
*** 158,165 ****
QString accountsArchiver_;
bool categoryTagAddMenu_;
- QString saveModule_;
- QString loadModule_;
- QString savePath_;
- QString savePrefix_;
double npcMoveTime_;
double tamedNpcMoveTime_;
--- 159,162 ----
***************
*** 171,178 ****
unsigned int animalWildFleeRange_;
- // Remote Admin
- unsigned int ra_port_;
- bool EnableRA_;
-
// Regenerate
unsigned int hitpointrate_;
--- 168,171 ----
***************
*** 350,353 ****
--- 343,347 ----
// Persistency Module
+ QString databaseDriver() const;
QString databaseHost() const;
QString databasePassword() const;
***************
*** 355,362 ****
QString databaseName() const;
- // Remote Admin
- unsigned int ra_port() const;
- bool EnableRA() const;
-
// Regenerate
unsigned int hitpointrate() const;
--- 349,352 ----
***************
*** 422,431 ****
bool enableGame() const;
- // Worldsave
- QString savePath() const;
- QString saveModule() const;
- QString loadModule() const;
- QString savePrefix() const;
-
// Path Finding
int pathfindMaxSteps() const;
--- 412,415 ----
***************
*** 942,955 ****
}
- inline unsigned int cSrvParams::ra_port() const
- {
- return ra_port_;
- }
-
- inline bool cSrvParams::EnableRA() const
- {
- return EnableRA_;
- }
-
inline long int cSrvParams::murderdecay() const
{
--- 926,929 ----
***************
*** 1092,1095 ****
--- 1066,1074 ----
}
+ inline QString cSrvParams::databaseDriver() const
+ {
+ return databaseDriver_;
+ }
+
inline QString cSrvParams::databaseHost() const
{
***************
*** 1140,1163 ****
{
return categoryTagAddMenu_;
- }
-
- inline QString cSrvParams::saveModule() const
- {
- return saveModule_;
- }
-
- inline QString cSrvParams::loadModule() const
- {
- return loadModule_;
- }
-
- inline QString cSrvParams::savePrefix() const
- {
- return savePrefix_;
- }
-
- inline QString cSrvParams::savePath() const
- {
- return savePath_;
}
--- 1119,1122 ----
Index: uobject.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/uobject.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** uobject.h 22 Aug 2003 16:57:09 -0000 1.71
--- uobject.h 26 Aug 2003 15:01:05 -0000 1.72
***************
*** 57,66 ****
class cItem;
- namespace FlatStore
- {
- class OutputFile;
- class InputFile;
- };
-
struct stError;
--- 57,60 ----
***************
*** 110,116 ****
void save();
bool del();
- virtual void save( FlatStore::OutputFile*, bool first = false ) throw();
- virtual bool load( unsigned char chunkGroup, unsigned char chunkType, FlatStore::InputFile* ) throw();
- virtual bool postload() throw();
QString eventList( void ) const; // Returns the list of events
--- 104,107 ----
Index: wolf.dsp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolf.dsp,v
retrieving revision 1.204
retrieving revision 1.205
diff -C2 -d -r1.204 -r1.205
*** wolf.dsp 23 Aug 2003 01:03:31 -0000 1.204
--- wolf.dsp 26 Aug 2003 15:01:06 -0000 1.205
***************
*** 1,23 ****
# Microsoft Developer Studio Project File - Name="wolf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
! # **...
[truncated message content] |