Crossfire Server, Branches 1.12  R18729
player.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_player_c =
3  * "$Id: player.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  CrossFire, A Multiplayer game for X-windows
8 
9  Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10  Copyright (C) 1992 Frank Tore Johansen
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 
26  The authors can be reached via e-mail at crossfire-devel@real-time.com
27 */
28 
34 #include <global.h>
35 
46  client_spell *info;
47  client_spell *next;
48 
49  /* Clear item stack (used by DMs only) */
50  if (pl->stack_items)
51  free(pl->stack_items);
52  pl->stack_position = 0;
53 
54  info = pl->spell_state;
55  while (info) {
56  next = info->next;
57  free(info);
58  info = next;
59  }
60 }
61 
69  if (first_player != pl) {
70  player *prev = first_player;
71 
72  while (prev != NULL && prev->next != NULL && prev->next != pl)
73  prev = prev->next;
74  if (prev->next != pl) {
75  LOG(llevError, "Free_player: Can't find previous player.\n");
76  exit(1);
77  }
78  prev->next = pl->next;
79  } else
80  first_player = pl->next;
81 
82  if (pl->ob != NULL) {
83  if (!QUERY_FLAG(pl->ob, FLAG_REMOVED))
84  remove_ob(pl->ob);
85  free_object(pl->ob);
86  }
87 
88  clear_player(pl);
89 
90  free(pl->socket.faces_sent);
91 
92  CFREE(pl);
93 }
94 
106 int atnr_is_dragon_enabled(int attacknr) {
107  if (attacknr == ATNR_MAGIC
108  || attacknr == ATNR_FIRE
109  || attacknr == ATNR_ELECTRICITY
110  || attacknr == ATNR_COLD
111  || attacknr == ATNR_ACID
112  || attacknr == ATNR_POISON)
113  return 1;
114  return 0;
115 }
116 
125 int is_dragon_pl(const object *op) {
126  if (op != NULL
127  && op->type == PLAYER
128  && op->arch != NULL
129  && op->arch->clone.race != NULL
130  && strcmp(op->arch->clone.race, "dragon") == 0)
131  return 1;
132  return 0;
133 }
134 
148  client_spell *info = pl->spell_state;
149 
150  while (info) {
151  if (info->spell == spell)
152  return info;
153  info = info->next;
154  }
155  info = (client_spell *)malloc(sizeof(client_spell));
156  if (info == NULL)
158  memset(info, 0, sizeof(client_spell));
159  info->next = pl->spell_state;
160  info->spell = spell;
161  pl->spell_state = info;
162  return info;
163 }
164 
173 int is_wraith_pl(object *op) {
174  object *item = NULL;
175 
176  if (op != NULL && op->type == PLAYER && op->arch != NULL)
177  for (item = op->inv; item != NULL && strcmp(item->name, "wraith feed"); item = item->below)
178  ;
179  if (item)
180  return 1;
181  return 0;
182 }
183 
192 int is_old_wraith_pl(object *op) {
193  object *item = NULL;
194 
195  if (op != NULL && op->type == PLAYER && op->arch != NULL)
196  for (item = op->inv; item != NULL && strcmp(item->name, "Wraith_Force"); item = item->below)
197  ;
198  if (item)
199  return !is_wraith_pl(op);
200  return 0;
201 }
Definition: player.h:146
void free_player(player *pl)
Definition: player.c:68
#define OUT_OF_MEMORY
Definition: define.h:94
const char * race
Definition: object.h:171
object * spell
Definition: player.h:112
object clone
Definition: object.h:326
socket_struct socket
Definition: player.h:148
#define PLAYER
Definition: define.h:113
#define FLAG_REMOVED
Definition: define.h:528
int stack_position
Definition: player.h:254
client_spell * get_client_spell_state(player *pl, object *spell)
Definition: player.c:147
void clear_player(player *pl)
Definition: player.c:45
void remove_ob(object *op)
Definition: object.c:1515
uint8 * faces_sent
Definition: newserver.h:121
int is_wraith_pl(object *op)
Definition: player.c:173
int is_dragon_pl(const object *op)
Definition: player.c:125
tag_t * stack_items
Definition: player.h:252
const char * name
Definition: object.h:167
struct obj * below
Definition: object.h:145
void fatal(int err)
Definition: glue.c:60
#define ATNR_MAGIC
Definition: attack.h:78
#define ATNR_ELECTRICITY
Definition: attack.h:80
#define ATNR_POISON
Definition: attack.h:87
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
int is_old_wraith_pl(object *op)
Definition: player.c:192
client_spell * spell_state
Definition: player.h:250
object * ob
Definition: player.h:207
struct client_spell * next
Definition: player.h:116
#define CFREE(x)
Definition: global.h:296
struct archt * arch
Definition: object.h:263
EXTERN player * first_player
Definition: global.h:190
struct pl * next
Definition: player.h:147
struct obj * inv
Definition: object.h:148
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:63
#define ATNR_COLD
Definition: attack.h:81
void free_object(object *ob)
Definition: object.c:1238
#define ATNR_ACID
Definition: attack.h:83
uint8 type
Definition: object.h:189
int atnr_is_dragon_enabled(int attacknr)
Definition: player.c:106
#define ATNR_FIRE
Definition: attack.h:79