diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 28d6c4ab..98c7e974 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -48,14 +48,18 @@ end function g_game.getSupportedClients() return { - 760, 770, 772, 780, 781, 782, 790, - 792, 800, 810, 811, 840, 842, 850, - 853, 854, 860, 861, 862, 870, 910, - 940, 944, 953, 954, 960, 961, 963, - 970, 972, 973, 980, 981, 982, 983, - 984, 985, 986, 1001, 1002, 1010, - 1020, 1021, 1022, 1031, 1034, 1035, - 1036, 1037, 1038, 1039, 1040, 1041 + 740, 760, 770, 772, + 780, 781, 782, 790, 792, + + 800, 810, 811, 840, 842, 850, + 853, 854, 860, 861, 862, 870, + + 910, 940, 944, 953, 954, 960, 961, + 963, 970, 972, 973, 980, 981, 982, + 983, 984, 985, 986, + + 1001, 1002, 1010, 1020, 1021, 1022, 1031, + 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041 } end diff --git a/src/client/const.h b/src/client/const.h index 2914199c..7a5dcc1f 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -333,7 +333,6 @@ namespace Otc }; enum GameFeature { - // 1-50 defined in c++ GameProtocolChecksum = 1, GameAccountNames = 2, GameChallengeOnLogin = 3, @@ -352,7 +351,7 @@ namespace Otc GameMagicEffectU16 = 16, GamePlayerMarket = 17, GameSpritesU32 = 18, - GameChargeableItems = 19, + // 19 unused GameOfflineTrainingTime = 20, GamePurseSlot = 21, GameFormatCreatureName = 22, diff --git a/src/client/game.cpp b/src/client/game.cpp index 71c6d5d6..87472043 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1475,36 +1475,30 @@ void Game::setProtocolVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change protocol version while online"); - if(version != 0 && (version < 760 || version > 1041)) + if(version != 0 && (version < 740 || version > 1041)) stdext::throw_exception(stdext::format("Protocol version %d not supported", version)); m_features.reset(); enableFeature(Otc::GameFormatCreatureName); - if(version >= 770) - { + if(version >= 770) { enableFeature(Otc::GameLooktypeU16); enableFeature(Otc::GameMessageStatements); } - if(version >= 780) - { + if(version >= 780) { enableFeature(Otc::GamePlayerAddons); enableFeature(Otc::GamePlayerStamina); enableFeature(Otc::GameNewFluids); enableFeature(Otc::GameMessageLevel); enableFeature(Otc::GamePlayerStateU16); - enableFeature(Otc::GameNewOutfitProtocol); // This might be 790 not 780 + enableFeature(Otc::GameNewOutfitProtocol); } if(version >= 790) { enableFeature(Otc::GameWritableDate); } - if(version >= 780 && version <= 854) { // 780 might not be accurate - enableFeature(Otc::GameChargeableItems); - } - if(version >= 840) { enableFeature(Otc::GameProtocolChecksum); enableFeature(Otc::GameAccountNames); @@ -1611,7 +1605,7 @@ void Game::setClientVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change client version while online"); - if(version != 0 && (version < 760 || version > 1041)) + if(version != 0 && (version < 740 || version > 1041)) stdext::throw_exception(stdext::format("Client version %d not supported", version)); m_clientVersion = version; diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index f59b3314..ce25348b 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -53,14 +53,12 @@ void ThingType::serialize(const FileStreamPtr& fin) continue; int attr = i; - if(g_game.getFeature(Otc::GameChargeableItems)) { + if(g_game.getProtocolVersion() >= 780) { if(attr == ThingAttrChargeable) attr = ThingAttrWritable; else if(attr >= ThingAttrWritable) attr += 1; - } - - if(g_game.getProtocolVersion() >= 1010) { + } else if(g_game.getProtocolVersion() >= 1010) { if(attr == ThingAttrNoMoveAnimation) attr = 16; else if(attr >= ThingAttrPickupable) @@ -140,16 +138,8 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS break; } - if(g_game.getFeature(Otc::GameChargeableItems)) { - if(attr == ThingAttrWritable) { - m_attribs.set(ThingAttrChargeable, true); - continue; - } else if(attr > ThingAttrWritable) - attr -= 1; - } - if(g_game.getProtocolVersion() >= 1010) { - /* In 10.10 all attributes from 16 and up were + /* In 10.10+ all attributes from 16 and up were * incremented by 1 to make space for 16 as * "No Movement Animation" flag. */ @@ -157,12 +147,58 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS attr = ThingAttrNoMoveAnimation; else if(attr > 16) attr -= 1; + } else if(g_game.getProtocolVersion() >= 780) { + /* In 7.80-8.54 all attributes from 8 and higher were + * incremented by 1 to make space for 8 as + * "Item Charges" flag. + */ + if(attr == 8) { + m_attribs.set(ThingAttrChargeable, true); + continue; + } else if(attr > 8) + attr -= 1; + } else if(g_game.getProtocolVersion() >= 755) { + /* In 7.55-7.72 attributes 23 is "Floor Change". */ + if(attr == 23) + attr = ThingAttrFloorChange; + } else if(g_game.getProtocolVersion() >= 740) { + /* 7.4-7.5 */ + if(attr > 0 && attr <= 15) + attr += 1; + else if(attr == 17) + attr = ThingAttrFloorChange; + else if(attr == 18) + attr += 12; + else if(attr == 19 || attr == 22) + attr += 6; + else if(attr == 16) + attr += 5; + else if(attr == 20) + attr += 4; + else if(attr == 24) + attr += 2; + else if(attr >= 25 && attr <= 27) + attr -= 8; + else if(attr == 23) + attr -= 3; + else if(attr == 28) + attr -= 1; + + if(attr == ThingAttrMultiUse) + attr = ThingAttrForceUse; + else if(attr == ThingAttrForceUse) + attr = ThingAttrMultiUse; } switch(attr) { case ThingAttrDisplacement: { - m_displacement.x = fin->getU16(); - m_displacement.y = fin->getU16(); + if(g_game.getProtocolVersion() >= 755) { + m_displacement.x = fin->getU16(); + m_displacement.y = fin->getU16(); + } else { + m_displacement.x = 8; + m_displacement.y = 8; + } m_attribs.set(attr, true); break; } @@ -220,7 +256,10 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS m_layers = fin->getU8(); m_numPatternX = fin->getU8(); m_numPatternY = fin->getU8(); - m_numPatternZ = fin->getU8(); + if(g_game.getProtocolVersion() >= 755) + m_numPatternZ = fin->getU8(); + else + m_numPatternZ = 1; m_animationPhases = fin->getU8(); int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * m_animationPhases; diff --git a/src/client/thingtype.h b/src/client/thingtype.h index 47761f20..446c9230 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -82,7 +82,8 @@ enum ThingAttr : uint8 { ThingAttrOpacity = 100, ThingAttrNotPreWalkable = 101, - ThingAttrNoMoveAnimation = 253, // real value is 16, but we need to do this for backwards compatibility + ThingAttrFloorChange = 252, + ThingAttrNoMoveAnimation = 253, // 10.10: real value is 16, but we need to do this for backwards compatibility ThingAttrChargeable = 254, // deprecated ThingLastAttr = 255 };