mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-05-01 18:13:57 +00:00
* Add multiplayer extension * Fix animation system to work when host is outside ISLE world - Move TickHostSessions outside m_inIsleWorld gate so the host can coordinate animations from any world - Load animation catalog early in HandleCreate so the host can coordinate before entering the ISLE world - Use network-reported positions for remote player location detection instead of requiring spawned ROIs - Always erase sessions at launch — the host's job ends when the animation starts; clients play and complete independently - Replace BroadcastAnimComplete with locally-driven completion callbacks: host generates eventId at launch, clients cache completion JSON at start time, fire it when ScenePlayer finishes - Make StopAnimation only do local cleanup (stop playback, cancel own interest, reset coordinator) without destroying the session host, so other players' sessions survive world transitions - Broadcast state=0 in ResetAnimationState for full teardown paths (shutdown, reconnect, host migration) so clients aren't left with stale session state * Fix use-after-free crash in ScenePlayer when remote player disconnects mid-animation When a remote player's ROI is destroyed (disconnect, timeout, or respawn), notify all active ScenePlayer instances to null out dangling references before the ROI is freed. The animation engine already handles null ROI map entries gracefully, so playback continues for remaining participants. * Fix crash when performer's child ROIs are left dangling in ScenePlayer NotifyROIDestroyed now walks the parent chain to also invalidate child ROIs of the destroyed performer (head, limbs, etc.) that were placed into the roiMap by BuildROIMap. The ancestor walk happens once; all other fields are cleaned with simple pointer equality. * Allow spectator to play click animation during scene playback * Make PTATCAM track spectator ROI instead of camera in ScenePlayer * Only regenerate emscripten version files when git state changes Replace add_custom_target(ALL) with add_custom_command(OUTPUT) so the version script only runs when .git/HEAD or the current branch ref file changes, instead of on every build. * Fix ROI name collision causing dangling pointers in NPC locomotion roiMaps When ScenePlayer created cloned NPC ROIs for cooperative animations, it renamed them to match the original character name and added them to the ViewManager. This created a name collision: two ROIs with the same name. The original game's AppendROIToScene searches by name and stops at the first match, so if a locomotion BuildROIMap ran while the clone existed, it could capture pointers to the clone's child ROIs. When the clone was later destroyed (CleanupProps), those roiMap entries became dangling pointers, crashing in AnimateWithTransform at roi.h:151 (SetVisibility). Fix: use the alias mechanism (already supported by AnimUtils::BuildROIMap) instead of renaming clones. Also unify all ROI name generation behind a shared counter to prevent character manager key collisions.
118 lines
3.4 KiB
C++
118 lines
3.4 KiB
C++
#ifndef LEGOBUILDINGMANAGER_H
|
|
#define LEGOBUILDINGMANAGER_H
|
|
|
|
#include "decomp.h"
|
|
#include "extensions/fwd.h"
|
|
#include "lego1_export.h"
|
|
#include "misc/legotypes.h"
|
|
#include "mxcore.h"
|
|
|
|
class LegoEntity;
|
|
class LegoROI;
|
|
class LegoStorage;
|
|
class LegoWorld;
|
|
class LegoCacheSound;
|
|
class LegoPathBoundary;
|
|
|
|
// SIZE 0x2c
|
|
struct LegoBuildingInfo {
|
|
enum {
|
|
c_hasVariants = 0x01,
|
|
c_hasSounds = 0x02,
|
|
c_hasMoves = 0x04,
|
|
c_hasMoods = 0x08
|
|
};
|
|
|
|
LegoEntity* m_entity; // 0x00
|
|
const char* m_variant; // 0x04
|
|
MxU32 m_sound; // 0x08
|
|
MxU32 m_move; // 0x0c
|
|
MxU8 m_mood; // 0x10
|
|
MxS8 m_counter; // 0x11
|
|
MxS8 m_initialCounter; // 0x12 - initial value loaded to m_counter
|
|
MxU8 m_flags; // 0x13
|
|
float m_adjustedY; // 0x14
|
|
const char* m_boundaryName; // 0x18
|
|
float m_x; // 0x1c
|
|
float m_y; // 0x20
|
|
float m_z; // 0x24
|
|
LegoPathBoundary* m_boundary; // 0x28
|
|
};
|
|
|
|
// VTABLE: LEGO1 0x100d6f50
|
|
// SIZE 0x30
|
|
class LegoBuildingManager : public MxCore {
|
|
public:
|
|
// SIZE 0x14
|
|
struct AnimEntry {
|
|
LegoEntity* m_entity; // 0x00
|
|
LegoROI* m_roi; // 0x04
|
|
MxLong m_time; // 0x08
|
|
float m_y; // 0x0c
|
|
MxBool m_muted; // 0x10
|
|
};
|
|
|
|
LegoBuildingManager();
|
|
~LegoBuildingManager() override;
|
|
|
|
MxResult Tickle() override; // vtable+0x08
|
|
|
|
// FUNCTION: LEGO1 0x1002f930
|
|
const char* ClassName() const override // vtable+0x0c
|
|
{
|
|
// While this class exists in BETA10, it didn't have a ClassName().
|
|
// The constructor suggests that it did not inherit from MxCore back then and did not have a VTABLE.
|
|
// STRING: LEGO1 0x100f37d0
|
|
return "LegoBuildingManager";
|
|
}
|
|
|
|
LEGO1_EXPORT static void configureLegoBuildingManager(MxS32);
|
|
static void SetCustomizeAnimFile(const char* p_value);
|
|
|
|
void Init();
|
|
void LoadWorldInfo();
|
|
void CreateBuilding(MxS32 p_index, LegoWorld* p_world);
|
|
void Reset();
|
|
MxResult Write(LegoStorage* p_storage);
|
|
MxResult Read(LegoStorage* p_storage);
|
|
LegoBuildingInfo* GetInfo(LegoEntity* p_entity);
|
|
MxBool SwitchVariant(LegoEntity* p_entity);
|
|
MxBool SwitchSound(LegoEntity* p_entity);
|
|
MxBool SwitchMove(LegoEntity* p_entity);
|
|
MxBool SwitchMood(LegoEntity* p_entity);
|
|
MxU32 GetAnimationId(LegoEntity* p_entity);
|
|
MxU32 GetSoundId(LegoEntity* p_entity, MxBool p_basedOnMood);
|
|
MxBool DecrementCounter(LegoEntity* p_entity);
|
|
MxBool DecrementCounter(MxS32 p_index);
|
|
MxBool DecrementCounter(LegoBuildingInfo* p_data);
|
|
void ScheduleAnimation(LegoEntity* p_entity, MxLong p_length, MxBool p_haveSound, MxBool p_hideAfterAnimation);
|
|
void ClearCounters();
|
|
void AdjustHeight(MxS32 p_index);
|
|
MxResult DetermineBoundaries();
|
|
LegoBuildingInfo* GetInfoArray(MxS32& p_length);
|
|
void AdjustCounter(LegoEntity* p_entity, MxS32 p_adjust);
|
|
void SetInitialCounters();
|
|
|
|
static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; }
|
|
|
|
// SYNTHETIC: LEGO1 0x1002f940
|
|
// LegoBuildingManager::`scalar deleting destructor'
|
|
|
|
private:
|
|
friend class Multiplayer::WorldStateSync;
|
|
|
|
static char* g_customizeAnimFile;
|
|
static MxS32 g_maxMove[16];
|
|
static MxU32 g_maxSound;
|
|
|
|
MxU8 m_nextVariant; // 0x08
|
|
MxBool m_boundariesDetermined; // 0x09
|
|
AnimEntry* m_entries[5]; // 0x0c
|
|
MxS8 m_numEntries; // 0x20
|
|
LegoCacheSound* m_sound; // 0x24
|
|
MxBool m_hideAfterAnimation; // 0x28
|
|
LegoWorld* m_world; // 0x2c
|
|
};
|
|
|
|
#endif // LEGOBUILDINGMANAGER_H
|