bool Exec_MSG_UpdateItem(int conn, char* pMsg)
{
MSG_UpdateItem* stUpdateItem = (MSG_UpdateItem*)pMsg;
if (!pMob[conn].MOB.CurrentScore.Hp && pUser[conn].Mode == USER_PLAY)
{
SendHpMode(conn);
AddCrackError(conn, 1, 16);
return false;
}
int GateID = stUpdateItem->ItemID - 15000;
if (GateID >= 0 && GateID < MAX_ITEMLIST)
{
int State = pItem[GateID].State;
int NexState = stUpdateItem->State;
if (State != 3 || NexState != 3)
{
int DoorKey = BASE_GetItemAbility(&pItem[GateID].ITEM, EF_KEYID);
int Key = 0;
if (DoorKey)
{
for (int i = 0; i < MAX_CARRY; ++i)
{
Key = BASE_GetItemAbility(&pMob[conn].MOB.Carry[i], EF_KEYID);
if (Key == DoorKey)
{
memset(&pMob[conn].MOB.Carry[i], 0, sizeof(STRUCT_ITEM));
SendItem(conn, ITEM_PLACE_CARRY, i, &pMob[conn].MOB.Carry[i]);
break;
}
}
}
if (Key != DoorKey)
{
if (pItem[GateID].ITEM.sIndex != 773) //Portão do Castelo
{
if (pItem[GateID].ITEM.sIndex != 359) //Moita
SendClientMessage(conn, g_pMessageStringTable[_NN_No_Key]);
return false;
}
}
else
{
int Height = 0;
int isUpdate = UpdateItem(GateID, NexState, &Height);
if (isUpdate)
{
stUpdateItem->Height = Height;
GridMulticast(pItem[GateID].PosX, pItem[GateID].PosY, (MSG_STANDARD*)stUpdateItem, 0);
return false;
}
}
}
}
else
{
AddCrackError(conn, 30, 52);
snprintf(szLog, 128, "UpdateItem Crash - MAC:%X%X%X%X", pUser[conn].Mac[0], pUser[conn].Mac[1], pUser[conn].Mac[2], pUser[conn].Mac[3]);
Log(szLog, pUser[conn].AccountName, pUser[conn].IP);
return false;
}
return false;
}