| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "global.h" |
| 20 |
|
| 21 |
#include <string.h> |
| 22 |
|
| 23 |
#include "ob_methods.h" |
| 24 |
#include "ob_types.h" |
| 25 |
#include "sounds.h" |
| 26 |
#include "sproto.h" |
| 27 |
|
| 28 |
static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags); |
| 29 |
static void apply_savebed(object *pl); |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
void init_type_savebed(void) { |
| 35 |
register_apply(SAVEBED, savebed_type_apply); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags) { |
| 48 |
if (applier->type == PLAYER) |
| 49 |
apply_savebed(applier); |
| 50 |
return METHOD_OK; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
static void apply_savebed(object *pl) { |
| 60 |
|
| 61 |
if (!pl->stats.exp) { |
| 62 |
draw_ext_info_format(NDI_UNIQUE | NDI_RED, 5, pl, |
| 63 |
MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOADSAVE, |
| 64 |
"You must gain a bit of experience before you can save."); |
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
execute_global_event(EVENT_LOGOUT, pl->contr, pl->contr->socket.host); |
| 70 |
|
| 71 |
|
| 72 |
pets_terminate_all(pl); |
| 73 |
object_remove(pl); |
| 74 |
pl->direction = 0; |
| 75 |
draw_ext_info_format(NDI_UNIQUE|NDI_ALL|NDI_DK_ORANGE, 5, pl, |
| 76 |
MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_PLAYER, |
| 77 |
"%s leaves the game.", pl->name); |
| 78 |
|
| 79 |
|
| 80 |
safe_strncpy(pl->contr->savebed_map, pl->map->path, |
| 81 |
sizeof(pl->contr->savebed_map)); |
| 82 |
pl->contr->bed_x = pl->x; |
| 83 |
pl->contr->bed_y = pl->y; |
| 84 |
|
| 85 |
strcpy(pl->contr->killer, "left"); |
| 86 |
hiscore_check(pl, 0); |
| 87 |
save_player(pl, 0); |
| 88 |
party_leave(pl); |
| 89 |
#if MAP_MAXTIMEOUT |
| 90 |
MAP_SWAP_TIME(pl->map) = MAP_TIMEOUT(pl->map); |
| 91 |
#endif |
| 92 |
play_again(pl); |
| 93 |
pl->speed = 0; |
| 94 |
object_update_speed(pl); |
| 95 |
} |