Read the NPC ID limit from the XDT

This commit is contained in:
dongresource 2020-12-21 01:57:56 +01:00 committed by Gent S
parent 9057f31bff
commit e0808ffcbd
2 changed files with 9 additions and 3 deletions

View File

@ -209,8 +209,10 @@ void summonWCommand(std::string full, std::vector<std::string>& args, CNSocket*
return;
}
int limit = NPCManager::NPCData.back()["m_iNpcNumber"];
// permission & sanity check
if (type >= 3314)
if (type > limit)
return;
BaseNPC *npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, true);
@ -540,8 +542,10 @@ void summonGroupCommand(std::string full, std::vector<std::string>& args, CNSock
return;
}
int limit = NPCManager::NPCData.back()["m_iNpcNumber"];
// permission & sanity check
if (type >= 3314 || type2 >= 3314 || count > 5) {
if (type > limit || type2 > limit || count > 5) {
ChatManager::sendServerMessage(sock, "Invalid parameters; double check types and count");
return;
}

View File

@ -498,8 +498,10 @@ void NPCManager::npcSummonHandler(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_NPC_SUMMON* req = (sP_CL2FE_REQ_NPC_SUMMON*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
int limit = NPCData.back()["m_iNpcNumber"];
// permission & sanity check
if (plr->accountLevel > 30 || req->iNPCType >= 3314 || req->iNPCCnt > 100)
if (plr->accountLevel > 30 || req->iNPCType >= limit || req->iNPCCnt > 100)
return;
for (int i = 0; i < req->iNPCCnt; i++) {