Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed May 29, 2024
1 parent 27c3d86 commit 6c55c08
Show file tree
Hide file tree
Showing 50 changed files with 1,142 additions and 658 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
# VCPKG
# cmake -DCMAKE_TOOLCHAIN_FILE=/opt/workspace/vcpkg/scripts/buildsystems/vcpkg.cmake ..
# Needed libs is in file vcpkg.json
# Windows required libs: .\vcpkg install --triplet x64-windows asio pugixml spdlog curl protobuf parallel-hashmap magic-enum mio luajit libmariadb mpir abseil
# Windows required libs: .\vcpkg install --triplet x64-windows asio pugixml spdlog curl protobuf parallel-hashmap magic-enum mio luajit libmariadb mpir abseil bshoshany-thread-pool
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
Expand Down Expand Up @@ -124,4 +124,4 @@ add_subdirectory(src)

if(BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()
3 changes: 3 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ partyListMaxDistance = 30
toggleMapCustom = false

-- Market
-- NOTE: marketRefreshPricesInterval (in minutes, minimum is 1 minute)
-- NOTE: set it to 0 for disable, is the time in which the task will run updating the prices of the items that will be sent to the client
marketOfferDuration = 30 * 24 * 60 * 60
marketRefreshPricesInterval = 30
premiumToCreateMarketOffer = true
checkExpiredMarketOffersEachMinutes = 60
maxMarketOffersAtATimePerPlayer = 100
Expand Down
55 changes: 54 additions & 1 deletion data-otxserver/migrations/45.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
function onUpdateDatabase()
return false -- true = There are others migrations file | false = this is the last migration file
logger.info("Updating database to version 46 (feat: vip groups)")

db.query([[
CREATE TABLE IF NOT EXISTS `account_vipgroups` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose vip group entry it is',
`name` varchar(128) NOT NULL,
`customizable` BOOLEAN NOT NULL DEFAULT '1',
CONSTRAINT `account_vipgroups_pk` PRIMARY KEY (`id`, `account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
]])

db.query([[
CREATE TRIGGER `oncreate_accounts` AFTER INSERT ON `accounts` FOR EACH ROW BEGIN
INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Enemies', 0);
INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Friends', 0);
INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Trading Partner', 0);
END;
]])

db.query([[
CREATE TABLE IF NOT EXISTS `account_vipgrouplist` (
`account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose viplist entry it is',
`player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry',
`vipgroup_id` int(11) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs',
INDEX `account_id` (`account_id`),
INDEX `player_id` (`player_id`),
INDEX `vipgroup_id` (`vipgroup_id`),
CONSTRAINT `account_vipgrouplist_unique` UNIQUE (`account_id`, `player_id`, `vipgroup_id`),
CONSTRAINT `account_vipgrouplist_player_fk`
FOREIGN KEY (`player_id`) REFERENCES `players` (`id`)
ON DELETE CASCADE,
CONSTRAINT `account_vipgrouplist_vipgroup_fk`
FOREIGN KEY (`vipgroup_id`, `account_id`) REFERENCES `account_vipgroups` (`id`, `account_id`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
]])

db.query([[
INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`)
SELECT 1, id, 'Friends', 0 FROM `accounts`;
]])

db.query([[
INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`)
SELECT 2, id, 'Enemies', 0 FROM `accounts`;
]])

db.query([[
INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`)
SELECT 3, id, 'Trading Partners', 0 FROM `accounts`;
]])

