From 3203e597b9546d85c3eff887ea4f01e051ebbba0 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 10 Jul 2013 16:59:10 -0400 Subject: [PATCH] fix piston bugs, fix crashes, don't use bluescreens when compiled with debug mode in visual studio --- src/PowderToySDL.cpp | 2 +- src/gui/preview/PreviewModel.cpp | 4 ++-- src/simulation/Simulation.cpp | 2 +- src/simulation/elements/PSTN.cpp | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index f49ed55a0..0f79d9e0f 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -779,7 +779,7 @@ int main(int argc, char * argv[]) engine->Begin(XRES+BARSIZE, YRES+MENUSIZE); engine->SetFastQuit(Client::Ref().GetPrefBool("FastQuit", true)); -#ifndef DEBUG +#if !defined(DEBUG) && !defined(_DEBUG) //Get ready to catch any dodgy errors signal(SIGSEGV, SigHandler); signal(SIGFPE, SigHandler); diff --git a/src/gui/preview/PreviewModel.cpp b/src/gui/preview/PreviewModel.cpp index 5903f7793..8d5d574de 100644 --- a/src/gui/preview/PreviewModel.cpp +++ b/src/gui/preview/PreviewModel.cpp @@ -252,7 +252,7 @@ void PreviewModel::Update() delete updateSaveDataInfo; updateSaveDataInfo = NULL; - if (save) + if (save && saveData) { commentsTotal = save->Comments; try @@ -279,7 +279,7 @@ void PreviewModel::Update() delete updateSaveInfoInfo; updateSaveInfoInfo = NULL; - if (save) + if (save && saveData) { commentsTotal = save->Comments; try diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 5d40529c1..747a019d5 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -308,7 +308,7 @@ void Simulation::Restore(const Snapshot & snap) { parts_lastActiveIndex = NPART-1; - for(int i; i= 0 && posY >= 0)) { @@ -176,14 +176,14 @@ int Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int dir } r = sim->pmap[posY][posX]; if (sim->IsWallBlocking(posX, posY, 0) || (block && (r&0xFF) == block)) - break; + return spaces; if(!r) { spaces++; tempParts[currentPos++] = -1; if(spaces >= amount) break; } else { - if(spaces < maxSize && !retract) + if(spaces < maxSize && currentPos < maxSize && (!retract || ((r&0xFF) == PT_FRME) && posX == stackX && posY == stackY)) tempParts[currentPos++] = r>>8; else return spaces; @@ -212,7 +212,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct posY = stackY + (c*newY); posX = stackX + (c*newX); if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) { - int val = CanMoveStack(sim, posX+realDirectionX, posY+realDirectionY, realDirectionX, realDirectionY, maxSize, amount, retract, block); + int val = CanMoveStack(sim, posX, posY, realDirectionX, realDirectionY, maxSize, amount, retract, block); if(val < amount) amount = val; } else { @@ -224,7 +224,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct posY = stackY - (c*newY); posX = stackX - (c*newX); if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) { - int val = CanMoveStack(sim, posX+realDirectionX, posY+realDirectionY, realDirectionX, realDirectionY, maxSize, amount, retract, block); + int val = CanMoveStack(sim, posX, posY, realDirectionX, realDirectionY, maxSize, amount, retract, block); if(val < amount) amount = val; } else {