Merge branch 'implement-new-codo-maps' into 'develop'
"Implement new CODO maps" (Step 1)
This commit is contained in:
commit
ac00a60a25
@ -116,15 +116,13 @@ namespace Components
|
||||
bool AssetHandler::IsAssetEligible(Game::XAssetType type, Game::XAssetHeader *asset)
|
||||
{
|
||||
const char* name = Game::DB_GetXAssetNameHandlers[type](asset);
|
||||
if (!name) return false;
|
||||
|
||||
// Should we perform the null check before or after this?
|
||||
if (Flags::HasFlag("entries"))
|
||||
{
|
||||
OutputDebugStringA(Utils::String::VA("%s: %d: %s\n", FastFiles::Current().data(), type, name));
|
||||
}
|
||||
|
||||
if (!name) return false;
|
||||
|
||||
bool restrict = false;
|
||||
AssetHandler::RestrictSignal(type, *asset, name, &restrict);
|
||||
|
||||
@ -190,9 +188,7 @@ namespace Components
|
||||
}
|
||||
|
||||
offset->pointer = *reinterpret_cast<void**>(pointer);
|
||||
|
||||
//Game::XAssetHeader zob{ offset->pointer };
|
||||
}
|
||||
}
|
||||
|
||||
void AssetHandler::ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder)
|
||||
{
|
||||
|
@ -25,5 +25,27 @@ namespace Components
|
||||
#ifndef DEBUG
|
||||
QuickPatch::OnFrame(AntiCheat::FlagIntegrityCheck);
|
||||
#endif
|
||||
|
||||
Command::Add("dumpraw", [] (Command::Params params)
|
||||
{
|
||||
if (params.Length() < 2)
|
||||
{
|
||||
Logger::Print("Specify a filename!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string filename = params[1];
|
||||
const char* data = Game::LoadModdableRawfile(0, filename.data());
|
||||
|
||||
if (data)
|
||||
{
|
||||
Utils::IO::WriteFile("raw/" + filename, data);
|
||||
Logger::Print("File '%s' written to raw!\n", filename.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Print("File '%s' does not exist!\n", filename.data());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -523,15 +523,15 @@ namespace Components
|
||||
Utils::Memory::Allocator allocator;
|
||||
Game::snd_alias_t* tempSounds = allocator.AllocateArray<Game::snd_alias_t>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
char* src = &buffer[i * 108];
|
||||
|
||||
std::memcpy(&tempSounds[i], src + 0, 60);
|
||||
std::memcpy(&tempSounds[i], src + 0, 60);
|
||||
std::memcpy(&tempSounds[i].pad2[36], src + 68, 20);
|
||||
std::memcpy(&tempSounds[i].pad2[56], src + 88, 20);
|
||||
|
||||
AssetHandler::Relocate(src + 0, buffer + (i * 100) + 0, 60);
|
||||
AssetHandler::Relocate(src + 0, buffer + (i * 100) + 0, 60);
|
||||
AssetHandler::Relocate(src + 68, buffer + (i * 100) + 60, 20);
|
||||
AssetHandler::Relocate(src + 88, buffer + (i * 100) + 80, 20);
|
||||
}
|
||||
@ -554,7 +554,7 @@ namespace Components
|
||||
bool Zones::LoadVehicleDef(bool atStreamStart, char* buffer)
|
||||
{
|
||||
bool result = Game::Load_Stream(atStreamStart, buffer, 788);
|
||||
|
||||
|
||||
Game::VehicleDef vehicle[2];
|
||||
std::memcpy(vehicle, &buffer[0], 400);
|
||||
std::memcpy(&vehicle->pad[404], &buffer[400], 388);
|
||||
@ -671,6 +671,7 @@ namespace Components
|
||||
|
||||
memcpy(buffer + 28, buffer + 32, 4);
|
||||
AssetHandler::Relocate(buffer + 32, buffer + 28, 4);
|
||||
//AssetHandler::Relocate(buffer + 28, buffer + 32, 4); // There is no point in storing the LoadDef
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -718,7 +719,7 @@ namespace Components
|
||||
Utils::Hook::Set<BYTE>(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS);
|
||||
|
||||
// Change block for images
|
||||
//Utils::Hook::Set<BYTE>(0x4C13E4, ((Zones::ZoneVersion >= 332) ? 3 : 0));
|
||||
Utils::Hook::Set<BYTE>(0x4D3224, ((Zones::ZoneVersion >= 332) ? 3 : 0));
|
||||
|
||||
if (patch)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ namespace Game
|
||||
typedef void(__cdecl * Live_ParsePlaylists_t)(const char* data);
|
||||
extern Live_ParsePlaylists_t Live_ParsePlaylists;
|
||||
|
||||
typedef void* (__cdecl * LoadModdableRawfile_t)(int a1, const char* filename);
|
||||
typedef char* (__cdecl * LoadModdableRawfile_t)(int a1, const char* filename);
|
||||
extern LoadModdableRawfile_t LoadModdableRawfile;
|
||||
|
||||
typedef int(__cdecl * PC_ReadToken_t)(source_t*, token_t*);
|
||||
|
@ -86,6 +86,7 @@
|
||||
|
||||
#include "Utils\IO.hpp"
|
||||
#include "Utils\CSV.hpp"
|
||||
#include "Utils\Chain.hpp"
|
||||
#include "Utils\Utils.hpp"
|
||||
#include "Utils\WebIO.hpp"
|
||||
#include "Utils\Memory.hpp"
|
||||
|
151
src/Utils/Chain.hpp
Normal file
151
src/Utils/Chain.hpp
Normal file
@ -0,0 +1,151 @@
|
||||
namespace Utils
|
||||
{
|
||||
template <typename T>
|
||||
class Chain
|
||||
{
|
||||
public:
|
||||
class Entry
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<T> Object;
|
||||
std::shared_ptr<Entry> Next;
|
||||
|
||||
public:
|
||||
bool HasNext()
|
||||
{
|
||||
return (this->Next.use_count() > 0);
|
||||
}
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return (this->Object.use_count() > 0);
|
||||
}
|
||||
|
||||
void Set(T object)
|
||||
{
|
||||
this->Object = std::shared_ptr<T>(new T());
|
||||
*this->Object.get() = object;
|
||||
}
|
||||
|
||||
std::shared_ptr<T> Get()
|
||||
{
|
||||
return this->Object;
|
||||
}
|
||||
|
||||
Entry GetNext()
|
||||
{
|
||||
if (this->HasNext())
|
||||
{
|
||||
return *(this->Next.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
return Entry();
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Entry> GetNextEntry()
|
||||
{
|
||||
return this->Next;
|
||||
}
|
||||
|
||||
void SetNextEntry(std::shared_ptr<Entry> entry)
|
||||
{
|
||||
this->Next = entry;
|
||||
}
|
||||
|
||||
T *operator->()
|
||||
{
|
||||
return (this->Object.get());
|
||||
}
|
||||
|
||||
Entry& operator++ ()
|
||||
{
|
||||
*this = this->GetNext();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Entry operator++ (int)
|
||||
{
|
||||
Entry result = *this;
|
||||
this->operator++();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::mutex Mutex;
|
||||
Entry Object;
|
||||
|
||||
public:
|
||||
void Add(T object)
|
||||
{
|
||||
this->Mutex.lock();
|
||||
|
||||
if (!this->Empty())
|
||||
{
|
||||
// Create new chain entry
|
||||
std::shared_ptr<Entry> currentObject = std::shared_ptr<Entry>(new Entry);
|
||||
*currentObject.get() = this->Object;
|
||||
|
||||
// Add it to the chain
|
||||
this->Object = Entry();
|
||||
this->Object.SetNextEntry(currentObject);
|
||||
}
|
||||
|
||||
this->Object.Set(object);
|
||||
|
||||
this->Mutex.unlock();
|
||||
}
|
||||
|
||||
void Remove(std::shared_ptr<T> object)
|
||||
{
|
||||
this->Mutex.lock();
|
||||
|
||||
if (!this->Empty())
|
||||
{
|
||||
if (this->Object.Get().get() == object.get())
|
||||
{
|
||||
this->Object = this->Object.GetNext();
|
||||
}
|
||||
else if(this->Object.HasNext())
|
||||
{
|
||||
for (auto entry = this->Object; entry.IsValid(); ++entry)
|
||||
{
|
||||
auto next = entry.GetNext();
|
||||
|
||||
if (next.IsValid() && next.Get().get() == object.get())
|
||||
{
|
||||
*entry.GetNextEntry().get() = next.GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->Mutex.unlock();
|
||||
}
|
||||
|
||||
void Remove(Entry entry)
|
||||
{
|
||||
if (entry.IsValid())
|
||||
{
|
||||
this->Remove(entry.Get());
|
||||
}
|
||||
}
|
||||
|
||||
bool Empty()
|
||||
{
|
||||
return !this->Object.IsValid();
|
||||
}
|
||||
|
||||
Entry Begin()
|
||||
{
|
||||
return this->Object;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
this->Object = Entry();
|
||||
}
|
||||
};
|
||||
}
|
@ -11,6 +11,8 @@ namespace Utils
|
||||
|
||||
void WriteFile(std::string file, std::string data)
|
||||
{
|
||||
CreateDirectory(file.substr(0, file.find_last_of("/\\")));
|
||||
|
||||
std::ofstream stream(file, std::ios::binary);
|
||||
|
||||
if (stream.is_open())
|
||||
|
Loading…
Reference in New Issue
Block a user