diff options
| author | raczman <none@none> | 2010-03-07 15:20:19 +0100 |
|---|---|---|
| committer | raczman <none@none> | 2010-03-07 15:20:19 +0100 |
| commit | 91b8ee104eac7446f9b8cbea7ed9dce641740c8e (patch) | |
| tree | 2866b76745089d8066dad65b63e5aff07e92f4f6 /src/game/Level1.cpp | |
| parent | aeebe57dc08d8b2d90972f50f00c4a28dd3947ba (diff) | |
Added new type-safe cast functions.
This, when properly used, should get rid of most memory corruption issues,
currently, casting types C-style with no checks leads to some abstract crashing.
Functionality is same as with dynamic_cast<>, but with no RTTI check - so when
casting into invalid type you will receive NULL, and most probably crash.
At the same time, i took the liberty to convert most Player* casts to ToPlayer().
Still needs crapload of casts being moved to new facility.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Level1.cpp')
| -rw-r--r-- | src/game/Level1.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 9a9c60f245e..d84cb06352a 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1113,9 +1113,9 @@ bool ChatHandler::HandleModifyHPCommand(const char* args) if (chr->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)chr, 0)) return false; - PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink((Player*)chr).c_str(), hp, hpm); - if (chr->GetTypeId() == TYPEID_PLAYER && needReportToTarget((Player*)chr)) - ChatHandler((Player*)chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); + 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); chr->SetMaxHealth( hpm ); chr->SetHealth( hp ); @@ -1460,20 +1460,20 @@ bool ChatHandler::HandleModifyTalentCommand (const char* args) // check online security if (HasLowerSecurity((Player*)target, 0)) return false; - ((Player*)target)->SetFreeTalentPoints(tp); - ((Player*)target)->SendTalentsInfoData(false); + target->ToPlayer()->SetFreeTalentPoints(tp); + target->ToPlayer()->SendTalentsInfoData(false); return true; } else if(((Creature*)target)->isPet()) { Unit *owner = target->GetOwner(); - if(owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor((Player*)owner)) + if(owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor(owner->ToPlayer())) { // check online security if (HasLowerSecurity((Player*)owner, 0)) return false; ((Pet *)target)->SetFreeTalentPoints(tp); - ((Player*)owner)->SendTalentsInfoData(true); + owner->ToPlayer()->SendTalentsInfoData(true); return true; } } |
