mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-17 12:00:26 +02:00
Co-op: clients take the host's allegiances
The scripts make allegiances (ai_allegiance player human) and only the host runs them, so on clients marines stayed enemies of the players: red reticles and the wrong team. The host sends its ally and friend tables with the presentation each tick.
This commit is contained in:
1 parent
91e838e2f6
commit
5ff4b6ee8d
3 files changed
+40
-2
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user