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

Function getRegionAt

bwapi/BWAPI/Source/BW/Pathing.cpp:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 }
59
60 const BW::region *getRegionAt(int x, int y)
61 {
62 BWAPI::TilePosition tp(x/32, y/32);
63 if ( tp.x < 0 || tp.y < 0 || tp.x >= 256 || tp.y >= 256 )
64 return nullptr;
65
66 // Obtain the region IDs from the positions
67 u16 id = BW::BWDATA::SAIPathing->mapTileRegionId[tp.y][tp.x];
68
69 // Check if the id is splitting the tile between regions
70 if ( id & 0xE000 )
71 {
72 // Correct the ID (convert higher bits)
73 id = (id & 0x1FFF) + ((id & 0xC000) >> 1);
74
75 // Get source region from split-tile based on walk tile
76 int minitilePosX = (x&0x1F)/8;
77 int minitilePosY = (y&0x1F)/8;
78 int minitileShift = minitilePosX + minitilePosY * 4;
79 BW::split *t = &BW::BWDATA::SAIPathing->splitTiles[id];
80 if ( (t->minitileMask >> minitileShift) & 1 )
81 return &BW::BWDATA::SAIPathing->regions[t->rgn2];
82 return &BW::BWDATA::SAIPathing->regions[t->rgn1];
83 }
84 else if ( id < 5000 )
85 {
86 // Get source region from tile
87 return &BW::BWDATA::SAIPathing->regions[id];
88 }
89 else
90 {
91 return nullptr;
92 }
93 }
94 const BW::region *getRegionAt(Position pos)
95 {
96 return getRegionAt(pos.x, pos.y);

Callers 2

getRegionAtMethod · 0.85
hasPathMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected