@@ -1540,14 +1540,14 @@ int CLuaElementDefs::setElementData(lua_State* luaVM)
15401540{
15411541 // bool setElementData ( element theElement, string key, var value, [var syncMode = true] )
15421542 CElement* pElement;
1543- SString strKey ;
1543+ CStringName key ;
15441544 CLuaArgument value;
15451545 ESyncType syncType = ESyncType::BROADCAST;
15461546 std::optional<eCustomDataClientTrust> clientTrust{};
15471547
15481548 CScriptArgReader argStream (luaVM);
15491549 argStream.ReadUserData (pElement);
1550- argStream.ReadString (strKey );
1550+ argStream.ReadStringName (key );
15511551 argStream.ReadLuaArgument (value);
15521552
15531553 if (argStream.NextIsBool ())
@@ -1571,15 +1571,15 @@ int CLuaElementDefs::setElementData(lua_State* luaVM)
15711571 {
15721572 LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
15731573
1574- if (strKey. length () > MAX_CUSTOMDATA_NAME_LENGTH)
1574+ if (key-> length () > MAX_CUSTOMDATA_NAME_LENGTH)
15751575 {
15761576 // Warn and truncate if key is too long
15771577 m_pScriptDebugging->LogCustom (luaVM, SString (" Truncated argument @ '%s' [%s]" , lua_tostring (luaVM, lua_upvalueindex (1 )),
15781578 *SString (" string length reduced to %d characters at argument 2" , MAX_CUSTOMDATA_NAME_LENGTH)));
1579- strKey = strKey. Left ( MAX_CUSTOMDATA_NAME_LENGTH);
1579+ key = key-> substr ( 0 , MAX_CUSTOMDATA_NAME_LENGTH);
15801580 }
15811581
1582- if (CStaticFunctionDefinitions::SetElementData (pElement, strKey , value, syncType, clientTrust))
1582+ if (CStaticFunctionDefinitions::SetElementData (pElement, key. ToCString () , value, syncType, clientTrust))
15831583 {
15841584 lua_pushboolean (luaVM, true );
15851585 return 1 ;
@@ -1596,25 +1596,25 @@ int CLuaElementDefs::removeElementData(lua_State* luaVM)
15961596{
15971597 // bool removeElementData ( element theElement, string key )
15981598 CElement* pElement;
1599- SString strKey ;
1599+ CStringName key ;
16001600
16011601 CScriptArgReader argStream (luaVM);
16021602 argStream.ReadUserData (pElement);
1603- argStream.ReadString (strKey );
1603+ argStream.ReadStringName (key );
16041604
16051605 if (!argStream.HasErrors ())
16061606 {
16071607 LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
16081608
1609- if (strKey. length () > MAX_CUSTOMDATA_NAME_LENGTH)
1609+ if (key-> length () > MAX_CUSTOMDATA_NAME_LENGTH)
16101610 {
16111611 // Warn and truncate if key is too long
16121612 m_pScriptDebugging->LogCustom (luaVM, SString (" Truncated argument @ '%s' [%s]" , lua_tostring (luaVM, lua_upvalueindex (1 )),
16131613 *SString (" string length reduced to %d characters at argument 2" , MAX_CUSTOMDATA_NAME_LENGTH)));
1614- strKey = strKey. Left ( MAX_CUSTOMDATA_NAME_LENGTH);
1614+ key = key-> substr ( 0 , MAX_CUSTOMDATA_NAME_LENGTH);
16151615 }
16161616
1617- if (CStaticFunctionDefinitions::RemoveElementData (pElement, strKey ))
1617+ if (CStaticFunctionDefinitions::RemoveElementData (pElement, key. ToCString () ))
16181618 {
16191619 lua_pushboolean (luaVM, true );
16201620 return 1 ;
@@ -1631,19 +1631,19 @@ int CLuaElementDefs::addElementDataSubscriber(lua_State* luaVM)
16311631{
16321632 // bool addElementDataSubscriber ( element theElement, string key, player thePlayer )
16331633 CElement* pElement;
1634- SString strKey ;
1634+ CStringName key ;
16351635 CPlayer* pPlayer;
16361636
16371637 CScriptArgReader argStream (luaVM);
16381638 argStream.ReadUserData (pElement);
1639- argStream.ReadString (strKey );
1639+ argStream.ReadStringName (key );
16401640 argStream.ReadUserData (pPlayer);
16411641
16421642 if (!argStream.HasErrors ())
16431643 {
16441644 LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
16451645
1646- if (CStaticFunctionDefinitions::AddElementDataSubscriber (pElement, strKey , pPlayer))
1646+ if (CStaticFunctionDefinitions::AddElementDataSubscriber (pElement, key. ToCString () , pPlayer))
16471647 {
16481648 lua_pushboolean (luaVM, true );
16491649 return 1 ;
@@ -1660,19 +1660,19 @@ int CLuaElementDefs::removeElementDataSubscriber(lua_State* luaVM)
16601660{
16611661 // bool removeElementDataSubscriber ( element theElement, string key, player thePlayer )
16621662 CElement* pElement;
1663- SString strKey ;
1663+ CStringName key ;
16641664 CPlayer* pPlayer;
16651665
16661666 CScriptArgReader argStream (luaVM);
16671667 argStream.ReadUserData (pElement);
1668- argStream.ReadString (strKey );
1668+ argStream.ReadStringName (key );
16691669 argStream.ReadUserData (pPlayer);
16701670
16711671 if (!argStream.HasErrors ())
16721672 {
16731673 LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
16741674
1675- if (CStaticFunctionDefinitions::RemoveElementDataSubscriber (pElement, strKey , pPlayer))
1675+ if (CStaticFunctionDefinitions::RemoveElementDataSubscriber (pElement, key. ToCString () , pPlayer))
16761676 {
16771677 lua_pushboolean (luaVM, true );
16781678 return 1 ;
@@ -1689,19 +1689,19 @@ int CLuaElementDefs::hasElementDataSubscriber(lua_State* luaVM)
16891689{
16901690 // bool hasElementDataSubscriber ( element theElement, string key, player thePlayer )
16911691 CElement* pElement;
1692- SString strKey ;
1692+ CStringName key ;
16931693 CPlayer* pPlayer;
16941694
16951695 CScriptArgReader argStream (luaVM);
16961696 argStream.ReadUserData (pElement);
1697- argStream.ReadString (strKey );
1697+ argStream.ReadStringName (key );
16981698 argStream.ReadUserData (pPlayer);
16991699
17001700 if (!argStream.HasErrors ())
17011701 {
17021702 LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
17031703
1704- bool bResult = CStaticFunctionDefinitions::HasElementDataSubscriber (pElement, strKey , pPlayer);
1704+ bool bResult = CStaticFunctionDefinitions::HasElementDataSubscriber (pElement, key. ToCString () , pPlayer);
17051705 lua_pushboolean (luaVM, bResult);
17061706 return 1 ;
17071707 }
0 commit comments