return true
end
3 changes: 3 additions & 0 deletions data-otxserver/migrations/46.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function onUpdateDatabase()
return false -- true = There are others migrations file | false = this is the last migration file
end
17 changes: 15 additions & 2 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64466,8 +64466,8 @@ hands of its owner. Granted by TibiaRoyal.com"/>
<attribute key="range" value="5"/>
<attribute key="weight" value="2600"/>
<attribute key="imbuementslot" value="2">
<attribute key="life leech" value="3"/>
<attribute key="mana leech" value="3"/>
<attribute key="critical hit" value="3"/>
<attribute key="skillboost magic level" value="3"/>
</attribute>
<attribute key="script" value="moveevent;weapon">
Expand Down Expand Up @@ -74873,11 +74873,14 @@ Granted by TibiaGoals.com"/>
<attribute key="weight" value="280"/>
</item>
<item id="43740" article="a" name="scarab ocarina">
<attribute key="primarytype" value="light sources"/>
<attribute key="primarytype" value="quest items"/>
<attribute key="showAttributes" value="1"/>
<attribute key="description" value="It has a turquoise shimmer and was made from a real scarab shell."/>
<attribute key="absorbpercentearth" value="2"/>
<attribute key="weight" value="120"/>
<attribute key="script" value="moveevent">
<attribute key="slot" value="ammo"/>
</attribute>
</item>
<item id="43665" article="a" name="dead elder bloodjaw">
<attribute key="decayTo" value="0"/>
Expand Down Expand Up @@ -74994,6 +74997,15 @@ Granted by TibiaGoals.com"/>
<attribute key="duration" value="10"/>
<attribute key="fluidSource" value="blood"/>
</item>
<item id="43863" article="a" name="conch shell horn">
<attribute key="primarytype" value="quest items"/>
<attribute key="showAttributes" value="1"/>
<attribute key="absorbpercentice" value="5"/>
<attribute key="weight" value="150"/>
<attribute key="script" value="moveevent">
<attribute key="slot" value="ammo"/>
</attribute>
</item>
<item id="43864" article="a" name="sanguine blade">
<attribute key="primarytype" value="sword weapons"/>
<attribute key="weaponType" value="sword"/>
Expand Down Expand Up @@ -75809,3 +75821,4 @@ Granted by TibiaGoals.com"/>
<attribute key="weight" value="120" />
</item>
</items>

17 changes: 9 additions & 8 deletions data/scripts/actions/items/wheel_scrolls.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local promotionScrolls = {
[43946] = { storageName = "wheel.scroll.abridged", points = 3, name = "abridged promotion scroll" },
[43947] = { storageName = "wheel.scroll.basic", points = 5, name = "basic promotion scroll" },
[43948] = { storageName = "wheel.scroll.revised", points = 9, name = "revised promotion scroll" },
[43949] = { storageName = "wheel.scroll.extended", points = 13, name = "extended promotion scroll" },
[43950] = { storageName = "wheel.scroll.advanced", points = 20, name = "advanced promotion scroll" },
[43946] = { name = "abridged", points = 3, itemName = "abridged promotion scroll" },
[43947] = { name = "basic", points = 5, itemName = "basic promotion scroll" },
[43948] = { name = "revised", points = 9, itemName = "revised promotion scroll" },
[43949] = { name = "extended", points = 13, itemName = "extended promotion scroll" },
[43950] = { name = "advanced", points = 20, itemName = "advanced promotion scroll" },
}

local scroll = Action()
Expand All @@ -15,13 +15,14 @@ function scroll.onUse(player, item, fromPosition, target, toPosition, isHotkey)
end

local scrollData = promotionScrolls[item:getId()]
if player:getStorageValueByName(scrollData.storageName) == 1 then
local scrollKV = player:kv():scoped("wheel-of-destiny"):scoped("scrolls")
if scrollKV:get(scrollData.name) then
player:sendTextMessage(MESSAGE_LOOK, "You have already deciphered this scroll.")
return true
end

player:setStorageValueByName(scrollData.storageName, 1)
player:sendTextMessage(MESSAGE_LOOK, "You have gained " .. scrollData.points .. " promotion points for the Wheel of Destiny by deciphering the " .. scrollData.name .. ".")
scrollKV:set(scrollData.name, true)
player:sendTextMessage(MESSAGE_LOOK, "You have gained " .. scrollData.points .. " promotion points for the Wheel of Destiny by deciphering the " .. scrollData.itemName .. ".")
item:remove(1)
return true
end
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/lib/register_migrations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Migration:register()
return
end
if not self:_validateName() then
error("Invalid migration name: " .. self.name .. ". Migration names must be in the format: <timestamp>_<description>. Example: 20231128213149_add_new_monsters")
logger.error("Invalid migration name: " .. self.name .. ". Migration names must be in the format: <timestamp>_<description>. Example: 20231128213149_add_new_monsters")
end

