1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <sproto.h> |
26 | #include <sproto.h> |
26 | #include <spells.h> |
27 | #include <spells.h> |
27 | |
|
|
28 | #ifdef COZY_SERVER |
|
|
29 | // used for pet monster logic etc. |
|
|
30 | int |
|
|
31 | same_party (partylist *a, partylist *b) |
|
|
32 | { |
|
|
33 | return a == b && a; |
|
|
34 | } |
|
|
35 | #endif |
|
|
36 | |
28 | |
37 | static partylist *firstparty = NULL; /* Keeps track of first party in list */ |
29 | static partylist *firstparty = NULL; /* Keeps track of first party in list */ |
38 | static partylist *lastparty = NULL; /*Keeps track of last party in list */ |
30 | static partylist *lastparty = NULL; /*Keeps track of last party in list */ |
39 | |
31 | |
40 | partylist * |
32 | partylist * |
… | |
… | |
70 | remove_party (partylist *target_party) |
62 | remove_party (partylist *target_party) |
71 | { |
63 | { |
72 | partylist *tmpparty; |
64 | partylist *tmpparty; |
73 | partylist *previousparty; |
65 | partylist *previousparty; |
74 | partylist *nextparty; |
66 | partylist *nextparty; |
75 | player *pl; |
|
|
76 | |
67 | |
77 | if (firstparty == NULL) |
68 | if (firstparty == NULL) |
78 | { |
69 | { |
79 | LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); |
70 | LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); |
80 | return; |
71 | return; |
… | |
… | |
138 | /* Remove unused parties, this could be made to scale a lot better. */ |
129 | /* Remove unused parties, this could be made to scale a lot better. */ |
139 | void |
130 | void |
140 | obsolete_parties (void) |
131 | obsolete_parties (void) |
141 | { |
132 | { |
142 | int player_count; |
133 | int player_count; |
143 | player *pl; |
|
|
144 | partylist *party; |
134 | partylist *party; |
145 | partylist *next = NULL; |
135 | partylist *next = NULL; |
146 | |
136 | |
147 | if (!firstparty) |
137 | if (!firstparty) |
148 | return; /* we can't obsolete parties if there aren't any */ |
138 | return; /* we can't obsolete parties if there aren't any */ |
… | |
… | |
157 | remove_party (party); |
147 | remove_party (party); |
158 | } |
148 | } |
159 | } |
149 | } |
160 | |
150 | |
161 | void |
151 | void |
162 | add_kill_to_party (partylist *party, char *killer, char *dead, long exp) |
152 | add_kill_to_party (partylist *party, const char *killer, const char *dead, long exp) |
163 | { |
153 | { |
164 | int i, pos; |
154 | int i, pos; |
165 | |
155 | |
166 | if (party == NULL) |
156 | if (party == NULL) |
167 | return; |
157 | return; |
… | |
… | |
229 | } |
219 | } |
230 | |
220 | |
231 | void |
221 | void |
232 | send_party_message (object *op, char *msg) |
222 | send_party_message (object *op, char *msg) |
233 | { |
223 | { |
234 | player *pl; |
|
|
235 | |
|
|
236 | for_all_players (pl) |
224 | for_all_players (pl) |
237 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
225 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
238 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
226 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
239 | } |
227 | } |
240 | |
228 | |
… | |
… | |
363 | } |
351 | } |
364 | |
352 | |
365 | if (strncmp (params, "form ", 5) == 0) |
353 | if (strncmp (params, "form ", 5) == 0) |
366 | { |
354 | { |
367 | int player_count; |
355 | int player_count; |
368 | player *pl; |
|
|
369 | |
356 | |
370 | params += 5; |
357 | params += 5; |
371 | if (op->contr->party) |
358 | if (op->contr->party) |
372 | oldparty = op->contr->party; |
359 | oldparty = op->contr->party; |
373 | else |
360 | else |
… | |
… | |
396 | * it, so check if there are any other members and if not, delete the party |
383 | * it, so check if there are any other members and if not, delete the party |
397 | */ |
384 | */ |
398 | player_count = 0; |
385 | player_count = 0; |
399 | if (oldparty) |
386 | if (oldparty) |
400 | { |
387 | { |
401 | for (pl = first_player; pl->next != NULL; pl = pl->next) |
388 | for_all_players (pl) |
402 | { |
|
|
403 | if (pl->party == oldparty) |
389 | if (pl->party == oldparty) |
404 | player_count++; |
390 | player_count++; |
405 | } |
391 | |
406 | if (player_count == 0) |
392 | if (player_count == 0) |
407 | remove_party (oldparty); |
393 | remove_party (oldparty); |
408 | } |
394 | } |
|
|
395 | |
409 | return 0; |
396 | return 0; |
410 | } /* form */ |
397 | } /* form */ |
411 | |
398 | |
412 | if (strcmp (params, "leave") == 0) |
399 | if (strcmp (params, "leave") == 0) |
413 | { |
400 | { |
… | |
… | |
424 | return 1; |
411 | return 1; |
425 | } |
412 | } |
426 | |
413 | |
427 | if (strcmp (params, "who") == 0) |
414 | if (strcmp (params, "who") == 0) |
428 | { |
415 | { |
429 | player *pl; |
|
|
430 | |
|
|
431 | tmpparty = op->contr->party; |
416 | tmpparty = op->contr->party; |
432 | if (op->contr->party == NULL) |
417 | if (op->contr->party == NULL) |
433 | { |
418 | { |
434 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
419 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
435 | return 1; |
420 | return 1; |