This commit is contained in:
momo5502 2016-11-11 18:05:04 +01:00
parent 52add9ef91
commit aaf9325f07
4 changed files with 8 additions and 4 deletions

View File

@ -129,13 +129,14 @@ namespace Components
if (!surfs->surfaces) if (!surfs->surfaces)
{ {
Assert_Offset(Game::XModelLodInfo, partBits, 12);
Game::XModelSurfs* newSurfs = ModelSurfs::LoadXModelSurfaces(surfs->name); Game::XModelSurfs* newSurfs = ModelSurfs::LoadXModelSurfaces(surfs->name);
surfs->surfaces = newSurfs->surfaces; surfs->surfaces = newSurfs->surfaces;
surfs->numSurfaces = newSurfs->numSurfaces; surfs->numSurfaces = newSurfs->numSurfaces;
model->lods[i].surfs = newSurfs->surfaces; model->lods[i].surfs = newSurfs->surfaces;
std::memcpy(model->lods[i].pad3, newSurfs->pad, 24); std::memcpy(model->lods[i].partBits, newSurfs->pad, 24);
short numSurfs = static_cast<short>(newSurfs->numSurfaces); short numSurfs = static_cast<short>(newSurfs->numSurfaces);
model->lods[i].numSurfs = numSurfs; model->lods[i].numSurfs = numSurfs;

View File

@ -93,8 +93,10 @@ namespace Components
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
Assert_Offset(Game::XModelLodInfo, partBits, 12);
std::memcpy(&model->lods[i], &xmodel[72 + (i * 56)], 12); std::memcpy(&model->lods[i], &xmodel[72 + (i * 56)], 12);
std::memcpy(&model->lods[i].pad3, &xmodel[72 + (i * 56) + 16], 32); std::memcpy(&model->lods[i].partBits, &xmodel[72 + (i * 56) + 16], 32);
std::memcpy(reinterpret_cast<char*>(&model) + (size - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4); std::memcpy(reinterpret_cast<char*>(&model) + (size - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4);
} }

View File

@ -1425,8 +1425,8 @@ namespace Game
short numSurfs; // +4 short numSurfs; // +4
short maxSurfs;// +6 short maxSurfs;// +6
XModelSurfs* surfaces; // +8 XModelSurfs* surfaces; // +8
int partBits[4]; int partBits[4]; // +12
char pad3[8]; // +12 char pad3[8];
XSurface* surfs; XSurface* surfs;
char pad4[4]; char pad4[4];
}; };

View File

@ -141,6 +141,7 @@ using namespace std::literals;
#define CLIENT_CONFIG "iw4x_config.cfg" #define CLIENT_CONFIG "iw4x_config.cfg"
#define Assert_Size(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure has an invalid size.") #define Assert_Size(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure has an invalid size.")
#define Assert_Offset(x, y, offset) static_assert(offsetof(x, y) == offset, STRINGIZE(x) "::" STRINGIZE(y) " is not at the right offset.")
// Resource stuff // Resource stuff
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED