From c75ba3b3a8cafdf9a6676cfc59e3b49e4a782aca Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Tue, 23 Nov 2021 14:38:08 -0500 Subject: [PATCH] fix minor bugs --- luprex/core/cpp/drivenengine.cpp | 2 +- luprex/core/cpp/pprint.cpp | 1 + luprex/core/cpp/streambuffer.cpp | 15 ++++++--------- luprex/core/cpp/util.cpp | 2 +- luprex/core/cpp/world-core.cpp | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/luprex/core/cpp/drivenengine.cpp b/luprex/core/cpp/drivenengine.cpp index 9ebb0e7a..195526f8 100644 --- a/luprex/core/cpp/drivenengine.cpp +++ b/luprex/core/cpp/drivenengine.cpp @@ -164,7 +164,7 @@ UniqueChannel DrivenEngine::new_incoming_channel() { } else { UniqueChannel result = std::move(accepted_channels_.back()); accepted_channels_.pop_back(); - return std::move(result); + return result; } } diff --git a/luprex/core/cpp/pprint.cpp b/luprex/core/cpp/pprint.cpp index e0b129b7..d6d5db1c 100644 --- a/luprex/core/cpp/pprint.cpp +++ b/luprex/core/cpp/pprint.cpp @@ -122,6 +122,7 @@ static void tabify(Inspector &insp, int level) { } static void pprint_r(Inspector &insp, int level, LuaSlot root) { + lua_checkstack(insp.L, 20); LuaVar idv, pairs, key, val; LuaStack LS(insp.L, idv, pairs, key, val); diff --git a/luprex/core/cpp/streambuffer.cpp b/luprex/core/cpp/streambuffer.cpp index a467a0bc..5789af2d 100644 --- a/luprex/core/cpp/streambuffer.cpp +++ b/luprex/core/cpp/streambuffer.cpp @@ -309,9 +309,8 @@ double StreamBuffer::read_double() { } void StreamBuffer::write_hashvalue(const util::HashValue &hv) { - make_space(16); - memcpy(write_cursor_, &hv, 16); - write_cursor_ += 16; + write_uint64(hv.first); + write_uint64(hv.second); } void StreamBuffer::write_string(const std::string &s) { @@ -326,11 +325,9 @@ void StreamBuffer::write_string(const std::string &s) { } util::HashValue StreamBuffer::read_hashvalue() { - check_available(16); - util::HashValue hv; - memcpy(&hv, read_cursor_, 16); - read_cursor_ += 16; - return hv; + uint64_t f = read_uint64(); + uint64_t s = read_uint64(); + return util::HashValue(f,s); } std::string StreamBuffer::read_string() { @@ -546,7 +543,7 @@ LuaDefine(unittests_streambuffer, "c") { try { sb11.read_bytes(1); LuaAssert(L, false && "This should have thrown an exception"); - } catch (StreamEof) {} + } catch (const StreamEof &) {} LuaAssert(L, sb11.layout_is(6, 0, 5)); // Write some more bytes into the stream, forcing a shift-left diff --git a/luprex/core/cpp/util.cpp b/luprex/core/cpp/util.cpp index 4063c426..d63e9eb2 100644 --- a/luprex/core/cpp/util.cpp +++ b/luprex/core/cpp/util.cpp @@ -279,7 +279,7 @@ LuaSourcePtr read_lua_source(const std::string &dir) { std::string data = get_file_contents(dir + "/" + file); result->emplace_back(file, data); } - return std::move(result); + return result; } std::string XYZ::debug_string() const { diff --git a/luprex/core/cpp/world-core.cpp b/luprex/core/cpp/world-core.cpp index 4d8f6170..b525350f 100644 --- a/luprex/core/cpp/world-core.cpp +++ b/luprex/core/cpp/world-core.cpp @@ -254,7 +254,7 @@ util::IdVector World::get_near(int64_t player_id, float radius, bool exclude_now World::Redirects World::fetch_redirects() { World::Redirects result = std::move(redirects_); redirects_.clear(); - return std::move(result); + return result; } int64_t World::create_login_actor() {