Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2349
Modified Files:
ChangeLog basechar.h basedef.cpp basedef.h serverconfig.cpp
Log Message:
Creature sounds are back!
Index: serverconfig.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/serverconfig.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** serverconfig.cpp 9 Sep 2004 02:07:52 -0000 1.6
--- serverconfig.cpp 9 Sep 2004 05:52:47 -0000 1.7
***************
*** 31,34 ****
--- 31,35 ----
#include "preferences.h"
#include "log.h"
+ #include "basedef.h"
// Library Includes
***************
*** 224,227 ****
--- 225,232 ----
flush(); // if any key created, save it.
+
+ // Reload Body Info
+ CharBaseDefs::instance()->loadBodyInfo();
+
cComponent::load();
}
Index: basedef.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basedef.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** basedef.cpp 9 Sep 2004 03:19:58 -0000 1.17
--- basedef.cpp 9 Sep 2004 05:52:47 -0000 1.18
***************
*** 31,36 ****
--- 31,38 ----
#include "definitions.h"
#include "scriptmanager.h"
+ #include "serverconfig.h"
#include "basics.h"
#include <string.h>
+ #include <qdom.h>
void cBaseDef::processNode( const cElement* node ) {
***************
*** 118,122 ****
basesound_ = 0;
soundmode_ = 0;
- flags_ = 0;
figurine_ = 0;
minDamage_ = 0;
--- 120,123 ----
***************
*** 169,184 ****
lootPacks_ = node->text();
}
- else if ( node->name() == "canfly" )
- {
- flags_ |= 0x01;
- }
- else if ( node->name() == "antiblink" )
- {
- flags_ |= 0x02;
- }
- else if ( node->name() == "nocorpse" )
- {
- flags_ |= 0x04;
- }
else
{
--- 170,173 ----
***************
*** 203,207 ****
}
! applyDefinition( element );
}
}
--- 192,196 ----
}
! applyDefinition(element);
}
}
***************
*** 220,223 ****
--- 209,302 ----
}
+ void cCharBaseDefs::loadBodyInfo() {
+ // Null the existing one
+ memset(bodyinfo, 0, sizeof(bodyinfo));
+
+ QString filename = Config::instance()->getString("General", "Bodyinfo File", "definitions/system/bodyinfo.xml", true);
+ QFile file(filename);
+
+ if (!file.open(IO_ReadOnly)) {
+ Console::instance()->log(LOG_WARNING, QString("Unable to load body information from %1.\n").arg(filename));
+ }
+
+ QDomDocument document;
+ document.setContent(&file);
+
+ QDomNode parent = document.namedItem("bodyinfo");
+ if (parent.isElement()) {
+ for (int i = 0; i < parent.childNodes().count(); ++i) {
+ QDomElement element = parent.childNodes().item(i).toElement();
+
+ if (!element.isNull()) {
+ QString id = hex2dec(element.attribute("id"));
+ bool ok = false;
+
+ stBodyInfo bodyinfo;
+
+ // The body id (mandatory)
+ bodyinfo.body = id.toUShort(&ok);
+ if (!ok) {
+ Console::instance()->log(LOG_WARNING, QString("Invalid body id in bodyinfo file: %1.\n").arg(id));
+ continue;
+ }
+
+ // The offset for sounds this creature is using
+ QString basesound = hex2dec(element.attribute("basesound"));
+ if (!basesound.isNull()) {
+ bodyinfo.basesound = basesound.toUShort(&ok);
+ if (!ok) {
+ Console::instance()->log(LOG_WARNING, QString("Invalid basesound in bodyinfo file: %1.\n").arg(basesound));
+ continue;
+ }
+ } else {
+ bodyinfo.basesound = 0;
+ }
+
+ // Load the figurine for shrinking (this is just a display id)
+ QString figurine = hex2dec(element.attribute("figurine"));
+ if (!figurine.isNull()) {
+ bodyinfo.figurine = figurine.toUShort(&ok);
+ if (!ok) {
+ Console::instance()->log(LOG_WARNING, QString("Invalid figurine in bodyinfo file: %1.\n").arg(figurine));
+ continue;
+ }
+ } else {
+ bodyinfo.figurine = 0;
+ }
+
+ // Soundmode for skipping non existing sounds
+ QString soundmode = hex2dec(element.attribute("soundmode"));
+ if (!soundmode.isNull()) {
+ bodyinfo.soundmode = soundmode.toUShort(&ok);
+ if (!ok) {
+ Console::instance()->log(LOG_WARNING, QString("Invalid soundmode in bodyinfo file: %1.\n").arg(soundmode));
+ continue;
+ }
+ } else {
+ bodyinfo.soundmode = 0;
+ }
+
+ // Flags for this creature (noblink, canfly, nocorpse)
+ QString flags = hex2dec(element.attribute("flags"));
+ if (!flags.isNull()) {
+ bodyinfo.flags = flags.toUShort(&ok);
+ if (!ok) {
+ Console::instance()->log(LOG_WARNING, QString("Invalid flags in bodyinfo file: %1.\n").arg(flags));
+ continue;
+ }
+ } else {
+ bodyinfo.flags = 0;
+ }
+
+ if (bodyinfo.body < 0x400) {
+ this->bodyinfo[bodyinfo.body] = bodyinfo;
+ }
+ }
+ }
+ }
+
+ document.clear();
+ }
+
cCharBaseDefs::cCharBaseDefs()
{
Index: basedef.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basedef.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** basedef.h 9 Sep 2004 03:19:58 -0000 1.15
--- basedef.h 9 Sep 2004 05:52:47 -0000 1.16
***************
*** 115,119 ****
unsigned short basesound_;
unsigned char soundmode_;
- unsigned int flags_;
unsigned char type_;
unsigned short figurine_;
--- 115,118 ----
***************
*** 124,132 ****
QCString lootPacks_;
unsigned char controlSlots_;
! unsigned char criticalHealth_;
// Misc Properties
void load();
! void reset();
public:
cCharBaseDef( const QCString& id );
--- 123,131 ----
QCString lootPacks_;
unsigned char controlSlots_;
! unsigned char criticalHealth_;
// Misc Properties
void load();
! void reset();
public:
cCharBaseDef( const QCString& id );
***************
*** 165,192 ****
}
- inline unsigned int flags()
- {
- load();
- return flags_;
- }
-
- inline bool canFly()
- {
- load();
- return ( flags_ & 0x01 ) != 0;
- }
-
- inline bool antiBlink()
- {
- load();
- return ( flags_ & 0x02 ) != 0;
- }
-
- inline bool noCorpse()
- {
- load();
- return ( flags_ & 0x04 ) != 0;
- }
-
inline unsigned short maxDamage()
{
--- 164,167 ----
***************
*** 220,229 ****
--- 195,216 ----
};
+ struct stBodyInfo {
+ unsigned short body;
+ unsigned short basesound;
+ unsigned short figurine;
+ unsigned char flags;
+ unsigned char soundmode;
+ };
+
class cCharBaseDefs
{
+ friend class cCharBaseDef;
+
protected:
typedef QMap<QCString, cCharBaseDef*> Container;
typedef Container::iterator Iterator;
Container definitions;
+ stBodyInfo bodyinfo[0x400];
+
public:
cCharBaseDefs();
***************
*** 234,240 ****
--- 221,236 ----
cCharBaseDef* get( const QCString& id );
+ inline const stBodyInfo &getBodyInfo(unsigned short body) {
+ if (body < 0x400) {
+ return bodyinfo[body];
+ } else {
+ return bodyinfo[0];
+ }
+ }
+
// When reset is called, all loaded basedefs are unflagged.
void reset();
void refreshScripts();
+ void loadBodyInfo();
};
Index: ChangeLog
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ChangeLog,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** ChangeLog 9 Sep 2004 03:19:58 -0000 1.42
--- ChangeLog 9 Sep 2004 05:52:47 -0000 1.43
***************
*** 44,47 ****
--- 44,48 ----
a basedefinition.
- Moved several methods to a common baseclass for char and item base definitions.
+ - Added support for a separate file to define properties for certain bodies. (Sounds, Flags, Figurines)
Wolfpack 12.9.9 Beta (4. September 2004)
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.83
retrieving revision 1.84
diff -C2 -d -r1.83 -r1.84
*** basechar.h 31 Aug 2004 15:18:25 -0000 1.83
--- basechar.h 9 Sep 2004 05:52:47 -0000 1.84
***************
*** 535,539 ****
inline unsigned short basesound()
{
! return basedef_ ? basedef_->basesound() : 0;
}
--- 535,543 ----
inline unsigned short basesound()
{
! unsigned short result = basedef_ ? basedef_->basesound() : 0;
! if (!result) {
! result = CharBaseDefs::instance()->getBodyInfo(body()).basesound;
! }
! return result;
}
***************
*** 545,554 ****
inline unsigned char soundmode()
{
! return basedef_ ? basedef_->soundmode() : 0;
}
inline unsigned short figurine()
{
! return basedef_ ? basedef_->figurine() : 0;
}
--- 549,566 ----
inline unsigned char soundmode()
{
! unsigned char result = basedef_ ? basedef_->soundmode() : 0;
! if (!result) {
! result = CharBaseDefs::instance()->getBodyInfo(body()).soundmode;
! }
! return result;
}
inline unsigned short figurine()
{
! unsigned short result = basedef_ ? basedef_->figurine() : 0;
! if (!result) {
! result = CharBaseDefs::instance()->getBodyInfo(body()).figurine;
! }
! return result;
}
***************
*** 590,604 ****
inline bool isCanFly()
{
! return basedef_ ? basedef_->canFly() : false;
}
inline bool isAntiBlink()
{
! return basedef_ ? basedef_->antiBlink() : false;
}
inline bool isNoCorpse()
{
! return basedef_ ? basedef_->noCorpse() : false;
}
private:
--- 602,616 ----
inline bool isCanFly()
{
! return (CharBaseDefs::instance()->getBodyInfo(body()).flags & 0x01) != 0;
}
inline bool isAntiBlink()
{
! return (CharBaseDefs::instance()->getBodyInfo(body()).flags & 0x02) != 0;
}
inline bool isNoCorpse()
{
! return (CharBaseDefs::instance()->getBodyInfo(body()).flags & 0x04) != 0;
}
private:
|