diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/beinghandler.cpp | 1 | ||||
-rw-r--r-- | src/net/buysellhandler.cpp | 12 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 45 | ||||
-rw-r--r-- | src/net/chathandler.cpp | 5 | ||||
-rw-r--r-- | src/net/equipmenthandler.cpp | 7 | ||||
-rw-r--r-- | src/net/inventoryhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/loginhandler.cpp | 35 | ||||
-rw-r--r-- | src/net/loginhandler.h | 1 | ||||
-rw-r--r-- | src/net/maploginhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/network.cpp | 14 | ||||
-rw-r--r-- | src/net/network.h | 3 | ||||
-rw-r--r-- | src/net/npchandler.cpp | 2 | ||||
-rw-r--r-- | src/net/partyhandler.cpp | 1 |
13 files changed, 67 insertions, 77 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index e13ef3a2..0db8fcbf 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -32,7 +32,6 @@ #include "../game.h" #include "../localplayer.h" #include "../log.h" -#include "../main.h" #include "../npc.h" #include "../particle.h" #include "../player_relations.h" diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp index 5292b6f9..67c79ec4 100644 --- a/src/net/buysellhandler.cpp +++ b/src/net/buysellhandler.cpp @@ -35,6 +35,8 @@ #include "../gui/chat.h" #include "../gui/sell.h" +#include "../utils/gettext.h" + extern BuyDialog *buyDialog; extern Window *buySellDialog; extern SellDialog *sellDialog; @@ -104,27 +106,27 @@ void BuySellHandler::handleMessage(MessageIn *msg) } } else { - chatWindow->chatLog("Nothing to sell", BY_SERVER); + chatWindow->chatLog(_("Nothing to sell"), BY_SERVER); current_npc = 0; } break; case SMSG_NPC_BUY_RESPONSE: if (msg->readInt8() == 0) { - chatWindow->chatLog("Thanks for buying", BY_SERVER); + chatWindow->chatLog(_("Thanks for buying"), BY_SERVER); } else { // Reset player money since buy dialog already assumed purchase // would go fine buyDialog->setMoney(player_node->mGp); - chatWindow->chatLog("Unable to buy", BY_SERVER); + chatWindow->chatLog(_("Unable to buy"), BY_SERVER); } break; case SMSG_NPC_SELL_RESPONSE: if (msg->readInt8() == 0) { - chatWindow->chatLog("Thanks for selling", BY_SERVER); + chatWindow->chatLog(_("Thanks for selling"), BY_SERVER); } else { - chatWindow->chatLog("Unable to sell", BY_SERVER); + chatWindow->chatLog(_("Unable to sell"), BY_SERVER); } break; } diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index b04fb94a..932cf705 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -21,10 +21,8 @@ #include "charserverhandler.h" #include "messagein.h" -#include "network.h" #include "protocol.h" -#include "../extensions.h" #include "../game.h" #include "../localplayer.h" #include "../log.h" @@ -34,10 +32,8 @@ #include "../gui/char_select.h" #include "../gui/ok_dialog.h" -/* - * Yeah, this is a global. Get over it. - */ -struct EXTENSIONS extensions; +#include "../utils/gettext.h" +#include "../utils/tostring.h" CharServerHandler::CharServerHandler(): mCharCreateDialog(0) @@ -58,9 +54,7 @@ CharServerHandler::CharServerHandler(): void CharServerHandler::handleMessage(MessageIn *msg) { - int slot; - int flags; - int code; + int slot, flags, code; LocalPlayer *tempPlayer; logger->log("CharServerHandler: Packet ID: %x, Length: %d", @@ -73,22 +67,22 @@ void CharServerHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Authentication failed"; + errorMessage = _("Authentication failed"); break; case 1: - errorMessage = "Map server(s) offline"; + errorMessage = _("Map server(s) offline"); break; case 2: - errorMessage = "This account is already logged in"; + errorMessage = _("This account is already logged in"); break; case 3: - errorMessage = "Speed hack detected"; + errorMessage = _("Speed hack detected"); break; case 8: - errorMessage = "Duplicated login"; + errorMessage = _("Duplicated login"); break; default: - errorMessage = "Unknown connection error"; + errorMessage = _("Unknown connection error"); break; } state = ERROR_STATE; @@ -96,11 +90,8 @@ void CharServerHandler::handleMessage(MessageIn *msg) case 0x006b: msg->skip(2); // Length word - flags = msg->readInt32(); // Aethyra extensions flags + flags = msg->readInt32(); // Aethyra extensions flags logger->log("Server flags are: %x", flags); - extensions.aethyra_inventory = (bool)(flags & 0x01); - extensions.aethyra_spells = (bool)(flags & 0x02); - extensions.aethyra_misc = (bool)(flags & 0x04); msg->skip(16); // Unused // Derive number of characters from message length @@ -112,7 +103,7 @@ void CharServerHandler::handleMessage(MessageIn *msg) mCharInfo->select(slot); mCharInfo->setEntry(tempPlayer); logger->log("CharServer: Player: %s (%d)", - tempPlayer->getName().c_str(), slot); + tempPlayer->getName().c_str(), slot); } state = CHAR_SELECT_STATE; @@ -121,13 +112,13 @@ void CharServerHandler::handleMessage(MessageIn *msg) case 0x006c: switch (msg->readInt8()) { case 0: - errorMessage = "Access denied"; + errorMessage = _("Access denied"); break; case 1: - errorMessage = "Cannot use this ID"; + errorMessage = _("Cannot use this ID"); break; default: - errorMessage = "Unknown failure to select character"; + errorMessage = _("Unknown failure to select character"); break; } mCharInfo->unlock(); @@ -149,8 +140,8 @@ void CharServerHandler::handleMessage(MessageIn *msg) break; case 0x006e: - new OkDialog("Error", "Failed to create character. Most likely" - " the name is already taken."); + new OkDialog(_("Error"), _("Failed to create character. Most likely" + " the name is already taken.")); if (mCharCreateDialog) mCharCreateDialog->unlock(); @@ -161,12 +152,12 @@ void CharServerHandler::handleMessage(MessageIn *msg) mCharInfo->setEntry(0); mCharInfo->unlock(); n_character--; - new OkDialog("Info", "Player deleted"); + new OkDialog(_("Info"), _("Player deleted")); break; case 0x0070: mCharInfo->unlock(); - new OkDialog("Error", "Failed to delete character."); + new OkDialog(_("Error"), _("Failed to delete character.")); break; case 0x0071: diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp index bf5a5a37..25877907 100644 --- a/src/net/chathandler.cpp +++ b/src/net/chathandler.cpp @@ -33,6 +33,7 @@ #include "../gui/chat.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" #include "../utils/trim.h" @@ -72,10 +73,10 @@ void ChatHandler::handleMessage(MessageIn *msg) //chatWindow->chatLog("Whisper sent", BY_SERVER); break; case 0x01: - chatWindow->chatLog("Whisper could not be sent, user is offline", BY_SERVER); + chatWindow->chatLog(_("Whisper could not be sent, user is offline"), BY_SERVER); break; case 0x02: - chatWindow->chatLog("Whisper could not be sent, ignored by user", BY_SERVER); + chatWindow->chatLog(_("Whisper could not be sent, ignored by user"), BY_SERVER); break; } break; diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 973de0f6..9a3c396a 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -23,7 +23,6 @@ #include "messagein.h" #include "protocol.h" -#include "../beingmanager.h" #include "../equipment.h" #include "../inventory.h" #include "../item.h" @@ -32,6 +31,8 @@ #include "../gui/chat.h" +#include "../utils/gettext.h" + EquipmentHandler::EquipmentHandler() { static const Uint16 _messages[] = { @@ -97,7 +98,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) logger->log("Equipping: %i %i %i", index, equipPoint, type); if (!type) { - chatWindow->chatLog("Unable to equip.", BY_SERVER); + chatWindow->chatLog(_("Unable to equip."), BY_SERVER); break; } @@ -135,7 +136,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) type = msg->readInt8(); if (!type) { - chatWindow->chatLog("Unable to unequip.", BY_SERVER); + chatWindow->chatLog(_("Unable to unequip."), BY_SERVER); break; } diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index 3ce0899a..46f03e28 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -35,6 +35,8 @@ #include "../resources/iteminfo.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" #include "../utils/tostring.h" InventoryHandler::InventoryHandler() @@ -139,13 +141,13 @@ void InventoryHandler::handleMessage(MessageIn *msg) itemType = msg->readInt8(); if (msg->readInt8() > 0) { - chatWindow->chatLog("Unable to pick up item", BY_SERVER); + chatWindow->chatLog(_("Unable to pick up item"), BY_SERVER); } else { const ItemInfo &itemInfo = ItemDB::get(itemId); const std::string amountStr = (amount > 1) ? toString(amount) : "a"; - chatWindow->chatLog("You picked up " + amountStr + " " + - itemInfo.getName(), BY_SERVER); + chatWindow->chatLog(strprintf(_("You picked up %s %s"), + amountStr.c_str(), itemInfo.getName().c_str()), BY_SERVER); if (Item *item = inventory->getItem(index)) { item->setId(itemId); @@ -182,7 +184,7 @@ void InventoryHandler::handleMessage(MessageIn *msg) amount = msg->readInt16(); if (msg->readInt8() == 0) { - chatWindow->chatLog("Failed to use item", BY_SERVER); + chatWindow->chatLog(_("Failed to use item"), BY_SERVER); } else { if (Item *item = inventory->getItem(index)) item->setQuantity(amount); diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index a262e361..41314d16 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -21,7 +21,6 @@ #include "loginhandler.h" #include "messagein.h" -#include "network.h" #include "protocol.h" #include "../log.h" @@ -29,6 +28,10 @@ #include "../main.h" #include "../serverinfo.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" +#include "../utils/tostring.h" + extern SERVER_INFO **server_info; LoginHandler::LoginHandler() @@ -55,16 +58,16 @@ void LoginHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Authentication failed"; + errorMessage = _("Authentication failed"); break; case 1: - errorMessage = "No servers available"; + errorMessage = _("No servers available"); break; case 2: - errorMessage = "This account is already logged in"; + errorMessage = _("This account is already logged in"); break; default: - errorMessage = "Unknown connection error"; + errorMessage = _("Unknown connection error"); break; } state = ERROR_STATE; @@ -119,30 +122,34 @@ void LoginHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Unregistered ID"; + errorMessage = _("Unregistered ID"); break; case 1: - errorMessage = "Wrong password"; + errorMessage = _("Wrong password"); break; case 2: - errorMessage = "Account expired"; + errorMessage = _("Account expired"); break; case 3: - errorMessage = "Rejected from server"; + errorMessage = _("Rejected from server"); break; case 4: - errorMessage = "You have been permanently banned from the game. Please contact the GM Team"; + errorMessage = _("You have been permanently banned from the" + " game. Please contact the GM Team"); break; case 6: - errorMessage = "You have been temporarily banned from the game until " - + msg->readString(20) + ".\n Please contact the GM team via the forums"; + errorMessage = strprintf(_("You have been temporarily " + "banned from the game until %s.\n" + " Please contact the GM team via " + "the forums"), + msg->readString(20).c_str()); break; case 9: - errorMessage = "This user name is already taken"; + errorMessage = _("This user name is already taken"); break; default: - errorMessage = "Unknown error"; + errorMessage = _("Unknown error"); break; } state = ERROR_STATE; diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index c847b4c1..df86b634 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -25,7 +25,6 @@ #include <string> #include "messagehandler.h" -#include <string> struct LoginData; diff --git a/src/net/maploginhandler.cpp b/src/net/maploginhandler.cpp index b851117e..b5192bd7 100644 --- a/src/net/maploginhandler.cpp +++ b/src/net/maploginhandler.cpp @@ -27,6 +27,8 @@ #include "../log.h" #include "../main.h" +#include "../utils/gettext.h" + MapLoginHandler::MapLoginHandler() { static const Uint16 _messages[] = { @@ -50,13 +52,13 @@ void MapLoginHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Authentication failed"; + errorMessage = _("Authentication failed"); break; case 2: - errorMessage = "This account is already logged in"; + errorMessage = _("This account is already logged in"); break; default: - errorMessage = "Unknown connection error"; + errorMessage = _("Unknown connection error"); break; } state = ERROR_STATE; diff --git a/src/net/network.cpp b/src/net/network.cpp index 941995c9..059da779 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -26,6 +26,7 @@ #include "network.h" #include "../log.h" +#include "../utils/tostring.h" /** Warning: buffers and other variables are shared, so there can be only one connection active at a time */ @@ -418,19 +419,6 @@ void Network::receive() SDLNet_FreeSocketSet(set); } -char *iptostring(int address) -{ - static char asciiIP[16]; - - sprintf(asciiIP, "%i.%i.%i.%i", - (unsigned char)(address), - (unsigned char)(address >> 8), - (unsigned char)(address >> 16), - (unsigned char)(address >> 24)); - - return asciiIP; -} - void Network::setError(const std::string& error) { logger->log("Network error: %s", error.c_str()); diff --git a/src/net/network.h b/src/net/network.h index c035f55c..02fe7538 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -115,7 +115,4 @@ class Network MessageHandlers mMessageHandlers; }; -/** Convert an address from int format to string */ -char *iptostring(int address); - #endif diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp index 20f2b7dc..ea03537f 100644 --- a/src/net/npchandler.cpp +++ b/src/net/npchandler.cpp @@ -92,6 +92,7 @@ void NPCHandler::handleMessage(MessageIn *msg) current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); npcIntegerDialog->setRange(0, 2147483647); npcIntegerDialog->setVisible(true); + npcIntegerDialog->requestFocus(); break; case SMSG_NPC_STR_INPUT: @@ -100,6 +101,7 @@ void NPCHandler::handleMessage(MessageIn *msg) current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); npcStringDialog->setValue(""); npcStringDialog->setVisible(true); + npcStringDialog->requestFocus(); break; } } diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp index 8f0b3a00..03aca66d 100644 --- a/src/net/partyhandler.cpp +++ b/src/net/partyhandler.cpp @@ -29,7 +29,6 @@ #include "../gui/confirm_dialog.h" #include "../beingmanager.h" -#include "../game.h" #include "../party.h" PartyHandler::PartyHandler(Party *party) : mParty(party) |