Yo remplazaria esto en el .h
std::vector<RESPLOC_DATA> m_RespLoc;
por esto
std::map<int,RESPLOC_DATA> m_RespLoc;
y en el cpp
en void cRespawnLocation::Load(char* path)
cambiaria esto:
this->m_RespLoc.push_back(info);
por esto:
this->m_RespLoc.insert(std::pair<int,RESPLOC_DATA>(info.Map, info));
cambiaria esto
bool cRespawnLocation::IsMap(LPOBJ lpObj)
{
for(std::vector<RESPLOC_DATA>::iterator it=this->m_RespLoc.begin();it != this->m_RespLoc.end();it++)
{
if (it->Map == lpObj->Map)
{
return true;
}
}
return false;
}
por esto
bool cRespawnLocation::IsMap(LPOBJ lpObj)
{
std::map<int,RESPLOC_DATA>::iterator it = this->m_RespLoc.find(lpObj->Map);
if (it == this->m_CustomMixInfo.end())
{
return 0;
}
else
{
return 1;
}
}
y por ultimo cambiaría esto
bool cRespawnLocation::GetUserRespawnLocation(LPOBJ lpObj,int* gate,int* map,int* x,int* y,int* dir,int* level)
{
bool result = 0;
for(std::vector<RESPLOC_DATA>::iterator it=this->m_RespLoc.begin();it != this->m_RespLoc.end();it++)
{
if (lpObj->Map == it->Map)
{
if (it->MoveGate == 0)
{
return 0;
}
result = gGate.GetGate(it->Gate,gate,map,x,y,dir,level);
if (lpObj->Map == MAP_KANTURU3)
{
gKanturuBattleUserMng.DelUserData(lpObj->Index);
}
if (lpObj->Map == MAP_RAKLION2)
{
gRaklionBattleUserMng.DelUserData(lpObj->Index);
}
}
}
return result;
}
por esto
bool cRespawnLocation::GetUserRespawnLocation(LPOBJ lpObj,int* gate,int* map,int* x,int* y,int* dir,int* level)
{
std::map<int,RESPLOC_DATA>::iterator it = this->m_RespLoc.find(lpObj->Map);
if (it == this->m_CustomMixInfo.end() || it->second.MoveGate == 0)
{
return 0;
}
if (lpObj->Map == MAP_KANTURU3)
{
gKanturuBattleUserMng.DelUserData(lpObj->Index);
}
if (lpObj->Map == MAP_RAKLION2)
{
gRaklionBattleUserMng.DelUserData(lpObj->Index);
}
return gGate.GetGate(it->second.Gate,gate,map,x,y,dir,level);
}
eso seria todo entonces no tenemos que recorrer todo un vector si no que vamos directamente al que necesitamos, aunque no parezca aceleramos mucho la lectura, perdón si me equivoque en algo lo hice a ojo. Saludos a todos.