table.insert(Migration.registry, self)
Expand Down
101 changes: 71 additions & 30 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS `server_config` (
CONSTRAINT `server_config_pk` PRIMARY KEY (`config`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '45'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0');
INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '46'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0');

-- Table structure `accounts`
CREATE TABLE IF NOT EXISTS `accounts` (
Expand Down Expand Up @@ -215,40 +215,79 @@ CREATE TABLE IF NOT EXISTS `account_viplist` (
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Table structure `account_vipgroup`
CREATE TABLE IF NOT EXISTS `account_vipgroups` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose vip group entry it is',
`name` varchar(128) NOT NULL,
`customizable` BOOLEAN NOT NULL DEFAULT '1',
CONSTRAINT `account_vipgroups_pk` PRIMARY KEY (`id`, `account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Trigger
--
DELIMITER //
CREATE TRIGGER `oncreate_accounts` AFTER INSERT ON `accounts` FOR EACH ROW BEGIN
INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Enemies', 0);
INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Friends', 0);
INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Trading Partner', 0);
END
//
DELIMITER ;

-- Table structure `account_vipgrouplist`
CREATE TABLE IF NOT EXISTS `account_vipgrouplist` (
`account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose viplist entry it is',
`player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry',
`vipgroup_id` int(11) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs',
INDEX `account_id` (`account_id`),
INDEX `player_id` (`player_id`),
INDEX `vipgroup_id` (`vipgroup_id`),
CONSTRAINT `account_vipgrouplist_unique` UNIQUE (`account_id`, `player_id`, `vipgroup_id`),
CONSTRAINT `account_vipgrouplist_player_fk`
FOREIGN KEY (`player_id`) REFERENCES `players` (`id`)
ON DELETE CASCADE,
CONSTRAINT `account_vipgrouplist_vipgroup_fk`
FOREIGN KEY (`vipgroup_id`, `account_id`) REFERENCES `account_vipgroups` (`id`, `account_id`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Table structure `boosted_boss`
CREATE TABLE IF NOT EXISTS `boosted_boss` (
`boostname` TEXT,
`date` varchar(250) NOT NULL DEFAULT '',
`raceid` varchar(250) NOT NULL DEFAULT '',
`looktypeEx` int(11) NOT NULL DEFAULT "0",
`looktype` int(11) NOT NULL DEFAULT "136",
`lookfeet` int(11) NOT NULL DEFAULT "0",
`looklegs` int(11) NOT NULL DEFAULT "0",
`lookhead` int(11) NOT NULL DEFAULT "0",
`lookbody` int(11) NOT NULL DEFAULT "0",
`lookaddons` int(11) NOT NULL DEFAULT "0",
`lookmount` int(11) DEFAULT "0",
`looktypeEx` int(11) NOT NULL DEFAULT 0,
`looktype` int(11) NOT NULL DEFAULT 136,
`lookfeet` int(11) NOT NULL DEFAULT 0,
`looklegs` int(11) NOT NULL DEFAULT 0,
`lookhead` int(11) NOT NULL DEFAULT 0,
`lookbody` int(11) NOT NULL DEFAULT 0,
`lookaddons` int(11) NOT NULL DEFAULT 0,
`lookmount` int(11) DEFAULT 0,
PRIMARY KEY (`date`)
) AS SELECT 0 AS date, "default" AS boostname, 0 AS raceid;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `boosted_boss` (`boostname`, `date`, `raceid`) VALUES ('default', 0, 0);

-- Table structure `boosted_creature`
CREATE TABLE IF NOT EXISTS `boosted_creature` (
`boostname` TEXT,
`date` varchar(250) NOT NULL DEFAULT '',
`raceid` varchar(250) NOT NULL DEFAULT '',
`looktype` int(11) NOT NULL DEFAULT "136",
`lookfeet` int(11) NOT NULL DEFAULT "0",
`looklegs` int(11) NOT NULL DEFAULT "0",
`lookhead` int(11) NOT NULL DEFAULT "0",
`lookbody` int(11) NOT NULL DEFAULT "0",
`lookaddons` int(11) NOT NULL DEFAULT "0",
`lookmount` int(11) DEFAULT "0",
`looktype` int(11) NOT NULL DEFAULT 136,
`lookfeet` int(11) NOT NULL DEFAULT 0,
`looklegs` int(11) NOT NULL DEFAULT 0,
`lookhead` int(11) NOT NULL DEFAULT 0,
`lookbody` int(11) NOT NULL DEFAULT 0,
`lookaddons` int(11) NOT NULL DEFAULT 0,
`lookmount` int(11) DEFAULT 0,
PRIMARY KEY (`date`)
) AS SELECT 0 AS date, "default" AS boostname, 0 AS raceid;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------
INSERT INTO `boosted_creature` (`boostname`, `date`, `raceid`) VALUES ('default', 0, 0);

--
-- Tabble Structure `daily_reward_history`
CREATE TABLE IF NOT EXISTS `daily_reward_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -372,9 +411,9 @@ CREATE TABLE IF NOT EXISTS `guild_ranks` (
--
DELIMITER //
CREATE TRIGGER `oncreate_guilds` AFTER INSERT ON `guilds` FOR EACH ROW BEGIN
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('The Leader', 3, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Vice-Leader', 2, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Member', 1, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('The Leader', 3, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Vice-Leader', 2, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Member', 1, NEW.`id`);
END
//
DELIMITER ;
Expand Down Expand Up @@ -428,15 +467,13 @@ CREATE TABLE IF NOT EXISTS `houses` (
-- trigger
--
DELIMITER //
CREATE TRIGGER `ondelete_players` BEFORE DELETE ON `players`
FOR EACH ROW BEGIN
UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
CREATE TRIGGER `ondelete_players` BEFORE DELETE ON `players` FOR EACH ROW BEGIN
UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
END
//
DELIMITER ;

-- Table structure `house_lists`

CREATE TABLE IF NOT EXISTS `house_lists` (
`house_id` int NOT NULL,
`listid` int NOT NULL,
Expand All @@ -448,7 +485,6 @@ CREATE TABLE IF NOT EXISTS `house_lists` (
CONSTRAINT `houses_list_house_fk` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;


-- Table structure `ip_bans`
CREATE TABLE IF NOT EXISTS `ip_bans` (
`ip` int(11) NOT NULL,
Expand Down Expand Up @@ -503,7 +539,6 @@ CREATE TABLE IF NOT EXISTS `market_offers` (
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- Table structure `players_online`
CREATE TABLE IF NOT EXISTS `players_online` (
`player_id` int(11) NOT NULL,
Expand Down Expand Up @@ -634,7 +669,6 @@ CREATE TABLE IF NOT EXISTS `player_wheeldata` (
PRIMARY KEY (`player_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- Table structure `player_kills`
CREATE TABLE IF NOT EXISTS `player_kills` (
`player_id` int(11) NOT NULL,
Expand Down Expand Up @@ -793,6 +827,7 @@ CREATE TABLE IF NOT EXISTS `account_sessions` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Table structure `kv_store`
CREATE TABLE IF NOT EXISTS `kv_store` (
`key_name` varchar(191) NOT NULL,
`timestamp` bigint NOT NULL,
Expand All @@ -815,3 +850,9 @@ INSERT INTO `players`
(4, 'Paladin Sample', 1, 1, 8, 3, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0),
(5, 'Knight Sample', 1, 1, 8, 4, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0),
(6, 'GOD', 6, 1, 2, 0, 155, 155, 100, 113, 115, 95, 39, 75, 0, 60, 60, 0, 8, '', 410, 1, 10, 0, 10, 0, 10, 0, 10, 0);

-- Create vip groups for GOD account
INSERT INTO `account_vipgroups` (`name`, `account_id`, `customizable`) VALUES
('Friends', 1, 0),
('Enemies', 1, 0),
('Trading Partners', 1, 0);
1 change: 1 addition & 0 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ enum ConfigKey_t : uint16_t {
MAP_DOWNLOAD_URL,
MAP_NAME,
MARKET_OFFER_DURATION,
MARKET_REFRESH_PRICES,
MARKET_PREMIUM,
MAX_ALLOWED_ON_A_DUMMY,
MAX_CONTAINER_ITEM,
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ bool ConfigManager::load() {
loadIntConfig(L, GAME_PORT, "gameProtocolPort", 7172);
loadIntConfig(L, LOGIN_PORT, "loginProtocolPort", 7171);
loadIntConfig(L, MARKET_OFFER_DURATION, "marketOfferDuration", 30 * 24 * 60 * 60);
loadIntConfig(L, MARKET_REFRESH_PRICES, "marketRefreshPricesInterval", 30);
loadIntConfig(L, PREMIUM_DEPOT_LIMIT, "premiumDepotLimit", 8000);
loadIntConfig(L, SQL_PORT, "mysqlPort", 3306);
loadIntConfig(L, STASH_ITEMS, "stashItemCount", 5000);
Expand Down
1 change: 1 addition & 0 deletions src/creatures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ target_sources(${PROJECT_NAME}_lib PRIVATE
players/wheel/player_wheel.cpp
players/wheel/wheel_gems.cpp
players/vocations/vocation.cpp
players/vip/player_vip.cpp
)
Loading

0 comments on commit 6c55c08

Please sign in to comment.