| 4898 | } |
| 4899 | |
| 4900 | void initserver(bool dedicated) |
| 4901 | { |
| 4902 | copystring(servpubkey, ""); |
| 4903 | if(scl.ssk && hex2bin(ssk, scl.ssk, 32) != 32) scl.ssk = NULL; |
| 4904 | ed25519_pubkey_from_private(spk, ssk); |
| 4905 | bin2hex(servpubkey, spk, 32); |
| 4906 | sg->smapname[0] = '\0'; |
| 4907 | servparallfun(); |
| 4908 | |
| 4909 | // init server parameters from commandline |
| 4910 | if(scl.demopath) initserverparameter("demo_path", scl.demopath); |
| 4911 | if(scl.maxdemos > 0) initserverparameter("demo_max_number", scl.maxdemos); |
| 4912 | |
| 4913 | // start logging |
| 4914 | initserverparameter("logthreshold_console", scl.verbose > 1 ? ACLOG_DEBUG : (scl.verbose ? ACLOG_VERBOSE : ACLOG_INFO)); |
| 4915 | initserverparameter("logthreshold_syslog", scl.syslogthres); |
| 4916 | initserverparameter("logthreshold_file", scl.filethres); |
| 4917 | if((isdedicated = dedicated)) |
| 4918 | { |
| 4919 | restartlogging(); |
| 4920 | if(!logcheck(ACLOG_ERROR)) printf("WARNING: logging not started!\n"); |
| 4921 | } |
| 4922 | mlog(ACLOG_INFO, "logging local AssaultCube server (version %d, protocol %d/%d) now..", AC_VERSION, SERVER_PROTOCOL_VERSION, EXT_VERSION); |
| 4923 | |
| 4924 | copystring(sg->servdesc_current, scl.servdesc_full); |
| 4925 | servermsinit(dedicated); |
| 4926 | |
| 4927 | if(isdedicated) |
| 4928 | { |
| 4929 | serverparameters.init(scl.parfilepath); |
| 4930 | if(serverparameters.load()) serverparameters.read(); // do this early, so the parameters are properly set during initialisation |
| 4931 | ENetAddress address = { ENET_HOST_ANY, (enet_uint16)scl.serverport }; |
| 4932 | if(scl.ip[0] && enet_address_set_host(&address, scl.ip)<0) mlog(ACLOG_WARNING, "server ip not resolved!"); |
| 4933 | serverhost = enet_host_create(&address, scl.maxclients+1, 3, 0, scl.uprate); |
| 4934 | if(!serverhost) fatal("could not create server host"); |
| 4935 | loopi(scl.maxclients) serverhost->peers[i].data = (void *)-1; |
| 4936 | |
| 4937 | if(scl.ssk) mlog(ACLOG_INFO,"server public key: %s", servpubkey); |
| 4938 | formatstring(vitafilename)("%s.cfg", scl.vitabasename); |
| 4939 | formatstring(vitafilename_backup)("%s_bak.cfg", scl.vitabasename); |
| 4940 | formatstring(vitafilename_update)("%s_update.cfg", scl.vitabasename); |
| 4941 | formatstring(vitafilename_update_backup_base)("%s_update_", scl.vitabasename); |
| 4942 | path(vitafilename); path(vitafilename_backup); path(vitafilename_update); path(vitafilename_update_backup_base); |
| 4943 | char *vn; |
| 4944 | int gotvitas = readvitas((vn = vitafilename)); |
| 4945 | if(gotvitas < 0) gotvitas = readvitas((vn = vitafilename_backup)); |
| 4946 | if(gotvitas >= 0) mlog(ACLOG_INFO, "read %d player vitas from %s", gotvitas, vn); |
| 4947 | maprot.init(scl.maprotfile); |
| 4948 | passwords.init(scl.pwdfile, scl.adminpasswd); |
| 4949 | ipblacklist.init(scl.blfile); |
| 4950 | geoiplist.init(scl.geoipfile); |
| 4951 | nickblacklist.init(scl.nbfile); |
| 4952 | forbiddenlist.init(scl.forbidden); |
| 4953 | serverinfoinfo.init(scl.infopath, MAXTRANS / 2); |
| 4954 | serverinfomotd.init(scl.motdpath, MAXSTRLEN - 5); |
| 4955 | mlog(ACLOG_VERBOSE, "holding up to %d recorded demos in memory", demo_max_number); |
| 4956 | if(demo_save) mlog(ACLOG_VERBOSE,"all recorded demos will be written to: \"%s\"", demo_path); |
| 4957 | if(scl.voteperm[0]) mlog(ACLOG_VERBOSE,"vote permission string: \"%s\"", scl.voteperm); |
no test coverage detected