Limit ChatHandler::HandleModifyHPCommand to players. Closes issue #1031

--HG--
branch : trunk
This commit is contained in:
Spp
2010-03-09 10:40:42 +01:00
parent a4513c2559
commit 6f4be37051
+9 -21
View File
@@ -1077,31 +1077,20 @@ bool ChatHandler::HandleRecallCommand(const char* args)
//Edit Player HP //Edit Player HP
bool ChatHandler::HandleModifyHPCommand(const char* args) bool ChatHandler::HandleModifyHPCommand(const char* args)
{ {
if(!*args) if (!*args)
return false; 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 hp = atoi((char*)args);
int32 hpm = 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); SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
Unit *chr = getSelectedUnit(); Player *chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@@ -1109,16 +1098,15 @@ bool ChatHandler::HandleModifyHPCommand(const char* args)
return false; return false;
} }
// check online security if (HasLowerSecurity(chr, 0))
if (chr->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)chr, 0))
return false; return false;
PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr->ToPlayer()).c_str(), hp, hpm); PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr).c_str(), hp, hpm);
if (chr->GetTypeId() == TYPEID_PLAYER && needReportToTarget(chr->ToPlayer())) if (needReportToTarget(chr))
ChatHandler(chr->ToPlayer()).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm);
chr->SetMaxHealth( hpm ); chr->SetMaxHealth(hpm);
chr->SetHealth( hp ); chr->SetHealth(hp);
return true; return true;
} }