Minor changes to help players see each other

This commit is contained in:
2024-02-28 15:35:47 -05:00
parent 0c126e62d6
commit 4495ae7133
8 changed files with 25 additions and 15 deletions

View File

@@ -152,7 +152,7 @@ public:
}
void do_view_command(const StringVec &cmd) {
stdostream() << world_->tangibles_near_debug_string(actor_id_, 100);
stdostream() << world_->tangibles_near_debug_string(actor_id_, 1000);
}
void do_menu_command(const StringVec &cmd) {

View File

@@ -80,6 +80,10 @@ public:
stdostream() << "Syntax Error: " << words[1] << std::endl;
}
void do_view_command(const StringVec &cmd) {
stdostream() << master_->tangibles_near_debug_string(admin_id_, 1000);
}
void do_menu_command(const StringVec &cmd) {
int64_t place = sv::to_int64(cmd[1], admin_id_);
master_->update_gui(admin_id_, place, &gui_);
@@ -118,6 +122,7 @@ public:
else if (words[0] == "luainvoke") do_luainvoke_command(words);
else if (words[0] == "luaprobe") do_luaprobe_command(words);
else if (words[0] == "syntax") do_syntax_command(words);
else if (words[0] == "view") do_view_command(words);
else if (words[0] == "menu") do_menu_command(words);
else if (words[0] == "choose") do_choose_command(words);
else if (words[0] == "tick") do_tick_command(words);

View File

@@ -780,11 +780,9 @@ PlaneMap::~PlaneMap() {}
void PlaneMap::scan(const PlaneScan &sc, util::IdVector *into) const {
into->clear();
int startpos = 0;
if (sc.near_ != 0) {
if (sc.include_near_) {
into->push_back(sc.near_);
startpos = 1;
}
}
@@ -799,7 +797,7 @@ void PlaneMap::scan(const PlaneScan &sc, util::IdVector *into) const {
}
if (sc.sorted_) {
std::sort(into->begin() + startpos, into->end());
std::sort(into->begin(), into->end());
}
}

View File

@@ -112,10 +112,13 @@ private:
// When true, the items are sorted by ID.
// WARNING: setting this to false can create
// nondeterminism. Scans by lua should always be sorted.
// When sorting and 'include_near' are both specified,
// the near item is returned in its sorted order.
bool sorted_;
// The near ID, if nonzero, is either PREPENDED to the
// results, or OMITTED from the results, depending on include_near_.
// The near ID is omitted from the results if include_near is false.
// The near ID is included in the results if include_near is true.
// The near ID is ignored if near is zero.
int64_t near_;
bool include_near_;

View File

@@ -467,8 +467,7 @@ LuaDefine(tangible_find, "config",
"|"
"|If you specify 'near', then by default, the near tangible is"
"|filtered out of the search. If you want to include it in the"
"|results, set the 'include' flag to true. In this case, the"
"|near tangible will always be the first search result:"
"|results, set the 'include' flag to true."
"|"
"| include : include the 'near' object in the results"
"|"

View File

@@ -60,17 +60,19 @@ eng::string World::tangible_ids_debug_string() const {
eng::string World::tangibles_near_debug_string(int64_t actor, int64_t distance) {
assert(stack_is_clear());
lua_State *L = state();
LuaVar tangibles, database, mt;
LuaExtStack LS(L, tangibles, database);
LuaVar tangibles, tanobj, classtab;
LuaExtStack LS(L, tangibles, tanobj, classtab);
LS.rawget(tangibles, LuaRegistry, "tangibles");
eng::ostringstream result;
util::IdVector tans;
get_near(actor, distance, true, false, true, &tans);
for (int64_t id : tans) {
const Tangible *tan = tangible_get(id);
LS.rawget(database, tangibles, id);
AnimState state = tan->anim_queue_.get_final_everything();
result << id << ": " << state.debug_string() << std::endl;
LS.rawget(tanobj, tangibles, id);
LS.tangetclass(classtab, tanobj);
eng::string cname = LS.classname(classtab);
AnimState state = tan->anim_queue_.get_final_persistent();
result << id << " (" << cname << "): " << state.debug_string() << std::endl;
}
return result.str();
}

View File

@@ -96,8 +96,8 @@ public:
using IdVector = util::IdVector;
using TanVector = eng::vector<const Tangible*>;
using Redirects = eng::map<int64_t, int64_t>;
const float RadiusVisibility = 100.0;
const float RadiusClose = 10.0;
const float RadiusVisibility = 1000.0;
const float RadiusClose = 1000.0;
// Constructor.
//