… | |
… | |
158 | * simple case at top - no encryption - makes it easier to read. |
158 | * simple case at top - no encryption - makes it easier to read. |
159 | */ |
159 | */ |
160 | char * |
160 | char * |
161 | crypt_string (char *str, char *salt) |
161 | crypt_string (char *str, char *salt) |
162 | { |
162 | { |
163 | #if defined(WIN32) || (defined(__FreeBSD__) && !defined(HAVE_LIBDES)) |
163 | #if (defined(__FreeBSD__) && !defined(HAVE_LIBDES)) |
164 | return (str); |
164 | return (str); |
165 | #else |
165 | #else |
166 | static char *c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; |
166 | static char *c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; |
167 | char s[2]; |
167 | char s[2]; |
168 | |
168 | |
… | |
… | |
194 | enter_player_savebed (object *op) |
194 | enter_player_savebed (object *op) |
195 | { |
195 | { |
196 | maptile *oldmap = op->map; |
196 | maptile *oldmap = op->map; |
197 | object *tmp; |
197 | object *tmp; |
198 | |
198 | |
199 | tmp = get_object (); |
199 | tmp = object::create (); |
200 | |
200 | |
201 | EXIT_PATH (tmp) = op->contr->savebed_map; |
201 | EXIT_PATH (tmp) = op->contr->savebed_map; |
202 | EXIT_X (tmp) = op->contr->bed_x; |
202 | EXIT_X (tmp) = op->contr->bed_x; |
203 | EXIT_Y (tmp) = op->contr->bed_y; |
203 | EXIT_Y (tmp) = op->contr->bed_y; |
204 | enter_exit (op, tmp); |
204 | enter_exit (op, tmp); |
… | |
… | |
217 | EXIT_PATH (tmp) = op->contr->savebed_map; |
217 | EXIT_PATH (tmp) = op->contr->savebed_map; |
218 | EXIT_X (tmp) = op->contr->bed_x; |
218 | EXIT_X (tmp) = op->contr->bed_x; |
219 | EXIT_Y (tmp) = op->contr->bed_y; |
219 | EXIT_Y (tmp) = op->contr->bed_y; |
220 | enter_exit (op, tmp); |
220 | enter_exit (op, tmp); |
221 | } |
221 | } |
222 | free_object (tmp); |
222 | |
|
|
223 | tmp->destroy (); |
223 | } |
224 | } |
224 | |
225 | |
225 | /* All this really is is a glorified remove_object that also updates |
226 | /* All this really is is a glorified remove_object that also updates |
226 | * the counts on the map if needed. |
227 | * the counts on the map if needed. |
227 | */ |
228 | */ |
228 | void |
229 | void |
229 | leave_map (object *op) |
230 | leave_map (object *op) |
230 | { |
231 | { |
231 | maptile *oldmap = op->map; |
232 | maptile *oldmap = op->map; |
232 | |
233 | |
233 | remove_ob (op); |
234 | op->remove (); |
234 | |
235 | |
235 | if (oldmap) |
236 | if (oldmap) |
236 | { |
237 | { |
237 | if (!op->contr->hidden) |
238 | if (!op->contr->hidden) |
238 | oldmap->players--; |
239 | oldmap->players--; |
… | |
… | |
298 | /* not much we can do in this case. */ |
299 | /* not much we can do in this case. */ |
299 | LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", newmap->path, x, y); |
300 | LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", newmap->path, x, y); |
300 | } |
301 | } |
301 | } /* end if looking for free spot */ |
302 | } /* end if looking for free spot */ |
302 | |
303 | |
303 | if (op->map != NULL) |
304 | if (op->map) |
304 | if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr))) |
305 | if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr))) |
305 | return; |
306 | return; |
306 | |
307 | |
307 | if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
308 | if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
308 | return; |
309 | return; |
… | |
… | |
311 | return; |
312 | return; |
312 | |
313 | |
313 | /* If it is a player login, he has yet to be inserted anyplace. |
314 | /* If it is a player login, he has yet to be inserted anyplace. |
314 | * otherwise, we need to deal with removing the player here. |
315 | * otherwise, we need to deal with removing the player here. |
315 | */ |
316 | */ |
316 | remove_ob (op); |
317 | op->remove (); |
317 | |
318 | |
318 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
319 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
319 | op->x = x; |
320 | op->x = x; |
320 | op->y = y; |
321 | op->y = y; |
321 | op->map = newmap; |
322 | op->map = newmap; |
… | |
… | |
338 | if (op->type == PLAYER && op->contr->ranges[range_golem] != NULL) |
339 | if (op->type == PLAYER && op->contr->ranges[range_golem] != NULL) |
339 | { |
340 | { |
340 | int i = find_free_spot (op->contr->ranges[range_golem], newmap, |
341 | int i = find_free_spot (op->contr->ranges[range_golem], newmap, |
341 | x, y, 1, SIZEOFFREE); |
342 | x, y, 1, SIZEOFFREE); |
342 | |
343 | |
343 | remove_ob (op->contr->ranges[range_golem]); |
344 | op->contr->ranges[range_golem]->remove (); |
344 | |
345 | |
345 | if (i == -1) |
346 | if (i == -1) |
346 | { |
347 | { |
347 | remove_friendly_object (op->contr->ranges[range_golem]); |
348 | remove_friendly_object (op->contr->ranges[range_golem]); |
348 | free_object (op->contr->ranges[range_golem]); |
349 | op->contr->ranges[range_golem]->destroy (); |
349 | op->contr->ranges[range_golem] = NULL; |
350 | op->contr->ranges[range_golem] = 0; |
350 | op->contr->golem_count = 0; |
|
|
351 | } |
351 | } |
352 | else |
352 | else |
353 | { |
353 | { |
354 | for (object *tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more) |
354 | for (object *tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more) |
355 | { |
355 | { |
… | |
… | |
777 | #define PORTAL_DESTINATION_NAME "Town portal destination" /* this one should really be in a header file */ |
777 | #define PORTAL_DESTINATION_NAME "Town portal destination" /* this one should really be in a header file */ |
778 | object *tmp; |
778 | object *tmp; |
779 | |
779 | |
780 | /* It may be nice to support other creatures moving across |
780 | /* It may be nice to support other creatures moving across |
781 | * exits, but right now a lot of the code looks at op->contr, |
781 | * exits, but right now a lot of the code looks at op->contr, |
782 | * so thta is an RFE. |
782 | * so that is an RFE. |
783 | */ |
783 | */ |
784 | if (op->type != PLAYER) |
784 | if (op->type != PLAYER) |
785 | return; |
785 | return; |
786 | |
786 | |
787 | /* First, lets figure out what map the player is going to go to */ |
787 | /* First, lets figure out what map the player is going to go to */ |
… | |
… | |
893 | if (tmp->type == FORCE && tmp->slaying && !strcmp (tmp->slaying, PORTAL_DESTINATION_NAME)) |
893 | if (tmp->type == FORCE && tmp->slaying && !strcmp (tmp->slaying, PORTAL_DESTINATION_NAME)) |
894 | break; |
894 | break; |
895 | } |
895 | } |
896 | if (tmp) |
896 | if (tmp) |
897 | { |
897 | { |
898 | remove_ob (tmp); |
898 | tmp->remove (); |
899 | free_object (tmp); |
899 | tmp->destroy (); |
900 | } |
900 | } |
901 | |
901 | |
902 | strcpy (op->contr->savebed_map, path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob))); |
902 | strcpy (op->contr->savebed_map, path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob))); |
903 | op->contr->bed_x = EXIT_X (exit_ob), op->contr->bed_y = EXIT_Y (exit_ob); |
903 | op->contr->bed_x = EXIT_X (exit_ob), op->contr->bed_y = EXIT_Y (exit_ob); |
904 | save_player (op, 1); |
904 | save_player (op, 1); |
… | |
… | |
1098 | process_events (maptile *map) |
1098 | process_events (maptile *map) |
1099 | { |
1099 | { |
1100 | object *op; |
1100 | object *op; |
1101 | |
1101 | |
1102 | static object *marker; |
1102 | static object *marker; |
|
|
1103 | |
1103 | if (!marker) |
1104 | if (!marker) |
1104 | marker = get_object (); |
1105 | marker = object::create (); |
1105 | |
1106 | |
1106 | process_players1 (map); |
1107 | process_players1 (map); |
1107 | |
1108 | |
1108 | marker->active_next = active_objects; |
1109 | marker->active_next = active_objects; |
1109 | |
1110 | |
… | |
… | |
1153 | * around. |
1154 | * around. |
1154 | */ |
1155 | */ |
1155 | if (QUERY_FLAG (op, FLAG_REMOVED) && op->type != PLAYER && op->map && op->map->in_memory != MAP_IN_MEMORY) |
1156 | if (QUERY_FLAG (op, FLAG_REMOVED) && op->type != PLAYER && op->map && op->map->in_memory != MAP_IN_MEMORY) |
1156 | { |
1157 | { |
1157 | LOG (llevError, "BUG: process_events(): Removed object on list\n"); |
1158 | LOG (llevError, "BUG: process_events(): Removed object on list\n"); |
1158 | dump_object (op); |
1159 | char *dump = dump_object (op); |
1159 | LOG (llevError, errmsg); |
1160 | LOG (llevError, dump); |
1160 | free_object (op); |
1161 | free (dump); |
|
|
1162 | op->destroy (); |
1161 | continue; |
1163 | continue; |
1162 | } |
1164 | } |
1163 | |
1165 | |
1164 | if (!op->speed) |
1166 | if (!op->speed) |
1165 | { |
1167 | { |
… | |
… | |
1299 | * cleanup. We also leave that loop to actually handle the freeing |
1301 | * cleanup. We also leave that loop to actually handle the freeing |
1300 | * of the data. |
1302 | * of the data. |
1301 | */ |
1303 | */ |
1302 | if (pl->ob->type != DEAD_OBJECT) |
1304 | if (pl->ob->type != DEAD_OBJECT) |
1303 | { |
1305 | { |
1304 | pl->socket.status = Ns_Dead; |
1306 | pl->socket->status = Ns_Dead; |
1305 | |
1307 | |
1306 | /* If a hidden dm dropped connection do not create |
1308 | /* If a hidden dm dropped connection do not create |
1307 | * inconsistencies by showing that they have left the game |
1309 | * inconsistencies by showing that they have left the game |
1308 | */ |
1310 | */ |
1309 | if (!(QUERY_FLAG (pl->ob, FLAG_WIZ) && pl->ob->contr->hidden) |
1311 | if (!(QUERY_FLAG (pl->ob, FLAG_WIZ) && pl->ob->contr->hidden) |
1310 | && draw_exit && (pl->state != ST_GET_NAME && pl->state != ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) |
1312 | && draw_exit && (pl->state != ST_GET_NAME && pl->state != ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) |
1311 | { |
1313 | { |
1312 | if (pl->ob->map) |
1314 | if (pl->ob->map) |
1313 | { |
1315 | { |
1314 | INVOKE_PLAYER (LOGOUT, pl); |
1316 | INVOKE_PLAYER (LOGOUT, pl); |
1315 | LOG (llevInfo, "LOGOUT: Player named %s from ip %s\n", &pl->ob->name, pl->socket.host); |
1317 | LOG (llevInfo, "LOGOUT: Player named %s from ip %s\n", &pl->ob->name, pl->socket->host); |
1316 | } |
1318 | } |
1317 | |
1319 | |
1318 | char buf[MAX_BUF]; |
1320 | char buf[MAX_BUF]; |
1319 | |
1321 | |
1320 | sprintf (buf, "%s left the game.", &pl->ob->name); |
1322 | sprintf (buf, "%s left the game.", &pl->ob->name); |
… | |
… | |
1414 | flush_old_maps (); /* Clears the tmp-files of maps which have reset */ |
1416 | flush_old_maps (); /* Clears the tmp-files of maps which have reset */ |
1415 | |
1417 | |
1416 | if (!(pticks % 2503)) |
1418 | if (!(pticks % 2503)) |
1417 | fix_weight (); /* Hack to fix weightproblems caused by bugs */ |
1419 | fix_weight (); /* Hack to fix weightproblems caused by bugs */ |
1418 | |
1420 | |
1419 | if (!(pticks % 2521)) |
|
|
1420 | metaserver_update (); /* 2500 ticks is about 5 minutes */ |
|
|
1421 | |
|
|
1422 | if (!(pticks % 5003)) |
1421 | if (!(pticks % 5003)) |
1423 | write_book_archive (); |
1422 | write_book_archive (); |
1424 | |
1423 | |
1425 | if (!(pticks % 5009)) |
1424 | if (!(pticks % 5009)) |
1426 | clean_friendly_list (); |
1425 | clean_friendly_list (); |