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.33 by root, Fri Nov 6 13:03:34 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 it under
8 it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
9 the Free Software Foundation; either version 2 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
10 (at your option) any later version. 11 * option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
18 along with this program; if not, write to the Free Software 19 * and the GNU General Public License along with this program. If not, see
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * <http://www.gnu.org/licenses/>.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#ifndef __CEXTRACT__
26# include <sproto.h> 26#include <sproto.h>
27#endif
28#include <spells.h> 27#include <spells.h>
29 28
30#ifdef COZY_SERVER 29static 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 30
42partylist * 31partylist *
43get_firstparty (void) 32get_firstparty (void)
44{ 33{
45 return firstparty; 34 return firstparty;
46} 35}
47 36
48void remove_party (partylist *target_party); 37static 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) 38remove_party (partylist *target_party)
73{ 39{
74 partylist *tmpparty;
75 partylist *previousparty;
76 partylist *nextparty;
77 player *pl;
78
79 if (firstparty == NULL) 40 if (firstparty == NULL)
80 { 41 {
81 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);
82 return; 43 return;
83 } 44 }
84 45
85 for (pl = first_player; pl != NULL; pl = pl->next) 46 for_all_players (pl)
86 if (pl->party == target_party) 47 if (pl->party == target_party)
87 pl->party = NULL; 48 pl->party = NULL;
88 49
89 /* special case-ism for parties at the beginning and end of the list */ 50 partylist **prevlink = &firstparty;
90 if (target_party == firstparty)
91 {
92 firstparty = firstparty->next;
93 51
94 if (target_party->partyleader) 52 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) 53 if (p->next == target_party)
125 { 54 {
126 previousparty = tmpparty; 55 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; 56 break;
137 } 57 }
58
59 *prevlink = target_party->next;
60
61 free (target_party->partyleader);
62 free (target_party->partyname);
63 sfree (target_party);
138} 64}
139 65
140/* 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. */
141void 67void
142obsolete_parties (void) 68obsolete_parties (void)
143{ 69{
144 int player_count; 70 int player_count;
145 player *pl;
146 partylist *party; 71 partylist *party;
147 partylist *next = NULL; 72 partylist *next = NULL;
148 73
149 if (!firstparty) 74 if (!firstparty)
150 return; /* we can't obsolete parties if there aren't any */ 75 return; /* we can't obsolete parties if there aren't any */
76
151 for (party = firstparty; party != NULL; party = next) 77 for (party = firstparty; party != NULL; party = next)
152 { 78 {
153 next = party->next; 79 next = party->next;
154 player_count = 0; 80 player_count = 0;
155 for (pl = first_player; pl != NULL; pl = pl->next) 81 for_all_players (pl)
156 if (pl->party == party) 82 if (pl->party == party)
157 player_count++; 83 player_count++;
158 if (player_count == 0) 84 if (player_count == 0)
159 remove_party (party); 85 remove_party (party);
160 } 86 }
161} 87}
162 88
163#ifdef PARTY_KILL_LOG
164void 89void
165add_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)
166{ 91{
167 int i, pos; 92 int i, pos;
168 93
169 if (party == NULL) 94 if (party == NULL)
170 return; 95 return;
96
171 if (party->kills >= PARTY_KILL_LOG) 97 if (party->kills >= PARTY_KILL_LOG)
172 { 98 {
173 pos = PARTY_KILL_LOG - 1; 99 pos = PARTY_KILL_LOG - 1;
174 for (i = 0; i < PARTY_KILL_LOG - 1; i++) 100 for (i = 0; i < PARTY_KILL_LOG - 1; i++)
175 party->party_kills[i] = party->party_kills[i + 1]; 101 party->party_kills[i] = party->party_kills[i + 1];
176 } 102 }
177 else 103 else
178 pos = party->kills; 104 pos = party->kills;
105
179 party->kills++; 106 party->kills++;
180 party->total_exp += exp; 107 party->total_exp += exp;
181 party->party_kills[pos].exp = exp; 108 party->party_kills[pos].exp = exp;
182 assign (party->party_kills[pos].killer, killer); 109 assign (party->party_kills[pos].killer, killer);
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#endif
188 114
189int 115static int
190confirm_party_password (object *op) 116confirm_party_password (object *op)
191{ 117{
192 partylist *tmppartylist; 118 partylist *tmppartylist;
193 119
194 for (tmppartylist = firstparty; tmppartylist != NULL; tmppartylist = tmppartylist->next) 120 for (tmppartylist = firstparty; tmppartylist != NULL; tmppartylist = tmppartylist->next)
200 else 126 else
201 return 1; 127 return 1;
202 } 128 }
203 } 129 }
204 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);
205} 139}
206 140
207void 141void
208receive_party_password (object *op, char k) 142receive_party_password (object *op, char k)
209{ 143{
216 op->contr->party = op->contr->party_to_join; 150 op->contr->party = op->contr->party_to_join;
217 op->contr->party_to_join = NULL; 151 op->contr->party_to_join = NULL;
218 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname); 152 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); 153 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname);
220 send_party_message (op, buf); 154 send_party_message (op, buf);
221 op->contr->state = ST_PLAYING; 155 op->contr->ns->state = ST_PLAYING;
222 return; 156 return;
223 } 157 }
224 else 158 else
225 { 159 {
226 new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password"); 160 new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password");
227 op->contr->party_to_join = NULL; 161 op->contr->party_to_join = NULL;
228 op->contr->state = ST_PLAYING; 162 op->contr->ns->state = ST_PLAYING;
229 return; 163 return;
230 } 164 }
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} 165}
242 166
243int 167int
244command_gsay (object *op, char *params) 168command_gsay (object *op, char *params)
245{ 169{
246 char party_params[MAX_BUF];
247
248 if (!params) 170 if (!params)
249 return 0; 171 return 0;
250 strcpy (party_params, "say "); 172
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
256 177
257int 178int
258command_party (object *op, char *params) 179command_party (object *op, char *params)
259{ 180{
260 char buf[MAX_BUF]; 181 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 182
264 if (params == NULL) 183 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 184
185 if (!params)
186 params = (char *)"";
187
279 if (strcmp (params, "help") == 0) 188 if (!strcmp (params, "help"))
280 { 189 buf << "\n"
281 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"
282 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"
283 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"
284 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"
285 new_draw_info (NDI_UNIQUE, 0, op, "To leave a party type: party leave"); 194 " - 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>"); 195 " - 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"); 196 " - There is an 8 character max\n"
288 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"
289 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"
290#ifdef PARTY_KILL_LOG 199 " - 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) 200 else if (strncmp (params, "form ", 5) == 0)
372 { 201 {
373 int player_count;
374 player *pl;
375
376 params += 5; 202 params += 5;
377 if (op->contr->party)
378 oldparty = op->contr->party;
379 else
380 oldparty = NULL;
381 203
382 if (firstparty) 204 if (party)
205 buf << "You are already a member of party " << party->partyname << ". You must leave it first.";
206 else
383 { 207 {
384 for (tmpparty = firstparty; tmpparty != NULL; tmpparty = tmpparty->next) 208 for (partylist *tmpparty = firstparty; tmpparty; tmpparty = tmpparty->next)
385 { 209 {
386 if (!strcmp (tmpparty->partyname, params)) 210 if (!strcmp (tmpparty->partyname, params))
387 { 211 {
388 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";
389 return 1; 213 goto reply;
390 } 214 }
391 } 215 }
392 lastparty->next = form_party (op, params); 216
393 lastparty = lastparty->next; 217 /* Forms the party struct for a party called 'params'. it is the responsibility
394 } 218 * of the caller to ensure that the name is unique, and that it is placed in the
395 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;
396 { 233 }
397 firstparty = form_party (op, params); 234 }
398 lastparty = firstparty; 235 else if (strcmp (params, "list") == 0)
236 {
237 if (!firstparty)
238 buf << "There are no parties active right now";
239 else
399 } 240 {
400 /* 241 buf << "Party name Leader\n\n"
401 * The player might have previously been a member of a party, if so, he will be leaving 242 "---------- ------\n\n";
402 * it, so check if there are any other members and if not, delete the party 243
403 */ 244 for (partylist *p = firstparty; p; p = p->next)
404 player_count = 0; 245 buf.printf ("%-32s %s\n\n", p->partyname, p->partyleader);
405 if (oldparty)
406 { 246 }
407 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))
408 { 260 {
409 if (pl->party == oldparty) 261 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 { 262 {
449 if (pl->ob->contr->own_title[0] != '\0') 263 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 264
461 if (strncmp (params, "passwd ", 7) == 0) 265 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); 266 send_party_message (op, buf);
488 return 0; 267 buf.clear ();
268
269 buf << "You have joined party: " << p->partyname << ".";
489 } 270 }
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 { 271 else
535 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);
536 return 1; 273
274 goto reply;
537 } 275 }
538 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++)
539 { 296 {
540 if (op->contr->party == firstparty) 297 sint64 exp = party->party_kills[i].exp;
298 char suffix = ' ';
299 if (exp > 1000000)
541 { 300 {
542 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already in party: %s", firstparty->partyname); 301 exp /= 1000000;
543 return 1; 302 suffix = 'M';
544 } 303 }
545 /* found party player wants to join */ 304 else if (exp > 1000)
546 if (firstparty->passwd[0] == '\0')
547 { 305 {
548 op->contr->party = firstparty; 306 exp /= 1000;
549 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s", firstparty->partyname); 307 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 } 308 }
554 else 309
555 { 310 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 } 311 }
560 }
561 312
562 tmpparty = firstparty; 313 buf << " ----------------+----------------+--------\n";
563 while (tmpparty != NULL) 314
564 {
565 if (strcmp (tmpparty->partyname, params) == 0)
566 { 315 {
567 if (op->contr->party == tmpparty) 316 sint64 exp = party->total_exp;
317 char suffix = ' ';
318
319 if (exp > 1000000)
568 { 320 {
569 new_draw_info_format (NDI_UNIQUE, 0, op, "You are already a member of party: %s", tmpparty->partyname); 321 exp /= 1000000;
570 return 1; 322 suffix = 'M';
571 } 323 }
572 else 324 else if (exp > 1000)
573 { 325 {
574 if (tmpparty->passwd[0] == '\0') 326 exp /= 1000;
575 { 327 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 } 328 }
329
330 buf.printf (" Totals: %d kills, %.1f%c exp", party->kills, (double)exp, suffix);
588 } 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";
589 else 370 else
590 tmpparty = tmpparty->next;
591 } 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>";
592 378
593 new_draw_info_format (NDI_UNIQUE, 0, op, "Party %s does not exist. You must form it first.", params); 379reply:
594 return 1; 380 op->contr->send_msg (NDI_UNIQUE | NDI_REPLY, MSG_CHANNEL ("party"), buf);
595 } /* join */
596 381
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; 382 return 1;
610} 383}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines