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