diff options
| author | jacob1 <jfu614@gmail.com> | 2012-10-04 14:42:09 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2012-12-15 20:13:12 (GMT) |
| commit | a623959a314e544f092c85f037d8b564adc2af45 (patch) | |
| tree | b409fc023ed80900c0061314d12b05c8c43ecc17 /src/simulation/Simulation.cpp | |
| parent | 0fd86e994afb7edb4fb923f7b46da77ad423acc2 (diff) | |
| download | powder-a623959a314e544f092c85f037d8b564adc2af45.zip powder-a623959a314e544f092c85f037d8b564adc2af45.tar.gz | |
save stamps on 1 pixel grid (works exactly like in tpt now), delete signs with Ctrl+X, also fixes stamps on very bottom/right edge and other edge cases
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index f016112..21f8109 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -167,7 +167,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save) GameSave * Simulation::Save() { - return Save(0, 0, XRES, YRES); + return Save(0, 0, XRES-1, YRES-1); } GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2) @@ -192,14 +192,14 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2) blockX = fullX/CELL; blockY = fullY/CELL; - blockX2 = fullX2/CELL; - blockY2 = fullY2/CELL; + blockX2 = (fullX2+CELL)/CELL; + blockY2 = (fullY2+CELL)/CELL; - fullX = blockX*CELL; - fullY = blockY*CELL; + //fullX = blockX*CELL; + //fullY = blockY*CELL; - fullX2 = blockX2*CELL; - fullY2 = blockY2*CELL; + //fullX2 = blockX2*CELL; + //fullY2 = blockY2*CELL; blockW = blockX2-blockX; blockH = blockY2-blockY; @@ -216,11 +216,11 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2) int x, y; x = int(parts[i].x + 0.5f); y = int(parts[i].y + 0.5f); - if(parts[i].type && x >= fullX && y >= fullY && x < fullX2 && y < fullY2) + if(parts[i].type && x >= fullX && y >= fullY && x <= fullX2 && y <= fullY2) { Particle tempPart = parts[i]; - tempPart.x -= fullX; - tempPart.y -= fullY; + tempPart.x -= blockX*CELL; + tempPart.y -= blockY*CELL; if(elements[tempPart.type].Enabled) { *newSave << tempPart; @@ -243,11 +243,11 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2) for(int i = 0; i < MAXSIGNS && i < signs.size(); i++) { - if(signs[i].text.length() && signs[i].x >= fullX && signs[i].y >= fullY && signs[i].x < fullX2 && signs[i].y < fullY2) + if(signs[i].text.length() && signs[i].x >= fullX && signs[i].y >= fullY && signs[i].x <= fullX2 && signs[i].y <= fullY2) { sign tempSign = signs[i]; - tempSign.x -= fullX; - tempSign.y -= fullY; + tempSign.x -= blockX*CELL; + tempSign.y -= blockY*CELL; *newSave << tempSign; } } @@ -340,9 +340,17 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h) if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] == WL_GRAV) gravWallChanged = true; bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0; + emap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0; delete_part(cx+area_x, cy+area_y, 0); } } + for(int i = 0; i < MAXSIGNS && i < signs.size(); i++) + { + if(signs[i].text.length() && signs[i].x >= area_x && signs[i].y >= area_y && signs[i].x <= area_x+area_w && signs[i].y <= area_y+area_h) + { + signs.erase(signs.begin()+i); + } + } } void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags) |
