| 699 | } |
| 700 | |
| 701 | int main(int argc, char **argv) |
| 702 | { |
| 703 | if(enet_initialize()<0) fatal("Unable to initialise network module"); |
| 704 | atexit(enet_deinitialize); |
| 705 | |
| 706 | const char *dir = "", *ip = AC_MASTER_URI; |
| 707 | int port = AC_MASTER_PORT; |
| 708 | if(argc>=2) dir = argv[1]; |
| 709 | if(argc>=3 && argv[2][0]) port = atoi(argv[2]); |
| 710 | if(argc>=4) ip = argv[3][0] ? argv[3] : NULL; |
| 711 | defformatstring(logname)("%smaster.log", dir); |
| 712 | defformatstring(cfgname)("%smaster.cfg", dir); |
| 713 | path(logname); |
| 714 | path(cfgname); |
| 715 | logfile = fopen(logname, "a"); |
| 716 | if(!logfile) logfile = stdout; |
| 717 | setvbuf(logfile, NULL, _IOLBF, 0); |
| 718 | #ifndef WIN32 |
| 719 | signal(SIGUSR1, reloadsignal); |
| 720 | #endif |
| 721 | setupserver(port, ip); |
| 722 | for(;;) |
| 723 | { |
| 724 | if(reloadcfg) |
| 725 | { |
| 726 | conoutf("reloading master.cfg"); |
| 727 | execfile(cfgname); |
| 728 | bangameservers(); |
| 729 | banclients(); |
| 730 | gengbanlist(); |
| 731 | reloadcfg = false; |
| 732 | } |
| 733 | |
| 734 | servtime = enet_time_get(); |
| 735 | checkclients(); |
| 736 | checkgameservers(); |
| 737 | } |
| 738 | |
| 739 | return EXIT_SUCCESS; |
| 740 | } |
| 741 |
no test coverage detected