|
|
1 | |
1 | /* |
2 | /* |
2 | * static char *rcsid_player_c = |
3 | * static char *rcsid_player_c = |
3 | * "$Id: player.C,v 1.3 2006/09/03 08:05:39 root Exp $"; |
4 | * "$Id: player.C,v 1.4 2006/09/10 16:00:23 root Exp $"; |
4 | */ |
5 | */ |
5 | |
6 | |
6 | /* |
7 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
8 | |
9 | |
… | |
… | |
27 | */ |
28 | */ |
28 | |
29 | |
29 | #include <global.h> |
30 | #include <global.h> |
30 | #include <funcpoint.h> |
31 | #include <funcpoint.h> |
31 | |
32 | |
|
|
33 | void |
32 | void free_player(player *pl) { |
34 | free_player (player *pl) |
|
|
35 | { |
33 | |
36 | |
34 | if (first_player!=pl) { |
37 | if (first_player != pl) |
|
|
38 | { |
35 | player *prev=first_player; |
39 | player *prev = first_player; |
|
|
40 | |
36 | while(prev!=NULL&&prev->next!=NULL&&prev->next!=pl) |
41 | while (prev != NULL && prev->next != NULL && prev->next != pl) |
37 | prev=prev->next; |
42 | prev = prev->next; |
38 | if(prev->next!=pl) { |
43 | if (prev->next != pl) |
|
|
44 | { |
39 | LOG(llevError,"Free_player: Can't find previous player.\n"); |
45 | LOG (llevError, "Free_player: Can't find previous player.\n"); |
40 | exit(1); |
46 | exit (1); |
41 | } |
47 | } |
42 | prev->next=pl->next; |
48 | prev->next = pl->next; |
|
|
49 | } |
|
|
50 | else |
43 | } else first_player=pl->next; |
51 | first_player = pl->next; |
44 | |
52 | |
45 | if(pl->ob != NULL) { |
53 | if (pl->ob != NULL) |
|
|
54 | { |
46 | if (!QUERY_FLAG(pl->ob, FLAG_REMOVED)) remove_ob(pl->ob); |
55 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
56 | remove_ob (pl->ob); |
47 | free_object(pl->ob); |
57 | free_object (pl->ob); |
48 | } |
58 | } |
49 | /* Clear item stack */ |
59 | /* Clear item stack */ |
50 | if (pl->stack_items) free( pl->stack_items ); |
60 | if (pl->stack_items) |
|
|
61 | free (pl->stack_items); |
51 | |
62 | |
52 | free(pl->socket.faces_sent); |
63 | free (pl->socket.faces_sent); |
53 | |
64 | |
54 | delete pl; |
65 | delete pl; |
55 | } |
66 | } |
56 | |
67 | |
57 | |
68 | |
58 | /* Determine if the attacktype represented by the |
69 | /* Determine if the attacktype represented by the |
59 | * specified attack-number is enabled for dragon players. |
70 | * specified attack-number is enabled for dragon players. |
60 | * A dragon player (quetzal) can gain resistances for |
71 | * A dragon player (quetzal) can gain resistances for |
61 | * all enabled attacktypes. |
72 | * all enabled attacktypes. |
62 | */ |
73 | */ |
|
|
74 | int |
63 | int atnr_is_dragon_enabled(int attacknr) { |
75 | atnr_is_dragon_enabled (int attacknr) |
|
|
76 | { |
64 | if (attacknr == ATNR_MAGIC || attacknr == ATNR_FIRE || |
77 | if (attacknr == ATNR_MAGIC || attacknr == ATNR_FIRE || |
65 | attacknr == ATNR_ELECTRICITY || attacknr == ATNR_COLD || |
78 | attacknr == ATNR_ELECTRICITY || attacknr == ATNR_COLD || attacknr == ATNR_ACID || attacknr == ATNR_POISON) |
66 | attacknr == ATNR_ACID || attacknr == ATNR_POISON) |
|
|
67 | return 1; |
79 | return 1; |
68 | return 0; |
80 | return 0; |
69 | } |
81 | } |
70 | |
82 | |
71 | /* |
83 | /* |
72 | * returns true if the adressed object 'ob' is a player |
84 | * returns true if the adressed object 'ob' is a player |
73 | * of the dragon race. |
85 | * of the dragon race. |
74 | */ |
86 | */ |
|
|
87 | int |
75 | int is_dragon_pl(const object* op) { |
88 | is_dragon_pl (const object *op) |
76 | if (op != NULL && op->type == PLAYER && op->arch != NULL |
89 | { |
77 | && op->arch->clone.race != NULL && |
90 | 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; |
91 | return 1; |
80 | return 0; |
92 | return 0; |
81 | } |
93 | } |