@@ -1767,13 +1767,13 @@ int CLuaElementDefs::SetElementData(lua_State* luaVM)
17671767{
17681768 // bool setElementData ( element theElement, string key, var value, [bool synchronize = true] )
17691769 CClientEntity* pEntity;
1770- SString strKey ;
1770+ CStringName key ;
17711771 CLuaArgument value;
17721772 bool bSynchronize;
17731773
17741774 CScriptArgReader argStream (luaVM);
17751775 argStream.ReadUserData (pEntity);
1776- argStream.ReadString (strKey );
1776+ argStream.ReadStringName (key );
17771777 argStream.ReadLuaArgument (value);
17781778 argStream.ReadBool (bSynchronize, true );
17791779
@@ -1782,15 +1782,16 @@ int CLuaElementDefs::SetElementData(lua_State* luaVM)
17821782 CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine (luaVM);
17831783 if (pLuaMain)
17841784 {
1785- if (strKey. length () > MAX_CUSTOMDATA_NAME_LENGTH)
1785+ if (key-> length () > MAX_CUSTOMDATA_NAME_LENGTH)
17861786 {
17871787 // Warn and truncate if key is too long
17881788 m_pScriptDebugging->LogCustom (luaVM, SString (" Truncated argument @ '%s' [%s]" , lua_tostring (luaVM, lua_upvalueindex (1 )),
17891789 *SString (" string length reduced to %d characters at argument 2" , MAX_CUSTOMDATA_NAME_LENGTH)));
1790- strKey = strKey.Left (MAX_CUSTOMDATA_NAME_LENGTH);
1790+
1791+ key = key->substr (0 , MAX_CUSTOMDATA_NAME_LENGTH);
17911792 }
17921793
1793- if (CStaticFunctionDefinitions::SetElementData (*pEntity, strKey , value, bSynchronize))
1794+ if (CStaticFunctionDefinitions::SetElementData (*pEntity, key. ToCString () , value, bSynchronize))
17941795 {
17951796 lua_pushboolean (luaVM, true );
17961797 return 1 ;
@@ -1809,26 +1810,27 @@ int CLuaElementDefs::RemoveElementData(lua_State* luaVM)
18091810{
18101811 // bool removeElementData ( element theElement, string key )
18111812 CClientEntity* pEntity;
1812- SString strKey ;
1813+ CStringName key ;
18131814
18141815 CScriptArgReader argStream (luaVM);
18151816 argStream.ReadUserData (pEntity);
1816- argStream.ReadString (strKey );
1817+ argStream.ReadStringName (key );
18171818
18181819 if (!argStream.HasErrors ())
18191820 {
18201821 CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine (luaVM);
18211822 if (pLuaMain)
18221823 {
1823- if (strKey. length () > MAX_CUSTOMDATA_NAME_LENGTH)
1824+ if (key-> length () > MAX_CUSTOMDATA_NAME_LENGTH)
18241825 {
18251826 // Warn and truncate if key is too long
18261827 m_pScriptDebugging->LogCustom (luaVM, SString (" Truncated argument @ '%s' [%s]" , lua_tostring (luaVM, lua_upvalueindex (1 )),
18271828 *SString (" string length reduced to %d characters at argument 2" , MAX_CUSTOMDATA_NAME_LENGTH)));
1828- strKey = strKey.Left (MAX_CUSTOMDATA_NAME_LENGTH);
1829+
1830+ key = key->substr (0 , MAX_CUSTOMDATA_NAME_LENGTH);
18291831 }
18301832
1831- if (CStaticFunctionDefinitions::RemoveElementData (*pEntity, strKey ))
1833+ if (CStaticFunctionDefinitions::RemoveElementData (*pEntity, key. ToCString () ))
18321834 {
18331835 lua_pushboolean (luaVM, true );
18341836 return 1 ;
0 commit comments