Various bug fixes

This commit is contained in:
Jack Andersen 2018-06-01 20:06:25 -10:00
parent 56a5cfd115
commit 357a7efa9a
16 changed files with 90 additions and 65 deletions

View File

@ -401,14 +401,14 @@ struct ActorParameters : BigDNA
UniqueID32 xraySkin;
UniqueID32 thermalModel;
UniqueID32 thermalSkin;
Value<bool> unknown1;
Value<float> unknown2;
Value<float> unknown3;
Value<bool> globalTimeProvider;
Value<float> fadeInTime;
Value<float> fadeOutTime;
VisorParameters visorParameters;
Value<bool> thermalHeat;
Value<bool> unknown4;
Value<bool> unknown5;
Value<float> unknown6;
Value<bool> renderUnsorted;
Value<bool> noSortThermal;
Value<float> thermalMag;
void addCMDLRigPairs(std::unordered_map<UniqueID32, std::pair<UniqueID32, UniqueID32>>& addTo,
const UniqueID32& cinf) const

View File

@ -217,6 +217,7 @@ void CSfxManager::KillAll(ESfxChannels chan)
const CSfxHandle& handle = *it;
handle->Stop();
handle->Release();
handle->Close();
it = chanObj.x48_handles.erase(it);
}
}
@ -248,6 +249,7 @@ void CSfxManager::TurnOffChannel(ESfxChannels chan)
else
{
handle->Stop();
handle->Close();
it = chanObj.x48_handles.erase(it);
continue;
}
@ -260,6 +262,7 @@ void CSfxManager::TurnOffChannel(ESfxChannels chan)
if (!handle->IsLooped())
{
handle->Release();
handle->Close();
it = chanObj.x48_handles.erase(it);
continue;
}
@ -393,6 +396,7 @@ void CSfxManager::StopSound(const CSfxHandle& handle)
handle->Stop();
handle->Release();
CSfxChannel& chanObj = m_channels[int(m_currentChannel)];
handle->Close();
chanObj.x48_handles.erase(handle);
}
@ -500,6 +504,7 @@ void CSfxManager::StopAndRemoveAllEmitters()
const CSfxHandle& handle = *it;
handle->Stop();
handle->Release();
handle->Close();
it = chanObj.x48_handles.erase(it);
}
}
@ -646,6 +651,7 @@ void CSfxManager::Update(float dt)
{
handle->Stop();
m_doUpdate = true;
handle->Close();
it = chanObj.x48_handles.erase(it);
continue;
}
@ -675,6 +681,7 @@ void CSfxManager::Update(float dt)
if (handle->IsPlaying())
{
handle->Stop();
handle->Close();
chanObj.x48_handles.erase(handle);
}
}
@ -684,6 +691,7 @@ void CSfxManager::Update(float dt)
if (handle->IsPlaying() && !handle->IsInArea())
{
handle->Stop();
handle->Close();
chanObj.x48_handles.erase(handle);
}
}
@ -707,6 +715,7 @@ void CSfxManager::Update(float dt)
handle->Stop();
handle->Release();
m_doUpdate = true;
handle->Close();
it = chanObj.x48_handles.erase(it);
continue;
}

View File

@ -82,10 +82,11 @@ public:
bool x14_25_isPlaying:1;
bool x14_26_looped:1;
bool x14_27_inArea:1;
bool x14_28_available:1;
bool x14_28_isReleased:1;
bool x14_29_useAcoustics:1;
protected:
bool m_isEmitter:1;
bool m_isClosed:1;
public:
virtual ~CBaseSfxWrapper() = default;
virtual void SetActive(bool v) { x14_24_isActive = v; }
@ -112,15 +113,19 @@ public:
virtual void SetReverb(float rev)=0;
bool IsEmitter() const { return m_isEmitter; }
void Release() { x14_28_available = true; x4_timeRemaining = 15.f; }
bool Available() const { return x14_28_available; }
void Release() { x14_28_isReleased = true; x4_timeRemaining = 15.f; }
bool IsReleased() const { return x14_28_isReleased; }
void Close() { m_isClosed = true; }
bool IsClosed() const { return m_isClosed; }
float GetTimeRemaining() const { return x4_timeRemaining; }
void SetTimeRemaining(float t) { x4_timeRemaining = t; }
CBaseSfxWrapper(bool looped, s16 prio, /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: x8_rank(0), xa_prio(prio), /*xc_handle(handle),*/ x10_area(area), x14_24_isActive(true), x14_25_isPlaying(false),
x14_26_looped(looped), x14_27_inArea(true), x14_28_available(false), x14_29_useAcoustics(useAcoustics) {}
x14_26_looped(looped), x14_27_inArea(true), x14_28_isReleased(false), m_isClosed(false),
x14_29_useAcoustics(useAcoustics) {}
};
class CSfxEmitterWrapper : public CBaseSfxWrapper

View File

