2012-06-19 21:15:56 -03:00
|
|
|
-- this is the first file executed when the application starts
|
|
|
|
|
-- we have to load the first modules form here
|
2023-05-13 19:51:28 -03:00
|
|
|
|
|
|
|
|
-- updater
|
2023-05-11 11:38:24 -03:00
|
|
|
Services = {
|
2023-07-28 14:51:00 -03:00
|
|
|
--updater = "http://localhost/api/updater.php",
|
2023-05-11 11:38:24 -03:00
|
|
|
}
|
|
|
|
|
|
2023-06-30 20:13:09 -03:00
|
|
|
g_app.setName("OTClient - Redemption");
|
|
|
|
|
g_app.setCompactName("otclient");
|
2023-11-27 14:40:05 -03:00
|
|
|
g_app.setOrganizationName("otcr");
|
2023-06-30 20:13:09 -03:00
|
|
|
|
2023-05-11 11:38:24 -03:00
|
|
|
g_app.hasUpdater = function()
|
|
|
|
|
return (Services.updater and Services.updater ~= "" and g_modules.getModule("updater"))
|
|
|
|
|
end
|
|
|
|
|
|
2012-06-19 21:15:56 -03:00
|
|
|
-- setup logger
|
2022-11-17 15:35:27 -03:00
|
|
|
g_logger.setLogFile(g_resources.getWorkDir() .. g_app.getCompactName() .. '.log')
|
|
|
|
|
g_logger.info(os.date('== application started at %b %d %Y %X'))
|
2023-03-02 21:03:46 -05:00
|
|
|
g_logger.info("== operating system: " .. g_platform.getOSName())
|
2012-06-19 21:15:56 -03:00
|
|
|
|
|
|
|
|
-- print first terminal message
|
2022-11-17 15:35:27 -03:00
|
|
|
g_logger.info(g_app.getName() .. ' ' .. g_app.getVersion() .. ' rev ' .. g_app.getBuildRevision() .. ' (' ..
|
2023-05-13 19:51:28 -03:00
|
|
|
g_app.getBuildCommit() .. ') built on ' .. g_app.getBuildDate() .. ' for arch ' ..
|
|
|
|
|
g_app.getBuildArch())
|
2012-06-19 21:15:56 -03:00
|
|
|
|
2013-01-18 20:39:11 -02:00
|
|
|
-- add data directory to the search path
|
2022-11-17 15:35:27 -03:00
|
|
|
if not g_resources.addSearchPath(g_resources.getWorkDir() .. 'data', true) then
|
|
|
|
|
g_logger.fatal('Unable to add data directory to the search path.')
|
2013-01-18 20:39:11 -02:00
|
|
|
end
|
|
|
|
|
|
2012-06-19 21:15:56 -03:00
|
|
|
-- add modules directory to the search path
|
2022-11-17 15:35:27 -03:00
|
|
|
if not g_resources.addSearchPath(g_resources.getWorkDir() .. 'modules', true) then
|
|
|
|
|
g_logger.fatal('Unable to add modules directory to the search path.')
|
2012-06-19 21:15:56 -03:00
|
|
|
end
|
|
|
|
|
|
2012-07-16 20:04:45 -03:00
|
|
|
-- try to add mods path too
|
2022-11-17 15:35:27 -03:00
|
|
|
g_resources.addSearchPath(g_resources.getWorkDir() .. 'mods', true)
|
2012-06-19 21:15:56 -03:00
|
|
|
|
|
|
|
|
-- setup directory for saving configurations
|
2018-02-28 21:44:17 +01:00
|
|
|
g_resources.setupUserWriteDir(('%s/'):format(g_app.getCompactName()))
|
2012-07-16 16:35:14 -03:00
|
|
|
|
|
|
|
|
-- search all packages
|
|
|
|
|
g_resources.searchAndAddPackages('/', '.otpkg', true)
|
2012-06-19 21:15:56 -03:00
|
|
|
|
2014-04-02 01:54:13 +13:00
|
|
|
-- load settings
|
2022-11-17 15:35:27 -03:00
|
|
|
g_configs.loadSettings('/config.otml')
|
2012-06-19 21:15:56 -03:00
|
|
|
|
|
|
|
|
g_modules.discoverModules()
|
|
|
|
|
|
2012-07-17 20:49:21 -03:00
|
|
|
-- libraries modules 0-99
|
2012-08-31 20:33:51 -03:00
|
|
|
g_modules.autoLoadModules(99)
|
2022-11-17 15:35:27 -03:00
|
|
|
g_modules.ensureModuleLoaded('corelib')
|
|
|
|
|
g_modules.ensureModuleLoaded('gamelib')
|
2023-05-11 11:38:24 -03:00
|
|
|
g_modules.ensureModuleLoaded("startup")
|
|
|
|
|
|
|
|
|
|
local function loadModules()
|
|
|
|
|
-- client modules 100-499
|
|
|
|
|
g_modules.autoLoadModules(499)
|
|
|
|
|
g_modules.ensureModuleLoaded('client')
|
2012-06-19 21:15:56 -03:00
|
|
|
|
2023-05-11 11:38:24 -03:00
|
|
|
-- game modules 500-999
|
|
|
|
|
g_modules.autoLoadModules(999)
|
|
|
|
|
g_modules.ensureModuleLoaded('game_interface')
|
2012-06-19 21:15:56 -03:00
|
|
|
|
2023-05-11 11:38:24 -03:00
|
|
|
-- mods 1000-9999
|
|
|
|
|
g_modules.autoLoadModules(9999)
|
2023-11-21 22:27:20 -03:00
|
|
|
g_modules.ensureModuleLoaded('client_mods')
|
|
|
|
|
|
|
|
|
|
if not g_game.isEnabledBotProtection() then
|
|
|
|
|
g_modules.ensureModuleLoaded('game_bot')
|
|
|
|
|
end
|
2012-06-19 21:15:56 -03:00
|
|
|
|
2023-05-11 11:38:24 -03:00
|
|
|
local script = '/' .. g_app.getCompactName() .. 'rc.lua'
|
2013-02-10 02:54:20 -02:00
|
|
|
|
2023-05-11 11:38:24 -03:00
|
|
|
if g_resources.fileExists(script) then
|
|
|
|
|
dofile(script)
|
|
|
|
|
end
|
2018-02-28 21:44:17 +01:00
|
|
|
end
|
2023-05-11 11:38:24 -03:00
|
|
|
|
|
|
|
|
-- run updater, must use data.zip
|
|
|
|
|
if g_app.hasUpdater() then
|
2023-05-13 19:51:28 -03:00
|
|
|
g_modules.ensureModuleLoaded("updater")
|
|
|
|
|
return Updater.init(loadModules)
|
2023-05-11 11:38:24 -03:00
|
|
|
end
|
2023-07-28 14:51:00 -03:00
|
|
|
|
|
|
|
|
loadModules()
|
|
|
|
|
|
|
|
|
|
-- uncomment the line below so that modules are reloaded when modified. (Note: Use only mod dev)
|
|
|
|
|
-- g_modules.enableAutoReload()
|