From 360729120cd942d70e2d66bb907d2727571ca07c Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 15 Apr 2017 16:48:43 +0200 Subject: [PATCH] [General] Allow building custom maps --- src/Components/Modules/AssetHandler.cpp | 5 ----- src/Components/Modules/AssetInterfaces/IGfxWorld.cpp | 4 ---- src/Components/Modules/AssetInterfaces/ILoadedSound.cpp | 6 +++--- src/Components/Modules/AssetInterfaces/IclipMap_t.cpp | 4 ---- src/STDInclude.hpp | 5 ----- src/Utils/Stream.cpp | 5 +++++ src/Utils/Stream.hpp | 1 + 7 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 9a7727fa..9356e5ea 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -440,17 +440,12 @@ namespace Components AssetHandler::RegisterInterface(new Assets::IRawFile()); AssetHandler::RegisterInterface(new Assets::IComWorld()); AssetHandler::RegisterInterface(new Assets::IGfxImage()); -#ifdef ENABLE_EXPERIMENTAL_MAP_CODE AssetHandler::RegisterInterface(new Assets::IGfxWorld()); -#endif AssetHandler::RegisterInterface(new Assets::ISndCurve()); AssetHandler::RegisterInterface(new Assets::IMaterial()); AssetHandler::RegisterInterface(new Assets::IMenuList()); AssetHandler::RegisterInterface(new Assets::ImenuDef_t()); - -#ifdef ENABLE_EXPERIMENTAL_MAP_CODE AssetHandler::RegisterInterface(new Assets::IclipMap_t()); -#endif AssetHandler::RegisterInterface(new Assets::IPhysPreset()); AssetHandler::RegisterInterface(new Assets::IXAnimParts()); AssetHandler::RegisterInterface(new Assets::IFxEffectDef()); diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp index a79f3e91..6d0cd829 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp @@ -2,8 +2,6 @@ #define IW4X_GFXMAP_VERSION 1 -#ifdef ENABLE_EXPERIMENTAL_MAP_CODE - namespace Assets { void IGfxWorld::loadGfxWorldDpvsStatic(Game::GfxWorld* world, Game::GfxWorldDpvsStatic* asset, Components::ZoneBuilder::Zone* builder, Utils::Stream::Reader* reader) @@ -1367,5 +1365,3 @@ namespace Assets SaveLogExit(); } } - -#endif diff --git a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp index 376de25c..f903eaa5 100644 --- a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp +++ b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp @@ -21,7 +21,7 @@ namespace Assets Game::LoadedSound* reference = nullptr; if (!reference) reference = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_LOADED_SOUND, "weapons/c4_detpack/c4_drop_dirt1.wav").loadSnd; - memcpy(sound, reference, sizeof(Game::LoadedSound)); + std::memcpy(sound, reference, sizeof(Game::LoadedSound)); sound->sound.data = nullptr; Utils::Stream::Reader reader(builder->getAllocator(), soundFile.getBuffer()); @@ -68,7 +68,7 @@ namespace Assets // skip any extra parameters if (chunkSize > 16) { - reader.seek(chunkSize - 16); + reader.seekRelative(chunkSize - 16); } } break; @@ -81,7 +81,7 @@ namespace Assets default: if (chunkSize > 0) { - reader.seek(chunkSize); + reader.seekRelative(chunkSize); } break; } diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 3a853711..6e000573 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -2,8 +2,6 @@ #define IW4X_CLIPMAP_VERSION 1 -#ifdef ENABLE_EXPERIMENTAL_MAP_CODE - namespace Assets { void IclipMap_t::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) @@ -913,5 +911,3 @@ namespace Assets header->clipMap = clipMap; } } - -#endif diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index a7a5441f..63103a29 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -155,8 +155,3 @@ using namespace std::literals; #define _APS_NEXT_SYMED_VALUE 101 #endif #endif - -// Enables custom map code -#ifdef DEBUG -#define ENABLE_EXPERIMENTAL_MAP_CODE -#endif diff --git a/src/Utils/Stream.cpp b/src/Utils/Stream.cpp index ac57f996..6ff73adc 100644 --- a/src/Utils/Stream.cpp +++ b/src/Utils/Stream.cpp @@ -59,6 +59,11 @@ namespace Utils } } + void Stream::Reader::seekRelative(unsigned int _position) + { + return this->seek(_position + this->position); + } + void* Stream::Reader::readPointer() { void* pointer = this->read(); diff --git a/src/Utils/Stream.hpp b/src/Utils/Stream.hpp index 9687dcc8..9b5bf558 100644 --- a/src/Utils/Stream.hpp +++ b/src/Utils/Stream.hpp @@ -54,6 +54,7 @@ namespace Utils bool end(); void seek(unsigned int position); + void seekRelative(unsigned int position); void* readPointer(); void mapPointer(void* oldPointer, void* newPointer);