diff options
| author | Spp <none@none> | 2010-03-09 10:40:42 +0100 |
|---|---|---|
| committer | Spp <none@none> | 2010-03-09 10:40:42 +0100 |
| commit | 6f4be370513f5834f2a1f7d0dcc479597ce4ecf4 (patch) | |
| tree | 37d4e6f9030f7b3448a96555393e4ced23bc4ff8 /src | |
| parent | a4513c2559374d145b85c8399aa86374060a0fc4 (diff) | |
Limit ChatHandler::HandleModifyHPCommand to players. Closes issue #1031
--HG--
branch : trunk
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/Level1.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 436ea362532..9aa1d3eca2a 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1077,31 +1077,20 @@ bool ChatHandler::HandleRecallCommand(const char* args) //Edit Player HP bool ChatHandler::HandleModifyHPCommand(const char* args) { - if(!*args) + if (!*args) return false; - // char* pHp = strtok((char*)args, " "); - // if (!pHp) - // return false; - - // char* pHpMax = strtok(NULL, " "); - // if (!pHpMax) - // return false; - - // int32 hpm = atoi(pHpMax); - // int32 hp = atoi(pHp); - int32 hp = atoi((char*)args); int32 hpm = atoi((char*)args); - if (hp <= 0 || hpm <= 0 || hpm < hp) + if (hp < 1 || hpm < 1 || hpm < hp) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); return false; } - Unit *chr = getSelectedUnit(); + Player *chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1109,16 +1098,15 @@ bool ChatHandler::HandleModifyHPCommand(const char* args) return false; } - // check online security - if (chr->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)chr, 0)) + if (HasLowerSecurity(chr, 0)) return false; - PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr->ToPlayer()).c_str(), hp, hpm); - if (chr->GetTypeId() == TYPEID_PLAYER && needReportToTarget(chr->ToPlayer())) - ChatHandler(chr->ToPlayer()).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); + PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr).c_str(), hp, hpm); + if (needReportToTarget(chr)) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); - chr->SetMaxHealth( hpm ); - chr->SetHealth( hp ); + chr->SetMaxHealth(hpm); + chr->SetHealth(hp); return true; } |
