diff --git a/Laptop/PostalService.cpp b/Laptop/PostalService.cpp index 84fa5b57..0303185f 100644 --- a/Laptop/PostalService.cpp +++ b/Laptop/PostalService.cpp @@ -952,6 +952,38 @@ UINT16 CPostalService::RemoveDestination(UINT16 usDestinationID) return usDestinationID; } +// WANNE: This method returns, if a given sector (x, y, z) is a shipment destination sector +BOOLEAN CPostalService::IsSectorAShipmentSector(UINT8 ubMapX, UINT8 ubMapY, UINT8 ubMapZ) +{ + BOOLEAN isShipmentSector = FALSE; + + vector destinations; + RefToDestinationListIterator dli = LookupDestinationList().begin(); + + while (dli != LookupDestinationList().end()) + { + destinations.push_back(&DESTINATION(dli)); + dli++; + } + + for (unsigned int i = 0; i < destinations.size(); i++) + { + PDestinationStruct destStruct = destinations.at(i); + if (destStruct) + { + if (destStruct->ubMapX == ubMapX && + destStruct->ubMapY == ubMapY && + destStruct->ubMapZ == ubMapZ) + { + isShipmentSector = TRUE; + break; + } + } + } + + return isShipmentSector; +} + UINT16 CPostalService::GetShipmentCount(SHIPMENT_STATUS TargetedShipmentStatus) { if(_Shipments.empty()) diff --git a/Laptop/PostalService.h b/Laptop/PostalService.h index 6297e40d..b567643f 100644 --- a/Laptop/PostalService.h +++ b/Laptop/PostalService.h @@ -222,6 +222,9 @@ public: UINT16 RemoveDestination(UINT16 usDestinationID); RefToDestinationStruct GetDestination(UINT16 usDestinationID) const; RefToDestinationList LookupDestinationList(void) const; + + // WANNE: + BOOLEAN IsSectorAShipmentSector(UINT8 ubMapX, UINT8 ubMapY, UINT8 ubMapZ); // Delivery method management UINT8 AddDeliveryMethod(STR16 pszDescription); diff --git a/Strategic/Player Command.cpp b/Strategic/Player Command.cpp index 7eeb05a4..f10526ca 100644 --- a/Strategic/Player Command.cpp +++ b/Strategic/Player Command.cpp @@ -27,10 +27,10 @@ #include "Random.h" #endif +#include "postalservice.h" extern BOOLEAN fMapScreenBottomDirty; - - +extern CPostalService gPostalService; void GetSectorFacilitiesFlags( INT16 sMapX, INT16 sMapY, STR16 sFacilitiesString ) { @@ -144,10 +144,21 @@ BOOLEAN SetThisSectorAsPlayerControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, B return FALSE; } - // check if we ever grabbed drassen airport, if so, set fact we can go to BR's - if( ( sMapX == BOBBYR_SHIPPING_DEST_SECTOR_X ) && ( sMapY == BOBBYR_SHIPPING_DEST_SECTOR_Y ) ) + if (LaptopSaveInfo.fBobbyRSiteCanBeAccessed == FALSE) { - LaptopSaveInfo.fBobbyRSiteCanBeAccessed = TRUE; + // Check if the sector is a shipment sector + BOOLEAN isShipmentSector = gPostalService.IsSectorAShipmentSector((UINT8)sMapX, (UINT8)sMapY, (UINT8)bMapZ); + + if (isShipmentSector) + LaptopSaveInfo.fBobbyRSiteCanBeAccessed = TRUE; + } + + // WANNE: Get Airport sector from ShippingDestination.xml file! + // check if we ever grabbed drassen airport, if so, set fact we can go to BR's + //if( ( sMapX == BOBBYR_SHIPPING_DEST_SECTOR_X ) && ( sMapY == BOBBYR_SHIPPING_DEST_SECTOR_Y ) ) + if (LaptopSaveInfo.fBobbyRSiteCanBeAccessed) + { + //LaptopSaveInfo.fBobbyRSiteCanBeAccessed = TRUE; //If the player has been to Bobbyr when it was down, and we havent already sent email, send him an email if( LaptopSaveInfo.ubHaveBeenToBobbyRaysAtLeastOnceWhileUnderConstruction == BOBBYR_BEEN_TO_SITE_ONCE && LaptopSaveInfo.ubHaveBeenToBobbyRaysAtLeastOnceWhileUnderConstruction != BOBBYR_ALREADY_SENT_EMAIL )