diff options
| author | jacob1 <jfu614@gmail.com> | 2013-03-03 20:38:52 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-03-03 20:38:52 (GMT) |
| commit | 17d79e8d8e585a39ca8b16efa1d18a11409f8079 (patch) | |
| tree | 3dffb7755e0fec6065885df298db448b342def79 /src | |
| parent | 846d7d8064cf84c6b4e55a8a0417e7e605e0d144 (diff) | |
| download | powder-17d79e8d8e585a39ca8b16efa1d18a11409f8079.zip powder-17d79e8d8e585a39ca8b16efa1d18a11409f8079.tar.gz | |
fix crash when drawing particles in invalid coordinates (using console)
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics/Renderer.cpp | 4 | ||||
| -rw-r--r-- | src/preview/PreviewController.cpp | 7 | ||||
| -rw-r--r-- | src/preview/PreviewModel.cpp | 8 | ||||
| -rw-r--r-- | src/preview/PreviewView.cpp | 11 | ||||
| -rw-r--r-- | src/simulation/Simulation.cpp | 14 |
5 files changed, 12 insertions, 32 deletions
diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 486a0d4..3a1a2cd 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -1172,10 +1172,10 @@ void Renderer::render_parts() fnx = sim->parts[i].x; fny = sim->parts[i].y; - if((sim->photons[ny][nx]&0xFF) && !(sim->elements[t].Properties & TYPE_ENERGY) && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH) - continue; if(nx >= XRES || nx < 0 || ny >= YRES || ny < 0) continue; + if((sim->photons[ny][nx]&0xFF) && !(sim->elements[t].Properties & TYPE_ENERGY) && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH) + continue; //Defaults pixel_mode = 0 | PMODE_FLAT; diff --git a/src/preview/PreviewController.cpp b/src/preview/PreviewController.cpp index 37561b7..1616c63 100644 --- a/src/preview/PreviewController.cpp +++ b/src/preview/PreviewController.cpp @@ -1,10 +1,3 @@ -/* - * PreviewController.cpp - * - * Created on: Jan 21, 2012 - * Author: Simon - */ - #include <sstream> #include "client/Client.h" #include "PreviewController.h" diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp index b5dbf40..ea3904d 100644 --- a/src/preview/PreviewModel.cpp +++ b/src/preview/PreviewModel.cpp @@ -1,10 +1,3 @@ -/* - * PreviewModel.cpp - * - * Created on: Jan 21, 2012 - * Author: Simon - */ - #include <cmath> #include "PreviewModel.h" #include "client/Client.h" @@ -25,7 +18,6 @@ PreviewModel::PreviewModel(): commentsPageNumber(1), commentBoxEnabled(false) { - // TODO Auto-generated constructor stub } diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index 61a0c8f..1859a2a 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -1,10 +1,3 @@ -/* - * PreviewView.cpp - * - * Created on: Jan 21, 2012 - * Author: Simon - */ - #include <sstream> #include <vector> #include <cmath> @@ -274,7 +267,7 @@ void PreviewView::OnDraw() g->drawrect(Position.X, Position.Y, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 100); g->draw_line(Position.X+XRES/2, Position.Y+1, Position.X+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255); - if(!(!votesUp && !votesDown)) + if(votesUp || votesDown) { float ryf; int nyu, nyd; @@ -573,5 +566,7 @@ PreviewView::~PreviewView() RemoveComponent(submitCommentButton); delete submitCommentButton; } + if(savePreview) + delete savePreview; } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index d64ccf7..ef3c3d9 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2947,10 +2947,10 @@ int Simulation::create_part(int p, int x, int y, int tv) parts[i].life = 75; break; /*Testing - case PT_WOOD: - parts[i].life = 150; - break; - End Testing*/ + case PT_WOOD: + parts[i].life = 150; + break; + End Testing*/ case PT_WARP: parts[i].life = rand()%95+70; break; @@ -3555,7 +3555,7 @@ void Simulation::update_particles_i(int start, int inc) { golnum = parts[r>>8].ctype+1; if (golnum<=0 || golnum>NGOLALT) { - parts[r>>8].type = PT_NONE; + kill_part(r>>8); continue; } if (parts[r>>8].tmp == grule[golnum][9]-1) { @@ -3575,7 +3575,7 @@ void Simulation::update_particles_i(int start, int inc) } else { parts[r>>8].tmp --; if (parts[r>>8].tmp<=0) - parts[r>>8].type = PT_NONE;//using kill_part makes it not work + kill_part(r>>8); } } //} @@ -3604,7 +3604,7 @@ void Simulation::update_particles_i(int start, int inc) parts[r>>8].tmp --; } if (r && parts[r>>8].tmp<=0) - parts[r>>8].type = PT_NONE;//using kill_part makes it not work + kill_part(r>>8); } for ( z = 0; z<=NGOL; z++) gol2[ny][nx][z] = 0;//this improves performance A LOT compared to the memset, i was getting ~23 more fps with this. |
