Skip to content

Commit

Permalink
various changes for building fastfiles on IW5
Browse files Browse the repository at this point in the history
  • Loading branch information
RektInator committed Nov 29, 2020
1 parent 9e99162 commit 5fbc3a1
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 181 deletions.
2 changes: 1 addition & 1 deletion src/IW5/Assets/AttachmentDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace ZoneTool
if (name == "cheytacscope")
{
auto scope = mem->Alloc<AttachmentDef>();
auto base = DB_FindXAssetHeader(attachment, /*name.data()*/ "l96a1scope", 1).attachment;
auto base = DB_FindXAssetHeader(attachment, /*name.data()*/ "msrscope", 1).attachment;

memcpy(scope, base, sizeof AttachmentDef);
scope->szInternalName = mem->StrDup(name);
Expand Down
87 changes: 49 additions & 38 deletions src/IW5/Assets/ClipMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace ZoneTool
VMProtectBeginUltra("IW5::IClipMap::parse");
#endif

auto colmap = mem->Alloc<clipMap_t>();
auto* colmap = mem->Alloc<clipMap_t>();

colmap->name = read.read_string();
colmap->isInUse = read.read_int();
Expand Down Expand Up @@ -255,6 +255,17 @@ colmap->dynEntDefList[_num1][_num2]._item = newEntDef[_num2]._item;
colmap->dynEntClientList[1] = new DynEntityClient[colmap->dynEntCount[1]];
colmap->dynEntCollList[0] = new DynEntityColl[colmap->dynEntCount[0]];
colmap->dynEntCollList[1] = new DynEntityColl[colmap->dynEntCount[1]];
#else
colmap->dynEntDefList[0] = 0;
colmap->dynEntDefList[1] = 0;
colmap->dynEntPoseList[0] = 0;
colmap->dynEntPoseList[1] = 0;
colmap->dynEntClientList[0] = 0;
colmap->dynEntClientList[1] = 0;
colmap->dynEntCollList[0] = 0;
colmap->dynEntCollList[1] = 0;
colmap->dynEntCount[0] = 0;
colmap->dynEntCount[1] = 0;
#endif

// parse stages
Expand Down Expand Up @@ -332,43 +343,43 @@ colmap->dynEntDefList[_num1][_num2]._item = newEntDef[_num2]._item;
}
}

if (data->dynEntDefList[0])
{
for (int i = 0; i < data->dynEntCount[0]; i++)
{
if (data->dynEntDefList[0][i].xModel)
{
zone->add_asset_of_type(xmodel, data->dynEntDefList[0][i].xModel->name);
}
if (data->dynEntDefList[0][i].destroyFx)
{
zone->add_asset_of_type(fx, data->dynEntDefList[0][i].destroyFx->name);
}
if (data->dynEntDefList[0][i].physPreset)
{
zone->add_asset_of_type(physpreset, data->dynEntDefList[0][i].physPreset->name);
}
}
}

if (data->dynEntDefList[1])
{
for (int i = 0; i < data->dynEntCount[1]; i++)
{
if (data->dynEntDefList[1][i].xModel)
{
zone->add_asset_of_type(xmodel, data->dynEntDefList[1][i].xModel->name);
}
if (data->dynEntDefList[1][i].destroyFx)
{
zone->add_asset_of_type(fx, data->dynEntDefList[1][i].destroyFx->name);
}
if (data->dynEntDefList[1][i].physPreset)
{
zone->add_asset_of_type(physpreset, data->dynEntDefList[1][i].physPreset->name);
}
}
}
//if (data->dynEntDefList[0])
//{
// for (int i = 0; i < data->dynEntCount[0]; i++)
// {
// if (data->dynEntDefList[0][i].xModel)
// {
// zone->add_asset_of_type(xmodel, data->dynEntDefList[0][i].xModel->name);
// }
// if (data->dynEntDefList[0][i].destroyFx)
// {
// zone->add_asset_of_type(fx, data->dynEntDefList[0][i].destroyFx->name);
// }
// if (data->dynEntDefList[0][i].physPreset)
// {
// zone->add_asset_of_type(physpreset, data->dynEntDefList[0][i].physPreset->name);
// }
// }
//}

//if (data->dynEntDefList[1])
//{
// for (int i = 0; i < data->dynEntCount[1]; i++)
// {
// if (data->dynEntDefList[1][i].xModel)
// {
// zone->add_asset_of_type(xmodel, data->dynEntDefList[1][i].xModel->name);
// }
// if (data->dynEntDefList[1][i].destroyFx)
// {
// zone->add_asset_of_type(fx, data->dynEntDefList[1][i].destroyFx->name);
// }
// if (data->dynEntDefList[1][i].physPreset)
// {
// zone->add_asset_of_type(physpreset, data->dynEntDefList[1][i].physPreset->name);
// }
// }
//}

