Crossfire Server, Branch 1.12
R12190
|
00001 /* 00002 * static char *rcsid_player_c = 00003 * "$Id: player.c 11578 2009-02-23 22:02:27Z lalo $"; 00004 */ 00005 00006 /* 00007 CrossFire, A Multiplayer game for X-windows 00008 00009 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 00010 Copyright (C) 1992 Frank Tore Johansen 00011 00012 This program is free software; you can redistribute it and/or modify 00013 it under the terms of the GNU General Public License as published by 00014 the Free Software Foundation; either version 2 of the License, or 00015 (at your option) any later version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 GNU General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with this program; if not, write to the Free Software 00024 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 00026 The authors can be reached via e-mail at crossfire-devel@real-time.com 00027 */ 00028 00034 #include <global.h> 00035 00045 void clear_player(player *pl) { 00046 client_spell *info; 00047 client_spell *next; 00048 00049 /* Clear item stack (used by DMs only) */ 00050 if (pl->stack_items) 00051 free(pl->stack_items); 00052 pl->stack_position = 0; 00053 00054 info = pl->spell_state; 00055 while (info) { 00056 next = info->next; 00057 free(info); 00058 info = next; 00059 } 00060 } 00061 00068 void free_player(player *pl) { 00069 if (first_player != pl) { 00070 player *prev = first_player; 00071 00072 while (prev != NULL && prev->next != NULL && prev->next != pl) 00073 prev = prev->next; 00074 if (prev->next != pl) { 00075 LOG(llevError, "Free_player: Can't find previous player.\n"); 00076 exit(1); 00077 } 00078 prev->next = pl->next; 00079 } else 00080 first_player = pl->next; 00081 00082 if (pl->ob != NULL) { 00083 if (!QUERY_FLAG(pl->ob, FLAG_REMOVED)) 00084 remove_ob(pl->ob); 00085 free_object(pl->ob); 00086 } 00087 00088 clear_player(pl); 00089 00090 free(pl->socket.faces_sent); 00091 00092 CFREE(pl); 00093 } 00094 00106 int atnr_is_dragon_enabled(int attacknr) { 00107 if (attacknr == ATNR_MAGIC 00108 || attacknr == ATNR_FIRE 00109 || attacknr == ATNR_ELECTRICITY 00110 || attacknr == ATNR_COLD 00111 || attacknr == ATNR_ACID 00112 || attacknr == ATNR_POISON) 00113 return 1; 00114 return 0; 00115 } 00116 00125 int is_dragon_pl(const object *op) { 00126 if (op != NULL 00127 && op->type == PLAYER 00128 && op->arch != NULL 00129 && op->arch->clone.race != NULL 00130 && strcmp(op->arch->clone.race, "dragon") == 0) 00131 return 1; 00132 return 0; 00133 } 00134 00147 client_spell *get_client_spell_state(player *pl, object *spell) { 00148 client_spell *info = pl->spell_state; 00149 00150 while (info) { 00151 if (info->spell == spell) 00152 return info; 00153 info = info->next; 00154 } 00155 info = (client_spell *)malloc(sizeof(client_spell)); 00156 if (info == NULL) 00157 fatal(OUT_OF_MEMORY); 00158 memset(info, 0, sizeof(client_spell)); 00159 info->next = pl->spell_state; 00160 info->spell = spell; 00161 pl->spell_state = info; 00162 return info; 00163 } 00164 00173 int is_wraith_pl(object *op) { 00174 object *item = NULL; 00175 00176 if (op != NULL && op->type == PLAYER && op->arch != NULL) 00177 for (item = op->inv; item != NULL && strcmp(item->name, "wraith feed"); item = item->below) 00178 ; 00179 if (item) 00180 return 1; 00181 return 0; 00182 } 00183 00192 int is_old_wraith_pl(object *op) { 00193 object *item = NULL; 00194 00195 if (op != NULL && op->type == PLAYER && op->arch != NULL) 00196 for (item = op->inv; item != NULL && strcmp(item->name, "Wraith_Force"); item = item->below) 00197 ; 00198 if (item) 00199 return !is_wraith_pl(op); 00200 return 0; 00201 }