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]>
This commit is contained in:
1 parent
6d0abf9caf
commit
3282320fb7
34 files changed
+402
-46
No files matched your search
@@ -110,6 +110,22 @@ void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id)
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
void local_mp_report_backup_spawn(const char *unit_name, int32_t slot_id, const char *backup)
|
||||
{
|
||||
__declspec(align(16)) uint8_t blk[LMP_BLK_SIZE];
|
||||
uint8_t *gsd = g_game_save_data ? *g_game_save_data : NULL;
|
||||
|
||||
if (gsd == NULL || fn_hud_notify_script == NULL || unit_name == NULL)
|
||||
return;
|
||||
memset(blk, 0, sizeof(blk));
|
||||
fn_blk_ctor(blk);
|
||||
fn_blk_set_str(blk, "unit", unit_name);
|
||||
fn_blk_set_str(blk, "backup", backup);
|
||||
blk_set_int(blk, "slot", slot_id);
|
||||
fn_hud_notify_script(gsd + LMP_GSD_OFF_HUD_QUEUE, "wtoLocalMpBackupSpawn", blk);
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
int install_local_mp_award_hooks(void)
|
||||
{
|
||||
g_game_save_data = (uint8_t **)g_lmp.game_save_data;
|
||||
|
||||
@@ -58,12 +58,13 @@ 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, int is_silent);
|
||||
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). */
|
||||
|
||||
@@ -287,7 +287,9 @@ static void __fastcall hook_sem_change_aircraft_send(
|
||||
mplayer[LMP_MP_OFF_GUI_STATE] != LMP_GUI_STATE_CA_READY)
|
||||
g_lmp_set_player_gui_state((int32_t)mplayer[LMP_MP_OFF_PID], LMP_GUI_STATE_CA_READY);
|
||||
|
||||
local_mp_players_queue_spawn(req_slot_id, req_spare_type, req_base_id, is_silent);
|
||||
const char *backup = !is_silent && modifications_blk != NULL
|
||||
? g_lmp_datablock_get_str(modifications_blk, "wtoBackup", "") : NULL;
|
||||
local_mp_players_queue_spawn(req_slot_id, req_spare_type, req_base_id, backup, is_silent);
|
||||
log_line("local_mp: configured unit='%s' weapon='%s' slot=%d silent=%d",
|
||||
unit_name ? unit_name : "", weapon_name ? weapon_name : "", (int)req_slot_id, is_silent);
|
||||
}
|
||||
|
||||
@@ -26,13 +26,30 @@ static int g_respawn_dispatched = 0;
|
||||
static int32_t g_pending_slot_id = -1;
|
||||
static int32_t g_pending_spare_type = -1;
|
||||
static int32_t g_pending_base_id = -1;
|
||||
/* Holds the source token or a classic inventory UID (item_%016llx_%x). */
|
||||
static char g_pending_backup[64];
|
||||
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t base_id, int is_silent)
|
||||
static void clear_pending_spawn(void)
|
||||
{
|
||||
g_respawn_dispatched = 0;
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_spare_type = -1;
|
||||
g_pending_base_id = -1;
|
||||
g_pending_backup[0] = '\0';
|
||||
}
|
||||
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t base_id, const char *backup, int is_silent)
|
||||
{
|
||||
if (!is_silent || g_pending_slot_id < 0) {
|
||||
size_t length = backup ? strlen(backup) : 0;
|
||||
g_pending_slot_id = slot_id;
|
||||
g_pending_spare_type = spare_type;
|
||||
g_pending_base_id = base_id;
|
||||
g_pending_backup[0] = '\0';
|
||||
if (length > 0 && length < sizeof(g_pending_backup))
|
||||
memcpy(g_pending_backup, backup, length + 1);
|
||||
} else if (slot_id != g_pending_slot_id) {
|
||||
g_pending_backup[0] = '\0';
|
||||
}
|
||||
if (!is_silent)
|
||||
g_respawn_dispatched = 0;
|
||||
@@ -112,6 +129,8 @@ static void __fastcall hook_mplayer_init_from_matching(uint8_t *mplayer, uint8_t
|
||||
*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID) = 1;
|
||||
local_mp_events_reset();
|
||||
local_mp_zones_reset();
|
||||
g_accept_pending = 0;
|
||||
clear_pending_spawn();
|
||||
log_line("local_mp: initialized local player team=%d squad=%d",
|
||||
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_TEAM)),
|
||||
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID)));
|
||||
@@ -136,20 +155,22 @@ static void finish_pending_spawn(uint8_t *mplayer)
|
||||
if (!g_respawn_dispatched || mplayer == NULL)
|
||||
return;
|
||||
if (mplayer[LMP_MP_OFF_GUI_STATE] == LMP_GUI_STATE_CA_SELECT) {
|
||||
g_respawn_dispatched = 0;
|
||||
clear_pending_spawn();
|
||||
return;
|
||||
}
|
||||
if (mplayer[LMP_MP_OFF_GUI_STATE] != LMP_GUI_STATE_PILOT_CONTROL)
|
||||
return;
|
||||
|
||||
g_respawn_dispatched = 0;
|
||||
hero_name = g_local_mp_hero ? local_mp_unit_name(*g_local_mp_hero) : NULL;
|
||||
|
||||
if (g_pending_slot_id >= 0 && g_pending_slot_id < 32) {
|
||||
uint32_t bit = 1u << (uint32_t)g_pending_slot_id;
|
||||
if (has_unlimited_respawns())
|
||||
local_mp_report_airfield_spawn(hero_name, g_pending_base_id);
|
||||
else if (g_pending_spare_type < 0)
|
||||
else if (g_pending_backup[0] != '\0') {
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK) |= bit;
|
||||
local_mp_report_backup_spawn(hero_name, g_pending_slot_id, g_pending_backup);
|
||||
} else if (g_pending_spare_type < 0)
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK) |= bit;
|
||||
else
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK) |= bit;
|
||||
@@ -157,9 +178,8 @@ static void finish_pending_spawn(uint8_t *mplayer)
|
||||
hero_name ? hero_name : "", (int)g_pending_slot_id, (int)g_pending_spare_type,
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK),
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK));
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_base_id = -1;
|
||||
}
|
||||
clear_pending_spawn();
|
||||
}
|
||||
|
||||
static void __fastcall hook_gui_state_update(uint8_t *gui_state_obj, float dt)
|
||||
@@ -171,9 +191,7 @@ static void __fastcall hook_gui_state_update(uint8_t *gui_state_obj, float dt)
|
||||
|
||||
if (!local_mp_is_host()) {
|
||||
g_accept_pending = 0;
|
||||
g_respawn_dispatched = 0;
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_base_id = -1;
|
||||
clear_pending_spawn();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,6 +224,8 @@ static int64_t __fastcall hook_do_respawn_player(void *app)
|
||||
g_respawn_dispatched = 1;
|
||||
|
||||
result = orig_do_respawn(app);
|
||||
if (!result)
|
||||
g_respawn_dispatched = 0;
|
||||
finish_pending_spawn(mplayer);
|
||||
bind_ai_mplayer_units();
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user