Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9823
Modified Files:
basechar.cpp basics.cpp basics.h items.cpp spawnregions.cpp
world.cpp
Log Message:
hopefully fixes some errors related to duplicate save items.
Index: basics.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basics.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** basics.h 2 Oct 2004 22:15:49 -0000 1.37
--- basics.h 12 Oct 2004 23:59:28 -0000 1.38
***************
*** 144,147 ****
--- 144,148 ----
private:
class cBufferedReaderPrivate *d;
+ QString error_;
public:
***************
*** 167,170 ****
--- 168,183 ----
unsigned int objectCount();
+
+ inline void setError(const QString &error) {
+ error_ = error;
+ }
+
+ inline bool hasError() {
+ return !error_.isNull();
+ }
+
+ inline const QString &error() {
+ return error_;
+ }
};
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -C2 -d -r1.160 -r1.161
*** basechar.cpp 9 Oct 2004 14:28:58 -0000 1.160
--- basechar.cpp 12 Oct 2004 23:59:27 -0000 1.161
***************
*** 1058,1063 ****
{
// This is not allowed
! if ( ser == INVALID_SERIAL )
return;
if ( this->serial() != INVALID_SERIAL )
--- 1058,1070 ----
{
// This is not allowed
! if ( ser == INVALID_SERIAL || ser == serial_ )
! return;
!
! // is the new serial already occupied?
! P_CHAR other = World::instance()->findChar(ser);
! if (other && other != this) {
! Console::instance()->log(LOG_ERROR, tr("Trying to change the serial of char 0x%1 to the already occupied serial 0x%2.\n").arg(serial_, 0, 16).arg(ser, 0, 16));
return;
+ }
if ( this->serial() != INVALID_SERIAL )
***************
*** 3535,3538 ****
--- 3542,3546 ----
pItem->remove();
}
+ content_.clear(); // Clear the content
if ( multi_ )
Index: world.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/world.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -d -r1.134 -r1.135
*** world.cpp 9 Oct 2004 14:29:00 -0000 1.134
--- world.cpp 12 Oct 2004 23:59:28 -0000 1.135
***************
*** 451,455 ****
try {
object->load( reader );
! objects.append(object);
} catch (wpException& e) {
Console::instance()->log( LOG_WARNING, e.error() + "\n" );
--- 451,486 ----
try {
object->load( reader );
!
! if (reader.hasError()) {
! Console::instance()->log(LOG_ERROR, reader.error());
! reader.setError(QString::null);
!
! cUObject *obj = dynamic_cast<cUObject*>(object);
! if (obj) {
! obj->setSpawnregion(0);
! SectorMaps::instance()->remove(obj);
! unregisterObject(obj);
!
! if (obj->multi()) {
! obj->multi()->removeObject(obj);
! obj->setMulti(0);
! }
! }
!
! P_ITEM item = dynamic_cast<P_ITEM>(object);
! if (item) {
! item->removeFromCont();
! item->setOwner(0);
! }
!
! P_NPC npc = dynamic_cast<P_NPC>(object);
! if (npc) {
! npc->setOwner(0);
! npc->setAI(0);
! }
! delete object;
! } else {
! objects.append(object);
! }
} catch (wpException& e) {
Console::instance()->log( LOG_WARNING, e.error() + "\n" );
***************
*** 1187,1192 ****
_itemCount--;
if ( _lastItemSerial == serial )
! _lastItemSerial--;
}
else if ( isCharSerial( serial ) )
--- 1218,1225 ----
_itemCount--;
+ /*
+ This isn't good...
if ( _lastItemSerial == serial )
! _lastItemSerial--;*/
}
else if ( isCharSerial( serial ) )
***************
*** 1213,1218 ****
_charCount--;
if ( _lastCharSerial == serial )
! _lastCharSerial--;
}
else
--- 1246,1253 ----
_charCount--;
+ /*
+ This sometimes kills stuff...
if ( _lastCharSerial == serial )
! _lastCharSerial--;*/
}
else
Index: basics.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basics.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** basics.cpp 2 Oct 2004 22:15:49 -0000 1.41
--- basics.cpp 12 Oct 2004 23:59:28 -0000 1.42
***************
*** 354,357 ****
--- 354,358 ----
cBufferedReader::cBufferedReader( const QCString& magic, unsigned int version )
{
+ error_ = QString::null;
d = new cBufferedReaderPrivate;
d->buffer.resize( 4096 );
Index: items.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v
retrieving revision 1.453
retrieving revision 1.454
diff -C2 -d -r1.453 -r1.454
*** items.cpp 9 Oct 2004 14:28:59 -0000 1.453
--- items.cpp 12 Oct 2004 23:59:28 -0000 1.454
***************
*** 348,351 ****
--- 348,355 ----
void cItem::save( cBufferedWriter& writer, unsigned int version )
{
+ if (free || (container_ && container_->free)) {
+ Console::instance()->log(LOG_ERROR, tr("Saving item 0x%1 although it's already freed.\n").arg(serial_, 0, 16));
+ }
+
cUObject::save( writer, version );
***************
*** 375,379 ****
color_ = reader.readShort();
// Here we assume that containers are always before us in the save
! cUObject* container = World::instance()->findObject( reader.readInt() );
layer_ = reader.readByte();
amount_ = reader.readShort();
--- 379,384 ----
color_ = reader.readShort();
// Here we assume that containers are always before us in the save
! SERIAL containerSerial = reader.readInt();
! cUObject* container = World::instance()->findObject( containerSerial );
layer_ = reader.readByte();
amount_ = reader.readShort();
***************
*** 393,397 ****
if ( iContainer )
{
! iContainer->addItem( this, false, true, true );
}
else
--- 398,402 ----
if ( iContainer )
{
! iContainer->addItem( this, false, true, false );
}
else
***************
*** 403,406 ****
--- 408,415 ----
}
}
+ } else {
+ if (containerSerial != INVALID_SERIAL) { // Indicate an error
+ reader.setError(tr("Deleting item 0x%1 because of invalid container 0x%2.\n").arg(serial_, 0, 16).arg(containerSerial, 0, 16));
+ }
}
}
***************
*** 480,485 ****
void cItem::setSerial( const SERIAL ser )
{
! if ( ser == INVALID_SERIAL )
return;
if ( serial() != INVALID_SERIAL )
--- 489,501 ----
void cItem::setSerial( const SERIAL ser )
{
! if ( ser == INVALID_SERIAL || ser == serial_ )
! return;
!
! // is the new serial already occupied?
! P_ITEM other = World::instance()->findItem(ser);
! if (other && other != this) {
! Console::instance()->log(LOG_ERROR, tr("Trying to change the serial of item 0x%1 to the already occupied serial 0x%2.\n").arg(serial_, 0, 16).arg(ser, 0, 16));
return;
+ }
if ( serial() != INVALID_SERIAL )
***************
*** 1083,1087 ****
if ( item )
! item->addItem( nItem, false, true, true );
}
}
--- 1099,1103 ----
if ( item )
! item->addItem( nItem, false, true, false );
}
}
Index: spawnregions.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/spawnregions.cpp,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -d -r1.78 -r1.79
*** spawnregions.cpp 11 Oct 2004 20:27:01 -0000 1.78
--- spawnregions.cpp 12 Oct 2004 23:59:28 -0000 1.79
***************
*** 918,921 ****
--- 918,928 ----
object->setSpawnregion( region );
}
+ } else {
+ cUObject *object;
+ QPtrList<cUObject> &list = it.data();
+ for ( object = list.first(); object; object = list.next() )
+ {
+ object->remove();
+ }
}
}
|