Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Feat: OTC and 12.x only compatibility (#1195)
Browse files Browse the repository at this point in the history
* Removing Old Clients Compatibility

- Now ahead we will only support protocol 12

WARNING: Test it before apply.

* Remove clients compability

* Feature/client compatibility (#2)

* Create LICENSE

* [OTC] minor compatibility adjusts

* [OTC compatibility]: minor protocol adjusts.

* [OTC compatibility]: make extra baseSkill cipClient only.

* [OTC compatibility]: add some TODO's to migrate msg from lua to cpp.

* [OTC compatibility]: add comments

* [OTC compatibility]: add client check for duplicated magicLevel (OTC wont receive).

* [OTC compatibility]: remove unecessary version check.

* [OTC compatibility]: clarifying some prey attributes.

* [otc compatibility]: add missing bless byte

* [OTC compatibility]: Embuiment, prey and balance fixes.

* [OTC compatibility]: fix exiva/tournament buttons issues.

* Fix bless bug

* [OTC compatibility]: fix infinity loop.

* [OTC compatibility]: reduce bless logic.

* [OTC compatibility]: minor init.lua and store adjustments.

* map-from-rar-to-zip

Co-authored-by: dudantas <[email protected]>
Co-authored-by: Lucas Grossi <[email protected]>
  • Loading branch information
3 people authored Jun 8, 2020
1 parent 81826f1 commit da6bddb
Show file tree
Hide file tree
Showing 26 changed files with 300 additions and 650 deletions.
7 changes: 3 additions & 4 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions data/actions/scripts/others/food.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 1 addition & 5 deletions data/actions/scripts/others/potions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 7 additions & 10 deletions data/creaturescripts/scripts/others/login.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function Player.sendTibiaTime(self, hours, minutes)
-- TODO: Migrate to protocolgame.cpp
local msg = NetworkMessage()
msg:addByte(0xEF)
msg:addByte(hours)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 10 additions & 14 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions data/lib/core/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions data/lib/core/quests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions data/modules/scripts/bestiary/bestiary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
52 changes: 23 additions & 29 deletions data/modules/scripts/blessings/blessings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,55 +80,49 @@ 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
if curBless == nil then
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)

Expand Down
32 changes: 14 additions & 18 deletions data/modules/scripts/daily_reward/daily_reward.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit da6bddb

Please sign in to comment.