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__ |
25 | #ifndef __CEXTRACT__ |
27 | # include <sproto.h> |
26 | # include <sproto.h> |
… | |
… | |
55 | form_party (object *op, const char *params) |
54 | form_party (object *op, const char *params) |
56 | { |
55 | { |
57 | partylist *newparty; |
56 | partylist *newparty; |
58 | |
57 | |
59 | newparty = (partylist *) malloc (sizeof (partylist)); |
58 | newparty = (partylist *) malloc (sizeof (partylist)); |
60 | newparty->partyname = strdup_local (params); |
59 | newparty->partyname = strdup (params); |
61 | newparty->total_exp = 0; |
60 | newparty->total_exp = 0; |
62 | newparty->kills = 0; |
61 | newparty->kills = 0; |
63 | newparty->passwd[0] = '\0'; |
62 | newparty->passwd[0] = '\0'; |
64 | newparty->next = NULL; |
63 | newparty->next = NULL; |
65 | newparty->partyleader = strdup_local (op->name); |
64 | newparty->partyleader = strdup (op->name); |
66 | 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); |
67 | op->contr->party = newparty; |
66 | op->contr->party = newparty; |
68 | |
67 | |
69 | return newparty; |
68 | return newparty; |
70 | } |
69 | } |
… | |
… | |
81 | { |
80 | { |
82 | 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); |
83 | return; |
82 | return; |
84 | } |
83 | } |
85 | |
84 | |
86 | for (pl = first_player; pl != NULL; pl = pl->next) |
85 | for_all_players (pl) |
87 | if (pl->party == target_party) |
86 | if (pl->party == target_party) |
88 | pl->party = NULL; |
87 | pl->party = NULL; |
89 | |
88 | |
90 | /* 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 */ |
91 | if (target_party == firstparty) |
90 | if (target_party == firstparty) |
… | |
… | |
151 | return; /* we can't obsolete parties if there aren't any */ |
150 | return; /* we can't obsolete parties if there aren't any */ |
152 | for (party = firstparty; party != NULL; party = next) |
151 | for (party = firstparty; party != NULL; party = next) |
153 | { |
152 | { |
154 | next = party->next; |
153 | next = party->next; |
155 | player_count = 0; |
154 | player_count = 0; |
156 | for (pl = first_player; pl != NULL; pl = pl->next) |
155 | for_all_players (pl) |
157 | if (pl->party == party) |
156 | if (pl->party == party) |
158 | player_count++; |
157 | player_count++; |
159 | if (player_count == 0) |
158 | if (player_count == 0) |
160 | remove_party (party); |
159 | remove_party (party); |
161 | } |
160 | } |
… | |
… | |
178 | else |
177 | else |
179 | pos = party->kills; |
178 | pos = party->kills; |
180 | party->kills++; |
179 | party->kills++; |
181 | party->total_exp += exp; |
180 | party->total_exp += exp; |
182 | party->party_kills[pos].exp = exp; |
181 | party->party_kills[pos].exp = exp; |
183 | strncpy (party->party_kills[pos].killer, killer, MAX_NAME); |
182 | assign (party->party_kills[pos].killer, killer); |
184 | strncpy (party->party_kills[pos].dead, dead, MAX_NAME); |
183 | assign (party->party_kills[pos].dead, dead); |
185 | party->party_kills[pos].killer[MAX_NAME] = 0; |
184 | party->party_kills[pos].killer[MAX_NAME] = 0; |
186 | party->party_kills[pos].dead[MAX_NAME] = 0; |
185 | party->party_kills[pos].dead[MAX_NAME] = 0; |
187 | } |
186 | } |
188 | #endif |
187 | #endif |
189 | |
188 | |
… | |
… | |
217 | op->contr->party = op->contr->party_to_join; |
216 | op->contr->party = op->contr->party_to_join; |
218 | op->contr->party_to_join = NULL; |
217 | op->contr->party_to_join = NULL; |
219 | 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); |
220 | 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); |
221 | send_party_message (op, buf); |
220 | send_party_message (op, buf); |
222 | op->contr->state = ST_PLAYING; |
221 | op->contr->ns->state = ST_PLAYING; |
223 | return; |
222 | return; |
224 | } |
223 | } |
225 | else |
224 | else |
226 | { |
225 | { |
227 | 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"); |
228 | op->contr->party_to_join = NULL; |
227 | op->contr->party_to_join = NULL; |
229 | op->contr->state = ST_PLAYING; |
228 | op->contr->ns->state = ST_PLAYING; |
230 | return; |
229 | return; |
231 | } |
230 | } |
232 | } |
231 | } |
233 | |
232 | |
234 | void |
233 | void |
235 | send_party_message (object *op, char *msg) |
234 | send_party_message (object *op, char *msg) |
236 | { |
235 | { |
237 | player *pl; |
236 | player *pl; |
238 | |
237 | |
239 | for (pl = first_player; pl != NULL; pl = pl->next) |
238 | for_all_players (pl) |
240 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
239 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
241 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
240 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
242 | } |
241 | } |
243 | |
242 | |
244 | int |
243 | int |
… | |
… | |
274 | currentparty = op->contr->party->partyname; |
273 | currentparty = op->contr->party->partyname; |
275 | 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); |
276 | } |
275 | } |
277 | return 1; |
276 | return 1; |
278 | } |
277 | } |
|
|
278 | |
279 | if (strcmp (params, "help") == 0) |
279 | if (strcmp (params, "help") == 0) |
280 | { |
280 | { |
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 form a party type: party form <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, "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."); |
283 | 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 |
290 | #ifdef PARTY_KILL_LOG |
291 | 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"); |
292 | #endif |
292 | #endif |
293 | return 1; |
293 | return 1; |
294 | } |
294 | } |
|
|
295 | |
295 | #ifdef PARTY_KILL_LOG |
296 | #ifdef PARTY_KILL_LOG |
296 | if (!strncmp (params, "kills", 5)) |
297 | if (!strncmp (params, "kills", 5)) |
297 | { |
298 | { |
298 | int i, max; |
299 | int i, max; |
299 | char chr; |
300 | char chr; |
… | |
… | |
349 | 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); |
350 | new_draw_info (NDI_UNIQUE, 0, op, buffer); |
351 | new_draw_info (NDI_UNIQUE, 0, op, buffer); |
351 | return 1; |
352 | return 1; |
352 | } |
353 | } |
353 | #endif /* PARTY_KILL_LOG */ |
354 | #endif /* PARTY_KILL_LOG */ |
|
|
355 | |
354 | if (strncmp (params, "say ", 4) == 0) |
356 | if (strncmp (params, "say ", 4) == 0) |
355 | { |
357 | { |
356 | if (op->contr->party == NULL) |
358 | if (op->contr->party == NULL) |
357 | { |
359 | { |
358 | 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."); |
… | |
… | |
360 | } |
362 | } |
361 | params += 4; |
363 | params += 4; |
362 | currentparty = op->contr->party->partyname; |
364 | currentparty = op->contr->party->partyname; |
363 | 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); |
364 | send_party_message (op, buf); |
366 | send_party_message (op, buf); |
365 | 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); |
366 | return 1; |
368 | return 1; |
367 | } |
369 | } |
368 | |
370 | |
369 | if (strncmp (params, "form ", 5) == 0) |
371 | if (strncmp (params, "form ", 5) == 0) |
370 | { |
372 | { |
… | |
… | |
425 | sprintf (buf, "%s leaves party %s.", &op->name, currentparty); |
427 | sprintf (buf, "%s leaves party %s.", &op->name, currentparty); |
426 | send_party_message (op, buf); |
428 | send_party_message (op, buf); |
427 | op->contr->party = NULL; |
429 | op->contr->party = NULL; |
428 | return 1; |
430 | return 1; |
429 | } |
431 | } |
|
|
432 | |
430 | if (strcmp (params, "who") == 0) |
433 | if (strcmp (params, "who") == 0) |
431 | { |
434 | { |
432 | player *pl; |
435 | player *pl; |
433 | |
436 | |
434 | tmpparty = op->contr->party; |
437 | tmpparty = op->contr->party; |
… | |
… | |
436 | { |
439 | { |
437 | 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."); |
438 | return 1; |
441 | return 1; |
439 | } |
442 | } |
440 | 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); |
441 | for (pl = first_player; pl != NULL; pl = pl->next) |
444 | for_all_players (pl) |
442 | if (pl->ob->contr->party == op->contr->party) |
445 | if (pl->ob->contr->party == op->contr->party) |
443 | { |
446 | { |
444 | if (settings.set_title == TRUE) |
447 | if (settings.set_title == TRUE) |
445 | { |
448 | { |
446 | if (pl->ob->contr->own_title[0] != '\0') |
449 | if (pl->ob->contr->own_title[0] != '\0') |