| 933 | |
| 934 | |
| 935 | void cWorld::TickClients(float a_Dt) |
| 936 | { |
| 937 | cClientHandleList RemoveClients; |
| 938 | { |
| 939 | cCSLock Lock(m_CSClients); |
| 940 | |
| 941 | // Remove clients scheduled for removal: |
| 942 | for (cClientHandleList::iterator itr = m_ClientsToRemove.begin(), end = m_ClientsToRemove.end(); itr != end; ++itr) |
| 943 | { |
| 944 | m_Clients.remove(*itr); |
| 945 | } // for itr - m_ClientsToRemove[] |
| 946 | m_ClientsToRemove.clear(); |
| 947 | |
| 948 | // Add clients scheduled for adding: |
| 949 | for (cClientHandleList::iterator itr = m_ClientsToAdd.begin(), end = m_ClientsToAdd.end(); itr != end; ++itr) |
| 950 | { |
| 951 | if (std::find(m_Clients.begin(), m_Clients.end(), *itr) != m_Clients.end()) |
| 952 | { |
| 953 | ASSERT(!"Adding a client that is already in the clientlist"); |
| 954 | continue; |
| 955 | } |
| 956 | m_Clients.push_back(*itr); |
| 957 | } // for itr - m_ClientsToRemove[] |
| 958 | m_ClientsToAdd.clear(); |
| 959 | |
| 960 | // Tick the clients, take out those that have been destroyed into RemoveClients |
| 961 | for (cClientHandleList::iterator itr = m_Clients.begin(); itr != m_Clients.end();) |
| 962 | { |
| 963 | if ((*itr)->IsDestroyed()) |
| 964 | { |
| 965 | // Remove the client later, when CS is not held, to avoid deadlock |
| 966 | RemoveClients.push_back(*itr); |
| 967 | itr = m_Clients.erase(itr); |
| 968 | continue; |
| 969 | } |
| 970 | (*itr)->Tick(a_Dt); |
| 971 | ++itr; |
| 972 | } // for itr - m_Clients[] |
| 973 | } |
| 974 | |
| 975 | // Delete the clients that have been destroyed |
| 976 | for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr) |
| 977 | { |
| 978 | delete *itr; |
| 979 | } // for itr - RemoveClients[] |
| 980 | } |
| 981 | |
| 982 | |
| 983 |
nothing calls this directly
no test coverage detected