mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Merge branch 'indev' into master
This commit is contained in:
parent
02fb1a3571
commit
6f66b3fb31
@ -8,12 +8,12 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "tier0/threadtools.h"
|
||||
#include "tier1/cvar.h"
|
||||
#include "tier1/utldict.h"
|
||||
#include "datacache/mdlcache.h"
|
||||
#include "datacache/imdlcache.h"
|
||||
#include "datacache/idatacache.h"
|
||||
#include "rtech/rtech_utils.h"
|
||||
#include "public/studio.h"
|
||||
#include "tier1/utldict.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -81,7 +81,7 @@ studiohdr_t* CMDLCache::FindMDL(CMDLCache* cache, MDLHandle_t handle, void* a3)
|
||||
FindCachedMDL(cache, pStudioData, a3);
|
||||
pMDLCache = *reinterpret_cast<void**>(pStudioData);
|
||||
}
|
||||
LABEL_6:
|
||||
|
||||
pStudioHdr = *reinterpret_cast<studiohdr_t**>(pMDLCache);
|
||||
if (pStudioHdr)
|
||||
return pStudioHdr;
|
||||
@ -90,7 +90,11 @@ studiohdr_t* CMDLCache::FindMDL(CMDLCache* cache, MDLHandle_t handle, void* a3)
|
||||
}
|
||||
pMDLCache = pStudioData->m_pAnimData;
|
||||
if (pMDLCache)
|
||||
goto LABEL_6;
|
||||
{
|
||||
pStudioHdr = *reinterpret_cast<studiohdr_t**>(pMDLCache);
|
||||
if (pStudioHdr)
|
||||
return pStudioHdr;
|
||||
}
|
||||
}
|
||||
return FindUncachedMDL(cache, handle, pStudioData, a3);
|
||||
}
|
||||
@ -156,7 +160,7 @@ studiohdr_t* CMDLCache::FindUncachedMDL(CMDLCache* cache, MDLHandle_t handle, st
|
||||
|
||||
size_t nFileNameLen = strlen(szModelName);
|
||||
|
||||
if (static_cast<int>(nFileNameLen) < 5 ||
|
||||
if (nFileNameLen < 5 ||
|
||||
(Q_stricmp(&szModelName[nFileNameLen - 5], ".rmdl") != 0) &&
|
||||
(Q_stricmp(&szModelName[nFileNameLen - 5], ".rrig") != 0) &&
|
||||
(Q_stricmp(&szModelName[nFileNameLen - 5], ".rpak") != 0))
|
||||
|
@ -14,19 +14,27 @@ struct RStaticProp_t
|
||||
uint8_t m_pUnknown[0x62]{};
|
||||
};
|
||||
|
||||
struct CMDLFallBack
|
||||
struct RMDLFallBack_t
|
||||
{
|
||||
studiohdr_t* m_pErrorHDR{};
|
||||
MDLHandle_t m_hErrorMDL{};
|
||||
studiohdr_t* m_pEmptyHDR{};
|
||||
MDLHandle_t m_hEmptyMDL{};
|
||||
studiohdr_t* m_pErrorHDR;
|
||||
studiohdr_t* m_pEmptyHDR;
|
||||
MDLHandle_t m_hErrorMDL;
|
||||
MDLHandle_t m_hEmptyMDL;
|
||||
|
||||
// This has to be cleared if 'common.rpak' is getting unloaded!
|
||||
RMDLFallBack_t(void)
|
||||
: m_pErrorHDR(nullptr)
|
||||
, m_pEmptyHDR(nullptr)
|
||||
, m_hErrorMDL(NULL)
|
||||
, m_hEmptyMDL(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// This must be cleared if 'common.rpak' is getting unloaded!
|
||||
void Clear(void)
|
||||
{
|
||||
m_pErrorHDR = nullptr;
|
||||
m_pEmptyHDR = nullptr;
|
||||
m_hErrorMDL = NULL;
|
||||
m_pEmptyHDR = nullptr;
|
||||
m_hEmptyMDL = NULL;
|
||||
}
|
||||
};
|
||||
@ -52,7 +60,7 @@ struct studiodata_t
|
||||
int m_nGuidLock; // always -1, set to 1 and 0 in CMDLCache::FindUncachedMDL.
|
||||
};
|
||||
|
||||
inline CMDLFallBack* g_pMDLFallback = new CMDLFallBack();
|
||||
inline RMDLFallBack_t* g_pMDLFallback = new RMDLFallBack_t();
|
||||
inline vector<MDLHandle_t> g_vBadMDLHandles;
|
||||
|
||||
class CMDLCache
|
||||
|
18
r5dev/engine/enginetrace.cpp
Normal file
18
r5dev/engine/enginetrace.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
//============================================================================//
|
||||
//
|
||||
// Purpose: Ray Tracing
|
||||
//
|
||||
//============================================================================//
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "engine/enginetrace.h"
|
||||
|
||||
void CEngineTrace_Attach()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CEngineTrace_Dettach()
|
||||
{
|
||||
|
||||
}
|
92
r5dev/engine/enginetrace.h
Normal file
92
r5dev/engine/enginetrace.h
Normal file
@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
|
||||
#include "mathlib/mathlib.h"
|
||||
|
||||
// EVERYTHING IN HERE STILL NEEDS TESTING!!!!
|
||||
|
||||
struct Ray_t
|
||||
{
|
||||
VectorAligned m_Start;
|
||||
VectorAligned m_Delta;
|
||||
VectorAligned m_StartOffset;
|
||||
VectorAligned m_Extents;
|
||||
char gap2C[0x10];
|
||||
void* m_pWorldAxisTransform;
|
||||
bool m_IsRay;
|
||||
bool m_IsSwept;
|
||||
|
||||
void Init(Vector3D const& start, Vector3D const& end)
|
||||
{
|
||||
m_Delta = end - start;
|
||||
|
||||
m_IsSwept = (m_Delta.LengthSqr() != 0);
|
||||
|
||||
m_Extents.Init();
|
||||
|
||||
m_pWorldAxisTransform = NULL;
|
||||
m_IsRay = true;
|
||||
|
||||
m_StartOffset.Init();
|
||||
m_Start = start;
|
||||
}
|
||||
};
|
||||
|
||||
struct csurface_t
|
||||
{
|
||||
const char* name;
|
||||
int surfaceProp;
|
||||
uint16_t flags;
|
||||
};
|
||||
|
||||
struct trace_t
|
||||
{
|
||||
Vector3D start;
|
||||
float unk1;
|
||||
Vector3D endpos;
|
||||
float unk2;
|
||||
cplane_t plane;
|
||||
float fraction;
|
||||
int contents;
|
||||
bool allsolid;
|
||||
bool startsolid;
|
||||
char gap3A[0x6];
|
||||
csurface_t surface;
|
||||
float fractionleftsolid;
|
||||
int hitgroup;
|
||||
short physicsBone;
|
||||
char gap5A[0x6];
|
||||
void* hit_entity;
|
||||
int hitbox;
|
||||
char gap6C[0x114];
|
||||
}; //Size: 0x0180
|
||||
|
||||
class CEngineTrace
|
||||
{
|
||||
virtual void stub_0() const = 0;
|
||||
virtual void stub_1() const = 0;
|
||||
virtual void ClipRayToCollideable(__m128* a2, unsigned int a3, __int64* a4, void* a5) = 0;
|
||||
virtual void TraceRay(const Ray_t& ray, unsigned int fMask, void* tracefilter, trace_t pTrace) = 0;
|
||||
virtual void TraceRay(const Ray_t& ray, unsigned int fMask, trace_t pTrace) = 0;
|
||||
};
|
||||
|
||||
/* ==== CENGINETRACE ======================================================================================================================================================= */
|
||||
|
||||
inline CEngineTrace* g_pEngineTrace = nullptr;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CEngineTrace_Attach();
|
||||
void CEngineTrace_Detach();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class VEngine_Trace : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const { }
|
||||
virtual void GetFun(void) const { }
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const { }
|
||||
virtual void Attach(void) const { }
|
||||
virtual void Detach(void) const { }
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
REGISTER(VEngine_Trace);
|
@ -9,10 +9,9 @@
|
||||
#include "public/avi/iavi.h"
|
||||
#include "public/avi/ibik.h"
|
||||
#include "public/const.h"
|
||||
#include "public/imaterial.h"
|
||||
#include "game/client/hud.h"
|
||||
|
||||
typedef void* IMaterial; // HACK
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sprite Models
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -354,7 +354,7 @@ void CAI_NetworkManager::LoadNetworkGraph(CAI_NetworkManager* pAINetworkManager,
|
||||
|
||||
if (nAiNetVersion > AINET_VERSION_NUMBER)
|
||||
{
|
||||
Warning(eDLL_T::SERVER, "AI node graph '%s' is unsupported (net version: '%d' supported: '%d')\n",
|
||||
Warning(eDLL_T::SERVER, "AI node graph '%s' is unsupported (net version: '%d' expected: '%d')\n",
|
||||
fsGraphPath.relative_path().u8string().c_str(), nAiNetVersion, AINET_VERSION_NUMBER);
|
||||
}
|
||||
else if (nAiMapVersion != g_ServerGlobalVariables->m_nMapVersion)
|
||||
|
@ -79,17 +79,18 @@ bool CBrowser::Init(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBrowser::RunFrame(void)
|
||||
{
|
||||
// Uncomment these when adjusting the theme or layout.
|
||||
{
|
||||
//ImGui::ShowStyleEditor();
|
||||
//ImGui::ShowDemoWindow();
|
||||
}
|
||||
|
||||
if (!m_bInitialized)
|
||||
{
|
||||
Init();
|
||||
m_bInitialized = true;
|
||||
}
|
||||
|
||||
{
|
||||
//ImGui::ShowStyleEditor();
|
||||
//ImGui::ShowDemoWindow();
|
||||
}
|
||||
|
||||
int nVars = 0;
|
||||
if (m_Style == ImGuiStyle_t::MODERN)
|
||||
{
|
||||
@ -101,14 +102,20 @@ void CBrowser::RunFrame(void)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 6.f, 6.f }); nVars++;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, m_flFadeAlpha); nVars++;
|
||||
}
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(928.f, 524.f)); nVars++;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(928.f, 524.f)); nVars++;
|
||||
|
||||
if (m_Style != ImGuiStyle_t::MODERN)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f); nVars++;
|
||||
}
|
||||
|
||||
if (!ImGui::Begin(m_pszBrowserTitle, &m_bActivate, ImGuiWindowFlags_NoScrollbar))
|
||||
if (m_bActivate && m_bReclaimFocus) // Reclaim focus on window apparition.
|
||||
{
|
||||
ImGui::SetNextWindowFocus();
|
||||
m_bReclaimFocus = false;
|
||||
}
|
||||
|
||||
if (!ImGui::Begin(m_pszBrowserLabel, &m_bActivate, ImGuiWindowFlags_NoScrollbar, &ResetInput))
|
||||
{
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(nVars);
|
||||
@ -117,7 +124,6 @@ void CBrowser::RunFrame(void)
|
||||
|
||||
ImGui::PopStyleVar(nVars);
|
||||
DrawSurface();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@ -155,6 +161,7 @@ void CBrowser::RunTask()
|
||||
else // Refresh server list the next time 'm_bActivate' evaluates to true.
|
||||
{
|
||||
m_bQueryListNonRecursive = true;
|
||||
m_bReclaimFocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +219,7 @@ void CBrowser::BrowserPanel(void)
|
||||
ImGui::BeginGroup();
|
||||
m_imServerBrowserFilter.Draw();
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Refresh List"))
|
||||
{
|
||||
m_svServerListMessage.clear();
|
||||
@ -219,6 +227,7 @@ void CBrowser::BrowserPanel(void)
|
||||
std::thread refresh(&CBrowser::RefreshServerList, this);
|
||||
refresh.detach();
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::TextColored(ImVec4(1.00f, 0.00f, 0.00f, 1.00f), m_svServerListMessage.c_str());
|
||||
ImGui::Separator();
|
||||
|
@ -21,24 +21,56 @@ History:
|
||||
#include "windows/id3dx.h"
|
||||
#include "windows/console.h"
|
||||
#include "windows/resource.h"
|
||||
#include "squirrel/sqtype.h"
|
||||
#include "gameui/IConsole.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CConsole::CConsole(void)
|
||||
CConsole::CConsole(void)
|
||||
: m_pszConsoleLabel("Console")
|
||||
, m_pszLoggingLabel("LoggingRegion")
|
||||
, m_nHistoryPos(-1)
|
||||
, m_nSuggestPos(-1)
|
||||
, m_nScrollBack(0)
|
||||
, m_nSelectBack(0)
|
||||
, m_flScrollX(0.f)
|
||||
, m_flScrollY(0.f)
|
||||
, m_flFadeAlpha(0.f)
|
||||
, m_bInitialized(false)
|
||||
, m_bReclaimFocus(false)
|
||||
, m_bCopyToClipBoard(false)
|
||||
, m_bModifyInput(false)
|
||||
, m_bCanAutoComplete(false)
|
||||
, m_bSuggestActive(false)
|
||||
, m_bSuggestMoved(false)
|
||||
, m_bSuggestUpdate(false)
|
||||
, m_bActivate(false)
|
||||
, m_Style(ImGuiStyle_t::NONE)
|
||||
{
|
||||
m_nInputFlags =
|
||||
ImGuiInputTextFlags_EnterReturnsTrue |
|
||||
ImGuiInputTextFlags_CallbackCompletion |
|
||||
ImGuiInputTextFlags_CallbackHistory |
|
||||
ImGuiInputTextFlags_CallbackAlways |
|
||||
ImGuiInputTextFlags_CallbackEdit |
|
||||
ImGuiInputTextFlags_AutoCaretEnd;
|
||||
|
||||
m_nSuggestFlags =
|
||||
ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoSavedSettings |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar;
|
||||
|
||||
m_nLoggingFlags =
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_HorizontalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar;
|
||||
|
||||
memset(m_szInputBuf, '\0', sizeof(m_szInputBuf));
|
||||
|
||||
m_nHistoryPos = -1;
|
||||
m_bInitialized = false;
|
||||
m_pszConsoleLabel = "Console";
|
||||
m_pszLoggingLabel = "LoggingRegion";
|
||||
|
||||
m_vCommands.push_back("CLEAR");
|
||||
m_vCommands.push_back("HELP");
|
||||
m_vCommands.push_back("HISTORY");
|
||||
|
||||
memset(m_szWindowLabel, '\0', sizeof(m_szWindowLabel));
|
||||
snprintf(m_szSummary, sizeof(m_szSummary), "%zu history items", m_vHistory.size());
|
||||
}
|
||||
|
||||
@ -64,12 +96,7 @@ bool CConsole::Init(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::RunFrame(void)
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
{
|
||||
Init();
|
||||
m_bInitialized = true;
|
||||
}
|
||||
|
||||
// Uncomment these when adjusting the theme or layout.
|
||||
{
|
||||
//ImGui::ShowStyleEditor();
|
||||
//ImGui::ShowDemoWindow();
|
||||
@ -79,11 +106,13 @@ void CConsole::RunFrame(void)
|
||||
* BASE PANEL SETUP *
|
||||
**************************/
|
||||
{
|
||||
int nVars = 0;
|
||||
if (!m_bActivate)
|
||||
if (!m_bInitialized)
|
||||
{
|
||||
return;
|
||||
Init();
|
||||
m_bInitialized = true;
|
||||
}
|
||||
|
||||
int nVars = 0;
|
||||
if (m_Style == ImGuiStyle_t::MODERN)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 8.f, 10.f }); nVars++;
|
||||
@ -138,6 +167,9 @@ void CConsole::RunFrame(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::RunTask()
|
||||
{
|
||||
// m_Logger and m_vHistory are modified.
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
|
||||
ClampLogSize();
|
||||
ClampHistorySize();
|
||||
}
|
||||
@ -149,7 +181,7 @@ void CConsole::Think(void)
|
||||
{
|
||||
if (m_bActivate)
|
||||
{
|
||||
if (m_flFadeAlpha <= 1.f)
|
||||
if (m_flFadeAlpha < 1.f)
|
||||
{
|
||||
m_flFadeAlpha += .1f;
|
||||
}
|
||||
@ -167,7 +199,7 @@ void CConsole::Think(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::DrawSurface(void)
|
||||
{
|
||||
if (!ImGui::Begin(m_pszConsoleLabel, &m_bActivate))
|
||||
if (!ImGui::Begin(m_pszConsoleLabel, &m_bActivate, ImGuiWindowFlags_None, &ResetInput))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
@ -211,7 +243,9 @@ void CConsole::DrawSurface(void)
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
ImGui::BeginChild(m_pszLoggingLabel, ImVec2(0, -flFooterHeightReserve), true, m_nLoggingFlags);
|
||||
|
||||
m_Mutex.lock();
|
||||
// Mutex is locked here, as we start using/modifying
|
||||
// non-atomic members that are used from several threads.
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
m_Logger.Render();
|
||||
|
||||
if (m_bCopyToClipBoard)
|
||||
@ -219,15 +253,14 @@ void CConsole::DrawSurface(void)
|
||||
m_Logger.Copy(true);
|
||||
m_bCopyToClipBoard = false;
|
||||
}
|
||||
m_Mutex.unlock();
|
||||
|
||||
m_flScrollX = ImGui::GetScrollX();
|
||||
m_flScrollY = ImGui::GetScrollY();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
ImGui::EndChild();
|
||||
ImGui::Separator();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
ImGui::PushItemWidth(flFooterWidthReserve - 80);
|
||||
if (ImGui::InputText("##input", m_szInputBuf, IM_ARRAYSIZE(m_szInputBuf), m_nInputFlags, &TextEditCallbackStub, reinterpret_cast<void*>(this)))
|
||||
{
|
||||
@ -253,13 +286,13 @@ void CConsole::DrawSurface(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-focus on window apparition.
|
||||
// Auto-focus input field on window apparition.
|
||||
ImGui::SetItemDefaultFocus();
|
||||
|
||||
// Auto-focus previous widget.
|
||||
// Auto-focus input field if reclaim is demanded.
|
||||
if (m_bReclaimFocus)
|
||||
{
|
||||
ImGui::SetKeyboardFocusHere(-1);
|
||||
ImGui::SetKeyboardFocusHere(-1); // -1 means previous widget.
|
||||
m_bReclaimFocus = false;
|
||||
}
|
||||
|
||||
@ -302,7 +335,7 @@ void CConsole::OptionsPanel(void)
|
||||
ImGui::Text("Console Hotkey:");
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Hotkey("##ToggleConsole", &g_pImGuiConfig->IConsole_Config.m_nBind0, ImVec2(80, 80)))
|
||||
if (ImGui::Hotkey("##ToggleConsole", &g_pImGuiConfig->m_ConsoleConfig.m_nBind0, ImVec2(80, 80)))
|
||||
{
|
||||
g_pImGuiConfig->Save();
|
||||
}
|
||||
@ -310,7 +343,7 @@ void CConsole::OptionsPanel(void)
|
||||
ImGui::Text("Browser Hotkey:");
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Hotkey("##ToggleBrowser", &g_pImGuiConfig->IBrowser_Config.m_nBind0, ImVec2(80, 80)))
|
||||
if (ImGui::Hotkey("##ToggleBrowser", &g_pImGuiConfig->m_BrowserConfig.m_nBind0, ImVec2(80, 80)))
|
||||
{
|
||||
g_pImGuiConfig->Save();
|
||||
}
|
||||
@ -326,27 +359,33 @@ void CConsole::SuggestPanel(void)
|
||||
ImGui::Begin("##suggest", nullptr, m_nSuggestFlags);
|
||||
ImGui::PushAllowKeyboardFocus(false);
|
||||
|
||||
for (size_t i = 0; i < m_vSuggest.size(); i++)
|
||||
for (size_t i = 0, ns = m_vSuggest.size(); i < ns; i++)
|
||||
{
|
||||
bool bIsIndexActive = m_nSuggestPos == i;
|
||||
const CSuggest& suggest = m_vSuggest[i];
|
||||
const bool bIsIndexActive = m_nSuggestPos == i;
|
||||
|
||||
ImGui::PushID(static_cast<int>(i));
|
||||
|
||||
if (con_suggestion_showflags->GetBool())
|
||||
{
|
||||
int k = ColorCodeFlags(m_vSuggest[i].m_nFlags);
|
||||
const int k = GetFlagColorIndex(suggest.m_nFlags);
|
||||
ImGui::Image(m_vFlagIcons[k].m_idIcon, ImVec2(m_vFlagIcons[k].m_nWidth, m_vFlagIcons[k].m_nHeight));
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
if (ImGui::Selectable(m_vSuggest[i].m_svName.c_str(), bIsIndexActive))
|
||||
if (ImGui::Selectable(suggest.m_svName.c_str(), bIsIndexActive))
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
// Remove the default value from ConVar before assigning it to the input buffer.
|
||||
string svConVar = m_vSuggest[i].m_svName.substr(0, m_vSuggest[i].m_svName.find(' ')) + ' ';
|
||||
memmove(m_szInputBuf, svConVar.data(), svConVar.size() + 1);
|
||||
const string svConVar = suggest.m_svName.substr(0, suggest.m_svName.find(' ')) + ' ';
|
||||
|
||||
memmove(m_szInputBuf, svConVar.data(), svConVar.size() + 1);
|
||||
ResetAutoComplete();
|
||||
|
||||
// Mutex lock is obtained here are we modify m_vHistory
|
||||
// which is used in the main and render thread.
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
BuildSummary(svConVar);
|
||||
}
|
||||
ImGui::PopID();
|
||||
@ -407,7 +446,7 @@ bool CConsole::AutoComplete(void)
|
||||
// Don't suggest if user tries to assign value to ConVar or execute ConCommand.
|
||||
if (strstr(m_szInputBuf, " ") || strstr(m_szInputBuf, ";"))
|
||||
{
|
||||
// !TODO: Add completion logic here.
|
||||
// !TODO: Add IConVar completion logic here.
|
||||
m_bCanAutoComplete = false;
|
||||
m_bSuggestActive = false;
|
||||
m_nSuggestPos = -1;
|
||||
@ -442,27 +481,28 @@ void CConsole::ClearAutoComplete(void)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: find ConVars/ConCommands from user input and add to vector
|
||||
// - Ignores ConVars marked FCVAR_HIDDEN
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::FindFromPartial(void)
|
||||
{
|
||||
ClearAutoComplete();
|
||||
|
||||
for (size_t i = 0; i < m_vsvCommandBases.size(); i++)
|
||||
for (const CSuggest& suggest : m_vsvCommandBases)
|
||||
{
|
||||
if (m_vSuggest.size() >= con_suggestion_limit->GetSizeT())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_vsvCommandBases[i].m_svName.find(m_szInputBuf) == string::npos)
|
||||
if (suggest.m_svName.find(m_szInputBuf) == string::npos)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::find(m_vSuggest.begin(), m_vSuggest.end(),
|
||||
m_vsvCommandBases[i].m_svName) == m_vSuggest.end())
|
||||
suggest.m_svName) == m_vSuggest.end())
|
||||
{
|
||||
string svValue; int nFlags = FCVAR_NONE;
|
||||
const ConCommandBase* pCommandBase = g_pCVar->FindCommandBase(m_vsvCommandBases[i].m_svName.c_str());
|
||||
const ConCommandBase* pCommandBase = g_pCVar->FindCommandBase(suggest.m_svName.c_str());
|
||||
|
||||
if (!pCommandBase || pCommandBase->IsFlagSet(FCVAR_HIDDEN))
|
||||
{
|
||||
@ -504,73 +544,39 @@ void CConsole::FindFromPartial(void)
|
||||
}
|
||||
else // Display compile-time flags instead.
|
||||
{
|
||||
nFlags = m_vsvCommandBases[i].m_nFlags;
|
||||
nFlags = suggest.m_nFlags;
|
||||
}
|
||||
}
|
||||
m_vSuggest.push_back(CSuggest(m_vsvCommandBases[i].m_svName + svValue, nFlags));
|
||||
m_vSuggest.push_back(CSuggest(suggest.m_svName + svValue, nFlags));
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
|
||||
std::sort(m_vSuggest.begin(), m_vSuggest.end());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: processes submitted commands for the main thread
|
||||
// Input : pszCommand -
|
||||
// Input : svCommand -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::ProcessCommand(const char* pszCommand)
|
||||
void CConsole::ProcessCommand(string svCommand)
|
||||
{
|
||||
DevMsg(eDLL_T::COMMON, "] %s\n", pszCommand);
|
||||
|
||||
Cbuf_AddText(Cbuf_GetCurrentPlayer(), pszCommand, cmd_source_t::kCommandSrcCode);
|
||||
//g_TaskScheduler->Dispatch(Cbuf_Execute, 0); // Run in main thread.
|
||||
StringRTrim(svCommand, " "); // Remove trailing white space characters to prevent history duplication.
|
||||
AddLog(ImVec4(1.00f, 0.80f, 0.60f, 1.00f), "%s] %s\n", Plat_GetProcessUpTime(), svCommand.c_str());
|
||||
|
||||
Cbuf_AddText(Cbuf_GetCurrentPlayer(), svCommand.c_str(), cmd_source_t::kCommandSrcCode);
|
||||
m_nHistoryPos = -1;
|
||||
for (size_t i = m_vHistory.size(); i-- > 0; )
|
||||
|
||||
for (size_t i = m_vHistory.size(); i-- > 0;)
|
||||
{
|
||||
if (m_vHistory[i].compare(pszCommand) == 0)
|
||||
if (m_vHistory[i].compare(svCommand) == 0)
|
||||
{
|
||||
m_vHistory.erase(m_vHistory.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_vHistory.push_back(Strdup(pszCommand));
|
||||
if (Stricmp(pszCommand, "CLEAR") == 0)
|
||||
{
|
||||
ClearLog();
|
||||
}
|
||||
else if (Stricmp(pszCommand, "HELP") == 0)
|
||||
{
|
||||
AddLog(ImVec4(0.81f, 0.81f, 0.81f, 1.00f), "Commands:\n");
|
||||
for (size_t i = 0; i < m_vCommands.size(); i++)
|
||||
{
|
||||
AddLog(ImVec4(0.81f, 0.81f, 0.81f, 1.00f), "- %s\n", m_vCommands[i].c_str());
|
||||
}
|
||||
|
||||
AddLog(ImVec4(0.81f, 0.81f, 0.81f, 1.00f), "Contexts:\n");
|
||||
AddLog(ImVec4(0.59f, 0.58f, 0.73f, 1.00f), "- Script(S): = Server DLL (Script)\n");
|
||||
AddLog(ImVec4(0.59f, 0.58f, 0.63f, 1.00f), "- Script(C): = Client DLL (Script)\n");
|
||||
AddLog(ImVec4(0.59f, 0.48f, 0.53f, 1.00f), "- Script(U): = UI DLL (Script)\n");
|
||||
|
||||
AddLog(ImVec4(0.23f, 0.47f, 0.85f, 1.00f), "- Native(S): = Server DLL (Code)\n");
|
||||
AddLog(ImVec4(0.46f, 0.46f, 0.46f, 1.00f), "- Native(C): = Client DLL (Code)\n");
|
||||
AddLog(ImVec4(0.59f, 0.35f, 0.46f, 1.00f), "- Native(U): = UI DLL (Code)\n");
|
||||
|
||||
AddLog(ImVec4(0.70f, 0.70f, 0.70f, 1.00f), "- Native(E): = Engine DLL (Code)\n");
|
||||
AddLog(ImVec4(0.32f, 0.64f, 0.72f, 1.00f), "- Native(F): = FileSystem (Code)\n");
|
||||
AddLog(ImVec4(0.36f, 0.70f, 0.35f, 1.00f), "- Native(R): = PakLoadAPI (Code)\n");
|
||||
AddLog(ImVec4(0.75f, 0.41f, 0.67f, 1.00f), "- Native(M): = MaterialSystem (Code)\n");
|
||||
}
|
||||
else if (Stricmp(pszCommand, "HISTORY") == 0)
|
||||
{
|
||||
ssize_t nFirst = static_cast<ssize_t>(m_vHistory.size()) - 10;
|
||||
for (ssize_t i = nFirst > 0 ? nFirst : 0; i < static_cast<ssize_t>(m_vHistory.size()); i++)
|
||||
{
|
||||
AddLog(ImVec4(0.81f, 0.81f, 0.81f, 1.00f), "%3d: %s\n", i, m_vHistory[i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
m_vHistory.push_back(svCommand);
|
||||
m_Logger.m_bScrollToBottom = true;
|
||||
}
|
||||
|
||||
@ -582,32 +588,19 @@ void CConsole::BuildSummary(string svConVar)
|
||||
{
|
||||
if (!svConVar.empty())
|
||||
{
|
||||
for (size_t i = 0; i < svConVar.size(); i++)
|
||||
{
|
||||
if (svConVar[i] == ' ' || svConVar[i] == ';')
|
||||
{
|
||||
svConVar.erase(i, svConVar.length() - 1); // Remove space or semicolon before we call 'g_pCVar->FindVar(..)'.
|
||||
}
|
||||
}
|
||||
// Remove trailing space and semicolon before we call 'g_pCVar->FindVar(..)'.
|
||||
StringRTrim(svConVar, " ;");
|
||||
|
||||
ConVar* pConVar = g_pCVar->FindVar(svConVar.c_str());
|
||||
if (pConVar)
|
||||
if (const ConVar* pConVar = g_pCVar->FindVar(svConVar.c_str()))
|
||||
{
|
||||
// Display the current and default value of ConVar if found.
|
||||
snprintf(m_szSummary, sizeof(m_szSummary), "(\"%s\", default \"%s\")", pConVar->GetString(), pConVar->GetDefault());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Display amount of history items if ConVar cannot be found.
|
||||
ClampHistorySize();
|
||||
snprintf(m_szSummary, sizeof(m_szSummary), "%zu history items", m_vHistory.size());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // Default or empty param.
|
||||
{
|
||||
ClampHistorySize();
|
||||
snprintf(m_szSummary, sizeof(m_szSummary), "%zu history items", m_vHistory.size());
|
||||
}
|
||||
// Display amount of history items if ConVar cannot be found or input is empty.
|
||||
ClampHistorySize();
|
||||
snprintf(m_szSummary, sizeof(m_szSummary), "%zu history items", m_vHistory.size());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -616,7 +609,7 @@ void CConsole::BuildSummary(string svConVar)
|
||||
void CConsole::BuildSuggestPanelRect(void)
|
||||
{
|
||||
float flSinglePadding = 0.f;
|
||||
float flItemHeight = ImGui::GetTextLineHeightWithSpacing() + 1.0f;
|
||||
const float flItemHeight = ImGui::GetTextLineHeightWithSpacing() + 1.0f;
|
||||
|
||||
if (m_vSuggest.size() > 1)
|
||||
{
|
||||
@ -627,7 +620,9 @@ void CConsole::BuildSuggestPanelRect(void)
|
||||
m_ivSuggestWindowPos = ImGui::GetItemRectMin();
|
||||
m_ivSuggestWindowPos.y += ImGui::GetItemRectSize().y;
|
||||
|
||||
float flWindowHeight = (flSinglePadding + std::clamp(static_cast<float>(m_vSuggest.size()) * (flItemHeight), 37.0f, 127.5f));
|
||||
const float flWindowHeight = (flSinglePadding + std::clamp(
|
||||
static_cast<float>(m_vSuggest.size()) * (flItemHeight), 37.0f, 127.5f));
|
||||
|
||||
m_ivSuggestWindowSize = ImVec2(600, flWindowHeight);
|
||||
}
|
||||
|
||||
@ -636,10 +631,11 @@ void CConsole::BuildSuggestPanelRect(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::ClampLogSize(void)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
if (m_Logger.GetTotalLines() > con_max_size_logvector->GetInt())
|
||||
const int nMaxLines = con_max_lines->GetInt();
|
||||
|
||||
if (m_Logger.GetTotalLines() > nMaxLines)
|
||||
{
|
||||
while (m_Logger.GetTotalLines() > con_max_size_logvector->GetInt())
|
||||
while (m_Logger.GetTotalLines() > nMaxLines)
|
||||
{
|
||||
m_Logger.RemoveLine(0);
|
||||
m_nScrollBack++;
|
||||
@ -656,7 +652,7 @@ void CConsole::ClampLogSize(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::ClampHistorySize(void)
|
||||
{
|
||||
while (m_vHistory.size() > con_max_size_history->GetSizeT())
|
||||
while (m_vHistory.size() > con_max_history->GetSizeT())
|
||||
{
|
||||
m_vHistory.erase(m_vHistory.begin());
|
||||
}
|
||||
@ -668,29 +664,27 @@ void CConsole::ClampHistorySize(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CConsole::LoadFlagIcons(void)
|
||||
{
|
||||
int k = 0; // Get all image resources for displaying flags.
|
||||
for (int i = IDB_PNG3; i <= IDB_PNG24; i++)
|
||||
{
|
||||
m_vFlagIcons.push_back(MODULERESOURCE());
|
||||
m_vFlagIcons[k] = GetModuleResource(i);
|
||||
bool ret = false;
|
||||
|
||||
bool ret = LoadTextureBuffer(reinterpret_cast<unsigned char*>(m_vFlagIcons[k].m_pData), static_cast<int>(m_vFlagIcons[k].m_nSize),
|
||||
&m_vFlagIcons[k].m_idIcon, &m_vFlagIcons[k].m_nWidth, &m_vFlagIcons[k].m_nHeight);
|
||||
if (!ret)
|
||||
{
|
||||
IM_ASSERT(ret);
|
||||
return false;
|
||||
}
|
||||
k++;
|
||||
// Get all image resources for displaying flags.
|
||||
for (int i = IDB_PNG3, k = NULL; i <= IDB_PNG24; i++, k++)
|
||||
{
|
||||
m_vFlagIcons.push_back(MODULERESOURCE(GetModuleResource(i)));
|
||||
MODULERESOURCE& rFlagIcon = m_vFlagIcons[k];
|
||||
|
||||
ret = LoadTextureBuffer(reinterpret_cast<unsigned char*>(rFlagIcon.m_pData),
|
||||
static_cast<int>(rFlagIcon.m_nSize), &rFlagIcon.m_idIcon, &rFlagIcon.m_nWidth, &rFlagIcon.m_nHeight);
|
||||
|
||||
IM_ASSERT(ret);
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns flag image index for CommandBase (must be aligned with resource.h!)
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
int CConsole::ColorCodeFlags(int nFlags) const
|
||||
int CConsole::GetFlagColorIndex(int nFlags) const
|
||||
{
|
||||
switch (nFlags)
|
||||
{
|
||||
@ -899,7 +893,9 @@ void CConsole::AddLog(const ConLog_t& conLog)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: adds logs to the vector (internal)
|
||||
// Input : *fmt -
|
||||
// Only call when mutex lock is obtained!
|
||||
// Input : &color -
|
||||
// *fmt -
|
||||
// ... -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::AddLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2)
|
||||
@ -911,8 +907,49 @@ void CConsole::AddLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2)
|
||||
buf[IM_ARRAYSIZE(buf) - 1] = 0;
|
||||
va_end(args);
|
||||
|
||||
m_Logger.InsertText(ConLog_t(buf, color));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: removes lines from console with sanitized start and end indices
|
||||
// input : nStart -
|
||||
// nEnd -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::RemoveLog(int nStart, int nEnd)
|
||||
{
|
||||
int nLines = m_Logger.GetTotalLines();
|
||||
if (nEnd >= nLines)
|
||||
{
|
||||
// Sanitize for last array elem.
|
||||
nEnd = (nLines - 1);
|
||||
}
|
||||
|
||||
if (nStart >= nEnd)
|
||||
{
|
||||
if (nEnd > 0)
|
||||
{
|
||||
nStart = (nEnd - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// First elem cannot be removed!
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (nStart < 0)
|
||||
{
|
||||
nStart = 0;
|
||||
}
|
||||
|
||||
// User wants to remove everything.
|
||||
if (nLines <= (nStart - nEnd))
|
||||
{
|
||||
ClearLog();
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
m_Logger.InsertText(ConLog_t(Strdup(buf), color));
|
||||
m_Logger.RemoveLine(nStart, nEnd);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -924,6 +961,26 @@ void CConsole::ClearLog(void)
|
||||
m_Logger.RemoveLine(0, (m_Logger.GetTotalLines() - 1));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: gets all console submissions
|
||||
// Output : vector of strings
|
||||
//-----------------------------------------------------------------------------
|
||||
vector<string> CConsole::GetHistory(void)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
return m_vHistory;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: clears the entire submission history vector
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::ClearHistory(void)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
m_vHistory.clear();
|
||||
BuildSummary();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets the console front-end style
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -30,7 +30,7 @@ private:
|
||||
void ClearAutoComplete(void);
|
||||
|
||||
void FindFromPartial(void);
|
||||
void ProcessCommand(const char* pszCommand);
|
||||
void ProcessCommand(string svCommand);
|
||||
|
||||
void BuildSummary(string svConVar = "");
|
||||
void BuildSuggestPanelRect(void);
|
||||
@ -39,7 +39,7 @@ private:
|
||||
void ClampHistorySize(void);
|
||||
|
||||
bool LoadFlagIcons(void);
|
||||
int ColorCodeFlags(int nFlags) const;
|
||||
int GetFlagColorIndex(int nFlags) const;
|
||||
|
||||
int TextEditCallback(ImGuiInputTextCallbackData* pData);
|
||||
static int TextEditCallbackStub(ImGuiInputTextCallbackData* pData);
|
||||
@ -47,71 +47,59 @@ private:
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void AddLog(const ConLog_t& conLog);
|
||||
|
||||
private:
|
||||
void AddLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2);
|
||||
void RemoveLog(int nStart, int nEnd);
|
||||
void ClearLog(void);
|
||||
|
||||
vector<string> GetHistory(void);
|
||||
void ClearHistory(void);
|
||||
|
||||
private: // Internal only.
|
||||
void AddLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
virtual void SetStyleVar(void);
|
||||
|
||||
private:
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
const char* m_pszConsoleLabel = nullptr;
|
||||
const char* m_pszLoggingLabel = nullptr;
|
||||
char m_szInputBuf[512] = { '\0' };
|
||||
char m_szSummary[512] = { '\0' };
|
||||
char m_szWindowLabel[512] = { '\0' };
|
||||
const char* m_pszConsoleLabel;
|
||||
const char* m_pszLoggingLabel;
|
||||
char m_szInputBuf[512];
|
||||
char m_szSummary[512];
|
||||
char m_szWindowLabel[512];
|
||||
|
||||
vector<string> m_vCommands;
|
||||
vector<string> m_vHistory;
|
||||
string m_svInputConVar;
|
||||
ssize_t m_nHistoryPos = -1;
|
||||
int m_nScrollBack = 0;
|
||||
int m_nSelectBack = 0;
|
||||
float m_flScrollX = 0.f;
|
||||
float m_flScrollY = 0.f;
|
||||
float m_flFadeAlpha = 0.f;
|
||||
ssize_t m_nHistoryPos;
|
||||
ssize_t m_nSuggestPos;
|
||||
int m_nScrollBack;
|
||||
int m_nSelectBack;
|
||||
float m_flScrollX;
|
||||
float m_flScrollY;
|
||||
float m_flFadeAlpha;
|
||||
|
||||
bool m_bInitialized = false;
|
||||
bool m_bReclaimFocus = false;
|
||||
bool m_bCopyToClipBoard = false;
|
||||
bool m_bModifyInput = false;
|
||||
bool m_bInitialized;
|
||||
bool m_bReclaimFocus;
|
||||
bool m_bCopyToClipBoard;
|
||||
bool m_bModifyInput;
|
||||
|
||||
bool m_bCanAutoComplete;
|
||||
bool m_bSuggestActive;
|
||||
bool m_bSuggestMoved;
|
||||
bool m_bSuggestUpdate;
|
||||
|
||||
bool m_bCanAutoComplete = false;
|
||||
bool m_bSuggestActive = false;
|
||||
bool m_bSuggestMoved = false;
|
||||
bool m_bSuggestUpdate = false;
|
||||
ssize_t m_nSuggestPos = -1;
|
||||
vector<CSuggest> m_vSuggest;
|
||||
vector<MODULERESOURCE> m_vFlagIcons;
|
||||
vector<string> m_vHistory;
|
||||
|
||||
ImGuiStyle_t m_Style = ImGuiStyle_t::NONE;
|
||||
ImGuiStyle_t m_Style;
|
||||
ImVec2 m_ivSuggestWindowPos;
|
||||
ImVec2 m_ivSuggestWindowSize;
|
||||
CTextLogger m_Logger;
|
||||
mutable std::mutex m_Mutex;
|
||||
|
||||
ImGuiInputTextFlags m_nInputFlags =
|
||||
ImGuiInputTextFlags_AutoCaretEnd |
|
||||
ImGuiInputTextFlags_CallbackCompletion |
|
||||
ImGuiInputTextFlags_CallbackHistory |
|
||||
ImGuiInputTextFlags_CallbackAlways |
|
||||
ImGuiInputTextFlags_CallbackEdit |
|
||||
ImGuiInputTextFlags_EnterReturnsTrue;
|
||||
ImGuiInputTextFlags m_nInputFlags;
|
||||
ImGuiWindowFlags m_nSuggestFlags;
|
||||
ImGuiWindowFlags m_nLoggingFlags;
|
||||
|
||||
ImGuiWindowFlags m_nSuggestFlags =
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoSavedSettings |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar;
|
||||
|
||||
ImGuiWindowFlags m_nLoggingFlags =
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_HorizontalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar;
|
||||
public:
|
||||
bool m_bActivate = false;
|
||||
vector<CSuggest> m_vsvCommandBases;
|
||||
|
@ -17,8 +17,8 @@ public:
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
extern CInputSystem* g_pInputSystem
|
||||
;
|
||||
extern CInputSystem* g_pInputSystem;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class VInputSystem : public IDetour
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "engine/server/sv_main.h"
|
||||
#include "server/vengineserver_impl.h"
|
||||
#include "client/cdll_engine_int.h"
|
||||
#include "engine/enginetrace.h"
|
||||
#ifndef DEDICATED
|
||||
#include "gameui/IConsole.h"
|
||||
#endif // !DEDICATED
|
||||
@ -75,6 +76,7 @@ bool CModAppSystemGroup::Create(CModAppSystemGroup* pModAppSystemGroup)
|
||||
|
||||
#ifndef DEDICATED
|
||||
g_pClientEntityList = g_pFactory->GetFactoryPtr("VClientEntityList003", false).RCast<IClientEntityList*>();
|
||||
g_pEngineTrace = g_pFactory->GetFactoryPtr("EngineTraceClient004", false).RCast<CEngineTrace*>();
|
||||
|
||||
for (auto& map : g_pCVar->DumpToMap())
|
||||
{
|
||||
|
@ -1,26 +1,37 @@
|
||||
#pragma once
|
||||
#ifndef DEDICATED
|
||||
#include "materialsystem/cshaderglue.h"
|
||||
#include "public/imaterialinternal.h"
|
||||
#include "public/materialsystem/shader_vcs_version.h"
|
||||
#include "public/rendersystem/schema/texture.g.h"
|
||||
|
||||
struct CMaterialGlue_Unknown
|
||||
{
|
||||
__m128i unk1;
|
||||
__m128i unk2;
|
||||
__m128i unk3;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1) // Without this MSVC might get the idea to align our members to completely fuck the offsets up.
|
||||
// [ PIXIE ]: The texture GUID's aren't in a specific order, gonna leave them as ptr's so an individual can check them in any memory searcher.
|
||||
// [ PIXIE ]: Verification needed for earlier seasons, if the struct is the same.
|
||||
class CMaterialGlue // [ PIXIE ]: Class seems mostly right, a few members are still missing though.
|
||||
// [ PIXIE ]: Class seems mostly right, a few members are still missing though.
|
||||
class CMaterialGlue : public IMaterialInternal
|
||||
{
|
||||
public:
|
||||
void* m_pVTable; //0x0000
|
||||
uint8_t pad_0008[8]; //0x0008
|
||||
uint64_t m_GUID; //0x0010
|
||||
const char* m_pszName; //0x0018
|
||||
const char* m_pszSurfaceName1; //0x0020
|
||||
const char* m_pszSurfaceName2; //0x0028
|
||||
const char* m_pszSurfaceProp; //0x0020
|
||||
const char* m_pszSurfaceProp2; //0x0028
|
||||
CMaterialGlue* m_pDepthShadow; //0x0030
|
||||
CMaterialGlue* m_pDepthPrepass; //0x0038
|
||||
CMaterialGlue* m_pDepthVSM; //0x0040
|
||||
CMaterialGlue* m_pDepthShadowTight; //0x0048
|
||||
CMaterialGlue* m_pColPass; //0x0050
|
||||
CShaderGlue* m_pShaderGlue; //0x0058
|
||||
void* m_pTextureGUID; //0x0060
|
||||
void* m_pStreamableTextures; //0x0068
|
||||
TextureHeader_t** m_pTextureHandles; //0x0060
|
||||
TextureHeader_t** m_pStreamableTextureHandles; //0x0068
|
||||
int16_t m_nStreamableTextureCount; //0x0070
|
||||
int16_t m_iWidth; //0x0072
|
||||
int16_t m_iHeight; //0x0074
|
||||
@ -29,12 +40,17 @@ public:
|
||||
int32_t m_unused2; //0x007C
|
||||
uint8_t pad_0080[8]; //0x0080
|
||||
uint32_t m_iUnknownFlags1; //0x0088
|
||||
char pad_008C[103]; //0x008C
|
||||
uint8_t m_iUnknown1; //0x00F3
|
||||
char pad_00F4[12]; //0x00F4
|
||||
void* m_pDXBuffer; //0x0100 [ PIXIE ]: ID3D11Buffer*, might need to include dx here.
|
||||
void* m_pDXBufferVTable; //0x0108 [ PIXIE ]: ID3D11BufferVtbl, probably just leave it as a void*
|
||||
void* m_pUnknown2; //0x0110
|
||||
char pad_008C[4]; //0x008C
|
||||
CMaterialGlue_Unknown unk_sections[2];
|
||||
_BYTE bytef0;
|
||||
_BYTE bytef1;
|
||||
_BYTE materialType;
|
||||
_BYTE bytef3;
|
||||
int dwordf4;
|
||||
void* textureAnim;
|
||||
void** m_pDXBuffer;
|
||||
void** m_pID3D11BufferVTable;
|
||||
void* m_pViewsBuffer;
|
||||
uint32_t m_iUnknown3; //0x0118
|
||||
uint16_t m_iUnknown4; //0x011C
|
||||
uint16_t m_iUnknown5; //0x011E
|
||||
@ -45,12 +61,16 @@ public:
|
||||
}; //Size: 0x0130 confirmed end size.
|
||||
static_assert(sizeof(CMaterialGlue) == 0x130);
|
||||
#pragma pack(pop)
|
||||
#endif // !DEDICATED
|
||||
|
||||
inline void* g_pMaterialGlueVFTable = nullptr;
|
||||
|
||||
|
||||
/* ==== CMATERIALGLUE ================================================================================================================================================== */
|
||||
#ifndef DEDICATED
|
||||
inline CMemory p_GetMaterialAtCrossHair;
|
||||
inline auto GetMaterialAtCrossHair = p_GetMaterialAtCrossHair.RCast<CMaterialGlue* (*)(void)>();
|
||||
#endif // !DEDICATED
|
||||
|
||||
void CMaterialGlue_Attach();
|
||||
void CMaterialGlue_Detach();
|
||||
@ -59,14 +79,18 @@ class VMaterialGlue : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
spdlog::debug("| FUN: CMaterialGlue::GetMaterialAtCrossHair: {:#18x} |\n", p_GetMaterialAtCrossHair.GetPtr());
|
||||
#endif // !DEDICATED
|
||||
spdlog::debug("| CON: g_pMaterialGlueVFTable : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pMaterialGlueVFTable));
|
||||
spdlog::debug("+----------------------------------------------------------------+\n");
|
||||
}
|
||||
virtual void GetFun(void) const
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
p_GetMaterialAtCrossHair = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\xC4\x48\x83\xEC\x58\x48\x83\x3D\x00\x00\x00\x00\x00"), "xxxxxxxxxx?????");
|
||||
GetMaterialAtCrossHair = p_GetMaterialAtCrossHair.RCast<CMaterialGlue* (*)(void)>(); /*48 8B C4 48 83 EC 58 48 83 3D ? ? ? ? ?*/
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const
|
||||
|
@ -141,6 +141,7 @@ void CMaterialSystem_Attach()
|
||||
#ifndef DEDICATED
|
||||
DetourAttach((LPVOID*)&v_StreamDB_Init, &StreamDB_Init);
|
||||
DetourAttach((LPVOID*)&v_DispatchDrawCall, &DispatchDrawCall);
|
||||
DetourAttach((LPVOID*)&CMaterialSystem__FindMaterialEx, &CMaterialSystem::FindMaterialEx);
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
|
||||
@ -149,5 +150,6 @@ void CMaterialSystem_Detach()
|
||||
#ifndef DEDICATED
|
||||
DetourDetach((LPVOID*)&v_StreamDB_Init, &StreamDB_Init);
|
||||
DetourDetach((LPVOID*)&v_DispatchDrawCall, &DispatchDrawCall);
|
||||
DetourDetach((LPVOID*)&CMaterialSystem__FindMaterialEx, &CMaterialSystem::FindMaterialEx);
|
||||
#endif // !DEDICATED
|
||||
}
|
@ -1,14 +1,27 @@
|
||||
#pragma once
|
||||
#ifndef MATERIALSYSTEM_H
|
||||
#define MATERIALSYSTEM_H
|
||||
#include "cmaterialglue.h"
|
||||
|
||||
#define STREAM_DB_EXT "stbsp"
|
||||
|
||||
class CMaterialSystem
|
||||
{
|
||||
public:
|
||||
#ifndef DEDICATED
|
||||
static CMaterialGlue* FindMaterialEx(CMaterialSystem* pMatSys, const char* pMaterialName, uint8_t nMaterialType, int nUnk, bool bComplain);
|
||||
#endif // !DEDICATED
|
||||
};
|
||||
|
||||
/* ==== MATERIALSYSTEM ================================================================================================================================================== */
|
||||
inline CMemory p_CMaterialSystem__Init;
|
||||
inline auto CMaterialSystem__Init = p_CMaterialSystem__Init.RCast<void* (*)(void* thisptr)>();
|
||||
inline auto CMaterialSystem__Init = p_CMaterialSystem__Init.RCast<void* (*)(CMaterialSystem* thisptr)>();
|
||||
|
||||
inline void* g_pMaterialSystem = nullptr;
|
||||
inline void* g_pMaterialVFTable = nullptr;
|
||||
#ifndef DEDICATED
|
||||
inline CMemory p_CMaterialSystem__FindMaterialEx;
|
||||
inline auto CMaterialSystem__FindMaterialEx = p_CMaterialSystem__FindMaterialEx.RCast<CMaterialGlue* (*)(CMaterialSystem* pMatSys, const char* pMaterialName, uint8_t nMaterialType, int nUnk, bool bComplain)>();
|
||||
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
inline CMemory p_DispatchDrawCall;
|
||||
inline auto v_DispatchDrawCall = p_DispatchDrawCall.RCast<void* (*)(int64_t a1, uint64_t a2, int a3, int a4, char a5, int a6, uint8_t a7, int64_t a8, uint32_t a9, uint32_t a10, __m128* a11, int a12)>();
|
||||
@ -50,8 +63,10 @@ class VMaterialSystem : public IDetour
|
||||
virtual void GetFun(void) const
|
||||
{
|
||||
p_CMaterialSystem__Init = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x70\x48\x83\x3D\x00\x00\x00\x00\x00"), "xxxx?xxxxxxxxxxxxxxxxxx?????");
|
||||
CMaterialSystem__Init = p_CMaterialSystem__Init.RCast<void* (*)(void*)>(); /*48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??*/
|
||||
CMaterialSystem__Init = p_CMaterialSystem__Init.RCast<void* (*)(CMaterialSystem*)>(); /*48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??*/
|
||||
#ifndef DEDICATED
|
||||
p_CMaterialSystem__FindMaterialEx = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x44\x89\x4C\x24\x00\x44\x88\x44\x24\x00\x48\x89\x4C\x24\x00"), "xxxx?xxxx?xxxx?");
|
||||
CMaterialSystem__FindMaterialEx = p_CMaterialSystem__FindMaterialEx.RCast<CMaterialGlue* (*)(CMaterialSystem*, const char*, uint8_t, int, bool)>(); /*44 89 4C 24 ?? 44 88 44 24 ?? 48 89 4C 24 ??*/
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
p_DispatchDrawCall = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x44\x89\x4C\x24\x00\x44\x89\x44\x24\x00\x48\x89\x4C\x24\x00\x55\x53"), "xxxx?xxxx?xxxx?xx");
|
||||
v_DispatchDrawCall = p_DispatchDrawCall.RCast<void* (*)(int64_t, uint64_t, int, int, char, int, uint8_t, int64_t, uint32_t, uint32_t, __m128*, int)>();
|
||||
@ -85,3 +100,5 @@ class VMaterialSystem : public IDetour
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
REGISTER(VMaterialSystem);
|
||||
|
||||
#endif // MATERIALSYSTEM_H
|
102
r5dev/public/imaterial.h
Normal file
102
r5dev/public/imaterial.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef IMATERIAL_H
|
||||
#define IMATERIAL_H
|
||||
|
||||
abstract_class IMaterial
|
||||
{
|
||||
public:
|
||||
virtual const char* GetName() const = 0;
|
||||
virtual uint8_t GetMaterialType() const = 0;
|
||||
|
||||
virtual const char* GetNullString() const = 0;
|
||||
virtual int64_t ReturnZero() const = 0;
|
||||
|
||||
virtual void* sub_1403B41A0(void* unk) = 0; // IDK
|
||||
|
||||
virtual int GetMappingWidth() const = 0;
|
||||
virtual int GetMappingHeight() const = 0;
|
||||
|
||||
private:
|
||||
//TODO! <-- most of these are bitwise and operators testing flags of the member CMaterialGlue::unkFlags.
|
||||
// Don't call these without reversing/renaming first, as the const qualifier might have to be removed.
|
||||
virtual void stub_0() const = 0;
|
||||
virtual void stub_1() const = 0;
|
||||
virtual void stub_2() const = 0;
|
||||
virtual void stub_3() const = 0;
|
||||
virtual void stub_4() const = 0;
|
||||
virtual void stub_5() const = 0;
|
||||
virtual void stub_6() const = 0;
|
||||
virtual void stub_7() const = 0;
|
||||
virtual void stub_8() const = 0;
|
||||
virtual void stub_9() const = 0;
|
||||
virtual void stub_10() const = 0;
|
||||
virtual void stub_11() const = 0;
|
||||
virtual void stub_12() const = 0;
|
||||
virtual void stub_13() const = 0;
|
||||
virtual void stub_14() const = 0;
|
||||
virtual void stub_15() const = 0;
|
||||
virtual void stub_16() const = 0;
|
||||
virtual void stub_17() const = 0;
|
||||
virtual void stub_18() const = 0;
|
||||
virtual void stub_19() const = 0;
|
||||
virtual void stub_20() const = 0;
|
||||
virtual void stub_21() const = 0;
|
||||
virtual void stub_22() const = 0;
|
||||
virtual void stub_23() const = 0;
|
||||
virtual void stub_24() const = 0;
|
||||
virtual void stub_25() const = 0;
|
||||
virtual void stub_26() const = 0;
|
||||
virtual void stub_27() const = 0;
|
||||
virtual void stub_28() const = 0;
|
||||
virtual void stub_29() const = 0;
|
||||
virtual void stub_30() const = 0;
|
||||
virtual void stub_31() const = 0;
|
||||
virtual void stub_32() const = 0;
|
||||
virtual void stub_33() const = 0;
|
||||
virtual void stub_34() const = 0;
|
||||
virtual void stub_35() const = 0;
|
||||
virtual void stub_36() const = 0;
|
||||
virtual void stub_37() const = 0;
|
||||
virtual void stub_38() const = 0;
|
||||
virtual void stub_39() const = 0;
|
||||
virtual void stub_40() const = 0;
|
||||
virtual void stub_41() const = 0;
|
||||
virtual void stub_42() const = 0;
|
||||
virtual void stub_43() const = 0;
|
||||
virtual void stub_44() const = 0;
|
||||
virtual void stub_45() const = 0;
|
||||
virtual void stub_46() const = 0;
|
||||
virtual void stub_47() const = 0;
|
||||
virtual void stub_48() const = 0;
|
||||
virtual void stub_49() const = 0;
|
||||
virtual void stub_50() const = 0;
|
||||
virtual void stub_51() const = 0;
|
||||
virtual void stub_52() const = 0;
|
||||
virtual void stub_53() const = 0;
|
||||
virtual void stub_54() const = 0;
|
||||
virtual void stub_55() const = 0;
|
||||
virtual void stub_56() const = 0;
|
||||
virtual void stub_57() const = 0;
|
||||
virtual void stub_58() const = 0;
|
||||
virtual void stub_59() const = 0;
|
||||
virtual void stub_60() const = 0;
|
||||
virtual void stub_61() const = 0;
|
||||
virtual void stub_62() const = 0;
|
||||
virtual void stub_63() const = 0;
|
||||
virtual void stub_64() const = 0;
|
||||
virtual void stub_65() const = 0;
|
||||
virtual void stub_66() const = 0;
|
||||
virtual void stub_67() const = 0;
|
||||
virtual void stub_68() const = 0;
|
||||
virtual void stub_69() const = 0;
|
||||
virtual void stub_70() const = 0;
|
||||
virtual void stub_71() const = 0;
|
||||
virtual void stub_72() const = 0;
|
||||
virtual void stub_73() const = 0;
|
||||
virtual void stub_74() const = 0;
|
||||
virtual void stub_75() const = 0;
|
||||
virtual void stub_76() const = 0;
|
||||
virtual void stub_77() const = 0;
|
||||
virtual void stub_78() const = 0;
|
||||
};
|
||||
|
||||
#endif // IMATERIAL_H
|
11
r5dev/public/imaterialinternal.h
Normal file
11
r5dev/public/imaterialinternal.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef IMATERIALINTERNAL_H
|
||||
#define IMATERIALINTERNAL_H
|
||||
#include "imaterial.h"
|
||||
|
||||
abstract_class IMaterialInternal : public IMaterial
|
||||
{
|
||||
public:
|
||||
virtual bool IsErrorMaterial() const = 0;
|
||||
};
|
||||
|
||||
#endif // IMATERIALINTERNAL_H
|
19
r5dev/public/materialsystem/shader_vcs_version.h
Normal file
19
r5dev/public/materialsystem/shader_vcs_version.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef SHADER_VCS_VERSION_H
|
||||
#define SHADER_VCS_VERSION_H
|
||||
|
||||
struct ShaderHeader_t
|
||||
{
|
||||
char* m_pszDebugName;
|
||||
uint8_t m_byte1;
|
||||
uint8_t m_byte2;
|
||||
uint8_t m_byte3;
|
||||
uint8_t m_byte4;
|
||||
uint8_t m_byte5;
|
||||
uint8_t m_byte6;
|
||||
uint8_t m_byte7;
|
||||
uint8_t m_byte8;
|
||||
ID3D11DeviceChild** m_ppShader;
|
||||
__int64* m_pUnk2;
|
||||
};
|
||||
|
||||
#endif // SHADER_VCS_VERSION_H
|
256
r5dev/public/rendersystem/schema/texture.g.h
Normal file
256
r5dev/public/rendersystem/schema/texture.g.h
Normal file
@ -0,0 +1,256 @@
|
||||
#ifndef TEXTURE_G_H
|
||||
#define TEXTURE_G_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structure definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
/*schema*/ struct TextureDesc_t
|
||||
{
|
||||
uint64_t m_AssetGuid;
|
||||
const char* m_pDebugName;
|
||||
uint16 m_nWidth;
|
||||
uint16 m_nHeight;
|
||||
uint16 m_nDepth;
|
||||
uint16_t m_nImageFormat;
|
||||
};
|
||||
|
||||
/*schema*/ struct TextureHeader_t : public TextureDesc_t
|
||||
{
|
||||
uint32_t m_nDataLength;
|
||||
uint8_t unknown_2;
|
||||
uint8_t m_nOptStreamedMipCount;
|
||||
uint8_t m_nArraySize;
|
||||
uint8_t m_nLayerCount;
|
||||
uint8_t m_nCPUAccessFlag; // [ PIXIE ]: In RTech::CreateDXBuffer textureDescription Usage is determined by the CPU Access Flag so I assume it's the same case here.
|
||||
uint8_t m_nPermanentMipCount;
|
||||
uint8_t m_nStreamedMipCount;
|
||||
uint8_t unknown_4[13];
|
||||
__int64 m_nPixelCount;
|
||||
uint8_t unknown_5[3];
|
||||
uint8_t m_nTotalStreamedMipCount; // Does not get set until after RTech::CreateDXTexture.
|
||||
uint8_t unk4[228];
|
||||
#ifdef GAMEDLL_S3
|
||||
uint8_t unk5[57];
|
||||
#endif // GAMEDLL_S3
|
||||
ID3D11Texture2D* m_ppTexture;
|
||||
ID3D11ShaderResourceView* m_ppShaderResourceView;
|
||||
uint8_t m_nTextureMipLevels;
|
||||
uint8_t m_nTextureMipLevelsStreamedOpt;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Table definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
static const pair<uint8_t, uint8_t> s_pBytesPerPixel[] =
|
||||
{
|
||||
{ 8u, 4u },
|
||||
{ 8u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 8u, 4u },
|
||||
{ 8u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 1u },
|
||||
{ 16u, 1u },
|
||||
{ 16u, 1u },
|
||||
{ 12u, 1u },
|
||||
{ 12u, 1u },
|
||||
{ 12u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 0u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 5u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 5u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 1u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 2u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 1u, 0u },
|
||||
{ 0u, 0u }
|
||||
};
|
||||
|
||||
// Map of dxgi format to txtr asset format
|
||||
static const std::map<DXGI_FORMAT, uint16_t> s_DxgiToTxtrTable{
|
||||
{ DXGI_FORMAT_BC1_UNORM, 0 },
|
||||
{ DXGI_FORMAT_BC1_UNORM_SRGB, 1 },
|
||||
{ DXGI_FORMAT_BC2_UNORM, 2 },
|
||||
{ DXGI_FORMAT_BC2_UNORM_SRGB, 3 },
|
||||
{ DXGI_FORMAT_BC3_UNORM, 4 },
|
||||
{ DXGI_FORMAT_BC3_UNORM_SRGB, 5 },
|
||||
{ DXGI_FORMAT_BC4_UNORM, 6 },
|
||||
{ DXGI_FORMAT_BC4_SNORM, 7 },
|
||||
{ DXGI_FORMAT_BC5_UNORM, 8 },
|
||||
{ DXGI_FORMAT_BC5_SNORM, 9 },
|
||||
{ DXGI_FORMAT_BC6H_UF16, 10 },
|
||||
{ DXGI_FORMAT_BC6H_SF16, 11 },
|
||||
{ DXGI_FORMAT_BC7_UNORM, 12 },
|
||||
{ DXGI_FORMAT_BC7_UNORM_SRGB, 13 },
|
||||
{ DXGI_FORMAT_R32G32B32A32_FLOAT, 14 },
|
||||
{ DXGI_FORMAT_R32G32B32A32_UINT, 15 },
|
||||
{ DXGI_FORMAT_R32G32B32A32_SINT, 16 },
|
||||
{ DXGI_FORMAT_R32G32B32_FLOAT, 17 },
|
||||
{ DXGI_FORMAT_R32G32B32_UINT, 18 },
|
||||
{ DXGI_FORMAT_R32G32B32_SINT, 19 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_FLOAT, 20 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_UNORM, 21 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_UINT, 22 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_SNORM, 23 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_SINT, 24 },
|
||||
{ DXGI_FORMAT_R32G32_FLOAT, 25 },
|
||||
{ DXGI_FORMAT_R32G32_UINT, 26 },
|
||||
{ DXGI_FORMAT_R32G32_SINT, 27 },
|
||||
{ DXGI_FORMAT_R10G10B10A2_UNORM, 28 },
|
||||
{ DXGI_FORMAT_R10G10B10A2_UINT, 29 },
|
||||
{ DXGI_FORMAT_R11G11B10_FLOAT, 30 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM, 31 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 32 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UINT, 33 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_SNORM, 34 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_SINT, 35 },
|
||||
{ DXGI_FORMAT_R16G16_FLOAT, 36 },
|
||||
{ DXGI_FORMAT_R16G16_UNORM, 37 },
|
||||
{ DXGI_FORMAT_R16G16_UINT, 38 },
|
||||
{ DXGI_FORMAT_R16G16_SNORM, 39 },
|
||||
{ DXGI_FORMAT_R16G16_SINT, 40 },
|
||||
{ DXGI_FORMAT_R32_FLOAT, 41 },
|
||||
{ DXGI_FORMAT_R32_UINT, 42 },
|
||||
{ DXGI_FORMAT_R32_SINT, 43 },
|
||||
{ DXGI_FORMAT_R8G8_UNORM, 44 },
|
||||
{ DXGI_FORMAT_R8G8_UINT, 45 },
|
||||
{ DXGI_FORMAT_R8G8_SNORM, 46 },
|
||||
{ DXGI_FORMAT_R8G8_SINT, 47 },
|
||||
{ DXGI_FORMAT_R16_FLOAT, 48 },
|
||||
{ DXGI_FORMAT_R16_UNORM, 49 },
|
||||
{ DXGI_FORMAT_R16_UINT, 50 },
|
||||
{ DXGI_FORMAT_R16_SNORM, 51 },
|
||||
{ DXGI_FORMAT_R16_SINT, 52 },
|
||||
{ DXGI_FORMAT_R8_UNORM, 53 },
|
||||
{ DXGI_FORMAT_R8_UINT, 54 },
|
||||
{ DXGI_FORMAT_R8_SNORM, 55 },
|
||||
{ DXGI_FORMAT_R8_SINT, 56 },
|
||||
{ DXGI_FORMAT_A8_UNORM, 57 },
|
||||
{ DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 58 },
|
||||
{ DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 59 },
|
||||
{ DXGI_FORMAT_D32_FLOAT, 60 },
|
||||
{ DXGI_FORMAT_D16_UNORM, 61 },
|
||||
};
|
||||
|
||||
// Map of txtr asset format to dxgi format
|
||||
static const std::map<uint16_t, DXGI_FORMAT> s_TxtrToDxgiTable{
|
||||
{ 0, DXGI_FORMAT_BC1_UNORM },
|
||||
{ 1, DXGI_FORMAT_BC1_UNORM_SRGB },
|
||||
{ 2, DXGI_FORMAT_BC2_UNORM },
|
||||
{ 3, DXGI_FORMAT_BC2_UNORM_SRGB },
|
||||
{ 4, DXGI_FORMAT_BC3_UNORM },
|
||||
{ 5, DXGI_FORMAT_BC3_UNORM_SRGB},
|
||||
{ 6, DXGI_FORMAT_BC4_UNORM },
|
||||
{ 7, DXGI_FORMAT_BC4_SNORM },
|
||||
{ 8, DXGI_FORMAT_BC5_UNORM },
|
||||
{ 9, DXGI_FORMAT_BC5_SNORM },
|
||||
{ 10, DXGI_FORMAT_BC6H_UF16 },
|
||||
{ 11, DXGI_FORMAT_BC6H_SF16 },
|
||||
{ 12, DXGI_FORMAT_BC7_UNORM },
|
||||
{ 13, DXGI_FORMAT_BC7_UNORM_SRGB },
|
||||
{ 14, DXGI_FORMAT_R32G32B32A32_FLOAT },
|
||||
{ 15, DXGI_FORMAT_R32G32B32A32_UINT },
|
||||
{ 16, DXGI_FORMAT_R32G32B32A32_SINT },
|
||||
{ 17, DXGI_FORMAT_R32G32B32_FLOAT },
|
||||
{ 18, DXGI_FORMAT_R32G32B32_UINT },
|
||||
{ 19, DXGI_FORMAT_R32G32B32_SINT },
|
||||
{ 20, DXGI_FORMAT_R16G16B16A16_FLOAT },
|
||||
{ 21, DXGI_FORMAT_R16G16B16A16_UNORM },
|
||||
{ 22, DXGI_FORMAT_R16G16B16A16_UINT },
|
||||
{ 23, DXGI_FORMAT_R16G16B16A16_SNORM },
|
||||
{ 24, DXGI_FORMAT_R16G16B16A16_SINT },
|
||||
{ 25, DXGI_FORMAT_R32G32_FLOAT },
|
||||
{ 26, DXGI_FORMAT_R32G32_UINT },
|
||||
{ 27, DXGI_FORMAT_R32G32_SINT },
|
||||
{ 28, DXGI_FORMAT_R10G10B10A2_UNORM },
|
||||
{ 29, DXGI_FORMAT_R10G10B10A2_UINT },
|
||||
{ 30, DXGI_FORMAT_R11G11B10_FLOAT },
|
||||
{ 31, DXGI_FORMAT_R8G8B8A8_UNORM },
|
||||
{ 32, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB },
|
||||
{ 33, DXGI_FORMAT_R8G8B8A8_UINT },
|
||||
{ 34, DXGI_FORMAT_R8G8B8A8_SNORM },
|
||||
{ 35, DXGI_FORMAT_R8G8B8A8_SINT },
|
||||
{ 36, DXGI_FORMAT_R16G16_FLOAT },
|
||||
{ 37, DXGI_FORMAT_R16G16_UNORM },
|
||||
{ 38, DXGI_FORMAT_R16G16_UINT },
|
||||
{ 39, DXGI_FORMAT_R16G16_SNORM },
|
||||
{ 40, DXGI_FORMAT_R16G16_SINT },
|
||||
{ 41, DXGI_FORMAT_R32_FLOAT },
|
||||
{ 42, DXGI_FORMAT_R32_UINT },
|
||||
{ 43, DXGI_FORMAT_R32_SINT },
|
||||
{ 44, DXGI_FORMAT_R8G8_UNORM },
|
||||
{ 45, DXGI_FORMAT_R8G8_UINT },
|
||||
{ 46, DXGI_FORMAT_R8G8_SNORM },
|
||||
{ 47, DXGI_FORMAT_R8G8_SINT },
|
||||
{ 48, DXGI_FORMAT_R16_FLOAT },
|
||||
{ 49, DXGI_FORMAT_R16_UNORM },
|
||||
{ 50, DXGI_FORMAT_R16_UINT },
|
||||
{ 51, DXGI_FORMAT_R16_SNORM },
|
||||
{ 52, DXGI_FORMAT_R16_SINT },
|
||||
{ 53, DXGI_FORMAT_R8_UNORM },
|
||||
{ 54, DXGI_FORMAT_R8_UINT },
|
||||
{ 55, DXGI_FORMAT_R8_SNORM },
|
||||
{ 56, DXGI_FORMAT_R8_SINT },
|
||||
{ 57, DXGI_FORMAT_A8_UNORM},
|
||||
{ 58, DXGI_FORMAT_R9G9B9E5_SHAREDEXP },
|
||||
{ 59, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM },
|
||||
{ 60, DXGI_FORMAT_D32_FLOAT },
|
||||
{ 61, DXGI_FORMAT_D16_UNORM },
|
||||
};
|
||||
|
||||
#endif // TEXTURE_G_H
|
@ -683,6 +683,29 @@ vector<string> StringSplit(string svInput, char cDelim, size_t nMax)
|
||||
return vSubStrings;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For trimming leading characters from input.
|
||||
string& StringLTrim(string& svInput, const char* pszToTrim)
|
||||
{
|
||||
svInput.erase(0, svInput.find_first_not_of(pszToTrim));
|
||||
return svInput;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For trimming trailing characters from input.
|
||||
string& StringRTrim(string& svInput, const char* pszToTrim)
|
||||
{
|
||||
svInput.erase(svInput.find_last_not_of(pszToTrim) + 1);
|
||||
return svInput;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For trimming leading and trailing characters from input.
|
||||
string& StringTrim(string& svInput, const char* pszToTrim)
|
||||
{
|
||||
return StringLTrim(StringRTrim(svInput, pszToTrim), pszToTrim);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For converting a string to an array of bytes.
|
||||
vector<int> StringToBytes(const string& svInput, bool bNullTerminator)
|
||||
|
@ -51,6 +51,10 @@ string StringUnescape(const string& svInput);
|
||||
size_t StringCount(const string& svInput, char cDelim);
|
||||
vector<string> StringSplit(string svInput, char cDelim, size_t nMax = SIZE_MAX);
|
||||
|
||||
string& StringLTrim(string& svInput, const char* pszToTrim);
|
||||
string& StringRTrim(string& svInput, const char* pszToTrim);
|
||||
string& StringTrim(string& svInput, const char* pszToTrim);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Bytes
|
||||
vector<int> StringToBytes(const string& svInput, bool bNullTerminator);
|
||||
|
@ -3,6 +3,7 @@ fs_vpk_build "english" "client" "mp_common" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_aqueduct" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_aqueduct_night" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_arena_composite" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_arena_skygarden" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_ashs_redemption" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_canyonlands_64k_x_64k" "1"
|
||||
fs_vpk_build "english" "client" "mp_rr_canyonlands_mu1" "1"
|
||||
|
@ -3,6 +3,7 @@ fs_vpk_unpack "vpk/englishclient_mp_common.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_aqueduct.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_aqueduct_night.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_arena_composite.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_arena_skygarden.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_ashs_redemption.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_canyonlands_64k_x_64k.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishclient_mp_rr_canyonlands_mu1.bsp.pak000_dir.vpk"
|
||||
|
@ -2,6 +2,7 @@ fs_vpk_build "english" "server" "mp_common" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_aqueduct" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_aqueduct_night" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_arena_composite" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_arena_skygarden" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_ashs_redemption" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_canyonlands_64k_x_64k" "1"
|
||||
fs_vpk_build "english" "server" "mp_rr_canyonlands_mu1" "1"
|
||||
|
@ -2,6 +2,7 @@ fs_vpk_unpack "vpk/englishserver_mp_common.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_aqueduct.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_aqueduct_night.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_arena_composite.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_arena_skygarden.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_ashs_redemption.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_canyonlands_64k_x_64k.bsp.pak000_dir.vpk"
|
||||
fs_vpk_unpack "vpk/englishserver_mp_rr_canyonlands_mu1.bsp.pak000_dir.vpk"
|
||||
|
10
r5dev/resource/cfg/startup_client_dev.cfg
Normal file
10
r5dev/resource/cfg/startup_client_dev.cfg
Normal file
@ -0,0 +1,10 @@
|
||||
-ansiclr
|
||||
-dev
|
||||
-devsdk
|
||||
-fnf
|
||||
-multiple
|
||||
-novid
|
||||
-showdevmenu
|
||||
-wconsole
|
||||
-windowed
|
||||
-playlistfile "playlists_r5_patch.txt"
|
8
r5dev/resource/cfg/startup_client_retail.cfg
Normal file
8
r5dev/resource/cfg/startup_client_retail.cfg
Normal file
@ -0,0 +1,8 @@
|
||||
-ansiclr
|
||||
-fnf
|
||||
-multiple
|
||||
-novid
|
||||
-showdevmenu
|
||||
-wconsole
|
||||
-windowed
|
||||
-playlistfile "playlists_r5_patch.txt"
|
@ -4,6 +4,7 @@
|
||||
#ifndef DEDICATED
|
||||
#include "windows/id3dx.h"
|
||||
#include "materialsystem/cshaderglue.h"
|
||||
#include "public/rendersystem/schema/texture.g.h"
|
||||
#endif // !DEDICATED
|
||||
|
||||
/******************************************************************************
|
||||
@ -510,16 +511,16 @@ uint8_t __fastcall RTech::DecompressPakFile(RPakDecompState_t* state, uint64_t i
|
||||
//----------------------------------------------------------------------------------
|
||||
// Purpose: creates 2D texture and shader resource from textureHeader and imageData.
|
||||
//----------------------------------------------------------------------------------
|
||||
void RTech::CreateDXTexture(RTechTextureInfo_t* textureHeader, int64_t imageData)
|
||||
void RTech::CreateDXTexture(TextureHeader_t* textureHeader, int64_t imageData)
|
||||
{
|
||||
if (textureHeader->unk0 && !textureHeader->m_nHeight) // Return never gets hit. Maybe its some debug check?
|
||||
if (textureHeader->m_nDepth && !textureHeader->m_nHeight) // Return never gets hit. Maybe its some debug check?
|
||||
return;
|
||||
|
||||
__int64 initialData[4096]{};
|
||||
textureHeader->m_nTextureMipLevels = textureHeader->m_nMipLevels;
|
||||
textureHeader->m_nTextureMipLevels = textureHeader->m_nPermanentMipCount;
|
||||
|
||||
const int totalStreamedMips = textureHeader->m_nMipLevelsStreamedOpt + textureHeader->m_nMipLevelsStreamed;
|
||||
uint32_t mipLevel = textureHeader->m_nMipLevels + totalStreamedMips;
|
||||
const int totalStreamedMips = textureHeader->m_nOptStreamedMipCount + textureHeader->m_nStreamedMipCount;
|
||||
uint32_t mipLevel = textureHeader->m_nPermanentMipCount + totalStreamedMips;
|
||||
if (mipLevel != totalStreamedMips)
|
||||
{
|
||||
do
|
||||
@ -535,8 +536,8 @@ void RTech::CreateDXTexture(RTechTextureInfo_t* textureHeader, int64_t imageData
|
||||
if (textureHeader->m_nHeight >> mipLevel > 1)
|
||||
mipHeight = (textureHeader->m_nHeight >> mipLevel) - 1;
|
||||
|
||||
uint8_t x = s_pRTechBytesPerPixel[textureHeader->m_nFormat].first;
|
||||
uint8_t y = s_pRTechBytesPerPixel[textureHeader->m_nFormat].second;
|
||||
uint8_t x = s_pBytesPerPixel[textureHeader->m_nImageFormat].first;
|
||||
uint8_t y = s_pBytesPerPixel[textureHeader->m_nImageFormat].second;
|
||||
|
||||
uint32_t bytesPerPixelWidth = (y + mipWidth) >> (y >> 1);
|
||||
uint32_t bytesPerPixelHeight = (y + mipHeight) >> (y >> 1);
|
||||
@ -555,18 +556,18 @@ void RTech::CreateDXTexture(RTechTextureInfo_t* textureHeader, int64_t imageData
|
||||
*(uint32_t*)((uint8_t*)&initialData[1] + offsetCurrentResourceData + 4) = slicePitch;
|
||||
|
||||
imageData += (slicePitch + 15) & 0xFFFFFFF0;
|
||||
subResourceEntry += textureHeader->m_nMipLevels;
|
||||
subResourceEntry += textureHeader->m_nPermanentMipCount;
|
||||
}
|
||||
}
|
||||
} while (mipLevel != totalStreamedMips);
|
||||
}
|
||||
|
||||
const DXGI_FORMAT dxgiFormat = rpakToDxgiFormat[textureHeader->m_nFormat]; // Get dxgi format
|
||||
const DXGI_FORMAT dxgiFormat = s_TxtrToDxgiTable.at(textureHeader->m_nImageFormat); // Get dxgi format
|
||||
|
||||
D3D11_TEXTURE2D_DESC textureDesc{};
|
||||
textureDesc.Width = textureHeader->m_nWidth >> mipLevel;
|
||||
textureDesc.Height = textureHeader->m_nHeight >> mipLevel;
|
||||
textureDesc.MipLevels = textureHeader->m_nMipLevels;
|
||||
textureDesc.MipLevels = textureHeader->m_nPermanentMipCount;
|
||||
textureDesc.ArraySize = textureHeader->m_nArraySize;
|
||||
textureDesc.Format = dxgiFormat;
|
||||
textureDesc.SampleDesc.Count = 1;
|
||||
@ -579,7 +580,7 @@ void RTech::CreateDXTexture(RTechTextureInfo_t* textureHeader, int64_t imageData
|
||||
const D3D11_SUBRESOURCE_DATA* subResData = (D3D11_SUBRESOURCE_DATA*)((uint8_t*)initialData + offsetStartResourceData);
|
||||
const HRESULT createTextureRes = (*g_ppGameDevice)->CreateTexture2D(&textureDesc, subResData, &textureHeader->m_ppTexture);
|
||||
if (createTextureRes < S_OK)
|
||||
Error(eDLL_T::RTECH, EXIT_FAILURE, "Couldn't create texture \"%s\": error code %08x\n", textureHeader->m_nDebugName, createTextureRes);
|
||||
Error(eDLL_T::RTECH, EXIT_FAILURE, "Couldn't create texture \"%s\": error code %08x\n", textureHeader->m_pDebugName, createTextureRes);
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC shaderResource{};
|
||||
shaderResource.Format = dxgiFormat;
|
||||
@ -597,7 +598,7 @@ void RTech::CreateDXTexture(RTechTextureInfo_t* textureHeader, int64_t imageData
|
||||
|
||||
const HRESULT createShaderResourceRes = (*g_ppGameDevice)->CreateShaderResourceView(textureHeader->m_ppTexture, &shaderResource, &textureHeader->m_ppShaderResourceView);
|
||||
if (createShaderResourceRes < S_OK)
|
||||
Error(eDLL_T::RTECH, EXIT_FAILURE, "Couldn't create shader resource view for texture \"%s\": error code %08x\n", textureHeader->m_nDebugName, createShaderResourceRes);
|
||||
Error(eDLL_T::RTECH, EXIT_FAILURE, "Couldn't create shader resource view for texture \"%s\": error code %08x\n", textureHeader->m_pDebugName, createShaderResourceRes);
|
||||
}
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include "tier0/jobthread.h"
|
||||
#include "vpklib/packedstore.h"
|
||||
#include "rtech/rtech_game.h"
|
||||
#ifndef DEDICATED
|
||||
#include "public/rendersystem/schema/texture.g.h"
|
||||
#endif // !DEDICATED
|
||||
|
||||
#define PAK_PARAM_SIZE 0xB0
|
||||
#define DCMP_BUF_SIZE 0x400000
|
||||
@ -71,7 +74,7 @@ enum class RPakStatus_t : int32_t
|
||||
PAK_STATUS_BUSY = 15
|
||||
};
|
||||
|
||||
const std::map<RPakStatus_t, string> RPakStatusToString {
|
||||
const static std::map<RPakStatus_t, string> g_PakStatusToString {
|
||||
{ RPakStatus_t::PAK_STATUS_FREED, "PAK_STATUS_FREED" },
|
||||
{ RPakStatus_t::PAK_STATUS_LOAD_PENDING, "PAK_STATUS_LOAD_PENDING" },
|
||||
{ RPakStatus_t::PAK_STATUS_REPAK_RUNNING, "PAK_STATUS_REPAK_RUNNING" },
|
||||
@ -172,249 +175,6 @@ struct __declspec(align(8)) RPakDecompState_t
|
||||
uint64_t m_nDecompStreamSize;
|
||||
};
|
||||
|
||||
#if not defined DEDICATED
|
||||
struct RTechTextureInfo_t
|
||||
{
|
||||
uint64_t m_nGUID;
|
||||
const char* m_nDebugName;
|
||||
uint16_t m_nWidth;
|
||||
uint16_t m_nHeight;
|
||||
uint16_t unk0;
|
||||
uint16_t m_nFormat;
|
||||
uint32_t m_nDataSize;
|
||||
uint8_t unk1;
|
||||
uint8_t m_nMipLevelsStreamedOpt;
|
||||
uint8_t m_nArraySize;
|
||||
uint8_t m_nLayerCount;
|
||||
uint8_t m_nCPUAccessFlag; // [ PIXIE ]: In RTech::CreateDXBuffer textureDescription Usage is determined by the CPU Access Flag so I assume it's the same case here.
|
||||
uint8_t m_nMipLevels;
|
||||
uint8_t m_nMipLevelsStreamed;
|
||||
uint8_t unk3[24];
|
||||
uint8_t m_nTotalStreamedMips; // Does not get set until after RTech::CreateDXTexture.
|
||||
uint8_t unk4[228];
|
||||
#ifdef GAMEDLL_S3
|
||||
uint8_t unk5[57];
|
||||
#endif // GAMEDLL_S3
|
||||
ID3D11Texture2D* m_ppTexture;
|
||||
ID3D11ShaderResourceView* m_ppShaderResourceView;
|
||||
uint8_t m_nTextureMipLevels;
|
||||
uint8_t m_nTextureMipLevelsStreamedOpt;
|
||||
};
|
||||
|
||||
static pair<uint8_t, uint8_t> s_pRTechBytesPerPixel[] =
|
||||
{
|
||||
{ 8u, 4u },
|
||||
{ 8u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 8u, 4u },
|
||||
{ 8u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 4u },
|
||||
{ 16u, 1u },
|
||||
{ 16u, 1u },
|
||||
{ 16u, 1u },
|
||||
{ 12u, 1u },
|
||||
{ 12u, 1u },
|
||||
{ 12u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 8u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 1u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 4u, 1u },
|
||||
{ 2u, 1u },
|
||||
{ 0u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 5u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 5u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 1u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 2u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 0u, 0u },
|
||||
{ 1u, 0u },
|
||||
{ 0u, 0u }
|
||||
};
|
||||
|
||||
// Map of dxgi format to txtr asset format
|
||||
static std::map<DXGI_FORMAT, uint16_t> dxgiToRPakFormat {
|
||||
{ DXGI_FORMAT_BC1_UNORM, 0 },
|
||||
{ DXGI_FORMAT_BC1_UNORM_SRGB, 1 },
|
||||
{ DXGI_FORMAT_BC2_UNORM, 2 },
|
||||
{ DXGI_FORMAT_BC2_UNORM_SRGB, 3 },
|
||||
{ DXGI_FORMAT_BC3_UNORM, 4 },
|
||||
{ DXGI_FORMAT_BC3_UNORM_SRGB, 5 },
|
||||
{ DXGI_FORMAT_BC4_UNORM, 6 },
|
||||
{ DXGI_FORMAT_BC4_SNORM, 7 },
|
||||
{ DXGI_FORMAT_BC5_UNORM, 8 },
|
||||
{ DXGI_FORMAT_BC5_SNORM, 9 },
|
||||
{ DXGI_FORMAT_BC6H_UF16, 10 },
|
||||
{ DXGI_FORMAT_BC6H_SF16, 11 },
|
||||
{ DXGI_FORMAT_BC7_UNORM, 12 },
|
||||
{ DXGI_FORMAT_BC7_UNORM_SRGB, 13 },
|
||||
{ DXGI_FORMAT_R32G32B32A32_FLOAT, 14 },
|
||||
{ DXGI_FORMAT_R32G32B32A32_UINT, 15 },
|
||||
{ DXGI_FORMAT_R32G32B32A32_SINT, 16 },
|
||||
{ DXGI_FORMAT_R32G32B32_FLOAT, 17 },
|
||||
{ DXGI_FORMAT_R32G32B32_UINT, 18 },
|
||||
{ DXGI_FORMAT_R32G32B32_SINT, 19 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_FLOAT, 20 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_UNORM, 21 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_UINT, 22 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_SNORM, 23 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_SINT, 24 },
|
||||
{ DXGI_FORMAT_R32G32_FLOAT, 25 },
|
||||
{ DXGI_FORMAT_R32G32_UINT, 26 },
|
||||
{ DXGI_FORMAT_R32G32_SINT, 27 },
|
||||
{ DXGI_FORMAT_R10G10B10A2_UNORM, 28 },
|
||||
{ DXGI_FORMAT_R10G10B10A2_UINT, 29 },
|
||||
{ DXGI_FORMAT_R11G11B10_FLOAT, 30 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM, 31 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 32 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UINT, 33 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_SNORM, 34 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_SINT, 35 },
|
||||
{ DXGI_FORMAT_R16G16_FLOAT, 36 },
|
||||
{ DXGI_FORMAT_R16G16_UNORM, 37 },
|
||||
{ DXGI_FORMAT_R16G16_UINT, 38 },
|
||||
{ DXGI_FORMAT_R16G16_SNORM, 39 },
|
||||
{ DXGI_FORMAT_R16G16_SINT, 40 },
|
||||
{ DXGI_FORMAT_R32_FLOAT, 41 },
|
||||
{ DXGI_FORMAT_R32_UINT, 42 },
|
||||
{ DXGI_FORMAT_R32_SINT, 43 },
|
||||
{ DXGI_FORMAT_R8G8_UNORM, 44 },
|
||||
{ DXGI_FORMAT_R8G8_UINT, 45 },
|
||||
{ DXGI_FORMAT_R8G8_SNORM, 46 },
|
||||
{ DXGI_FORMAT_R8G8_SINT, 47 },
|
||||
{ DXGI_FORMAT_R16_FLOAT, 48 },
|
||||
{ DXGI_FORMAT_R16_UNORM, 49 },
|
||||
{ DXGI_FORMAT_R16_UINT, 50 },
|
||||
{ DXGI_FORMAT_R16_SNORM, 51 },
|
||||
{ DXGI_FORMAT_R16_SINT, 52 },
|
||||
{ DXGI_FORMAT_R8_UNORM, 53 },
|
||||
{ DXGI_FORMAT_R8_UINT, 54 },
|
||||
{ DXGI_FORMAT_R8_SNORM, 55 },
|
||||
{ DXGI_FORMAT_R8_SINT, 56 },
|
||||
{ DXGI_FORMAT_A8_UNORM, 57 },
|
||||
{ DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 58 },
|
||||
{ DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 59 },
|
||||
{ DXGI_FORMAT_D32_FLOAT, 60 },
|
||||
{ DXGI_FORMAT_D16_UNORM, 61 },
|
||||
};
|
||||
|
||||
// Map of txtr asset format to dxgi format
|
||||
static std::map<uint16_t, DXGI_FORMAT> rpakToDxgiFormat {
|
||||
{ 0, DXGI_FORMAT_BC1_UNORM },
|
||||
{ 1, DXGI_FORMAT_BC1_UNORM_SRGB },
|
||||
{ 2, DXGI_FORMAT_BC2_UNORM },
|
||||
{ 3, DXGI_FORMAT_BC2_UNORM_SRGB },
|
||||
{ 4, DXGI_FORMAT_BC3_UNORM },
|
||||
{ 5, DXGI_FORMAT_BC3_UNORM_SRGB},
|
||||
{ 6, DXGI_FORMAT_BC4_UNORM },
|
||||
{ 7, DXGI_FORMAT_BC4_SNORM },
|
||||
{ 8, DXGI_FORMAT_BC5_UNORM },
|
||||
{ 9, DXGI_FORMAT_BC5_SNORM },
|
||||
{ 10, DXGI_FORMAT_BC6H_UF16 },
|
||||
{ 11, DXGI_FORMAT_BC6H_SF16 },
|
||||
{ 12, DXGI_FORMAT_BC7_UNORM },
|
||||
{ 13, DXGI_FORMAT_BC7_UNORM_SRGB },
|
||||
{ 14, DXGI_FORMAT_R32G32B32A32_FLOAT },
|
||||
{ 15, DXGI_FORMAT_R32G32B32A32_UINT },
|
||||
{ 16, DXGI_FORMAT_R32G32B32A32_SINT },
|
||||
{ 17, DXGI_FORMAT_R32G32B32_FLOAT },
|
||||
{ 18, DXGI_FORMAT_R32G32B32_UINT },
|
||||
{ 19, DXGI_FORMAT_R32G32B32_SINT },
|
||||
{ 20, DXGI_FORMAT_R16G16B16A16_FLOAT },
|
||||
{ 21, DXGI_FORMAT_R16G16B16A16_UNORM },
|
||||
{ 22, DXGI_FORMAT_R16G16B16A16_UINT },
|
||||
{ 23, DXGI_FORMAT_R16G16B16A16_SNORM },
|
||||
{ 24, DXGI_FORMAT_R16G16B16A16_SINT },
|
||||
{ 25, DXGI_FORMAT_R32G32_FLOAT },
|
||||
{ 26, DXGI_FORMAT_R32G32_UINT },
|
||||
{ 27, DXGI_FORMAT_R32G32_SINT },
|
||||
{ 28, DXGI_FORMAT_R10G10B10A2_UNORM },
|
||||
{ 29, DXGI_FORMAT_R10G10B10A2_UINT },
|
||||
{ 30, DXGI_FORMAT_R11G11B10_FLOAT },
|
||||
{ 31, DXGI_FORMAT_R8G8B8A8_UNORM },
|
||||
{ 32, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB },
|
||||
{ 33, DXGI_FORMAT_R8G8B8A8_UINT },
|
||||
{ 34, DXGI_FORMAT_R8G8B8A8_SNORM },
|
||||
{ 35, DXGI_FORMAT_R8G8B8A8_SINT },
|
||||
{ 36, DXGI_FORMAT_R16G16_FLOAT },
|
||||
{ 37, DXGI_FORMAT_R16G16_UNORM },
|
||||
{ 38, DXGI_FORMAT_R16G16_UINT },
|
||||
{ 39, DXGI_FORMAT_R16G16_SNORM },
|
||||
{ 40, DXGI_FORMAT_R16G16_SINT },
|
||||
{ 41, DXGI_FORMAT_R32_FLOAT },
|
||||
{ 42, DXGI_FORMAT_R32_UINT },
|
||||
{ 43, DXGI_FORMAT_R32_SINT },
|
||||
{ 44, DXGI_FORMAT_R8G8_UNORM },
|
||||
{ 45, DXGI_FORMAT_R8G8_UINT },
|
||||
{ 46, DXGI_FORMAT_R8G8_SNORM },
|
||||
{ 47, DXGI_FORMAT_R8G8_SINT },
|
||||
{ 48, DXGI_FORMAT_R16_FLOAT },
|
||||
{ 49, DXGI_FORMAT_R16_UNORM },
|
||||
{ 50, DXGI_FORMAT_R16_UINT },
|
||||
{ 51, DXGI_FORMAT_R16_SNORM },
|
||||
{ 52, DXGI_FORMAT_R16_SINT },
|
||||
{ 53, DXGI_FORMAT_R8_UNORM },
|
||||
{ 54, DXGI_FORMAT_R8_UINT },
|
||||
{ 55, DXGI_FORMAT_R8_SNORM },
|
||||
{ 56, DXGI_FORMAT_R8_SINT },
|
||||
{ 57, DXGI_FORMAT_A8_UNORM},
|
||||
{ 58, DXGI_FORMAT_R9G9B9E5_SHAREDEXP },
|
||||
{ 59, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM },
|
||||
{ 60, DXGI_FORMAT_D32_FLOAT },
|
||||
{ 61, DXGI_FORMAT_D16_UNORM },
|
||||
};
|
||||
|
||||
#endif // !DEDICATED
|
||||
|
||||
class RPakLoadedInfo_t
|
||||
{
|
||||
public:
|
||||
@ -447,7 +207,7 @@ public:
|
||||
/* ==== RTECH =========================================================================================================================================================== */
|
||||
#if not defined DEDICATED
|
||||
inline CMemory p_RTech_CreateDXTexture;
|
||||
inline auto RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(RTechTextureInfo_t*, int64_t)>();
|
||||
inline auto RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(TextureHeader_t*, int64_t)>();
|
||||
|
||||
inline CMemory p_GetStreamOverlay;
|
||||
inline auto GetStreamOverlay = p_GetStreamOverlay.RCast<void(*)(const char* mode, char* buf, size_t bufSize)>();
|
||||
@ -488,7 +248,7 @@ public:
|
||||
static int32_t OpenFile(const CHAR* szFilePath, void* unused, LONGLONG* fileSizeOut);
|
||||
|
||||
#if not defined DEDICATED
|
||||
static void CreateDXTexture(RTechTextureInfo_t* textureHeader, int64_t cpuArg);
|
||||
static void CreateDXTexture(TextureHeader_t* textureHeader, int64_t cpuArg);
|
||||
void** LoadShaderSet(void** VTablePtr);
|
||||
#endif // !DEDICATED
|
||||
};
|
||||
@ -533,7 +293,7 @@ class VPakFile : public IDetour
|
||||
RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(RTechTextureInfo_t*, int64_t)>(); /*48 8B C4 48 89 48 08 53 55 41 55*/
|
||||
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
p_RTech_CreateDXTexture = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xE8\x00\x00\x00\x00\x4C\x8B\xC7\x48\x8B\xD5\x48\x8B\xCB\x48\x83\xC4\x60"), "x????xxxxxxxxxxxxx").FollowNearCallSelf();
|
||||
RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(RTechTextureInfo_t*, int64_t)>(); /*E8 ? ? ? ? 4C 8B C7 48 8B D5 48 8B CB 48 83 C4 60*/
|
||||
RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(TextureHeader_t*, int64_t)>(); /*E8 ? ? ? ? 4C 8B C7 48 8B D5 48 8B CB 48 83 C4 60*/
|
||||
#endif
|
||||
p_GetStreamOverlay = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xE8\x00\x00\x00\x00\x80\x7C\x24\x00\x00\x0F\x84\x00\x00\x00\x00\x48\x89\x9C\x24\x00\x00\x00\x00"), "x????xxx??xx????xxxx????").FollowNearCallSelf();
|
||||
GetStreamOverlay = p_GetStreamOverlay.RCast<void(*)(const char*, char*, size_t)>(); /*E8 ? ? ? ? 80 7C 24 ? ? 0F 84 ? ? ? ? 48 89 9C 24 ? ? ? ?*/
|
||||
|
@ -23,7 +23,7 @@ void CUIBaseSurface::Init()
|
||||
this->SetClientSize({ WindowX, WindowY });
|
||||
this->SetFormBorderStyle(Forms::FormBorderStyle::FixedSingle);
|
||||
this->SetStartPosition(Forms::FormStartPosition::CenterParent);
|
||||
this->SetMinimizeBox(false);
|
||||
this->SetMinimizeBox(true);
|
||||
this->SetMaximizeBox(false);
|
||||
this->SetBackColor(Drawing::Color(47, 54, 61));
|
||||
|
||||
|
@ -390,7 +390,7 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cfgFile.rdbuf();
|
||||
svCmdLineArgs = ss.str() + "-launcher";
|
||||
svCmdLineArgs = ss.str() + "-launcher" + "-noworkerdll";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -413,7 +413,7 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cfgFile.rdbuf();
|
||||
svCmdLineArgs = ss.str() + "-launcher";
|
||||
svCmdLineArgs = ss.str() + "-launcher" + "-noworkerdll";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
2
r5dev/thirdparty/imgui/include/imgui.h
vendored
2
r5dev/thirdparty/imgui/include/imgui.h
vendored
@ -323,7 +323,7 @@ namespace ImGui
|
||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
||||
// - Note that the bottom of window stack always contains a window called "Debug".
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0, void* close_callback = nullptr);
|
||||
IMGUI_API void End();
|
||||
|
||||
// Child Windows
|
||||
|
@ -2136,6 +2136,7 @@ struct IMGUI_API ImGuiWindow
|
||||
int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy
|
||||
int MemoryDrawListVtxCapacity;
|
||||
bool MemoryCompacted; // Set when window extraneous data have been garbage collected
|
||||
void* CloseCallback; // Callback ran when the close button is pressed.
|
||||
|
||||
public:
|
||||
ImGuiWindow(ImGuiContext* context, const char* name);
|
||||
|
@ -22,13 +22,13 @@ public:
|
||||
{
|
||||
int m_nBind0 = VK_OEM_3;
|
||||
int m_nBind1 = VK_INSERT;
|
||||
} IConsole_Config;
|
||||
} m_ConsoleConfig;
|
||||
|
||||
struct
|
||||
{
|
||||
int m_nBind0 = VK_HOME;
|
||||
int m_nBind1 = VK_F10;
|
||||
} IBrowser_Config;
|
||||
} m_BrowserConfig;
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
|
9
r5dev/thirdparty/imgui/src/imgui.cpp
vendored
9
r5dev/thirdparty/imgui/src/imgui.cpp
vendored
@ -5913,8 +5913,14 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
|
||||
|
||||
// Close button
|
||||
if (has_close_button)
|
||||
{
|
||||
if (CloseButton(window->GetID("#CLOSE"), close_button_pos))
|
||||
{
|
||||
*p_open = false;
|
||||
if (window->CloseCallback)
|
||||
((void(*)(void))window->CloseCallback)();
|
||||
}
|
||||
}
|
||||
|
||||
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
||||
g.CurrentItemFlags = item_flags_backup;
|
||||
@ -6012,7 +6018,7 @@ static ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window)
|
||||
// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
|
||||
// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
|
||||
// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
|
||||
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags, void* close_callback)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
@ -6160,6 +6166,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0);
|
||||
window->Active = true;
|
||||
window->HasCloseButton = (p_open != NULL);
|
||||
window->CloseCallback = close_callback;
|
||||
window->ClipRect = ImVec4(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX);
|
||||
window->IDStack.resize(1);
|
||||
window->DrawList->_ResetForNewFrame();
|
||||
|
66
r5dev/thirdparty/imgui/src/imgui_utility.cpp
vendored
66
r5dev/thirdparty/imgui/src/imgui_utility.cpp
vendored
@ -37,45 +37,47 @@ char* Strdup(const char* s)
|
||||
void Strtrim(char* s)
|
||||
{
|
||||
char* str_end = s + strlen(s);
|
||||
|
||||
while (str_end > s && str_end[-1] == ' ')
|
||||
{
|
||||
str_end--; *str_end = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiConfig::Load()
|
||||
{
|
||||
fs::path fsPath = "platform\\imgui.json";
|
||||
static const fs::path fsPath = "platform\\imgui.json";
|
||||
DevMsg(eDLL_T::MS, "Loading ImGui config file '%s'\n", fsPath.relative_path().u8string().c_str());
|
||||
|
||||
if (fs::exists(fsPath))
|
||||
if (!fs::exists(fsPath))
|
||||
{
|
||||
try
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
nlohmann::json jsIn;
|
||||
std::ifstream configFile(fsPath, std::ios::binary); // Parse config file.
|
||||
|
||||
configFile >> jsIn;
|
||||
configFile.close();
|
||||
|
||||
if (jsIn.is_null() || jsIn["config"].is_null())
|
||||
{
|
||||
nlohmann::json jsIn;
|
||||
std::ifstream configFile(fsPath, std::ios::binary); // Parse config file.
|
||||
|
||||
configFile >> jsIn;
|
||||
configFile.close();
|
||||
|
||||
if (!jsIn.is_null())
|
||||
{
|
||||
if (!jsIn["config"].is_null())
|
||||
{
|
||||
// IConsole
|
||||
IConsole_Config.m_nBind0 = jsIn["config"]["GameConsole"]["bind0"].get<int>();
|
||||
IConsole_Config.m_nBind1 = jsIn["config"]["GameConsole"]["bind1"].get<int>();
|
||||
|
||||
// IBrowser
|
||||
IBrowser_Config.m_nBind0 = jsIn["config"]["GameBrowser"]["bind0"].get<int>();
|
||||
IBrowser_Config.m_nBind1 = jsIn["config"]["GameBrowser"]["bind1"].get<int>();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
Warning(eDLL_T::MS, "Exception while parsing ImGui config file:\n%s\n", ex.what());
|
||||
return;
|
||||
return; // Invalid or no config.
|
||||
}
|
||||
|
||||
// IConsole
|
||||
m_ConsoleConfig.m_nBind0 = jsIn["config"]["GameConsole"]["bind0"].get<int>();
|
||||
m_ConsoleConfig.m_nBind1 = jsIn["config"]["GameConsole"]["bind1"].get<int>();
|
||||
|
||||
// IBrowser
|
||||
m_BrowserConfig.m_nBind0 = jsIn["config"]["GameBrowser"]["bind0"].get<int>();
|
||||
m_BrowserConfig.m_nBind1 = jsIn["config"]["GameBrowser"]["bind1"].get<int>();
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
Warning(eDLL_T::MS, "Exception while parsing ImGui config file:\n%s\n", ex.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,12 +86,12 @@ void ImGuiConfig::Save()
|
||||
nlohmann::json jsOut;
|
||||
|
||||
// IConsole
|
||||
jsOut["config"]["GameConsole"]["bind0"] = IConsole_Config.m_nBind0;
|
||||
jsOut["config"]["GameConsole"]["bind1"] = IConsole_Config.m_nBind1;
|
||||
jsOut["config"]["GameConsole"]["bind0"] = m_ConsoleConfig.m_nBind0;
|
||||
jsOut["config"]["GameConsole"]["bind1"] = m_ConsoleConfig.m_nBind1;
|
||||
|
||||
// IBrowser
|
||||
jsOut["config"]["GameBrowser"]["bind0"] = IBrowser_Config.m_nBind0;
|
||||
jsOut["config"]["GameBrowser"]["bind1"] = IBrowser_Config.m_nBind1;
|
||||
jsOut["config"]["GameBrowser"]["bind0"] = m_BrowserConfig.m_nBind0;
|
||||
jsOut["config"]["GameBrowser"]["bind1"] = m_BrowserConfig.m_nBind1;
|
||||
|
||||
fs::path fsPath = "platform\\imgui.json";
|
||||
|
||||
|
@ -114,6 +114,16 @@
|
||||
#error
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//#ifndef schema
|
||||
//#define schema namespace ValveSchemaMarker {}
|
||||
//#endif
|
||||
//#define noschema
|
||||
//#define schema_pragma( ... )
|
||||
//#define META( ... )
|
||||
//#define TYPEMETA( ... )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Old-school defines we're going to support since much code uses them
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -175,12 +175,12 @@ void ConVar::Init(void) const
|
||||
con_notify_warning_clr = ConVar::Create("con_notify_warning_clr", "180 180 20 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Warning RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
|
||||
con_notify_error_clr = ConVar::Create("con_notify_error_clr" , "225 20 20 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Error RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
|
||||
|
||||
con_max_size_logvector = ConVar::Create("con_max_size_logvector" , "1024", FCVAR_DEVELOPMENTONLY, "Maximum number of logs in the console before cleanup starts.", true, 1.f, false, 0.f, nullptr, nullptr);
|
||||
con_max_size_history = ConVar::Create("con_max_size_history" , "512" , FCVAR_DEVELOPMENTONLY, "Maximum number of command history items before cleanup starts.", true, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_limit = ConVar::Create("con_suggestion_limit" , "128" , FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", true, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_showhelptext = ConVar::Create("con_suggestion_showhelptext" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase help text in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_showflags = ConVar::Create("con_suggestion_showflags" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase flags in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_flags_realtime = ConVar::Create("con_suggestion_flags_realtime" , "1" , FCVAR_DEVELOPMENTONLY, "Whether to show compile-time or run-time CommandBase flags.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_max_lines = ConVar::Create("con_max_lines" , "1024", FCVAR_DEVELOPMENTONLY, "Maximum number of lines in the console before cleanup starts.", true, 1.f, false, 0.f, nullptr, nullptr);
|
||||
con_max_history = ConVar::Create("con_max_history" , "512" , FCVAR_DEVELOPMENTONLY, "Maximum number of command submission items before history cleanup starts.", true, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_limit = ConVar::Create("con_suggestion_limit" , "128" , FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", true, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_showhelptext = ConVar::Create("con_suggestion_showhelptext" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase help text in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_showflags = ConVar::Create("con_suggestion_showflags" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase flags in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
con_suggestion_flags_realtime = ConVar::Create("con_suggestion_flags_realtime", "1" , FCVAR_DEVELOPMENTONLY, "Whether to show compile-time or run-time CommandBase flags.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
#endif // !DEDICATED
|
||||
//-------------------------------------------------------------------------
|
||||
// FILESYSTEM |
|
||||
@ -209,8 +209,8 @@ void ConVar::Init(void) const
|
||||
net_processTimeBudget = ConVar::Create("net_processTimeBudget" ,"200" , FCVAR_RELEASE , "Net message process budget in milliseconds (removing netchannel if exceeded).", true, 0.f, false, 0.f, nullptr, "0 = disabled.");
|
||||
//-------------------------------------------------------------------------
|
||||
// NETWORKSYSTEM |
|
||||
pylon_matchmaking_hostname = ConVar::Create("pylon_matchmaking_hostname", "ms.r5reloaded.com", FCVAR_RELEASE , "Holds the pylon matchmaking hostname.", false, 0.f, false, 0.f, &MP_HostName_Changed_f, nullptr);
|
||||
pylon_host_update_interval = ConVar::Create("pylon_host_update_interval", "5" , FCVAR_RELEASE , "Length of time in seconds between each status update interval to master server.", true, 5.f, false, 0.f, nullptr, nullptr);
|
||||
pylon_matchmaking_hostname = ConVar::Create("pylon_matchmaking_hostname", "ms.r5reloaded.com", FCVAR_RELEASE, "Holds the pylon matchmaking hostname.", false, 0.f, false, 0.f, &MP_HostName_Changed_f, nullptr);
|
||||
pylon_host_update_interval = ConVar::Create("pylon_host_update_interval", "5" , FCVAR_RELEASE, "Length of time in seconds between each status update interval to master server.", true, 5.f, false, 0.f, nullptr, nullptr);
|
||||
pylon_showdebuginfo = ConVar::Create("pylon_showdebuginfo" , "0" , FCVAR_RELEASE, "Shows debug output for pylon.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
//-------------------------------------------------------------------------
|
||||
// RTECH API |
|
||||
@ -888,8 +888,6 @@ void ConVar::InstallChangeCallback(FnChangeCallback_t callback, bool bInvoke /*=
|
||||
{
|
||||
callback(reinterpret_cast<IConVar*>(&m_pIConVarVFTable), m_Value.m_pszString, m_Value.m_fValue);
|
||||
}
|
||||
|
||||
sizeof(CUtlVector<int>);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -329,6 +329,7 @@ void ConCommand::Init(void)
|
||||
ConCommand::Create("sphere", "Draw a debug sphere.", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, Sphere_f, nullptr);
|
||||
ConCommand::Create("capsule", "Draw a debug capsule.", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, Capsule_f, nullptr);
|
||||
#endif //!DEDICATED
|
||||
ConCommand::Create("con_help", "Shows the colors and description of each context.", FCVAR_RELEASE, CON_Help_f, nullptr);
|
||||
#ifndef CLIENT_DLL
|
||||
ConCommand::Create("reload_playlists", "Reloads the playlists file.", FCVAR_RELEASE, Host_ReloadPlaylists_f, nullptr);
|
||||
#endif // !CLIENT_DLL
|
||||
@ -347,10 +348,15 @@ void ConCommand::Init(void)
|
||||
//-------------------------------------------------------------------------
|
||||
// CLIENT DLL |
|
||||
ConCommand::Create("script_client", "Run input code as CLIENT script on the VM.", FCVAR_CLIENTDLL | FCVAR_CHEAT, SQVM_ClientScript_f, nullptr);
|
||||
ConCommand::Create("cl_showconsole", "Opens the game console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, GameConsole_Invoke_f, nullptr);
|
||||
ConCommand::Create("cl_showconsole", "Opens the developer console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, GameConsole_Invoke_f, nullptr);
|
||||
ConCommand::Create("cl_showbrowser", "Opens the server browser.", FCVAR_CLIENTDLL | FCVAR_RELEASE, ServerBrowser_Invoke_f, nullptr);
|
||||
ConCommand::Create("rcon", "Forward RCON query to remote server. | Usage: rcon \"<query>\".", FCVAR_CLIENTDLL | FCVAR_RELEASE, RCON_CmdQuery_f, nullptr);
|
||||
ConCommand::Create("rcon_disconnect", "Disconnect from RCON server.", FCVAR_CLIENTDLL | FCVAR_RELEASE, RCON_Disconnect_f, nullptr);
|
||||
|
||||
ConCommand::Create("con_history", "Shows the developer console submission history.", FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_LogHistory_f, nullptr);
|
||||
ConCommand::Create("con_removeline", "Removes a range of lines from the developer console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_RemoveLine_f, nullptr);
|
||||
ConCommand::Create("con_clearlines", "Clears all lines from the developer console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_ClearLines_f, nullptr);
|
||||
ConCommand::Create("con_clearhistory", "Clears all submissions from the developer console history.", FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_ClearHistory_f, nullptr);
|
||||
//-------------------------------------------------------------------------
|
||||
// UI DLL |
|
||||
ConCommand::Create("script_ui", "Run input code as UI script on the VM.", FCVAR_CLIENTDLL | FCVAR_CHEAT, SQVM_UIScript_f, nullptr);
|
||||
|
@ -144,8 +144,8 @@ ConVar* con_notify_common_clr = nullptr;
|
||||
ConVar* con_notify_warning_clr = nullptr;
|
||||
ConVar* con_notify_error_clr = nullptr;
|
||||
|
||||
ConVar* con_max_size_logvector = nullptr;
|
||||
ConVar* con_max_size_history = nullptr;
|
||||
ConVar* con_max_lines = nullptr;
|
||||
ConVar* con_max_history = nullptr;
|
||||
ConVar* con_suggestion_limit = nullptr;
|
||||
ConVar* con_suggestion_showhelptext = nullptr;
|
||||
ConVar* con_suggestion_showflags = nullptr;
|
||||
|
@ -140,8 +140,8 @@ extern ConVar* con_notify_common_clr;
|
||||
extern ConVar* con_notify_warning_clr;
|
||||
extern ConVar* con_notify_error_clr;
|
||||
|
||||
extern ConVar* con_max_size_logvector;
|
||||
extern ConVar* con_max_size_history;
|
||||
extern ConVar* con_max_lines;
|
||||
extern ConVar* con_max_history;
|
||||
extern ConVar* con_suggestion_limit;
|
||||
extern ConVar* con_suggestion_showhelptext;
|
||||
extern ConVar* con_suggestion_showflags;
|
||||
|
@ -181,7 +181,7 @@ void CLogSystem::DrawHostStats(void) const
|
||||
|
||||
if (cl_hoststats_invert_x->GetBool())
|
||||
{
|
||||
nWidth = g_nWindowWidth - nWidth;
|
||||
nWidth = g_nWindowWidth - nWidth;
|
||||
}
|
||||
if (cl_hoststats_invert_y->GetBool())
|
||||
{
|
||||
@ -257,7 +257,7 @@ void CLogSystem::DrawCrosshairMaterial(void) const
|
||||
pMaterialGlue->m_pszName,
|
||||
pMaterialGlue->m_GUID,
|
||||
pMaterialGlue->m_iWidth, pMaterialGlue->m_iHeight,
|
||||
pMaterialGlue->m_pszSurfaceName1, pMaterialGlue->m_pszSurfaceName2,
|
||||
pMaterialGlue->m_pszSurfaceProp, pMaterialGlue->m_pszSurfaceProp2,
|
||||
pMaterialGlue->m_nStreamableTextureCount,
|
||||
pMaterialGlue->m_pShaderGlue->m_nTextureInputCount);
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
/*******************************************************************
|
||||
* ██████╗ ██╗ ██╗ ██╗██████╗ ██╗ ██╗ ██╗ ██╗██████╗ *
|
||||
* ██╔══██╗███║ ██║ ██║██╔══██╗██║ ██╔╝ ██║ ██║██╔══██╗ *
|
||||
* ██████╔╝╚██║ ██║ ██║██████╔╝█████╔╝ ██║ ██║██████╔╝ *
|
||||
* ██╔══██╗ ██║ ╚██╗ ██╔╝██╔═══╝ ██╔═██╗ ██║ ██║██╔══██╗ *
|
||||
* ██║ ██║ ██║ ╚████╔╝ ██║ ██║ ██╗ ███████╗██║██████╔╝ *
|
||||
* ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝╚═════╝ *
|
||||
*******************************************************************/
|
||||
//=============================================================================//
|
||||
//
|
||||
// Purpose: Valve Pak utility class.
|
||||
//
|
||||
//=============================================================================//
|
||||
// packedstore.cpp
|
||||
//
|
||||
// Note: VPK's are created in pairs of a directory file and block archive(s).
|
||||
// - <locale><context>_<source>.bsp.pak000_dir.vpk --> directory file.
|
||||
// - <context>_<source>.bsp.pak000_<patch>.vpk --> block archive.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "core/stdafx.h"
|
||||
#include "tier1/cvar.h"
|
||||
#include "mathlib/adler32.h"
|
||||
@ -48,63 +52,48 @@ void CPackedStore::InitLzDecompParams(void)
|
||||
// bSanitizeName - retrieve the directory file name from block name
|
||||
// Output : VPKDir_t
|
||||
//-----------------------------------------------------------------------------
|
||||
VPKDir_t CPackedStore::GetDirectoryFile(string svPackDirFile, bool bSanitizeName) const
|
||||
VPKDir_t CPackedStore::GetDirectoryFile(const string& svPackDirFile, bool bSanitizeName) const
|
||||
{
|
||||
/*| PACKDIRFILE |||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
|
||||
std::smatch smRegexMatches;
|
||||
|
||||
if (!bSanitizeName)
|
||||
return VPKDir_t(svPackDirFile);
|
||||
|
||||
std::smatch smRegexMatches;
|
||||
std::regex_search(svPackDirFile, smRegexMatches, BLOCK_REGEX);
|
||||
|
||||
if (smRegexMatches.empty())
|
||||
return VPKDir_t(svPackDirFile);
|
||||
|
||||
StringReplace(svPackDirFile, smRegexMatches[0], "pak000_dir");
|
||||
string svSanitizedName = svPackDirFile;
|
||||
StringReplace(svSanitizedName, smRegexMatches[0], "pak000_dir");
|
||||
|
||||
bool bHasLocale = false;
|
||||
bool bHasContext = false;
|
||||
string svPackDirPrefix;
|
||||
|
||||
size_t nLocaleIndex = 0; // Default to ENGLISH;
|
||||
size_t nContextIndex = 0; // Default to SERVER;
|
||||
|
||||
for (size_t i = 0, nl = DIR_LOCALE.size(); i < nl; i++)
|
||||
for (const string& svLocale : DIR_LOCALE)
|
||||
{
|
||||
const string& svLocale = DIR_LOCALE[i];
|
||||
if (svPackDirFile.find(svLocale) != string::npos)
|
||||
if (svSanitizedName.find(svLocale) != string::npos)
|
||||
{
|
||||
svPackDirPrefix.append(svLocale);
|
||||
nLocaleIndex = i;
|
||||
bHasLocale = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (svPackDirPrefix.empty()) // No locale found.
|
||||
if (!bHasLocale) // Only sanitize if no locale was provided.
|
||||
{
|
||||
string svPackDirPrefix;
|
||||
svPackDirPrefix.append(DIR_LOCALE[0]);
|
||||
}
|
||||
|
||||
if (!bHasLocale)
|
||||
{
|
||||
for (size_t i = 0, nc = DIR_CONTEXT.size(); i < nc; i++)
|
||||
for (const string& svContext : DIR_CONTEXT)
|
||||
{
|
||||
const string& svContext = DIR_CONTEXT[i];
|
||||
if (svPackDirFile.find(svContext) != string::npos)
|
||||
if (svSanitizedName.find(svContext) != string::npos)
|
||||
{
|
||||
svPackDirPrefix.append(svContext);
|
||||
nContextIndex = i;
|
||||
bHasContext = true;
|
||||
StringReplace(svSanitizedName, svContext, svPackDirPrefix);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bHasContext) // Context is required for this to work.
|
||||
{
|
||||
StringReplace(svPackDirFile, DIR_CONTEXT[nContextIndex], svPackDirPrefix);
|
||||
}
|
||||
|
||||
return VPKDir_t(svPackDirFile);
|
||||
return VPKDir_t(svSanitizedName);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -115,7 +104,6 @@ VPKDir_t CPackedStore::GetDirectoryFile(string svPackDirFile, bool bSanitizeName
|
||||
//-----------------------------------------------------------------------------
|
||||
string CPackedStore::GetPackFile(const string& svPackDirFile, uint16_t iArchiveIndex) const
|
||||
{
|
||||
/*| ARCHIVES ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
|
||||
string svPackChunkFile = StripLocalePrefix(svPackDirFile);
|
||||
ostringstream oss;
|
||||
|
||||
@ -155,7 +143,6 @@ lzham_compress_level CPackedStore::GetCompressionLevel(void) const
|
||||
//-----------------------------------------------------------------------------
|
||||
vector<VPKEntryBlock_t> CPackedStore::GetEntryBlocks(CIOStream* pReader) const
|
||||
{
|
||||
/*| ENTRYBLOCKS |||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
|
||||
string svName, svPath, svExtension;
|
||||
vector<VPKEntryBlock_t> vBlocks;
|
||||
while (!(svExtension = pReader->ReadString()).empty())
|
||||
@ -414,12 +401,13 @@ void CPackedStore::BuildManifest(const vector<VPKEntryBlock_t>& vBlock, const st
|
||||
|
||||
for (const VPKEntryBlock_t& vEntry : vBlock)
|
||||
{
|
||||
const VPKChunkDescriptor_t& vDescriptor = vEntry.m_vChunks[0];
|
||||
jEntry[vEntry.m_svEntryPath] =
|
||||
{
|
||||
{ "preloadSize", vEntry.m_iPreloadSize },
|
||||
{ "loadFlags", vEntry.m_vChunks[0].m_nLoadFlags },
|
||||
{ "textureFlags", vEntry.m_vChunks[0].m_nTextureFlags },
|
||||
{ "useCompression", vEntry.m_vChunks[0].m_nCompressedSize != vEntry.m_vChunks[0].m_nUncompressedSize },
|
||||
{ "loadFlags", vDescriptor.m_nLoadFlags },
|
||||
{ "textureFlags", vDescriptor.m_nTextureFlags },
|
||||
{ "useCompression", vDescriptor.m_nCompressedSize != vDescriptor.m_nUncompressedSize },
|
||||
{ "useDataSharing", true }
|
||||
};
|
||||
}
|
||||
@ -606,8 +594,8 @@ void CPackedStore::UnpackAll(const VPKDir_t& vDir, const string& svPathOut)
|
||||
|
||||
for (size_t i = 0, fs = vDir.m_vPackFile.size(); i < fs; i++)
|
||||
{
|
||||
fs::path fspVpkPath(vDir.m_svDirPath);
|
||||
string svPath = fspVpkPath.parent_path().u8string() + '\\' + vDir.m_vPackFile[i];
|
||||
const fs::path fspVpkPath(vDir.m_svDirPath);
|
||||
const string svPath = fspVpkPath.parent_path().u8string() + '\\' + vDir.m_vPackFile[i];
|
||||
CIOStream iStream(svPath, CIOStream::Mode_t::READ); // Create stream to read from each archive.
|
||||
|
||||
for (size_t j = 0, es = vDir.m_vEntryBlocks.size(); j < es; j++)
|
||||
@ -619,7 +607,7 @@ void CPackedStore::UnpackAll(const VPKDir_t& vDir, const string& svPathOut)
|
||||
}
|
||||
else // Chunk belongs to this block.
|
||||
{
|
||||
string svFilePath = CreateDirectories(svPathOut + vBlock.m_svEntryPath);
|
||||
const string svFilePath = CreateDirectories(svPathOut + vBlock.m_svEntryPath);
|
||||
CIOStream oStream(svFilePath, CIOStream::Mode_t::WRITE);
|
||||
|
||||
if (!oStream.IsWritable())
|
||||
@ -814,7 +802,7 @@ void VPKDir_t::Build(const string& svDirectoryFile, const vector<VPKEntryBlock_t
|
||||
writer.Write<uint32_t>(this->m_vHeader.m_nDirectorySize);
|
||||
writer.Write<uint32_t>(this->m_vHeader.m_nSignatureSize);
|
||||
|
||||
for (VPKEntryBlock_t vBlock : vEntryBlocks)
|
||||
for (const VPKEntryBlock_t& vBlock : vEntryBlocks)
|
||||
{
|
||||
string svExtension = GetExtension(vBlock.m_svEntryPath);
|
||||
string svFilePath = RemoveFileName(vBlock.m_svEntryPath);
|
||||
|
@ -1,4 +1,13 @@
|
||||
#pragma once
|
||||
#ifndef PACKEDSTORE_H
|
||||
#define PACKEDSTORE_H
|
||||
/*******************************************************************
|
||||
* ██████╗ ██╗ ██╗ ██╗██████╗ ██╗ ██╗ ██╗ ██╗██████╗ *
|
||||
* ██╔══██╗███║ ██║ ██║██╔══██╗██║ ██╔╝ ██║ ██║██╔══██╗ *
|
||||
* ██████╔╝╚██║ ██║ ██║██████╔╝█████╔╝ ██║ ██║██████╔╝ *
|
||||
* ██╔══██╗ ██║ ╚██╗ ██╔╝██╔═══╝ ██╔═██╗ ██║ ██║██╔══██╗ *
|
||||
* ██║ ██║ ██║ ╚████╔╝ ██║ ██║ ██╗ ███████╗██║██████╔╝ *
|
||||
* ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝╚═════╝ *
|
||||
*******************************************************************/
|
||||
#include "public/utility/binstream.h"
|
||||
#include "thirdparty/lzham/include/lzham.h"
|
||||
|
||||
@ -83,11 +92,11 @@ struct VPKData_t
|
||||
|
||||
struct VPKChunkDescriptor_t
|
||||
{
|
||||
uint32_t m_nLoadFlags {}; // Load flags.
|
||||
uint16_t m_nTextureFlags {}; // Texture flags (only used if the entry is a vtf).
|
||||
uint64_t m_nArchiveOffset {}; // Offset in archive.
|
||||
uint64_t m_nCompressedSize {}; // Compressed size of chunk.
|
||||
uint64_t m_nUncompressedSize{}; // Uncompressed size of chunk.
|
||||
uint32_t m_nLoadFlags; // Load flags.
|
||||
uint16_t m_nTextureFlags; // Texture flags (only used if the entry is a vtf).
|
||||
uint64_t m_nArchiveOffset; // Offset in archive.
|
||||
uint64_t m_nCompressedSize; // Compressed size of chunk.
|
||||
uint64_t m_nUncompressedSize; // Uncompressed size of chunk.
|
||||
bool m_bIsCompressed = false;
|
||||
|
||||
VPKChunkDescriptor_t(){};
|
||||
@ -97,11 +106,11 @@ struct VPKChunkDescriptor_t
|
||||
|
||||
struct VPKEntryBlock_t
|
||||
{
|
||||
uint32_t m_nFileCRC {}; // Crc32 for the uncompressed entry.
|
||||
uint16_t m_iPreloadSize {}; // Preload bytes.
|
||||
uint16_t m_iPackFileIndex{}; // Index of the pack file that contains this entry.
|
||||
vector<VPKChunkDescriptor_t> m_vChunks {}; // Vector of all the chunks of a given entry (chunks have a size limit of 1 MiB, anything over this limit is fragmented into smaller chunks).
|
||||
string m_svEntryPath {}; // Path to entry within vpk.
|
||||
uint32_t m_nFileCRC; // Crc32 for the uncompressed entry.
|
||||
uint16_t m_iPreloadSize; // Preload bytes.
|
||||
uint16_t m_iPackFileIndex; // Index of the pack file that contains this entry.
|
||||
vector<VPKChunkDescriptor_t> m_vChunks; // Vector of all the chunks of a given entry (chunks have a size limit of 1 MiB, anything over this limit is fragmented into smaller chunks).
|
||||
string m_svEntryPath; // Path to entry within vpk.
|
||||
|
||||
VPKEntryBlock_t(CIOStream* pReader, string svEntryPath);
|
||||
VPKEntryBlock_t(const vector<uint8_t>& vData, int64_t nOffset, uint16_t nPreloadData, uint16_t nArchiveIndex, uint32_t nEntryFlags, uint16_t nTextureFlags, const string& svEntryPath);
|
||||
@ -109,21 +118,21 @@ struct VPKEntryBlock_t
|
||||
|
||||
struct VPKDirHeader_t
|
||||
{
|
||||
uint32_t m_nHeaderMarker {}; // File magic.
|
||||
uint16_t m_nMajorVersion {}; // Vpk major version.
|
||||
uint16_t m_nMinorVersion {}; // Vpk minor version.
|
||||
uint32_t m_nDirectorySize{}; // Directory tree size.
|
||||
uint32_t m_nSignatureSize{}; // Directory signature.
|
||||
uint32_t m_nHeaderMarker; // File magic.
|
||||
uint16_t m_nMajorVersion; // Vpk major version.
|
||||
uint16_t m_nMinorVersion; // Vpk minor version.
|
||||
uint32_t m_nDirectorySize; // Directory tree size.
|
||||
uint32_t m_nSignatureSize; // Directory signature.
|
||||
};
|
||||
|
||||
struct VPKDir_t
|
||||
{
|
||||
VPKDirHeader_t m_vHeader {}; // Dir header.
|
||||
uint32_t m_nFileDataSize {}; // File data section size.
|
||||
vector<VPKEntryBlock_t> m_vEntryBlocks {}; // Vector of entry blocks.
|
||||
uint16_t m_iPackFileCount{}; // Highest archive index (archive count-1).
|
||||
vector<string> m_vPackFile {}; // Vector of archive file names.
|
||||
string m_svDirPath {}; // Path to vpk_dir file.
|
||||
VPKDirHeader_t m_vHeader; // Dir header.
|
||||
uint32_t m_nFileDataSize; // File data section size.
|
||||
vector<VPKEntryBlock_t> m_vEntryBlocks; // Vector of entry blocks.
|
||||
uint16_t m_iPackFileCount; // Highest archive index (archive count-1).
|
||||
vector<string> m_vPackFile; // Vector of archive file names.
|
||||
string m_svDirPath; // Path to vpk_dir file.
|
||||
|
||||
VPKDir_t(const string& svPath);
|
||||
VPKDir_t() { m_vHeader.m_nHeaderMarker = VPK_HEADER_MARKER; m_vHeader.m_nMajorVersion = VPK_MAJOR_VERSION; m_vHeader.m_nMinorVersion = VPK_MINOR_VERSION; };
|
||||
@ -143,7 +152,7 @@ public:
|
||||
void InitLzCompParams(void);
|
||||
void InitLzDecompParams(void);
|
||||
|
||||
VPKDir_t GetDirectoryFile(string svDirectoryFile, bool bSanitizeName) const;
|
||||
VPKDir_t GetDirectoryFile(const string& svDirectoryFile, bool bSanitizeName) const;
|
||||
string GetPackFile(const string& svPackDirFile, uint16_t iArchiveIndex) const;
|
||||
lzham_compress_level GetCompressionLevel(void) const;
|
||||
|
||||
@ -183,3 +192,5 @@ private:
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
extern CPackedStore* g_pPackedStore;
|
||||
|
||||
#endif // PACKEDSTORE_H
|
@ -269,6 +269,8 @@
|
||||
<ClInclude Include="..\public\iframetask.h" />
|
||||
<ClInclude Include="..\public\igame.h" />
|
||||
<ClInclude Include="..\public\ihandleentity.h" />
|
||||
<ClInclude Include="..\public\imaterial.h" />
|
||||
<ClInclude Include="..\public\imaterialinternal.h" />
|
||||
<ClInclude Include="..\public\inetchannel.h" />
|
||||
<ClInclude Include="..\public\inetmessage.h" />
|
||||
<ClInclude Include="..\public\inetmsghandler.h" />
|
||||
@ -276,7 +278,9 @@
|
||||
<ClInclude Include="..\public\isurfacesystem.h" />
|
||||
<ClInclude Include="..\public\ivrenderview.h" />
|
||||
<ClInclude Include="..\public\ivscript.h" />
|
||||
<ClInclude Include="..\public\materialsystem\shader_vcs_version.h" />
|
||||
<ClInclude Include="..\public\model_types.h" />
|
||||
<ClInclude Include="..\public\rendersystem\schema\texture.g.h" />
|
||||
<ClInclude Include="..\public\studio.h" />
|
||||
<ClInclude Include="..\core\resource.h" />
|
||||
<ClInclude Include="..\public\utility\binstream.h" />
|
||||
|
@ -223,6 +223,15 @@
|
||||
<Filter Include="sdk\pluginsystem">
|
||||
<UniqueIdentifier>{b22e88ea-1ee0-4431-82a4-e877a6798f23}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="sdk\public\rendersystem">
|
||||
<UniqueIdentifier>{a254a718-eeec-434e-b3a3-77604c8f372e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="sdk\public\rendersystem\schema">
|
||||
<UniqueIdentifier>{a41c5a4b-d1a5-4b95-aa63-b61ca185a0a9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="sdk\public\materialsystem">
|
||||
<UniqueIdentifier>{565eefdf-15cf-47dc-a22b-0d3521e8c5c9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\client\cdll_engine_int.cpp">
|
||||
@ -1769,6 +1778,18 @@
|
||||
<ClInclude Include="..\public\igame.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\imaterial.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\imaterialinternal.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\rendersystem\schema\texture.g.h">
|
||||
<Filter>sdk\public\rendersystem\schema</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\materialsystem\shader_vcs_version.h">
|
||||
<Filter>sdk\public\materialsystem</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -35,6 +35,7 @@
|
||||
<ClCompile Include="..\engine\cmodel_bsp.cpp" />
|
||||
<ClCompile Include="..\engine\common.cpp" />
|
||||
<ClCompile Include="..\engine\debugoverlay.cpp" />
|
||||
<ClCompile Include="..\engine\enginetrace.cpp" />
|
||||
<ClCompile Include="..\engine\gl_rsurf.cpp" />
|
||||
<ClCompile Include="..\engine\gl_screen.cpp" />
|
||||
<ClCompile Include="..\engine\host.cpp" />
|
||||
@ -190,6 +191,7 @@
|
||||
<ClInclude Include="..\engine\common.h" />
|
||||
<ClInclude Include="..\engine\datablock.h" />
|
||||
<ClInclude Include="..\engine\debugoverlay.h" />
|
||||
<ClInclude Include="..\engine\enginetrace.h" />
|
||||
<ClInclude Include="..\engine\framesnapshot.h" />
|
||||
<ClInclude Include="..\engine\gl_matsysiface.h" />
|
||||
<ClInclude Include="..\engine\gl_model_private.h" />
|
||||
@ -294,6 +296,8 @@
|
||||
<ClInclude Include="..\public\iframetask.h" />
|
||||
<ClInclude Include="..\public\igame.h" />
|
||||
<ClInclude Include="..\public\ihandleentity.h" />
|
||||
<ClInclude Include="..\public\imaterial.h" />
|
||||
<ClInclude Include="..\public\imaterialinternal.h" />
|
||||
<ClInclude Include="..\public\inetchannel.h" />
|
||||
<ClInclude Include="..\public\inetmessage.h" />
|
||||
<ClInclude Include="..\public\inetmsghandler.h" />
|
||||
@ -302,7 +306,9 @@
|
||||
<ClInclude Include="..\public\isurfacesystem.h" />
|
||||
<ClInclude Include="..\public\ivrenderview.h" />
|
||||
<ClInclude Include="..\public\ivscript.h" />
|
||||
<ClInclude Include="..\public\materialsystem\shader_vcs_version.h" />
|
||||
<ClInclude Include="..\public\model_types.h" />
|
||||
<ClInclude Include="..\public\rendersystem\schema\texture.g.h" />
|
||||
<ClInclude Include="..\public\studio.h" />
|
||||
<ClInclude Include="..\core\resource.h" />
|
||||
<ClInclude Include="..\public\utility\binstream.h" />
|
||||
|
@ -232,6 +232,15 @@
|
||||
<Filter Include="sdk\pluginsystem">
|
||||
<UniqueIdentifier>{cd7b0538-e28c-4181-9e19-588f77d41d36}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="sdk\public\rendersystem">
|
||||
<UniqueIdentifier>{993b2009-3b46-4ffd-8f09-4f2d6ff7691a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="sdk\public\rendersystem\schema">
|
||||
<UniqueIdentifier>{5bdaa309-3120-4e90-a824-41f7ef739225}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="sdk\public\materialsystem">
|
||||
<UniqueIdentifier>{1718d302-db9b-4d2e-b666-cb9f2712eef4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\client\vengineclient_impl.cpp">
|
||||
@ -639,6 +648,9 @@
|
||||
<ClCompile Include="..\engine\sys_mainwind.cpp">
|
||||
<Filter>sdk\engine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\engine\enginetrace.cpp">
|
||||
<Filter>sdk\engine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1856,6 +1868,21 @@
|
||||
<ClInclude Include="..\public\igame.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\imaterial.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\imaterialinternal.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\rendersystem\schema\texture.g.h">
|
||||
<Filter>sdk\public\rendersystem\schema</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\materialsystem\shader_vcs_version.h">
|
||||
<Filter>sdk\public\materialsystem</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\engine\enginetrace.h">
|
||||
<Filter>sdk\engine</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -218,31 +218,31 @@ Pak_ListPaks_f
|
||||
*/
|
||||
void Pak_ListPaks_f(const CCommand& args)
|
||||
{
|
||||
DevMsg(eDLL_T::RTECH, "| id | name | status | asset count |\n");
|
||||
DevMsg(eDLL_T::RTECH, "|----|----------------------------------------------------|--------------------------------------|-------------|\n");
|
||||
DevMsg(eDLL_T::RTECH, "| id | name | status | asset count |\n");
|
||||
DevMsg(eDLL_T::RTECH, "|------|----------------------------------------------------|--------------------------------------|-------------|\n");
|
||||
|
||||
uint32_t nActuallyLoaded = 0;
|
||||
uint32_t nTotalLoaded = 0;
|
||||
|
||||
for (int16_t i = 0; i < *s_pLoadedPakCount; ++i)
|
||||
{
|
||||
RPakLoadedInfo_t info = g_pLoadedPakInfo[i];
|
||||
const RPakLoadedInfo_t& info = g_pLoadedPakInfo[i];
|
||||
|
||||
if (info.m_nStatus == RPakStatus_t::PAK_STATUS_FREED)
|
||||
continue;
|
||||
|
||||
string rpakStatus = "RPAK_CREATED_A_NEW_STATUS_SOMEHOW";
|
||||
|
||||
auto it = RPakStatusToString.find(info.m_nStatus);
|
||||
if (it != RPakStatusToString.end())
|
||||
auto it = g_PakStatusToString.find(info.m_nStatus);
|
||||
if (it != g_PakStatusToString.end())
|
||||
rpakStatus = it->second;
|
||||
|
||||
// todo: make status into a string from an array/vector
|
||||
DevMsg(eDLL_T::RTECH, "| %02i | %-50s | %-36s | %11i |\n", info.m_nHandle, info.m_pszFileName, rpakStatus.c_str(), info.m_nAssetCount);
|
||||
nActuallyLoaded++;
|
||||
DevMsg(eDLL_T::RTECH, "| %04i | %-50s | %-36s | %11i |\n", info.m_nHandle, info.m_pszFileName, rpakStatus.c_str(), info.m_nAssetCount);
|
||||
nTotalLoaded++;
|
||||
}
|
||||
DevMsg(eDLL_T::RTECH, "|----|----------------------------------------------------|--------------------------------------|-------------|\n");
|
||||
DevMsg(eDLL_T::RTECH, "| %16i loaded paks. |\n", nActuallyLoaded);
|
||||
DevMsg(eDLL_T::RTECH, "|----|----------------------------------------------------|--------------------------------------|-------------|\n");
|
||||
DevMsg(eDLL_T::RTECH, "|------|----------------------------------------------------|--------------------------------------|-------------|\n");
|
||||
DevMsg(eDLL_T::RTECH, "| %18i loaded paks. |\n", nTotalLoaded);
|
||||
DevMsg(eDLL_T::RTECH, "|------|----------------------------------------------------|--------------------------------------|-------------|\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -388,11 +388,11 @@ void RTech_Decompress_f(const CCommand& args)
|
||||
return;
|
||||
}
|
||||
|
||||
const string modDir = "paks\\Win32\\";
|
||||
const string baseDir = "paks\\Win64\\";
|
||||
static const string modDir = "paks\\Win32\\";
|
||||
static const string baseDir = "paks\\Win64\\";
|
||||
|
||||
string pakNameOut = modDir + args.Arg(1);
|
||||
string pakNameIn = baseDir + args.Arg(1);
|
||||
const string pakNameOut = modDir + args.Arg(1);
|
||||
const string pakNameIn = baseDir + args.Arg(1);
|
||||
|
||||
CreateDirectories(pakNameOut);
|
||||
|
||||
@ -406,22 +406,20 @@ void RTech_Decompress_f(const CCommand& args)
|
||||
}
|
||||
|
||||
DevMsg(eDLL_T::RTECH, " |-+ Processing: '%s'\n", pakNameIn.c_str());
|
||||
|
||||
CIOStream reader(pakNameIn, CIOStream::Mode_t::READ);
|
||||
|
||||
RPakHeader_t rheader = reader.Read<RPakHeader_t>();
|
||||
uint16_t flags = (rheader.m_nFlags[0] << 8) | rheader.m_nFlags[1];
|
||||
|
||||
DevMsg(eDLL_T::RTECH, " | |-+ Header ------------------------------------------------\n");
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Magic : '%08X'\n", rheader.m_nMagic);
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Version : '%hu'\n", rheader.m_nVersion);
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Flags : '%04hX'\n", flags);
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Hash : '%llu%llu'\n", rheader.m_nHash0, rheader.m_nHash1);
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Entries : '%u'\n", rheader.m_nAssetEntryCount);
|
||||
DevMsg(eDLL_T::RTECH, " | |-+ Compression -------------------------------------------\n");
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Size disk: '%llu'\n", rheader.m_nSizeDisk);
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Size decp: '%llu'\n", rheader.m_nSizeMemory);
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Ratio : '%.02f'\n", (rheader.m_nSizeDisk * 100.f) / rheader.m_nSizeMemory);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Magic : '%08X'\n", rheader.m_nMagic);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Version : '%hu'\n", rheader.m_nVersion);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Flags : '%04hX'\n", flags);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Hash : '%llu%llu'\n", rheader.m_nHash0, rheader.m_nHash1);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Entries : '%u'\n", rheader.m_nAssetEntryCount);
|
||||
DevMsg(eDLL_T::RTECH, " | |-+ Compression -----------------------------------------\n");
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Size disk: '%llu'\n", rheader.m_nSizeDisk);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Size decp: '%llu'\n", rheader.m_nSizeMemory);
|
||||
|
||||
if (rheader.m_nMagic != RPAKHEADER)
|
||||
{
|
||||
@ -435,7 +433,7 @@ void RTech_Decompress_f(const CCommand& args)
|
||||
}
|
||||
if (rheader.m_nSizeDisk != reader.GetSize())
|
||||
{
|
||||
Error(eDLL_T::RTECH, NO_ERROR, "%s - pak file '%s' decompressed size '%zu' doesn't match expected value '%llu'!\n", __FUNCTION__, pakNameIn.c_str(), reader.GetSize(), rheader.m_nSizeMemory);
|
||||
Error(eDLL_T::RTECH, NO_ERROR, "%s - pak file '%s' decompressed size '%zu' doesn't match expected size '%llu'!\n", __FUNCTION__, pakNameIn.c_str(), reader.GetSize(), rheader.m_nSizeMemory);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -449,9 +447,10 @@ void RTech_Decompress_f(const CCommand& args)
|
||||
}
|
||||
else
|
||||
{
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- Calculated size: '%llu'\n", decompSize);
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Size calc: '%llu'\n", decompSize);
|
||||
}
|
||||
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Ratio : '%.02f'\n", (rheader.m_nSizeDisk * 100.f) / rheader.m_nSizeMemory);
|
||||
vector<uint8_t> pakBuf(rheader.m_nSizeMemory, 0);
|
||||
|
||||
state.m_nOutMask = UINT64_MAX;
|
||||
@ -472,18 +471,19 @@ void RTech_Decompress_f(const CCommand& args)
|
||||
if (rheader.m_nPatchIndex > 0) // Check if its an patch rpak.
|
||||
{
|
||||
// Loop through all the structs and patch their compress size.
|
||||
for (uint32_t i = 1, patch_offset = 0x88; i <= rheader.m_nPatchIndex; i++, patch_offset += sizeof(RPakPatchCompressedHeader_t))
|
||||
for (uint32_t i = 1, patchOffset = (sizeof(RPakHeader_t) + sizeof(uint64_t));
|
||||
i <= rheader.m_nPatchIndex; i++, patchOffset += sizeof(RPakPatchCompressedHeader_t))
|
||||
{
|
||||
RPakPatchCompressedHeader_t* patch_header = (RPakPatchCompressedHeader_t*)((uintptr_t)pakBuf.data() + patch_offset);
|
||||
patch_header->m_nSizeDisk = patch_header->m_nSizeMemory; // Fix size for decompress.
|
||||
RPakPatchCompressedHeader_t* patchHeader = (RPakPatchCompressedHeader_t*)((uintptr_t)pakBuf.data() + patchOffset);
|
||||
patchHeader->m_nSizeDisk = patchHeader->m_nSizeMemory; // Fix size for decompress.
|
||||
}
|
||||
}
|
||||
|
||||
memcpy_s(pakBuf.data(), state.m_nDecompSize, &rheader, sizeof(RPakHeader_t)); // Overwrite first 0x80 bytes which are NULL with the header data.
|
||||
writer.Write(pakBuf.data(), state.m_nDecompSize);
|
||||
|
||||
DevMsg(eDLL_T::RTECH, " | | |-- CRC32 : '%08X'\n", crc32::update(NULL, pakBuf.data(), state.m_nDecompSize));
|
||||
DevMsg(eDLL_T::RTECH, " |-+ Decompressed rpak to: '%s'\n", pakNameOut.c_str());
|
||||
DevMsg(eDLL_T::RTECH, " | |-- Checksum : '%08X'\n", crc32::update(NULL, pakBuf.data(), state.m_nDecompSize));
|
||||
DevMsg(eDLL_T::RTECH, " |-+ Decompressed pak file to: '%s'\n", pakNameOut.c_str());
|
||||
DevMsg(eDLL_T::RTECH, "--------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
@ -627,7 +627,98 @@ void NET_UseRandomKeyChanged_f(IConVar* pConVar, const char* pOldString, float f
|
||||
NET_SetKey(DEFAULT_NET_ENCRYPTION_KEY);
|
||||
}
|
||||
}
|
||||
/*
|
||||
=====================
|
||||
CON_Help_f
|
||||
|
||||
Shows the colors and
|
||||
description of each
|
||||
context.
|
||||
=====================
|
||||
*/
|
||||
void CON_Help_f(const CCommand& args)
|
||||
{
|
||||
DevMsg(eDLL_T::COMMON, "Contexts:\n");
|
||||
SQVM_PrintFunc(reinterpret_cast<HSQUIRRELVM>(SQCONTEXT::SERVER), (SQChar*)(" = Server DLL (Script)\n"));
|
||||
SQVM_PrintFunc(reinterpret_cast<HSQUIRRELVM>(SQCONTEXT::CLIENT), (SQChar*)(" = Client DLL (Script)\n"));
|
||||
SQVM_PrintFunc(reinterpret_cast<HSQUIRRELVM>(SQCONTEXT::UI), (SQChar*)(" = UI DLL (Script)\n"));
|
||||
|
||||
DevMsg(eDLL_T::SERVER, " = Server DLL (Code)\n");
|
||||
DevMsg(eDLL_T::CLIENT, " = Client DLL (Code)\n");
|
||||
DevMsg(eDLL_T::UI, " = UI DLL (Code)\n");
|
||||
DevMsg(eDLL_T::ENGINE, " = Engine DLL (Code)\n");
|
||||
DevMsg(eDLL_T::FS, " = FileSystem (Code)\n");
|
||||
DevMsg(eDLL_T::RTECH, " = PakLoad API (Code)\n");
|
||||
DevMsg(eDLL_T::MS, " = MaterialSystem (Code)\n");
|
||||
DevMsg(eDLL_T::NETCON, " = Net Console (Code)\n");
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
/*
|
||||
=====================
|
||||
CON_LogHistory_f
|
||||
|
||||
Shows the game console
|
||||
submission history.
|
||||
=====================
|
||||
*/
|
||||
void CON_LogHistory_f(const CCommand& args)
|
||||
{
|
||||
const vector<string> vHistory = g_pConsole->GetHistory();
|
||||
for (size_t i = 0, nh = vHistory.size(); i < nh; i++)
|
||||
{
|
||||
DevMsg(eDLL_T::COMMON, "%3d: %s\n", i, vHistory[i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CON_RemoveLine_f
|
||||
|
||||
Removes a range of lines
|
||||
from the console.
|
||||
=====================
|
||||
*/
|
||||
void CON_RemoveLine_f(const CCommand& args)
|
||||
{
|
||||
if (args.ArgC() < 3)
|
||||
{
|
||||
DevMsg(eDLL_T::CLIENT, "Usage 'con_removeline': start(int) end(int)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int start = atoi(args[1]);
|
||||
int end = atoi(args[2]);
|
||||
|
||||
g_pConsole->RemoveLog(start, end);
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CON_ClearLines_f
|
||||
|
||||
Clears all lines from
|
||||
the developer console.
|
||||
=====================
|
||||
*/
|
||||
void CON_ClearLines_f(const CCommand& args)
|
||||
{
|
||||
g_pConsole->ClearLog();
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CON_ClearHistory_f
|
||||
|
||||
Clears all submissions from the
|
||||
developer console history.
|
||||
=====================
|
||||
*/
|
||||
void CON_ClearHistory_f(const CCommand& args)
|
||||
{
|
||||
g_pConsole->ClearHistory();
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
RCON_CmdQuery_f
|
||||
@ -738,7 +829,7 @@ void RCON_PasswordChanged_f(IConVar* pConVar, const char* pOldString, float flOl
|
||||
=====================
|
||||
SQVM_ServerScript_f
|
||||
|
||||
Exectutes input on the
|
||||
Executes input on the
|
||||
VM in SERVER context.
|
||||
=====================
|
||||
*/
|
||||
@ -755,7 +846,7 @@ void SQVM_ServerScript_f(const CCommand& args)
|
||||
=====================
|
||||
SQVM_ClientScript_f
|
||||
|
||||
Exectutes input on the
|
||||
Executes input on the
|
||||
VM in CLIENT context.
|
||||
=====================
|
||||
*/
|
||||
@ -799,9 +890,9 @@ void Mat_CrossHair_f(const CCommand& args)
|
||||
DevMsg(eDLL_T::MS, "-+ Material --------------------------------------------------\n");
|
||||
DevMsg(eDLL_T::MS, " |-- ADDR: '%llX'\n", material);
|
||||
DevMsg(eDLL_T::MS, " |-- GUID: '%llX'\n", material->m_GUID);
|
||||
DevMsg(eDLL_T::MS, " |-- Streamable Texture Count: '%d'\n", material->m_nStreamableTextureCount);
|
||||
DevMsg(eDLL_T::MS, " |-- Material Width: '%d'\n", material->m_iWidth);
|
||||
DevMsg(eDLL_T::MS, " |-- Material Height: '%d'\n", material->m_iHeight);
|
||||
DevMsg(eDLL_T::MS, " |-- Streaming texture count: '%d'\n", material->m_nStreamableTextureCount);
|
||||
DevMsg(eDLL_T::MS, " |-- Material width: '%d'\n", material->m_iWidth);
|
||||
DevMsg(eDLL_T::MS, " |-- Material height: '%d'\n", material->m_iHeight);
|
||||
DevMsg(eDLL_T::MS, " |-- Flags: '%llX'\n", material->m_iFlags);
|
||||
|
||||
std::function<void(CMaterialGlue*, const char*)> fnPrintChild = [](CMaterialGlue* material, const char* print)
|
||||
@ -810,30 +901,40 @@ void Mat_CrossHair_f(const CCommand& args)
|
||||
DevMsg(eDLL_T::MS, " | |-+ Child material ----------------------------------------\n");
|
||||
DevMsg(eDLL_T::MS, print, material);
|
||||
DevMsg(eDLL_T::MS, " | |-- GUID: '%llX'\n", material->m_GUID);
|
||||
DevMsg(eDLL_T::MS, " | |-- Material Name: '%s'\n", material->m_pszName);
|
||||
DevMsg(eDLL_T::MS, " | |-- Material name: '%s'\n", material->m_pszName);
|
||||
};
|
||||
|
||||
DevMsg(eDLL_T::MS, " |-- Material Name: '%s'\n", material->m_pszName);
|
||||
DevMsg(eDLL_T::MS, " |-- Material Surface Name 1: '%s'\n", material->m_pszSurfaceName1);
|
||||
DevMsg(eDLL_T::MS, " |-- Material Surface Name 2: '%s'\n", material->m_pszSurfaceName2);
|
||||
DevMsg(eDLL_T::MS, " |-- DX Buffer: '%llX'\n", material->m_pDXBuffer);
|
||||
DevMsg(eDLL_T::MS, " |-- DX BufferVTable: '%llX'\n", material->m_pDXBufferVTable);
|
||||
DevMsg(eDLL_T::MS, " |-- Material name: '%s'\n", material->m_pszName);
|
||||
DevMsg(eDLL_T::MS, " |-- Material surface name 1: '%s'\n", material->m_pszSurfaceProp);
|
||||
DevMsg(eDLL_T::MS, " |-- Material surface name 2: '%s'\n", material->m_pszSurfaceProp2);
|
||||
DevMsg(eDLL_T::MS, " |-- DX buffer: '%llX'\n", material->m_pDXBuffer);
|
||||
DevMsg(eDLL_T::MS, " |-- DX buffer VFTable: '%llX'\n", material->m_pID3D11BufferVTable);
|
||||
|
||||
material->m_pDepthShadow ? fnPrintChild(material->m_pDepthShadow, " | |-+ DepthShadow Addr: '%llX'\n") : DevMsg(eDLL_T::MS, " | |-+ DepthShadow Addr: 'NULL'\n");
|
||||
material->m_pDepthPrepass ? fnPrintChild(material->m_pDepthPrepass, " | |-+ DepthPrepass Addr: '%llX'\n") : DevMsg(eDLL_T::MS, " | |-+ DepthPrepass Addr: 'NULL'\n");
|
||||
material->m_pDepthVSM ? fnPrintChild(material->m_pDepthVSM, " | |-+ DepthVSM Addr: '%llX'\n") : DevMsg(eDLL_T::MS, " | |-+ DepthVSM Addr: 'NULL'\n");
|
||||
material->m_pDepthShadow ? fnPrintChild(material->m_pDepthShadow, " | |-+ DepthShadowTight Addr: '%llX'\n") : DevMsg(eDLL_T::MS, " | |-+ DepthShadowTight Addr: 'NULL'\n");
|
||||
material->m_pColPass ? fnPrintChild(material->m_pColPass, " | |-+ ColPass Addr: '%llX'\n") : DevMsg(eDLL_T::MS, " | |-+ ColPass Addr: 'NULL'\n");
|
||||
material->m_pDepthShadow
|
||||
? fnPrintChild(material->m_pDepthShadow, " | |-+ DepthShadow: '%llX'\n")
|
||||
: DevMsg(eDLL_T::MS, " | |-+ DepthShadow: 'NULL'\n");
|
||||
material->m_pDepthPrepass
|
||||
? fnPrintChild(material->m_pDepthPrepass, " | |-+ DepthPrepass: '%llX'\n")
|
||||
: DevMsg(eDLL_T::MS, " | |-+ DepthPrepass: 'NULL'\n");
|
||||
material->m_pDepthVSM
|
||||
? fnPrintChild(material->m_pDepthVSM, " | |-+ DepthVSM: '%llX'\n")
|
||||
: DevMsg(eDLL_T::MS, " | |-+ DepthVSM: 'NULL'\n");
|
||||
material->m_pDepthShadow
|
||||
? fnPrintChild(material->m_pDepthShadow, " | |-+ DepthShadowTight: '%llX'\n")
|
||||
: DevMsg(eDLL_T::MS, " | |-+ DepthShadowTight: 'NULL'\n");
|
||||
material->m_pColPass
|
||||
? fnPrintChild(material->m_pColPass, " | |-+ ColPass: '%llX'\n")
|
||||
: DevMsg(eDLL_T::MS, " | |-+ ColPass: 'NULL'\n");
|
||||
|
||||
DevMsg(eDLL_T::MS, "-+ Texture GUID map ------------------------------------------\n");
|
||||
material->m_pTextureGUID ? DevMsg(eDLL_T::MS, " |-- TextureMap 1 Addr: '%llX'\n", material->m_pTextureGUID) : DevMsg(eDLL_T::MS, " |-- TextureMap 1 Addr: 'NULL'\n");
|
||||
material->m_pStreamableTextures ? DevMsg(eDLL_T::MS, " |-- TextureMap 2 Addr: '%llX'\n", material->m_pStreamableTextures) : DevMsg(eDLL_T::MS, " |-- TextureMap 2 Addr: 'NULL'\n");
|
||||
DevMsg(eDLL_T::MS, " |-- Texture handles: '%llX'\n", material->m_pTextureHandles);
|
||||
DevMsg(eDLL_T::MS, " |-- Streaming texture handles: '%llX'\n", material->m_pStreamableTextureHandles);
|
||||
|
||||
DevMsg(eDLL_T::MS, "--------------------------------------------------------------\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DevMsg(eDLL_T::MS, "%s - No Material found >:(\n", __FUNCTION__);
|
||||
DevMsg(eDLL_T::MS, "%s - No material found >:(\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,13 @@ void VPK_Mount_f(const CCommand& args);
|
||||
void NET_SetKey_f(const CCommand& args);
|
||||
void NET_GenerateKey_f(const CCommand& args);
|
||||
void NET_UseRandomKeyChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue);
|
||||
void CON_Help_f(const CCommand& args);
|
||||
#ifndef DEDICATED
|
||||
void CON_LogHistory_f(const CCommand& args);
|
||||
void CON_RemoveLine_f(const CCommand& args);
|
||||
void CON_ClearLines_f(const CCommand& args);
|
||||
void CON_ClearHistory_f(const CCommand& args);
|
||||
|
||||
void RCON_CmdQuery_f(const CCommand& args);
|
||||
void RCON_Disconnect_f(const CCommand& args);
|
||||
#endif // !DEDICATED
|
||||
|
@ -29,28 +29,24 @@ typedef BOOL(WINAPI* IPostMessageA)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l
|
||||
typedef BOOL(WINAPI* IPostMessageW)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
static BOOL g_bInitMenu = false;
|
||||
static BOOL g_bInitialized = false;
|
||||
static BOOL g_bPresentHooked = false;
|
||||
static BOOL g_bImGuiInitialized = false;
|
||||
static BOOL s_bInitialized = false;
|
||||
static BOOL s_bImGuiInitialized = false;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
static WNDPROC g_oWndProc = NULL;
|
||||
static HWND g_hGameWindow = NULL;
|
||||
extern DWORD g_dThreadId = NULL;
|
||||
static WNDPROC s_oWndProc = NULL;
|
||||
static HWND s_hGameWindow = NULL;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
static IPostMessageA s_oPostMessageA = NULL;
|
||||
static IPostMessageW s_oPostMessageW = NULL;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
static IPostMessageA g_oPostMessageA = NULL;
|
||||
static IPostMessageW g_oPostMessageW = NULL;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
static IDXGIResizeBuffers g_oResizeBuffers = NULL;
|
||||
static IDXGISwapChainPresent g_fnIDXGISwapChainPresent = NULL;
|
||||
static IDXGISwapChain* g_pSwapChain = nullptr;
|
||||
static ID3D11DeviceContext* g_pDeviceContext = nullptr;
|
||||
static ID3D11Device* g_pDevice = nullptr;
|
||||
static ID3D11RenderTargetView* g_pRenderTargetView = nullptr;
|
||||
static ID3D11DepthStencilView* g_pDepthStencilView = nullptr;
|
||||
static IDXGIResizeBuffers s_oResizeBuffers = NULL;
|
||||
static IDXGISwapChainPresent s_fnSwapChainPresent = NULL;
|
||||
static IDXGISwapChain* s_pSwapChain = nullptr;
|
||||
static ID3D11DeviceContext* s_pDeviceContext = nullptr;
|
||||
static ID3D11Device* s_pDevice = nullptr;
|
||||
static ID3D11RenderTargetView* s_pRenderTargetView = nullptr;
|
||||
static ID3D11DepthStencilView* s_pDepthStencilView = nullptr;
|
||||
|
||||
//#################################################################################
|
||||
// WINDOW PROCEDURE
|
||||
@ -67,14 +63,16 @@ LRESULT CALLBACK HwndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
|
||||
{
|
||||
if (wParam == g_pImGuiConfig->IConsole_Config.m_nBind0 || wParam == g_pImGuiConfig->IConsole_Config.m_nBind1)
|
||||
if (wParam == g_pImGuiConfig->m_ConsoleConfig.m_nBind0 || wParam == g_pImGuiConfig->m_ConsoleConfig.m_nBind1)
|
||||
{
|
||||
g_pConsole->m_bActivate ^= true;
|
||||
ResetInput(); // Disable input to game when console is drawn.
|
||||
}
|
||||
|
||||
if (wParam == g_pImGuiConfig->IBrowser_Config.m_nBind0 || wParam == g_pImGuiConfig->IBrowser_Config.m_nBind1)
|
||||
if (wParam == g_pImGuiConfig->m_BrowserConfig.m_nBind0 || wParam == g_pImGuiConfig->m_BrowserConfig.m_nBind1)
|
||||
{
|
||||
g_pBrowser->m_bActivate ^= true;
|
||||
ResetInput(); // Disable input to game when browser is drawn.
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +111,7 @@ LRESULT CALLBACK HwndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
return CallWindowProc(g_oWndProc, hWnd, uMsg, wParam, lParam);
|
||||
return CallWindowProc(s_oWndProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
//#################################################################################
|
||||
@ -127,7 +125,7 @@ BOOL WINAPI HPostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return g_oPostMessageA(hWnd, Msg, wParam, lParam);
|
||||
return s_oPostMessageA(hWnd, Msg, wParam, lParam);
|
||||
}
|
||||
|
||||
BOOL WINAPI HPostMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
@ -137,7 +135,7 @@ BOOL WINAPI HPostMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return g_oPostMessageW(hWnd, Msg, wParam, lParam);
|
||||
return s_oPostMessageW(hWnd, Msg, wParam, lParam);
|
||||
}
|
||||
|
||||
//#################################################################################
|
||||
@ -146,10 +144,10 @@ BOOL WINAPI HPostMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
void GetPresent()
|
||||
{
|
||||
WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, DXGIMsgProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "DX", NULL };
|
||||
WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, DXGIMsgProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "GameSDK001", NULL };
|
||||
RegisterClassExA(&wc);
|
||||
|
||||
HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL);
|
||||
HWND hWnd = CreateWindowA("GameSDK001", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL);
|
||||
DXGI_SWAP_CHAIN_DESC sd = { 0 };
|
||||
D3D_FEATURE_LEVEL nFeatureLevelsSet = D3D_FEATURE_LEVEL_11_0;
|
||||
D3D_FEATURE_LEVEL nFeatureLevelsSupported;
|
||||
@ -173,9 +171,9 @@ void GetPresent()
|
||||
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
g_hGameWindow = sd.OutputWindow;
|
||||
s_hGameWindow = sd.OutputWindow;
|
||||
UINT nFeatureLevelsRequested = 1;
|
||||
HRESULT hr = 0;
|
||||
HRESULT hr = NULL;
|
||||
IDXGISwapChain* pSwapChain = nullptr;
|
||||
ID3D11Device* pDevice = nullptr;
|
||||
ID3D11DeviceContext* pContext = nullptr;
|
||||
@ -203,25 +201,24 @@ void GetPresent()
|
||||
DWORD_PTR* pContextVTable = nullptr;
|
||||
DWORD_PTR* pDeviceVTable = nullptr;
|
||||
|
||||
pSwapChainVtable = (DWORD_PTR*)pSwapChain;
|
||||
pSwapChainVtable = (DWORD_PTR*)pSwapChainVtable[0];
|
||||
pContextVTable = (DWORD_PTR*)pContext;
|
||||
pContextVTable = (DWORD_PTR*)pContextVTable[0];
|
||||
pDeviceVTable = (DWORD_PTR*)pDevice;
|
||||
pDeviceVTable = (DWORD_PTR*)pDeviceVTable[0];
|
||||
pSwapChainVtable = reinterpret_cast<DWORD_PTR*>(pSwapChain);
|
||||
pSwapChainVtable = reinterpret_cast<DWORD_PTR*>(pSwapChainVtable[0]);
|
||||
pContextVTable = reinterpret_cast<DWORD_PTR*>(pContext);
|
||||
pContextVTable = reinterpret_cast<DWORD_PTR*>(pContextVTable[0]);
|
||||
pDeviceVTable = reinterpret_cast<DWORD_PTR*>(pDevice);
|
||||
pDeviceVTable = reinterpret_cast<DWORD_PTR*>(pDeviceVTable[0]);
|
||||
|
||||
int pIDX = (int)DXGISwapChainVTbl::Present;
|
||||
int rIDX = (int)DXGISwapChainVTbl::ResizeBuffers;
|
||||
int pIDX = static_cast<int>(DXGISwapChainVTbl::Present);
|
||||
int rIDX = static_cast<int>(DXGISwapChainVTbl::ResizeBuffers);
|
||||
|
||||
g_fnIDXGISwapChainPresent = (IDXGISwapChainPresent)(DWORD_PTR)pSwapChainVtable[pIDX];
|
||||
g_oResizeBuffers = (IDXGIResizeBuffers)(DWORD_PTR)pSwapChainVtable[rIDX];
|
||||
s_fnSwapChainPresent = reinterpret_cast<IDXGISwapChainPresent>(pSwapChainVtable[pIDX]);
|
||||
s_oResizeBuffers = reinterpret_cast<IDXGIResizeBuffers>(pSwapChainVtable[rIDX]);
|
||||
|
||||
pSwapChain->Release();
|
||||
pContext->Release();
|
||||
pDevice->Release();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
g_bPresentHooked = true;
|
||||
}
|
||||
|
||||
//#################################################################################
|
||||
@ -233,15 +230,15 @@ void SetupImGui()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGui_ImplWin32_Init(g_hGameWindow);
|
||||
ImGui_ImplDX11_Init(g_pDevice, g_pDeviceContext);
|
||||
ImGui::GetIO().ImeWindowHandle = g_hGameWindow;
|
||||
ImGui_ImplWin32_Init(s_hGameWindow);
|
||||
ImGui_ImplDX11_Init(s_pDevice, s_pDeviceContext);
|
||||
ImGui::GetIO().ImeWindowHandle = s_hGameWindow;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_IsSRGB;
|
||||
|
||||
g_bImGuiInitialized = true;
|
||||
s_bImGuiInitialized = true;
|
||||
}
|
||||
|
||||
void DrawImGui()
|
||||
@ -254,25 +251,13 @@ void DrawImGui()
|
||||
g_pBrowser->RunTask();
|
||||
g_pConsole->RunTask();
|
||||
|
||||
if (g_pBrowser->m_bActivate)
|
||||
{
|
||||
g_pInputSystem->EnableInput(false); // Disable input to game when browser is drawn.
|
||||
g_pBrowser->RunFrame();
|
||||
}
|
||||
if (g_pConsole->m_bActivate)
|
||||
{
|
||||
g_pInputSystem->EnableInput(false); // Disable input to game when console is drawn.
|
||||
g_pConsole->RunFrame();
|
||||
}
|
||||
if (!g_pConsole->m_bActivate && !g_pBrowser->m_bActivate)
|
||||
{
|
||||
g_pInputSystem->EnableInput(true); // Enable input to game when both are not drawn.
|
||||
}
|
||||
g_pBrowser->RunFrame();
|
||||
g_pConsole->RunFrame();
|
||||
|
||||
ImGui::EndFrame();
|
||||
ImGui::Render();
|
||||
|
||||
g_pDeviceContext->OMSetRenderTargets(1, &g_pRenderTargetView, NULL);
|
||||
s_pDeviceContext->OMSetRenderTargets(1, &s_pRenderTargetView, NULL);
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
@ -287,23 +272,26 @@ void CreateRenderTarget(IDXGISwapChain* pSwapChain)
|
||||
pSwapChain->GetDesc(&sd);
|
||||
ZeroMemory(&rd, sizeof(rd));
|
||||
|
||||
g_hGameWindow = sd.OutputWindow;
|
||||
s_hGameWindow = sd.OutputWindow;
|
||||
rd.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
rd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
|
||||
if (pBackBuffer != NULL) { g_pDevice->CreateRenderTargetView(pBackBuffer, &rd, &g_pRenderTargetView); }
|
||||
g_pDeviceContext->OMSetRenderTargets(1, &g_pRenderTargetView, NULL);
|
||||
pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(&pBackBuffer));
|
||||
if (pBackBuffer)
|
||||
{
|
||||
s_pDevice->CreateRenderTargetView(pBackBuffer, &rd, &s_pRenderTargetView);
|
||||
}
|
||||
|
||||
s_pDeviceContext->OMSetRenderTargets(1, &s_pRenderTargetView, NULL);
|
||||
pBackBuffer->Release();
|
||||
}
|
||||
|
||||
void CreateViewPort( UINT nWidth, UINT nHeight)
|
||||
void CreateViewPort(UINT nWidth, UINT nHeight)
|
||||
{
|
||||
float width = *(float*)(&nWidth);
|
||||
float height = *(float*)(&nHeight);
|
||||
|
||||
D3D11_VIEWPORT vp{};
|
||||
FLOAT width = *reinterpret_cast<FLOAT*>(&nWidth);
|
||||
FLOAT height = *reinterpret_cast<FLOAT*>(&nHeight);
|
||||
D3D11_VIEWPORT vp;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
vp.Width = width;
|
||||
@ -314,16 +302,16 @@ void CreateViewPort( UINT nWidth, UINT nHeight)
|
||||
vp.TopLeftY = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
g_pDeviceContext->RSSetViewports(1, &vp);
|
||||
s_pDeviceContext->RSSetViewports(1, &vp);
|
||||
}
|
||||
|
||||
void DestroyRenderTarget()
|
||||
{
|
||||
if (g_pRenderTargetView != nullptr)
|
||||
if (s_pRenderTargetView)
|
||||
{
|
||||
g_pRenderTargetView->Release();
|
||||
g_pRenderTargetView = nullptr;
|
||||
g_pDeviceContext->OMSetRenderTargets(0, 0, 0);
|
||||
s_pRenderTargetView->Release();
|
||||
s_pRenderTargetView = nullptr;
|
||||
s_pDeviceContext->OMSetRenderTargets(0, 0, 0);
|
||||
|
||||
if (mat_showdxoutput->GetBool())
|
||||
{
|
||||
@ -340,7 +328,7 @@ void DestroyRenderTarget()
|
||||
|
||||
HRESULT GetDeviceAndCtxFromSwapchain(IDXGISwapChain* pSwapChain, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext)
|
||||
{
|
||||
HRESULT ret = pSwapChain->GetDevice(__uuidof(ID3D11Device), (PVOID*)ppDevice);
|
||||
HRESULT ret = pSwapChain->GetDevice(__uuidof(ID3D11Device), reinterpret_cast<PVOID*>(ppDevice));
|
||||
if (SUCCEEDED(ret))
|
||||
{
|
||||
(*ppDevice)->GetImmediateContext(ppContext);
|
||||
@ -352,8 +340,7 @@ HRESULT __stdcall GetResizeBuffers(IDXGISwapChain* pSwapChain, UINT nBufferCount
|
||||
{
|
||||
g_pConsole->m_bActivate = false;
|
||||
g_pBrowser->m_bActivate = false;
|
||||
g_bInitialized = false;
|
||||
g_bPresentHooked = false;
|
||||
s_bInitialized = false;
|
||||
|
||||
g_nWindowWidth = nWidth;
|
||||
g_nWindowHeight = nHeight;
|
||||
@ -362,36 +349,36 @@ HRESULT __stdcall GetResizeBuffers(IDXGISwapChain* pSwapChain, UINT nBufferCount
|
||||
DestroyRenderTarget();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
return g_oResizeBuffers(pSwapChain, nBufferCount, nWidth, nHeight, dxFormat, nSwapChainFlags);
|
||||
return s_oResizeBuffers(pSwapChain, nBufferCount, nWidth, nHeight, dxFormat, nSwapChainFlags);
|
||||
}
|
||||
|
||||
HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT nFlags)
|
||||
{
|
||||
if (!g_bInitialized)
|
||||
if (!s_bInitialized)
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
if (FAILED(hr = GetDeviceAndCtxFromSwapchain(pSwapChain, &g_pDevice, &g_pDeviceContext)))
|
||||
HRESULT hr;
|
||||
if (FAILED(hr = GetDeviceAndCtxFromSwapchain(pSwapChain, &s_pDevice, &s_pDeviceContext)))
|
||||
{
|
||||
Error(eDLL_T::MS, EXIT_FAILURE, "Failed to get device and context from swap chain: error code = %08x\n", hr);
|
||||
return g_fnIDXGISwapChainPresent(pSwapChain, nSyncInterval, nFlags);
|
||||
return s_fnSwapChainPresent(pSwapChain, nSyncInterval, nFlags);
|
||||
}
|
||||
|
||||
CreateRenderTarget(pSwapChain);
|
||||
|
||||
if (!g_oWndProc)
|
||||
{ // Only initialize HwndProc pointer once to avoid stack overflow during ResizeBuffers(..)
|
||||
SetupImGui(); // Don't re-init imgui every time.
|
||||
g_oWndProc = (WNDPROC)SetWindowLongPtr(g_hGameWindow, GWLP_WNDPROC, (LONG_PTR)HwndProc);
|
||||
if (!s_oWndProc) // Only initialize HwndProc pointer once to avoid stack overflow during ResizeBuffers(..)
|
||||
{
|
||||
SetupImGui();
|
||||
s_oWndProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(s_hGameWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(HwndProc)));
|
||||
}
|
||||
|
||||
g_pSwapChain = pSwapChain;
|
||||
s_pSwapChain = pSwapChain;
|
||||
g_ThreadRenderThreadID = GetCurrentThreadId();
|
||||
g_bInitialized = true;
|
||||
s_bInitialized = true;
|
||||
}
|
||||
|
||||
DrawImGui();
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
return g_fnIDXGISwapChainPresent(pSwapChain, nSyncInterval, nFlags);
|
||||
return s_fnSwapChainPresent(pSwapChain, nSyncInterval, nFlags);
|
||||
}
|
||||
|
||||
bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView** out_srv, int* out_width, int* out_height)
|
||||
@ -401,16 +388,16 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
int image_height = 0;
|
||||
unsigned char* image_data = stbi_load_from_memory(buffer, len, &image_width, &image_height, NULL, 4);
|
||||
|
||||
if (image_data == NULL)
|
||||
if (!image_data)
|
||||
{
|
||||
assert(image_data == NULL);
|
||||
assert(image_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
ID3D11Texture2D* pTexture = NULL;
|
||||
ID3D11Texture2D* pTexture = nullptr;
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
D3D11_SUBRESOURCE_DATA subResource{};
|
||||
D3D11_SUBRESOURCE_DATA subResource;
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -429,7 +416,7 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
subResource.pSysMem = image_data;
|
||||
subResource.SysMemPitch = desc.Width * 4;
|
||||
subResource.SysMemSlicePitch = 0;
|
||||
g_pDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
s_pDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
|
||||
// Create texture view
|
||||
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
||||
@ -440,7 +427,7 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
|
||||
if (pTexture)
|
||||
{
|
||||
g_pDevice->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
|
||||
s_pDevice->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
|
||||
pTexture->Release();
|
||||
}
|
||||
|
||||
@ -451,6 +438,12 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResetInput()
|
||||
{
|
||||
g_pInputSystem->EnableInput( // Enables the input system when both are not drawn.
|
||||
!g_pBrowser->m_bActivate && !g_pConsole->m_bActivate);
|
||||
}
|
||||
|
||||
//#################################################################################
|
||||
// MANAGEMENT
|
||||
//#################################################################################
|
||||
@ -458,20 +451,20 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
void InstallDXHooks()
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
g_oPostMessageA = (IPostMessageA)DetourFindFunction("user32.dll", "PostMessageA");
|
||||
g_oPostMessageW = (IPostMessageW)DetourFindFunction("user32.dll", "PostMessageW");
|
||||
s_oPostMessageA = (IPostMessageA)DetourFindFunction("user32.dll", "PostMessageA");
|
||||
s_oPostMessageW = (IPostMessageW)DetourFindFunction("user32.dll", "PostMessageW");
|
||||
|
||||
// Begin the detour transaction
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
// Hook PostMessage
|
||||
DetourAttach(&(LPVOID&)g_oPostMessageA, (PBYTE)HPostMessageA);
|
||||
DetourAttach(&(LPVOID&)g_oPostMessageW, (PBYTE)HPostMessageW);
|
||||
DetourAttach(&(LPVOID&)s_oPostMessageA, (PBYTE)HPostMessageA);
|
||||
DetourAttach(&(LPVOID&)s_oPostMessageW, (PBYTE)HPostMessageW);
|
||||
|
||||
// Hook SwapChain
|
||||
DetourAttach(&(LPVOID&)g_fnIDXGISwapChainPresent, (PBYTE)Present);
|
||||
DetourAttach(&(LPVOID&)g_oResizeBuffers, (PBYTE)GetResizeBuffers);
|
||||
DetourAttach(&(LPVOID&)s_fnSwapChainPresent, (PBYTE)Present);
|
||||
DetourAttach(&(LPVOID&)s_oResizeBuffers, (PBYTE)GetResizeBuffers);
|
||||
|
||||
// Commit the transaction
|
||||
HRESULT hr = DetourTransactionCommit();
|
||||
@ -489,35 +482,35 @@ void DirectX_Shutdown()
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
// Unhook PostMessage
|
||||
DetourDetach(&(LPVOID&)g_oPostMessageA, (PBYTE)HPostMessageA);
|
||||
DetourDetach(&(LPVOID&)g_oPostMessageW, (PBYTE)HPostMessageW);
|
||||
DetourDetach(&(LPVOID&)s_oPostMessageA, (PBYTE)HPostMessageA);
|
||||
DetourDetach(&(LPVOID&)s_oPostMessageW, (PBYTE)HPostMessageW);
|
||||
|
||||
// Unhook SwapChain
|
||||
DetourDetach(&(LPVOID&)g_fnIDXGISwapChainPresent, (PBYTE)Present);
|
||||
DetourDetach(&(LPVOID&)g_oResizeBuffers, (PBYTE)GetResizeBuffers);
|
||||
DetourDetach(&(LPVOID&)s_fnSwapChainPresent, (PBYTE)Present);
|
||||
DetourDetach(&(LPVOID&)s_oResizeBuffers, (PBYTE)GetResizeBuffers);
|
||||
|
||||
// Commit the transaction
|
||||
DetourTransactionCommit();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Shutdown ImGui
|
||||
if (g_bImGuiInitialized)
|
||||
if (s_bImGuiInitialized)
|
||||
{
|
||||
ImGui_ImplWin32_Shutdown();
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
g_bImGuiInitialized = false;
|
||||
s_bImGuiInitialized = false;
|
||||
}
|
||||
g_bInitialized = false;
|
||||
s_bInitialized = false;
|
||||
}
|
||||
|
||||
void VDXGI::GetAdr(void) const
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
spdlog::debug("| FUN: IDXGISwapChain::Present : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_fnIDXGISwapChainPresent));
|
||||
spdlog::debug("| VAR: g_pSwapChain : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pSwapChain) );
|
||||
spdlog::debug("| VAR: g_pRenderTargetView : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pRenderTargetView) );
|
||||
spdlog::debug("| VAR: g_pDeviceContext : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDeviceContext) );
|
||||
spdlog::debug("| VAR: g_pDevice : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDevice) );
|
||||
spdlog::debug("| FUN: IDXGISwapChain::Present : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_fnSwapChainPresent));
|
||||
spdlog::debug("| VAR: s_pSwapChain : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_pSwapChain) );
|
||||
spdlog::debug("| VAR: s_pRenderTargetView : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_pRenderTargetView) );
|
||||
spdlog::debug("| VAR: s_pDeviceContext : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_pDeviceContext) );
|
||||
spdlog::debug("| VAR: s_pDevice : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_pDevice) );
|
||||
spdlog::debug("| VAR: g_ppGameDevice : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_ppGameDevice) );
|
||||
spdlog::debug("+----------------------------------------------------------------+\n");
|
||||
}
|
||||
@ -531,15 +524,14 @@ DWORD __stdcall DXSwapChainWorker(LPVOID)
|
||||
g_pImGuiConfig->Load(); // Load ImGui configs.
|
||||
GetPresent();
|
||||
InstallDXHooks();
|
||||
return true;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void DirectX_Init()
|
||||
{
|
||||
// Create a worker thread for the in-game console frontend
|
||||
DWORD __stdcall DXSwapChainWorker(LPVOID);
|
||||
HANDLE hThread = CreateThread(NULL, 0, DXSwapChainWorker, NULL, 0, &g_dThreadId);
|
||||
|
||||
HANDLE hThread = CreateThread(NULL, 0, DXSwapChainWorker, NULL, 0, NULL);
|
||||
if (hThread)
|
||||
{
|
||||
CloseHandle(hThread);
|
||||
|
@ -19,6 +19,7 @@ extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam
|
||||
extern HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT nFlags);
|
||||
//extern bool LoadTextureBuffer(unsigned char* image_data, const int& image_width, const int& image_height, ID3D11ShaderResourceView** out_srv);
|
||||
extern bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView** out_srv, int* out_width, int* out_height);
|
||||
extern void ResetInput();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Typedefs
|
||||
@ -27,9 +28,8 @@ typedef HRESULT(__stdcall* IDXGIResizeBuffers) (IDXGISwapChain* pSwapChain, UI
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Globals
|
||||
extern DWORD g_dThreadId;
|
||||
inline INT g_nWindowWidth;
|
||||
inline INT g_nWindowHeight;
|
||||
inline UINT g_nWindowWidth;
|
||||
inline UINT g_nWindowHeight;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
|
Loading…
x
Reference in New Issue
Block a user