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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines