Merge branch 'small_stage_cleanup' of git://github.com/addtheice/Server into addtheice-small_stage_cleanup

This commit is contained in:
KimLS 2013-05-24 00:56:20 -07:00
commit ee7d7c6f24
28 changed files with 380 additions and 535 deletions

View File

@ -10,7 +10,6 @@ SET(common_sources
database.cpp database.cpp
dbasync.cpp dbasync.cpp
dbcore.cpp dbcore.cpp
DBMemLeak.cpp
debug.cpp debug.cpp
emu_opcodes.cpp emu_opcodes.cpp
EmuTCPConnection.cpp EmuTCPConnection.cpp
@ -103,7 +102,6 @@ SET(common_headers
database.h database.h
dbasync.h dbasync.h
dbcore.h dbcore.h
DBMemLeak.h
debug.h debug.h
deity.h deity.h
emu_opcodes.h emu_opcodes.h

View File

@ -20,17 +20,9 @@
#include "Condition.h" #include "Condition.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#else
#include <pthread.h>
#include <sys/time.h>
#include <errno.h>
#endif
#ifdef _WINDOWS Condition::Condition()
{
Condition::Condition()
{
m_events[SignalEvent] = CreateEvent (nullptr, // security m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event? FALSE, // is auto-reset event?
FALSE, // is signaled initially? FALSE, // is signaled initially?
@ -41,33 +33,33 @@ Condition::Condition()
nullptr); // name nullptr); // name
m_waiters = 0; m_waiters = 0;
InitializeCriticalSection(&CSMutex); InitializeCriticalSection(&CSMutex);
} }
Condition::~Condition() Condition::~Condition()
{ {
DeleteCriticalSection(&CSMutex); DeleteCriticalSection(&CSMutex);
CloseHandle(m_events[SignalEvent]); CloseHandle(m_events[SignalEvent]);
CloseHandle(m_events[BroadcastEvent]); CloseHandle(m_events[BroadcastEvent]);
} }
void Condition::Signal() void Condition::Signal()
{ {
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
if(m_waiters > 0) if(m_waiters > 0)
SetEvent(m_events[SignalEvent]); SetEvent(m_events[SignalEvent]);
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
} }
void Condition::SignalAll() void Condition::SignalAll()
{ {
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
if(m_waiters > 0) if(m_waiters > 0)
SetEvent(m_events[BroadcastEvent]); SetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
} }
void Condition::Wait() void Condition::Wait()
{ {
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
m_waiters++; m_waiters++;
@ -85,49 +77,51 @@ void Condition::Wait()
ResetEvent(m_events[BroadcastEvent]); ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
} }
#else
#include <pthread.h>
#include <sys/time.h>
#include <errno.h>
#else //!WIN32 Condition::Condition()
{
Condition::Condition()
{
pthread_cond_init(&cond,nullptr); pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,nullptr); pthread_mutex_init(&mutex,nullptr);
} }
void Condition::Signal() void Condition::Signal()
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond); pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
void Condition::SignalAll() void Condition::SignalAll()
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
pthread_cond_broadcast(&cond); pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
void Condition::Wait() void Condition::Wait()
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond,&mutex); pthread_cond_wait(&cond,&mutex);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
/* /*
I commented this specifically because I think it might be very I commented this specifically because I think it might be very
difficult to write a windows counterpart to it, so I would like difficult to write a windows counterpart to it, so I would like
to discourage its use until we can confirm that it can be reasonably to discourage its use until we can confirm that it can be reasonably
implemented on windows. implemented on windows.
bool Condition::TimedWait(unsigned long usec) bool Condition::TimedWait(unsigned long usec)
{ {
struct timeval now; struct timeval now;
struct timespec timeout; struct timespec timeout;
int retcode=0; int retcode=0;
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
gettimeofday(&now,nullptr); gettimeofday(&now,nullptr);
now.tv_usec+=usec; now.tv_usec+=usec;
@ -139,15 +133,16 @@ int retcode=0;
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return retcode!=ETIMEDOUT; return retcode!=ETIMEDOUT;
} }
*/ */
Condition::~Condition() Condition::~Condition()
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
pthread_cond_destroy(&cond); pthread_cond_destroy(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
pthread_mutex_destroy(&mutex); pthread_mutex_destroy(&mutex);
} }
#endif #endif

