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.5 by root, Tue Sep 12 19:20:08 2006 UTC vs.
Revision 1.26 by root, Sun Sep 7 21:31:23 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines