Skip to content

Commit

Permalink
fix solar panels sometimes not working
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Mar 25, 2018
1 parent 1b658a3 commit 1f97199
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
32 changes: 9 additions & 23 deletions src/simulation/Simulation.cpp
Expand Up @@ -2741,33 +2741,19 @@ int Simulation::do_move(int i, int x, int y, float nxf, float nyf)
return result;
}

int Simulation::pn_junction_sprk(int x, int y, int pt)
{
int r = pmap[y][x];
if (TYP(r) != pt)
return 0;
r >>= 8;
if (parts[r].type != pt)
return 0;
if (parts[r].life != 0)
return 0;

parts[r].ctype = pt;
part_change_type(r,x,y,PT_SPRK);
parts[r].life = 4;
return 1;
}

void Simulation::photoelectric_effect(int nx, int ny)//create sparks from PHOT when hitting PSCN and NSCN
{
unsigned r = pmap[ny][nx];

if (TYP(r) == PT_PSCN) {
if (TYP(pmap[ny][nx-1]) == PT_NSCN ||
TYP(pmap[ny][nx+1]) == PT_NSCN ||
TYP(pmap[ny-1][nx]) == PT_NSCN ||
TYP(pmap[ny+1][nx]) == PT_NSCN)
pn_junction_sprk(nx, ny, PT_PSCN);
if (TYP(r) == PT_PSCN)
{
if (TYP(pmap[ny][nx-1]) == PT_NSCN || TYP(pmap[ny][nx+1]) == PT_NSCN ||
TYP(pmap[ny-1][nx]) == PT_NSCN || TYP(pmap[ny+1][nx]) == PT_NSCN)
{
parts[ID(r)].ctype = PT_PSCN;
part_change_type(ID(r), nx, ny, PT_SPRK);
parts[ID(r)].life = 4;
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/simulation/Simulation.h
Expand Up @@ -127,7 +127,6 @@ class Simulation
int is_blocking(int t, int x, int y);
int is_boundary(int pt, int x, int y);
int find_next_boundary(int pt, int *x, int *y, int dm, int *em);
int pn_junction_sprk(int x, int y, int pt);
void photoelectric_effect(int nx, int ny);
unsigned direction_to_map(float dx, float dy, int t);
int do_move(int i, int x, int y, float nxf, float nyf);
Expand Down

0 comments on commit 1f97199

Please sign in to comment.