Crossfire Server, Branches 1.12  R18729
savebed.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2007 Mark Wedel & 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 
27 #include <global.h>
28 #include <ob_methods.h>
29 #include <ob_types.h>
30 #include <sounds.h>
31 #include <sproto.h>
32 
33 static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags);
34 static void apply_savebed(object *pl);
35 
39 void init_type_savebed(void) {
41 }
42 
52 static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags) {
53  if (applier->type == PLAYER)
54  apply_savebed(applier);
55  return METHOD_OK;
56 }
57 
64 static void apply_savebed(object *pl) {
65  /* Lauwenmark : Here we handle the LOGOUT global event */
67 
68  /* Need to call terminate_all_pets() before we remove the player ob */
70  remove_ob(pl);
71  pl->direction = 0;
73  "%s leaves the game.",
74  "%s leaves the game.",
75  pl->name);
76 
77  /* update respawn position */
78  strcpy(pl->contr->savebed_map, pl->map->path);
79  pl->contr->bed_x = pl->x;
80  pl->contr->bed_y = pl->y;
81 
82  strcpy(pl->contr->killer, "left");
83  check_score(pl, 0); /* Always check score */
84  (void)save_player(pl, 0);
85 #if MAP_MAXTIMEOUT
86  MAP_SWAP_TIME(pl->map) = MAP_TIMEOUT(pl->map);
87 #endif
88  play_again(pl);
89  pl->speed = 0;
90  update_ob_speed(pl);
91 }
sint16 bed_x
Definition: player.h:152
char path[HUGE_BUF]
Definition: map.h:384
Definition: player.h:146
#define NDI_ALL
Definition: newclient.h:220
int save_player(object *op, int flag)
Definition: login.c:223
socket_struct socket
Definition: player.h:148
#define EVENT_LOGOUT
Definition: plugin.h:85
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:414
void play_again(object *op)
Definition: player.c:810
sint16 x
Definition: object.h:179
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
Definition: standalone.c:175
void terminate_all_pets(object *owner)
Definition: pets.c:250
static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags)
Definition: savebed.c:52
char savebed_map[MAX_BUF]
Definition: player.h:151
#define NDI_DK_ORANGE
Definition: newclient.h:201
char * host
Definition: newserver.h:125
#define PLAYER
Definition: define.h:113
char method_ret
Definition: ob_methods.h:41
void remove_ob(object *op)
Definition: object.c:1515
#define METHOD_OK
Definition: ob_methods.h:42
struct mapdef * map
Definition: object.h:155
#define MAP_TIMEOUT(m)
Definition: map.h:85
const char * name
Definition: object.h:167
int execute_global_event(int eventcode,...)
Definition: standalone.c:229
void check_score(object *op, int quiet)
Definition: hiscore.c:289
sint16 y
Definition: object.h:179
void register_apply(int ob_type, apply_func method)
Definition: ob_types.c:79
struct pl * contr
Definition: object.h:134
float speed
Definition: object.h:181
#define MSG_TYPE_ADMIN
Definition: newclient.h:324
void init_type_savebed(void)
Definition: savebed.c:39
sint16 bed_y
Definition: player.h:152
char killer[BIG_NAME]
Definition: player.h:222
#define SAVEBED
Definition: define.h:288
sint8 direction
Definition: object.h:185
#define MAP_SWAP_TIME(m)
Definition: map.h:86
void update_ob_speed(object *op)
Definition: object.c:1008
static void apply_savebed(object *pl)
Definition: savebed.c:64
#define NDI_UNIQUE
Definition: newclient.h:219
uint8 type
Definition: object.h:189