Crossfire Server, Trunk  R20805
player_changer.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
18 #include "global.h"
19 
20 #include <string.h>
21 
22 #include "ob_methods.h"
23 #include "ob_types.h"
24 #include "sounds.h"
25 #include "sproto.h"
26 
27 static method_ret player_changer_type_process(ob_methods *context, object *op);
28 
34 }
35 
49 static method_ret player_changer_type_process(ob_methods *context, object *op) {
50  object *player;
51  char c;
52 
53  if (!op->above || !EXIT_PATH(op))
54  return METHOD_OK;
55 
56  /* This isn't all that great - means that the player_mover
57  * needs to be on top.
58  */
59  if (op->above->type == PLAYER) {
60  /* Lauwenmark: Handle for plugin TRIGGER event */
61  if (execute_event(op, EVENT_TRIGGER, op->above, NULL, NULL, SCRIPT_FIX_NOTHING) != 0)
62  return METHOD_OK;
63  player = op->above;
64  FOR_INV_PREPARE(op, walk)
67 
68  fix_object(player);
71 
72  /* update players death & WoR home-position */
73  sscanf(EXIT_PATH(op), "%c", &c);
74  if (c == '/') {
76  sizeof(player->contr->savebed_map));
77  player->contr->bed_x = EXIT_X(op);
78  player->contr->bed_y = EXIT_Y(op);
79  } else
80  LOG(llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", EXIT_PATH(op));
81 
82  enter_exit(op->above, op);
83  save_player(player, 1);
84  }
85 
86  return METHOD_OK;
87 }
void enter_exit(object *op, object *exit_ob)
Definition: server.c:708
int16_t bed_x
Definition: player.h:98
int save_player(object *op, int flag)
Definition: login.c:211
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:342
struct pl player
void init_type_player_changer(void)
void esrv_send_inventory(object *pl, object *op)
Definition: item.c:307
struct obj * above
Definition: object.h:288
static method_ret player_changer_type_process(ob_methods *context, object *op)
#define safe_strncpy
Definition: compat.h:23
char savebed_map[MAX_BUF]
Definition: player.h:97
char method_ret
Definition: ob_methods.h:14
void apply_changes_to_player(object *pl, object *change, int limit_stats)
Definition: apply.c:1581
#define AC_PLAYER_STAT_LIMIT
Definition: define.h:632
#define METHOD_OK
Definition: ob_methods.h:15
#define FOR_INV_FINISH()
Definition: define.h:712
int16_t bed_y
Definition: player.h:98
#define EXIT_PATH(xyz)
Definition: define.h:455
#define EXIT_X(xyz)
Definition: define.h:457
struct pl * contr
Definition: object.h:276
#define EXIT_Y(xyz)
Definition: define.h:458
Definition: object.h:107
#define UPD_FACE
Definition: newclient.h:292
uint8_t type
Definition: object.h:338
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: main.c:364
void register_process(int ob_type, process_func method)
Definition: ob_types.c:71
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
void fix_object(object *op)
Definition: living.c:1118
#define SCRIPT_FIX_NOTHING
Definition: global.h:362
#define EVENT_TRIGGER
Definition: plugin.h:74
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:705