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.6 by root, Thu Sep 14 22:34:03 2006 UTC vs.
Revision 1.26 by root, Sun Sep 7 21:31:23 2008 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_local (params);
60 newparty->total_exp = 0;
61 newparty->kills = 0;
62 newparty->passwd[0] = '\0';
63 newparty->next = NULL;
64 newparty->partyleader = strdup_local (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;
261 partylist *tmpparty, *oldparty; /* For iterating over linked list */ 184 partylist *party = op->contr->party;
262 char *currentparty; /* For iterating over linked list */
263 185
264 if (params == NULL) 186 if (!params)
265 { 187 params = (char *)"";
266 if (op->contr->party == NULL) 188
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 if (strcmp (params, "help") == 0) 189 if (!strcmp (params, "help"))
279 { 190 buf << " - To form a party type: C<party form> <partyname>\n"
280 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>"); 191 " - To join a party type: C<party join> <partyname>\n"
281 new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>");
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#ifdef PARTY_KILL_LOG 199 " - To see what you've killed, type: C<party kills>\n";
290 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills");
291#endif
292 return 1;
293 }
294#ifdef PARTY_KILL_LOG
295 if (!strncmp (params, "kills", 5))
296 {
297 int i, max;
298 char chr;
299 char buffer[80];
300 float exp;
301
302 if (op->contr->party == NULL)
303 {
304 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
305 return 1;
306 }
307 tmpparty = op->contr->party;
308 if (!tmpparty->kills)
309 {
310 new_draw_info (NDI_UNIQUE, 0, op, "You haven't killed anything yet.");
311 return 1;
312 }
313 max = tmpparty->kills - 1;
314 if (max > PARTY_KILL_LOG - 1)
315 max = PARTY_KILL_LOG - 1;
316 new_draw_info (NDI_UNIQUE, 0, op, "Killed | Killer| Exp");
317 new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------");
318 for (i = 0; i <= max; i++)
319 {
320 exp = tmpparty->party_kills[i].exp;
321 chr = ' ';
322 if (exp > 1000000)
323 {
324 exp /= 1000000;
325 chr = 'M';
326 }
327 else if (exp > 1000)
328 {
329 exp /= 1000;
330 chr = 'k';
331 }
332 sprintf (buffer, "%16s|%16s|%6.1f%c", tmpparty->party_kills[i].dead, tmpparty->party_kills[i].killer, exp, chr);
333 new_draw_info (NDI_UNIQUE, 0, op, buffer);
334 }
335 exp = tmpparty->total_exp;
336 chr = ' ';
337 if (exp > 1000000)
338 {
339 exp /= 1000000;
340 chr = 'M';
341 }
342 else if (exp > 1000)
343 {
344 exp /= 1000;
345 chr = 'k';
346 }
347 new_draw_info (NDI_UNIQUE, 0, op, "----------------+----------------+--------");
348 sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr);
349 new_draw_info (NDI_UNIQUE, 0, op, buffer);
350 return 1;
351 }
352#endif /* PARTY_KILL_LOG */
353 if (strncmp (params, "say ", 4) == 0)
354 {
355 if (op->contr->party == NULL)
356 {
357 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
358 return 1;
359 }
360 params += 4;
361 currentparty = op->contr->party->partyname;
362 snprintf (buf, MAX_BUF - 1, "[%s] %s says: %s", currentparty, &op->name, params);
363 send_party_message (op, buf);
364 new_draw_info_format (NDI_WHITE, 0, op, "[%s] You say: %s", currentparty, params);
365 return 1;
366 }
367
368 if (strncmp (params, "form ", 5) == 0) 200 else if (strncmp (params, "form ", 5) == 0)
369 { 201 {
370 int player_count;
371 player *pl;
372
373 params += 5; 202 params += 5;
374 if (op->contr->party)
375 oldparty = op->contr->party;
376 else
377 oldparty = NULL;
378 203
379 if (firstparty) 204 if (party)
205 buf << "You are already a member of party " << party->partyname << ". You must leave it first.";
206 else
380 { 207 {
381 for (tmpparty = firstparty; tmpparty != NULL; tmpparty = tmpparty->next) 208 for (partylist *tmpparty = firstparty; tmpparty; tmpparty = tmpparty->next)
382 { 209 {
383 if (!strcmp (tmpparty->partyname, params)) 210 if (!strcmp (tmpparty->partyname, params))
384 { 211 {
385 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";
386 return 1; 213 goto reply;
387 } 214 }
388 } 215 }
389 lastparty->next = form_party (op, params); 216
390 lastparty = lastparty->next; 217 /* Forms the party struct for a party called 'params'. it is the responsibility
391 } 218 * of the caller to ensure that the name is unique, and that it is placed in the
392 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;
393 { 233 }
394 firstparty = form_party (op, params); 234 }
395 lastparty = firstparty; 235 else if (strcmp (params, "list") == 0)
236 {
237 if (!firstparty)
238 buf << "There are no parties active right now";
239 else
396 } 240 {
397 /* 241 buf << "Party name Leader\n\n"
398 * The player might have previously been a member of a party, if so, he will be leaving 242 "---------- ------\n\n";
399 * it, so check if there are any other members and if not, delete the party 243
400 */ 244 for (partylist *p = firstparty; p; p = p->next)
401 player_count = 0; 245 buf.printf ("%-32s %s\n\n", p->partyname, p->partyleader);
402 if (oldparty)
403 { 246 }
404 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))
405 { 260 {
406 if (pl->party == oldparty) 261 if (!*p->passwd)
407 player_count++;
408 }
409 if (player_count == 0)
410 remove_party (oldparty);
411 }
412 return 0;
413 } /* form */
414
415 if (strcmp (params, "leave") == 0)
416 {
417 if (op->contr->party == NULL)
418 {
419 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
420 return 1;
421 }
422 currentparty = op->contr->party->partyname;
423 new_draw_info_format (NDI_UNIQUE, 0, op, "You leave party %s.", currentparty);
424 sprintf (buf, "%s leaves party %s.", &op->name, currentparty);
425 send_party_message (op, buf);
426 op->contr->party = NULL;
427 return 1;
428 }
429 if (strcmp (params, "who") == 0)
430 {
431 player *pl;
432
433 tmpparty = op->contr->party;
434 if (op->contr->party == NULL)
435 {
436 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
437 return 1;
438 }
439 new_draw_info_format (NDI_UNIQUE, 0, op, "Members of party: %s.", op->contr->party->partyname);
440 for (pl = first_player; pl != NULL; pl = pl->next)
441 if (pl->ob->contr->party == op->contr->party)
442 {
443 if (settings.set_title == TRUE)
444 { 262 {
445 if (pl->ob->contr->own_title[0] != '\0') 263 op->contr->party = p;
446 sprintf (buf, "%3d %s the %s", pl->ob->level, &pl->ob->name, pl->ob->contr->own_title);
447 else
448 sprintf (buf, "%3d %s the %s", pl->ob->level, &pl->ob->name, pl->ob->contr->title);
449 }
450 else
451 sprintf (buf, "%3d %s the %s", pl->ob->level, &pl->ob->name, pl->ob->contr->title);
452 new_draw_info (NDI_UNIQUE, 0, op, buf);
453 }
454 return 1;
455 } /* leave */
456 264
457 if (strncmp (params, "passwd ", 7) == 0) 265 buf << op->name << " joins party " << p->partyname << ".";
458 {
459 partylist *tmplist;
460
461 params += 7;
462
463 if (op->contr->party == NULL)
464 {
465 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of a party");
466 return 1;
467 }
468
469 if (strlen (params) > 8)
470 {
471 new_draw_info (NDI_UNIQUE, 0, op, "The password must not exceed 8 characters");
472 return 1;
473 }
474
475 tmplist = firstparty;
476 while (tmplist != NULL)
477 {
478 if (tmplist == op->contr->party)
479 {
480 strcpy (tmplist->passwd, params);
481 new_draw_info_format (NDI_UNIQUE, 0, op, "The password for party %s is %s", tmplist->partyname, tmplist->passwd);
482 snprintf (buf, MAX_BUF, "Password for party %s is now %s, changed by %s", tmplist->partyname, tmplist->passwd, &op->name);
483 send_party_message (op, buf); 266 send_party_message (op, buf);
484 return 0; 267 buf.clear ();
268
269 buf << "You have joined party: " << p->partyname << ".";
485 } 270 }
486 tmplist = tmplist->next;
487 }
488 return 0;
489 } /* passwd */
490
491 if (strcmp (params, "list") == 0)
492 {
493 partylist *tmplist;
494
495 tmplist = firstparty;
496
497 if (firstparty == NULL)
498 {
499 new_draw_info (NDI_UNIQUE, 0, op, "There are no parties active right now");
500 return 1;
501 }
502
503 new_draw_info (NDI_UNIQUE, 0, op, "Party name Leader");
504 new_draw_info (NDI_UNIQUE, 0, op, "---------- ------");
505
506 while (tmplist != NULL)
507 {
508 new_draw_info_format (NDI_UNIQUE, 0, op, "%-32s %s", tmplist->partyname, tmplist->partyleader);
509 tmplist = tmplist->next;
510 }
511 return 0;
512 } /* list */
513
514 if (strncmp (params, "join ", 5) == 0)
515 {
516
517 params += 5;
518
519 /* Can't join a party cause non exist */
520 if (firstparty == NULL)
521 {
522 new_draw_info_format (NDI_UNIQUE, 0, op, "Party: %s does not exist. You must form it first", params);
523 return 1;
524 }
525
526 /* Special case if thier is only one party */
527 if (firstparty->next == NULL)
528 {
529 if (strcmp (firstparty->partyname, params) != 0)
530 { 271 else
531 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);
532 return 1; 273
274 goto reply;
533 } 275 }
534 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++)
535 { 296 {
536 if (op->contr->party == firstparty) 297 sint64 exp = party->party_kills[i].exp;
298 char suffix = ' ';
299 if (exp > 1000000)
537 { 300 {
538 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already in party: %s", firstparty->partyname); 301 exp /= 1000000;
539 return 1; 302 suffix = 'M';
540 } 303 }
541 /* found party player wants to join */ 304 else if (exp > 1000)
542 if (firstparty->passwd[0] == '\0')
543 { 305 {
544 op->contr->party = firstparty; 306 exp /= 1000;
545 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s", firstparty->partyname); 307 suffix = 'k';
546 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, firstparty->partyname);
547 send_party_message (op, buf);
548 return 0;
549 } 308 }
550 else 309
551 { 310 buf.printf (" %16s|%16s|%6.1f%c\n", party->party_kills[i].dead, party->party_kills[i].killer, (double)exp, suffix);
552 get_party_password (op, firstparty);
553 return 0;
554 }
555 } 311 }
556 }
557 312
558 tmpparty = firstparty; 313 buf << " ----------------+----------------+--------\n";
559 while (tmpparty != NULL) 314
560 {
561 if (strcmp (tmpparty->partyname, params) == 0)
562 { 315 {
563 if (op->contr->party == tmpparty) 316 sint64 exp = party->total_exp;
317 char suffix = ' ';
318
319 if (exp > 1000000)
564 { 320 {
565 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already a member of party: %s", tmpparty->partyname); 321 exp /= 1000000;
566 return 1; 322 suffix = 'M';
567 } 323 }
568 else 324 else if (exp > 1000)
569 { 325 {
570 if (tmpparty->passwd[0] == '\0') 326 exp /= 1000;
571 { 327 suffix = 'k';
572 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s", tmpparty->partyname);
573 op->contr->party = tmpparty;
574 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, tmpparty->partyname);
575 send_party_message (op, buf);
576 return 0;
577 }
578 else
579 {
580 get_party_password (op, tmpparty);
581 return 0;
582 }
583 } 328 }
329
330 buf.printf (" Totals: %d kills, %.1f%c exp", party->kills, (double)exp, suffix);
584 } 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";
585 else 370 else
586 tmpparty = tmpparty->next;
587 } 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>";
588 378
589 new_draw_info_format (NDI_UNIQUE, 0, op, "Party %s does not exist. You must form it first.", params); 379reply:
590 return 1; 380 op->contr->send_msg (NDI_UNIQUE | NDI_REPLY, MSG_CHANNEL ("party"), buf);
591 } /* join */
592 381
593 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>");
594 new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>");
595 new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it.");
596 new_draw_info (NDI_UNIQUE, 0, op, "For a list of current parties type: party list");
597 new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave");
598 new_draw_info (NDI_UNIQUE, 0, op, "To change a passwd for a party type: party passwd <password>");
599 new_draw_info (NDI_UNIQUE, 0, op, "There is an 8 character max");
600 new_draw_info (NDI_UNIQUE, 0, op, "To talk to party members type: party say <msg>");
601 new_draw_info (NDI_UNIQUE, 0, op, "To see who is in your party: party who");
602#ifdef PARTY_KILL_LOG
603 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills");
604#endif
605 return 1; 382 return 1;
606} 383}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines