Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed Sep 28, 2023
1 parent 1fa45a1 commit ef72e29
Show file tree
Hide file tree
Showing 217 changed files with 7,533 additions and 7,154 deletions.
9 changes: 8 additions & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ maxAllowedOnADummy = 1
toggleSaveInterval = true
saveIntervalType = "minute"
toggleSaveIntervalCleanMap = true
saveIntervalTime = 15
saveIntervalTime = 30

-- Imbuement
toggleImbuementShrineStorage = false
Expand All @@ -253,6 +253,11 @@ 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.
--[[ NOTE: The togglehouseTransferOnRestart setting controls whether house transfers/leave are true/false upon server restart.
• When set to true, the transfers will only occur during a server restart.
Setting this to false may pose risks; if a house is abandoned and contains a large number of items on the floor, those items will be transferred to the player's depot instantly.
• This could potentially freeze the server due to the heavy operation. It's advised to keep this setting enabled (true) to minimize risks.
]]
-- Periods: daily/weekly/monthly/yearly/never
-- Base: sqm,rent,sqm+rent
housePriceRentMultiplier = 0.0
Expand All @@ -263,6 +268,7 @@ houseOwnedByAccount = false
houseBuyLevel = 100
housePurchasedShowPrice = false
onlyInvitedCanMoveHouseItems = true
togglehouseTransferOnRestart = true

