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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines