Files
xshxdex98 7a1ffca28b Network: glass and destructible scenery break the same for everyone
Breakable surfaces (glass) are broken by each machine's own projectiles
with its own random damage, so a pane could shatter on the host and stay
whole, still blocking, on a client. In co-op the host now sends each break
(and a few again every refresh, for late joiners), and a client breaks the
same surface with its shards.

Destructible scenery and devices (lights, panels) are the map's, at the
same index on every machine, but only damage to units was synced: a
client's shots never damaged them, and what the host broke didn't break
or play its effects on the clients. A client now reports its hits on them
like any other, the host checks and deals them, and every client deals the
host's damage to its own copy, which breaks, plays its effects and is
destroyed as the host's was.

Both are new message kinds that a client without them ignores, so the
network version is unchanged.
2026-10-05 13:00:01 -05:00

111 lines
2.4 KiB
C

/*
BREAKABLE_SURFACES.H
header included in hcex build.
*/
#ifndef __BREAKABLE_SURFACES_H
#define __BREAKABLE_SURFACES_H
#pragma once
/* ---------- headers */
#include "math/real_math.h"
#include "tag_files/tag_groups.h"
/* ---------- constants */
enum
{
MAXIMUM_BREAKABLE_SURFACE_QUEUE_SIZE = 1024,
};
enum
{
MAXIMUM_BREAKABLE_SURFACES_PER_MAP = 256,
MAXIMUM_PARTICLE_EFFECTS_PER_BREAKABLE_SURFACE_DEFINITION = 8,
};
enum
{
_breakable_surface_particle_effect_color_interpolate_in_hsv_bit = 0,
_breakable_surface_particle_effect_color_interpolate_along_farthest_hue_path_bit,
NUMBER_OF_BREAKABLE_SURFACE_PARTICLE_EFFECT_FLAGS,
};
/* ---------- macros */
/* ---------- structures */
struct breakable_surface_datum
{
real vitality;
};
struct structure_breakable_surface
{
real_point3d centroid;
real bounding_radius;
long collision_surface_index;
long unused[7];
};
struct breakable_surface_particle_effect
{
struct tag_reference particle;
unsigned long flags;
real density;
real velocity_scale_lower_bound;
real velocity_scale_upper_bound;
real velocity_cone_angle;
real angular_velocity_lower_bound;
real angular_velocity_upper_bound;
unsigned long unused1[2];
real radius_lower_bound;
real radius_upper_bound;
unsigned long unused2[2];
real_argb_color tint_lower_bound;
real_argb_color tint_upper_bound;
unsigned long unused3[7];
};
/* ---------- prototypes/BREAKABLE_SURFACES.C */
struct breakable_surface_datum *breakable_surface_get(
short breakable_surface_index);
/* port: breaks a surface as damage at `epicenter` would, shards and all,
for a network co-op client the host told (port/linux/game/network_coop.c);
nothing if it is already broken */
void breakable_surface_port_break(
short breakable_surface_index,
real_point3d const *epicenter);
void breakable_surfaces_initialize(
void);
void breakable_surfaces_dispose(
void);
void breakable_surfaces_initialize_for_new_map(
void);
void breakable_surfaces_dispose_from_old_map(
void);
void breakable_surfaces_enable(
boolean state);
void breakable_surfaces_reset(
void);
byte *breakable_surface_flags_get(
void);
boolean breakable_surface_extant(
short breakable_surface_index);
void breakable_surface_damage(
short breakable_surface_index,
struct damage_data *damage_data,
long seed_surface_index);
void breakable_surface_damage_area_of_effect(
const struct damage_data *damage_data);
/* ---------- globals */
/* ---------- public code */
#endif // __BREAKABLE_SURFACES_H