1 | /* |
1 | /* |
2 | * static char *rcsid_c_party_c = |
2 | * static char *rcsid_c_party_c = |
3 | * "$Id: c_party.C,v 1.1 2006/08/13 17:16:04 elmex Exp $"; |
3 | * "$Id: c_party.C,v 1.2 2006/08/29 08:01:37 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
43 | static partylist * firstparty=NULL; /* Keeps track of first party in list */ |
43 | static partylist * firstparty=NULL; /* Keeps track of first party in list */ |
44 | static partylist * lastparty=NULL; /*Keeps track of last party in list */ |
44 | static partylist * lastparty=NULL; /*Keeps track of last party in list */ |
45 | |
45 | |
46 | partylist* get_firstparty(void) |
46 | partylist* get_firstparty(void) |
47 | { |
47 | { |
48 | return firstparty; |
48 | return firstparty; |
49 | } |
49 | } |
50 | |
50 | |
51 | void remove_party(partylist *target_party); |
51 | void remove_party(partylist *target_party); |
52 | |
52 | |
53 | /* Forms the party struct for a party called 'params'. it is the responsibility |
53 | /* Forms the party struct for a party called 'params'. it is the responsibility |
… | |
… | |
63 | newparty->kills=0; |
63 | newparty->kills=0; |
64 | newparty->passwd[0] = '\0'; |
64 | newparty->passwd[0] = '\0'; |
65 | newparty->next = NULL; |
65 | newparty->next = NULL; |
66 | newparty->partyleader = strdup_local(op->name); |
66 | newparty->partyleader = strdup_local(op->name); |
67 | new_draw_info_format(NDI_UNIQUE, 0, op, |
67 | new_draw_info_format(NDI_UNIQUE, 0, op, |
68 | "You have formed party: %s",newparty->partyname); |
68 | "You have formed party: %s",newparty->partyname); |
69 | op->contr->party=newparty; |
69 | op->contr->party=newparty; |
70 | return newparty; |
70 | return newparty; |
71 | } |
71 | } |
72 | |
72 | |
73 | void remove_party(partylist *target_party) { |
73 | void remove_party(partylist *target_party) { |
… | |
… | |
75 | partylist *previousparty; |
75 | partylist *previousparty; |
76 | partylist *nextparty; |
76 | partylist *nextparty; |
77 | player *pl; |
77 | player *pl; |
78 | |
78 | |
79 | if (firstparty==NULL) { |
79 | if (firstparty==NULL) { |
80 | LOG(llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", |
80 | LOG(llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", |
81 | target_party->partyname); |
81 | target_party->partyname); |
82 | return; |
82 | return; |
83 | } |
83 | } |
84 | for (pl=first_player;pl!=NULL;pl=pl->next) |
84 | for (pl=first_player;pl!=NULL;pl=pl->next) |
85 | if (pl->party==target_party) pl->party=NULL; |
85 | if (pl->party==target_party) pl->party=NULL; |
86 | |
86 | |
87 | /* special case-ism for parties at the beginning and end of the list */ |
87 | /* special case-ism for parties at the beginning and end of the list */ |
88 | if (target_party==firstparty) { |
88 | if (target_party==firstparty) { |
89 | firstparty=firstparty->next; |
89 | firstparty=firstparty->next; |
90 | if (target_party->partyleader) free(target_party->partyleader); |
90 | if (target_party->partyleader) free(target_party->partyleader); |
91 | if (target_party->partyname) free(target_party->partyname); |
91 | if (target_party->partyname) free(target_party->partyname); |
92 | free(target_party); |
92 | free(target_party); |
93 | return; |
93 | return; |
94 | } |
94 | } |
95 | else if (target_party == lastparty) { |
95 | else if (target_party == lastparty) { |
96 | for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty=tmpparty->next) { |
96 | for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty=tmpparty->next) { |
97 | if (tmpparty->next==target_party) { |
97 | if (tmpparty->next==target_party) { |
98 | lastparty=tmpparty; |
98 | lastparty=tmpparty; |
99 | if (target_party->partyleader) free(target_party->partyleader); |
99 | if (target_party->partyleader) free(target_party->partyleader); |
100 | if (target_party->partyname) free(target_party->partyname); |
100 | if (target_party->partyname) free(target_party->partyname); |
101 | free(target_party); |
101 | free(target_party); |
102 | lastparty->next=NULL; |
102 | lastparty->next=NULL; |
103 | return; |
103 | return; |
104 | } |
104 | } |
105 | } |
105 | } |
106 | } |
106 | } |
107 | for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty=tmpparty->next) |
107 | for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty=tmpparty->next) |
108 | if (tmpparty->next == target_party) { |
108 | if (tmpparty->next == target_party) { |
109 | previousparty=tmpparty; |
109 | previousparty=tmpparty; |
110 | nextparty=tmpparty->next->next; |
110 | nextparty=tmpparty->next->next; |
111 | /* this should be safe, because we already dealt with the lastparty case */ |
111 | /* this should be safe, because we already dealt with the lastparty case */ |
112 | |
112 | |
113 | previousparty->next=nextparty; |
113 | previousparty->next=nextparty; |
114 | if (target_party->partyleader) free(target_party->partyleader); |
114 | if (target_party->partyleader) free(target_party->partyleader); |
115 | if (target_party->partyname) free(target_party->partyname); |
115 | if (target_party->partyname) free(target_party->partyname); |
116 | free(target_party); |
116 | free(target_party); |
117 | return; |
117 | return; |
118 | } |
118 | } |
119 | } |
119 | } |
120 | |
120 | |
121 | /* Remove unused parties, this could be made to scale a lot better. */ |
121 | /* Remove unused parties, this could be made to scale a lot better. */ |
122 | void obsolete_parties(void) { |
122 | void obsolete_parties(void) { |
123 | int player_count; |
123 | int player_count; |
124 | player *pl; |
124 | player *pl; |
125 | partylist *party; |
125 | partylist *party; |
126 | partylist* next = NULL; |
126 | partylist* next = NULL; |
127 | |
127 | |
128 | if (!firstparty) return; /* we can't obsolete parties if there aren't any */ |
128 | if (!firstparty) return; /* we can't obsolete parties if there aren't any */ |
129 | for (party=firstparty; party!=NULL; party=next) { |
129 | for (party=firstparty; party!=NULL; party=next) { |
130 | next = party->next; |
130 | next = party->next; |
131 | player_count=0; |
131 | player_count=0; |
… | |
… | |
144 | if(party==NULL) return; |
144 | if(party==NULL) return; |
145 | if(party->kills>=PARTY_KILL_LOG) |
145 | if(party->kills>=PARTY_KILL_LOG) |
146 | { |
146 | { |
147 | pos=PARTY_KILL_LOG-1; |
147 | pos=PARTY_KILL_LOG-1; |
148 | for(i=0;i<PARTY_KILL_LOG-1;i++) |
148 | for(i=0;i<PARTY_KILL_LOG-1;i++) |
149 | memcpy(&(party->party_kills[i]),&(party->party_kills[i+1]), |
149 | memcpy(&(party->party_kills[i]),&(party->party_kills[i+1]), |
150 | sizeof(party->party_kills[0])); |
150 | sizeof(party->party_kills[0])); |
151 | } |
151 | } |
152 | else |
152 | else |
153 | pos=party->kills; |
153 | pos=party->kills; |
154 | party->kills++; |
154 | party->kills++; |
155 | party->total_exp+=exp; |
155 | party->total_exp+=exp; |
… | |
… | |
162 | #endif |
162 | #endif |
163 | |
163 | |
164 | int confirm_party_password(object *op) { |
164 | int confirm_party_password(object *op) { |
165 | partylist *tmppartylist; |
165 | partylist *tmppartylist; |
166 | for(tmppartylist = firstparty; tmppartylist != NULL;tmppartylist = tmppartylist->next) { |
166 | for(tmppartylist = firstparty; tmppartylist != NULL;tmppartylist = tmppartylist->next) { |
167 | if(!strcmp(op->contr->party_to_join->partyname, tmppartylist->partyname)) { |
167 | if(!strcmp(op->contr->party_to_join->partyname, tmppartylist->partyname)) { |
168 | if(strcmp(op->contr->write_buf+1,tmppartylist->passwd) == 0) |
168 | if(strcmp(op->contr->write_buf+1,tmppartylist->passwd) == 0) |
169 | return 0; |
169 | return 0; |
170 | else |
170 | else |
171 | return 1; |
171 | return 1; |
172 | } |
172 | } |
173 | } |
173 | } |
174 | return 1; |
174 | return 1; |
175 | } |
175 | } |
176 | |
176 | |
177 | void receive_party_password(object *op, char k) { |
177 | void receive_party_password(object *op, char k) { |
… | |
… | |
180 | partylist* joined_party = op->contr->party_to_join; |
180 | partylist* joined_party = op->contr->party_to_join; |
181 | char buf[ MAX_BUF ]; |
181 | char buf[ MAX_BUF ]; |
182 | op->contr->party = op->contr->party_to_join; |
182 | op->contr->party = op->contr->party_to_join; |
183 | op->contr->party_to_join = NULL; |
183 | op->contr->party_to_join = NULL; |
184 | new_draw_info_format(NDI_UNIQUE, 0,op, |
184 | new_draw_info_format(NDI_UNIQUE, 0,op, |
185 | "You have joined party: %s\n",joined_party->partyname); |
185 | "You have joined party: %s\n",joined_party->partyname); |
186 | snprintf( buf, MAX_BUF, "%s joins party %s", op->name, joined_party->partyname ); |
186 | snprintf( buf, MAX_BUF, "%s joins party %s", op->name, joined_party->partyname ); |
187 | send_party_message( op, buf ); |
187 | send_party_message( op, buf ); |
188 | op->contr->state = ST_PLAYING; |
188 | op->contr->state = ST_PLAYING; |
189 | return; |
189 | return; |
190 | } |
190 | } |
… | |
… | |
199 | void send_party_message(object *op,char *msg) |
199 | void send_party_message(object *op,char *msg) |
200 | { |
200 | { |
201 | player *pl; |
201 | player *pl; |
202 | for(pl=first_player;pl!=NULL;pl=pl->next) |
202 | for(pl=first_player;pl!=NULL;pl=pl->next) |
203 | if(pl->ob->contr->party==op->contr->party && pl->ob!=op) |
203 | if(pl->ob->contr->party==op->contr->party && pl->ob!=op) |
204 | new_draw_info(NDI_WHITE, 0, pl->ob, msg); |
204 | new_draw_info(NDI_WHITE, 0, pl->ob, msg); |
205 | } |
205 | } |
206 | |
206 | |
207 | int command_gsay(object *op, char *params) |
207 | int command_gsay(object *op, char *params) |
208 | { |
208 | { |
209 | char party_params[MAX_BUF]; |
209 | char party_params[MAX_BUF]; |
… | |
… | |
227 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
227 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
228 | new_draw_info(NDI_UNIQUE, 0,op,"For help try: party help"); |
228 | new_draw_info(NDI_UNIQUE, 0,op,"For help try: party help"); |
229 | } |
229 | } |
230 | else { |
230 | else { |
231 | currentparty = op->contr->party->partyname; |
231 | currentparty = op->contr->party->partyname; |
232 | new_draw_info_format(NDI_UNIQUE, 0, op, |
232 | new_draw_info_format(NDI_UNIQUE, 0, op, |
233 | "You are a member of party %s.", currentparty); |
233 | "You are a member of party %s.", currentparty); |
234 | } |
234 | } |
235 | return 1; |
235 | return 1; |
236 | } |
236 | } |
237 | if(strcmp(params, "help")==0) { |
237 | if(strcmp(params, "help")==0) { |
238 | new_draw_info(NDI_UNIQUE, 0,op,"To form a party type: party form <partyname>"); |
238 | new_draw_info(NDI_UNIQUE, 0,op,"To form a party type: party form <partyname>"); |
… | |
… | |
256 | char chr; |
256 | char chr; |
257 | char buffer[80]; |
257 | char buffer[80]; |
258 | float exp; |
258 | float exp; |
259 | |
259 | |
260 | if(op->contr->party==NULL) |
260 | if(op->contr->party==NULL) |
261 | { |
261 | { |
262 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
262 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
263 | return 1; |
263 | return 1; |
264 | } |
264 | } |
265 | tmpparty = op->contr->party; |
265 | tmpparty = op->contr->party; |
266 | if(!tmpparty->kills) |
266 | if(!tmpparty->kills) |
267 | { |
267 | { |
268 | new_draw_info(NDI_UNIQUE,0,op,"You haven't killed anything yet."); |
268 | new_draw_info(NDI_UNIQUE,0,op,"You haven't killed anything yet."); |
269 | return 1; |
269 | return 1; |
270 | } |
270 | } |
271 | max=tmpparty->kills-1; |
271 | max=tmpparty->kills-1; |
272 | if(max>PARTY_KILL_LOG-1) max=PARTY_KILL_LOG-1; |
272 | if(max>PARTY_KILL_LOG-1) max=PARTY_KILL_LOG-1; |
273 | new_draw_info(NDI_UNIQUE,0,op, |
273 | new_draw_info(NDI_UNIQUE,0,op, |
274 | "Killed | Killer| Exp"); |
274 | "Killed | Killer| Exp"); |
275 | new_draw_info(NDI_UNIQUE,0,op, |
275 | new_draw_info(NDI_UNIQUE,0,op, |
276 | "----------------+----------------+--------"); |
276 | "----------------+----------------+--------"); |
277 | for(i=0;i<=max;i++) |
277 | for(i=0;i<=max;i++) |
278 | { |
278 | { |
279 | exp=tmpparty->party_kills[i].exp; |
279 | exp=tmpparty->party_kills[i].exp; |
280 | chr=' '; |
280 | chr=' '; |
281 | if(exp>1000000) { exp/=1000000; chr='M'; } |
281 | if(exp>1000000) { exp/=1000000; chr='M'; } |
282 | else |
282 | else |
283 | if(exp>1000) { exp/=1000; chr='k'; } |
283 | if(exp>1000) { exp/=1000; chr='k'; } |
284 | sprintf(buffer,"%16s|%16s|%6.1f%c", |
284 | sprintf(buffer,"%16s|%16s|%6.1f%c", |
285 | tmpparty->party_kills[i].dead, |
285 | tmpparty->party_kills[i].dead, |
286 | tmpparty->party_kills[i].killer,exp,chr); |
286 | tmpparty->party_kills[i].killer,exp,chr); |
287 | new_draw_info(NDI_UNIQUE,0,op,buffer); |
287 | new_draw_info(NDI_UNIQUE,0,op,buffer); |
288 | } |
288 | } |
289 | exp=tmpparty->total_exp; |
289 | exp=tmpparty->total_exp; |
290 | chr=' '; |
290 | chr=' '; |
291 | if(exp>1000000) { exp/=1000000; chr='M'; } |
291 | if(exp>1000000) { exp/=1000000; chr='M'; } |
292 | else |
292 | else |
293 | if(exp>1000) { exp/=1000; chr='k'; } |
293 | if(exp>1000) { exp/=1000; chr='k'; } |
294 | new_draw_info(NDI_UNIQUE,0,op, |
294 | new_draw_info(NDI_UNIQUE,0,op, |
295 | "----------------+----------------+--------"); |
295 | "----------------+----------------+--------"); |
296 | sprintf(buffer,"Totals: %d kills, %.1f%c exp",tmpparty->kills, |
296 | sprintf(buffer,"Totals: %d kills, %.1f%c exp",tmpparty->kills, |
297 | exp,chr); |
297 | exp,chr); |
298 | new_draw_info(NDI_UNIQUE,0,op,buffer); |
298 | new_draw_info(NDI_UNIQUE,0,op,buffer); |
299 | return 1; |
299 | return 1; |
300 | } |
300 | } |
301 | #endif /* PARTY_KILL_LOG */ |
301 | #endif /* PARTY_KILL_LOG */ |
302 | if(strncmp(params, "say ", 4)==0) |
302 | if(strncmp(params, "say ", 4)==0) |
… | |
… | |
321 | params += 5; |
321 | params += 5; |
322 | if (op->contr->party) oldparty = op->contr->party; |
322 | if (op->contr->party) oldparty = op->contr->party; |
323 | else oldparty = NULL; |
323 | else oldparty = NULL; |
324 | |
324 | |
325 | if (firstparty) { |
325 | if (firstparty) { |
326 | for (tmpparty = firstparty; tmpparty != NULL;tmpparty = tmpparty->next) { |
326 | for (tmpparty = firstparty; tmpparty != NULL;tmpparty = tmpparty->next) { |
327 | if (!strcmp(tmpparty->partyname, params)) { |
327 | if (!strcmp(tmpparty->partyname, params)) { |
328 | new_draw_info_format(NDI_UNIQUE, 0,op, |
328 | new_draw_info_format(NDI_UNIQUE, 0,op, |
329 | "The party %s already exists, pick another name",params); |
329 | "The party %s already exists, pick another name",params); |
330 | return 1; |
330 | return 1; |
331 | } |
331 | } |
332 | } |
332 | } |
333 | lastparty->next=form_party(op, params); |
333 | lastparty->next=form_party(op, params); |
334 | lastparty = lastparty->next; |
334 | lastparty = lastparty->next; |
335 | } |
335 | } |
336 | else { |
336 | else { |
337 | firstparty=form_party(op, params); |
337 | firstparty=form_party(op, params); |
338 | lastparty=firstparty; |
338 | lastparty=firstparty; |
339 | } |
339 | } |
340 | /* |
340 | /* |
341 | * The player might have previously been a member of a party, if so, he will be leaving |
341 | * The player might have previously been a member of a party, if so, he will be leaving |
342 | * it, so check if there are any other members and if not, delete the party |
342 | * it, so check if there are any other members and if not, delete the party |
343 | */ |
343 | */ |
344 | player_count=0; |
344 | player_count=0; |
345 | if (oldparty) { |
345 | if (oldparty) { |
346 | for (pl=first_player;pl->next!=NULL;pl=pl->next) { |
346 | for (pl=first_player;pl->next!=NULL;pl=pl->next) { |
347 | if (pl->party==oldparty) player_count++; |
347 | if (pl->party==oldparty) player_count++; |
348 | } |
348 | } |
349 | if (player_count == 0) |
349 | if (player_count == 0) |
350 | remove_party(oldparty); |
350 | remove_party(oldparty); |
351 | } |
351 | } |
352 | return 0; |
352 | return 0; |
353 | } /* form */ |
353 | } /* form */ |
354 | |
354 | |
355 | if(strcmp(params, "leave")==0) { |
355 | if(strcmp(params, "leave")==0) { |
… | |
… | |
358 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
358 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
359 | return 1; |
359 | return 1; |
360 | } |
360 | } |
361 | currentparty = op->contr->party->partyname; |
361 | currentparty = op->contr->party->partyname; |
362 | new_draw_info_format(NDI_UNIQUE, 0, op, |
362 | new_draw_info_format(NDI_UNIQUE, 0, op, |
363 | "You leave party %s.",currentparty); |
363 | "You leave party %s.",currentparty); |
364 | sprintf(buf,"%s leaves party %s.",op->name,currentparty); |
364 | sprintf(buf,"%s leaves party %s.",op->name,currentparty); |
365 | send_party_message(op,buf); |
365 | send_party_message(op,buf); |
366 | op->contr->party=NULL; |
366 | op->contr->party=NULL; |
367 | return 1; |
367 | return 1; |
368 | } |
368 | } |
… | |
… | |
372 | if(op->contr->party==NULL) { |
372 | if(op->contr->party==NULL) { |
373 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
373 | new_draw_info(NDI_UNIQUE, 0,op,"You are not a member of any party."); |
374 | return 1; |
374 | return 1; |
375 | } |
375 | } |
376 | new_draw_info_format(NDI_UNIQUE, 0, op, |
376 | new_draw_info_format(NDI_UNIQUE, 0, op, |
377 | "Members of party: %s.", op->contr->party->partyname); |
377 | "Members of party: %s.", op->contr->party->partyname); |
378 | for(pl=first_player;pl!=NULL;pl=pl->next) |
378 | for(pl=first_player;pl!=NULL;pl=pl->next) |
379 | if(pl->ob->contr->party==op->contr->party) { |
379 | if(pl->ob->contr->party==op->contr->party) { |
380 | if (settings.set_title == TRUE) { |
380 | if (settings.set_title == TRUE) { |
381 | if(pl->ob->contr->own_title[0]!='\0') |
381 | if(pl->ob->contr->own_title[0]!='\0') |
382 | sprintf(buf,"%3d %s the %s", |
382 | sprintf(buf,"%3d %s the %s", |
383 | pl->ob->level,pl->ob->name,pl->ob->contr->own_title); |
383 | pl->ob->level,pl->ob->name,pl->ob->contr->own_title); |
384 | else |
384 | else |
|
|
385 | sprintf(buf,"%3d %s the %s", |
|
|
386 | pl->ob->level,pl->ob->name,pl->ob->contr->title); |
|
|
387 | } else |
385 | sprintf(buf,"%3d %s the %s", |
388 | sprintf(buf,"%3d %s the %s", |
386 | pl->ob->level,pl->ob->name,pl->ob->contr->title); |
389 | pl->ob->level,pl->ob->name,pl->ob->contr->title); |
387 | } else |
|
|
388 | sprintf(buf,"%3d %s the %s", |
|
|
389 | pl->ob->level,pl->ob->name,pl->ob->contr->title); |
|
|
390 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
390 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
391 | } |
391 | } |
392 | return 1; |
392 | return 1; |
393 | } /* leave */ |
393 | } /* leave */ |
394 | |
394 | |
… | |
… | |
409 | |
409 | |
410 | tmplist = firstparty; |
410 | tmplist = firstparty; |
411 | while(tmplist != NULL) { |
411 | while(tmplist != NULL) { |
412 | if(tmplist == op->contr->party) { |
412 | if(tmplist == op->contr->party) { |
413 | strcpy(tmplist->passwd,params); |
413 | strcpy(tmplist->passwd,params); |
414 | new_draw_info_format(NDI_UNIQUE, 0, op, |
414 | new_draw_info_format(NDI_UNIQUE, 0, op, |
415 | "The password for party %s is %s", tmplist->partyname,tmplist->passwd); |
415 | "The password for party %s is %s", tmplist->partyname,tmplist->passwd); |
416 | snprintf( buf, MAX_BUF, "Password for party %s is now %s, changed by %s", |
416 | snprintf( buf, MAX_BUF, "Password for party %s is now %s, changed by %s", |
417 | tmplist->partyname, tmplist->passwd, op->name ); |
417 | tmplist->partyname, tmplist->passwd, op->name ); |
418 | send_party_message(op,buf); |
418 | send_party_message(op,buf); |
419 | return 0; |
419 | return 0; |
420 | } |
420 | } |
… | |
… | |
436 | new_draw_info(NDI_UNIQUE, 0,op,"Party name Leader"); |
436 | new_draw_info(NDI_UNIQUE, 0,op,"Party name Leader"); |
437 | new_draw_info(NDI_UNIQUE, 0,op,"---------- ------"); |
437 | new_draw_info(NDI_UNIQUE, 0,op,"---------- ------"); |
438 | |
438 | |
439 | while(tmplist != NULL) { |
439 | while(tmplist != NULL) { |
440 | new_draw_info_format(NDI_UNIQUE, 0,op, |
440 | new_draw_info_format(NDI_UNIQUE, 0,op, |
441 | "%-32s %s",tmplist->partyname |
441 | "%-32s %s",tmplist->partyname |
442 | ,tmplist->partyleader); |
442 | ,tmplist->partyleader); |
443 | tmplist = tmplist->next; |
443 | tmplist = tmplist->next; |
444 | } |
444 | } |
445 | return 0; |
445 | return 0; |
446 | } /* list */ |
446 | } /* list */ |
… | |
… | |
450 | params += 5; |
450 | params += 5; |
451 | |
451 | |
452 | /* Can't join a party cause non exist */ |
452 | /* Can't join a party cause non exist */ |
453 | if(firstparty == NULL) { |
453 | if(firstparty == NULL) { |
454 | new_draw_info_format(NDI_UNIQUE, 0, op, |
454 | new_draw_info_format(NDI_UNIQUE, 0, op, |
455 | "Party: %s does not exist. You must form it first",params); |
455 | "Party: %s does not exist. You must form it first",params); |
456 | return 1; |
456 | return 1; |
457 | } |
457 | } |
458 | |
458 | |
459 | /* Special case if thier is only one party */ |
459 | /* Special case if thier is only one party */ |
460 | if(firstparty->next == NULL) { |
460 | if(firstparty->next == NULL) { |
461 | if(strcmp(firstparty->partyname,params) != 0) { |
461 | if(strcmp(firstparty->partyname,params) != 0) { |
462 | new_draw_info_format(NDI_UNIQUE, 0,op, |
462 | new_draw_info_format(NDI_UNIQUE, 0,op, |
463 | "Party: %s does not exist. You must form it first",params); |
463 | "Party: %s does not exist. You must form it first",params); |
464 | return 1; |
464 | return 1; |
465 | } |
465 | } |
466 | else { |
466 | else { |
467 | if(op->contr->party == firstparty) { |
467 | if(op->contr->party == firstparty) { |
468 | new_draw_info_format(NDI_UNIQUE, 0, op, |
468 | new_draw_info_format(NDI_UNIQUE, 0, op, |
469 | "You are already in party: %s" |
469 | "You are already in party: %s" |
470 | ,firstparty->partyname); |
470 | ,firstparty->partyname); |
471 | return 1; |
471 | return 1; |
472 | } |
472 | } |
473 | /* found party player wants to join */ |
473 | /* found party player wants to join */ |
474 | if(firstparty->passwd[0] == '\0') { |
474 | if(firstparty->passwd[0] == '\0') { |
475 | op->contr->party = firstparty; |
475 | op->contr->party = firstparty; |
476 | new_draw_info_format(NDI_UNIQUE, 0, op, |
476 | new_draw_info_format(NDI_UNIQUE, 0, op, |
477 | "You have joined party: %s",firstparty->partyname); |
477 | "You have joined party: %s",firstparty->partyname); |
478 | snprintf( buf, MAX_BUF, "%s joins party %s", op->name, firstparty->partyname ); |
478 | snprintf( buf, MAX_BUF, "%s joins party %s", op->name, firstparty->partyname ); |
479 | send_party_message( op, buf ); |
479 | send_party_message( op, buf ); |
480 | return 0; |
480 | return 0; |
481 | } |
481 | } |
482 | else { |
482 | else { |
… | |
… | |
488 | |
488 | |
489 | tmpparty = firstparty; |
489 | tmpparty = firstparty; |
490 | while(tmpparty != NULL) { |
490 | while(tmpparty != NULL) { |
491 | if(strcmp(tmpparty->partyname,params) == 0) { |
491 | if(strcmp(tmpparty->partyname,params) == 0) { |
492 | if(op->contr->party == tmpparty) { |
492 | if(op->contr->party == tmpparty) { |
493 | new_draw_info_format(NDI_UNIQUE, 0, op, |
493 | new_draw_info_format(NDI_UNIQUE, 0, op, |
494 | "You are already a member of party: %s" |
494 | "You are already a member of party: %s" |
495 | ,tmpparty->partyname); |
495 | ,tmpparty->partyname); |
496 | return 1; |
496 | return 1; |
497 | } |
497 | } |
498 | else { |
498 | else { |
499 | if(tmpparty->passwd[0] == '\0') { |
499 | if(tmpparty->passwd[0] == '\0') { |
500 | new_draw_info_format(NDI_UNIQUE, 0, op, |
500 | new_draw_info_format(NDI_UNIQUE, 0, op, |
501 | "You have joined party: %s",tmpparty->partyname); |
501 | "You have joined party: %s",tmpparty->partyname); |
502 | op->contr->party = tmpparty; |
502 | op->contr->party = tmpparty; |
503 | snprintf( buf, MAX_BUF, "%s joins party %s", op->name, tmpparty->partyname ); |
503 | snprintf( buf, MAX_BUF, "%s joins party %s", op->name, tmpparty->partyname ); |
504 | send_party_message( op, buf ); |
504 | send_party_message( op, buf ); |
505 | return 0; |
505 | return 0; |
506 | } |
506 | } |
… | |
… | |
513 | else |
513 | else |
514 | tmpparty = tmpparty->next; |
514 | tmpparty = tmpparty->next; |
515 | } |
515 | } |
516 | |
516 | |
517 | new_draw_info_format(NDI_UNIQUE, 0,op, |
517 | new_draw_info_format(NDI_UNIQUE, 0,op, |
518 | "Party %s does not exist. You must form it first.",params); |
518 | "Party %s does not exist. You must form it first.",params); |
519 | return 1; |
519 | return 1; |
520 | } /* join */ |
520 | } /* join */ |
521 | |
521 | |
522 | new_draw_info(NDI_UNIQUE, 0,op,"To form a party type: party form <partyname>"); |
522 | new_draw_info(NDI_UNIQUE, 0,op,"To form a party type: party form <partyname>"); |
523 | new_draw_info(NDI_UNIQUE, 0,op,"To join a party type: party join <partyname>"); |
523 | new_draw_info(NDI_UNIQUE, 0,op,"To join a party type: party join <partyname>"); |