Merge pull request #65 from Rackover/fix_device_recovery

Fix device recovery issues on CODO maps >359
This commit is contained in:
Dss0 2021-02-07 21:32:55 +01:00 committed by GitHub
commit c26c4b4659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 0 deletions

View File

@ -1655,18 +1655,48 @@ namespace Components
image->delayLoadPixels = image359.loaded; image->delayLoadPixels = image359.loaded;
image->name = image359.name; image->name = image359.name;
FixImageCategory(image);
// Used for later stuff // Used for later stuff
(&image->delayLoadPixels)[1] = image359.pad3[1]; (&image->delayLoadPixels)[1] = image359.pad3[1];
} }
else else
{ {
std::memcpy(buffer + 28, buffer + (size - 4), 4); std::memcpy(buffer + 28, buffer + (size - 4), 4);
Game::GfxImage* image = reinterpret_cast<Game::GfxImage*>(buffer);
FixImageCategory(image);
} }
} }
return result; return result;
} }
void Zones::FixImageCategory(Game::GfxImage* image) {
// CODO makes use of additional enumerator values (9, 10, 11) that don't exist in IW4
// We have to translate them. 9 is for Reflection probes, 11 is for Compass, 10 is for Lightmap
switch (image->category)
{
case 9:
image->category = Game::ImageCategory::IMG_CATEGORY_AUTO_GENERATED;
break;
case 10:
image->category = Game::ImageCategory::IMG_CATEGORY_LIGHTMAP;
break;
case 11:
image->category = Game::ImageCategory::IMG_CATEGORY_LOAD_FROM_FILE;
break;
}
if (image->category > 7 || image->category < 0) {
#ifdef DEBUG
if (IsDebuggerPresent()) __debugbreak();
#endif
}
}
bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size) bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size)
{ {
int count = 0; int count = 0;

View File

@ -100,5 +100,6 @@ namespace Components
static void LoadMaterialAsset(Game::Material** asset); static void LoadMaterialAsset(Game::Material** asset);
static void LoadTracerDef(bool atStreamStart, Game::TracerDef* tracer, int size); static void LoadTracerDef(bool atStreamStart, Game::TracerDef* tracer, int size);
static void LoadTracerDefFxEffect(); static void LoadTracerDefFxEffect();
static void FixImageCategory(Game::GfxImage* image);
}; };
} }

View File

@ -98,6 +98,19 @@ namespace Game
DVAR_FLAG_NONEXISTENT = 0xFFFFFFFF //no such dvar DVAR_FLAG_NONEXISTENT = 0xFFFFFFFF //no such dvar
} dvar_flag; } dvar_flag;
enum ImageCategory : char
{
IMG_CATEGORY_UNKNOWN = 0x0,
IMG_CATEGORY_AUTO_GENERATED = 0x1,
IMG_CATEGORY_LIGHTMAP = 0x2,
IMG_CATEGORY_LOAD_FROM_FILE = 0x3,
IMG_CATEGORY_RAW = 0x4,
IMG_CATEGORY_FIRST_UNMANAGED = 0x5,
IMG_CATEGORY_WATER = 0x5,
IMG_CATEGORY_RENDERTARGET = 0x6,
IMG_CATEGORY_TEMP = 0x7,
} ;
enum DvarSetSource enum DvarSetSource
{ {
DVAR_SOURCE_INTERNAL = 0x0, DVAR_SOURCE_INTERNAL = 0x0,