Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move client version from config.lua to definitions.h #355

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move client version from config.lua to definitions.h
  • Loading branch information
dudantas committed Apr 27, 2022
commit 6e560b3a181e146324fc05d78c14f1ad2ddaa21b
4 changes: 0 additions & 4 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ maxPacketsPerSecond = 25
maxItem = 2000
maxContainer = 100

-- Version
clientVersion = 1285
clientVersionStr = "12.85"

-- Depot Limit
freeDepotLimit = 2000
premiumDepotLimit = 10000
Expand Down
248 changes: 0 additions & 248 deletions data/scripts/lib/actions.lua

This file was deleted.

28 changes: 13 additions & 15 deletions data/scripts/lib/register_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ ActionsLib.useMachete = function(player, item, fromPosition, target, toPosition,
end

ActionsLib.usePick = function(player, item, fromPosition, target, toPosition, isHotkey)
if(CLIENT_VERSION >= 854) then
if target.itemid == 11227 then -- shiny stone refining
local chance = math.random(1, 100)
if chance == 1 then
player:addItem(ITEM_CRYSTAL_COIN) -- 1% chance of getting crystal coin
elseif chance <= 6 then
player:addItem(ITEM_GOLD_COIN) -- 5% chance of getting gold coin
elseif chance <= 51 then
player:addItem(ITEM_PLATINUM_COIN) -- 45% chance of getting platinum coin
else
player:addItem(2145) -- 49% chance of getting small diamond
end
target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
target:remove(1)
return true
if target.itemid == 11227 then -- shiny stone refining
local chance = math.random(1, 100)
if chance == 1 then
player:addItem(ITEM_CRYSTAL_COIN) -- 1% chance of getting crystal coin
elseif chance <= 6 then
player:addItem(ITEM_GOLD_COIN) -- 5% chance of getting gold coin
elseif chance <= 51 then
player:addItem(ITEM_PLATINUM_COIN) -- 45% chance of getting platinum coin
else
player:addItem(2145) -- 49% chance of getting small diamond
end
target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
target:remove(1)
return true
end

local tile = Tile(toPosition)
Expand Down
2 changes: 0 additions & 2 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ enum stringConfig_t {
DEFAULT_PRIORITY,
MAP_AUTHOR,
STORE_IMAGES_URL,
CLIENT_VERSION_STR,
MAP_CUSTOM_NAME,
MAP_CUSTOM_AUTHOR,
DISCORD_WEBHOOK_URL,
Expand Down Expand Up @@ -134,7 +133,6 @@ enum integerConfig_t {
MAX_CONTAINER,
MAX_ITEM,
MARKET_OFFER_DURATION,
CLIENT_VERSION,
DEPOT_BOXES,
FREE_DEPOT_LIMIT,
PREMIUM_DEPOT_LIMIT,
Expand Down
2 changes: 0 additions & 2 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ bool ConfigManager::load()
string[MYSQL_PASS] = getGlobalString(L, "mysqlPass", "");
string[MYSQL_DB] = getGlobalString(L, "mysqlDatabase", "canary");
string[MYSQL_SOCK] = getGlobalString(L, "mysqlSock", "");
string[CLIENT_VERSION_STR] = getGlobalString(L, "clientVersionStr", "12.85");

integer[SQL_PORT] = getGlobalNumber(L, "mysqlPort", 3306);
integer[GAME_PORT] = getGlobalNumber(L, "gameProtocolPort", 7172);
Expand All @@ -133,7 +132,6 @@ bool ConfigManager::load()

integer[MARKET_OFFER_DURATION] = getGlobalNumber(L, "marketOfferDuration", 30 * 24 * 60 * 60);

integer[CLIENT_VERSION] = getGlobalNumber(L, "clientVersion", 1285);
integer[FREE_DEPOT_LIMIT] = getGlobalNumber(L, "freeDepotLimit", 2000);
integer[PREMIUM_DEPOT_LIMIT] = getGlobalNumber(L, "premiumDepotLimit", 8000);
integer[DEPOT_BOXES] = getGlobalNumber(L, "depotBoxes", 19);
Expand Down
2 changes: 0 additions & 2 deletions src/lua/functions/core/game/config_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ConfigFunctions final : LuaScriptInterface {
registerEnumIn(L, "configKeys", DEFAULT_PRIORITY)
registerEnumIn(L, "configKeys", MAP_AUTHOR)
registerEnumIn(L, "configKeys", STORE_IMAGES_URL)
registerEnumIn(L, "configKeys", CLIENT_VERSION_STR)
registerEnumIn(L, "configKeys", PARTY_LIST_MAX_DISTANCE)
registerEnumIn(L, "configKeys", SQL_PORT)
registerEnumIn(L, "configKeys", MAX_PLAYERS)
Expand Down Expand Up @@ -137,7 +136,6 @@ class ConfigFunctions final : LuaScriptInterface {
registerEnumIn(L, "configKeys", EXP_FROM_PLAYERS_LEVEL_RANGE)
registerEnumIn(L, "configKeys", MAX_PACKETS_PER_SECOND)
registerEnumIn(L, "configKeys", STORE_COIN_PACKET)
registerEnumIn(L, "configKeys", CLIENT_VERSION)
registerEnumIn(L, "configKeys", DAY_KILLS_TO_RED)
registerEnumIn(L, "configKeys", WEEK_KILLS_TO_RED)
registerEnumIn(L, "configKeys", MONTH_KILLS_TO_RED)
Expand Down
5 changes: 3 additions & 2 deletions src/lua/functions/core/game/game_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,9 @@ int GameFunctions::luaGameStartRaid(lua_State* L) {
int GameFunctions::luaGameGetClientVersion(lua_State* L) {
// Game.getClientVersion()
lua_createtable(L, 0, 3);
setField(L, "version", g_configManager().getNumber(CLIENT_VERSION));
setField(L, "string", g_configManager().getString(CLIENT_VERSION_STR));
setField(L, "min", CLIENT_VERSION);
setField(L, "max", CLIENT_VERSION);
setField(L, "string", std::to_string(CLIENT_VERSION_UPPER) + "." + std::to_string(CLIENT_VERSION_LOWER));
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/otserv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void loadModules() {
modulesLoadHelper(g_configManager().load(),
"config.lua");

SPDLOG_INFO("Server protocol: {}",
g_configManager().getString(CLIENT_VERSION_STR));
SPDLOG_INFO("Server protocol: {}.{}",
CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER);

// set RSA key
try {
Expand Down
4 changes: 2 additions & 2 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,10 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage &msg)
return;
}

if (clientVersion != g_configManager().getNumber(CLIENT_VERSION))
if (clientVersion != CLIENT_VERSION)
{
std::ostringstream ss;
ss << "Only clients with protocol " << g_configManager().getString(CLIENT_VERSION_STR) << " allowed!";
ss << "Only clients with protocol " << CLIENT_VERSION_UPPER << "." << CLIENT_VERSION_LOWER << " allowed!";
disconnectClient(ss.str());
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/network/protocol/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ProtocolGame final : public Protocol

void sendLockerItems(std::map<uint16_t, uint16_t> itemMap, uint16_t count);

uint32_t getVersion() const
uint16_t getVersion() const
{
return version;
}
Expand Down Expand Up @@ -465,7 +465,7 @@ class ProtocolGame final : public Protocol

uint32_t eventConnect = 0;
uint32_t challengeTimestamp = 0;
uint32_t version = g_configManager().getNumber(CLIENT_VERSION);
uint16_t version = CLIENT_VERSION;
int32_t clientVersion = 0;

uint8_t challengeRandom = 0;
Expand Down
Loading