1 | /* |
1 | /* |
2 | * static char *rcsid_main_c = |
2 | * static char *rcsid_main_c = |
3 | * "$Id: main.C,v 1.6 2006/08/25 13:24:50 root Exp $"; |
3 | * "$Id: main.C,v 1.13 2006/08/29 07:34:00 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 | |
… | |
… | |
280 | LOG(llevInfo,"enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", |
280 | LOG(llevInfo,"enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", |
281 | newmap->path, x , y); |
281 | newmap->path, x , y); |
282 | } |
282 | } |
283 | } /* end if looking for free spot */ |
283 | } /* end if looking for free spot */ |
284 | |
284 | |
|
|
285 | if (op->map!=NULL) |
|
|
286 | { |
|
|
287 | INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (op->map), ARG_MAP (newmap)); |
|
|
288 | INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr)); |
|
|
289 | } |
285 | |
290 | |
286 | /* If it is a player login, he has yet to be inserted anyplace. |
291 | /* If it is a player login, he has yet to be inserted anyplace. |
287 | * otherwise, we need to deal with removing the playe here. |
292 | * otherwise, we need to deal with removing the player here. |
288 | */ |
293 | */ |
289 | if(!QUERY_FLAG(op, FLAG_REMOVED)) |
294 | if(!QUERY_FLAG(op, FLAG_REMOVED)) |
290 | remove_ob(op); |
295 | remove_ob(op); |
291 | |
|
|
292 | if (op->map!=NULL) |
|
|
293 | INVOKE_PLAYER (LEAVE, op->contr); |
|
|
294 | |
296 | |
295 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
297 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
296 | op->x = x; |
298 | op->x = x; |
297 | op->y = y; |
299 | op->y = y; |
298 | op->map = newmap; |
300 | op->map = newmap; |
299 | insert_ob_in_map(op,op->map,NULL,INS_NO_WALK_ON); |
301 | insert_ob_in_map(op,op->map,NULL,INS_NO_WALK_ON); |
300 | |
302 | |
301 | INVOKE_PLAYER (ENTER, op->contr); |
303 | INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr)); |
302 | |
304 | |
303 | if (!op->contr->hidden) |
305 | if (!op->contr->hidden) |
304 | newmap->players++; |
306 | newmap->players++; |
305 | |
307 | |
306 | newmap->timeout=0; |
308 | newmap->timeout=0; |
… | |
… | |
714 | /* It may be nice to support other creatures moving across |
716 | /* It may be nice to support other creatures moving across |
715 | * exits, but right now a lot of the code looks at op->contr, |
717 | * exits, but right now a lot of the code looks at op->contr, |
716 | * so thta is an RFE. |
718 | * so thta is an RFE. |
717 | */ |
719 | */ |
718 | if (op->type != PLAYER) return; |
720 | if (op->type != PLAYER) return; |
719 | |
|
|
720 | /* Need to remove player from transport */ |
|
|
721 | if (op->contr->transport) apply_transport(op, op->contr->transport, AP_UNAPPLY); |
|
|
722 | |
721 | |
723 | /* First, lets figure out what map the player is going to go to */ |
722 | /* First, lets figure out what map the player is going to go to */ |
724 | if (exit_ob){ |
723 | if (exit_ob){ |
725 | |
724 | |
726 | /* check to see if we make a template map */ |
725 | /* check to see if we make a template map */ |
… | |
… | |
1310 | void server_tick () |
1309 | void server_tick () |
1311 | { |
1310 | { |
1312 | nroferrors = 0; |
1311 | nroferrors = 0; |
1313 | |
1312 | |
1314 | doeric_server(); |
1313 | doeric_server(); |
|
|
1314 | INVOKE_GLOBAL (CLOCK); |
1315 | process_events(NULL); /* "do" something with objects with speed */ |
1315 | process_events(NULL); /* "do" something with objects with speed */ |
1316 | cftimer_process_timers();/* Process the crossfire Timers */ |
|
|
1317 | /* Lauwenmark : Here we handle the CLOCK global event */ |
|
|
1318 | execute_global_event(EVENT_CLOCK); |
|
|
1319 | flush_sockets(); |
1316 | flush_sockets(); |
1320 | check_active_maps(); /* Removes unused maps after a certain timeout */ |
1317 | check_active_maps(); /* Removes unused maps after a certain timeout */ |
1321 | do_specials(); /* Routines called from time to time. */ |
1318 | do_specials(); /* Routines called from time to time. */ |
1322 | |
1319 | |
1323 | ++pticks; |
1320 | ++pticks; |
1324 | } |
1321 | } |
1325 | |
1322 | |
1326 | static void plugin_load_original_map(mapstruct *map) |
|
|
1327 | { |
|
|
1328 | INVOKE_MAP (LOAD, map); |
|
|
1329 | } |
|
|
1330 | |
|
|
1331 | static void plugin_load_temporary_map(mapstruct *map) |
|
|
1332 | { |
|
|
1333 | INVOKE_MAP (SWAPIN, map); |
|
|
1334 | } |
|
|
1335 | |
|
|
1336 | static void plugin_clean_temporary_map(mapstruct *map) |
|
|
1337 | { |
|
|
1338 | INVOKE_MAP (CLEAN, map); |
|
|
1339 | } |
|
|
1340 | |
|
|
1341 | static void plugin_object_free(object *ob) |
|
|
1342 | { |
|
|
1343 | cfperl_free_ob (ob); |
|
|
1344 | } |
|
|
1345 | |
|
|
1346 | int main(int argc, char **argv) |
1323 | int main(int argc, char **argv) |
1347 | { |
1324 | { |
1348 | settings.argc = argc; |
1325 | settings.argc = argc; |
1349 | settings.argv = argv; |
1326 | settings.argv = argv; |
1350 | |
1327 | |
1351 | init (argc, argv); |
1328 | init (argc, argv); |
1352 | |
1329 | |
1353 | initPlugins (); /* GROS - Init the Plugins */ |
|
|
1354 | |
|
|
1355 | load_original_map_callback = plugin_load_original_map; |
|
|
1356 | load_temporary_map_callback = plugin_load_temporary_map; |
|
|
1357 | clean_temporary_map_callback = plugin_clean_temporary_map; |
|
|
1358 | object_free_callback = plugin_object_free; |
|
|
1359 | |
|
|
1360 | cfperl_init (); |
1330 | cfperl_init (); |
|
|
1331 | initPlugins (); |
1361 | |
1332 | |
1362 | for (;;) |
1333 | for (;;) |
1363 | cfperl_main (); |
1334 | cfperl_main (); |
1364 | |
1335 | |
1365 | // unreached |
1336 | // unreached |