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

This commit is contained in:
Phillip Stephens 2020-06-03 04:12:11 -07:00
commit 86942c44ef
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
7 changed files with 60 additions and 41 deletions

View File

@ -173,7 +173,7 @@ else()
-Wno-unused-variable -Wno-unused-result
-Wno-unused-function -Wno-sign-compare -Wno-unknown-pragmas -Werror)
# doesn't work with generator expression in add_compile_options?
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
add_compile_options(-Wno-unknown-warning-option -Wno-unused-private-field)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-Wno-lto-type-mismatch)

View File

@ -1844,6 +1844,12 @@ CFrontEndUI::CFrontEndUI() : CIOWin("FrontEndUI") {
m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None);
}
CFrontEndUI::~CFrontEndUI() {
if (x14_phase >= EPhase::DisplayFrontEnd) {
CAudioSys::RemoveAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
}
}
void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue) {
xf4_curAudio->StopMixing();
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CSlideShow>()));

View File

@ -371,6 +371,7 @@ private:
public:
CFrontEndUI();
~CFrontEndUI();
void StartSlideShow(CArchitectureQueue& queue);
std::string GetAttractMovieFileName(int idx);
std::string GetNextAttractMovieFileName();

View File

@ -120,10 +120,11 @@ void COmegaPirate::CFlash::Render(CStateManager& mgr) {
COmegaPirate::COmegaPirate(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms,
CElitePirateData data, CAssetId w1, CAssetId w2, CAssetId w3)
CElitePirateData data, CAssetId skeletonModelId, CAssetId skeletonSkinRulesId,
CAssetId skeletonLayoutInfoId)
: CElitePirate(uid, name, info, xf, std::move(mData), pInfo, actParms, data)
, x9d0_initialScale(GetModelData()->GetScale())
, x9f0_skeletonModel(*g_SimplePool, w1, w2, w3, 0, 0)
, x9f0_skeletonModel(*g_SimplePool, skeletonModelId, skeletonSkinRulesId, skeletonLayoutInfoId, 0, 0)
, xb70_thermalSpot(g_SimplePool->GetObj("Thermal_Spot_2"sv)) {
x9a4_scriptWaypointPlatforms.reserve(3);
x9b8_scriptEffects.reserve(24);

View File

@ -122,7 +122,7 @@ private:
public:
COmegaPirate(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms, CElitePirateData data,
CAssetId w1, CAssetId w2, CAssetId w3);
CAssetId skeletonModelId, CAssetId skeletonSkinRulesId, CAssetId skeletonLayoutInfoId);
void Think(float dt, CStateManager& mgr) override;
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;

View File

