Improve Textmode Ressource usage and cat_save/load
This commit is contained in:
parent
2209707f70
commit
074b394908
@ -62,8 +62,6 @@ DECLARE_HOOKED_METHOD(IsPlayingTimeDemo, bool);
|
||||
// ClientMode
|
||||
DECLARE_HOOKED_METHOD(OverrideView, void, void *, CViewSetup *);
|
||||
// g_IEngine
|
||||
// IVModelRender
|
||||
DECLARE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *, const DrawModelState_t &, const ModelRenderInfo_t &, matrix3x4_t *);
|
||||
// IStudioRender
|
||||
DECLARE_HOOKED_METHOD(BeginFrame, void, IStudioRender *);
|
||||
// IBaseClient
|
||||
@ -79,6 +77,7 @@ DECLARE_HOOKED_METHOD(SDL_SetClipboardText, int, const char *);
|
||||
// IUniformRandomStream
|
||||
DECLARE_HOOKED_METHOD(RandomInt, int, IUniformRandomStream *, int, int);
|
||||
#endif
|
||||
DECLARE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *, const DrawModelState_t &, const ModelRenderInfo_t &, matrix3x4_t *);
|
||||
} // namespace hooked_methods
|
||||
|
||||
// TODO
|
||||
|
@ -22,3 +22,6 @@ target_sources(cathook PRIVATE
|
||||
if(EnableVisuals)
|
||||
add_subdirectory(visual)
|
||||
endif()
|
||||
if(NOT EnableVisuals)
|
||||
add_subdirectory(textmode)
|
||||
endif()
|
||||
|
@ -7,29 +7,68 @@
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
/*// 81
|
||||
ITexture *FindTexture_null_hook(void* this_, char const* pTextureName, const
|
||||
char *pTextureGroupName, bool complain, int nAdditionalCreationFlags) { static
|
||||
ITexture *st = ((FindTexture_t)hooks::materialsystem.GetMethod(81))(this_,
|
||||
pTextureName, pTextureGroupName, complain, nAdditionalCreationFlags); return st;
|
||||
typedef ITexture *(*FindTexture_t)(void *, const char *, const char *, bool, int);
|
||||
typedef IMaterial *(*FindMaterialEx_t)(void *, const char *, const char *, int, bool, const char *);
|
||||
typedef IMaterial *(*FindMaterial_t)(void *, const char *, const char *, bool, const char *);
|
||||
// 81
|
||||
FindTexture_t FindTexture_Original;
|
||||
FindMaterialEx_t FindMaterialEx_Original;
|
||||
FindMaterial_t FindMaterial_Original;
|
||||
|
||||
ITexture *FindTexture_null_hook(void *this_, char const *pTextureName, const char *pTextureGroupName, bool complain, int nAdditionalCreationFlags)
|
||||
{
|
||||
static ITexture *st = FindTexture_Original(this_, pTextureName, pTextureGroupName, complain, nAdditionalCreationFlags);
|
||||
return st;
|
||||
}
|
||||
|
||||
// 123
|
||||
IMaterial *FindMaterialEx_null_hook(void* this_, char const* pMaterialName,
|
||||
const char *pTextureGroupName, int nContext, bool complain, const char
|
||||
*pComplainPrefix) { static IMaterial *st =
|
||||
((FindMaterialEx_t)hooks::materialsystem.GetMethod(123))(this_, pMaterialName,
|
||||
pTextureGroupName, nContext, complain, pComplainPrefix); return st;
|
||||
IMaterial *FindMaterialEx_null_hook(void *this_, char const *pMaterialName, const char *pTextureGroupName, int nContext, bool complain, const char *pComplainPrefix)
|
||||
{
|
||||
static IMaterial *st = FindMaterialEx_Original(this_, pMaterialName, pTextureGroupName, nContext, complain, pComplainPrefix);
|
||||
return st;
|
||||
}
|
||||
|
||||
// 73
|
||||
IMaterial *FindMaterial_null_hook(void* this_, char const* pMaterialName, const
|
||||
char *pTextureGroupName, bool complain, const char *pComplainPrefix) { static
|
||||
IMaterial *st = ((FindMaterial_t)hooks::materialsystem.GetMethod(73))(this_,
|
||||
pMaterialName, pTextureGroupName, complain, pComplainPrefix); return st;
|
||||
IMaterial *FindMaterial_null_hook(void *this_, char const *pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix)
|
||||
{
|
||||
static IMaterial *st = FindMaterial_Original(this_, pMaterialName, pTextureGroupName, complain, pComplainPrefix);
|
||||
return st;
|
||||
}
|
||||
|
||||
void ReloadTextures_null_hook(void* this_) {}
|
||||
void ReloadMaterials_null_hook(void* this_, const char *pSubString) {}
|
||||
void ReloadFilesInList_null_hook(void* this_, IFileList *pFilesToReload) {}
|
||||
*/
|
||||
void ReloadTextures_null_hook(void *this_)
|
||||
{
|
||||
}
|
||||
void ReloadMaterials_null_hook(void *this_, const char *pSubString)
|
||||
{
|
||||
}
|
||||
void ReloadFilesInList_null_hook(void *this_, IFileList *pFilesToReload)
|
||||
{
|
||||
}
|
||||
void NullHook()
|
||||
{
|
||||
g_IMaterialSystem->SetInStubMode(true);
|
||||
}
|
||||
void RemoveNullHook()
|
||||
{
|
||||
g_IMaterialSystem->SetInStubMode(false);
|
||||
}
|
||||
static CatCommand ApplyNullhook("debug_material_hook", "Debug", []() { NullHook(); });
|
||||
static CatCommand RemoveNullhook("debug_material_hook_clear", "Debug", []() { RemoveNullHook(); });
|
||||
static settings::Bool debug_framerate("debug.framerate", "false");
|
||||
static float framerate = 0.0f;
|
||||
static Timer send_timer{};
|
||||
static InitRoutine init([]() {
|
||||
#if !ENABLE_VISUALS
|
||||
NullHook();
|
||||
#endif
|
||||
EC::Register(
|
||||
EC::Paint,
|
||||
[]() {
|
||||
if (!*debug_framerate)
|
||||
return;
|
||||
framerate = 0.9 * framerate + (1.0 - 0.9) * g_GlobalVars->absoluteframetime;
|
||||
if (send_timer.test_and_set(1000))
|
||||
logging::Info("FPS: %f", 1.0f / framerate);
|
||||
},
|
||||
"material_cm");
|
||||
});
|
||||
|
1
src/hooks/textmode/CMakeLists.txt
Normal file
1
src/hooks/textmode/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/DrawModelExecute.cpp")
|
12
src/hooks/textmode/DrawModelExecute.cpp
Normal file
12
src/hooks/textmode/DrawModelExecute.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
Created by Jenny White on 29.04.18.
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
#include "HookedMethods.hpp"
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, const DrawModelState_t &state, const ModelRenderInfo_t &info, matrix3x4_t *bone)
|
||||
{
|
||||
}
|
||||
}
|
@ -53,7 +53,6 @@ static CatCommand cat("cat", "", [](const CCommand &args) {
|
||||
|
||||
void save_thread(const int ArgC, const std::string ArgS)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono_literals::operator""s(1));
|
||||
settings::SettingsWriter writer{ settings::Manager::instance() };
|
||||
|
||||
DIR *config_directory = opendir(DATA_PATH "/configs");
|
||||
@ -99,7 +98,6 @@ static CatCommand save("save", "", [](const CCommand &args) {
|
||||
|
||||
void load_thread(const int ArgC, const std::string ArgS)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono_literals::operator""s(1));
|
||||
settings::SettingsReader loader{ settings::Manager::instance() };
|
||||
if (ArgC == 1)
|
||||
{
|
||||
@ -123,7 +121,6 @@ void load_thread(const int ArgC, const std::string ArgS)
|
||||
logging::Info("cat_load: Force crash. Couldn't load config!");
|
||||
std::terminate();
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono_literals::operator""s(3));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -190,7 +187,7 @@ static void getAndSortAllConfigs()
|
||||
logging::Info("Sorted %u config files\n", sortedConfigs.size());
|
||||
}
|
||||
|
||||
static CatCommand cat_find("find", "Find a command by name", [](const CCommand &args){
|
||||
static CatCommand cat_find("find", "Find a command by name", [](const CCommand &args) {
|
||||
// We need arguments
|
||||
if (args.ArgC() < 2)
|
||||
return logging::Info("Usage: cat_find (name)");
|
||||
@ -212,15 +209,14 @@ static CatCommand cat_find("find", "Find a command by name", [](const CCommand &
|
||||
found_rvars.push_back(s);
|
||||
}
|
||||
// Yes
|
||||
g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255),"Found rvars:\n");
|
||||
g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "Found rvars:\n");
|
||||
// Nothing found :C
|
||||
if (found_rvars.empty())
|
||||
g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255),"No rvars found.\n");
|
||||
g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "No rvars found.\n");
|
||||
// Found rvars
|
||||
else
|
||||
for (auto &s : found_rvars)
|
||||
g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255),"%s\n",s.c_str());
|
||||
|
||||
g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "%s\n", s.c_str());
|
||||
});
|
||||
|
||||
static int cat_completionCallback(const char *c_partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
|
Reference in New Issue
Block a user