Skip to content

Commit

Permalink
partial refactor of zonetool source code
Browse files Browse the repository at this point in the history
  • Loading branch information
RektInator committed Nov 1, 2019
1 parent 9f02928 commit f42658e
Show file tree
Hide file tree
Showing 156 changed files with 2,285 additions and 2,285 deletions.
6 changes: 3 additions & 3 deletions src/CODO/Assets/LocalizeEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ namespace ZoneTool::CODO
{
}

void ILocalizeEntry::init(const std::string& name, std::shared_ptr<ZoneMemory>& mem)
void ILocalizeEntry::init(const std::string& name, ZoneMemory* mem)
{
this->m_name = name;
this->m_asset = DB_FindXAssetHeader(this->type(), this->name().data()).localize;
}

void ILocalizeEntry::prepare(std::shared_ptr<ZoneBuffer>& buf, std::shared_ptr<ZoneMemory>& mem)
void ILocalizeEntry::prepare(ZoneBuffer* buf, ZoneMemory* mem)
{
}

Expand All @@ -42,7 +42,7 @@ namespace ZoneTool::CODO
return localize;
}

void ILocalizeEntry::write(IZone* zone, std::shared_ptr<ZoneBuffer>& buf)
void ILocalizeEntry::write(IZone* zone, ZoneBuffer* buf)
{
auto data = this->m_asset;
auto dest = buf->write(data);
Expand Down
6 changes: 3 additions & 3 deletions src/CODO/Assets/LocalizeEntry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace ZoneTool::CODO
ILocalizeEntry();
~ILocalizeEntry();

void init(const std::string& name, std::shared_ptr<ZoneMemory>& mem) override;
void prepare(std::shared_ptr<ZoneBuffer>& buf, std::shared_ptr<ZoneMemory>& mem) override;
void init(const std::string& name, ZoneMemory* mem) override;
void prepare(ZoneBuffer* buf, ZoneMemory* mem) override;
void load_depending(IZone* zone) override;

std::string name() override;
std::int32_t type() override;
void write(IZone* zone, std::shared_ptr<ZoneBuffer>& buffer) override;
void write(IZone* zone, ZoneBuffer* buffer) override;

static void dump(LocalizeEntry* asset);
};
Expand Down
8 changes: 4 additions & 4 deletions src/CODO/Assets/StringTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace ZoneTool::CODO
return hash;
}

StringTable* StringTable_Parse(std::string name, std::shared_ptr<ZoneMemory>& mem)
StringTable* StringTable_Parse(std::string name, ZoneMemory* mem)
{
auto table = std::make_unique<CSV>(name);
auto stringtable = mem->Alloc<StringTable>();
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace ZoneTool::CODO
{
}

void IStringTable::init(const std::string& name, std::shared_ptr<ZoneMemory>& mem)
void IStringTable::init(const std::string& name, ZoneMemory* mem)
{
this->m_name = name;
this->m_asset = DB_FindXAssetHeader(this->type(), this->name().data()).stringtable;
Expand All @@ -151,7 +151,7 @@ namespace ZoneTool::CODO
}
}

void IStringTable::prepare(std::shared_ptr<ZoneBuffer>& buf, std::shared_ptr<ZoneMemory>& mem)
void IStringTable::prepare(ZoneBuffer* buf, ZoneMemory* mem)
{
}

Expand All @@ -169,7 +169,7 @@ namespace ZoneTool::CODO
return stringtable;
}

void IStringTable::write(IZone* zone, std::shared_ptr<ZoneBuffer>& buf)
void IStringTable::write(IZone* zone, ZoneBuffer* buf)
{
auto data = this->m_asset;
auto dest = buf->write(data);
Expand Down
6 changes: 3 additions & 3 deletions src/CODO/Assets/StringTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace ZoneTool::CODO
IStringTable();
~IStringTable();

void init(const std::string& name, std::shared_ptr<ZoneMemory>& mem) override;
void prepare(std::shared_ptr<ZoneBuffer>& buf, std::shared_ptr<ZoneMemory>& mem) override;
void init(const std::string& name, ZoneMemory* mem) override;
void prepare(ZoneBuffer* buf, ZoneMemory* mem) override;
void load_depending(IZone* zone) override;

std::string name() override;
std::int32_t type() override;
void write(IZone* zone, std::shared_ptr<ZoneBuffer>& buffer) override;
void write(IZone* zone, ZoneBuffer* buffer) override;

static void dump(StringTable* asset);
};
Expand Down
40 changes: 20 additions & 20 deletions src/CODO/CODO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace ZoneTool::CODO
{
const char* Linker::Version()
const char* Linker::version()
{
return "CODO";
}

bool Linker::InUse()
bool Linker::is_used()
{
return false;
}
Expand All @@ -40,29 +40,29 @@ namespace ZoneTool::CODO
return "";
}

void Linker::Startup()
void Linker::startup()
{
if (this->InUse())
if (this->is_used())
{
// todo
}
}

std::shared_ptr<IZone> Linker::AllocZone(std::string& zone)
std::shared_ptr<IZone> Linker::alloc_zone(const std::string& zone)
{
// allocate zone
auto ptr = std::make_shared<Zone>(zone, this);
return ptr;
}

std::shared_ptr<ZoneBuffer> Linker::AllocBuffer()
std::shared_ptr<ZoneBuffer> Linker::alloc_buffer()
{
auto ptr = std::make_shared<ZoneBuffer>();
ptr->init_streams(8);
return ptr;
}

void Linker::LoadZone(std::string& name)
void Linker::load_zone(const std::string& name)
{
ZONETOOL_INFO("Loading zone \"%s\"...", name.data());

Expand All @@ -72,16 +72,16 @@ namespace ZoneTool::CODO
ZONETOOL_INFO("Zone \"%s\" loaded.", name.data());
}

void Linker::UnloadZones()
void Linker::unload_zones()
{
}

bool Linker::IsValidAssetType(std::string& type)
bool Linker::is_valid_asset_type(std::string& type)
{
return this->TypeToInt(type) >= 0;
return this->type_to_int(type) >= 0;
}

std::int32_t Linker::TypeToInt(std::string type)
std::int32_t Linker::type_to_int(std::string type)
{
auto xassettypes = reinterpret_cast<char**>(0x00799278);

Expand All @@ -94,35 +94,35 @@ namespace ZoneTool::CODO
return -1;
}

std::string Linker::TypeToString(std::int32_t type)
std::string Linker::type_to_string(std::int32_t type)
{
auto xassettypes = reinterpret_cast<char**>(0x00799278);
return xassettypes[type];
}

bool Linker::SupportsBuilding()
bool Linker::supports_building()
{
return false;
}

void Linker::DumpZone(std::string& name)
void Linker::dump_zone(const std::string& name)
{
//isDumpingComplete = false;
//isDumping = true;
//is_dumping_complete = false;
//is_dumping = true;
//currentDumpingZone = name;
LoadZone(name);
load_zone(name);

//while (!isDumpingComplete)
//while (!is_dumping_complete)
//{
// Sleep(1);
//}
}

void Linker::VerifyZone(std::string& name)
void Linker::verify_zone(const std::string& name)
{
//isVerifying = true;
//currentDumpingZone = name;
LoadZone(name);
load_zone(name);
}

Linker::Linker()
Expand Down
26 changes: 13 additions & 13 deletions src/CODO/CODO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ namespace ZoneTool::CODO
Linker();
~Linker();

const char* Version() override;
bool InUse() override;
void Startup() override;
std::shared_ptr<IZone> AllocZone(std::string& zone) override;
std::shared_ptr<ZoneBuffer> AllocBuffer() override;
void LoadZone(std::string& name) override;
void UnloadZones() override;
bool IsValidAssetType(std::string& type) override;
std::int32_t TypeToInt(std::string type) override;
std::string TypeToString(std::int32_t type) override;
bool SupportsBuilding() override;
const char* version() override;
bool is_used() override;
void startup() override;
std::shared_ptr<IZone> alloc_zone(const std::string& zone) override;
std::shared_ptr<ZoneBuffer> alloc_buffer() override;
void load_zone(const std::string& name) override;
void unload_zones() override;
bool is_valid_asset_type(std::string& type) override;
std::int32_t type_to_int(std::string type) override;
std::string type_to_string(std::int32_t type) override;
bool supports_building() override;

void DumpZone(std::string& name) override;
void VerifyZone(std::string& name) override;
void dump_zone(const std::string& name) override;
void verify_zone(const std::string& name) override;

static const char* GetAssetName(XAssetType type, XAssetHeader header);
};
Expand Down
4 changes: 2 additions & 2 deletions src/CODO/Functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ namespace ZoneTool::CODO

static const char* SL_ConvertToString(std::uint16_t index)
{
return Memory::Func<const char*(int)>(0x004EC1D0)(index);
return Memory::func<const char*(int)>(0x004EC1D0)(index);
}

static short SL_AllocString(const std::string& string)
{
return Memory::Func<short(const char*, std::uint32_t, std::size_t)>(0x00436B40)(
return Memory::func<short(const char*, std::uint32_t, std::size_t)>(0x00436B40)(
string.data(), 1, string.size() + 1);
}
}
26 changes: 13 additions & 13 deletions src/CODO/Zone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace ZoneTool::CODO
{
IAsset* Zone::FindAsset(std::int32_t type, std::string name)
IAsset* Zone::find_asset(std::int32_t type, const std::string& name)
{
for (auto idx = 0u; idx < m_assets.size(); idx++)
{
Expand All @@ -23,7 +23,7 @@ namespace ZoneTool::CODO
return nullptr;
}

void* Zone::GetAssetPointer(std::int32_t type, std::string name)
void* Zone::get_asset_pointer(std::int32_t type, const std::string& name)
{
for (auto idx = 0u; idx < m_assets.size(); idx++)
{
Expand All @@ -39,7 +39,7 @@ namespace ZoneTool::CODO
return nullptr;
}

void Zone::AddAssetOfTypePtr(std::int32_t type, void* pointer)
void Zone::add_asset_of_type_by_pointer(std::int32_t type, void* pointer)
{
#ifdef USE_VMPROTECT
VMProtectBeginUltra("IW4::Zone::AddAssetOfTypePtr");
Expand Down Expand Up @@ -75,14 +75,14 @@ namespace ZoneTool::CODO
#endif
}

void Zone::AddAssetOfType(std::int32_t type, const std::string& name)
void Zone::add_asset_of_type(std::int32_t type, const std::string& name)
{
#ifdef USE_VMPROTECT
VMProtectBeginUltra("IW4::Zone::AddAssetOfType");
#endif

// don't add asset if it already exists
if (GetAssetPointer(type, name))
if (get_asset_pointer(type, name))
{
return;
}
Expand All @@ -91,7 +91,7 @@ namespace ZoneTool::CODO
if (type == __type__) \
{ \
auto asset = std::make_shared < __interface__ >(); \
asset->init(name, this->m_zonemem); \
asset->init(name, this->m_zonemem.get()); \
asset->load_depending(this); \
m_assets.push_back(asset); \
}
Expand Down Expand Up @@ -133,18 +133,18 @@ namespace ZoneTool::CODO
#endif
}

void Zone::AddAssetOfType(const std::string& type, const std::string& name)
void Zone::add_asset_of_type(const std::string& type, const std::string& name)
{
std::int32_t itype = m_linker->TypeToInt(type);
this->AddAssetOfType(itype, name);
std::int32_t itype = m_linker->type_to_int(type);
this->add_asset_of_type(itype, name);
}

std::int32_t Zone::GetTypeByName(const std::string& type)
std::int32_t Zone::get_type_by_name(const std::string& type)
{
return m_linker->TypeToInt(type);
return m_linker->type_to_int(type);
}

void Zone::Build(std::shared_ptr<ZoneBuffer>& buf)
void Zone::build(ZoneBuffer* buf)
{
auto startTime = GetTickCount64();

Expand All @@ -170,7 +170,7 @@ namespace ZoneTool::CODO
// write asset types to header
for (auto i = 0u; i < m_assets.size(); i++)
{
m_assets[i]->prepare(buf, this->m_zonemem);
m_assets[i]->prepare(buf, this->m_zonemem.get());
}

// write scriptstring count
Expand Down
14 changes: 7 additions & 7 deletions src/CODO/Zone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ namespace ZoneTool::CODO
Zone(std::string name, ILinker* linker);
~Zone();

IAsset* FindAsset(std::int32_t type, std::string name) override;
void* Zone::GetAssetPointer(std::int32_t type, std::string name) override;
IAsset* find_asset(std::int32_t type, const std::string& name) override;
void* Zone::get_asset_pointer(std::int32_t type, const std::string& name) override;

void AddAssetOfTypePtr(std::int32_t type, void* pointer) override;
void add_asset_of_type_by_pointer(std::int32_t type, void* pointer) override;

void AddAssetOfType(std::int32_t type, const std::string& name) override;
void AddAssetOfType(const std::string& type, const std::string& name) override;
std::int32_t GetTypeByName(const std::string& type) override;
void add_asset_of_type(std::int32_t type, const std::string& name) override;
void add_asset_of_type(const std::string& type, const std::string& name) override;
std::int32_t get_type_by_name(const std::string& type) override;

void Build(std::shared_ptr<ZoneBuffer>& buf) override;
void build(ZoneBuffer* buf) override;
};
}
2 changes: 1 addition & 1 deletion src/IW3/Assets/XAnimParts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace ZoneTool
// dump asset
IW4::IXAnimParts::dump(asset, SL_ConvertToString);

// free memory
// free memory_
delete[] asset;
}
}
Expand Down
Loading

0 comments on commit f42658e

Please sign in to comment.