Crossfire Server, Trunk  R20576
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 <>.
12  */
19 #include "global.h"
21 #include <string.h>
23 #include "ob_methods.h"
24 #include "ob_types.h"
25 #include "sounds.h"
26 #include "sproto.h"
28 static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags);
29 static void apply_savebed(object *pl);
34 void init_type_savebed(void) {
36 }
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 }
59 static void apply_savebed(object *pl) {
60  /* Refuse to save a player without any experience. */
61  if (!pl->stats.exp) {
64  "You must gain a bit of experience before you can save.");
65  return;
66  }
68  /* Lauwenmark : Here we handle the LOGOUT global event */
71  /* Need to call pets_terminate_all() before we remove the player ob */
73  object_remove(pl);
74  pl->direction = 0;
77  "%s leaves the game.", pl->name);
79  /* update respawn position */
81  sizeof(pl->contr->savebed_map));
82  pl->contr->bed_x = pl->x;
83  pl->contr->bed_y = pl->y;
85  strcpy(pl->contr->killer, "left");
86  hiscore_check(pl, 0); /* Always check score */
87  save_player(pl, 0);
88  party_leave(pl);
90  MAP_SWAP_TIME(pl->map) = MAP_TIMEOUT(pl->map);
91 #endif
92  play_again(pl);
93  pl->speed = 0;
95 }
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Sends message to player(s).
Definition: main.c:315
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
One player.
Definition: player.h:92
Sound-related defines.
Typedefs for ob_methods.
Definition: ob_methods.h:45
#define NDI_ALL
Inform all players of this message.
Definition: newclient.h:246
int16_t bed_x
Definition: player.h:98
int save_player(object *op, int flag)
Saves a player to disk.
Definition: login.c:211
socket_struct socket
Socket information for this player.
Definition: player.h:94
Player logout.
Definition: plugin.h:89
void play_again(object *op)
Ask the player whether to play again or disconnect.
Definition: player.c:878
int64_t exp
Definition: living.h:46
load/save operations
Definition: newclient.h:477
void party_leave(object *op)
Makes a player leave his party.
Definition: party.c:104
Global type definitions and header inclusions.
#define safe_strncpy
Definition: compat.h:23
void pets_terminate_all(object *owner)
Removes all pets someone owns.
Definition: pets.c:231
static method_ret savebed_type_apply(ob_methods *context, object *op, object *applier, int aflags)
Attempts to apply a savebed.
Definition: savebed.c:47
char savebed_map[MAX_BUF]
Map where player will respawn after death.
Definition: player.h:97
Definition: newclient.h:227
char * host
Which host it is connected from (ip address).
Definition: newserver.h:110
char method_ret
Define some standard return values for callbacks which don&#39;t need to return any other results...
Definition: ob_methods.h:14
int16_t y
Position in the map for this object.
Definition: object.h:326
#define NDI_RED
Definition: newclient.h:224
#define METHOD_OK
Definition: ob_methods.h:15
Player coming/going/death.
Definition: newclient.h:474
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
#define MAP_TIMEOUT(m)
Definition: map.h:66
const char * name
The name of the object, obviously...
Definition: object.h:311
int16_t bed_y
x,y - coordinates of respawn (savebed).
Definition: player.h:98
int execute_global_event(int eventcode,...)
Definition: main.c:369
int8_t direction
Means the object is moving that way.
Definition: object.h:334
void hiscore_check(object *op, int quiet)
Checks if player should enter the hiscore, and if so writes her into the list.
Definition: hiscore.c:302
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
Definition: ob_types.c:62
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
float speed
The overall speed of this object.
Definition: object.h:328
void init_type_savebed(void)
Initializer for the SAVEBED object type.
Definition: savebed.c:34
Definition: newclient.h:377
int16_t x
Definition: object.h:326
Object type variables.
See Player.
Definition: object.h:107
char killer[BIG_NAME]
Who killed this player.
Definition: player.h:171
living stats
Str, Con, Dex, etc.
Definition: object.h:368
uint8_t type
Definition: object.h:338
#define MAP_SWAP_TIME(m)
Definition: map.h:67
static void apply_savebed(object *pl)
Apply a bed to reality.
Definition: savebed.c:59
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
Object type functions and variables.
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.c:1129
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
Definition: object.c:1654
See Savebed.
Definition: object.h:219