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.17 by root, Sun Mar 18 03:05:40 2007 UTC vs.
Revision 1.42 by root, Sat Nov 17 23:40:03 2018 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 10 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation; either version 2 of the License, or 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * along with this program; if not, write to the Free Software 20 * and the GNU General Public License along with this program. If not, see
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25#include <global.h> 26#include <global.h>
26#include <sproto.h> 27#include <sproto.h>
27#include <spells.h> 28#include <spells.h>
28 29
29#ifdef COZY_SERVER 30static partylist *firstparty;
30// used for pet monster logic etc.
31int
32same_party (partylist *a, partylist *b)
33{
34 return a == b && a;
35}
36#endif
37
38static partylist *firstparty = NULL; /* Keeps track of first party in list */
39static partylist *lastparty = NULL; /*Keeps track of last party in list */
40 31
41partylist * 32partylist *
42get_firstparty (void) 33get_firstparty ()
43{ 34{
44 return firstparty; 35 return firstparty;
45} 36}
46 37
47void remove_party (partylist *target_party); 38static void
48
49/* Forms the party struct for a party called 'params'. it is the responsibility
50 * of the caller to ensure that the name is unique, and that it is placed in the
51 * main party list correctly */
52static partylist *
53form_party (object *op, const char *params)
54{
55 partylist *newparty;
56
57 newparty = (partylist *) malloc (sizeof (partylist));
58 newparty->partyname = strdup (params);
59 newparty->total_exp = 0;
60 newparty->kills = 0;
61 newparty->passwd[0] = '\0';
62 newparty->next = NULL;
63 newparty->partyleader = strdup (op->name);
64 new_draw_info_format (NDI_UNIQUE, 0, op, "You have formed party: %s", newparty->partyname);
65 op->contr->party = newparty;
66
67 return newparty;
68}
69
70void
71remove_party (partylist *target_party) 39remove_party (partylist *target_party)
72{ 40{
73 partylist *tmpparty;
74 partylist *previousparty;
75 partylist *nextparty;
76
77 if (firstparty == NULL) 41 if (firstparty == NULL)
78 { 42 {
79 LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); 43 LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname);
80 return; 44 return;
81 } 45 }
82 46
83 for_all_players (pl) 47 for_all_players (pl)
84 if (pl->party == target_party) 48 if (pl->party == target_party)
85 pl->party = NULL; 49 pl->party = NULL;
86 50
87 /* special case-ism for parties at the beginning and end of the list */ 51 partylist **prevlink = &firstparty;
88 if (target_party == firstparty)
89 {
90 firstparty = firstparty->next;
91 52
92 if (target_party->partyleader) 53 for (partylist *p = firstparty; p; p = p->next)
93 free (target_party->partyleader);
94
95 if (target_party->partyname)
96 free (target_party->partyname);
97
98 free (target_party);
99 return;
100 }
101 else if (target_party == lastparty)
102 {
103 for (tmpparty = firstparty; tmpparty->next != NULL; tmpparty = tmpparty->next)
104 {
105 if (tmpparty->next == target_party)
106 {
107 lastparty = tmpparty;
108
109 if (target_party->partyleader)
110 free (target_party->partyleader);
111
112 if (target_party->partyname)
113 free (target_party->partyname);
114
115 free (target_party);
116 lastparty->next = NULL;
117 return;
118 }
119 }
120 }
121 for (tmpparty = firstparty; tmpparty->next != NULL; tmpparty = tmpparty->next)
122 if (tmpparty->next == target_party) 54 if (p->next == target_party)
123 { 55 {
124 previousparty = tmpparty; 56 prevlink = &p->next;
125 nextparty = tmpparty->next->next;
126 /* this should be safe, because we already dealt with the lastparty case */
127
128 previousparty->next = nextparty;
129 if (target_party->partyleader)
130 free (target_party->partyleader);
131 if (target_party->partyname)
132 free (target_party->partyname);
133 free (target_party);
134 return; 57 break;
135 } 58 }
59
60 *prevlink = target_party->next;
61
62 free (target_party->partyleader);
63 free (target_party->partyname);
64 sfree (target_party);
136} 65}
137 66
138/* Remove unused parties, this could be made to scale a lot better. */ 67/* Remove unused parties, this could be made to scale a lot better. */
139void 68void
140obsolete_parties (void) 69obsolete_parties ()
141{ 70{
142 int player_count; 71 int player_count;
143 partylist *party; 72 partylist *party;
144 partylist *next = NULL; 73 partylist *next = NULL;
145 74
146 if (!firstparty) 75 if (!firstparty)
147 return; /* we can't obsolete parties if there aren't any */ 76 return; /* we can't obsolete parties if there aren't any */
77
148 for (party = firstparty; party != NULL; party = next) 78 for (party = firstparty; party != NULL; party = next)
149 { 79 {
150 next = party->next; 80 next = party->next;
151 player_count = 0; 81 player_count = 0;
152 for_all_players (pl) 82 for_all_players (pl)
181 assign (party->party_kills[pos].dead, dead); 111 assign (party->party_kills[pos].dead, dead);
182 party->party_kills[pos].killer[MAX_NAME] = 0; 112 party->party_kills[pos].killer[MAX_NAME] = 0;
183 party->party_kills[pos].dead[MAX_NAME] = 0; 113 party->party_kills[pos].dead[MAX_NAME] = 0;
184} 114}
185 115
186int 116static int
187confirm_party_password (object *op) 117confirm_party_password (object *op)
188{ 118{
189 partylist *tmppartylist; 119 partylist *tmppartylist;
190 120
191 for (tmppartylist = firstparty; tmppartylist != NULL; tmppartylist = tmppartylist->next) 121 for (tmppartylist = firstparty; tmppartylist != NULL; tmppartylist = tmppartylist->next)
197 else 127 else
198 return 1; 128 return 1;
199 } 129 }
200 } 130 }
201 return 1; 131 return 1;
132}
133
134static void
135send_party_message (object *op, const char *msg)
136{
137 for_all_players (pl)
138 if (pl->ob->contr->party == op->contr->party && pl->ob != op)
139 pl->send_msg (NDI_UNIQUE, MSG_CHANNEL ("party"), msg);
202} 140}
203 141
204void 142void
205receive_party_password (object *op, char k) 143receive_party_password (object *op, char k)
206{ 144{
225 op->contr->ns->state = ST_PLAYING; 163 op->contr->ns->state = ST_PLAYING;
226 return; 164 return;
227 } 165 }
228} 166}
229 167
230void
231send_party_message (object *op, char *msg)
232{
233 for_all_players (pl)
234 if (pl->ob->contr->party == op->contr->party && pl->ob != op)
235 new_draw_info (NDI_WHITE, 0, pl->ob, msg);
236}
237
238int 168int
239command_gsay (object *op, char *params) 169command_gsay (object *op, char *params)
240{ 170{
241 char party_params[MAX_BUF];
242
243 if (!params) 171 if (!params)
244 return 0; 172 return 0;
245 173
246 strcpy (party_params, "say ");
247 strcat (party_params, params);
248 command_party (op, party_params); 174 command_party (op, format ("say %s", params));
175
249 return 0; 176 return 0;
250} 177}
251 178
252int 179int
253command_party (object *op, char *params) 180command_party (object *op, char *params)
254{ 181{
255 char buf[MAX_BUF]; 182 dynbuf_text &buf = msg_dynbuf; buf.clear ();
256 partylist *tmpparty, *oldparty; /* For iterating over linked list */
257 char *currentparty; /* For iterating over linked list */
258 183
259 if (params == NULL) 184 partylist *party = op->contr->party;
260 {
261 if (op->contr->party == NULL)
262 {
263 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
264 new_draw_info (NDI_UNIQUE, 0, op, "For help try: party help");
265 }
266 else
267 {
268 currentparty = op->contr->party->partyname;
269 new_draw_info_format (NDI_UNIQUE, 0, op, "You are a member of party %s.", currentparty);
270 }
271 return 1;
272 }
273 185
186 if (!params)
187 params = (char *)"";
188
274 if (strcmp (params, "help") == 0) 189 if (!strcmp (params, "help"))
275 { 190 buf << "\n"
276 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>"); 191 " - To form a party type: C<party form> <partyname>\n"
277 new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>"); 192 " - To join a party type: C<party join> <partyname>\n"
278 new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it."); 193 " - If the party has a passwd, it will you prompt you for it.\n"
279 new_draw_info (NDI_UNIQUE, 0, op, "For a list of current parties type: party list"); 194 " - For a list of current parties type: C<party list>\n"
280 new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); 195 " - To leave a party type: C<party leave>\n"
281 new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>"); 196 " - To change a passwd for a party type: C<party passwd> <password>\n"
282 new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max"); 197 " - There is an 8 character max\n"
283 new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>"); 198 " - To talk to party members type: C<party say> <msg>\n"
284 new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who"); 199 " - To see who is in your party: C<party who>\n"
285 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); 200 " - To see what you've killed, type: C<party kills>\n";
286 return 1;
287 }
288
289 if (!strncmp (params, "kills", 5))
290 {
291 int i, max;
292 char chr;
293 char buffer[80];
294 float exp;
295
296 if (op->contr->party == NULL)
297 {
298 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
299 return 1;
300 }
301 tmpparty = op->contr->party;
302 if (!tmpparty->kills)
303 {
304 new_draw_info (NDI_UNIQUE, 0, op, "You haven't killed anything yet.");
305 return 1;
306 }
307 max = tmpparty->kills - 1;
308 if (max > PARTY_KILL_LOG - 1)
309 max = PARTY_KILL_LOG - 1;
310 new_draw_info (NDI_UNIQUE, 0, op, "Killed | Killer| Exp");
311 new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------");
312 for (i = 0; i <= max; i++)
313 {
314 exp = tmpparty->party_kills[i].exp;
315 chr = ' ';
316 if (exp > 1000000)
317 {
318 exp /= 1000000;
319 chr = 'M';
320 }
321 else if (exp > 1000)
322 {
323 exp /= 1000;
324 chr = 'k';
325 }
326 sprintf (buffer, "%16s|%16s|%6.1f%c", tmpparty->party_kills[i].dead, tmpparty->party_kills[i].killer, exp, chr);
327 new_draw_info (NDI_UNIQUE, 0, op, buffer);
328 }
329 exp = tmpparty->total_exp;
330 chr = ' ';
331 if (exp > 1000000)
332 {
333 exp /= 1000000;
334 chr = 'M';
335 }
336 else if (exp > 1000)
337 {
338 exp /= 1000;
339 chr = 'k';
340 }
341 new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------");
342 sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr);
343 new_draw_info (NDI_UNIQUE, 0, op, buffer);
344 return 1;
345 }
346
347 if (strncmp (params, "say ", 4) == 0)
348 {
349 if (op->contr->party == NULL)
350 {
351 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
352 return 1;
353 }
354 params += 4;
355 currentparty = op->contr->party->partyname;
356 snprintf (buf, MAX_BUF - 1, "[%s] %s says: %s", currentparty, &op->name, params);
357 send_party_message (op, buf);
358 new_draw_info_format (NDI_LT_GREEN | NDI_UNIQUE, 0, op, "[%s] You say: %s", currentparty, params);
359 return 1;
360 }
361
362 if (strncmp (params, "form ", 5) == 0) 201 else if (strncmp (params, "form ", 5) == 0)
363 { 202 {
364 int player_count;
365
366 params += 5; 203 params += 5;
367 if (op->contr->party)
368 oldparty = op->contr->party;
369 else
370 oldparty = NULL;
371 204
372 if (firstparty) 205 if (party)
206 buf << "You are already a member of party " << party->partyname << ". You must leave it first.";
207 else
373 { 208 {
374 for (tmpparty = firstparty; tmpparty != NULL; tmpparty = tmpparty->next) 209 for (partylist *tmpparty = firstparty; tmpparty; tmpparty = tmpparty->next)
375 { 210 {
376 if (!strcmp (tmpparty->partyname, params)) 211 if (!strcmp (tmpparty->partyname, params))
377 { 212 {
378 new_draw_info_format (NDI_UNIQUE, 0, op, "The party %s already exists, pick another name", params); 213 buf << "The party " << tmpparty->partyname << " already exists, pick another name";
379 return 1; 214 goto reply;
380 } 215 }
381 } 216 }
382 lastparty->next = form_party (op, params); 217
383 lastparty = lastparty->next; 218 /* Forms the party struct for a party called 'params'. it is the responsibility
384 } 219 * of the caller to ensure that the name is unique, and that it is placed in the
385 else 220 * main party list correctly */
386 { 221
387 firstparty = form_party (op, params); 222 party = salloc0<partylist> ();
223 party->partyname = strdup (params);
224 party->total_exp = 0;
225 party->kills = 0;
226 party->passwd[0] = '\0';
227 party->next = NULL;
228 party->partyleader = strdup (op->name);
229
230 buf << "You have formed party: " << party->partyname << ".";
231
388 lastparty = firstparty; 232 party->next = firstparty;
389 } 233 op->contr->party = firstparty = party;
390 /*
391 * The player might have previously been a member of a party, if so, he will be leaving
392 * it, so check if there are any other members and if not, delete the party
393 */
394 player_count = 0;
395 if (oldparty)
396 {
397 for_all_players (pl)
398 if (pl->party == oldparty)
399 player_count++;
400
401 if (player_count == 0)
402 remove_party (oldparty);
403 }
404
405 return 0;
406 } /* form */
407
408 if (strcmp (params, "leave") == 0)
409 {
410 if (op->contr->party == NULL)
411 {
412 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
413 return 1;
414 }
415 currentparty = op->contr->party->partyname;
416 new_draw_info_format (NDI_UNIQUE, 0, op, "You leave party %s.", currentparty);
417 sprintf (buf, "%s leaves party %s.", &op->name, currentparty);
418 send_party_message (op, buf);
419 op->contr->party = NULL;
420 return 1;
421 }
422
423 if (strcmp (params, "who") == 0)
424 {
425 tmpparty = op->contr->party;
426 if (op->contr->party == NULL)
427 {
428 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
429 return 1;
430 }
431 new_draw_info_format (NDI_UNIQUE, 0, op, "Members of party: %s.", op->contr->party->partyname);
432 for_all_players (pl)
433 if (pl->ob->contr->party == op->contr->party)
434 {
435 if (settings.set_title == TRUE)
436 {
437 if (pl->ob->contr->own_title[0] != '\0')
438 sprintf (buf, "%3d %s the %s", pl->ob->level, &pl->ob->name, pl->ob->contr->own_title);
439 else
440 sprintf (buf, "%3d %s the %s", pl->ob->level, &pl->ob->name, pl->ob->contr->title);
441 }
442 else
443 sprintf (buf, "%3d %s the %s", pl->ob->level, &pl->ob->name, pl->ob->contr->title);
444 new_draw_info (NDI_UNIQUE, 0, op, buf);
445 } 234 }
446 return 1; 235 }
447 } /* leave */ 236 else if (strcmp (params, "list") == 0)
237 {
238 if (!firstparty)
239 buf << "There are no parties active right now";
240 else
241 {
242 buf << "Party name Leader\n\n"
243 "---------- ------\n\n";
448 244
245 for (partylist *p = firstparty; p; p = p->next)
246 buf.printf ("%-32s %s\n\n", p->partyname, p->partyleader);
247 }
248 }
449 if (strncmp (params, "passwd ", 7) == 0) 249 else if (strncmp (params, "join ", 5) == 0)
450 { 250 {
451 partylist *tmplist;
452
453 params += 7; 251 params += 5;
454 252
455 if (op->contr->party == NULL) 253 /* Can't join a party cause non exist */
456 { 254 if (!firstparty)
457 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of a party"); 255 buf << "Party: " << params << " does not exist. You must form it first.";
458 return 1; 256 else if (party)
459 } 257 buf << "You are already a member of party " << party->partyname << ". You must leave it first.";
460 258 else
461 if (strlen (params) > 8) 259 for (partylist *p = firstparty; p; p = p->next)
462 { 260 if (!strcmp (p->partyname, params))
463 new_draw_info (NDI_UNIQUE, 0, op, "The password must not exceed 8 characters");
464 return 1;
465 }
466
467 tmplist = firstparty;
468 while (tmplist != NULL)
469 {
470 if (tmplist == op->contr->party)
471 { 261 {
472 strcpy (tmplist->passwd, params); 262 if (!*p->passwd)
473 new_draw_info_format (NDI_UNIQUE, 0, op, "The password for party %s is %s", tmplist->partyname, tmplist->passwd); 263 {
474 snprintf (buf, MAX_BUF, "Password for party %s is now %s, changed by %s", tmplist->partyname, tmplist->passwd, &op->name); 264 op->contr->party = p;
265
266 buf << op->name << " joins party " << p->partyname << ".";
475 send_party_message (op, buf); 267 send_party_message (op, buf);
476 return 0; 268 buf.clear ();
269
270 buf << "You have joined party: " << p->partyname << ".";
477 } 271 }
478 tmplist = tmplist->next;
479 }
480 return 0;
481 } /* passwd */
482
483 if (strcmp (params, "list") == 0)
484 {
485 partylist *tmplist;
486
487 tmplist = firstparty;
488
489 if (firstparty == NULL)
490 {
491 new_draw_info (NDI_UNIQUE, 0, op, "There are no parties active right now");
492 return 1;
493 }
494
495 new_draw_info (NDI_UNIQUE, 0, op, "Party name Leader");
496 new_draw_info (NDI_UNIQUE, 0, op, "---------- ------");
497
498 while (tmplist != NULL)
499 {
500 new_draw_info_format (NDI_UNIQUE, 0, op, "%-32s %s", tmplist->partyname, tmplist->partyleader);
501 tmplist = tmplist->next;
502 }
503 return 0;
504 } /* list */
505
506 if (strncmp (params, "join ", 5) == 0)
507 {
508
509 params += 5;
510
511 /* Can't join a party cause non exist */
512 if (firstparty == NULL)
513 {
514 new_draw_info_format (NDI_UNIQUE, 0, op, "Party: %s does not exist. You must form it first", params);
515 return 1;
516 }
517
518 /* Special case if thier is only one party */
519 if (firstparty->next == NULL)
520 {
521 if (strcmp (firstparty->partyname, params) != 0)
522 { 272 else
523 new_draw_info_format (NDI_UNIQUE, 0, op, "Party: %s does not exist. You must form it first", params); 273 get_party_password (op, p);
524 return 1; 274
275 goto reply;
525 } 276 }
526 else 277 else
278 buf << "Party " << params << " does not exist. You must form it first.";
279 }
280 else if (!party)
281 buf << "You are not a member of any party.\n\n"
282 "For help try: C<party help>";
283 else if (!*params)
284 buf << "You are a member of party " << party->partyname << ".";
285 else if (!strncmp (params, "kills", 5))
286 {
287 if (!party->kills)
288 buf << "You haven't killed anything yet.";
289 else
290 {
291 int max = min (party->kills - 1, PARTY_KILL_LOG - 1);
292
293 buf << " Killed | Killer| Exp\n"
294 << " ----------------+----------------+--------\n";
295
296 for (int i = 0; i <= max; i++)
527 { 297 {
528 if (op->contr->party == firstparty) 298 sint64 exp = party->party_kills[i].exp;
299 char suffix = ' ';
300 if (exp > 1000000)
529 { 301 {
530 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already in party: %s", firstparty->partyname); 302 exp /= 1000000;
531 return 1; 303 suffix = 'M';
532 } 304 }
533 /* found party player wants to join */ 305 else if (exp > 1000)
534 if (firstparty->passwd[0] == '\0')
535 { 306 {
536 op->contr->party = firstparty; 307 exp /= 1000;
537 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s", firstparty->partyname); 308 suffix = 'k';
538 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, firstparty->partyname);
539 send_party_message (op, buf);
540 return 0;
541 } 309 }
542 else 310
543 { 311 buf.printf (" %16s|%16s|%6.1f%c\n", party->party_kills[i].dead, party->party_kills[i].killer, (double)exp, suffix);
544 get_party_password (op, firstparty);
545 return 0;
546 }
547 } 312 }
548 }
549 313
550 tmpparty = firstparty; 314 buf << " ----------------+----------------+--------\n";
551 while (tmpparty != NULL) 315
552 {
553 if (strcmp (tmpparty->partyname, params) == 0)
554 { 316 {
555 if (op->contr->party == tmpparty) 317 sint64 exp = party->total_exp;
318 char suffix = ' ';
319
320 if (exp > 1000000)
556 { 321 {
557 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already a member of party: %s", tmpparty->partyname); 322 exp /= 1000000;
558 return 1; 323 suffix = 'M';
559 } 324 }
560 else 325 else if (exp > 1000)
561 { 326 {
562 if (tmpparty->passwd[0] == '\0') 327 exp /= 1000;
563 { 328 suffix = 'k';
564 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s", tmpparty->partyname);
565 op->contr->party = tmpparty;
566 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, tmpparty->partyname);
567 send_party_message (op, buf);
568 return 0;
569 }
570 else
571 {
572 get_party_password (op, tmpparty);
573 return 0;
574 }
575 } 329 }
330
331 buf.printf (" Totals: %d kills, %.1f%c exp", party->kills, (double)exp, suffix);
576 } 332 }
333 }
334 }
335 else if (strncmp (params, "say ", 4) == 0)
336 {
337 params += 4;
338
339 buf << "[" << party->partyname << "] " << op->name << " says: " << params;
340 send_party_message (op, buf);
341 buf.clear ();
342
343 buf << "[" << party->partyname << "] You say: " << params;
344 }
345 else if (strcmp (params, "leave") == 0)
346 {
347 buf << op->name << " leaves party " << party->partyname << ".";
348 send_party_message (op, buf);
349 buf.clear ();
350
351 buf << "You leave party " << party->partyname << ".";
352
353 op->contr->party = 0;
354 obsolete_parties ();
355 }
356 else if (strcmp (params, "who") == 0)
357 {
358 buf << "Members of party " << party->partyname << ".\n";
359
360 for_all_players (pl)
361 if (pl->ob->contr->party == party)
362 buf.printf (" - %s/%d %s\n\n", &pl->ob->name, pl->ob->level,
363 *pl->ob->contr->own_title ? pl->ob->contr->own_title : pl->ob->contr->title);
364 }
365 else if (strncmp (params, "passwd ", 7) == 0)
366 {
367 params += 7;
368
369 if (strlen (params) > 8)
370 buf << "The password must not exceed 8 characters";
577 else 371 else
578 tmpparty = tmpparty->next;
579 } 372 {
373 strcpy (party->passwd, params);
374 buf << "The password for party " << party->partyname << " is set to B<" << params << "> by " << &op->name;
375 }
376 }
377 else
378 buf << "I did not understand your command. For help try: C<party help>";
580 379
581 new_draw_info_format (NDI_UNIQUE, 0, op, "Party %s does not exist. You must form it first.", params); 380reply:
582 return 1; 381 op->contr->send_msg (NDI_UNIQUE | NDI_REPLY, MSG_CHANNEL ("party"), buf);
583 } /* join */
584 382
585 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>");
586 new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>");
587 new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it.");
588 new_draw_info (NDI_UNIQUE, 0, op, "For a list of current parties type: party list");
589 new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave");
590 new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>");
591 new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max");
592 new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>");
593 new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who");
594 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills");
595 return 1; 383 return 1;
596} 384}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines