Files
GuvenandClaude Opus 5.5 1d38b3f936 Co-op hosts can make the players' AI allies immune to their fire
Server Setup's Co-op Options has ALLY FRIENDLY FIRE
(network.coop_ally_friendly_fire), ON by default as in the campaign. OFF,
the players' weapons, grenades, melee and vehicles do their AI allies no
damage, so that no player can kill Captain Keyes on Truth and
Reconciliation, the Marines, or the other allies a level needs. The AI's
own hits of its allies, the enemies' damage, and FRIENDLY FIRE between
players are unchanged. A hit is the players' when its owner is a player
and the victim is a friendly unit that is no player's, so friendly-team
vehicles are immune to the players too, splatter included. An ally that
cannot die cannot raise an allegiance incident, so the players cannot turn
the Marines hostile either.

The rule is in game_engine_friendly_damage (game_engine.c), which only the
host's damage reaches: a client's hits are the host's to deal. The host
sends the choice with the game's settings, as bit 1 of network_game's
cooperative_flags beside PLAYER COLLISIONS', so network version 33: a
client of version 32 would play the game's settings without it. NETCODE.md
says so, and network_format.txt is recorded for 33.

The menu row is tools/port_settings.py's (COOP_SETUP_SCREENS); only the
server settings screen was written again. Its 8 rows fit above the help
area.

Checked: the Windows build; the harness tests, the new
test_coop_ally_friendly_fire (a player's hit of an ally ON and OFF, the
AI's own hit, players' friendly fire in every mode, no unit, the campaign
without co-op, and four negative controls) and test_coop_scaling_menu with
the eighth row; network_format.py; the Co-op Options screen drawn with the
row; and in play as the host on a10 and a50 (Keyes and the Marines
unharmed with OFF) and b30 (no splatter). Not yet: a client's hits online,
d20's ending, c20's Sentinels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:45:03 +01:00

139 lines
3.6 KiB
C

/*
NETWORK_GAME_MANAGER.H
header included in hcex build.
*/
#ifndef __NETWORK_GAME_MANAGER_H
#define __NETWORK_GAME_MANAGER_H
#pragma once
/* ---------- headers */
#include "game/game_engine.h"
#include "game/players.h"
/* ---------- constants */
/* ---------- macros */
/* ---------- structures */
struct network_game;
struct network_machine;
struct network_player;
struct network_machine
{
wchar_t name[32];
char machine_index;
byte __padding41[3];
};
struct network_game_map
{
long version;
char name[0x80];
};
struct network_game_local_data
{
boolean game_objects_loaded;
byte __padding431[3];
};
/* port: network_game's cooperative_flags */
enum
{
/* the players pass through each other (Server Setup's PLAYER COLLISIONS:
OFF, co-op's): network_coop_player_collisions */
_network_game_cooperative_no_player_collisions_bit = 0,
/* the players do their AI allies no harm (Server Setup's ALLY FRIENDLY
FIRE: OFF, co-op's): network_coop_ally_friendly_fire */
_network_game_cooperative_no_ally_friendly_fire_bit = 1,
};
struct network_game
{
wchar_t name[16];
struct network_game_map map;
struct game_variant variant;
/* port: co-op's switches (_network_game_cooperative_*_bit), in a byte the
Xbox's game left as padding, which builds before them send as 0 */
byte cooperative_flags;
char minimum_players;
/* port: 128 does not fit a signed char */
byte maximum_players;
byte maximum_teams;
short difficulty;
short machine_count;
/* port: the native builds' session limits, 128 machines and players
(port/linux/include/halo_port_limits.h) */
struct network_machine machines[HALO_PORT_MAXIMUM_NETWORK_MACHINES];
short player_count;
struct network_player players[HALO_PORT_MAXIMUM_NETWORK_PLAYERS];
short __unknown426;
unsigned long random_seed;
long number_of_games_played;
/* port: the gametype's PC options (game_engine.h) */
struct game_variant_options variant_options;
struct network_game_local_data local_data;
};
/* ---------- prototypes/EXAMPLE.C */
void network_game_invalidate_player(
struct network_player *player);
void network_game_end_and_load_ui(
struct network_game *game);
void network_game_assign_players_to_team(
struct network_game *game,
char const *prefix);
boolean network_player_is_valid(
struct network_player *player);
boolean network_game_add_machine(
struct network_game *game,
struct network_machine *machine);
boolean network_game_update_machine(
struct network_game *game,
struct network_machine *machine);
void xbox_set_machine_name(
char const *machine_name);
void network_game_generate_local_machine_name(
wchar_t *machine_name);
boolean network_game_spawn_player(
struct network_player *player);
boolean network_game_player_is_valid(
struct network_player *player,
struct network_game *game);
void network_game_reset_for_next_round(
struct network_game *game,
boolean unload_game_objects);
boolean network_game_add_player(
struct network_game *game,
struct network_player *player);
boolean network_game_has_free_player_slot(
struct network_game *game);
void network_game_invalidate_machine(
struct network_game *game,
word machine_index);
void network_game_invalidate(
struct network_game *game);
boolean network_game_update_player(
struct network_game *game,
struct network_player *player);
boolean network_game_remove_player(
struct network_game *game,
struct network_player *player);
boolean network_game_remove_machine(
struct network_game *game,
struct network_machine *machine);
boolean network_game_create_game_objects(
struct network_game *game);
/* ---------- globals */
/* ---------- public code */
#endif // __NETWORK_GAME_MANAGER_H