diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-04-28 11:52:08 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-05-02 21:45:54 +0200 |
commit | 0261eb73e5588f5732aef5df753311d488c45d06 (patch) | |
tree | d641b0cad81ea58b8d8680b002197a4f592ef4a9 /src/game-server | |
parent | 23ccc8080a5283adce9f06909fc89b63d0e25452 (diff) | |
download | manaserv-0261eb73e5588f5732aef5df753311d488c45d06.tar.gz manaserv-0261eb73e5588f5732aef5df753311d488c45d06.tar.xz manaserv-0261eb73e5588f5732aef5df753311d488c45d06.zip |
Fixed a bunch of cppcheck warnings
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/attribute.cpp | 2 | ||||
-rw-r--r-- | src/game-server/attribute.h | 2 | ||||
-rw-r--r-- | src/game-server/being.cpp | 15 | ||||
-rw-r--r-- | src/game-server/commandhandler.cpp | 23 | ||||
-rw-r--r-- | src/game-server/spawnareacomponent.cpp | 2 | ||||
-rw-r--r-- | src/game-server/state.cpp | 2 |
6 files changed, 19 insertions, 27 deletions
diff --git a/src/game-server/attribute.cpp b/src/game-server/attribute.cpp index 71e5d94..f898b6e 100644 --- a/src/game-server/attribute.cpp +++ b/src/game-server/attribute.cpp @@ -394,7 +394,7 @@ void AttributeModifiersEffect::clearMods(double baseValue) mMod = mEffectType == Additive ? 0 : 1; } -double Attribute::checkBounds(double baseValue) +double Attribute::checkBounds(double baseValue) const { LOG_DEBUG("Checking bounds for value: " << baseValue); if (baseValue > mMaxValue) diff --git a/src/game-server/attribute.h b/src/game-server/attribute.h index 736e54a..2ac1378 100644 --- a/src/game-server/attribute.h +++ b/src/game-server/attribute.h @@ -195,7 +195,7 @@ class Attribute * Checks the min and max permitted values for the given base value * and return the adjusted value. */ - double checkBounds(double baseValue); + double checkBounds(double baseValue) const; double mBase; // The attribute base value double mMinValue; // The min authorized base and derived attribute value diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index 4ddec98..f3d4530 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -234,12 +234,11 @@ void BeingComponent::move(Entity &entity) * class has been used, because that seems to be the most logical * place extra functionality will be added. */ - for (Path::iterator pathIterator = mPath.begin(); - pathIterator != mPath.end(); pathIterator++) + for (Point &point : mPath) { const unsigned char walkmask = entity.getComponent<ActorComponent>()->getWalkMask(); - if (!map->getWalk(pathIterator->x, pathIterator->y, walkmask)) + if (!map->getWalk(point.x, point.y, walkmask)) { mPath.clear(); break; @@ -498,12 +497,10 @@ void BeingComponent::removeStatusEffect(int id) bool BeingComponent::hasStatusEffect(int id) const { - StatusEffects::const_iterator it = mStatus.begin(); - while (it != mStatus.end()) + for (auto &statusIt : mStatus) { - if (it->second.status->getId() == id) + if (statusIt.second.status->getId() == id) return true; - it++; } return false; } @@ -566,12 +563,12 @@ void BeingComponent::update(Entity &entity) if (it->second.time <= 0 || mAction == DEAD) { StatusEffects::iterator removeIt = it; - it++; // bring this iterator to the safety of the next element + ++it; // bring this iterator to the safety of the next element mStatus.erase(removeIt); } else { - it++; + ++it; } } diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index dcdd8c6..4c210bf 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -198,13 +198,11 @@ static std::string playerRights(Entity *ch) std::stringstream str; str << (unsigned)ch->getComponent<CharacterComponent>()->getAccountLevel(); str << " ( "; - std::list<std::string> classes = - PermissionManager::getClassList(ch); - for (std::list<std::string>::iterator i = classes.begin(); - i != classes.end(); - i++) + std::list<std::string> classes = PermissionManager::getClassList(ch); + + for (std::string &permission : classes) { - str << (*i) << " "; + str << permission << " "; } str << ")"; return str.str(); @@ -257,7 +255,7 @@ static std::string getArgument(std::string &args) } else { - argument = args.substr(0); + argument = args; args = std::string(); } return argument; @@ -269,12 +267,10 @@ static void handleHelp(Entity *player, std::string &args) { // short list of all commands say("=Available Commands=", player); - std::list<std::string> commands = PermissionManager::getPermissionList(player); - for (std::list<std::string>::iterator i = commands.begin(); - i != commands.end(); - i++) + for (std::string &command : + PermissionManager::getPermissionList(player)) { - say((*i), player); + say(command, player); } } else { // don't show help for commands the player may not use @@ -909,7 +905,7 @@ static void handleBan(Entity *player, std::string &args) // feedback for command user std::string otherName = other->getComponent<BeingComponent>()->getName(); std::string msg = "You've banned " + otherName + " for " + utils::toString(length) + " minutes"; - say(msg.c_str(), player); + say(msg, player); // log transaction msg = "User banned " + otherName + " for " + utils::toString(length) + " minutes"; accountHandler->sendTransaction(characterComponent->getDatabaseID(), @@ -1423,7 +1419,6 @@ static void handleCraft(Entity *player, std::string &args) std::stringstream errMsg; std::list<InventoryItem> recipe; Inventory playerInventory(player); - std::map<int, int> totalAmountOfItem; while (true) { diff --git a/src/game-server/spawnareacomponent.cpp b/src/game-server/spawnareacomponent.cpp index 54cb017..33bd5ac 100644 --- a/src/game-server/spawnareacomponent.cpp +++ b/src/game-server/spawnareacomponent.cpp @@ -58,7 +58,6 @@ void SpawnAreaComponent::update(Entity &entity) } // Find a free spawn location. Give up after 10 tries - int triesLeft = 10; Point position; const int x = mZone.x; const int y = mZone.y; @@ -81,6 +80,7 @@ void SpawnAreaComponent::update(Entity &entity) if (being) { + int triesLeft = 10; do { position = Point(x + rand() % width, y + rand() % height); diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index db224b8..0b97ec0 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -110,7 +110,7 @@ static void serializeLooks(Entity *ch, MessageOut &msg) } } - if (lookChanges.size() > 0) + if (!lookChanges.empty()) { // Number of look changes to send msg.writeInt8(lookChanges.size()); |