ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_party.C
(Generate patch)

Comparing deliantra/server/server/c_party.C (file contents):
Revision 1.11 by root, Tue Dec 26 08:54:59 2006 UTC vs.
Revision 1.19 by root, Mon May 28 21:28:35 2007 UTC

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 it
8 it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
9 the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
10 (at your option) any later version. 11 * 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, but
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 GNU General Public License for more details. 16 * 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 along
18 along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 to <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.
30int
31same_party (partylist *a, partylist *b)
32{
33 return a == b && a;
34}
35#endif
36 28
37static partylist *firstparty = NULL; /* Keeps track of first party in list */ 29static partylist *firstparty = NULL; /* Keeps track of first party in list */
38static partylist *lastparty = NULL; /*Keeps track of last party in list */ 30static partylist *lastparty = NULL; /*Keeps track of last party in list */
39 31
40partylist * 32partylist *
70remove_party (partylist *target_party) 62remove_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. */
139void 130void
140obsolete_parties (void) 131obsolete_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 */
156 if (player_count == 0) 146 if (player_count == 0)
157 remove_party (party); 147 remove_party (party);
158 } 148 }
159} 149}
160 150
161#ifdef PARTY_KILL_LOG
162void 151void
163add_kill_to_party (partylist *party, char *killer, char *dead, long exp) 152add_kill_to_party (partylist *party, const char *killer, const char *dead, long exp)
164{ 153{
165 int i, pos; 154 int i, pos;
166 155
167 if (party == NULL) 156 if (party == NULL)
168 return; 157 return;
158
169 if (party->kills >= PARTY_KILL_LOG) 159 if (party->kills >= PARTY_KILL_LOG)
170 { 160 {
171 pos = PARTY_KILL_LOG - 1; 161 pos = PARTY_KILL_LOG - 1;
172 for (i = 0; i < PARTY_KILL_LOG - 1; i++) 162 for (i = 0; i < PARTY_KILL_LOG - 1; i++)
173 party->party_kills[i] = party->party_kills[i + 1]; 163 party->party_kills[i] = party->party_kills[i + 1];
174 } 164 }
175 else 165 else
176 pos = party->kills; 166 pos = party->kills;
167
177 party->kills++; 168 party->kills++;
178 party->total_exp += exp; 169 party->total_exp += exp;
179 party->party_kills[pos].exp = exp; 170 party->party_kills[pos].exp = exp;
180 assign (party->party_kills[pos].killer, killer); 171 assign (party->party_kills[pos].killer, killer);
181 assign (party->party_kills[pos].dead, dead); 172 assign (party->party_kills[pos].dead, dead);
182 party->party_kills[pos].killer[MAX_NAME] = 0; 173 party->party_kills[pos].killer[MAX_NAME] = 0;
183 party->party_kills[pos].dead[MAX_NAME] = 0; 174 party->party_kills[pos].dead[MAX_NAME] = 0;
184} 175}
185#endif
186 176
187int 177int
188confirm_party_password (object *op) 178confirm_party_password (object *op)
189{ 179{
190 partylist *tmppartylist; 180 partylist *tmppartylist;
229} 219}
230 220
231void 221void
232send_party_message (object *op, char *msg) 222send_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
243{ 231{
244 char party_params[MAX_BUF]; 232 char party_params[MAX_BUF];
245 233
246 if (!params) 234 if (!params)
247 return 0; 235 return 0;
236
248 strcpy (party_params, "say "); 237 strcpy (party_params, "say ");
249 strcat (party_params, params); 238 strcat (party_params, params);
250 command_party (op, party_params); 239 command_party (op, party_params);
251 return 0; 240 return 0;
252} 241}
253
254 242
255int 243int
256command_party (object *op, char *params) 244command_party (object *op, char *params)
257{ 245{
258 char buf[MAX_BUF]; 246 char buf[MAX_BUF];
283 new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); 271 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>"); 272 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"); 273 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>"); 274 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"); 275 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"); 276 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills");
290#endif
291 return 1; 277 return 1;
292 } 278 }
293 279
294#ifdef PARTY_KILL_LOG
295 if (!strncmp (params, "kills", 5)) 280 if (!strncmp (params, "kills", 5))
296 { 281 {
297 int i, max; 282 int i, max;
298 char chr; 283 char chr;
299 char buffer[80]; 284 char buffer[80];
347 new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------"); 332 new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------");
348 sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr); 333 sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr);
349 new_draw_info (NDI_UNIQUE, 0, op, buffer); 334 new_draw_info (NDI_UNIQUE, 0, op, buffer);
350 return 1; 335 return 1;
351 } 336 }
352#endif /* PARTY_KILL_LOG */
353 337
354 if (strncmp (params, "say ", 4) == 0) 338 if (strncmp (params, "say ", 4) == 0)
355 { 339 {
356 if (op->contr->party == NULL) 340 if (op->contr->party == NULL)
357 { 341 {
367 } 351 }
368 352
369 if (strncmp (params, "form ", 5) == 0) 353 if (strncmp (params, "form ", 5) == 0)
370 { 354 {
371 int player_count; 355 int player_count;
372 player *pl;
373 356
374 params += 5; 357 params += 5;
375 if (op->contr->party) 358 if (op->contr->party)
376 oldparty = op->contr->party; 359 oldparty = op->contr->party;
377 else 360 else
400 * 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
401 */ 384 */
402 player_count = 0; 385 player_count = 0;
403 if (oldparty) 386 if (oldparty)
404 { 387 {
405 for (pl = first_player; pl->next != NULL; pl = pl->next) 388 for_all_players (pl)
406 {
407 if (pl->party == oldparty) 389 if (pl->party == oldparty)
408 player_count++; 390 player_count++;
409 } 391
410 if (player_count == 0) 392 if (player_count == 0)
411 remove_party (oldparty); 393 remove_party (oldparty);
412 } 394 }
395
413 return 0; 396 return 0;
414 } /* form */ 397 } /* form */
415 398
416 if (strcmp (params, "leave") == 0) 399 if (strcmp (params, "leave") == 0)
417 { 400 {
428 return 1; 411 return 1;
429 } 412 }
430 413
431 if (strcmp (params, "who") == 0) 414 if (strcmp (params, "who") == 0)
432 { 415 {
433 player *pl;
434
435 tmpparty = op->contr->party; 416 tmpparty = op->contr->party;
436 if (op->contr->party == NULL) 417 if (op->contr->party == NULL)
437 { 418 {
438 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.");
439 return 1; 420 return 1;
599 new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); 580 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>"); 581 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"); 582 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>"); 583 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"); 584 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"); 585 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills");
606#endif
607 return 1; 586 return 1;
608} 587}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines