- Scoreboard scores come from the local service: BattleEconomy missionScores() writes the official mission scores into the stock mission block customScoreParams, which the client copies into MissionSettings+0x6d8 without reading it; local_mp_scores.c reads them with DataBlock::getReal. The hardcoded scores and the death score go. - countActivePlayers already counts players with a living vehicle; the only LocalMP gap is its filter skipping bots (MPlayer+0x1d8 bit 7). A one-byte exe patch drops that filter bit instead of a rewrite hook. - ucavLaunch returns early on a host; an exe patch skips that return instead of clearing the global host flag around the call. - onBecameDead no longer runs with isLocalMP cleared: that only queued an EventOnPlayerDeath stock LocalMP skips on purpose, and broke the local player id remap inside the function. - The host chat object keeps its two-field layout, now documented from the host chat handler that reads it.
88 lines
4.4 KiB
C
88 lines
4.4 KiB
C
/*
|
|
* Shared internal state, resolved engine pointers, and subsystem interfaces
|
|
* for the LocalMP in-process host bridge.
|
|
*
|
|
* All addresses are resolved dynamically from masked .text signatures in
|
|
* local_mp_offsets.h and every detour is gated on local_mp_is_host().
|
|
*/
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
/* HUD script event raised for each combat event of the local player (local_mp_awards.c). */
|
|
#define LMP_AWARD_EVENT_NAME "wtoLocalMpExpEvent"
|
|
|
|
typedef char *(__fastcall *LmpGetPlayerCountryFn)(uint8_t *mis, int32_t pid, char *buf, int32_t buf_size);
|
|
typedef void (__fastcall *LmpSetPlayerGuiStateFn)(int32_t player_id, int32_t state);
|
|
typedef void (__fastcall *LmpAircraftChangeResultFn)(void *econ_state, int32_t err_code);
|
|
typedef void *(__fastcall *LmpGetUnitByEidFn)(uint32_t eid);
|
|
typedef void (__fastcall *LmpSetOwningMPlayerFn)(void *unit, void *mplayer, uint8_t f1, uint8_t set_pid);
|
|
typedef const char *(__fastcall *LmpDataBlockGetStrFn)(const void *blk, const char *name, const char *def);
|
|
|
|
/* One combat event of the local player, as facts only (see local_mp_awards.c). */
|
|
typedef struct LocalMpAwardEvent {
|
|
uint32_t exp_event; /* EXP_EVENT_* code (globalScripts/expEventConsts.nut) */
|
|
const uint8_t *victim; /* destroyed or damaged unit; NULL for a zone capture */
|
|
int victim_is_player; /* victim belongs to an MPlayer (player or bound bot) */
|
|
int friendly; /* victim was on the local player's team */
|
|
const char *modifier; /* stock messageModifier, e.g. "from_severe_damage", or NULL */
|
|
int32_t damage; /* naval award damage for EXP_EVENT_UNIT_DAMAGE, else 0 */
|
|
} LocalMpAwardEvent;
|
|
|
|
extern uint8_t **g_local_mp_multiplayer;
|
|
extern uint8_t **g_local_mp_app;
|
|
extern uint8_t **g_local_mp_mplayer;
|
|
extern uint8_t **g_local_mp_hero;
|
|
extern uint8_t *g_local_mp_mission_settings;
|
|
extern void ***g_local_mp_stdmem;
|
|
extern uint8_t ***g_local_mp_player_table;
|
|
extern uint32_t *g_local_mp_player_count;
|
|
|
|
extern LmpGetPlayerCountryFn g_lmp_get_player_country;
|
|
extern LmpSetPlayerGuiStateFn g_lmp_set_player_gui_state;
|
|
extern LmpAircraftChangeResultFn g_lmp_aircraft_change_result;
|
|
extern LmpGetUnitByEidFn g_lmp_get_unit_by_eid;
|
|
extern LmpSetOwningMPlayerFn g_lmp_set_owning_mplayer;
|
|
extern LmpDataBlockGetStrFn g_lmp_datablock_get_str;
|
|
|
|
uint8_t *local_mp_scan_unique(const uint8_t *base, size_t size, const char *name, const char *spec);
|
|
void *local_mp_resolve_rip(const uint8_t *insn, size_t disp_off, size_t insn_len);
|
|
int local_mp_is_host(void);
|
|
int local_mp_is_local_mplayer(const uint8_t *mp);
|
|
uint8_t *local_mp_econ_state(void);
|
|
uint8_t *local_mp_find_mplayer(int64_t user_id, uint8_t pid);
|
|
void *local_mp_mem_alloc(size_t size);
|
|
void local_mp_mem_free(void *ptr);
|
|
char *local_mp_strdup(const char *s);
|
|
const char *local_mp_unit_name(const uint8_t *unit);
|
|
|
|
/* Player state & slot tracking notifications shared with loadout module. */
|
|
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int is_silent);
|
|
|
|
/* Combat event reporting to the GUI scripts (local_mp_awards.c). */
|
|
void local_mp_report_award_event(const LocalMpAwardEvent *ev);
|
|
const char *local_mp_unit_exp_class(const uint8_t *unit);
|
|
|
|
/* Mission scores of combat events from the mission settings (local_mp_scores.c). */
|
|
float local_mp_score_param(const char *key);
|
|
float local_mp_event_score(const char *event, const uint8_t *unit, int victim_is_player);
|
|
|
|
/* Assist deduplication lifecycle shared between kill and event hooks. */
|
|
void local_mp_events_reset(void);
|
|
void local_mp_events_begin_death(const uint8_t *victim);
|
|
|
|
/* Shared MPlayer scoreboard helpers exposed by local_mp_kills.c. */
|
|
void local_mp_add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id);
|
|
void local_mp_mark_mplayer_dirty(uint8_t *mp);
|
|
void local_mp_inc_mplayer_stat(uint8_t *mp, size_t off);
|
|
|
|
/* Subsystem hook installers invoked once from install_local_mp_hooks(). */
|
|
int install_local_mp_player_hooks(const uint8_t *text, size_t text_size, uint8_t *p_do_respawn);
|
|
int install_local_mp_loadout_hooks(const uint8_t *text, size_t text_size);
|
|
int install_local_mp_action_hooks(const uint8_t *text, size_t text_size);
|
|
int install_local_mp_award_hooks(const uint8_t *text, size_t text_size, uint8_t *p_ground_dead);
|
|
int install_local_mp_kill_hooks(const uint8_t *text, size_t text_size, uint8_t *p_ground_dead);
|
|
int install_local_mp_event_hooks(const uint8_t *text, size_t text_size);
|
|
int install_local_mp_score_reader(const uint8_t *text, size_t text_size);
|