Skip to content

Commit

Permalink
Merge branch 'main' into bug-cyclopedia-resistance-values
Browse files Browse the repository at this point in the history
  • Loading branch information
ElimarCosta authored Jan 28, 2023
2 parents 83ed72f + 9f85261 commit 4ad1f60
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 19 deletions.
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ deathLosePercent = -1

-- Houses
-- NOTE: set housePriceEachSQM to -1 to disable the ingame buy house functionality
-- NOTE: set houseBuyLevel to 0 to disable the min level purchase functionality.
-- Periods: daily/weekly/monthly/yearly/never
housePriceEachSQM = 1000
houseRentPeriod = "never"
houseOwnedByAccount = false
houseBuyLevel = 100

-- Item Usage
timeBetweenActions = 200
Expand Down
2 changes: 1 addition & 1 deletion data-canary/scripts/actions/door/custom_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end
local customDoor = Action()

function customDoor.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if Creature.isInsideDoor(player, toPosition) then
if Creature.checkCreatureInsideDoor(player, toPosition) then
return true
end

Expand Down
2 changes: 1 addition & 1 deletion data-canary/scripts/actions/door/key_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function keyDoor.onUse(player, item, fromPosition, target, toPosition, isHotkey)
end
for index, value in ipairs(KeyDoorTable) do
if value.openDoor == item.itemid then
if Creature.isInsideDoor(player, toPosition) then
if Creature.checkCreatureInsideDoor(player, toPosition) then
return false
end
item:transform(value.closedDoor)
Expand Down
2 changes: 1 addition & 1 deletion data-canary/scripts/actions/door/level_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function levelDoor.onUse(player, item, fromPosition, target, toPosition, isHotke
end
end

if Creature.isInsideDoor(player, toPosition) then
if Creature.checkCreatureInsideDoor(player, toPosition) then
return true
end
return true
Expand Down
2 changes: 1 addition & 1 deletion data-canary/scripts/actions/door/quest_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function questDoor.onUse(player, item, fromPosition, target, toPosition, isHotke
end
end

if Creature.isInsideDoor(player, toPosition) then
if Creature.checkCreatureInsideDoor(player, toPosition) then
return true
end
return true
Expand Down
6 changes: 6 additions & 0 deletions data-canary/scripts/talkactions/player/buy_house.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ function buyHouse.onSay(player, words, param)
return false
end

local houseBuyLevel = configManager.getNumber(configKeys.HOUSE_BUY_LEVEL)
if (houseBuyLevel ~= nil and player:getLevel() < houseBuyLevel) then
player:sendCancelMessage("You need to be level " .. houseBuyLevel .. " to buy a house.")
return false;
end

local position = player:getPosition()
position:getNextPosition(player:getDirection())

Expand Down
11 changes: 9 additions & 2 deletions data-canary/scripts/talkactions/player/server_info.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
local serverInfo = TalkAction("!serverinfo")

function serverInfo.onSay(player, words, param)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Server Info:"
local text = "Server Info:"
.. "\nExp rate: " .. getRateFromTable(experienceStages, player:getLevel(), configManager.getNumber(configKeys.RATE_EXPERIENCE))
.. "\nSkill rate: " .. configManager.getNumber(configKeys.RATE_SKILL)
.. "\nMagic rate: " .. configManager.getNumber(configKeys.RATE_MAGIC)
.. "\nLoot rate: " .. configManager.getNumber(configKeys.RATE_LOOT))
.. "\nLoot rate: " .. configManager.getNumber(configKeys.RATE_LOOT)

local houseBuyLevel = configManager.getNumber(configKeys.HOUSE_BUY_LEVEL)
if (houseBuyLevel ~= nil and player:getLevel() < houseBuyLevel) then
text = text .. '\nLevel to buy house: ' .. houseBuyLevel
end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
return false
end

Expand Down
6 changes: 6 additions & 0 deletions data-otservbr-global/scripts/talkactions/player/buy_house.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ function buyHouse.onSay(player, words, param)
return false
end

local houseBuyLevel = configManager.getNumber(configKeys.HOUSE_BUY_LEVEL)
if (houseBuyLevel ~= nil and player:getLevel() < houseBuyLevel) then
player:sendCancelMessage("You need to be level " .. houseBuyLevel .. " to buy a house.")
return false;
end

local position = player:getPosition()
position:getNextPosition(player:getDirection())

Expand Down
13 changes: 10 additions & 3 deletions data-otservbr-global/scripts/talkactions/player/server_info.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local serverInfo = TalkAction("!serverinfo")

function serverInfo.onSay(player, words, param)
local configRateSkill = configManager.getNumber(configKeys.RATE_SKILL)
local configRateSkill = configManager.getNumber(configKeys.RATE_SKILL)
local baseRate = player:getFinalBaseRateExperience()
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Server Info:"
local text = "Server Info:"
.. "\nExp rate: " .. baseRate
.. "\nSword Skill rate: " .. getRateFromTable(skillsStages, player:getSkillLevel(SKILL_SWORD), configRateSkill)
.. "\nClub Skill rate: " .. getRateFromTable(skillsStages, player:getSkillLevel(SKILL_CLUB), configRateSkill)
Expand All @@ -12,7 +12,14 @@ function serverInfo.onSay(player, words, param)
.. "\nShield Skill rate: " .. getRateFromTable(skillsStages, player:getSkillLevel(SKILL_SHIELD), configRateSkill)
.. "\nFist Skill rate: " .. getRateFromTable(skillsStages, player:getSkillLevel(SKILL_FIST), configRateSkill)
.. "\nMagic rate: " .. getRateFromTable(magicLevelStages, player:getBaseMagicLevel(), configManager.getNumber(configKeys.RATE_MAGIC))
.. "\nLoot rate: " .. configManager.getNumber(configKeys.RATE_LOOT))
.. "\nLoot rate: " .. configManager.getNumber(configKeys.RATE_LOOT)

