mirror of https://github.com/AxioDL/metaforce.git
Fix gbalink compiling on linux, finish CScriptDock
This commit is contained in:
parent
9109151bf9
commit
a2c9271ee1
|
@ -311,6 +311,7 @@ public:
|
|||
void SetAreaAttributes(const CScriptAreaAttributes* areaAttributes);
|
||||
bool GetActive() const { return xf0_25_active; }
|
||||
void SetActive(bool active) { xf0_25_active = active; }
|
||||
CObjectList& GetAreaObjects() const { return *GetPostConstructed()->x10c0_areaObjs.get(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@ CMaterialList MakeDockMaterialList()
|
|||
|
||||
CScriptDock::CScriptDock(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
||||
const zeus::CVector3f position, const zeus::CVector3f& extents, s32 dock, TAreaId area,
|
||||
bool active, s32 w1, bool loadConnected)
|
||||
bool active, s32 dockReferenceCount, bool loadConnected)
|
||||
: CPhysicsActor(uid, active, name, info, zeus::CTransform(zeus::CMatrix3f::skIdentityMatrix3f, position),
|
||||
CModelData::CModelDataNull(), MakeDockMaterialList(), zeus::CAABox(-extents * 0.5f, extents * 0.5f),
|
||||
SMoverData(1.f), CActorParameters::None(), 0.3f, 0.1f)
|
||||
, x258_dockReferenceCount(w1)
|
||||
, x258_dockReferenceCount(dockReferenceCount)
|
||||
, x25c_dock(dock)
|
||||
, x260_area(area)
|
||||
, x268_25_loadConnected(loadConnected)
|
||||
|
@ -39,11 +39,43 @@ void CScriptDock::Think(float dt, CStateManager& mgr)
|
|||
x268_24_dockReferenced = false;
|
||||
}
|
||||
|
||||
CGameArea* area = mgr.WorldNC()->GetArea(x260_area);
|
||||
if (x268_26_areaPostConstructed != area->IsPostConstructed())
|
||||
if (x268_26_areaPostConstructed != mgr.WorldNC()->GetArea(x260_area)->IsPostConstructed())
|
||||
{
|
||||
if (area->IsPostConstructed())
|
||||
if (mgr.WorldNC()->GetArea(x260_area)->IsPostConstructed())
|
||||
CEntity::SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
||||
else
|
||||
CEntity::SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||
}
|
||||
|
||||
if (mgr.GetNextAreaId() != x260_area)
|
||||
x264_dockState = EDockState::Three;
|
||||
else if (x264_dockState == EDockState::Three)
|
||||
x264_dockState = EDockState::Idle;
|
||||
else if (x264_dockState == EDockState::PlayerTouched)
|
||||
x264_dockState = EDockState::EnterNextArea;
|
||||
else if (x264_dockState == EDockState::EnterNextArea)
|
||||
{
|
||||
CPlayer& player = mgr.GetPlayer();
|
||||
if (HasPointCrossedDock(mgr, player.GetTransform().origin))
|
||||
{
|
||||
IGameArea::Dock* dock = mgr.WorldNC()->GetArea(mgr.GetNextAreaId())->DockNC(x25c_dock);
|
||||
TAreaId aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
||||
if (aid != kInvalidAreaId && mgr.WorldNC()->GetArea(aid)->GetActive())
|
||||
{
|
||||
mgr.SetCurrentAreaId(aid);
|
||||
s32 otherDock = dock->GetOtherDockNumber(dock->GetReferenceCount());
|
||||
|
||||
CObjectList& objs = mgr.WorldNC()->GetArea(aid)->GetAreaObjects();
|
||||
for (CEntity* ent : objs)
|
||||
{
|
||||
CScriptDock* dock = static_cast<CScriptDock*>(ent);
|
||||
if (dock && dock->GetDockId() == otherDock)
|
||||
dock->SetLoadConnected(mgr, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x264_dockState = EDockState::Idle;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +145,8 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
|
|||
IGameArea::Dock* dock = mgr.WorldNC()->GetArea(x260_area)->DockNC(x25c_dock);
|
||||
aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aid == 0 || mgr.GetWorld()->GetNumAreas() <= aid)
|
||||
else if (aid == 0 || (mgr.GetWorld()->GetNumAreas() <= aid || !mgr.WorldNC()->GetArea(aid)->GetActive()))
|
||||
return;
|
||||
|
||||
if (!mgr.WorldNC()->GetArea(aid)->GetActive())
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
/* Propogate through area chain */
|
||||
sub800C40DC((msg == EScriptObjectMessage::Increment), mgr.GetWorld()->GetAreaAlways(aid), mgr.WorldNC());
|
||||
|
@ -166,7 +192,6 @@ void CScriptDock::SetDockReference(CStateManager& mgr, s32 ref)
|
|||
s32 CScriptDock::GetDockReference(CStateManager& mgr) const
|
||||
{
|
||||
return mgr.GetWorld()->GetAreaAlways(x260_area)->GetDock(x25c_dock)->GetReferenceCount();
|
||||
|
||||
}
|
||||
|
||||
TAreaId CScriptDock::GetCurrentConnectedAreaId(const CStateManager& mgr) const
|
||||
|
@ -204,11 +229,15 @@ void CScriptDock::UpdateAreaActivateFlags(CStateManager& mgr)
|
|||
mgr.SetCurrentAreaId(mgr.GetNextAreaId());
|
||||
}
|
||||
|
||||
void CScriptDock::AreaLoaded(CStateManager& mgr)
|
||||
bool CScriptDock::HasPointCrossedDock(const CStateManager& mgr, const zeus::CVector3f& point) const
|
||||
{
|
||||
SetLoadConnected(mgr, x268_25_loadConnected);
|
||||
const zeus::CPlane plane = GetPlane(mgr);
|
||||
|
||||
return (plane.vec.dot(point) >= plane.d);
|
||||
}
|
||||
|
||||
void CScriptDock::AreaLoaded(CStateManager& mgr) { SetLoadConnected(mgr, x268_25_loadConnected); }
|
||||
|
||||
void CScriptDock::SetLoadConnected(CStateManager& mgr, bool loadOther)
|
||||
{
|
||||
IGameArea::Dock* dock = mgr.WorldNC()->GetArea(x260_area)->DockNC(x25c_dock);
|
||||
|
|
|
@ -10,9 +10,9 @@ class CScriptDock : public CPhysicsActor
|
|||
{
|
||||
enum EDockState
|
||||
{
|
||||
Zero,
|
||||
Idle,
|
||||
PlayerTouched,
|
||||
Two,
|
||||
EnterNextArea,
|
||||
Three
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <string>
|
||||
#include "hecl/hecl.hpp"
|
||||
#if __APPLE__
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
|
||||
namespace net
|
||||
{
|
||||
|
@ -309,12 +311,21 @@ static u64 LastGCTick = 0;
|
|||
static u64 TimeCmdSent = 0;
|
||||
static bool Booted = false;
|
||||
|
||||
static u64 MachToDolphinNum;
|
||||
static u64 MachToDolphinDenom;
|
||||
static u64 SysToDolphinNum;
|
||||
static u64 SysToDolphinDenom;
|
||||
|
||||
static u64 GetGCTicks()
|
||||
{
|
||||
return mach_absolute_time() * MachToDolphinNum / MachToDolphinDenom;
|
||||
#if __APPLE__
|
||||
return mach_absolute_time() * SysToDolphinNum / SysToDolphinDenom;
|
||||
#elif __linux__
|
||||
struct timespec tp;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
|
||||
return u64((tp.tv_sec * 1000000000ull) + tp.tv_nsec) * SysToDolphinNum / SysToDolphinDenom;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void WaitGCTicks(u64 ticks)
|
||||
|
@ -1303,11 +1314,15 @@ void CGBASupport::StartLink()
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#if __APPLE__
|
||||
mach_timebase_info_data_t timebase;
|
||||
mach_timebase_info(&timebase);
|
||||
MachToDolphinNum = 486000000ull * timebase.numer;
|
||||
MachToDolphinDenom = 1000000000ull * timebase.denom;
|
||||
|
||||
SysToDolphinNum = 486000000ull * timebase.numer;
|
||||
SysToDolphinDenom = 1000000000ull * timebase.denom;
|
||||
#elif __linux__
|
||||
SysToDolphinNum = 486000000ull;
|
||||
SysToDolphinDenom = 1000000000ull;
|
||||
#endif
|
||||
CGBASupport gba("client_pad.bin");
|
||||
gba.Update(0.f);
|
||||
gba.InitializeSupport();
|
||||
|
|
Loading…
Reference in New Issue