MCPcopy Create free account
hub / github.com/bwapi/bwapi / getRegionAt

Method getRegionAt

bwapi/BWAPIClient/Source/GameImpl.cpp:912–946  ·  view source on GitHub ↗

------------------------------------------------- GET REGION AT ------------------------------------------

Source from the content-addressed store, hash-verified

910 }
911 //------------------------------------------------- GET REGION AT ------------------------------------------
912 BWAPI::Region GameImpl::getRegionAt(int x, int y) const
913 {
914 if ( !Position(x,y) )
915 {
916 this->setLastError(BWAPI::Errors::Invalid_Parameter);
917 return nullptr;
918 }
919 unsigned short idx = data->mapTileRegionId[x/32][y/32];
920 if ( idx & 0x2000 )
921 {
922 const int minitilePosX = (x&0x1F)/8;
923 const int minitilePosY = (y&0x1F)/8;
924 const int minitileShift = minitilePosX + minitilePosY * 4;
925 const int index = idx & 0x1FFF;
926 if (index >= std::extent<decltype(data->mapSplitTilesMiniTileMask)>::value)
927 return nullptr;
928
929 unsigned short miniTileMask = data->mapSplitTilesMiniTileMask[index];
930
931 if (index >= std::extent<decltype(data->mapSplitTilesRegion1)>::value)
932 return nullptr;
933
934 if ((miniTileMask >> minitileShift) & 1)
935 {
936 unsigned short rgn2 = data->mapSplitTilesRegion2[index];
937 return this->getRegion(rgn2);
938 }
939 else
940 {
941 unsigned short rgn1 = data->mapSplitTilesRegion1[index];
942 return this->getRegion(rgn1);
943 }
944 }
945 return this->getRegion(idx);
946 }
947 int GameImpl::getLastEventTime() const
948 {
949 return 0;

Callers

nothing calls this directly

Calls 3

setLastErrorMethod · 0.95
getRegionMethod · 0.95
PositionClass · 0.50

Tested by

no test coverage detected