Looked at the $corpse function and unfortunately found some bugs that could cause it to work incorrectly. Below is the corrected $corpse with a new $corpse(empty) option that will return TRUE when there are no more items on the corpse.
Code: Select all
[color=red]DWORD parmCorpse(PCHAR szVar, PCHAR szOutput, PSPAWNINFO pChar)
{
DWORD i=0;[/color]
DWORD iSlotCnt=0;
[color=red] // $corpse(xxx)
if (!EQADDR_LOOTWND) return PMP_ERROR_BADPARM;
PEQWINDOW pLootWindow = NULL;
pLootWindow = (PEQWINDOW)*EQADDR_LOOTWND;
CHAR szTemp[MAX_STRING] = {0};[/color]
if (!strncmp("corpse()",szVar,8)) {
i += 7;[color=red]
if (pLootWindow->Open == 1) {
strcat(szOutput,"TRUE");
} else {
strcat(szOutput,"FALSE");
}
// $corpse(has,xxx)[/color]
} else if (!strncmp("corpse(has,",szVar,11)) {[color=red]
if (!strstr(szVar,")")) {
DebugSpew("PMP - Bad $merchant() '%s'",szVar);
return PMP_ERROR_BADPARM;
} else {
i += (strstr(szVar,")")-szVar);
if (pLootWindow->Open == 1) {[/color]
PCHAR szArg = szVar+11;[color=red]
if (szArg[0]=='"') szArg++;
CHAR szTemp[MAX_STRING] = {0};
DebugSpew("$corpse(has) -- looking for '%s'", szArg);
BOOL Found = FALSE;[/color]
for (iSlotCnt=0;iSlotCnt<79;iSlotCnt++) {
if (pLootWindow->ItemDesc[iSlotCnt]) {
if (!strnicmp(szArg,pLootWindow->ItemDesc[iSlotCnt]->Item->Name,strlen(pLootWindow->ItemDesc[iSlotCnt]->Item->Name))) {
Found=TRUE;
DebugSpew("Corpse does have: %s",pLootWindow->ItemDesc[iSlotCnt]->Item->Name);[color=red]
break;
}
}
}
if (Found) {
strcat(szOutput,"TRUE");
} else {
strcat(szOutput,"FALSE");
}
} else {
strcat(szOutput,"FALSE");
}
}[/color]
// $corpse(empty)
} else if (!strncmp("corpse(empty)",szVar,13)) {
i += 12;
if (pLootWindow->Open == 1) {
DebugSpew("$corpse(empty)");
BOOL Found = FALSE;
for (iSlotCnt=0;iSlotCnt<79;iSlotCnt++) {
if (pLootWindow->ItemDesc[iSlotCnt]) {
Found=TRUE;
break;
}
}
if (Found) {
DebugSpew("Corpse is not empty");
strcat(szOutput,"FALSE");
} else {
strcat(szOutput,"TRUE");
}
} else {
strcat(szOutput,"TRUE");
}
// $corpse(Unknown)[color=red]
} else {
DebugSpew("PMP - Bad $corpse() '%s'",szVar);
return PMP_ERROR_BADPARM;
}
return i;
}[/color]
*Damn those smilies
*Added color to make it pretty.