Skip to content

Commit

Permalink
Merge branch 'main' into dudantas/fix-relogin-with-different-protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Nov 22, 2023
2 parents c12c8bf + 8e2f213 commit 07fff10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 11 additions & 3 deletions data-otservbr-global/npc/hireling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function createHirelingType(HirelingName)
end

local npcConfig = {}
local enableBankSystem = {}

npcConfig.name = HirelingName
npcConfig.description = HirelingName
Expand Down Expand Up @@ -355,6 +356,7 @@ function createHirelingType(HirelingName)
end

npcType.onDisappear = function(npc, creature)
enableBankSystem[creature:getId()] = nil
npcHandler:onDisappear(npc, creature)
end

Expand All @@ -363,6 +365,7 @@ function createHirelingType(HirelingName)
end

npcType.onCloseChannel = function(npc, creature)
enableBankSystem[creature:getId()] = nil
npcHandler:onCloseChannel(npc, creature)
end

Expand Down Expand Up @@ -586,7 +589,9 @@ function createHirelingType(HirelingName)
elseif MsgContains(message, "stash") then
if hireling:hasSkill(HIRELING_SKILLS.STEWARD) then
npcHandler:say(GREETINGS.STASH, npc, creature)
player:setSpecialContainersAvailable(true)
player:openStash(true)
player:sendTextMessage(MESSAGE_FAILURE, "Your supply stash contains " .. player:getStashCount() .. " item" .. (player:getStashCount() > 1 and "s." or "."))
else
sendSkillNotLearned(npc, creature, HIRELING_SKILLS.STEWARD)
end
Expand Down Expand Up @@ -614,15 +619,18 @@ function createHirelingType(HirelingName)
npcHandler:setTopic(playerId, TOPIC.SERVICES)
npcHandler:say("Alright then, I will be here.", npc, creature)
end
elseif npcHandler:getTopic(playerId) >= TOPIC.BANK and npcHandler:getTopic(playerId) < TOPIC.FOOD then
elseif npcHandler:getTopic(playerId) == TOPIC.BANK then
enableBankSystem[playerId] = true
elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then
handleFoodActions(npc, creature, message)
end
if enableBankSystem[playerId] then
-- Parse bank
npc:parseBank(message, npc, creature, npcHandler)
-- Parse guild bank
npc:parseGuildBank(message, npc, creature, playerId, npcHandler)
-- Normal messages
npc:parseBankMessages(message, npc, creature, npcHandler)
elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then
handleFoodActions(npc, creature, message)
end
return true
end
Expand Down
2 changes: 2 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4214,6 +4214,8 @@ void Game::playerStashWithdraw(uint32_t playerId, uint16_t itemId, uint32_t coun
if (player->isDepotSearchOpenOnItem(itemId)) {
player->requestDepotSearchItem(itemId, 0);
}

player->sendOpenStash(true);
}

void Game::playerSeekInContainer(uint32_t playerId, uint8_t containerId, uint16_t index, uint8_t containerCategory) {
Expand Down
5 changes: 4 additions & 1 deletion src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6906,7 +6906,10 @@ void ProtocolGame::sendPreyData(const std::unique_ptr<PreySlot> &slot) {
}

if (oldProtocol) {
msg.add<uint16_t>(static_cast<uint16_t>(std::max<uint32_t>(std::max<uint32_t>(static_cast<uint32_t>(((slot->freeRerollTimeStamp - OTSYS_TIME()) / 1000)), 0), 0)));
auto currentTime = OTSYS_TIME();
auto timeDiffMs = (slot->freeRerollTimeStamp > currentTime) ? (slot->freeRerollTimeStamp - currentTime) : 0;
auto timeDiffMinutes = timeDiffMs / 60000;
msg.add<uint16_t>(timeDiffMinutes ? timeDiffMinutes : 0);
} else {
msg.add<uint32_t>(std::max<uint32_t>(static_cast<uint32_t>(((slot->freeRerollTimeStamp - OTSYS_TIME()) / 1000)), 0));
msg.addByte(static_cast<uint8_t>(slot->option));
Expand Down

0 comments on commit 07fff10

Please sign in to comment.