Compile fixes, and initial asset name parser

This commit is contained in:
Phillip Stephens 2017-07-02 03:18:38 -07:00
parent 704e1b110a
commit 38a13868f0
21 changed files with 528 additions and 112 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "jbus"]
path = jbus
url = https://github.com/AxioDL/jbus.git
[submodule "assetnameparser/tinyxml2"]
path = assetnameparser/tinyxml2
url = https://github.com/leethomason/tinyxml2.git

View File

@ -106,6 +106,7 @@ add_subdirectory(amuse)
add_subdirectory(specter)
set(SPECTER_INCLUDE_DIR specter/include specter/freetype2/include)
add_subdirectory(nod)
add_subdirectory(assetnameparser)
set(NOD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nod/include)
add_definitions(-DZE_ATHENA_TYPES=1)
set(ZEUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/specter/zeus/include)

View File

@ -22,13 +22,13 @@ CCharAnimTime CAnimTreeTimeScale::GetRealLifeTime(const CCharAnimTime& time) con
if (x28_ > CCharAnimTime())
{
if (tmp < CCharAnimTime(x28_ * x20_))
return x18_timeScale->TimeScaleIntegral(x20_, x20_ + tmp);
return x18_timeScale->VTimeScaleIntegral(x20_, x20_ + tmp);
else
{
CCharAnimTime integral = x18_timeScale->TimeScaleIntegral(x20_, x28_);
CCharAnimTime integral = x18_timeScale->VTimeScaleIntegral(x20_, x28_);
if (integral > tmp)
return x18_timeScale->FindUpperLimit(x20_, tmp) * x20_;
return x18_timeScale->VFindUpperLimit(x20_, tmp) * x20_;
else
return integral + (integral * tmp);
}

View File

@ -2,14 +2,14 @@
#define __URDE_CANIMTREETIMESCALE_HPP__
#include "CAnimTreeSingleChild.hpp"
#include "CConstantAnimationTimeScale.hpp"
#include "CTimeScaleFunctions.hpp"
namespace urde
{
class CAnimTreeTimeScale : public CAnimTreeSingleChild
{
std::unique_ptr<CConstantAnimationTimeScale> x18_timeScale;
std::shared_ptr<CConstantAnimationTimeScale> x18_timeScale;
CCharAnimTime x20_;
CCharAnimTime x28_;
public:

View File

@ -1,19 +0,0 @@
#include "CConstantAnimationTimeScale.hpp"
namespace urde
{
float CConstantAnimationTimeScale::VTimeScaleIntegral(const float& a, const float& b) const { return (b - a) * x4_; }
float CConstantAnimationTimeScale::VFindUpperLimit(const float& a, const float& b) const { return (b / x4_) + a; }
std::unique_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VClone() const
{
return std::make_unique<CConstantAnimationTimeScale>(x4_);
}
std::unique_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
{
return Clone();
}
}

View File

@ -1,22 +0,0 @@
#ifndef __URDE_CONSTANTANIMATIONTIMESCALE_HPP__
#define __URDE_CONSTANTANIMATIONTIMESCALE_HPP__
#include "IVaryingAnimationTimeScale.hpp"
namespace urde
{
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
{
private:
float x4_;
public:
CConstantAnimationTimeScale(float f) : x4_(f) {}
u32 GetType() const { return 0; }
float VTimeScaleIntegral(const float &, const float &) const;
float VFindUpperLimit(const float &, const float &) const;
std::unique_ptr<IVaryingAnimationTimeScale> VClone() const;
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float &) const;
};
}
#endif // __URDE_CONSTANTANIMATIONTIMESCALE_HPP__

View File

@ -1,31 +0,0 @@
#ifndef __URDE_CLINEARANIMATIONTIMESCALE_HPP__
#define __URDE_CLINEARANIMATIONTIMESCALE_HPP__
#include "IVaryingAnimationTimeScale.hpp"
namespace urde
{
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale
{
public:
class CFunctionDescription
{
public:
CFunctionDescription(const float&, const float&, const float&);
CFunctionDescription FunctionMirroredAround(const float&) const;
};
private:
public:
CLinearAnimationTimeScale(const CCharAnimTime&, float, const CCharAnimTime&, float);
u32 GetType() const { return 1; }
float VTimeScaleIntegral(const float &, const float &) const { return 0.f; }
float VFindUpperLimit(const float &, const float &) const { return 0.f; }
std::unique_ptr<IVaryingAnimationTimeScale> VClone() { return {}; }
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float &) const { return {}; }
float TimeScaleIntegralWithSortedLimits(const CFunctionDescription&, const float&, const float&);
float GetScale(const CFunctionDescription&, const float&);
};
}
#endif // __URDE_CLINEARANIMATIONTIMESCALE_HPP__

View File

@ -8,8 +8,6 @@ set(CHARACTER_SOURCES
IMetaAnim.hpp IMetaAnim.cpp
IMetaTrans.hpp
IVaryingAnimationTimeScale.hpp
CLinearAnimationTimeScale.hpp CLinearAnimationTimeScale.cpp
CConstantAnimationTimeScale.hpp CConstantAnimationTimeScale.cpp
CAnimationDatabase.hpp
CAnimationDatabaseGame.hpp CAnimationDatabaseGame.cpp
CTransitionDatabase.hpp

View File

@ -9,41 +9,39 @@ std::shared_ptr<IVaryingAnimationTimeScale> IVaryingAnimationTimeScale::Clone()
return VClone();
}
void CConstantAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
{
}
void CConstantAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
{
}
float CConstantAnimationTimeScale::VTimeScaleIntegral(const float& a, const float& b) const { return (b - a) * x4_; }
float CConstantAnimationTimeScale::VFindUpperLimit(const float& a, const float& b) const { return (b / x4_) + a; }
std::shared_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VClone() const
{
return {};
CConstantAnimationTimeScale* ret = new CConstantAnimationTimeScale(x4_);
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
std::shared_ptr<IVaryingAnimationTimeScale>
CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
std::shared_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
{
return {};
return Clone();
}
void CLinearAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
float CLinearAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
{
return 0.f;
}
void CLinearAnimationTimeScale::TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc,
float CLinearAnimationTimeScale::TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc,
const float&, const float&)
{
return 0.f;
}
void CLinearAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
float CLinearAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
{
return 0.f;
}
void CLinearAnimationTimeScale::FindUpperLimitFromRoot(const CFunctionDescription& desc,
float CLinearAnimationTimeScale::FindUpperLimitFromRoot(const CFunctionDescription& desc,
const float&, const float&)
{
return 0.f;
}
std::shared_ptr<IVaryingAnimationTimeScale> CLinearAnimationTimeScale::VClone() const

View File

@ -17,21 +17,25 @@ class IVaryingAnimationTimeScale
public:
virtual ~IVaryingAnimationTimeScale() = default;
virtual EVaryingAnimationTimeScaleType GetType() const=0;
virtual void VTimeScaleIntegral(const float&, const float&) const=0;
virtual void VFindUpperLimit(const float&, const float&) const=0;
virtual float VTimeScaleIntegral(const float&, const float&) const=0;
virtual float VFindUpperLimit(const float&, const float&) const=0;
virtual std::shared_ptr<IVaryingAnimationTimeScale> VClone() const=0;
virtual std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const=0;
std::shared_ptr<IVaryingAnimationTimeScale> Clone() const;
};
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
{
private:
float x4_;
public:
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Constant;}
void VTimeScaleIntegral(const float&, const float&) const;
void VFindUpperLimit(const float&, const float&) const;
CConstantAnimationTimeScale(float f) : x4_(f) {}
EVaryingAnimationTimeScaleType GetType() const { return EVaryingAnimationTimeScaleType::Constant; }
float VTimeScaleIntegral(const float &, const float &) const;
float VFindUpperLimit(const float &, const float &) const;
std::shared_ptr<IVaryingAnimationTimeScale> VClone() const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float &) const;
};
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale
@ -46,10 +50,10 @@ public:
};
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Linear;}
void VTimeScaleIntegral(const float&, const float&) const;
void TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc, const float&, const float&);
void VFindUpperLimit(const float&, const float&) const;
void FindUpperLimitFromRoot(const CFunctionDescription& desc, const float&, const float&);
float VTimeScaleIntegral(const float&, const float&) const;
float TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc, const float&, const float&);
float VFindUpperLimit(const float&, const float&) const;
float FindUpperLimitFromRoot(const CFunctionDescription& desc, const float&, const float&);
std::shared_ptr<IVaryingAnimationTimeScale> VClone() const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const;
};

View File

@ -9,7 +9,7 @@ class IWeaponRenderer
{
public:
virtual ~IWeaponRenderer() = default;
virtual void AddParticleGen(const CParticleGen&);
virtual void AddParticleGen(const CParticleGen&)=0;
};
class CDefaultWeaponRenderer : public IWeaponRenderer

View File

@ -6,6 +6,56 @@
namespace urde
{
void CGunController::UnLoadFidget()
{
}
void CGunController::LoadFidgetAnimAsync(CStateManager &, s32, s32, s32)
{
}
void CGunController::GetFreeLookSetId() const
{
}
bool CGunController::IsFidgetLoaded() const
{
return false;
}
bool CGunController::IsComboOver() const
{
return true;
}
void CGunController::EnterFreeLook(CStateManager &, s32, s32)
{
}
void CGunController::EnterComboFire(CStateManager &, s32)
{
}
void CGunController::EnterFidget(CStateManager &, s32, s32, s32)
{
}
void CGunController::EnterStruck(CStateManager &, float)
{
}
void CGunController::EnterIdle(CStateManager &)
{
}
bool CGunController::Update(float dt, CStateManager& mgr)
{
CAnimData& animData = *x0_modelData.AnimationData();
@ -51,6 +101,11 @@ bool CGunController::Update(float dt, CStateManager& mgr)
return true;
}
void CGunController::ReturnToDefault(CStateManager &, float)
{
}
void CGunController::ReturnToBasePosition(CStateManager& mgr, float)
{
const CPASDatabase& pasDatabase = x0_modelData.AnimationData()->GetCharacterInfo().GetPASDatabase();

View File

@ -51,7 +51,7 @@ public:
s32 GetNumTriggers() const;
CAiTrigger& GetTrig(s32) const;
const char* GetName() const;
const char* GetName() const { return x4_name; }
void SetTriggers(CAiTrigger* triggers);
void SetNumTriggers(s32 numTriggers) { x2c_numTriggers = numTriggers; }
void CallFunc(CStateManager& mgr, CAi& ai, EStateMsg msg, float delta) const

2
amuse

@ -1 +1 @@
Subproject commit 4e7c31849d5c9e1e274fa86fc74d3cbecf9e11de
Subproject commit 0bace131e877b24f29924b7d6887100e81461b48

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) # because of CMAKE_CXX_STANDARD
add_subdirectory(tinyxml2)
add_executable(assetnameparser "main.cpp")
include_directories(${LOGVISOR_INCLUDE_DIR})
set(AN_PARSER_LIBS "")
if (UNIX)
list(APPEND AN_PARSER_LIBS pthread)
if(UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND AN_PARSER_LIBS dl)
endif()
endif()
target_link_libraries(assetnameparser tinyxml2 logvisor ${AN_PARSER_LIBS})

413
assetnameparser/main.cpp Normal file
View File

@ -0,0 +1,413 @@
#include <iostream>
#include <stdint.h>
#include <vector>
#include "tinyxml2/tinyxml2.h"
#include "logvisor/logvisor.hpp"
#ifndef _WIN32
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/statvfs.h>
#include <errno.h>
#else
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <Windows.h>
#include <wchar.h>
#include "winsupport.hpp"
#if UNICODE
#define IS_UCS2 1
#endif
#endif
static logvisor::Module Log("AssetNameParser");
// TODO: Clean this up
#undef bswap16
#undef bswap32
#undef bswap64
/* Type-sensitive byte swappers */
template <typename T>
static inline T bswap16(T val)
{
#if __GNUC__
return __builtin_bswap16(val);
#elif _WIN32
return _byteswap_ushort(val);
#else
return (val = (val << 8) | ((val >> 8) & 0xFF));
#endif
}
template <typename T>
static inline T bswap32(T val)
{
#if __GNUC__
return __builtin_bswap32(val);
#elif _WIN32
return _byteswap_ulong(val);
#else
val = (val & 0x0000FFFF) << 16 | (val & 0xFFFF0000) >> 16;
val = (val & 0x00FF00FF) << 8 | (val & 0xFF00FF00) >> 8;
return val;
#endif
}
template <typename T>
static inline T bswap64(T val)
{
#if __GNUC__
return __builtin_bswap64(val);
#elif _WIN32
return _byteswap_uint64(val);
#else
return ((val & 0xFF00000000000000ULL) >> 56) |
((val & 0x00FF000000000000ULL) >> 40) |
((val & 0x0000FF0000000000ULL) >> 24) |
((val & 0x000000FF00000000ULL) >> 8) |
((val & 0x00000000FF000000ULL) << 8) |
((val & 0x0000000000FF0000ULL) << 24) |
((val & 0x000000000000FF00ULL) << 40) |
((val & 0x00000000000000FFULL) << 56);
#endif
}
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
static inline int16_t SBig(int16_t val) {return bswap16(val);}
static inline uint16_t SBig(uint16_t val) {return bswap16(val);}
static inline int32_t SBig(int32_t val) {return bswap32(val);}
static inline uint32_t SBig(uint32_t val) {return bswap32(val);}
static inline int64_t SBig(int64_t val) {return bswap64(val);}
static inline uint64_t SBig(uint64_t val) {return bswap64(val);}
static inline float SBig(float val)
{
int32_t ival = bswap32(*((int32_t*)(&val)));
return *((float*)(&ival));
}
static inline double SBig(double val)
{
int64_t ival = bswap64(*((int64_t*)(&val)));
return *((double*)(&ival));
}
#ifndef SBIG
#define SBIG(q) ( ( (q) & 0x000000FF ) << 24 | ( (q) & 0x0000FF00 ) << 8 \
| ( (q) & 0x00FF0000 ) >> 8 | ( (q) & 0xFF000000 ) >> 24 )
#endif
static inline int16_t SLittle(int16_t val) {return val;}
static inline uint16_t SLittle(uint16_t val) {return val;}
static inline int32_t SLittle(int32_t val) {return val;}
static inline uint32_t SLittle(uint32_t val) {return val;}
static inline int64_t SLittle(int64_t val) {return val;}
static inline uint64_t SLittle(uint64_t val) {return val;}
static inline float SLittle(float val) {return val;}
static inline double SLittle(double val) {return val;}
#ifndef SLITTLE
#define SLITTLE(q) (q)
#endif
#else
static inline int16_t SLittle(int16_t val) {return bswap16(val);}
static inline uint16_t SLittle(uint16_t val) {return bswap16(val);}
static inline int32_t SLittle(int32_t val) {return bswap32(val);}
static inline uint32_t SLittle(uint32_t val) {return bswap32(val);}
static inline int64_t SLittle(int64_t val) {return bswap64(val);}
static inline uint64_t SLittle(uint64_t val) {return bswap64(val);}
static inline float SLittle(float val)
{
int32_t ival = bswap32(*((int32_t*)(&val)));
return *((float*)(&ival));
}
static inline double SLittle(double val)
{
int64_t ival = bswap64(*((int64_t*)(&val)));
return *((double*)(&ival));
}
#ifndef SLITTLE
#define SLITTLE(q) ( ( (q) & 0x000000FF ) << 24 | ( (q) & 0x0000FF00 ) << 8 \
| ( (q) & 0x00FF0000 ) >> 8 | ( (q) & 0xFF000000 ) >> 24 )
#endif
static inline int16_t SBig(int16_t val) {return val;}
static inline uint16_t SBig(uint16_t val) {return val;}
static inline int32_t SBig(int32_t val) {return val;}
static inline uint32_t SBig(uint32_t val) {return val;}
static inline int64_t SBig(int64_t val) {return val;}
static inline uint64_t SBig(uint64_t val) {return val;}
static inline float SBig(float val) {return val;}
static inline double SBig(double val) {return val;}
#ifndef SBIG
#define SBIG(q) (q)
#endif
#endif
class FourCC
{
protected:
union
{
char fcc[4];
uint32_t num;
};
public:
FourCC() /* Sentinel FourCC */
: num(0) {}
FourCC(const FourCC& other)
{num = other.num;}
FourCC(const char* name)
: num(*(uint32_t*)name) {}
FourCC(uint32_t n)
: num(n) {}
bool operator==(const FourCC& other) const {return num == other.num;}
bool operator!=(const FourCC& other) const {return num != other.num;}
bool operator==(const char* other) const {return num == *(uint32_t*)other;}
bool operator!=(const char* other) const {return num != *(uint32_t*)other;}
bool operator==(int32_t other) const { return num == other;}
bool operator!=(int32_t other) const { return num != other;}
bool operator==(uint32_t other) const {return num == other;}
bool operator!=(uint32_t other) const {return num != other;}
std::string toString() const {return std::string(fcc, 4);}
uint32_t toUint32() const {return num;}
operator uint32_t() const {return num;}
};
struct SAsset
{
FourCC type;
uint64_t id;
std::string name;
std::string dir;
};
enum class FileLockType
{
None = 0,
Read,
Write
};
#if IS_UCS2
typedef wchar_t SystemChar;
static inline size_t StrLen(const SystemChar* str) { return wcslen(str); }
typedef std::wstring SystemString;
static inline void ToLower(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), towlower); }
static inline void ToUpper(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), towupper); }
class SystemUTF8View
{
std::string m_utf8;
public:
explicit SystemUTF8View(const SystemString& str) : m_utf8(WideToUTF8(str)) {}
operator const std::string&() const { return m_utf8; }
const std::string& str() const { return m_utf8; }
const char* c_str() const { return m_utf8.c_str(); }
std::string operator+(const std::string& other) const { return m_utf8 + other; }
std::string operator+(const char* other) const { return m_utf8 + other; }
};
inline std::string operator+(const std::string& lhs, const SystemUTF8View& rhs) { return lhs + std::string(rhs); }
inline std::string operator+(const char* lhs, const SystemUTF8View& rhs) { return lhs + std::string(rhs); }
class SystemStringView
{
std::wstring m_sys;
public:
explicit SystemStringView(const std::string& str) : m_sys(UTF8ToWide(str)) {}
operator const std::wstring&() const { return m_sys; }
const std::wstring& sys_str() const { return m_sys; }
const SystemChar* c_str() const { return m_sys.c_str(); }
std::wstring operator+(const std::wstring& other) const { return m_sys + other; }
std::wstring operator+(const wchar_t* other) const { return m_sys + other; }
};
inline std::wstring operator+(const std::wstring& lhs, const SystemStringView& rhs) { return lhs + std::wstring(rhs); }
inline std::wstring operator+(const wchar_t* lhs, const SystemStringView& rhs) { return lhs + std::wstring(rhs); }
#ifndef _S
#define _S(val) L##val
#endif
typedef struct _stat Sstat;
#else
typedef char SystemChar;
static inline size_t StrLen(const SystemChar* str) { return strlen(str); }
typedef std::string SystemString;
class SystemUTF8View
{
const std::string& m_utf8;
public:
explicit SystemUTF8View(const SystemString& str) : m_utf8(str) {}
operator const std::string&() const { return m_utf8; }
const std::string& str() const { return m_utf8; }
const char* c_str() const { return m_utf8.c_str(); }
std::string operator+(const std::string& other) const { return std::string(m_utf8) + other; }
std::string operator+(const char* other) const { return std::string(m_utf8) + other; }
};
inline std::string operator+(const std::string& lhs, const SystemUTF8View& rhs) { return lhs + std::string(rhs); }
inline std::string operator+(const char* lhs, const SystemUTF8View& rhs) { return lhs + std::string(rhs); }
class SystemStringView
{
const std::string& m_sys;
public:
explicit SystemStringView(const std::string& str) : m_sys(str) {}
operator const std::string&() const { return m_sys; }
const std::string& sys_str() const { return m_sys; }
const SystemChar* c_str() const { return m_sys.c_str(); }
std::string operator+(const std::string& other) const { return m_sys + other; }
std::string operator+(const char* other) const { return m_sys + other; }
};
inline std::string operator+(const std::string& lhs, const SystemStringView& rhs) { return lhs + std::string(rhs); }
inline std::string operator+(const char* lhs, const SystemStringView& rhs) { return lhs + std::string(rhs); }
#ifndef _S
#define _S(val) val
#endif
typedef struct stat Sstat;
#endif
static inline int StrCmp(const SystemChar* str1, const SystemChar* str2)
{
#if IS_UCS2
return wcscmp(str1, str2);
#else
return strcmp(str1, str2);
#endif
}
static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLockType lock = FileLockType::None)
{
#if IS_UCS2
FILE* fp = _wfopen(path, mode);
if (!fp)
return nullptr;
#else
FILE* fp = 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);
#else
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
fprintf(stderr, "flock %s: %s", path, strerror(errno));
#endif
}
return fp;
}
#if _WIN32
int wmain(int argc, const wchar_t* argv[])
#else
int main(int argc, const char* argv[])
#endif
{
logvisor::RegisterStandardExceptions();
logvisor::RegisterConsoleLogger();
if (argc < 3)
{
Log.report(logvisor::Error, _S("Usage: %s <input> <output>"), argv[0]);
return 1;
}
SystemString inPath = argv[1];
SystemString outPath = argv[2];
tinyxml2::XMLDocument doc;
std::vector<SAsset> assets;
FILE* docF = Fopen(inPath.c_str(), _S("rb"));
if (!doc.LoadFile(docF))
{
const tinyxml2::XMLElement* elm = doc.RootElement();
if (strcmp(elm->Name(), "AssetNameMap"))
{
Log.report(logvisor::Fatal, _S("Invalid database supplied"));
return 1;
}
elm = elm->FirstChildElement("AssetNameMap");
if (elm == nullptr)
{
Log.report(logvisor::Fatal, _S("Malformed AssetName database"));
return 1;
}
elm = elm->FirstChildElement("Asset");
while (elm)
{
const tinyxml2::XMLElement* keyElm = elm->FirstChildElement("Key");
const tinyxml2::XMLElement* valueElm = elm->FirstChildElement("Value");
if (!keyElm || !valueElm)
{
Log.report(logvisor::Fatal, _S("Malformed Asset entry, [Key,Value] required"));
return 0;
}
const tinyxml2::XMLElement* nameElm = valueElm->FirstChildElement("Name");
const tinyxml2::XMLElement* dirElm = valueElm->FirstChildElement("Directory");
const tinyxml2::XMLElement* typeElm = valueElm->FirstChildElement("Type");
if (!nameElm || !dirElm || ! typeElm)
{
Log.report(logvisor::Fatal, _S("Malformed Value entry, [Name,Directory,Type] required"));
return 0;
}
assets.emplace_back();
SAsset& asset = assets.back();
asset.type = typeElm->GetText();
asset.id = strtoull(keyElm->GetText(), nullptr, 16);
asset.name = nameElm->GetText();
asset.dir = dirElm->GetText();
elm = elm->NextSiblingElement("Asset");
}
FILE* f = Fopen(outPath.c_str(), _S("wb"));
if (!f)
{
Log.report(logvisor::Fatal, _S("Unable to open destination"));
return 0;
}
uint32_t assetCount = SBig(uint32_t(assets.size()));
FourCC sentinel(SBIG('AIDM'));
fwrite(&sentinel, 1, 4, f);
fwrite(&assetCount, 1, 4, f);
for (const SAsset& asset : assets)
{
fwrite(&asset.type, 1, 4, f);
uint64_t id = SBig(asset.id);
fwrite(&id, 1, 8, f);
uint32_t tmp = SBig(uint32_t(asset.name.length()));
fwrite(&tmp, 1, 4, f);
fwrite(asset.name.c_str(), 1, SBig(tmp), f);
tmp = SBig(uint32_t(asset.dir.length()));
fwrite(&tmp, 1, 4, f);
fwrite(asset.dir.c_str(), 1, SBig(tmp), f);
}
fflush(f);
fclose(f);
fclose(docF);
return 0;
}
if (docF)
fclose(docF);
Log.report(logvisor::Fatal, _S("failed to load"));
return 1;
}

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

2
hecl

@ -1 +1 @@
Subproject commit da67582f23559060c842c7daa75bec31efbc816f
Subproject commit 4a3865ec8abe1e2c92dd2d4b70e0cb5039efdf38

View File

@ -4,4 +4,4 @@ add_executable(mpcksum
main.cpp)
target_link_libraries(mpcksum
athena-core z lzo2)
athena-core athena-libyaml z lzo2)

View File

@ -23,7 +23,7 @@ endif()
add_executable(visigen ${PLAT_SRCS}
VISIRenderer.cpp VISIRenderer.hpp
VISIBuilder.cpp VISIBuilder.hpp)
target_link_libraries(visigen logvisor athena-core zeus glew xxhash ${BOO_SYS_LIBS})
target_link_libraries(visigen logvisor athena-core athena-libyaml zeus glew xxhash ${ZLIB_LIBRARIES} ${LZO_LIB} ${BOO_SYS_LIBS})
add_custom_command(TARGET visigen POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:visigen> $<TARGET_FILE_DIR:urde>)