BOOL GetICCStatusDO(USHORT Ctn, UCHAR ucSlot, USHORT *lr, UCHAR *rsp) { *lr = 0; if(ucSlot) { if(GetSlotState(Ctn, ucSlot, &rsp[2]) ) { rsp[0] = 0x80; rsp[1] = 0x01; rsp[3] = 0x90; rsp[4] = 0x00; *lr=5; } } else { if(GetSlotState(Ctn, 1, &rsp[2]) && GetSlotState(Ctn, 2, &rsp[3]) ) { rsp[0] = 0x80; rsp[1] = 0x02; rsp[4] = 0x90; rsp[5] = 0x00; *lr=6; } } return (*lr>0); }
void CVehicleManager::FlagForRespawn(EntityId vehicleID) { if(GetSlotState(vehicleID)) { m_pVehicles[vehicleID]->SetWasted(TRUE); m_iRespawnDelay[vehicleID] = 150; } }
void EvictAssetsAsNecessary(assets_s* assets) { Assert(assets->memoryNeeded < assets->dyMemoryBlock.stack.size) uint64_t memoryEvicted = 0; cell_s* cellToCheck = assets->assetUseQueue.head; while(memoryEvicted < assets->memoryNeeded) { assetData_s* leastRecentlyUsedAsset = (assetData_s*) cellToCheck->data; //(assetData_s*) Pop(&assets->assetUseQueue); assetState_e state = GetSlotState(leastRecentlyUsedAsset); cell_s* nextCell; if(state == assetState_loaded && !IsLocked(leastRecentlyUsedAsset)) { memoryEvicted += EvictAsset(assets, leastRecentlyUsedAsset); nextCell = cellToCheck->next; RemoveCell(&assets->assetUseQueue, cellToCheck); } else { nextCell = cellToCheck->next; } cellToCheck = nextCell; } assets->memoryNeeded = 0; }
BOOL CVehiclePool::Delete(BYTE byteVehicleID) { if(!GetSlotState(byteVehicleID) || !m_pVehicles[byteVehicleID]) { return FALSE; } m_bVehicleSlotState[byteVehicleID] = FALSE; delete m_pVehicles[byteVehicleID]; m_pVehicles[byteVehicleID] = NULL; return TRUE; }
BOOL CPickupPool::Delete(BYTE bytePickupID) { if(!GetSlotState(bytePickupID) || !m_pPickups[bytePickupID]) { return FALSE; } m_bPickupSlotState[bytePickupID] = FALSE; delete m_pPickups[bytePickupID]; m_pPickups[bytePickupID] = NULL; return TRUE; }
BOOL CPedPool::Delete(BYTE bytePedID) { if(!GetSlotState(bytePedID) || !m_pPeds[bytePedID]) { return FALSE; } m_bPedSlotState[bytePedID] = FALSE; delete m_pPeds[bytePedID]; m_pPeds[bytePedID] = NULL; return TRUE; }
BOOL CVehicleManager::Delete(EntityId vehicleID) { if(!GetSlotState(vehicleID) || !m_pVehicles[vehicleID]) { return FALSE; } m_bVehicleSlotState[vehicleID] = FALSE; delete m_pVehicles[vehicleID]; m_pVehicles[vehicleID] = NULL; pScripts->onVehicleDestroy(vehicleID); return TRUE; }
BOOL CVehiclePool::Delete(VEHICLEID VehicleID) { if(!GetSlotState(VehicleID) || !m_pVehicles[VehicleID]) { return FALSE; // Vehicle already deleted or not used. } m_bVehicleSlotState[VehicleID] = FALSE; delete m_pVehicles[VehicleID]; m_pVehicles[VehicleID] = NULL; m_pGTAVehicles[VehicleID] = 0; return TRUE; }
void CVehiclePool::AssignSpecialParamsToVehicle(VEHICLEID VehicleID, BYTE byteObjective, BYTE byteDoorsLocked) { if(!GetSlotState(VehicleID)) return; CVehicle *pVehicle = m_pVehicles[VehicleID]; if(pVehicle && m_bIsActive[VehicleID]) { if (byteObjective) { pVehicle->m_byteObjectiveVehicle = 1; pVehicle->m_bSpecialMarkerEnabled = false; } pVehicle->SetDoorState(byteDoorsLocked); } }
BOOL CPlayerPool::Delete(BYTE bytePlayerID, BYTE byteReason) { if(!GetSlotState(bytePlayerID) || !m_pPlayers[bytePlayerID]) { return FALSE; } m_bPlayerSlotState[bytePlayerID] = FALSE; delete m_pPlayers[bytePlayerID]; m_pPlayers[bytePlayerID] = NULL; if(pChatWindow) { pChatWindow->AddInfoMessage("*** %s left the server. (%s)", m_szPlayerNames[bytePlayerID],szQuitReasons[byteReason]); } return TRUE; }
int CVehiclePool::FindNearestToLocalPlayerPed() { float fLeastDistance=10000.0f; float fThisDistance; VEHICLEID ClosestSoFar=INVALID_VEHICLE_ID; VEHICLEID x=0; while(x < MAX_VEHICLES) { if(GetSlotState(x) && m_bIsActive[x]) { fThisDistance = m_pVehicles[x]->GetDistanceFromLocalPlayerPed(); if(fThisDistance < fLeastDistance) { fLeastDistance = fThisDistance; ClosestSoFar = x; } } x++; } return ClosestSoFar; }
uint64_t EvictAsset(assets_s* assets, assetData_s* assetSlot) { Assert(GetSlotState(assetSlot) == assetState_loaded); uint64_t memoryEvicted; void* start; uint32_t memorySize; { assetSlotType_e type = GetSlotType(assetSlot); switch(type) { case(assetSlotType_bitmap): { start = assetSlot->bitmap.memory; break; } case(assetSlotType_sound): { start = assetSlot->sound.samples[0]; break; } default: { memoryEvicted = 0; return memoryEvicted; } } memorySize = assetSlot->memorySize; ContractMemory(&assets->dyMemoryBlock.stack, start, memorySize); SetSlotState(assetSlot, assetState_unloaded); } memoryEvicted = memorySize; for(cell_s* cell = assets->assetUseQueue.head; cell != NULL; cell = cell->next) { assetData_s* slotToMove = (assetData_s*) cell->data; assetSlotType_e type = GetSlotType(slotToMove); uint8_t* memory; switch(type) { case(assetSlotType_bitmap): { memory = (uint8_t*) slotToMove->bitmap.memory; break; } case(assetSlotType_sound): { memory = (uint8_t*) slotToMove->sound.samples[0]; break; } default: { memory = NULL; break; } } if(memory > start) { memory = memory - memorySize; } } ShiftBlocksBack(&assets->dyMemoryBlock, (uint8_t*) start, memorySize); return memoryEvicted; }
CVehicle* CVehiclePool::GetVehicle( _VehicleID vehicleID ) { if( GetSlotState( vehicleID ) == false ) return (CVehicle*)0; return this->vehicles[ vehicleID ]; }
void CVehiclePool::Process() { BYTE x=0; CVehicle *pVehicle; DWORD dwThisTime = GetTickCount(); while(x != MAX_VEHICLES) { if(GetSlotState(x) == TRUE) { // It's inuse. pVehicle = m_pVehicles[x]; if(m_bIsActive[x]) { if(pVehicle->GetHealth() == 0.0f) { // It's dead SetForRespawn(x); } else if(pVehicle->HasExceededWorldBoundries( pNetGame->m_WorldBounds[0],pNetGame->m_WorldBounds[1], pNetGame->m_WorldBounds[2],pNetGame->m_WorldBounds[3])) { if(pVehicle->IsOkToRespawn()) { SetForRespawn(x); } } else if(pVehicle->GetVehicleSubtype() != VEHICLE_SUBTYPE_BOAT && pVehicle->GetVehicleSubtype() != VEHICLE_SUBTYPE_PLANE && pVehicle->HasSunk()) // Not boat and has sunk. { SetForRespawn(x); } else { if(pVehicle->IsDriverLocalPlayer()) { pVehicle->SetInvulnerable(FALSE); } else { pVehicle->SetInvulnerable(TRUE); } // Lock vehicles beyond given radius. if(pVehicle->GetDistanceFromLocalPlayerPed() > 300.0f) { pVehicle->SetLockedState(1); } else { pVehicle->SetLockedState(0); } if(pVehicle->GetVehicleSubtype() == VEHICLE_SUBTYPE_BIKE) { pVehicle->VerifyControlState(); } // code to respawn vehicle after it has been idle for 4 minutes pVehicle->UpdateLastDrivenTime(); if(pVehicle->m_bHasBeenDriven) { if((dwThisTime - pVehicle->m_dwTimeSinceLastDriven) > 250000) { SetForRespawn(x); } } } } else // !m_bIsActive { if(m_iRespawnDelay[x] != 0) { m_iRespawnDelay[x]--; } else { if(pVehicle->IsOkToRespawn()) { Spawn(x,m_SpawnInfo[x].byteVehicleType,&m_SpawnInfo[x].vecPos, m_SpawnInfo[x].fRotation,m_SpawnInfo[x].iColor1,m_SpawnInfo[x].iColor2); } } } } x++; } }
void CVehiclePool::Process() { // Process all vehicles in the vehicle pool. CVehicle *pVehicle; DWORD dwThisTime = GetTickCount(); CPlayerPool* pPlayerPool = pNetGame->GetPlayerPool(); CLocalPlayer* pLocalPlayer = pPlayerPool->GetLocalPlayer(); int iLocalPlayersInRange = 0; if (pLocalPlayer) iLocalPlayersInRange = pLocalPlayer->DetermineNumberOfPlayersInLocalRange(); ProcessWaitingList(); for(VEHICLEID x = 0; x != MAX_VEHICLES; x++) { if(GetSlotState(x) == TRUE) { // It's in use. pVehicle = m_pVehicles[x]; if(m_bIsActive[x]) { if(pVehicle->IsDriverLocalPlayer()) { pVehicle->SetInvulnerable(FALSE); } else { pVehicle->SetInvulnerable(TRUE); } if (pVehicle->GetHealth() == 0.0f) // || pVehicle->IsWrecked()) // It's dead { if (pLocalPlayer->m_LastVehicle == x) // Notify server of death { NotifyVehicleDeath(x); } continue; } if( pVehicle->GetVehicleSubtype() != VEHICLE_SUBTYPE_BOAT && pVehicle->HasSunk() ) // Not boat and has sunk. { if (pLocalPlayer->m_LastVehicle == x) { NotifyVehicleDeath(x); } continue; } // Active and in world. pLocalPlayer->ProcessUndrivenSync(x, pVehicle, iLocalPlayersInRange); // sync unoccupied vehicle if needed /* This has an impact on undriven passenger sync. check for driver instead // Kye: This the source of the audio bug? if(!pVehicle->IsOccupied()) { pVehicle->SetEngineState(FALSE); } else { pVehicle->SetEngineState(TRUE); }*/ // Update the actual ingame pointer if it's not the same as the one we have listed. if(pVehicle->m_pVehicle != m_pGTAVehicles[x]) { m_pGTAVehicles[x] = pVehicle->m_pVehicle; } pVehicle->ProcessMarkers(); } } } }