Update gravity walls, fixes issue #52

This commit is contained in:
Simon Robertshaw 2012-08-05 14:03:54 +01:00
parent 05024cc787
commit 351ce1525f
2 changed files with 14 additions and 3 deletions

View File

@ -114,7 +114,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
} }
} }
grav->gravity_mask(); gravWallChanged = true;
return 0; return 0;
} }
@ -232,6 +232,8 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h)
{ {
for (cx=0; cx<area_w; cx++) for (cx=0; cx<area_w; cx++)
{ {
if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] == WL_GRAV)
gravWallChanged = true;
bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0; bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
delete_part(cx+area_x, cy+area_y, 0); delete_part(cx+area_x, cy+area_y, 0);
} }
@ -1240,6 +1242,10 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brus
fvx[j][i] = 0.0f; fvx[j][i] = 0.0f;
fvy[j][i] = 0.0f; fvy[j][i] = 0.0f;
} }
if (b==WL_GRAV || bmap[j][i]==WL_GRAV)
{
gravWallChanged = true;
}
if (b==WL_STREAM) if (b==WL_STREAM)
{ {
i = x + rx/2; i = x + rx/2;
@ -1253,7 +1259,6 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brus
bmap[j][i] = WL_STREAM; bmap[j][i] = WL_STREAM;
continue; continue;
} }
if (b==0 && bmap[j][i]==WL_GRAV) gravwl_timeout = 60;
bmap[j][i] = b; bmap[j][i] = b;
} }
} }
@ -4341,6 +4346,12 @@ void Simulation::update_particles()//doesn't update the particles themselves, bu
gravy = grav->gravy; gravy = grav->gravy;
gravp = grav->gravp; gravp = grav->gravp;
gravmap = grav->gravmap; gravmap = grav->gravmap;
if(gravWallChanged)
{
grav->gravity_mask();
gravWallChanged = false;
}
} }
} }

View File

@ -62,7 +62,7 @@ public:
playerst fighters[256]; //255 is the maximum number of fighters playerst fighters[256]; //255 is the maximum number of fighters
unsigned char fighcount; //Contains the number of fighters unsigned char fighcount; //Contains the number of fighters
int lighting_recreate; int lighting_recreate;
int gravwl_timeout; bool gravWallChanged;
Particle portalp[CHANNELS][8][80]; Particle portalp[CHANNELS][8][80];
Particle emptyparticle; Particle emptyparticle;
int portal_rx[8]; int portal_rx[8];