@@ -1540,14 +1540,14 @@ int CLuaElementDefs::setElementData(lua_State* luaVM)
1540
1540
{
1541
1541
// bool setElementData ( element theElement, string key, var value, [var syncMode = true] )
1542
1542
CElement* pElement;
1543
- SString strKey ;
1543
+ CStringName key ;
1544
1544
CLuaArgument value;
1545
1545
ESyncType syncType = ESyncType::BROADCAST;
1546
1546
std::optional<eCustomDataClientTrust> clientTrust{};
1547
1547
1548
1548
CScriptArgReader argStream (luaVM);
1549
1549
argStream.ReadUserData (pElement);
1550
- argStream.ReadString (strKey );
1550
+ argStream.ReadStringName (key );
1551
1551
argStream.ReadLuaArgument (value);
1552
1552
1553
1553
if (argStream.NextIsBool ())
@@ -1571,15 +1571,15 @@ int CLuaElementDefs::setElementData(lua_State* luaVM)
1571
1571
{
1572
1572
LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
1573
1573
1574
- if (strKey. length () > MAX_CUSTOMDATA_NAME_LENGTH)
1574
+ if (key-> length () > MAX_CUSTOMDATA_NAME_LENGTH)
1575
1575
{
1576
1576
// Warn and truncate if key is too long
1577
1577
m_pScriptDebugging->LogCustom (luaVM, SString (" Truncated argument @ '%s' [%s]" , lua_tostring (luaVM, lua_upvalueindex (1 )),
1578
1578
*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);
1580
1580
}
1581
1581
1582
- if (CStaticFunctionDefinitions::SetElementData (pElement, strKey , value, syncType, clientTrust))
1582
+ if (CStaticFunctionDefinitions::SetElementData (pElement, key. ToCString () , value, syncType, clientTrust))
1583
1583
{
1584
1584
lua_pushboolean (luaVM, true );
1585
1585
return 1 ;
@@ -1596,25 +1596,25 @@ int CLuaElementDefs::removeElementData(lua_State* luaVM)
1596
1596
{
1597
1597
// bool removeElementData ( element theElement, string key )
1598
1598
CElement* pElement;
1599
- SString strKey ;
1599
+ CStringName key ;
1600
1600
1601
1601
CScriptArgReader argStream (luaVM);
1602
1602
argStream.ReadUserData (pElement);
1603
- argStream.ReadString (strKey );
1603
+ argStream.ReadStringName (key );
1604
1604
1605
1605
if (!argStream.HasErrors ())
1606
1606
{
1607
1607
LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
1608
1608
1609
- if (strKey. length () > MAX_CUSTOMDATA_NAME_LENGTH)
1609
+ if (key-> length () > MAX_CUSTOMDATA_NAME_LENGTH)
1610
1610
{
1611
1611
// Warn and truncate if key is too long
1612
1612
m_pScriptDebugging->LogCustom (luaVM, SString (" Truncated argument @ '%s' [%s]" , lua_tostring (luaVM, lua_upvalueindex (1 )),
1613
1613
*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);
1615
1615
}
1616
1616
1617
- if (CStaticFunctionDefinitions::RemoveElementData (pElement, strKey ))
1617
+ if (CStaticFunctionDefinitions::RemoveElementData (pElement, key. ToCString () ))
1618
1618
{
1619
1619
lua_pushboolean (luaVM, true );
1620
1620
return 1 ;
@@ -1631,19 +1631,19 @@ int CLuaElementDefs::addElementDataSubscriber(lua_State* luaVM)
1631
1631
{
1632
1632
// bool addElementDataSubscriber ( element theElement, string key, player thePlayer )
1633
1633
CElement* pElement;
1634
- SString strKey ;
1634
+ CStringName key ;
1635
1635
CPlayer* pPlayer;
1636
1636
1637
1637
CScriptArgReader argStream (luaVM);
1638
1638
argStream.ReadUserData (pElement);
1639
- argStream.ReadString (strKey );
1639
+ argStream.ReadStringName (key );
1640
1640
argStream.ReadUserData (pPlayer);
1641
1641
1642
1642
if (!argStream.HasErrors ())
1643
1643
{
1644
1644
LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
1645
1645
1646
- if (CStaticFunctionDefinitions::AddElementDataSubscriber (pElement, strKey , pPlayer))
1646
+ if (CStaticFunctionDefinitions::AddElementDataSubscriber (pElement, key. ToCString () , pPlayer))
1647
1647
{
1648
1648
lua_pushboolean (luaVM, true );
1649
1649
return 1 ;
@@ -1660,19 +1660,19 @@ int CLuaElementDefs::removeElementDataSubscriber(lua_State* luaVM)
1660
1660
{
1661
1661
// bool removeElementDataSubscriber ( element theElement, string key, player thePlayer )
1662
1662
CElement* pElement;
1663
- SString strKey ;
1663
+ CStringName key ;
1664
1664
CPlayer* pPlayer;
1665
1665
1666
1666
CScriptArgReader argStream (luaVM);
1667
1667
argStream.ReadUserData (pElement);
1668
- argStream.ReadString (strKey );
1668
+ argStream.ReadStringName (key );
1669
1669
argStream.ReadUserData (pPlayer);
1670
1670
1671
1671
if (!argStream.HasErrors ())
1672
1672
{
1673
1673
LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
1674
1674
1675
- if (CStaticFunctionDefinitions::RemoveElementDataSubscriber (pElement, strKey , pPlayer))
1675
+ if (CStaticFunctionDefinitions::RemoveElementDataSubscriber (pElement, key. ToCString () , pPlayer))
1676
1676
{
1677
1677
lua_pushboolean (luaVM, true );
1678
1678
return 1 ;
@@ -1689,19 +1689,19 @@ int CLuaElementDefs::hasElementDataSubscriber(lua_State* luaVM)
1689
1689
{
1690
1690
// bool hasElementDataSubscriber ( element theElement, string key, player thePlayer )
1691
1691
CElement* pElement;
1692
- SString strKey ;
1692
+ CStringName key ;
1693
1693
CPlayer* pPlayer;
1694
1694
1695
1695
CScriptArgReader argStream (luaVM);
1696
1696
argStream.ReadUserData (pElement);
1697
- argStream.ReadString (strKey );
1697
+ argStream.ReadStringName (key );
1698
1698
argStream.ReadUserData (pPlayer);
1699
1699
1700
1700
if (!argStream.HasErrors ())
1701
1701
{
1702
1702
LogWarningIfPlayerHasNotJoinedYet (luaVM, pElement);
1703
1703
1704
- bool bResult = CStaticFunctionDefinitions::HasElementDataSubscriber (pElement, strKey , pPlayer);
1704
+ bool bResult = CStaticFunctionDefinitions::HasElementDataSubscriber (pElement, key. ToCString () , pPlayer);
1705
1705
lua_pushboolean (luaVM, bResult);
1706
1706
return 1 ;
1707
1707
}
0 commit comments