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