diff --git a/Plugins/BulletPhysics/BasePhysicManager.cpp b/Plugins/BulletPhysics/BasePhysicManager.cpp index 07cfbb66..6e0c5ad7 100644 --- a/Plugins/BulletPhysics/BasePhysicManager.cpp +++ b/Plugins/BulletPhysics/BasePhysicManager.cpp @@ -20,6 +20,21 @@ #include +template +inline T* GetWorldSurfaceByIndex(int index) +{ + return (((T*)r_worldmodel->surfaces) + index); +} + +template +inline int GetWorldSurfaceIndex(T* surf) +{ + auto surf25 = (T*)surf; + auto surfbase = (T*)r_worldmodel->surfaces; + + return surf25 - surfbase; +} + IClientPhysicManager* g_pClientPhysicManager{}; IClientPhysicManager* ClientPhysicManager() @@ -4158,34 +4173,84 @@ void CBasePhysicManager::UpdateAllPhysicObjects(TEMPENTITY** ppTempEntFree, TEMP } -std::shared_ptr CBasePhysicManager::GenerateWorldVertexArray(model_t *mod) +template +void CBasePhysicManager::BuildSurfaceDisplayList(model_t* mod, T *fa, std::deque& glpolys) { - std::string worldModelName; +#define BLOCK_WIDTH 128 +#define BLOCK_HEIGHT 128 + int i, lindex, lnumverts; + medge_t* pedges, * r_pedge; + float* vec; + float s, t; + glpoly_t* poly; - if (mod->name[0] == '*') + pedges = mod->edges; + lnumverts = fa->numedges; + + int allocSize = (int)sizeof(glpoly_t) + ((lnumverts - 4) * VERTEXSIZE * sizeof(float)); + + if (allocSize < 0) + return; + + poly = (glpoly_t*)malloc(allocSize); + + glpolys.push_front(poly); + + poly->next = NULL; + poly->flags = fa->flags; + //fa->polys = poly; + poly->numverts = lnumverts; + poly->chain = NULL; + + for (i = 0; i < lnumverts; i++) { - auto worldmodel = EngineFindWorldModelBySubModel(mod); + lindex = mod->surfedges[fa->firstedge + i]; - if (!worldmodel) + if (lindex > 0) { - gEngfuncs.Con_Printf("CBasePhysicManager::GenerateWorldVertexArray: Failed to find worldmodel for submodel \"%s\"!\n", mod->name); - return nullptr; + r_pedge = &pedges[lindex]; + vec = mod->vertexes[r_pedge->v[0]].position; + } + else + { + r_pedge = &pedges[-lindex]; + vec = mod->vertexes[r_pedge->v[1]].position; } - worldModelName = worldmodel->name; - } - else - { - worldModelName = mod->name; - } + s = DotProduct(vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3]; + s /= fa->texinfo->texture->width; - auto found = m_worldVertexResources.find(worldModelName); + t = DotProduct(vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3]; + t /= fa->texinfo->texture->height; - if (found != m_worldVertexResources.end()) - { - return found->second; + poly->verts[i][0] = vec[0]; + poly->verts[i][1] = vec[1]; + poly->verts[i][2] = vec[2]; + poly->verts[i][3] = s; + poly->verts[i][4] = t; +#if 0 + s = DotProduct(vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3]; + s -= fa->texturemins[0]; + s += fa->light_s * 16; + s += 8; + s /= BLOCK_WIDTH * 16; + + t = DotProduct(vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3]; + t -= fa->texturemins[1]; + t += fa->light_t * 16; + t += 8; + t /= BLOCK_HEIGHT * 16; +#endif + poly->verts[i][5] = 0; + poly->verts[i][6] = 0; } + poly->numverts = lnumverts; +} + +template +std::shared_ptr CBasePhysicManager::GenerateWorldVertexArrayInternal(model_t* mod) +{ auto worldVertexArray = std::make_shared(); CPhysicBrushVertex Vertexes[3]; @@ -4197,12 +4262,17 @@ std::shared_ptr CBasePhysicManager::GenerateWorldVertexArray for (int i = 0; i < mod->numsurfaces; i++) { - auto surf = GetWorldSurfaceByIndex(i); + auto surf = GetWorldSurfaceByIndex(i); if ((surf->flags & (SURF_DRAWTURB | SURF_UNDERWATER | SURF_DRAWSKY))) continue; - auto poly = surf->polys; + std::deque glpolys; + + BuildSurfaceDisplayList(mod, surf, glpolys); + + if (glpolys.empty()) + continue; auto brushface = &worldVertexArray->vFaceBuffer[i]; @@ -4210,7 +4280,7 @@ std::shared_ptr CBasePhysicManager::GenerateWorldVertexArray brushface->start_vertex = iStartVert; - for (poly = surf->polys; poly; poly = poly->next) + for (const auto& poly : glpolys) { auto v = poly->verts[0]; @@ -4247,24 +4317,67 @@ std::shared_ptr CBasePhysicManager::GenerateWorldVertexArray } } + for (auto& poly : glpolys) + { + free(poly); + } + brushface->num_vertexes = iNumVerts - iStartVert; } //Always shrink to save system memory worldVertexArray->vVertexBuffer.shrink_to_fit(); - m_worldVertexResources[worldModelName] = worldVertexArray; - return worldVertexArray; } -/*void CBasePhysicManager::FreeWorldVertexArray() +std::shared_ptr CBasePhysicManager::GenerateWorldVertexArray(model_t *mod) { - if (m_worldVertexArray) { - delete m_worldVertexArray; - m_worldVertexArray = NULL; + std::string worldModelName; + + if (mod->name[0] == '*') + { + auto worldmodel = EngineFindWorldModelBySubModel(mod); + + if (!worldmodel) + { + gEngfuncs.Con_Printf("CBasePhysicManager::GenerateWorldVertexArray: Failed to find worldmodel for submodel \"%s\"!\n", mod->name); + return nullptr; + } + + worldModelName = worldmodel->name; + } + else + { + worldModelName = mod->name; + } + + auto found = m_worldVertexResources.find(worldModelName); + + if (found != m_worldVertexResources.end()) + { + return found->second; + } + + std::shared_ptr worldVertexArray; + + if (g_dwVideoMode == VIDEOMODE_SOFTWARE) + { + worldVertexArray = GenerateWorldVertexArrayInternal(mod); + } + else if (g_iEngineType == ENGINE_GOLDSRC_HL25) + { + worldVertexArray = GenerateWorldVertexArrayInternal(mod); + } + else + { + worldVertexArray = GenerateWorldVertexArrayInternal(mod); } -}*/ + + m_worldVertexResources[worldModelName] = worldVertexArray; + + return worldVertexArray; +} /* Purpose : Generate IndexArray for world and all brush models @@ -4276,7 +4389,18 @@ std::shared_ptr CBasePhysicManager::GenerateBrushIndexArray(m pIndexArray->flags |= PhysicIndexArrayFlag_FromBSP; pIndexArray->pVertexArray = pWorldVertexArray; - GenerateIndexArrayForBrushModel(mod, pIndexArray.get()); + if (g_dwVideoMode == VIDEOMODE_SOFTWARE) + { + GenerateIndexArrayForBrushModel(mod, pIndexArray.get()); + } + else if (g_iEngineType == ENGINE_GOLDSRC_HL25) + { + GenerateIndexArrayForBrushModel(mod, pIndexArray.get()); + } + else + { + GenerateIndexArrayForBrushModel(mod, pIndexArray.get()); + } auto name = UTIL_GetAbsoluteModelName(mod); @@ -4302,19 +4426,20 @@ void CBasePhysicManager::FreeAllIndexArrays(int withflags, int withoutflags) } } +template void CBasePhysicManager::GenerateIndexArrayForBrushModel(model_t* mod, CPhysicIndexArray* pIndexArray) { if (mod == r_worldmodel) { - GenerateIndexArrayRecursiveWorldNode(mod, mod->nodes, pIndexArray); + GenerateIndexArrayRecursiveWorldNode(mod, (T2 *)mod->nodes, pIndexArray); } else { for (int i = 0; i < mod->nummodelsurfaces; i++) { - auto surf = GetWorldSurfaceByIndex(mod->firstmodelsurface + i); + auto surf = GetWorldSurfaceByIndex(mod->firstmodelsurface + i); - GenerateIndexArrayForSurface(mod, surf, pIndexArray); + GenerateIndexArrayForSurface(mod, surf, pIndexArray); } } @@ -4322,7 +4447,8 @@ void CBasePhysicManager::GenerateIndexArrayForBrushModel(model_t* mod, CPhysicIn pIndexArray->vIndexBuffer.shrink_to_fit(); } -void CBasePhysicManager::GenerateIndexArrayForSurface(model_t* mod, msurface_t* surf, CPhysicIndexArray* pIndexArray) +template +void CBasePhysicManager::GenerateIndexArrayForSurface(model_t* mod, T* surf, CPhysicIndexArray* pIndexArray) { if (surf->flags & SURF_DRAWTURB) { @@ -4339,12 +4465,13 @@ void CBasePhysicManager::GenerateIndexArrayForSurface(model_t* mod, msurface_t* return; } - auto surfIndex = GetWorldSurfaceIndex(surf); + auto surfIndex = GetWorldSurfaceIndex(surf); GenerateIndexArrayForBrushface(&pIndexArray->pVertexArray->vFaceBuffer[surfIndex], pIndexArray); } -void CBasePhysicManager::GenerateIndexArrayRecursiveWorldNode(model_t* mod, mnode_t* node, CPhysicIndexArray* pIndexArray) +template +void CBasePhysicManager::GenerateIndexArrayRecursiveWorldNode(model_t* mod, T2* node, CPhysicIndexArray* pIndexArray) { if (node->contents == CONTENTS_SOLID) return; @@ -4352,16 +4479,16 @@ void CBasePhysicManager::GenerateIndexArrayRecursiveWorldNode(model_t* mod, mnod if (node->contents < 0) return; - GenerateIndexArrayRecursiveWorldNode(mod, node->children[0], pIndexArray); + GenerateIndexArrayRecursiveWorldNode(mod, node->children[0], pIndexArray); for (int i = 0; i < node->numsurfaces; ++i) { - auto surf = GetWorldSurfaceByIndex(node->firstsurface + i); + auto surf = GetWorldSurfaceByIndex(node->firstsurface + i); - GenerateIndexArrayForSurface(mod, surf, pIndexArray); + GenerateIndexArrayForSurface(mod, surf, pIndexArray); } - GenerateIndexArrayRecursiveWorldNode(mod, node->children[1], pIndexArray); + GenerateIndexArrayRecursiveWorldNode(mod, node->children[1], pIndexArray); } void CBasePhysicManager::GenerateIndexArrayForBrushface(CPhysicBrushFace* brushface, CPhysicIndexArray* pIndexArray) diff --git a/Plugins/BulletPhysics/BasePhysicManager.h b/Plugins/BulletPhysics/BasePhysicManager.h index 1916e3b6..a325b4ed 100644 --- a/Plugins/BulletPhysics/BasePhysicManager.h +++ b/Plugins/BulletPhysics/BasePhysicManager.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "ClientPhysicManager.h" #include "ClientPhysicConfig.h" @@ -135,11 +136,24 @@ class CBasePhysicManager : public IClientPhysicManager private: //WorldVertexArray and WorldIndexArray Management std::shared_ptr GenerateWorldVertexArray(model_t* mod); + + template + std::shared_ptr GenerateWorldVertexArrayInternal(model_t* mod); + + template + void BuildSurfaceDisplayList(model_t* mod, T *fa, std::deque& glpolys); + std::shared_ptr GenerateBrushIndexArray(model_t* mod, const std::shared_ptr & pWorldVertexArray); + template void GenerateIndexArrayForBrushModel(model_t* mod, CPhysicIndexArray* pIndexArray); - void GenerateIndexArrayRecursiveWorldNode(model_t* mod, mnode_t* node, CPhysicIndexArray* pIndexArray); - void GenerateIndexArrayForSurface(model_t* mod, msurface_t* psurf, CPhysicIndexArray* pIndexArray); + + template + void GenerateIndexArrayRecursiveWorldNode(model_t* mod, T2* node, CPhysicIndexArray* pIndexArray); + + template + void GenerateIndexArrayForSurface(model_t* mod, T* psurf, CPhysicIndexArray* pIndexArray); + void GenerateIndexArrayForBrushface(CPhysicBrushFace* brushface, CPhysicIndexArray* pIndexArray); //Deprecated: use Resource Management now diff --git a/Plugins/BulletPhysics/BulletPhysicManager.cpp b/Plugins/BulletPhysics/BulletPhysicManager.cpp index 3865c755..fc11dd94 100644 --- a/Plugins/BulletPhysics/BulletPhysicManager.cpp +++ b/Plugins/BulletPhysics/BulletPhysicManager.cpp @@ -1437,7 +1437,6 @@ CBulletPhysicsDebugDraw : public btIDebugDraw void drawLine(const btVector3& from1, const btVector3& to1, const btVector3& color1) override { //The texture must be reset to zero upon drawing. - vgui::surface()->DrawSetTexture(-1); vgui::surface()->DrawSetTexture(0); if (IsDebugDrawWallHackEnabled()) diff --git a/Plugins/BulletPhysics/exportfuncs.cpp b/Plugins/BulletPhysics/exportfuncs.cpp index 87f7e023..5f5759a5 100644 --- a/Plugins/BulletPhysics/exportfuncs.cpp +++ b/Plugins/BulletPhysics/exportfuncs.cpp @@ -142,35 +142,6 @@ bool CL_IsFirstPersonMode(cl_entity_t *player) return false; } -msurface_t* GetWorldSurfaceByIndex(int index) -{ - msurface_t* surf; - - if (g_iEngineType == ENGINE_GOLDSRC_HL25) - { - surf = (((msurface_hl25_t*)r_worldmodel->surfaces) + index); - } - else - { - surf = r_worldmodel->surfaces + index; - } - - return surf; -} - -int GetWorldSurfaceIndex(msurface_t* surf) -{ - if (g_iEngineType == ENGINE_GOLDSRC_HL25) - { - auto surf25 = (msurface_hl25_t*)surf; - auto surfbase = (msurface_hl25_t*)r_worldmodel->surfaces; - - return surf25 - surfbase; - } - - return surf - r_worldmodel->surfaces; -} - int EngineGetMaxClientEdicts(void) { return (*cl_max_edicts); @@ -508,7 +479,11 @@ int studioapi_StudioCheckBBox() qboolean R_CullBox(vec3_t mins, vec3_t maxs) { - return gPrivateFuncs.R_CullBox(mins, maxs); + if(gPrivateFuncs.R_CullBox) + return gPrivateFuncs.R_CullBox(mins, maxs); + + //We don't have such thing in software mode + return false; } void EngineStudio_FillAddress(int version, struct r_studio_interface_s** ppinterface, struct engine_studio_api_s* pstudio) diff --git a/Plugins/BulletPhysics/exportfuncs.h b/Plugins/BulletPhysics/exportfuncs.h index 1febfe61..5850367e 100644 --- a/Plugins/BulletPhysics/exportfuncs.h +++ b/Plugins/BulletPhysics/exportfuncs.h @@ -60,9 +60,6 @@ void HUD_Shutdown(void); void HUD_CreateEntities(void); void V_CalcRefdef(struct ref_params_s* pparams); -msurface_t* GetWorldSurfaceByIndex(int index); -int GetWorldSurfaceIndex(msurface_t* surf); - entity_state_t* R_GetPlayerState(int index); void V_RenderView(void); diff --git a/Plugins/BulletPhysics/plugins.cpp b/Plugins/BulletPhysics/plugins.cpp index 940a470f..66d9f688 100644 --- a/Plugins/BulletPhysics/plugins.cpp +++ b/Plugins/BulletPhysics/plugins.cpp @@ -20,6 +20,8 @@ IFileSystem *g_pFileSystem = NULL; IFileSystem_HL25* g_pFileSystem_HL25 = NULL; int g_iEngineType = 0; +DWORD g_dwVideoMode = VIDEOMODE_SOFTWARE; + PVOID g_dwEngineBase = 0; DWORD g_dwEngineSize = 0; PVOID g_dwEngineTextBase = 0; @@ -64,6 +66,7 @@ void IPluginsV4::LoadEngine(cl_enginefunc_t *pEngfuncs) g_dwEngineTextBase = g_pMetaHookAPI->GetSectionByName(g_dwEngineBase, ".text\x0\x0\x0", &g_dwEngineTextSize); g_dwEngineDataBase = g_pMetaHookAPI->GetSectionByName(g_dwEngineBase, ".data\x0\x0\x0", &g_dwEngineDataSize); g_dwEngineRdataBase = g_pMetaHookAPI->GetSectionByName(g_dwEngineBase, ".rdata\x0\x0", &g_dwEngineRdataSize); + g_dwVideoMode = g_pMetaHookAPI->GetVideoMode(nullptr, nullptr, nullptr, nullptr); memcpy(&gEngfuncs, pEngfuncs, sizeof(gEngfuncs)); diff --git a/Plugins/BulletPhysics/plugins.h b/Plugins/BulletPhysics/plugins.h index ea724774..d4cb2dc8 100644 --- a/Plugins/BulletPhysics/plugins.h +++ b/Plugins/BulletPhysics/plugins.h @@ -7,6 +7,8 @@ extern IFileSystem *g_pFileSystem; extern IFileSystem_HL25* g_pFileSystem_HL25; extern int g_iEngineType; +extern DWORD g_dwVideoMode; + extern PVOID g_dwEngineBase; extern DWORD g_dwEngineSize; extern PVOID g_dwEngineTextBase; diff --git a/Plugins/BulletPhysics/privatehook.cpp b/Plugins/BulletPhysics/privatehook.cpp index a616b8d5..a3e58bc6 100644 --- a/Plugins/BulletPhysics/privatehook.cpp +++ b/Plugins/BulletPhysics/privatehook.cpp @@ -52,8 +52,8 @@ private_funcs_t gPrivateFuncs = {0}; studiohdr_t** pstudiohdr = NULL; model_t** r_model = NULL; void* g_pGameStudioRenderer = NULL; -int* r_framecount = NULL; -int* r_visframecount = NULL; +//int* r_framecount = NULL; +//int* r_visframecount = NULL; int* cl_parsecount = NULL; void* cl_frames = NULL; int size_of_frame = 0; @@ -139,7 +139,7 @@ void Engine_FillAddreess(void) } } Sig_FuncNotFound(R_DrawTEntitiesOnList); - +#if 0 if (g_iEngineType == ENGINE_SVENGINE) { gPrivateFuncs.R_RecursiveWorldNode = (decltype(gPrivateFuncs.R_RecursiveWorldNode))Search_Pattern(R_RECURSIVEWORLDNODE_SIG_SVENGINE); @@ -159,6 +159,7 @@ void Engine_FillAddreess(void) gPrivateFuncs.R_RecursiveWorldNode = (decltype(gPrivateFuncs.R_RecursiveWorldNode))Search_Pattern(R_RECURSIVEWORLDNODE_SIG_BLOB); } Sig_FuncNotFound(R_RecursiveWorldNode); +#endif if (g_iEngineType == ENGINE_SVENGINE) { @@ -178,7 +179,7 @@ void Engine_FillAddreess(void) { gPrivateFuncs.R_CullBox = (decltype(gPrivateFuncs.R_CullBox))Search_Pattern(R_CULLBOX_SIG_BLOB); } - Sig_FuncNotFound(R_CullBox); + //Sig_FuncNotFound(R_CullBox); if (1) { @@ -193,7 +194,7 @@ void Engine_FillAddreess(void) auto R_RenderView_PushString = Search_Pattern(pattern); if (R_RenderView_PushString) { - PVOID Candidate = g_pMetaHookAPI->ReverseSearchFunctionBeginEx(R_RenderView_PushString, 0x100, [](PUCHAR Candidate) { + PVOID Candidate = g_pMetaHookAPI->ReverseSearchFunctionBeginEx(R_RenderView_PushString, 0x150, [](PUCHAR Candidate) { if (Candidate[0] == 0xD9 && Candidate[1] == 0x05) @@ -210,17 +211,32 @@ void Engine_FillAddreess(void) return TRUE; return FALSE; - }); + }); - if (g_iEngineType == ENGINE_SVENGINE) + if (Candidate) { - gPrivateFuncs.R_RenderView_SvEngine = (decltype(gPrivateFuncs.R_RenderView_SvEngine))Candidate; + if (g_iEngineType == ENGINE_SVENGINE) + { + gPrivateFuncs.R_RenderView_SvEngine = (decltype(gPrivateFuncs.R_RenderView_SvEngine))Candidate; + } + else + { + gPrivateFuncs.R_RenderView = (decltype(gPrivateFuncs.R_RenderView))Candidate; + } } else { - gPrivateFuncs.R_RenderView = (decltype(gPrivateFuncs.R_RenderView))Candidate; + Sig_NotFound(R_RenderView); } } + else + { + Sig_NotFound(R_RenderView_PushString); + } + } + else + { + Sig_NotFound(R_RenderView_String); } } @@ -235,7 +251,33 @@ void Engine_FillAddreess(void) if ((gPrivateFuncs.R_RenderView || gPrivateFuncs.R_RenderView_SvEngine) && !gPrivateFuncs.V_RenderView) { - if (1) + if (g_dwVideoMode == VIDEOMODE_SOFTWARE) + { + //R_RenderView: called without + const char V_RenderView_StringPattern[] = "R_RenderView: called without enough stack"; + auto V_RenderView_String = Search_Pattern_Data(V_RenderView_StringPattern); + if (!V_RenderView_String) + V_RenderView_String = Search_Pattern_Rdata(V_RenderView_StringPattern); + + Sig_VarNotFound(V_RenderView_String); + + char pattern[] = "\x68\x2A\x2A\x2A\x2A\xE8"; + *(DWORD*)(pattern + 1) = (DWORD)V_RenderView_String; + auto V_RenderView_PushString = Search_Pattern(pattern); + + Sig_VarNotFound(V_RenderView_PushString); + + gPrivateFuncs.V_RenderView = (decltype(gPrivateFuncs.V_RenderView))g_pMetaHookAPI->ReverseSearchFunctionBeginEx(V_RenderView_PushString, 0x150, [](PUCHAR Candidate) { + + if (Candidate[0] == 0x55 && + Candidate[1] == 0x8B && + Candidate[2] == 0xEC) + return TRUE; + + return FALSE; + }); + } + else { const char pattern[] = "\x68\x00\x40\x00\x00\xFF"; /* @@ -247,6 +289,7 @@ void Engine_FillAddreess(void) while (SearchBegin < SearchLimit) { PUCHAR pFound = (PUCHAR)Search_Pattern_From_Size(SearchBegin, SearchLimit - SearchBegin, pattern); + if (pFound) { typedef struct @@ -608,24 +651,64 @@ void Engine_FillAddreess(void) Sig_VarNotFound(cl_viewentity); } - if (g_iEngineType == ENGINE_SVENGINE) - { - gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_SVENGINE); - } - else if (g_iEngineType == ENGINE_GOLDSRC_HL25) - { - gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_HL25); - } - else if (g_iEngineType == ENGINE_GOLDSRC) + if (1) { - gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_NEW); + //Setting up renderer... + const char sigs1[] = "Setting up renderer...\n"; + auto SettingUpRenderer_String = Search_Pattern_Data(sigs1); + if (!SettingUpRenderer_String) + SettingUpRenderer_String = Search_Pattern_Rdata(sigs1); + Sig_VarNotFound(SettingUpRenderer_String); + char pattern[] = "\x68\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A"; + *(DWORD*)(pattern + 1) = (DWORD)SettingUpRenderer_String; + auto SettingUpRenderer_PushString = Search_Pattern(pattern); + Sig_VarNotFound(SettingUpRenderer_PushString); + + g_pMetaHookAPI->DisasmRanges((PUCHAR)SettingUpRenderer_PushString + Sig_Length(pattern), 0x50, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) { + + auto pinst = (cs_insn*)inst; + + if (address[0] == 0xE8) + { + PVOID target = (decltype(target))pinst->detail->x86.operands[0].imm; + + gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))target; + return TRUE; + } + + if (address[0] == 0xCC) + return TRUE; + + if (pinst->id == X86_INS_RET) + return TRUE; + + return FALSE; + + }, 0, NULL); + } - else if (g_iEngineType == ENGINE_GOLDSRC_BLOB) + + if (!gPrivateFuncs.R_NewMap) { - gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_BLOB); + if (g_iEngineType == ENGINE_SVENGINE) + { + gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_SVENGINE); + } + else if (g_iEngineType == ENGINE_GOLDSRC_HL25) + { + gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_HL25); + } + else if (g_iEngineType == ENGINE_GOLDSRC) + { + gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_NEW); + } + else if (g_iEngineType == ENGINE_GOLDSRC_BLOB) + { + gPrivateFuncs.R_NewMap = (decltype(gPrivateFuncs.R_NewMap))Search_Pattern(R_NEWMAP_SIG_BLOB); + } + Sig_FuncNotFound(R_NewMap); } - Sig_FuncNotFound(R_NewMap); - +#if 0 if (1) { typedef struct @@ -733,7 +816,7 @@ void Engine_FillAddreess(void) Sig_VarNotFound(r_framecount); Sig_VarNotFound(r_visframecount); } - +#endif if (1) { #define MOD_KNOWN_SIG "\xB8\x9D\x82\x97\x53\x81\xE9" @@ -778,6 +861,19 @@ void Engine_FillAddreess(void) return TRUE; } + //.text : 101D5F00 55 push ebp + //.text : 101D5F01 8B EC mov ebp, esp + //.text : 101D5F03 83 EC 08 sub esp, 8 + if (Candidate[0] == 0x55 && + Candidate[1] == 0x8B && + Candidate[2] == 0xEC && + Candidate[3] == 0x83 && + Candidate[4] == 0xEC && + Candidate[5] == 0x08) + { + return TRUE; + } + return FALSE; }); Sig_FuncNotFound(Mod_LoadStudioModel); diff --git a/Plugins/BulletPhysics/privatehook.h b/Plugins/BulletPhysics/privatehook.h index 3ae06e23..d8deed82 100644 --- a/Plugins/BulletPhysics/privatehook.h +++ b/Plugins/BulletPhysics/privatehook.h @@ -88,8 +88,8 @@ extern void* g_pGameStudioRenderer; extern float(*pbonetransform)[128][3][4]; extern float(*plighttransform)[128][3][4]; -extern int* r_framecount; -extern int *r_visframecount; +//extern int* r_framecount; +//extern int *r_visframecount; extern int *cl_parsecount; extern void *cl_frames; extern int size_of_frame; diff --git a/Plugins/VGUI2Extension/GameUI.cpp b/Plugins/VGUI2Extension/GameUI.cpp index 5bbead25..28a89d11 100644 --- a/Plugins/VGUI2Extension/GameUI.cpp +++ b/Plugins/VGUI2Extension/GameUI.cpp @@ -3622,7 +3622,7 @@ void GameUI_FillAddress(void) return FALSE; }, 0, &ctx); - + Sig_FuncNotFound(CBasePanel_ctor); } if (1) diff --git a/include/HLSDK/common/com_model.h b/include/HLSDK/common/com_model.h index b8867ae8..0fdf556a 100644 --- a/include/HLSDK/common/com_model.h +++ b/include/HLSDK/common/com_model.h @@ -130,6 +130,25 @@ typedef struct mnode_s unsigned short numsurfaces; } mnode_t; +//software mode +typedef struct mnode_sw_s +{ + // common with leaf + int contents; // 0, to differentiate from leafs + int visframe; // node needs to be traversed if current + + short minmaxs[6]; // for bounding box culling + + struct mnode_sw_s* parent; + + // node specific + mplane_t* plane; + struct mnode_sw_s* children[2]; + + unsigned short firstsurface; + unsigned short numsurfaces; +} mnode_sw_t; + typedef struct msurface_s msurface_t; typedef struct decal_s decal_t; @@ -147,7 +166,7 @@ struct decal_s short entityIndex; // Entity this is attached to }; -typedef struct mleaf_s +typedef struct mleaf_sw_s { // common with node int contents; // wil be a negative contents number @@ -155,7 +174,7 @@ typedef struct mleaf_s short minmaxs[6]; // for bounding box culling - struct mnode_s *parent; + struct mnode_sw_s *parent; // leaf specific byte *compressed_vis; @@ -165,6 +184,26 @@ typedef struct mleaf_s int nummarksurfaces; int key; // BSP sequence number for leaf's contents byte ambient_sound_level[NUM_AMBIENTS]; +} mleaf_sw_t; + +typedef struct mleaf_s +{ + // common with node + int contents; // wil be a negative contents number + int visframe; // node needs to be traversed if current + + float minmaxs[6]; // for bounding box culling + + struct mnode_s* parent; + + // leaf specific + byte* compressed_vis; + struct efrag_s* efrags; + + msurface_t** firstmarksurface; + int nummarksurfaces; + int key; // BSP sequence number for leaf's contents + byte ambient_sound_level[NUM_AMBIENTS]; } mleaf_t; /*struct msurface_s