… | |
… | |
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--; |
|
|
240 | |
239 | if (oldmap->players <= 0) |
241 | if (oldmap->players <= 0) |
240 | { /* can be less than zero due to errors in tracking this */ |
242 | /* can be less than zero due to errors in tracking this */ |
241 | set_map_timeout (oldmap); |
243 | set_map_timeout (oldmap); |
242 | } |
|
|
243 | } |
244 | } |
244 | } |
245 | } |
245 | |
246 | |
246 | /* |
247 | /* |
247 | * enter_map(): Moves the player and pets from current map (if any) to |
248 | * enter_map(): Moves the player and pets from current map (if any) to |
… | |
… | |
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; |
309 | |
310 | |
310 | if (INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr), ARG_INT (x), ARG_INT (y))) |
311 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (op->contr), ARG_INT (x), ARG_INT (y))) |
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 */ |
788 | if (exit_ob) |
788 | if (exit_ob) |
789 | { |
789 | { |
790 | |
|
|
791 | /* check to see if we make a template map */ |
790 | /* check to see if we make a template map */ |
792 | if (EXIT_PATH (exit_ob) && EXIT_PATH (exit_ob)[1] == '@') |
791 | if (EXIT_PATH (exit_ob) && EXIT_PATH (exit_ob)[1] == '@') |
793 | { |
792 | { |
794 | if (EXIT_PATH (exit_ob)[2] == '!') |
793 | if (EXIT_PATH (exit_ob)[2] == '!') |
795 | { |
794 | { |
… | |
… | |
894 | 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)) |
895 | break; |
894 | break; |
896 | } |
895 | } |
897 | if (tmp) |
896 | if (tmp) |
898 | { |
897 | { |
899 | remove_ob (tmp); |
898 | tmp->remove (); |
900 | free_object (tmp); |
899 | tmp->destroy (); |
901 | } |
900 | } |
902 | |
901 | |
903 | 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))); |
904 | 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); |
905 | save_player (op, 1); |
904 | save_player (op, 1); |
… | |
… | |
916 | } |
915 | } |
917 | else |
916 | else |
918 | { |
917 | { |
919 | int flags = 0; |
918 | int flags = 0; |
920 | maptile *newmap; |
919 | maptile *newmap; |
921 | |
|
|
922 | |
920 | |
923 | /* Hypothetically, I guess its possible that a standard map matches |
921 | /* Hypothetically, I guess its possible that a standard map matches |
924 | * the localdir, but that seems pretty unlikely - unlikely enough that |
922 | * the localdir, but that seems pretty unlikely - unlikely enough that |
925 | * I'm not going to attempt to try to deal with that possibility. |
923 | * I'm not going to attempt to try to deal with that possibility. |
926 | * We use the fact that when a player saves on a unique map, it prepends |
924 | * We use the fact that when a player saves on a unique map, it prepends |
… | |
… | |
947 | { |
945 | { |
948 | LOG (llevError, "enter_exit: could not load emergency map? Fatal error\n"); |
946 | LOG (llevError, "enter_exit: could not load emergency map? Fatal error\n"); |
949 | abort (); |
947 | abort (); |
950 | } |
948 | } |
951 | } |
949 | } |
|
|
950 | |
952 | enter_map (op, newmap, op->x, op->y); |
951 | enter_map (op, newmap, op->x, op->y); |
953 | } |
952 | } |
954 | } |
953 | } |
955 | |
954 | |
956 | /* |
955 | /* |
… | |
… | |
1099 | process_events (maptile *map) |
1098 | process_events (maptile *map) |
1100 | { |
1099 | { |
1101 | object *op; |
1100 | object *op; |
1102 | |
1101 | |
1103 | static object *marker; |
1102 | static object *marker; |
|
|
1103 | |
1104 | if (!marker) |
1104 | if (!marker) |
1105 | marker = get_object (); |
1105 | marker = object::create (); |
1106 | |
1106 | |
1107 | process_players1 (map); |
1107 | process_players1 (map); |
1108 | |
1108 | |
1109 | marker->active_next = active_objects; |
1109 | marker->active_next = active_objects; |
1110 | |
1110 | |
… | |
… | |
1154 | * around. |
1154 | * around. |
1155 | */ |
1155 | */ |
1156 | 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) |
1157 | { |
1157 | { |
1158 | LOG (llevError, "BUG: process_events(): Removed object on list\n"); |
1158 | LOG (llevError, "BUG: process_events(): Removed object on list\n"); |
1159 | dump_object (op); |
1159 | char *dump = dump_object (op); |
1160 | LOG (llevError, errmsg); |
1160 | LOG (llevError, dump); |
1161 | free_object (op); |
1161 | free (dump); |
|
|
1162 | op->destroy (); |
1162 | continue; |
1163 | continue; |
1163 | } |
1164 | } |
1164 | |
1165 | |
1165 | if (!op->speed) |
1166 | if (!op->speed) |
1166 | { |
1167 | { |
… | |
… | |
1415 | 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 */ |
1416 | |
1417 | |
1417 | if (!(pticks % 2503)) |
1418 | if (!(pticks % 2503)) |
1418 | fix_weight (); /* Hack to fix weightproblems caused by bugs */ |
1419 | fix_weight (); /* Hack to fix weightproblems caused by bugs */ |
1419 | |
1420 | |
1420 | if (!(pticks % 2521)) |
|
|
1421 | metaserver_update (); /* 2500 ticks is about 5 minutes */ |
|
|
1422 | |
|
|
1423 | if (!(pticks % 5003)) |
1421 | if (!(pticks % 5003)) |
1424 | write_book_archive (); |
1422 | write_book_archive (); |
1425 | |
1423 | |
1426 | if (!(pticks % 5009)) |
1424 | if (!(pticks % 5009)) |
1427 | clean_friendly_list (); |
1425 | clean_friendly_list (); |
… | |
… | |
1453 | main (int argc, char **argv) |
1451 | main (int argc, char **argv) |
1454 | { |
1452 | { |
1455 | settings.argc = argc; |
1453 | settings.argc = argc; |
1456 | settings.argv = argv; |
1454 | settings.argv = argv; |
1457 | |
1455 | |
1458 | cfperl_init (); |
|
|
1459 | |
|
|
1460 | init (argc, argv); |
1456 | init (argc, argv); |
1461 | |
1457 | |
1462 | initPlugins (); |
1458 | initPlugins (); |
1463 | |
1459 | |
1464 | for (;;) |
1460 | for (;;) |