1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT 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 3 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, see <http://www.gnu.org/licenses/>. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * |
20 | |
|
|
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <sproto.h> |
25 | #include <sproto.h> |
26 | #include <spells.h> |
26 | #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 | |
27 | |
37 | static partylist *firstparty = NULL; /* Keeps track of first party in list */ |
28 | static partylist *firstparty = NULL; /* Keeps track of first party in list */ |
38 | static partylist *lastparty = NULL; /*Keeps track of last party in list */ |
29 | static partylist *lastparty = NULL; /*Keeps track of last party in list */ |
39 | |
30 | |
40 | partylist * |
31 | partylist * |
… | |
… | |
70 | remove_party (partylist *target_party) |
61 | remove_party (partylist *target_party) |
71 | { |
62 | { |
72 | partylist *tmpparty; |
63 | partylist *tmpparty; |
73 | partylist *previousparty; |
64 | partylist *previousparty; |
74 | partylist *nextparty; |
65 | partylist *nextparty; |
75 | player *pl; |
|
|
76 | |
66 | |
77 | if (firstparty == NULL) |
67 | if (firstparty == NULL) |
78 | { |
68 | { |
79 | LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); |
69 | LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); |
80 | return; |
70 | return; |
… | |
… | |
138 | /* Remove unused parties, this could be made to scale a lot better. */ |
128 | /* Remove unused parties, this could be made to scale a lot better. */ |
139 | void |
129 | void |
140 | obsolete_parties (void) |
130 | obsolete_parties (void) |
141 | { |
131 | { |
142 | int player_count; |
132 | int player_count; |
143 | player *pl; |
|
|
144 | partylist *party; |
133 | partylist *party; |
145 | partylist *next = NULL; |
134 | partylist *next = NULL; |
146 | |
135 | |
147 | if (!firstparty) |
136 | if (!firstparty) |
148 | return; /* we can't obsolete parties if there aren't any */ |
137 | return; /* we can't obsolete parties if there aren't any */ |
… | |
… | |
156 | if (player_count == 0) |
145 | if (player_count == 0) |
157 | remove_party (party); |
146 | remove_party (party); |
158 | } |
147 | } |
159 | } |
148 | } |
160 | |
149 | |
161 | #ifdef PARTY_KILL_LOG |
|
|
162 | void |
150 | void |
163 | add_kill_to_party (partylist *party, char *killer, char *dead, long exp) |
151 | add_kill_to_party (partylist *party, const char *killer, const char *dead, long exp) |
164 | { |
152 | { |
165 | int i, pos; |
153 | int i, pos; |
166 | |
154 | |
167 | if (party == NULL) |
155 | if (party == NULL) |
168 | return; |
156 | return; |
|
|
157 | |
169 | if (party->kills >= PARTY_KILL_LOG) |
158 | if (party->kills >= PARTY_KILL_LOG) |
170 | { |
159 | { |
171 | pos = PARTY_KILL_LOG - 1; |
160 | pos = PARTY_KILL_LOG - 1; |
172 | for (i = 0; i < PARTY_KILL_LOG - 1; i++) |
161 | for (i = 0; i < PARTY_KILL_LOG - 1; i++) |
173 | party->party_kills[i] = party->party_kills[i + 1]; |
162 | party->party_kills[i] = party->party_kills[i + 1]; |
174 | } |
163 | } |
175 | else |
164 | else |
176 | pos = party->kills; |
165 | pos = party->kills; |
|
|
166 | |
177 | party->kills++; |
167 | party->kills++; |
178 | party->total_exp += exp; |
168 | party->total_exp += exp; |
179 | party->party_kills[pos].exp = exp; |
169 | party->party_kills[pos].exp = exp; |
180 | assign (party->party_kills[pos].killer, killer); |
170 | assign (party->party_kills[pos].killer, killer); |
181 | assign (party->party_kills[pos].dead, dead); |
171 | assign (party->party_kills[pos].dead, dead); |
182 | party->party_kills[pos].killer[MAX_NAME] = 0; |
172 | party->party_kills[pos].killer[MAX_NAME] = 0; |
183 | party->party_kills[pos].dead[MAX_NAME] = 0; |
173 | party->party_kills[pos].dead[MAX_NAME] = 0; |
184 | } |
174 | } |
185 | #endif |
|
|
186 | |
175 | |
187 | int |
176 | int |
188 | confirm_party_password (object *op) |
177 | confirm_party_password (object *op) |
189 | { |
178 | { |
190 | partylist *tmppartylist; |
179 | partylist *tmppartylist; |
… | |
… | |
229 | } |
218 | } |
230 | |
219 | |
231 | void |
220 | void |
232 | send_party_message (object *op, char *msg) |
221 | send_party_message (object *op, char *msg) |
233 | { |
222 | { |
234 | player *pl; |
|
|
235 | |
|
|
236 | for_all_players (pl) |
223 | for_all_players (pl) |
237 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
224 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
238 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
225 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
239 | } |
226 | } |
240 | |
227 | |
… | |
… | |
243 | { |
230 | { |
244 | char party_params[MAX_BUF]; |
231 | char party_params[MAX_BUF]; |
245 | |
232 | |
246 | if (!params) |
233 | if (!params) |
247 | return 0; |
234 | return 0; |
|
|
235 | |
248 | strcpy (party_params, "say "); |
236 | strcpy (party_params, "say "); |
249 | strcat (party_params, params); |
237 | strcat (party_params, params); |
250 | command_party (op, party_params); |
238 | command_party (op, party_params); |
251 | return 0; |
239 | return 0; |
252 | } |
240 | } |
253 | |
|
|
254 | |
241 | |
255 | int |
242 | int |
256 | command_party (object *op, char *params) |
243 | command_party (object *op, char *params) |
257 | { |
244 | { |
258 | char buf[MAX_BUF]; |
245 | char buf[MAX_BUF]; |
… | |
… | |
283 | new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); |
270 | new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); |
284 | new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>"); |
271 | new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>"); |
285 | new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max"); |
272 | new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max"); |
286 | new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>"); |
273 | new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>"); |
287 | new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who"); |
274 | new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who"); |
288 | #ifdef PARTY_KILL_LOG |
|
|
289 | new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); |
275 | new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); |
290 | #endif |
|
|
291 | return 1; |
276 | return 1; |
292 | } |
277 | } |
293 | |
278 | |
294 | #ifdef PARTY_KILL_LOG |
|
|
295 | if (!strncmp (params, "kills", 5)) |
279 | if (!strncmp (params, "kills", 5)) |
296 | { |
280 | { |
297 | int i, max; |
281 | int i, max; |
298 | char chr; |
282 | char chr; |
299 | char buffer[80]; |
283 | char buffer[80]; |
… | |
… | |
347 | new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------"); |
331 | new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------"); |
348 | sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr); |
332 | sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr); |
349 | new_draw_info (NDI_UNIQUE, 0, op, buffer); |
333 | new_draw_info (NDI_UNIQUE, 0, op, buffer); |
350 | return 1; |
334 | return 1; |
351 | } |
335 | } |
352 | #endif /* PARTY_KILL_LOG */ |
|
|
353 | |
336 | |
354 | if (strncmp (params, "say ", 4) == 0) |
337 | if (strncmp (params, "say ", 4) == 0) |
355 | { |
338 | { |
356 | if (op->contr->party == NULL) |
339 | if (op->contr->party == NULL) |
357 | { |
340 | { |
… | |
… | |
367 | } |
350 | } |
368 | |
351 | |
369 | if (strncmp (params, "form ", 5) == 0) |
352 | if (strncmp (params, "form ", 5) == 0) |
370 | { |
353 | { |
371 | int player_count; |
354 | int player_count; |
372 | player *pl; |
|
|
373 | |
355 | |
374 | params += 5; |
356 | params += 5; |
375 | if (op->contr->party) |
357 | if (op->contr->party) |
376 | oldparty = op->contr->party; |
358 | oldparty = op->contr->party; |
377 | else |
359 | else |
… | |
… | |
400 | * it, so check if there are any other members and if not, delete the party |
382 | * it, so check if there are any other members and if not, delete the party |
401 | */ |
383 | */ |
402 | player_count = 0; |
384 | player_count = 0; |
403 | if (oldparty) |
385 | if (oldparty) |
404 | { |
386 | { |
405 | for (pl = first_player; pl->next != NULL; pl = pl->next) |
387 | for_all_players (pl) |
406 | { |
|
|
407 | if (pl->party == oldparty) |
388 | if (pl->party == oldparty) |
408 | player_count++; |
389 | player_count++; |
409 | } |
390 | |
410 | if (player_count == 0) |
391 | if (player_count == 0) |
411 | remove_party (oldparty); |
392 | remove_party (oldparty); |
412 | } |
393 | } |
|
|
394 | |
413 | return 0; |
395 | return 0; |
414 | } /* form */ |
396 | } /* form */ |
415 | |
397 | |
416 | if (strcmp (params, "leave") == 0) |
398 | if (strcmp (params, "leave") == 0) |
417 | { |
399 | { |
… | |
… | |
428 | return 1; |
410 | return 1; |
429 | } |
411 | } |
430 | |
412 | |
431 | if (strcmp (params, "who") == 0) |
413 | if (strcmp (params, "who") == 0) |
432 | { |
414 | { |
433 | player *pl; |
|
|
434 | |
|
|
435 | tmpparty = op->contr->party; |
415 | tmpparty = op->contr->party; |
436 | if (op->contr->party == NULL) |
416 | if (op->contr->party == NULL) |
437 | { |
417 | { |
438 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
418 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
439 | return 1; |
419 | return 1; |
… | |
… | |
599 | new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); |
579 | new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); |
600 | new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>"); |
580 | new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>"); |
601 | new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max"); |
581 | new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max"); |
602 | new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>"); |
582 | new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>"); |
603 | new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who"); |
583 | new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who"); |
604 | #ifdef PARTY_KILL_LOG |
|
|
605 | new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); |
584 | new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); |
606 | #endif |
|
|
607 | return 1; |
585 | return 1; |
608 | } |
586 | } |