diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-09-25 03:15:26 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-09-25 03:15:26 +0200 |
commit | 661d16e98c62dfff40f481177bf3f1a0c58c2124 (patch) | |
tree | a415866c4c94a0a0c53045a47220ca413ae9c5c9 /src/net | |
parent | 758d80263b1647c712c0e0cdd3dfca9945a1bb7e (diff) | |
parent | 7d0738df0d139af3175fcc1fec5b9be4a467f4f4 (diff) | |
download | mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.tar.gz mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.tar.bz2 mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.tar.xz mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.zip |
Merge branch '1.0'
Conflicts:
src/actorspritemanager.h
src/beingmanager.cpp
src/game.cpp
src/gui/beingpopup.cpp
src/gui/chat.cpp
src/gui/chat.h
src/gui/inventorywindow.h
src/gui/itempopup.cpp
src/gui/socialwindow.cpp
src/gui/statuswindow.cpp
src/gui/widgets/chattab.cpp
src/gui/widgets/chattab.h
src/net/tmwa/inventoryhandler.cpp
src/net/tmwa/partyhandler.cpp
src/party.cpp
src/sound.cpp
src/utils/stringutils.cpp
src/utils/stringutils.h
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/net.cpp | 12 | ||||
-rw-r--r-- | src/net/net.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 25 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/network.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 20 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 4 |
10 files changed, 65 insertions, 15 deletions
diff --git a/src/net/net.cpp b/src/net/net.cpp index 5e7c989f..7e7395a6 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -22,6 +22,7 @@ #include "net/net.h" #include "main.h" +#include "log.h" #include "net/adminhandler.h" #include "net/charhandler.h" @@ -41,6 +42,8 @@ #include "net/manaserv/generalhandler.h" +#include "utils/gettext.h" + Net::AdminHandler *adminHandler = NULL; Net::CharHandler *charHandler = NULL; Net::ChatHandler *chatHandler = NULL; @@ -124,12 +127,19 @@ namespace Net { ServerInfo::Type networkType = ServerInfo::UNKNOWN; -void connectToServer(const ServerInfo &server) +void connectToServer(ServerInfo &server) { if (server.type == ServerInfo::UNKNOWN) { // TODO: Query the server about itself and choose the netcode based on // that + + if (server.port == 6901) + server.type = ServerInfo::TMWATHENA; + else if (server.port == 9601) + server.type = ServerInfo::MANASERV; + else + logger->error(_("Unknown Server Type! Exiting.")); } if (networkType == server.type && getGeneralHandler() != NULL) diff --git a/src/net/net.h b/src/net/net.h index 9d9ee10e..6029f3ba 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -67,7 +67,7 @@ ServerInfo::Type getNetworkType(); /** * Handles server detection and connection */ -void connectToServer(const ServerInfo &server); +void connectToServer(ServerInfo &server); void unload(); diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 543beec2..97967eb9 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -47,6 +47,7 @@ BeingHandler::BeingHandler(bool enableSync): static const Uint16 _messages[] = { SMSG_BEING_VISIBLE, SMSG_BEING_MOVE, + SMSG_BEING_SPAWN, SMSG_BEING_MOVE2, SMSG_BEING_REMOVE, SMSG_SKILL_DAMAGE, @@ -227,6 +228,13 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); break; + case SMSG_BEING_SPAWN: + /* + * TODO: This packet might need handling in the future. + */ + // Do nothing. + break; + case SMSG_BEING_MOVE2: /* * A simplified movement packet, used by the diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 820864ce..1063ee39 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -77,6 +77,9 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) msg.skip(2); // Length word msg.skip(20); // Unused + delete_all(mCharacters); + mCharacters.clear(); + // Derive number of characters from message length const int count = (msg.getLength() - 24) / 106; diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 67fe5d98..39d49bc7 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -119,7 +119,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // Unused std::string guildName = msg.readString(24); - logger->log("Guild position info: %d %d %d %s\n", guildId, + logger->log("Guild position info: %d %d %d %s", guildId, emblem, posMode, guildName.c_str()); } break; diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 4a46e475..9fac8e8c 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -130,6 +130,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) int index, amount, itemId, equipType, arrow; int identified, cards[4], itemType; Inventory *inventory = PlayerInfo::getInventory(); + PlayerInfo::getEquipment()->setBackend(&mEquips); switch (msg.getId()) { @@ -139,8 +140,6 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { // Clear inventory - this will be a complete refresh mEquips.clear(); - PlayerInfo::getEquipment()->setBackend(&mEquips); - inventory->clear(); } else @@ -242,6 +241,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) inventory->setItem(index, itemId, amount); } + + inventoryWindow->updateButtons(); } break; case SMSG_PLAYER_INVENTORY_REMOVE: @@ -252,6 +253,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) item->increaseQuantity(-amount); if (item->getQuantity() == 0) inventory->removeItemAt(index); + inventoryWindow->updateButtons(); } break; @@ -263,7 +265,15 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // type if (Item *item = inventory->getItem(index)) - item->setQuantity(amount); + { + if (amount) + item->setQuantity(amount); + else + inventory->removeItemAt(index); + + inventoryWindow->updateButtons(); + } + break; case SMSG_ITEM_USE_RESPONSE: @@ -277,7 +287,14 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) else { if (Item *item = inventory->getItem(index)) - item->setQuantity(amount); + { + if (amount) + item->setQuantity(amount); + else + inventory->removeItemAt(index); + + inventoryWindow->updateButtons(); + } } break; diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 18d73517..79d3bc65 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -88,6 +88,8 @@ class EquipBackend : public Equipment::Backend { { item->setEquipped(true); } + + inventoryWindow->updateButtons(); } private: diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index ddfbbc5d..aff19b11 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -326,7 +326,7 @@ MessageIn Network::getNextMessage() len = readWord(2); #ifdef DEBUG - logger->log("Received packet 0x%x of length %d\n", msgId, len); + logger->log("Received packet 0x%x of length %d", msgId, len); #endif MessageIn msg(mInBuffer, len); diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 3d7aa263..00b1e621 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -184,7 +184,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) partyTab->chatLog(_("Experience sharing not possible."), BY_SERVER); break; default: - logger->log("Unknown party exp option: %d\n", exp); + logger->log("Unknown party exp option: %d", exp); } switch (item) @@ -208,7 +208,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) partyTab->chatLog(_("Item sharing not possible."), BY_SERVER); break; default: - logger->log("Unknown party item option: %d\n", exp); + logger->log("Unknown party item option: %d", exp); } break; } @@ -322,17 +322,23 @@ void PartyHandler::invite(Being *being) void PartyHandler::invite(const std::string &name) { - if (partyTab) + Being *invitee = actorSpriteManager->findBeingByName(name, Being::PLAYER); + + if (invitee) { - partyTab->chatLog(_("Inviting like this isn't supported at the moment."), - BY_SERVER); + invite(invitee); + partyTab->chatLog(strprintf(_("Invited user %s to party."), + invitee->getName().c_str()), BY_SERVER); + } + else if (partyTab) + { + partyTab->chatLog(strprintf(_("Inviting failed, because you can't see " + "a player called %s."), name.c_str()), BY_SERVER); } else { SERVER_NOTICE(_("You can only inivte when you are in a party!")) } - - // TODO? } void PartyHandler::inviteResponse(const std::string &inviter, bool accept) diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 6a1e8918..ca42a5c9 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -286,6 +286,10 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) player_node->setAction(Being::DEAD); } } + + if (statusWindow) + statusWindow->updateAttrs(); + break; case SMSG_PLAYER_STAT_UPDATE_2: |