int32 do_init(int32 argc, int8** argv) { ShowStatus("do_init: begin server initialization...\n"); MAP_CONF_FILENAME = "./conf/map_darkstar.conf"; srand((uint32)time(NULL)); WELL512::seed((uint32)time(NULL)); map_config_default(); map_config_read(MAP_CONF_FILENAME); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); ShowStatus("do_init: map_config is reading"); ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); luautils::init(); CmdHandler.init(luautils::LuaHandle); PacketParserInitialize(); SqlHandle = Sql_Malloc(); ShowStatus("do_init: sqlhandle is allocating"); if( Sql_Connect(SqlHandle,map_config.mysql_login, map_config.mysql_password, map_config.mysql_host, map_config.mysql_port, map_config.mysql_database) == SQL_ERROR ) { exit(EXIT_FAILURE); } Sql_Keepalive(SqlHandle); // отчищаем таблицу сессий при старте сервера (временное решение, т.к. в кластере это не будет работать) Sql_Query(SqlHandle, "TRUNCATE TABLE accounts_sessions"); ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); ShowStatus("do_init: zlib is reading"); zlib_init(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); ShowStatus("do_init: loading items"); itemutils::Initialize(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); // нужно будет написать один метод для инициализации всех данных в battleutils // и один метод для освобождения этих данных ShowStatus("do_init: loading spells"); spell::LoadSpellList(); mobSpellList::LoadMobSpellList(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); charutils::ResetAllTwoHours(); guildutils::Initialize(); charutils::LoadExpTable(); linkshell::LoadLinkshellList(); traits::LoadTraitsList(); effects::LoadEffectsParameters(); battleutils::LoadSkillTable(); meritNameSpace::LoadMeritsList(); nameSpaceUnlockableWeapons::LoadUnlockableWeaponList(); ability::LoadAbilitiesList(); battleutils::LoadWeaponSkillsList(); battleutils::LoadMobSkillsList(); battleutils::LoadEnmityTable(); battleutils::LoadSkillChainDamageModifiers(); petutils::LoadPetList(); conquest::LoadConquestSystem(); mobutils::LoadCustomMods(); ShowStatus("do_init: loading zones"); zoneutils::LoadZoneList(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); luautils::OnServerStart(); fishingutils::LoadFishingMessages(); ShowStatus("do_init: server is binding with port %u",map_config.usMapPort); map_fd = makeBind_udp(map_config.uiMapIp,map_config.usMapPort); ShowMessage("\t - " CL_GREEN"[OK]" CL_RESET"\n"); CVanaTime::getInstance()->setCustomOffset(map_config.vanadiel_time_offset); CTaskMgr::getInstance()->AddTask("time_server", gettick(), NULL, CTaskMgr::TASK_INTERVAL, time_server, 2400); CTaskMgr::getInstance()->AddTask("map_cleanup", gettick(), NULL, CTaskMgr::TASK_INTERVAL, map_cleanup, 5000); CTaskMgr::getInstance()->AddTask("garbage_collect", gettick(), NULL, CTaskMgr::TASK_INTERVAL, map_garbage_collect, 15 * 60 * 1000); CREATE(g_PBuff, int8, map_config.buffer_size + 20); CREATE(PTempBuff, int8, map_config.buffer_size + 20); aFree((void*)map_config.mysql_login); aFree((void*)map_config.mysql_password); ShowStatus("The map-server is " CL_GREEN"ready" CL_RESET" to work...\n"); ShowMessage("=======================================================================\n"); return 0; }
int32 do_init(int32 argc, int8** argv) { ShowStatus("do_init: begin server initialization...\n"); map_ip.s_addr = 0; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--ip") == 0) map_ip.s_addr = inet_addr(argv[i + 1]); else if (strcmp(argv[i], "--port") == 0) map_port = std::stoi(argv[i + 1]); } MAP_CONF_FILENAME = "./conf/map_darkstar.conf"; srand((uint32)time(nullptr)); dsprand::seed(); map_config_default(); map_config_read(MAP_CONF_FILENAME); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); ShowStatus("do_init: map_config is reading"); ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); luautils::init(); CmdHandler.init(luautils::LuaHandle); PacketParserInitialize(); SqlHandle = Sql_Malloc(); ShowStatus("do_init: sqlhandle is allocating"); if (Sql_Connect(SqlHandle, map_config.mysql_login, map_config.mysql_password, map_config.mysql_host, map_config.mysql_port, map_config.mysql_database) == SQL_ERROR) { do_final(EXIT_FAILURE); } Sql_Keepalive(SqlHandle); // отчищаем таблицу сессий при старте сервера (временное решение, т.к. в кластере это не будет работать) Sql_Query(SqlHandle, "DELETE FROM accounts_sessions WHERE IF(%u = 0 AND %u = 0, true, server_addr = %u AND server_port = %u);", map_ip, map_port, map_ip, map_port); ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); ShowStatus("do_init: zlib is reading"); zlib_init(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); messageThread = std::thread(message::init, map_config.msg_server_ip, map_config.msg_server_port); ShowStatus("do_init: loading items"); itemutils::Initialize(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); // нужно будет написать один метод для инициализации всех данных в battleutils // и один метод для освобождения этих данных ShowStatus("do_init: loading spells"); spell::LoadSpellList(); mobSpellList::LoadMobSpellList(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); guildutils::Initialize(); charutils::LoadExpTable(); linkshell::LoadLinkshellList(); traits::LoadTraitsList(); effects::LoadEffectsParameters(); battleutils::LoadSkillTable(); meritNameSpace::LoadMeritsList(); ability::LoadAbilitiesList(); battleutils::LoadWeaponSkillsList(); battleutils::LoadMobSkillsList(); battleutils::LoadSkillChainDamageModifiers(); petutils::LoadPetList(); mobutils::LoadCustomMods(); ShowStatus("do_init: loading zones\n"); zoneutils::LoadZoneList(); ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n"); fishingutils::LoadFishingMessages(); ShowStatus("do_init: server is binding with port %u", map_port == 0 ? map_config.usMapPort : map_port); map_fd = makeBind_udp(map_config.uiMapIp, map_port == 0 ? map_config.usMapPort : map_port); ShowMessage("\t - " CL_GREEN"[OK]" CL_RESET"\n"); CVanaTime::getInstance()->setCustomOffset(map_config.vanadiel_time_offset); zoneutils::InitializeWeather(); // Need VanaTime initialized CTransportHandler::getInstance()->InitializeTransport(); CTaskMgr::getInstance()->AddTask("time_server", gettick(), nullptr, CTaskMgr::TASK_INTERVAL, time_server, 2400); CTaskMgr::getInstance()->AddTask("map_cleanup", gettick(), nullptr, CTaskMgr::TASK_INTERVAL, map_cleanup, 5000); CTaskMgr::getInstance()->AddTask("garbage_collect", gettick(), nullptr, CTaskMgr::TASK_INTERVAL, map_garbage_collect, 15 * 60 * 1000); CREATE(g_PBuff, int8, map_config.buffer_size + 20); CREATE(PTempBuff, int8, map_config.buffer_size + 20); ShowStatus("The map-server is " CL_GREEN"ready" CL_RESET" to work...\n"); ShowMessage("=======================================================================\n"); return 0; }
int32 do_init(int32 argc, int8** argv) { ShowStatus("do_init: begin server initialization...\n"); MAP_CONF_FILENAME = "./conf/map_darkstar.conf"; srand((uint32)time(NULL)); map_config_default(); map_config_read(MAP_CONF_FILENAME); ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); ShowStatus("do_init: map_config is reading"); ShowMessage("\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); luautils::init(); CmdHandler.init("conf/commands.conf",luautils::LuaHandle); PacketParderInitialize(); SqlHandle = Sql_Malloc(); ShowStatus("do_init: sqlhandle is allocating"); if( Sql_Connect(SqlHandle,map_config.mysql_login, map_config.mysql_password, map_config.mysql_host, map_config.mysql_port, map_config.mysql_database) == SQL_ERROR ) { exit(EXIT_FAILURE); } Sql_Keepalive(SqlHandle); ShowMessage("\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); ShowStatus("do_init: zlib is reading"); zlib_init(); ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); ShowStatus("do_init: loading items"); itemutils::LoadItemList(); ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); // нужно будет написать один метод для инициализации всех данных в battleutils // и один метод для освобождения этих данных ShowStatus("do_init: loading spells"); battleutils::LoadSpellList(); ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); guildutils::Initialize(); charutils::LoadExpTable(); battleutils::LoadSkillTable(); battleutils::LoadAbilitiesList(); battleutils::LoadWeaponSkillsList(); battleutils::LoadTraitsList(); battleutils::LoadMobSkillsList(); battleutils::LoadEnmityTable(); petutils::LoadPetList(); ShowStatus("do_init: loading zones"); zoneutils::LoadZoneList(); ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n"); luautils::OnServerStart(); ShowStatus("do_init: server is binding with port %u",map_config.usMapPort); map_fd = makeBind_udp(map_config.uiMapIp,map_config.usMapPort); ShowMessage("\t - "CL_GREEN"[OK]"CL_RESET"\n"); CVanaTime::getInstance()->setCustomOffset(map_config.vanadiel_time_offset); CTaskMgr::getInstance()->AddTask("time_server", gettick()+1000, NULL, CTaskMgr::TASK_INTERVAL, time_server, 2400); CTaskMgr::getInstance()->AddTask("map_cleanup", gettick()+5000, NULL, CTaskMgr::TASK_INTERVAL, map_cleanup, map_config.max_time_lastupdate); CREATE(g_PBuff, int8, map_config.buffer_size + 20); CREATE(PTempBuff, int8, map_config.buffer_size + 20); ShowStatus("The map-server is "CL_GREEN"ready"CL_RESET" to work...\n"); ShowMessage("=======================================================================\n"); return 0; }