|
From: <cn...@us...> - 2020-10-25 04:20:20
|
Revision: 1062
http://sourceforge.net/p/seq/svn/1062
Author: cn187
Date: 2020-10-25 04:20:17 +0000 (Sun, 25 Oct 2020)
Log Message:
-----------
Replace Q3IntDict with QHash
Modified Paths:
--------------
showeq/branches/pre_6_0_beta/src/bazaarlog.cpp
showeq/branches/pre_6_0_beta/src/eqstr.cpp
showeq/branches/pre_6_0_beta/src/eqstr.h
showeq/branches/pre_6_0_beta/src/interface.cpp
showeq/branches/pre_6_0_beta/src/interface.h
showeq/branches/pre_6_0_beta/src/map.cpp
showeq/branches/pre_6_0_beta/src/map.h
showeq/branches/pre_6_0_beta/src/packet.cpp
showeq/branches/pre_6_0_beta/src/packetinfo.cpp
showeq/branches/pre_6_0_beta/src/packetinfo.h
showeq/branches/pre_6_0_beta/src/spawnlist.cpp
showeq/branches/pre_6_0_beta/src/spawnlist2.cpp
showeq/branches/pre_6_0_beta/src/spawnshell.cpp
showeq/branches/pre_6_0_beta/src/spawnshell.h
Modified: showeq/branches/pre_6_0_beta/src/bazaarlog.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/bazaarlog.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/bazaarlog.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -64,7 +64,7 @@
char *p;
if ((p = rindex(name,'(')) != NULL && isdigit(*(p+1)))
*p=0;
- Item *merchant = m_shell.spawns().find(resp.player_id);
+ Item *merchant = m_shell.spawns().value(resp.player_id, nullptr);
const char *merchant_name = "unknown";
if (merchant)
merchant_name = merchant->name();
Modified: showeq/branches/pre_6_0_beta/src/eqstr.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/eqstr.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/eqstr.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -34,17 +34,14 @@
#include <Q3ValueVector>
#include <Q3CString>
-EQStr::EQStr(int size)
- : m_messageStrings(size),
+EQStr::EQStr()
+ : m_messageStrings(),
m_loaded(false)
{
- // make sure strings get deleted
- m_messageStrings.setAutoDelete(true);
}
EQStr::~EQStr()
{
- // not really necessary, but just for completeness sake
m_messageStrings.clear();
}
@@ -103,7 +100,7 @@
maxFormatId = formatId;
// insert the format string into the dictionary.
- m_messageStrings.insert(formatId, new QString((*it).mid(spc+1)));
+ m_messageStrings.insert(formatId, QString((*it).mid(spc+1)));
}
// note that strings are loaded
@@ -119,24 +116,19 @@
QString EQStr::find(uint32_t formatid) const
{
// attempt to find the message string
- QString* res = m_messageStrings.find(formatid);
+ QString res = m_messageStrings.value(formatid, QString());
- // if the message string was found, return it
- if (res)
- return *res;
-
- // otherwise return a NULL/Empty QString
- return QString();
+ return res;
}
QString EQStr::message(uint32_t formatid) const
{
// attempt to find the message string
- QString* res = m_messageStrings.find(formatid);
+ QString res = m_messageStrings.value(formatid, QString());
// if the message string was found, return it
- if (res)
- return *res;
+ if (!res.isEmpty())
+ return res;
// otherwise return a fabricated string
return QString("Unknown: ") + QString::number(formatid, 16);
@@ -145,11 +137,11 @@
QString EQStr::formatMessage(uint32_t formatid,
const char* arguments, size_t argsLen) const
{
- QString* formatStringRes = m_messageStrings.find(formatid);
+ QString formatStringRes = m_messageStrings.value(formatid, QString());
QString tempStr;
- if (formatStringRes == NULL)
+ if (formatStringRes.isEmpty())
{
uint32_t arg_len;
unsigned char *cp;
@@ -193,12 +185,12 @@
int curPos;
size_t substArg;
int substArgValue;
- QString* substFormatStringRes;
+ QString substFormatStringRes;
QString substFormatString;
////////////////////////////
// replace template (%T) arguments in formatted string
- QString formatString = *formatStringRes;
+ QString formatString = formatStringRes;
QRegExp rxt("%T(\\d{1,3})", true, false);
// find first template substitution
@@ -206,7 +198,7 @@
while (curPos != -1)
{
- substFormatStringRes = NULL;
+ substFormatStringRes = QString();
substArg = rxt.cap(1).toInt(&ok);
if (ok && (substArg <= argList.size()))
{
@@ -213,12 +205,12 @@
substArgValue = argList[substArg-1].toInt(&ok);
if (ok)
- substFormatStringRes = m_messageStrings.find(substArgValue);
+ substFormatStringRes = m_messageStrings.value(substArgValue, QString());
}
// replace template argument with subst string
- if (substFormatStringRes != NULL)
- formatString.replace(curPos, rxt.matchedLength(), *substFormatStringRes);
+ if (substFormatStringRes.isEmpty())
+ formatString.replace(curPos, rxt.matchedLength(), substFormatStringRes);
else
curPos += rxt.matchedLength(); // if no replacement string, skip over
Modified: showeq/branches/pre_6_0_beta/src/eqstr.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/eqstr.h 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/eqstr.h 2020-10-25 04:20:17 UTC (rev 1062)
@@ -27,7 +27,7 @@
#include <cstdint>
-#include <Q3IntDict>
+#include <QHash>
#include <QString>
//----------------------------------------------------------------------
@@ -35,7 +35,7 @@
class EQStr
{
public:
- EQStr(int size = 8009);
+ EQStr();
~EQStr();
bool load(const QString& eqstrFile);
@@ -45,7 +45,7 @@
const char* arguments, size_t argslen) const;
protected:
- Q3IntDict<QString> m_messageStrings;
+ QHash<int, QString> m_messageStrings;
bool m_loaded;
};
Modified: showeq/branches/pre_6_0_beta/src/interface.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/interface.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/interface.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -262,7 +262,7 @@
m_spells = new Spells(fileInfo.absFilePath());
// Create the EQStr storage
- m_eqStrings = new EQStr(8009); // increase if the number of strings exeeds
+ m_eqStrings = new EQStr();
// Create the Zone Manager
m_zoneMgr = new ZoneMgr(this, "zonemgr");
@@ -4995,12 +4995,17 @@
// iterate over the spawns adding their paths to the file
ItemConstIterator it(m_spawnShell->getConstMap(tSpawn));
const Item* item;
- for (item = it.current(); item != 0; item = ++it)
+ while (it.hasNext())
{
+ it.next();
+ item = it.value();
+ if (!item)
+ break;
+
if ((item->NPC() == SPAWN_NPC) ||
(item->NPC() == SPAWN_NPC_CORPSE) ||
(item->NPC() == SPAWN_NPC_UNKNOWN))
- saveSpawnPath(out, it.current());
+ saveSpawnPath(out, it.value());
}
seqInfo("Finished writing '%s'!\n", (const char*)fileName);
Modified: showeq/branches/pre_6_0_beta/src/interface.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/interface.h 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/interface.h 2020-10-25 04:20:17 UTC (rev 1062)
@@ -41,7 +41,7 @@
#include <QMessageBox>
#include <Q3TabDialog>
#include <QSpinBox>
-#include <Q3IntDict>
+#include <QHash>
#include <Q3PtrDict>
#include <Q3TextStream>
#include "everquest.h"
@@ -436,10 +436,10 @@
QLabel* m_stsbarZEM;
QString ipstr[5];
- QString macstr[5];
-
- Q3IntDict<QString> m_formattedMessageStrings;
+ QString macstr[5];
+ QHash<QString, QString> m_formattedMessageStrings;
+
QAction* m_action_character_Class[PLAYER_CLASSES];
QAction* m_action_character_Race[PLAYER_RACES];
QAction* m_action_log_AllPackets;
Modified: showeq/branches/pre_6_0_beta/src/map.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/map.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/map.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -300,10 +300,10 @@
{
}
-uint16_t MapMgr::spawnAggroRange(const Spawn* spawn)
-{
- uint16_t* range = m_spawnAggroRange.find(spawn->id());
- return (!range) ? 0 : *range;
+uint16_t MapMgr::spawnAggroRange(const Spawn* spawn)
+{
+ uint16_t range = m_spawnAggroRange.value(spawn->id(), 0);
+ return range;
}
void MapMgr::zoneBegin(const QString& shortZoneName)
@@ -458,24 +458,23 @@
// iterate over the exixsting spawns to adjust the map size and find
// ones with aggro information
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
// Adjust X and Y for spawns on map
m_mapData.quickCheckPos(item->x(), item->y());
-
+
if (m_mapData.isAggro(item->transformedName(), &range))
{
// create a range to insert into the dictionary
- uint16_t* newrange = new uint16_t;
-
- // save the range value
- *newrange = range;
-
+
// insert the spawns ID and aggro range into the dictionary.
- m_spawnAggroRange.insert(item->id(), newrange);
+ m_spawnAggroRange.insert(item->id(), range);
}
}
@@ -525,14 +524,8 @@
uint16_t range;
if (m_mapData.isAggro(item->transformedName(), &range))
{
- // create a range to insert into the dictionary
- uint16_t* newrange = new uint16_t;
-
- // save the range value
- *newrange = range;
-
// insert the spawns ID and aggro range into the dictionary.
- m_spawnAggroRange.insert(item->id(), newrange);
+ m_spawnAggroRange.insert(item->id(), range);
}
// signal that the map has changed
@@ -3464,10 +3457,13 @@
p.setPen(Qt::yellow);
/* Paint the dropped items */
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
filterFlags = item->filterFlags();
@@ -3521,10 +3517,13 @@
p.setPen(QColor (110, 60, 0));
/* Paint the door items */
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = (const Door*)it.current();
+ item = (const Door*)it.value();
+ if (!item)
+ break;
filterFlags = item->filterFlags();
@@ -3723,14 +3722,14 @@
/* Paint the spawns */
const Spawn* spawn;
// iterate over all spawns in of the current type
- while (it.current())
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
- // increment iterator to the next spawn
- ++it;
-
#ifdef DEBUGMAP
spawn = spawnType(item);
@@ -4421,11 +4420,14 @@
ItemConstIterator it(itemMap);
// iterate over all spawns in of the current type
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
-
+ item = it.value();
+ if (!item)
+ break;
+
if (m_spawnDepthFilter &&
((item->z() > m_param.playerHeadRoom()) ||
(item->z() < m_param.playerFloorRoom())))
Modified: showeq/branches/pre_6_0_beta/src/map.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/map.h 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/map.h 2020-10-25 04:20:17 UTC (rev 1062)
@@ -39,7 +39,7 @@
#include <QLabel>
#include <QToolTip>
#include <QRegExp>
-#include <Q3IntDict>
+#include <QHash>
#include <Q3TextStream>
#include <QDateTime>
#include <QPen>
@@ -216,8 +216,8 @@
QWidget* m_dialogParent;
CLineDlg *m_dlgLineProps;
MapData m_mapData;
- Q3IntDict<uint16_t> m_spawnAggroRange;
-
+ QHash<int, uint16_t> m_spawnAggroRange;
+
QString m_curLineColor;
QString m_curLineName;
QString m_curLocationColor;
Modified: showeq/branches/pre_6_0_beta/src/packet.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/packet.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/packet.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -126,8 +126,8 @@
m_packetTypeDB->list();
#endif
- // create the world opcode db (with hash size of 29)
- m_worldOPCodeDB = new EQPacketOPCodeDB(29);
+ // create the world opcode db
+ m_worldOPCodeDB = new EQPacketOPCodeDB();
// load the world opcode db
if (!m_worldOPCodeDB->load(*m_packetTypeDB, worldopcodesxml))
@@ -139,9 +139,9 @@
//m_worldOPCodeDB->save("/tmp/worldopcodes.xml");
- // create the zone opcode db (with hash size of 211)
- m_zoneOPCodeDB = new EQPacketOPCodeDB(211);
-
+ // create the zone opcode db
+ m_zoneOPCodeDB = new EQPacketOPCodeDB();
+
// load the zone opcode db
if (!m_zoneOPCodeDB->load(*m_packetTypeDB, zoneopcodesxml))
seqFatal("Error loading '%s'!", (const char*)zoneopcodesxml);
Modified: showeq/branches/pre_6_0_beta/src/packetinfo.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/packetinfo.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/packetinfo.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -274,10 +274,9 @@
//----------------------------------------------------------------------
// EQPacketOPCodeDB
-EQPacketOPCodeDB::EQPacketOPCodeDB(int size)
- : m_opcodes(size)
+EQPacketOPCodeDB::EQPacketOPCodeDB()
+ : m_opcodes()
{
- m_opcodes.setAutoDelete(true);
}
EQPacketOPCodeDB::~EQPacketOPCodeDB()
@@ -344,15 +343,17 @@
OrderedMap orderedOPCodes;
// iterate over all the opcodes, inserting them into the ordered map
- Q3IntDictIterator<EQPacketOPCode> it(m_opcodes);
- while ((currentOPCode = it.current()) != NULL)
+ QHashIterator<int, EQPacketOPCode*> it(m_opcodes);
+ while (it.hasNext())
{
+ it.next();
+ if (!it.value())
+ break;
+ currentOPCode = it.value();
// insert into the ordered opcode map
orderedOPCodes.insert(OrderedMap::value_type(currentOPCode->opcode(),
currentOPCode));
- // get next opcode
- ++it;
}
OrderedMap::iterator oit;
@@ -431,8 +432,6 @@
void EQPacketOPCodeDB::list(void) const
{
- m_opcodes.statistics();
-
seqInfo("EQPacketOPCodeDB contains %d opcodes (in %d buckets)",
m_opcodes.count(), m_opcodes.size());
@@ -440,11 +439,15 @@
EQPacketPayload* currentPayload;
// iterate over all the opcodes
- Q3IntDictIterator<EQPacketOPCode> it(m_opcodes);
- while ((current = it.current()) != NULL)
+ QHashIterator<int, EQPacketOPCode*> it(m_opcodes);
+ while (it.hasNext())
{
+ it.next();
+ if (!it.value())
+ break;
+ current = it.value();
fprintf(stderr, "\tkey=%04lx opcode=%04x",
- it.currentKey(), current->opcode());
+ it.key(), current->opcode());
if (!current->name().isNull())
fprintf(stderr, " name='%s'", current->name().latin1());
@@ -475,8 +478,6 @@
++pit;
}
-
- ++it;
}
}
Modified: showeq/branches/pre_6_0_beta/src/packetinfo.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/packetinfo.h 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/packetinfo.h 2020-10-25 04:20:17 UTC (rev 1062)
@@ -32,7 +32,6 @@
#include <Q3PtrList>
#include <QHash>
#include <QByteArray>
-#include <Q3IntDict>
#include <Q3CString>
#include <Q3StrList>
#include <QStringList>
@@ -269,7 +268,7 @@
class EQPacketOPCodeDB
{
public:
- EQPacketOPCodeDB(int size);
+ EQPacketOPCodeDB();
~EQPacketOPCodeDB();
bool load(const EQPacketTypeDB& typeDB, const QString& filename);
@@ -285,10 +284,10 @@
bool move(const QString& oldOPCodeName, const QString& newOPCodeName);
const EQPacketOPCode* find(uint16_t opcode) const;
const EQPacketOPCode* find(const QString& opcodeName) const;
- const Q3IntDict<EQPacketOPCode> opcodes() const;
+ const QHash<int, EQPacketOPCode*> opcodes() const;
protected:
- Q3IntDict<EQPacketOPCode> m_opcodes;
+ QHash<int, EQPacketOPCode*> m_opcodes;
QHash<QString, EQPacketOPCode*> m_opcodesByName;
};
@@ -301,7 +300,7 @@
inline EQPacketOPCode* EQPacketOPCodeDB::edit(uint16_t opcode)
{
// attempt to find the opcode object
- return m_opcodes.find(opcode);
+ return m_opcodes.value(opcode, nullptr);
}
inline EQPacketOPCode* EQPacketOPCodeDB::edit(const QString& name)
@@ -313,7 +312,7 @@
inline const EQPacketOPCode* EQPacketOPCodeDB::find(uint16_t opcode) const
{
// attempt to find the opcode object
- return m_opcodes.find(opcode);
+ return m_opcodes.value(opcode, nullptr);
}
inline const EQPacketOPCode* EQPacketOPCodeDB::find(const QString& opcode) const
@@ -322,7 +321,7 @@
return m_opcodesByName.value(opcode, nullptr);
}
-inline const Q3IntDict<EQPacketOPCode> EQPacketOPCodeDB::opcodes() const
+inline const QHash<int, EQPacketOPCode*> EQPacketOPCodeDB::opcodes() const
{
return m_opcodes;
}
Modified: showeq/branches/pre_6_0_beta/src/spawnlist.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/spawnlist.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/spawnlist.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -906,10 +906,14 @@
uint8_t level = 0;
// iterate over all spawns in of the current type
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
// skip filtered spawns
if ((item->filterFlags() & FILTER_FLAG_FILTERED) &&
@@ -969,12 +973,15 @@
const ItemMap& itemMap = m_spawnShell->getConstMap(types[i]);
ItemConstIterator it(itemMap);
uint8_t level = 0;
-
+
// iterate over all spawns in of the current type
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
// retrieve the filter string
filterStr = filterString(item, flags);
@@ -1028,12 +1035,15 @@
{
const ItemMap& itemMap = m_spawnShell->getConstMap(types[i]);
ItemConstIterator it(itemMap);
-
+
// iterate over all spawns in of the current type
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
// just create a new SpawnListItem
litem = new SpawnListItem(this);
Modified: showeq/branches/pre_6_0_beta/src/spawnlist2.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/spawnlist2.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/spawnlist2.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -609,10 +609,13 @@
ItemConstIterator it(itemMap);
// iterate over all spawns in of the current type
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
// if item hasn't changed since last update, then nothing to do, next...
if (item->lastChanged() <= m_lastUpdate)
@@ -909,10 +912,13 @@
uint8_t level = 0;
// iterate over all spawns in of the current type
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
// get the item from the list
- item = it.current();
+ item = it.value();
+ if (!item)
+ break;
// skip filtered spawns
if ((item->filterFlags() & FILTER_FLAG_FILTERED) &&
Modified: showeq/branches/pre_6_0_beta/src/spawnshell.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/spawnshell.cpp 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/spawnshell.cpp 2020-10-25 04:20:17 UTC (rev 1062)
@@ -108,10 +108,10 @@
m_player(player),
m_filterMgr(filterMgr),
m_guildMgr(guildMgr),
- m_spawns(701),
- m_drops(211),
- m_doors(307),
- m_players(2)
+ m_spawns(),
+ m_drops(),
+ m_doors(),
+ m_players()
{
m_cntDeadSpawnIDs = 0;
m_posDeadSpawnIDs = 0;
@@ -118,14 +118,6 @@
for (int i = 0; i < MAX_DEAD_SPAWNIDS; i++)
m_deadSpawnID[i] = 0;
- // these should auto delete
- m_spawns.setAutoDelete(true);
- m_drops.setAutoDelete(true);
- m_doors.setAutoDelete(true);
-
- // we don't want this one to auto-delete
- m_players.setAutoDelete(false);
-
// bogus list
m_players.insert(0, m_player);
@@ -166,6 +158,11 @@
m_timer->start(showeq_params->saveSpawnsFrequency, true);
}
+SpawnShell::~SpawnShell()
+{
+ clear();
+}
+
void SpawnShell::clear(void)
{
#ifdef SPAWNSHELL_DIAG
@@ -174,8 +171,13 @@
emit clearItems();
+ qDeleteAll(m_spawns);
m_spawns.clear();
+
+ qDeleteAll(m_doors);
m_doors.clear();
+
+ qDeleteAll(m_drops);
m_drops.clear();
// clear the players list, reinsert the player
@@ -199,7 +201,7 @@
return (const Item*)m_player;
if (type != tPlayer)
- item = getMap(type).find(id);
+ item = getMap(type).value(id, nullptr);
return item;
}
@@ -217,11 +219,15 @@
// find closest spawn
// iterate over all the items in the map
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the item
- item = it.current();
-
+ item = it.value();
+ if (!item)
+ break;
+
// calculate the distance from the specified point
distance = item->calcDist(x, y);
@@ -243,10 +249,14 @@
ItemIterator it(m_spawns);
Spawn* spawn;
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// the item and coerce it to the Spawn type
- spawn = (Spawn*)it.current();
+ spawn = (Spawn*)it.value();
+ if (!spawn)
+ break;
if (name == spawn->name())
return spawn;
@@ -265,7 +275,7 @@
#endif
ItemMap& theMap = getMap(type);
- Item* item = theMap.find(id);
+ Item* item = theMap.value(id, nullptr);
if (item != NULL)
{
@@ -329,8 +339,14 @@
{
ItemIterator it(getMap(type));
- for (; it.current(); ++it)
- out << it.current()->dumpString() << endl;
+ while (it.hasNext())
+ {
+ it.next();
+ if (!it.value())
+ break;
+
+ out << it.value()->dumpString() << endl;
+ }
}
// same-name slots, connecting to Packet signals
@@ -402,7 +418,7 @@
seqDebug("SpawnShell::newGroundItem(makeDropStruct *)");
#endif
- Drop* item = (Drop*)m_drops.find(ds.dropId);
+ Drop* item = (Drop*)m_drops.value(ds.dropId, nullptr);
if (item != NULL)
{
item->update(&ds, name);
@@ -459,7 +475,7 @@
#ifdef SPAWNSHELL_DIAG
seqDebug("SpawnShell::newDoorSpawn(doorStruct*)");
#endif
- Item* item = m_doors.find(d.doorId);
+ Item* item = m_doors.value(d.doorId, nullptr);
if (item != NULL)
{
Door* door = (Door*)item;
@@ -794,7 +810,7 @@
}
else
{
- if((item=m_spawns.find(spawn->spawnId)))
+ if((item=m_spawns.value(spawn->spawnId, nullptr)))
{
// Update existing spawn
Spawn *s=(Spawn*)item;
@@ -851,7 +867,7 @@
}
}
- Item* item = m_spawns.find(s.spawnId);
+ Item* item = m_spawns.value(s.spawnId, nullptr);
if (item != NULL)
{
Spawn* spawn = (Spawn*)item;
@@ -1104,7 +1120,7 @@
}
else
{
- item = m_spawns.find(id);
+ item = m_spawns.value(id, nullptr);
}
if (item != NULL)
@@ -1185,7 +1201,7 @@
su->spawnId, su->subcommand, su->arg1, su->arg2);
#endif
- Item* item = m_spawns.find(su->spawnId);
+ Item* item = m_spawns.value(su->spawnId, nullptr);
if (item != NULL)
{
Spawn* spawn = (Spawn*)item;
@@ -1236,9 +1252,9 @@
seqDebug("SpawnShell::illusionSpawn(id=%d, name=%s, new race=%d)",
illusion->spawnId, illusion->name, illusion->race);
#endif
-
- Item* item = m_spawns.find(illusion->spawnId);
-
+
+ Item* item = m_spawns.value(illusion->spawnId, nullptr);
+
if (item != NULL)
{
Spawn* spawn = (Spawn*) item;
@@ -1309,7 +1325,7 @@
app->spawnId, app->type, app->parameter);
#endif
- Item* item = m_spawns.find(app->spawnId);
+ Item* item = m_spawns.value(app->spawnId, nullptr);
if (item != NULL)
{
@@ -1355,7 +1371,7 @@
seqDebug("SpawnShell::updateNpcHP(id=%d, maxhp=%d hp=%d)",
hpupdate->spawnId, hpupdate->maxHP, hpupdate->curHP);
#endif
- Item* item = m_spawns.find(hpupdate->spawnId);
+ Item* item = m_spawns.value(hpupdate->spawnId, nullptr);
if (item != NULL)
{
Spawn* spawn = (Spawn*)item;
@@ -1369,7 +1385,7 @@
void SpawnShell::spawnWearingUpdate(const uint8_t* data)
{
const wearChangeStruct *wearing = (const wearChangeStruct *)data;
- Item* item = m_spawns.find(wearing->spawnId);
+ Item* item = m_spawns.value(wearing->spawnId, nullptr);
if (item != NULL)
{
// ZBTEMP: Find newItemID
@@ -1395,7 +1411,7 @@
{
if (con->playerid != con->targetid)
{
- item = m_spawns.find(con->targetid);
+ item = m_spawns.value(con->targetid, nullptr);
if (item != NULL)
{
spawn = (Spawn*)item;
@@ -1413,8 +1429,8 @@
if (con->playerid != con->targetid)
{
// find the spawn if it exists
- item = m_spawns.find(con->targetid);
-
+ item = m_spawns.value(con->targetid, nullptr);
+
// has the spawn been seen before?
if (item != NULL)
{
@@ -1457,7 +1473,7 @@
else
{
// Set flag to change its icon
- if((item=m_spawns.find(rmSpawn->spawnId)))
+ if((item=m_spawns.value(rmSpawn->spawnId, nullptr)))
{
Spawn *s=(Spawn*)item;
s->setNotUpdated(true);
@@ -1502,7 +1518,7 @@
if (deadspawn->spawnId != m_player->id())
{
- item = m_spawns.find(deadspawn->spawnId);
+ item = m_spawns.value(deadspawn->spawnId, nullptr);
}
else
{
@@ -1529,7 +1545,7 @@
spawn->setName(spawn->realName() + Spawn_Corpse_Designator);
Item* killer;
- killer = m_spawns.find(deadspawn->killerId);
+ killer = m_spawns.value(deadspawn->killerId, nullptr);
emit killSpawn(item, killer, deadspawn->killerId);
}
}
@@ -1576,7 +1592,7 @@
void SpawnShell::corpseLoc(const uint8_t* data)
{
const corpseLocStruct* corpseLoc = (const corpseLocStruct*)data;
- Item* item = m_spawns.find(corpseLoc->spawnId);
+ Item* item = m_spawns.value(corpseLoc->spawnId, nullptr);
if (item != NULL)
{
Spawn* spawn = (Spawn*)item;
@@ -1611,7 +1627,8 @@
m_players.take(0);
// re-insert the player into the list
- m_players.replace(playerID, m_player);
+ delete m_players.take(playerID);
+ m_players.insert(playerID, m_player);
emit changeItem(m_player, tSpawnChangedALL);
}
@@ -1632,11 +1649,15 @@
{
Spawn* spawn;
// iterate over all the items in the map
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the item
- spawn = (Spawn*)it.current();
-
+ spawn = (Spawn*)it.value();
+ if (!spawn)
+ break;
+
// update the flags, if they changed, send a notification
if (updateFilterFlags(spawn))
{
@@ -1649,11 +1670,15 @@
{
Item* item;
// iterate over all the items in the map
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the item
- item = it.current();
-
+ item = it.value();
+ if (!item)
+ break;
+
// update the flags, if they changed, send a notification
if (updateFilterFlags(item))
{
@@ -1679,11 +1704,15 @@
{
Spawn* spawn;
// iterate over all the items in the map
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the item
- spawn = (Spawn*)it.current();
-
+ spawn = (Spawn*)it.value();
+ if (!spawn)
+ break;
+
// update the flags, if they changed, send a notification
if (updateRuntimeFilterFlags(spawn))
{
@@ -1696,11 +1725,15 @@
{
Item* item;
// iterate over all the items in the map
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the item
- item = it.current();
-
+ item = it.value();
+ if (!item)
+ break;
+
// update the flags, if they changed, send a notification
if (updateRuntimeFilterFlags(item))
{
@@ -1739,10 +1772,14 @@
Spawn* spawn;
// iterate over all the items in the map
- for (; it.current(); ++it)
+ while (it.hasNext())
{
+ it.next();
+
// get the spawn
- spawn = (Spawn*)it.current();
+ spawn = (Spawn*)it.value();
+ if (!spawn)
+ break;
// save the spawn id
d << spawn->id();
Modified: showeq/branches/pre_6_0_beta/src/spawnshell.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/spawnshell.h 2020-10-25 04:20:02 UTC (rev 1061)
+++ showeq/branches/pre_6_0_beta/src/spawnshell.h 2020-10-25 04:20:17 UTC (rev 1062)
@@ -42,7 +42,7 @@
#include <cstdio>
#include <cmath>
-#include <Q3IntDict>
+#include <QHash>
#include <QTimer>
#include <Q3TextStream>
@@ -69,9 +69,9 @@
//----------------------------------------------------------------------
// type definitions
-typedef Q3IntDict<Item> ItemMap;
-typedef Q3IntDictIterator<Item> ItemIterator;
-typedef Q3IntDictIterator<Item> ItemConstIterator;
+typedef QHash<int, Item*> ItemMap;
+typedef QHashIterator<int, Item*> ItemIterator;
+typedef QHashIterator<int, Item*> ItemConstIterator;
//----------------------------------------------------------------------
// SpawnShell
@@ -84,6 +84,8 @@
Player* player,
GuildMgr* guildMgr);
+ ~SpawnShell();
+
const Item* findID(spawnItemType type, int idSpawn);
const Item* findClosestItem(spawnItemType type,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|