@ -3659,11 +3659,14 @@ CEntity* ScriptLoader::LoadOmegaPirate(CStateManager& mgr, CInputStream& in, int
return nullptr;
}
const CAssetId skeletonModelId{in};
const CAssetId skeletonSkinRulesId{in};
const CAssetId skeletonLayoutInfoId{in};
CModelData mData(CAnimRes(pInfo.GetAnimationParameters().GetACSFile(), pInfo.GetAnimationParameters().GetCharacter(),
actHead.x40_scale, pInfo.GetAnimationParameters().GetInitialAnimation(), true));
return new MP1::COmegaPirate(mgr.AllocateUniqueId(), actHead.x0_name, info, actHead.x10_transform, std::move(mData),
pInfo, actParms, elitePirateData, CAssetId(in), CAssetId(in), CAssetId(in));
pInfo, actParms, elitePirateData, skeletonModelId, skeletonSkinRulesId,
skeletonLayoutInfoId);
}
CEntity* ScriptLoader::LoadPhazonPool(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {

View File

@ -1,8 +1,10 @@
#include <iostream>
#include <cstdint>
#include <iostream>
#include <memory>
#include <vector>
#include <logvisor/logvisor.hpp>
#include "tinyxml2/tinyxml2.h"
#include "logvisor/logvisor.hpp"
#ifndef _WIN32
#include <cstdlib>
@ -30,7 +32,9 @@
#endif
#endif
static logvisor::Module Log("AssetNameParser");
namespace {
logvisor::Module Log("AssetNameParser");
// TODO: Clean this up
#undef bswap16
#undef bswap32
@ -133,45 +137,54 @@ struct SAsset {
enum class FileLockType { None = 0, Read, Write };
#if IS_UCS2
typedef wchar_t SystemChar;
typedef std::wstring SystemString;
using SystemChar = wchar_t;
using SystemString = std::wstring;
#ifndef _SYS_STR
#define _SYS_STR(val) L##val
#endif
typedef struct _stat Sstat;
using Sstat = struct _stat;
#else
typedef char SystemChar;
typedef std::string SystemString;
using SystemChar = char;
using SystemString = std::string;
#ifndef _SYS_STR
#define _SYS_STR(val) val
#endif
typedef struct stat Sstat;
using Sstat = struct stat;
#endif
static FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLockType lock = FileLockType::None) {
struct FILEDeleter {
void operator()(FILE* file) const { std::fclose(file); }
};
using FILEPtr = std::unique_ptr<FILE, FILEDeleter>;
FILEPtr Fopen(const SystemChar* path, const SystemChar* mode, FileLockType lock = FileLockType::None) {
#if IS_UCS2
FILE* fp = _wfopen(path, mode);
if (!fp)
FILEPtr fp{_wfopen(path, mode)};
if (!fp) {
return nullptr;
}
#else
FILE* fp = fopen(path, mode);
if (!fp)
FILEPtr fp{std::fopen(path, mode)};
if (!fp) {
return nullptr;
}
#endif
if (lock != FileLockType::None) {
#if _WIN32
OVERLAPPED ov = {};
LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1,
&ov);
LockFileEx((HANDLE)(uintptr_t)_fileno(fp.get()), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0,
1, &ov);
#else
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
fprintf(stderr, "flock %s: %s", path, strerror(errno));
if (flock(fileno(fp.get()), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB)) {
std::fprintf(stderr, "flock %s: %s", path, strerror(errno));
}
#endif
}
return fp;
}
} // Anonymous namespace
#if _WIN32
int wmain(int argc, const wchar_t* argv[])
@ -191,8 +204,8 @@ int main(int argc, const char* argv[])
tinyxml2::XMLDocument doc;
std::vector<SAsset> assets;
FILE* docF = Fopen(inPath.c_str(), _SYS_STR("rb"));
if (doc.LoadFile(docF) == tinyxml2::XML_SUCCESS) {
FILEPtr docF = Fopen(inPath.c_str(), _SYS_STR("rb"));
if (doc.LoadFile(docF.get()) == tinyxml2::XML_SUCCESS) {
const tinyxml2::XMLElement* elm = doc.RootElement();
if (strcmp(elm->Name(), "AssetNameMap") != 0) {
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Invalid database supplied")));
@ -238,7 +251,7 @@ int main(int argc, const char* argv[])
elm = elm->NextSiblingElement("Asset");
}
FILE* f = Fopen(outPath.c_str(), _SYS_STR("wb"));
FILEPtr f = Fopen(outPath.c_str(), _SYS_STR("wb"));
if (f == nullptr) {
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open destination")));
return 0;
@ -246,28 +259,23 @@ int main(int argc, const char* argv[])
uint32_t assetCount = SBig(uint32_t(assets.size()));
FourCC sentinel(SBIG('AIDM'));
fwrite(&sentinel, 1, 4, f);
fwrite(&assetCount, 1, 4, f);
fwrite(&sentinel, sizeof(sentinel), 1, f.get());
fwrite(&assetCount, sizeof(assetCount), 1, f.get());
for (const SAsset& asset : assets) {
fwrite(&asset.type, 1, 4, f);
fwrite(&asset.type, sizeof(asset.type), 1, f.get());
uint64_t id = SBig(asset.id);
fwrite(&id, 1, 8, f);
fwrite(&id, sizeof(id), 1, f.get());
uint32_t tmp = SBig(uint32_t(asset.name.length()));
fwrite(&tmp, 1, 4, f);
fwrite(asset.name.c_str(), 1, SBig(tmp), f);
fwrite(&tmp, sizeof(tmp), 1, f.get());
fwrite(asset.name.c_str(), 1, SBig(tmp), f.get());
tmp = SBig(uint32_t(asset.dir.length()));
fwrite(&tmp, 1, 4, f);
fwrite(asset.dir.c_str(), 1, SBig(tmp), f);
fwrite(&tmp, sizeof(tmp), 1, f.get());
fwrite(asset.dir.c_str(), SBig(tmp), 1, f.get());
}
fflush(f);
fclose(f);
fclose(docF);
fflush(f.get());
return 0;
}
if (docF)
fclose(docF);
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("failed to load")));
return 1;
}