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