Skip to content

Commit

Permalink
Add 'bxt_print_entities_by_index'
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyAG committed Feb 21, 2023
1 parent f557194 commit 1724ef6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3923,6 +3923,34 @@ struct HwDLL::Cmd_BXT_Print_Entities
}
};

struct HwDLL::Cmd_BXT_Print_Entities_By_Index
{
USAGE("Usage: bxt_print_entities_by_index <min_range> <max_range>\n");

static void handler(int value1, int value2)
{
const auto& hw = HwDLL::GetInstance();

std::ostringstream out;

edict_t* edicts;
const int numEdicts = hw.GetEdicts(&edicts);
for (int e = 0; e < numEdicts; ++e) {
const edict_t* ent = edicts + e;
if (!hw.IsValidEdict(ent))
continue;

if ((e < value1) || (e > value2))
continue;

HwDLL::GetInstance().PrintEntities(out, e, ent);
}

auto str = out.str();
hw.ORIG_Con_Printf("%s", str.c_str());
}
};

void HwDLL::GetOriginOfEntity(Vector& origin, const edict_t* ent)
{
const auto& hw = HwDLL::GetInstance();
Expand Down Expand Up @@ -4890,6 +4918,7 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded()
wrapper::Add<Cmd_BXT_Append, Handler<const char *>>("bxt_append");
wrapper::Add<Cmd_BXT_FreeCam, Handler<int>>("bxt_freecam");
wrapper::Add<Cmd_BXT_Print_Entities, Handler<const char*>, Handler<const char*, const char*>>("bxt_print_entities");
wrapper::Add<Cmd_BXT_Print_Entities_By_Index, Handler<int, int>>("bxt_print_entities_by_index");

wrapper::Add<Cmd_BXT_TAS_Editor_Resimulate, Handler<>>("bxt_tas_editor_resimulate");
wrapper::Add<Cmd_BXT_TAS_Editor_Apply_Smoothing, Handler<>>("bxt_tas_editor_apply_smoothing");
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/modules/HwDLL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ class HwDLL : public IHookableNameFilterOrdered
struct Cmd_BXT_TAS_Optim_Init;
struct Cmd_BXT_FreeCam;
struct Cmd_BXT_Print_Entities;
struct Cmd_BXT_Print_Entities_By_Index;
struct Cmd_BXT_TAS_Become_Simulator_Client;
struct Cmd_BXT_TAS_Server_Send_Command;
struct Cmd_BXT_TAS_Client_Load_Received_Script;
Expand Down

0 comments on commit 1724ef6

Please sign in to comment.