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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines