diff --git a/port/linux/game/network_coop.c b/port/linux/game/network_coop.c index 50421dbd..9e38dd31 100644 --- a/port/linux/game/network_coop.c +++ b/port/linux/game/network_coop.c @@ -73,6 +73,7 @@ index and tag, since the map placed them at the same index everywhere. #include "effects/effect_definitions.h" #include "effects/player_effects.h" #include "game/game.h" +#include "game/game_allegiance.h" #include "game/game_engine.h" #include "game/players.h" #include "game/player_queues_new.h" @@ -272,6 +273,10 @@ struct distributed_coop_presentation byte pad[2]; real players_maximum_body_vitality; real players_maximum_shield_vitality; + /* which teams are allies and friends (game_allegiance.c): the scripts + make them, so a client's would leave the marines its enemies */ + unsigned long ally_teams[GAME_ALLEGIANCE_BITVECTOR_LONGS]; + unsigned long friendly_teams[GAME_ALLEGIANCE_BITVECTOR_LONGS]; }; struct distributed_coop_presentation_message @@ -1422,6 +1427,7 @@ static void host_presentation( presentation->players_vitality_set = (byte)players_vitality.set; presentation->players_maximum_body_vitality = players_vitality.maximum_body; presentation->players_maximum_shield_vitality = players_vitality.maximum_shield; + game_allegiance_get_teams(presentation->ally_teams, presentation->friendly_teams); SET_FLAG(presentation->flags, _presentation_skippable_bit, skip_vote.offered); presentation->skip_votes = (byte)MIN(skip_vote.votes, 255); presentation->skip_voters = (byte)MIN(skip_vote.voters, 255); @@ -2853,6 +2859,7 @@ static void client_presentation_apply( players_vitality.maximum_body = presentation->players_maximum_body_vitality; players_vitality.maximum_shield = presentation->players_maximum_shield_vitality; } + game_allegiance_set_teams(presentation->ally_teams, presentation->friendly_teams); if (!presentation->scripted_shake && player_effect_port_scripted_active()) player_effect_port_scripted_end(); diff --git a/source/game/game_allegiance.c b/source/game/game_allegiance.c index 15f2e970..4421b65f 100644 --- a/source/game/game_allegiance.c +++ b/source/game/game_allegiance.c @@ -88,8 +88,8 @@ struct game_allegiance_globals short allegiance_count; struct game_allegiance_record allegiances[8]; byte reserved92[2]; - unsigned long ally_bitvector[4]; - unsigned long friendly_bitvector[4]; + unsigned long ally_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS]; + unsigned long friendly_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS]; }; typedef char game_allegiance_record_size_assert[ @@ -452,6 +452,28 @@ void game_allegiance_update( return; } +/* port: which teams are allies and which friends. A co-op client takes the +host's, as only the host runs the scripts that make allegiances. */ +void game_allegiance_get_teams( + unsigned long ally_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS], + unsigned long friendly_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS]) +{ + csmemcpy(ally_bitvector, game_allegiance_globals->ally_bitvector, + sizeof(game_allegiance_globals->ally_bitvector)); + csmemcpy(friendly_bitvector, game_allegiance_globals->friendly_bitvector, + sizeof(game_allegiance_globals->friendly_bitvector)); +} + +void game_allegiance_set_teams( + unsigned long const ally_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS], + unsigned long const friendly_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS]) +{ + csmemcpy(game_allegiance_globals->ally_bitvector, ally_bitvector, + sizeof(game_allegiance_globals->ally_bitvector)); + csmemcpy(game_allegiance_globals->friendly_bitvector, friendly_bitvector, + sizeof(game_allegiance_globals->friendly_bitvector)); +} + void game_allegiance_create( short team1_index, boolean team1_suspicious, diff --git a/source/game/game_allegiance.h b/source/game/game_allegiance.h index e607caeb..fbbe2ab4 100644 --- a/source/game/game_allegiance.h +++ b/source/game/game_allegiance.h @@ -11,6 +11,9 @@ enum _allegiance_incident_forgive }; +/* port: the longs of game_allegiance_get_teams' bit vectors */ +#define GAME_ALLEGIANCE_BITVECTOR_LONGS 4 + /* ---------- prototypes/GAME_ALLEGIANCE.C */ void game_allegiance_initialize( @@ -23,6 +26,12 @@ void game_allegiance_dispose_from_old_map( void); void game_allegiance_update( void); +void game_allegiance_get_teams( + unsigned long ally_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS], + unsigned long friendly_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS]); +void game_allegiance_set_teams( + unsigned long const ally_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS], + unsigned long const friendly_bitvector[GAME_ALLEGIANCE_BITVECTOR_LONGS]); void game_allegiance_create( short team1_index, boolean team1_suspicious,