Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv28299
Modified Files:
ai.h basechar.h combat.cpp definable.cpp npc.cpp npc.h
srvparams.cpp srvparams.h uobject.cpp wolf.dsp wolfpack.cpp
wpdefmanager.cpp wpdefmanager.h
Added Files:
ai_humans.cpp
Removed Files:
ai_vendors.cpp
Log Message:
introducing guard ai,
fixes performance issues with definition lists
--- NEW FILE: ai_humans.cpp ---
//==================================================================================
//
// Wolfpack Emu (WP)
// UO Server Emulation Program
//
// Copyright 2001-2003 by holders identified in authors.txt
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Palace - Suite 330, Boston, MA 02111-1307, USA.
//
// * In addition to that license, if you are running this program or modified
// * versions of it on a public system you HAVE TO make the complete source of
// * the version used by you available or provide people with a location to
// * download it.
//
//
//
// Wolfpack Homepage: http://wpdev.sf.net/
//==================================================================================
#include "ai.h"
#include "npc.h"
#include "player.h"
#include "network/uosocket.h"
#include "speech.h"
#include "targetrequests.h"
#include "TmpEff.h"
#include "srvparams.h"
#include "globals.h"
#include "sectors.h"
#include "world.h"
#include "basics.h"
// library includes
#include <math.h>
static AbstractAI* productCreator_HV()
{
return new Human_Vendor( NULL );
}
void Human_Vendor::registerInFactory()
{
AIFactory::instance()->registerType("Human_Vendor", productCreator_HV);
}
void Human_Vendor::onSpeechInput( P_PLAYER pTalker, const QString &comm )
{
if( !pTalker->socket() )
return;
if( m_npc->inRange( pTalker, 4 ) && VendorChkName( m_npc, comm ) )
{
if( comm.contains( tr(" BUY") ) )
{
P_ITEM pContA = m_npc->GetItemOnLayer( cBaseChar::BuyRestockContainer );
P_ITEM pContB = m_npc->GetItemOnLayer( cBaseChar::BuyNoRestockContainer );
m_npc->turnTo( pTalker );
if( !pContA && !pContB )
{
m_npc->talk( tr( "Sorry but i have no goods to sell" ) );
return;
}
m_npc->talk( tr( "Take a look at my wares!" ) );
pTalker->socket()->sendBuyWindow( m_npc );
}
else if( comm.contains( tr(" SELL") ) )
{
P_ITEM pContC = m_npc->GetItemOnLayer( cBaseChar::SellContainer );
m_npc->turnTo( pTalker );
if( !pContC )
{
m_npc->talk( tr( "Sorry, I cannot use any of your wares!" ) );
return;
}
m_npc->talk( tr( "This could be of interest!" ) );
pTalker->socket()->sendSellWindow( m_npc, pTalker );
}
}
}
Human_Stablemaster::Human_Stablemaster( P_NPC npc ) : AbstractAI( npc )
{
notorityOverride_ = 1;
m_actions.append( new Action_Wander( npc, this ) );
m_actions.append( new Action_FleeAttacker( npc, this ) );
}
void Human_Stablemaster::init( P_NPC npc )
{
AbstractAI::init( npc );
}
static AbstractAI* productCreator_HS()
{
return new Human_Stablemaster( NULL );
}
void Human_Stablemaster::registerInFactory()
{
AIFactory::instance()->registerType("Human_Stablemaster", productCreator_HS);
}
void Human_Stablemaster::onSpeechInput( P_PLAYER pTalker, const QString &message )
{
if( !pTalker->socket() )
return;
if( m_npc->inRange( pTalker, 4 ) && ( VendorChkName( m_npc, message ) || message.contains( tr("STABLEMASTER") ) ) )
{
if( message.contains( tr(" STABLE") ) )
{
m_npc->talk( tr("Which pet do you want me to stable?") );
pTalker->socket()->attachTarget( new cStableTarget( m_npc ) );
}
else if( message.contains( tr(" RELEASE") ) )
{
int gold = pTalker->CountBankGold() + pTalker->CountGold();
P_ITEM pPack = m_npc->getBackpack();
cItem::ContainerContent stableitems;
if( pPack )
{
cItem::ContainerContent content = pPack->content();
cItem::ContainerContent::const_iterator it( content.begin() );
while( it != content.end() )
{
if( !(*it)->tags().has( "player" ) || !(*it)->tags().has( "pet" ) )
continue;
if( (*it) && (*it)->id() == 0x1ea7 && (*it)->tags().get( "player" ).asInt() == pTalker->serial() )
stableitems.push_back( (*it) );
++it;
}
}
if( !stableitems.empty() )
{
cItem::ContainerContent::const_iterator it( stableitems.begin() );
while( it != stableitems.end() )
{
if( (*it) )
{
P_NPC pPet = dynamic_cast<P_NPC>(World::instance()->findChar( (*it)->tags().get( "pet" ).asInt() ));
if( pPet )
{
pPet->free = false;
pPet->moveTo( m_npc->pos() );
pPet->resend();
}
(*it)->remove();
}
++it;
}
pPack->update();
m_npc->talk( tr("Here's your pet back!") );
}
}
}
}
void Human_Stablemaster::refreshStock()
{
}
void Human_Stablemaster::handleTargetInput( P_PLAYER player, cUORxTarget *target )
{
if( !player )
return;
P_ITEM pPack = m_npc->getBackpack();
if( !pPack )
return;
P_NPC pPet = dynamic_cast< P_NPC >(World::instance()->findChar( target->serial() ));
if( !pPet )
{
m_npc->talk( tr("I cannot stable that!" ) );
return;
}
if( pPet->owner() != player )
{
m_npc->talk( tr("This does not belong to you!" ) );
return;
}
// we spawn a worldgem in the stablemasters backpack for the pet
// it does only hold the serial of it, the serial of the owner and the
// number of refresh signals since begin of stabling
// the pet becomes "free", which means, that it isnt in the world
// but will still be saved.
P_ITEM pGem = new cItem();
pGem->Init( false );
pGem->tags().set( "player", cVariant( player->serial() ) );
pGem->tags().set( "pet", cVariant( pPet->serial() ) );
pGem->setId( 0x1ea7 );
pGem->setName( tr("petitem: %1").arg(pPet->name()) );
pGem->setVisible( 2 ); // gm visible
pPack->addItem( pGem );
pGem->update();
pPet->free = true;
MapObjects::instance()->remove( pPet );
pPet->removeFromView();
m_npc->talk( tr("Say release to get your pet back!") );
}
static AbstractAI* productCreator_HG()
{
return new Human_Guard( NULL );
}
void Human_Guard::registerInFactory()
{
AIFactory::instance()->registerType("Human_Guard", productCreator_HG);
}
Human_Guard::Human_Guard( P_NPC npc ) : AbstractAI( npc )
{
notorityOverride_ = 1;
m_actions.append( new Human_Guard_Fight( npc, this ) );
m_actions.append( new Human_Guard_TeleToTarget( npc, this ) );
m_actions.append( new Human_Guard_Disappear( npc, this ) );
}
void Human_Guard::init( P_NPC npc )
{
npc->setSummonTime( uiCurrentTime + MY_CLOCKS_PER_SEC * SrvParams->guardDispelTime() );
AbstractAI::init( npc );
}
void Human_Guard_Fight::execute()
{
// talk only in about every 10th check
switch( RandomNum( 0, 20 ) )
{
case 0: m_npc->talk( tr( "Thou shalt regret thine actions, swine!" ), -1, 0, true ); break;
case 1: m_npc->talk( tr( "Death to all Evil!" ), -1, 0, true ); break;
}
m_npc->setSummonTime( uiCurrentTime + MY_CLOCKS_PER_SEC * SrvParams->guardDispelTime() );
// Fighting is handled within combat..
}
float Human_Guard_Fight::preCondition()
{
if( m_npc->combatTarget() == INVALID_SERIAL )
return 0.0f;
P_CHAR pTarget = World::instance()->findChar( m_npc->combatTarget() );
if( !pTarget || pTarget->isDead() )
return 0.0f;
if( pTarget && m_npc->dist( pTarget ) < 2 )
return 1.0f;
else
return 0.0f;
}
float Human_Guard_Fight::postCondition()
{
return 1.0f - preCondition();
}
void Human_Guard_TeleToTarget::execute()
{
m_npc->setSummonTime( uiCurrentTime + MY_CLOCKS_PER_SEC * SrvParams->guardDispelTime() );
// Teleports the guard towards the target
P_CHAR pTarget = World::instance()->findChar( m_npc->combatTarget() );
if( pTarget )
{
m_npc->moveTo( pTarget->pos() );
m_npc->soundEffect( 0x1FE );
m_npc->effect( 0x372A, 0x09, 0x06 );
m_npc->resend( false );
}
}
float Human_Guard_TeleToTarget::preCondition()
{
if( m_npc->combatTarget() == INVALID_SERIAL )
return 0.0f;
P_CHAR pTarget = World::instance()->findChar( m_npc->combatTarget() );
if( !pTarget || pTarget->isDead() )
return 0.0f;
if( pTarget && m_npc->dist( pTarget ) >= 2 )
return 1.0f;
else
return 0.0f;
}
float Human_Guard_TeleToTarget::postCondition()
{
return 1.0f - preCondition();
}
void Human_Guard_Disappear::execute()
{
// nothing to do
}
float Human_Guard_Disappear::preCondition()
{
if( m_npc->combatTarget() == INVALID_SERIAL )
return 1.0f;
P_CHAR pTarget = World::instance()->findChar( m_npc->combatTarget() );
if( !pTarget || pTarget->isDead() )
return 1.0f;
return 0.0f;
}
float Human_Guard_Disappear::postCondition()
{
// not really needed in this case, but necessary for the system ;)
return 1.0f - preCondition();
}
Index: ai.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** ai.h 13 Sep 2003 13:37:15 -0000 1.18
--- ai.h 20 Sep 2003 12:01:43 -0000 1.19
***************
*** 263,267 ****
{
protected:
! Monster_Aggressive_L1() : Monster_Aggressive(){}
public:
--- 263,267 ----
{
protected:
! Monster_Aggressive_L1() : Monster_Aggressive() {}
public:
***************
*** 342,345 ****
--- 342,347 ----
public:
+ AnimalAI( P_NPC npc ) : AbstractAI( npc ) {}
+
virtual void onSpeechInput( P_PLAYER pTalker, const QString &comm );
};
***************
*** 351,355 ****
public:
! Animal_Wild( P_NPC npc )
{
m_actions.append( new Action_Wander( npc, this ) );
--- 353,357 ----
public:
! Animal_Wild( P_NPC npc ) : AnimalAI( npc )
{
m_actions.append( new Action_Wander( npc, this ) );
***************
*** 369,373 ****
public:
! Animal_Domestic( P_NPC npc )
{
m_actions.append( new Action_Wander( npc, this ) );
--- 371,375 ----
public:
! Animal_Domestic( P_NPC npc ) : AnimalAI( npc )
{
m_actions.append( new Action_Wander( npc, this ) );
***************
*** 423,426 ****
--- 425,477 ----
QString m_name;
QString onspeech;
+ };
+
+ class Human_Guard_Fight : public AbstractAction
+ {
+ protected:
+ Human_Guard_Fight() : AbstractAction() {}
+ public:
+ Human_Guard_Fight( P_NPC npc, AbstractAI* ai ) : AbstractAction( npc, ai ) {}
+ virtual void execute();
+ virtual float preCondition();
+ virtual float postCondition();
+ };
+
+ class Human_Guard_TeleToTarget : public AbstractAction
+ {
+ protected:
+ Human_Guard_TeleToTarget() : AbstractAction() {}
+ public:
+ Human_Guard_TeleToTarget( P_NPC npc, AbstractAI* ai ) : AbstractAction( npc, ai ) {}
+ virtual void execute();
+ virtual float preCondition();
+ virtual float postCondition();
+ };
+
+ class Human_Guard_Disappear : public AbstractAction
+ {
+ protected:
+ Human_Guard_Disappear() : AbstractAction() {}
+ public:
+ Human_Guard_Disappear( P_NPC npc, AbstractAI* ai ) : AbstractAction( npc, ai ) {}
+ virtual void execute();
+ virtual float preCondition();
+ virtual float postCondition();
+ };
+
+ class Human_Guard : public AbstractAI
+ {
+ protected:
+ Human_Guard() : AbstractAI()
+ {
+ notorityOverride_ = 1;
+ }
+
+ public:
+ Human_Guard( P_NPC npc );
+ virtual void init( P_NPC npc );
+
+ static void registerInFactory();
+ virtual QString name() { return "Human_Guard"; }
};
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** basechar.h 16 Sep 2003 18:15:24 -0000 1.36
--- basechar.h 20 Sep 2003 12:01:43 -0000 1.37
***************
*** 129,133 ****
bool isMurderer() const;
bool isCriminal() const;
! bool isInnocent() const;
void unhide();
int CountItems(short ID, short col= -1);
--- 129,133 ----
bool isMurderer() const;
bool isCriminal() const;
! virtual bool isInnocent();
void unhide();
int CountItems(short ID, short col= -1);
***************
*** 1316,1320 ****
}
! inline bool cBaseChar::isInnocent() const
{
return !isMurderer() && !isCriminal();
--- 1316,1320 ----
}
! inline bool cBaseChar::isInnocent()
{
return !isMurderer() && !isCriminal();
Index: combat.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/combat.cpp,v
retrieving revision 1.154
retrieving revision 1.155
diff -C2 -d -r1.154 -r1.155
*** combat.cpp 19 Sep 2003 22:02:41 -0000 1.154
--- combat.cpp 20 Sep 2003 12:01:43 -0000 1.155
***************
*** 950,967 ****
if( pDefender->isDead() ) // Highlight // Repsys
{
- #pragma message("reimplement with new npc ai sys")
- /* if( ( pAttacker->npcaitype() == 4 || pAttacker->npcaitype() == 9 ) && pDefender->isNpc() )
- {
- pDefender->action( 0x15 );
- pDefender->playDeathSound();
- cCharStuff::DeleteChar( pDefender ); // Guards, don't give body
- }
- else
- {
-
- pAttacker->setSwingTarget( -1 );
- }
- */
-
// murder count \/
if( ( pAttacker->objectType() == enPlayer ) && ( pDefender->objectType() == enPlayer ) ) //Player vs Player
--- 950,953 ----
***************
*** 1289,1293 ****
pGuard->toggleCombat();
pGuard->setNextMoveTime();
- pGuard->setSummonTime( ( uiCurrentTime + (MY_CLOCKS_PER_SEC*25) ) );
pGuard->soundEffect( 0x1FE );
--- 1275,1278 ----
***************
*** 1296,1306 ****
// Send guard to surrounding Players
pGuard->resend( false );
-
- // 50% talk chance
- switch( RandomNum( 0, 4 ) )
- {
- case 0: pGuard->talk( tr( "Thou shalt regret thine actions, swine!" ), -1, 0, true ); break;
- case 1: pGuard->talk( tr( "Death to all Evil!" ), -1, 0, true ); break;
- }
}
}
--- 1281,1284 ----
Index: definable.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/definable.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** definable.cpp 11 Sep 2003 16:19:50 -0000 1.14
--- definable.cpp 20 Sep 2003 12:01:43 -0000 1.15
***************
*** 35,38 ****
--- 35,40 ----
#include "basics.h"
+ //#include "console.h"
+
// Qt Includes
#include <qdom.h>
***************
*** 41,44 ****
--- 43,48 ----
void cDefinable::applyDefinition( const cElement* sectionNode )
{
+ //unsigned int starttime = getNormalizedTime();
+
if( sectionNode->hasAttribute( "inherit" ) )
{
***************
*** 74,77 ****
--- 78,85 ----
for( unsigned int i = 0; i < sectionNode->childCount(); ++i )
processNode( sectionNode->getChild( i ) );
+
+ //unsigned int endtime = getNormalizedTime();
+
+ //Console::instance()->send( QString( "applyDefinition took %1 ms\n" ).arg( (float)(endtime - starttime) / MY_CLOCKS_PER_SEC * 1000.0f ) );
}
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** npc.cpp 14 Sep 2003 16:31:48 -0000 1.45
--- npc.cpp 20 Sep 2003 12:01:43 -0000 1.46
***************
*** 372,375 ****
--- 372,378 ----
return ai_->notorityOverride();
+ if( !pChar )
+ return 3;
+
if( pChar->kills() > SrvParams->maxkills() )
result = 0x06; // 6 = Red -> Murderer
Index: npc.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** npc.h 5 Sep 2003 00:03:45 -0000 1.24
--- npc.h 20 Sep 2003 12:01:43 -0000 1.25
***************
*** 93,97 ****
virtual void resend( bool clean = true, bool excludeself = false );
virtual void talk( const QString &message, UI16 color = 0xFFFF, UINT8 type = 0, bool autospam = false, cUOSocket* socket = NULL );
! virtual UINT8 notority( P_CHAR pChar );
virtual void kill();
virtual void showName( cUOSocket *socket );
--- 93,97 ----
virtual void resend( bool clean = true, bool excludeself = false );
virtual void talk( const QString &message, UI16 color = 0xFFFF, UINT8 type = 0, bool autospam = false, cUOSocket* socket = NULL );
! virtual UINT8 notority( P_CHAR pChar = NULL );
virtual void kill();
virtual void showName( cUOSocket *socket );
***************
*** 106,109 ****
--- 106,110 ----
void awardFame( short amount );
void awardKarma( P_CHAR pKilled, short amount );
+ virtual bool isInnocent();
// other public methods
***************
*** 590,593 ****
--- 591,598 ----
}
+ inline bool cNPC::isInnocent()
+ {
+ return notority() != 1;
+ }
#endif /* CNPC_H_HEADER_INCLUDED */
Index: srvparams.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** srvparams.cpp 19 Sep 2003 20:41:08 -0000 1.90
--- srvparams.cpp 20 Sep 2003 12:01:43 -0000 1.91
***************
*** 109,112 ****
--- 109,113 ----
checkAITime_ = getDouble( "AI", "Default AI Check Time", 1.2, true );
animalWildFleeRange_ = getNumber( "AI", "Wild animals flee range", 8, true );
+ guardDispelTime_ = getNumber( "AI", "Guard dispel time (sec)", 25, true );
// Persistency
Index: srvparams.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** srvparams.h 19 Sep 2003 20:41:08 -0000 1.58
--- srvparams.h 20 Sep 2003 12:01:44 -0000 1.59
***************
*** 130,133 ****
--- 130,134 ----
float checkAITime_;
unsigned int animalWildFleeRange_;
+ unsigned int guardDispelTime_;
// Regenerate
***************
*** 287,290 ****
--- 288,294 ----
int pathfindFleeRadius() const;
+ // AI
+ unsigned int guardDispelTime() const;
+
private:
void setDefaultStartLocation();
***************
*** 698,701 ****
--- 702,710 ----
{
return pathfindMaxIterations_;
+ }
+
+ inline unsigned int cSrvParams::guardDispelTime() const
+ {
+ return guardDispelTime_;
}
Index: uobject.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/uobject.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -C2 -d -r1.114 -r1.115
*** uobject.cpp 12 Sep 2003 22:11:47 -0000 1.114
--- uobject.cpp 20 Sep 2003 12:01:44 -0000 1.115
***************
*** 439,444 ****
QString Value = Tag->getValue();
//<direction>SE</direction>
! if( TagName == "direction" )
{
if( Value == "NE" )
--- 439,449 ----
QString Value = Tag->getValue();
+ if( TagName == "name" )
+ {
+ name_ = Value;
+ }
+
//<direction>SE</direction>
! else if( TagName == "direction" )
{
if( Value == "NE" )
Index: wolf.dsp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolf.dsp,v
retrieving revision 1.236
retrieving revision 1.237
diff -C2 -d -r1.236 -r1.237
*** wolf.dsp 20 Sep 2003 01:05:10 -0000 1.236
--- wolf.dsp 20 Sep 2003 12:01:44 -0000 1.237
***************
*** 1,23 ****
# Microsoft Developer Studio Project File - Name="wolf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
! # ** NICHT BEARBEITEN **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=wolf - Win32 Debug
! !MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
! !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak".
!MESSAGE
! !MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
! !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak" CFG="wolf - Win32 Debug"
!MESSAGE
! !MESSAGE Für die Konfiguration stehen zur Auswahl:
!MESSAGE
! !MESSAGE "wolf - Win32 Release" (basierend auf "Win32 (x86) Console Application")
! !MESSAGE "wolf - Win32 Debug" (basierend auf "Win32 (x86) Console Application")
!MESSAGE
--- 1,23 ----
# Microsoft Developer Studio Project File - Name="wolf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
! # ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=wolf - Win32 Debug
! !MESSAGE This is not a valid makefile. To build this project using NMAKE,
! !MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak".
!MESSAGE
! !MESSAGE You can specify a configuration when running NMAKE
! !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak" CFG="wolf - Win32 Debug"
!MESSAGE
! !MESSAGE Possible choices for configuration are:
!MESSAGE
! !MESSAGE "wolf - Win32 Release" (based on "Win32 (x86) Console Application")
! !MESSAGE "wolf - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
***************
*** 64,68 ****
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
! # PROP Output_Dir "C:\wolfpack\"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
--- 64,68 ----
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
! # PROP Output_Dir "C:\Software Engineering\wolfpack\"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
***************
*** 77,81 ****
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
! # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt312.lib kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt312.lib shell32.lib /nologo /version:12.9 /subsystem:windows /map /debug /machine:I386 /out:"C:\wolfpack\wolfpack.exe" /pdbtype:sept /libpath:"lib\bugreport\lib" /libpath:"flatstore\Debug"
# SUBTRACT LINK32 /pdb:none
--- 77,81 ----
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
! # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt320.lib kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt320.lib shell32.lib /nologo /version:12.9 /subsystem:windows /map /debug /machine:I386 /out:"C:\Software Engineering\wolfpack\wolfpack.exe" /pdbtype:sept /libpath:"lib\bugreport\lib" /libpath:"flatstore\Debug"
# SUBTRACT LINK32 /pdb:none
***************
*** 103,111 ****
# Begin Source File
! SOURCE=.\ai_monsters.cpp
# End Source File
# Begin Source File
! SOURCE=.\ai_vendors.cpp
# End Source File
# Begin Source File
--- 103,111 ----
# Begin Source File
! SOURCE=.\ai_humans.cpp
# End Source File
# Begin Source File
! SOURCE=.\ai_monsters.cpp
# End Source File
# Begin Source File
Index: wolfpack.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.cpp,v
retrieving revision 1.468
retrieving revision 1.469
diff -C2 -d -r1.468 -r1.469
*** wolfpack.cpp 17 Sep 2003 19:15:34 -0000 1.468
--- wolfpack.cpp 20 Sep 2003 12:01:44 -0000 1.469
***************
*** 470,473 ****
--- 470,474 ----
Human_Vendor::registerInFactory();
Human_Stablemaster::registerInFactory();
+ Human_Guard::registerInFactory();
Animal_Wild::registerInFactory();
Animal_Domestic::registerInFactory();
***************
*** 538,543 ****
default: niceLevel.wait(10); break;
}
-
- uiCurrentTime = getNormalizedTime();
// Python threading - end
--- 539,542 ----
Index: wpdefmanager.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpdefmanager.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** wpdefmanager.cpp 13 Sep 2003 13:08:41 -0000 1.66
--- wpdefmanager.cpp 20 Sep 2003 12:01:44 -0000 1.67
***************
*** 268,271 ****
--- 268,273 ----
BaseDefManager::instance()->unload();
+
+ listcache_.clear();
}
***************
*** 293,296 ****
--- 295,337 ----
Console::instance()->ProgressDone();
+ // create a list cache, because reading all the lists on the fly
+ // means wasting time
+ QMap< QString, cElement* >::iterator it = impl->unique[ WPDT_LIST ].begin();
+
+ while( it != impl->unique[ WPDT_LIST ].end() )
+ {
+ cElement *DefSection = it.data();
+
+ QStringList list;
+ QString data;
+ for( unsigned int i = 0; i < DefSection->childCount(); ++i )
+ {
+ const cElement *childTag = DefSection->getChild( i );
+
+ // Using the nodename is a very very bad habit
+ // if the name of the node is "item" then
+ // use the node value instead
+
+ if( childTag->name() == "item" )
+ data = childTag->text();
+ else
+ data = childTag->name();
+
+ int mult = childTag->getAttribute( "mult" ).toInt();
+ if( mult <= 0 )
+ mult = 1;
+ int i = 0;
+ while( i < mult )
+ {
+ list.push_back( data );
+ ++i;
+ }
+ }
+
+ listcache_.insert( it.key(), list );
+
+ ++it;
+ }
+
Commands::instance()->loadACLs();
BaseDefManager::instance()->load();
***************
*** 314,358 ****
}
! QString WPDefManager::getRandomListEntry( const QString& ListSection ) const
{
! QStringList list = this->getList( ListSection );
! if( list.isEmpty() )
return QString();
else
! return list[ RandomNum( 0, list.size()-1 ) ];
}
! QStringList WPDefManager::getList( const QString& ListSection ) const
{
- const cElement* DefSection = getDefinition( WPDT_LIST, ListSection );
QStringList list;
- QString data;
-
- if( !DefSection )
- return list;
! for( unsigned int i = 0; i < DefSection->childCount(); ++i )
! {
! const cElement *childTag = DefSection->getChild( i );
!
! // Using the nodename is a very very bad habit
! // if the name of the node is "item" then
! // use the node value instead
!
! if( childTag->name() == "item" )
! data = childTag->text();
! else
! data = childTag->name();
!
! int mult = childTag->getAttribute( "mult" ).toInt();
! if( mult <= 0 )
! mult = 1;
! int i = 0;
! while( i < mult )
! {
! list.push_back( data );
! ++i;
! }
! }
return list;
--- 355,379 ----
}
! QString WPDefManager::getRandomListEntry( const QString& ListSection )
{
! QStringList *list = NULL;
!
! QMap< QString, QStringList >::iterator it = listcache_.find( ListSection );
! if( it != listcache_.end() )
! list = &(it.data());
!
! if( !list || list->isEmpty() )
return QString();
else
! return (*list)[ RandomNum( 0, list->size()-1 ) ];
}
! QStringList WPDefManager::getList( const QString& ListSection )
{
QStringList list;
! QMap< QString, QStringList >::iterator it = listcache_.find( ListSection );
! if( it != listcache_.end() )
! list = it.data();
return list;
Index: wpdefmanager.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpdefmanager.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** wpdefmanager.h 2 Sep 2003 02:06:34 -0000 1.31
--- wpdefmanager.h 20 Sep 2003 12:01:44 -0000 1.32
***************
*** 145,151 ****
//const QDomElement* getSection( eDefCategory Type, const QString& Section ) const;
QStringList getSections( eDefCategory Type ) const;
! QString getRandomListEntry( const QString& ListSection ) const;
! QStringList getList( const QString& ListSection ) const;
QString getText( const QString& TextSection ) const;
};
--- 145,154 ----
//const QDomElement* getSection( eDefCategory Type, const QString& Section ) const;
QStringList getSections( eDefCategory Type ) const;
! QString getRandomListEntry( const QString& ListSection );
! QStringList getList( const QString& ListSection );
QString getText( const QString& TextSection ) const;
+
+ protected:
+ QMap< QString, QStringList > listcache_;
};
--- ai_vendors.cpp DELETED ---
|