Update of /cvsroot/seq/showeq/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14505/src Modified Files: Makefile.am category.cpp classes.h combatlog.cpp combatlog.h compass.cpp compassframe.cpp crctab.h datetimemgr.cpp datetimemgr.h decode.h deity.h drawmap.cpp editor.cpp everquest.h experiencelog.cpp experiencelog.h filter.cpp filter.h filtermgr.cpp filtermgr.h fixpt.h group.cpp group.h guild.cpp guild.h interface.cpp interface.h itemdb.cpp itemdb.h itemdbtool.cpp languages.h logger.cpp main.cpp main.h map.cpp map.h mapcore.cpp mapcore.h netdiag.cpp packet.cpp packet.h packetcapture.cpp packetcapture.h packetcommon.h packetformat.cpp packetformat.h packetfragment.cpp packetfragment.h packetlog.cpp packetlog.h packetstream.cpp packetstream.h player.cpp player.h point.h races.h seqlistview.cpp seqwindow.cpp seqwindow.h skilllist.cpp skills.h spawn.cpp spawn.h spawnlist.cpp spawnlist.h spawnlist2.cpp spawnlist2.h spawnlistcommon.cpp spawnlistcommon.h spawnlog.cpp spawnlog.h spawnmonitor.cpp spawnmonitor.h spawnpointlist.cpp spawnpointlist.h spawnshell.cpp spawnshell.h spelllist.cpp spelllist.h spells.cpp spells.h spells_en2spellsh.pl spellshell.cpp spellshell.h staticspells.h statlist.cpp statlist.h typenames.h util.cpp util.h weapons.h weapons1.h weapons27.h weapons28.h weapons2b.h xmlconv.cpp xmlconv.h xmlpreferences.cpp xmlpreferences.h zonemgr.cpp zonemgr.h zones.h Added Files: bazaarlog.cpp bazaarlog.h datalocationmgr.cpp datalocationmgr.h diagnosticmessages.cpp diagnosticmessages.h diagnosticmessageslight.cpp eqstr.cpp eqstr.h filter2xml.pl filteredspawnlog.cpp filteredspawnlog.h filternotifications.cpp filternotifications.h guildlist.cpp guildlist.h guildshell.cpp guildshell.h h2info.pl mapicon.cpp mapicon.h mapicondialog.ui mapicondialog.ui.h message.cpp message.h messagefilter.cpp messagefilter.h messagefilterdialog.cpp messagefilterdialog.h messages.cpp messages.h messageshell.cpp messageshell.h messagewindow.cpp messagewindow.h netstream.cpp netstream.h packetinfo.cpp packetinfo.h pointarray.h terminal.cpp terminal.h weapons29.h weapons2a.h Removed Files: decode.cpp msgdlg.cpp msgdlg.h opcodes.h Log Message: Merged pre_5_0_beta down to the trunk. pre_5_0_beta should be treated as closed. All future development will occur on the branch. Updated version to 5.1.0.0 in preparation for new expansion release pending fixes for live compatibility. --- NEW FILE: pointarray.h --- /* * point.h * * ShowEQ Distributed under GPL * http://seq.sf.net/ */ // Original Author: Zaphod (do...@us...) // interfaces modeled after QPoint and QPointArray interface // but for 3D data of arbitraty type T. // // NOTE: Trying to keep this file ShowEQ/Everquest independent to allow it // to be reused for other Show{} style projects. // #ifndef __POINTARRAY_H_ #define __POINTARRAY_H_ #ifdef __FreeBSD__ #include "point.h" #include <sys/types.h> #else #include <stdint.h> #endif #include <qmemarray.h> #include <qpoint.h> // Point3DArray template <class _T> class Point3DArray : public QMemArray<Point3D<_T> > { public: Point3DArray() {}; Point3DArray(int size) : QMemArray<Point3D<_T> > (size) {} Point3DArray(const Point3DArray<_T>& array) : QMemArray<Point3D<_T> > (array) {} Point3DArray(uint32_t nPoints, const _T* points); ~Point3DArray() {}; Point3DArray<_T>& operator=(const Point3DArray<_T>& array) { return (Point3DArray<_T>&)assign(array); } Point3DArray<_T> copy() const { Point3DArray<_T> tmp; return *((Point3DArray<_T>*)&tmp.duplicate(*this)); } QRect boundingRect() const; void point(uint32_t i, _T* x, _T* y, _T* z) const; const Point3D<_T>& point( uint32_t i) const; void setPoint(uint32_t i, _T x, _T y, _T z); void setPoint(uint32_t i, const Point3D<_T>& p); bool setPoints(uint32_t nPoints, const _T* points); bool setPoints(uint32_t nPoints, _T firstx, _T firsty, _T firstz, ...); bool putPoints(uint32_t index, uint32_t nPoints, const _T* points); bool putPoints(uint32_t index, uint32_t nPoints, _T firstx, _T firsty, _T firstz, ...); QPointArray getQPointArray(); }; template <class _T> inline Point3DArray<_T>::Point3DArray(uint32_t nPoints, const _T* points) { setPoints(nPoints, points); } template <class _T> inline QRect Point3DArray<_T>::boundingRect() const { if (QMemArray<Point3D<_T> >::isEmpty()) return QRect(0, 0, 0, 0); Point3D<_T>* d = QMemArray<Point3D<_T> >::data(); _T minX, maxX, minY, maxY; minX = maxX = d->x(); minY = maxY = d->y(); uint32_t i; for (++d, i = 1; i < QMemArray<Point3D<_T> >::size(); i++, d++) { if (d->x() < minX) minX = d->x(); else if (d->x() > maxX) maxX = d->x(); if (d->y() < minY) minY = d->y(); else if (d->y() > maxY) maxY = d->y(); } return QRect(QPoint(minX, minY), QPoint(maxX, maxY)); } template <class _T> inline void Point3DArray<_T>::point(uint32_t index, _T* x, _T* y, _T* z) const { Point3D<_T> p = QMemArray<Point3D<_T> >::at(index); *x = p.x(); *y = p. y(); *z = p. z(); } template <class _T> inline const Point3D<_T>& Point3DArray<_T>::point(uint32_t index) const { return QMemArray<Point3D<_T> >::at(index); } template <class _T> inline void Point3DArray<_T>::setPoint(uint32_t index, _T x, _T y, _T z) { QMemArray<Point3D<_T> >::at(index) = Point3D<_T>(x, y, z); } template <class _T> inline void Point3DArray<_T>::setPoint(uint32_t index, const Point3D<_T>& p) { QMemArray<Point3D<_T> >::at(index) = p; } template <class _T> inline bool Point3DArray<_T>::setPoints(uint32_t nPoints, const _T* points) { if (!QMemArray<Point3D<_T> >::resize(nPoints)) return false; for (uint32_t i = 0; nPoints; nPoints--, i++, points += 3) setPoint(i, *points, *(points + 1), *(points + 2)); return true; } template <class _T> inline bool Point3DArray<_T>::setPoints(uint32_t nPoints, _T firstx, _T firsty, _T firstz, ...) { if (!QMemArray<Point3D<_T> >::resize(nPoints)) return false; setPoint( 0, firstx, firsty, firstz); va_list ap; va_start(ap, firstz); _T x, y, z; uint32_t i; for (i = 1, --nPoints; nPoints; nPoints--, i++) { x = va_arg(ap, _T); y = va_arg(ap, _T); z = va_arg(ap, _T); setPoint(i, x, y, z); } va_end(ap); return true; } template <class _T> inline bool Point3DArray<_T>::putPoints(uint32_t index, uint32_t nPoints, const _T* points) { if ((index + nPoints) > QMemArray<Point3D<_T> >::size()) if (!QMemArray<Point3D<_T> >::resize(index + nPoints)) return false; for (uint32_t i = index; nPoints; nPoints--, i++, points += 3) setPoint(i, *points, *(points + 1), *(points + 2)); return true; } template <class _T> inline bool Point3DArray<_T>::putPoints(uint32_t index, uint32_t nPoints, _T firstx, _T firsty, _T firstz, ...) { if ((index + nPoints) > QMemArray<Point3D<_T> >::size()) if (!QMemArray<Point3D<_T> >::resize(index + nPoints)) return false; setPoint( 0, firstx, firsty, firstz); va_list ap; va_start(ap, firstz); _T x, y, z; uint32_t i; for (i = index + 1, --nPoints; nPoints; nPoints--, i++) { x = va_arg(ap, _T); y = va_arg(ap, _T); z = va_arg(ap, _T); setPoint(i, x, y, z); } va_end(ap); return true; } template <class _T> inline QPointArray Point3DArray<_T>::getQPointArray() { // create a temporary QPointArray of the same size as this array QPointArray tmp(QMemArray<Point3D<_T> >::size()); // copy each Point3D<_T> as a QPoint into the temporary QPointArray for (uint32_t i = 0; i < QMemArray<Point3D<_T> >::size(); i++) tmp.setPoint(i, point(i).qpoint()); // return the temporary QPointArray return tmp; } #endif // __POINTARRAY_H_ --- NEW FILE: message.h --- /* * message.h * * ShowEQ Distributed under GPL * http://seq.sourceforge.net/ * * Copyright 2002-2003 Zaphod (do...@us...) * */ #ifndef _MESSAGE_H_ #define _MESSAGE_H_ #include <stdint.h> #include <qstring.h> #include <qdatetime.h> #include <qvaluevector.h> //---------------------------------------------------------------------- // constants const uint32_t ME_InvalidColor = 0x000000FF; //---------------------------------------------------------------------- // enumerated types enum MessageType { MT_Guild = 0, MT_Group = 2, MT_Shout = 3, MT_Auction = 4, MT_OOC = 5, MT_Tell = 7, MT_Say = 8, MT_GMSay = 11, MT_GMTell = 14, MT_Raid = 15, MT_Debug, MT_Info, MT_Warning, MT_General, MT_Motd, MT_System, MT_Money, MT_Random, MT_Emote, MT_Time, MT_Spell, MT_Zone, MT_Inspect, MT_Player, MT_Consider, MT_Alert, MT_Danger, MT_Caution, MT_Hunt, MT_Locate, MT_Max = MT_Locate, }; //---------------------------------------------------------------------- // MessageEntry class MessageEntry { public: MessageEntry(MessageType type, const QDateTime& dateTime, const QDateTime& eqDateTime, const QString& text, uint32_t color = ME_InvalidColor, uint32_t filterFlags = 0); MessageEntry(); ~MessageEntry(); MessageType type() const { return m_type; } const QDateTime& dateTime() const { return m_dateTime; } const QDateTime& eqDateTime() const { return m_eqDateTime; } const QString& text() const { return m_text; } const uint32_t color() const { return m_color; } uint32_t filterFlags() const { return m_filterFlags; } void setFilterFlags(uint32_t filterFlags) { m_filterFlags = filterFlags; } static const QString& messageTypeString(MessageType type); protected: MessageType m_type; QDateTime m_dateTime; QDateTime m_eqDateTime; QString m_text; uint32_t m_color; uint32_t m_filterFlags; static QString s_messageTypeStrings[MT_Max+1]; }; inline MessageEntry::MessageEntry(MessageType type, const QDateTime& dateTime, const QDateTime& eqDateTime, const QString& text, uint32_t color, uint32_t filters) : m_type(type), m_dateTime(dateTime), m_eqDateTime(eqDateTime), m_text(text), m_color(color), m_filterFlags(filters) { } inline MessageEntry::MessageEntry() : m_type(MT_Debug), m_color(0x000000FF), m_filterFlags(0) { } inline MessageEntry::~MessageEntry() { } inline const QString& MessageEntry::messageTypeString(MessageType type) { static QString dummy; if (type <= MT_Max) return s_messageTypeStrings[type]; return dummy; } #endif // _MESSAGE_H_ Index: seqwindow.cpp =================================================================== RCS file: /cvsroot/seq/showeq/src/seqwindow.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- seqwindow.cpp 21 May 2002 21:37:36 -0000 1.1 +++ seqwindow.cpp 13 Sep 2005 15:23:13 -0000 1.2 @@ -4,7 +4,7 @@ * ShowEQ Distributed under GPL * http://seq.sourceforge.net/ * - * Copyright 2001 Zaphod (do...@us...). All Rights Reserved. + * Copyright 2001-2003 Zaphod (do...@us...). All Rights Reserved. * * Contributed to ShowEQ by Zaphod (do...@us...) * for use under the terms of the GNU General Public License, @@ -15,15 +15,23 @@ #include "seqwindow.h" #include "main.h" +#include <qpopupmenu.h> + SEQWindow::SEQWindow(const QString prefName, const QString caption, QWidget* parent, const char* name, WFlags f) - : QWidget(parent, name, f), + : QDockWindow(parent, name, f), m_preferenceName(prefName) { // set the windows caption - QWidget::setCaption(pSEQPrefs->getPrefString("Caption", preferenceName(), + QDockWindow::setCaption(pSEQPrefs->getPrefString("Caption", preferenceName(), caption)); - + + // windows default to resizable + setResizeEnabled(true); + + // windows default to be closable when not docked + setCloseMode(Always); + // restore the font restoreFont(); } @@ -32,11 +40,16 @@ { } +QPopupMenu* SEQWindow::menu() +{ + return 0; +} void SEQWindow::setCaption(const QString& text) { // set the caption - QWidget::setCaption(text); + QDockWindow::setCaption(text); + setName((const char*)caption()); // set the preference pSEQPrefs->setPrefString("Caption", preferenceName(), caption()); @@ -64,27 +77,78 @@ void SEQWindow::restoreSize() { - // retrieve the saved size information - QSize s = pSEQPrefs->getPrefSize("WindowSize", preferenceName(), size()); + if (place() == InDock) + { + QSize s = pSEQPrefs->getPrefSize("DockFixedExtent", preferenceName(), + fixedExtent()); + setFixedExtentWidth(s.width()); + setFixedExtentHeight(s.height()); + } + else + { + // retrieve the saved size information + QSize s = pSEQPrefs->getPrefSize("WindowSize", preferenceName(), size()); + + resize(s); + } - resize(s); + if (pSEQPrefs->getPrefBool("DockVisible", preferenceName(), !isHidden())) + show(); + else + hide(); } void SEQWindow::restorePosition() { - // retrieve the saved position information - QPoint p = pSEQPrefs->getPrefPoint("WindowPos", preferenceName(), pos()); - - // Move window to new position - move(p); + if (place() == InDock) + { + setNewLine(pSEQPrefs->getPrefBool("DockNewLine", preferenceName(), + newLine())); + setOffset(pSEQPrefs->getPrefInt("DockOffset", preferenceName(), offset())); + } + else + { + // retrieve the saved position information + QPoint p = pSEQPrefs->getPrefPoint("WindowPos", preferenceName(), pos()); + + // Move window to new position + move(p); + } } void SEQWindow::savePrefs(void) { if (pSEQPrefs->getPrefBool("SavePosition", "Interface", true)) { - // save the windows size and position information - pSEQPrefs->setPrefSize("WindowSize", preferenceName(), size()); - pSEQPrefs->setPrefPoint("WindowPos", preferenceName(), pos()); + if (place() == InDock) + { + pSEQPrefs->setPrefBool("DockNewLine", preferenceName(), newLine()); + pSEQPrefs->setPrefInt("DockOffset", preferenceName(), offset()); + pSEQPrefs->setPrefSize("DockFixedExtent", preferenceName(), fixedExtent()); + } + else + { + // save the windows size and position information + pSEQPrefs->setPrefSize("WindowSize", preferenceName(), size()); + pSEQPrefs->setPrefPoint("WindowPos", preferenceName(), pos()); + } + + pSEQPrefs->setPrefBool("DockVisible", preferenceName(), !isHidden()); + } +} + +void SEQWindow::mousePressEvent(QMouseEvent* e) +{ + if (e->button() == RightButton) + { + QPopupMenu* popupMenu = menu(); + if (popupMenu) + popupMenu->popup(mapToGlobal(e->pos())); + else + QDockWindow::mousePressEvent(e); } + else + QDockWindow::mousePressEvent(e); } + +#include "seqwindow.moc" Index: util.cpp =================================================================== RCS file: /cvsroot/seq/showeq/src/util.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- util.cpp 11 Nov 2003 07:13:53 -0000 1.21 +++ util.cpp 13 Sep 2005 15:23:14 -0000 1.22 @@ -5,6 +5,10 @@ * http://seq.sourceforge.net/ */ +#include "util.h" +#include "diagnosticmessages.h" +#include "main.h" + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -14,9 +18,6 @@ #include <qfileinfo.h> #include <qdir.h> -#include "util.h" -#include "main.h" - #ifdef __FreeBSD__ long int lroundf(float x) //closest int away from 0 @@ -78,6 +79,22 @@ return newstring; } /* END Commanate */ +QString classString(uint8_t classVal) +{ + // a non-sparse array of class names + static const char* classnames[] = + { +#include "classes.h" + }; + + // return class name from list if it's within range + if ((classVal < (sizeof(classnames) / sizeof (char*))) && + (classnames[classVal] != NULL)) + return classnames[classVal]; + else + return QString::number(classVal); +} + QString spell_name (uint16_t spellId) { @@ -138,98 +155,6 @@ return QString::number(langId); } -/* Saves spawn to spawn DB */ -void spawndb (const dbSpawnStruct *dbSpawn) -{ - FILE *sdb; - struct dbSpawnStruct s; - int found=0; - char thisname[256]; - char dbname[256]; - - /* Check if this is not a player or a corpse */ - if (dbSpawn->spawn.NPC == 0 || dbSpawn->spawn.NPC == 2) { - return; - } - - strcpy (thisname, dbSpawn->spawn.name); - - /* Strip off number after spawn name */ - size_t nameLen = strlen(dbSpawn->spawn.name); - for (size_t a=0; a < nameLen; a++) - if (thisname[a]<='9') - thisname[a]=0; - - if ((sdb = fopen (SPAWNFILE, "r")) != NULL) - { - while (fread (&s, sizeof(dbSpawnStruct), 1, sdb)) - { - strcpy (dbname, s.spawn.name); - size_t nameLen = strlen(s.spawn.name); - for (size_t a=0; a < nameLen; a++) - if (dbname[a]<='9') - dbname[a]=0; - if ( (!strcmp(dbname, thisname)) && - (dbSpawn->spawn.level == s.spawn.level) && - (!strcmp(dbSpawn->zoneName, s.zoneName)) ) - { - found=1; - break; - } - } - - fclose (sdb); - } - else { - puts("Error opening spawn file '" SPAWNFILE "'"); - } - - if (!found) - { - if ((sdb = fopen (SPAWNFILE, "a")) != NULL) - { - fwrite (dbSpawn, sizeof(dbSpawnStruct), 1, sdb); - fclose (sdb); - } - else { - puts("Error opening spawn file '" SPAWNFILE "'"); - } - } -} - -void petdb(const petStruct *spawn) -{ - FILE *pdb; - struct petStruct s; - int found=0; - - if ((pdb = fopen (LOGDIR "/pet.db", "r")) != NULL) - { - while (fread (&s, sizeof(petStruct), 1, pdb)) - { - // Unique on owner class, owner level and pet level - if ((spawn->owner.class_==s.owner.class_) && - (spawn->owner.level==s.owner.level) && - (spawn->pet.level==s.pet.level)) - { - found=1; - break; - } - } - - fclose (pdb); - } - - if (!found) - { - if ((pdb = fopen (LOGDIR "/pet.db", "a")) != NULL) - { - fwrite (spawn, sizeof(petStruct), 1, pdb); - fclose (pdb); - } - } -} - QString print_races (uint16_t races) { QString race_str; @@ -880,26 +805,26 @@ { // if what's supposed to be a directory isn't somethings wierd. if (!dirInfo.isDir()) - fprintf(stderr, "\tDirectory '%s' isn't a directory!\n", + seqWarn("\tDirectory '%s' isn't a directory!", (const char*)dirInfo.absFilePath()); else { // if the directory isn't writable, that might explain it if (!dirInfo.isWritable()) - fprintf(stderr, "\tCan't write to directory: %s\n", + seqWarn("\tCan't write to directory: %s", (const char*)dirInfo.absFilePath()); // if the directory isn't readable, that might explain it if (!dirInfo.isReadable()) - fprintf(stderr, "\tCan't read directory: %s\n", + seqWarn("\tCan't read directory: %s", (const char*)dirInfo.absFilePath()); // is the directory executable (listable), if (!dirInfo.isExecutable()) - fprintf(stderr, "\tCan't execute/access directory: %s\n", + seqWarn("\tCan't execute/access directory: %s", (const char*)dirInfo.absFilePath()); } } else // directory doesn't exist - fprintf(stderr, "\tDirectory '%s' doesn't exist!\n", + seqWarn("\tDirectory '%s' doesn't exist!", (const char*)dirInfo.absFilePath()); @@ -908,12 +833,12 @@ { // The file exists, but is it writable if (!fileInfo.isWritable()) - fprintf(stderr, "\tCan't write to file: %s\n", + seqWarn("\tCan't write to file: %s", (const char*)fileInfo.absFilePath()); // Is the file really a file (or did someone do something wierd) if (!fileInfo.isFile()) - fprintf(stderr, "\tNot a file:'%s'!", + seqWarn("\tNot a file:'%s'!", (const char*)fileInfo.absFilePath()); } } @@ -931,22 +856,22 @@ { // if what's supposed to be a directory isn't somethings wierd. if (!dirInfo.isDir()) - fprintf(stderr, "\tDirectory '%s' isn't a directory!\n", + seqWarn("\tDirectory '%s' isn't a directory!", (const char*)dirInfo.absFilePath()); else { // if the directory isn't readable, that might explain it if (!dirInfo.isReadable()) - fprintf(stderr, "\tCan't read directory: %s\n", + seqWarn("\tCan't read directory: %s", (const char*)dirInfo.absFilePath()); // is the directory executable (listable), if (!dirInfo.isExecutable()) - fprintf(stderr, "\tCan't execute/access directory: %s\n", + seqWarn("\tCan't execute/access directory: %s", (const char*)dirInfo.absFilePath()); } } else // directory doesn't exist - fprintf(stderr, "\tDirectory '%s' doesn't exist!\n", + seqWarn("\tDirectory '%s' doesn't exist!", (const char*)dirInfo.absFilePath()); @@ -955,16 +880,16 @@ { // The file exists, but is it writable if (!fileInfo.isReadable()) - fprintf(stderr, "\tCan't read to file: %s\n", + seqWarn("\tCan't read to file: %s", (const char*)fileInfo.absFilePath()); // Is the file really a file (or did someone do something wierd) if (!fileInfo.isFile()) - fprintf(stderr, "\tNot a file:'%s'!", + seqWarn("\tNot a file:'%s'!", (const char*)fileInfo.absFilePath()); } else - fprintf(stderr, "\tFile '%s' doesn't exist.\n", + seqWarn("\tFile '%s' doesn't exist.", (const char*)fileInfo.absFilePath()); } @@ -1038,31 +963,25 @@ return crc ^ 0xFFFFFFFF; } - -bool findFile( QString& filename ) +////////////////////////////////////////////////////////////////// +// Seeded CRC16 needed by the packet layer. +uint16_t calcCRC16(uint8_t* p, uint32_t length, uint32_t seed) { - bool found = false; - - QFileInfo fi( filename ); - QDir dir( fi.dirPath( true ) ); - QString fileLower = fi.fileName().lower(); - - QStringList dirEntries = dir.entryList(); - - for ( QStringList::Iterator it = dirEntries.begin(); - it != dirEntries.end(); - ++it ) - { - QString entry( (*it).lower() ); - if ( entry == fileLower ) - { - filename = fi.dirPath( true ); - filename += "/"; - filename += *it; - found = true; - break; - } - } - return found; +#include "crctab.h" + unsigned long crc = 0L ^ 0xffffffff; + + // CRC each byte of the seed + crc = crc >> 8 ^ crctab[(seed ^ crc) & 0xFF]; + crc = crc >> 8 ^ crctab[(seed >> 8 ^ crc) & 0xFF]; + crc = crc >> 8 ^ crctab[(seed >> 16 ^ crc) & 0xFF]; + crc = crc >> 8 ^ crctab[(seed >> 24 ^ crc) & 0xFF]; + + // Then crc the buffer + while(length--) + { + crc = crc >> 8 ^ crctab[(*(p++) ^ crc) & 0xFF]; + } + + return crc ^ 0xffffffffL; } --- NEW FILE: filter2xml.pl --- #!/usr/bin/perl $dir = 0; while($_ = $ARGV[0], /^-/) { shift; last if /^--$/; if (/^-D/) { $dir = 1; } } if (!$dir) { migrate(@ARGV); } else { migratedir(@ARGV); } sub migratedir { local ($source, $dest, $comments) = @_; opendir(SOURCEDIR, $source) || die "Can't open '$source' directory: $!\n"; @conffiles = grep /^filters_.*\.conf$/, readdir SOURCEDIR; closedir(SOURCEDIR); foreach $file (@conffiles) { ($destfile = $file) =~ s/^filters_(.*)\.conf$/$1.xml/; # print "$source/$file => $dest/$destfile\n"; migrate("$source/$file", "$dest/$destfile", $comments); } } sub migrate { local ($source, $dest, $comments) = @_; print "Migrating '$source' to '$dest'\n"; # open source and destination files open(SOURCE_FILE, "<$source") || die "Can't find '$source' $SOURCE_FILE: $!\n"; open(DEST_FILE, ">$dest") || die "Can't create '$dest' $DEST_FILE: $!\n"; # print the XML header print DEST_FILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; print DEST_FILE "<!DOCTYPE seqfilters SYSTEM \"seqfilters.dtd\">\n"; print DEST_FILE "<seqfilters>\n"; $incomment = 0; $insection = 0; # iterate over the contents of the source file while ($line = <SOURCE_FILE>) { # handle empty lines if ($line =~ m/^\s*$/) { next if (!$comments); if ($incomment) { print DEST_FILE "---> \n"; $incomment = 0; } next; } # handle escaping of XML unfriendly characters $line =~ s/&/&/g; $line =~ s/</</g; $line =~ s/>/>/g; $line =~ s/\"/"/g; # handle comments if ($line =~ m/^\#/) { next if (!$comments); if ($incomment) { $line =~ s/^\#(.*)$/ $1 /; } else { $line =~ s/^\#(.*)$/<--\n $1 /; $incomment = 1; } print DEST_FILE $line; next; } if ($incomment) { print DEST_FILE "---> \n"; $incomment = 0; } # handle section breaks if ($line =~ m/^\[/) { print DEST_FILE " </section>\n" if ($insection); $insection = 1; $line =~ s/^\[([^\]]+)\]\s*$/ <section name="$1">/; print DEST_FILE $line, "\n"; } else { # min and max default to 0 $min = 0; $max = 0; # fix line termination and errant trailing spaces $line =~ s/^(.*?)\s*$/$1/; # seperate @line = split(m/;/, $line); # process level ranges if ($#line > 0) { $range = $line[1]; if ($range =~ m/^(\d+)-$/) { $min = $1; $max = 255; } elsif ($range =~ m/^-(\d+)$/) { $min = 0; $max = $1; } elsif ($range =~ m/^(\d+)-(\d+)/) { $min = $1; $max = $2; } } # print out in the XML filter format print DEST_FILE " <oldfilter>"; print DEST_FILE "<regex>", $line[0], "</regex>" if ($line[0]); # handle outputting level ranges if ($min || $max) { print DEST_FILE "<level"; print DEST_FILE " min=\"$min\"" if ($min); print DEST_FILE " max=\"$max\"" if ($max); print DEST_FILE "/>"; } # close the filter entry print DEST_FILE "</oldfilter>\n" } } # close the section print DEST_FILE " </section>\n" if ($insection); print DEST_FILE "</seqfilters>\n"; } --- NEW FILE: filteredspawnlog.cpp --- /* * spawnlog.cpp * * ShowEQ Distributed under GPL * http://www.sourceforge.net/projects/seq * * Copyright 2001-2003 by the respective ShowEQ Developers * Portions Copyright 2001-2003 Zaphod (do...@us...). */ #include "filteredspawnlog.h" #include "filtermgr.h" #include "spawn.h" #include "datetimemgr.h" FilteredSpawnLog::FilteredSpawnLog(DateTimeMgr* dateTimeMgr, FilterMgr* filterMgr, const QString& filename) : SEQLogger(filename, NULL, "FilteredSpawnLog"), m_dateTimeMgr(dateTimeMgr), m_filterMgr(filterMgr), m_logFilters(0) { } FilteredSpawnLog::~FilteredSpawnLog() { } void FilteredSpawnLog::setFilters(uint32_t flags) { m_logFilters = flags; } void FilteredSpawnLog::addItem(const Item* item) { uint32_t filterFlags = item->filterFlags(); if (!(filterFlags & m_logFilters)) return; if (filterFlags & (FILTER_FLAG_ALERT | FILTER_FLAG_DANGER | FILTER_FLAG_CAUTION | FILTER_FLAG_HUNT | FILTER_FLAG_LOCATE)) logSpawn(item, "spawned", filterFlags); } void FilteredSpawnLog::delItem(const Item* item) { uint32_t filterFlags = item->filterFlags(); if (!(filterFlags & m_logFilters)) return; if (filterFlags & FILTER_FLAG_ALERT) logSpawn(item, "despawned", filterFlags); } void FilteredSpawnLog::killSpawn(const Item* item) { uint32_t filterFlags = item->filterFlags(); if (!(filterFlags & m_logFilters)) return; if (filterFlags & FILTER_FLAG_ALERT) logSpawn(item, "killed", filterFlags); } void FilteredSpawnLog::logSpawn(const Item* item, const char* action, uint32_t flag) { // make sure the log file is open if (!open()) return; // get the current EQ Date&Time const QDateTime& eqDate = m_dateTimeMgr->updatedDateTime(); // log the information outputf("%s %s %s LOC %dy, %dx, %dz at %s (%s)\n", (const char*)m_filterMgr->filterString(flag), action, (const char*)item->name(), item->y(), item->x(), item->z(), eqDate.isValid() ? (const char*)eqDate.toString() : "", (const char*)item->spawnTimeStr()); flush(); } #include "filteredspawnlog.moc" Index: compass.cpp =================================================================== RCS file: /cvsroot/seq/showeq/src/compass.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- compass.cpp 30 Aug 2003 15:51:45 -0000 1.2 +++ compass.cpp 13 Sep 2005 15:23:11 -0000 1.3 @@ -167,3 +167,5 @@ paintCompass (&p); p.end(); } + +#include "compass.moc" Index: packetformat.cpp =================================================================== RCS file: /cvsroot/seq/showeq/src/packetformat.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- packetformat.cpp 25 Oct 2003 00:21:00 -0000 1.1 +++ packetformat.cpp 13 Sep 2005 15:23:12 -0000 1.2 @@ -4,124 +4,100 @@ * ShowEQ Distributed under GPL * http://www.sourceforge.net/projects/seq * - * Copyright 2000-2003 by the respective ShowEQ Developers - * Portions Copyright 2001-2003 Zaphod (do...@us...). + * Copyright 2000-2004 by the respective ShowEQ Developers + * Portions Copyright 2001-2004 Zaphod (do...@us...). */ /* Implementation of packet format classes class */ #include "packetformat.h" +#include "diagnosticmessages.h" -//---------------------------------------------------------------------- -// EQPacketFormatRaw class methods -QString EQPacketFormatRaw::headerFlags(const QString& prefix, - bool brief) const -{ - QString tmp; - if (!prefix.isEmpty()) - { - if (brief) - tmp = prefix + ": "; - else - tmp = prefix + "[Hdr (" + QString::number(flagsHi(), 16) + ", " - + QString::number(flagsLo(), 16) + "): "; - } - else if (!brief) - tmp = "[Hdr (" + QString::number(flagsHi(), 16) + ", " - + QString::number(flagsLo(), 16) + "): "; - - if (isARQ()) - tmp += "ARQ, "; - if (isClosingLo()) - tmp += "closingLo, "; - if (isFragment()) - tmp += "Fragment, "; - if (isASQ()) - tmp += "ASQ, "; - if (isSEQStart()) - tmp += "SEQStart, "; - if (isClosingHi()) - tmp += "closingHi, "; - if (isSEQEnd()) - tmp += "SEQEnd, "; - if (isARSP()) - tmp += "ARSP, "; - if (isNAK()) - tmp += "NAK, "; - if (isSpecARQ()) - tmp += "SpecARQ, "; - if (m_flagsHi.m_unknown1) - tmp += "HiUnknown1, "; - - if (skip() != 0) - tmp += QString("Skip: ") + QString::number(skip(), 16) + ", "; - - tmp += QString("seq: ") + QString::number(seq(), 16); - - tmp += "] "; - - if (!brief) - { - if (isARQ()) - tmp += QString("[ARQ: ") + QString::number(arq(), 16) + "] "; - - if (isFragment()) - { - tmp += QString("[FragSeq: ") + QString::number(fragSeq(), 16) - + ", FragCur: " + QString::number(fragCur(), 16) - + ", FragTot: " + QString::number(fragTot(), 16) + "] "; - } - } - - return tmp; -} +#include <zlib.h> //---------------------------------------------------------------------- -// EQPacketFormat class methods -EQPacketFormat::EQPacketFormat(EQPacketFormat& packet, bool copy) +// EQProtocolPacket class methods +EQProtocolPacket::EQProtocolPacket(EQProtocolPacket& packet, bool copy) + : m_ownCopy(copy) { + // Take the easy stuff first. + m_length = packet.m_length; + m_netOp = packet.m_netOp; + m_flags = packet.m_flags; + m_payloadLength = packet.m_payloadLength; + m_rawPayloadLength = packet.m_rawPayloadLength; + m_arqSeq = packet.m_arqSeq; + m_subpacket = packet.m_subpacket; + m_bDecoded = packet.m_bDecoded; + if (!copy) { - // the data is someone elses memory - m_ownCopy = false; - // just copy all their values m_packet = packet.m_packet; - m_length = packet.m_length; - m_postSkipData = packet.m_postSkipData; - m_postSkipDataLength = packet.m_postSkipDataLength; m_payload = packet.m_payload; - m_payloadLength = packet.m_payloadLength; - m_arq = packet.m_arq; + m_rawPayload = packet.m_rawPayload; + m_bAllocedPayload = false; } else { - init(packet.m_packet, packet.m_length, copy); + // Need to copy copy their values for buffers. m_packet first. + m_packet = new uint8_t[m_length]; + memcpy(m_packet, packet.m_packet, m_length); + + // Still have m_payload, m_rawPayload to do. Only if this packet + // alloced itself otherwise these point into m_packet. + if (packet.m_bAllocedPayload) + { + // Have packet owned payload to copy over. + m_rawPayload = new uint8_t[m_rawPayloadLength]; + memcpy(m_rawPayload, packet.m_rawPayload, m_rawPayloadLength); + m_bAllocedPayload = true; + + m_payload = m_rawPayload + (packet.m_payload - packet.m_rawPayload); + } + else + { + // No packet owned payload and init copied the raw payload. Just set + // pointers into m_packet + m_rawPayload = m_packet + (packet.m_rawPayload - packet.m_packet); + m_payload = m_packet + (packet.m_payload - packet.m_packet); + m_bAllocedPayload = false; + } } } -EQPacketFormat::~EQPacketFormat() +EQProtocolPacket::~EQProtocolPacket() { if (m_ownCopy) delete [] (uint8_t*)m_packet; + + if (m_bAllocedPayload) + { + delete[] m_rawPayload; + } } -EQPacketFormat& EQPacketFormat::operator=(const EQPacketFormat& packet) +EQProtocolPacket& EQProtocolPacket::operator=(const EQProtocolPacket& packet) { // if this was a deep copy, delete the existing data if (m_ownCopy) delete [] (uint8_t*)m_packet; + if (m_bAllocedPayload) + { + delete[] m_rawPayload; + m_bAllocedPayload = false; + } - // initialize as deep as this object previously was - init(packet.m_packet, packet.m_length, m_ownCopy); + init(packet.m_packet, packet.m_length, m_ownCopy, packet.m_subpacket); return *this; } -void EQPacketFormat::init(EQPacketFormatRaw* packet, - uint16_t length, - bool copy) +void EQProtocolPacket::init(uint8_t* packet, uint16_t length, + bool copy, bool subpacket) { + m_subpacket = subpacket; + if (!copy) { // the data is someone elses memory @@ -139,8 +115,7 @@ m_ownCopy = true; // allocate memory for the copy - // NOTE: We should use an allocater for this instead of normal new - m_packet = (EQPacketFormatRaw*)new uint8_t[length]; + m_packet = new uint8_t[length]; // copy the data memcpy((void*)m_packet, (void*)packet, length); @@ -153,54 +128,160 @@ init(); } -void EQPacketFormat::init() +//////////////////////////////////////////////////////////////////////////// +// Initialize the packet. After this is done, flags will be correct and the +// payload will be pointing at the payload, unless flags say this is a +// compressed packet all bets are off until you've called decode. +void EQProtocolPacket::init() { - // calculate position of first byte past the skipable data - m_postSkipData = ((uint8_t*)m_packet) + m_packet->skip() + 2; + // Get the net op code. Leave in network order. Need this to decide things. + m_netOp = *(uint16_t*)(m_packet); - // calculate the length of the rest of the data - m_postSkipDataLength = m_length - (m_postSkipData - ((uint8_t*)m_packet)); + // Now line up the payload as best we can. Note that if this packet is + // compressed, the opcode could potentially be wrong and the payload + // not aligned properly. You need to call decode to make sure. But on + // non-compressed packets this is good enough and you don't need to decode + if (! hasFlags()) + { + // No flags. Netopcode, then payload. Easy. + m_flags = 0; + m_rawPayload = &m_packet[2]; + m_bAllocedPayload = false; - // get the location of the payload - m_payload = m_packet->payload(); + // Total - net op - crc + m_rawPayloadLength = m_length - 2 - (hasCRC() ? 2 : 0); - // calculate the lenght of the payload (length - diff - len(checkSum)) - m_payloadLength = m_length - (m_payload - ((uint8_t*)m_packet)) - 4; - + // Decoded since no flags + m_payload = m_rawPayload; + m_payloadLength = m_rawPayloadLength; + m_bDecoded = true; + } + else + { + // Flags in the stream. Placement depends on whether this is an app or net + // opcode. + if (IS_APP_OPCODE(m_netOp)) + { + // opcode is an app opcode. Flags are byte 2 of the packet. + m_flags = m_packet[1]; - // make a local copy of the arq to speed up comparisons - m_arq = eqntohuint16(&m_postSkipData[2]); + // The opcode is split by the flags. If it is compressed (based on those + // above flags) then this is wrong but will fixed by decode + m_netOp = m_packet[2] << 8 | m_packet[0]; + } + else + { + // Flags at byte #3 after net opcode. m_netOp is correct. + m_flags = m_packet[2]; + } + + // Either way, let's start the payload at byte 4 for now. Decode may + // change this. Length is total - netop - flags - crc. + m_rawPayload = &m_packet[3]; + m_rawPayloadLength = m_length - 2 - 1 - (hasCRC() ? 2 : 0); + m_bAllocedPayload = false; + + if (! (m_flags & PROTOCOL_FLAG_COMPRESSED)) + { + // We have the packet here, let's finish the job. + m_payloadLength = m_rawPayloadLength; + m_payload = m_rawPayload; + + m_bDecoded = true; + } + else + { + m_bDecoded = false; + } + } + + // Take seq off the top if necessary + if (hasArqSeq() && m_bDecoded) + { + m_arqSeq = eqntohuint16(m_payload); + m_payload += 2; + m_payloadLength -= 2; + } } -QString EQPacketFormat::headerFlags(const QString& prefix, - bool brief) const +//////////////////////////////////////////////////////////////// +// Take a raw wire packet and align the payload, decompressing if necessary +bool EQProtocolPacket::decode(uint32_t maxPayloadLength) { - QString tmp; + // No double decoding... + if (m_bDecoded) + { + return true; + } - if (brief) - tmp = prefix + ": "; - else - tmp = prefix + " Hdr (" + QString::number(flagsHi(), 16) + ", " - + QString::number(flagsLo(), 16) + "): "; + // Decoding is only necessary for compressed packets + if (hasFlags() && getFlags() & PROTOCOL_FLAG_COMPRESSED) + { + // Compressed app opcode? If so, net op is half compressed. Align + // the buffer we need to uncompress. + if (IS_APP_OPCODE(getNetOpCode())) + { + // Total - 1/2 netop - flags - crc + m_payloadLength = m_length - 1 - 1 - (hasCRC() ? 2 : 0); + m_payload = &m_packet[2]; + } + else + { + // Total - netop - flags - crc + m_payloadLength = m_length - 2 - 1 - (hasCRC() ? 2 : 0); + m_payload = &m_packet[3]; + } - tmp += m_packet->headerFlags("", true); + // Compressed. Need to inflate. RawPayload is going to be our decompress + // buffer and needs to be managed properly. + m_rawPayload = new uint8_t[maxPayloadLength]; + m_rawPayloadLength = maxPayloadLength; // alloced size for zlib + m_bAllocedPayload = true; - if (!brief) - { - if (isARQ()) - tmp += QString("arq: ") + QString::number(arq(), 16) + ", "; - - if (isFragment()) + // Decompress + uint32_t retval = uncompress(m_rawPayload, (uLongf*)&m_rawPayloadLength, + m_payload, m_payloadLength); + + if (retval != 0) { - tmp += QString("FragSeq: ") + QString::number(fragSeq(), 16) - + ", FragCur: " + QString::number(fragCur(), 16) - + ", FragTot: " + QString::number(fragTot(), 16) + ", "; + seqWarn("Uncompress failed for packet op %04x, flags %02x. Error was %s (%d)", + getNetOpCode(), getFlags(), zError(retval), retval); + + delete[] m_rawPayload; + m_bAllocedPayload = false; + return false; } - tmp += QString("Opcode: ") + QString::number(eqntohuint16(payload()), 16); + // Align buffer pointers in the decompressed buffer and reconstitue the + // opcode if it's a split compressed app opcode + if (IS_APP_OPCODE(getNetOpCode())) + { + // Actual net op is first raw byte + first uncompressed byte + m_netOp = m_rawPayload[0] << 8 | m_packet[0]; + + // payload is the actual payload, skipping the 2nd byte of the opcode + m_payload = &m_rawPayload[1]; + m_payloadLength = m_rawPayloadLength - 1; + } + else + { + // Net op is correct. Payload is correct. + m_payload = m_rawPayload; + m_payloadLength = m_rawPayloadLength; + } + + // Take seq off the top if necessary + if (hasArqSeq()) + { + m_arqSeq = eqntohuint16(m_payload); + m_payload += 2; + m_payloadLength -= 2; + } + + m_bDecoded = true; } - return tmp; + return true; } //---------------------------------------------------------------------- @@ -224,6 +305,9 @@ // note whether or not this object ownw the memory m_ownCopy = copy; + // No session yet + m_sessionKey = 0; + // initialize the object init(ipdata); } @@ -233,6 +317,7 @@ { // note whether or not this object ownw the memory m_ownCopy = copy; + m_sessionKey = packet.getSessionKey(); if (copy) { @@ -312,17 +397,8 @@ length -= sizeof (struct udphdr); data += (sizeof (struct udphdr)); m_rawpayload = data; + m_rawpayloadSize = length; - // initialize underlying EQPacketFormat with the UDP payload - EQPacketFormat::init((EQPacketFormatRaw*)data, length, false); -} - -QString EQUDPIPPacketFormat::headerFlags(bool brief) const -{ - QString tmp; - tmp.sprintf("[%s:%d -> %s:%d]", - (const char*)getIPv4SourceA(), getSourcePort(), - (const char*)getIPv4DestA(), getDestPort()); - - return EQPacketFormat::headerFlags(tmp, brief); + // initialize underlying EQProtocolPacket with the UDP payload + EQProtocolPacket::init(data, length, false); } Index: seqlistview.cpp =================================================================== RCS file: /cvsroot/seq/showeq/src/seqlistview.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- seqlistview.cpp 24 May 2002 19:15:12 -0000 1.2 +++ seqlistview.cpp 13 Sep 2005 15:23:13 -0000 1.3 @@ -223,3 +223,5 @@ // trigger an update, otherwise things may look messy triggerUpdate(); } + +#include "seqlistview.moc" --- NEW FILE: guildlist.cpp --- /* * guildlist.cpp * * ShowEQ Distributed under GPL * http://www.sourceforge.net/projects/seq * * Copyright 2004 Zaphod (do...@us...). * */ #include "guildlist.h" #include "guildshell.h" #include "player.h" #include "zonemgr.h" #include "main.h" #include <qfont.h> #include <qpainter.h> #include <qfontdialog.h> #include <qinputdialog.h> #include <qpopupmenu.h> #include <qlineedit.h> #include <qlabel.h> #include <qlayout.h> //---------------------------------------------------------------------- // GuildListItem GuildListItem::GuildListItem(QListView* parent, const GuildMember* member, const GuildShell* guildShell) : QListViewItem(parent), m_member(member) { update(guildShell); } GuildListItem::~GuildListItem() { } void GuildListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QFont font = this->listView()->font(); // members that are actually logged in have their names in bold if (m_member->zoneId()) font.setBold(true); else font.setBold(false); p->setFont(font); QListViewItem::paintCell( p, cg, column, width, alignment ); } int GuildListItem::compare(QListViewItem *o, int col, bool ascending) const { if (!m_member) return -1; GuildListItem* other = (GuildListItem*)o; const GuildMember* otherMember = other->guildMember(); switch (col) { case 1: // Level if (m_member->level() == otherMember->level()) return 0; else return m_member->level() > otherMember->level() ? 1 : -1; case 3: // Rank if (m_member->guildRank() == otherMember->guildRank()) return 0; else return m_member->guildRank() > otherMember->guildRank() ? 1 : -1; case 4: // Last On if (m_member->lastOn() == otherMember->lastOn()) return 0; else return m_member->lastOn() > otherMember->lastOn() ? 1 : -1; default: return QListViewItem::compare(o, col, ascending); } } static const QString dateFormat("ddd MMM dd hh:mm:ss yyyy"); void GuildListItem::update(const GuildShell* guildShell) { if (!m_member) return; setText(tGuildListColName, m_member->name()); setText(tGuildListColLevel, QString::number(m_member->level())); setText(tGuildListColClass, m_member->classString()); setText(tGuildListColRank, m_member->guildRankString()); QDateTime dt; dt.setTime_t(m_member->lastOn()); setText(tGuildListColLastOn, dt.toString(dateFormat)); QString zoneString = guildShell->zoneString(m_member->zoneId()); if (m_member->zoneInstance()) zoneString += ":" + QString::number(m_member->zoneInstance()); setText(tGuildListColZone, zoneString); setText(tGuildListColPublicNote, m_member->publicNote()); } void GuildListItem::setGuildMember(const GuildMember* member) { m_member = member; } int GuildListItem::rtti() const { return 2004; } //---------------------------------------------------------------------- // GuildListWindow GuildListWindow::GuildListWindow(Player* player, GuildShell* guildShell, QWidget* parent, const char* name) : SEQWindow("GuildList", "ShowEQ - Guild Member List", parent, name), m_player(player), m_guildShell(guildShell), m_guildListItemDict(709), m_menu(0), m_membersOn(0) { m_guildListItemDict.setAutoDelete(false); // get whether to show offline guildmates or not m_showOffline = pSEQPrefs->getPrefBool("ShowOffline", preferenceName(), false); // get whether to keep the list sorted or not m_keepSorted = pSEQPrefs->getPrefBool("KeepSorted", preferenceName(), false); QBoxLayout* vLayout = new QVBoxLayout(boxLayout()); QHBoxLayout* hLayout= new QHBoxLayout(vLayout); // Guild Name m_guildName = new QLabel("Guild", this); m_guildName->setAlignment(AlignLeft|AlignVCenter|SingleLine); m_guildName->setFrameShape(LineEditPanel); m_guildName->setFrameShadow(Sunken); m_guildName->setMinimumWidth(50); m_guildName->setMaximumWidth(300); hLayout->addWidget(m_guildName, 1, AlignLeft); guildChanged(); // Guild Totals m_guildTotals = new QLabel("", this); m_guildTotals->setAlignment(AlignRight|AlignVCenter|SingleLine); m_guildTotals->setFrameShape(LineEditPanel); m_guildTotals->setFrameShadow(Sunken); m_guildTotals->setMinimumWidth(30); m_guildTotals->setMaximumWidth(120); hLayout->addWidget(m_guildTotals, 0, AlignRight); // create the spawn listview m_guildList = new SEQListView(preferenceName(), this, "guildlistview"); vLayout->addWidget(m_guildList); // setup the columns m_guildList->addColumn("Name"); m_guildList->addColumn("Level"); m_guildList->addColumn("Class"); m_guildList->addColumn("Rank"); m_guildList->addColumn("Last On", "LastOn"); m_guildList->addColumn("Zone"); m_guildList->addColumn("Public Note", "PublicNote"); // restore the columns settings from preferences m_guildList->restoreColumns(); connect(m_guildShell, SIGNAL(cleared()), this, SLOT(cleared())); connect(m_guildShell, SIGNAL(loaded()), this, SLOT(loaded())); connect(m_guildShell, SIGNAL(updated(const GuildMember*)), this, SLOT(updated(const GuildMember*))); connect(m_player, SIGNAL(guildChanged()), this, SLOT(guildChanged())); // populate the window populate(); } GuildListWindow::~GuildListWindow() { } QPopupMenu* GuildListWindow::menu() { if (m_menu) return m_menu; m_menu = new QPopupMenu; QPopupMenu* guildListColMenu = new QPopupMenu; m_menu->insertItem( "Show &Column", guildListColMenu); guildListColMenu->setCheckable(true); m_id_guildList_Cols[tGuildListColName] = guildListColMenu->insertItem("&Name"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColName], tGuildListColName); m_id_guildList_Cols[tGuildListColLevel] = guildListColMenu->insertItem("&Level"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColLevel], tGuildListColLevel); m_id_guildList_Cols[tGuildListColClass] = guildListColMenu->insertItem("&Class"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColClass], tGuildListColClass); m_id_guildList_Cols[tGuildListColRank] = guildListColMenu->insertItem("&Rank"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColRank], tGuildListColRank); m_id_guildList_Cols[tGuildListColLastOn] = guildListColMenu->insertItem("Last &On"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColLastOn], tGuildListColLastOn); m_id_guildList_Cols[tGuildListColZone] = guildListColMenu->insertItem("&Zone"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColZone], tGuildListColZone); m_id_guildList_Cols[tGuildListColPublicNote] = guildListColMenu->insertItem("&Public Note"); guildListColMenu->setItemParameter(m_id_guildList_Cols[tGuildListColPublicNote], tGuildListColPublicNote); connect (guildListColMenu, SIGNAL(activated(int)), this, SLOT(toggle_guildListCol(int))); m_menu->insertSeparator(-1); int x; x = m_menu->insertItem("Show Offline", this, SLOT(toggle_showOffline(int))); m_menu->setItemChecked(x, m_showOffline); x = m_menu->insertItem("Keep Sorted", this, SLOT(toggle_keepSorted(int))); m_menu->setItemChecked(x, m_keepSorted); m_menu->insertSeparator(-1); m_menu->insertItem("&Font...", this, SLOT(set_font(int))); m_menu->insertItem("&Caption...", this, SLOT(set_caption(int))); connect(m_menu, SIGNAL(aboutToShow()), this, SLOT(init_Menu())); return m_menu; } void GuildListWindow::cleared() { clear(); } void GuildListWindow::loaded() { populate(); } void GuildListWindow::updated(const GuildMember* member) { GuildListItem* memberItem = m_guildListItemDict.find((void*)member); // what to do if their is a member already if (memberItem) { // if not-showing offline users and this user has become offline, // then remove it if (!member->zoneId()) { // decrement members on count m_membersOn--; if (!m_showOffline) { // remove the item from the item dictionary m_guildListItemDict.remove((void*)member); // delete the item delete memberItem; } } else memberItem->update(m_guildShell); } // else { if (member->zoneId()) m_membersOn++; if (m_showOffline || (!m_showOffline && member->zoneId())) { // add the new guild member item memberItem = new GuildListItem(m_guildList, member, m_guildShell); // insert it into the dictionary m_guildListItemDict.insert((void*)member, memberItem); } } // make sure the guild list is sorted if (m_keepSorted) m_guildList->sort(); updateCount(); } void GuildListWindow::guildChanged() { QString guild(" Guild: %1 "); // set the guild name m_guildName->setText(guild.arg(m_player->guildTag())); } void GuildListWindow::init_Menu(void) { // make sure the menu bar settings are correct for (int i = 0; i < tGuildListColMaxCols; i++) m_menu->setItemChecked(m_id_guildList_Cols[i], m_guildList->columnVisible(i)); } void GuildListWindow::toggle_showOffline(int id) { // toggle immediate update value m_showOffline = !m_showOffline; m_menu->setItemChecked(id, m_showOffline); pSEQPrefs->setPrefBool("ShowOffline", preferenceName(), m_showOffline); // re-populate the window populate(); } void GuildListWindow::toggle_keepSorted(int id) { // toggle immediate update value m_keepSorted = !m_keepSorted; m_menu->setItemChecked(id, m_keepSorted); pSEQPrefs->setPrefBool("KeepSorted", preferenceName(), m_keepSorted); if (m_keepSorted) m_guildList->sort(); } void GuildListWindow::toggle_guildListCol( int id ) { int colnum; colnum = m_menu->itemParameter(id); if (menu()->isItemChecked(id)) m_guildList->setColumnVisible(colnum, false); else m_guildList->setColumnVisible(colnum, true); } void GuildListWindow::set_font(int id) { QFont newFont; bool ok = false; // get a new font newFont = QFontDialog::getFont(&ok, font(), this, caption() + " Font"); // if the user entered a font and clicked ok, set the windows font if (ok) setWindowFont(newFont); } void GuildListWindow::set_caption(int id) { bool ok = false; QString captionText = QInputDialog::getText("ShowEQ Guild List Window Caption", "Enter caption for the Guild List Window:", QLineEdit::Normal, caption(), &ok, this); // if the user entered a caption and clicked ok, set the windows caption if (ok) setCaption(captionText); } void GuildListWindow::clear(void) { // clear count m_membersOn = 0; // clear out the guild list item dictionary m_guildListItemDict.clear(); // clear the guild list contents m_guildList->clear(); updateCount(); } void GuildListWindow::populate(void) { GuildMember* member; GuildListItem* memberItem; // make sure everything is out of the list view first... clear(); // disable updates setUpdatesEnabled(false); // iterate over the members GuildMemberDictIterator it(m_guildShell->members()); // if showing offline members just insert them all if (m_showOffline) { // iterate over all the members while ((member = it.current())) { // increment members on count for each member on if (member->zoneId()) m_membersOn++; // add the new guild member item memberItem = new GuildListItem(m_guildList, member, m_guildShell); // insert it into the dictionary m_guildListItemDict.insert((void*)member, memberItem); ++it; } } else { // iterate over all the members while ((member = it.current())) { // all online members will have a non-zero zone id. if (member->zoneId()) { // increment members on count for each member on m_membersOn++; // add the new guild member item memberItem = new GuildListItem(m_guildList, member, m_guildShell); // insert it into the dictionary m_guildListItemDict.insert((void*)member, memberItem); } ++it; } } // make sure the guild list is sorted m_guildList->sort(); // update the counts updateCount(); // re-enable updates and force a repaint setUpdatesEnabled(true); repaint(); } void GuildListWindow::updateCount(void) { QString text(" %1 on/%2 total "); m_guildTotals->setText(text.arg(m_membersOn).arg(m_guildShell->members().count())); } #include "guildlist.moc" Index: combatlog.h =================================================================== RCS file: /cvsroot/seq/showeq/src/combatlog.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- combatlog.h 10 Sep 2003 06:24:05 -0000 1.8 +++ combatlog.h 13 Sep 2005 15:23:11 -0000 1.9 @@ -87,6 +87,7 @@ int getTotalDamage() { return m_iTotalDamage; }; int getTotalAttacks() { return m_iTotalAttacks; }; + void clear(void); void addMiss(int iMissReason); void addHit(int iDamage); @@ -166,6 +167,7 @@ void resetDPS(); void clearMob(); void clearOffense(); + void clear(void); private: Index: packetformat.h =================================================================== RCS file: /cvsroot/seq/showeq/src/packetformat.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- packetformat.h 25 Oct 2003 00:21:00 -0000 1.1 +++ packetformat.h 13 Sep 2005 15:23:12 -0000 1.2 @@ -4,8 +4,8 @@ * ShowEQ Distributed under GPL * http://www.sourceforge.net/projects/seq * - * Copyright 2000-2003 by the respective ShowEQ Developers - * Portions Copyright 2001-2003 Zaphod (do...@us...). + * Copyright 2000-2004 by the respective ShowEQ Developers + * Portions Copyright 2001-2004 Zaphod (do...@us...). */ #ifndef _PACKETFORMAT_H_ @@ -42,265 +42,183 @@ // Forward declarations class QString; -//---------------------------------------------------------------------- -// enumerated types -enum EQPacketHeaderFlagsHi -{ - seqEnd = 0x80, - closingHi = 0x40, - seqStart = 0x20, - asq = 0x10, - fragment = 0x08, - closingLo = 0x04, - ackRequest = 0x02, -}; - -enum EQPacketHeaderFlagsLo -{ - ackResponse = 0x04, - specAckRequest = 0x01 -}; - -//---------------------------------------------------------------------- -// EQPacketFormatRaw - -// Why EQPacketFormatRaw, because the EQPacket name was taken... ;-) -// (/thank Xylor for the format of the packets) -// (/thank fee for helping me to understand the format) -// Some simplifying assumptions based on observed packet behavior -// that are used to optimize access -// 1) the arq bit is always set when the fragment bit is set -// 2) the arq is always after 2 bytes past the embedded ack/req data. -// 3) the fragment stuff is always 4 bytes after the embedded ack/req data -// based on 1). -// -#pragma pack(1) -class EQPacketFormatRaw -{ - public: - // accessors to check for individual flasg - bool isARQ() const { return m_flagsHi.m_arq; } - bool isClosingLo() const { return m_flagsHi.m_closingLo; } - bool isFragment() const { return m_flagsHi.m_fragment; } - bool isASQ() const { return m_flagsHi.m_asq; } - bool isSEQStart() const { return m_flagsHi.m_seqStart; } - bool isClosingHi() const { return m_flagsHi.m_closingHi; } - bool isSEQEnd() const { return m_flagsHi.m_seqEnd; } - bool isARSP() const { return m_flagsLo.m_arsp; } - bool isSpecARQ() const { return m_flagsLo.m_specARQ; } - bool isNAK() const { return m_flagsLo.m_nak; } - - // Check flag against the EQPacketHeaderFlag{Hi, Lo} values - bool checkFlagHi(uint8_t mask) const - { return ((m_flagsHiVal & mask) != 0); } - bool checkFlagLo(uint8_t mask) const - { return ((m_flagsLoVal & mask) != 0); } - - // accessors to return the flag values - uint8_t flagsHi() const { return m_flagsHiVal; } - uint8_t flagsLo() const { return m_flagsLoVal; } - - // number of uint8_t's to skip when examining packets - uint8_t skip() const - { - return ((uint8_t)m_flagsLo.m_skip + - (isARSP() ? 2 : 0) + - (isNAK() ? 2 : 0)); - } - - // The following accessors are only valid if the corresponding - // flag is set. - uint16_t seq() const { return eqntohuint16(&m_data[0]); } - uint16_t arsp() const { return eqntohuint16(&m_data[2]); } - uint16_t nak() const { return eqntohuint16(&m_data[4]); } - uint16_t arq() const - { return eqntohuint16(&m_data[2 + skip()]); } - uint16_t fragSeq() const - { return eqntohuint16(&m_data[4 + skip()]); } - uint16_t fragCur() const - { return eqntohuint16(&m_data[6 + skip()]); } - uint16_t fragTot() const - { return eqntohuint16(&m_data[8 + skip()]); } - uint8_t asqHigh() const { return m_data[10 + skip()]; } - uint8_t asqLow() const { return m_data[11 + skip()]; } - uint32_t crc32(uint16_t len) const - { return eqntohuint32(&m_data[len - 2 - 4]); } +// Net Op Codes in net order. Underneath, there are actually channels +// 0-3, where 0x0900 is OP_Packet on channel 0, 0x0a00 is OP_Packet on +// channel 1, 0x0b00 is OP_Packet on channel 2, etc. and the same +// with OP_Oversized for 0x0d00-0x1000. Only channel 0 seems used. +static const uint16_t OP_SessionRequest = 0x0100; +static const uint16_t OP_SessionResponse = 0x0200; +static const uint16_t OP_Combined = 0x0300; +static const uint16_t OP_SessionDisconnect = 0x0500; +static const uint16_t OP_KeepAlive = 0x0600; +static const uint16_t OP_SessionStatRequest = 0x0700; +static const uint16_t OP_SessionStatResponse= 0x0800; +static const uint16_t OP_Packet = 0x0900; +static const uint16_t OP_Oversized = 0x0d00; +static const uint16_t OP_AckFuture = 0x1100; +static const uint16_t OP_Ack = 0x1500; +static const uint16_t OP_AppCombined = 0x1900; +static const uint16_t OP_AckAfterDisconnect = 0x1d00; - uint8_t* payload() - { - return m_data + // m_data is already passed the flag bytes - (skip() // skip arsp, specARQ data - + (isASQ() ? 1 : 0) // skip asqHigh - + (isARQ() ? 2 : 0) // skip arq - + ((isASQ() && isARQ()) ? 1 : 0) // skip asqLow - + (isFrag... [truncated message content] |