Files
WT-Offline/native/wto-net/src/local_mp_internal.h
T
N0VAN0M4LYandduduyagame 3282320fb7 fix(battle): show and debit confirmed backup vehicles
Use the signed i64 profile encoding identified in PR #13. Make attached backups selectable in LocalMP after the daily quota, and debit backups only after the engine confirms the selected slot entered play.

Record the stock daily allowance once per room and slot. Settle owned backups using the confirmed spawn facts and keep repeat settlement from charging the same battle again.

Verified server and launcher types, MSVC compilation, three client builds for patch and Quirrel checks, and a temporary 2.61.0.58 build. In-game acceptance is pending.

Co-authored-by: duduyagame <[email protected]>
2026-12-04 06:24:34 +08:00

115 lines
5.4 KiB
C

/*
* Shared internal state, resolved engine pointers, and subsystem interfaces
* for the LocalMP in-process host bridge.
*
* Addresses and structure offsets come from the build (local_mp_values.h); 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"
/* HUD script event raised when the local player's instant-win bomb explodes (local_mp_nuke.c). */
#define LMP_NUCLEAR_STRIKE_EVENT_NAME "wtoLocalMpNuclearStrike"
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 zone events */
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 damage points or bombing zone health in basis points */
} 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;
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, int32_t base_id, const char *backup, int is_silent);
/* Local player events sent to the GUI scripts (local_mp_awards.c). */
void local_mp_report_award_event(const LocalMpAwardEvent *ev);
void local_mp_report_nuclear_strike(void);
void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id);
void local_mp_report_backup_spawn(const char *unit_name, int32_t slot_id, const char *backup);
/* A destroyed unit that is some player's mission support unit: its reference is freed once the
* player has been given back control (local_mp_support.c). */
void local_mp_support_unit_dead(const uint8_t *victim);
void local_mp_credit_air_event_kill(uint8_t *player, int aircraft_victim);
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_add_personal_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);
/* Hook descriptor queued by a LocalMP module and enabled in a single batch by local_mp_core.c. */
typedef struct LocalMpHookSpec {
const char *name;
void *target;
void *detour;
void **original;
} LocalMpHookSpec;
int local_mp_queue_hooks(const char *module, const LocalMpHookSpec *specs, size_t count);
/* Module hook installers, called by install_local_mp_hooks() once the module's values are loaded. */
int install_local_mp_player_hooks(void);
int install_local_mp_loadout_hooks(void);
int install_local_mp_action_hooks(void);
int install_local_mp_award_hooks(void);
int install_local_mp_kill_hooks(void);
int install_local_mp_event_hooks(void);
int install_local_mp_score_reader(void);
int install_local_mp_nuke_hooks(void);
int install_local_mp_support_hooks(void);
int install_local_mp_damage_notification_hooks(void);
int install_local_mp_zone_hooks(void);
void local_mp_zones_reset(void);
int install_local_mp_air_event_hooks(void);
int install_local_mp_ground_ai_hooks(void);
void local_mp_ground_ai_update(float dt);