View File

@ -1,62 +0,0 @@
#ifdef _EQDEBUG
#include "../common/debug.h"
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "../common/Mutex.h"
#include "DBMemLeak.h"
#include <crtdbg.h>
#ifdef _WINDOWS
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
DBMemLeak dbmemleak;
LinkedList<DBMemLeakStruct*>* list = 0;
Mutex MDBMemLeak;
DBMemLeak::DBMemLeak() {
list = new LinkedList<DBMemLeakStruct*>;
}
DBMemLeak::~DBMemLeak() {
LinkedListIterator<DBMemLeakStruct*> iterator(*list);
iterator.Reset();
while (iterator.MoreElements()) {
char tmp[200];
snprintf(tmp, sizeof(tmp) - 3, "DB Mem Leak: Block=%6d, Query=%s", iterator.GetData()->memblock, iterator.GetData()->query);
snprintf(tmp, sizeof(tmp), "%s\n", tmp);
OutputDebugString(tmp);
iterator.Advance();
}
safe_delete(list);
}
void DBMemLeak::Alloc(const void* result, const char* query) {
LockMutex lock(&MDBMemLeak);
long requestNumber;
uint8* tmp2 = new uint8;
_CrtIsMemoryBlock( tmp2, 1, &requestNumber, 0, 0 );
safe_delete(tmp2);
DBMemLeakStruct* tmp = (DBMemLeakStruct*) new uchar[sizeof(DBMemLeakStruct) + strlen(query) + 1];
tmp->result = result;
tmp->memblock = requestNumber;
strcpy(tmp->query, query);
list->Append(tmp);
}
void DBMemLeak::Free(const void* result) {
LockMutex lock(&MDBMemLeak);
LinkedListIterator<DBMemLeakStruct*> iterator(*list);
iterator.Reset();
while (iterator.MoreElements()) {
if (result == iterator.GetData()->result)
iterator.RemoveCurrent();
else
iterator.Advance();
}
}
#endif

View File

@ -1,25 +0,0 @@
#ifdef _EQDEBUG
#ifndef DBMemLeak_H
#define DBMemLeak_H
#include "../common/types.h"
#include "../common/linked_list.h"
#define mysql_free_result(r) { DBMemLeak::Free(r); mysql_free_result(r); }
struct DBMemLeakStruct {
const void* result;
uint32 memblock;
char query[0];
};
class DBMemLeak {
public:
DBMemLeak();
~DBMemLeak();
static void Alloc(const void* result, const char* query);
static void Free(const void* result);
};
#endif
#endif

View File

@ -15,15 +15,32 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "EQPacket.h"
#include "EQStream.h"
#include "misc.h"
#include "Mutex.h"
#include "op_codes.h"
#include "CRC16.h"
#include <string> #include <string>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <sys/types.h> #include <algorithm>
#if defined(ZONE) || defined(WORLD)
#define RETRANSMITS
#endif
#ifdef RETRANSMITS
#include "rulesys.h"
#endif
#ifdef _WINDOWS #ifdef _WINDOWS
#include <time.h> #include <time.h>
#else #else
#include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/time.h> #include <sys/time.h>
@ -32,20 +49,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include "EQPacket.h"
#include "EQStream.h"
//#include "EQStreamFactory.h"
#include "misc.h"
#include "Mutex.h"
#include "op_codes.h"
#include "CRC16.h"
#if defined(ZONE) || defined(WORLD)
#define RETRANSMITS
#endif
#ifdef RETRANSMITS
#include "rulesys.h"
#endif
//for logsys //for logsys
#define _L "%s:%d: " #define _L "%s:%d: "

View File

