// *************************************************************** // Function: Initialization.cpp // *************************************************************** #define VLD_MAX_DATA_DUMP 0 #include "Main.h" int LoadDatabaseConfig(); //Load the database configuration bool ConnectToDatabase(); //Connect to a database depending on the configuration int InitNetworkServers(); //Initialize the login server and the ic server bool LoadReplayPackets(); bool LoadConfiguration(); bool PopulateOpcodeTable(); bool LoadDbConfigEtc(); bool CheckForCrash(); bool LoadSDItems(); bool UpdateLoop(); bool InitLogs(); int Shutdown(); //Clean-up the server //************************************ // Name: Initialize // // Initializes the login server. // // Parameters: // argc - Number of command line arguments // argv[] - Command line arguments // // Return: // 0 - No error // -1 - Error //************************************ int Initialize(int argc, char* argv[]) { //Initialize the timer TimerInit(); //Check for past server crashes CheckForCrash(); //Init the log files InitLogs(); gCoreLog.WriteCategory("[Loading]"); //Load replay packets if (!LoadReplayPackets()) { gCoreLog.SectionFail(); Shutdown(); return -1; } //Load server configuration options from the config file if (!LoadConfiguration()) { Shutdown(); return -1; } //Load the packet headers from the packet header file if (!PopulateOpcodeTable()) { Shutdown(); return -1; } //Connect to the GWLP database if (!ConnectToDatabase()) { Shutdown(); return -1; } //Load all the static data items if (!LoadSDItems()) { Shutdown(); return -1; } //Load configuration and misc stuff from the db gCoreLog.Section("Db config/misc..."); if (!LoadDbConfigEtc()) { gCoreLog.SectionFail(); gCoreLog.LOCATION; gCoreLog.error("Database dynamic configuration corrupt!"); Shutdown(); return -1; } gCoreLog.SectionOk(); //Init the servers we need to use, IC, login, etc. if (InitNetworkServers()!=0) { gCoreLog.SectionFail(); gCoreLog.LOCATION; gCoreLog.error("Failed to initialize network communications!"); Shutdown(); return -1; } //Set our start timer gServerStatus.startTime=time(NULL); gCoreLog.WriteCategory("[Auth Server Started]"); //Done with our initialization and we must start the main loop UpdateLoop(); return 0; }