Optional change to CharInfo routine...
Posted: Wed Apr 16, 2003 10:49 pm
Greetings Constructs,
As there has been issues with the CharInfo routine, I thought I would post my current code. My code has removed the item database updating functionality from /charinfo. I have added a new command /udpateitems.
Replace CharInfo function in EQLib.cpp as follows:
Add the following to TakeControlOfCommandList in EQLib.cpp:
before the line
Add the following as a new function to EQLib.cpp:
And finally, add the following to MQ.h:
End of line...
As there has been issues with the CharInfo routine, I thought I would post my current code. My code has removed the item database updating functionality from /charinfo. I have added a new command /udpateitems.
Replace CharInfo function in EQLib.cpp as follows:
Code: Select all
VOID CharInfo(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szBuffer[MAX_STRING] = {0};
bRunNextCommand = TRUE;
if (gFilterMacro == FILTERMACRO_NONE) cmdCharInfo(pChar, szLine);
PCHARINFO pCharInfo = NULL;
if (NULL == (pCharInfo = GetCharInfo())) return;
sprintf(szBuffer,"You are bound in %s at %1.2f, %1.2f, %1.2f", GetFullZone(pCharInfo->ZoneBoundId), pCharInfo->ZoneBoundX, pCharInfo->ZoneBoundY, pCharInfo->ZoneBoundZ);
WriteChatColor(szBuffer,USERCOLOR_DEFAULT);
sprintf(szBuffer,"You were born in %s at %1.2f, %1.2f, %1.2f", GetFullZone(pCharInfo->ZoneBirthId), pCharInfo->ZoneBirthX, pCharInfo->ZoneBirthY, pCharInfo->ZoneBirthZ);
WriteChatColor(szBuffer,USERCOLOR_DEFAULT);
}Code: Select all
{"/updateitems", "UpdateItemInfo"},Code: Select all
{NULL, NULL}Code: Select all
VOID UpdateItemInfo(PSPAWNINFO pChar, PCHAR szLine) {
CHAR szBuffer[MAX_STRING] = {0};
PCHARINFO pCharInfo = NULL;
if (NULL == (pCharInfo = GetCharInfo())) return;
for (int nInvIdx=0; nInvIdx < 30; nInvIdx++) {
if (pCharInfo->Inventory[nInvIdx] != NULL) {
BOOL Found = FALSE;
PITEMDB ItemDB = gItemDB;
while (ItemDB) {
if (ItemDB->ID == pCharInfo->Inventory[nInvIdx]->ItemNumber) {
Found = TRUE;
}
ItemDB = ItemDB->pNext;
}
if (!Found) {
PITEMDB Item = (PITEMDB)malloc(sizeof(ITEMDB));
Item->pNext = gItemDB;
Item->ID = pCharInfo->Inventory[nInvIdx]->ItemNumber;
strcpy(Item->szName, pCharInfo->Inventory[nInvIdx]->Name);
DebugSpew(" New Item found - %d: %s", Item->ID, Item->szName);
gItemDB = Item;
}
if (pCharInfo->Inventory[nInvIdx]->Type == ITEMTYPE_PACK) {
DebugSpew(" Opening Pack");
for (int nPackIdx = 0; nPackIdx < pCharInfo->Inventory[nInvIdx]->Container.Slots; nPackIdx++) {
if (pCharInfo->Inventory[nInvIdx]->Container.Contents[nPackIdx] != NULL) {
Found = FALSE;
PITEMDB ItemDB = gItemDB;
while (ItemDB) {
if (ItemDB->ID == pCharInfo->Inventory[nInvIdx]->Container.Contents[nPackIdx]->ItemNumber) {
Found = TRUE;
}
ItemDB = ItemDB->pNext;
}
if (!Found) {
PITEMDB Item = (PITEMDB)malloc(sizeof(ITEMDB));
Item->pNext = gItemDB;
Item->ID = pCharInfo->Inventory[nInvIdx]->Container.Contents[nPackIdx]->ItemNumber;
strcpy(Item->szName, pCharInfo->Inventory[nInvIdx]->Container.Contents[nPackIdx]->Name);
DebugSpew(" New Item found - %d: %s", Item->ID, Item->szName);
gItemDB = Item;
}
}
}
}
}
}
for (nInvIdx=0; nInvIdx < NUM_BANK_SLOTS; nInvIdx++) {
if (pCharInfo->Bank[nInvIdx] != NULL) {
BOOL Found = FALSE;
PITEMDB ItemDB = gItemDB;
while (ItemDB) {
if (ItemDB->ID == pCharInfo->Bank[nInvIdx]->ItemNumber) {
Found = TRUE;
}
ItemDB = ItemDB->pNext;
}
if (!Found) {
PITEMDB Item = (PITEMDB)malloc(sizeof(ITEMDB));
Item->pNext = gItemDB;
Item->ID = pCharInfo->Bank[nInvIdx]->ItemNumber;
strcpy(Item->szName, pCharInfo->Bank[nInvIdx]->Name);
DebugSpew(" New Item found - %d: %s", Item->ID, Item->szName);
gItemDB = Item;
}
if (pCharInfo->Bank[nInvIdx]->Type == ITEMTYPE_PACK) {
LONG nPackIdx;
for (nPackIdx = 0; nPackIdx < pCharInfo->Bank[nInvIdx]->Container.Slots; nPackIdx++) {
if (pCharInfo->Bank[nInvIdx]->Container.Contents[nPackIdx] != NULL) {
PITEMDB ItemDB = gItemDB;
Found = FALSE;
while (ItemDB) {
if (ItemDB->ID == pCharInfo->Bank[nInvIdx]->Container.Contents[nPackIdx]->ItemNumber) {
Found = TRUE;
}
ItemDB = ItemDB->pNext;
}
if (!Found) {
PITEMDB Item = (PITEMDB)malloc(sizeof(ITEMDB));
Item->pNext = gItemDB;
Item->ID = pCharInfo->Bank[nInvIdx]->Container.Contents[nPackIdx]->ItemNumber;
strcpy(Item->szName, pCharInfo->Bank[nInvIdx]->Container.Contents[nPackIdx]->Name);
DebugSpew(" New Item found - %d: %s", Item->ID, Item->szName);
gItemDB = Item;
}
}
}
}
}
}
PITEMDB ItemDB = gItemDB;
if (ItemDB) {
FILE *fDB = fopen(gszItemDB, "wt");
while (ItemDB) {
sprintf(szBuffer, "%d\t%s\n", ItemDB->ID, ItemDB->szName);
fputs(szBuffer, fDB);
ItemDB = ItemDB->pNext;
}
fclose(fDB);
}
}Code: Select all
extern "C" EQLIB_API VOID UpdateItemInfo (PSPAWNINFO, PCHAR);