File tree Expand file tree Collapse file tree 4 files changed +22
-12
lines changed
Client/mods/deathmatch/logic
Server/mods/deathmatch/logic/luadefs Expand file tree Collapse file tree 4 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -171,11 +171,11 @@ CClientEntity::~CClientEntity(void)
171
171
// return MapContains ( ms_ValidEntityMap, pEntity );
172
172
// }
173
173
174
- void CClientEntity::SetTypeName (const char * szName )
174
+ void CClientEntity::SetTypeName (const SString& name )
175
175
{
176
176
CClientEntity::RemoveEntityFromRoot (m_uiTypeHash, this );
177
- m_strTypeName.AssignLeft (szName , MAX_TYPENAME_LENGTH);
178
- m_uiTypeHash = HashString (szName );
177
+ m_strTypeName.AssignLeft (name , MAX_TYPENAME_LENGTH);
178
+ m_uiTypeHash = HashString (name );
179
179
if (IsFromRoot (m_pParent))
180
180
CClientEntity::AddEntityFromRoot (m_uiTypeHash, this );
181
181
}
Original file line number Diff line number Diff line change @@ -175,9 +175,9 @@ class CClientEntity : public CClientEntityBase
175
175
const SString& GetName (void ) const { return m_strName; }
176
176
void SetName (const char * szName) { m_strName.AssignLeft (szName, MAX_ELEMENT_NAME_LENGTH); }
177
177
178
- const char * GetTypeName (void ) { return m_strTypeName; };
179
- unsigned int GetTypeHash (void ) { return m_uiTypeHash; };
180
- void SetTypeName (const char * szName );
178
+ const SString& GetTypeName () { return m_strTypeName; }
179
+ unsigned int GetTypeHash () { return m_uiTypeHash; }
180
+ void SetTypeName (const SString& name );
181
181
182
182
CClientEntity* GetParent (void ) { return m_pParent; };
183
183
CClientEntity* SetParent (CClientEntity* pParent);
Original file line number Diff line number Diff line change @@ -934,10 +934,12 @@ int CLuaElementDefs::GetElementsWithinRange(lua_State* luaVM)
934
934
{
935
935
CVector position;
936
936
float radius;
937
+ SString elementType;
937
938
938
939
CScriptArgReader argStream (luaVM);
939
940
argStream.ReadVector3D (position);
940
941
argStream.ReadNumber (radius);
942
+ argStream.ReadString (elementType, " " );
941
943
942
944
if (!argStream.HasErrors ())
943
945
{
@@ -950,9 +952,12 @@ int CLuaElementDefs::GetElementsWithinRange(lua_State* luaVM)
950
952
951
953
for (CClientEntity* entity : result)
952
954
{
953
- lua_pushnumber (luaVM, ++index);
954
- lua_pushelement (luaVM, entity);
955
- lua_settable (luaVM, -3 );
955
+ if (elementType.empty () || elementType == entity->GetTypeName ())
956
+ {
957
+ lua_pushnumber (luaVM, ++index);
958
+ lua_pushelement (luaVM, entity);
959
+ lua_settable (luaVM, -3 );
960
+ }
956
961
}
957
962
958
963
return 1 ;
Original file line number Diff line number Diff line change @@ -992,10 +992,12 @@ int CLuaElementDefs::getElementsWithinRange(lua_State* luaVM)
992
992
{
993
993
CVector position;
994
994
float radius;
995
+ SString elementType;
995
996
996
997
CScriptArgReader argStream (luaVM);
997
998
argStream.ReadVector3D (position);
998
999
argStream.ReadNumber (radius);
1000
+ argStream.ReadString (elementType, " " );
999
1001
1000
1002
if (!argStream.HasErrors ())
1001
1003
{
@@ -1008,9 +1010,12 @@ int CLuaElementDefs::getElementsWithinRange(lua_State* luaVM)
1008
1010
1009
1011
for (CElement* entity : result)
1010
1012
{
1011
- lua_pushnumber (luaVM, ++index);
1012
- lua_pushelement (luaVM, entity);
1013
- lua_settable (luaVM, -3 );
1013
+ if (elementType.empty () || elementType == entity->GetTypeName ())
1014
+ {
1015
+ lua_pushnumber (luaVM, ++index);
1016
+ lua_pushelement (luaVM, entity);
1017
+ lua_settable (luaVM, -3 );
1018
+ }
1014
1019
}
1015
1020
1016
1021
return 1 ;
You can’t perform that action at this time.
0 commit comments