@ -16,20 +16,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifdef _WINDOWS #include "debug.h"
// VS6 doesn't like the length of STL generated names: disabling #include "StringUtil.h"
#pragma warning(disable:4786)
// Quagmire: Dont know why the one in debug.h doesnt work, but it doesnt.
#endif
#include "../common/debug.h"
/*#ifdef _CRTDBG_MAP_ALLOC
#undef new
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
*/
#include <sstream>
#include <iostream>
#include <limits.h>
#include "Item.h" #include "Item.h"
#include "database.h" #include "database.h"
#include "misc.h" #include "misc.h"
@ -37,6 +25,11 @@
#include "shareddb.h" #include "shareddb.h"
#include "classes.h" #include "classes.h"
#include <limits.h>
#include <sstream>
#include <iostream>
int32 NextItemInstSerialNumber = 1; int32 NextItemInstSerialNumber = 1;
static inline int32 GetNextItemInstSerialNumber() { static inline int32 GetNextItemInstSerialNumber() {
@ -1059,103 +1052,75 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
return SLOT_INVALID; return SLOT_INVALID;
} }
void Inventory::dumpInventory() { void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) {
iter_contents itb;
if (!inst || !inst->IsType(ItemClassContainer))
return;
// Go through bag, if bag
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
std::string subSlot;
StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
std::cout << subSlot << std::endl;
}
}
void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection) {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = nullptr; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) for (it=collection.begin(); it!=collection.end(); it++) {
printf("Worn items:\n");
for (it=m_worn.begin(); it!=m_worn.end(); it++) {
inst = it->second; inst = it->second;
it->first; it->first;
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); std::string slot;
StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
std::cout << slot << std::endl;
// Go through bag, if bag dumpBagContents(inst, &it);
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
} }
}
printf("Inventory items:\n"); void Inventory::dumpWornItems() {
for (it=m_inv.begin(); it!=m_inv.end(); it++) { std::cout << "Worn items:" << std::endl;
inst = it->second; dumpItemCollection(m_worn);
it->first; }
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); void Inventory::dumpInventory() {
std::cout << "Inventory items:" << std::endl;
dumpItemCollection(m_inv);
}
// Go through bag, if bag void Inventory::dumpBankItems() {
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} std::cout << "Bank items:" << std::endl;
} dumpItemCollection(m_bank);
} }
printf("Bank items:\n"); void Inventory::dumpSharedBankItems() {
for (it=m_bank.begin(); it!=m_bank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); std::cout << "Shared Bank items:" << std::endl;
dumpItemCollection(m_shbank);
}
// Go through bag, if bag void Inventory::dumpEntireInventory() {
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { dumpWornItems();
ItemInst* baginst = itb->second; dumpInventory();
if(!baginst || !baginst->GetItem()) dumpBankItems();
continue; dumpSharedBankItems();
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} std::cout << std::endl;
}
}
printf("Shared Bank items:\n");
for (it=m_shbank.begin(); it!=m_shbank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
}
printf("\n");
fflush(stdout);
} }
// Internal Method: Retrieves item within an inventory bucket // Internal Method: Retrieves item within an inventory bucket

View File

@ -195,7 +195,11 @@ public:
// Test whether a given slot can support a container item // Test whether a given slot can support a container item
static bool SupportsContainers(int16 slot_id); static bool SupportsContainers(int16 slot_id);
void dumpEntireInventory();
void dumpWornItems();
void dumpInventory(); void dumpInventory();
void dumpBankItems();
void dumpSharedBankItems();
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
@ -207,6 +211,9 @@ protected:
// Protected Methods // Protected Methods
/////////////////////////////// ///////////////////////////////
void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
void dumpBagContents(ItemInst *inst, iter_inst *it);
// Retrieves item within an inventory bucket // Retrieves item within an inventory bucket
ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const; ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const;

View File

@ -15,21 +15,25 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <string>
#include <vector>
#include "debug.h" #include "debug.h"
#include "ProcLauncher.h" #include "ProcLauncher.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#endif #endif
ProcLauncher ProcLauncher::s_launcher; ProcLauncher ProcLauncher::s_launcher;

View File

@ -126,27 +126,6 @@ bool strn0cpyt(char* dest, const char* source, uint32 size) {
return (bool) (source[strlen(dest)] == 0); return (bool) (source[strlen(dest)] == 0);
} }
const char *MakeUpperString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeUpperString(source, str);
return str;
}
void MakeUpperString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = toupper(*source);
target++;source++;
}
*target = 0;
}
const char *MakeLowerString(const char *source) { const char *MakeLowerString(const char *source) {
static char str[128]; static char str[128];
if (!source) if (!source)

View File

@ -23,19 +23,9 @@
void vStringFormat(std::string& output, const char* format, va_list args); void vStringFormat(std::string& output, const char* format, va_list args);
void StringFormat(std::string& output, const char* format, ...); void StringFormat(std::string& output, const char* format, ...);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// return: pointer to static buffer with the target string
const char *MakeUpperString(const char *source);
const char *MakeLowerString(const char *source); const char *MakeLowerString(const char *source);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1
void MakeUpperString(const char *source, char *target);
void MakeLowerString(const char *source, char *target); void MakeLowerString(const char *source, char *target);

View File

@ -216,7 +216,7 @@ public:
const char *GetRaidLeaderName(uint32 rid); const char *GetRaidLeaderName(uint32 rid);
/* /*
* Database Varaibles * Database Variables
*/ */
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len); bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
bool SetVariable(const char* varname, const char* varvalue); bool SetVariable(const char* varname, const char* varvalue);

View File

@ -7,7 +7,6 @@
//#include <winsock.h> //#include <winsock.h>
#endif #endif
#include <mysql.h> #include <mysql.h>
#include "../common/DBMemLeak.h"
#include "../common/types.h" #include "../common/types.h"
#include "../common/Mutex.h" #include "../common/Mutex.h"
#include "../common/linked_list.h" #include "../common/linked_list.h"

View File

@ -45,20 +45,7 @@
#ifndef _CRTDBG_MAP_ALLOC #ifndef _CRTDBG_MAP_ALLOC
#include <stdlib.h> #include <stdlib.h>
#include <crtdbg.h> #include <crtdbg.h>
#if (_MSC_VER < 1300)
#include <new>
#include <memory>
#define _CRTDBG_MAP_ALLOC
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#endif #endif
#endif
#endif
#ifdef _WINDOWS
// VS6 doesn't like the length of STL generated names: disabling
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#endif #endif
#ifndef EQDEBUG_H #ifndef EQDEBUG_H

View File

@ -18,9 +18,12 @@
#include "debug.h" #include "debug.h"
#include "logsys.h" #include "logsys.h"
#include "StringUtil.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <string>
void log_message(LogType type, const char *fmt, ...) { void log_message(LogType type, const char *fmt, ...) {
va_list args; va_list args;
@ -30,10 +33,10 @@ void log_message(LogType type, const char *fmt, ...) {
} }
void log_messageVA(LogType type, const char *fmt, va_list args) { void log_messageVA(LogType type, const char *fmt, va_list args) {
char prefix_buffer[256]; std::string prefix_buffer;
snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name);
prefix_buffer[255] = '\0';
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); StringFormat(prefix_buffer, "[%s] ", log_type_info[type].name);
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args);
} }

View File

@ -1,7 +1,9 @@
#include "shareddb.h"
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include "shareddb.h"
#include "mysql.h"
#include "Item.h" #include "Item.h"
#include "classes.h" #include "classes.h"
#include "rulesys.h" #include "rulesys.h"

View File

@ -20,6 +20,8 @@
#include "ErrorLog.h" #include "ErrorLog.h"
#include <string> #include <string>
#include <string>
extern ErrorLog *server_log; extern ErrorLog *server_log;
bool Encryption::LoadCrypto(std::string name) bool Encryption::LoadCrypto(std::string name)

View File

