From 2c3c1f15273835923d9bd4950a19ee88a95ee0f4 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 May 2017 14:34:36 +0200 Subject: Tracer replacement (#3704) * Replaced cTracer usage with cLineBlockTracer. * Exported new cLineBlockTracer utility functions to Lua API. --- Server/Plugins/Debuggers/Debuggers.lua | 72 ++++++++++++++++++++++++++++++++++ Server/Plugins/Debuggers/Info.lua | 12 ++++++ 2 files changed, 84 insertions(+) (limited to 'Server/Plugins/Debuggers') diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua index 7d7246484..fb18a0c19 100644 --- a/Server/Plugins/Debuggers/Debuggers.lua +++ b/Server/Plugins/Debuggers/Debuggers.lua @@ -1838,6 +1838,44 @@ end +function HandleConsoleHitTrace(a_Split) + local world = cRoot:Get():GetDefaultWorld() + local s = Vector3d(0, 70, 0) + local e = Vector3d(100, 75, 100) + if (tonumber(a_Split[2])) then + s.x = tonumber(a_Split[2]) + end + if (tonumber(a_Split[3])) then + s.y = tonumber(a_Split[3]) + end + if (tonumber(a_Split[4])) then + s.z = tonumber(a_Split[4]) + end + if (tonumber(a_Split[5])) then + e.x = tonumber(a_Split[5]) + end + if (tonumber(a_Split[6])) then + e.y = tonumber(a_Split[6]) + end + if (tonumber(a_Split[7])) then + e.z = tonumber(a_Split[7]) + end + local res, hitCoords, hitBlockCoords, hitBlockFace = cLineBlockTracer:FirstSolidHitTrace(world, s, e) + if (res) then + return true, string.format("The line hits block {%d, %d, %d} at point {%f, %f, %f}, face %s", + hitBlockCoords.x, hitBlockCoords.y, hitBlockCoords.z, + hitCoords.x, hitCoords.y, hitCoords.z, + BlockFaceToString(hitBlockFace) + ) + else + return true, "The two points specified don't have a solid block between them." + end +end + + + + + --- Monitors the state of the "inh" entity-spawning hook -- if false, the hook is installed before the "inh" command processing local isInhHookInstalled = false @@ -1954,6 +1992,40 @@ end +function HandleConsoleLosTrace(a_Split) + local world = cRoot:Get():GetDefaultWorld() + local s = Vector3d(0, 70, 0) + local e = Vector3d(100, 75, 100) + if (tonumber(a_Split[2])) then + s.x = tonumber(a_Split[2]) + end + if (tonumber(a_Split[3])) then + s.y = tonumber(a_Split[3]) + end + if (tonumber(a_Split[4])) then + s.z = tonumber(a_Split[4]) + end + if (tonumber(a_Split[5])) then + e.x = tonumber(a_Split[5]) + end + if (tonumber(a_Split[6])) then + e.y = tonumber(a_Split[6]) + end + if (tonumber(a_Split[7])) then + e.z = tonumber(a_Split[7]) + end + local res = cLineBlockTracer:LineOfSightTrace(world, s, e, cLineBlockTracer.losAir) + if (res) then + return true, "The two points can see each other." + else + return true, "The two points cannot see each other" + end +end + + + + + function HandleConsolePluginStats(a_Split) cPluginManager:ForEachPlugin( function (a_CBPlugin) diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua index 8b2e7017b..dea656837 100644 --- a/Server/Plugins/Debuggers/Info.lua +++ b/Server/Plugins/Debuggers/Info.lua @@ -290,6 +290,12 @@ g_PluginInfo = HelpString = "Tests the crypto hashing functions", }, + ["hittrace"] = + { + Handler = HandleConsoleHitTrace, + HelpString = "Tests the FirstSolidHit trace", + }, + ["inh"] = { Handler = HandleConsoleInh, @@ -302,6 +308,12 @@ g_PluginInfo = HelpString = "Loads the specified chunk into memory", }, + ["lostrace"] = + { + Handler = HandleConsoleLosTrace, + HelpString = "Tests a LineOfSight trace", + }, + ["pluginstats"] = { Handler = HandleConsolePluginStats, -- cgit v1.2.3