mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-13 23:28:21 +00:00
Merge branch 'master' into char_to_string
Conflicts: common/dbcore.h
This commit is contained in:
@@ -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
|
||||
|
||||
+123
-128
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
+21
-15
@@ -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: "
|
||||
@@ -1355,6 +1358,9 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
_log(NET__DEBUG, _L "Timeout expired in established state. Closing connection." __L);
|
||||
_SendDisconnect();
|
||||
SetState(DISCONNECTING);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+61
-96
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
//
|
||||
#define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
|
||||
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1;
|
||||
#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, String); Buffer += strlen(String) + 1; }
|
||||
#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, "%s", String); Buffer += strlen(String) + 1; }
|
||||
#define VARSTRUCT_ENCODE_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; }
|
||||
#define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); }
|
||||
#define VARSTRUCT_SKIP_TYPE(Type, Buffer) Buffer += sizeof(Type);
|
||||
|
||||
+15
-11
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
+2
-12
@@ -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);
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ private:
|
||||
void DBInitVars();
|
||||
|
||||
uint32 max_zonename;
|
||||
public: char** zonename_array;
|
||||
char** zonename_array;
|
||||
|
||||
Mutex Mvarcache;
|
||||
uint32 varcache_max;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#endif
|
||||
#include <mysql.h>
|
||||
#include <string>
|
||||
|
||||
#include "../common/DBMemLeak.h"
|
||||
#include "../common/types.h"
|
||||
#include "../common/Mutex.h"
|
||||
#include "../common/linked_list.h"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ namespace EQEmu
|
||||
*/
|
||||
const char* what() const throw() { return full_description().c_str(); }
|
||||
protected:
|
||||
std::string name_; //!< Exception name
|
||||
std::string desc_; //!< Exception Description
|
||||
mutable std::string full_desc_; //!< Full Exception Description
|
||||
std::string file_; //!< File Name
|
||||
long line_; //<! File Line
|
||||
std::string file_; //!< File Name
|
||||
std::string desc_; //!< Exception Description
|
||||
std::string name_; //!< Exception name
|
||||
};
|
||||
} // EQEmu
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1120,7 +1120,7 @@ struct QSPlayerLogTrade_Struct {
|
||||
};
|
||||
|
||||
struct QSHandinItems_Struct {
|
||||
char action_type[6]; // handin, return or reward
|
||||
char action_type[7]; // handin, return or reward
|
||||
uint16 char_slot;
|
||||
uint32 item_id;
|
||||
uint16 charges;
|
||||
|
||||
+5
-3
@@ -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"
|
||||
@@ -19,13 +21,13 @@
|
||||
|
||||
SharedDatabase::SharedDatabase()
|
||||
: Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr),
|
||||
loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr), loot_drop_hash(nullptr)
|
||||
loot_table_mmf(nullptr), loot_table_hash(nullptr), loot_drop_mmf(nullptr), loot_drop_hash(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SharedDatabase::SharedDatabase(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||
: Database(host, user, passwd, database, port), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr),
|
||||
faction_mmf(nullptr), faction_hash(nullptr), loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr),
|
||||
faction_mmf(nullptr), faction_hash(nullptr), loot_table_mmf(nullptr), loot_table_hash(nullptr), loot_drop_mmf(nullptr),
|
||||
loot_drop_hash(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
+1
-1
@@ -112,6 +112,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
EQEmu::MemoryMappedFile *skill_caps_mmf;
|
||||
EQEmu::MemoryMappedFile *items_mmf;
|
||||
EQEmu::FixedMemoryHashSet<Item_Struct> *items_hash;
|
||||
EQEmu::MemoryMappedFile *faction_mmf;
|
||||
@@ -120,7 +121,6 @@ protected:
|
||||
EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> *loot_table_hash;
|
||||
EQEmu::MemoryMappedFile *loot_drop_mmf;
|
||||
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> *loot_drop_hash;
|
||||
EQEmu::MemoryMappedFile *skill_caps_mmf;
|
||||
};
|
||||
|
||||
#endif /*SHAREDDB_H_*/
|
||||
|
||||
Reference in New Issue
Block a user