Validate arguments to /level and /summonW; fix retreatStep() bug.

This commit is contained in:
dongresource 2020-10-08 20:20:12 +02:00
parent bae834fefa
commit 9f280c2c31
2 changed files with 11 additions and 1 deletions

View File

@ -61,6 +61,11 @@ void populationCommand(std::string full, std::vector<std::string>& args, CNSocke
}
void levelCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
if (args.size() < 2) {
ChatManager::sendServerMessage(sock, "/level: no level specified");
return;
}
Player *plr = PlayerManager::getPlayer(sock);
if (plr == nullptr)
return;
@ -189,6 +194,10 @@ void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock
}
void summonWCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
if (args.size() < 2) {
ChatManager::sendServerMessage(sock, "/level: no mob type specified");
return;
}
Player* plr = PlayerManager::getPlayer(sock);
char *rest;

View File

@ -403,7 +403,8 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
int distance = hypot(mob->appearanceData.iX - mob->spawnX, mob->appearanceData.iY - mob->spawnY);
if (distance > mob->data["m_iIdleRange"]) {
//if (distance > mob->data["m_iIdleRange"]) {
if (distance > 10) {
INITSTRUCT(sP_FE2CL_NPC_MOVE, pkt);
auto targ = lerp(mob->appearanceData.iX, mob->appearanceData.iY, mob->spawnX, mob->spawnY, mob->data["m_iRunSpeed"]);