-- Item Usage
timeBetweenActions = 200
Expand Down Expand Up @@ -327,6 +333,7 @@ resetSessionsOnStartup = false
-- Misc.
-- NOTE: experienceDisplayRates: set to false to ignore exp rate or true to include exp rate
allowChangeOutfit = true
toggleMountInProtectionZone = false
freePremium = false
kickIdlePlayerAfterMinutes = 15
maxMessageBuffer = 4
Expand Down
20 changes: 12 additions & 8 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ CREATE TABLE IF NOT EXISTS `guild_membership` (
CREATE TABLE IF NOT EXISTS `houses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`owner` int(11) NOT NULL,
`new_owner` int(11) NOT NULL DEFAULT '-1',
`paid` int(10) UNSIGNED NOT NULL DEFAULT '0',
`warnings` int(11) NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL,
Expand Down Expand Up @@ -433,15 +434,18 @@ END
DELIMITER ;

-- Table structure `house_lists`

CREATE TABLE IF NOT EXISTS `house_lists` (
`house_id` int(11) NOT NULL,
`listid` int(11) NOT NULL,
`list` text NOT NULL,
INDEX `house_id` (`house_id`),
CONSTRAINT `houses_list_house_fk`
FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
`house_id` int NOT NULL,
`listid` int NOT NULL,
`version` int NOT NULL DEFAULT '0',
`list` text NOT NULL,
PRIMARY KEY (`house_id`, `listid`),
KEY `house_id_index` (`house_id`),
KEY `version` (`version`),
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` (
Expand Down
6 changes: 3 additions & 3 deletions src/account/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace account {
}

void Account::addPremiumDays(const int32_t &days) {
uint32_t timeLeft = static_cast<int>((m_account.premiumLastDay - getTimeNow()) % 86400);
auto timeLeft = static_cast<int32_t>((m_account.premiumLastDay - getTimeNow()) % 86400);
setPremiumDays(m_account.premiumRemainingDays + days);

if (timeLeft > 0) {
Expand Down Expand Up @@ -199,8 +199,8 @@ namespace account {

time_t currentTime = getTimeNow();

uint32_t daysLeft = static_cast<int>((lastDay - currentTime) / 86400);
uint32_t timeLeft = static_cast<int>((lastDay - currentTime) % 86400);
auto daysLeft = static_cast<int32_t>((lastDay - currentTime) / 86400);
auto timeLeft = static_cast<int32_t>((lastDay - currentTime) % 86400);

m_account.premiumRemainingDays = daysLeft > 0 ? daysLeft : 0;

Expand Down
77 changes: 40 additions & 37 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,57 +52,60 @@ CanaryServer::CanaryServer(
}

int CanaryServer::run() {
g_dispatcher().addTask([this] {
try {
loadConfigLua();
g_dispatcher().addTask(
[this] {
try {
loadConfigLua();

logger.info("Server protocol: {}.{}{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER, g_configManager().getBoolean(OLD_PROTOCOL) ? " and 10x allowed!" : "");
logger.info("Server protocol: {}.{}{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER, g_configManager().getBoolean(OLD_PROTOCOL) ? " and 10x allowed!" : "");

rsa.start();
initializeDatabase();
loadModules();
setWorldType();
loadMaps();
rsa.start();
initializeDatabase();
loadModules();
setWorldType();
loadMaps();

logger.info("Initializing gamestate...");
g_game().setGameState(GAME_STATE_INIT);
logger.info("Initializing gamestate...");
g_game().setGameState(GAME_STATE_INIT);

setupHousesRent();
setupHousesRent();
g_game().transferHouseItemsToDepot();

IOMarket::checkExpiredOffers();
IOMarket::getInstance().updateStatistics();
IOMarket::checkExpiredOffers();
IOMarket::getInstance().updateStatistics();

logger.info("Loaded all modules, server starting up...");
logger.info("Loaded all modules, server starting up...");

#ifndef _WIN32
if (getuid() == 0 || geteuid() == 0) {
logger.warn("{} has been executed as root user, "
"please consider running it as a normal user",
STATUS_SERVER_NAME);
}
if (getuid() == 0 || geteuid() == 0) {
logger.warn("{} has been executed as root user, "
"please consider running it as a normal user",
STATUS_SERVER_NAME);
}
#endif

g_game().start(&serviceManager);
g_game().setGameState(GAME_STATE_NORMAL);
g_game().start(&serviceManager);
g_game().setGameState(GAME_STATE_NORMAL);

g_webhook().sendMessage("Server is now online", "Server has successfully started.", WEBHOOK_COLOR_ONLINE);
g_webhook().sendMessage("Server is now online", "Server has successfully started.", WEBHOOK_COLOR_ONLINE);

loaderDone = true;
loaderSignal.notify_all();
} catch (FailedToInitializeCanary &err) {
loadFailed = true;
logger.error(err.what());
loaderDone = true;
loaderSignal.notify_all();
} catch (FailedToInitializeCanary &err) {
loadFailed = true;
logger.error(err.what());

logger.error("The program will close after pressing the enter key...");
logger.error("The program will close after pressing the enter key...");

if (isatty(STDIN_FILENO)) {
getchar();
}
if (isatty(STDIN_FILENO)) {
getchar();
}

loaderSignal.notify_all();
}
},
"CanaryServer::run");
loaderSignal.notify_all();
}
},
"CanaryServer::run"
);

loaderSignal.wait(loaderUniqueLock, [this] { return loaderDone || loadFailed; });

Expand Down Expand Up @@ -351,7 +354,7 @@ void CanaryServer::loadModules() {

g_game().loadBoostedCreature();
g_ioBosstiary().loadBoostedBoss();
g_ioprey().InitializeTaskHuntOptions();
g_ioprey().initializeTaskHuntOptions();
}

void CanaryServer::modulesLoadHelper(bool loaded, std::string moduleName) {
Expand Down
2 changes: 2 additions & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ enum booleanConfig_t {
VIP_STAY_ONLINE,

REWARD_CHEST_COLLECT_ENABLED,
TOGGLE_MOUNT_IN_PZ,
TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART,

LAST_BOOLEAN_CONFIG
};
Expand Down
4 changes: 4 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ bool ConfigManager::load() {
boolean[REWARD_CHEST_COLLECT_ENABLED] = getGlobalBoolean(L, "rewardChestCollectEnabled", true);
integer[REWARD_CHEST_MAX_COLLECT_ITEMS] = getGlobalNumber(L, "rewardChestMaxCollectItems", 200);

boolean[TOGGLE_MOUNT_IN_PZ] = getGlobalBoolean(L, "toggleMountInProtectionZone", false);

boolean[TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART] = getGlobalBoolean(L, "togglehouseTransferOnRestart", false);

loaded = true;
lua_close(L);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

static constexpr auto STATUS_SERVER_NAME = "OTX Server";
static constexpr auto STATUS_SERVER_VERSION = "6.2";
static constexpr auto STATUS_SERVER_DEVELOPERS = "OpenTibiaBR Organization and data editor: Mattyx14";
static constexpr auto STATUS_SERVER_DEVELOPERS = "Canary Base - OpenTibiaBR Organization and data editor: Mattyx14";

static constexpr auto AUTHENTICATOR_DIGITS = 6U;
static constexpr auto AUTHENTICATOR_PERIOD = 30U;
Expand Down
Loading

0 comments on commit ef72e29

Please sign in to comment.