Fix doors and various area streaming bugs

This commit is contained in:
Phillip Stephens 2018-05-01 17:43:31 -07:00
parent 711c3e0d2c
commit 734b25cad3
35 changed files with 189 additions and 284 deletions

3
.gitmodules vendored
View File

@ -37,3 +37,6 @@
[submodule "NESEmulator/fixNES"]
path = NESEmulator/fixNES
url = https://github.com/jackoalan/fixNES.git
[submodule "Editor/locale"]
path = Editor/locale
url = ssh://gitlab@git.axiodl.com/AxioDL/urde-translations.git

1
Editor/locale Submodule

@ -0,0 +1 @@
Subproject commit b2436bbd0331d15df34b68345770d295513cbd9d

View File

@ -1,8 +0,0 @@
bintoc(en_US.cpp en_US.yaml L_en_US)
bintoc(en_GB.cpp en_GB.yaml L_en_GB)
bintoc(ja_JP.cpp ja_JP.yaml L_ja_JP)
add_library(UrdeLocales
en_US.yaml en_US.cpp
en_GB.yaml en_GB.cpp
ja_JP.yaml ja_JP.cpp
locale.hpp locale.cpp)

View File

@ -1,18 +0,0 @@
en_GB:
color: "Colour"
branch: "Branch"
commit: "Commit"
date: "Date"
new_project: "New Project"
open_project: "Open Project"
extract_game: "Extract Game"
name: "Name"
type: "Type"
size: "Size"
directory: "Directory"
file: "File"
file_name: "File Name"
cancel: "Cancel"
system_locations: "System Locations"
recent_projects: "Recent Projects"
recent_files: "Recent Files"

View File

@ -1,18 +0,0 @@
en_US:
color: "Color"
branch: "Branch"
commit: "Commit"
date: "Date"
new_project: "New Project"
open_project: "Open Project"
extract_game: "Extract Game"
name: "Name"
type: "Type"
size: "Size"
directory: "Directory"
file: "File"
file_name: "File Name"
cancel: "Cancel"
system_locations: "System Locations"
recent_projects: "Recent Projects"
recent_files: "Recent Files"

View File

@ -1,18 +0,0 @@
ja_JP:
color: "色"
branch: "分派"
commit: "預ける"
date: "年月日"
new_project: "新しいプロジェクト"
open_project: "プロジェクトを開きます"
extract_game: "ビデオゲームを抽出"
name: "名"
type: "タイプ"
size: "サイズ"
directory: "ディレクトリ"
file: "ファイル"
file_name: "ファイル名"
cancel: "キャンセル"
system_locations: "システムの場所"
recent_projects: "最近使ったプロジェクト"
recent_files: "最近使用したファイル"

View File

@ -1,69 +0,0 @@
#include "locale.hpp"
#include <cstring>
#include <clocale>
#include <algorithm>
#undef min
#undef max
extern "C" const uint8_t L_en_US[];
extern "C" size_t L_en_US_SZ;
extern "C" const uint8_t L_en_GB[];
extern "C" size_t L_en_GB_SZ;
extern "C" const uint8_t L_ja_JP[];
extern "C" size_t L_ja_JP_SZ;
namespace urde
{
using namespace std::literals;
static const specter::Locale Locales[] =
{
{"en_US"sv, "US English"sv, L_en_US, L_en_US_SZ},
{"en_GB"sv, "British English"sv, L_en_GB, L_en_GB_SZ},
{"ja_JP"sv, "Japanese"sv, L_ja_JP, L_ja_JP_SZ}
};
std::vector<std::pair<std::string_view, std::string_view>> ListLocales()
{
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
std::vector<std::pair<std::string_view, std::string_view>> ret;
ret.reserve(localeCount);
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
ret.emplace_back(l.name(), l.fullName());
}
return ret;
}
const specter::Locale* LookupLocale(std::string_view name)
{
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
if (!name.compare(l.name()))
return &l;
}
return nullptr;
}
const specter::Locale* SystemLocaleOrEnglish()
{
const char* sysLocale = std::setlocale(LC_ALL, nullptr);
size_t sysLocaleLen = std::strlen(sysLocale);
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
if (!l.name().compare(0, std::min(l.name().size(), sysLocaleLen), sysLocale))
return &l;
}
return Locales;
}
}

View File

@ -1,15 +0,0 @@
#ifndef URDE_LOCALE_HPP
#define URDE_LOCALE_HPP
#include <specter/Translator.hpp>
namespace urde
{
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
const specter::Locale* LookupLocale(std::string_view name);
const specter::Locale* SystemLocaleOrEnglish();
}
#endif // URDE_LOCALE_HPP

View File

@ -360,7 +360,7 @@ TAreaId CStateManager::GetVisAreaId() const
CMaterialFilter::EFilterType::Include), nullptr);
for (TUniqueId id : nearList)
if (TCastToConstPtr<CScriptDock> dock = GetObjectById(id))
if (dock->GetDestinationAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation))
if (dock->GetAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation))
return dock->GetCurrentConnectedAreaId(*this);
return curArea;

View File

@ -551,7 +551,7 @@ zeus::CVector3f CBallCamera::ConstrainYawAngle(const CPlayer& player, float dist
{
lookDir = player.GetMoveDir();
TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(x3dc_tooCloseActorId);
if ((!door || !door->x2a8_26_useConservativeCameraDistance) &&
if ((!door || !door->x2a8_26_isOpen) &&
(x400_state == EBallCameraState::Boost || x400_state == EBallCameraState::Chase))
lookDir = player.GetLeaveMorphDir();
}
@ -1294,7 +1294,7 @@ void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr)
if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(x3dc_tooCloseActorId))
{
if (!door->x2a8_26_useConservativeCameraDistance)
if (!door->x2a8_26_isOpen)
{
if (x400_state == EBallCameraState::Boost)
{
@ -1454,7 +1454,7 @@ void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr)
finalPos = ClampElevationToWater(finalPos, mgr);
if (ballToCam2.magnitude() < 2.f && x3dc_tooCloseActorId != kInvalidUniqueId && x3e0_tooCloseActorDist < 5.f)
if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(x3dc_tooCloseActorId))
if (!door->x2a8_26_useConservativeCameraDistance)
if (!door->x2a8_26_isOpen)
finalPos = GetTranslation();
float backupZ = finalPos.z;
@ -1770,7 +1770,7 @@ bool CBallCamera::IsBallNearDoor(const zeus::CVector3f& pos, CStateManager& mgr)
{
TCastToConstPtr<CScriptDoor> door =
mgr.GetObjectById(mgr.GetCameraManager()->GetBallCamera()->x3dc_tooCloseActorId);
if (!door || door->x2a8_26_useConservativeCameraDistance)
if (!door || door->x2a8_26_isOpen)
return false;
auto tb = door->GetTouchBounds();
@ -1820,14 +1820,14 @@ bool CBallCamera::ConstrainElevationAndDistance(float& elevation, float& distanc
stretchFac = zeus::clamp(-1.f, std::fabs(x3e0_tooCloseActorDist / (3.f * distance)), 1.f);
if (x3e0_tooCloseActorDist < 3.f * distance)
doorClose = true;
if (door->x2a8_26_useConservativeCameraDistance)
if (door->x2a8_26_isOpen)
newDistance = stretchFac * (distance - x468_conservativeDoorCamDistance) +
x468_conservativeDoorCamDistance;
else
newDistance = stretchFac * (distance - 5.f) + 5.f;
if (x18d_28_obtuseDirection)
newDistance *= 1.f + x308_speedFactor;
baseElevation = door->x2a8_26_useConservativeCameraDistance ? 0.75f : 1.5f;
baseElevation = door->x2a8_26_isOpen ? 0.75f : 1.5f;
springSpeed = 4.f;
}
}

View File

@ -114,13 +114,13 @@ private:
std::shared_ptr<CTransitionManager> x1fc_transMgr;
float x200_speedScale = 1.f;
u32 x204_charIdx;
s32 x204_charIdx;
u16 x208_defaultAnim;
u32 x20c_passedBoolCount = 0;
u32 x210_passedIntCount = 0;
u32 x214_passedParticleCount = 0;
u32 x218_passedSoundCount = 0;
u32 x21c_particleLightIdx = 0;
s32 x21c_particleLightIdx = 0;
union
{
@ -251,7 +251,7 @@ public:
u32 GetPassedParticlePOICount() const { return x214_passedParticleCount; }
u32 GetPassedSoundPOICount() const { return x218_passedSoundCount; }
u32 GetCharacterIndex() const { return x204_charIdx; }
s32 GetCharacterIndex() const { return x204_charIdx; }
};
}

View File

@ -79,7 +79,7 @@ CCharacterInfo::CCharacterInfo(CInputStream& in)
std::vector<CEffectComponent>& comps = x98_effects.back().second;
u32 compCount = in.readUint32Big();
comps.reserve(compCount);
for (u32 j=0 ; j<compCount ; ++i)
for (u32 j=0 ; j<compCount ; ++j)
comps.emplace_back(in);
}
}
@ -95,7 +95,7 @@ CCharacterInfo::CCharacterInfo(CInputStream& in)
u32 aidxCount = in.readUint32Big();
xb0_animIdxs.reserve(aidxCount);
for (u32 i=0 ; i<aidxCount ; ++i)
xb0_animIdxs.push_back(in.readUint32Big());
xb0_animIdxs.push_back(in.readInt32Big());
}
}

View File

@ -39,7 +39,7 @@ private:
CAssetId xa8_cmdlOverlay = 0;
CAssetId xac_cskrOverlay = 0;
std::vector<u32> xb0_animIdxs;
std::vector<s32> xb0_animIdxs;
public:
CCharacterInfo(CInputStream& in);
@ -59,7 +59,7 @@ public:
CAssetId GetIceSkinRulesId() const { return xac_cskrOverlay; }
const CParticleResData& GetParticleResData() const { return x44_partRes; }
u32 GetAnimationIndex(u32 idx) const { return xb0_animIdxs.at(idx); }
s32 GetAnimationIndex(s32 idx) const { return xb0_animIdxs.at(idx); }
const CPASDatabase& GetPASDatabase() const { return x30_pasDatabase; }
};
}

View File

@ -9,7 +9,7 @@ namespace urde
{
CPOINode::CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time,
u32 index, bool c, float weight, u32 e, u32 f)
u32 index, bool c, float weight, s32 e, s32 f)
: x4_(1),
x8_name(name),
x18_type(type),
@ -29,8 +29,8 @@ CPOINode::CPOINode(CInputStream& in)
x24_index(in.readUint32Big()),
x28_(in.readBool()),
x2c_weight(in.readFloatBig()),
x30_charIdx(in.readUint32Big()),
x34_flags(in.readUint32Big())
x30_charIdx(in.readInt32Big()),
x34_flags(in.readInt32Big())
{}
bool CPOINode::operator>(const CPOINode& other) const

View File

@ -30,11 +30,11 @@ protected:
u32 x24_index;
bool x28_;
float x2c_weight;
u32 x30_charIdx = -1;
u32 x34_flags;
s32 x30_charIdx = -1;
s32 x34_flags;
public:
CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time,
u32 index, bool, float weight, u32 charIdx, u32 flags);
u32 index, bool, float weight, s32 charIdx, s32 flags);
CPOINode(CInputStream& in);
virtual ~CPOINode() = default;
@ -44,8 +44,8 @@ public:
EPOIType GetPoiType() const { return x18_type; }
u32 GetIndex() const {return x24_index;}
float GetWeight() const { return x2c_weight; }
u32 GetCharacterIndex() const { return x30_charIdx; }
u32 GetFlags() const { return x34_flags; }
s32 GetCharacterIndex() const { return x30_charIdx; }
s32 GetFlags() const { return x34_flags; }
bool operator>(const CPOINode& other) const;
bool operator<(const CPOINode& other) const;

View File

@ -495,6 +495,8 @@ void CBooModel::DisableAllLights()
void CBooModel::RemapMaterialData(SShader& shader)
{
if (!shader.m_geomLayout)
return;
x4_matSet = &shader.m_matSet;
m_geomLayout = &*shader.m_geomLayout;
m_matSetIdx = shader.m_matSetIdx;
@ -507,6 +509,8 @@ void CBooModel::RemapMaterialData(SShader& shader)
void CBooModel::RemapMaterialData(SShader& shader,
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& pipelines)
{
if (!shader.m_geomLayout)
return;
x4_matSet = &shader.m_matSet;
m_geomLayout = &*shader.m_geomLayout;
m_matSetIdx = shader.m_matSetIdx;

View File

@ -2006,6 +2006,7 @@ CFrontEndUI::CFrontEndUI()
m->ResetGameState();
g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id));
g_GameState->CurrentWorldState().SetAreaId(2);
g_GameState->GameOptions().ResetToDefaults();
g_GameState->WriteBackupBuf();

View File

@ -48,6 +48,7 @@
#include "AutoMapper/CMapWorld.hpp"
#include "AutoMapper/CMapArea.hpp"
#include "AutoMapper/CMapUniverse.hpp"
#include "World/CStateMachine.hpp"
#include "CScannableObjectInfo.hpp"
#include "Audio/CAudioGroupSet.hpp"
#include "Audio/CSfxManager.hpp"
@ -361,6 +362,7 @@ void CGameGlobalObjects::AddPaksAndFactories()
fmgr->AddFactory(FOURCC('DPSC'), FFactoryFunc(FDecalDataFactory));
fmgr->AddFactory(FOURCC('MAPA'), FFactoryFunc(FMapAreaFactory));
fmgr->AddFactory(FOURCC('MAPU'), FFactoryFunc(FMapUniverseFactory));
fmgr->AddFactory(FOURCC('AFSM'), FFactoryFunc(FAiFiniteStateMachineFactory));
}
}

View File

@ -1 +1,19 @@
#include "CParasite.hpp"
#include "World/CActorParameters.hpp"
#include "Character/CModelData.hpp"
#include "World/CPatternedInfo.hpp"
#include "TCastTo.hpp"
namespace urde::MP1
{
CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo)
: CWallWalker(ECharacter::Parasite, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, EColliderType::One, EBodyType::WallWalker, CActorParameters::None(), -1, false)
{
}
void CParasite::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
}

View File

