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.8 by root, Thu Dec 14 22:45:41 2006 UTC vs.
Revision 1.28 by root, Mon Apr 27 01:38:49 2009 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 11 * (at your 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 GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 *
20 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#ifndef __CEXTRACT__
26# include <sproto.h> 25#include <sproto.h>
27#endif
28#include <spells.h> 26#include <spells.h>
29 27
30#ifdef COZY_SERVER 28static 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 29
42partylist * 30partylist *
43get_firstparty (void) 31get_firstparty (void)
44{ 32{
45 return firstparty; 33 return firstparty;
46} 34}
47 35
48void remove_party (partylist *target_party);
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 36void
72remove_party (partylist *target_party) 37remove_party (partylist *target_party)
73{ 38{
74 partylist *tmpparty;
75 partylist *previousparty;
76 partylist *nextparty;
77 player *pl;
78
79 if (firstparty == NULL) 39 if (firstparty == NULL)
80 { 40 {
81 LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); 41 LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname);
82 return; 42 return;
83 } 43 }
84 44
85 for (pl = first_player; pl != NULL; pl = pl->next) 45 for_all_players (pl)
86 if (pl->party == target_party) 46 if (pl->party == target_party)
87 pl->party = NULL; 47 pl->party = NULL;
88 48
89 /* special case-ism for parties at the beginning and end of the list */ 49 partylist **prevlink = &firstparty;
90 if (target_party == firstparty)
91 {
92 firstparty = firstparty->next;
93 50
94 if (target_party->partyleader) 51 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) 52 if (p->next == target_party)
125 { 53 {
126 previousparty = tmpparty; 54 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; 55 break;
137 } 56 }
57
58 *prevlink = target_party->next;
59
60 free (target_party->partyleader);
61 free (target_party->partyname);
62 sfree (target_party);
138} 63}
139 64
140/* Remove unused parties, this could be made to scale a lot better. */ 65/* Remove unused parties, this could be made to scale a lot better. */
141void 66void
142obsolete_parties (void) 67obsolete_parties (void)
143{ 68{
144 int player_count; 69 int player_count;
145 player *pl;
146 partylist *party; 70 partylist *party;
147 partylist *next = NULL; 71 partylist *next = NULL;
148 72
149 if (!firstparty) 73 if (!firstparty)
150 return; /* we can't obsolete parties if there aren't any */ 74 return; /* we can't obsolete parties if there aren't any */
75
151 for (party = firstparty; party != NULL; party = next) 76 for (party = firstparty; party != NULL; party = next)
152 { 77 {
153 next = party->next; 78 next = party->next;
154 player_count = 0; 79 player_count = 0;
155 for (pl = first_player; pl != NULL; pl = pl->next) 80 for_all_players (pl)
156 if (pl->party == party) 81 if (pl->party == party)
157 player_count++; 82 player_count++;
158 if (player_count == 0) 83 if (player_count == 0)
159 remove_party (party); 84 remove_party (party);
160 } 85 }
161} 86}
162 87
163#ifdef PARTY_KILL_LOG
164void 88void
165add_kill_to_party (partylist *party, char *killer, char *dead, long exp) 89add_kill_to_party (partylist *party, const char *killer, const char *dead, long exp)
166{ 90{
167 int i, pos; 91 int i, pos;
168 92
169 if (party == NULL) 93 if (party == NULL)
170 return; 94 return;
95
171 if (party->kills >= PARTY_KILL_LOG) 96 if (party->kills >= PARTY_KILL_LOG)
172 { 97 {
173 pos = PARTY_KILL_LOG - 1; 98 pos = PARTY_KILL_LOG - 1;
174 for (i = 0; i < PARTY_KILL_LOG - 1; i++) 99 for (i = 0; i < PARTY_KILL_LOG - 1; i++)
175 party->party_kills[i] = party->party_kills[i + 1]; 100 party->party_kills[i] = party->party_kills[i + 1];
176 } 101 }
177 else 102 else
178 pos = party->kills; 103 pos = party->kills;
104
179 party->kills++; 105 party->kills++;
180 party->total_exp += exp; 106 party->total_exp += exp;
181 party->party_kills[pos].exp = exp; 107 party->party_kills[pos].exp = exp;
182 assign (party->party_kills[pos].killer, killer); 108 assign (party->party_kills[pos].killer, killer);
183 assign (party->party_kills[pos].dead, dead); 109 assign (party->party_kills[pos].dead, dead);
184 party->party_kills[pos].killer[MAX_NAME] = 0; 110 party->party_kills[pos].killer[MAX_NAME] = 0;
185 party->party_kills[pos].dead[MAX_NAME] = 0; 111 party->party_kills[pos].dead[MAX_NAME] = 0;
186} 112}
187#endif
188 113
189int 114int
190confirm_party_password (object *op) 115confirm_party_password (object *op)
191{ 116{
192 partylist *tmppartylist; 117 partylist *tmppartylist;
200 else 125 else
201 return 1; 126 return 1;
202 } 127 }
203 } 128 }
204 return 1; 129 return 1;
130}
131
132void
133send_party_message (object *op, const char *msg)
134{
135 for_all_players (pl)
136 if (pl->ob->contr->party == op->contr->party && pl->ob != op)
137 pl->send_msg (NDI_UNIQUE, MSG_CHANNEL ("party"), msg);
205} 138}
206 139
207void 140void
208receive_party_password (object *op, char k) 141receive_party_password (object *op, char k)
209{ 142{
216 op->contr->party = op->contr->party_to_join; 149 op->contr->party = op->contr->party_to_join;
217 op->contr->party_to_join = NULL; 150 op->contr->party_to_join = NULL;
218 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname); 151 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname);
219 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname); 152 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname);
220 send_party_message (op, buf); 153 send_party_message (op, buf);
221 op->contr->state = ST_PLAYING; 154 op->contr->ns->state = ST_PLAYING;
222 return; 155 return;
223 } 156 }
224 else 157 else
225 { 158 {
226 new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password"); 159 new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password");
227 op->contr->party_to_join = NULL; 160 op->contr->party_to_join = NULL;
228 op->contr->state = ST_PLAYING; 161 op->contr->ns->state = ST_PLAYING;
229 return; 162 return;
230 } 163 }
231}
232
233void
234send_party_message (object *op, char *msg)
235{
236 player *pl;
237
238 for (pl = first_player; pl != NULL; pl = pl->next)
239 if (pl->ob->contr->party == op->contr->party && pl->ob != op)
240 new_draw_info (NDI_WHITE, 0, pl->ob, msg);
241} 164}
242 165
243int 166int
244command_gsay (object *op, char *params) 167command_gsay (object *op, char *params)
245{ 168{
246 char party_params[MAX_BUF]; 169 char party_params[MAX_BUF];
247 170
248 if (!params) 171 if (!params)
249 return 0; 172 return 0;
173
250 strcpy (party_params, "say "); 174 strcpy (party_params, "say ");
251 strcat (party_params, params); 175 strcat (party_params, params);
252 command_party (op, party_params); 176 command_party (op, party_params);
253 return 0; 177 return 0;
254} 178}
255 179
256
257int 180int
258command_party (object *op, char *params) 181command_party (object *op, char *params)
259{ 182{
260 char buf[MAX_BUF]; 183 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 184
264 if (params == NULL) 185 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 186
187 if (!params)
188 params = (char *)"";
189
279 if (strcmp (params, "help") == 0) 190 if (!strcmp (params, "help"))
280 { 191 buf << "\n"
281 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>"); 192 " - 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>"); 193 " - 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."); 194 " - 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"); 195 " - 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"); 196 " - 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>"); 197 " - 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"); 198 " - There is an 8 character max\n"
288 new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>"); 199 " - 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"); 200 " - To see who is in your party: C<party who>\n"
290#ifdef PARTY_KILL_LOG 201 " - 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) 202 else if (strncmp (params, "form ", 5) == 0)
372 { 203 {
373 int player_count;
374 player *pl;
375
376 params += 5; 204 params += 5;
377 if (op->contr->party)
378 oldparty = op->contr->party;
379 else
380 oldparty = NULL;
381 205
382 if (firstparty) 206 if (party)
207 buf << "You are already a member of party " << party->partyname << ". You must leave it first.";
208 else
383 { 209 {
384 for (tmpparty = firstparty; tmpparty != NULL; tmpparty = tmpparty->next) 210 for (partylist *tmpparty = firstparty; tmpparty; tmpparty = tmpparty->next)
385 { 211 {
386 if (!strcmp (tmpparty->partyname, params)) 212 if (!strcmp (tmpparty->partyname, params))
387 { 213 {
388 new_draw_info_format (NDI_UNIQUE, 0, op, "The party %s already exists, pick another name", params); 214 buf << "The party " << tmpparty->partyname << " already exists, pick another name";
389 return 1; 215 goto reply;
390 } 216 }
391 } 217 }
392 lastparty->next = form_party (op, params); 218
393 lastparty = lastparty->next; 219 /* Forms the party struct for a party called 'params'. it is the responsibility
394 } 220 * of the caller to ensure that the name is unique, and that it is placed in the
395 else 221 * main party list correctly */
222
223 party = salloc0<partylist> ();
224 party->partyname = strdup (params);
225 party->total_exp = 0;
226 party->kills = 0;
227 party->passwd[0] = '\0';
228 party->next = NULL;
229 party->partyleader = strdup (op->name);
230
231 buf << "You have formed party: " << party->partyname << ".";
232
233 party->next = firstparty;
234 op->contr->party = firstparty = party;
396 { 235 }
397 firstparty = form_party (op, params); 236 }
398 lastparty = firstparty; 237 else if (strcmp (params, "list") == 0)
238 {
239 if (!firstparty)
240 buf << "There are no parties active right now";
241 else
399 } 242 {
400 /* 243 buf << "Party name Leader\n\n"
401 * The player might have previously been a member of a party, if so, he will be leaving 244 "---------- ------\n\n";
402 * it, so check if there are any other members and if not, delete the party 245
403 */ 246 for (partylist *p = firstparty; p; p = p->next)
404 player_count = 0; 247 buf.printf ("%-32s %s\n\n", p->partyname, p->partyleader);
405 if (oldparty)
406 { 248 }
407 for (pl = first_player; pl->next != NULL; pl = pl->next) 249 }
250 else if (strncmp (params, "join ", 5) == 0)
251 {
252 params += 5;
253
254 /* Can't join a party cause non exist */
255 if (!firstparty)
256 buf << "Party: " << params << " does not exist. You must form it first.";
257 else if (party)
258 buf << "You are already a member of party " << party->partyname << ". You must leave it first.";
259 else
260 for (partylist *p = firstparty; p; p = p->next)
261 if (!strcmp (p->partyname, params))
408 { 262 {
409 if (pl->party == oldparty) 263 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 (pl = first_player; pl != NULL; pl = pl->next)
445 if (pl->ob->contr->party == op->contr->party)
446 {
447 if (settings.set_title == TRUE)
448 { 264 {
449 if (pl->ob->contr->own_title[0] != '\0') 265 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 266
461 if (strncmp (params, "passwd ", 7) == 0) 267 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); 268 send_party_message (op, buf);
488 return 0; 269 buf.clear ();
270
271 buf << "You have joined party: " << p->partyname << ".";
489 } 272 }
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 { 273 else
535 new_draw_info_format (NDI_UNIQUE, 0, op, "Party: %s does not exist. You must form it first", params); 274 get_party_password (op, p);
536 return 1; 275
276 goto reply;
537 } 277 }
538 else 278 else
279 buf << "Party " << params << " does not exist. You must form it first.";
280 }
281 else if (!party)
282 buf << "You are not a member of any party.\n\n"
283 "For help try: C<party help>";
284 else if (!*params)
285 buf << "You are a member of party " << party->partyname << ".";
286 else if (!strncmp (params, "kills", 5))
287 {
288 if (!party->kills)
289 buf << "You haven't killed anything yet.";
290 else
291 {
292 int max = min (party->kills - 1, PARTY_KILL_LOG - 1);
293
294 buf << " Killed | Killer| Exp\n"
295 << " ----------------+----------------+--------\n";
296
297 for (int i = 0; i <= max; i++)
539 { 298 {
540 if (op->contr->party == firstparty) 299 sint64 exp = party->party_kills[i].exp;
300 char suffix = ' ';
301 if (exp > 1000000)
541 { 302 {
542 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already in party: %s", firstparty->partyname); 303 exp /= 1000000;
543 return 1; 304 suffix = 'M';
544 } 305 }
545 /* found party player wants to join */ 306 else if (exp > 1000)
546 if (firstparty->passwd[0] == '\0')
547 { 307 {
548 op->contr->party = firstparty; 308 exp /= 1000;
549 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s", firstparty->partyname); 309 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 } 310 }
554 else 311
555 { 312 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 } 313 }
560 }
561 314
562 tmpparty = firstparty; 315 buf << " ----------------+----------------+--------\n";
563 while (tmpparty != NULL) 316
564 {
565 if (strcmp (tmpparty->partyname, params) == 0)
566 { 317 {
567 if (op->contr->party == tmpparty) 318 sint64 exp = party->total_exp;
319 char suffix = ' ';
320
321 if (exp > 1000000)
568 { 322 {
569 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already a member of party: %s", tmpparty->partyname); 323 exp /= 1000000;
570 return 1; 324 suffix = 'M';
571 } 325 }
572 else 326 else if (exp > 1000)
573 { 327 {
574 if (tmpparty->passwd[0] == '\0') 328 exp /= 1000;
575 { 329 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 } 330 }
331
332 buf.printf (" Totals: %d kills, %.1f%c exp", party->kills, (double)exp, suffix);
588 } 333 }
334 }
335 }
336 else if (strncmp (params, "say ", 4) == 0)
337 {
338 params += 4;
339
340 buf << "[" << party->partyname << "] " << op->name << " says: " << params;
341 send_party_message (op, buf);
342 buf.clear ();
343
344 buf << "[" << party->partyname << "] You say: " << params;
345 }
346 else if (strcmp (params, "leave") == 0)
347 {
348 buf << op->name << " leaves party " << party->partyname << ".";
349 send_party_message (op, buf);
350 buf.clear ();
351
352 buf << "You leave party " << party->partyname << ".";
353
354 op->contr->party = 0;
355 obsolete_parties ();
356 }
357 else if (strcmp (params, "who") == 0)
358 {
359 buf << "Members of party " << party->partyname << ".\n";
360
361 for_all_players (pl)
362 if (pl->ob->contr->party == party)
363 buf.printf (" - %s/%d %s\n\n", &pl->ob->name, pl->ob->level,
364 *pl->ob->contr->own_title ? pl->ob->contr->own_title : pl->ob->contr->title);
365 }
366 else if (strncmp (params, "passwd ", 7) == 0)
367 {
368 params += 7;
369
370 if (strlen (params) > 8)
371 buf << "The password must not exceed 8 characters";
589 else 372 else
590 tmpparty = tmpparty->next;
591 } 373 {
374 strcpy (party->passwd, params);
375 buf << "The password for party " << party->partyname << " is set to B<" << params << "> by " << &op->name;
376 }
377 }
378 else
379 buf << "I did not understand your command. For help try: C<party help>";
592 380
593 new_draw_info_format (NDI_UNIQUE, 0, op, "Party %s does not exist. You must form it first.", params); 381reply:
594 return 1; 382 op->contr->send_msg (NDI_UNIQUE | NDI_REPLY, MSG_CHANNEL ("party"), buf);
595 } /* join */
596 383
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; 384 return 1;
610} 385}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines