| 3058 | } |
| 3059 | |
| 3060 | int CServer::Run() |
| 3061 | { |
| 3062 | if(m_RunServer == UNINITIALIZED) |
| 3063 | m_RunServer = RUNNING; |
| 3064 | |
| 3065 | m_AuthManager.Init(); |
| 3066 | |
| 3067 | if(Config()->m_Debug) |
| 3068 | { |
| 3069 | g_UuidManager.DebugDump(); |
| 3070 | } |
| 3071 | |
| 3072 | { |
| 3073 | int Size = GameServer()->PersistentClientDataSize(); |
| 3074 | for(auto &Client : m_aClients) |
| 3075 | { |
| 3076 | Client.m_HasPersistentData = false; |
| 3077 | Client.m_pPersistentData = malloc(Size); |
| 3078 | } |
| 3079 | } |
| 3080 | m_pPersistentData = malloc(GameServer()->PersistentDataSize()); |
| 3081 | |
| 3082 | // load map |
| 3083 | if(!LoadMap(Config()->m_SvMap)) |
| 3084 | { |
| 3085 | log_error("server", "failed to load map. mapname='%s'", Config()->m_SvMap); |
| 3086 | return -1; |
| 3087 | } |
| 3088 | |
| 3089 | if(Config()->m_SvSqliteFile[0] != '\0') |
| 3090 | { |
| 3091 | char aFullPath[IO_MAX_PATH_LENGTH]; |
| 3092 | Storage()->GetCompletePath(IStorage::TYPE_SAVE_OR_ABSOLUTE, Config()->m_SvSqliteFile, aFullPath, sizeof(aFullPath)); |
| 3093 | |
| 3094 | if(Config()->m_SvUseSql) |
| 3095 | { |
| 3096 | DbPool()->RegisterSqliteDatabase(CDbConnectionPool::WRITE_BACKUP, aFullPath); |
| 3097 | } |
| 3098 | else |
| 3099 | { |
| 3100 | DbPool()->RegisterSqliteDatabase(CDbConnectionPool::READ, aFullPath); |
| 3101 | DbPool()->RegisterSqliteDatabase(CDbConnectionPool::WRITE, aFullPath); |
| 3102 | } |
| 3103 | } |
| 3104 | |
| 3105 | // start server |
| 3106 | NETADDR BindAddr; |
| 3107 | if(g_Config.m_Bindaddr[0] == '\0') |
| 3108 | { |
| 3109 | mem_zero(&BindAddr, sizeof(BindAddr)); |
| 3110 | } |
| 3111 | else if(net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) != 0) |
| 3112 | { |
| 3113 | log_error("server", "The configured bindaddr '%s' cannot be resolved", g_Config.m_Bindaddr); |
| 3114 | return -1; |
| 3115 | } |
| 3116 | BindAddr.type = Config()->m_SvIpv4Only ? NETTYPE_IPV4 : NETTYPE_ALL; |
| 3117 |
no test coverage detected