@ -3,12 +3,19 @@
#include "World/CWallWalker.hpp"
namespace urde
{
class CModelData;
}
namespace urde::MP1
{
class CParasite : public CWallWalker
{
public:
CParasite();
CParasite(TUniqueId, std::string_view, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CPatternedInfo&);
void Accept(IVisitor&);
};
}
#endif // __URDE_MP1_CPARASITE_HPP__

View File

@ -450,7 +450,7 @@ CGameArea::CGameArea(CInputStream& in, int idx, int mlvlVersion)
u32 dockCount = in.readUint32Big();
xcc_docks.reserve(dockCount);
for (u32 i=0 ; i<dockCount ; ++i)
xcc_docks.emplace_back(in, xc_transform);
xcc_docks.push_back({in, xc_transform});
ClearTokenList();

View File

@ -374,7 +374,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(); }
CObjectList* GetAreaObjects() const { return GetPostConstructed() ? GetPostConstructed()->x10c0_areaObjs.get() : nullptr; }
CGameArea* GetNext() const { return x130_next; }

View File

@ -23,7 +23,7 @@ CMaterialList MakeDockMaterialList()
CScriptDock::CScriptDock(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CVector3f position, const zeus::CVector3f& extents, s32 dock, TAreaId area,
bool active, s32 dockReferenceCount, bool loadConnected)
: CPhysicsActor(uid, active, name, info, zeus::CTransform(zeus::CMatrix3f::skIdentityMatrix3f, position),
: CPhysicsActor(uid, true/*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(dockReferenceCount)
@ -40,6 +40,7 @@ void CScriptDock::Accept(IVisitor& visitor)
void CScriptDock::Think(float dt, CStateManager& mgr)
{
x30_24_active = true;
if (!GetActive())
{
UpdateAreaActivateFlags(mgr);
@ -96,7 +97,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
case EScriptObjectMessage::Registered:
{
CGameArea* area = mgr.WorldNC()->GetArea(x260_area);
if (area->GetDockCount() <= x25c_dock)
if (area->GetDockCount() < x25c_dock)
return;
IGameArea::Dock* dock = area->DockNC(x25c_dock);
if (!dock->IsReferenced())
@ -147,6 +148,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
break;
case EScriptObjectMessage::Increment:
SetLoadConnected(mgr, true);
[[fallthrough]];
case EScriptObjectMessage::Decrement:
{
TAreaId aid = x260_area;
@ -155,7 +157,7 @@ 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 || !mgr.WorldNC()->GetArea(aid)->GetActive()))
else if (aid == 0 || (aid >= mgr.GetWorld()->GetNumAreas() || !mgr.WorldNC()->GetArea(aid)->GetActive()))
return;
CWorld::PropogateAreaChain(CGameArea::EOcclusionState(msg == EScriptObjectMessage::Increment),
mgr.WorldNC()->GetArea(aid), mgr.WorldNC());
@ -203,10 +205,10 @@ s32 CScriptDock::GetDockReference(const CStateManager& mgr) const
TAreaId CScriptDock::GetCurrentConnectedAreaId(const CStateManager& mgr) const
{
if (mgr.GetWorld()->GetNumAreas() < x260_area)
if (x260_area >= mgr.GetWorld()->GetNumAreas())
return kInvalidAreaId;
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x260_area);
if (area->GetDockCount() < x25c_dock)
if (x25c_dock >= area->GetDockCount())
return kInvalidAreaId;
const IGameArea::Dock* dock = area->GetDock(x25c_dock);

View File

@ -43,7 +43,7 @@ public:
void Touch(CActor&, CStateManager&);
void CleanUp() {}
zeus::CPlane GetPlane(const CStateManager&) const;
TAreaId GetDestinationAreaId() const { return x260_area; }
TAreaId GetAreaId() const { return x260_area; }
s32 GetDockId() const { return x25c_dock; }
void SetDockReference(CStateManager& mgr, s32);
s32 GetDockReference(const CStateManager& mgr) const;

View File

@ -7,7 +7,7 @@ namespace urde
{
CScriptDockAreaChange::CScriptDockAreaChange(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 w1,
bool active)
: CEntity(uid, info, active, name), x34_dockReference(w1)
: CEntity(uid, info, true/*active*/, name), x34_dockReference(w1)
{
}

View File

@ -11,6 +11,7 @@ class CScriptDockAreaChange : public CEntity
public:
CScriptDockAreaChange(TUniqueId, std::string_view, const CEntityInfo&, s32, bool);
void Think(float dt, CStateManager& mgr) { x30_24_active = true; CEntity::Think(dt, mgr); }
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
};

View File

@ -16,7 +16,7 @@ namespace urde
static CMaterialList MakeDoorMaterialList(bool open)
{
CMaterialList ret;
ret.Add(EMaterialTypes::Solid);
//ret.Add(EMaterialTypes::Solid);
ret.Add(EMaterialTypes::Immovable);
ret.Add(EMaterialTypes::Orbit);
if (!open)
@ -27,20 +27,24 @@ static CMaterialList MakeDoorMaterialList(bool open)
CScriptDoor::CScriptDoor(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms,
const zeus::CVector3f&, const zeus::CAABox& aabb, bool active,
bool open, bool b2, float f1, bool ballDoor)
const zeus::CVector3f& vec, const zeus::CAABox& aabb, bool active,
bool open, bool b2, float animLen, bool ballDoor)
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeDoorMaterialList(open),
aabb, SMoverData(1.f), actParms, 0.3f, 0.1f)
{
x258_ = f1;
x2a8_29_ballDoor = ballDoor;
x258_animLen = animLen;
x2a8_24_ = false;
x2a8_25_ = open;
x2a8_26_useConservativeCameraDistance = open;
x2a8_26_isOpen = open;
x2a8_27_ = false;
x2a8_28_ = b2;
x2a8_27_ = true;
x2a8_29_ballDoor = ballDoor;
x2a8_30_ = false;
x264_ = GetBoundingBox();
x284_modelBounds = x64_modelData->GetBounds(xf.getRotation());
x29c_ = vec;
xe6_27_thermalVisorFlags = 1;
if (open)
SetDoorAnimation(EDoorAnimType::Open);
@ -68,17 +72,17 @@ void CScriptDoor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
if (!GetActive())
return;
if (x27c_partner1 == kInvalidUniqueId || uid != x27c_partner1)
if (x27c_partner1 != kInvalidUniqueId && x27c_partner1 != uid)
return;
if (x2a8_26_useConservativeCameraDistance)
if (x2a8_26_isOpen)
{
if (x27e_partner2 != kInvalidUniqueId)
{
if (CEntity* ent = mgr.ObjectById(x27e_partner2))
mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Close);
}
x2a8_26_useConservativeCameraDistance = false;
x2a8_26_isOpen = false;
SetDoorAnimation(EDoorAnimType::Close);
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId());
}
@ -95,13 +99,13 @@ void CScriptDoor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
{
if (TCastToPtr<CScriptDoor> door = mgr.ObjectById(x27c_partner1))
{
if (x2a8_26_useConservativeCameraDistance)
if (x2a8_26_isOpen)
return;
x2a8_30_ = true;
mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close);
}
}
else if (x2a8_26_useConservativeCameraDistance)
else if (x2a8_26_isOpen)
{
x2a8_30_ = true;
if (TCastToPtr<CScriptDoor> door = mgr.ObjectById(x27e_partner2))
@ -109,7 +113,7 @@ void CScriptDoor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close);
x2a8_30_ = true;
}
x2a8_26_useConservativeCameraDistance = false;
x2a8_26_isOpen = false;
SetDoorAnimation(EDoorAnimType::Close);
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId());
}
@ -117,7 +121,7 @@ void CScriptDoor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
}
case EScriptObjectMessage::Open:
{
if (!GetActive() || x2a8_26_useConservativeCameraDistance)
if (!GetActive() || x2a8_26_isOpen)
return;
u32 doorCond = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid)) ? 2 : GetDoorOpenCondition(mgr);
@ -172,11 +176,8 @@ void CScriptDoor::Think(float dt, CStateManager& mgr)
if (!GetActive())
return;
if (!x2a8_26_useConservativeCameraDistance)
{
if (x25c_ < 0.5f)
x25c_ += dt;
}
if (!x2a8_26_isOpen && x25c_animTime < 0.5f)
x25c_animTime += dt;
if (x2a8_27_ && GetDoorOpenCondition(mgr) == 2)
{
@ -191,33 +192,42 @@ void CScriptDoor::Think(float dt, CStateManager& mgr)
x2a8_28_ = false;
x2a8_24_ = false;
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::Decrement);
x25c_animTime = 0.f;
x2a8_30_ = false;
x25c_ = 0.f;
}
if (x2a8_26_useConservativeCameraDistance && x64_modelData->IsAnimating())
if (x2a8_26_isOpen && !x64_modelData->IsAnimating())
RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
else if (x2a8_25_ && x64_modelData->IsAnimating())
{
x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId());
x2a8_28_ = false;
x2a8_27_ = false;
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
}
if (GetScannableObjectInfo())
AddMaterial(EMaterialTypes::Solid, EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
else
AddMaterial(EMaterialTypes::Solid, EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, mgr);
{
if (x2a8_25_ && !x64_modelData->IsAnimating())
{
x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId());
x2a8_28_ = false;
x2a8_27_ = false;
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
}
if (GetScannableObjectInfo())
AddMaterial(/*EMaterialTypes::Solid, */EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
else
AddMaterial(/*EMaterialTypes::Solid, */EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, mgr);
}
if (x64_modelData->IsAnimating())
UpdateAnimation((x64_modelData->GetAnimationDuration(s32(x260_doorState)) / x258_) * dt, mgr, true);
{
float f1 = x64_modelData->GetAnimationDuration(s32(x260_doorState));
float f0 = x258_animLen;
f0 = f1 / f0;
f1 = f0 * dt;
UpdateAnimation(f1, mgr, true);
}
xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan;
}
void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager &mgr)
void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager &mgr) const
{
if (!xe4_30_outOfFrustum)
CPhysicsActor::Render(mgr);
@ -226,9 +236,9 @@ void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager
/* ORIGINAL 0-00 OFFSET: 8007E0BC */
void CScriptDoor::ForceClosed(CStateManager & mgr)
{
if (x2a8_26_useConservativeCameraDistance)
if (x2a8_26_isOpen)
{
x2a8_26_useConservativeCameraDistance = false;
x2a8_26_isOpen = false;
x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(x8_uid);
@ -237,7 +247,7 @@ void CScriptDoor::ForceClosed(CStateManager & mgr)
SetDoorAnimation(EDoorAnimType::Close);
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
x25c_ = 0.f;
x25c_animTime = 0.f;
x2a8_27_ = false;
x2a8_30_ = false;
}
@ -252,14 +262,16 @@ void CScriptDoor::ForceClosed(CStateManager & mgr)
/* ORIGINAL 0-00 OFFSET: 8007E1C4 */
bool CScriptDoor::IsConnectedToArea(const CStateManager& mgr, TAreaId areaId)
{
const CScriptDock* dock = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
if (dock)
const CScriptDock* dockEnt = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
if (dockEnt)
{
if (dock->GetDestinationAreaId() == areaId)
if (dockEnt->GetAreaId() == areaId)
return true;
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(areaId);
if (area->GetDock(dock->GetDockId())->GetConnectedAreaId(dock->GetDockReference(mgr)) == areaId)
const CWorld* world = mgr.GetWorld();
const CGameArea* area = world->GetAreaAlways(dockEnt->GetAreaId());
const CGameArea::Dock* dock = area->GetDock(dockEnt->GetDockId());
if (dock->GetConnectedAreaId(dockEnt->GetDockReference(mgr)) == areaId)
return true;
}
return false;
@ -270,13 +282,11 @@ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr)
{
TEditorId eid = mgr.GetEditorIdForUniqueId(uid);
mgr.MapWorldInfo()->SetDoorVisited(eid, true);
x2a8_26_useConservativeCameraDistance = true;
x2a8_26_isOpen = true;
x2a8_25_ = true;
x2a8_27_ = false;
const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid));
if (door)
if (const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid)))
x27c_partner1 = door->GetUniqueId();
SetDoorAnimation(EDoorAnimType::Open);
@ -295,7 +305,7 @@ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr)
if(TCastToConstPtr<CScriptDock> dock2 = mgr.GetObjectById(door->x282_dockId))
{
if (dock1->GetCurrentConnectedAreaId(mgr) == dock2->GetDestinationAreaId() && dock2->GetCurrentConnectedAreaId(mgr) == dock1->GetDestinationAreaId())
if (dock1->GetCurrentConnectedAreaId(mgr) == dock2->GetAreaId() && dock2->GetCurrentConnectedAreaId(mgr) == dock1->GetAreaId())
{
x27e_partner2 = door->GetUniqueId();
mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Open);
@ -323,18 +333,18 @@ u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr)
if (!dock)
return 2;
if (x25c_ < 0.05f || x2a8_30_)
if (x25c_animTime < 0.05f || x2a8_30_)
return 1;
TAreaId destArea = dock->GetDestinationAreaId();
if (destArea < 0 || destArea > mgr.GetWorld()->GetNumAreas())
TAreaId destArea = dock->GetAreaId();
if (destArea < 0 || destArea >= mgr.GetWorld()->GetNumAreas())
return 0;
if (!mgr.GetWorld()->AreSkyNeedsMet())
return 1;
TAreaId connArea = mgr.GetWorld()->GetAreaAlways(
dock->GetDestinationAreaId())->GetDock(
dock->GetAreaId())->GetDock(
dock->GetDockId())->GetConnectedAreaId(dock->GetDockReference(mgr));
if (connArea == kInvalidAreaId)
@ -370,7 +380,7 @@ u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr)
if (aliveArea->GetAreaId() == area->GetAreaId())
continue;
if (aliveArea->IsFinishedOccluding())
if (!aliveArea->IsFinishedOccluding())
return 1;
}

View File

@ -11,14 +11,13 @@ class CScriptDoor : public CPhysicsActor
public:
enum class EDoorAnimType
{
None = -1,
Open,
Close,
Ready,
};
float x258_;
float x25c_;
float x258_animLen;
float x25c_animTime;
EDoorAnimType x260_doorState = EDoorAnimType::Open;
zeus::CAABox x264_;
TUniqueId x27c_partner1 = kInvalidUniqueId;
@ -26,32 +25,15 @@ public:
TUniqueId x280_ = kInvalidUniqueId;
TUniqueId x282_dockId = kInvalidUniqueId;
zeus::CAABox x284_modelBounds;
zeus::CVector3f x29c_;
union
{
struct
{
bool x2a0_25_ : 1;
bool x2a0_26_ : 1;
};
u32 dummy1 = 0;
};
union
{
struct
{
bool x2a8_24_ : 1;
bool x2a8_25_ : 1;
bool x2a8_26_useConservativeCameraDistance : 1;
bool x2a8_27_ : 1;
bool x2a8_28_ : 1;
bool x2a8_29_ballDoor : 1;
bool x2a8_30_ : 1;
};
u32 dummy2 = 0;
};
bool x2a8_24_ : 1;
bool x2a8_25_ : 1;
bool x2a8_26_isOpen : 1;
bool x2a8_27_ : 1;
bool x2a8_28_ : 1;
bool x2a8_29_ballDoor : 1;
bool x2a8_30_ : 1;
public:
CScriptDoor(TUniqueId, std::string_view name, const CEntityInfo& info,
const zeus::CTransform&, CModelData&&, const CActorParameters&,
@ -62,14 +44,15 @@ public:
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
void Think(float, CStateManager& mgr);
void AddToRenderer(const zeus::CFrustum&, CStateManager& mgr);
void Render(const CStateManager&) {}
void AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const;
void Render(const CStateManager&) const {}
void ForceClosed(CStateManager&);
bool IsConnectedToArea(const CStateManager& mgr, TAreaId area);
void OpenDoor(TUniqueId, CStateManager&);
u32 GetDoorOpenCondition(CStateManager& mgr);
void SetDoorAnimation(EDoorAnimType);
std::experimental::optional<zeus::CAABox> GetProjectileBounds() const;
bool IsOpen() const { return x2a8_26_isOpen; }
};
}

View File

@ -1,6 +1,8 @@
#include "World/CScriptPlayerActor.hpp"
#include "World/CActorParameters.hpp"
#include "World/CLightParameters.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
@ -24,6 +26,8 @@ CScriptPlayerActor::CScriptPlayerActor(TUniqueId uid, std::string_view name, con
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
SetActorLights(aParams.GetLightParameters().MakeActorLights());
xe7_29_actorActive = true;
x2e3_24_cameraMoveIntoAlpha = true;
}
void CScriptPlayerActor::Think(float, CStateManager&)
@ -41,9 +45,11 @@ void CScriptPlayerActor::SetActive(bool active)
xe7_29_actorActive = true;
}
void CScriptPlayerActor::PreRender(CStateManager&, const zeus::CFrustum&)
void CScriptPlayerActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
{
if (x2e8_.GetCharacterNodeId() == 3)
g_Renderer->AllocatePhazonSuitMaskTexture();
CScriptActor::PreRender(mgr, frustum);
}
void CScriptPlayerActor::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const
@ -53,7 +59,6 @@ void CScriptPlayerActor::AddToRenderer(const zeus::CFrustum&, const CStateManage
void CScriptPlayerActor::Render(const CStateManager& mgr) const
{
}
void CScriptPlayerActor::TouchModels()

View File

@ -91,4 +91,10 @@ void CStateMachineState::Setup(const CStateMachine* machine)
}
std::string CStateMachineState::GetName() const { return {}; }
CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms, CObjectReference *)
{
return TToken<CStateMachine>::GetIObjObjectFor(std::make_unique<CStateMachine>(in));
}
}

View File

@ -1,8 +1,11 @@
#ifndef CSTATEMACHINE_HPP
#define CSTATEMACHINE_HPP
#include "RetroTypes.hpp"
#include "CAiFuncMap.hpp"
#include "IObj.hpp"
#include "CToken.hpp"
#include "IOStreams.hpp"
#include "IObjFactory.hpp"
namespace urde
{
@ -109,6 +112,9 @@ public:
float GetDelay() const;
};
CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
CObjectReference*);
}
#endif // CSTATEMACHINE_HPP

View File

@ -474,8 +474,8 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, bool skipLoadOther)
return;
x70_24_currentAreaNeedsAllocation = false;
x68_curAreaId = aid;
while (CGameArea* toDeallocateAreas = x4c_chainHeads[0])
CGameArea* toDeallocateAreas = x4c_chainHeads[0];
while (toDeallocateAreas)
{
if (toDeallocateAreas->Invalidate(&mgr))
{
@ -485,13 +485,14 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, bool skipLoadOther)
toDeallocateAreas = toDeallocateAreas->x130_next;
}
while (CGameArea* aliveAreas = x4c_chainHeads[3])
CGameArea* aliveAreas = x4c_chainHeads[3];
while (aliveAreas)
{
MoveToChain(aliveAreas, EChain::AliveJudgement);
aliveAreas = aliveAreas->x130_next;
}
while (CGameArea* loadingAreas = x4c_chainHeads[2])
CGameArea* loadingAreas = x4c_chainHeads[2];
while (loadingAreas)
{
MoveToChain(loadingAreas, EChain::ToDeallocate);
loadingAreas = loadingAreas->x130_next;
@ -531,15 +532,16 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, bool skipLoadOther)
}
}
}
while (CGameArea* judgementArea = x4c_chainHeads[4])
CGameArea* judgementArea = x4c_chainHeads[4];
while (judgementArea)
{
MoveToChain(judgementArea, EChain::ToDeallocate);
judgementArea = judgementArea->x130_next;
}
size_t toStreamCount = 0;
while (CGameArea* toDeallocateAreas = x4c_chainHeads[0])
toDeallocateAreas = x4c_chainHeads[0];
while (toDeallocateAreas)
{
toDeallocateAreas->RemoveStaticGeometry();
toDeallocateAreas = toDeallocateAreas->x130_next;

View File

@ -26,7 +26,7 @@ IGameArea::Dock::Dock(urde::CInputStream& in, const zeus::CTransform& xf)
TAreaId IGameArea::Dock::GetConnectedAreaId(s32 other) const
{
if (other >= x4_dockReferences.size() || other < 0)
if (u32(other) >= x4_dockReferences.size() || other < 0)
return kInvalidAreaId;
return x4_dockReferences[other].x0_area;
@ -34,8 +34,8 @@ TAreaId IGameArea::Dock::GetConnectedAreaId(s32 other) const
s16 IGameArea::Dock::GetOtherDockNumber(s32 other) const
{
if (other >= x4_dockReferences.size() || other < 0)
return kInvalidAreaId;
if (u32(other) >= x4_dockReferences.size() || other < 0)
return -1;
return x4_dockReferences[other].x4_dock;
}

View File

@ -422,7 +422,7 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
CModelData data;
if (animType == SBIG('ANCS'))
data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), true);
data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), false);
else
data = CStaticRes(staticId, head.x40_scale);
@ -483,7 +483,7 @@ CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in, int propCo
return nullptr;
CModelData mData =
CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), false);
if (collisionExtent.isZero())
aabb = mData.GetBounds(head.x10_transform.getRotation());
@ -648,7 +648,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int pr
CModelData data;
if (animType == SBIG('ANCS'))
data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), true);
else
data = CStaticRes(staticId, head.x40_scale);
@ -681,7 +681,7 @@ CEntity* ScriptLoader::LoadSound(CStateManager& mgr, CInputStream& in, int propC
bool acoustics = in.readBool();
bool worldSfx = in.readBool();
bool allowDuplicates = in.readBool();
u32 pitch = in.readUint32Big();
s32 pitch = in.readInt32Big();
if (soundId < 0)
return nullptr;
@ -804,7 +804,7 @@ CEntity* ScriptLoader::LoadNewIntroBoss(CStateManager& mgr, CInputStream& in, in
if (animType != SBIG('ANCS'))
return nullptr;
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), true);
return new MP1::CNewIntroBoss(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, res, pInfo, actParms,
f1, w1, dInfo, w2, w3, w4, w5);
@ -1335,7 +1335,7 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in, int pro
if (animType != SBIG('ANCS'))
return nullptr;
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), scale, true, aParms.GetInitialAnimation());
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), scale, aParms.GetInitialAnimation(), true);
CModelData mData(res);
return new MP1::CWarWasp(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, flavor, collider,
damageInfo1, actorParms, weaponDesc, damageInfo2, particle, w1);
@ -1592,7 +1592,7 @@ CEntity* ScriptLoader::LoadSpankWeed(CStateManager& mgr, CInputStream& in, int p
CEntity* ScriptLoader::LoadParasite(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{
if (!EnsurePropertyCount(propCount, 6, "Parasite"))
if (!EnsurePropertyCount(propCount, 25, "Parasite"))
return nullptr;
std::string name = mgr.HashInstanceName(in);
@ -1629,7 +1629,7 @@ CEntity* ScriptLoader::LoadParasite(CStateManager& mgr, CInputStream& in, int pr
return nullptr;
const CAnimationParameters& animParms = pInfo.GetAnimationParameters();
CModelData mData(CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
return nullptr; //return new MP1::CParasite(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo, )
return new MP1::CParasite(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo /*TODO: Finish */);
}
CEntity* ScriptLoader::LoadPlayerHint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)

2
hecl

@ -1 +1 @@
Subproject commit 71e620386d46b4208968e0bb61d9687775359880
Subproject commit 5fc99fe58c1257fce8f2d74517e23b2ae40d788a