Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23770
Modified Files:
ChangeLog player.cpp player.h pythonscript.cpp pythonscript.h
server.cpp world.cpp
Log Message:
update version db script.
Index: player.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** player.h 29 Aug 2004 20:40:50 -0000 1.58
--- player.h 4 Sep 2004 21:20:07 -0000 1.59
***************
*** 146,149 ****
--- 146,150 ----
QString profile() const;
Q_UINT8 fixedLightLevel() const;
+ Q_UINT8 maxControlSlots() const;
// bit flag getters
***************
*** 158,161 ****
--- 159,163 ----
// setters
+ void setMaxControlSlots(unsigned char data);
void setAccount( cAccount* data, bool moveFromAccToAcc = true );
void setAdditionalFlags( Q_UINT32 data );
***************
*** 234,237 ****
--- 236,242 ----
cAccount* account_;
+ // How many pets can this player control
+ unsigned char maxControlSlots_;
+
// time till char will be logged out
// cOldChar::logout_
***************
*** 401,404 ****
--- 406,420 ----
}
+ inline Q_UINT8 cPlayer::maxControlSlots() const
+ {
+ return maxControlSlots_;
+ }
+
+ inline void cPlayer::setMaxControlSlots( Q_UINT8 data )
+ {
+ maxControlSlots_ = data;
+ changed_ = true;
+ }
+
inline bool cPlayer::maySnoop() const
{
Index: server.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/server.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** server.cpp 3 Sep 2004 20:37:43 -0000 1.20
--- server.cpp 4 Sep 2004 21:20:07 -0000 1.21
***************
*** 271,275 ****
// Load all subcomponents
! load();
// Start the QT translator
--- 271,280 ----
// Load all subcomponents
! try {
! load();
! } catch(wpException &e) {
! Console::instance()->log(LOG_ERROR, e.error() + "\n");
! return false;
! }
// Start the QT translator
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.125
retrieving revision 1.126
diff -C2 -d -r1.125 -r1.126
*** player.cpp 31 Aug 2004 14:08:50 -0000 1.125
--- player.cpp 4 Sep 2004 21:19:52 -0000 1.126
***************
*** 70,73 ****
--- 70,74 ----
dexterityLock_ = 0;
intelligenceLock_ = 0;
+ maxControlSlots_ = 5;
}
***************
*** 94,98 ****
fields.push_back( "players.account,players.additionalflags,players.visualrange" );
fields.push_back( "players.profile,players.fixedlight" );
! fields.push_back( "players.strlock,players.dexlock,players.intlock" );
tables.push_back( "players" );
conditions.push_back( "uobjectmap.serial = players.serial" );
--- 95,99 ----
fields.push_back( "players.account,players.additionalflags,players.visualrange" );
fields.push_back( "players.profile,players.fixedlight" );
! fields.push_back( "players.strlock,players.dexlock,players.intlock,players.maxcontrolslots" );
tables.push_back( "players" );
conditions.push_back( "uobjectmap.serial = players.serial" );
***************
*** 120,123 ****
--- 121,127 ----
dexterityLock_ = reader.readByte();
intelligenceLock_ = reader.readByte();
+ if (version > 7) {
+ maxControlSlots_ = reader.readByte();
+ }
}
***************
*** 133,136 ****
--- 137,143 ----
writer.writeByte( dexterityLock_ );
writer.writeByte( intelligenceLock_ );
+ if (version > 7) {
+ writer.writeByte(maxControlSlots_);
+ }
}
***************
*** 147,150 ****
--- 154,158 ----
dexterityLock_ = atoi( result[offset++] );
intelligenceLock_ = atoi( result[offset++] );
+ maxControlSlots_ = atoi( result[offset++] );
playerRegisterAfterLoading( this );
***************
*** 177,180 ****
--- 185,189 ----
addField( "dexlock", dexterityLock_ );
addField( "intlock", intelligenceLock_ );
+ addField( "maxcontrolslots", maxControlSlots_ );
addCondition( "serial", serial() );
***************
*** 902,906 ****
// Only reset the owner if we have slots left
! if ( pets_.size() + pPet->controlSlots() <= 5 )
{
pPet->setOwner( this, true );
--- 911,915 ----
// Only reset the owner if we have slots left
! if ( pets_.size() + pPet->controlSlots() <= maxControlSlots() )
{
pPet->setOwner( this, true );
***************
*** 1101,1108 ****
\property char.logouttime This integer property is used when a player disconnects in an unsafe area.
This property indicates the time when the character will disappear from the world.
! This property is exclusive to player objects.
*/
else
SET_INT_PROPERTY( "logouttime", logoutTime_ )
/*
\property char.lightbonus This is the lightlevel bonus applied for this player.
--- 1110,1125 ----
\property char.logouttime This integer property is used when a player disconnects in an unsafe area.
This property indicates the time when the character will disappear from the world.
! This property is exclusive to players.
*/
else
SET_INT_PROPERTY( "logouttime", logoutTime_ )
+
+ /*
+ \property char.maxcontrolslots This property indicates how many control slots this character has.
+ This property is exclusive to players.
+ */
+ else
+ SET_INT_PROPERTY( "maxcontrolslots", maxControlSlots_ )
+
/*
\property char.lightbonus This is the lightlevel bonus applied for this player.
***************
*** 1222,1225 ****
--- 1239,1243 ----
PY_PROPERTY( "dexteritylock", dexterityLock_ )
PY_PROPERTY( "intelligencelock", intelligenceLock_ )
+ PY_PROPERTY( "maxcontrolslots", maxControlSlots_ )
// Forward the property to the account
Index: ChangeLog
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ChangeLog,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** ChangeLog 4 Sep 2004 19:59:10 -0000 1.27
--- ChangeLog 4 Sep 2004 21:19:52 -0000 1.28
***************
*** 2,5 ****
--- 2,9 ----
Wolfpack 12.9.10 Beta (4. September 2004)
+ - Made the maximum number of controlled pets a dynamic property for players.
+ Name: maxcontrolslots
+ - Implemented the event onUpdateDatabase for database updating.
+ - Exceptions thrown during server startup are now caught correctly.
Wolfpack 12.9.9 Beta (CVS)
Index: pythonscript.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/pythonscript.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** pythonscript.h 27 Aug 2004 14:41:16 -0000 1.39
--- pythonscript.h 4 Sep 2004 21:20:07 -0000 1.40
***************
*** 85,88 ****
--- 85,89 ----
EVENT_CONTEXTCHECKENABLED,
EVENT_SPAWN,
+ EVENT_UPDATEDATABASE,
EVENT_COUNT,
};
Index: world.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/world.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -C2 -d -r1.123 -r1.124
*** world.cpp 4 Sep 2004 15:24:22 -0000 1.123
--- world.cpp 4 Sep 2004 21:20:07 -0000 1.124
***************
*** 44,47 ****
--- 44,49 ----
#include "log.h"
#include "timing.h"
+ #include "scriptmanager.h"
+ #include "pythonscript.h"
#include "basics.h"
#include <sqlite.h>
***************
*** 83,88 ****
//
// ONCE AGAIN, DON'T FORGET TO INCREASE THIS VALUE
! #define DATABASE_VERSION 7
! #define WP_DATABASE_VERSION "7"
// This is used for autocreating the tables
--- 85,90 ----
//
// ONCE AGAIN, DON'T FORGET TO INCREASE THIS VALUE
! #define DATABASE_VERSION 8
! #define WP_DATABASE_VERSION "8"
// This is used for autocreating the tables
***************
*** 229,232 ****
--- 231,235 ----
dexlock tinyint(4) NOT NULL default '0',\
intlock tinyint(4) NOT NULL default '0',\
+ maxcontrolslots tinyint(4) NOT NULL default '5',\
PRIMARY KEY (serial)\
);" },
***************
*** 564,567 ****
--- 567,600 ----
}
+ // Load Options
+ QString settingsSql = "SELECT option,value FROM settings;";
+ if (Config::instance()->databaseDriver() == "mysql") {
+ settingsSql = "SELECT `option`,`value` FROM `settings`;";
+ }
+ cDBResult oresult = PersistentBroker::instance()->query(settingsSql);
+ while (oresult.fetchrow()) {
+ setOption(oresult.getString(0), oresult.getString(1));
+ }
+ oresult.free();
+
+ // Get Database Version (Since Version 7 SQL has it)
+ QString db_version;
+ getOption("db_version", db_version, "7");
+
+ if (db_version.toInt() != DATABASE_VERSION) {
+ cPythonScript *script = ScriptManager::instance()->getGlobalHook(EVENT_UPDATEDATABASE);
+ if (!script || !script->canHandleEvent(EVENT_UPDATEDATABASE)) {
+ throw wpException(QString("Unable to load world database. Version mismatch: %1 != %2.").arg(db_version.toInt()).arg(DATABASE_VERSION));
+ }
+
+ PyObject *args = Py_BuildValue("(ii)", DATABASE_VERSION, db_version.toInt());
+ bool result = script->callEventHandler(EVENT_UPDATEDATABASE, args);
+ Py_DECREF(args);
+
+ if (!result) {
+ throw wpException(QString("Unable to load world database. Version mismatch: %1 != %2.").arg(db_version.toInt()).arg(DATABASE_VERSION));
+ }
+ }
+
QStringList types = PersistentFactory::instance()->objectTypes();
***************
*** 620,630 ****
Timers::instance()->load();
- // Load Options
- cDBResult oresult = PersistentBroker::instance()->query("SELECT option,value FROM settings;");
- while (oresult.fetchrow()) {
- setOption(oresult.getString(0), oresult.getString(1));
- }
- oresult.free();
-
// It's not possible to use cItemIterator during postprocessing because it skips lingering items
ItemMap::iterator iter;
--- 653,656 ----
***************
*** 807,810 ****
--- 833,837 ----
Console::instance()->send( "Saving World..." );
+ setOption("db_version", WP_DATABASE_VERSION); // Make SURE it's saved
// Send a nice status gump to all sockets if enabled
Index: pythonscript.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/pythonscript.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** pythonscript.cpp 27 Aug 2004 14:41:16 -0000 1.47
--- pythonscript.cpp 4 Sep 2004 21:20:07 -0000 1.48
***************
*** 511,514 ****
--- 511,522 ----
"onSpawn",
+ /*
+ \event onUpdateDatabase
+ \param current The current database version.
+ \param version The version of the loaded database.
+ \condition Triggered when the version of the loaded database doesn't match the version the server expects.
+ */
+ "onUpdateDatabase",
+
0
};
|