diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-02 01:51:25 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-02 01:51:25 +0200 |
commit | 582428edf9e40db0d1ed7b78222562a7a5031fe4 (patch) | |
tree | 2a9f4b1303a3647e3d7bf4599e85ebd358159b4d /src | |
parent | 218dbbd7ce5415fe8c26857f06c5907c7cc6d175 (diff) | |
download | manaplus-582428edf9e40db0d1ed7b78222562a7a5031fe4.tar.gz manaplus-582428edf9e40db0d1ed7b78222562a7a5031fe4.tar.bz2 manaplus-582428edf9e40db0d1ed7b78222562a7a5031fe4.tar.xz manaplus-582428edf9e40db0d1ed7b78222562a7a5031fe4.zip |
Add serverversion checks. And disable some advanced features in old servers.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 1 | ||||
-rw-r--r-- | src/client.h | 1 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 21 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 32 | ||||
-rw-r--r-- | src/net/tmwa/loginhandler.cpp | 26 |
6 files changed, 59 insertions, 24 deletions
diff --git a/src/client.cpp b/src/client.cpp index 4eaad4234..e1753753e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -151,6 +151,7 @@ volatile int frame_count = 0; /**< Counts the frames during one second */ volatile int cur_time; volatile bool runCounters; bool isSafeMode = false; +int serverVersion; /** * Advances game logic counter. diff --git a/src/client.h b/src/client.h index 3ed9482dd..e3f596c1a 100644 --- a/src/client.h +++ b/src/client.h @@ -59,6 +59,7 @@ extern volatile int fps; extern volatile int tick_time; extern volatile int cur_time; extern bool isSafeMode; +extern int serverVersion; class ErrorListener : public gcn::ActionListener { diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 9c5c45185..0548a2715 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -631,7 +631,10 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) else { // SMSG_BEING_CHANGE_LOOKS2 id = msg.readInt16(); - id2 = msg.readInt16(); + if (type == 2 || serverVersion > 0) + id2 = msg.readInt16(); + else + id2 = 1; color = ""; } @@ -907,10 +910,18 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (!config.getBoolValue("hideShield")) dstBeing->setSprite(SPRITE_SHIELD, shield); //dstBeing->setSprite(SPRITE_SHOE, shoes); - logger->log("bmt: %d, %d, %d", colors[0], colors[2], colors[1]); - dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom, "", colors[0]); - dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid, "", colors[2]); - dstBeing->setSprite(SPRITE_HAT, headTop, "", colors[1]); + if (serverVersion > 0) + { + dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom, "", colors[0]); + dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid, "", colors[2]); + dstBeing->setSprite(SPRITE_HAT, headTop, "", colors[1]); + } + else + { + dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom); + dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid); + dstBeing->setSprite(SPRITE_HAT, headTop); + } //dstBeing->setSprite(SPRITE_GLOVES, gloves); //dstBeing->setSprite(SPRITE_CAPE, cape); //dstBeing->setSprite(SPRITE_MISC1, misc1); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index a1b7c83b8..35cca6f07 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -83,7 +83,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) int slots = msg.readInt16(); if (slots > 0 && slots < 30) loginData.characterSlots = slots; - bool version = msg.readInt8() == 1; + bool version = msg.readInt8() == 1 && serverVersion > 0; msg.skip(17); // Unused delete_all(mCharacters); diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index fc32c3ec3..7113cddb3 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -209,6 +209,9 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) cards[0], cards[1], cards[2], cards[3]); } + if (serverVersion < 1 && identified > 1) + identified = 1; + if (msg.getId() == SMSG_PLAYER_INVENTORY) { // Trick because arrows are not considered equipment @@ -255,6 +258,9 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) refine); } + if (serverVersion < 1 && identified > 1) + identified = 1; + mInventoryItems.push_back(InventoryItem(index, itemId, amount, refine, identified, false)); } @@ -299,6 +305,9 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) if (item && item->getId() == itemId) amount += inventory->getItem(index)->getQuantity(); + if (serverVersion < 1 && identified > 1) + identified = 1; + inventory->setItem(index, itemId, amount, refine, identified, equipType != 0); } @@ -410,6 +419,9 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { if (mStorage) { + if (serverVersion < 1 && identified > 1) + identified = 1; + mStorage->setItem(index, itemId, amount, refine, identified, false); } @@ -458,29 +470,31 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { index = msg.readInt16() - INVENTORY_OFFSET; itemId = msg.readInt16(); - if (itemId == 1172) - logger->log("step1"); int itemType = msg.readInt8(); // type identified = msg.readInt8(); // identify flag + msg.readInt16(); // equip type equipType = msg.readInt16(); msg.readInt8(); // attribute refine = msg.readInt8(); msg.skip(8); // card - if (itemId == 1172) - logger->log("step2"); - if (inventory) - inventory->setItem(index, itemId, 1, refine, identified, true); - - if (equipType) - mEquips.setEquipment(getSlot(equipType), index); if (debugInventory) { logger->log("Index: %d, ID: %d, Type: %d, Identified: %d", index, itemId, itemType, identified); } + + if (serverVersion < 1 && identified > 1) + identified = 1; + + if (inventory) + inventory->setItem(index, itemId, 1, refine, identified, true); + + if (equipType) + mEquips.setEquipment(getSlot(equipType), index); + } break; diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index a1b3c0f95..810d97056 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -198,15 +198,23 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) { // TODO: verify these! - msg.readInt8(); // -1 - msg.readInt8(); // T - msg.readInt8(); // M - msg.readInt8(); // W - - unsigned int options = msg.readInt32(); - - mRegistrationEnabled = options; -// mRegistrationEnabled = (options & 1); + char b1 = msg.readInt8(); // -1 + char b2 = msg.readInt8(); // T + char b3 = msg.readInt8(); // M + char b4 = msg.readInt8(); // W + if (b1 == -1 && b2 == 'E' && b3 == 'V' && b4 == 'L') + { + unsigned int options = msg.readInt8(); + mRegistrationEnabled = options; + msg.skip(2); + serverVersion = msg.readInt8(); + } + else + { + unsigned int options = msg.readInt32(); + mRegistrationEnabled = options; + serverVersion = 0; + } // Leave this last mVersionResponse = true; |