void CVehicle::StoreEmptyVehicle(EMPTYVEHICLESYNCPACKET * syncPacket) { // Check stuff if(syncPacket->bLights != GetLights()) SetLights(syncPacket->bLights); if(syncPacket->bSirenState != GetSirenState()) SetSirenState(syncPacket->bSirenState); if(syncPacket->bTaxiLights != GetTaxiLights()) TurnTaxiLights(syncPacket->bTaxiLights); if(syncPacket->fDirtLevel != GetDirtLevel()) SetDirtLevel(syncPacket->fDirtLevel); if(syncPacket->fPetrolHealth != GetPetrolTankHealth()) SetPetrolTankHealth(syncPacket->fPetrolHealth); if(syncPacket->uiHealth != GetHealth()) SetHealth(syncPacket->uiHealth); // Only when the vehicle stands still -> update stuff /*if(syncPacket->vecMoveSpeed.Length() == 0) { CVector3 vecPos; GetPosition(vecPos); if((vecPos-syncPacket->vecPosition).Length() > 5.0f || (vecPos-syncPacket->vecPosition).Length() < -5.0f) SetPosition(syncPacket->vecPosition); CVector3 vecRot; GetRotation(vecRot); if((vecRot-syncPacket->vecRotation).Length() > 5.0f || (vecRot-syncPacket->vecRotation).Length() < -5.0f) SetRotation(syncPacket->vecRotation); CVector3 vecTurnSpeed; GetTurnSpeed(vecTurnSpeed); if((vecTurnSpeed-syncPacket->vecTurnSpeed).Length() > 5.0f || (vecTurnSpeed-syncPacket->vecTurnSpeed).Length() < -5.0f) SetTurnSpeed(syncPacket->vecTurnSpeed); CVector3 vecMoveSpeed; GetMoveSpeed(vecMoveSpeed); if((vecMoveSpeed-syncPacket->vecMoveSpeed).Length() > 5.0f || (vecMoveSpeed-syncPacket->vecMoveSpeed).Length() < -5.0f) SetMoveSpeed(syncPacket->vecMoveSpeed); }*/ /*for(unsigned int ui = 0; ui <= 3; ui++) { if(syncPacket->bWindow[ui] != m_bWindow[ui]) SetWindowState(ui, syncPacket->bWindow[ui]); } for(unsigned int ui = 0; ui <= 5; ui++) { if(syncPacket->bTyre[ui] != m_bTyre[ui]) SetTyreState(ui, syncPacket->bTyre[ui]); }*/ }
bool CVehicleEntity::Create() { if (!m_pModelInfo) return false; // Is the vehicle already spawned? if(IsSpawned()) return false; m_pModelInfo->AddReference(true); EFLC::IVehicle * pVehicle = pIVehicleFactory->Create(m_pModelInfo->GetIndex(), 1, 0, 0); if (pVehicle) { pVehicle->Function76(0); //pVehicle->m_byteFlags1 |= 4u; //pVehicle->m_dwFlags1 |= 8u; // set fixed wait for collision/ CWorld__AddEntity(pVehicle, false); CVehicleModelInfo__AddReference(m_pModelInfo->GetModelInfo()); // we dont want to turn on the engine // CVehicle__TurnEngineOn(pVehicle, true); pVehicle->m_byteFlags10 |= 8u; // This maybe cause pool overflow if much vehicles are created and destroyed [NEED TEST] // If this cause overflow try to delete the create physics before call or disable the call in VehicleFactory::Create // Using this above *(WORD*) (g_pCore->GetBase() + 0x4B48D5) = 0x9090; before call to vehiclefactory [TESTED => crash] // Can someone confirm if this cause pool overflow or not if (*(DWORD*) pVehicle != COffsets::VAR_CBoat__VFTable) // Otherwise client crash if boat is on ground (not in water) { pVehicle->CreatePhysics(); pVehicle->ProcessInput(); } m_pModelInfo->RemoveReference(); m_pVehicle = new EFLC::CVehicle(pVehicle); //set the vehicle's color SetColors(m_dwColor[0], m_dwColor[1], m_dwColor[2], m_dwColor[3], m_dwColor[4]); //fix: no more random components for (int i = 0; i < 9; ++i) SetComponentState(i, false); // Mark as spawned m_bSpawned = true; // Reset the vehicle //Reset(); SetPosition(m_vecSpawnPosition); SetRotation(m_vecRotation); SetEngineState(GetEngineState()); m_pVehicle->SetHeadlights(GetLightsState()); if (GetSirenState()) SetSirenState(true); if (GetTaxiLightsState()) SetTaxiLightsState(true); CLogFile::Printf("Created vehicle! (Id: %d, Handle: %X)", m_vehicleId, g_pCore->GetGame()->GetPools()->GetVehiclePool()->HandleOf(pVehicle)); return true; } else { CLogFile::Printf("Created vehicle failed!"); return false; } }