1 | /* |
|
|
2 | * static char *rcsid_player_c = |
|
|
3 | * "$Id: player.C,v 1.2 2006/08/29 08:01:35 root Exp $"; |
|
|
4 | */ |
|
|
5 | |
|
|
6 | /* |
1 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
8 | |
3 | |
9 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
10 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
21 | |
16 | |
22 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
23 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | |
20 | |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
27 | */ |
22 | */ |
28 | |
23 | |
29 | #include <global.h> |
24 | #include <global.h> |
30 | #include <funcpoint.h> |
25 | #include <funcpoint.h> |
31 | |
26 | |
|
|
27 | void |
32 | void free_player(player *pl) { |
28 | free_player (player *pl) |
|
|
29 | { |
|
|
30 | if (first_player != pl) |
|
|
31 | { |
|
|
32 | player *prev = first_player; |
33 | |
33 | |
34 | if (first_player!=pl) { |
|
|
35 | player *prev=first_player; |
|
|
36 | while(prev!=NULL&&prev->next!=NULL&&prev->next!=pl) |
34 | while (prev != NULL && prev->next != NULL && prev->next != pl) |
37 | prev=prev->next; |
35 | prev = prev->next; |
|
|
36 | |
38 | if(prev->next!=pl) { |
37 | if (prev->next != pl) |
|
|
38 | { |
39 | LOG(llevError,"Free_player: Can't find previous player.\n"); |
39 | LOG (llevError, "Free_player: Can't find previous player.\n"); |
40 | exit(1); |
40 | exit (1); |
41 | } |
41 | } |
42 | prev->next=pl->next; |
|
|
43 | } else first_player=pl->next; |
|
|
44 | |
42 | |
45 | if(pl->ob != NULL) { |
43 | prev->next = pl->next; |
46 | if (!QUERY_FLAG(pl->ob, FLAG_REMOVED)) remove_ob(pl->ob); |
|
|
47 | free_object(pl->ob); |
|
|
48 | } |
44 | } |
49 | /* Clear item stack */ |
45 | else |
50 | if (pl->stack_items) free( pl->stack_items ); |
46 | first_player = pl->next; |
51 | |
47 | |
52 | free(pl->socket.faces_sent); |
48 | if (pl->ob) |
|
|
49 | { |
|
|
50 | pl->ob->contr = 0; |
|
|
51 | pl->ob->destroy (); |
|
|
52 | } |
53 | |
53 | |
54 | CFREE(pl); |
54 | /* Clear item stack */ |
|
|
55 | if (pl->stack_items) |
|
|
56 | free (pl->stack_items); |
|
|
57 | |
|
|
58 | pl->socket->status = Ns_Dead; |
|
|
59 | pl->socket->pl = 0; |
|
|
60 | |
|
|
61 | delete pl; |
55 | } |
62 | } |
56 | |
63 | |
57 | |
64 | |
58 | /* Determine if the attacktype represented by the |
65 | /* Determine if the attacktype represented by the |
59 | * specified attack-number is enabled for dragon players. |
66 | * specified attack-number is enabled for dragon players. |
60 | * A dragon player (quetzal) can gain resistances for |
67 | * A dragon player (quetzal) can gain resistances for |
61 | * all enabled attacktypes. |
68 | * all enabled attacktypes. |
62 | */ |
69 | */ |
|
|
70 | int |
63 | int atnr_is_dragon_enabled(int attacknr) { |
71 | atnr_is_dragon_enabled (int attacknr) |
|
|
72 | { |
64 | if (attacknr == ATNR_MAGIC || attacknr == ATNR_FIRE || |
73 | if (attacknr == ATNR_MAGIC || attacknr == ATNR_FIRE || |
65 | attacknr == ATNR_ELECTRICITY || attacknr == ATNR_COLD || |
74 | attacknr == ATNR_ELECTRICITY || attacknr == ATNR_COLD || attacknr == ATNR_ACID || attacknr == ATNR_POISON) |
66 | attacknr == ATNR_ACID || attacknr == ATNR_POISON) |
|
|
67 | return 1; |
75 | return 1; |
68 | return 0; |
76 | return 0; |
69 | } |
77 | } |
70 | |
78 | |
71 | /* |
79 | /* |
72 | * returns true if the adressed object 'ob' is a player |
80 | * returns true if the adressed object 'ob' is a player |
73 | * of the dragon race. |
81 | * of the dragon race. |
74 | */ |
82 | */ |
|
|
83 | int |
75 | int is_dragon_pl(const object* op) { |
84 | is_dragon_pl (const object *op) |
76 | if (op != NULL && op->type == PLAYER && op->arch != NULL |
85 | { |
77 | && op->arch->clone.race != NULL && |
86 | if (op != NULL && op->type == PLAYER && op->arch != NULL && op->arch->clone.race != NULL && strcmp (op->arch->clone.race, "dragon") == 0) |
78 | strcmp(op->arch->clone.race, "dragon")==0) |
|
|
79 | return 1; |
87 | return 1; |
80 | return 0; |
88 | return 0; |
81 | } |
89 | } |