diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2023-05-15 14:45:05 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2023-05-15 14:45:05 +0200 |
commit | f395960adeea1f51f01ec8045d1e175926a6ea4a (patch) | |
tree | bf9d107fb5891c3e6bd0abeb4d49573c73230707 | |
parent | f3071beef3ddd93bbe3ab6e30c14fc95a5112b9c (diff) | |
download | manaserv-f395960adeea1f51f01ec8045d1e175926a6ea4a.tar.gz manaserv-f395960adeea1f51f01ec8045d1e175926a6ea4a.tar.bz2 manaserv-f395960adeea1f51f01ec8045d1e175926a6ea4a.tar.xz manaserv-f395960adeea1f51f01ec8045d1e175926a6ea4a.zip |
General code cleanups
* Overall includes cleanup
* Use std::make_pair
* Make some functions const
44 files changed, 145 insertions, 159 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp index 2e4e5c04..9cb32af1 100644 --- a/src/account-server/accounthandler.cpp +++ b/src/account-server/accounthandler.cpp @@ -27,6 +27,7 @@ #include "account-server/serverhandler.h" #include "chat-server/chathandler.h" #include "common/configuration.h" +#include "common/defines.h" #include "common/manaserv_protocol.h" #include "common/transaction.h" #include "net/connectionhandler.h" @@ -903,7 +904,7 @@ void AccountHandler::handleCharacterSelectMessage(AccountClient &client, { MessageOut reply(APMSG_CHAR_SELECT_RESPONSE); - Account *acc = client.getAccount(); + const Account *acc = client.getAccount(); if (!acc) { reply.writeInt8(ERRMSG_NO_LOGIN); @@ -912,9 +913,10 @@ void AccountHandler::handleCharacterSelectMessage(AccountClient &client, } int slot = msg.readInt8(); - Characters &chars = acc->getCharacters(); + const Characters &chars = acc->getCharacters(); + const auto charIt = chars.find(slot); - if (chars.find(slot) == chars.end()) + if (charIt == chars.end()) { // Invalid char selection reply.writeInt8(ERRMSG_INVALID_ARGUMENT); @@ -922,14 +924,14 @@ void AccountHandler::handleCharacterSelectMessage(AccountClient &client, return; } - CharacterData *selectedChar = chars[slot]; + const CharacterData &selectedChar = *charIt->second; - std::string address; - int port; + std::string gameServerAddress; + int gameServerPort; if (!GameServerHandler::getGameServerFromMap - (selectedChar->getMapId(), address, port)) + (selectedChar.getMapId(), gameServerAddress, gameServerPort)) { - LOG_ERROR("Character Selection: No game server for map #"<<selectedChar->getMapId()); + LOG_ERROR("Character Selection: No game server for map #" << selectedChar.getMapId()); reply.writeInt8(ERRMSG_FAILURE); client.send(reply); return; @@ -937,12 +939,12 @@ void AccountHandler::handleCharacterSelectMessage(AccountClient &client, reply.writeInt8(ERRMSG_OK); - LOG_DEBUG(selectedChar->getName() << " is trying to enter the servers."); + LOG_DEBUG(selectedChar.getName() << " is trying to enter the servers."); std::string magic_token(utils::getMagicToken()); reply.writeString(magic_token, MAGIC_TOKEN_LENGTH); - reply.writeString(address); - reply.writeInt16(port); + reply.writeString(gameServerAddress); + reply.writeInt16(gameServerPort); // Give address and port for the chat server reply.writeString(Configuration::getValue("net_publicChatHost", @@ -950,21 +952,20 @@ void AccountHandler::handleCharacterSelectMessage(AccountClient &client, // When the chatListenToClientPort is set, we use it. // Otherwise, we use the accountListenToClientPort + 2 if the option is set. - // If neither, the DEFAULT_SERVER_PORT + 2 is used. - const int alternativePort = + const int defaultChatPort = Configuration::getValue("net_accountListenToClientPort", DEFAULT_SERVER_PORT) + 2; reply.writeInt16(Configuration::getValue("net_chatListenToClientPort", - alternativePort)); + defaultChatPort)); GameServerHandler::registerClient(magic_token, selectedChar); - registerChatClient(magic_token, selectedChar->getName(), acc->getLevel()); + registerChatClient(magic_token, selectedChar.getName(), acc->getLevel()); client.send(reply); // log transaction Transaction trans; - trans.mCharacterId = selectedChar->getDatabaseID(); + trans.mCharacterId = selectedChar.getDatabaseID(); trans.mAction = TRANS_CHAR_SELECTED; storage->addTransaction(trans); } diff --git a/src/account-server/character.cpp b/src/account-server/character.cpp index c61be1f6..a43c91e7 100644 --- a/src/account-server/character.cpp +++ b/src/account-server/character.cpp @@ -41,7 +41,7 @@ CharacterData::CharacterData(const std::string &name, int id): { } -void CharacterData::serialize(MessageOut &msg) +void CharacterData::serialize(MessageOut &msg) const { // general character properties msg.writeInt8(getAccountLevel()); @@ -94,7 +94,7 @@ void CharacterData::serialize(MessageOut &msg) // questlog msg.writeInt16(mQuests.size()); - for (QuestInfo &quest : mQuests) { + for (const QuestInfo &quest : mQuests) { msg.writeInt16(quest.id); msg.writeInt8(quest.state); msg.writeString(quest.title); diff --git a/src/account-server/character.h b/src/account-server/character.h index d7e905cc..e3c1b49c 100644 --- a/src/account-server/character.h +++ b/src/account-server/character.h @@ -25,7 +25,6 @@ #include <vector> #include <set> -#include "common/defines.h" #include "common/inventorydata.h" #include "utils/point.h" @@ -82,7 +81,7 @@ class CharacterData public: CharacterData(const std::string &name, int id = -1); - void serialize(MessageOut &msg); + void serialize(MessageOut &msg) const; void deserialize(MessageIn &msg); /** diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index 54754546..aa9f78cd 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -18,13 +18,12 @@ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>. */ +#include "account-server/serverhandler.h" + #include <cassert> #include <sstream> #include <list> -#include "account-server/serverhandler.h" - -#include "account-server/accountclient.h" #include "account-server/accounthandler.h" #include "account-server/character.h" #include "account-server/flooritem.h" @@ -154,20 +153,20 @@ bool GameServerHandler::getGameServerFromMap(int mapId, } static void registerGameClient(GameServer *s, const std::string &token, - CharacterData *ptr) + const CharacterData &ptr) { MessageOut msg(AGMSG_PLAYER_ENTER); msg.writeString(token, MAGIC_TOKEN_LENGTH); - msg.writeInt32(ptr->getDatabaseID()); - msg.writeString(ptr->getName()); - ptr->serialize(msg); + msg.writeInt32(ptr.getDatabaseID()); + msg.writeString(ptr.getName()); + ptr.serialize(msg); s->send(msg); } void GameServerHandler::registerClient(const std::string &token, - CharacterData *ptr) + const CharacterData &ptr) { - GameServer *s = ::getGameServerFromMap(ptr->getMapId()); + GameServer *s = ::getGameServerFromMap(ptr.getMapId()); assert(s); registerGameClient(s, token, ptr); } @@ -318,7 +317,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) int mapId = ptr->getMapId(); if (GameServer *s = getGameServerFromMap(mapId)) { - registerGameClient(s, magic_token, ptr); + registerGameClient(s, magic_token, *ptr); MessageOut result(AGMSG_REDIRECT_RESPONSE); result.writeInt32(id); result.writeString(magic_token, MAGIC_TOKEN_LENGTH); @@ -470,11 +469,8 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) break; } - // get the post for that character - Post *post = postalManager->getPost(ptr); - - // send the post if valid - if (post) + // get the post for that character and send the post if valid + if (Post *post = postalManager->getPost(ptr)) { for (unsigned i = 0; i < post->getNumberOfLetters(); ++i) { @@ -483,8 +479,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) Letter *letter = post->getLetter(i); result.writeString(letter->getSender()->getName()); result.writeString(letter->getContents()); - std::vector<InventoryItem> items = letter->getAttachments(); - for (auto &item : items) + for (auto &item : letter->getAttachments()) { result.writeInt16(item.itemId); result.writeInt16(item.amount); @@ -522,26 +517,18 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) break; } - // get the letter contents - std::string contents = msg.readString(); - - std::vector< std::pair<int, int> > items; - while (msg.getUnreadLength()) - { - items.push_back(std::pair<int, int>(msg.readInt16(), msg.readInt16())); - } - // save the letter LOG_DEBUG("Creating letter"); auto letter = new Letter(0, sender, receiver); - letter->addText(contents); - for (auto &i : items) + letter->addText(msg.readString()); + while (msg.getUnreadLength() >= 4) { InventoryItem item; - item.itemId = i.first; - item.amount = i.second; + item.itemId = msg.readInt16(); + item.amount = msg.readInt16(); letter->addAttachment(item); } + postalManager->addLetter(letter); result.writeInt8(ERRMSG_OK); diff --git a/src/account-server/serverhandler.h b/src/account-server/serverhandler.h index 916a0224..57732d1d 100644 --- a/src/account-server/serverhandler.h +++ b/src/account-server/serverhandler.h @@ -48,9 +48,9 @@ namespace GameServerHandler bool getGameServerFromMap(int, std::string &address, int &port); /** - * Warns a game server about a soon-to-connect client. + * Notifies a game server about a soon-to-connect client. */ - void registerClient(const std::string &token, CharacterData *); + void registerClient(const std::string &token, const CharacterData &); /** * Dumps per-server statistics into given stream diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index 34a49cfc..96590524 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -26,10 +26,10 @@ #include "account-server/account.h" #include "account-server/character.h" #include "account-server/flooritem.h" -#include "chat-server/chatchannel.h" #include "chat-server/guild.h" #include "chat-server/post.h" #include "common/configuration.h" +#include "common/defines.h" #include "common/manaserv_protocol.h" #include "dal/dalexcept.h" #include "dal/dataproviderfactory.h" @@ -1438,14 +1438,13 @@ std::map<int, Guild*> Storage::getGuildList() std::list<std::pair<int, int> > members; for (unsigned j = 0; j < memberInfo.rows(); ++j) { - members.push_back(std::pair<int, int>(toUint(memberInfo(j, 0)), - toUint(memberInfo(j, 1)))); + members.push_back(std::make_pair(toUint(memberInfo(j, 0)), + toUint(memberInfo(j, 1)))); } for (auto i : members) { - CharacterData *character = getCharacter(i.first, nullptr); - if (character) + if (CharacterData *character = getCharacter(i.first, nullptr)) { character->addGuild(guild.second->getName()); guild.second->addMember(character->getDatabaseID(), i.second); @@ -1945,7 +1944,6 @@ void Storage::syncDatabase() } dal::PerformTransaction transaction(mDb); - int itemCount = 0; for_each_xml_child_node(node, rootNode) { // Try to load the version of the item database. @@ -2029,7 +2027,6 @@ void Storage::syncDatabase() utils::throwError("(Storage::SyncDatabase) " "SQL query preparation failure #1."); } - itemCount++; } catch (const dal::DbSqlQueryExecFailure &e) { diff --git a/src/chat-server/chatchannel.cpp b/src/chat-server/chatchannel.cpp index 2673bd18..aee4eb8c 100644 --- a/src/chat-server/chatchannel.cpp +++ b/src/chat-server/chatchannel.cpp @@ -108,7 +108,7 @@ void ChatChannel::setUserMode(ChatClient *user, unsigned char mode) else { std::stringstream ss; ss << mode; - user->userModes.insert(std::pair<ChatChannel*, std::string>(this, ss.str())); + user->userModes.insert(std::make_pair(this, ss.str())); } } diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp index a80d8404..a33d08a9 100644 --- a/src/chat-server/chathandler.cpp +++ b/src/chat-server/chathandler.cpp @@ -98,11 +98,10 @@ void ChatHandler::tokenMatched(ChatClient *client, Pending *p) msg.writeInt8(ERRMSG_OK); // Add chat client to player map - mPlayerMap.insert(std::pair<std::string, ChatClient*>(client->characterName, client)); + mPlayerMap.insert(std::make_pair(client->characterName, client)); } client->send(msg); - } NetComputer *ChatHandler::computerConnected(ENetPeer *peer) diff --git a/src/chat-server/guildhandler.cpp b/src/chat-server/guildhandler.cpp index b6870699..a47f8073 100644 --- a/src/chat-server/guildhandler.cpp +++ b/src/chat-server/guildhandler.cpp @@ -22,6 +22,7 @@ #include "chatchannel.h" #include "chatchannelmanager.h" #include "chatclient.h" +#include "common/defines.h" #include "guild.h" #include "guildmanager.h" @@ -54,12 +55,9 @@ void ChatHandler::sendGuildInvite(const std::string &invitedName, void ChatHandler::sendGuildRejoin(ChatClient &client) { // Get list of guilds and check what rights they have. - std::vector<Guild *> guilds = - guildManager->getGuildsForPlayer(client.characterId); + client.guilds = guildManager->getGuildsForPlayer(client.characterId); - client.guilds = guilds; - - for (auto guild : guilds) + for (auto guild : client.guilds) { const int permissions = guild->getUserPermissions(client.characterId); const std::string guildName = guild->getName(); diff --git a/src/chat-server/post.cpp b/src/chat-server/post.cpp index aca1de65..cfd9506b 100644 --- a/src/chat-server/post.cpp +++ b/src/chat-server/post.cpp @@ -52,7 +52,7 @@ void Letter::addText(const std::string &text) mContents = text; } -std::string Letter::getContents() const +const std::string &Letter::getContents() const { return mContents; } @@ -80,7 +80,7 @@ CharacterData *Letter::getSender() const return mSender; } -std::vector<InventoryItem> Letter::getAttachments() const +const std::vector<InventoryItem> &Letter::getAttachments() const { return mAttachments; } diff --git a/src/chat-server/post.h b/src/chat-server/post.h index 88a85489..de15bf1a 100644 --- a/src/chat-server/post.h +++ b/src/chat-server/post.h @@ -85,7 +85,7 @@ public: * Get the text contents of letter * @return String containing the text */ - std::string getContents() const; + const std::string &getContents() const; /** * Add an attachment @@ -109,7 +109,7 @@ public: /** * Get the attachments */ - std::vector<InventoryItem> getAttachments() const; + const std::vector<InventoryItem> &getAttachments() const; private: unsigned mId; diff --git a/src/common/permissionmanager.cpp b/src/common/permissionmanager.cpp index 661c1ae3..cae5fee0 100644 --- a/src/common/permissionmanager.cpp +++ b/src/common/permissionmanager.cpp @@ -21,6 +21,7 @@ #include "common/permissionmanager.h" #include "game-server/charactercomponent.h" +#include "game-server/entity.h" #include "utils/logger.h" #include "utils/xml.h" @@ -172,4 +173,3 @@ std::list<std::string> PermissionManager::getClassList(const Entity* character) return result; } - diff --git a/src/dal/dataprovider.cpp b/src/dal/dataprovider.cpp index 6c8c1674..7dedcaf2 100644 --- a/src/dal/dataprovider.cpp +++ b/src/dal/dataprovider.cpp @@ -20,8 +20,6 @@ #include "dataprovider.h" -#include "utils/logger.h" - namespace dal { diff --git a/src/game-server/abilitycomponent.cpp b/src/game-server/abilitycomponent.cpp index eb224980..b1213245 100644 --- a/src/game-server/abilitycomponent.cpp +++ b/src/game-server/abilitycomponent.cpp @@ -20,7 +20,7 @@ #include "abilitycomponent.h" -#include "game-server/being.h" +#include "game-server/actorcomponent.h" #include "game-server/entity.h" #include "scripting/scriptmanager.h" @@ -211,8 +211,8 @@ bool AbilityComponent::giveAbility(int id) bool AbilityComponent::giveAbility(const AbilityManager::AbilityInfo *info) { - bool added = mAbilities.insert(std::pair<int, AbilityValue>(info->id, - AbilityValue(info))).second; + bool added = mAbilities.insert(std::make_pair(info->id, + AbilityValue(info))).second; signal_ability_changed.emit(info->id); return added; diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp index 6072894e..03941778 100644 --- a/src/game-server/accountconnection.cpp +++ b/src/game-server/accountconnection.cpp @@ -21,9 +21,10 @@ #include "game-server/accountconnection.h" #include "common/configuration.h" +#include "common/defines.h" +#include "game-server/being.h" #include "game-server/charactercomponent.h" #include "game-server/gamehandler.h" -#include "game-server/map.h" #include "game-server/mapcomposite.h" #include "game-server/mapmanager.h" #include "game-server/item.h" @@ -34,7 +35,6 @@ #include "net/messagein.h" #include "utils/logger.h" #include "utils/tokendispenser.h" -#include "utils/tokencollector.h" /** Maximum size of sync buffer in bytes. */ const unsigned SYNC_BUFFER_SIZE = 1024; diff --git a/src/game-server/attributeinfo.h b/src/game-server/attributeinfo.h index b18e8f6d..b1cae1a6 100644 --- a/src/game-server/attributeinfo.h +++ b/src/game-server/attributeinfo.h @@ -22,6 +22,7 @@ #define ATTRIBUTEINFO_H_ #include <limits> +#include <string> #include <vector> /** diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index 238d63e6..b1e6063b 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -18,22 +18,19 @@ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>. */ -#include <cassert> - #include "game-server/being.h" -#include "common/configuration.h" +#include <cassert> + #include "common/defines.h" +#include "game-server/actorcomponent.h" #include "game-server/attributemanager.h" -#include "game-server/charactercomponent.h" -#include "game-server/collisiondetection.h" #include "game-server/mapcomposite.h" -#include "game-server/effect.h" #include "game-server/statuseffect.h" #include "game-server/statusmanager.h" +#include "scripting/scriptmanager.h" #include "utils/logger.h" #include "utils/speedconv.h" -#include "scripting/scriptmanager.h" Script::Ref BeingComponent::mRecalculateDerivedAttributesCallback; @@ -363,8 +360,7 @@ void BeingComponent::setAttribute(Entity &entity, void BeingComponent::createAttribute(AttributeInfo *attributeInfo) { - mAttributes.insert(std::pair<AttributeInfo *, Attribute> - (attributeInfo, Attribute(attributeInfo))); + mAttributes.insert(std::make_pair(attributeInfo, Attribute(attributeInfo))); } const Attribute *BeingComponent::getAttribute(AttributeInfo *attribute) const diff --git a/src/game-server/being.h b/src/game-server/being.h index 38fd3247..6e5933ec 100644 --- a/src/game-server/being.h +++ b/src/game-server/being.h @@ -27,12 +27,16 @@ #include <string> #include <vector> -#include "game-server/actorcomponent.h" #include "game-server/attribute.h" -#include "game-server/attributemanager.h" +#include "game-server/component.h" +#include "game-server/map.h" #include "game-server/timeout.h" - #include "scripting/script.h" +#include "utils/point.h" + +#include <sigc++/signal.h> + +using namespace ManaServ; class BeingComponent; class MapComposite; diff --git a/src/game-server/buysell.cpp b/src/game-server/buysell.cpp index 86975393..61a0c14a 100644 --- a/src/game-server/buysell.cpp +++ b/src/game-server/buysell.cpp @@ -20,6 +20,7 @@ #include "game-server/buysell.h" +#include "game-server/being.h" #include "game-server/charactercomponent.h" #include "game-server/gamehandler.h" #include "game-server/inventory.h" diff --git a/src/game-server/charactercomponent.cpp b/src/game-server/charactercomponent.cpp index 68ecc792..4f2244ac 100644 --- a/src/game-server/charactercomponent.cpp +++ b/src/game-server/charactercomponent.cpp @@ -21,12 +21,13 @@ #include "game-server/charactercomponent.h" #include "common/configuration.h" +#include "game-server/abilitycomponent.h" #include "game-server/accountconnection.h" +#include "game-server/actorcomponent.h" #include "game-server/attributemanager.h" +#include "game-server/being.h" #include "game-server/buysell.h" #include "game-server/inventory.h" -#include "game-server/item.h" -#include "game-server/itemmanager.h" #include "game-server/gamehandler.h" #include "game-server/map.h" #include "game-server/mapcomposite.h" @@ -207,9 +208,9 @@ void CharacterComponent::deserialize(Entity &entity, MessageIn &msg) poss.setEquipment(equipmentData); } -void CharacterComponent::serialize(Entity &entity, MessageOut &msg) +void CharacterComponent::serialize(Entity &entity, MessageOut &msg) const { - auto *beingComponent = entity.getComponent<BeingComponent>(); + const auto *beingComponent = entity.getComponent<BeingComponent>(); // general character properties msg.writeInt8(getAccountLevel()); @@ -268,8 +269,8 @@ void CharacterComponent::serialize(Entity &entity, MessageOut &msg) // questlog msg.writeInt16(mQuestlog.size()); - for (auto questlogIt : mQuestlog) { - QuestInfo &quest = questlogIt.second; + for (const auto &questlogIt : mQuestlog) { + const QuestInfo &quest = questlogIt.second; msg.writeInt16(quest.id); msg.writeInt8(quest.state); msg.writeString(quest.title); diff --git a/src/game-server/charactercomponent.h b/src/game-server/charactercomponent.h index 2160e1cb..5a468dcc 100644 --- a/src/game-server/charactercomponent.h +++ b/src/game-server/charactercomponent.h @@ -21,25 +21,23 @@ #ifndef CHARACTER_H #define CHARACTER_H -#include "common/defines.h" #include "common/inventorydata.h" #include "common/manaserv_protocol.h" -#include "game-server/abilitycomponent.h" -#include "game-server/being.h" +#include "game-server/component.h" #include "game-server/mapcomposite.h" -#include "game-server/mapmanager.h" -#include "game-server/abilitymanager.h" - +#include "game-server/timeout.h" #include "scripting/script.h" -#include "utils/logger.h" - #include <map> #include <set> #include <string> #include <vector> +#include <sigc++/signal.h> + +using namespace ManaServ; + class BuySell; struct GameClient; class MessageIn; @@ -313,7 +311,7 @@ class CharacterComponent : public Component sigc::signal<void, Entity &> signal_disconnected; - void serialize(Entity &entity, MessageOut &msg); + void serialize(Entity &entity, MessageOut &msg) const; private: void deserialize(Entity &entity, MessageIn &msg); diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index 4c51df4f..c9ec4e44 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -20,6 +20,8 @@ #include <sstream> +#include "game-server/abilitycomponent.h" +#include "game-server/being.h" #include "game-server/commandhandler.h" #include "game-server/accountconnection.h" #include "game-server/charactercomponent.h" diff --git a/src/game-server/effect.cpp b/src/game-server/effect.cpp index a1af5288..f4cd87b8 100644 --- a/src/game-server/effect.cpp +++ b/src/game-server/effect.cpp @@ -21,6 +21,7 @@ #include "game-server/effect.h" +#include "game-server/actorcomponent.h" #include "game-server/being.h" #include "game-server/entity.h" #include "game-server/state.h" diff --git a/src/game-server/effect.h b/src/game-server/effect.h index 2517f50f..8146044b 100644 --- a/src/game-server/effect.h +++ b/src/game-server/effect.h @@ -23,7 +23,6 @@ #define EFFECT_H #include "game-server/component.h" -#include "game-server/state.h" class Entity; class MapComposite; diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index 01653f2a..2ed4b1b7 100644 --- a/src/game-server/gamehandler.cpp +++ b/src/game-server/gamehandler.cpp @@ -18,21 +18,22 @@ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>. */ +#include "game-server/gamehandler.h" + #include <cassert> #include <map> -#include "game-server/gamehandler.h" - #include "common/configuration.h" #include "common/transaction.h" +#include "game-server/abilitycomponent.h" #include "game-server/accountconnection.h" +#include "game-server/being.h" #include "game-server/buysell.h" #include "game-server/commandhandler.h" #include "game-server/emotemanager.h" #include "game-server/inventory.h" #include "game-server/item.h" #include "game-server/itemmanager.h" -#include "game-server/map.h" #include "game-server/mapcomposite.h" #include "game-server/npc.h" #include "game-server/postman.h" diff --git a/src/game-server/inventory.cpp b/src/game-server/inventory.cpp index 9468001e..221bffc1 100644 --- a/src/game-server/inventory.cpp +++ b/src/game-server/inventory.cpp @@ -18,14 +18,16 @@ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>. */ +#include "game-server/inventory.h" + #include <algorithm> #include <cassert> +#include "game-server/being.h" +#include "game-server/charactercomponent.h" #include "game-server/gamehandler.h" -#include "game-server/inventory.h" #include "game-server/item.h" #include "game-server/itemmanager.h" -#include "game-server/state.h" #include "net/messageout.h" #include "utils/logger.h" diff --git a/src/game-server/inventory.h b/src/game-server/inventory.h index 627d0c97..6b222a87 100644 --- a/src/game-server/inventory.h +++ b/src/game-server/inventory.h @@ -21,8 +21,8 @@ #ifndef INVENTORY_H #define INVENTORY_H -#include "game-server/charactercomponent.h" -#include "net/messageout.h" +#include "common/inventorydata.h" +#include "game-server/entity.h" class ItemClass; diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp index d9df83cd..2d169a05 100644 --- a/src/game-server/mapcomposite.cpp +++ b/src/game-server/mapcomposite.cpp @@ -24,8 +24,8 @@ #include "accountconnection.h" #include "common/configuration.h" -#include "common/resourcemanager.h" -#include "game-server/charactercomponent.h" +#include "game-server/actorcomponent.h" +#include "game-server/being.h" #include "game-server/mapcomposite.h" #include "game-server/map.h" #include "game-server/mapmanager.h" diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index 0688abf7..fbc2b4a1 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -20,18 +20,16 @@ #include "game-server/monster.h" -#include "common/configuration.h" -#include "common/resourcemanager.h" +#include "game-server/abilitycomponent.h" +#include "game-server/actorcomponent.h" #include "game-server/attributemanager.h" -#include "game-server/charactercomponent.h" -#include "game-server/collisiondetection.h" -#include "game-server/item.h" +#include "game-server/being.h" +#include "game-server/entity.h" #include "game-server/map.h" #include "game-server/mapcomposite.h" #include "game-server/state.h" #include "scripting/scriptmanager.h" #include "utils/logger.h" -#include "utils/speedconv.h" #include <cmath> @@ -115,4 +113,3 @@ void MonsterComponent::monsterDied(Entity *monster) { mDecayTimeout.set(DECAY_TIME); } - diff --git a/src/game-server/monster.h b/src/game-server/monster.h index a6b17369..8c1da777 100644 --- a/src/game-server/monster.h +++ b/src/game-server/monster.h @@ -21,15 +21,12 @@ #ifndef MONSTER_H #define MONSTER_H -#include "game-server/abilitymanager.h" -#include "game-server/being.h" - #include "common/defines.h" - +#include "game-server/abilitymanager.h" +#include "game-server/component.h" +#include "game-server/timeout.h" #include "scripting/script.h" -#include "utils/string.h" - #include <map> #include <set> #include <string> @@ -37,6 +34,8 @@ #include <sigc++/connection.h> +using namespace ManaServ; + class CharacterComponent; class ItemClass; class Script; diff --git a/src/game-server/npc.cpp b/src/game-server/npc.cpp index bcc62d33..fa4901b1 100644 --- a/src/game-server/npc.cpp +++ b/src/game-server/npc.cpp @@ -21,10 +21,8 @@ #include "game-server/npc.h" +#include "game-server/actorcomponent.h" #include "game-server/charactercomponent.h" -#include "game-server/gamehandler.h" -#include "game-server/map.h" -#include "net/messageout.h" #include "scripting/script.h" #include "scripting/scriptmanager.h" diff --git a/src/game-server/postman.h b/src/game-server/postman.h index a8d82770..03443e2b 100644 --- a/src/game-server/postman.h +++ b/src/game-server/postman.h @@ -24,6 +24,7 @@ #include <map> #include <string> +#include "game-server/accountconnection.h" #include "game-server/charactercomponent.h" #include "game-server/entity.h" @@ -57,13 +58,13 @@ public: std::map<int, Entity*>::iterator itr = mCharacters.find(dataBaseId); if (itr == mCharacters.end()) { - mCharacters.insert(std::pair<int, Entity*>(dataBaseId, player)); + mCharacters.insert(std::make_pair(dataBaseId, player)); } } void getPost(Entity *player, PostCallback &f) { - mCallbacks.insert(std::pair<Entity*, PostCallback>(player, f)); + mCallbacks.insert(std::make_pair(player, f)); accountHandler->getPost(player); } diff --git a/src/game-server/quest.cpp b/src/game-server/quest.cpp index 444c8140..f7b97d34 100644 --- a/src/game-server/quest.cpp +++ b/src/game-server/quest.cpp @@ -22,6 +22,8 @@ #include "game-server/accountconnection.h" #include "game-server/charactercomponent.h" +#include "game-server/entity.h" +#include "scripting/scriptmanager.h" #include "utils/logger.h" #include <cassert> diff --git a/src/game-server/quest.h b/src/game-server/quest.h index 4344f1c9..aa4f8bfc 100644 --- a/src/game-server/quest.h +++ b/src/game-server/quest.h @@ -21,13 +21,7 @@ #ifndef GAMESERVER_QUEST_H #define GAMESERVER_QUEST_H -#include <string> - -#include "scripting/scriptmanager.h" - -class Entity; -class Script; - +#include "scripting/script.h" class QuestCallback { diff --git a/src/game-server/settingsmanager.cpp b/src/game-server/settingsmanager.cpp index d6e5e564..b9b5c3bb 100644 --- a/src/game-server/settingsmanager.cpp +++ b/src/game-server/settingsmanager.cpp @@ -19,19 +19,18 @@ */ #include "game-server/settingsmanager.h" -#include "common/defines.h" -#include "utils/logger.h" -#include "utils/xml.h" +#include "common/defines.h" #include "common/resourcemanager.h" - #include "game-server/abilitymanager.h" #include "game-server/attributemanager.h" +#include "game-server/emotemanager.h" #include "game-server/itemmanager.h" #include "game-server/mapmanager.h" #include "game-server/monstermanager.h" -#include "game-server/emotemanager.h" #include "game-server/statusmanager.h" +#include "utils/logger.h" +#include "utils/xml.h" /** * Initialize all managers and load configuration into them. diff --git a/src/game-server/spawnareacomponent.cpp b/src/game-server/spawnareacomponent.cpp index 15e24b3a..c532a172 100644 --- a/src/game-server/spawnareacomponent.cpp +++ b/src/game-server/spawnareacomponent.cpp @@ -20,6 +20,9 @@ #include "game-server/spawnareacomponent.h" +#include "game-server/actorcomponent.h" +#include "game-server/being.h" +#include "game-server/entity.h" #include "game-server/mapcomposite.h" #include "game-server/monster.h" #include "game-server/state.h" diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index 6fa84901..47fe9053 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -21,10 +21,12 @@ #include "game-server/state.h" #include "common/configuration.h" +#include "game-server/abilitycomponent.h" #include "game-server/accountconnection.h" +#include "game-server/being.h" +#include "game-server/charactercomponent.h" #include "game-server/effect.h" #include "game-server/gamehandler.h" -#include "game-server/inventory.h" #include "game-server/item.h" #include "game-server/itemmanager.h" #include "game-server/map.h" @@ -32,12 +34,10 @@ #include "game-server/mapmanager.h" #include "game-server/monster.h" #include "game-server/npc.h" -#include "game-server/trade.h" #include "net/messageout.h" #include "scripting/script.h" #include "scripting/scriptmanager.h" #include "utils/logger.h" -#include "utils/speedconv.h" #include <cassert> diff --git a/src/game-server/trade.cpp b/src/game-server/trade.cpp index a7cf7153..a6114f80 100644 --- a/src/game-server/trade.cpp +++ b/src/game-server/trade.cpp @@ -18,11 +18,14 @@ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>. */ +#include "game-server/trade.h" + #include <algorithm> #include <cassert> -#include "game-server/trade.h" - +#include "common/defines.h" +#include "game-server/actorcomponent.h" +#include "game-server/being.h" #include "game-server/charactercomponent.h" #include "game-server/gamehandler.h" #include "game-server/inventory.h" diff --git a/src/net/bandwidth.cpp b/src/net/bandwidth.cpp index d394b222..5550fbee 100644 --- a/src/net/bandwidth.cpp +++ b/src/net/bandwidth.cpp @@ -50,7 +50,7 @@ void BandwidthMonitor::increaseClientOutput(NetComputer *nc, int size) if (itr == mClientBandwidth.end()) { std::pair<ClientBandwidth::iterator, bool> retItr; - retItr = mClientBandwidth.insert(std::pair<NetComputer*, std::pair<int, int> >(nc, std::pair<int, int>(0, 0))); + retItr = mClientBandwidth.insert(std::make_pair(nc, std::make_pair(0, 0))); itr = retItr.first; } @@ -69,7 +69,7 @@ void BandwidthMonitor::increaseClientInput(NetComputer *nc, int size) if (itr == mClientBandwidth.end()) { std::pair<ClientBandwidth::iterator, bool> retItr; - retItr = mClientBandwidth.insert(std::pair<NetComputer*, std::pair<int, int> >(nc, std::pair<int, int>(0, 0))); + retItr = mClientBandwidth.insert(std::make_pair(nc, std::make_pair(0, 0))); itr = retItr.first; } diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 8b92ecd4..ce2ee95f 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -24,7 +24,9 @@ #include "common/defines.h" #include "common/resourcemanager.h" +#include "game-server/abilitycomponent.h" #include "game-server/accountconnection.h" +#include "game-server/being.h" #include "game-server/buysell.h" #include "game-server/charactercomponent.h" #include "game-server/collisiondetection.h" @@ -50,7 +52,6 @@ #include "scripting/luascript.h" #include "scripting/scriptmanager.h" #include "utils/logger.h" -#include "utils/speedconv.h" #include <cstring> #include <cmath> diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index c737aad9..99b92960 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -23,11 +23,12 @@ #include <cstring> -#include "game-server/charactercomponent.h" +#include "game-server/actorcomponent.h" +#include "game-server/being.h" +#include "game-server/entity.h" #include "game-server/itemmanager.h" #include "game-server/monster.h" #include "game-server/monstermanager.h" -#include "game-server/npc.h" #include "utils/logger.h" @@ -299,7 +300,7 @@ AbilityManager::AbilityInfo *checkAbility(lua_State *s, int p) AttributeInfo *checkAttribute(lua_State *s, int p) { - AttributeInfo *attributeInfo; + AttributeInfo *attributeInfo = nullptr; switch (lua_type(s, p)) { diff --git a/src/scripting/scriptmanager.cpp b/src/scripting/scriptmanager.cpp index 06b9b761..9abf3ebb 100644 --- a/src/scripting/scriptmanager.cpp +++ b/src/scripting/scriptmanager.cpp @@ -22,6 +22,7 @@ #include "common/configuration.h" #include "scripting/script.h" +#include "utils/logger.h" static Script *_currentState; diff --git a/src/scripting/scriptmanager.h b/src/scripting/scriptmanager.h index 293b1dab..0347774e 100644 --- a/src/scripting/scriptmanager.h +++ b/src/scripting/scriptmanager.h @@ -21,7 +21,8 @@ #ifndef SCRIPTMANAGER_H #define SCRIPTMANAGER_H -#include "game-server/charactercomponent.h" +#include "common/inventorydata.h" +#include "game-server/entity.h" #include <string> diff --git a/src/utils/tokencollector.cpp b/src/utils/tokencollector.cpp index ecbae632..2af10445 100644 --- a/src/utils/tokencollector.cpp +++ b/src/utils/tokencollector.cpp @@ -92,7 +92,8 @@ void TokenCollectorBase::removeOutdated(time_t current) { // Timeout happens after 30 seconds. Much longer may actually pass, though. time_t threshold = current - 30; - if (threshold < mLastCheck) return; + if (threshold < mLastCheck) + return; std::list<Item>::iterator it; |