From b8dda388e0cf300f573d411dc670099e56c2e3c3 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Fri, 18 Aug 2017 11:29:54 +0100 Subject: Represent cItem::m_Lore as an AStringVector (#3882) * Replace cItem::m_Lore with AStringVector * Reword deprecation warning * Fix lua bindings --- src/Bindings/DeprecatedBindings.cpp | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/Bindings/DeprecatedBindings.cpp') diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index e75250604..3ae1fd990 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -347,6 +347,58 @@ static int tolua_set_cBlockInfo_m_PlaceSound(lua_State * tolua_S) +static int tolua_get_cItem_m_Lore(lua_State * tolua_S) +{ + // Maintain legacy m_Lore variable as Lore table split by ` (grave-accent) + cLuaState L(tolua_S); + if (!L.CheckParamSelf("const cItem")) + { + return 0; + } + + const cItem * Self = nullptr; + L.GetStackValue(1, Self); + + AString LoreString = StringJoin(Self->m_LoreTable, "`"); + + L.Push(LoreString); + + LOGWARNING("cItem.m_Lore is deprecated, use cItem.m_LoreTable instead"); + L.LogStackTrace(0); + return 1; +} + + + + + +static int tolua_set_cItem_m_Lore(lua_State * tolua_S) +{ + // Maintain legacy m_Lore variable as Lore table split by ` (grave-accent) + cLuaState L(tolua_S); + if ( + !L.CheckParamSelf("cItem") || + !L.CheckParamString(2) + ) + { + return 0; + } + + cItem * Self = nullptr; + AString LoreString; + L.GetStackValues(1, Self, LoreString); + + Self->m_LoreTable = StringSplit(LoreString, "`"); + + LOGWARNING("cItem.m_Lore is deprecated, use cItem.m_LoreTable instead"); + L.LogStackTrace(0); + return 0; +} + + + + + /* method: Trace of class cTracer */ static int tolua_cTracer_Trace(lua_State * a_LuaState) { @@ -500,6 +552,10 @@ void DeprecatedBindings::Bind(lua_State * tolua_S) tolua_variable(tolua_S, "m_PlaceSound", tolua_get_cBlockInfo_m_PlaceSound, tolua_set_cBlockInfo_m_PlaceSound); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cItem"); + tolua_variable(tolua_S, "m_Lore", tolua_get_cItem_m_Lore, tolua_set_cItem_m_Lore); + tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cTracer"); tolua_function(tolua_S, "Trace", tolua_cTracer_Trace); tolua_endmodule(tolua_S); -- cgit v1.2.3