7.4 .dat support, playing an actual server might not work yet

This commit is contained in:
Sam
2014-07-29 21:11:17 +02:00
parent c2ff89b2cf
commit 6b46370d1a
5 changed files with 75 additions and 38 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
};