Merge branch 'master' of ssh://git.axiodl.com:6431/AxioDL/urde

This commit is contained in:
Jack Andersen 2019-09-30 21:41:42 -10:00
commit e1d46755a3
780 changed files with 5723 additions and 3544 deletions

View File

@ -669,11 +669,12 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os, athena::io::I
}
}
if (s < secCount - 1)
reader.seek(secStart + secSizes[s], athena::Begin);
if (s < secCount - 1) {
reader.seek(secStart + secSizes[s], athena::SeekOrigin::Begin);
}
}
reader.seek(afterHeaderPos, athena::Begin);
reader.seek(afterHeaderPos, athena::SeekOrigin::Begin);
visitedDLOffsets = false;
unsigned createdUVLayers = 0;
@ -989,8 +990,9 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os, athena::io::I
}
}
if (s < secCount - 1)
reader.seek(secStart + secSizes[s], athena::Begin);
if (s < secCount - 1) {
reader.seek(secStart + secSizes[s], athena::SeekOrigin::Begin);
}
}
/* Finish Mesh */
@ -1088,8 +1090,9 @@ void NameCMDL(athena::io::IStreamReader& reader, PAKRouter& pakRouter, typename
matSet.nameTextures(pakRouter, bestName.c_str(), s);
}
if (s < head.secCount - 1)
reader.seek(secStart + head.secSizes[s], athena::Begin);
if (s < head.secCount - 1) {
reader.seek(secStart + head.secSizes[s], athena::SeekOrigin::Begin);
}
}
}
@ -1547,7 +1550,7 @@ bool WriteHMDLCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& in
}
/* Ensure final surface's alignment writes zeros */
writer.seek(-1, athena::Current);
writer.seek(-1, athena::SeekOrigin::Current);
writer.writeUByte(0);
writer.close();
return true;
@ -2042,7 +2045,7 @@ void SurfaceHeader_1::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
aabb[1] = reader.readVec3fBig();
remAABB -= 24;
}
reader.seek(remAABB, athena::Current);
reader.seek(remAABB, athena::SeekOrigin::Current);
/* align */
reader.seekAlign32();
}
@ -2106,7 +2109,7 @@ void SurfaceHeader_2::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
aabb[1] = reader.readVec3fBig();
remAABB -= 24;
}
reader.seek(remAABB, athena::Current);
reader.seek(remAABB, athena::SeekOrigin::Current);
/* align */
reader.seekAlign32();
}
@ -2174,7 +2177,7 @@ void SurfaceHeader_3::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
aabb[1] = reader.readVec3fBig();
remAABB -= 24;
}
reader.seek(remAABB, athena::Current);
reader.seek(remAABB, athena::SeekOrigin::Current);
/* unk3 */
unk3 = reader.readUByte();
/* align */

View File

@ -17,9 +17,9 @@ extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
extern ThreadLocalPtr<hecl::blender::Token> g_ThreadBlenderToken;
/* This comes up a great deal */
typedef athena::io::DNA<athena::Big> BigDNA;
typedef athena::io::DNAV<athena::Big> BigDNAV;
typedef athena::io::DNAVYaml<athena::Big> BigDNAVYaml;
using BigDNA = athena::io::DNA<athena::Endian::Big>;
using BigDNAV = athena::io::DNAV<athena::Endian::Big>;
using BigDNAVYaml = athena::io::DNAVYaml<athena::Endian::Big>;
/** FourCC with DNA read/write */
using DNAFourCC = hecl::DNAFourCC;

View File

