From 0f9ec2061c4ad6157c3186f1cab9c4d8558980b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 29 May 2015 14:30:20 +0300 Subject: Add strong typed int type BeingId. --- src/actions/actions.cpp | 19 ++++++++++++++----- src/actions/commands.cpp | 7 ++++--- src/actions/pets.cpp | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/actions') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index a666d01a2..0b8e8aedc 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -480,7 +480,8 @@ impHandler(heal) const Being *being = nullptr; if (args[0] == ':') { - being = actorManager->findBeing(atoi(args.substr(1).c_str())); + being = actorManager->findBeing(fromInt(atoi( + args.substr(1).c_str()), BeingId)); if (being && being->getType() == ActorType::Monster) being = nullptr; } @@ -588,7 +589,8 @@ impHandler(pickup) } else { - FloorItem *const item = actorManager->findItem(atoi(args.c_str())); + FloorItem *const item = actorManager->findItem(fromInt( + atoi(args.c_str()), BeingId)); if (item) localPlayer->pickUp(item); } @@ -758,7 +760,8 @@ impHandler(attack) } else { - target = actorManager->findBeing(atoi(args.substr(1).c_str())); + target = actorManager->findBeing(fromInt(atoi( + args.substr(1).c_str()), BeingId)); if (target && target->getType() != ActorType::Monster) target = nullptr; } @@ -789,7 +792,8 @@ impHandler(targetAttack) } else { - target = actorManager->findBeing(atoi(args.substr(1).c_str())); + target = actorManager->findBeing(fromInt(atoi( + args.substr(1).c_str()), BeingId)); if (target && target->getType() != ActorType::Monster) target = nullptr; } @@ -1599,9 +1603,14 @@ impHandler(kick) if (!args.empty()) { if (args[0] != ':') + { target = actorManager->findNearestByName(args); + } else - target = actorManager->findBeing(atoi(args.substr(1).c_str())); + { + target = actorManager->findBeing(fromInt(atoi( + args.substr(1).c_str()), BeingId)); + } } if (!target) target = localPlayer->getTarget(); diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 9ec4ca28f..0bcca016c 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -254,7 +254,7 @@ impHandler(chatNuke) if (!being) return true; - actorManager->addBlock(static_cast(being->getId())); + actorManager->addBlock(being->getId()); actorManager->destroy(being); return true; } @@ -268,7 +268,7 @@ impHandler(chatAdd) return true; const int id = atoi(event.args.c_str()); - if (!id) + if (id == 0) return true; Inventory *const inv = PlayerInfo::getInventory(); @@ -286,7 +286,8 @@ impHandler(chatAdd) return true; } - const FloorItem *const floorItem = actorManager->findItem(id); + const FloorItem *const floorItem = actorManager->findItem( + fromInt(id, BeingId)); if (floorItem) { diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp index a31e8aadc..a6c9a24df 100644 --- a/src/actions/pets.cpp +++ b/src/actions/pets.cpp @@ -66,8 +66,8 @@ static const Being *getPet() } #endif #ifdef EATHENA_SUPPORT - const int id = PlayerInfo::getPetBeingId(); - if (!id) + const BeingId id = PlayerInfo::getPetBeingId(); + if (id == BeingId_zero) return nullptr; return actorManager->findBeing(id); #else -- cgit v1.2.3-60-g2f50