From 9aa64710bcffc2d0e343fed6523e9eb9ba57c52d Mon Sep 17 00:00:00 2001 From: Pirulax Date: Mon, 6 Aug 2018 14:53:49 +0200 Subject: [PATCH 1/8] Fix getElementBoundingBox() OOP version returning 6 numbers instead of a 2 vectors --- .../logic/luadefs/CLuaElementDefs.cpp | 43 ++++++++++++++++++- .../logic/luadefs/CLuaElementDefs.h | 1 + 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 7b6d412da7..a1ffadbc22 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -129,7 +129,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "getChildrenCount", "getElementChildrenCount"); lua_classfunction(luaVM, "getID", "getElementID"); lua_classfunction(luaVM, "getParent", "getElementParent"); - lua_classfunction(luaVM, "getBoundingBox", "getElementBoundingBox"); + lua_classfunction(luaVM, "getBoundingBox", OOP_GetElementBoundingBox); lua_classfunction(luaVM, "getPosition", OOP_GetElementPosition); lua_classfunction(luaVM, "getRotation", OOP_GetElementRotation); lua_classfunction(luaVM, "getMatrix", OOP_GetElementMatrix); @@ -199,6 +199,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "distanceFromCentreOfMassToBaseOfModel", NULL, "getElementDistanceFromCentreOfMassToBaseOfModel"); lua_classvariable(luaVM, "radius", NULL, "getElementRadius"); lua_classvariable(luaVM, "childrenCount", NULL, "getElementChildrenCount"); + lua_classfunction(luaVM, "boundingBox", NULL, OOP_GetElementBoundingBox); lua_classvariable(luaVM, "position", SetElementPosition, OOP_GetElementPosition); lua_classvariable(luaVM, "rotation", OOP_SetElementRotation, OOP_GetElementRotation); lua_classvariable(luaVM, "matrix", SetElementMatrix, OOP_GetElementMatrix); @@ -1000,6 +1001,46 @@ int CLuaElementDefs::GetElementDimension(lua_State* luaVM) return 1; } +int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) +{ + // Verify the argument + CClientEntity* pEntity; + bool bLegacy; + CScriptArgReader argStream(luaVM); + argStream.ReadUserData(pEntity); + argStream.ReadBool(bLegacy, true); + + if (!argStream.HasErrors()) + { + // Grab the bounding box and return it + CVector vecMin, vecMax; + if (CStaticFunctionDefinitions::GetElementBoundingBox(*pEntity, vecMin, vecMax)) + { + if (!bLegacy) + { + lua_pushvector(luaVM, vecMin) + lua_pushvector(luaVM, vecMax) + } + else + { + lua_pushnumber(luaVM, vecMin.fX); + lua_pushnumber(luaVM, vecMin.fY); + lua_pushnumber(luaVM, vecMin.fZ); + lua_pushnumber(luaVM, vecMax.fX); + lua_pushnumber(luaVM, vecMax.fY); + lua_pushnumber(luaVM, vecMax.fZ); + } + + return 6; + } + } + else + m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); + + // Failed + lua_pushboolean(luaVM, false); + + int CLuaElementDefs::GetElementBoundingBox(lua_State* luaVM) { // Verify the argument diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 3e93e3d4aa..0a3d6c2b97 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -42,6 +42,7 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(GetElementDimension); LUA_DECLARE(GetElementZoneName); LUA_DECLARE(GetElementBoundingBox); + LUA_DECLARE_OOP(GetElementBoundingBox);// Probably wrong, tell me how to declare the OOP version of this. LUA_DECLARE(GetElementRadius); LUA_DECLARE(IsElementAttached); LUA_DECLARE(GetElementAttachedTo); From 3248b5c205354b0bd42ce627a598f3d2154196f9 Mon Sep 17 00:00:00 2001 From: Pirulax Date: Mon, 6 Aug 2018 15:50:46 +0200 Subject: [PATCH 2/8] Remove LUA_DECLARE_OOP at line 45 from the header. --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 0a3d6c2b97..3e93e3d4aa 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -42,7 +42,6 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(GetElementDimension); LUA_DECLARE(GetElementZoneName); LUA_DECLARE(GetElementBoundingBox); - LUA_DECLARE_OOP(GetElementBoundingBox);// Probably wrong, tell me how to declare the OOP version of this. LUA_DECLARE(GetElementRadius); LUA_DECLARE(IsElementAttached); LUA_DECLARE(GetElementAttachedTo); From 28702809b743817b94e105c262ffd3047a14dbe2 Mon Sep 17 00:00:00 2001 From: Pirulax Date: Wed, 8 Aug 2018 00:11:27 +0200 Subject: [PATCH 3/8] Added check for client version instead of bLegacy argument --- .../mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index a1ffadbc22..b954c15a4f 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -12,6 +12,7 @@ #include "StdInc.h" using std::list; +#define MIN_CLIENT_REQ_GETBOUNDINGBOX_OOP "1.5.5-9.13987" // Update this to the version number when merged void CLuaElementDefs::LoadFunctions(void) { @@ -1003,12 +1004,9 @@ int CLuaElementDefs::GetElementDimension(lua_State* luaVM) int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) { - // Verify the argument CClientEntity* pEntity; - bool bLegacy; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pEntity); - argStream.ReadBool(bLegacy, true); if (!argStream.HasErrors()) { @@ -1016,10 +1014,10 @@ int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) CVector vecMin, vecMax; if (CStaticFunctionDefinitions::GetElementBoundingBox(*pEntity, vecMin, vecMax)) { - if (!bLegacy) + if (!MinClientReqCheck(argStream, MIN_CLIENT_REQ_GETBOUNDINGBOX_OOP)) { - lua_pushvector(luaVM, vecMin) - lua_pushvector(luaVM, vecMax) + lua_pushvector(luaVM, vecMin); + lua_pushvector(luaVM, vecMax); } else { From a683700974192ecbfe49bcb9f03a3fc9c025574f Mon Sep 17 00:00:00 2001 From: Pirulax Date: Wed, 8 Aug 2018 00:12:38 +0200 Subject: [PATCH 4/8] Added LUA_DECLARE_OOP instead of LUA_DECLARE --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 3e93e3d4aa..b1c6386242 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -41,7 +41,8 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(GetElementsWithinRange); LUA_DECLARE(GetElementDimension); LUA_DECLARE(GetElementZoneName); - LUA_DECLARE(GetElementBoundingBox); + // DECLARE_OOP Declares both the normal and a OOP_ version of a given funciton, just for furtherer reference. + LUA_DECLARE_OOP(GetElementBoundingBox); LUA_DECLARE(GetElementRadius); LUA_DECLARE(IsElementAttached); LUA_DECLARE(GetElementAttachedTo); From 831f172070ae765c03c846b00dfeb8e93695d7ed Mon Sep 17 00:00:00 2001 From: Pirulax Date: Wed, 8 Aug 2018 12:13:06 +0200 Subject: [PATCH 5/8] fixed errors hopefully --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index b954c15a4f..5812f1ca67 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -1018,6 +1018,7 @@ int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) { lua_pushvector(luaVM, vecMin); lua_pushvector(luaVM, vecMax); + return 2; } else { @@ -1027,9 +1028,8 @@ int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) lua_pushnumber(luaVM, vecMax.fX); lua_pushnumber(luaVM, vecMax.fY); lua_pushnumber(luaVM, vecMax.fZ); - } - - return 6; + return 6; + } } } else @@ -1037,7 +1037,7 @@ int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) // Failed lua_pushboolean(luaVM, false); - +} int CLuaElementDefs::GetElementBoundingBox(lua_State* luaVM) { From 64fdbd0214caf35d3ef82791a235880c0e384496 Mon Sep 17 00:00:00 2001 From: Pirulax Date: Wed, 8 Aug 2018 12:18:50 +0200 Subject: [PATCH 6/8] maybe now I fixed every mistake I made in my life --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 5812f1ca67..fa24f3793c 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -200,7 +200,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "distanceFromCentreOfMassToBaseOfModel", NULL, "getElementDistanceFromCentreOfMassToBaseOfModel"); lua_classvariable(luaVM, "radius", NULL, "getElementRadius"); lua_classvariable(luaVM, "childrenCount", NULL, "getElementChildrenCount"); - lua_classfunction(luaVM, "boundingBox", NULL, OOP_GetElementBoundingBox); + lua_classvariable(luaVM, "boundingBox", NULL, OOP_GetElementBoundingBox); lua_classvariable(luaVM, "position", SetElementPosition, OOP_GetElementPosition); lua_classvariable(luaVM, "rotation", OOP_SetElementRotation, OOP_GetElementRotation); lua_classvariable(luaVM, "matrix", SetElementMatrix, OOP_GetElementMatrix); From c7947ed85322586bd17b20a842c1c308844fe1ec Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Fri, 10 Aug 2018 03:46:30 +0100 Subject: [PATCH 7/8] rm -rf comment --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index b1c6386242..779a6346d1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -41,7 +41,6 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(GetElementsWithinRange); LUA_DECLARE(GetElementDimension); LUA_DECLARE(GetElementZoneName); - // DECLARE_OOP Declares both the normal and a OOP_ version of a given funciton, just for furtherer reference. LUA_DECLARE_OOP(GetElementBoundingBox); LUA_DECLARE(GetElementRadius); LUA_DECLARE(IsElementAttached); From 691a839c4c39b282bf022d272af0c6f018787844 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Fri, 10 Aug 2018 03:49:09 +0100 Subject: [PATCH 8/8] bump rev --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index fa24f3793c..b9a3fad8a8 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -12,7 +12,7 @@ #include "StdInc.h" using std::list; -#define MIN_CLIENT_REQ_GETBOUNDINGBOX_OOP "1.5.5-9.13987" // Update this to the version number when merged +#define MIN_CLIENT_REQ_GETBOUNDINGBOX_OOP "1.5.5-9.13999" void CLuaElementDefs::LoadFunctions(void) {