diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-12-16 16:38:29 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-12-16 16:38:29 (GMT) |
| commit | 0c5e99aef6c997b8bce53189537523e7f742d64b (patch) | |
| tree | fbe46aa7b53660b6c399728f1adc1504b188dc98 /src/simulation/Simulation.cpp | |
| parent | 00190b4aabad65531ee0e859c3e4f358841238f6 (diff) | |
| parent | 06f8f88374a1b9e288da30d754ba4bf02768d863 (diff) | |
| download | powder-0c5e99aef6c997b8bce53189537523e7f742d64b.zip powder-0c5e99aef6c997b8bce53189537523e7f742d64b.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
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) |
