Merge branch 'develop' into insanely-fast-crit-sections
This commit is contained in:
commit
29a929eee0
2
deps/pdcurses
vendored
2
deps/pdcurses
vendored
@ -1 +1 @@
|
||||
Subproject commit f1cd4f4569451a5028ddf3d3c202f0ad6b1ae446
|
||||
Subproject commit 2fa0f10dd844da47ee83c05a40a1ec541ceb95e1
|
2
deps/zlib
vendored
2
deps/zlib
vendored
@ -1 +1 @@
|
||||
Subproject commit c3f3043f7aa80750245f8166a338c4877020b589
|
||||
Subproject commit 2014a993addbc8f1b9785d97f55fd189792c2f78
|
@ -6,6 +6,8 @@ namespace Components
|
||||
|
||||
bool Bans::IsBanned(Bans::Entry entry)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _(Bans::AccessMutex);
|
||||
|
||||
Bans::BanList list;
|
||||
Bans::LoadBans(&list);
|
||||
|
||||
|
@ -18,14 +18,14 @@ namespace Components
|
||||
return result;
|
||||
}
|
||||
|
||||
char* Command::Params::operator[](size_t index)
|
||||
const char* Command::Params::operator[](size_t index)
|
||||
{
|
||||
return this->get(index);
|
||||
}
|
||||
|
||||
char* Command::ClientParams::get(size_t index)
|
||||
const char* Command::ClientParams::get(size_t index)
|
||||
{
|
||||
if (index >= this->length()) return const_cast<char*>("");
|
||||
if (index >= this->length()) return "";
|
||||
return Game::cmd_argv[this->commandId][index];
|
||||
}
|
||||
|
||||
@ -34,9 +34,9 @@ namespace Components
|
||||
return Game::cmd_argc[this->commandId];
|
||||
}
|
||||
|
||||
char* Command::ServerParams::get(size_t index)
|
||||
const char* Command::ServerParams::get(size_t index)
|
||||
{
|
||||
if (index >= this->length()) return const_cast<char*>("");
|
||||
if (index >= this->length()) return "";
|
||||
return Game::cmd_argv_sv[this->commandId][index];
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,11 @@ namespace Components
|
||||
public:
|
||||
Params() {};
|
||||
virtual ~Params() {};
|
||||
virtual char* get(size_t index) = 0;
|
||||
virtual const char* get(size_t index) = 0;
|
||||
virtual size_t length() = 0;
|
||||
|
||||
virtual std::string join(size_t startIndex);
|
||||
virtual char* operator[](size_t index);
|
||||
virtual const char* operator[](size_t index);
|
||||
};
|
||||
|
||||
class ClientParams : public Params
|
||||
@ -24,7 +24,7 @@ namespace Components
|
||||
ClientParams(const ClientParams &obj) : commandId(obj.commandId) {};
|
||||
ClientParams() : ClientParams(*Game::cmd_id) {};
|
||||
|
||||
char* get(size_t index) override;
|
||||
const char* get(size_t index) override;
|
||||
size_t length() override;
|
||||
|
||||
private:
|
||||
@ -38,7 +38,7 @@ namespace Components
|
||||
ServerParams(const ServerParams &obj) : commandId(obj.commandId) {};
|
||||
ServerParams() : ServerParams(*Game::cmd_id_sv) {};
|
||||
|
||||
char* get(size_t index) override;
|
||||
const char* get(size_t index) override;
|
||||
size_t length() override;
|
||||
|
||||
private:
|
||||
|
@ -22,24 +22,24 @@ namespace Components
|
||||
return this->dvar;
|
||||
}
|
||||
|
||||
template <> char* Dvar::Var::get()
|
||||
{
|
||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING && this->dvar->current.string)
|
||||
{
|
||||
return const_cast<char*>(this->dvar->current.string);
|
||||
}
|
||||
|
||||
return const_cast<char*>("");
|
||||
}
|
||||
|
||||
template <> const char* Dvar::Var::get()
|
||||
{
|
||||
return this->get<char*>();
|
||||
if (this->dvar == nullptr)
|
||||
return "";
|
||||
|
||||
if (this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING
|
||||
|| this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM)
|
||||
{
|
||||
if (this->dvar->current.string != nullptr)
|
||||
return this->dvar->current.string;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
template <> int Dvar::Var::get()
|
||||
{
|
||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT)
|
||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT || this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM)
|
||||
{
|
||||
return this->dvar->current.integer;
|
||||
}
|
||||
@ -209,7 +209,7 @@ namespace Components
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
static std::string lastValidName = "Unknown Soldier";
|
||||
std::string name = Dvar::Var("name").get<char*>();
|
||||
std::string name = Dvar::Var("name").get<const char*>();
|
||||
|
||||
// Don't perform any checks if name didn't change
|
||||
if (name == lastValidName) return;
|
||||
|
@ -2,38 +2,96 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Game::dvar_t* Elevators::SV_DisableElevators;
|
||||
Dvar::Var Elevators::BG_Elevators;
|
||||
|
||||
__declspec(naked) void Elevators::PM_GroundTraceStub()
|
||||
int Elevators::PM_CorrectAllSolid(Game::pmove_s* pm, Game::pml_t* pml, Game::trace_t* trace)
|
||||
{
|
||||
assert(pm != nullptr);
|
||||
assert(pm->ps != nullptr);
|
||||
|
||||
Game::vec3_t point;
|
||||
auto* ps = pm->ps;
|
||||
|
||||
auto i = 0;
|
||||
const auto elevatorSetting = Elevators::BG_Elevators.get<int>();
|
||||
while (true)
|
||||
{
|
||||
point[0] = ps->origin[0] + Game::CorrectSolidDeltas[i][0];
|
||||
point[1] = ps->origin[1] + Game::CorrectSolidDeltas[i][1];
|
||||
point[2] = ps->origin[2] + Game::CorrectSolidDeltas[i][2];
|
||||
|
||||
Game::PM_playerTrace(pm, trace, point, point, &pm->bounds, ps->clientNum, pm->tracemask);
|
||||
|
||||
// If the player wishes to glitch without effort they can do so
|
||||
if (!trace->startsolid || elevatorSetting == Elevators::EASY)
|
||||
{
|
||||
ps->origin[0] = point[0];
|
||||
ps->origin[1] = point[1];
|
||||
ps->origin[2] = point[2];
|
||||
point[2] = (ps->origin[2] - 1.0f) - 0.25f;
|
||||
|
||||
Game::PM_playerTrace(pm, trace, ps->origin, point, &pm->bounds, ps->clientNum, pm->tracemask);
|
||||
|
||||
// If elevators are disabled we need to check that startsolid is false before proceeding
|
||||
// like later versions of the game do
|
||||
if (!trace->startsolid || elevatorSetting >= Elevators::ENABLED)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i += 1;
|
||||
if (i >= 26)
|
||||
{
|
||||
ps->groundEntityNum = Game::ENTITYNUM_NONE;
|
||||
pml->groundPlane = 0;
|
||||
pml->almostGroundPlane = 0;
|
||||
pml->walking = 0;
|
||||
Game::Jump_ClearState(ps);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
pml->groundTrace = *trace;
|
||||
|
||||
const auto fraction = trace->fraction;
|
||||
ps->origin[0] += fraction * (point[0] - ps->origin[0]);
|
||||
ps->origin[1] += fraction * (point[1] - ps->origin[1]);
|
||||
ps->origin[2] += fraction * (point[2] - ps->origin[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Elevators::PM_Trace_Hk(Game::pmove_s* pm, Game::trace_t* trace, const float* f3,
|
||||
const float* f4, const Game::Bounds* bounds, int a6, int a7)
|
||||
{
|
||||
Game::PM_Trace(pm, trace, f3, f4, bounds, a6, a7);
|
||||
|
||||
// Allow the player to stand even when there is no headroom
|
||||
if (Elevators::BG_Elevators.get<int>() == Elevators::EASY)
|
||||
{
|
||||
trace->allsolid = false;
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void Elevators::PM_CorrectAllSolidStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push eax
|
||||
mov eax, Elevators::SV_DisableElevators
|
||||
cmp byte ptr [eax + 16], 1
|
||||
pushad
|
||||
|
||||
push [esp + 0x8 + 0x24]
|
||||
push [esp + 0x8 + 0x24]
|
||||
push eax
|
||||
call Elevators::PM_CorrectAllSolid
|
||||
add esp, 0xC
|
||||
|
||||
mov [esp + 0x20], eax
|
||||
popad
|
||||
pop eax
|
||||
|
||||
// Always skip PM_CorrectAllSolid if SV_DisableElevators is set to 1
|
||||
je noElevators
|
||||
|
||||
// Original code
|
||||
cmp byte ptr [esp + 0x50], 0
|
||||
rep movsd
|
||||
mov esi, [esp + 0x58]
|
||||
|
||||
// Original code flow
|
||||
push 0x573694
|
||||
retn
|
||||
|
||||
noElevators:
|
||||
|
||||
// Original code
|
||||
rep movsd
|
||||
mov esi, [esp + 0x58]
|
||||
|
||||
// Jump over call to PM_CorrectAllSolid
|
||||
push 0x5736AE
|
||||
retn
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,12 +99,26 @@ namespace Components
|
||||
{
|
||||
Dvar::OnInit([]
|
||||
{
|
||||
Elevators::SV_DisableElevators = Game::Dvar_RegisterBool("sv_disableElevators",
|
||||
false, Game::DVAR_FLAG_REPLICATED, "Disable elevators");
|
||||
static const char* values[] =
|
||||
{
|
||||
"off",
|
||||
"normal",
|
||||
"easy",
|
||||
nullptr
|
||||
};
|
||||
|
||||
Elevators::BG_Elevators = Game::Dvar_RegisterEnum("bg_elevators", values,
|
||||
Elevators::ENABLED, Game::DVAR_FLAG_REPLICATED, "Elevators glitch settings");
|
||||
});
|
||||
|
||||
// Hook PM_GroundTrace so me way skip PM_CorrectAllSolid (disable elevators)
|
||||
Utils::Hook(0x573689, Elevators::PM_GroundTraceStub, HOOK_JUMP).install()->quick();
|
||||
//Replace PM_CorrectAllSolid
|
||||
Utils::Hook(0x57369E, Elevators::PM_CorrectAllSolidStub, HOOK_CALL).install()->quick();
|
||||
|
||||
// Place hooks in PM_CheckDuck. If the elevators dvar is set to easy the
|
||||
// flags for duck/prone will always be removed from the player state
|
||||
Utils::Hook(0x570EC5, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x570E0B, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x570D70, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick();
|
||||
}
|
||||
|
||||
Elevators::~Elevators()
|
||||
|
@ -9,8 +9,11 @@ namespace Components
|
||||
~Elevators();
|
||||
|
||||
private:
|
||||
static Game::dvar_t* SV_DisableElevators;
|
||||
enum ElevatorSettings { DISABLED, ENABLED, EASY };
|
||||
static Dvar::Var BG_Elevators;
|
||||
|
||||
static void PM_GroundTraceStub();
|
||||
static int PM_CorrectAllSolid(Game::pmove_s* move, Game::pml_t* pml, Game::trace_t* trace);
|
||||
static void PM_CorrectAllSolidStub();
|
||||
static void PM_Trace_Hk(Game::pmove_s*, Game::trace_t*, const float*, const float*, const Game::Bounds*, int, int);
|
||||
};
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ namespace Components
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
||||
|
||||
const unsigned int modId = *reinterpret_cast<unsigned int*>(const_cast<char*>("IW4x")) | 0x80000000;
|
||||
const unsigned int modId = *reinterpret_cast<unsigned int*>("IW4x") | 0x80000000;
|
||||
|
||||
// Split up the list
|
||||
for (auto entry : Friends::FriendsList)
|
||||
|
@ -536,14 +536,13 @@ namespace Components
|
||||
if (weaponDef->requireLockonToFire)
|
||||
return false;
|
||||
|
||||
if (ps->linkFlags & 4)
|
||||
if (ps->linkFlags & Game::PLF_WEAPONVIEW_ONLY)
|
||||
return false;
|
||||
|
||||
if (ps->weaponState >= Game::WEAPON_STUNNED_START && ps->weaponState <= Game::WEAPON_STUNNED_END)
|
||||
return false;
|
||||
|
||||
// The game checks for these flags. Their meaning is to be researched if necessary.
|
||||
if (ps->eFlags & 0x100C00)
|
||||
if (ps->eFlags & (Game::EF_VEHICLE_ACTIVE | Game::EF_TURRET_ACTIVE_DUCK | Game::EF_TURRET_ACTIVE_PRONE))
|
||||
return false;
|
||||
|
||||
if (!ps->hasAmmo)
|
||||
|
@ -21,7 +21,7 @@ namespace Components
|
||||
|
||||
Dvar::Var("xblive_privateserver").set(false);
|
||||
|
||||
std::string playlistFilename = Dvar::Var("playlistFilename").get<char*>();
|
||||
std::string playlistFilename = Dvar::Var("playlistFilename").get<const char*>();
|
||||
FileSystem::File playlist(playlistFilename);
|
||||
|
||||
if (playlist.exists())
|
||||
|
@ -964,204 +964,6 @@ namespace Components
|
||||
}
|
||||
});
|
||||
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized() || !Dvar::Var("r_drawAabbTrees").get<bool>()) return;
|
||||
|
||||
float cyan[4] = { 0.0f, 0.5f, 0.5f, 1.0f };
|
||||
float red[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
Game::clipMap_t* clipMap = *reinterpret_cast<Game::clipMap_t**>(0x7998E0);
|
||||
//Game::GfxWorld* gameWorld = *reinterpret_cast<Game::GfxWorld**>(0x66DEE94);
|
||||
if (!clipMap) return;
|
||||
|
||||
for (unsigned short i = 0; i < clipMap->smodelNodeCount; ++i)
|
||||
{
|
||||
Game::R_AddDebugBounds(cyan, &clipMap->smodelNodes[i].bounds);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < clipMap->numStaticModels; i += 2)
|
||||
{
|
||||
Game::R_AddDebugBounds(red, &clipMap->staticModelList[i].absBounds);
|
||||
}
|
||||
});
|
||||
|
||||
Dvar::OnInit([]
|
||||
{
|
||||
Dvar::Register<bool>("r_drawSceneModelBoundingBoxes", false, Game::DVAR_FLAG_CHEAT, "Draw scene model bounding boxes");
|
||||
Dvar::Register<bool>("r_drawSceneModelCollisions", false, Game::DVAR_FLAG_CHEAT, "Draw scene model collisions");
|
||||
Dvar::Register<bool>("r_drawTriggers", false, Game::DVAR_FLAG_CHEAT, "Draw triggers");
|
||||
Dvar::Register<bool>("r_drawModelNames", false, Game::DVAR_FLAG_CHEAT, "Draw all model names");
|
||||
Dvar::Register<bool>("r_drawAabbTrees", false, Game::DVAR_FLAG_USERCREATED, "Draw aabb trees");
|
||||
});
|
||||
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized() || !Dvar::Var("r_drawModelNames").get<bool>()) return;
|
||||
|
||||
float sceneModelsColor[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
float dobjsColor[4] = { 0.0f, 1.0f, 1.0f, 1.0f };
|
||||
float staticModelsColor[4] = { 1.0f, 0.0f, 1.0f, 1.0f };
|
||||
|
||||
auto mapName = Dvar::Var("mapname").get<const char*>();
|
||||
auto* scene = Game::scene;
|
||||
auto world = Game::DB_FindXAssetEntry(Game::XAssetType::ASSET_TYPE_GFXWORLD, Utils::String::VA("maps/mp/%s.d3dbsp", mapName))->asset.header.gfxWorld;
|
||||
|
||||
for (auto i = 0; i < scene->sceneModelCount; i++)
|
||||
{
|
||||
if (!scene->sceneModel[i].model)
|
||||
continue;
|
||||
|
||||
Game::R_AddDebugString(sceneModelsColor, scene->sceneModel[i].placement.base.origin, 1.0, scene->sceneModel[i].model->name);
|
||||
}
|
||||
|
||||
for (auto i = 0; i < scene->sceneDObjCount; i++)
|
||||
{
|
||||
if (scene->sceneDObj[i].obj) {
|
||||
for (int j = 0; j < scene->sceneDObj[i].obj->numModels; j++)
|
||||
{
|
||||
Game::R_AddDebugString(dobjsColor, scene->sceneDObj[i].placement.origin, 1.0, scene->sceneDObj[i].obj->models[j]->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Static models
|
||||
for (size_t i = 0; i < world->dpvs.smodelCount; i++)
|
||||
{
|
||||
auto staticModel = world->dpvs.smodelDrawInsts[i];
|
||||
if (staticModel.model) {
|
||||
Game::R_AddDebugString(staticModelsColor, staticModel.placement.origin, 1.0, staticModel.model->name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized() || !Dvar::Var("r_drawSceneModelBoundingBoxes").get<bool>()) return;
|
||||
|
||||
float red[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
float blue[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||
|
||||
auto* scene = Game::scene;
|
||||
|
||||
for(auto i = 0; i < scene->sceneModelCount; i++)
|
||||
{
|
||||
if(!scene->sceneModel[i].model)
|
||||
continue;
|
||||
|
||||
auto b = scene->sceneModel[i].model->bounds;
|
||||
b.midPoint[0] += scene->sceneModel[i].placement.base.origin[0];
|
||||
b.midPoint[1] += scene->sceneModel[i].placement.base.origin[1];
|
||||
b.midPoint[2] += scene->sceneModel[i].placement.base.origin[2];
|
||||
b.halfSize[0] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[1] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[2] *= scene->sceneModel[i].placement.scale;
|
||||
Game::R_AddDebugBounds(red, &b, &scene->sceneModel[i].placement.base.quat);
|
||||
}
|
||||
|
||||
for(auto i = 0; i < scene->sceneDObjCount; i++)
|
||||
{
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[0] = std::abs(scene->sceneDObj[i].cull.bounds.halfSize[0]);
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[1] = std::abs(scene->sceneDObj[i].cull.bounds.halfSize[1]);
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[2] = std::abs(scene->sceneDObj[i].cull.bounds.halfSize[2]);
|
||||
|
||||
if (scene->sceneDObj[i].cull.bounds.halfSize[0] < 0 ||
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[1] < 0 ||
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[2] < 0) {
|
||||
|
||||
Components::Logger::Print("WARNING: Negative half size for DOBJ %s, this will cause culling issues!", scene->sceneDObj[i].obj->models[0]->name);
|
||||
}
|
||||
|
||||
Game::R_AddDebugBounds(blue, &scene->sceneDObj[i].cull.bounds);
|
||||
}
|
||||
});
|
||||
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized()) return;
|
||||
if (!Dvar::Var("r_drawSceneModelCollisions").get<bool>()) return;
|
||||
|
||||
float green[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
auto* scene = Game::scene;
|
||||
|
||||
for (auto i = 0; i < scene->sceneModelCount; i++)
|
||||
{
|
||||
if (!scene->sceneModel[i].model)
|
||||
continue;
|
||||
|
||||
for (auto j = 0; j < scene->sceneModel[i].model->numCollSurfs; j++) {
|
||||
auto b = scene->sceneModel[i].model->collSurfs[j].bounds;
|
||||
b.midPoint[0] += scene->sceneModel[i].placement.base.origin[0];
|
||||
b.midPoint[1] += scene->sceneModel[i].placement.base.origin[1];
|
||||
b.midPoint[2] += scene->sceneModel[i].placement.base.origin[2];
|
||||
b.halfSize[0] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[1] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[2] *= scene->sceneModel[i].placement.scale;
|
||||
|
||||
Game::R_AddDebugBounds(green, &b, &scene->sceneModel[i].placement.base.quat);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized() || !Dvar::Var("r_drawTriggers").get<bool>()) return;
|
||||
|
||||
float hurt[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
float hurtTouch[4] = { 0.75f, 0.0f, 0.0f, 1.0f };
|
||||
float damage[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||
float once[4] = { 0.0f, 1.0f, 1.0f, 1.0f };
|
||||
float multiple[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
auto* entities = Game::g_entities;
|
||||
for(auto i = 0u; i < 0x800; i++)
|
||||
{
|
||||
auto* ent = &entities[i];
|
||||
|
||||
if(ent->r.isInUse)
|
||||
{
|
||||
Game::Bounds b = ent->r.box;
|
||||
b.midPoint[0] += ent->r.currentOrigin[0];
|
||||
b.midPoint[1] += ent->r.currentOrigin[1];
|
||||
b.midPoint[2] += ent->r.currentOrigin[2];
|
||||
|
||||
switch(ent->handler)
|
||||
{
|
||||
case Game::ENT_HANDLER_TRIGGER_HURT:
|
||||
Game::R_AddDebugBounds(hurt, &b);
|
||||
break;
|
||||
|
||||
case Game::ENT_HANDLER_TRIGGER_HURT_TOUCH:
|
||||
Game::R_AddDebugBounds(hurtTouch, &b);
|
||||
break;
|
||||
|
||||
case Game::ENT_HANDLER_TRIGGER_DAMAGE:
|
||||
Game::R_AddDebugBounds(damage, &b);
|
||||
break;
|
||||
|
||||
case Game::ENT_HANDLER_TRIGGER_MULTIPLE:
|
||||
if(ent->spawnflags & 0x40)
|
||||
Game::R_AddDebugBounds(once, &b);
|
||||
else
|
||||
Game::R_AddDebugBounds(multiple, &b);
|
||||
break;
|
||||
|
||||
default:
|
||||
float rv = std::min((float)ent->handler, (float)5) / 5;
|
||||
float gv = std::clamp((float)ent->handler-5, (float)0, (float)5) / 5;
|
||||
float bv = std::clamp((float)ent->handler - 10, (float)0, (float)5) / 5;
|
||||
|
||||
float color[4] = { rv, gv, bv, 1.0f };
|
||||
|
||||
Game::R_AddDebugBounds(color, &b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Dvars
|
||||
Dvar::Register<bool>("ui_streamFriendly", false, Game::DVAR_FLAG_SAVED, "Stream friendly UI");
|
||||
|
||||
|
@ -8,6 +8,30 @@ namespace Components
|
||||
Utils::Signal<Scheduler::Callback> Renderer::EndRecoverDeviceSignal;
|
||||
Utils::Signal<Scheduler::Callback> Renderer::BeginRecoverDeviceSignal;
|
||||
|
||||
Dvar::Var Renderer::r_drawTriggers;
|
||||
Dvar::Var Renderer::r_drawSceneModelCollisions;
|
||||
Dvar::Var Renderer::r_drawModelBoundingBoxes;
|
||||
Dvar::Var Renderer::r_drawModelNames;
|
||||
Dvar::Var Renderer::r_drawAABBTrees;
|
||||
Dvar::Var Renderer::r_playerDrawDebugDistance;
|
||||
|
||||
float cyan[4] = { 0.0f, 0.5f, 0.5f, 1.0f };
|
||||
float red[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
float green[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
// R_draw model names & collisions colors
|
||||
float sceneModelsColor[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
float dobjsColor[4] = { 0.0f, 1.0f, 1.0f, 1.0f };
|
||||
float staticModelsColor[4] = { 1.0f, 0.0f, 1.0f, 1.0f };
|
||||
float gentitiesColor[4] = { 1.0f, 0.5f, 0.5f, 1.0f };
|
||||
|
||||
// Trigger colors
|
||||
float hurt[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
float hurtTouch[4] = { 0.75f, 0.0f, 0.0f, 1.0f };
|
||||
float damage[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||
float once[4] = { 0.0f, 1.0f, 1.0f, 1.0f };
|
||||
float multiple[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
__declspec(naked) void Renderer::FrameStub()
|
||||
{
|
||||
__asm
|
||||
@ -127,7 +151,7 @@ namespace Components
|
||||
|
||||
// show error
|
||||
pushad;
|
||||
push [esp + 24h + 20h];
|
||||
push[esp + 24h + 20h];
|
||||
push eax;
|
||||
call R_TextureFromCodeError;
|
||||
add esp, 8;
|
||||
@ -166,37 +190,317 @@ namespace Components
|
||||
return Utils::Hook::Call<int(int, float, float, const char*, Game::vec4_t*, int)>(0x005033E0)(a1, a2, a3, Utils::String::VA("%s (^3%s^7)", mat->info.name, mat->techniqueSet->name), color, a6);
|
||||
}
|
||||
|
||||
void Renderer::DebugDrawTriggers()
|
||||
{
|
||||
if (!r_drawTriggers.get<bool>()) return;
|
||||
|
||||
auto entities = Game::g_entities;
|
||||
|
||||
for (auto i = 0u; i < 0x800u; i++)
|
||||
{
|
||||
auto* ent = &entities[i];
|
||||
|
||||
if (ent->r.isInUse)
|
||||
{
|
||||
Game::Bounds b = ent->r.box;
|
||||
b.midPoint[0] += ent->r.currentOrigin[0];
|
||||
b.midPoint[1] += ent->r.currentOrigin[1];
|
||||
b.midPoint[2] += ent->r.currentOrigin[2];
|
||||
|
||||
switch (ent->handler)
|
||||
{
|
||||
case Game::ENT_HANDLER_TRIGGER_HURT:
|
||||
Game::R_AddDebugBounds(hurt, &b);
|
||||
break;
|
||||
|
||||
case Game::ENT_HANDLER_TRIGGER_HURT_TOUCH:
|
||||
Game::R_AddDebugBounds(hurtTouch, &b);
|
||||
break;
|
||||
|
||||
case Game::ENT_HANDLER_TRIGGER_DAMAGE:
|
||||
Game::R_AddDebugBounds(damage, &b);
|
||||
break;
|
||||
|
||||
case Game::ENT_HANDLER_TRIGGER_MULTIPLE:
|
||||
if (ent->spawnflags & 0x40)
|
||||
Game::R_AddDebugBounds(once, &b);
|
||||
else
|
||||
Game::R_AddDebugBounds(multiple, &b);
|
||||
break;
|
||||
|
||||
default:
|
||||
auto rv = std::min(static_cast<float>(ent->handler), 5.0f) / 5.0f;
|
||||
auto gv = std::clamp(static_cast<float>(ent->handler - 5), 0.f, 5.0f) / 5.0f;
|
||||
auto bv = std::clamp(static_cast<float>(ent->handler - 10), 0.f, 5.0f) / 5.0f;
|
||||
|
||||
float color[4] = { rv, gv, bv, 1.0f };
|
||||
|
||||
Game::R_AddDebugBounds(color, &b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::DebugDrawSceneModelCollisions()
|
||||
{
|
||||
if (!r_drawSceneModelCollisions.get<bool>()) return;
|
||||
|
||||
auto scene = Game::scene;
|
||||
|
||||
for (auto i = 0; i < scene->sceneModelCount; i++)
|
||||
{
|
||||
if (!scene->sceneModel[i].model)
|
||||
continue;
|
||||
|
||||
for (auto j = 0; j < scene->sceneModel[i].model->numCollSurfs; j++)
|
||||
{
|
||||
auto b = scene->sceneModel[i].model->collSurfs[j].bounds;
|
||||
b.midPoint[0] += scene->sceneModel[i].placement.base.origin[0];
|
||||
b.midPoint[1] += scene->sceneModel[i].placement.base.origin[1];
|
||||
b.midPoint[2] += scene->sceneModel[i].placement.base.origin[2];
|
||||
b.halfSize[0] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[1] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[2] *= scene->sceneModel[i].placement.scale;
|
||||
|
||||
Game::R_AddDebugBounds(green, &b, &scene->sceneModel[i].placement.base.quat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::DebugDrawModelBoundingBoxes()
|
||||
{
|
||||
auto val = r_drawModelBoundingBoxes.get<int>();
|
||||
|
||||
if (!val) return;
|
||||
|
||||
// Ingame only
|
||||
int clientNum = Game::CG_GetClientNum();
|
||||
if (!Game::CL_IsCgameInitialized() ||
|
||||
clientNum >= 18 ||
|
||||
clientNum < 0 ||
|
||||
Game::g_entities[clientNum].client == nullptr) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Game::gentity_t* clientEntity = &Game::g_entities[clientNum];
|
||||
|
||||
float playerPosition[3]{ clientEntity->r.currentOrigin[0], clientEntity->r.currentOrigin[1], clientEntity->r.currentOrigin[2] };
|
||||
|
||||
const auto mapName = Dvar::Var("mapname").get<const char*>();
|
||||
auto scene = Game::scene;
|
||||
auto world = Game::DB_FindXAssetEntry(Game::XAssetType::ASSET_TYPE_GFXWORLD, Utils::String::VA("maps/mp/%s.d3dbsp", mapName))->asset.header.gfxWorld;
|
||||
|
||||
auto drawDistance = r_playerDrawDebugDistance.get<int>();
|
||||
auto sqrDist = drawDistance * drawDistance;
|
||||
|
||||
switch (val)
|
||||
{
|
||||
case 1:
|
||||
for (auto i = 0; i < scene->sceneModelCount; i++)
|
||||
{
|
||||
if (!scene->sceneModel[i].model)
|
||||
continue;
|
||||
|
||||
if (Utils::Vec3SqrDistance(playerPosition, scene->sceneModel[i].placement.base.origin) < sqrDist)
|
||||
{
|
||||
auto b = scene->sceneModel[i].model->bounds;
|
||||
b.midPoint[0] += scene->sceneModel[i].placement.base.origin[0];
|
||||
b.midPoint[1] += scene->sceneModel[i].placement.base.origin[1];
|
||||
b.midPoint[2] += scene->sceneModel[i].placement.base.origin[2];
|
||||
b.halfSize[0] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[1] *= scene->sceneModel[i].placement.scale;
|
||||
b.halfSize[2] *= scene->sceneModel[i].placement.scale;
|
||||
Game::R_AddDebugBounds(sceneModelsColor, &b, &scene->sceneModel[i].placement.base.quat);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (auto i = 0; i < scene->sceneDObjCount; i++)
|
||||
{
|
||||
|
||||
if (Utils::Vec3SqrDistance(playerPosition, scene->sceneDObj[i].cull.bounds.midPoint) < sqrDist)
|
||||
{
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[0] = std::abs(scene->sceneDObj[i].cull.bounds.halfSize[0]);
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[1] = std::abs(scene->sceneDObj[i].cull.bounds.halfSize[1]);
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[2] = std::abs(scene->sceneDObj[i].cull.bounds.halfSize[2]);
|
||||
|
||||
if (scene->sceneDObj[i].cull.bounds.halfSize[0] < 0 ||
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[1] < 0 ||
|
||||
scene->sceneDObj[i].cull.bounds.halfSize[2] < 0)
|
||||
{
|
||||
|
||||
Components::Logger::Print("WARNING: Negative half size for DOBJ %s, this will cause culling issues!", scene->sceneDObj[i].obj->models[0]->name);
|
||||
}
|
||||
|
||||
Game::R_AddDebugBounds(dobjsColor, &scene->sceneDObj[i].cull.bounds);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Static models
|
||||
for (size_t i = 0; i < world->dpvs.smodelCount; i++)
|
||||
{
|
||||
auto staticModel = world->dpvs.smodelDrawInsts[i];
|
||||
|
||||
if (Utils::Vec3SqrDistance(playerPosition, staticModel.placement.origin) < sqrDist)
|
||||
{
|
||||
if (staticModel.model)
|
||||
{
|
||||
Game::Bounds b = staticModel.model->bounds;
|
||||
b.midPoint[0] += staticModel.placement.origin[0];
|
||||
b.midPoint[1] += staticModel.placement.origin[1];
|
||||
b.midPoint[2] += staticModel.placement.origin[2];
|
||||
b.halfSize[0] *= staticModel.placement.scale;
|
||||
b.halfSize[1] *= staticModel.placement.scale;
|
||||
b.halfSize[2] *= staticModel.placement.scale;
|
||||
|
||||
Game::R_AddDebugBounds(staticModelsColor, &b);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::DebugDrawModelNames()
|
||||
{
|
||||
auto val = r_drawModelNames.get<int>();
|
||||
|
||||
if (!val) return;
|
||||
|
||||
// Ingame only
|
||||
int clientNum = Game::CG_GetClientNum();
|
||||
if (!Game::CL_IsCgameInitialized() ||
|
||||
clientNum >= 18 ||
|
||||
clientNum < 0 ||
|
||||
Game::g_entities[clientNum].client == nullptr) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Game::gentity_t* clientEntity = &Game::g_entities[clientNum];
|
||||
|
||||
float playerPosition[3]{ clientEntity->r.currentOrigin[0], clientEntity->r.currentOrigin[1], clientEntity->r.currentOrigin[2] };
|
||||
|
||||
const auto mapName = Dvar::Var("mapname").get<const char*>();
|
||||
auto scene = Game::scene;
|
||||
auto world = Game::DB_FindXAssetEntry(Game::XAssetType::ASSET_TYPE_GFXWORLD, Utils::String::VA("maps/mp/%s.d3dbsp", mapName))->asset.header.gfxWorld;
|
||||
|
||||
auto drawDistance = r_playerDrawDebugDistance.get<int>();
|
||||
auto sqrDist = drawDistance * drawDistance;
|
||||
|
||||
switch (val) {
|
||||
case 1:
|
||||
for (auto i = 0; i < scene->sceneModelCount; i++)
|
||||
{
|
||||
if (!scene->sceneModel[i].model)
|
||||
continue;
|
||||
|
||||
if (Utils::Vec3SqrDistance(playerPosition, scene->sceneModel[i].placement.base.origin) < sqrDist)
|
||||
{
|
||||
Game::R_AddDebugString(sceneModelsColor, scene->sceneModel[i].placement.base.origin, 1.0, scene->sceneModel[i].model->name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (auto i = 0; i < scene->sceneDObjCount; i++)
|
||||
{
|
||||
if (scene->sceneDObj[i].obj)
|
||||
{
|
||||
for (int j = 0; j < scene->sceneDObj[i].obj->numModels; j++)
|
||||
{
|
||||
if (Utils::Vec3SqrDistance(playerPosition, scene->sceneDObj[i].placement.origin) < sqrDist)
|
||||
{
|
||||
Game::R_AddDebugString(dobjsColor, scene->sceneDObj[i].placement.origin, 1.0, scene->sceneDObj[i].obj->models[j]->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Static models
|
||||
for (size_t i = 0; i < world->dpvs.smodelCount; i++)
|
||||
{
|
||||
auto staticModel = world->dpvs.smodelDrawInsts[i];
|
||||
if (staticModel.model)
|
||||
{
|
||||
auto dist = Utils::Vec3SqrDistance(playerPosition, staticModel.placement.origin);
|
||||
if (dist < sqrDist)
|
||||
{
|
||||
Game::R_AddDebugString(staticModelsColor, staticModel.placement.origin, 1.0, staticModel.model->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::DebugDrawAABBTrees()
|
||||
{
|
||||
if (!r_drawAABBTrees.get<bool>()) return;
|
||||
|
||||
Game::clipMap_t* clipMap = *reinterpret_cast<Game::clipMap_t**>(0x7998E0);
|
||||
if (!clipMap) return;
|
||||
|
||||
for (unsigned short i = 0; i < clipMap->smodelNodeCount; ++i)
|
||||
{
|
||||
Game::R_AddDebugBounds(cyan, &clipMap->smodelNodes[i].bounds);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < clipMap->numStaticModels; i += 2)
|
||||
{
|
||||
Game::R_AddDebugBounds(red, &clipMap->staticModelList[i].absBounds);
|
||||
}
|
||||
}
|
||||
|
||||
Renderer::Renderer()
|
||||
{
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
|
||||
// Renderer::OnBackendFrame([] (IDirect3DDevice9* device)
|
||||
// {
|
||||
// if (Game::Sys_Milliseconds() % 2)
|
||||
// {
|
||||
// device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0, 0, 0);
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
//
|
||||
// IDirect3DSurface9* buffer = nullptr;
|
||||
//
|
||||
// device->CreateOffscreenPlainSurface(Renderer::Width(), Renderer::Height(), D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &buffer, nullptr);
|
||||
// device->GetFrontBufferData(0, buffer);
|
||||
//
|
||||
// if (buffer)
|
||||
// {
|
||||
// D3DSURFACE_DESC desc;
|
||||
// D3DLOCKED_RECT lockedRect;
|
||||
//
|
||||
// buffer->GetDesc(&desc);
|
||||
//
|
||||
// HRESULT res = buffer->LockRect(&lockedRect, NULL, D3DLOCK_READONLY);
|
||||
//
|
||||
//
|
||||
// buffer->UnlockRect();
|
||||
// }
|
||||
// });
|
||||
Scheduler::OnFrame([]() {
|
||||
if (Game::CL_IsCgameInitialized())
|
||||
{
|
||||
DebugDrawAABBTrees();
|
||||
DebugDrawModelNames();
|
||||
DebugDrawModelBoundingBoxes();
|
||||
DebugDrawSceneModelCollisions();
|
||||
DebugDrawTriggers();
|
||||
}
|
||||
});
|
||||
|
||||
// Renderer::OnBackendFrame([] (IDirect3DDevice9* device)
|
||||
// {
|
||||
// if (Game::Sys_Milliseconds() % 2)
|
||||
// {
|
||||
// device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0, 0, 0);
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
//
|
||||
// IDirect3DSurface9* buffer = nullptr;
|
||||
//
|
||||
// device->CreateOffscreenPlainSurface(Renderer::Width(), Renderer::Height(), D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &buffer, nullptr);
|
||||
// device->GetFrontBufferData(0, buffer);
|
||||
//
|
||||
// if (buffer)
|
||||
// {
|
||||
// D3DSURFACE_DESC desc;
|
||||
// D3DLOCKED_RECT lockedRect;
|
||||
//
|
||||
// buffer->GetDesc(&desc);
|
||||
//
|
||||
// HRESULT res = buffer->LockRect(&lockedRect, NULL, D3DLOCK_READONLY);
|
||||
//
|
||||
//
|
||||
// buffer->UnlockRect();
|
||||
// }
|
||||
// });
|
||||
|
||||
// Log broken materials
|
||||
Utils::Hook(0x0054CAAA, Renderer::StoreGfxBufContextPtrStub1, HOOK_JUMP).install()->quick();
|
||||
@ -230,6 +534,25 @@ namespace Components
|
||||
|
||||
// End vid_restart
|
||||
Utils::Hook(0x4CA3A7, Renderer::PostVidRestartStub, HOOK_CALL).install()->quick();
|
||||
|
||||
Dvar::OnInit([]
|
||||
{
|
||||
static const char* values[] =
|
||||
{
|
||||
"Disabled",
|
||||
"Scene Models",
|
||||
"Scene Dynamic Objects",
|
||||
"GfxWorld Static Models",
|
||||
nullptr
|
||||
};
|
||||
|
||||
Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_FLAG_CHEAT, "Draw scene model bounding boxes");
|
||||
Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_FLAG_CHEAT, "Draw scene model collisions");
|
||||
Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_FLAG_CHEAT, "Draw triggers");
|
||||
Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_FLAG_CHEAT, "Draw all model names");
|
||||
Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_FLAG_CHEAT, "Draw aabb trees");
|
||||
Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_FLAG_SAVED, "r_draw debug functions draw distance, relative to the player");
|
||||
});
|
||||
}
|
||||
|
||||
Renderer::~Renderer()
|
||||
|
@ -35,10 +35,23 @@ namespace Components
|
||||
|
||||
static int DrawTechsetForMaterial(int a1, float a2, float a3, const char* material, Game::vec4_t* color, int a6);
|
||||
|
||||
static void DebugDrawTriggers();
|
||||
static void DebugDrawSceneModelCollisions();
|
||||
static void DebugDrawModelBoundingBoxes();
|
||||
static void DebugDrawModelNames();
|
||||
static void DebugDrawAABBTrees();
|
||||
|
||||
static Utils::Signal<Scheduler::Callback> EndRecoverDeviceSignal;
|
||||
static Utils::Signal<Scheduler::Callback> BeginRecoverDeviceSignal;
|
||||
|
||||
static Utils::Signal<BackendCallback> BackendFrameSignal;
|
||||
static Utils::Signal<BackendCallback> SingleBackendFrameSignal;
|
||||
|
||||
static Dvar::Var r_drawTriggers;
|
||||
static Dvar::Var r_drawSceneModelCollisions;
|
||||
static Dvar::Var r_drawModelBoundingBoxes;
|
||||
static Dvar::Var r_drawModelNames;
|
||||
static Dvar::Var r_drawAABBTrees;
|
||||
static Dvar::Var r_playerDrawDebugDistance;
|
||||
};
|
||||
}
|
||||
|
@ -23,16 +23,22 @@ namespace Components
|
||||
StartupMessages::TotalMessages = StartupMessages::MessageList.size();
|
||||
}
|
||||
|
||||
std::string message = StartupMessages::MessageList.front();
|
||||
StartupMessages::MessageList.pop_front();
|
||||
const auto& message = StartupMessages::MessageList.front();
|
||||
|
||||
Game::Dvar_SetStringByName("ui_startupMessage", message.data());
|
||||
Game::Dvar_SetStringByName("ui_startupMessageTitle", Utils::String::VA("Messages (%d/%d)", StartupMessages::TotalMessages - StartupMessages::MessageList.size(), StartupMessages::TotalMessages));
|
||||
Game::Dvar_SetStringByName("ui_startupNextButtonText", StartupMessages::MessageList.size() ? "Next" : "Close");
|
||||
Game::Cbuf_AddText(0, "openmenu startup_messages");
|
||||
|
||||
StartupMessages::MessageList.pop_front();
|
||||
});
|
||||
}
|
||||
|
||||
StartupMessages::~StartupMessages()
|
||||
{
|
||||
StartupMessages::MessageList.clear();
|
||||
}
|
||||
|
||||
void StartupMessages::AddMessage(const std::string& message)
|
||||
{
|
||||
StartupMessages::MessageList.push_back(message);
|
||||
|
@ -6,6 +6,7 @@ namespace Components
|
||||
{
|
||||
public:
|
||||
StartupMessages();
|
||||
~StartupMessages();
|
||||
|
||||
static void AddMessage(const std::string& message);
|
||||
|
||||
|
@ -15,19 +15,14 @@ namespace Components
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<> char* UIScript::Token::get()
|
||||
template<> const char* UIScript::Token::get()
|
||||
{
|
||||
if (this->isValid())
|
||||
{
|
||||
return this->token;
|
||||
}
|
||||
|
||||
return const_cast<char*>("");
|
||||
}
|
||||
|
||||
template<> const char* UIScript::Token::get()
|
||||
{
|
||||
return this->get<char*>();
|
||||
return "";
|
||||
}
|
||||
|
||||
template<> std::string UIScript::Token::get()
|
||||
|
@ -1300,7 +1300,7 @@ namespace Components
|
||||
}, nullptr, false);
|
||||
|
||||
// HACK: set language to 'techsets' to load from that dir
|
||||
char* language = Utils::Hook::Get<char*>(0x649E740);
|
||||
const char* language = Utils::Hook::Get<const char*>(0x649E740);
|
||||
Utils::Hook::Set<const char*>(0x649E740, "techsets");
|
||||
|
||||
// load generated techset fastfiles
|
||||
@ -1447,7 +1447,7 @@ namespace Components
|
||||
Utils::IO::WriteFile("zone_source/techsets/techsets.csv", csvStr.data());
|
||||
|
||||
// set language back
|
||||
Utils::Hook::Set<char*>(0x649E740, language);
|
||||
Utils::Hook::Set<const char*>(0x649E740, language);
|
||||
|
||||
Logger::Print("Building zone 'techsets/techsets'...\n");
|
||||
Zone("techsets/techsets").build();
|
||||
|
@ -380,6 +380,10 @@ namespace Game
|
||||
Field_AdjustScroll_t Field_AdjustScroll = Field_AdjustScroll_t(0x488C10);
|
||||
AimAssist_ApplyAutoMelee_t AimAssist_ApplyAutoMelee = AimAssist_ApplyAutoMelee_t(0x56A360);
|
||||
|
||||
Jump_ClearState_t Jump_ClearState = Jump_ClearState_t(0x04B3890);
|
||||
PM_playerTrace_t PM_playerTrace = PM_playerTrace_t(0x458980);
|
||||
PM_Trace_t PM_Trace = PM_Trace_t(0x441F60);
|
||||
|
||||
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
|
||||
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);
|
||||
|
||||
@ -506,6 +510,8 @@ namespace Game
|
||||
Sys_TempPriorityEnd(&critSect->tempPriority);
|
||||
}
|
||||
|
||||
vec3_t* CorrectSolidDeltas = reinterpret_cast<vec3_t*>(0x739BB8); // Count 26
|
||||
|
||||
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
|
||||
{
|
||||
int elSize = DB_GetXAssetSizeHandlers[type]();
|
||||
@ -788,9 +794,9 @@ namespace Game
|
||||
|
||||
float Vec2Normalize(vec2_t& vec)
|
||||
{
|
||||
const float length = std::sqrt((vec[0] * vec[0]) + (vec[1] * vec[1]));
|
||||
const auto length = std::sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
|
||||
|
||||
if(length > 0.0f)
|
||||
if (length > 0.0f)
|
||||
{
|
||||
vec[0] /= length;
|
||||
vec[1] /= length;
|
||||
@ -801,9 +807,9 @@ namespace Game
|
||||
|
||||
float Vec3Normalize(vec3_t& vec)
|
||||
{
|
||||
const float length = std::sqrt(std::pow(vec[0], 2.0f) + std::pow(vec[1], 2.0f) + std::pow(vec[2], 2.0f));
|
||||
const auto length = std::sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
|
||||
|
||||
if(length > 0.0f)
|
||||
if (length > 0.0f)
|
||||
{
|
||||
vec[0] /= length;
|
||||
vec[1] /= length;
|
||||
|
@ -759,7 +759,7 @@ namespace Game
|
||||
typedef void(__cdecl * SV_Cmd_EndTokenizedString_t)();
|
||||
extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
||||
|
||||
typedef void(__cdecl* SV_Cmd_ArgvBuffer_t)(int arg, char* buf, int size);
|
||||
typedef void(__cdecl * SV_Cmd_ArgvBuffer_t)(int arg, char* buf, int size);
|
||||
extern SV_Cmd_ArgvBuffer_t SV_Cmd_ArgvBuffer;
|
||||
|
||||
typedef void(__cdecl * SV_SetConfigstring_t)(int index, const char* string);
|
||||
@ -903,6 +903,15 @@ namespace Game
|
||||
typedef void(__cdecl * AimAssist_ApplyAutoMelee_t)(const AimInput* input, AimOutput* output);
|
||||
extern AimAssist_ApplyAutoMelee_t AimAssist_ApplyAutoMelee;
|
||||
|
||||
typedef void(__cdecl * Jump_ClearState_t)(playerState_s* ps);
|
||||
extern Jump_ClearState_t Jump_ClearState;
|
||||
|
||||
typedef void(__cdecl * PM_playerTrace_t)(pmove_s*, trace_t*, const float*, const float*, const Bounds*, int, int);
|
||||
extern PM_playerTrace_t PM_playerTrace;
|
||||
|
||||
typedef void(__cdecl * PM_Trace_t)(pmove_s*, trace_t*, const float*, const float*, const Bounds*, int, int);
|
||||
extern PM_Trace_t PM_Trace;
|
||||
|
||||
extern XAssetHeader* DB_XAssetPool;
|
||||
extern unsigned int* g_poolSize;
|
||||
|
||||
@ -953,6 +962,7 @@ namespace Game
|
||||
extern int* serverMessageSequence;
|
||||
|
||||
constexpr auto MAX_GENTITIES = 2048u;
|
||||
constexpr auto ENTITYNUM_NONE = MAX_GENTITIES - 1;
|
||||
extern gentity_t* g_entities;
|
||||
|
||||
extern netadr_t* connectedHost;
|
||||
@ -1024,6 +1034,8 @@ namespace Game
|
||||
|
||||
void Sys_UnlockWrite(FastCriticalSection*);
|
||||
|
||||
extern vec3_t* CorrectSolidDeltas;
|
||||
|
||||
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
|
||||
void Menu_FreeItemMemory(Game::itemDef_s* item);
|
||||
void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1);
|
||||
|
@ -211,6 +211,31 @@ namespace Game
|
||||
FL_MOVER_SLIDE = 0x8000000
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HITLOC_NONE,
|
||||
HITLOC_HELMET,
|
||||
HITLOC_HEAD,
|
||||
HITLOC_NECK,
|
||||
HITLOC_TORSO_UPR,
|
||||
HITLOC_TORSO_LWR,
|
||||
HITLOC_R_ARM_UPR,
|
||||
HITLOC_L_ARM_UPR,
|
||||
HITLOC_R_ARM_LWR,
|
||||
HITLOC_L_ARM_LWR,
|
||||
HITLOC_R_HAND,
|
||||
HITLOC_L_HAND,
|
||||
HITLOC_R_LEG_UPR,
|
||||
HITLOC_L_LEG_UPR,
|
||||
HITLOC_R_LEG_LWR,
|
||||
HITLOC_L_LEG_LWR,
|
||||
HITLOC_R_FOOT,
|
||||
HITLOC_L_FOOT,
|
||||
HITLOC_GUN,
|
||||
HITLOC_SHIELD,
|
||||
HITLOC_NUM
|
||||
} hitLocation_t;
|
||||
|
||||
struct FxEffectDef;
|
||||
struct pathnode_t;
|
||||
struct pathnode_tree_t;
|
||||
@ -1085,6 +1110,40 @@ namespace Game
|
||||
PM_DEAD_LINKED = 0x9,
|
||||
};
|
||||
|
||||
enum playerEFlag
|
||||
{
|
||||
EF_NONSOLID_BMODEL = 0x1,
|
||||
EF_TELEPORT_BIT = 0x2,
|
||||
EF_CROUCHING = 0x4,
|
||||
EF_PRONE = 0x8,
|
||||
EF_NODRAW = 0x20,
|
||||
EF_TIMED_OBJECT = 0x40,
|
||||
EF_VOTED = 0x80,
|
||||
EF_TALK = 0x100,
|
||||
EF_FIRING = 0x200,
|
||||
EF_TURRET_ACTIVE_PRONE = 0x400,
|
||||
EF_TURRET_ACTIVE_DUCK = 0x800,
|
||||
EF_LOCK_LIGHT_VIS = 0x1000,
|
||||
EF_AIM_ASSIST = 0x2000,
|
||||
EF_LOOP_RUMBLE = 0x4000,
|
||||
EF_LASER_SIGHT = 0x8000,
|
||||
EF_MANTLE = 0x10000,
|
||||
EF_DEAD = 0x20000,
|
||||
EF_ADS = 0x40000,
|
||||
EF_NEW = 0x80000,
|
||||
EF_VEHICLE_ACTIVE = 0x100000,
|
||||
EF_JAMMING = 0x200000,
|
||||
EF_COMPASS_PING = 0x400000,
|
||||
EF_SOFT = 0x800000
|
||||
};
|
||||
|
||||
enum playerLinkFlag
|
||||
{
|
||||
PLF_ANGLES_LOCKED = 0x1,
|
||||
PLF_USES_OFFSET = 0x2,
|
||||
PLF_WEAPONVIEW_ONLY = 0x4
|
||||
};
|
||||
|
||||
struct playerState_s
|
||||
{
|
||||
int commandTime;
|
||||
@ -1132,7 +1191,7 @@ namespace Game
|
||||
int unpredictableEventSequenceOld;
|
||||
int unpredictableEvents[4];
|
||||
unsigned int unpredictableEventParms[4];
|
||||
int clientNum;
|
||||
int clientNum; // 260
|
||||
int viewmodelIndex;
|
||||
float viewangles[3];
|
||||
int viewHeightTarget;
|
||||
@ -5348,21 +5407,42 @@ namespace Game
|
||||
PLAYER_FLAG_FROZEN = 1 << 2,
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SESS_STATE_PLAYING = 0x0,
|
||||
SESS_STATE_DEAD = 0x1,
|
||||
SESS_STATE_SPECTATOR = 0x2,
|
||||
SESS_STATE_INTERMISSION = 0x3
|
||||
} sessionState_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CON_DISCONNECTED = 0x0,
|
||||
CON_CONNECTING = 0x1,
|
||||
CON_CONNECTED = 0x2
|
||||
} clientConnected_t;
|
||||
|
||||
typedef struct gclient_s
|
||||
{
|
||||
unsigned char pad[12764];
|
||||
unsigned int team;
|
||||
playerState_s ps;
|
||||
sessionState_t sessionState; // 12572
|
||||
char pad0[40];
|
||||
clientConnected_t connected; // 12616
|
||||
char pad1[144];
|
||||
unsigned int team; // 12764
|
||||
char pad2[436];
|
||||
int flags;
|
||||
int flags; // 13204
|
||||
int spectatorClient;
|
||||
int lastCmdTime;
|
||||
int buttons;
|
||||
int oldbuttons;
|
||||
int latched_buttons;
|
||||
int buttonsSinceLastFrame;
|
||||
char pad3[700];
|
||||
int oldbuttons; // 13220
|
||||
int latched_buttons; // 13224
|
||||
int buttonsSinceLastFrame; // 13228
|
||||
char pad3[700]; // 13232
|
||||
} gclient_t;
|
||||
|
||||
static_assert(sizeof(gclient_t) == 13932);
|
||||
|
||||
struct EntHandle
|
||||
{
|
||||
unsigned __int16 number;
|
||||
@ -6930,15 +7010,43 @@ namespace Game
|
||||
const char* args[9];
|
||||
};
|
||||
|
||||
enum TraceHitType
|
||||
{
|
||||
TRACE_HITTYPE_NONE = 0,
|
||||
TRACE_HITTYPE_ENTITY = 1,
|
||||
TRACE_HITTYPE_DYNENT_MODEL = 2,
|
||||
TRACE_HITTYPE_DYNENT_BRUSH = 3,
|
||||
TRACE_HITTYPE_GLASS = 4
|
||||
};
|
||||
|
||||
struct trace_t
|
||||
{
|
||||
float fraction;
|
||||
float normal[3];
|
||||
int surfaceFlags;
|
||||
int contents;
|
||||
const char* material;
|
||||
TraceHitType hitType;
|
||||
unsigned __int16 hitId;
|
||||
unsigned __int16 modelIndex;
|
||||
unsigned __int16 partName;
|
||||
unsigned __int16 partGroup;
|
||||
bool allsolid;
|
||||
bool startsolid;
|
||||
bool walkable;
|
||||
};
|
||||
|
||||
static_assert(sizeof(trace_t) == 0x2C);
|
||||
|
||||
struct pmove_s
|
||||
{
|
||||
playerState_s* ps;
|
||||
usercmd_s cmd;
|
||||
usercmd_s oldcmd;
|
||||
int tracemask;
|
||||
int tracemask; // 84
|
||||
int numtouch;
|
||||
int touchents[32];
|
||||
char __pad0[24];
|
||||
Bounds bounds; // 220
|
||||
float xyspeed;
|
||||
int proneChange;
|
||||
float maxSprintTimeMultiplier;
|
||||
@ -6952,6 +7060,27 @@ namespace Game
|
||||
unsigned char handler;
|
||||
};
|
||||
|
||||
static_assert(sizeof(pmove_s) == 296);
|
||||
|
||||
struct pml_t
|
||||
{
|
||||
float forward[3];
|
||||
float right[3];
|
||||
float up[3];
|
||||
float frametime;
|
||||
int msec;
|
||||
int walking;
|
||||
int groundPlane;
|
||||
int almostGroundPlane;
|
||||
trace_t groundTrace;
|
||||
float impactSpeed;
|
||||
float previous_origin[3];
|
||||
float previous_velocity[3];
|
||||
int holdrand;
|
||||
};
|
||||
|
||||
static_assert(sizeof(pml_t) == 0x84);
|
||||
|
||||
enum EffectiveStance
|
||||
{
|
||||
PM_EFF_STANCE_DEFAULT = 0,
|
||||
|
@ -149,4 +149,15 @@ namespace Utils
|
||||
{
|
||||
return !(base1 + len1 <= base2 || base2 + len2 <= base1);
|
||||
}
|
||||
|
||||
float Vec3SqrDistance(const float v1[3], const float v2[3])
|
||||
{
|
||||
auto x = v2[0] - v1[0];
|
||||
auto y = v2[1] - v1[1];
|
||||
auto z = v2[2] - v1[2];
|
||||
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace Utils
|
||||
void OpenUrl(const std::string& url);
|
||||
|
||||
bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);
|
||||
float Vec3SqrDistance(const float v1[3], const float v2[3]);
|
||||
|
||||
template <typename T> inline void RotLeft(T& object, size_t bits)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user