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
dbasync.cpp
dbcore.cpp
DBMemLeak.cpp
debug.cpp
emu_opcodes.cpp
EmuTCPConnection.cpp
@ -103,7 +102,6 @@ SET(common_headers
database.h
dbasync.h
dbcore.h
DBMemLeak.h
debug.h
deity.h
emu_opcodes.h

View File

@ -20,134 +20,129 @@
#include "Condition.h"
#ifdef _WINDOWS
Condition::Condition()
{
m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_waiters = 0;
InitializeCriticalSection(&CSMutex);
}
Condition::~Condition()
{
DeleteCriticalSection(&CSMutex);
CloseHandle(m_events[SignalEvent]);
CloseHandle(m_events[BroadcastEvent]);
}
void Condition::Signal()
{
EnterCriticalSection(&CSMutex);
if(m_waiters > 0)
SetEvent(m_events[SignalEvent]);
LeaveCriticalSection(&CSMutex);
}
void Condition::SignalAll()
{
EnterCriticalSection(&CSMutex);
if(m_waiters > 0)
SetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
void Condition::Wait()
{
EnterCriticalSection(&CSMutex);
m_waiters++;
LeaveCriticalSection(&CSMutex);
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
EnterCriticalSection(&CSMutex);
m_waiters--;
//see if we are the last person waiting on the condition, and there was a broadcast
//if so, we need to reset the broadcast event.
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
#else
#include <pthread.h>
#include <sys/time.h>
#include <errno.h>
#include <pthread.h>
#include <sys/time.h>
#include <errno.h>
Condition::Condition()
{
pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,nullptr);
}
void Condition::Signal()
{
pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
void Condition::SignalAll()
{
pthread_mutex_lock(&mutex);
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex);
}
void Condition::Wait()
{
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond,&mutex);
pthread_mutex_unlock(&mutex);
}
/*
I commented this specifically because I think it might be very
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
implemented on windows.
bool Condition::TimedWait(unsigned long usec)
{
struct timeval now;
struct timespec timeout;
int retcode=0;
pthread_mutex_lock(&mutex);
gettimeofday(&now,nullptr);
now.tv_usec+=usec;
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
timeout.tv_nsec = (now.tv_usec%1000000) *1000;
//cout << "now=" << now.tv_sec << "."<<now.tv_usec << endl;
//cout << "timeout=" << timeout.tv_sec << "."<<timeout.tv_nsec << endl;
retcode=pthread_cond_timedwait(&cond,&mutex,&timeout);
pthread_mutex_unlock(&mutex);
return retcode!=ETIMEDOUT;
}
*/
Condition::~Condition()
{
pthread_mutex_lock(&mutex);
pthread_cond_destroy(&cond);
pthread_mutex_unlock(&mutex);
pthread_mutex_destroy(&mutex);
}
#endif
#ifdef _WINDOWS
Condition::Condition()
{
m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_waiters = 0;
InitializeCriticalSection(&CSMutex);
}
Condition::~Condition()
{
DeleteCriticalSection(&CSMutex);
CloseHandle(m_events[SignalEvent]);
CloseHandle(m_events[BroadcastEvent]);
}
void Condition::Signal()
{
EnterCriticalSection(&CSMutex);
if(m_waiters > 0)
SetEvent(m_events[SignalEvent]);
LeaveCriticalSection(&CSMutex);
}
void Condition::SignalAll()
{
EnterCriticalSection(&CSMutex);
if(m_waiters > 0)
SetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
void Condition::Wait()
{
EnterCriticalSection(&CSMutex);
m_waiters++;
LeaveCriticalSection(&CSMutex);
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
EnterCriticalSection(&CSMutex);
m_waiters--;
//see if we are the last person waiting on the condition, and there was a broadcast
//if so, we need to reset the broadcast event.
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
#else //!WIN32
Condition::Condition()
{
pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,nullptr);
}
void Condition::Signal()
{
pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
void Condition::SignalAll()
{
pthread_mutex_lock(&mutex);
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex);
}
void Condition::Wait()
{
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond,&mutex);
pthread_mutex_unlock(&mutex);
}
/*
I commented this specifically because I think it might be very
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
implemented on windows.
bool Condition::TimedWait(unsigned long usec)
{
struct timeval now;
struct timespec timeout;
int retcode=0;
pthread_mutex_lock(&mutex);
gettimeofday(&now,nullptr);
now.tv_usec+=usec;
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
timeout.tv_nsec = (now.tv_usec%1000000) *1000;
//cout << "now=" << now.tv_sec << "."<<now.tv_usec << endl;
//cout << "timeout=" << timeout.tv_sec << "."<<timeout.tv_nsec << endl;
retcode=pthread_cond_timedwait(&cond,&mutex,&timeout);
pthread_mutex_unlock(&mutex);
return retcode!=ETIMEDOUT;
}
*/
Condition::~Condition()
{
pthread_mutex_lock(&mutex);
pthread_cond_destroy(&cond);
pthread_mutex_unlock(&mutex);
pthread_mutex_destroy(&mutex);
}
#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
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#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 <iomanip>
#include <iostream>
#include <vector>
#include <sys/types.h>
#include <algorithm>
#if defined(ZONE) || defined(WORLD)
#define RETRANSMITS
#endif
#ifdef RETRANSMITS
#include "rulesys.h"
#endif
#ifdef _WINDOWS
#include <time.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h>
@ -32,20 +49,6 @@
#include <fcntl.h>
#include <arpa/inet.h>
#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
#define _L "%s:%d: "

View File

@ -16,20 +16,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef _WINDOWS
// VS6 doesn't like the length of STL generated names: disabling
#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 "debug.h"
#include "StringUtil.h"
#include "Item.h"
#include "database.h"
#include "misc.h"
@ -37,6 +25,11 @@
#include "shareddb.h"
#include "classes.h"
#include <limits.h>
#include <sstream>
#include <iostream>
int32 NextItemInstSerialNumber = 1;
static inline int32 GetNextItemInstSerialNumber() {
@ -1059,103 +1052,75 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
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_contents itb;
ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag)
printf("Worn items:\n");
for (it=m_worn.begin(); it!=m_worn.end(); it++) {
for (it=collection.begin(); it!=collection.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
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;
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());
}
}
dumpBagContents(inst, &it);
}
}
printf("Inventory items:\n");
for (it=m_inv.begin(); it!=m_inv.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
void Inventory::dumpWornItems() {
std::cout << "Worn items:" << std::endl;
dumpItemCollection(m_worn);
}
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
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());
void Inventory::dumpBankItems() {
std::cout << "Bank items:" << std::endl;
dumpItemCollection(m_bank);
}
}
}
}
void Inventory::dumpSharedBankItems() {
std::cout << "Shared Bank items:" << std::endl;
dumpItemCollection(m_shbank);
}
printf("Bank items:\n");
for (it=m_bank.begin(); it!=m_bank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
void Inventory::dumpEntireInventory() {
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("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);
dumpWornItems();
dumpInventory();
dumpBankItems();
dumpSharedBankItems();
std::cout << std::endl;
}
// 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
static bool SupportsContainers(int16 slot_id);
void dumpEntireInventory();
void dumpWornItems();
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, int value);
@ -207,6 +211,9 @@ protected:
// Protected Methods
///////////////////////////////
void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
void dumpBagContents(ItemInst *inst, iter_inst *it);
// Retrieves item within an inventory bucket
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
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string>
#include <vector>
#include "debug.h"
#include "ProcLauncher.h"
#ifdef _WINDOWS
#include <windows.h>
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#endif
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);
}
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) {
static char str[128];
if (!source)

View File

@ -23,19 +23,9 @@
void vStringFormat(std::string& output, const char* format, va_list args);
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);
//////////////////////////////////////////////////////////////////////
//
// 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);