@ -2,8 +2,34 @@
#include "../common/EQPacket.h" #include "../common/EQPacket.h"
#include "../common/EQStreamIntf.h" #include "../common/EQStreamIntf.h"
#include "../common/misc.h" #include "../common/misc.h"
#include "../common/rulesys.h"
#include "../common/emu_opcodes.h"
#include "../common/eq_packet_structs.h"
#include "../common/packet_dump.h"
#include "../common/EQStreamIntf.h"
#include "../common/Item.h"
#include "../common/races.h"
#include "../common/classes.h"
#include "../common/languages.h"
#include "../common/skills.h"
#include "../common/extprofile.h"
#include "../common/StringUtil.h"
#include "../common/clientversions.h"
#include "client.h"
#include "worlddb.h"
#include "WorldConfig.h"
#include "LoginServer.h"
#include "LoginServerList.h"
#include "zoneserver.h"
#include "zonelist.h"
#include "clientlist.h"
#include "wguild_mgr.h"
#include "SoFCharCreateData.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -17,44 +43,18 @@
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#include <winsock.h> #include <winsock.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else #else
#include <sys/socket.h>
#ifdef FREEBSD //Timothy Whitman - January 7, 2003 #ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "client.h"
#include "../common/emu_opcodes.h"
#include "../common/eq_packet_structs.h"
#include "../common/packet_dump.h"
#include "../common/EQStreamIntf.h"
#include "worlddb.h"
#include "../common/Item.h"
#include "../common/races.h"
#include "../common/classes.h"
#include "../common/languages.h"
#include "../common/skills.h"
#include "../common/extprofile.h"
#include "../common/StringUtil.h"
#include "WorldConfig.h"
#include "LoginServer.h"
#include "LoginServerList.h"
#include "zoneserver.h"
#include "zonelist.h"
#include "clientlist.h"
#include "wguild_mgr.h"
#include "../common/rulesys.h"
#include "SoFCharCreateData.h"
#include "../common/clientversions.h"
std::vector<RaceClassAllocation> character_create_allocations; std::vector<RaceClassAllocation> character_create_allocations;
std::vector<RaceClassCombos> character_create_race_class_combos; std::vector<RaceClassCombos> character_create_race_class_combos;

View File

