From 4495ae7133ee8b2dbbe077ec75f0e4b04b0890d8 Mon Sep 17 00:00:00 2001 From: jyelon Date: Wed, 28 Feb 2024 15:35:47 -0500 Subject: [PATCH] Minor changes to help players see each other --- luprex/cpp/core/lpxclient.cpp | 2 +- luprex/cpp/core/lpxserver.cpp | 5 +++++ luprex/cpp/core/planemap.cpp | 4 +--- luprex/cpp/core/planemap.hpp | 7 +++++-- luprex/cpp/core/world-accessor.cpp | 3 +-- luprex/cpp/core/world-testing.cpp | 12 +++++++----- luprex/cpp/core/world.hpp | 4 ++-- luprex/lua/login.lua | 3 +++ 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/luprex/cpp/core/lpxclient.cpp b/luprex/cpp/core/lpxclient.cpp index d0f47445..cc1749fc 100644 --- a/luprex/cpp/core/lpxclient.cpp +++ b/luprex/cpp/core/lpxclient.cpp @@ -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) { diff --git a/luprex/cpp/core/lpxserver.cpp b/luprex/cpp/core/lpxserver.cpp index fa19f5cd..01f6fe83 100644 --- a/luprex/cpp/core/lpxserver.cpp +++ b/luprex/cpp/core/lpxserver.cpp @@ -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); diff --git a/luprex/cpp/core/planemap.cpp b/luprex/cpp/core/planemap.cpp index 3423a67b..3ab1876a 100644 --- a/luprex/cpp/core/planemap.cpp +++ b/luprex/cpp/core/planemap.cpp @@ -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()); } } diff --git a/luprex/cpp/core/planemap.hpp b/luprex/cpp/core/planemap.hpp index c6d62c8f..36fe6526 100644 --- a/luprex/cpp/core/planemap.hpp +++ b/luprex/cpp/core/planemap.hpp @@ -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_; diff --git a/luprex/cpp/core/world-accessor.cpp b/luprex/cpp/core/world-accessor.cpp index b144461e..f4aa9703 100644 --- a/luprex/cpp/core/world-accessor.cpp +++ b/luprex/cpp/core/world-accessor.cpp @@ -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" "|" diff --git a/luprex/cpp/core/world-testing.cpp b/luprex/cpp/core/world-testing.cpp index c5304bbd..1872f9dd 100644 --- a/luprex/cpp/core/world-testing.cpp +++ b/luprex/cpp/core/world-testing.cpp @@ -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(); } diff --git a/luprex/cpp/core/world.hpp b/luprex/cpp/core/world.hpp index b0dc99a2..dae42b84 100644 --- a/luprex/cpp/core/world.hpp +++ b/luprex/cpp/core/world.hpp @@ -96,8 +96,8 @@ public: using IdVector = util::IdVector; using TanVector = eng::vector; using Redirects = eng::map; - const float RadiusVisibility = 100.0; - const float RadiusClose = 10.0; + const float RadiusVisibility = 1000.0; + const float RadiusClose = 1000.0; // Constructor. // diff --git a/luprex/lua/login.lua b/luprex/lua/login.lua index 3917627c..fdce20ea 100644 --- a/luprex/lua/login.lua +++ b/luprex/lua/login.lua @@ -2,6 +2,9 @@ makeclass('login') function login.initialize(actor, place) dprint("login.initialize:", actor) + local x = math.random(1, 100) + local y = math.random(1, 100) + tangible.animate(actor, nil, {action="warpto", plane="earth", xyz={x, y, 90}}) end function login.interface(actor, place)