diff --git a/config.lua.dist b/config.lua.dist index 26a475e19..b441df3c6 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -39,10 +39,9 @@ maxPacketsPerSecond = 25 maxItem = 2000 maxContainer = 100 --- Version Manual -clientVersionMin = 1100 -clientVersionMax = 1200 -clientVersionStr = "Only support outdated 10.00 and version 12.00" +--- Version +clientVersion = 1200 +clientVersionStr = "12.00" -- Depot Limit freeDepotLimit = 2000 diff --git a/data/actions/scripts/others/food.lua b/data/actions/scripts/others/food.lua index ca418c427..57341b960 100644 --- a/data/actions/scripts/others/food.lua +++ b/data/actions/scripts/others/food.lua @@ -132,11 +132,7 @@ function onUse(player, item, fromPosition, target, toPosition, isHotkey) player:feed(food[1] * 12) player:say(food[2], TALKTYPE_MONSTER_SAY) item:remove(1) - - local client = player:getClient() - if client.version > 1140 then - player:updateSupplyTracker(item) - end + player:updateSupplyTracker(item) return true end diff --git a/data/actions/scripts/others/potions.lua b/data/actions/scripts/others/potions.lua index 718f94444..736f6f308 100644 --- a/data/actions/scripts/others/potions.lua +++ b/data/actions/scripts/others/potions.lua @@ -257,11 +257,7 @@ function onUse(player, item, fromPosition, target, toPosition, isHotkey) return true end - local client = player:getClient() - if client.version > 1140 then - player:updateSupplyTracker(item) - end - + player:updateSupplyTracker(item) item:remove(1) return true end diff --git a/data/creaturescripts/scripts/others/login.lua b/data/creaturescripts/scripts/others/login.lua index 63dc5e7d1..a5de51eb2 100644 --- a/data/creaturescripts/scripts/others/login.lua +++ b/data/creaturescripts/scripts/others/login.lua @@ -1,4 +1,5 @@ function Player.sendTibiaTime(self, hours, minutes) + -- TODO: Migrate to protocolgame.cpp local msg = NetworkMessage() msg:addByte(0xEF) msg:addByte(hours) @@ -56,10 +57,8 @@ function onLogin(player) nextUseXpStamina[playerId] = 1 -- Prey Small Window - if player:getClient().version > 1110 then - for slot = CONST_PREY_SLOT_FIRST, CONST_PREY_SLOT_THIRD do - player:sendPreyData(slot) - end + for slot = CONST_PREY_SLOT_FIRST, CONST_PREY_SLOT_THIRD do + player:sendPreyData(slot) end -- New prey @@ -131,12 +130,10 @@ function onLogin(player) player:setStaminaXpBoost(staminaBonus) player:setBaseXpGain(baseExp) - if player:getClient().version > 1110 then - local worldTime = getWorldTime() - local hours = math.floor(worldTime / 60) - local minutes = worldTime % 60 - player:sendTibiaTime(hours, minutes) - end + local worldTime = getWorldTime() + local hours = math.floor(worldTime / 60) + local minutes = worldTime % 60 + player:sendTibiaTime(hours, minutes) if player:getStorageValue(Storage.isTraining) == 1 then --Reset exercise weapon storage player:setStorageValue(Storage.isTraining,0) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 07c638bca..de5f19591 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -323,15 +323,13 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, return false end - -- Loot Analyser apenas 11.x+ - if self:getClient().os == CLIENTOS_NEW_WINDOWS then - local t = Tile(fromCylinder:getPosition()) - local corpse = t:getTopDownItem() - if corpse then - local itemType = corpse:getType() - if itemType:isCorpse() and toPosition.x == CONTAINER_POSITION then - self:sendLootStats(item) - end + -- Loot Analyser + local t = Tile(fromCylinder:getPosition()) + local corpse = t:getTopDownItem() + if corpse then + local itemType = corpse:getType() + if itemType:isCorpse() and toPosition.x == CONTAINER_POSITION then + self:sendLootStats(item) end end @@ -611,7 +609,8 @@ function Player:onTradeRequest(target, item) end function Player:onTradeAccept(target, item, targetItem) - target:closeImbuementWindow(self) + self:closeImbuementWindow() + target:closeImbuementWindow() return true end @@ -755,10 +754,7 @@ function Player:onGainSkillTries(skill, tries) end function Player:onRemoveCount(item) - -- Apenas cliente 11.x - if self:getClient().os == CLIENTOS_NEW_WINDOWS then - self:sendWaste(item:getId()) - end + self:sendWaste(item:getId()) end function Player:onRequestQuestLog() diff --git a/data/lib/core/player.lua b/data/lib/core/player.lua index 075075e2b..a762fafd7 100644 --- a/data/lib/core/player.lua +++ b/data/lib/core/player.lua @@ -257,6 +257,7 @@ end -- Impact Analyser function Player.sendHealingImpact(self, healAmmount) + -- TODO: Migrate to protocolgame.cpp local msg = NetworkMessage() msg:addByte(0xCC) -- DEC: 204 msg:addByte(0) -- 0 = healing / 1 = damage (boolean) @@ -265,6 +266,7 @@ function Player.sendHealingImpact(self, healAmmount) end function Player.sendDamageImpact(self, damage) + -- TODO: Migrate to protocolgame.cpp local msg = NetworkMessage() msg:addByte(0xCC) -- DEC: 204 msg:addByte(1) -- 0 = healing / 1 = damage (boolean) diff --git a/data/lib/core/quests.lua b/data/lib/core/quests.lua index e5591163e..dca676a1d 100644 --- a/data/lib/core/quests.lua +++ b/data/lib/core/quests.lua @@ -5428,6 +5428,7 @@ function Player.sendQuestLog(self) end function Player.sendQuestLine(self, questId) + -- consider migrate to ProtocolGame.cpp local quest = Game.getQuest(questId) if quest then local missions = quest.missions @@ -5438,17 +5439,14 @@ function Player.sendQuestLine(self, questId) if missions then for missionId = 1, #missions do if self:missionIsStarted(questId, missionId) then - if (self:getClient().version >= 1120) then - msg:addU16(questId) - end + msg:addU16(questId) msg:addString(self:getMissionName(questId, missionId)) msg:addString(self:getMissionDescription(questId, missionId)) end end end - if (self:getClient().os == CLIENTOS_NEW_WINDOWS) then - self:sendQuestTracker() - end + + self:sendQuestTracker() msg:sendToPlayer(self) msg:delete() end diff --git a/data/modules/scripts/bestiary/bestiary.lua b/data/modules/scripts/bestiary/bestiary.lua index 61ef9553d..bcf1dd48c 100644 --- a/data/modules/scripts/bestiary/bestiary.lua +++ b/data/modules/scripts/bestiary/bestiary.lua @@ -597,9 +597,7 @@ function Player.getCharmFromTarget(self, target) end function Player.sendBestiaryEntryChanged(self, monsterID) - if self:getClient().version < 1200 then - return - end + -- TODO: Migrate to protocolgame.cpp local msg = NetworkMessage() msg:addByte(Bestiary.S_Packets.SendBestiaryTracker) msg:addU16(monsterID) diff --git a/data/modules/scripts/blessings/blessings.lua b/data/modules/scripts/blessings/blessings.lua index d24bb9fc6..68e4519a4 100644 --- a/data/modules/scripts/blessings/blessings.lua +++ b/data/modules/scripts/blessings/blessings.lua @@ -80,16 +80,12 @@ Blessings.S_Packet = { function onRecvbyte(player, msg, byte) if (byte == Blessings.C_Packet.OpenWindow) then - if (player:getClient().os ~= CLIENTOS_NEW_WINDOWS and player:getClient().os ~= CLIENTOS_FLASH) then - player:sendCancelMessage("Only work with Flash Client & 11.0") - return false - end - Blessings.sendBlessDialog(player) end end Blessings.sendBlessStatus = function(player, curBless) + -- why not using ProtocolGame::sendBlessStatus ? local msg = NetworkMessage() msg:addByte(Blessings.S_Packet.BlessStatus) callback = function(k) return true end @@ -97,38 +93,36 @@ Blessings.sendBlessStatus = function(player, curBless) curBless = player:getBlessings(callback) -- ex: {1, 2, 5, 7} end Blessings.DebugPrint(#curBless, "sendBlessStatus curBless") - if player:getClient().version >= 1120 then - local bitWiseCurrentBless = 0 - local blessCount = 0 - for i = 1, #curBless do - if curBless[i].losscount then - blessCount = blessCount + 1 - end - if (not curBless[i].losscount and Blessings.Config.HasToF) or curBless[i].losscount then - bitWiseCurrentBless = bit.bor(bitWiseCurrentBless, Blessings.BitWiseTable[curBless[i].id]) - end - end - if blessCount > 5 and Blessings.Config.InventoryGlowOnFiveBless then - bitWiseCurrentBless = bit.bor(bitWiseCurrentBless, 1) + local bitWiseCurrentBless = 0 + local blessCount = 0 + + for i = 1, #curBless do + if curBless[i].losscount then + blessCount = blessCount + 1 end - msg:addU16(bitWiseCurrentBless) - dlgBtnColour = 1 - if blessCount >= 7 then - dlgBtnColour = 3 - elseif blessCount > 0 then - dlgBtnColour = 2 + if (not curBless[i].losscount and Blessings.Config.HasToF) or curBless[i].losscount then + bitWiseCurrentBless = bit.bor(bitWiseCurrentBless, Blessings.BitWiseTable[curBless[i].id]) end - msg:addByte(dlgBtnColour) -- Bless dialog button colour 1 = Disabled | 2 = normal | 3 = green - elseif #curBless >= 5 then - msg:addU16(1) -- TODO ? - else - msg:addU16(0) end + if blessCount > 5 and Blessings.Config.InventoryGlowOnFiveBless then + bitWiseCurrentBless = bit.bor(bitWiseCurrentBless, 1) + end + + msg:addU16(bitWiseCurrentBless) + msg:addByte(blessCount >= 7 and 3 or (blessCount > 0 and 2 or 1)) -- Bless dialog button colour 1 = Disabled | 2 = normal | 3 = green + + -- if #curBless >= 5 then + -- msg:addU16(1) -- TODO ? + -- else + -- msg:addU16(0) + -- end + msg:sendToPlayer(player) end Blessings.sendBlessDialog = function(player) + -- TODO: Migrate to protocolgame.cpp local msg = NetworkMessage() msg:addByte(Blessings.S_Packet.BlessDialog) diff --git a/data/modules/scripts/daily_reward/daily_reward.lua b/data/modules/scripts/daily_reward/daily_reward.lua index 57236e7e2..3077ae79e 100644 --- a/data/modules/scripts/daily_reward/daily_reward.lua +++ b/data/modules/scripts/daily_reward/daily_reward.lua @@ -265,14 +265,10 @@ DailyReward.loadDailyReward = function(playerId, source) source = REWARD_FROM_PANEL end - if player:getClient().os == CLIENTOS_NEW_WINDOWS then - player:sendCollectionResource(player:getCollectionTokens()) - player:sendDailyReward() - player:sendOpenRewardWall(source) - player:sendDailyRewardCollectionState(false) - else - player:sendCancelMessage("The current client does not have support, download the latest version.") - end + player:sendCollectionResource(player:getCollectionTokens()) + player:sendDailyReward() + player:sendOpenRewardWall(source) + player:sendDailyRewardCollectionState(false) return true end @@ -405,6 +401,7 @@ function Player.sendOpenRewardWall(self, shrine) end function Player.sendCollectionResource(self, value) + -- TODO: Migrate to protocolgame.cpp local msg = NetworkMessage() msg:addByte(0xEE) -- resource byte msg:addByte(0x14) @@ -561,17 +558,16 @@ end function Player.sendRestingAreaState(self, zone, state) local msg = NetworkMessage() - if self:getClient().os == CLIENTOS_NEW_WINDOWS then - msg:addByte(ServerPackets.RestingAreaState) - msg:addByte(zone) -- [1 if protection zone, 0 if not] - msg:addByte(state) -- [inactive = 0, active = 1] - if state == 1 then - msg:addString("Within Resting Area") - else - msg:addString("Resting Area (no active bonus)") - end - msg:sendToPlayer(self) + + msg:addByte(ServerPackets.RestingAreaState) + msg:addByte(zone) -- [1 if protection zone, 0 if not] + msg:addByte(state) -- [inactive = 0, active = 1] + if state == 1 then + msg:addString("Within Resting Area") + else + msg:addString("Resting Area (no active bonus)") end + msg:sendToPlayer(self) end function Player.sendDailyRewardCollectionState(self, state) diff --git a/data/modules/scripts/gamestore/init.lua b/data/modules/scripts/gamestore/init.lua index eeae80037..641500d6a 100644 --- a/data/modules/scripts/gamestore/init.lua +++ b/data/modules/scripts/gamestore/init.lua @@ -16,16 +16,15 @@ GameStore.OfferTypes = { OFFER_TYPE_MOUNT = 5, OFFER_TYPE_NAMECHANGE = 6, OFFER_TYPE_SEXCHANGE = 7, - OFFER_TYPE_PROMOTION = 8, - OFFER_TYPE_HOUSE = 9, - OFFER_TYPE_EXPBOOST = 10, - OFFER_TYPE_PREYSLOT = 11, - OFFER_TYPE_PREYBONUS = 12, - OFFER_TYPE_TEMPLE = 13, - OFFER_TYPE_BLESSINGS = 14, - OFFER_TYPE_PREMIUM = 15, - OFFER_TYPE_POUCH = 16, - OFFER_TYPE_ALLBLESSINGS = 17 + OFFER_TYPE_HOUSE = 8, + OFFER_TYPE_EXPBOOST = 9, + OFFER_TYPE_PREYSLOT = 10, + OFFER_TYPE_PREYBONUS = 11, + OFFER_TYPE_TEMPLE = 12, + OFFER_TYPE_BLESSINGS = 13, + OFFER_TYPE_PREMIUM = 14, + OFFER_TYPE_POUCH = 15, + OFFER_TYPE_ALLBLESSINGS = 16 } GameStore.ClientOfferTypes = { @@ -65,6 +64,7 @@ GameStore.SendingPackets = { S_CoinBalance = 0xDF, -- 223 S_StoreError = 0xE0, -- 224 S_RequestPurchaseData = 0xE1, -- 225 + S_ShowDescription = 0xEA, S_CoinBalanceUpdating = 0xF2, -- 242 S_OpenStore = 0xFB, -- 251 S_StoreOffers = 0xFC, -- 252 @@ -157,9 +157,7 @@ function parseSendDescription(playerId, msg) if not player then return false end - if player:getClient().version < 1180 then - return false - end + local offerId = msg:getU32() if offerId then addPlayerEvent(sendShowDescription, 350, playerId, offerId) @@ -213,7 +211,7 @@ function sendShowDescription(playerId, offerId) end local offer = GameStore.getOfferById(offerId) local msg = NetworkMessage() - msg:addByte(0xea) + msg:addByte(GameStore.SendingPackets.S_ShowDescription) msg:addU32(offerId) msg:addString(offer.description or "No description to be displayed") msg:sendToPlayer(player) @@ -246,11 +244,7 @@ function parseRequestStoreOffers(playerId, msg) return false end - local serviceType = GameStore.ServiceTypes.SERVICE_STANDERD - if player:getClient().version >= 1092 then - serviceType = msg:getByte() - end - + local serviceType = msg:getByte() local categoryName = msg:getString() local category = GameStore.getCategoryByName(categoryName) @@ -309,7 +303,6 @@ function parseBuyStoreOffer(playerId, msg) elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PREYSLOT then GameStore.processPreySlotPurchase(player) elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PREYBONUS then GameStore.processPreyBonusReroll(player, offer.count) elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_TEMPLE then GameStore.processTempleTeleportPurchase(player) - elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PROMOTION then GameStore.processPromotionPurchase(player, offer.id) else -- This should never happen by our convention, but just in case the guarding condition is messed up... error({code = 0, message = "This offer is unavailable [2]"}) @@ -374,9 +367,6 @@ function openStore(playerId) end local msg = NetworkMessage() msg:addByte(GameStore.SendingPackets.S_OpenStore) - if player:getClient().version < 1180 then - msg:addByte(0x00) - end local GameStoreCategories, GameStoreCount = nil, 0 if (player:getVocation():getId() == VOCATION.ID.NONE) then @@ -389,13 +379,7 @@ function openStore(playerId) msg:addU16(GameStoreCount) for k, category in ipairs(GameStoreCategories) do msg:addString(category.name) - if player:getClient().version < 1180 then - msg:addString(category.description) - end - - if player:getClient().version >= 1093 then - msg:addByte(category.state or GameStore.States.STATE_NONE) - end + msg:addByte(category.state or GameStore.States.STATE_NONE) msg:addByte(#category.icons) for m, icon in ipairs(category.icons) do @@ -417,13 +401,14 @@ function sendShowDescription(playerId, offerId) end local offer = GameStore.getOfferById(offerId) local msg = NetworkMessage() - msg:addByte(0xea) + msg:addByte(GameStore.SendingPackets.S_ShowDescription) msg:addU32(offerId) msg:addString(offer.description or "No description to be displayed") msg:sendToPlayer(player) end function sendShowStoreOffers(playerId, category) + -- consider using protocolgame::sendStoreCategoryOffers local player = Player(playerId) if not player then return false @@ -434,14 +419,8 @@ function sendShowStoreOffers(playerId, category) msg:addByte(GameStore.SendingPackets.S_StoreOffers) msg:addString(category.name) - if player:getClient().version >= 1180 then - msg:addU32(0) - if player:getClient().version >= 1185 then - msg:addU32(0) - else - msg:addU16(0) - end - end + msg:addU32(0) + msg:addU32(0) msg:addU16(category.offers and #category.offers or 0x00) if category.offers then @@ -548,11 +527,6 @@ function sendShowStoreOffers(playerId, category) disabled = 1 disabledReason = "You already have this mount." end - elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PROMOTION then - if GameStore.canAddPromotionToPlayer(playerId, offer.id).ability == false then - disabled = 1 - disabledReason = "You can't get this promotion" - end elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PREYSLOT then local unlockedColumns = player:getStorageValue(STORE_SLOT_STORAGE) if (unlockedColumns == 1) then @@ -571,93 +545,46 @@ function sendShowStoreOffers(playerId, category) end end - if player:getClient().version >= 1180 then - msg:addString(name); - msg:addByte(0x01); - msg:addU32(offer.id and offer.id or 0xFFFF); - msg:addU16(1); - msg:addU32(offerPrice); + msg:addString(name); + msg:addByte(0x01); + msg:addU32(offer.id and offer.id or 0xFFFF); + msg:addU16(1); + msg:addU32(offerPrice); - msg:addByte(0x00); + msg:addByte(0x00); - msg:addByte(disabled) - if disabled == 1 and player:getClient().version >= 1093 then - msg:addByte(0x01); - msg:addString(disabledReason) - end - - if (offer.state) then - if (offer.state == GameStore.States.STATE_SALE) then - local daySub = offer.validUntil - os.date("*t").day - if (daySub >= 0) then - msg:addByte(offer.state) - msg:addU32(os.time() + daySub * 86400) - msg:addU32(offer.basePrice) - haveSaleOffer = 1 - else - msg:addByte(GameStore.States.STATE_NONE) - end - else - msg:addByte(offer.state) - end - else - msg:addByte(GameStore.States.STATE_NONE) - end - msg:addByte(0x00); - - msg:addString(offer.icons[1]) + msg:addByte(disabled) + if disabled == 1 then + msg:addByte(0x01); + msg:addString(disabledReason) + end - msg:addU16(0); - msg:addU16(0x01); - msg:addU16(0x0182); - msg:addU16(0); - msg:addU16(0); - msg:addByte(0x00); - else - msg:addU32(offer.id and offer.id or 0xFFFF) -- offerid - msg:addString(name) - msg:addString(offer.description or GameStore.getDefaultDescription(offer.type)) - msg:addU32(offerPrice) - - if (offer.state) then - if (offer.state == GameStore.States.STATE_SALE) then - local daySub = offer.validUntil - os.date("*t").day - if (daySub >= 0) then - msg:addByte(offer.state) - msg:addU32(os.time() + daySub * 86400) - msg:addU32(offer.basePrice) - haveSaleOffer = 1 - else - msg:addByte(GameStore.States.STATE_NONE) - end - else + if (offer.state) then + if (offer.state == GameStore.States.STATE_SALE) then + local daySub = offer.validUntil - os.date("*t").day + if (daySub >= 0) then msg:addByte(offer.state) - end - else - msg:addByte(GameStore.States.STATE_NONE) - end - - if table.contains({ CLIENTOS_OTCLIENT_LINUX, CLIENTOS_OTCLIENT_WINDOWS, CLIENTOS_OTCLIENT_MAC }, player:getClient().os) then - if disabled == 1 then - msg:addByte(0) -- offer type 0 means disabled + msg:addU32(os.time() + daySub * 86400) + msg:addU32(offer.basePrice) + haveSaleOffer = 1 else - msg:addByte(offer.type) + msg:addByte(GameStore.States.STATE_NONE) end else - -- supporting the old way - msg:addByte(disabled) - end - if disabled == 1 and player:getClient().version >= 1093 then - msg:addString(disabledReason) + msg:addByte(offer.state) end - - msg:addByte(#offer.icons) - for k, icon in ipairs(offer.icons) do - msg:addString(icon) - end - - msg:addU16(0) -- We still don't support SubOffers! + else + msg:addByte(GameStore.States.STATE_NONE) end + + msg:addByte(0x00); + msg:addString(offer.icons[1]) + msg:addU16(0); + msg:addU16(0x01); + msg:addU16(0x0182); + msg:addU16(0); + msg:addU16(0); + msg:addByte(0x00); end end @@ -689,9 +616,7 @@ function sendStoreTransactionHistory(playerId, page, entriesPerPage) msg:addU32(entry.time) msg:addByte(entry.mode) msg:addU32(entry.amount) - if player:getClient().version >= 1200 then - msg:addByte(0x0) -- 0 = transferable tibia coin, 1 = normal tibia coin - end + msg:addByte(0x0) -- 0 = transferable tibia coin, 1 = normal tibia coin msg:addString(entry.description) end @@ -739,7 +664,7 @@ function sendCoinBalanceUpdating(playerId, updating) local msg = NetworkMessage() msg:addByte(GameStore.SendingPackets.S_CoinBalanceUpdating) - msg:addByte(0x00) + msg:addByte(updating and 1 or 0) msg:sendToPlayer(player) if updating == true then @@ -754,9 +679,6 @@ function sendUpdateCoinBalance(playerId) end local msg = NetworkMessage() - msg:addByte(GameStore.SendingPackets.S_CoinBalanceUpdating) - msg:addByte(0x01) - msg:addByte(GameStore.SendingPackets.S_CoinBalance) msg:addByte(0x01) @@ -964,84 +886,6 @@ GameStore.canChangeToName = function(name) return result end -GameStore.canAddPromotionToPlayer = function(playerId, promotion, send) - local player = Player(playerId) - if not player then - return false - end - - local result = { - ability = true - } - local vocation = player:getVocation() - -- Working -- - local vocationCopy, baseVocation = vocation, vocation - vocation = vocation:getDemotion() - while vocation do - baseVocation = vocation - vocation = vocation:getDemotion() - end - - local baseVocationsCount = GameStore.BaseVocationsCount or 4 - - local newVocId = (baseVocationsCount * promotion) + baseVocation:getId() - - if not Vocation(newVocId) then - if send then - addPlayerEvent(sendStoreError, 350, playerId, GameStore.StoreErrors.STORE_ERROR_NETWORK, "The offer is fake, please report it!") - end - result.ability = false - return result - end - -- If promotion is less than player's voc, or player don't have previous promotion - if newVocId <= vocationCopy:getId() then - if send then - addPlayerEvent(sendStoreError, 350, playerId, GameStore.StoreErrors.STORE_ERROR_NETWORK, "You already have this promotion!") - end - result.ability = false - return result - end - - if (newVocId - baseVocationsCount) ~= vocationCopy:getId() then - if send then - addPlayerEvent(sendStoreError, 350, playerId, GameStore.StoreErrors.STORE_ERROR_NETWORK, "You need higher promotion to get his one.") - end - result.ability = false - return result - end - - result.vocId = newVocId - return result -end - -GameStore.addPromotionToPlayer = function(playerId, promotion) - local player = Player(playerId) - if not player then - return false - end - - local result = GameStore.canAddPromotionToPlayer(player, promotion, true) - if result.ability == false then return false end - - local basics = { - health = 185, - mana = 40, - cap = 500 - } - - player:setVocation(result.vocId) - local newVoc = player:getVocation() - player:setMaxHealth(basics.health + (newVoc:getHealthGain() * player:getLevel())) - player:setMaxMana(basics.mana + (newVoc:getManaGain() * player:getLevel())) - player:setCapacity(basics.cap + (newVoc:getCapacityGain() * player:getLevel())) - - player:addHealth(player:getMaxHealth()) - player:addMana(player:getMaxMana()) - - player:sendTextMessage(MESSAGE_INFO_DESCR, "You have been promoted to " .. newVoc:getName()) - return true -end - -- -- PURCHASE PROCESSOR FUNCTIONS -- Must throw an error when the purchase has not been made. The error must of @@ -1295,12 +1139,6 @@ function GameStore.processTempleTeleportPurchase(player) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been teleported to your hometown.') end -function GameStore.processPromotionPurchase(player, offerId) - if not GameStore.addPromotionToPlayer(player.id, offerId) then - return error({code = 0}) - end -end - --==Player==-- function Player.getCoinsBalance(self) resultId = db.storeQuery("SELECT `coins` FROM `accounts` WHERE `id` = " .. self:getAccountId()) diff --git a/data/modules/scripts/prey_system/prey.lua b/data/modules/scripts/prey_system/prey.lua index 091746fbc..d6e5ea46d 100644 --- a/data/modules/scripts/prey_system/prey.lua +++ b/data/modules/scripts/prey_system/prey.lua @@ -397,7 +397,7 @@ function Player.sendPreyData(self, slot) elseif slotState == Prey.StateTypes.SELECTION then msg:addByte(slot) - msg:addByte(3) + msg:addByte(slotState) local preyMonsterList = self:getPreyMonsterList(slot) if preyMonsterList == '' then @@ -454,27 +454,32 @@ function Player.sendPreyData(self, slot) -- Next free reroll msg:addU16(self:getMinutesUntilFreeReroll(slot)) + -- Feature unavailable (wildcards) + msg:addByte(0x00) - -- Client 11.9+ compat, feature unavailable. - if self:getClient().version >= 1190 then - msg:addByte(0x00) - end + -- send prey message + msg:sendToPlayer(self) + + -- close emb window + self:closeImbuementWindow() -- Send resources - msg:addByte(0xEC) self:sendResource("prey", self:getPreyBonusRerolls()) self:sendResource("bank", self:getBankBalance()) self:sendResource("inventory", self:getMoney()) - -- List reroll price + -- Send reroll price + self:sendPreyRerollPrice() + +end + +function Player:sendPreyRerollPrice() + local msg = NetworkMessage() + msg:addByte(Prey.S_Packets.PreyRerollPrice) msg:addU32(self:getRerollPrice()) - - -- Wildcard and Direct Selection price. - if self:getClient().version >= 1190 then - msg:addByte(0x01) - msg:addByte(0x05) - end + msg:addByte(0x01) -- wildcards + msg:addByte(0x05) -- select directly msg:sendToPlayer(self) end diff --git a/data/movements/scripts/quests/cults_of_tibia/ice_death.lua b/data/movements/scripts/quests/cults_of_tibia/ice_death.lua index ace8eb183..147008644 100644 --- a/data/movements/scripts/quests/cults_of_tibia/ice_death.lua +++ b/data/movements/scripts/quests/cults_of_tibia/ice_death.lua @@ -1,11 +1,10 @@ function Player.sendFakeDeathWindow(self) + -- consider migrating to ProtocolGame::sendDeath local msg = NetworkMessage(); msg:addByte(0x28); msg:addByte(0x01); msg:addByte(2); - if (self:getClient().os >= 1120) then - msg:addByte(0x00); -- Use death redemption - end + msg:addByte(0x00); -- Use death redemption msg:sendToPlayer(self, false); return true end diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 901d412cb..33a641ff3 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -129,8 +129,7 @@ bool ConfigManager::load() integer[MARKET_OFFER_DURATION] = getGlobalNumber(L, "marketOfferDuration", 30 * 24 * 60 * 60); - integer[VERSION_MIN] = getGlobalNumber(L, "clientVersionMin", CLIENT_VERSION_MIN); - integer[VERSION_MAX] = getGlobalNumber(L, "clientVersionMax", CLIENT_VERSION_MAX); + integer[VERSION] = getGlobalNumber(L, "clientVersion", CLIENT_VERSION); integer[FREE_DEPOT_LIMIT] = getGlobalNumber(L, "freeDepotLimit", 2000); integer[PREMIUM_DEPOT_LIMIT] = getGlobalNumber(L, "premiumDepotLimit", 8000); integer[DEPOT_BOXES] = getGlobalNumber(L, "depotBoxes", 19); diff --git a/src/configmanager.h b/src/configmanager.h index 25d459f0a..827a20bed 100644 --- a/src/configmanager.h +++ b/src/configmanager.h @@ -108,8 +108,7 @@ class ConfigManager MAX_CONTAINER, MAX_ITEM, MARKET_OFFER_DURATION, - VERSION_MIN, - VERSION_MAX, + VERSION, DEPOT_BOXES, FREE_DEPOT_LIMIT, PREMIUM_DEPOT_LIMIT, diff --git a/src/definitions.h b/src/definitions.h index 4daff970e..b507d5f1c 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -24,8 +24,7 @@ static constexpr auto STATUS_SERVER_NAME = "OTServBR - Global"; static constexpr auto STATUS_SERVER_VERSION = "TFS 1.3"; static constexpr auto STATUS_SERVER_DEVELOPERS = "OTServBR, Mark Samman and The Forgotten Server Developers"; -static constexpr auto CLIENT_VERSION_MIN = 1200; -static constexpr auto CLIENT_VERSION_MAX = 1200; +static constexpr auto CLIENT_VERSION = 1200; static constexpr auto CLIENT_VERSION_STR = "12.00"; static constexpr auto AUTHENTICATOR_DIGITS = 6U; diff --git a/src/enums.h b/src/enums.h index 042753ebe..12f853078 100644 --- a/src/enums.h +++ b/src/enums.h @@ -153,21 +153,14 @@ enum OperatingSystem_t : uint8_t { }; // New Prey -enum PreySlotNum_t : uint16_t +enum PreySlotNum_t : uint8_t { PREY_SLOTNUM_FIRST = 0, PREY_SLOTNUM_SECOND = 1, PREY_SLOTNUM_THIRD = 2, }; -enum PreySlotStatus_t : uint16_t -{ - PREY_SLOT_LOCKED = 0, - PREY_SLOT_UNLOCKED = 1, -}; - - -enum PreyState_t : uint16_t +enum PreyState_t : uint8_t { PREY_STATE_LOCKED = 0, PREY_STATE_INACTIVE = 1, @@ -680,4 +673,11 @@ enum MonstersEvent_t : uint8_t { MONSTERS_EVENT_SAY = 5, }; +enum Resource_t : uint8_t +{ + RESOURCE_BANK = 0x00, + RESOURCE_INVENTORY = 0x01, + RESOURCE_PREY = 0x0A, +}; + #endif diff --git a/src/game.cpp b/src/game.cpp index b68e43aee..001201e87 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1269,11 +1269,6 @@ ReturnValue Game::internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder, } if (Player* player = actor->getPlayer()) { - if (player->getProtocolVersion() < 1140 || player->operatingSystem != CLIENTOS_NEW_WINDOWS) { - player->updateLootTracker(item); - return ret; - } - const ItemType& it = Item::items[fromCylinder->getItem()->getID()]; if (it.id <= 0) { return ret; @@ -5082,18 +5077,6 @@ void Game::updatePlayerShield(Player* player) } } -void Game::updatePlayerHelpers(const Player& player) -{ - uint32_t creatureId = player.getID(); - uint16_t helpers = player.getHelpers(); - - SpectatorHashSet spectators; - map.getSpectators(spectators, player.getPosition(), true, true); - for (Creature* spectator : spectators) { - spectator->getPlayer()->sendCreatureHelpers(creatureId, helpers); - } -} - void Game::updateCreatureType(Creature* creature) { const Player* masterPlayer = nullptr; diff --git a/src/game.h b/src/game.h index e3d5830e4..7159feb89 100644 --- a/src/game.h +++ b/src/game.h @@ -437,7 +437,6 @@ class Game void changeLight(const Creature* creature); void updateCreatureSkull(const Creature* player); void updatePlayerShield(Player* player); - void updatePlayerHelpers(const Player& player); void updateCreatureType(Creature* creature); void updateCreatureWalkthrough(const Creature* creature); diff --git a/src/guild.cpp b/src/guild.cpp index 6430cf71a..cfde4472e 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -28,19 +28,11 @@ extern Game g_game; void Guild::addMember(Player* player) { membersOnline.push_back(player); - for (Player* member : membersOnline) { - g_game.updatePlayerHelpers(*member); - } } void Guild::removeMember(Player* player) { membersOnline.remove(player); - for (Player* member : membersOnline) { - g_game.updatePlayerHelpers(*member); - } - g_game.updatePlayerHelpers(*player); - if (membersOnline.empty()) { g_game.removeGuild(id); delete this; diff --git a/src/luascript.cpp b/src/luascript.cpp index fc6d32dd1..7bad6f700 100644 --- a/src/luascript.cpp +++ b/src/luascript.cpp @@ -2064,8 +2064,7 @@ void LuaScriptInterface::registerFunctions() registerEnumIn("configKeys", ConfigManager::EXP_FROM_PLAYERS_LEVEL_RANGE) registerEnumIn("configKeys", ConfigManager::MAX_PACKETS_PER_SECOND) registerEnumIn("configKeys", ConfigManager::STORE_COIN_PACKET) - registerEnumIn("configKeys", ConfigManager::VERSION_MIN) - registerEnumIn("configKeys", ConfigManager::VERSION_MAX) + registerEnumIn("configKeys", ConfigManager::VERSION) registerEnumIn("configKeys", ConfigManager::DAY_KILLS_TO_RED) registerEnumIn("configKeys", ConfigManager::WEEK_KILLS_TO_RED) registerEnumIn("configKeys", ConfigManager::MONTH_KILLS_TO_RED) @@ -4971,8 +4970,7 @@ int LuaScriptInterface::luaGameGetClientVersion(lua_State* L) { // Game.getClientVersion() lua_createtable(L, 0, 3); - setField(L, "min", CLIENT_VERSION_MIN); - setField(L, "max", CLIENT_VERSION_MAX); + setField(L, "version", CLIENT_VERSION); setField(L, "string", CLIENT_VERSION_STR); return 1; } diff --git a/src/party.cpp b/src/party.cpp index 3d5dd278e..c36d15e48 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -45,7 +45,6 @@ void Party::disband() currentLeader->setParty(nullptr); currentLeader->sendClosePrivate(CHANNEL_PARTY); g_game.updatePlayerShield(currentLeader); - g_game.updatePlayerHelpers(*currentLeader); currentLeader->sendCreatureSkull(currentLeader); currentLeader->sendTextMessage(MESSAGE_INFO_DESCR, "Your party has been disbanded."); @@ -70,7 +69,6 @@ void Party::disband() member->sendCreatureSkull(currentLeader); currentLeader->sendCreatureSkull(member); - g_game.updatePlayerHelpers(*member); } memberList.clear(); delete this; @@ -112,12 +110,10 @@ bool Party::leaveParty(Player* player) player->setParty(nullptr); player->sendClosePrivate(CHANNEL_PARTY); g_game.updatePlayerShield(player); - g_game.updatePlayerHelpers(*player); for (Player* member : memberList) { member->sendCreatureSkull(player); player->sendPlayerPartyIcons(member); - g_game.updatePlayerHelpers(*member); } leader->sendCreatureSkull(player); @@ -213,8 +209,6 @@ bool Party::joinParty(Player& player) memberList.push_back(&player); - g_game.updatePlayerHelpers(player); - player.removePartyInvitation(this); updateSharedExperience(); @@ -244,12 +238,6 @@ bool Party::removeInvite(Player& player, bool removeFromPlayer/* = true*/) if (empty()) { disband(); - } else { - for (Player* member : memberList) { - g_game.updatePlayerHelpers(*member); - } - - g_game.updatePlayerHelpers(*leader); } return true; @@ -287,11 +275,6 @@ bool Party::invitePlayer(Player& player) inviteList.push_back(&player); - for (Player* member : memberList) { - g_game.updatePlayerHelpers(*member); - } - g_game.updatePlayerHelpers(*leader); - leader->sendCreatureShield(&player); player.sendCreatureShield(leader); diff --git a/src/player.h b/src/player.h index 8d48c6f19..1b6913626 100644 --- a/src/player.h +++ b/src/player.h @@ -921,11 +921,6 @@ class Player final : public Creature, public Cylinder client->sendCreatureType(creature, creatureType); } } - void sendCreatureHelpers(uint32_t creatureId, uint16_t helpers) { - if (client) { - client->sendCreatureHelpers(creatureId, helpers); - } - } void sendSpellCooldown(uint8_t spellId, uint32_t time) { if (client) { client->sendSpellCooldown(spellId, time); @@ -1373,7 +1368,7 @@ class Player final : public Creature, public Cylinder bool updateKillTracker(Container* corpse, const std::string& playerName, const Outfit_t creatureOutfit) const { - if (client && getProtocolVersion() > 1140) { + if (client) { client->sendKillTrackerUpdate(corpse, playerName, creatureOutfit); return true; } @@ -1383,21 +1378,21 @@ class Player final : public Creature, public Cylinder void updateSupplyTracker(const Item* item) { - if (client && getProtocolVersion() > 1140) { + if (client) { client->sendUpdateSupplyTracker(item); } } void updateImpactTracker(int32_t quantity, bool isHeal) { - if (client && getProtocolVersion() > 1140) { + if (client) { client->sendUpdateImpactTracker(quantity, isHeal); } } void updateLootTracker(Item* item) { - if (client && getProtocolVersion() > 1140) { + if (client) { client->sendUpdateLootTracker(item); } } diff --git a/src/protocolgame.cpp b/src/protocolgame.cpp index c6653ecd0..6d2446fe4 100644 --- a/src/protocolgame.cpp +++ b/src/protocolgame.cpp @@ -258,14 +258,15 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg) } OperatingSystem_t operatingSystem = static_cast(msg.get()); - version = msg.get(); - if (version >= 1111) { + + if (operatingSystem <= CLIENTOS_NEW_WINDOWS) enableCompact(); - } + + version = msg.get(); clientVersion = msg.get(); - msg.skipBytes(3); // U32 client version, U8 client type, U16 dat revision + msg.skipBytes(3); // U16 dat revision, game preview state if (clientVersion >= 1149 && clientVersion < 1200) { // on 1149.6xxx, this was removed later. @@ -315,13 +316,6 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg) return; } - if (version < g_config.getNumber(ConfigManager::VERSION_MIN) || version > g_config.getNumber(ConfigManager::VERSION_MAX)) { - std::ostringstream ss; - ss << "Only clients with protocol " << g_config.getString(ConfigManager::VERSION_STR) << " allowed!"; - disconnectClient(ss.str()); - return; - } - if (g_game.getGameState() == GAME_STATE_STARTUP) { disconnectClient("Gameworld is starting up. Please wait."); return; @@ -529,10 +523,6 @@ void ProtocolGame::parsePacket(NetworkMessage& msg) void ProtocolGame::GetTileDescription(const Tile* tile, NetworkMessage& msg) { - if (version < 1200) { - msg.add(0x00); //environmental effects - } - int32_t count; Item* ground = tile->getGround(); if (ground) { @@ -1372,11 +1362,11 @@ void ProtocolGame::sendCreatureType(const Creature* creature, uint8_t creatureTy msg.add(creature->getID()); msg.addByte(creatureType); - if (player->getOperatingSystem() == CLIENTOS_WINDOWS && player->getProtocolVersion() >= 1120) { + if (player->getOperatingSystem() == CLIENTOS_WINDOWS) { msg.addByte(creatureType); // type or any byte idk } - if (creatureType == CREATURETYPE_SUMMONPLAYER && player->getProtocolVersion() >= 1120) { + if (creatureType == CREATURETYPE_SUMMONPLAYER) { const Creature* master = creature->getMaster(); if (master) { msg.add(master->getID()); @@ -1386,19 +1376,6 @@ void ProtocolGame::sendCreatureType(const Creature* creature, uint8_t creatureTy writeToOutputBuffer(msg); } -void ProtocolGame::sendCreatureHelpers(uint32_t creatureId, uint16_t helpers) -{ - if (version >= 1185) { - return; - } - - NetworkMessage msg; - msg.addByte(0x94); - msg.add(creatureId); - msg.add(helpers); - writeToOutputBuffer(msg); -} - void ProtocolGame::sendCreatureSquare(const Creature* creature, SquareColor_t color) { if (!canSee(creature)) { @@ -1425,8 +1402,7 @@ void ProtocolGame::sendAddMarker(const Position& pos, uint8_t markType, const st { NetworkMessage msg; msg.addByte(0xDD); - if (version >= 1200) - msg.addByte(0x00); // unknow + msg.addByte(0x00); // unknow msg.addPosition(pos); msg.addByte(markType); @@ -1440,9 +1416,7 @@ void ProtocolGame::sendReLoginWindow(uint8_t unfairFightReduction) msg.addByte(0x28); msg.addByte(0x00); msg.addByte(unfairFightReduction); - if (version >= 1120) { - msg.addByte(0x00); // use death redemption (boolean) - } + msg.addByte(0x00); // use death redemption (boolean) writeToOutputBuffer(msg); } @@ -1483,6 +1457,8 @@ void ProtocolGame::sendBasicData() void ProtocolGame::sendBlessStatus() { + if (!player) return; + NetworkMessage msg; //uint8_t maxClientBlessings = (player->operatingSystem == CLIENTOS_NEW_WINDOWS) ? 8 : 6; (compartability for the client 10) //Ignore ToF (bless 1) @@ -1500,17 +1476,9 @@ void ProtocolGame::sendBlessStatus() msg.addByte(0x9C); - if (player->getProtocolVersion() >= 1120) { - if (blessCount >= 5) //Show up the glowing effect in items if have all blesses - flag |= 1; - - msg.add(flag); - msg.addByte((blessCount >= 7) ? 3 : ((blessCount >= 5) ? 2 : 1)); // 1 = Disabled | 2 = normal | 3 = green - }else if (blessCount >= 5) { - msg.add(0x01); - } else { - msg.add(0x00); - } + msg.add((blessCount >= 5) ? (flag | 1) : flag); //Show up the glowing effect in items if have all blesses + msg.addByte((blessCount >= 7) ? 3 : ((blessCount >= 5) ? 2 : 1)); // 1 = Disabled | 2 = normal | 3 = green + // msg.add(0); writeToOutputBuffer(msg); } @@ -1541,35 +1509,43 @@ void ProtocolGame::sendPremiumTrigger() } // Send preyInfo -void ProtocolGame::sendPreyData() -{ +void ProtocolGame::closeImbuingWindow() { NetworkMessage msg; - for (int i = 0; i < 3; i++) { - msg.addByte(0xE8); - msg.addByte(i); + msg.addByte(0xEC); + writeToOutputBuffer(msg); +} - msg.addByte(0x00); - msg.addByte(0x00); - msg.add(0); - if (version >= 1190) { - msg.addByte(0x00); // wildCards - } +void ProtocolGame::initPreyData() +{ + for (uint8_t i = 0; i <= PREY_SLOTNUM_THIRD; i++) { + sendPreyData(static_cast(i), PREY_STATE_LOCKED); } - msg.addByte(0xEC); - msg.addByte(0xEE); - msg.addByte(0x0A); - msg.add(0); - msg.addByte(0xEE); - msg.addByte(0x01); - msg.add(0); - // prey prices - msg.addByte(0xE9); - msg.add(0); - if (version >= 1190) { - msg.addByte(0x00); // unknown price - msg.addByte(0x00); // selectCreatureDirectly price (5 in tibia) - } + sendResourcesBalance(); + sendPreyRerollPrice(); +} + +void ProtocolGame::sendPreyRerollPrice(uint32_t price /*= 0*/, uint8_t wildcard /*= 0*/, uint8_t directly /*= 0*/) +{ + NetworkMessage msg; + msg.addByte(0xE9); // reroll prices + msg.add(price); // price + msg.addByte(wildcard); // wildcard + msg.addByte(directly); // selectCreatureDirectly price (5 in tibia) + writeToOutputBuffer(msg); +} + +void ProtocolGame::sendPreyData(PreySlotNum_t slot, PreyState_t slotState) +{ + NetworkMessage msg; + msg.addByte(0xE8); + msg.addByte(slot); + + msg.addByte(slotState); + msg.addByte(0x00); // empty byte + msg.add(0); // next free roll + msg.addByte(0x00); // wildCards + writeToOutputBuffer(msg); } @@ -1691,12 +1667,7 @@ void ProtocolGame::sendIcons(uint16_t icons) { NetworkMessage msg; msg.addByte(0xA2); - if (version >= 1140) { // TODO: verify compatibility of the new icon range ( 16-31 ) - msg.add(icons); - } else { - msg.add(icons); - } - + msg.add(icons); writeToOutputBuffer(msg); } @@ -1804,23 +1775,25 @@ void ProtocolGame::sendGameNews() writeToOutputBuffer(msg); } -void ProtocolGame::sendResourceBalance(uint64_t money, uint64_t bank) +void ProtocolGame::sendResourcesBalance(uint64_t money /*= 0*/, uint64_t bank /*= 0*/, uint64_t prey /*= 0*/) +{ + sendResourceBalance(RESOURCE_BANK, bank); + sendResourceBalance(RESOURCE_INVENTORY, money); + sendResourceBalance(RESOURCE_PREY, prey); +} + +void ProtocolGame::sendResourceBalance(Resource_t resourceType, uint64_t value) { NetworkMessage msg; msg.addByte(0xEE); - msg.addByte(0x00); - msg.add(bank); - msg.addByte(0xEE); - msg.addByte(0x01); - msg.add(money); + msg.addByte(resourceType); + msg.add(value); writeToOutputBuffer(msg); } void ProtocolGame::sendSaleItemList(const std::list& shop) { - if (player->getProtocolVersion() >= 1100) { - sendResourceBalance(player->getMoney(), player->getBankBalance()); - } + sendResourcesBalance(player->getMoney(), player->getBankBalance()); NetworkMessage msg; msg.addByte(0x7B); @@ -1961,7 +1934,7 @@ void ProtocolGame::sendMarketEnter(uint32_t depotId) writeToOutputBuffer(msg); updateCoinBalance(); - sendResourceBalance(player->getMoney(), player->getBankBalance()); + sendResourcesBalance(player->getMoney(), player->getBankBalance()); } void ProtocolGame::sendCoinBalance() @@ -1970,10 +1943,16 @@ void ProtocolGame::sendCoinBalance() return; } + // send is updating + // TODO: export this to it own function NetworkMessage msg; msg.addByte(0xF2); msg.addByte(0x01); + writeToOutputBuffer(msg); + + msg.reset(); + // send update msg.addByte(0xDF); msg.addByte(0x01); @@ -1985,12 +1964,6 @@ void ProtocolGame::sendCoinBalance() void ProtocolGame::updateCoinBalance() { - NetworkMessage msg; - msg.addByte(0xF2); - msg.addByte(0x00); - - writeToOutputBuffer(msg); - g_dispatcher.addTask( createTask(std::bind([](ProtocolGame* client) { if (client && client->player) { @@ -2354,13 +2327,11 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId) msg.add(0x00); } - if (version > 1099) { - uint8_t slot = Item::items[itemId].imbuingSlots; - if(slot > 0) { - msg.addString(std::to_string(slot)); - } else { - msg.add(0x00); - } + uint8_t slot = Item::items[itemId].imbuingSlots; + if(slot > 0) { + msg.addString(std::to_string(slot)); + } else { + msg.add(0x00); } MarketStatistics* statistics = IOMarket::getInstance().getPurchaseStatistics(itemId); @@ -2608,8 +2579,7 @@ void ProtocolGame::sendMagicEffect(const Position& pos, uint8_t type) void ProtocolGame::sendCreatureHealth(const Creature* creature) { - if (player->getProtocolVersion() >= 1120 && creature->isHealthHidden()) { - // on newer clients, sending health 0 causes it to show the creature name with an empty healthbar + if (creature->isHealthHidden()) { return; } @@ -2787,13 +2757,8 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos msg.addString(g_config.getString(ConfigManager::STORE_IMAGES_URL)); msg.add(static_cast(g_config.getNumber(ConfigManager::STORE_COIN_PACKET))); - if (version >= 1150 || shouldAddExivaRestrictions) { - msg.addByte(0x00); // exiva button enabled - } - - if (version >= 1215) { - msg.addByte(0x01); // tournament button enabled - } + msg.addByte(shouldAddExivaRestrictions ? 0x01 : 0x00); // exiva button enabled + // msg.addByte(0x01); // tournament button enabled writeToOutputBuffer(msg); @@ -2817,9 +2782,7 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos sendPremiumTrigger(); sendStoreHighlight(); - if (version >= 1200) { - sendItemsPrice(); - } + sendItemsPrice(); //gameworld light-settings sendWorldLight(g_game.getWorldLightInfo()); @@ -2859,11 +2822,10 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos sendBasicData(); sendInventoryClientIds(); - sendPreyData(); - if (player->getProtocolVersion() >= 1130) { - player->sendClientCheck(); - player->sendGameNews(); - } + initPreyData(); + + player->sendClientCheck(); + player->sendGameNews(); player->sendIcons(); } @@ -3090,25 +3052,14 @@ void ProtocolGame::sendOutfitWindow() } protocolOutfits.emplace_back(outfit.name, outfit.lookType, addons); - if (protocolOutfits.size() == 150 && version < 1185) { // Game client doesn't allow more than 100 outfits - break; - } - } - - if (version >= 1185) { - msg.add(protocolOutfits.size()); - } else { - msg.addByte(protocolOutfits.size()); } + msg.add(protocolOutfits.size()); for (const ProtocolOutfit& outfit : protocolOutfits) { msg.add(outfit.lookType); msg.addString(outfit.name); msg.addByte(outfit.addons); - - if (version >= 1185) { - msg.addByte(0x00); - } + msg.addByte(0x00); } std::vector mounts; @@ -3118,26 +3069,16 @@ void ProtocolGame::sendOutfitWindow() } } - if (version >= 1185) { - msg.add(mounts.size()); - } else { - msg.addByte(mounts.size()); - } - + msg.add(mounts.size()); for (const Mount* mount : mounts) { msg.add(mount->clientId); msg.addString(mount->name); - - if (version >= 1185) { - msg.addByte(0x00); - } - } - - if (version >= 1185) { - msg.addByte(0x00); msg.addByte(0x00); } + msg.addByte(0x00); + msg.addByte(0x00); + writeToOutputBuffer(msg); } @@ -3160,11 +3101,7 @@ void ProtocolGame::sendVIP(uint32_t guid, const std::string& name, const std::st msg.add(std::min(10, icon)); msg.addByte(notify ? 0x01 : 0x00); msg.addByte(status); - if (version >= 1110) { - /* vipGroups: This is used for showing VipGroups by ids */ - msg.addByte(0x00); - } - + msg.addByte(0x00); // vipGroups writeToOutputBuffer(msg); } @@ -3172,9 +3109,7 @@ void ProtocolGame::sendSpellCooldown(uint8_t spellId, uint32_t time) { NetworkMessage msg; msg.addByte(0xA4); - if (player->getProtocolVersion() < 1120 && spellId >= 170) { - spellId = 150; - } + msg.addByte(spellId); msg.add(time); writeToOutputBuffer(msg); @@ -3373,6 +3308,7 @@ void ProtocolGame::sendStoreTrasactionHistory(HistoryStoreOfferList &list, uint3 msg.add(offer.time); msg.addByte(offer.mode); msg.add(offer.amount); //FIXME: investigate why it doesn't send the price properly + msg.addByte(0x00); // 0 = transferable tibia coin, 1 = normal tibia coin msg.addString(offer.description); } @@ -3421,22 +3357,22 @@ void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bo msg.add(0x61); msg.add(remove); msg.add(creature->getID()); - if (player->getProtocolVersion() >= 1120 && creature->isHealthHidden()) { + if (creature->isHealthHidden()) { msg.addByte(CREATURETYPE_HIDDEN); } else { msg.addByte(creatureType); } - if (player->getProtocolVersion() >= 1120) { - if (creatureType == CREATURETYPE_SUMMONPLAYER) { - const Creature* master = creature->getMaster(); - if (master) { - msg.add(master->getID()); - } + if (creatureType == CREATURETYPE_SUMMONPLAYER) { + const Creature* master = creature->getMaster(); + if (master) { + msg.add(master->getID()); + } else { + msg.add(0x00); } } - if (player->getProtocolVersion() >= 1120 && creature->isHealthHidden()) { + if (creature->isHealthHidden()) { msg.addString(""); } else { msg.addString(creature->getName()); @@ -3471,47 +3407,34 @@ void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bo msg.addByte(player->getGuildEmblem(otherPlayer)); } - if (player->getProtocolVersion() >= 1120) { - if (creatureType == CREATURETYPE_MONSTER) { - const Creature* master = creature->getMaster(); - if (master) { - const Player* masterPlayer = master->getPlayer(); - if (masterPlayer) { - creatureType = CREATURETYPE_SUMMONPLAYER; - } + if (creatureType == CREATURETYPE_MONSTER) { + const Creature* master = creature->getMaster(); + if (master) { + const Player* masterPlayer = master->getPlayer(); + if (masterPlayer) { + creatureType = CREATURETYPE_SUMMONPLAYER; } } } - if (player->getProtocolVersion() >= 1120 && creature->isHealthHidden()) { + if (creature->isHealthHidden()) { msg.addByte(CREATURETYPE_HIDDEN); } else { msg.addByte(creatureType); // Type (for summons) } - if (player->getProtocolVersion() >= 1120) { - if (creatureType == CREATURETYPE_SUMMONPLAYER) { - const Creature* master = creature->getMaster(); - if (master) { - msg.add(master->getID()); - } + if (creatureType == CREATURETYPE_SUMMONPLAYER) { + const Creature* master = creature->getMaster(); + if (master) { + msg.add(master->getID()); + } else { + msg.add(0x00); } } msg.addByte(creature->getSpeechBubble()); msg.addByte(0xFF); // MARK_UNMARKED - if (version >= 1110) { - msg.addByte(0x00); // inspection type - } - - if (version < 1185) { - if (otherPlayer) { - msg.add(otherPlayer->getHelpers()); - } else { - msg.add(0x00); - } - } - + msg.addByte(0x00); // inspection type msg.addByte(player->canWalkthroughEx(creature) ? 0x00 : 0x01); } @@ -3523,9 +3446,6 @@ void ProtocolGame::AddPlayerStats(NetworkMessage& msg) msg.add(std::min(player->getMaxHealth(), std::numeric_limits::max())); msg.add(player->getFreeCapacity()); - if (version < 1150) { - msg.add(player->getCapacity()); - } msg.add(player->getExperience()); @@ -3533,9 +3453,6 @@ void ProtocolGame::AddPlayerStats(NetworkMessage& msg) msg.addByte(player->getLevelPercent()); msg.add(player->getBaseXpGain()); // base xp gain rate - if (version < 1150) { - msg.add(player->getVoucherXpBoost()); // xp voucher - } msg.add(player->getGrindingXpBoost()); // low level bonus msg.add(player->getStoreXpBoost()); // xp boost msg.add(player->getStaminaXpBoost()); // stamina multiplier (100 = 1.0x) @@ -3543,12 +3460,6 @@ void ProtocolGame::AddPlayerStats(NetworkMessage& msg) msg.add(std::min(player->getMana(), std::numeric_limits::max())); msg.add(std::min(player->getMaxMana(), std::numeric_limits::max())); - if (version < 1200) { - msg.addByte(std::min(player->getMagicLevel(), std::numeric_limits::max())); - msg.addByte(std::min(player->getBaseMagicLevel(), std::numeric_limits::max())); - msg.addByte(player->getMagicLevelPercent()); - } - msg.addByte(player->getSoul()); msg.add(player->getStaminaMinutes()); @@ -3568,22 +3479,24 @@ void ProtocolGame::AddPlayerSkills(NetworkMessage& msg) { msg.addByte(0xA1); - if (version >= 1200) { - msg.add(player->getMagicLevel()); - msg.add(player->getBaseMagicLevel()); + msg.add(player->getMagicLevel()); + + if (player->getOperatingSystem() <= CLIENTOS_NEW_WINDOWS) { msg.add(player->getBaseMagicLevel()); - msg.add(player->getMagicLevelPercent() * 100); } + msg.add(player->getBaseMagicLevel()); + msg.add(player->getMagicLevelPercent() * 100); + for (uint8_t i = SKILL_FIRST; i <= SKILL_FISHING; ++i) { msg.add(std::min(player->getSkillLevel(i), std::numeric_limits::max())); msg.add(player->getBaseSkill(i)); - if (version >= 1200) { + + if (player->getOperatingSystem() <= CLIENTOS_NEW_WINDOWS) { msg.add(player->getBaseSkill(i)); - msg.add(player->getSkillPercent(i) * 100); - } else { - msg.addByte(player->getSkillPercent(i)); } + + msg.add(player->getSkillPercent(i) * 100); } for (uint8_t i = SKILL_CRITICAL_HIT_CHANCE; i <= SKILL_LAST; ++i) { @@ -3591,10 +3504,9 @@ void ProtocolGame::AddPlayerSkills(NetworkMessage& msg) msg.add(player->getBaseSkill(i)); } - if (version >= 1150) { // used for imbuement (Feather) - msg.add(player->getCapacity()); // total capacity - msg.add(player->getCapacity()); // base total capacity - } + // used for imbuement (Feather) + msg.add(player->getCapacity()); // total capacity + msg.add(player->getCapacity()); // base total capacity } void ProtocolGame::AddOutfit(NetworkMessage& msg, const Outfit_t& outfit) @@ -3704,9 +3616,7 @@ void ProtocolGame::sendImbuementWindow(Item* item) msg.add(itm.second); } - if (player->getProtocolVersion() >= 1100) { - sendResourceBalance(player->getMoney(), player->getBankBalance()); - } + sendResourcesBalance(player->getMoney(), player->getBankBalance()); writeToOutputBuffer(msg); } @@ -3717,15 +3627,11 @@ void ProtocolGame::AddItem(NetworkMessage& msg, uint16_t id, uint8_t count) msg.add(it.clientId); - if (version < 1200) { - msg.addByte(0xFF); // MARK_UNMARKED - } - if (it.stackable) { msg.addByte(count); } else if (it.isSplash() || it.isFluidContainer()) { msg.addByte(fluidMap[count & 7]); - } else if (version >= 1150 && it.isContainer()) { + } else if (it.isContainer() && player->getOperatingSystem() <= CLIENTOS_NEW_WINDOWS) { msg.addByte(0x00); } @@ -3740,21 +3646,16 @@ void ProtocolGame::AddItem(NetworkMessage& msg, const Item* item) msg.add(it.clientId); - if (version < 1200) { - msg.addByte(0xFF); // MARK_UNMARKED - } - if (it.stackable) { msg.addByte(std::min(0xFF, item->getItemCount())); } else if (it.isSplash() || it.isFluidContainer()) { msg.addByte(fluidMap[item->getFluidType() & 7]); - } else if (version >= 1150 && it.isContainer()) { + } else if (it.isContainer() && player->getOperatingSystem() <= CLIENTOS_NEW_WINDOWS) { uint32_t quickLootFlags = item->getQuickLootFlags(); if (quickLootFlags > 0) { msg.addByte(2); msg.add(quickLootFlags); - } - else { + } else { msg.addByte(0x00); } } @@ -3819,11 +3720,11 @@ void ProtocolGame::sendKillTrackerUpdate(Container* corpse, const std::string& n void ProtocolGame::sendUpdateSupplyTracker(const Item* item) { - if (!player || !item || getVersion() < 1140) { + if (!player || !item) { return; } - NetworkMessage msg; + NetworkMessage msg; msg.addByte(0xCE); msg.add(item->getClientID()); @@ -3832,7 +3733,7 @@ void ProtocolGame::sendUpdateSupplyTracker(const Item* item) void ProtocolGame::sendUpdateImpactTracker(int32_t quantity, bool isHeal) { - if (!player || getVersion() < 1140) { + if (!player) { return; } @@ -3846,12 +3747,12 @@ void ProtocolGame::sendUpdateImpactTracker(int32_t quantity, bool isHeal) void ProtocolGame::sendUpdateLootTracker(Item* item) { - if (!player || getVersion() < 1140) { + if (!player) { return; } - NetworkMessage msg; - msg.addByte(0xCF); + NetworkMessage msg; + msg.addByte(0xCF); AddItem(msg, item); msg.addString(item->getName()); item->setIsLootTrackeable(false); diff --git a/src/protocolgame.h b/src/protocolgame.h index 62df5572e..5915be87b 100644 --- a/src/protocolgame.h +++ b/src/protocolgame.h @@ -210,7 +210,10 @@ class ProtocolGame final : public Protocol void sendUnjustifiedPoints(const uint8_t& dayProgress, const uint8_t& dayLeft, const uint8_t& weekProgress, const uint8_t& weekLeft, const uint8_t& monthProgress, const uint8_t& monthLeft, const uint8_t& skullDuration); // Send preyInfo - void sendPreyData(); + void closeImbuingWindow(); + void initPreyData(); + void sendPreyRerollPrice(uint32_t price = 0, uint8_t wildcard = 0,uint8_t directly = 0); + void sendPreyData(PreySlotNum_t slot, PreyState_t slotState); void sendCancelWalk(); void sendChangeSpeed(const Creature* creature, uint32_t speed); @@ -229,13 +232,13 @@ class ProtocolGame final : public Protocol void sendCreatureShield(const Creature* creature); void sendCreatureSkull(const Creature* creature); void sendCreatureType(const Creature* creature, uint8_t creatureType); - void sendCreatureHelpers(uint32_t creatureId, uint16_t helpers); void sendShop(Npc* npc, const ShopInfoList& itemList); void sendCloseShop(); void sendClientCheck(); void sendGameNews(); - void sendResourceBalance(uint64_t money, uint64_t bank); + void sendResourcesBalance(uint64_t money = 0, uint64_t bank = 0, uint64_t prey = 0); + void sendResourceBalance(Resource_t resourceType, uint64_t value); void sendSaleItemList(const std::list& shop); void sendMarketEnter(uint32_t depotId); void updateCoinBalance(); @@ -366,7 +369,7 @@ class ProtocolGame final : public Protocol uint32_t eventConnect = 0; uint32_t challengeTimestamp = 0; - uint16_t version = CLIENT_VERSION_MIN; + uint16_t version = CLIENT_VERSION; uint32_t clientVersion = 0; uint8_t challengeRandom = 0; diff --git a/src/protocollogin.cpp b/src/protocollogin.cpp index 8674d142e..8770df535 100644 --- a/src/protocollogin.cpp +++ b/src/protocollogin.cpp @@ -129,29 +129,21 @@ void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg) return; } - msg.skipBytes(2); // client OS - // OperatingSystem_t operatingSystem = static_cast(msg.get()); + OperatingSystem_t operatingSystem = static_cast(msg.get()); - uint16_t version = msg.get(); - if (version >= 1111) { + if (operatingSystem <= CLIENTOS_NEW_WINDOWS) enableCompact(); - } + + uint16_t version = msg.get(); msg.skipBytes(17); /* * Skipped bytes: - * 4 bytes: protocolVersion + * 4 bytes: client version * 12 bytes: dat, spr, pic signatures (4 bytes each) * 1 byte: 0 */ - if (version <= 760) { - std::ostringstream ss; - ss << "Only clients with protocol " << g_config.getString(ConfigManager::VERSION_STR) << " allowed!"; - disconnectClient(ss.str(), version); - return; - } - if (!Protocol::RSA_decrypt(msg)) { std::cout << "[ProtocolLogin::onRecvFirstMessage] RSA Decrypt Failed" << std::endl; disconnect(); @@ -166,13 +158,6 @@ void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg) enableXTEAEncryption(); setXTEAKey(std::move(key)); - if (version < g_config.getNumber(ConfigManager::VERSION_MIN) || version > g_config.getNumber(ConfigManager::VERSION_MAX)) { - std::ostringstream ss; - ss << "Only clients with protocol " << g_config.getString(ConfigManager::VERSION_STR) << " allowed!"; - disconnectClient(ss.str(), version); - return; - } - if (g_game.getGameState() == GAME_STATE_STARTUP) { disconnectClient("Gameworld is starting up. Please wait.", version); return;