From 66e9b868b0083859479b43ce965a2078b12f8b92 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 18 Oct 2016 21:40:50 +0200 Subject: [PATCH 1/5] Zone experiments --- src/Components/Modules/AssetHandler.cpp | 224 ++++++++++++++++++++++++ src/Components/Modules/Zones.cpp | 46 ++++- 2 files changed, 267 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 00eaa136..28bef154 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -132,6 +132,230 @@ namespace Components } } + if (type == 20/* && name == "maps/mp/mp_underpass.d3dbsp"s*/) + { + char* world = nullptr; + Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_FX_MAP, [] (Game::XAssetHeader header, void* world) + { + *reinterpret_cast(world) = header.gfxMap; + }, &world, false); + + if (world) + { + //std::memcpy(world + 4, &asset->rawfile->sizeCompressed, Game::DB_GetXAssetSizeHandlers[Game::XAssetType::ASSET_TYPE_FX_MAP]() - 4); + } + } + + if (type == 22) + { + OutputDebugStringA(Utils::String::VA("%s: %s\n", FastFiles::Current().data(), name)); + } + + + if (type <= 9 && type >= 6 && Zones::Version() >= 359) + { + static Game::XAssetType __type; + static std::string __name; + __name = name; + __type = type; + + Game::MaterialTechniqueSet* techset = nullptr; + Game::DB_EnumXAssets_Internal(type, [] (Game::XAssetHeader header, void* _asset) + { + Game::MaterialTechniqueSet** _techset = reinterpret_cast(_asset); + + if (__name == Game::DB_GetXAssetNameHandlers[__type](&header)) + { + *_techset = header.materialTechset; + } + }, &techset, false); + + if (techset) + { + if(type == 6) + + std::memcpy(asset->materialTechset, techset, Game::DB_GetXAssetSizeHandlers[type]()); + //return false; + OutputDebugStringA(""); + } + } + + if (type == 21 && asset->gfxMap->baseName == "mp_underpass"s) + { + //asset->gfxMap->dpvs.smodelCount = 0; + + Game::GfxWorld* world = nullptr; + Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_GFX_MAP, [] (Game::XAssetHeader header, void* world) + { + *reinterpret_cast(world) = header.gfxMap; + }, &world, false); + +// int targetId = *world->skies->skyStartSurfs; +// int sourceId = *asset->gfxMap->skies->skyStartSurfs; + +// world->dpvs.surfaceVisData[0][targetId] = asset->gfxMap->dpvs.surfaceVisData[0][sourceId]; +// world->dpvs.surfaceVisData[1][targetId] = asset->gfxMap->dpvs.surfaceVisData[1][sourceId]; +// world->dpvs.surfaceVisData[2][targetId] = asset->gfxMap->dpvs.surfaceVisData[2][sourceId]; +// +// world->dpvs.surfaces[targetId].material = asset->gfxMap->dpvs.surfaces[sourceId].material; +// world->dpvs.surfacesBounds[targetId].flags = asset->gfxMap->dpvs.surfacesBounds[sourceId].flags; +// +// world->dpvs.surfaceCastsSunShadow[targetId] = asset->gfxMap->dpvs.surfaceCastsSunShadow[sourceId]; +// +// world->skies->skyImage = asset->gfxMap->skies->skyImage; + +// std::memcpy(&world->worldDraw.lightmaps[world->dpvs.surfaces[targetId].lightmapIndex], &asset->gfxMap->worldDraw.lightmaps[asset->gfxMap->dpvs.surfaces[sourceId].lightmapIndex], 8); + +// DWORD* stuff = reinterpret_cast(asset->gfxMap->unknown1); +// for (unsigned int i = 0; i < asset->gfxMap->dpvs.staticSurfaceCount; ++i) +// { +// asset->gfxMap->dpvs.surfaces[i].tris.vertexLayerData = 0; +// } + + auto replaceMaterial = [] (Game::GfxSurface* surfs, unsigned int count, Game::Material** base) + { + static int _i = 0; + _i++; + for (unsigned int i = 0; i < count; ++i) + { + Game::Material* source = *base; + Game::Material* target = surfs[i].material; + + if (source->gameFlags == target->gameFlags) + { + *base = target; + OutputDebugStringA(Utils::String::VA("SUCCESS: replaced %s with %s %d\n", source->name, target->name, _i)); + OutputDebugStringA(Utils::String::VA("SortKey: %X\nGameFlags: %X\nStateFlags: %X\nTechset: %s\n\n", source->sortKey & 0xFF, source->gameFlags & 0xFF, source->stateFlags & 0xFF, source->techniqueSet->name)); + + source = target; + OutputDebugStringA(Utils::String::VA("SortKey: %X\nGameFlags: %X\nStateFlags: %X\nTechset: %s\n\n", source->sortKey & 0xFF, source->gameFlags & 0xFF, source->stateFlags & 0xFF, source->techniqueSet->name)); + return; + } + } + + OutputDebugStringA(Utils::String::VA("FAILURE: unable to replace %s %d\n", (*base)->name, _i)); + + Game::Material* source = *base; + OutputDebugStringA(Utils::String::VA("SortKey: %X\nGameFlags: %X\nStateFlags: %X\nTechset: %s\n\n", source->sortKey & 0xFF, source->gameFlags & 0xFF, source->stateFlags & 0xFF, source->techniqueSet->name)); + }; + +// for (unsigned int i = 0; i < world->dpvs.staticSurfaceCount; ++i) +// { +// replaceMaterial(asset->gfxMap->dpvs.surfaces, asset->gfxMap->dpvs.staticSurfaceCount, &world->dpvs.surfaces[i].material); +// } + +// for (int i = 0; i < world->materialMemoryCount; ++i) +// { +// for (int j = 0; j < asset->gfxMap->materialMemoryCount; ++j) +// { +// if (world->materialMemory[i].material->gameFlags == asset->gfxMap->materialMemory[j].material->gameFlags) +// { +// world->materialMemory[i].material = asset->gfxMap->materialMemory[j].material; +// world->materialMemory[i].memory = asset->gfxMap->materialMemory[j].memory; +// } +// } +// } + +// //std::memcpy(&world->dpvs, &asset->gfxMap->dpvs, sizeof(Game::GfxWorldDpvsStatic)); +// std::memcpy(&world->worldDraw, &asset->gfxMap->worldDraw, sizeof(Game::GfxWorldDraw)); +// std::memcpy(&world->lightGrid, &asset->gfxMap->lightGrid, sizeof(Game::GfxLightGrid)); +// //std::memcpy(&world->dpvsPlanes, &asset->gfxMap->dpvsPlanes, sizeof(Game::GfxWorldDpvsPlanes)); +// world->dpvs.surfaces = asset->gfxMap->dpvs.surfaces; +// world->dpvs.surfacesBounds = asset->gfxMap->dpvs.surfacesBounds; +// world->dpvs.staticSurfaceCount = asset->gfxMap->dpvs.staticSurfaceCount; +// world->dpvs.sortedSurfIndex = asset->gfxMap->dpvs.sortedSurfIndex; +// world->dpvs.surfaceVisData[0] = asset->gfxMap->dpvs.surfaceVisData[0]; +// world->dpvs.surfaceVisData[1] = asset->gfxMap->dpvs.surfaceVisData[1]; +// world->dpvs.surfaceVisData[2] = asset->gfxMap->dpvs.surfaceVisData[2]; +// +// world->cellCasterBits[0] = asset->gfxMap->cellCasterBits[0]; +// world->cellCasterBits[1] = asset->gfxMap->cellCasterBits[1]; +// +// world->skies = asset->gfxMap->skies; +// world->materialMemory = asset->gfxMap->materialMemory; +// world->materialMemoryCount = asset->gfxMap->materialMemoryCount; +// +// world->dpvs.litSurfsBegin = asset->gfxMap->dpvs.litSurfsBegin; +// world->dpvs.litSurfsEnd = asset->gfxMap->dpvs.litSurfsEnd; +// world->dpvs.surfaceMaterials = asset->gfxMap->dpvs.surfaceMaterials; +// +// std::memcpy(world->pad, asset->gfxMap->pad, 68); +// std::memcpy(world->dpvs.unknown1, asset->gfxMap->dpvs.unknown1, 8); +// std::memcpy(&world->dpvs.unknown1[0x18], &asset->gfxMap->dpvs.unknown1[0x18], 4); +// std::memcpy(&world->sun, &asset->gfxMap->sun, sizeof(Game::sunflare_t)); + + //world->dpvs.smodelCount = 0; + + //std::memcpy(world->dpvsPlanes.planes, asset->gfxMap->dpvsPlanes.planes, 20 * (std::min(world->planeCount, asset->gfxMap->planeCount))); + +// for (int i = 0; i < world->planeCount; ++i) +// { +// world->dpvsPlanes.planes[i].type = 0; +// } + + //world->cells = asset->gfxMap->cells; + +// for(int i = 0; i < std::min(asset->gfxMap->dpvsPlanes.cellCount, world->dpvsPlanes.cellCount); ++i) +// { +// // for (int j = 0; j < std::min(asset->gfxMap->aabbTreeCounts[i].aabbTreeCount, world->aabbTreeCounts[i].aabbTreeCount); ++j) +// // { +// // Game::GfxAabbTree* treeA = &world->aabbTrees[i].aabbTree[j]; +// // Game::GfxAabbTree* treeB = &asset->gfxMap->aabbTrees[i].aabbTree[j]; +// // +// // treeA->childrenOffset +// // } +// +// for (int j = 0; j < std::min(asset->gfxMap->cells[i].portalCount, world->cells[i].portalCount); ++j) +// { +// Game::GfxPortal* portalA = &world->cells[i].portals[j]; +// Game::GfxPortal* portalB = &asset->gfxMap->cells[i].portals[j]; +// +// std::memcpy(&portalA->writable, &portalB->writable, sizeof(portalA->writable)); +// std::memcpy(&portalA->plane, &portalB->plane, sizeof(portalA->plane)); +// //std::memcpy(&portalA->unknown, &portalB->unknown, sizeof(portalA->unknown)); +// std::memcpy(&portalA->hullAxis, &portalB->hullAxis, sizeof(portalA->hullAxis)); +// } +// +// //std::memcpy(&world->cells[i], &asset->gfxMap->cells[i], sizeof(Game::GfxCell)); +// //std::memcpy(&world->cells[i], &asset->gfxMap->cells[i], sizeof(Game::GfxCell)); +// } + + //std::memcpy(&world->planeCount, &asset->gfxMap->planeCount, 620); + +// asset->gfxMap->cells = world->cells; +// asset->gfxMap->aabbTrees = world->aabbTrees; +// asset->gfxMap->aabbTreeCounts = world->aabbTreeCounts; +// std::memcpy(&asset->gfxMap->dpvsPlanes, &world->dpvsPlanes, sizeof(Game::GfxWorldDpvsPlanes)); + + + //std::memcpy(&world->planeCount, &asset->gfxMap->planeCount, 620); + + OutputDebugStringA(""); + } + + static Game::MaterialTechniqueSet* technique = nullptr; + + if (type == 5 && Utils::String::StartsWith(name, "wc/")) + { + if (technique == (Game::MaterialTechniqueSet*)1) + { + technique = asset->material->techniqueSet; + } + + if (!technique) + { + technique = (Game::MaterialTechniqueSet*)1; + } + + if (Zones::Version() >= 359) + { + //asset->material->techniqueSet = technique; + } + + //asset->material->sortKey = rand() & 0xFF; + //OutputDebugStringA(Utils::String::VA("%s: %X %s", FastFiles::Current().data(), asset->material->sortKey & 0xFF, asset->material->name)); + } + if (type == 5 && name == "wc/codo_ui_viewer_black_decal3"s) { asset->material->sortKey = 0xE; diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index e4d11585..c0767c76 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1126,7 +1126,12 @@ namespace Components { bool result = Game::Load_Stream(atStreamStart, buffer, size + 4); + // This shouldn't make any difference. + // The new entry is an additional remapped techset which is linked at runtime. + // It's used when the 0x100 gameFlag in a material is set. + // As MW2 flags are only 1 byte large, this won't be possible anyways int shiftTest = 4; + std::memmove(buffer + 8 + shiftTest, buffer + 12 + shiftTest, 196 - shiftTest); AssetHandler::Relocate(buffer + 12 + shiftTest, buffer + 8 + shiftTest, 196 - shiftTest); @@ -1140,11 +1145,15 @@ namespace Components struct material339_s { char drawSurfBegin[8]; // 4 - //int surfaceTypeBits; + //int surfaceTypeBits; const char *name; char drawSurf[6]; - char gameFlags; - char pad; + + union + { + char gameFlags; + short sGameFlags; + }; char sortKey; char textureAtlasRowCount; char textureAtlasColumnCount; @@ -1177,6 +1186,11 @@ namespace Components material->drawSurf[10] = material359.drawSurf[2]; material->drawSurf[11] = material359.drawSurf[3]; + if (material359.sGameFlags & 0x100) + { + //OutputDebugStringA(""); + } + return result; } @@ -1209,6 +1223,30 @@ namespace Components char* varGfxWorld = *reinterpret_cast(0x112A7F4); std::memmove(varGfxWorld + 348, varGfxWorld + 1316, 8); } + + void ModifyShit() + { + //Game::GfxWorldDraw* worldDraw = *reinterpret_cast(0x112A8D4); + //Game::GfxWorldVertexData* vd = *reinterpret_cast(0x112B078); + + //worldDraw->vertexLayerDataSize = 0; + + //for (unsigned int i = 0; i < worldDraw->vertexCount; ++i) + { + //vd->vertices[i].normal.packed++; + //vd->vertices[i].tangent.packed++; + //vd->vertices[i].color.packed = Utils::Cryptography::Rand::GenerateInt(); + //std::swap(vd->vertices[i].xyz[0], vd->vertices[i].xyz[1]); + } + + // for (unsigned int i = 0; i < worldDraw->vertexCount; ++i) + // { + // OutputDebugStringA(Utils::String::VA("%f %f\n", vd->vertices[i].texCoord[0], vd->vertices[i].texCoord[1])); + // + // vd->vertices[i].lmapCoord[0] = 1.0f; + // vd->vertices[i].lmapCoord[1] = 1.0f; + // } + } void Zones::InstallPatches(int version) { @@ -1366,6 +1404,8 @@ namespace Components Zones::Zones() { + Utils::Hook(0x483876, ModifyShit, HOOK_CALL).Install()->Quick(); + Zones::ZoneVersion = 0; // Ignore missing soundaliases for now From 157061b6e87ab620eb7a94892ffa8e9e84367e10 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 21 Oct 2016 22:50:17 +0200 Subject: [PATCH 2/5] Various fixes and fastfile stuff --- deps/fmt | 2 +- deps/mongoose | 2 +- src/Components/Modules/AssetHandler.cpp | 58 +++++++++++++++------- src/Components/Modules/ConnectProtocol.cpp | 2 +- src/Components/Modules/FastFiles.cpp | 5 ++ src/Components/Modules/FastFiles.hpp | 2 +- src/Components/Modules/Maps.cpp | 22 +++++--- src/Components/Modules/ZoneBuilder.cpp | 3 ++ 8 files changed, 68 insertions(+), 28 deletions(-) diff --git a/deps/fmt b/deps/fmt index ed874df2..abbefd71 160000 --- a/deps/fmt +++ b/deps/fmt @@ -1 +1 @@ -Subproject commit ed874df293f8c0831477a2abbdabfb3a0d0441a8 +Subproject commit abbefd71666055daac9e14e78262620f9e845850 diff --git a/deps/mongoose b/deps/mongoose index a17eae41..835af2ca 160000 --- a/deps/mongoose +++ b/deps/mongoose @@ -1 +1 @@ -Subproject commit a17eae4142f3ab5eea8189810189ab1fec67294a +Subproject commit 835af2cae1b731a350ac86003f82183302bd2155 diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 28bef154..2e60509d 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -151,7 +151,7 @@ namespace Components OutputDebugStringA(Utils::String::VA("%s: %s\n", FastFiles::Current().data(), name)); } - + /* if (type <= 9 && type >= 6 && Zones::Version() >= 359) { static Game::XAssetType __type; @@ -179,9 +179,11 @@ namespace Components OutputDebugStringA(""); } } + */ - if (type == 21 && asset->gfxMap->baseName == "mp_underpass"s) + if (type == 21/* && asset->gfxMap->baseName == "mp_underpass"s*/ && false) { + //asset->gfxMap->dpvs.smodelCount = 0; Game::GfxWorld* world = nullptr; @@ -335,26 +337,46 @@ namespace Components static Game::MaterialTechniqueSet* technique = nullptr; - if (type == 5 && Utils::String::StartsWith(name, "wc/")) + /*if (type == 9) { - if (technique == (Game::MaterialTechniqueSet*)1) + FILE* fp; + fopen_s(&fp, "test.txt", "a"); + fprintf(fp, "%s: %s\n", FastFiles::Current().data(), name); + + for (int i = 0; i < 48; i++) { - technique = asset->material->techniqueSet; + if (asset->materialTechset->techniques[i]) + { + fprintf(fp, "\t%d: %s\n", i, asset->materialTechset->techniques[i]->name); + + for (int j = 0; j materialTechset->techniques[i]->numPasses; j++) + { + Game::MaterialPass* pass = &asset->materialTechset->techniques[i]->passes[j]; + + for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++) + { + fprintf(fp, "\t\t%d.%d.%d:\n", i, j, k); + + fprintf(fp, "\t\t\tDest: %d\n", pass->argumentDef[k].dest & 0xFFFF); + fprintf(fp, "\t\t\tMore: %d\n", pass->argumentDef[k].more & 0xFFFF); + fprintf(fp, "\t\t\tType: %d\n", pass->argumentDef[k].type & 0xFFFF); + fprintf(fp, "\t\t\tPara: %d\n", pass->argumentDef[k].paramID & 0xFFFF); + } + } + } } - if (!technique) - { - technique = (Game::MaterialTechniqueSet*)1; - } + fprintf(fp, "\n"); + fclose(fp); + }*/ - if (Zones::Version() >= 359) - { - //asset->material->techniqueSet = technique; - } - - //asset->material->sortKey = rand() & 0xFF; - //OutputDebugStringA(Utils::String::VA("%s: %X %s", FastFiles::Current().data(), asset->material->sortKey & 0xFF, asset->material->name)); - } +// if (type == 5) +// { +// FILE* fp; +// fopen_s(&fp, "test.txt", "a"); +// fprintf(fp, "%s: %s %X %X %X\n", FastFiles::Current().data(), name, asset->material->sortKey & 0xFF, asset->material->gameFlags & 0xFF, asset->material->stateFlags & 0xFF); +// fclose(fp); +// } if (type == 5 && name == "wc/codo_ui_viewer_black_decal3"s) { @@ -545,7 +567,7 @@ namespace Components // Log missing empty assets QuickPatch::OnFrame([] () { - if (Game::Sys_IsDatabaseReady() && Game::Sys_IsDatabaseReady2() && !AssetHandler::EmptyAssets.empty()) + if (FastFiles::Ready() && !AssetHandler::EmptyAssets.empty()) { for (auto& asset : AssetHandler::EmptyAssets) { diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 80936761..59a5680f 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -197,7 +197,7 @@ namespace Components { if (ConnectProtocol::Used()) { - if (!Game::Sys_IsDatabaseReady() && !Game::Sys_IsDatabaseReady2()) + if (!FastFiles::Ready()) { QuickPatch::Once(ConnectProtocol::Invocation); } diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index c13a755a..5005908e 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -218,6 +218,11 @@ namespace Components return std::ifstream(path.data()).good(); } + bool FastFiles::Ready() + { + return (Game::Sys_IsDatabaseReady() && Game::Sys_IsDatabaseReady2()); + } + const char* FastFiles::GetZoneLocation(const char* file) { const char* dir = Dvar::Var("fs_basepath").Get(); diff --git a/src/Components/Modules/FastFiles.hpp b/src/Components/Modules/FastFiles.hpp index 6e1b329a..33a8e129 100644 --- a/src/Components/Modules/FastFiles.hpp +++ b/src/Components/Modules/FastFiles.hpp @@ -12,7 +12,7 @@ namespace Components static void AddZonePath(std::string path); static std::string Current(); - + static bool Ready(); static bool Exists(std::string file); static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 6db0596f..65f5dba4 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -314,7 +314,15 @@ namespace Components Assert_Size(Game::XAssetEntry, 16); Maps::EntryPool.clear(); - Maps::EntryPool.resize(789312); + + if (ZoneBuilder::IsEnabled()) + { + Maps::EntryPool.resize(1183968); + } + else + { + Maps::EntryPool.resize(789312); + } // Apply new size Utils::Hook::Set(0x5BAEB0, Maps::EntryPool.size()); @@ -404,11 +412,13 @@ namespace Components Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp"); Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp"); - //Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); - //Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp"); - //Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); - //Maps::AddDependency("mp_firingrange", "mp_underpass"); - //Maps::AddDependency("mp_underpass", "mp_firingrange"); + Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_firingrange", "mp_underpass"); + Maps::AddDependency("zm_asylum_sh", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_rust_long", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_rust_long", "mp_rust"); #if defined(DEBUG) && defined(ENABLE_DXSDK) Command::Add("dumpmap", [] (Command::Params) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 91488a54..ad471d56 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -493,8 +493,11 @@ namespace Components Utils::Hook::Nop(0x5BB3F2, 5); Utils::Hook::Nop(0x5BB422, 5); Utils::Hook::Nop(0x5BB43A, 5); + // Increase asset pools Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MAP_ENTS, 10); + Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODELSURFS, 8192); + Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 14336); // hunk size (was 300 MiB) Utils::Hook::Set(0x64A029, 0x38400000); // 900 MiB From 64f80a21be05ef2bc4de105f9dd5b51072a9a740 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 22 Oct 2016 01:14:00 +0200 Subject: [PATCH 3/5] Slowmotion stuff. Seems like it has no effect.... --- src/Components/Loader.cpp | 1 + src/Components/Loader.hpp | 1 + src/Components/Modules/AntiCheat.cpp | 2 +- src/Components/Modules/Slowmotion.cpp | 85 +++++++++++++++++++++++++++ src/Components/Modules/Slowmotion.hpp | 22 +++++++ src/Game/Functions.cpp | 4 ++ src/Game/Functions.hpp | 9 +++ 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/Components/Modules/Slowmotion.cpp create mode 100644 src/Components/Modules/Slowmotion.hpp diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index a5ff5504..8f27afb1 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -63,6 +63,7 @@ namespace Components Loader::Register(new QuickPatch()); Loader::Register(new ServerInfo()); Loader::Register(new ServerList()); + Loader::Register(new SlowMotion()); Loader::Register(new StringTable()); Loader::Register(new ZoneBuilder()); Loader::Register(new AssetHandler()); diff --git a/src/Components/Loader.hpp b/src/Components/Loader.hpp index 8d700b9f..faba9e9a 100644 --- a/src/Components/Loader.hpp +++ b/src/Components/Loader.hpp @@ -76,6 +76,7 @@ namespace Components #include "Modules\QuickPatch.hpp" #include "Modules\ServerInfo.hpp" #include "Modules\ServerList.hpp" +#include "Modules\SlowMotion.hpp" #include "Modules\StringTable.hpp" #include "Modules\ZoneBuilder.hpp" #include "Modules\AssetHandler.hpp" diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index 993f51f9..ae81bb12 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -371,7 +371,7 @@ namespace Components __asm { pushad - push[esp + 20h] + push [esp + 20h] call AntiCheat::AssertCalleeModule diff --git a/src/Components/Modules/Slowmotion.cpp b/src/Components/Modules/Slowmotion.cpp new file mode 100644 index 00000000..240e6a54 --- /dev/null +++ b/src/Components/Modules/Slowmotion.cpp @@ -0,0 +1,85 @@ +#include "STDInclude.hpp" + +namespace Components +{ + int SlowMotion::Delay = 0; + + void SlowMotion::ApplySlowMotion(int timePassed) + { + if (SlowMotion::Delay <= 0) + { + Utils::Hook::Call(0x60B2D0)(timePassed); + } + else + { + SlowMotion::Delay -= timePassed; + } + } + + __declspec(naked) void SlowMotion::ApplySlowMotionStub() + { + __asm + { + pushad + push [esp + 20h] + + call SlowMotion::ApplySlowMotion + + pop ecx + popad + + retn + } + } + + void SlowMotion::SetSlowMotion() + { + int duration = 1000; + float start = Game::Scr_GetFloat(0); + float end = 1.0f; + + if (Game::Scr_GetNumParam() >= 2) + { + end = Game::Scr_GetFloat(1); + } + + if (Game::Scr_GetNumParam() >= 3) + { + duration = static_cast(Game::Scr_GetFloat(2) * 1000.0); + } + + int delay = 0; + + if (start > end) + { + if (duration < 150) + { + delay = duration; + } + else + { + delay = 150; + } + } + + duration = duration - delay; + + Game::Com_SetSlowMotion(start, end, duration); + SlowMotion::Delay = delay; + + // set snapshot num to 1 behind (T6 does this, why shouldn't we?) + for (int i = 0; i < *Game::svs_numclients; i++) + { + Game::svs_clients[i].snapNum = (*reinterpret_cast(0x31D9384)) - 1; + } + } + + SlowMotion::SlowMotion() + { + if (!Dedicated::IsEnabled()) return; + + SlowMotion::Delay = 0; + Utils::Hook(0x5F5FF2, SlowMotion::SetSlowMotion, HOOK_JUMP).Install()->Quick(); + Utils::Hook(0x60B38A, SlowMotion::ApplySlowMotionStub, HOOK_CALL).Install()->Quick(); + } +} diff --git a/src/Components/Modules/Slowmotion.hpp b/src/Components/Modules/Slowmotion.hpp new file mode 100644 index 00000000..f150d4d4 --- /dev/null +++ b/src/Components/Modules/Slowmotion.hpp @@ -0,0 +1,22 @@ +#define BUTTON_FLAG_LEANLEFT 0x40 +#define BUTTON_FLAG_LEANRIGHT 0x80 + +namespace Components +{ + class SlowMotion : public Component + { + public: + SlowMotion(); + +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* GetName() { return "SlowMotion"; }; +#endif + + private: + static int Delay; + + static void SetSlowMotion(); + static void ApplySlowMotion(int timePassed); + static void ApplySlowMotionStub(); + }; +} diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 347ba22d..105b331b 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -28,6 +28,7 @@ namespace Game Com_Printf_t Com_Printf = (Com_Printf_t)0x402500; Com_PrintMessage_t Com_PrintMessage = (Com_PrintMessage_t)0x4AA830; Com_ParseExt_t Com_ParseExt = (Com_ParseExt_t)0x474D60; + Com_SetSlowMotion_t Com_SetSlowMotion = (Com_SetSlowMotion_t)0x446E20; Con_DrawMiniConsole_t Con_DrawMiniConsole = (Con_DrawMiniConsole_t)0x464F30; Con_DrawSolidConsole_t Con_DrawSolidConsole = (Con_DrawSolidConsole_t)0x5A5040; @@ -176,6 +177,9 @@ namespace Game Scr_LoadScript_t Scr_LoadScript = (Scr_LoadScript_t)0x45D940; Scr_GetFunctionHandle_t Scr_GetFunctionHandle = (Scr_GetFunctionHandle_t)0x4234F0; + Scr_GetFloat_t Scr_GetFloat = (Scr_GetFloat_t)0x443140; + Scr_GetNumParam_t Scr_GetNumParam = (Scr_GetNumParam_t)0x4B0E90; + Scr_ExecThread_t Scr_ExecThread = (Scr_ExecThread_t)0x4AD0B0; Scr_FreeThread_t Scr_FreeThread = (Scr_FreeThread_t)0x4BD320; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 4ac3219b..fef65f63 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -60,6 +60,9 @@ namespace Game typedef char* (__cdecl * Com_ParseExt_t)(const char **data_p); extern Com_ParseExt_t Com_ParseExt; + typedef void(__cdecl * Com_SetSlowMotion_t)(float start, float end, int duration); + extern Com_SetSlowMotion_t Com_SetSlowMotion; + typedef char* (__cdecl * Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha); extern Con_DrawMiniConsole_t Con_DrawMiniConsole; @@ -425,6 +428,12 @@ namespace Game typedef int(__cdecl * Scr_LoadScript_t)(const char*); extern Scr_LoadScript_t Scr_LoadScript; + typedef float(__cdecl * Scr_GetFloat_t)(int); + extern Scr_GetFloat_t Scr_GetFloat; + + typedef int(__cdecl * Scr_GetNumParam_t)(void); + extern Scr_GetNumParam_t Scr_GetNumParam; + typedef int(__cdecl * Scr_GetFunctionHandle_t)(const char*, const char*); extern Scr_GetFunctionHandle_t Scr_GetFunctionHandle; From d2c5c45042626a04427f8d5420c98894c961cbc8 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 23 Oct 2016 16:45:21 +0200 Subject: [PATCH 4/5] Fix shader stuff --- deps/mongoose | 2 +- src/Components/Modules/AssetHandler.cpp | 273 ++++-------------------- src/Components/Modules/Maps.cpp | 3 - src/Components/Modules/Zones.cpp | 45 ++-- src/Game/Structs.hpp | 27 +++ 5 files changed, 86 insertions(+), 264 deletions(-) diff --git a/deps/mongoose b/deps/mongoose index 835af2ca..c722cfec 160000 --- a/deps/mongoose +++ b/deps/mongoose @@ -1 +1 @@ -Subproject commit 835af2cae1b731a350ac86003f82183302bd2155 +Subproject commit c722cfec18231c6d18ab8a73993b763aa1e0dd7e diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 2e60509d..88164902 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -132,251 +132,58 @@ namespace Components } } - if (type == 20/* && name == "maps/mp/mp_underpass.d3dbsp"s*/) + if (type == 9 && false) { - char* world = nullptr; - Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_FX_MAP, [] (Game::XAssetHeader header, void* world) + static Game::MaterialTechniqueSet* technique = nullptr; + + auto printTechset = [] (Game::MaterialTechniqueSet* technique, std::string zone) { - *reinterpret_cast(world) = header.gfxMap; - }, &world, false); + FILE* fp; + fopen_s(&fp, "test.txt", "a"); + fprintf(fp, "%s: %s\n", zone.data(), technique->name); - if (world) - { - //std::memcpy(world + 4, &asset->rawfile->sizeCompressed, Game::DB_GetXAssetSizeHandlers[Game::XAssetType::ASSET_TYPE_FX_MAP]() - 4); - } - } - - if (type == 22) - { - OutputDebugStringA(Utils::String::VA("%s: %s\n", FastFiles::Current().data(), name)); - } - - /* - if (type <= 9 && type >= 6 && Zones::Version() >= 359) - { - static Game::XAssetType __type; - static std::string __name; - __name = name; - __type = type; - - Game::MaterialTechniqueSet* techset = nullptr; - Game::DB_EnumXAssets_Internal(type, [] (Game::XAssetHeader header, void* _asset) - { - Game::MaterialTechniqueSet** _techset = reinterpret_cast(_asset); - - if (__name == Game::DB_GetXAssetNameHandlers[__type](&header)) + for (int i = 0; i < 48; i++) { - *_techset = header.materialTechset; - } - }, &techset, false); - - if (techset) - { - if(type == 6) - - std::memcpy(asset->materialTechset, techset, Game::DB_GetXAssetSizeHandlers[type]()); - //return false; - OutputDebugStringA(""); - } - } - */ - - if (type == 21/* && asset->gfxMap->baseName == "mp_underpass"s*/ && false) - { - - //asset->gfxMap->dpvs.smodelCount = 0; - - Game::GfxWorld* world = nullptr; - Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_GFX_MAP, [] (Game::XAssetHeader header, void* world) - { - *reinterpret_cast(world) = header.gfxMap; - }, &world, false); - -// int targetId = *world->skies->skyStartSurfs; -// int sourceId = *asset->gfxMap->skies->skyStartSurfs; - -// world->dpvs.surfaceVisData[0][targetId] = asset->gfxMap->dpvs.surfaceVisData[0][sourceId]; -// world->dpvs.surfaceVisData[1][targetId] = asset->gfxMap->dpvs.surfaceVisData[1][sourceId]; -// world->dpvs.surfaceVisData[2][targetId] = asset->gfxMap->dpvs.surfaceVisData[2][sourceId]; -// -// world->dpvs.surfaces[targetId].material = asset->gfxMap->dpvs.surfaces[sourceId].material; -// world->dpvs.surfacesBounds[targetId].flags = asset->gfxMap->dpvs.surfacesBounds[sourceId].flags; -// -// world->dpvs.surfaceCastsSunShadow[targetId] = asset->gfxMap->dpvs.surfaceCastsSunShadow[sourceId]; -// -// world->skies->skyImage = asset->gfxMap->skies->skyImage; - -// std::memcpy(&world->worldDraw.lightmaps[world->dpvs.surfaces[targetId].lightmapIndex], &asset->gfxMap->worldDraw.lightmaps[asset->gfxMap->dpvs.surfaces[sourceId].lightmapIndex], 8); - -// DWORD* stuff = reinterpret_cast(asset->gfxMap->unknown1); -// for (unsigned int i = 0; i < asset->gfxMap->dpvs.staticSurfaceCount; ++i) -// { -// asset->gfxMap->dpvs.surfaces[i].tris.vertexLayerData = 0; -// } - - auto replaceMaterial = [] (Game::GfxSurface* surfs, unsigned int count, Game::Material** base) - { - static int _i = 0; - _i++; - for (unsigned int i = 0; i < count; ++i) - { - Game::Material* source = *base; - Game::Material* target = surfs[i].material; - - if (source->gameFlags == target->gameFlags) + if (technique->techniques[i]) { - *base = target; - OutputDebugStringA(Utils::String::VA("SUCCESS: replaced %s with %s %d\n", source->name, target->name, _i)); - OutputDebugStringA(Utils::String::VA("SortKey: %X\nGameFlags: %X\nStateFlags: %X\nTechset: %s\n\n", source->sortKey & 0xFF, source->gameFlags & 0xFF, source->stateFlags & 0xFF, source->techniqueSet->name)); + fprintf(fp, "\t%d: %s\n", i, technique->techniques[i]->name); - source = target; - OutputDebugStringA(Utils::String::VA("SortKey: %X\nGameFlags: %X\nStateFlags: %X\nTechset: %s\n\n", source->sortKey & 0xFF, source->gameFlags & 0xFF, source->stateFlags & 0xFF, source->techniqueSet->name)); - return; - } - } - - OutputDebugStringA(Utils::String::VA("FAILURE: unable to replace %s %d\n", (*base)->name, _i)); - - Game::Material* source = *base; - OutputDebugStringA(Utils::String::VA("SortKey: %X\nGameFlags: %X\nStateFlags: %X\nTechset: %s\n\n", source->sortKey & 0xFF, source->gameFlags & 0xFF, source->stateFlags & 0xFF, source->techniqueSet->name)); - }; - -// for (unsigned int i = 0; i < world->dpvs.staticSurfaceCount; ++i) -// { -// replaceMaterial(asset->gfxMap->dpvs.surfaces, asset->gfxMap->dpvs.staticSurfaceCount, &world->dpvs.surfaces[i].material); -// } - -// for (int i = 0; i < world->materialMemoryCount; ++i) -// { -// for (int j = 0; j < asset->gfxMap->materialMemoryCount; ++j) -// { -// if (world->materialMemory[i].material->gameFlags == asset->gfxMap->materialMemory[j].material->gameFlags) -// { -// world->materialMemory[i].material = asset->gfxMap->materialMemory[j].material; -// world->materialMemory[i].memory = asset->gfxMap->materialMemory[j].memory; -// } -// } -// } - -// //std::memcpy(&world->dpvs, &asset->gfxMap->dpvs, sizeof(Game::GfxWorldDpvsStatic)); -// std::memcpy(&world->worldDraw, &asset->gfxMap->worldDraw, sizeof(Game::GfxWorldDraw)); -// std::memcpy(&world->lightGrid, &asset->gfxMap->lightGrid, sizeof(Game::GfxLightGrid)); -// //std::memcpy(&world->dpvsPlanes, &asset->gfxMap->dpvsPlanes, sizeof(Game::GfxWorldDpvsPlanes)); -// world->dpvs.surfaces = asset->gfxMap->dpvs.surfaces; -// world->dpvs.surfacesBounds = asset->gfxMap->dpvs.surfacesBounds; -// world->dpvs.staticSurfaceCount = asset->gfxMap->dpvs.staticSurfaceCount; -// world->dpvs.sortedSurfIndex = asset->gfxMap->dpvs.sortedSurfIndex; -// world->dpvs.surfaceVisData[0] = asset->gfxMap->dpvs.surfaceVisData[0]; -// world->dpvs.surfaceVisData[1] = asset->gfxMap->dpvs.surfaceVisData[1]; -// world->dpvs.surfaceVisData[2] = asset->gfxMap->dpvs.surfaceVisData[2]; -// -// world->cellCasterBits[0] = asset->gfxMap->cellCasterBits[0]; -// world->cellCasterBits[1] = asset->gfxMap->cellCasterBits[1]; -// -// world->skies = asset->gfxMap->skies; -// world->materialMemory = asset->gfxMap->materialMemory; -// world->materialMemoryCount = asset->gfxMap->materialMemoryCount; -// -// world->dpvs.litSurfsBegin = asset->gfxMap->dpvs.litSurfsBegin; -// world->dpvs.litSurfsEnd = asset->gfxMap->dpvs.litSurfsEnd; -// world->dpvs.surfaceMaterials = asset->gfxMap->dpvs.surfaceMaterials; -// -// std::memcpy(world->pad, asset->gfxMap->pad, 68); -// std::memcpy(world->dpvs.unknown1, asset->gfxMap->dpvs.unknown1, 8); -// std::memcpy(&world->dpvs.unknown1[0x18], &asset->gfxMap->dpvs.unknown1[0x18], 4); -// std::memcpy(&world->sun, &asset->gfxMap->sun, sizeof(Game::sunflare_t)); - - //world->dpvs.smodelCount = 0; - - //std::memcpy(world->dpvsPlanes.planes, asset->gfxMap->dpvsPlanes.planes, 20 * (std::min(world->planeCount, asset->gfxMap->planeCount))); - -// for (int i = 0; i < world->planeCount; ++i) -// { -// world->dpvsPlanes.planes[i].type = 0; -// } - - //world->cells = asset->gfxMap->cells; - -// for(int i = 0; i < std::min(asset->gfxMap->dpvsPlanes.cellCount, world->dpvsPlanes.cellCount); ++i) -// { -// // for (int j = 0; j < std::min(asset->gfxMap->aabbTreeCounts[i].aabbTreeCount, world->aabbTreeCounts[i].aabbTreeCount); ++j) -// // { -// // Game::GfxAabbTree* treeA = &world->aabbTrees[i].aabbTree[j]; -// // Game::GfxAabbTree* treeB = &asset->gfxMap->aabbTrees[i].aabbTree[j]; -// // -// // treeA->childrenOffset -// // } -// -// for (int j = 0; j < std::min(asset->gfxMap->cells[i].portalCount, world->cells[i].portalCount); ++j) -// { -// Game::GfxPortal* portalA = &world->cells[i].portals[j]; -// Game::GfxPortal* portalB = &asset->gfxMap->cells[i].portals[j]; -// -// std::memcpy(&portalA->writable, &portalB->writable, sizeof(portalA->writable)); -// std::memcpy(&portalA->plane, &portalB->plane, sizeof(portalA->plane)); -// //std::memcpy(&portalA->unknown, &portalB->unknown, sizeof(portalA->unknown)); -// std::memcpy(&portalA->hullAxis, &portalB->hullAxis, sizeof(portalA->hullAxis)); -// } -// -// //std::memcpy(&world->cells[i], &asset->gfxMap->cells[i], sizeof(Game::GfxCell)); -// //std::memcpy(&world->cells[i], &asset->gfxMap->cells[i], sizeof(Game::GfxCell)); -// } - - //std::memcpy(&world->planeCount, &asset->gfxMap->planeCount, 620); - -// asset->gfxMap->cells = world->cells; -// asset->gfxMap->aabbTrees = world->aabbTrees; -// asset->gfxMap->aabbTreeCounts = world->aabbTreeCounts; -// std::memcpy(&asset->gfxMap->dpvsPlanes, &world->dpvsPlanes, sizeof(Game::GfxWorldDpvsPlanes)); - - - //std::memcpy(&world->planeCount, &asset->gfxMap->planeCount, 620); - - OutputDebugStringA(""); - } - - static Game::MaterialTechniqueSet* technique = nullptr; - - /*if (type == 9) - { - FILE* fp; - fopen_s(&fp, "test.txt", "a"); - fprintf(fp, "%s: %s\n", FastFiles::Current().data(), name); - - for (int i = 0; i < 48; i++) - { - if (asset->materialTechset->techniques[i]) - { - fprintf(fp, "\t%d: %s\n", i, asset->materialTechset->techniques[i]->name); - - for (int j = 0; j materialTechset->techniques[i]->numPasses; j++) - { - Game::MaterialPass* pass = &asset->materialTechset->techniques[i]->passes[j]; - - for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++) + for (int j = 0; j < technique->techniques[i]->numPasses; j++) { - fprintf(fp, "\t\t%d.%d.%d:\n", i, j, k); + Game::MaterialPass* pass = &technique->techniques[i]->passes[j]; - fprintf(fp, "\t\t\tDest: %d\n", pass->argumentDef[k].dest & 0xFFFF); - fprintf(fp, "\t\t\tMore: %d\n", pass->argumentDef[k].more & 0xFFFF); - fprintf(fp, "\t\t\tType: %d\n", pass->argumentDef[k].type & 0xFFFF); - fprintf(fp, "\t\t\tPara: %d\n", pass->argumentDef[k].paramID & 0xFFFF); + for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++) + { + fprintf(fp, "\t\t%d.%d.%d:\n", i, j, k); + + fprintf(fp, "\t\t\tDest: %d\n", pass->argumentDef[k].dest & 0xFFFF); + fprintf(fp, "\t\t\tMore: %d\n", pass->argumentDef[k].more & 0xFFFF); + fprintf(fp, "\t\t\tType: %d\n", pass->argumentDef[k].type & 0xFFFF); + fprintf(fp, "\t\t\tPara: %d\n", pass->argumentDef[k].paramID & 0xFFFF); + } } } } + + fprintf(fp, "\n"); + fclose(fp); + }; + + static std::map techs; + + if (FastFiles::Current() == "mp_firingrange") + { + techs[name] = asset->materialTechset; + printTechset(asset->materialTechset, "mp_firingrange"); } - - fprintf(fp, "\n"); - fclose(fp); - }*/ - -// if (type == 5) -// { -// FILE* fp; -// fopen_s(&fp, "test.txt", "a"); -// fprintf(fp, "%s: %s %X %X %X\n", FastFiles::Current().data(), name, asset->material->sortKey & 0xFF, asset->material->gameFlags & 0xFF, asset->material->stateFlags & 0xFF); -// fclose(fp); -// } + else + { + if (techs.find(name) != techs.end()) + { + printTechset(asset->materialTechset, FastFiles::Current()); + } + } + } if (type == 5 && name == "wc/codo_ui_viewer_black_decal3"s) { diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 65f5dba4..877849a3 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -415,10 +415,7 @@ namespace Components Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp"); Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); - Maps::AddDependency("mp_firingrange", "mp_underpass"); - Maps::AddDependency("zm_asylum_sh", "iw4x_dependencies_mp"); Maps::AddDependency("mp_rust_long", "iw4x_dependencies_mp"); - Maps::AddDependency("mp_rust_long", "mp_rust"); #if defined(DEBUG) && defined(ENABLE_DXSDK) Command::Add("dumpmap", [] (Command::Params) diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index c0767c76..3f6968bf 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1005,12 +1005,29 @@ namespace Components if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms { arg->paramID -= 3; + + if (Zones::Version() >= 359) + { + arg->paramID -= 7; + } } // >= 21 works fine for specular, but breaks trees // >= 4 is too low, breaks specular else if (arg->paramID >= 11 && arg->paramID < 58) { arg->paramID -= 2; + + if (Zones::Version() >= 359) + { + if (arg->paramID > 15 && arg->paramID < 34) + { + arg->paramID -= 1; + } + else if (arg->paramID >= 50) + { + arg->paramID += 6; + } + } } } @@ -1145,7 +1162,7 @@ namespace Components struct material339_s { char drawSurfBegin[8]; // 4 - //int surfaceTypeBits; + //int surfaceTypeBits; const char *name; char drawSurf[6]; @@ -1223,30 +1240,6 @@ namespace Components char* varGfxWorld = *reinterpret_cast(0x112A7F4); std::memmove(varGfxWorld + 348, varGfxWorld + 1316, 8); } - - void ModifyShit() - { - //Game::GfxWorldDraw* worldDraw = *reinterpret_cast(0x112A8D4); - //Game::GfxWorldVertexData* vd = *reinterpret_cast(0x112B078); - - //worldDraw->vertexLayerDataSize = 0; - - //for (unsigned int i = 0; i < worldDraw->vertexCount; ++i) - { - //vd->vertices[i].normal.packed++; - //vd->vertices[i].tangent.packed++; - //vd->vertices[i].color.packed = Utils::Cryptography::Rand::GenerateInt(); - //std::swap(vd->vertices[i].xyz[0], vd->vertices[i].xyz[1]); - } - - // for (unsigned int i = 0; i < worldDraw->vertexCount; ++i) - // { - // OutputDebugStringA(Utils::String::VA("%f %f\n", vd->vertices[i].texCoord[0], vd->vertices[i].texCoord[1])); - // - // vd->vertices[i].lmapCoord[0] = 1.0f; - // vd->vertices[i].lmapCoord[1] = 1.0f; - // } - } void Zones::InstallPatches(int version) { @@ -1404,8 +1397,6 @@ namespace Components Zones::Zones() { - Utils::Hook(0x483876, ModifyShit, HOOK_CALL).Install()->Quick(); - Zones::ZoneVersion = 0; // Ignore missing soundaliases for now diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 93a0e9ce..dd2cf825 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -2476,6 +2476,33 @@ namespace Game GfxColor groundLighting; }; + enum surfaceType_t + { + SF_TRIANGLES = 0x0, + SF_TRIANGLES_NO_SUN_SHADOW = 0x1, + SF_BEGIN_STATICMODEL = 0x2, + SF_STATICMODEL_RIGID = 0x2, + SF_STATICMODEL_INSTANCED = 0x3, + SF_STATICMODEL_RIGID_NO_SUN_SHADOW = 0x4, + SF_STATICMODEL_INSTANCED_NO_SUN_SHADOW = 0x5, + SF_END_STATICMODEL = 0x6, + SF_BMODEL = 0x6, + SF_BEGIN_XMODEL = 0x7, + SF_XMODEL_RIGID = 0x7, + SF_XMODEL_SKINNED = 0x8, + SF_END_XMODEL = 0x9, + SF_BEGIN_FX = 0x9, + SF_CODE = 0x9, + SF_GLASS = 0xA, + SF_MARK = 0xB, + SF_SPARK = 0xC, + SF_PARTICLE_CLOUD = 0xD, + SF_PARTICLE_SPARK_CLOUD = 0xE, + SF_END_FX = 0xF, + SF_NUM_SURFACE_TYPES = 0xF, + SF_FORCE_32_BITS = 0xFFFFFFFF, + }; + struct srfTriangles_t { int vertexLayerData; From 2e6f0c1144c8c3f7d2437a6fda5ecda2721bb569 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 23 Oct 2016 17:13:44 +0200 Subject: [PATCH 5/5] Stuff --- src/Components/Modules/AssetHandler.cpp | 15 ++++++--------- src/Components/Modules/Maps.cpp | 1 + src/Components/Modules/Zones.cpp | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 88164902..9dc783cc 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -132,6 +132,7 @@ namespace Components } } +#if DEBUG if (type == 9 && false) { static Game::MaterialTechniqueSet* technique = nullptr; @@ -154,12 +155,7 @@ namespace Components for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++) { - fprintf(fp, "\t\t%d.%d.%d:\n", i, j, k); - - fprintf(fp, "\t\t\tDest: %d\n", pass->argumentDef[k].dest & 0xFFFF); - fprintf(fp, "\t\t\tMore: %d\n", pass->argumentDef[k].more & 0xFFFF); - fprintf(fp, "\t\t\tType: %d\n", pass->argumentDef[k].type & 0xFFFF); - fprintf(fp, "\t\t\tPara: %d\n", pass->argumentDef[k].paramID & 0xFFFF); + fprintf(fp, "\t\t\t%d.%d.%d Para: %d\n", i, j, k, pass->argumentDef[k].paramID & 0xFFFF); } } } @@ -171,10 +167,10 @@ namespace Components static std::map techs; - if (FastFiles::Current() == "mp_firingrange") + if (FastFiles::Current() == "mp_rust_long") { techs[name] = asset->materialTechset; - printTechset(asset->materialTechset, "mp_firingrange"); + printTechset(asset->materialTechset, "mp_rust_long"); } else { @@ -184,8 +180,9 @@ namespace Components } } } +#endif - if (type == 5 && name == "wc/codo_ui_viewer_black_decal3"s) + if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && name == "wc/codo_ui_viewer_black_decal3"s) { asset->material->sortKey = 0xE; } diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 877849a3..7ca2a43f 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -416,6 +416,7 @@ namespace Components Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp"); Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); Maps::AddDependency("mp_rust_long", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_rust_long", "mp_rust"); #if defined(DEBUG) && defined(ENABLE_DXSDK) Command::Add("dumpmap", [] (Command::Params) diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 3f6968bf..f30456c3 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1006,7 +1006,7 @@ namespace Components { arg->paramID -= 3; - if (Zones::Version() >= 359) + if (Zones::Version() >= 359/* && arg->paramID <= 113*/) { arg->paramID -= 7; }