@ -3,15 +3,15 @@
namespace GX {
template <>
void Color::Enumerate<athena::io::DNA<athena::Big>::Read>(typename Read::StreamT& reader) {
void Color::Enumerate<athena::io::DNA<athena::Endian::Big>::Read>(Read::StreamT& reader) {
reader.readUBytesToBuf(&num, 4);
}
template <>
void Color::Enumerate<athena::io::DNA<athena::Big>::Write>(typename Write::StreamT& writer) {
void Color::Enumerate<athena::io::DNA<athena::Endian::Big>::Write>(Write::StreamT& writer) {
writer.writeUBytes(reinterpret_cast<const atUint8*>(&num), 4);
}
template <>
void Color::Enumerate<athena::io::DNA<athena::Big>::BinarySize>(typename BinarySize::StreamT& s) {
void Color::Enumerate<athena::io::DNA<athena::Endian::Big>::BinarySize>(BinarySize::StreamT& s) {
s += 4;
}

View File

@ -246,7 +246,7 @@ enum BlendFactor : uint16_t {
BL_INVDSTALPHA
};
struct Color : athena::io::DNA<athena::Big> {
struct Color : athena::io::DNA<athena::Endian::Big> {
union {
uint8_t color[4];
uint32_t num = 0;

View File

@ -18,12 +18,12 @@ namespace DataSpec {
/** PAK entry stream reader */
class PAKEntryReadStream : public athena::io::IStreamReader {
std::unique_ptr<atUint8[]> m_buf;
atUint64 m_sz;
atUint64 m_pos;
atUint64 m_sz = 0;
atUint64 m_pos = 0;
public:
PAKEntryReadStream() {}
operator bool() const { return m_buf.operator bool(); }
PAKEntryReadStream() = default;
explicit operator bool() const { return m_buf.operator bool(); }
PAKEntryReadStream(const PAKEntryReadStream& other) = delete;
PAKEntryReadStream(PAKEntryReadStream&& other) = default;
PAKEntryReadStream& operator=(const PAKEntryReadStream& other) = delete;
@ -34,14 +34,16 @@ public:
LogDNACommon.report(logvisor::Fatal, fmt("PAK stream cursor overrun"));
}
void seek(atInt64 pos, athena::SeekOrigin origin) override {
if (origin == athena::Begin)
if (origin == athena::SeekOrigin::Begin) {
m_pos = pos;
else if (origin == athena::Current)
} else if (origin == athena::SeekOrigin::Current) {
m_pos += pos;
else if (origin == athena::End)
} else if (origin == athena::SeekOrigin::End) {
m_pos = m_sz + pos;
if (m_pos > m_sz)
}
if (m_pos > m_sz) {
LogDNACommon.report(logvisor::Fatal, fmt("PAK stream cursor overrun"));
}
}
atUint64 position() const override { return m_pos; }
atUint64 length() const override { return m_sz; }

View File

@ -113,7 +113,7 @@ void WPSM<IDType>::_read(athena::io::YAMLDocReader& r) {
xunk_FC60.read(r);
break;
case SBIG('SPS1'):
xunk_SPS2.read(r);
xunk_SPS1.read(r);
break;
case SBIG('SPS2'):
xunk_SPS2.read(r);

View File

@ -238,7 +238,7 @@ bool AGSC::Cook(const hecl::ProjectPath& dir, const hecl::ProjectPath& refOutPat
amuse::AudioGroupDatabase group(path.getAbsolutePath());
auto proj = group.getProj().toGCNData(group.getPool(), group.getSdir());
auto pool = group.getPool().toData<athena::Big>();
auto pool = group.getPool().toData<athena::Endian::Big>();
auto sdirSamp = group.getSdir().toGCNData(group);
w.writeUint32Big(pool.size());

View File

@ -61,6 +61,7 @@ set(DNAMP1_SOURCES
FRME.cpp
SCAN.cpp
DeafBabe.cpp
Tweaks/CTweakAutoMapper.cpp
Tweaks/CTweakPlayer.cpp
Tweaks/CTweakTargeting.cpp
Tweaks/CTweakBall.cpp

View File

@ -115,7 +115,7 @@ void PAKBridge::build() {
if (worldMapEnt) {
worldMapEnt->name = entry.name + "_mapw";
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
rs.seek(8, athena::Current);
rs.seek(8, athena::SeekOrigin::Current);
atUint32 areaCount = rs.readUint32Big();
mapw.reserve(areaCount);
for (atUint32 i = 0; i < areaCount; ++i)

View File

@ -46,7 +46,7 @@ void MREA::AddCMDLRigPairs(PAKEntryReadStream& rs, PAKRouter<PAKBridge>& pakRout
atUint64 secStart = rs.position();
while (curSec != head.sclySecIdx)
secStart += head.secSizes[curSec++];
rs.seek(secStart, athena::Begin);
rs.seek(secStart, athena::SeekOrigin::Begin);
SCLY scly;
scly.read(rs);
scly.addCMDLRigPairs(pakRouter, charAssoc);
@ -65,7 +65,7 @@ UniqueID32 MREA::GetPATHId(PAKEntryReadStream& rs) {
secStart += head.secSizes[curSec++];
if (!head.secSizes[curSec])
return {};
rs.seek(secStart, athena::Begin);
rs.seek(secStart, athena::SeekOrigin::Begin);
return {rs};
}
@ -81,7 +81,7 @@ static void OutputOctreeNode(hecl::blender::PyOutStream& os, athena::io::MemoryR
offsets[i] = r.readUint32Big();
u32 dataStart = r.position();
for (int i = 0; i < 8; ++i) {
r.seek(dataStart + offsets[i], athena::Begin);
r.seek(dataStart + offsets[i], athena::SeekOrigin::Begin);
int chFlags = (flags >> (i * 2)) & 0x3;
zeus::CAABox pos, neg, res;
@ -231,7 +231,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 secStart = rs.position();
matSet.read(rs);
matSet.readToBlender(os, pakRouter, entry, 0);
rs.seek(secStart + head.secSizes[0], athena::Begin);
rs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
std::vector<DNACMDL::VertexAttributes> vertAttribs;
DNACMDL::GetVertexAttributes(matSet, vertAttribs);
@ -241,7 +241,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
MeshHeader mHeader;
secStart = rs.position();
mHeader.read(rs);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin);
rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
curSec += DNACMDL::ReadGeomSectionsToBlender<PAKRouter<PAKBridge>, MaterialSet, RigPair, DNACMDL::SurfaceHeader_1>(
os, rs, pakRouter, entry, dummy, true, true, vertAttribs, m, head.secCount, 0, &head.secSizes[curSec]);
os.format(fmt(
@ -255,14 +255,14 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
/* Skip AROT */
secStart = rs.position();
rs.seek(secStart + head.secSizes[curSec++], athena::Begin);
rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Read SCLY layers */
secStart = rs.position();
SCLY scly;
scly.read(rs);
scly.exportToLayerDirectories(entry, pakRouter, force);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin);
rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Read collision meshes */
DeafBabe collision;
@ -270,32 +270,32 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
collision.read(rs);
DeafBabe::BlenderInit(os);
collision.sendToBlender(os);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin);
rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Skip unknown section */
rs.seek(head.secSizes[curSec++], athena::Current);
rs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Read BABEDEAD Lights as Cycles emissives */
secStart = rs.position();
ReadBabeDeadToBlender_1_2(os, rs);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin);
rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Dump VISI entities */
secStart = rs.position();
if (head.secSizes[curSec] && rs.readUint32Big() == 'VISI') {
{
rs.seek(secStart, athena::Begin);
rs.seek(secStart, athena::SeekOrigin::Begin);
auto visiData = rs.readUBytes(head.secSizes[curSec]);
athena::io::FileWriter visiOut(outPath.getWithExtension(_SYS_STR(".visi"), true).getAbsolutePath());
visiOut.writeUBytes(visiData.get(), head.secSizes[curSec]);
rs.seek(secStart + 4, athena::Begin);
rs.seek(secStart + 4, athena::SeekOrigin::Begin);
}
athena::io::YAMLDocWriter visiWriter("VISI");
if (auto __vec = visiWriter.enterSubVector("entities")) {
rs.seek(18, athena::Current);
rs.seek(18, athena::SeekOrigin::Current);
uint32_t entityCount = rs.readUint32Big();
rs.seek(8, athena::Current);
rs.seek(8, athena::SeekOrigin::Current);
for (uint32_t i = 0; i < entityCount; ++i) {
uint32_t entityId = rs.readUint32Big();
visiWriter.writeUint32(entityId);
@ -333,14 +333,14 @@ void MREA::Name(const SpecBase& dataSpec, PAKEntryReadStream& rs, PAKRouter<PAKB
MaterialSet matSet;
matSet.read(rs);
matSet.nameTextures(pakRouter, fmt::format(fmt("MREA_{}"), entry.id).c_str(), -1);
rs.seek(secStart + head.secSizes[0], athena::Begin);
rs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
/* Skip to SCLY */
atUint32 curSec = 1;
secStart = rs.position();
while (curSec != head.sclySecIdx)
secStart += head.secSizes[curSec++];
rs.seek(secStart, athena::Begin);
rs.seek(secStart, athena::SeekOrigin::Begin);
SCLY scly;
scly.read(rs);
scly.nameIDs(pakRouter);
@ -348,7 +348,7 @@ void MREA::Name(const SpecBase& dataSpec, PAKEntryReadStream& rs, PAKRouter<PAKB
/* Skip to PATH */
while (curSec != head.pathSecIdx)
secStart += head.secSizes[curSec++];
rs.seek(secStart, athena::Begin);
rs.seek(secStart, athena::SeekOrigin::Begin);
UniqueID32 pathID(rs);
const nod::Node* node;

View File

@ -13,7 +13,7 @@ void SCLY::Enumerate<BigDNA::Read>(athena::io::IStreamReader& rs) {
rs.enumerate<ScriptLayer>(layers, layerCount, [&i, this](athena::io::IStreamReader& rs, ScriptLayer& layer) {
atUint64 start = rs.position();
layer.read(rs);
rs.seek(start + layerSizes[i++], athena::Begin);
rs.seek(start + layerSizes[i++], athena::SeekOrigin::Begin);
});
}
@ -118,9 +118,10 @@ void SCLY::ScriptLayer::Enumerate<BigDNA::Read>(athena::io::IStreamReader& rs) {
fmt(_SYS_STR("Error while reading object of type 0x{:02X}, did not read the expected amount of "
"data, read 0x{:x}, expected 0x{:x}")),
(atUint32)type, actualLen, len);
rs.seek(start + len, athena::Begin);
} else
rs.seek(start + len, athena::SeekOrigin::Begin);
} else {
Log.report(logvisor::Fatal, fmt(_SYS_STR("Unable to find type 0x{:X} in object database")), (atUint32)type);
}
}
}

View File

@ -0,0 +1,18 @@
#include "DataSpec/DNAMP1/Tweaks/CTweakAutoMapper.hpp"
#include <hecl/CVar.hpp>
#include <hecl/CVarManager.hpp>
namespace DataSpec::DNAMP1 {
namespace {
}
void CTweakAutoMapper::_tweakListener(hecl::CVar* cv) {
}
void CTweakAutoMapper::initCVars(hecl::CVarManager* mgr) {
}
}

View File

@ -1,7 +1,12 @@
#pragma once
#include "../../DataSpec/DNACommon/Tweaks/ITweakAutoMapper.hpp"
#include "zeus/CVector3f.hpp"
#include "DataSpec/DNACommon/Tweaks/ITweakAutoMapper.hpp"
#include <zeus/CVector3f.hpp>
namespace hecl {
class CVar;
}
namespace DataSpec::DNAMP1 {
struct CTweakAutoMapper final : public ITweakAutoMapper {
@ -132,5 +137,9 @@ struct CTweakAutoMapper final : public ITweakAutoMapper {
const zeus::CColor& GetAreaFlashPulseColor() const override { return xf4_areaFlashPulseColor; }
const zeus::CColor& GetDoorColor(int idx) const override { return x104_doorColors[idx]; }
const zeus::CColor& GetOpenDoorColor() const override { return x11c_openDoorColor; }
void initCVars(hecl::CVarManager*) override;
private:
void _tweakListener(hecl::CVar* cv);
};
} // namespace DataSpec::DNAMP1

View File

@ -1,10 +1,46 @@
#include "CTweakGame.hpp"
#include "hecl/CVarManager.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
#include "Runtime/Camera/CCameraManager.hpp"
#include <hecl/CVar.hpp>
#include <hecl/CVarManager.hpp>
namespace DataSpec::DNAMP1 {
hecl::CVar* tw_fov = nullptr;
hecl::CVar* tw_hardmodeDMult = nullptr;
hecl::CVar* tw_hardmodeWMult = nullptr;
namespace {
constexpr std::string_view skFov = "tweaks.game.FieldOfView"sv;
constexpr std::string_view skHardModeDamageMultName = "tweaks.game.HardModeDamageMult"sv;
constexpr std::string_view skHardModeWeaponMultName = "tweaks.game.HardModeWeaponMult"sv;
} // anonymous namespace
void CTweakGame::_tweakGameListener(hecl::CVar* cv) {
if (cv == tw_fov) {
x24_fov = cv->toReal();
} else if (cv == tw_hardmodeDMult) {
x60_hardmodeDamageMult = cv->toReal();
} else if (cv == tw_hardmodeWMult) {
x64_hardmodeWeaponMult = cv->toReal();
}
}
void CTweakGame::initCVars(hecl::CVarManager* mgr) {
// mgr->findOrMakeCVar("tweaks.game.hardmodeDamageMult", "", x60_hardmodeDamageMult, hecl::CVar::EFlags::Game |
// hecl::CVar::Archive | hecl::CVar::Cheat); mgr->findOrMakeCVar("tweaks.game.hardmodeWeaponMult", "",
// x64_hardmodeWeaponMult, hecl::CVar::EFlags::Game | hecl::CVar::Archive | hecl::CVar::Cheat);
auto assignRealValue = [this, mgr](std::string_view name, std::string_view desc, float& v, hecl::CVar::EFlags flags) {
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
// Check if the CVar was deserialized, this avoid an unnecessary conversion
if (cv->wasDeserialized())
v = cv->toReal();
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
return cv;
};
tw_fov = assignRealValue(skFov, "", x24_fov,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
tw_hardmodeDMult =
assignRealValue(skHardModeDamageMultName, "", x60_hardmodeDamageMult,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Cheat);
tw_hardmodeWMult =
assignRealValue(skHardModeWeaponMultName, "", x64_hardmodeWeaponMult,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Cheat);
}
} // namespace DataSpec::DNAMP1

View File

@ -1,6 +1,10 @@
#pragma once
#include "../../DNACommon/Tweaks/ITweakGame.hpp"
#include "DataSpec/DNACommon/Tweaks/ITweakGame.hpp"
namespace hecl {
class CVar;
}
namespace DataSpec::DNAMP1 {
@ -56,5 +60,7 @@ struct CTweakGame final : ITweakGame {
}
void initCVars(hecl::CVarManager* mgr) override;
private:
void _tweakGameListener(hecl::CVar* cv);
};
} // namespace DataSpec::DNAMP1

View File

@ -89,14 +89,16 @@ struct CTweakPlayerGun final : ITweakPlayerGun {
}
const SWeaponInfo& GetBeamInfo(atInt32 beam) const override {
if (beam < 0 || beam > 5)
if (beam < 0 || beam >= 5) {
return xa8_beams[0];
}
return xa8_beams[beam];
}
const SComboShotParam& GetComboShotInfo(atInt32 beam) const override {
if (beam < 0 || beam > 5)
if (beam < 0 || beam >= 5) {
return x1f0_combos[0];
}
return x1f0_combos[beam];
}

View File

@ -57,7 +57,7 @@ bool AGSC::Cook(const hecl::ProjectPath& dir, const hecl::ProjectPath& outPath)
amuse::AudioGroupDatabase group(dir.getAbsolutePath());
auto proj = group.getProj().toGCNData(group.getPool(), group.getSdir());
auto pool = group.getPool().toData<athena::Big>();
auto pool = group.getPool().toData<athena::Endian::Big>();
auto sdirSamp = group.getSdir().toGCNData(group);
Header head;

View File

@ -86,7 +86,7 @@ void PAKBridge::build() {
std::vector<UniqueID32> mapw;
if (worldMapEnt) {
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
rs.seek(8, athena::Current);
rs.seek(8, athena::SeekOrigin::Current);
atUint32 areaCount = rs.readUint32Big();
mapw.reserve(areaCount);
for (atUint32 i = 0; i < areaCount; ++i)

View File

@ -80,10 +80,11 @@ MREA::StreamReader::StreamReader(athena::io::IStreamReader& source, atUint32 blk
void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) {
atUint64 target = diff;
if (whence == athena::Current)
if (whence == athena::SeekOrigin::Current) {
target = m_pos + diff;
else if (whence == athena::End)
} else if (whence == athena::SeekOrigin::End) {
target = m_totalDecompLen - diff;
}
if (target >= m_totalDecompLen)
Log.report(logvisor::Fatal, fmt("MREA stream seek overrun"));
@ -106,7 +107,7 @@ void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) {
/* Seek source if needed */
if (bIdx != m_nextBlk - 1) {
m_source.seek(m_blkBase + cAccum, athena::Begin);
m_source.seek(m_blkBase + cAccum, athena::SeekOrigin::Begin);
m_nextBlk = bIdx;
nextBlock();
}
@ -168,7 +169,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 decompLen = drs.length();
mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen);
mreaDecompOut.close();
drs.seek(0, athena::Begin);
drs.seek(0, athena::SeekOrigin::Begin);
/* Start up blender connection */
hecl::blender::Connection& conn = btok.getBlenderConnection();
@ -181,12 +182,12 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
egmcOffset += head.secSizes[i];
/* Load EGMC if possible so we can assign meshes to scanIds */
drs.seek(egmcOffset, athena::Begin);
drs.seek(egmcOffset, athena::SeekOrigin::Begin);
UniqueID32 egmcId(drs);
DNACommon::EGMC egmc;
pakRouter.lookupAndReadDNA(egmcId, egmc);
drs.seek(0, athena::Begin);
drs.seek(0, athena::SeekOrigin::Begin);
/* Open Py Stream and read sections */
hecl::blender::PyOutStream os = conn.beginPythonOut(true);
@ -224,7 +225,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 secStart = drs.position();
matSet.read(drs);
matSet.readToBlender(os, pakRouter, entry, 0);
drs.seek(secStart + head.secSizes[0], athena::Begin);
drs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
std::vector<DNACMDL::VertexAttributes> vertAttribs;
DNACMDL::GetVertexAttributes(matSet, vertAttribs);
@ -234,7 +235,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
MeshHeader mHeader;
secStart = drs.position();
mHeader.read(drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
curSec += DNACMDL::ReadGeomSectionsToBlender<PAKRouter<PAKBridge>, MaterialSet, RigPair, DNACMDL::SurfaceHeader_2>(
os, drs, pakRouter, entry, dummy, true, true, vertAttribs, m, head.secCount, 0, &head.secSizes[curSec]);
os.format(fmt(
@ -246,25 +247,26 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
mHeader.visorFlags.disableXray() ? "True" : "False", mHeader.visorFlags.thermalLevelStr());
/* Seek through AROT-relation sections */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
}
/* Skip AROT */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Skip BVH */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Skip Bitmap */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Skip SCLY (for now) */
for (atUint32 l = 0; l < head.sclyLayerCount; ++l)
drs.seek(head.secSizes[curSec++], athena::Current);
for (atUint32 l = 0; l < head.sclyLayerCount; ++l) {
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
}
/* Skip SCGN (for now) */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Read collision meshes */
DeafBabe collision;
@ -272,15 +274,15 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
collision.read(drs);
DeafBabe::BlenderInit(os);
collision.sendToBlender(os);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Skip unknown section */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Read BABEDEAD Lights as Cycles emissives */
secStart = drs.position();
DNAMP1::MREA::ReadBabeDeadToBlender_1_2(os, drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Origins to center of mass */
os << "bpy.context.view_layer.layer_collection.children['Collision'].hide_viewport = False\n"

View File

@ -69,7 +69,7 @@ struct MREA {
Value<atUint32> unk3SecIdx;
Value<atUint32> egmcSecIdx;
Value<atUint32> compressedBlockCount;
Seek<12, athena::Current> align1;
Seek<12, athena::SeekOrigin::Current> align1;
Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes;
};

View File

@ -14,7 +14,7 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::Read>(athena::io::IS
if (extraType == 1)
extraFloat = reader.readFloatBig();
else if (extraType == 2)
reader.seek(35, athena::Current);
reader.seek(35, athena::SeekOrigin::Current);
}
template <>
@ -29,7 +29,7 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::Write>(athena::io::I
if (extraType == 1)
writer.writeFloatBig(extraFloat);
else if (extraType == 2)
writer.seek(35, athena::Current);
writer.seek(35, athena::SeekOrigin::Current);
}
template <>

View File

@ -90,7 +90,7 @@ void PAKBridge::build() {
std::vector<UniqueID64> mapw;
if (worldMapEnt) {
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
rs.seek(8, athena::Current);
rs.seek(8, athena::SeekOrigin::Current);
atUint32 areaCount = rs.readUint32Big();
mapw.reserve(areaCount);
for (atUint32 i = 0; i < areaCount; ++i)

View File

@ -84,7 +84,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 decompLen = drs.length();
mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen);
mreaDecompOut.close();
drs.seek(0, athena::Begin);
drs.seek(0, athena::SeekOrigin::Begin);
/* Start up blender connection */
hecl::blender::Connection& conn = btok.getBlenderConnection();
@ -118,7 +118,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 secStart = drs.position();
matSet.read(drs);
matSet.readToBlender(os, pakRouter, entry, 0);
drs.seek(secStart + head.secSizes[0], athena::Begin);
drs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
std::vector<DNACMDL::VertexAttributes> vertAttribs;
DNACMDL::GetVertexAttributes(matSet, vertAttribs);
@ -131,16 +131,16 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
MeshHeader mHeader;
secStart = drs.position();
mHeader.read(drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Surface count from here */
secStart = drs.position();
surfaceCounts.push_back(drs.readUint32Big());
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Seek through AROT-relation sections */
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
}
/* Skip though WOBJs */
@ -150,13 +150,13 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
/* Skip AROT */
if (secIdxIt->first == FOURCC('ROCT')) {
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt;
}
/* Skip AABB */
if (secIdxIt->first == FOURCC('AABB')) {
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt;
}
@ -173,20 +173,20 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
/* Skip DEPS */
if (secIdxIt->first == FOURCC('DEPS')) {
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt;
}
/* Skip SOBJ (SCLY) */
if (secIdxIt->first == FOURCC('SOBJ')) {
for (atUint32 l = 0; l < head.sclyLayerCount; ++l)
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt;
}
/* Skip SGEN */
if (secIdxIt->first == FOURCC('SGEN')) {
drs.seek(head.secSizes[curSec++], athena::Current);
drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt;
}
@ -197,7 +197,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
collision.read(drs);
DNAMP2::DeafBabe::BlenderInit(os);
collision.sendToBlender(os);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
++secIdxIt;
}
@ -205,7 +205,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
if (secIdxIt->first == FOURCC('LITE')) {
secStart = drs.position();
ReadBabeDeadToBlender_3(os, drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin);
drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
++secIdxIt;
}
@ -231,7 +231,7 @@ bool MREA::ExtractLayerDeps(PAKEntryReadStream& rs, PAKBridge::Level::Area& area
StreamReader drs(rs, head.compressedBlockCount, head.secIndexCount);
for (const std::pair<DNAFourCC, atUint32>& idx : drs.m_secIdxs) {
if (idx.first == FOURCC('DEPS')) {
drs.seek(head.getSecOffset(idx.second), athena::Begin);
drs.seek(head.getSecOffset(idx.second), athena::SeekOrigin::Begin);
DEPS deps;
deps.read(drs);

View File

@ -25,7 +25,7 @@ struct MREA {
Value<atUint32> secCount;
Value<atUint32> compressedBlockCount;
Value<atUint32> secIndexCount;
Seek<20, athena::Current> align1;
Seek<20, athena::SeekOrigin::Current> align1;
Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes;
atUint32 getSecOffset(atUint32 idx) const {

View File

@ -11,11 +11,11 @@ void PAK::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
if (m_header.version != 2)
Log.report(logvisor::Fatal, fmt("unexpected PAK magic"));
reader.seek(8, athena::Current);
reader.seek(8, athena::SeekOrigin::Current);
atUint32 strgSz = reader.readUint32Big();
reader.seek(4, athena::Current);
reader.seek(4, athena::SeekOrigin::Current);
atUint32 rshdSz = reader.readUint32Big();
reader.seek(44, athena::Current);
reader.seek(44, athena::SeekOrigin::Current);
atUint32 dataOffset = 128 + strgSz + rshdSz;
atUint64 strgBase = reader.position();
@ -26,7 +26,7 @@ void PAK::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
m_nameEntries.emplace_back();
m_nameEntries.back().read(reader);
}
reader.seek(strgBase + strgSz, athena::Begin);
reader.seek(strgBase + strgSz, athena::SeekOrigin::Begin);
atUint32 count = reader.readUint32Big();
m_entries.clear();
@ -91,12 +91,12 @@ void PAK::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
atUint32 dataPad = ((dataSz + 63) & ~63) - dataSz;
dataSz += dataPad;
writer.writeUint32Big(dataSz);
writer.seek(36, athena::Current);
writer.seek(36, athena::SeekOrigin::Current);
writer.writeUint32Big((atUint32)m_nameEntries.size());
for (const NameEntry& entry : m_nameEntries)
entry.write(writer);
writer.seek(strgPad, athena::Current);
writer.seek(strgPad, athena::SeekOrigin::Current);
writer.writeUint32Big((atUint32)m_entries.size());
for (const auto& entry : m_entries) {
@ -104,7 +104,7 @@ void PAK::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
copy.offset -= dataOffset;
copy.write(writer);
}
writer.seek(rshdPad, athena::Current);
writer.seek(rshdPad, athena::SeekOrigin::Current);
}
template <>

View File

@ -19,7 +19,7 @@ struct PAK : BigDNA {
Value<atUint32> version;
Value<atUint32> headSz;
Value<atUint8> md5sum[16];
Seek<40, athena::Current> seek;
Seek<40, athena::SeekOrigin::Current> seek;
} m_header;
struct NameEntry : BigDNA {

View File

@ -42,7 +42,7 @@ void STRG::_read(athena::io::IStreamReader& reader) {
for (atUint32 l = 0; l < langCount; ++l) {
std::vector<std::string> strs;
for (atUint32 s = 0; s < strCount; ++s) {
reader.seek(strBase + strOffs[l * strCount + s], athena::Begin);
reader.seek(strBase + strOffs[l * strCount + s], athena::SeekOrigin::Begin);
atUint32 len = reader.readUint32Big();
strs.emplace_back(reader.readString(len));
}

View File

@ -1,7 +1,12 @@
#pragma once
#include <functional>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "hecl/Database.hpp"
#include "hecl/Blender/Token.hpp"

View File

@ -1155,7 +1155,7 @@ struct SpecMP1 : SpecBase {
void writePakFileIndex(athena::io::FileWriter& w, const std::vector<urde::SObjectTag>& tags,
const std::vector<std::tuple<size_t, size_t, bool>>& index, atUint64 resTableOffset) override {
w.seek(resTableOffset, athena::Begin);
w.seek(resTableOffset, athena::SeekOrigin::Begin);
auto it = tags.begin();
for (const auto& item : index) {

View File

@ -129,7 +129,7 @@ bool ProjectManager::openProject(hecl::SystemStringView path) {
}
r.reset();
reader.seek(0, athena::Begin);
reader.seek(0, athena::SeekOrigin::Begin);
if (!r.parse(&reader)) {
return makeProj(true);
}

View File

@ -1,15 +1,20 @@
#pragma once
#include "hecl/ClientProcess.hpp"
#include "hecl/Database.hpp"
#include "Runtime/IFactory.hpp"
#include <list>
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <unordered_map>
#include "DataSpec/SpecBase.hpp"
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/CResFactory.hpp"
#include "DataSpec/SpecBase.hpp"
#include <optional>
#include "Runtime/IFactory.hpp"
#include <thread>
#include <mutex>
#include <hecl/ClientProcess.hpp>
#include <hecl/Database.hpp>
namespace urde {

View File

@ -1,7 +1,7 @@
#pragma once
#include "ProjectResourceFactoryBase.hpp"
#include "CToken.hpp"
#include "Editor/ProjectResourceFactoryBase.hpp"
#include "Runtime/CToken.hpp"
namespace urde {
class MP1OriginalIDs;

View File

@ -42,7 +42,7 @@ public:
GameMode
};
struct State : athena::io::DNAVYaml<athena::Big> {
struct State : athena::io::DNAVYaml<athena::Endian::Big> {
Delete _d;
};
static Space* NewSpaceFromConfigStream(ViewManager& vm, Space* parent, ConfigReader& r);

View File

@ -346,6 +346,7 @@ bool ViewManager::proc() {
if (m_rootSpaceView && m_editorFrames <= 30)
m_rootSpaceView->setMultiplyColor(zeus::CColor::lerp({1, 1, 1, 0}, {1, 1, 1, 1}, m_editorFrames / 30.0));
m_cvarManager.proc();
m_projManager.mainUpdate();
if (m_testGameView)

View File

@ -1,11 +1,15 @@
#pragma once
#include "RetroTypes.hpp"
#include "CFactoryMgr.hpp"
#include "IObj.hpp"
#include "CToken.hpp"
#include "IOStreams.hpp"
#include "amuse/AudioGroupData.hpp"
#include <memory>
#include <string>
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/IObj.hpp"
#include "Runtime/RetroTypes.hpp"
#include <amuse/AudioGroupData.hpp>
namespace urde {

View File

@ -1,15 +1,16 @@
#pragma once
#include "../GCNTypes.hpp"
#include "zeus/CVector3f.hpp"
#include "amuse/amuse.hpp"
#include "boo/audiodev/IAudioVoiceEngine.hpp"
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/GCNTypes.hpp"
#include "Runtime/RetroTypes.hpp"
#include <amuse/amuse.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <zeus/CVector3f.hpp>
namespace urde {
class CSimplePool;
class CAudioGroupSet;
class CSimplePool;
CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
CObjectReference* selfRef);

View File

@ -1,6 +1,8 @@
#pragma once
#include "CSfxManager.hpp"
#include <memory>
#include "Runtime/Audio/CSfxManager.hpp"
namespace urde {

View File

@ -1,10 +1,14 @@
#pragma once
#include <memory>
#include <unordered_set>
#include <vector>
#include "../RetroTypes.hpp"
#include "zeus/CVector3f.hpp"
#include "CAudioSys.hpp"
#include "DNAMP1/SFX/SFX.h"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Audio/CAudioSys.hpp"
#include <zeus/CVector3f.hpp>
namespace urde {

View File

@ -1,10 +1,17 @@
#pragma once
#include "CAudioSys.hpp"
#include "RetroTypes.hpp"
#include <cstring>
#include <memory>
#include <optional>
#include <vector>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Audio/CAudioSys.hpp"
#include "g721.h"
#include "boo/audiodev/IAudioVoice.hpp"
#include "boo/audiodev/IAudioVoiceEngine.hpp"
#include <boo/audiodev/IAudioVoice.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp>
namespace urde {
class IDvdRequest;

View File

@ -862,7 +862,7 @@ void CStreamAudioManager::Start(bool oneshot, std::string_view fileName, float v
SDSPPlayer& p = s_Players[oneshot];
SDSPPlayer& qp = s_QueuedPlayers[oneshot];
if (p.x10_playState != EPlayerState::Stopped && CStringExtras::CompareCaseInsensitive(fileName, p.x0_fileName)) {
if (p.x10_playState != EPlayerState::Stopped && !CStringExtras::CompareCaseInsensitive(fileName, p.x0_fileName)) {
/* Enque new stream */
qp = SDSPPlayer(EPlayerState::FadeIn, fileName, volume, fadeIn, fadeOut, -1, music);
Stop(oneshot, p.x0_fileName);
@ -900,10 +900,10 @@ void CStreamAudioManager::Stop(bool oneshot, std::string_view fileName) {
SDSPPlayer& p = s_Players[oneshot];
SDSPPlayer& qp = s_QueuedPlayers[oneshot];
if (!CStringExtras::CompareCaseInsensitive(fileName, qp.x0_fileName)) {
if (CStringExtras::CompareCaseInsensitive(fileName, qp.x0_fileName)) {
/* Cancel enqueued file */
qp = SDSPPlayer();
} else if (!CStringExtras::CompareCaseInsensitive(fileName, p.x0_fileName) && p.x20_internalHandle != -1 &&
} else if (CStringExtras::CompareCaseInsensitive(fileName, p.x0_fileName) && p.x20_internalHandle != -1 &&
p.x10_playState != EPlayerState::Stopped) {
/* Fade out or stop */
if (p.x1c_fadeOut <= FLT_EPSILON)

View File

@ -1,6 +1,8 @@
#pragma once
#include "RetroTypes.hpp"
#include <string_view>
#include "Runtime/GCNTypes.hpp"
namespace urde {

View File

@ -1,18 +1,28 @@
#pragma once
#include "RetroTypes.hpp"
#include "CInGameTweakManagerBase.hpp"
#include "zeus/CQuaternion.hpp"
#include "zeus/CTransform.hpp"
#include "zeus/CVector3f.hpp"
#include "MP1/CInGameGuiManager.hpp"
#include <list>
#include <memory>
#include <optional>
#include <vector>
#include "Runtime/CInGameTweakManagerBase.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/MP1/CInGameGuiManager.hpp"
#include <zeus/CQuaternion.hpp>
#include <zeus/CTransform.hpp>
#include <zeus/CVector2f.hpp>
#include <zeus/CVector2i.hpp>
#include <zeus/CVector3f.hpp>
namespace urde {
struct CFinalInput;
class IWorld;
class CMapUniverse;
class CMapWorldInfo;
class CStateManager;
class CMapUniverse;
class IWorld;
struct CFinalInput;
class CAutoMapper {
public:

View File

@ -1,13 +1,18 @@
#pragma once
#include "RetroTypes.hpp"
#include "CResFactory.hpp"
#include "zeus/CAABox.hpp"
#include "zeus/CVector3f.hpp"
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
#include "Graphics/CLineRenderer.hpp"
#include "Graphics/Shaders/CMapSurfaceShader.hpp"
#include "CMappableObject.hpp"
#include <memory>
#include <vector>
#include "Runtime/CResFactory.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/AutoMapper/CMappableObject.hpp"
#include "Runtime/Graphics/CLineRenderer.hpp"
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CAABox.hpp>
#include <zeus/CVector3f.hpp>
namespace urde {
class IWorld;

View File

@ -1,12 +1,16 @@
#pragma once
#include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp"
#include "zeus/CColor.hpp"
#include "zeus/CTransform.hpp"
#include "IFactory.hpp"
#include "CToken.hpp"
#include "CMapArea.hpp"
#include <string>
#include <vector>
#include "Runtime/CToken.hpp"
#include "Runtime/IFactory.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/AutoMapper/CMapArea.hpp"
#include <zeus/CColor.hpp>
#include <zeus/CTransform.hpp>
#include <zeus/CVector3f.hpp>
namespace urde {
class CStateManager;

View File

@ -1,16 +1,21 @@
#pragma once
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include "zeus/CColor.hpp"
#include "zeus/CVector3f.hpp"
#include "zeus/CTransform.hpp"
#include "CMapArea.hpp"
#include <vector>
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/AutoMapper/CMapArea.hpp"
#include <zeus/CColor.hpp>
#include <zeus/CTransform.hpp>
#include <zeus/CVector3f.hpp>
namespace urde {
class IWorld;
class CMapWorldInfo;
class CStateManager;
class IWorld;
class CMapWorld {
public:
/* skDrawProfileItemNames; */

View File

@ -1,6 +1,9 @@
#pragma once
#include "RetroTypes.hpp"
#include <map>
#include <vector>
#include "Runtime/RetroTypes.hpp"
namespace urde {
class CSaveWorld;

View File

@ -1,16 +1,20 @@
#pragma once
#include "RetroTypes.hpp"
#include "zeus/CAABox.hpp"
#include "zeus/CTransform.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/Shaders/CMapSurfaceShader.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Graphics/CLineRenderer.hpp"
#include <optional>
#include <utility>
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/CLineRenderer.hpp"
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
#include <zeus/CAABox.hpp>
#include <zeus/CTransform.hpp>
namespace urde {
class CStateManager;
class CMapWorldInfo;
class CStateManager;
class CMappableObject {
static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;

View File

@ -1,8 +1,10 @@
#pragma once
#include "GCNTypes.hpp"
#include "Input/CFinalInput.hpp"
#include "rstl.hpp"
#include <memory>
#include "Runtime/GCNTypes.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/Input/CFinalInput.hpp"
namespace urde {
class CIOWin;

View File

@ -1,7 +1,7 @@
#pragma once
#include <list>
#include "CArchitectureMessage.hpp"
#include "Runtime/CArchitectureMessage.hpp"
namespace urde {

View File

@ -4,7 +4,7 @@
#include <cstdlib>
#include <chrono>
#include "RetroTypes.hpp"
#include "Runtime/GCNTypes.hpp"
namespace urde {

View File

@ -59,16 +59,14 @@ u64 CBasics::GetGCTicks() {
const u64 CBasics::SECONDS_TO_2000 = 946684800LL;
const u64 CBasics::TICKS_PER_SECOND = 60750000LL;
#ifndef _WIN32
static struct tm* localtime_r(const time_t& time, struct tm& timeSt, long& gmtOff) {
#ifndef _WIN32
auto ret = ::localtime_r(&time, &timeSt);
if (!ret)
return nullptr;
gmtOff = ret->tm_gmtoff;
return ret;
}
#else
static struct tm* localtime_r(const time_t& time, struct tm& timeSt, long& gmtOff) {
struct tm _gmSt;
auto reta = localtime_s(&timeSt, &time);
auto retb = gmtime_s(&_gmSt, &time);
@ -76,8 +74,8 @@ static struct tm* localtime_r(const time_t& time, struct tm& timeSt, long& gmtOf
return nullptr;
gmtOff = mktime(&timeSt) - mktime(&_gmSt);
return &timeSt;
}
#endif
}
OSTime CBasics::ToWiiTime(std::chrono::system_clock::time_point time) {
auto sec = std::chrono::time_point_cast<std::chrono::seconds>(time);

View File

@ -1,8 +1,10 @@
#include "CCRC32.hpp"
#include "Runtime/CCRC32.hpp"
#include <array>
namespace urde {
const uint32_t CCRC32::crc32Table[256] = {
namespace {
constexpr std::array<uint32_t, 256> crc32Table{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832,
0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A,
@ -31,14 +33,19 @@ const uint32_t CCRC32::crc32Table[256] = {
0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330,
0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D};
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D,
};
constexpr uint32_t permute(uint32_t checksum, uint8_t b) { return (checksum >> 8) ^ crc32Table[(checksum & 0xFF) ^ b]; }
} // Anonymous namespace
uint32_t CCRC32::Calculate(const void* data, uint32_t length) {
if (!data || length == 0)
if (data == nullptr || length == 0) {
return 0;
}
uint32_t checksum = 0xFFFFFFFF;
const uint8_t* buf = reinterpret_cast<const uint8_t*>(data);
const uint8_t* buf = static_cast<const uint8_t*>(data);
uint32_t words = length / 4;
while ((words--) > 0) {
checksum = permute(checksum, *buf++);
@ -48,8 +55,9 @@ uint32_t CCRC32::Calculate(const void* data, uint32_t length) {
}
uint32_t rem = length % 4;
while ((rem--) > 0)
while ((rem--) > 0) {
checksum = permute(checksum, *buf++);
}
return checksum;
}

View File

@ -1,14 +1,10 @@
#pragma once
#include <cstdint>
namespace urde {
class CCRC32 {
static const uint32_t crc32Table[256];
static uint32_t permute(uint32_t checksum, uint8_t b) {
return (checksum >> 8) ^ crc32Table[(checksum & 0xFF) ^ b];
}
public:
static uint32_t Calculate(const void* data, uint32_t length);
};

View File

@ -1,6 +1,7 @@
#pragma once
#include "CFactoryMgr.hpp"
#include <vector>
#include "Runtime/CFactoryMgr.hpp"
namespace urde {
class CDependencyGroup {

View File

@ -1,13 +1,18 @@
#pragma once
#include "RetroTypes.hpp"
#include "athena/FileReader.hpp"
#include <thread>
#include <mutex>
#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <unordered_map>
#include "Runtime/GCNTypes.hpp"
#include "Runtime/RetroTypes.hpp"
#include <athena/FileReader.hpp>
namespace urde {
enum class ESeekOrigin { Begin = 0, Cur = 1, End = 2 };

View File

@ -1,9 +1,10 @@
#pragma once
#include <unordered_map>
#include "RetroTypes.hpp"
#include "IOStreams.hpp"
#include "IFactory.hpp"
#include "Runtime/IFactory.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
struct SObjectTag;

View File

@ -1,6 +1,10 @@
#pragma once
#include "RetroTypes.hpp"
#include <cstddef>
#include <memory>
#include <vector>
#include "Runtime/RetroTypes.hpp"
namespace urde {
class CGameAllocator {

View File

@ -1,7 +1,10 @@
#pragma once
#include "RetroTypes.hpp"
#include "IFactory.hpp"
#include <string_view>
#include <vector>
#include "Runtime/IFactory.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
class CGameHintInfo {

View File

@ -1,9 +1,11 @@
#pragma once
#include <array>
#include "RetroTypes.hpp"
#include "Audio/CAudioSys.hpp"
#include "CSaveWorld.hpp"
#include <vector>
#include "Runtime/CSaveWorld.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Audio/CAudioSys.hpp"
namespace urde {
struct CFinalInput;

View File

@ -1,7 +1,7 @@
#pragma once
#include <utility>
#include <memory>
#include <utility>
namespace urde {

View File

@ -1,15 +1,18 @@
#pragma once
#include <memory>
#include "CBasics.hpp"
#include "CPlayerState.hpp"
#include "CGameOptions.hpp"
#include "CRelayTracker.hpp"
#include "World/CWorldTransManager.hpp"
#include "AutoMapper/CMapWorldInfo.hpp"
#include "World/CWorld.hpp"
#include <vector>
#include "DataSpec/DNACommon/DNACommon.hpp"
#include "Runtime/CBasics.hpp"
#include "Runtime/CGameOptions.hpp"
#include "Runtime/CPlayerState.hpp"
#include "Runtime/CRelayTracker.hpp"
#include "Runtime/AutoMapper/CMapWorldInfo.hpp"
#include "Runtime/World/CWorld.hpp"
#include "Runtime/World/CWorldTransManager.hpp"
namespace urde {
class CSaveWorldMemory;

View File

@ -1,9 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include <memory>
#include <string>
#include "RetroTypes.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
class CArchitectureMessage;

View File

@ -1,10 +1,11 @@
#pragma once
#include <memory>
#include <list>
#include "CIOWin.hpp"
#include "rstl.hpp"
#include "CArchitectureQueue.hpp"
#include <memory>
#include "Runtime/CArchitectureQueue.hpp"
#include "Runtime/CIOWin.hpp"
#include "Runtime/rstl.hpp"
namespace urde {

View File

@ -3,7 +3,7 @@
#include <string>
#include <vector>
#include "RetroTypes.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {

View File

@ -1,6 +1,6 @@
#pragma once
#include "CIOWin.hpp"
#include "Runtime/CIOWin.hpp"
namespace urde {

View File

@ -1,6 +1,6 @@
#pragma once
#include "CIOWin.hpp"
#include "Runtime/CIOWin.hpp"
namespace urde {

View File

@ -11,7 +11,7 @@ namespace urde {
using ECardResult = kabufuda::ECardResult;
static kabufuda::SystemString g_CardImagePaths[2] = {};
static kabufuda::Card g_CardStates[2] = {{"GM8E", "01"}, {"GM8E", "01"}};
static kabufuda::Card g_CardStates[2] = {kabufuda::Card{"GM8E", "01"}, kabufuda::Card{"GM8E", "01"}};
// static kabufuda::ECardResult g_OpResults[2] = {};
CSaveWorldIntermediate::CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw) : x0_mlvlId(mlvl), x8_savwId(savw) {

View File

@ -1,17 +1,23 @@
#pragma once
#include "CToken.hpp"
#include "World/CWorld.hpp"
#include "CGameHintInfo.hpp"
#include "CSaveWorld.hpp"
#include "GuiSys/CStringTable.hpp"
#include "kabufuda/Card.hpp"
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "Runtime/CGameHintInfo.hpp"
#include "Runtime/CSaveWorld.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/GuiSys/CStringTable.hpp"
#include "Runtime/World/CWorld.hpp"
#include <kabufuda/Card.hpp>
namespace urde {
class CDummyWorld;
class CStringTable;
class CSimplePool;
class CStringTable;
class CSaveWorldMemory {
friend class CMemoryCardSys;

View File

@ -1,7 +1,7 @@
#pragma once
#include "World/CEntity.hpp"
#include "RetroTypes.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CEntity.hpp"
namespace urde {

View File

@ -18,9 +18,11 @@ CPakFile::~CPakFile() {
}
const SObjectTag* CPakFile::GetResIdByName(std::string_view name) const {
for (const std::pair<std::string, SObjectTag>& p : x54_nameList)
if (!CStringExtras::CompareCaseInsensitive(p.first.c_str(), name))
for (const std::pair<std::string, SObjectTag>& p : x54_nameList) {
if (CStringExtras::CompareCaseInsensitive(p.first, name)) {
return &p.second;
}
}
return nullptr;
}

View File

@ -1,11 +1,14 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "RetroTypes.hpp"
#include "CStringExtras.hpp"
#include "CDvdFile.hpp"
#include "CDvdRequest.hpp"
#include "CFactoryMgr.hpp"
#include "Runtime/CDvdFile.hpp"
#include "Runtime/CDvdRequest.hpp"
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/CStringExtras.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {

View File

@ -1,7 +1,7 @@
#pragma once
#include "CIOWin.hpp"
#include "Graphics/CMoviePlayer.hpp"
#include "Runtime/CIOWin.hpp"
#include "Runtime/Graphics/CMoviePlayer.hpp"
namespace urde {

View File

@ -1,18 +1,26 @@
#include "CPlayerState.hpp"
#include "IOStreams.hpp"
#include "zeus/Math.hpp"
#include "CStateManager.hpp"
#include "Camera/CCameraManager.hpp"
#include "Camera/CFirstPersonCamera.hpp"
#include "CMemoryCardSys.hpp"
#include "GameGlobalObjects.hpp"
#include "TCastTo.hpp"
#include "Runtime/CPlayerState.hpp"
#include <algorithm>
#include <array>
#include "Runtime/CMemoryCardSys.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/Camera/CCameraManager.hpp"
#include "Runtime/Camera/CFirstPersonCamera.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
#include <zeus/Math.hpp>
namespace urde {
const u32 CPlayerState::PowerUpMaxValues[41] = {1, 1, 1, 1, 250, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
namespace {
constexpr std::array<u32, 41> PowerUpMaxValues{
1, 1, 1, 1, 250, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
};
const char* CPlayerState::PowerUpNames[41] = {
[[maybe_unused]] constexpr std::array<const char*, 41> PowerUpNames{
"Power Beam",
"Ice Beam",
"Wave Beam",
@ -56,6 +64,15 @@ const char* CPlayerState::PowerUpNames[41] = {
"Artifact of Newborn",
};
constexpr std::array<u32, 5> costs{
5, 10, 10, 10, 1,
};
constexpr std::array<float, 5> ComboAmmoPeriods{
0.2f, 0.1f, 0.2f, 0.2f, 1.f,
};
} // Anonymous namespace
CPlayerState::CPlayerState() : x188_staticIntf(5) {
x0_24_alive = true;
x24_powerups.resize(41);
@ -73,12 +90,13 @@ CPlayerState::CPlayerState(CBitStreamReader& stream) : x188_staticIntf(5) {
x8_currentBeam = EBeamId(stream.ReadEncoded(CBitStreamReader::GetBitCount(5)));
x20_currentSuit = EPlayerSuit(stream.ReadEncoded(CBitStreamReader::GetBitCount(4)));
x24_powerups.resize(41);
for (u32 i = 0; i < x24_powerups.size(); ++i) {
if (PowerUpMaxValues[i] == 0)
for (size_t i = 0; i < x24_powerups.size(); ++i) {
if (PowerUpMaxValues[i] == 0) {
continue;
}
u32 a = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
u32 b = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
const u32 a = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
const u32 b = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
x24_powerups[i] = CPowerUp(a, b);
}
@ -103,7 +121,7 @@ void CPlayerState::PutTo(CBitStreamWriter& stream) {
stream.WriteEncoded(hp.iHP, 32);
stream.WriteEncoded(u32(x8_currentBeam), CBitStreamWriter::GetBitCount(5));
stream.WriteEncoded(u32(x20_currentSuit), CBitStreamWriter::GetBitCount(4));
for (u32 i = 0; i < x24_powerups.size(); ++i) {
for (size_t i = 0; i < x24_powerups.size(); ++i) {
const CPowerUp& pup = x24_powerups[i];
stream.WriteEncoded(pup.x0_amount, CBitStreamWriter::GetBitCount(PowerUpMaxValues[i]));
stream.WriteEncoded(pup.x4_capacity, CBitStreamWriter::GetBitCount(PowerUpMaxValues[i]));
@ -120,13 +138,9 @@ void CPlayerState::PutTo(CBitStreamWriter& stream) {
stream.WriteEncoded(x180_scanCompletionRate.second, CBitStreamWriter::GetBitCount(0x100));
}
static const u32 costs[] = {5, 10, 10, 10, 1};
u32 CPlayerState::GetMissileCostForAltAttack() const { return costs[size_t(x8_currentBeam)]; }
u32 CPlayerState::GetMissileCostForAltAttack() const { return costs[u32(x8_currentBeam)]; }
static const float ComboAmmoPeriods[] = {0.2f, 0.1f, 0.2f, 0.2f, 1.f};
float CPlayerState::GetComboFireAmmoPeriod() const { return ComboAmmoPeriods[u32(x8_currentBeam)]; }
float CPlayerState::GetComboFireAmmoPeriod() const { return ComboAmmoPeriods[size_t(x8_currentBeam)]; }
u32 CPlayerState::CalculateItemCollectionRate() const {
u32 total = GetItemCapacity(EItemType::PowerBombs);
@ -373,6 +387,8 @@ void CPlayerState::InitializeScanTimes() {
x170_scanTimes.emplace_back(state.first, 0.f);
}
u32 CPlayerState::GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[size_t(type)]; }
const std::unordered_map<std::string_view, CPlayerState::EItemType> CPlayerState::g_TypeNameMap = {
{"powerbeam"sv, EItemType::PowerBeam},
{"icebeam"sv, EItemType::IceBeam},

View File

@ -1,12 +1,14 @@
#pragma once
#include "RetroTypes.hpp"
#include "CBasics.hpp"
#include "CStaticInterference.hpp"
#include "IOStreams.hpp"
#include "rstl.hpp"
#include "World/CHealthInfo.hpp"
#include <string_view>
#include <unordered_map>
#include <vector>
#include "Runtime/CStaticInterference.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/World/CHealthInfo.hpp"
namespace urde {
@ -88,8 +90,6 @@ public:
private:
static const std::unordered_map<std::string_view, EItemType> g_TypeNameMap;
static const u32 PowerUpMaxValues[41];
static const char* PowerUpNames[41];
struct CPowerUp {
u32 x0_amount = 0;
u32 x4_capacity = 0;
@ -174,7 +174,7 @@ public:
CPlayerState();
CPlayerState(CBitStreamReader& stream);
void PutTo(CBitStreamWriter& stream);
static u32 GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; }
static u32 GetPowerUpMaxValue(EItemType type);
static EItemType ItemNameToType(std::string_view name);
bool CanTakeDamage() const { return m_canTakeDamage; }
void SetCanTakeDamage(bool c) { m_canTakeDamage = c; }

View File

@ -1,6 +1,6 @@
#pragma once
#include "GCNTypes.hpp"
#include "Runtime/GCNTypes.hpp"
namespace urde {

View File

@ -1,12 +1,15 @@
#pragma once
#include "IOStreams.hpp"
#include "World/ScriptObjectSupport.hpp"
#include "RetroTypes.hpp"
#include <vector>
#include "Runtime/IOStreams.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/World/ScriptObjectSupport.hpp"
namespace urde {
class CStateManager;
class CSaveWorld;
class CStateManager;
#if 0
struct CMailMessage
{

View File

@ -1,10 +1,15 @@
#pragma once
#include <list>
#include <memory>
#include <unordered_map>
#include "IFactory.hpp"
#include "CResLoader.hpp"
#include "IVParamObj.hpp"
#include "CToken.hpp"
#include <vector>
#include "Runtime/CResLoader.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/IFactory.hpp"
#include "Runtime/IVParamObj.hpp"
#include "Runtime/MP1/MP1OriginalIDs.hpp"
namespace urde {
class IDvdRequest;

View File

@ -7,17 +7,19 @@ static logvisor::Module Log("CResLoader");
CResLoader::CResLoader() { x48_curPak = x18_pakLoadedList.end(); }
const std::vector<CAssetId>* CResLoader::GetTagListForFile(std::string_view name) const {
std::string namePak = std::string(name) + ".upak";
for (const std::unique_ptr<CPakFile>& pak : x18_pakLoadedList)
if (!CStringExtras::CompareCaseInsensitive(namePak, pak->x18_path))
const std::string namePak = std::string(name).append(".upak");
for (const std::unique_ptr<CPakFile>& pak : x18_pakLoadedList) {
if (CStringExtras::CompareCaseInsensitive(namePak, pak->x18_path)) {
return &pak->GetDepList();
}
}
return nullptr;
}
void CResLoader::AddPakFileAsync(std::string_view name, bool buildDepList, bool worldPak) {
std::string namePak = std::string(name) + ".upak";
if (CDvdFile::FileExists(namePak.c_str())) {
x30_pakLoadingList.emplace_back(new CPakFile(namePak, buildDepList, worldPak));
const std::string namePak = std::string(name).append(".upak");
if (CDvdFile::FileExists(namePak)) {
x30_pakLoadingList.emplace_back(std::make_unique<CPakFile>(namePak, buildDepList, worldPak));
++x44_pakLoadingCount;
}
}
@ -35,11 +37,13 @@ void CResLoader::WaitForPakFileLoadingComplete() {
std::unique_ptr<CInputStream> CResLoader::LoadNewResourcePartSync(const SObjectTag& tag, u32 length, u32 offset,
void* extBuf) {
void* buf = extBuf;
CPakFile* file = FindResourceForLoad(tag);
if (!buf)
if (buf == nullptr) {
buf = new u8[length];
}
CPakFile* const file = FindResourceForLoad(tag);
file->SyncSeekRead(buf, length, ESeekOrigin::Begin, x50_cachedResInfo->GetOffset() + offset);
return std::unique_ptr<CInputStream>(new athena::io::MemoryReader((atUint8*)buf, length, !extBuf));
return std::make_unique<athena::io::MemoryReader>(buf, length, !extBuf);
}
void CResLoader::LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]>& bufOut, int* sizeOut) {
@ -52,29 +56,36 @@ void CResLoader::LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]
std::unique_ptr<CInputStream> CResLoader::LoadResourceFromMemorySync(const SObjectTag& tag, const void* buf) {
FindResourceForLoad(tag);
CInputStream* newStrm = new athena::io::MemoryReader((atUint8*)buf, x50_cachedResInfo->GetSize());
std::unique_ptr<CInputStream> newStrm = std::make_unique<athena::io::MemoryReader>(buf, x50_cachedResInfo->GetSize());
if (x50_cachedResInfo->IsCompressed()) {
newStrm->readUint32Big();
newStrm = new CZipInputStream(std::unique_ptr<CInputStream>(newStrm));
newStrm = std::make_unique<CZipInputStream>(std::move(newStrm));
}
return std::unique_ptr<CInputStream>(newStrm);
return newStrm;
}
std::unique_ptr<CInputStream> CResLoader::LoadNewResourceSync(const SObjectTag& tag, void* extBuf) {
void* buf = extBuf;
if (CPakFile* file = FindResourceForLoad(tag)) {
size_t resSz = ROUND_UP_32(x50_cachedResInfo->GetSize());
if (!buf)
if (CPakFile* const file = FindResourceForLoad(tag)) {
const size_t resSz = ROUND_UP_32(x50_cachedResInfo->GetSize());
void* buf = extBuf;
if (buf == nullptr) {
buf = new u8[resSz];
}
file->SyncSeekRead(buf, resSz, ESeekOrigin::Begin, x50_cachedResInfo->GetOffset());
CInputStream* newStrm = new athena::io::MemoryReader((atUint8*)buf, resSz, !extBuf);
const bool takeOwnership = extBuf == nullptr;
std::unique_ptr<CInputStream> newStrm = std::make_unique<athena::io::MemoryReader>(buf, resSz, takeOwnership);
if (x50_cachedResInfo->IsCompressed()) {
newStrm->readUint32Big();
newStrm = new CZipInputStream(std::unique_ptr<CInputStream>(newStrm));
newStrm = std::make_unique<CZipInputStream>(std::move(newStrm));
}
return std::unique_ptr<CInputStream>(newStrm);
return newStrm;
}
return {};
return nullptr;
}
std::shared_ptr<IDvdRequest> CResLoader::LoadResourcePartAsync(const SObjectTag& tag, u32 off, u32 size, void* buf) {
@ -106,7 +117,7 @@ std::unique_ptr<u8[]> CResLoader::LoadNewResourcePartSync(const urde::SObjectTag
void CResLoader::GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const {
std::string path = std::string(pakName) + ".upak";
for (const std::unique_ptr<CPakFile>& file : x18_pakLoadedList) {
if (!CStringExtras::CompareCaseInsensitive(file->GetPath(), path)) {
if (CStringExtras::CompareCaseInsensitive(file->GetPath(), path)) {
auto& depList = file->GetDepList();
out.reserve(depList.size());
for (const auto& dep : depList) {

View File

@ -1,14 +1,18 @@
#pragma once
#include <functional>
#include <list>
#include <memory>
#include <string>
#include "RetroTypes.hpp"
#include "CPakFile.hpp"
#include "IOStreams.hpp"
#include <vector>
#include "Runtime/CPakFile.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
struct SObjectTag;
class IDvdRequest;
struct SObjectTag;
class CResLoader {
std::string m_loaderPath;

View File

@ -1,8 +1,11 @@
#pragma once
#include "RetroTypes.hpp"
#include <vector>
#include "DNACommon/SAVWCommon.hpp"
#include "CFactoryMgr.hpp"
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {

View File

@ -1,9 +1,11 @@
#pragma once
#include "RetroTypes.hpp"
#include "IFactory.hpp"
#include "CToken.hpp"
#include "zeus/CVector2i.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/IFactory.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp"
#include <zeus/CVector2i.hpp>
namespace urde {
class CScannableObjectInfo {

View File

@ -11,15 +11,17 @@ CSimplePool::CSimplePool(IFactory& factory)
CSimplePool::~CSimplePool() { assert(x8_resources.empty() && "Dangling CSimplePool resources detected"); }
CToken CSimplePool::GetObj(const SObjectTag& tag, const CVParamTransfer& paramXfer) {
if (!tag)
if (!tag) {
return {};
}
auto iter = x8_resources.find(tag);
if (iter != x8_resources.end())
const auto iter = x8_resources.find(tag);
if (iter != x8_resources.end()) {
return CToken(iter->second);
}
CObjectReference* ret = new CObjectReference(*this, std::unique_ptr<IObj>(), tag, paramXfer);
x8_resources.emplace(std::make_pair<SObjectTag, CObjectReference*>((SObjectTag)tag, std::move(ret)));
auto* const ret = new CObjectReference(*this, nullptr, tag, paramXfer);
x8_resources.emplace(tag, ret);
return CToken(ret);
}

View File

@ -1,13 +1,15 @@
#pragma once
#include "IObjectStore.hpp"
#include "RetroTypes.hpp"
#include "IVParamObj.hpp"
#include <unordered_map>
#include <vector>
#include "Runtime/IObjectStore.hpp"
#include "Runtime/IVParamObj.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
class IFactory;
class CObjectReference;
class IFactory;
class CSimplePool : public IObjectStore {
protected:

View File

@ -1,20 +1,32 @@
#include "CSortedLists.hpp"
#include "World/CActor.hpp"
#include "Runtime/CSortedLists.hpp"
#include <algorithm>
#include <cassert>
#include "Runtime/World/CActor.hpp"
namespace urde {
namespace {
template <typename T, typename S>
static std::remove_reference_t<decltype(std::declval<T>()[0])>& AccessElement(T& arr, S idx) {
assert(std::extent<T>::value > idx && idx >= 0);
auto AccessElement(T& arr, S idx) -> typename T::reference {
assert(std::size(arr) > static_cast<size_t>(idx) && idx >= 0);
return arr[idx];
}
template <typename T, typename S>
auto AccessElement(const T& arr, S idx) -> typename T::const_reference {
assert(std::size(arr) > static_cast<size_t>(idx) && idx >= 0);
return arr[idx];
}
} // Anonymous namespace
CSortedListManager::CSortedListManager() { Reset(); }
void CSortedListManager::Reset() {
std::fill(std::begin(x0_nodes), std::end(x0_nodes), SNode());
for (int i = 0; i < 6; ++i)
xb000_sortedLists[i].Reset();
x0_nodes.fill(SNode{});
for (auto& list : xb000_sortedLists) {
list.Reset();
}
}
void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) const {
@ -33,32 +45,39 @@ void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) c
}
void CSortedListManager::RemoveFromList(ESortedList list, s16 idx) {
SSortedList& sl = xb000_sortedLists[u32(list)];
const auto listIndex = static_cast<size_t>(list);
SSortedList& sl = xb000_sortedLists[listIndex];
while (idx < sl.x800_size - 1) {
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + 1)).x1c_selfIdxs[int(list)] = idx;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + 1)).x1c_selfIdxs[listIndex] = idx;
AccessElement(sl.x0_ids, idx) = AccessElement(sl.x0_ids, idx + 1);
++idx;
}
--sl.x800_size;
}
void CSortedListManager::MoveInList(ESortedList list, s16 idx) {
SSortedList& sl = xb000_sortedLists[int(list)];
const auto listIndex = static_cast<size_t>(list);
SSortedList& sl = xb000_sortedLists[listIndex];
while (true) {
if (idx > 0 && AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx - 1)).x4_box[int(list)] >
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x4_box[int(list)]) {
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx - 1)).x1c_selfIdxs[int(list)] = idx;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x1c_selfIdxs[int(list)] = idx - 1;
if (idx > 0 && AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx - 1)).x4_box[listIndex] >
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x4_box[listIndex]) {
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx - 1)).x1c_selfIdxs[listIndex] = idx;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x1c_selfIdxs[listIndex] = idx - 1;
std::swap(AccessElement(sl.x0_ids, idx), AccessElement(sl.x0_ids, idx - 1));
--idx;
} else {
if (idx >= sl.x800_size - 1)
if (idx >= sl.x800_size - 1) {
return;
if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + 1)).x4_box[int(list)] >=
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x4_box[int(list)])
}
if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + 1)).x4_box[listIndex] >=
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x4_box[listIndex]) {
return;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + 1)).x1c_selfIdxs[int(list)] = idx;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x1c_selfIdxs[int(list)] = idx + 1;
}
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + 1)).x1c_selfIdxs[listIndex] = idx;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx)).x1c_selfIdxs[listIndex] = idx + 1;
std::swap(AccessElement(sl.x0_ids, idx), AccessElement(sl.x0_ids, idx + 1));
++idx;
}
@ -66,11 +85,13 @@ void CSortedListManager::MoveInList(ESortedList list, s16 idx) {
}
void CSortedListManager::InsertInList(ESortedList list, SNode& node) {
SSortedList& sl = xb000_sortedLists[int(list)];
const auto listIndex = static_cast<size_t>(list);
SSortedList& sl = xb000_sortedLists[listIndex];
int insIdx = 0;
for (int i = sl.x800_size; i > 0;) {
/* Binary search cycle to find insert index */
if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, insIdx + i / 2)).x4_box[int(list)] < node.x4_box[int(list)]) {
if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, insIdx + i / 2)).x4_box[listIndex] < node.x4_box[listIndex]) {
/* Upper */
insIdx = insIdx + i / 2 + 1;
i = i - i / 2 - 1;
@ -82,22 +103,24 @@ void CSortedListManager::InsertInList(ESortedList list, SNode& node) {
/* Shift ids for insert */
for (int i = sl.x800_size; i > insIdx; --i) {
AccessElement(x0_nodes, AccessElement(sl.x0_ids, i - 1)).x1c_selfIdxs[int(list)] = i;
AccessElement(x0_nodes, AccessElement(sl.x0_ids, i - 1)).x1c_selfIdxs[listIndex] = i;
AccessElement(sl.x0_ids, i) = AccessElement(sl.x0_ids, i - 1);
}
/* Do insert */
AccessElement(sl.x0_ids, insIdx) = node.x0_actor->GetUniqueId().Value();
node.x1c_selfIdxs[int(list)] = s16(insIdx);
node.x1c_selfIdxs[listIndex] = s16(insIdx);
++sl.x800_size;
}
s16 CSortedListManager::FindInListUpper(ESortedList list, float val) const {
const SSortedList& sl = xb000_sortedLists[int(list)];
const auto listIndex = static_cast<size_t>(list);
const SSortedList& sl = xb000_sortedLists[listIndex];
int idx = 0;
for (int i = sl.x800_size; i > 0;) {
/* Binary search cycle to find index */
if (!(val < AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[int(list)])) {
if (!(val < AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[listIndex])) {
/* Upper */
idx = idx + i / 2 + 1;
i = i - i / 2 - 1;
@ -106,15 +129,18 @@ s16 CSortedListManager::FindInListUpper(ESortedList list, float val) const {
i /= 2;
}
}
return idx;
}
s16 CSortedListManager::FindInListLower(ESortedList list, float val) const {
const SSortedList& sl = xb000_sortedLists[int(list)];
const auto listIndex = static_cast<size_t>(list);
const SSortedList& sl = xb000_sortedLists[listIndex];
int idx = 0;
for (int i = sl.x800_size; i > 0;) {
/* Binary search cycle to find index */
if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[int(list)] < val) {
if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[listIndex] < val) {
/* Upper */
idx = idx + i / 2 + 1;
i = i - i / 2 - 1;
@ -123,27 +149,28 @@ s16 CSortedListManager::FindInListLower(ESortedList list, float val) const {
i /= 2;
}
}
return idx;
}
s16 CSortedListManager::ConstructIntersectionArray(const zeus::CAABox& aabb) {
int minXa = FindInListLower(ESortedList::MinX, aabb.min.x());
int maxXa = FindInListUpper(ESortedList::MinX, aabb.max.x());
int minXb = FindInListLower(ESortedList::MaxX, aabb.min.x());
int maxXb = FindInListUpper(ESortedList::MaxX, aabb.max.x());
int xEnd = std::min(int(xb000_sortedLists[3].x800_size) - maxXb, minXa) + (maxXb + (maxXa - minXa) - minXb) / 2;
const int minXa = FindInListLower(ESortedList::MinX, aabb.min.x());
const int maxXa = FindInListUpper(ESortedList::MinX, aabb.max.x());
const int minXb = FindInListLower(ESortedList::MaxX, aabb.min.x());
const int maxXb = FindInListUpper(ESortedList::MaxX, aabb.max.x());
const int xEnd = std::min(int(xb000_sortedLists[3].x800_size) - maxXb, minXa) + (maxXb + (maxXa - minXa) - minXb) / 2;
int minYa = FindInListLower(ESortedList::MinY, aabb.min.y());
int maxYa = FindInListUpper(ESortedList::MinY, aabb.max.y());
int minYb = FindInListLower(ESortedList::MaxY, aabb.min.y());
int maxYb = FindInListUpper(ESortedList::MaxY, aabb.max.y());
int yEnd = std::min(int(xb000_sortedLists[4].x800_size) - maxYb, minYa) + (maxYb + (maxYa - minYa) - minYb) / 2;
const int minYa = FindInListLower(ESortedList::MinY, aabb.min.y());
const int maxYa = FindInListUpper(ESortedList::MinY, aabb.max.y());
const int minYb = FindInListLower(ESortedList::MaxY, aabb.min.y());
const int maxYb = FindInListUpper(ESortedList::MaxY, aabb.max.y());
const int yEnd = std::min(int(xb000_sortedLists[4].x800_size) - maxYb, minYa) + (maxYb + (maxYa - minYa) - minYb) / 2;
int minZa = FindInListLower(ESortedList::MinZ, aabb.min.z());
int maxZa = FindInListUpper(ESortedList::MinZ, aabb.max.z());
int minZb = FindInListLower(ESortedList::MaxZ, aabb.min.z());
int maxZb = FindInListUpper(ESortedList::MaxZ, aabb.max.z());
int zEnd = std::min(int(xb000_sortedLists[5].x800_size) - maxZb, minZa) + (maxZb + (maxZa - minZa) - minZb) / 2;
const int minZa = FindInListLower(ESortedList::MinZ, aabb.min.z());
const int maxZa = FindInListUpper(ESortedList::MinZ, aabb.max.z());
const int minZb = FindInListLower(ESortedList::MaxZ, aabb.min.z());
const int maxZb = FindInListUpper(ESortedList::MaxZ, aabb.max.z());
const int zEnd = std::min(int(xb000_sortedLists[5].x800_size) - maxZb, minZa) + (maxZb + (maxZa - minZa) - minZb) / 2;
if (xEnd < yEnd && xEnd < zEnd) {
return CalculateIntersections(ESortedList::MinX, ESortedList::MaxX, minXa, maxXa, minXb, maxXb, ESortedList::MinY,
@ -160,31 +187,38 @@ s16 CSortedListManager::ConstructIntersectionArray(const zeus::CAABox& aabb) {
s16 CSortedListManager::CalculateIntersections(ESortedList la, ESortedList lb, s16 a, s16 b, s16 c, s16 d,
ESortedList slA, ESortedList slB, ESortedList slC, ESortedList slD,
const zeus::CAABox& aabb) {
const auto listAIndex = static_cast<size_t>(la);
const auto listBIndex = static_cast<size_t>(lb);
s16 headId = -1;
s16 tailId = -1;
for (int i = a; i < b; ++i)
AddToLinkedList(AccessElement(xb000_sortedLists[int(la)].x0_ids, i), headId, tailId);
for (int i = c; i < d; ++i)
AddToLinkedList(AccessElement(xb000_sortedLists[int(lb)].x0_ids, i), headId, tailId);
for (int i = a; i < b; ++i) {
AddToLinkedList(AccessElement(xb000_sortedLists[listAIndex].x0_ids, i), headId, tailId);
}
for (int i = c; i < d; ++i) {
AddToLinkedList(AccessElement(xb000_sortedLists[listBIndex].x0_ids, i), headId, tailId);
}
if (a < xb000_sortedLists[int(lb)].x800_size - d) {
if (a < xb000_sortedLists[listBIndex].x800_size - d) {
for (int i = 0; i < a; ++i) {
s16 id = AccessElement(xb000_sortedLists[int(la)].x0_ids, i);
if (AccessElement(x0_nodes, id).x4_box[int(lb)] > aabb[int(lb)])
const s16 id = AccessElement(xb000_sortedLists[listAIndex].x0_ids, i);
if (AccessElement(x0_nodes, id).x4_box[listBIndex] > aabb[listBIndex]) {
AddToLinkedList(id, headId, tailId);
}
}
} else {
for (int i = d; i < xb000_sortedLists[int(lb)].x800_size; ++i) {
s16 id = AccessElement(xb000_sortedLists[int(lb)].x0_ids, i);
if (AccessElement(x0_nodes, id).x4_box[int(la)] < aabb[int(la)])
for (int i = d; i < xb000_sortedLists[listBIndex].x800_size; ++i) {
const s16 id = AccessElement(xb000_sortedLists[listBIndex].x0_ids, i);
if (AccessElement(x0_nodes, id).x4_box[listAIndex] < aabb[listAIndex]) {
AddToLinkedList(id, headId, tailId);
}
}
}
for (s16* id = &headId; *id != -1;) {
SNode& node = AccessElement(x0_nodes, *id);
if (node.x4_box[int(slA)] > aabb[int(slB)] || node.x4_box[int(slB)] < aabb[int(slA)] ||
node.x4_box[int(slC)] > aabb[int(slD)] || node.x4_box[int(slD)] < aabb[int(slC)]) {
if (node.x4_box[size_t(slA)] > aabb[size_t(slB)] || node.x4_box[size_t(slB)] < aabb[size_t(slA)] ||
node.x4_box[size_t(slC)] > aabb[size_t(slD)] || node.x4_box[size_t(slD)] < aabb[size_t(slC)]) {
/* Not intersecting; remove from chain */
*id = node.x28_next;
node.x28_next = -1;

View File

@ -1,16 +1,19 @@
#pragma once
#include "RetroTypes.hpp"
#include "zeus/CAABox.hpp"
#include "Collision/CMaterialFilter.hpp"
#include <array>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Collision/CMaterialFilter.hpp"
#include <zeus/CAABox.hpp>
namespace urde {
enum ESortedList { MinX, MinY, MinZ, MaxX, MaxY, MaxZ };
enum class ESortedList { MinX, MinY, MinZ, MaxX, MaxY, MaxZ };
struct SSortedList {
s16 x0_ids[1024];
std::array<s16, 1024> x0_ids;
u32 x800_size = 0;
void Reset() { std::fill(std::begin(x0_ids), std::end(x0_ids), -1); }
void Reset() { x0_ids.fill(-1); }
SSortedList() { Reset(); }
};
@ -19,14 +22,14 @@ class CSortedListManager {
struct SNode {
const CActor* x0_actor = nullptr;
zeus::CAABox x4_box = zeus::skNullBox;
s16 x1c_selfIdxs[6] = {-1, -1, -1, -1, -1, -1};
std::array<s16, 6> x1c_selfIdxs{-1, -1, -1, -1, -1, -1};
s16 x28_next = -1;
bool x2a_populated = false;
SNode() = default;
SNode(const CActor* act, const zeus::CAABox& aabb) : x0_actor(act), x4_box(aabb), x2a_populated(true) {}
};
SNode x0_nodes[1024];
SSortedList xb000_sortedLists[6];
std::array<SNode, 1024> x0_nodes;
std::array<SSortedList, 6> xb000_sortedLists;
void Reset();
void AddToLinkedList(s16 a, s16& b, s16& c) const;
void RemoveFromList(ESortedList, s16);

View File

@ -24,7 +24,7 @@
#include "AutoMapper/CMapWorldInfo.hpp"
#include "Particle/CGenDescription.hpp"
#include "CMemoryCardSys.hpp"
#include "TCastTo.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
#include "World/CScriptSpecialFunction.hpp"
#include "CTimeProvider.hpp"
#include "Camera/CBallCamera.hpp"
@ -71,7 +71,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
, x8c0_mapWorldInfo(mwInfo)
, x8c4_worldTransManager(wtMgr)
, x8c8_worldLayerState(layerState) {
x86c_stateManagerContainer.reset(new CStateManagerContainer);
x86c_stateManagerContainer = std::make_unique<CStateManagerContainer>();
x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager;
x874_sortedListManager = &x86c_stateManagerContainer->x3c0_sortedListManager;
x878_weaponManager = &x86c_stateManagerContainer->xe3d8_weaponManager;
@ -1292,21 +1292,21 @@ void CStateManager::LoadScriptObjects(TAreaId aid, CInputStream& in, std::vector
std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, EScriptObjectType type, u32 length,
CInputStream& in) {
TEditorId id = in.readUint32Big();
u32 connCount = in.readUint32Big();
const TEditorId id = in.readUint32Big();
const u32 connCount = in.readUint32Big();
length -= 8;
std::vector<SConnection> conns;
conns.reserve(connCount);
for (int i = 0; i < connCount; ++i) {
EScriptObjectState state = EScriptObjectState(in.readUint32Big());
EScriptObjectMessage msg = EScriptObjectMessage(in.readUint32Big());
TEditorId target = in.readUint32Big();
for (u32 i = 0; i < connCount; ++i) {
const auto state = EScriptObjectState(in.readUint32Big());
const auto msg = EScriptObjectMessage(in.readUint32Big());
const TEditorId target = in.readUint32Big();
length -= 12;
conns.push_back(SConnection{state, msg, target});
}
u32 propCount = in.readUint32Big();
const u32 propCount = in.readUint32Big();
length -= 4;
auto startPos = in.position();
const auto startPos = in.position();
bool error = false;
FScriptLoader loader = {};
@ -1315,7 +1315,7 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
CEntity* ent = nullptr;
if (loader) {
CEntityInfo info(aid, conns, id);
const CEntityInfo info(aid, std::move(conns), id);
ent = loader(*this, in, propCount, info);
} else {
error = true;
@ -2146,7 +2146,7 @@ void CStateManager::InitializeState(CAssetId mlvlId, TAreaId aid, CAssetId mreaI
if (xb3c_initPhase == EInitPhase::LoadWorld) {
CreateStandardGameObjects();
x850_world.reset(new CWorld(*g_SimplePool, *g_ResFactory, mlvlId));
x850_world = std::make_unique<CWorld>(*g_SimplePool, *g_ResFactory, mlvlId);
xb3c_initPhase = EInitPhase::LoadFirstArea;
}
@ -2216,17 +2216,18 @@ void CStateManager::InitializeState(CAssetId mlvlId, TAreaId aid, CAssetId mreaI
}
void CStateManager::CreateStandardGameObjects() {
float height = g_tweakPlayer->GetPlayerHeight();
float xyHe = g_tweakPlayer->GetPlayerXYHalfExtent();
float stepUp = g_tweakPlayer->GetStepUpHeight();
float stepDown = g_tweakPlayer->GetStepDownHeight();
float ballRadius = g_tweakPlayer->GetPlayerBallHalfExtent();
zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}};
auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f));
x84c_player.reset(
new CPlayer(AllocateUniqueId(), zeus::CTransform(q), pBounds, g_tweakPlayerRes->xc4_ballTransitionsANCS,
zeus::CVector3f{1.65f, 1.65f, 1.65f}, 200.f, stepUp, stepDown, ballRadius,
CMaterialList(EMaterialTypes::Player, EMaterialTypes::Solid, EMaterialTypes::GroundCollider)));
const float height = g_tweakPlayer->GetPlayerHeight();
const float xyHe = g_tweakPlayer->GetPlayerXYHalfExtent();
const float stepUp = g_tweakPlayer->GetStepUpHeight();
const float stepDown = g_tweakPlayer->GetStepDownHeight();
const float ballRadius = g_tweakPlayer->GetPlayerBallHalfExtent();
const zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}};
const auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f));
x84c_player = std::make_unique<CPlayer>(
AllocateUniqueId(), zeus::CTransform(q), pBounds, g_tweakPlayerRes->xc4_ballTransitionsANCS,
zeus::CVector3f{1.65f, 1.65f, 1.65f}, 200.f, stepUp, stepDown, ballRadius,
CMaterialList(EMaterialTypes::Player, EMaterialTypes::Solid, EMaterialTypes::GroundCollider));
AddObject(*x84c_player);
x870_cameraManager->CreateStandardCameras(*this);
}

View File

@ -1,49 +1,61 @@
#pragma once
#include <list>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include "CBasics.hpp"
#include "World/ScriptObjectSupport.hpp"
#include "GameObjectLists.hpp"
#include "Camera/CCameraManager.hpp"
#include "Camera/CCameraFilter.hpp"
#include "CRandom16.hpp"
#include "zeus/CAABox.hpp"
#include "Weapon/CWeaponMgr.hpp"
#include "World/CAi.hpp"
#include "CToken.hpp"
#include "World/ScriptLoader.hpp"
#include "Input/CFinalInput.hpp"
#include "CSortedLists.hpp"
#include "World/CFluidPlaneManager.hpp"
#include "World/CEnvFxManager.hpp"
#include "World/CActorModelParticles.hpp"
#include "Input/CRumbleManager.hpp"
#include "Camera/CCameraShakeData.hpp"
#include "Graphics/Shaders/CColoredQuadFilter.hpp"
#include <string>
#include <utility>
#include <vector>
#include "Runtime/CBasics.hpp"
#include "Runtime/CRandom16.hpp"
#include "Runtime/CSortedLists.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Camera/CCameraManager.hpp"
#include "Runtime/Camera/CCameraShakeData.hpp"
#include "Runtime/GameObjectLists.hpp"
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
#include "Runtime/Input/CFinalInput.hpp"
#include "Runtime/Input/CRumbleManager.hpp"
#include "Runtime/Weapon/CWeaponMgr.hpp"
#include "Runtime/World/CActorModelParticles.hpp"
#include "Runtime/World/CAi.hpp"
#include "Runtime/World/CEnvFxManager.hpp"
#include "Runtime/World/CFluidPlaneManager.hpp"
#include "Runtime/World/ScriptLoader.hpp"
#include "Runtime/World/ScriptObjectSupport.hpp"
#include <zeus/CAABox.hpp>
#include <zeus/CVector2f.hpp>
#include <zeus/CVector2i.hpp>
namespace urde {
class CRelayTracker;
class CMapWorldInfo;
class CPlayerState;
class CWorldTransManager;
class CObjectList;
class CSortedListManager;
class CFluidPlaneManager;
class CEnvFxManager;
class CActorModelParticles;
class CTeamAiTypes;
class CRumbleManager;
class CActor;
class CLight;
class CActorModelParticles;
class CDamageInfo;
class CEnvFxManager;
class CFluidPlaneManager;
class CLight;
class CMapWorldInfo;
class CMaterialFilter;
struct CFinalInput;
class CObjectList;
class CPlayer;
class CWorld;
class CTexture;
class CWorldLayerState;
class CPlayerState;
class CProjectedShadow;
class CRelayTracker;
class CRumbleManager;
class CSortedListManager;
class CTeamAiTypes;
class CTexture;
class CWorld;
class CWorldLayerState;
class CWorldTransManager;
struct CFinalInput;
namespace MP1 {
class CMFGameLoader;

View File

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include "RetroTypes.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
class CStateManager;

View File

@ -1,6 +1,7 @@
#pragma once
#include <chrono>
#include <fmt/format.h>
namespace urde {
class CStopwatch {

View File

@ -1,29 +1,39 @@
#pragma once
#include <algorithm>
#include <cctype>
#include <string>
#include <cstring>
namespace urde {
class CStringExtras {
public:
static int CompareCaseInsensitive(const char* a, const char* b) {
#if _WIN32
return _stricmp(a, b);
#else
return strcasecmp(a, b);
#endif
}
static int CompareCaseInsensitive(std::string_view a, std::string_view b) {
return CompareCaseInsensitive(a.data(), b.data());
// Checks if the provided views into string data can be considered equal or not based on
// whether or not all their characters are equal to one another in a character insensitive manner.
//
// NOTE: This differs slightly from the actual version of this function within the game executable
// in order to better accomodate string views and potentially non-null-terminated string data.
//
// In the game executable, the function essentially behaves like strcasecmp in that it returns
// an int indicating whether or not the first argument is less than, equal to,
// or greater than the second argument. Given no usages in the code depend on the less than or
// greater than cases, but rather just care about whether or not the strings are equal to one
// another, this is a safe change to make.
//
static bool CompareCaseInsensitive(std::string_view a, std::string_view b) {
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char lhs, char rhs) {
return std::tolower(lhs) == std::tolower(rhs);
});
}
static int IndexOfSubstring(std::string_view haystack, std::string_view needle) {
std::string str(haystack);
std::transform(str.begin(), str.end(), str.begin(), tolower);
std::string::size_type s = str.find(needle);
if (s == std::string::npos)
std::transform(str.begin(), str.end(), str.begin(),
[](char c) { return std::tolower(static_cast<unsigned char>(c)); });
const std::string::size_type s = str.find(needle);
if (s == std::string::npos) {
return -1;
}
return s;
}
};

View File

@ -16,7 +16,7 @@ u16 CObjectReference::RemoveReference() {
CObjectReference::CObjectReference(IObjectStore& objStore, std::unique_ptr<IObj>&& obj, const SObjectTag& objTag,
CVParamTransfer buildParams)
: x4_objTag(objTag), xC_objectStore(&objStore), x10_object(std::move(obj)), x14_params(buildParams) {}
: x4_objTag(objTag), xC_objectStore(&objStore), x10_object(std::move(obj)), x14_params(std::move(buildParams)) {}
CObjectReference::CObjectReference(std::unique_ptr<IObj>&& obj) : x10_object(std::move(obj)) {}
void CObjectReference::Unlock() {
@ -128,7 +128,7 @@ CToken::CToken(const CToken& other) : x0_objRef(other.x0_objRef) {
Lock();
}
}
CToken::CToken(CToken&& other) : x0_objRef(other.x0_objRef), x4_lockHeld(other.x4_lockHeld) {
CToken::CToken(CToken&& other) noexcept : x0_objRef(other.x0_objRef), x4_lockHeld(other.x4_lockHeld) {
other.x0_objRef = nullptr;
other.x4_lockHeld = false;
}

View File

@ -1,19 +1,21 @@
#pragma once
#include <memory>
#include "IObj.hpp"
#include "RetroTypes.hpp"
#include "IVParamObj.hpp"
#include "IObjectStore.hpp"
#include "IFactory.hpp"
#include "Runtime/IFactory.hpp"
#include "Runtime/IObj.hpp"
#include "Runtime/IObjectStore.hpp"
#include "Runtime/IVParamObj.hpp"
#include "Runtime/RetroTypes.hpp"
namespace urde {
class IObjectStore;
/** Shared data-structure for CToken references, analogous to std::shared_ptr */
class CObjectReference {
friend class CToken;
friend class CSimplePool;
friend class CToken;
u16 x0_refCount = 0;
u16 x2_lockCount = 0;
bool x3_loading = false; /* Rightmost bit of lockCount */
@ -60,8 +62,9 @@ public:
* This class is analogous to std::shared_ptr and C++11 rvalues have been implemented accordingly
* (default/empty constructor, move constructor/assign) */
class CToken {
friend class CSimplePool;
friend class CModel;
friend class CSimplePool;
CObjectReference* x0_objRef = nullptr;
bool x4_lockHeld = false;
@ -82,7 +85,7 @@ public:
CToken& operator=(CToken&& other);
CToken() = default;
CToken(const CToken& other);
CToken(CToken&& other);
CToken(CToken&& other) noexcept;
CToken(IObj* obj);
CToken(std::unique_ptr<IObj>&& obj);
const SObjectTag* GetObjectTag() const;

View File

@ -1,6 +1,6 @@
#include "GameGlobalObjects.hpp"
#include "CBallCamera.hpp"
#include "TCastTo.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
#include "CStateManager.hpp"
#include "Collision/CCollisionActor.hpp"
#include "World/CPlayer.hpp"

View File

@ -1,7 +1,15 @@
#pragma once
#include "CGameCamera.hpp"
#include "CCameraSpline.hpp"
#include <cmath>
#include <memory>
#include <vector>
#include "Runtime/Camera/CCameraSpline.hpp"
#include "Runtime/Camera/CGameCamera.hpp"
#include <zeus/CAABox.hpp>
#include <zeus/CTransform.hpp>
#include <zeus/CVector3f.hpp>
namespace urde {
class CPlayer;

View File

@ -1,10 +1,14 @@
#pragma once
#include "zeus/CColor.hpp"
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include "Graphics/Shaders/CCameraBlurFilter.hpp"
#include "Graphics/Shaders/CXRayBlurFilter.hpp"
#include <memory>
#include <optional>
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
#include "Runtime/Graphics/Shaders/CXRayBlurFilter.hpp"
#include <zeus/CColor.hpp>
namespace urde {
class CTexture;

View File

@ -5,7 +5,7 @@
#include "World/CScriptWater.hpp"
#include "World/CPlayer.hpp"
#include "GameGlobalObjects.hpp"
#include "TCastTo.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
#include "CCinematicCamera.hpp"
#include "CBallCamera.hpp"
#include "CInterpolationCamera.hpp"
@ -15,11 +15,7 @@
#include "World/CExplosion.hpp"
namespace urde {
float CCameraManager::sAspect = 1.42f;
float CCameraManager::sFarPlane = 750.f;
float CCameraManager::sNearPlane = 0.2f;
float CCameraManager::sFirstPersonFOV = 55.f;
float CCameraManager::sThirdPersonFOV = 60.f;
CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCameraId) {
CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::skZero3f, zeus::skZero3f,
@ -135,13 +131,13 @@ void CCameraManager::CreateStandardCameras(CStateManager& stateMgr) {
TUniqueId fpId = stateMgr.AllocateUniqueId();
x7c_fpCamera =
new CFirstPersonCamera(fpId, zeus::CTransform(), stateMgr.Player()->GetUniqueId(),
g_tweakPlayer->GetOrbitCameraSpeed(), sFirstPersonFOV, sNearPlane, sFarPlane, sAspect);
g_tweakPlayer->GetOrbitCameraSpeed(), sFirstPersonFOV, NearPlane(), FarPlane(), Aspect());
stateMgr.AddObject(x7c_fpCamera);
stateMgr.Player()->SetCameraState(CPlayer::EPlayerCameraState::FirstPerson, stateMgr);
SetCurrentCameraId(fpId, stateMgr);
x80_ballCamera = new CBallCamera(stateMgr.AllocateUniqueId(), stateMgr.Player()->GetUniqueId(),
zeus::CTransform(), sThirdPersonFOV, sNearPlane, sFarPlane, sAspect);
x80_ballCamera = new CBallCamera(stateMgr.AllocateUniqueId(), stateMgr.Player()->GetUniqueId(), zeus::CTransform(),
ThirdPersonFOV(), NearPlane(), FarPlane(), Aspect());
stateMgr.AddObject(x80_ballCamera);
x88_interpCamera = new CInterpolationCamera(stateMgr.AllocateUniqueId(), zeus::CTransform());

View File

@ -1,27 +1,29 @@
#pragma once
#include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp"
#include "World/CGameArea.hpp"
#include <list>
#include <vector>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/World/CGameArea.hpp"
#include <zeus/CVector3f.hpp>
namespace urde {
class CFirstPersonCamera;
class CBallCamera;
class CStateManager;
class CGameCamera;
class CCameraShakeData;
class CScriptWater;
class CInterpolationCamera;
struct CFinalInput;
class CScriptCameraHint;
class CCinematicCamera;
class CFirstPersonCamera;
class CGameCamera;
class CInterpolationCamera;
class CScriptCameraHint;
class CScriptWater;
class CStateManager;
struct CFinalInput;
class CCameraManager {
static float sAspect;
static float sFarPlane;
static float sNearPlane;
static float sFirstPersonFOV;
static float sThirdPersonFOV;
TUniqueId x0_curCameraId;
std::vector<TUniqueId> x4_cineCameras;
std::list<CCameraShakeData> x14_shakers;
@ -80,11 +82,11 @@ class CCameraManager {
public:
CCameraManager(TUniqueId curCameraId = kInvalidUniqueId);
static float Aspect() { return sAspect; }
static float FarPlane() { return sFarPlane; }
static float NearPlane() { return sNearPlane; }
static float Aspect() { return 1.42f; }
static float FarPlane() { return 750.0f; }
static float NearPlane() { return 0.2f; }
static float FirstPersonFOV() { return sFirstPersonFOV; }
static float ThirdPersonFOV() { return sThirdPersonFOV; }
static float ThirdPersonFOV() { return 60.0f; }
void ResetCameras(CStateManager& mgr);
void SetSpecialCameras(CFirstPersonCamera& fp, CBallCamera& ball);

View File

@ -1,7 +1,8 @@
#pragma once
#include "zeus/CVector3f.hpp"
#include "RetroTypes.hpp"
#include "Runtime/RetroTypes.hpp"
#include <zeus/CVector3f.hpp>
namespace urde {
class CRandom16;

View File

@ -1,7 +1,7 @@
#include "Camera/CCameraSpline.hpp"
#include "CStateManager.hpp"
#include "World/CScriptCameraWaypoint.hpp"
#include "TCastTo.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
namespace urde {
CCameraSpline::CCameraSpline(bool closedLoop) : x48_closedLoop(closedLoop) {}

View File

@ -2,7 +2,7 @@
#include "CStateManager.hpp"
#include "World/CPlayer.hpp"
#include "World/CScriptActor.hpp"
#include "TCastTo.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
#include "World/CScriptCameraWaypoint.hpp"
#include "GameGlobalObjects.hpp"
#include "Character/CAnimTreeNode.hpp"

Some files were not shown because too many files have changed in this diff Show More