// ----------------------------------------------------------------------- // // // ROUTINE: CLightCycleMgr::RemoveCyclist // // PURPOSE: Completely removes a light cycle from the manager // // ----------------------------------------------------------------------- // bool CLightCycleMgr::RemoveCyclist(HOBJECT hObj) { // Since we're removing from the list, we need to walk it manually std::vector<LIGHT_CYCLIST*>::iterator iter; for(iter=m_collCyclists.begin();iter!=m_collCyclists.end();iter++) { if((*iter)->hObject == hObj) { // We found him. Killlllll! KIIIILLLLLLLLL! LIGHT_CYCLIST* pCyclist = (*iter); debug_delete(pCyclist); // Remove from list m_collCyclists.erase(iter); // Notify the client CAutoMessage cMsg; cMsg.WriteByte(LCI_REMOVE_CYCLIST); cMsg.WriteObject(hObj); g_pLTServer->SendToClient(cMsg, MID_LIGHT_CYCLE_INFO, NULL, MESSAGE_GUARANTEED); return true; } } return false; }
// ----------------------------------------------------------------------- // // // ROUTINE: CLightCycleMgr::AddCyclist // // PURPOSE: Creats a new cyclist and adds it to the list // // ----------------------------------------------------------------------- // bool CLightCycleMgr::AddCyclist(HOBJECT hObj, bool bUpdate) { // Allocate LIGHT_CYCLIST* pCyclist = debug_new(LIGHT_CYCLIST); pCyclist->bUpdating = bUpdate; pCyclist->hObject = hObj; // Add to our list m_collCyclists.push_back(pCyclist); // Tell the client CAutoMessage cMsg; cMsg.WriteByte(LCI_ADD_CYCLIST); cMsg.WriteObject(hObj); cMsg.WriteByte((uint8)bUpdate); g_pLTServer->SendToClient(cMsg, MID_LIGHT_CYCLE_INFO, NULL, MESSAGE_GUARANTEED); return true; }
// ----------------------------------------------------------------------- // // // ROUTINE: CLightCycleMgr::DerezCyclist // // PURPOSE: Starts a light cycle derez // // ----------------------------------------------------------------------- // bool CLightCycleMgr::DerezCyclist(HOBJECT hObj) { // Sanity check LIGHT_CYCLIST* pCyclist = FindCyclist(hObj); if(!pCyclist) return false; // Maybe we're already derezzing if(pCyclist->fStartDerezTime != 0.0f) { ASSERT(FALSE); return true; } // Start the derez timer pCyclist->fStartDerezTime = g_pLTServer->GetTime(); CAutoMessage cMsg; cMsg.WriteByte(LCI_DEREZ_CYCLIST); cMsg.WriteObject(hObj); g_pLTServer->SendToClient(cMsg, MID_LIGHT_CYCLE_INFO, NULL, MESSAGE_GUARANTEED); return true; }