… | |
… | |
608 | |
608 | |
609 | /* If we are coming from another template map, use reletive paths unless |
609 | /* If we are coming from another template map, use reletive paths unless |
610 | * indicated otherwise. |
610 | * indicated otherwise. |
611 | */ |
611 | */ |
612 | if (exit_ob->map->templatemap && (resultname[0] != '/')) |
612 | if (exit_ob->map->templatemap && (resultname[0] != '/')) |
613 | { |
|
|
614 | new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname); |
613 | new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname); |
615 | } |
|
|
616 | else |
614 | else |
617 | { |
|
|
618 | new_map_name = create_template_pathname (resultname); |
615 | new_map_name = create_template_pathname (resultname); |
619 | } |
|
|
620 | |
616 | |
621 | new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE); |
617 | new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE); |
622 | if (!new_map) |
618 | if (!new_map) |
623 | { |
619 | { |
624 | memset (&rp, 0, sizeof (RMParms)); |
620 | memset (&rp, 0, sizeof (RMParms)); |
… | |
… | |
874 | tmp->destroy (); |
870 | tmp->destroy (); |
875 | } |
871 | } |
876 | |
872 | |
877 | strcpy (op->contr->savebed_map, path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob))); |
873 | strcpy (op->contr->savebed_map, path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob))); |
878 | op->contr->bed_x = EXIT_X (exit_ob), op->contr->bed_y = EXIT_Y (exit_ob); |
874 | op->contr->bed_x = EXIT_X (exit_ob), op->contr->bed_y = EXIT_Y (exit_ob); |
879 | save_player (op, 1); |
875 | op->contr->save (); |
880 | /* LOG(llevDebug,"enter_exit: Taking damned exit %s to (%d,%d) on map %s\n", |
876 | /* LOG(llevDebug,"enter_exit: Taking damned exit %s to (%d,%d) on map %s\n", |
881 | * exit_ob->name?exit_ob->name:"(none)", exit_ob->x, exit_ob->y, |
877 | * exit_ob->name?exit_ob->name:"(none)", exit_ob->x, exit_ob->y, |
882 | * path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob))); */ |
878 | * path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob))); */ |
883 | } |
879 | } |
884 | |
880 | |
… | |
… | |
968 | /* check for ST_PLAYING state so that we don't try to save off when |
964 | /* check for ST_PLAYING state so that we don't try to save off when |
969 | * the player is logging in. |
965 | * the player is logging in. |
970 | */ |
966 | */ |
971 | if ((pl->last_save_tick + AUTOSAVE) < (uint32) pticks && pl->ns->state == ST_PLAYING) |
967 | if ((pl->last_save_tick + AUTOSAVE) < (uint32) pticks && pl->ns->state == ST_PLAYING) |
972 | { |
968 | { |
973 | save_player (pl->ob, 1); |
969 | pl->ob->contr->save (); |
974 | pl->last_save_tick = pticks; |
970 | pl->last_save_tick = pticks; |
975 | } |
971 | } |
976 | #endif |
972 | #endif |
977 | } /* end of for loop for all the players */ |
973 | } /* end of for loop for all the players */ |
978 | } /* for flag */ |
974 | } /* for flag */ |
… | |
… | |
1197 | { |
1193 | { |
1198 | LOG (llevDebug, "Cleanup called.\n"); |
1194 | LOG (llevDebug, "Cleanup called.\n"); |
1199 | |
1195 | |
1200 | if (init_done) |
1196 | if (init_done) |
1201 | { |
1197 | { |
1202 | for (player *pl = first_player; pl != NULL; pl = pl->next) |
1198 | for (player *pl = first_player; pl; pl = pl->next) |
1203 | save_player (pl->ob, 0); |
1199 | pl->save (1); |
1204 | |
1200 | |
1205 | for (player *pl = first_player; pl != NULL; pl = pl->next) |
1201 | for (player *pl = first_player; pl; pl = pl->next) |
1206 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
1202 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
1207 | leave_map (pl->ob); |
1203 | leave_map (pl->ob); |
1208 | |
1204 | |
1209 | clean_tmp_files (); |
1205 | clean_tmp_files (); |
1210 | write_book_archive (); |
1206 | write_book_archive (); |
… | |
… | |
1221 | void |
1217 | void |
1222 | leave (player *pl, int draw_exit) |
1218 | leave (player *pl, int draw_exit) |
1223 | { |
1219 | { |
1224 | if (pl) |
1220 | if (pl) |
1225 | { |
1221 | { |
|
|
1222 | if (pl->ob->type != DEAD_OBJECT) |
|
|
1223 | { |
|
|
1224 | /* If a hidden dm dropped connection do not create |
|
|
1225 | * inconsistencies by showing that they have left the game |
|
|
1226 | */ |
|
|
1227 | if (!(QUERY_FLAG (pl->ob, FLAG_WIZ) && pl->ob->contr->hidden) |
|
|
1228 | && draw_exit) |
|
|
1229 | { |
|
|
1230 | if (pl->ob->map) |
|
|
1231 | { |
|
|
1232 | INVOKE_PLAYER (LOGOUT, pl); |
|
|
1233 | LOG (llevInfo, "LOGOUT: Player named %s from ip %s\n", &pl->ob->name, pl->ns->host); |
|
|
1234 | } |
|
|
1235 | |
|
|
1236 | char buf[MAX_BUF]; |
|
|
1237 | |
|
|
1238 | sprintf (buf, "%s left the game.", &pl->ob->name); |
|
|
1239 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, 0, buf); |
|
|
1240 | } |
|
|
1241 | |
|
|
1242 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
1243 | leave_map (pl->ob); |
|
|
1244 | |
|
|
1245 | pl->ob->type = DEAD_OBJECT; /* To avoid problems with inventory window */ |
|
|
1246 | } |
|
|
1247 | |
1226 | /* We do this so that the socket handling routine can do the final |
1248 | /* We do this so that the socket handling routine can do the final |
1227 | * cleanup. We also leave that loop to actually handle the freeing |
1249 | * cleanup. We also leave that loop to actually handle the freeing |
1228 | * of the data. |
1250 | * of the data. |
1229 | */ |
1251 | */ |
1230 | if (pl->ns) |
1252 | if (pl->ns) |
1231 | pl->ns->destroy (); |
1253 | pl->ns->destroy (); |
1232 | |
1254 | |
1233 | if (pl->ob->type != DEAD_OBJECT) |
|
|
1234 | { |
|
|
1235 | /* If a hidden dm dropped connection do not create |
|
|
1236 | * inconsistencies by showing that they have left the game |
|
|
1237 | */ |
|
|
1238 | if (!(QUERY_FLAG (pl->ob, FLAG_WIZ) && pl->ob->contr->hidden) |
|
|
1239 | && draw_exit && (pl->ns->state != ST_GET_NAME && pl->ns->state != ST_GET_PASSWORD && pl->ns->state != ST_CONFIRM_PASSWORD)) |
|
|
1240 | { |
|
|
1241 | if (pl->ob->map) |
|
|
1242 | { |
|
|
1243 | INVOKE_PLAYER (LOGOUT, pl); |
|
|
1244 | LOG (llevInfo, "LOGOUT: Player named %s from ip %s\n", &pl->ob->name, pl->ns->host); |
|
|
1245 | } |
|
|
1246 | |
|
|
1247 | char buf[MAX_BUF]; |
|
|
1248 | |
|
|
1249 | sprintf (buf, "%s left the game.", &pl->ob->name); |
|
|
1250 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf); |
|
|
1251 | } |
|
|
1252 | |
|
|
1253 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
1254 | leave_map (pl->ob); |
|
|
1255 | |
|
|
1256 | pl->ob->type = DEAD_OBJECT; /* To avoid problems with inventory window */ |
|
|
1257 | } |
|
|
1258 | } |
1255 | } |
1259 | } |
1256 | } |
1260 | |
1257 | |
1261 | int |
1258 | int |
1262 | forbid_play (void) |
1259 | forbid_play (void) |