if (data->mapEnts)
{
Expand Down
48 changes: 46 additions & 2 deletions src/IW5/Assets/XModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ namespace ZoneTool
asset->physPreset = read.read_asset<PhysPreset>();
asset->physCollmap = read.read_asset<PhysCollmap>();

// fix tags
for (auto i = 0u; i < asset->numBones; i++)
{
auto tag_name = std::string(SL_ConvertToString(asset->boneNames[i]));

// fix xmodel tags
if (tag_name.find("tag_") != std::string::npos &&
tag_name.find("_scope") != std::string::npos &&
tag_name.find("thermal") == std::string::npos)
{
ZONETOOL_INFO("fixing tag %s -> tag_scope", tag_name.data());
asset->boneNames[i] = SL_AllocString("tag_scope");
}
}

#ifdef USE_VMPROTECT
VMProtectEnd();
#endif
Expand All @@ -116,8 +131,7 @@ namespace ZoneTool
{
this->is_scope_model_ = false;
this->name_ = name;
this->asset_ = this->parse(name, mem);


if ((name.find("weapon_") != std::string::npos || name.find("viewmodel_") != std::string::npos) &&
name.find("_scope") != std::string::npos &&
!FileSystem::FileExists("XModel\\" + name + ".xme6"))
Expand Down Expand Up @@ -176,11 +190,41 @@ namespace ZoneTool
model->lods[0].surfaces->xSurficies = new XSurface[allocated_surfaces.size()];
memcpy(model->lods[0].surfaces->xSurficies, allocated_surfaces.data(), sizeof XSurface * allocated_surfaces.size());

// remove all bones besides for tag_scope
XBoneInfo scope_info = {};
auto found_bone = false;

for (auto i = 0u; i < model->numBones; i++)
{
if (SL_ConvertToString(model->boneNames[i]) == "tag_scope"s)
{
memcpy(&scope_info, &model->boneInfo[i], sizeof XBoneInfo);
found_bone = true;
break;
}
}

if (found_bone)
{
model->numBones = 1;
model->numRootBones = 1;
memcpy(&model->boneInfo[0], &scope_info, sizeof XBoneInfo);
model->boneNames[0] = SL_AllocString("tag_scope");
}
else
{
ZONETOOL_FATAL("You dun goofed");
}

//
this->is_scope_model_ = true;
this->asset_ = model;
}
}
else
{
this->asset_ = this->parse(name, mem);
}

// don't reparse the surfaces
// this->is_scope_model_ = true;
Expand Down
6 changes: 3 additions & 3 deletions src/ZoneTool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ function ZoneTool:project()

filter "toolset:msc*"
postbuildcommands {
"if \"%COMPUTERNAME%\" == \"DESKTOP-CDFBECH\" ( copy /y \"$(TargetPath)\" \"E:\\SteamLibrary\\steamapps\\common\\Call of Duty 4\\zoneiw3.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-CDFBECH\" ( copy /y \"$(TargetPath)\" \"E:\\SteamLibrary\\steamapps\\common\\Call of Duty Modern Warfare 2\\zonetool.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-CDFBECH\" ( copy /y \"$(TargetPath)\" \"E:\\SteamLibrary\\steamapps\\common\\Call of Duty Modern Warfare 3\\zonetool.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-QM2NUQP\" ( copy /y \"$(TargetPath)\" \"H:\\SteamLibrary\\steamapps\\common\\Call of Duty 4\\zoneiw3.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-QM2NUQP\" ( copy /y \"$(TargetPath)\" \"H:\\SteamLibrary\\steamapps\\common\\Call of Duty Modern Warfare 2\\zonetool.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-QM2NUQP\" ( copy /y \"$(TargetPath)\" \"H:\\SteamLibrary\\steamapps\\common\\Call of Duty Modern Warfare 3\\zonetool.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-G5EPE91\" ( copy /y \"$(TargetPath)\" \"D:\\Program Files (x86)\\Steam\\steamapps\\common\\Call of Duty 4\\zoneiw3.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-G5EPE91\" ( copy /y \"$(TargetPath)\" \"D:\\Program Files (x86)\\Steam\\steamapps\\common\\Call of Duty Modern Warfare 2\\zonetool.dll\" )",
"if \"%COMPUTERNAME%\" == \"DESKTOP-G5EPE91\" ( copy /y \"$(TargetPath)\" \"D:\\Program Files (x86)\\Steam\\steamapps\\common\\Call of Duty Modern Warfare 3\\zonetool.dll\" )",
Expand Down
7 changes: 4 additions & 3 deletions src/ZoneUtils/ZoneUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ namespace ZoneTool
printf("[ ERROR ][ " __FUNCTION__ " ]: " __FMT__ "\n", __VA_ARGS__)

#define ZONETOOL_FATAL(__FMT__,...) \
printf("[ FATAL ][ " __FUNCTION__ " ]: " __FMT__ "\n", __VA_ARGS__); \
MessageBoxA(nullptr, &va("Oops! An unexpected error occured. Error was: " __FMT__ "\n\nZoneTool must be restarted to resolve the error. Last error code reported by windows: 0x%08X (%u)", __VA_ARGS__, GetLastError(), GetLastError())[0], nullptr, 0); \
std::exit(0)
printf("[ FATAL ][ " __FUNCTION__ " ]: " __FMT__ "\n", __VA_ARGS__)

//MessageBoxA(nullptr, &va("Oops! An unexpected error occured. Error was: " __FMT__ "\n\nZoneTool must be restarted to resolve the error. Last error code reported by windows: 0x%08X (%u)", __VA_ARGS__, GetLastError(), GetLastError())[0], nullptr, 0); \
// std::exit(0)

#define ZONETOOL_WARNING(__FMT__,...) \
printf("[ WARNING ][ " __FUNCTION__ " ]: " __FMT__ "\n", __VA_ARGS__)
Expand Down
Loading

0 comments on commit 5fbc3a1

Please sign in to comment.