local houseBuyLevel = configManager.getNumber(configKeys.HOUSE_BUY_LEVEL)
if (houseBuyLevel ~= nil and player:getLevel() < houseBuyLevel) then
text = text .. '\nLevel to buy house: ' .. houseBuyLevel
end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
return false
end

Expand Down
1 change: 1 addition & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ enum integerConfig_t {
RATE_MAGIC,
RATE_SPAWN,
HOUSE_PRICE,
HOUSE_BUY_LEVEL,
MAX_MESSAGEBUFFER,
ACTIONS_DELAY_INTERVAL,
EX_ACTIONS_DELAY_INTERVAL,
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ bool ConfigManager::load()
integer[RATE_MAGIC] = getGlobalNumber(L, "rateMagic", 1);
integer[RATE_SPAWN] = getGlobalNumber(L, "rateSpawn", 1);
integer[HOUSE_PRICE] = getGlobalNumber(L, "housePriceEachSQM", 1000);
integer[HOUSE_BUY_LEVEL] = getGlobalNumber(L, "houseBuyLevel", 0);
integer[ACTIONS_DELAY_INTERVAL] = getGlobalNumber(L, "timeBetweenActions", 200);
integer[EX_ACTIONS_DELAY_INTERVAL] = getGlobalNumber(L, "timeBetweenExActions", 1000);
integer[MAX_MESSAGEBUFFER] = getGlobalNumber(L, "maxMessageBuffer", 4);
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/grouping/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ bool Party::passPartyLeadership(Player* player)
memberList.insert(memberList.begin(), oldLeader);

updateSharedExperience();
updateTrackerAnalyzer();

for (Player* member : memberList) {
member->sendPartyCreatureShield(oldLeader);
Expand Down
1 change: 1 addition & 0 deletions src/lua/functions/core/game/config_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void ConfigFunctions::init(lua_State* L) {
registerEnumIn(L, "configKeys", RATE_MAGIC)
registerEnumIn(L, "configKeys", RATE_SPAWN)
registerEnumIn(L, "configKeys", HOUSE_PRICE)
registerEnumIn(L, "configKeys", HOUSE_BUY_LEVEL)
registerEnumIn(L, "configKeys", MAX_MESSAGEBUFFER)
registerEnumIn(L, "configKeys", ACTIONS_DELAY_INTERVAL)
registerEnumIn(L, "configKeys", EX_ACTIONS_DELAY_INTERVAL)
Expand Down
10 changes: 3 additions & 7 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,10 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage &msg)
return;
}

OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(msg.get<uint16_t>());
if (operatingSystem <= CLIENTOS_NEW_MAC) {
setChecksumMethod(CHECKSUM_METHOD_SEQUENCE);
enableCompression();
} else {
setChecksumMethod(CHECKSUM_METHOD_ADLER32);
}
setChecksumMethod(CHECKSUM_METHOD_SEQUENCE);
enableCompression();

OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(msg.get<uint16_t>());

version = msg.get<uint16_t>(); // Protocol version

Expand Down
4 changes: 1 addition & 3 deletions src/utils/const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const uint32_t MAX_STATICWALK = 100;
static constexpr size_t NETWORKMESSAGE_PLAYERNAME_MAXLENGTH = 30;
static constexpr int32_t NETWORKMESSAGE_MAXSIZE = 65500;

// QT clients probably have bigger input buffer because of exiva options
// But for now we don't support exiva options
static constexpr int32_t INPUTMESSAGE_MAXSIZE = 2048;
static constexpr int32_t INPUTMESSAGE_MAXSIZE = 4096;

static constexpr int32_t CHANNEL_GUILD = 0x00;
static constexpr int32_t CHANNEL_PARTY = 0x01;
Expand Down

0 comments on commit 4ad1f60

Please sign in to comment.