@ -509,7 +509,7 @@ private:
std::string x60_fileName; // arg1
union
{
u8 dummy = 0;
u32 dummy = 0;
struct
{
bool x70_24_unclaimed : 1;

View File

@ -12,7 +12,7 @@ CGameCamera::CGameCamera(TUniqueId uid, bool active, std::string_view name, cons
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic),
CActorParameters::None(), kInvalidUniqueId)
, xe8_watchedObject(watchedId)
, x12c_(xf)
, x12c_origXf(xf)
, x15c_currentFov(fovy)
, x160_znear(znear)
, x164_zfar(zfar)
@ -20,8 +20,8 @@ CGameCamera::CGameCamera(TUniqueId uid, bool active, std::string_view name, cons
, x16c_controllerIdx(controllerIdx)
, x170_24_perspDirty(true)
, x170_25_disablesInput(disableInput)
, x180_(fovy)
, x184_fov(fovy)
, x180_perspInterpStartFov(fovy)
, x184_perspInterpEndFov(fovy)
{
xe7_29_drawEnabled = false;
@ -108,18 +108,19 @@ void CGameCamera::UpdatePerspective(float dt)
return;
}
if (x178_ <= 0.f)
if (x178_perspInterpRemTime <= 0.f)
return;
x178_ -= dt;
if (x178_ > 0.f)
x178_perspInterpRemTime -= dt;
if (x178_perspInterpRemTime <= 0.f)
{
x15c_currentFov = x184_fov;
x15c_currentFov = x184_perspInterpEndFov;
x170_24_perspDirty = true;
}
else
{
x15c_currentFov = zeus::clamp(0.f, (dt / x17c_), 1.f) + ((x180_ - x184_fov) * x184_fov);
x15c_currentFov = zeus::clamp(0.f, (x178_perspInterpRemTime / x17c_perspInterpDur), 1.f) *
(x180_perspInterpStartFov - x184_perspInterpEndFov) + x184_perspInterpEndFov;
x170_24_perspDirty = true;
}
}
@ -130,16 +131,16 @@ void CGameCamera::SetFovInterpolation(float start, float fov, float time, float
{
x15c_currentFov = fov;
x170_24_perspDirty = true;
x184_fov = fov;
x178_ = x174_delayTime = 0.f;
x184_perspInterpEndFov = fov;
x178_perspInterpRemTime = x174_delayTime = 0.f;
}
else
{
x174_delayTime = std::max(0.f, delayTime);
x17c_ = time;
x178_ = time;
x180_ = start;
x184_fov = fov;
x17c_perspInterpDur = time;
x178_perspInterpRemTime = time;
x180_perspInterpStartFov = start;
x184_perspInterpEndFov = fov;
x15c_currentFov = start;
x170_24_perspDirty = true;
}
@ -147,12 +148,12 @@ void CGameCamera::SetFovInterpolation(float start, float fov, float time, float
void CGameCamera::SkipFovInterpolation()
{
if (x178_ > 0)
if (x178_perspInterpRemTime > 0)
{
x15c_currentFov = x184_fov;
x15c_currentFov = x184_perspInterpEndFov;
x170_24_perspDirty = true;
}
x178_ = x174_delayTime = 0.f;
x178_perspInterpRemTime = x174_delayTime = 0.f;
}
}

View File

@ -16,7 +16,7 @@ class CGameCamera : public CActor
protected:
TUniqueId xe8_watchedObject;
zeus::CMatrix4f xec_perspectiveMatrix;
zeus::CTransform x12c_;
zeus::CTransform x12c_origXf;
float x15c_currentFov;
float x160_znear;
float x164_zfar;
@ -25,10 +25,10 @@ protected:
bool x170_24_perspDirty : 1;
bool x170_25_disablesInput : 1;
float x174_delayTime = 0.f;
float x178_ = 0.f;
float x17c_ = 0.f;
float x180_;
float x184_fov;
float x178_perspInterpRemTime = 0.f;
float x17c_perspInterpDur = 0.f;
float x180_perspInterpStartFov;
float x184_perspInterpEndFov;
public:
CGameCamera(TUniqueId, bool active, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
float fov, float nearz, float farz, float aspect, TUniqueId watchedId, bool disableInput,

View File

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

View File

@ -12,6 +12,7 @@ class CActorParameters
{
friend class ScriptLoader;
friend class CActor;
friend class CScriptActor;
CLightParameters x0_lightParms;
CScannableParameters x40_scanParms;
std::pair<CAssetId, CAssetId> x44_xrayAssets = {};
@ -28,8 +29,8 @@ class CActorParameters
};
u32 _dummy = 0;
};
float x5c_ = 0.f;
float x60_ = 0.f;
float x5c_fadeInTime = 0.f;
float x60_fadeOutTime = 0.f;
float x64_thermalMag = 0.f;
public:
@ -39,7 +40,8 @@ public:
const std::pair<CAssetId, CAssetId>& xrayAssets,
const std::pair<CAssetId, CAssetId>& thermalAssets,
const CVisorParameters& visorParms, bool globalTimeProvider, bool thermalHeat,
bool renderUnsorted, bool noSortThermal)
bool renderUnsorted, bool noSortThermal,
float fadeInTime, float fadeOutTime, float thermalMag)
: x0_lightParms(lightParms)
, x40_scanParms(scanParms)
, x44_xrayAssets(xrayAssets)
@ -49,6 +51,9 @@ public:
, x58_25_thermalHeat(thermalHeat)
, x58_26_renderUnsorted(renderUnsorted)
, x58_27_noSortThermal(noSortThermal)
, x5c_fadeInTime(fadeInTime)
, x60_fadeOutTime(fadeOutTime)
, x64_thermalMag(thermalMag)
{
}
CActorParameters Scannable(const CScannableParameters& sParms) const

View File

@ -7,6 +7,7 @@
#include "CScriptColorModulate.hpp"
#include "Character/IAnimReader.hpp"
#include "TCastTo.hpp"
#include "CActorParameters.hpp"
namespace urde
{
@ -20,6 +21,8 @@ CScriptActor::CScriptActor(TUniqueId uid, std::string_view name, const CEntityIn
, x258_initialHealth(hInfo)
, x260_currentHealth(hInfo)
, x268_damageVulnerability(dVuln)
, x2d0_fadeInTime(actParms.x5c_fadeInTime)
, x2d4_fadeOutTime(actParms.x60_fadeOutTime)
, x2d8_shaderIdx(shaderIdx)
, x2dc_xrayAlpha(xrayAlpha)
{
@ -76,11 +79,11 @@ void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
if (!GetActive())
{
mgr.SendScriptMsg(this, x8_uid, EScriptObjectMessage::Activate);
CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_alphaMax);
CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_fadeInTime);
}
break;
case EScriptObjectMessage::Decrement:
CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_alphaMin);
CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_fadeOutTime);
break;
default:
break;

