Skip to content

Commit

Permalink
Merge pull request #43 from Scobalula/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Scobalula authored Nov 2, 2022
2 parents f4f0a63 + 4762d4b commit fab7d27
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 146 deletions.
2 changes: 1 addition & 1 deletion src/WraithXCOD/WraithXCOD/CoDAssets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ ExportGameResult CoDAssets::ExportSoundAsset(const CoDSound_t* Sound, const std:
if (Sound->IsFileEntry)
SoundData = SABSupport::LoadOpusSound(Sound);
else
SoundData = GameVanguard::ReadXSound(Sound);
SoundData = GameModernWarfare5::ReadXSound(Sound);
break;
case SupportedGames::Vanguard:
if (Sound->IsFileEntry)
Expand Down
18 changes: 1 addition & 17 deletions src/WraithXCOD/WraithXCOD/CoDXAnimReader.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
#include "stdafx.h"
#include "CoDXAnimReader.h"

CoDXAnimReader::CoDXAnimReader(uint8_t* Buf, size_t BufSize, bool OwnsBuf)
{
Buffer = Buf;
BufferSize = BufSize;
OwnsBuffer = OwnsBuf;

if (Buf == nullptr && BufSize > 0)
{
Buffer = new uint8_t[BufSize];
}
}

CoDXAnimReader::~CoDXAnimReader()
{
if (OwnsBuffer)
{
delete[] Buffer;
}
}

uint8_t* CoDXAnimReader::GetBuffer()
{
return Buffer;
return nullptr;
}
48 changes: 30 additions & 18 deletions src/WraithXCOD/WraithXCOD/CoDXAnimReader.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
#pragma once

// A class to handle reading a CoD XAnim.
class CoDXAnimReader
// A class to hold an XAnim Buffer.
class CoDXAnimBuffer
{
private:
// The entire xanim data buffer.
uint8_t* Buffer;
// The size of the xanim data buffer.
size_t BufferSize;
// Whether or not we own the buffer.
bool OwnsBuffer;

// The complete xanim buffer as 1 memory blob.
std::unique_ptr<uint8_t[]> Buffer;
public:
// The data byte array.
void* DataBytes;
// The data byte array.
void* DataShorts;
// The data byte array.
void* DataInts;
// The data byte array.
void* RandomDataBytes;
// The data byte array.
void* RandomDataShorts;
// The data byte array.
void* RandomDataInts;
// The data byte array.
void* Indices;
};

// A class to handle reading a CoD XAnim.
class CoDXAnimReader
{
public:
// Initializes the CoD Reader with a buffer.
CoDXAnimReader(uint8_t* Buf, size_t BufSize, bool OwnsBuf);
// Deletes the xanim reader.
~CoDXAnimReader();

Expand All @@ -23,19 +35,19 @@ class CoDXAnimReader
// The array of notetracks by frame index.
std::vector<std::pair<std::string, size_t>> Notetracks;
// The data byte array.
uint8_t* DataBytes;
std::unique_ptr<uint8_t[]> DataBytes;
// The data byte array.
uint8_t* DataShorts;
std::unique_ptr<uint8_t[]> DataShorts;
// The data byte array.
uint8_t* DataInts;
std::unique_ptr<uint8_t[]> DataInts;
// The data byte array.
uint8_t* RandomDataBytes;
std::unique_ptr<uint8_t[]> RandomDataBytes;
// The data byte array.
uint8_t* RandomDataShorts;
std::unique_ptr<uint8_t[]> RandomDataShorts;
// The data byte array.
uint8_t* RandomDataInts;
std::unique_ptr<uint8_t[]> RandomDataInts;
// The data byte array.
uint8_t* Indices;
std::unique_ptr<uint8_t[]> Indices;

// Gets the buffer from the anim.
uint8_t* GetBuffer();
Expand Down
14 changes: 7 additions & 7 deletions src/WraithXCOD/WraithXCOD/CoDXAnimTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,13 @@ std::unique_ptr<WraithAnim> CoDXAnimTranslator::TranslateXAnimReader(const std::

// TODO: Could prob use MemoryReader to make this safer

auto indices = (uint16_t*)Animation->Reader->Indices;
auto dataByte = (uint8_t*)Animation->Reader->DataBytes;
auto dataShort = (int16_t*)Animation->Reader->DataShorts;
auto dataInt = (int32_t*)Animation->Reader->DataInts;
auto randomDataByte = (uint8_t*)Animation->Reader->RandomDataBytes;
auto randomDataShort = (int16_t*)Animation->Reader->RandomDataShorts;
auto randomDataInt = (int32_t*)Animation->Reader->RandomDataInts;
auto indices = (uint16_t*)Animation->Reader->Indices.get();
auto dataByte = (uint8_t*)Animation->Reader->DataBytes.get();
auto dataShort = (int16_t*)Animation->Reader->DataShorts.get();
auto dataInt = (int32_t*)Animation->Reader->DataInts.get();
auto randomDataByte = (uint8_t*)Animation->Reader->RandomDataBytes.get();
auto randomDataShort = (int16_t*)Animation->Reader->RandomDataShorts.get();
auto randomDataInt = (int32_t*)Animation->Reader->RandomDataInts.get();

// Stage 0: Zero-Rotated bones
// Zero-rotated bones must be reset to identity, they are the first set of bones
Expand Down
Loading

0 comments on commit fab7d27

Please sign in to comment.