@ -1,18 +1,21 @@
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/logsys.h" #include "../common/logsys.h"
#include "../common/StringUtil.h"
#include "zoneserver.h" #include "zoneserver.h"
#include "client.h" #include "client.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
void log_message_clientVA(LogType type, Client *who, const char *fmt, va_list args) { void log_message_clientVA(LogType type, Client *who, const char *fmt, va_list args) {
char prefix_buffer[256];
snprintf(prefix_buffer, 255, "[%s] %s: ", log_type_info[type].name, who->GetAccountName());
prefix_buffer[255] = '\0';
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); std::string prefix_buffer;
StringFormat(prefix_buffer,"[%s] %s: ", log_type_info[type].name, who->GetAccountName());
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args);
} }
void log_message_client(LogType type, Client *who, const char *fmt, ...) { void log_message_client(LogType type, Client *who, const char *fmt, ...) {
@ -24,18 +27,17 @@ void log_message_client(LogType type, Client *who, const char *fmt, ...) {
void log_message_zoneVA(LogType type, ZoneServer *who, const char *fmt, va_list args) { void log_message_zoneVA(LogType type, ZoneServer *who, const char *fmt, va_list args) {
char prefix_buffer[256]; std::string prefix_buffer, zone_tag;
char zone_tag[65];
const char *zone_name=who->GetZoneName(); const char *zone_name=who->GetZoneName();
if (*zone_name==0)
snprintf(zone_tag,64,"[%d]", who->GetID()); if (zone_name == nullptr)
StringFormat(zone_tag,"[%d]", who->GetID());
else else
snprintf(zone_tag,64,"[%d] [%s]",who->GetID(),zone_name); StringFormat(zone_tag,"[%d] [%s]",who->GetID(),zone_name);
snprintf(prefix_buffer, 255, "[%s] %s ", log_type_info[type].name, zone_tag); StringFormat(prefix_buffer, "[%s] %s ", log_type_info[type].name, zone_tag.c_str());
prefix_buffer[255] = '\0';
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args);
} }
void log_message_zone(LogType type, ZoneServer *who, const char *fmt, ...) { void log_message_zone(LogType type, ZoneServer *who, const char *fmt, ...) {

View File

@ -27,12 +27,10 @@ Child of the Mob class.
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #define strncasecmp _strnicmp
#define strncasecmp _strnicmp #define strcasecmp _stricmp
#define strcasecmp _stricmp
#endif #endif
#include "masterentity.h" #include "masterentity.h"

View File

@ -24,13 +24,12 @@ target to center around.
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #define strncasecmp _strnicmp
#define strncasecmp _strnicmp #define strcasecmp _stricmp
#define strcasecmp _stricmp
#endif #endif
#include "masterentity.h" #include "masterentity.h"

View File

@ -26,19 +26,13 @@
// for windows compile // for windows compile
#ifdef _WINDOWS #ifdef _WINDOWS
#define abs64 _abs64 #define abs64 _abs64
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else #else
#include <stdarg.h> #include <stdarg.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "../common/unix.h" #include "../common/unix.h"
#define abs64 abs #define abs64 abs
#endif #endif
extern volatile bool RunLoops; extern volatile bool RunLoops;
@ -601,7 +595,7 @@ bool Client::Save(uint8 iCommitNow) {
p_timers.Store(&database); p_timers.Store(&database);
// printf("Dumping inventory on save:\n"); // printf("Dumping inventory on save:\n");
// m_inv.dumpInventory(); // m_inv.dumpEntireInventory();
SaveTaskState(); SaveTaskState();
if (iCommitNow <= 1) { if (iCommitNow <= 1) {

View File

@ -19,8 +19,6 @@
#define CLIENT_H #define CLIENT_H
class Client; class Client;
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/ptimer.h" #include "../common/ptimer.h"
#include "../common/emu_opcodes.h" #include "../common/emu_opcodes.h"
@ -30,29 +28,39 @@ class Client;
#include "../common/EQPacket.h" #include "../common/EQPacket.h"
#include "../common/linked_list.h" #include "../common/linked_list.h"
#include "../common/extprofile.h" #include "../common/extprofile.h"
#include "zonedb.h"
#include "errno.h"
#include "../common/classes.h" #include "../common/classes.h"
#include "../common/races.h" #include "../common/races.h"
#include "../common/deity.h" #include "../common/deity.h"
#include "../common/seperator.h"
#include "../common/Item.h"
#include "../common/guilds.h"
#include "../common/item_struct.h"
#include "../common/clientversions.h"
#include "zonedb.h"
#include "errno.h"
#include "mob.h" #include "mob.h"
#include "npc.h" #include "npc.h"
#include "merc.h" #include "merc.h"
#include "zone.h" #include "zone.h"
#include "AA.h" #include "AA.h"
#include "../common/seperator.h"
#include "../common/Item.h"
#include "updatemgr.h" #include "updatemgr.h"
#include "../common/guilds.h"
#include "questmgr.h" #include "questmgr.h"
#include "QGlobals.h"
#ifdef _WINDOWS
// since windows defines these within windef.h (which windows.h include)
// we are required to undefine these to use min and max from <algorithm>
#undef min
#undef max
#endif
#include <float.h> #include <float.h>
#include <set> #include <set>
#include <string> #include <string>
#include "../common/item_struct.h"
#include "../common/clientversions.h"
#include "QGlobals.h"
#include <algorithm> #include <algorithm>
#define CLIENT_TIMEOUT 90000 #define CLIENT_TIMEOUT 90000
#define CLIENT_LD_TIMEOUT 30000 // length of time client stays in zone after LDing #define CLIENT_LD_TIMEOUT 30000 // length of time client stays in zone after LDing
#define TARGETING_RANGE 200 // range for /assist and /target #define TARGETING_RANGE 200 // range for /assist and /target

View File

@ -15,19 +15,21 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <algorithm>
#include "../common/debug.h" #include "../common/debug.h"
#include "masterentity.h"
#include "worldserver.h"
#include "zonedb.h"
#include "../common/spdat.h" #include "../common/spdat.h"
#include "../common/packet_dump.h" #include "../common/packet_dump.h"
#include "../common/packet_functions.h" #include "../common/packet_functions.h"
#include "petitions.h"
#include "../common/serverinfo.h" #include "../common/serverinfo.h"
#include "../common/ZoneNumbers.h" #include "../common/ZoneNumbers.h"
#include "../common/moremath.h" #include "../common/moremath.h"
#include "../common/guilds.h" #include "../common/guilds.h"
#include "../common/logsys.h" #include "../common/logsys.h"
#include "masterentity.h"
#include "worldserver.h"
#include "zonedb.h"
#include "petitions.h"
#include "StringIDs.h" #include "StringIDs.h"
#include "NpcAI.h" #include "NpcAI.h"

View File

@ -9192,7 +9192,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) {
#ifdef _EQDEBUG #ifdef _EQDEBUG
printf("Dumping inventory on load:\n"); printf("Dumping inventory on load:\n");
m_inv.dumpInventory(); m_inv.dumpEntireInventory();
#endif #endif
//lost in current PP //lost in current PP

View File

@ -20,12 +20,13 @@
#include "../common/types.h" #include "../common/types.h"
#include "../common/linked_list.h" #include "../common/linked_list.h"
#include "zonedb.h"
#include "../common/eq_constants.h"
#include "zonedump.h"
#include "zonedbasync.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"
#include "../common/bodytypes.h" #include "../common/bodytypes.h"
#include "../common/eq_constants.h"
#include "zonedb.h"
#include "zonedump.h"
#include "zonedbasync.h"
#include "QGlobals.h" #include "QGlobals.h"
// max number of newspawns to send per bulk packet // max number of newspawns to send per bulk packet

View File

@ -1,4 +1,3 @@
#define DONT_SHARED_OPCODES
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
@ -16,34 +15,11 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define DONT_SHARED_OPCODES
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/features.h" #include "../common/features.h"
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#ifdef _CRTDBG_MAP_ALLOC
#undef new
#endif
#include <fstream>
#ifdef _CRTDBG_MAP_ALLOC
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#ifdef _WINDOWS
#include <conio.h>
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
volatile bool RunLoops = true;
extern volatile bool ZoneLoaded;
#include "../common/queue.h" #include "../common/queue.h"
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/EQStream.h" #include "../common/EQStream.h"
@ -52,7 +28,6 @@ extern volatile bool ZoneLoaded;
#include "../common/Mutex.h" #include "../common/Mutex.h"
#include "../common/version.h" #include "../common/version.h"
#include "../common/EQEMuError.h" #include "../common/EQEMuError.h"
#include "ZoneConfig.h"
#include "../common/packet_dump_file.h" #include "../common/packet_dump_file.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/guilds.h" #include "../common/guilds.h"
@ -60,16 +35,18 @@ extern volatile bool ZoneLoaded;
#include "../common/patches/patches.h" #include "../common/patches/patches.h"
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include "../common/MiscFunctions.h" #include "../common/MiscFunctions.h"
#include "../common/StringUtil.h"
#include "../common/platform.h" #include "../common/platform.h"
#include "../common/crash.h" #include "../common/crash.h"
#include "../common/ipc_mutex.h" #include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h" #include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h" #include "../common/eqemu_exception.h"
#include "../common/spdat.h"
#include "ZoneConfig.h"
#include "masterentity.h" #include "masterentity.h"
#include "worldserver.h" #include "worldserver.h"
#include "net.h" #include "net.h"
#include "../common/spdat.h"
#include "zone.h" #include "zone.h"
#include "command.h" #include "command.h"
#include "parser.h" #include "parser.h"
@ -82,6 +59,33 @@ extern volatile bool ZoneLoaded;
#include "tasks.h" #include "tasks.h"
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#ifdef _CRTDBG_MAP_ALLOC
#undef new
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#ifdef _WINDOWS
#include <conio.h>
#include <process.h>
#else
#include <pthread.h>
#include "../common/unix.h"
#endif
volatile bool RunLoops = true;
extern volatile bool ZoneLoaded;
TimeoutManager timeout_manager; TimeoutManager timeout_manager;
NetConnection net; NetConnection net;
EntityList entity_list; EntityList entity_list;
@ -102,13 +106,6 @@ const SPDat_Spell_Struct* spells;
void LoadSpells(EQEmu::MemoryMappedFile **mmf); void LoadSpells(EQEmu::MemoryMappedFile **mmf);
int32 SPDAT_RECORDS = -1; int32 SPDAT_RECORDS = -1;
#ifdef _WINDOWS
#include <process.h>
#else
#include <pthread.h>
#include "../common/unix.h"
#endif
void Shutdown(); void Shutdown();
extern void MapOpcodes(); extern void MapOpcodes();

View File

@ -25,21 +25,18 @@
#include <map> #include <map>
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#include <winsock.h> #include <winsock.h>
#include <process.h> #include <process.h>
#define snprintf _snprintf
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #define strncasecmp _strnicmp
#define strncasecmp _strnicmp #define strcasecmp _stricmp
#define strcasecmp _stricmp
#else #else
#include <stdarg.h> #include <stdarg.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "../common/unix.h" #include "../common/unix.h"
#endif #endif
/* /*