Skip to content
Permalink
Browse files

Add 'elementType' parameter to getElementsWithinRange

  • Loading branch information...
Jusonex committed Jul 29, 2018
1 parent 922b85e commit de149ef89c5bc36fc9521db018116080240e95a0
@@ -171,11 +171,11 @@ CClientEntity::~CClientEntity(void)
// return MapContains ( ms_ValidEntityMap, pEntity );
//}

void CClientEntity::SetTypeName(const char* szName)
void CClientEntity::SetTypeName(const SString& name)
{
CClientEntity::RemoveEntityFromRoot(m_uiTypeHash, this);
m_strTypeName.AssignLeft(szName, MAX_TYPENAME_LENGTH);
m_uiTypeHash = HashString(szName);
m_strTypeName.AssignLeft(name, MAX_TYPENAME_LENGTH);
m_uiTypeHash = HashString(name);
if (IsFromRoot(m_pParent))
CClientEntity::AddEntityFromRoot(m_uiTypeHash, this);
}
@@ -175,9 +175,9 @@ class CClientEntity : public CClientEntityBase
const SString& GetName(void) const { return m_strName; }
void SetName(const char* szName) { m_strName.AssignLeft(szName, MAX_ELEMENT_NAME_LENGTH); }

const char* GetTypeName(void) { return m_strTypeName; };
unsigned int GetTypeHash(void) { return m_uiTypeHash; };
void SetTypeName(const char* szName);
const SString& GetTypeName() { return m_strTypeName; }
unsigned int GetTypeHash() { return m_uiTypeHash; }
void SetTypeName(const SString& name);

CClientEntity* GetParent(void) { return m_pParent; };
CClientEntity* SetParent(CClientEntity* pParent);
@@ -934,10 +934,12 @@ int CLuaElementDefs::GetElementsWithinRange(lua_State* luaVM)
{
CVector position;
float radius;
SString elementType;

CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(position);
argStream.ReadNumber(radius);
argStream.ReadString(elementType, "");

if (!argStream.HasErrors())
{
@@ -950,9 +952,12 @@ int CLuaElementDefs::GetElementsWithinRange(lua_State* luaVM)

for (CClientEntity* entity : result)
{
lua_pushnumber(luaVM, ++index);
lua_pushelement(luaVM, entity);
lua_settable(luaVM, -3);
if (elementType.empty() || elementType == entity->GetTypeName())
{
lua_pushnumber(luaVM, ++index);
lua_pushelement(luaVM, entity);
lua_settable(luaVM, -3);
}
}

return 1;
@@ -992,10 +992,12 @@ int CLuaElementDefs::getElementsWithinRange(lua_State* luaVM)
{
CVector position;
float radius;
SString elementType;

CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(position);
argStream.ReadNumber(radius);
argStream.ReadString(elementType, "");

if (!argStream.HasErrors())
{
@@ -1008,9 +1010,12 @@ int CLuaElementDefs::getElementsWithinRange(lua_State* luaVM)

for (CElement* entity : result)
{
lua_pushnumber(luaVM, ++index);
lua_pushelement(luaVM, entity);
lua_settable(luaVM, -3);
if (elementType.empty() || elementType == entity->GetTypeName())
{
lua_pushnumber(luaVM, ++index);
lua_pushelement(luaVM, entity);
lua_settable(luaVM, -3);
}
}

return 1;

0 comments on commit de149ef

Please sign in to comment.
You can’t perform that action at this time.