View File

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

View File

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

View File

@ -45,22 +45,9 @@
#ifndef _CRTDBG_MAP_ALLOC
#include <stdlib.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
#ifdef _WINDOWS
// VS6 doesn't like the length of STL generated names: disabling
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#endif
#ifndef EQDEBUG_H
#define EQDEBUG_H

View File

@ -18,9 +18,12 @@
#include "debug.h"
#include "logsys.h"
#include "StringUtil.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <string>
void log_message(LogType type, const char *fmt, ...) {
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) {
char prefix_buffer[256];
snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name);
prefix_buffer[255] = '\0';
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args);
std::string prefix_buffer;
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 <cstring>
#include <cstdlib>
#include "shareddb.h"
#include "mysql.h"
#include "Item.h"
#include "classes.h"
#include "rulesys.h"

View File

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

View File

@ -2,8 +2,34 @@
#include "../common/EQPacket.h"
#include "../common/EQStreamIntf.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 <iomanip>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -17,44 +43,18 @@
#ifdef _WINDOWS
#include <windows.h>
#include <winsock.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/types.h>
#endif
#include <sys/socket.h>
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/types.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#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<RaceClassCombos> character_create_race_class_combos;

View File

@ -1,18 +1,21 @@
#include "../common/debug.h"
#include "../common/logsys.h"
#include "../common/StringUtil.h"
#include "zoneserver.h"
#include "client.h"
#include <stdarg.h>
#include <stdio.h>
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, ...) {
@ -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) {
char prefix_buffer[256];
char zone_tag[65];
std::string prefix_buffer, zone_tag;
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
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);
prefix_buffer[255] = '\0';
StringFormat(prefix_buffer, "[%s] %s ", log_type_info[type].name, zone_tag.c_str());
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, ...) {

View File

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

View File

@ -1476,7 +1476,7 @@ void Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_
if (killerMob != nullptr)
{
if (killerMob->IsNPC()) {
parse->EventNPC(EVENT_SLAY, killerMob->CastToNPC(), this, "", 0);
parse->EventNPC(EVENT_SLAY, killerMob->CastToNPC(), this, "", 0);
mod_client_death_npc(killerMob);
@ -2124,7 +2124,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
/* Send the EVENT_KILLED_MERIT event for all raid members */
for (int i = 0; i < MAX_RAID_MEMBERS; i++) {
if (kr->members[i].member != nullptr) { // If Group Member is Client
parse->EventNPC(EVENT_KILLED_MERIT, this, kr->members[i].member, "killed", 0);
parse->EventNPC(EVENT_KILLED_MERIT, this, kr->members[i].member, "killed", 0);
mod_npc_killed_merit(kr->members[i].member);
@ -2167,7 +2167,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client
Client *c = kg->members[i]->CastToClient();
parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0);
parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0);
mod_npc_killed_merit(c);
@ -2214,7 +2214,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
}
}
/* Send the EVENT_KILLED_MERIT event */
parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0);
parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0);
mod_npc_killed_merit(give_exp_client);
@ -2347,7 +2347,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
// Parse quests even if we're killed by an NPC
if(killerMob) {
Mob *oos = killerMob->GetOwnerOrSelf();
parse->EventNPC(EVENT_DEATH, this, oos, "", 0);
parse->EventNPC(EVENT_DEATH, this, oos, "", 0);
mod_npc_killed(oos);
@ -4234,7 +4234,7 @@ void Mob::ApplyMeleeDamageBonus(uint16 skill, int32 &damage){
if(!RuleB(Combat, UseIntervalAC)){
if(IsNPC()){ //across the board NPC damage bonuses.
//only account for STR here, assume their base STR was factored into their DB damages
//only account for STR here, assume their base STR was factored into their DB damages
int dmgbonusmod = 0;
dmgbonusmod += (100*(itembonuses.STR + spellbonuses.STR))/3;
dmgbonusmod += (100*(spellbonuses.ATK + itembonuses.ATK))/5;

View File

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

View File

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

View File

@ -19,8 +19,6 @@
#define CLIENT_H
class Client;
#include "../common/timer.h"
#include "../common/ptimer.h"
#include "../common/emu_opcodes.h"
@ -30,29 +28,39 @@ class Client;
#include "../common/EQPacket.h"
#include "../common/linked_list.h"
#include "../common/extprofile.h"
#include "zonedb.h"
#include "errno.h"
#include "../common/classes.h"
#include "../common/races.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 "npc.h"
#include "merc.h"
#include "zone.h"
#include "AA.h"
#include "../common/seperator.h"
#include "../common/Item.h"
#include "updatemgr.h"
#include "../common/guilds.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 <set>
#include <string>
#include "../common/item_struct.h"
#include "../common/clientversions.h"
#include "QGlobals.h"
#include <algorithm>
#define CLIENT_TIMEOUT 90000
#define CLIENT_LD_TIMEOUT 30000 // length of time client stays in zone after LDing
#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
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <algorithm>
#include "../common/debug.h"
#include "masterentity.h"
#include "worldserver.h"
#include "zonedb.h"
#include "../common/spdat.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
#include "petitions.h"
#include "../common/serverinfo.h"
#include "../common/ZoneNumbers.h"
#include "../common/moremath.h"
#include "../common/guilds.h"
#include "../common/logsys.h"
#include "masterentity.h"
#include "worldserver.h"
#include "zonedb.h"
#include "petitions.h"
#include "StringIDs.h"
#include "NpcAI.h"

View File

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

View File

@ -20,12 +20,13 @@
#include "../common/types.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/bodytypes.h"
#include "../common/eq_constants.h"
#include "zonedb.h"
#include "zonedump.h"
#include "zonedbasync.h"
#include "QGlobals.h"
// max number of newspawns to send per bulk packet

View File

@ -1,4 +1,3 @@
#define DONT_SHARED_OPCODES
/* EQEMu: Everquest Server Emulator
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
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define DONT_SHARED_OPCODES
#include "../common/debug.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/timer.h"
#include "../common/EQStream.h"
@ -52,7 +28,6 @@ extern volatile bool ZoneLoaded;
#include "../common/Mutex.h"
#include "../common/version.h"
#include "../common/EQEMuError.h"
#include "ZoneConfig.h"
#include "../common/packet_dump_file.h"
#include "../common/opcodemgr.h"
#include "../common/guilds.h"
@ -60,16 +35,18 @@ extern volatile bool ZoneLoaded;
#include "../common/patches/patches.h"
#include "../common/rulesys.h"
#include "../common/MiscFunctions.h"
#include "../common/StringUtil.h"
#include "../common/platform.h"
#include "../common/crash.h"
#include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h"
#include "../common/spdat.h"
#include "ZoneConfig.h"
#include "masterentity.h"
#include "worldserver.h"
#include "net.h"
#include "../common/spdat.h"
#include "zone.h"
#include "command.h"
#include "parser.h"
@ -82,6 +59,33 @@ extern volatile bool ZoneLoaded;
#include "tasks.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;
NetConnection net;
EntityList entity_list;
@ -102,13 +106,6 @@ const SPDat_Spell_Struct* spells;
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
int32 SPDAT_RECORDS = -1;
#ifdef _WINDOWS
#include <process.h>
#else
#include <pthread.h>
#include "../common/unix.h"
#endif
void Shutdown();
extern void MapOpcodes();

View File

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