示例#1
0
bool PSpawnedVehicles::UnspawnVehicle( u32 nLocalId )
{
  u16 Index;
  PSpawnedVehicle* tVhc;

  if (( nLocalId <= mVhcBaseLocalId ) && ( nLocalId > ( mVhcBaseLocalId - mSpawnedVehicles.size() ) ) )
  {
    Index = mVhcBaseLocalId - nLocalId;
    tVhc = mSpawnedVehicles[Index];
    if ( tVhc )
    {
      if ( tVhc->GetInformation().GetStatus() != 2 )
      {
        tVhc->SetStatus( 0 );
      }
      delete tVhc;
      mSpawnedVehicles[Index] = NULL;
      if ( mNextFreeHint > Index )
      {
        mNextFreeHint = Index;
      }
      return true;
    }
  }

  return false;
}
示例#2
0
bool PVehicles::GetVehicleInfo( u32 nVehicleId, PVehicleInformation* nInfo ) const
{
  PSpawnedVehicle* tVhc = GetSpawnedVehicle( nVehicleId );
  if ( tVhc )
  {
    *nInfo = tVhc->GetInformation();
    return true;
  }
  else
  {
    return nInfo->Load( nVehicleId );
  }
}
示例#3
0
PSpawnedVehicle* PVehicles::SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoordinates const* nVhcPos )
{
  PSpawnedVehicle* newVhc = NULL;
  PWorld* cWorld;
  PVehicleInformation nVhcInfo;

  if (( nLocation != PWorlds::mNcSubwayWorldId ) && IsValidVehicle( nVehicleId ) && !IsSpawned( nVehicleId ) )
  {
    cWorld = Worlds->LeaseWorld( nLocation );

    if ( cWorld && GetVehicleInfo( nVehicleId, &nVhcInfo ) )
    {
      newVhc = cWorld->GetSpawnedVehicules()->SpawnVehicle( &nVhcInfo, nVhcPos );
      if ( newVhc )
      {
        if ( !RegisterSpawnedVehicle( newVhc ) )
        {
          Console->Print( RED, BLACK, "[Error] PVehicles::SpawnVehicle : Could not register spawned vhc" );
        }
        if( gDevDebug )
          Console->Print( "%d Spawned vhc %d (local 0x%04x) type %d (requested: %d)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), newVhc->GetVehicleId(), newVhc->GetLocalId(), newVhc->GetInformation().GetVehicleType(), nVhcInfo.GetVehicleType() );
      }
      else
        Console->Print( RED, BLACK, "[Error] PVehicles::SpawnVehicle : Could not create vhc" );
    }

    Worlds->ReleaseWorld( nLocation );
  }

  return newVhc;
}