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. --- src/Bindings/DeprecatedBindings.cpp | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/Bindings/DeprecatedBindings.cpp') diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index 0ffc58cbb..029d4edb7 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -10,6 +10,7 @@ #include "../World.h" #include "../Entities/Player.h" #include "LuaState.h" +#include "../Tracer.h" @@ -291,6 +292,47 @@ tolua_lerror: +/* method: Trace of class cTracer */ +static int tolua_cTracer_Trace(lua_State * a_LuaState) +{ + // Log a deprecation warning with stacktrace: + cLuaState S(a_LuaState); + LOGWARNING("The function cTracer:Trace is obsolete, use the cLineBlockTracer instead"); + S.LogStackTrace(); + + // Check params: + if ( + !S.CheckParamUserType(1, "cTracer") || + !S.CheckParamUserType(2, "const Vector3", 3) || + !S.CheckParamNumber (4) + ) + { + return 0; + } + + // Read params: + cTracer * self; + Vector3d * start; + Vector3d * direction; + int distance; + bool lineOfSight = false; + if (!S.GetStackValues(1, self, start, direction, distance)) + { + LOGWARNING("Cannot retrieve parameters for cTracer::Trace. Expected a cTracer (self), Vector3d, Vector3d, number and optional boolean."); + S.LogStackValues(); + return 0; + } + S.GetStackValue(5, lineOfSight); + + // Call and push the result: + S.Push(self->Trace(*start, *direction, distance, lineOfSight)); + return 1; +} + + + + + /** function: cWorld:SetSignLines */ static int tolua_cWorld_SetSignLines(lua_State * tolua_S) { @@ -398,6 +440,10 @@ void DeprecatedBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "StringToMobType", tolua_AllToLua_StringToMobType00); + tolua_beginmodule(tolua_S, "cTracer"); + tolua_function(tolua_S, "Trace", tolua_cTracer_Trace); + tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cWorld"); tolua_function(tolua_S, "UpdateSign", tolua_cWorld_SetSignLines); tolua_endmodule(tolua_S); -- cgit v1.2.3