From e6f6eedd1364fd3792d6ca7aa3ac2d0c97911f70 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 9 Mar 2013 16:50:36 -0500 Subject: [PATCH] fix empty signs being created when shifting them out of bounds, draw parts of images when it goes partway off the top of the screen. --- src/graphics/RasterDrawMethods.inl | 6 ++++++ src/preview/PreviewModel.cpp | 3 +++ src/simulation/Simulation.cpp | 11 +++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl index dec15f193..07b8257c6 100644 --- a/src/graphics/RasterDrawMethods.inl +++ b/src/graphics/RasterDrawMethods.inl @@ -362,6 +362,12 @@ void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int int i, j, r, g, b; if (!img) return; if(y + h > VIDYRES) h = ((VIDYRES)-y)-1; //Adjust height to prevent drawing off the bottom + if (y < 0 && -y < h) + { + img += -y*w; + h += y; + y = 0; + } if(!h || y < 0) return; if(a >= 255) for (j=0; jsize(); i++) delete saveComments->at(i); saveComments->clear(); + delete saveComments; saveComments = NULL; } notifySaveChanged(); @@ -166,6 +167,7 @@ void PreviewModel::UpdateComments(int pageNumber) { for(int i = 0; i < saveComments->size(); i++) delete saveComments->at(i); + saveComments->clear(); delete saveComments; saveComments = NULL; } @@ -314,6 +316,7 @@ PreviewModel::~PreviewModel() { for(int i = 0; i < saveComments->size(); i++) delete saveComments->at(i); saveComments->clear(); + delete saveComments; } saveDataBuffer.clear(); } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index b6f4f84d4..3acf4139b 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -146,10 +146,13 @@ int Simulation::Load(int fullX, int fullY, GameSave * save) Element_PPIP::ppip_changed = 1; for(int i = 0; i < save->signs.size() && signs.size() < MAXSIGNS; i++) { - sign tempSign = save->signs[i]; - tempSign.x += fullX; - tempSign.y += fullY; - signs.push_back(tempSign); + if (save->signs[i].text[0]) + { + sign tempSign = save->signs[i]; + tempSign.x += fullX; + tempSign.y += fullY; + signs.push_back(tempSign); + } } for(int saveBlockX = 0; saveBlockX < save->blockWidth; saveBlockX++) {