Skip to content

Commit db9530d

Browse files
committed
Fixed power calculation bug
1 parent c42790a commit db9530d

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

Source/MicroCity/Connectivity.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@
55
void PowerFloodFill(uint8_t x, uint8_t y);
66
uint8_t* GetPowerGrid();
77

8-
#ifdef _WIN32
9-
// A 1 bit per tile representation of which tiles are powered
10-
inline uint8_t* GetPowerGrid()
11-
{
12-
// TODO: if arduboy then reuse the screen buffer memory
13-
static uint8_t PowerGrid[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8];
14-
15-
return PowerGrid;
16-
}
17-
#endif
18-
198
uint8_t GetConnections(int x, int y)
209
{
2110
if (x >= 0 && x < MAP_WIDTH && y >= 0 && y < MAP_HEIGHT)
@@ -445,15 +434,7 @@ void PowerFloodFill(uint8_t x, uint8_t y)
445434
void PowerFloodFill(uint8_t x, uint8_t y)
446435
{
447436
uint8_t* grid = (uint8_t*)GetPowerGrid();
448-
uint8_t* ptr = grid;
449-
int count = MAP_WIDTH * MAP_HEIGHT / 8;
450-
451-
while (count--)
452-
{
453-
*ptr++ = 0;
454-
}
455-
456-
uint8_t* stackPtr = ptr;
437+
uint8_t* stackPtr = grid;
457438
uint8_t stackSize = 0;
458439

459440
STACK_PUSH(x, y);

Source/Windows/MicroCity/WinMain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ uint8_t GetInput()
106106
return InputMask;
107107
}
108108

109+
uint8_t* GetPowerGrid()
110+
{
111+
static uint8_t PowerGrid[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8];
112+
return PowerGrid;
113+
}
109114

110115
int main(int argc, char* argv[])
111116
{

0 commit comments

Comments
 (0)