From 49d33bea55f46d2f61029f0dee9c3dfeb4d7c679 Mon Sep 17 00:00:00 2001 From: S6066 Date: Tue, 10 Jul 2018 14:48:23 +0200 Subject: [PATCH] Implement LuaImpl* for Vector[2|3] (#170) * Implement LuaImplQueryArg for Vector[2|3]i * Implement LuaImplReplyVal for Vector[2|3]i * Edit changelog * Fix previous commit crash * Network/ENetPeer: Fix reliable sequence number wrap error * Edit changelog * what have I done to changelog --- ChangeLog.md | 1 + SDK/include/NDK/LuaAPI.inl | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 39d2b3431..5bafdd7fc 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -125,6 +125,7 @@ Nazara Engine: - ⚠️ Removed Vector[2|3]::Distancef method and made Distance method templated - Added Vector2::Distance static method - ⚠️ Fixed compilation errors on MSVC with flag /permissive- on CullingList class +- Added LuaImplQueryArg & LuaImplReplyVal functions for Vector[2|3] - Fixed bug in ENet implementation causing legit reliable packets to be dropped on sequence number overflow Nazara Development Kit: diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 318bb6add..40fe33ec7 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -269,6 +269,15 @@ namespace Nz return ret; } + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2i* vec, TypeTag) + { + Vector2d vecDouble; + unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); + + vec->Set(vecDouble); + return ret; + } + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3d* vec, TypeTag) { switch (state.GetType(index)) @@ -308,6 +317,15 @@ namespace Nz return ret; } + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3i* vec, TypeTag) + { + Vector3d vecDouble; + unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); + + vec->Set(vecDouble); + return ret; + } + inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::Entity** handle, TypeTag) { if (!state.IsOfType(index, LuaType_Nil)) @@ -538,6 +556,12 @@ namespace Nz return 1; } + inline int LuaImplReplyVal(const LuaState& state, Vector2i&& val, TypeTag) + { + state.PushInstance("Vector2", val); + return 1; + } + inline int LuaImplReplyVal(const LuaState& state, Vector3d&& val, TypeTag) { state.PushInstance("Vector3", val); @@ -556,6 +580,12 @@ namespace Nz return 1; } + inline int LuaImplReplyVal(const LuaState& state, Vector3i&& val, TypeTag) + { + state.PushInstance("Vector3", val); + return 1; + } + inline int LuaImplReplyVal(const LuaState& state, Ndk::Entity* ptr, TypeTag) { state.PushInstance("Entity", ptr);