mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
ZoneCodeGenerator: Change ContentLoader to use vars for fastfile pointer transfer and change ZoneInputStream API to be able to specify load location to better reflect the way the games do it.
This commit is contained in:
@ -6,37 +6,42 @@ const void* ContentLoader::PTR_INSERT = reinterpret_cast<void*>(-2);
|
||||
|
||||
ContentLoader::ContentLoader()
|
||||
{
|
||||
varXString = nullptr;
|
||||
|
||||
m_zone = nullptr;
|
||||
m_stream = nullptr;
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXString(const char** pXString) const
|
||||
void ContentLoader::LoadXString(const bool atStreamStart) const
|
||||
{
|
||||
assert(pXString != nullptr);
|
||||
assert(varXString != nullptr);
|
||||
|
||||
if(*pXString != nullptr)
|
||||
if (atStreamStart)
|
||||
m_stream->Load<const char*>(varXString);
|
||||
|
||||
if(*varXString != nullptr)
|
||||
{
|
||||
if(*pXString == PTR_FOLLOWING)
|
||||
if(*varXString == PTR_FOLLOWING)
|
||||
{
|
||||
*pXString = m_stream->Alloc<const char>();
|
||||
m_stream->LoadNullTerminated();
|
||||
*varXString = m_stream->Alloc<const char>(alignof(const char));
|
||||
m_stream->LoadNullTerminated(const_cast<char*>(*varXString));
|
||||
}
|
||||
else
|
||||
{
|
||||
*pXString = m_stream->ConvertOffsetToPointer<const char>(*pXString);
|
||||
*varXString = m_stream->ConvertOffsetToPointer<const char>(*varXString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXStringArray(const char** pArray, const size_t count, const bool atStreamStart) const
|
||||
void ContentLoader::LoadXStringArray(const bool atStreamStart, const size_t count) const
|
||||
{
|
||||
assert(pArray != nullptr);
|
||||
assert(varXString != nullptr);
|
||||
|
||||
if(atStreamStart)
|
||||
m_stream->Load<const char*>(count);
|
||||
m_stream->Load<const char*>(varXString, count);
|
||||
|
||||
for(size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXString(&pArray[index]);
|
||||
LoadXString(&varXString[index]);
|
||||
}
|
||||
}
|
@ -9,13 +9,15 @@ protected:
|
||||
static const void* PTR_FOLLOWING;
|
||||
static const void* PTR_INSERT;
|
||||
|
||||
const char** varXString;
|
||||
|
||||
Zone* m_zone;
|
||||
IZoneInputStream* m_stream;
|
||||
|
||||
ContentLoader();
|
||||
|
||||
void LoadXString(const char** pXString) const;
|
||||
void LoadXStringArray(const char** pArray, size_t count, bool atStreamStart) const;
|
||||
void LoadXString(bool atStreamStart) const;
|
||||
void LoadXStringArray(bool atStreamStart, size_t count) const;
|
||||
|
||||
public:
|
||||
virtual ~ContentLoader() = default;
|
||||
|
@ -0,0 +1,16 @@
|
||||
#include "OutOfBlockBoundsException.h"
|
||||
|
||||
OutOfBlockBoundsException::OutOfBlockBoundsException(XBlock* block)
|
||||
{
|
||||
m_block = block;
|
||||
}
|
||||
|
||||
std::string OutOfBlockBoundsException::DetailedMessage()
|
||||
{
|
||||
return "Tried to load to location out of bounds from current XBlock " + m_block->m_name + ".";
|
||||
}
|
||||
|
||||
char const* OutOfBlockBoundsException::what() const
|
||||
{
|
||||
return "Invalid Zone. Out of XBlock bounds.";
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "LoadingException.h"
|
||||
#include "Zone/XBlock.h"
|
||||
|
||||
class OutOfBlockBoundsException final : public LoadingException
|
||||
{
|
||||
XBlock* m_block;
|
||||
|
||||
public:
|
||||
explicit OutOfBlockBoundsException(XBlock* block);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
};
|
Reference in New Issue
Block a user