ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_party.C
(Generate patch)

Comparing deliantra/server/server/c_party.C (file contents):
Revision 1.5 by root, Tue Sep 12 19:20:08 2006 UTC vs.
Revision 1.11 by root, Tue Dec 26 08:54:59 2006 UTC

1
2/* 1/*
3 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
4 3
5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
17 16
18 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 20
22 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
23*/ 22*/
24 23
25#include <global.h> 24#include <global.h>
26#ifndef __CEXTRACT__
27# include <sproto.h> 25#include <sproto.h>
28#endif
29#include <spells.h> 26#include <spells.h>
30 27
31#ifdef COZY_SERVER 28#ifdef COZY_SERVER
32// used for pet monster logic etc. 29// used for pet monster logic etc.
33int 30int
55form_party (object *op, const char *params) 52form_party (object *op, const char *params)
56{ 53{
57 partylist *newparty; 54 partylist *newparty;
58 55
59 newparty = (partylist *) malloc (sizeof (partylist)); 56 newparty = (partylist *) malloc (sizeof (partylist));
60 newparty->partyname = strdup_local (params); 57 newparty->partyname = strdup (params);
61 newparty->total_exp = 0; 58 newparty->total_exp = 0;
62 newparty->kills = 0; 59 newparty->kills = 0;
63 newparty->passwd[0] = '\0'; 60 newparty->passwd[0] = '\0';
64 newparty->next = NULL; 61 newparty->next = NULL;
65 newparty->partyleader = strdup_local (op->name); 62 newparty->partyleader = strdup (op->name);
66 new_draw_info_format (NDI_UNIQUE, 0, op, "You have formed party: %s", newparty->partyname); 63 new_draw_info_format (NDI_UNIQUE, 0, op, "You have formed party: %s", newparty->partyname);
67 op->contr->party = newparty; 64 op->contr->party = newparty;
68 65
69 return newparty; 66 return newparty;
70} 67}
81 { 78 {
82 LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); 79 LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname);
83 return; 80 return;
84 } 81 }
85 82
86 for (pl = first_player; pl != NULL; pl = pl->next) 83 for_all_players (pl)
87 if (pl->party == target_party) 84 if (pl->party == target_party)
88 pl->party = NULL; 85 pl->party = NULL;
89 86
90 /* 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 */
91 if (target_party == firstparty) 88 if (target_party == firstparty)
151 return; /* we can't obsolete parties if there aren't any */ 148 return; /* we can't obsolete parties if there aren't any */
152 for (party = firstparty; party != NULL; party = next) 149 for (party = firstparty; party != NULL; party = next)
153 { 150 {
154 next = party->next; 151 next = party->next;
155 player_count = 0; 152 player_count = 0;
156 for (pl = first_player; pl != NULL; pl = pl->next) 153 for_all_players (pl)
157 if (pl->party == party) 154 if (pl->party == party)
158 player_count++; 155 player_count++;
159 if (player_count == 0) 156 if (player_count == 0)
160 remove_party (party); 157 remove_party (party);
161 } 158 }
217 op->contr->party = op->contr->party_to_join; 214 op->contr->party = op->contr->party_to_join;
218 op->contr->party_to_join = NULL; 215 op->contr->party_to_join = NULL;
219 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname); 216 new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname);
220 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname); 217 snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname);
221 send_party_message (op, buf); 218 send_party_message (op, buf);
222 op->contr->state = ST_PLAYING; 219 op->contr->ns->state = ST_PLAYING;
223 return; 220 return;
224 } 221 }
225 else 222 else
226 { 223 {
227 new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password"); 224 new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password");
228 op->contr->party_to_join = NULL; 225 op->contr->party_to_join = NULL;
229 op->contr->state = ST_PLAYING; 226 op->contr->ns->state = ST_PLAYING;
230 return; 227 return;
231 } 228 }
232} 229}
233 230
234void 231void
235send_party_message (object *op, char *msg) 232send_party_message (object *op, char *msg)
236{ 233{
237 player *pl; 234 player *pl;
238 235
239 for (pl = first_player; pl != NULL; pl = pl->next) 236 for_all_players (pl)
240 if (pl->ob->contr->party == op->contr->party && pl->ob != op) 237 if (pl->ob->contr->party == op->contr->party && pl->ob != op)
241 new_draw_info (NDI_WHITE, 0, pl->ob, msg); 238 new_draw_info (NDI_WHITE, 0, pl->ob, msg);
242} 239}
243 240
244int 241int
274 currentparty = op->contr->party->partyname; 271 currentparty = op->contr->party->partyname;
275 new_draw_info_format (NDI_UNIQUE, 0, op, "You are a member of party %s.", currentparty); 272 new_draw_info_format (NDI_UNIQUE, 0, op, "You are a member of party %s.", currentparty);
276 } 273 }
277 return 1; 274 return 1;
278 } 275 }
276
279 if (strcmp (params, "help") == 0) 277 if (strcmp (params, "help") == 0)
280 { 278 {
281 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>"); 279 new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>");
282 new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>"); 280 new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>");
283 new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it."); 281 new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it.");
290#ifdef PARTY_KILL_LOG 288#ifdef PARTY_KILL_LOG
291 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); 289 new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills");
292#endif 290#endif
293 return 1; 291 return 1;
294 } 292 }
293
295#ifdef PARTY_KILL_LOG 294#ifdef PARTY_KILL_LOG
296 if (!strncmp (params, "kills", 5)) 295 if (!strncmp (params, "kills", 5))
297 { 296 {
298 int i, max; 297 int i, max;
299 char chr; 298 char chr;
349 sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr); 348 sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr);
350 new_draw_info (NDI_UNIQUE, 0, op, buffer); 349 new_draw_info (NDI_UNIQUE, 0, op, buffer);
351 return 1; 350 return 1;
352 } 351 }
353#endif /* PARTY_KILL_LOG */ 352#endif /* PARTY_KILL_LOG */
353
354 if (strncmp (params, "say ", 4) == 0) 354 if (strncmp (params, "say ", 4) == 0)
355 { 355 {
356 if (op->contr->party == NULL) 356 if (op->contr->party == NULL)
357 { 357 {
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.");
360 } 360 }
361 params += 4; 361 params += 4;
362 currentparty = op->contr->party->partyname; 362 currentparty = op->contr->party->partyname;
363 snprintf (buf, MAX_BUF - 1, "[%s] %s says: %s", currentparty, &op->name, params); 363 snprintf (buf, MAX_BUF - 1, "[%s] %s says: %s", currentparty, &op->name, params);
364 send_party_message (op, buf); 364 send_party_message (op, buf);
365 new_draw_info_format (NDI_WHITE, 0, op, "[%s] You say: %s", currentparty, params); 365 new_draw_info_format (NDI_LT_GREEN | NDI_UNIQUE, 0, op, "[%s] You say: %s", currentparty, params);
366 return 1; 366 return 1;
367 } 367 }
368 368
369 if (strncmp (params, "form ", 5) == 0) 369 if (strncmp (params, "form ", 5) == 0)
370 { 370 {
425 sprintf (buf, "%s leaves party %s.", &op->name, currentparty); 425 sprintf (buf, "%s leaves party %s.", &op->name, currentparty);
426 send_party_message (op, buf); 426 send_party_message (op, buf);
427 op->contr->party = NULL; 427 op->contr->party = NULL;
428 return 1; 428 return 1;
429 } 429 }
430
430 if (strcmp (params, "who") == 0) 431 if (strcmp (params, "who") == 0)
431 { 432 {
432 player *pl; 433 player *pl;
433 434
434 tmpparty = op->contr->party; 435 tmpparty = op->contr->party;
436 { 437 {
437 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); 438 new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party.");
438 return 1; 439 return 1;
439 } 440 }
440 new_draw_info_format (NDI_UNIQUE, 0, op, "Members of party: %s.", op->contr->party->partyname); 441 new_draw_info_format (NDI_UNIQUE, 0, op, "Members of party: %s.", op->contr->party->partyname);
441 for (pl = first_player; pl != NULL; pl = pl->next) 442 for_all_players (pl)
442 if (pl->ob->contr->party == op->contr->party) 443 if (pl->ob->contr->party == op->contr->party)
443 { 444 {
444 if (settings.set_title == TRUE) 445 if (settings.set_title == TRUE)
445 { 446 {
446 if (pl->ob->contr->own_title[0] != '\0') 447 if (pl->ob->contr->own_title[0] != '\0')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines