… | |
… | |
20 | |
20 | |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #ifndef __CEXTRACT__ |
|
|
26 | # include <sproto.h> |
25 | #include <sproto.h> |
27 | #endif |
|
|
28 | #include <spells.h> |
26 | #include <spells.h> |
29 | |
27 | |
30 | #ifdef COZY_SERVER |
28 | #ifdef COZY_SERVER |
31 | // used for pet monster logic etc. |
29 | // used for pet monster logic etc. |
32 | int |
30 | int |
… | |
… | |
54 | form_party (object *op, const char *params) |
52 | form_party (object *op, const char *params) |
55 | { |
53 | { |
56 | partylist *newparty; |
54 | partylist *newparty; |
57 | |
55 | |
58 | newparty = (partylist *) malloc (sizeof (partylist)); |
56 | newparty = (partylist *) malloc (sizeof (partylist)); |
59 | newparty->partyname = strdup_local (params); |
57 | newparty->partyname = strdup (params); |
60 | newparty->total_exp = 0; |
58 | newparty->total_exp = 0; |
61 | newparty->kills = 0; |
59 | newparty->kills = 0; |
62 | newparty->passwd[0] = '\0'; |
60 | newparty->passwd[0] = '\0'; |
63 | newparty->next = NULL; |
61 | newparty->next = NULL; |
64 | newparty->partyleader = strdup_local (op->name); |
62 | newparty->partyleader = strdup (op->name); |
65 | 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); |
66 | op->contr->party = newparty; |
64 | op->contr->party = newparty; |
67 | |
65 | |
68 | return newparty; |
66 | return newparty; |
69 | } |
67 | } |
… | |
… | |
80 | { |
78 | { |
81 | 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); |
82 | return; |
80 | return; |
83 | } |
81 | } |
84 | |
82 | |
85 | for (pl = first_player; pl != NULL; pl = pl->next) |
83 | for_all_players (pl) |
86 | if (pl->party == target_party) |
84 | if (pl->party == target_party) |
87 | pl->party = NULL; |
85 | pl->party = NULL; |
88 | |
86 | |
89 | /* 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 */ |
90 | if (target_party == firstparty) |
88 | if (target_party == firstparty) |
… | |
… | |
150 | return; /* we can't obsolete parties if there aren't any */ |
148 | return; /* we can't obsolete parties if there aren't any */ |
151 | for (party = firstparty; party != NULL; party = next) |
149 | for (party = firstparty; party != NULL; party = next) |
152 | { |
150 | { |
153 | next = party->next; |
151 | next = party->next; |
154 | player_count = 0; |
152 | player_count = 0; |
155 | for (pl = first_player; pl != NULL; pl = pl->next) |
153 | for_all_players (pl) |
156 | if (pl->party == party) |
154 | if (pl->party == party) |
157 | player_count++; |
155 | player_count++; |
158 | if (player_count == 0) |
156 | if (player_count == 0) |
159 | remove_party (party); |
157 | remove_party (party); |
160 | } |
158 | } |
… | |
… | |
216 | op->contr->party = op->contr->party_to_join; |
214 | op->contr->party = op->contr->party_to_join; |
217 | op->contr->party_to_join = NULL; |
215 | op->contr->party_to_join = NULL; |
218 | 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); |
219 | 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); |
220 | send_party_message (op, buf); |
218 | send_party_message (op, buf); |
221 | op->contr->state = ST_PLAYING; |
219 | op->contr->ns->state = ST_PLAYING; |
222 | return; |
220 | return; |
223 | } |
221 | } |
224 | else |
222 | else |
225 | { |
223 | { |
226 | 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"); |
227 | op->contr->party_to_join = NULL; |
225 | op->contr->party_to_join = NULL; |
228 | op->contr->state = ST_PLAYING; |
226 | op->contr->ns->state = ST_PLAYING; |
229 | return; |
227 | return; |
230 | } |
228 | } |
231 | } |
229 | } |
232 | |
230 | |
233 | void |
231 | void |
234 | send_party_message (object *op, char *msg) |
232 | send_party_message (object *op, char *msg) |
235 | { |
233 | { |
236 | player *pl; |
234 | player *pl; |
237 | |
235 | |
238 | for (pl = first_player; pl != NULL; pl = pl->next) |
236 | for_all_players (pl) |
239 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
237 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
240 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
238 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
241 | } |
239 | } |
242 | |
240 | |
243 | int |
241 | int |
… | |
… | |
439 | { |
437 | { |
440 | 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."); |
441 | return 1; |
439 | return 1; |
442 | } |
440 | } |
443 | 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); |
444 | for (pl = first_player; pl != NULL; pl = pl->next) |
442 | for_all_players (pl) |
445 | if (pl->ob->contr->party == op->contr->party) |
443 | if (pl->ob->contr->party == op->contr->party) |
446 | { |
444 | { |
447 | if (settings.set_title == TRUE) |
445 | if (settings.set_title == TRUE) |
448 | { |
446 | { |
449 | if (pl->ob->contr->own_title[0] != '\0') |
447 | if (pl->ob->contr->own_title[0] != '\0') |