1 | /* |
1 | /* |
2 | * static char *rcsid_main_c = |
2 | * static char *rcsid_main_c = |
3 | * "$Id: main.C,v 1.1 2006/08/13 17:16:04 elmex Exp $"; |
3 | * "$Id: main.C,v 1.4 2006/08/24 13:13:49 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
356 | if (oldmap->players <= 0) /* can be less than zero due to errors in tracking this */ |
356 | if (oldmap->players <= 0) /* can be less than zero due to errors in tracking this */ |
357 | set_map_timeout(oldmap); |
357 | set_map_timeout(oldmap); |
358 | } |
358 | } |
359 | } |
359 | } |
360 | swap_below_max (newmap->path); |
360 | swap_below_max (newmap->path); |
361 | |
|
|
362 | if( op->type == PLAYER) |
|
|
363 | MapNewmapCmd( op->contr); |
|
|
364 | } |
361 | } |
365 | |
362 | |
366 | void set_map_timeout(mapstruct *oldmap) |
363 | void set_map_timeout(mapstruct *oldmap) |
367 | { |
364 | { |
368 | #if MAP_MAXTIMEOUT |
365 | #if MAP_MAXTIMEOUT |
… | |
… | |
872 | } |
869 | } |
873 | |
870 | |
874 | /* |
871 | /* |
875 | * process_active_maps(): Works like process_events(), but it only |
872 | * process_active_maps(): Works like process_events(), but it only |
876 | * processes maps which a player is on. |
873 | * processes maps which a player is on. |
877 | * It will check that it isn't called too often, and abort |
|
|
878 | * if time since last call is less than MAX_TIME. |
|
|
879 | * |
874 | * |
880 | */ |
875 | */ |
881 | |
876 | |
|
|
877 | #if 0 // dead code, schmorp |
882 | void process_active_maps(void) { |
878 | void process_active_maps () |
883 | mapstruct *map; |
879 | { |
884 | |
|
|
885 | |
|
|
886 | /* |
|
|
887 | * If enough time has elapsed, do some work. |
|
|
888 | */ |
|
|
889 | if(enough_elapsed_time()) { |
|
|
890 | for(map=first_map;map!=NULL;map=map->next) { |
880 | for (mapstruct *map = first_map; map != NULL; map = map->next) |
891 | if(map->in_memory == MAP_IN_MEMORY) { |
881 | if (map->in_memory == MAP_IN_MEMORY) |
892 | if(players_on_map(map,TRUE)) |
882 | if (players_on_map (map, TRUE)) |
893 | process_events(map); |
883 | process_events (map); |
894 | } |
|
|
895 | } |
|
|
896 | } |
|
|
897 | } |
884 | } |
|
|
885 | #endif |
898 | |
886 | |
899 | /* process_players1 and process_players2 do all the player related stuff. |
887 | /* process_players1 and process_players2 do all the player related stuff. |
900 | * I moved it out of process events and process_map. This was to some |
888 | * I moved it out of process events and process_map. This was to some |
901 | * extent for debugging as well as to get a better idea of the time used |
889 | * extent for debugging as well as to get a better idea of the time used |
902 | * by the various functions. process_players1() does the processing before |
890 | * by the various functions. process_players1() does the processing before |
… | |
… | |
1316 | |
1304 | |
1317 | if (!(pticks % 12503)) |
1305 | if (!(pticks % 12503)) |
1318 | fix_luck(); |
1306 | fix_luck(); |
1319 | } |
1307 | } |
1320 | |
1308 | |
|
|
1309 | void server_tick () |
|
|
1310 | { |
|
|
1311 | nroferrors = 0; |
|
|
1312 | |
|
|
1313 | doeric_server(); |
|
|
1314 | process_events(NULL); /* "do" something with objects with speed */ |
|
|
1315 | cftimer_process_timers();/* Process the crossfire Timers */ |
|
|
1316 | /* Lauwenmark : Here we handle the CLOCK global event */ |
|
|
1317 | execute_global_event(EVENT_CLOCK); |
|
|
1318 | flush_sockets(); |
|
|
1319 | check_active_maps(); /* Removes unused maps after a certain timeout */ |
|
|
1320 | do_specials(); /* Routines called from time to time. */ |
|
|
1321 | } |
|
|
1322 | |
1321 | int main(int argc, char **argv) |
1323 | int main(int argc, char **argv) |
1322 | { |
1324 | { |
1323 | #ifdef WIN32 /* ---win32 this sets the win32 from 0d0a to 0a handling */ |
1325 | #ifdef WIN32 /* ---win32 this sets the win32 from 0d0a to 0a handling */ |
1324 | _fmode = _O_BINARY ; |
1326 | _fmode = _O_BINARY ; |
1325 | bRunning = 1; |
1327 | bRunning = 1; |
… | |
… | |
1331 | |
1333 | |
1332 | settings.argc=argc; |
1334 | settings.argc=argc; |
1333 | settings.argv=argv; |
1335 | settings.argv=argv; |
1334 | init(argc, argv); |
1336 | init(argc, argv); |
1335 | initPlugins(); /* GROS - Init the Plugins */ |
1337 | initPlugins(); /* GROS - Init the Plugins */ |
1336 | #ifdef WIN32 |
|
|
1337 | while ( bRunning ) |
|
|
1338 | { |
|
|
1339 | #else |
|
|
1340 | for(;;) { |
|
|
1341 | #endif |
|
|
1342 | nroferrors = 0; |
|
|
1343 | |
1338 | |
1344 | doeric_server(); |
1339 | cfperl_main (); |
1345 | process_events(NULL); /* "do" something with objects with speed */ |
|
|
1346 | cftimer_process_timers();/* Process the crossfire Timers */ |
|
|
1347 | /* Lauwenmark : Here we handle the CLOCK global event */ |
|
|
1348 | execute_global_event(EVENT_CLOCK); |
|
|
1349 | flush_sockets(); |
|
|
1350 | check_active_maps(); /* Removes unused maps after a certain timeout */ |
|
|
1351 | do_specials(); /* Routines called from time to time. */ |
|
|
1352 | |
1340 | |
1353 | sleep_delta(); /* Slepp proper amount of time before next tick */ |
|
|
1354 | } |
|
|
1355 | emergency_save( 0 ); |
1341 | emergency_save( 0 ); |
1356 | cleanup( ); |
1342 | cleanup( ); |
1357 | return 0; |
1343 | return 0; |
1358 | } |
1344 | } |