1 | /* |
1 | /* |
2 | * static char *rcsid_main_c = |
2 | * static char *rcsid_main_c = |
3 | * "$Id: main.c,v 1.2 2006/02/03 07:25:25 root Exp $"; |
3 | * "$Id: main.c,v 1.9 2006/06/19 10:15:44 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 | |
… | |
… | |
55 | |
55 | |
56 | void version(object *op) { |
56 | void version(object *op) { |
57 | if(op!=NULL) |
57 | if(op!=NULL) |
58 | clear_win_info(op); |
58 | clear_win_info(op); |
59 | |
59 | |
60 | new_draw_info_format(NDI_UNIQUE, 0, op, "This is Crossfire v%s-schmorp-cvs",VERSION); |
60 | new_draw_info_format(NDI_UNIQUE, 0, op, "This is Crossfire v%s",VERSION); |
61 | |
61 | |
62 | /* If in a socket, don't print out the list of authors. It confuses the |
62 | /* If in a socket, don't print out the list of authors. It confuses the |
63 | * crossclient program. |
63 | * crossclient program. |
64 | */ |
64 | */ |
65 | if (op==NULL) return; |
65 | if (op==NULL) return; |
… | |
… | |
511 | exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); |
511 | exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); |
512 | return; |
512 | return; |
513 | } |
513 | } |
514 | *sourcemap++ = '\0'; |
514 | *sourcemap++ = '\0'; |
515 | |
515 | |
516 | /* If we are not coming from a template map, we can use reletive directories |
516 | /* If we are not coming from a template map, we can use relative directories |
517 | * for the map to generate from. |
517 | * for the map to generate from. |
518 | */ |
518 | */ |
519 | if (!exit_ob->map->template) { |
519 | if (!exit_ob->map->template) { |
520 | sourcemap = path_combine_and_normalize(exit_ob->map->path, sourcemap); |
520 | sourcemap = path_combine_and_normalize(exit_ob->map->path, sourcemap); |
521 | } |
521 | } |
… | |
… | |
719 | /* It may be nice to support other creatures moving across |
719 | /* It may be nice to support other creatures moving across |
720 | * exits, but right now a lot of the code looks at op->contr, |
720 | * exits, but right now a lot of the code looks at op->contr, |
721 | * so thta is an RFE. |
721 | * so thta is an RFE. |
722 | */ |
722 | */ |
723 | if (op->type != PLAYER) return; |
723 | if (op->type != PLAYER) return; |
|
|
724 | |
|
|
725 | /* Need to remove player from transport */ |
|
|
726 | if (op->contr->transport) apply_transport(op, op->contr->transport, AP_UNAPPLY); |
724 | |
727 | |
725 | /* First, lets figure out what map the player is going to go to */ |
728 | /* First, lets figure out what map the player is going to go to */ |
726 | if (exit_ob){ |
729 | if (exit_ob){ |
727 | |
730 | |
728 | /* check to see if we make a template map */ |
731 | /* check to see if we make a template map */ |
… | |
… | |
782 | else |
785 | else |
783 | newmap = ready_map_name(EXIT_PATH(exit_ob), 0); |
786 | newmap = ready_map_name(EXIT_PATH(exit_ob), 0); |
784 | } |
787 | } |
785 | if (!newmap) |
788 | if (!newmap) |
786 | { |
789 | { |
|
|
790 | if (exit_ob->name) |
787 | new_draw_info_format(NDI_UNIQUE, 0, op, "The %s is closed.", exit_ob->name); |
791 | new_draw_info_format(NDI_UNIQUE, 0, op, "The %s is closed.", exit_ob->name); |
|
|
792 | /* don't cry to momma if name is not set - as in tmp objects |
|
|
793 | * used by the savebed code and character creation */ |
788 | return; |
794 | return; |
789 | } |
795 | } |
790 | |
796 | |
791 | /* This supports the old behaviour, but it really should not be used. |
797 | /* This supports the old behaviour, but it really should not be used. |
792 | * I will note for example that with this method, it is impossible to |
798 | * I will note for example that with this method, it is impossible to |
… | |
… | |
1188 | if (pl!=NULL) { |
1194 | if (pl!=NULL) { |
1189 | /* We do this so that the socket handling routine can do the final |
1195 | /* We do this so that the socket handling routine can do the final |
1190 | * cleanup. We also leave that loop to actually handle the freeing |
1196 | * cleanup. We also leave that loop to actually handle the freeing |
1191 | * of the data. |
1197 | * of the data. |
1192 | */ |
1198 | */ |
1193 | if (draw_exit==0) |
1199 | execute_global_event(EVENT_LOGOUT, pl, pl->socket.host); |
1194 | { |
1200 | |
1195 | } |
|
|
1196 | pl->socket.status=Ns_Dead; |
1201 | pl->socket.status=Ns_Dead; |
1197 | LOG(llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, |
1202 | LOG(llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, |
1198 | pl->socket.host); |
1203 | pl->socket.host); |
1199 | |
1204 | |
1200 | (void) sprintf(buf,"%s left the game.",pl->ob->name); |
1205 | (void) sprintf(buf,"%s left the game.",pl->ob->name); |
… | |
… | |
1333 | doeric_server(); |
1338 | doeric_server(); |
1334 | process_events(NULL); /* "do" something with objects with speed */ |
1339 | process_events(NULL); /* "do" something with objects with speed */ |
1335 | cftimer_process_timers();/* Process the crossfire Timers */ |
1340 | cftimer_process_timers();/* Process the crossfire Timers */ |
1336 | /* Lauwenmark : Here we handle the CLOCK global event */ |
1341 | /* Lauwenmark : Here we handle the CLOCK global event */ |
1337 | execute_global_event(EVENT_CLOCK); |
1342 | execute_global_event(EVENT_CLOCK); |
|
|
1343 | flush_sockets(); |
1338 | check_active_maps(); /* Removes unused maps after a certain timeout */ |
1344 | check_active_maps(); /* Removes unused maps after a certain timeout */ |
1339 | do_specials(); /* Routines called from time to time. */ |
1345 | do_specials(); /* Routines called from time to time. */ |
1340 | |
1346 | |
1341 | sleep_delta(); /* Slepp proper amount of time before next tick */ |
1347 | sleep_delta(); /* Slepp proper amount of time before next tick */ |
1342 | } |
1348 | } |