View File

@ -14,8 +14,8 @@ protected:
CHealthInfo x258_initialHealth;
CHealthInfo x260_currentHealth;
CDamageVulnerability x268_damageVulnerability;
float x2d0_alphaMax;
float x2d4_alphaMin;
float x2d0_fadeInTime;
float x2d4_fadeOutTime;
s32 x2d8_shaderIdx;
float x2dc_xrayAlpha;
TUniqueId x2e0_triggerId = kInvalidUniqueId;

View File

@ -273,7 +273,7 @@ void CScriptColorModulate::SetTargetFlags(CStateManager& stateMgr, const CModelF
}
}
TUniqueId CScriptColorModulate::FadeOutHelper(CStateManager& mgr, TUniqueId parent, float dt)
TUniqueId CScriptColorModulate::FadeOutHelper(CStateManager& mgr, TUniqueId parent, float fadeTime)
{
TAreaId aId = mgr.GetNextAreaId();
if (const CEntity* ent = mgr.GetObjectById(parent))
@ -281,7 +281,7 @@ TUniqueId CScriptColorModulate::FadeOutHelper(CStateManager& mgr, TUniqueId pare
TUniqueId ret = mgr.AllocateUniqueId();
CScriptColorModulate* colMod = new CScriptColorModulate(ret, "", CEntityInfo(aId, CEntity::NullConnectionList),
zeus::CColor(1.f, 1.f, 1.f, 0.f), zeus::CColor(1.f, 1.f, 1.f, 1.f), EBlendMode::Alpha, dt, 0.f,
zeus::CColor(1.f, 1.f, 1.f, 1.f), zeus::CColor(1.f, 1.f, 1.f, 0.f), EBlendMode::Alpha, fadeTime, 0.f,
false, false, true, true, false, true);
mgr.AddObject(colMod);
colMod->x34_parent = parent;
@ -293,7 +293,7 @@ TUniqueId CScriptColorModulate::FadeOutHelper(CStateManager& mgr, TUniqueId pare
return ret;
}
TUniqueId CScriptColorModulate::FadeInHelper(CStateManager& mgr, TUniqueId parent, float dt)
TUniqueId CScriptColorModulate::FadeInHelper(CStateManager& mgr, TUniqueId parent, float fadeTime)
{
TAreaId aId = mgr.GetNextAreaId();
if (const CEntity* ent = mgr.GetObjectById(parent))
@ -301,7 +301,7 @@ TUniqueId CScriptColorModulate::FadeInHelper(CStateManager& mgr, TUniqueId paren
TUniqueId ret = mgr.AllocateUniqueId();
CScriptColorModulate* colMod = new CScriptColorModulate(ret, "", CEntityInfo(aId, CEntity::NullConnectionList),
zeus::CColor(1.f, 1.f, 1.f, 1.f), zeus::CColor(1.f, 1.f, 1.f, 0.f), EBlendMode::Alpha, dt, 0.f,
zeus::CColor(1.f, 1.f, 1.f, 0.f), zeus::CColor(1.f, 1.f, 1.f, 1.f), EBlendMode::Alpha, fadeTime, 0.f,
false, false, true, true, false, true);
mgr.AddObject(colMod);
colMod->x34_parent = parent;

View File

@ -62,8 +62,8 @@ public:
void Think(float, CStateManager &);
CModelFlags CalculateFlags(const zeus::CColor&) const;
void SetTargetFlags(CStateManager&, const CModelFlags&);
static TUniqueId FadeOutHelper(CStateManager&, TUniqueId, float);
static TUniqueId FadeInHelper(CStateManager&, TUniqueId, float);
static TUniqueId FadeOutHelper(CStateManager& mgr, TUniqueId obj, float fadetime);
static TUniqueId FadeInHelper(CStateManager& mgr, TUniqueId obj, float fadetime);
void End(CStateManager&);
};
}

View File

@ -194,7 +194,7 @@ void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
break;
case EScriptObjectMessage::Activate:
{
if(GetActive())
if (GetActive())
x11c_24_playRequested = true;
}
break;
@ -210,7 +210,7 @@ void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
void CScriptSound::PlaySound(CStateManager& mgr)
{
if ((x11d_24_allowDuplicates || !xec_sfxHandle || !xec_sfxHandle->IsPlaying()) && !x11d_25_processedThisFrame)
if ((x11d_24_allowDuplicates || !xec_sfxHandle || xec_sfxHandle->IsClosed()) && !x11d_25_processedThisFrame)
{
x11d_25_processedThisFrame = true;
if (x11c_26_nonEmitter)

View File

@ -52,8 +52,9 @@ CScriptStreamedMusic::CScriptStreamedMusic(TUniqueId id, const CEntityInfo& info
x45_fileIsDsp(IsDSPFile(fileName)), x46_loop(loop), x47_music(music),
x48_fadeIn(fadeIn), x4c_fadeOut(fadeOut), x50_volume(volume)
{
while (x34_fileName.find("/audio") != std::string::npos)
x34_fileName.replace(x34_fileName.find("/audio"), std::strlen("/audio"), "/Audio");
size_t pos;
while ((pos = x34_fileName.find("audio/")) != std::string::npos)
x34_fileName.replace(pos, 6, "Audio/");
}
void CScriptStreamedMusic::Stop(CStateManager& mgr)

View File

@ -209,17 +209,17 @@ CActorParameters ScriptLoader::LoadActorParameters(CInputStream& in)
CAssetId infraModel = in.readUint32Big();
CAssetId infraSkin = in.readUint32Big();
bool b1 = true;
bool globalTimeProvider = true;
if (propCount > 7)
b1 = in.readBool();
globalTimeProvider = in.readBool();
float f1 = 1.f;
float fadeInTime = 1.f;
if (propCount > 8)
f1 = in.readFloatBig();
fadeInTime = in.readFloatBig();
float f2 = 1.f;
float fadeOutTime = 1.f;
if (propCount > 9)
f2 = in.readFloatBig();
fadeOutTime = in.readFloatBig();
CVisorParameters vParms;
if (propCount > 6)
@ -229,17 +229,17 @@ CActorParameters ScriptLoader::LoadActorParameters(CInputStream& in)
if (propCount > 10)
thermalHeat = in.readBool();
bool b3 = false;
bool renderUnsorted = false;
if (propCount > 11)
b3 = in.readBool();
renderUnsorted = in.readBool();
bool b4 = false;
bool noSortThermal = false;
if (propCount > 12)
b4 = in.readBool();
noSortThermal = in.readBool();
float f3 = 1.f;
float thermalMag = 1.f;
if (propCount > 13)
f3 = in.readFloatBig();
thermalMag = in.readFloatBig();
std::pair<CAssetId, CAssetId> xray = {};
if (g_ResFactory->GetResourceTypeById(xrayModel))
@ -249,7 +249,8 @@ CActorParameters ScriptLoader::LoadActorParameters(CInputStream& in)
if (g_ResFactory->GetResourceTypeById(infraModel))
infra = {infraModel, infraSkin};
return CActorParameters(lParms, sParams, xray, infra, vParms, b1, thermalHeat, b3, b4);
return CActorParameters(lParms, sParams, xray, infra, vParms, globalTimeProvider, thermalHeat,
renderUnsorted, noSortThermal, fadeInTime, fadeOutTime, thermalMag);
}
return CActorParameters::None();
}

2
hecl

@ -1 +1 @@
Subproject commit 7ae053a6ea6a7b8b40e0e40f2daa362d4c227433
Subproject commit 788fa73884d56417d6bc70918983c9d9ac8032b4