From 0ca680f4c8585642b7201d07a3632ed276e5794a Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 27 Aug 2012 13:32:17 +0100 Subject: [PATCH] Enable decorations in renderer for local save items, disable for server save previews. --- src/client/ThumbnailBroker.cpp | 16 +++++++++++----- src/client/ThumbnailBroker.h | 1 + src/preview/PreviewView.cpp | 2 +- src/save/ServerSaveActivity.cpp | 2 +- src/simulation/SaveRenderer.cpp | 8 ++++---- src/simulation/SaveRenderer.h | 4 ++-- src/simulation/Simulation.cpp | 1 + 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/client/ThumbnailBroker.cpp b/src/client/ThumbnailBroker.cpp index 3a6bc14c3..b0eaa9265 100644 --- a/src/client/ThumbnailBroker.cpp +++ b/src/client/ThumbnailBroker.cpp @@ -54,11 +54,12 @@ class ThumbnailBroker::ThumbRenderRequest { public: int Width, Height; + bool Decorations; GameSave * Save; ThumbnailListener * CompletedListener; - ThumbRenderRequest(GameSave * save, int width, int height, ThumbnailListener * completedListener) : - Save(save), Width(width), Height(height), CompletedListener(completedListener) {} - ThumbRenderRequest() : Save(0), Width(0), Height(0), CompletedListener(NULL) {} + ThumbRenderRequest(GameSave * save, bool decorations, int width, int height, ThumbnailListener * completedListener) : + Save(save), Width(width), Height(height), CompletedListener(completedListener), Decorations(decorations) {} + ThumbRenderRequest() : Save(0), Decorations(true), Width(0), Height(0), CompletedListener(NULL) {} }; ThumbnailBroker::ThumbnailBroker() @@ -77,12 +78,17 @@ ThumbnailBroker::~ThumbnailBroker() } void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener) +{ + RenderThumbnail(gameSave, true, width, height, tListener); +} + +void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, bool decorations, int width, int height, ThumbnailListener * tListener) { AttachThumbnailListener(tListener); pthread_mutex_lock(&thumbnailQueueMutex); bool running = thumbnailQueueRunning; thumbnailQueueRunning = true; - renderRequests.push_back(ThumbRenderRequest(new GameSave(*gameSave), width, height, tListener)); + renderRequests.push_back(ThumbRenderRequest(new GameSave(*gameSave), decorations, width, height, tListener)); pthread_mutex_unlock(&thumbnailQueueMutex); if(!running) @@ -167,7 +173,7 @@ void ThumbnailBroker::thumbnailQueueProcessTH() std::cout << typeid(*this).name() << " Processing render request" << std::endl; #endif - Thumbnail * thumbnail = SaveRenderer::Ref().Render(req.Save); + Thumbnail * thumbnail = SaveRenderer::Ref().Render(req.Save, req.Decorations); delete req.Save; if(thumbnail) diff --git a/src/client/ThumbnailBroker.h b/src/client/ThumbnailBroker.h index 8fec6c1e9..0bb7fcead 100644 --- a/src/client/ThumbnailBroker.h +++ b/src/client/ThumbnailBroker.h @@ -48,6 +48,7 @@ public: virtual ~ThumbnailBroker(); void FlushThumbQueue(); + void RenderThumbnail(GameSave * gameSave, bool decorations, int width, int height, ThumbnailListener * tListener); void RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener); void RetrieveThumbnail(int saveID, int saveDate, int width, int height, ThumbnailListener * tListener); void RetrieveThumbnail(int saveID, int width, int height, ThumbnailListener * tListener); diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index c0aacf9e3..00683fcda 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -356,7 +356,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender) if(save->GetGameSave()) { - savePreview = SaveRenderer::Ref().Render(save->GetGameSave()); + savePreview = SaveRenderer::Ref().Render(save->GetGameSave(), false); if(savePreview && savePreview->Data && !(savePreview->Size.X == XRES/2 && savePreview->Size.Y == YRES/2)) { diff --git a/src/save/ServerSaveActivity.cpp b/src/save/ServerSaveActivity.cpp index 0a91442c5..b8661a8cb 100644 --- a/src/save/ServerSaveActivity.cpp +++ b/src/save/ServerSaveActivity.cpp @@ -127,7 +127,7 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp SetOkayButton(okayButton); if(save.GetGameSave()) - ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), (Size.X/2)-16, -1, this); + ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), false, (Size.X/2)-16, -1, this); } ServerSaveActivity::ServerSaveActivity(SaveInfo save, bool saveNow, ServerSaveActivity::SaveUploadedCallback * callback) : diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index ecd284dc5..2de9a6cce 100644 --- a/src/simulation/SaveRenderer.cpp +++ b/src/simulation/SaveRenderer.cpp @@ -38,7 +38,7 @@ SaveRenderer::SaveRenderer(){ #endif } -Thumbnail * SaveRenderer::Render(GameSave * save) +Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations) { int width, height; Thumbnail * tempThumb; @@ -52,7 +52,7 @@ Thumbnail * SaveRenderer::Render(GameSave * save) if(!sim->Load(save)) { - ren->decorations_enable = false; + ren->decorations_enable = decorations; #if defined(OGLR) || defined(OGLI) pixel * pData = NULL; unsigned char * texData = NULL; @@ -123,7 +123,7 @@ Thumbnail * SaveRenderer::Render(GameSave * save) return tempThumb; } -Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize) +Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool decorations) { GameSave * tempSave; try { @@ -138,7 +138,7 @@ Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize) return thumb; } - Thumbnail * thumb = Render(tempSave); + Thumbnail * thumb = Render(tempSave, decorations); delete tempSave; return thumb; } diff --git a/src/simulation/SaveRenderer.h b/src/simulation/SaveRenderer.h index 22e3adfaf..e54517e07 100644 --- a/src/simulation/SaveRenderer.h +++ b/src/simulation/SaveRenderer.h @@ -24,8 +24,8 @@ class SaveRenderer: public Singleton { Renderer * ren; public: SaveRenderer(); - Thumbnail * Render(GameSave * save); - Thumbnail * Render(unsigned char * saveData, int saveDataSize); + Thumbnail * Render(GameSave * save, bool decorations = true); + Thumbnail * Render(unsigned char * saveData, int saveDataSize, bool decorations = true); virtual ~SaveRenderer(); private: diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 450f6d327..cb9b65488 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -238,6 +238,7 @@ Snapshot * Simulation::CreateSnapshot() void Simulation::Restore(const Snapshot & snap) { + parts_lastActiveIndex = NPART-1; 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]);