Crossfire Server, Branches 1.12  R18729
player_changer.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2008 Crossfire Development Team
5  Copyright (C) 1992 Frank Tore Johansen
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21  The authors can be reached via e-mail at crossfire-devel@real-time.com
22 */
23 
28 #include <global.h>
29 #include <ob_methods.h>
30 #include <ob_types.h>
31 #include <sounds.h>
32 #include <sproto.h>
33 
34 static method_ret player_changer_type_process(ob_methods *context, object *op);
35 
41 }
42 
56 static method_ret player_changer_type_process(ob_methods *context, object *op) {
57  object *player;
58  object *walk;
59  char c;
60 
61  if (!op->above || !EXIT_PATH(op))
62  return METHOD_OK;
63 
64  /* This isn't all that great - means that the player_mover
65  * needs to be on top.
66  */
67  if (op->above->type == PLAYER) {
68  /* Lauwenmark: Handle for plugin TRIGGER event */
69  if (execute_event(op, EVENT_TRIGGER, op->above, NULL, NULL, SCRIPT_FIX_NOTHING) != 0)
70  return METHOD_OK;
71  player = op->above;
72  for (walk = op->inv; walk != NULL; walk = walk->below)
73  apply_changes_to_player(player, walk);
74 
75  fix_object(player);
78 
79  /* update players death & WoR home-position */
80  sscanf(EXIT_PATH(op), "%c", &c);
81  if (c == '/') {
82  strcpy(player->contr->savebed_map, EXIT_PATH(op));
83  player->contr->bed_x = EXIT_X(op);
84  player->contr->bed_y = EXIT_Y(op);
85  } else
86  LOG(llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", EXIT_PATH(op));
87 
88  enter_exit(op->above, op);
89  save_player(player, 1);
90  }
91 
92  return METHOD_OK;
93 }
sint16 bed_x
Definition: player.h:152
void enter_exit(object *op, object *exit_ob)
Definition: server.c:740
int save_player(object *op, int flag)
Definition: login.c:223
void esrv_update_item(int flags, object *pl, object *op)
Definition: standalone.c:200
struct pl player
void init_type_player_changer(void)
void esrv_send_inventory(object *pl, object *op)
Definition: item.c:307
void apply_changes_to_player(object *pl, object *change)
Definition: apply.c:1776
struct obj * above
Definition: object.h:146
static method_ret player_changer_type_process(ob_methods *context, object *op)
char savebed_map[MAX_BUF]
Definition: player.h:151
#define PLAYER
Definition: define.h:113
char method_ret
Definition: ob_methods.h:41
#define METHOD_OK
Definition: ob_methods.h:42
struct obj * below
Definition: object.h:145
#define EXIT_PATH(xyz)
Definition: define.h:748
#define EXIT_X(xyz)
Definition: define.h:750
struct pl * contr
Definition: object.h:134
#define EXIT_Y(xyz)
Definition: define.h:751
sint16 bed_y
Definition: player.h:152
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: standalone.c:225
void register_process(int ob_type, process_func method)
Definition: ob_types.c:88
struct obj * inv
Definition: object.h:148
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:63
#define UPD_FACE
Definition: newclient.h:257
void fix_object(object *op)
Definition: living.c:900
#define SCRIPT_FIX_NOTHING
Definition: global.h:451
#define PLAYER_CHANGER
Definition: define.h:194
#define EVENT_TRIGGER
Definition: plugin.h:71
uint8 type
Definition: object.h:189