mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 22:15:37 +08:00
postpone variable definitions as long as possible (Effective C++ item 26)
This commit is contained in:
@@ -105,15 +105,14 @@ namespace BlackCore
|
|||||||
CUserList CContextNetwork::getUsers() const
|
CUserList CContextNetwork::getUsers() const
|
||||||
{
|
{
|
||||||
CUserList users;
|
CUserList users;
|
||||||
CUser user;
|
|
||||||
foreach(CAtcStation station, this->m_atcStationsOnline)
|
foreach(CAtcStation station, this->m_atcStationsOnline)
|
||||||
{
|
{
|
||||||
user = station.getController();
|
CUser user = station.getController();
|
||||||
users.push_back(user);
|
users.push_back(user);
|
||||||
}
|
}
|
||||||
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
||||||
{
|
{
|
||||||
user = aircraft.getPilot();
|
CUser user = aircraft.getPilot();
|
||||||
users.push_back(user);
|
users.push_back(user);
|
||||||
}
|
}
|
||||||
return users;
|
return users;
|
||||||
@@ -127,17 +126,15 @@ namespace BlackCore
|
|||||||
CUserList users;
|
CUserList users;
|
||||||
if (callsigns.isEmpty()) return users;
|
if (callsigns.isEmpty()) return users;
|
||||||
CCallsignList searchList(callsigns);
|
CCallsignList searchList(callsigns);
|
||||||
CUser user;
|
|
||||||
CCallsign callsign;
|
|
||||||
|
|
||||||
// do aircrafts first, this will handle most callsigns
|
// do aircrafts first, this will handle most callsigns
|
||||||
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
||||||
{
|
{
|
||||||
if (searchList.isEmpty()) break;
|
if (searchList.isEmpty()) break;
|
||||||
callsign = aircraft.getCallsign();
|
CCallsign callsign = aircraft.getCallsign();
|
||||||
if (searchList.contains(callsign))
|
if (searchList.contains(callsign))
|
||||||
{
|
{
|
||||||
user = aircraft.getPilot();
|
CUser user = aircraft.getPilot();
|
||||||
users.push_back(user);
|
users.push_back(user);
|
||||||
searchList.remove(callsign);
|
searchList.remove(callsign);
|
||||||
}
|
}
|
||||||
@@ -146,10 +143,10 @@ namespace BlackCore
|
|||||||
foreach(CAtcStation station, this->m_atcStationsOnline)
|
foreach(CAtcStation station, this->m_atcStationsOnline)
|
||||||
{
|
{
|
||||||
if (searchList.isEmpty()) break;
|
if (searchList.isEmpty()) break;
|
||||||
callsign = station.getCallsign();
|
CCallsign callsign = station.getCallsign();
|
||||||
if (searchList.contains(callsign))
|
if (searchList.contains(callsign))
|
||||||
{
|
{
|
||||||
user = station.getController();
|
CUser user = station.getController();
|
||||||
users.push_back(user);
|
users.push_back(user);
|
||||||
searchList.remove(callsign);
|
searchList.remove(callsign);
|
||||||
}
|
}
|
||||||
@@ -158,7 +155,7 @@ namespace BlackCore
|
|||||||
// we might have unresolved callsigns
|
// we might have unresolved callsigns
|
||||||
foreach(CCallsign callsign, searchList)
|
foreach(CCallsign callsign, searchList)
|
||||||
{
|
{
|
||||||
user = CUser();
|
CUser user;
|
||||||
user.setCallsign(callsign);
|
user.setCallsign(callsign);
|
||||||
users.push_back(user);
|
users.push_back(user);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user