fix solar panels sometimes not working

This commit is contained in:
jacob1 2018-03-25 18:34:25 -04:00
parent 1b658a3022
commit 1f97199df6
2 changed files with 9 additions and 24 deletions

View File

@ -2741,33 +2741,19 @@ int Simulation::do_move(int i, int x, int y, float nxf, float nyf)
return result; 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 void Simulation::photoelectric_effect(int nx, int ny)//create sparks from PHOT when hitting PSCN and NSCN
{ {
unsigned r = pmap[ny][nx]; unsigned r = pmap[ny][nx];
if (TYP(r) == PT_PSCN) { if (TYP(r) == PT_PSCN)
if (TYP(pmap[ny][nx-1]) == PT_NSCN || {
TYP(pmap[ny][nx+1]) == PT_NSCN || 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 || TYP(pmap[ny+1][nx]) == PT_NSCN)
TYP(pmap[ny+1][nx]) == PT_NSCN) {
pn_junction_sprk(nx, ny, PT_PSCN); parts[ID(r)].ctype = PT_PSCN;
part_change_type(ID(r), nx, ny, PT_SPRK);
parts[ID(r)].life = 4;
}
} }
} }

View File

@ -127,7 +127,6 @@ public:
int is_blocking(int t, int x, int y); int is_blocking(int t, int x, int y);
int is_boundary(int pt, 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 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); void photoelectric_effect(int nx, int ny);
unsigned direction_to_map(float dx, float dy, int t); unsigned direction_to_map(float dx, float dy, int t);
int do_move(int i, int x, int y, float nxf, float nyf); int do_move(int i, int x, int y, float nxf, float nyf);