… | |
… | |
54 | form_party (object *op, const char *params) |
54 | form_party (object *op, const char *params) |
55 | { |
55 | { |
56 | partylist *newparty; |
56 | partylist *newparty; |
57 | |
57 | |
58 | newparty = (partylist *) malloc (sizeof (partylist)); |
58 | newparty = (partylist *) malloc (sizeof (partylist)); |
59 | newparty->partyname = strdup_local (params); |
59 | newparty->partyname = strdup (params); |
60 | newparty->total_exp = 0; |
60 | newparty->total_exp = 0; |
61 | newparty->kills = 0; |
61 | newparty->kills = 0; |
62 | newparty->passwd[0] = '\0'; |
62 | newparty->passwd[0] = '\0'; |
63 | newparty->next = NULL; |
63 | newparty->next = NULL; |
64 | newparty->partyleader = strdup_local (op->name); |
64 | newparty->partyleader = strdup (op->name); |
65 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have formed party: %s", newparty->partyname); |
65 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have formed party: %s", newparty->partyname); |
66 | op->contr->party = newparty; |
66 | op->contr->party = newparty; |
67 | |
67 | |
68 | return newparty; |
68 | return newparty; |
69 | } |
69 | } |
… | |
… | |
80 | { |
80 | { |
81 | LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); |
81 | LOG (llevError, "remove_party(): I was asked to remove party %s, but no parties are defined", target_party->partyname); |
82 | return; |
82 | return; |
83 | } |
83 | } |
84 | |
84 | |
85 | for (pl = first_player; pl != NULL; pl = pl->next) |
85 | for_all_players (pl) |
86 | if (pl->party == target_party) |
86 | if (pl->party == target_party) |
87 | pl->party = NULL; |
87 | pl->party = NULL; |
88 | |
88 | |
89 | /* special case-ism for parties at the beginning and end of the list */ |
89 | /* special case-ism for parties at the beginning and end of the list */ |
90 | if (target_party == firstparty) |
90 | if (target_party == firstparty) |
… | |
… | |
150 | return; /* we can't obsolete parties if there aren't any */ |
150 | return; /* we can't obsolete parties if there aren't any */ |
151 | for (party = firstparty; party != NULL; party = next) |
151 | for (party = firstparty; party != NULL; party = next) |
152 | { |
152 | { |
153 | next = party->next; |
153 | next = party->next; |
154 | player_count = 0; |
154 | player_count = 0; |
155 | for (pl = first_player; pl != NULL; pl = pl->next) |
155 | for_all_players (pl) |
156 | if (pl->party == party) |
156 | if (pl->party == party) |
157 | player_count++; |
157 | player_count++; |
158 | if (player_count == 0) |
158 | if (player_count == 0) |
159 | remove_party (party); |
159 | remove_party (party); |
160 | } |
160 | } |
… | |
… | |
216 | op->contr->party = op->contr->party_to_join; |
216 | op->contr->party = op->contr->party_to_join; |
217 | op->contr->party_to_join = NULL; |
217 | op->contr->party_to_join = NULL; |
218 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname); |
218 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have joined party: %s\n", joined_party->partyname); |
219 | snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname); |
219 | snprintf (buf, MAX_BUF, "%s joins party %s", &op->name, joined_party->partyname); |
220 | send_party_message (op, buf); |
220 | send_party_message (op, buf); |
221 | op->contr->state = ST_PLAYING; |
221 | op->contr->ns->state = ST_PLAYING; |
222 | return; |
222 | return; |
223 | } |
223 | } |
224 | else |
224 | else |
225 | { |
225 | { |
226 | new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password"); |
226 | new_draw_info (NDI_UNIQUE, 0, op, "You entered the wrong password"); |
227 | op->contr->party_to_join = NULL; |
227 | op->contr->party_to_join = NULL; |
228 | op->contr->state = ST_PLAYING; |
228 | op->contr->ns->state = ST_PLAYING; |
229 | return; |
229 | return; |
230 | } |
230 | } |
231 | } |
231 | } |
232 | |
232 | |
233 | void |
233 | void |
234 | send_party_message (object *op, char *msg) |
234 | send_party_message (object *op, char *msg) |
235 | { |
235 | { |
236 | player *pl; |
236 | player *pl; |
237 | |
237 | |
238 | for (pl = first_player; pl != NULL; pl = pl->next) |
238 | for_all_players (pl) |
239 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
239 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
240 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
240 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
241 | } |
241 | } |
242 | |
242 | |
243 | int |
243 | int |
… | |
… | |
273 | currentparty = op->contr->party->partyname; |
273 | currentparty = op->contr->party->partyname; |
274 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are a member of party %s.", currentparty); |
274 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are a member of party %s.", currentparty); |
275 | } |
275 | } |
276 | return 1; |
276 | return 1; |
277 | } |
277 | } |
|
|
278 | |
278 | if (strcmp (params, "help") == 0) |
279 | if (strcmp (params, "help") == 0) |
279 | { |
280 | { |
280 | new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>"); |
281 | new_draw_info (NDI_UNIQUE, 0, op, "To form a party type: party form <partyname>"); |
281 | new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>"); |
282 | new_draw_info (NDI_UNIQUE, 0, op, "To join a party type: party join <partyname>"); |
282 | new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it."); |
283 | new_draw_info (NDI_UNIQUE, 0, op, "If the party has a passwd, it will you prompt you for it."); |
… | |
… | |
289 | #ifdef PARTY_KILL_LOG |
290 | #ifdef PARTY_KILL_LOG |
290 | new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); |
291 | new_draw_info (NDI_UNIQUE, 0, op, "To see what you've killed, type: party kills"); |
291 | #endif |
292 | #endif |
292 | return 1; |
293 | return 1; |
293 | } |
294 | } |
|
|
295 | |
294 | #ifdef PARTY_KILL_LOG |
296 | #ifdef PARTY_KILL_LOG |
295 | if (!strncmp (params, "kills", 5)) |
297 | if (!strncmp (params, "kills", 5)) |
296 | { |
298 | { |
297 | int i, max; |
299 | int i, max; |
298 | char chr; |
300 | char chr; |
… | |
… | |
348 | sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr); |
350 | sprintf (buffer, "Totals: %d kills, %.1f%c exp", tmpparty->kills, exp, chr); |
349 | new_draw_info (NDI_UNIQUE, 0, op, buffer); |
351 | new_draw_info (NDI_UNIQUE, 0, op, buffer); |
350 | return 1; |
352 | return 1; |
351 | } |
353 | } |
352 | #endif /* PARTY_KILL_LOG */ |
354 | #endif /* PARTY_KILL_LOG */ |
|
|
355 | |
353 | if (strncmp (params, "say ", 4) == 0) |
356 | if (strncmp (params, "say ", 4) == 0) |
354 | { |
357 | { |
355 | if (op->contr->party == NULL) |
358 | if (op->contr->party == NULL) |
356 | { |
359 | { |
357 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
360 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
… | |
… | |
359 | } |
362 | } |
360 | params += 4; |
363 | params += 4; |
361 | currentparty = op->contr->party->partyname; |
364 | currentparty = op->contr->party->partyname; |
362 | snprintf (buf, MAX_BUF - 1, "[%s] %s says: %s", currentparty, &op->name, params); |
365 | snprintf (buf, MAX_BUF - 1, "[%s] %s says: %s", currentparty, &op->name, params); |
363 | send_party_message (op, buf); |
366 | send_party_message (op, buf); |
364 | new_draw_info_format (NDI_WHITE, 0, op, "[%s] You say: %s", currentparty, params); |
367 | new_draw_info_format (NDI_LT_GREEN | NDI_UNIQUE, 0, op, "[%s] You say: %s", currentparty, params); |
365 | return 1; |
368 | return 1; |
366 | } |
369 | } |
367 | |
370 | |
368 | if (strncmp (params, "form ", 5) == 0) |
371 | if (strncmp (params, "form ", 5) == 0) |
369 | { |
372 | { |
… | |
… | |
424 | sprintf (buf, "%s leaves party %s.", &op->name, currentparty); |
427 | sprintf (buf, "%s leaves party %s.", &op->name, currentparty); |
425 | send_party_message (op, buf); |
428 | send_party_message (op, buf); |
426 | op->contr->party = NULL; |
429 | op->contr->party = NULL; |
427 | return 1; |
430 | return 1; |
428 | } |
431 | } |
|
|
432 | |
429 | if (strcmp (params, "who") == 0) |
433 | if (strcmp (params, "who") == 0) |
430 | { |
434 | { |
431 | player *pl; |
435 | player *pl; |
432 | |
436 | |
433 | tmpparty = op->contr->party; |
437 | tmpparty = op->contr->party; |
… | |
… | |
435 | { |
439 | { |
436 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
440 | new_draw_info (NDI_UNIQUE, 0, op, "You are not a member of any party."); |
437 | return 1; |
441 | return 1; |
438 | } |
442 | } |
439 | new_draw_info_format (NDI_UNIQUE, 0, op, "Members of party: %s.", op->contr->party->partyname); |
443 | new_draw_info_format (NDI_UNIQUE, 0, op, "Members of party: %s.", op->contr->party->partyname); |
440 | for (pl = first_player; pl != NULL; pl = pl->next) |
444 | for_all_players (pl) |
441 | if (pl->ob->contr->party == op->contr->party) |
445 | if (pl->ob->contr->party == op->contr->party) |
442 | { |
446 | { |
443 | if (settings.set_title == TRUE) |
447 | if (settings.set_title == TRUE) |
444 | { |
448 | { |
445 | if (pl->ob->contr->own_title[0] != '\0') |
449 | if (pl->ob->contr->own_title[0] != '\0') |