1 | /* |
1 | /* |
2 | * static char *rcsid_main_c = |
2 | * static char *rcsid_main_c = |
3 | * "$Id: main.c,v 1.10 2006/06/24 11:30:19 root Exp $"; |
3 | * "$Id: main.c,v 1.15 2006/08/11 12:21:35 elmex 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 | |
… | |
… | |
939 | if ((pl->last_save_tick+AUTOSAVE)<pticks && pl->state==ST_PLAYING) { |
939 | if ((pl->last_save_tick+AUTOSAVE)<pticks && pl->state==ST_PLAYING) { |
940 | /* Don't save the player on unholy ground. Instead, increase the |
940 | /* Don't save the player on unholy ground. Instead, increase the |
941 | * tick time so it will be about 10 seconds before we try and save |
941 | * tick time so it will be about 10 seconds before we try and save |
942 | * again. |
942 | * again. |
943 | */ |
943 | */ |
944 | if (get_map_flags(pl->ob->map, NULL, pl->ob->x, pl->ob->y, NULL, NULL) & P_NO_CLERIC) { |
944 | // if (get_map_flags(pl->ob->map, NULL, pl->ob->x, pl->ob->y, NULL, NULL) & P_NO_CLERIC) { |
945 | pl->last_save_tick += 100; |
945 | // pl->last_save_tick += 100; |
946 | } else { |
946 | // } else { |
947 | save_player(pl->ob,1); |
947 | save_player(pl->ob,1); |
948 | pl->last_save_tick = pticks; |
948 | pl->last_save_tick = pticks; |
949 | } |
949 | // } |
950 | } |
950 | } |
951 | #endif |
951 | #endif |
952 | } /* end of for loop for all the players */ |
952 | } /* end of for loop for all the players */ |
953 | } /* for flag */ |
953 | } /* for flag */ |
954 | for(pl=first_player;pl!=NULL;pl=pl->next) { |
954 | for(pl=first_player;pl!=NULL;pl=pl->next) { |
… | |
… | |
1089 | continue; |
1089 | continue; |
1090 | |
1090 | |
1091 | /* Animate the object. Bug of feature that andim_speed |
1091 | /* Animate the object. Bug of feature that andim_speed |
1092 | * is based on ticks, and not the creatures speed? |
1092 | * is based on ticks, and not the creatures speed? |
1093 | */ |
1093 | */ |
1094 | if (op->anim_speed && op->last_anim >= op->anim_speed) { |
1094 | if (op->anim_speed && op->last_anim >= op->anim_speed) |
|
|
1095 | { |
|
|
1096 | if ((op->type==PLAYER)||(op->type==MONSTER)) |
|
|
1097 | animate_object(op, op->facing); |
|
|
1098 | else |
1095 | animate_object (op, op->direction); |
1099 | animate_object (op, op->direction); |
|
|
1100 | |
1096 | op->last_anim = 1; |
1101 | op->last_anim = 1; |
1097 | } else { |
1102 | } |
|
|
1103 | else |
1098 | op->last_anim++; |
1104 | op->last_anim++; |
1099 | } |
|
|
1100 | |
1105 | |
1101 | if (op->speed_left > 0) { |
1106 | if (op->speed_left > 0) { |
1102 | #if 0 |
1107 | #if 0 |
1103 | /* I've seen occasional crashes in move_symptom() with it |
1108 | /* I've seen occasional crashes in move_symptom() with it |
1104 | * crashing because op is removed - add some debugging to |
1109 | * crashing because op is removed - add some debugging to |
… | |
… | |
1187 | #endif |
1192 | #endif |
1188 | exit(0); |
1193 | exit(0); |
1189 | } |
1194 | } |
1190 | |
1195 | |
1191 | void leave(player *pl, int draw_exit) { |
1196 | void leave(player *pl, int draw_exit) { |
1192 | char buf[MAX_BUF]; |
|
|
1193 | |
|
|
1194 | if (pl!=NULL) { |
1197 | if (pl != NULL) { |
1195 | /* We do this so that the socket handling routine can do the final |
1198 | /* We do this so that the socket handling routine can do the final |
1196 | * cleanup. We also leave that loop to actually handle the freeing |
1199 | * cleanup. We also leave that loop to actually handle the freeing |
1197 | * of the data. |
1200 | * of the data. |
1198 | */ |
1201 | */ |
1199 | if (pl->socket.status != Ns_Dead) |
1202 | if (pl->ob->type != DEAD_OBJECT) |
1200 | { |
1203 | { |
1201 | execute_global_event (EVENT_LOGOUT, pl, pl->socket.host); |
1204 | execute_global_event (EVENT_LOGOUT, pl, pl->socket.host); |
1202 | LOG (llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, pl->socket.host); |
1205 | LOG (llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, pl->socket.host); |
1203 | |
1206 | |
1204 | pl->socket.status=Ns_Dead; |
1207 | pl->socket.status = Ns_Dead; |
1205 | |
1208 | |
|
|
1209 | /* If a hidden dm dropped connection do not create |
|
|
1210 | * inconsistencies by showing that they have left the game |
|
|
1211 | */ |
|
|
1212 | if (!(QUERY_FLAG(pl->ob,FLAG_WIZ) && pl->ob->contr->hidden) |
|
|
1213 | && draw_exit |
|
|
1214 | && (pl->state != ST_GET_NAME && pl->state!=ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) |
|
|
1215 | { |
|
|
1216 | char buf[MAX_BUF]; |
1206 | (void) sprintf(buf,"%s left the game.",pl->ob->name); |
1217 | sprintf (buf, "%s left the game.", pl->ob->name); |
|
|
1218 | new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf); |
|
|
1219 | } |
|
|
1220 | |
|
|
1221 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
1222 | leave_map (pl->ob); |
|
|
1223 | |
|
|
1224 | pl->ob->type = DEAD_OBJECT; /* To avoid problems with inventory window */ |
1207 | } |
1225 | } |
1208 | |
|
|
1209 | if (pl->ob->map) { |
|
|
1210 | if (pl->ob->map->in_memory==MAP_IN_MEMORY) |
|
|
1211 | pl->ob->map->timeout = MAP_TIMEOUT(pl->ob->map); |
|
|
1212 | pl->ob->map->players--; |
|
|
1213 | pl->ob->map=NULL; |
|
|
1214 | } |
|
|
1215 | pl->ob->type = DEAD_OBJECT; /* To avoid problems with inventory window */ |
|
|
1216 | } |
1226 | } |
1217 | /* If a hidden dm dropped connection do not create |
|
|
1218 | * inconsistencies by showing that they have left the game |
|
|
1219 | */ |
|
|
1220 | if (!(QUERY_FLAG(pl->ob,FLAG_WIZ) && pl->ob->contr->hidden) && |
|
|
1221 | (pl!=NULL && draw_exit) && |
|
|
1222 | (pl->state != ST_GET_NAME && pl->state!=ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) |
|
|
1223 | new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf); |
|
|
1224 | } |
1227 | } |
1225 | |
1228 | |
1226 | int forbid_play(void) |
1229 | int forbid_play(void) |
1227 | { |
1230 | { |
1228 | #if !defined(_IBMR2) && !defined(___IBMR2) && defined(PERM_FILE) |
1231 | #if !defined(_IBMR2) && !defined(___IBMR2) && defined(PERM_FILE) |