#include "main.h" GWLPLog gCoreLog; FS_CONFIG gFsConfig; Server* gpFileServer=NULL; hash_map gData; hash_map gFiles; //Prepares the server for use int Initialize() { TimerInit(); //Load the configuration file printf("Loading config...\n"); ConfigLoader config_loader; config_loader.Load("Config/FsConfig.ini",&gCoreLog); config_loader.GetDataAsBool ("AutomaticIP", &gFsConfig.automaticIp); config_loader.GetDataAsIPBytes("IPAddress", gFsConfig.ipAddress); config_loader.GetDataAsShort ("Port", (short*)&gFsConfig.port); config_loader.GetDataAsBool ("LogAllMessages", &gFsConfig.logAllMessages); config_loader.GetDataAsBool ("UseArchive", &gFsConfig.useArchive); config_loader.GetDataAsString ("ArchivePath", gFsConfig.archivePath); config_loader.GetDataAsBool ("UseArenaNet", &gFsConfig.useArenaNet); config_loader.GetDataAsBool ("DisableArchiveFFNA", &gFsConfig.disableArchiveFFNA); config_loader.GetDataAsInt ("OriginalSegmentSize", &gFsConfig.originalSegmentSize); config_loader.GetDataAsInt ("ExpandedSegmentSize", &gFsConfig.expandedSegmentSize); config_loader.GetDataAsInt ("ChunkSize", &gFsConfig.chunkSize); config_loader.GetDataAsInt ("TimeWait", &gFsConfig.timeWait); config_loader.CleanUp(); if (config_loader.ErrorOccurred()) { printf("Failed to load configuration file.\n"); return -1; } //Set up the file server log file gCoreLog.SetFileHeader("GWLP File Server", "1.0"); if (gFsConfig.logAllMessages) { gCoreLog.Open("Logs/FsCore.txt", LOG_ALL); } else { gCoreLog.Open("Logs/FsCore.txt", LOG_WARNINGS | LOG_ERRORS | LOG_NOTICES); } gCoreLog.SetSpecialDefaults(CATEGORY_OPT, SECTION_OPT, SECTION_OPT_OK, SECTION_OPT_FAIL); gCoreLog.SetLevelDefaults(DEBUG_TEXT, WARNING_TEXT, NOTICE_TEXT, ERROR_TEXT, ALWAYS_TEXT); gCoreLog.WriteCategory("[Initialization]"); //Start the network server gCoreLog.Section("Initializing network server..."); if (gpFileServer!=NULL) { delete gpFileServer; } gpFileServer=new Server; assert(gpFileServer!=NULL); unsigned char* pIp=NULL; if (!gFsConfig.automaticIp) { pIp=gFsConfig.ipAddress; } if (gpFileServer->Init(gFsConfig.port, "FS", pIp, false, &gCoreLog)==-1) { gCoreLog.SectionFail(); return -1; } SERVERCONFIG serv_config; serv_config.notifyOnConnect=true; serv_config.maxConnections=5000; gpFileServer->UpdateServerConfig(serv_config); gpFileServer->Crypto=NULL; gCoreLog.SectionOk(); return 0; }