diff options
Diffstat (limited to 'src/simulation')
| -rw-r--r-- | src/simulation/Sample.h | 4 | ||||
| -rw-r--r-- | src/simulation/SaveRenderer.cpp | 36 | ||||
| -rw-r--r-- | src/simulation/SaveRenderer.h | 4 | ||||
| -rw-r--r-- | src/simulation/Sign.cpp | 2 | ||||
| -rw-r--r-- | src/simulation/Simulation.cpp | 75 | ||||
| -rw-r--r-- | src/simulation/Simulation.h | 7 | ||||
| -rw-r--r-- | src/simulation/Snapshot.h | 2 | ||||
| -rw-r--r-- | src/simulation/elements/BANG.cpp | 7 | ||||
| -rw-r--r-- | src/simulation/elements/CO2.cpp | 6 | ||||
| -rw-r--r-- | src/simulation/elements/LOLZ.cpp | 22 | ||||
| -rw-r--r-- | src/simulation/elements/LOVE.cpp | 22 |
11 files changed, 149 insertions, 38 deletions
diff --git a/src/simulation/Sample.h b/src/simulation/Sample.h index 0e67331..3605a5d 100644 --- a/src/simulation/Sample.h +++ b/src/simulation/Sample.h @@ -21,7 +21,9 @@ public: float GravityVelocityX; float GravityVelocityY; - SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0) {} + int NumParts; + + SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0), NumParts(0) {} }; #endif
\ No newline at end of file diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index 3e5c971..fc30a28 100644 --- a/src/simulation/SaveRenderer.cpp +++ b/src/simulation/SaveRenderer.cpp @@ -39,7 +39,7 @@ SaveRenderer::SaveRenderer(){ #endif } -Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations) +Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations, bool fire) { int width, height; Thumbnail * tempThumb; @@ -71,13 +71,16 @@ Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations) ren->RenderBegin(); ren->RenderEnd(); #else - int frame = 15; - while(frame) + if (fire) { - frame--; - ren->render_parts(); - ren->render_fire(); - ren->clearScreen(1.0f); + int frame = 15; + while(frame) + { + frame--; + ren->render_parts(); + ren->render_fire(); + ren->clearScreen(1.0f); + } } ren->RenderBegin(); @@ -119,13 +122,16 @@ Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations) ren->ClearAccumulation(); - int frame = 15; - while(frame) + if (fire) { - frame--; - ren->render_parts(); - ren->render_fire(); - ren->clearScreen(1.0f); + int frame = 15; + while(frame) + { + frame--; + ren->render_parts(); + ren->render_fire(); + ren->clearScreen(1.0f); + } } ren->RenderBegin(); @@ -151,7 +157,7 @@ Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations) return tempThumb; } -Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool decorations) +Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool decorations, bool fire) { GameSave * tempSave; try { @@ -166,7 +172,7 @@ Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool de return thumb; } - Thumbnail * thumb = Render(tempSave, decorations); + Thumbnail * thumb = Render(tempSave, decorations, fire); delete tempSave; return thumb; } diff --git a/src/simulation/SaveRenderer.h b/src/simulation/SaveRenderer.h index e54517e..be4a83b 100644 --- a/src/simulation/SaveRenderer.h +++ b/src/simulation/SaveRenderer.h @@ -24,8 +24,8 @@ class SaveRenderer: public Singleton<SaveRenderer> { Renderer * ren; public: SaveRenderer(); - Thumbnail * Render(GameSave * save, bool decorations = true); - Thumbnail * Render(unsigned char * saveData, int saveDataSize, bool decorations = true); + Thumbnail * Render(GameSave * save, bool decorations = true, bool fire = true); + Thumbnail * Render(unsigned char * saveData, int saveDataSize, bool decorations = true, bool fire = true); virtual ~SaveRenderer(); private: diff --git a/src/simulation/Sign.cpp b/src/simulation/Sign.cpp index 01d388f..2caf6c3 100644 --- a/src/simulation/Sign.cpp +++ b/src/simulation/Sign.cpp @@ -28,7 +28,7 @@ void sign::pos(int & x0, int & y0, int & w, int & h) { w = Graphics::textwidth("Temp: 0000.00"); } - else if (sregexp(text.c_str(), "^{c:[0-9]*|.*}$")==0) + else if (sregexp(text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { int sldr, startm; char buff[256]; diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 682d3e0..61b0944 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -230,6 +230,7 @@ Snapshot * Simulation::CreateSnapshot() snap->AirPressure.insert(snap->AirPressure.begin(), &pv[0][0], &pv[0][0]+((XRES/CELL)*(YRES/CELL))); snap->AirVelocityX.insert(snap->AirVelocityX.begin(), &vx[0][0], &vx[0][0]+((XRES/CELL)*(YRES/CELL))); snap->AirVelocityY.insert(snap->AirVelocityY.begin(), &vy[0][0], &vy[0][0]+((XRES/CELL)*(YRES/CELL))); + snap->AmbientHeat.insert(snap->AmbientHeat.begin(), &hv[0][0], &hv[0][0]+((XRES/CELL)*(YRES/CELL))); snap->Particles.insert(snap->Particles.begin(), parts, parts+NPART); snap->PortalParticles.insert(snap->PortalParticles.begin(), &portalp[0][0][0], &portalp[CHANNELS-1][8-1][80-1]); snap->WirelessData.insert(snap->WirelessData.begin(), &wireless[0][0], &wireless[CHANNELS-1][2-1]); @@ -250,6 +251,7 @@ void Simulation::Restore(const Snapshot & snap) std::copy(snap.AirPressure.begin(), snap.AirPressure.end(), &pv[0][0]); std::copy(snap.AirVelocityX.begin(), snap.AirVelocityX.end(), &vx[0][0]); std::copy(snap.AirVelocityY.begin(), snap.AirVelocityY.end(), &vy[0][0]); + std::copy(snap.AmbientHeat.begin(), snap.AmbientHeat.end(), &hv[0][0]); std::copy(snap.Particles.begin(), snap.Particles.end(), parts); std::copy(snap.PortalParticles.begin(), snap.PortalParticles.end(), &portalp[0][0][0]); std::copy(snap.WirelessData.begin(), snap.WirelessData.end(), &wireless[0][0]); @@ -437,6 +439,8 @@ SimulationSample Simulation::Get(int x, int y) sample.GravityVelocityX = gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]; sample.GravityVelocityY = gravy[(y/CELL)*(XRES/CELL)+(x/CELL)]; } + + sample.NumParts = NUM_PARTS; return sample; } @@ -3269,6 +3273,77 @@ void Simulation::update_particles_i(int start, int inc) } } + if (ISLOVE || ISLOLZ) //LOVE and LOLZ element handling + { + int nx, nnx, ny, nny, r, rt; + ISLOVE = 0; + ISLOLZ = 0; + for (ny=0; ny<YRES-4; ny++) + { + for (nx=0; nx<XRES-4; nx++) + { + r=pmap[ny][nx]; + if (!r) + { + continue; + } + else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&(parts[r>>8].type==PT_LOVE||parts[r>>8].type==PT_LOLZ)) + kill_part(r>>8); + else if (parts[r>>8].type==PT_LOVE) + { + love[nx/9][ny/9] = 1; + } + else if (parts[r>>8].type==PT_LOLZ) + { + lolz[nx/9][ny/9] = 1; + } + } + } + for (nx=9; nx<=XRES-18; nx++) + { + for (ny=9; ny<=YRES-7; ny++) + { + if (love[nx/9][ny/9]==1) + { + for ( nnx=0; nnx<9; nnx++) + for ( nny=0; nny<9; nny++) + { + if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES) + { + rt=pmap[ny+nny][nx+nnx]; + if (!rt&&Element_LOVE::RuleTable[nnx][nny]==1) + create_part(-1,nx+nnx,ny+nny,PT_LOVE); + else if (!rt) + continue; + else if (parts[rt>>8].type==PT_LOVE&&Element_LOVE::RuleTable[nnx][nny]==0) + kill_part(rt>>8); + } + } + } + love[nx/9][ny/9]=0; + if (lolz[nx/9][ny/9]==1) + { + for ( nnx=0; nnx<9; nnx++) + for ( nny=0; nny<9; nny++) + { + if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES) + { + rt=pmap[ny+nny][nx+nnx]; + if (!rt&&Element_LOLZ::RuleTable[nny][nnx]==1) + create_part(-1,nx+nnx,ny+nny,PT_LOLZ); + else if (!rt) + continue; + else if (parts[rt>>8].type==PT_LOLZ&&Element_LOLZ::RuleTable[nny][nnx]==0) + kill_part(rt>>8); + + } + } + } + lolz[nx/9][ny/9]=0; + } + } + } + //wire! if(elementCount[PT_WIRE] > 0) { diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index ba9fa1a..98c5025 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -117,6 +117,12 @@ public: int pretty_powder; int sandcolour; int sandcolour_frame; + static int loverule[9][9]; + bool ISLOVE; + int love[XRES/9][YRES/9]; + static int lolzrule[9][9]; + bool ISLOLZ; + int lolz[XRES/9][YRES/9]; int Load(GameSave * save); int Load(int x, int y, GameSave * save); @@ -204,6 +210,7 @@ public: Simulation(); ~Simulation(); }; + //#endif #endif /* SIMULATION_H_ */ diff --git a/src/simulation/Snapshot.h b/src/simulation/Snapshot.h index a1c34fa..d47f363 100644 --- a/src/simulation/Snapshot.h +++ b/src/simulation/Snapshot.h @@ -10,6 +10,7 @@ public: std::vector<float> AirPressure; std::vector<float> AirVelocityX; std::vector<float> AirVelocityY; + std::vector<float> AmbientHeat; std::vector<Particle> Particles; std::vector<Particle> PortalParticles; @@ -31,6 +32,7 @@ public: AirPressure(), AirVelocityX(), AirVelocityY(), + AmbientHeat(), Particles(), PortalParticles(), WirelessData(), diff --git a/src/simulation/elements/BANG.cpp b/src/simulation/elements/BANG.cpp index 2dc660a..b0ff983 100644 --- a/src/simulation/elements/BANG.cpp +++ b/src/simulation/elements/BANG.cpp @@ -75,8 +75,11 @@ int Element_BANG::update(UPDATE_FUNC_ARGS) } else if(parts[i].tmp==1) { - int tempvalue = 2; - sim->flood_prop(x, y, offsetof(Particle, tmp), &tempvalue, StructProperty::Integer); + if ((pmap[y][x]>>8 == i)) + { + int tempvalue = 2; + sim->flood_prop(x, y, offsetof(Particle, tmp), &tempvalue, StructProperty::Integer); + } parts[i].tmp = 2; } else if(parts[i].tmp==2) diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp index 4e29286..ca5cc31 100644 --- a/src/simulation/elements/CO2.cpp +++ b/src/simulation/elements/CO2.cpp @@ -71,11 +71,11 @@ int Element_CO2::update(UPDATE_FUNC_ARGS) } if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250)) { - sim->part_change_type(i,x,y,PT_CBNW); + sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW); if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet - sim->create_part(r>>8, x+rx, y+ry, PT_CBNW); + sim->create_part(i, x, y, PT_WATR); else - sim->kill_part(r>>8); + sim->kill_part(i); } } if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f) diff --git a/src/simulation/elements/LOLZ.cpp b/src/simulation/elements/LOLZ.cpp index 6feae3f..a5e8371 100644 --- a/src/simulation/elements/LOLZ.cpp +++ b/src/simulation/elements/LOLZ.cpp @@ -46,16 +46,24 @@ Element_LOLZ::Element_LOLZ() } +//#TPT-Directive ElementHeader Element_LOLZ static int RuleTable[9][9] +int Element_LOLZ::RuleTable[9][9] = +{ + {0,0,0,0,0,0,0,0,0}, + {1,0,0,0,0,0,1,0,0}, + {1,0,0,0,0,0,1,0,0}, + {1,0,0,1,1,0,0,1,0}, + {1,0,1,0,0,1,0,1,0}, + {1,0,1,0,0,1,0,1,0}, + {0,1,0,1,1,0,0,1,0}, + {0,1,0,0,0,0,0,1,0}, + {0,1,0,0,0,0,0,1,0}, +}; + //#TPT-Directive ElementHeader Element_LOLZ static int update(UPDATE_FUNC_ARGS) int Element_LOLZ::update(UPDATE_FUNC_ARGS) { - /*int t = parts[i].type; - if (t==PT_LOVE) - ISLOVE=1; - else if (t==PT_LOLZ) - ISLOLZ=1; - else if (t==PT_GRAV) - ISGRAV=1;*/ + sim->ISLOLZ = true; return 0; } diff --git a/src/simulation/elements/LOVE.cpp b/src/simulation/elements/LOVE.cpp index 28a20b7..3e7b3d4 100644 --- a/src/simulation/elements/LOVE.cpp +++ b/src/simulation/elements/LOVE.cpp @@ -46,16 +46,24 @@ Element_LOVE::Element_LOVE() } +//#TPT-Directive ElementHeader Element_LOVE static int RuleTable[9][9] +int Element_LOVE::RuleTable[9][9] = +{ + {0,0,1,1,0,0,0,0,0}, + {0,1,0,0,1,1,0,0,0}, + {1,0,0,0,0,0,1,0,0}, + {1,0,0,0,0,0,0,1,0}, + {0,1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1,0}, + {1,0,0,0,0,0,1,0,0}, + {0,1,0,0,1,1,0,0,0}, + {0,0,1,1,0,0,0,0,0}, +}; + //#TPT-Directive ElementHeader Element_LOVE static int update(UPDATE_FUNC_ARGS) int Element_LOVE::update(UPDATE_FUNC_ARGS) { - /*int t = parts[i].type; - if (t==PT_LOVE) - ISLOVE=1; - else if (t==PT_LOLZ) - ISLOLZ=1; - else if (t==PT_GRAV) - ISGRAV=1;*/ + sim->ISLOVE = true; return 0; } |
