From 5c59b9d6cb39a1786d3a859a0a8e9e44a6a86d9c Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 2 Oct 2012 19:45:35 -0400 Subject: [PATCH] don't render fire on stamps (reduces lag) --- src/client/ThumbnailBroker.cpp | 8 ++++---- src/client/ThumbnailBroker.h | 9 +++++---- src/preview/PreviewView.cpp | 2 +- src/save/LocalSaveActivity.cpp | 2 +- src/save/ServerSaveActivity.cpp | 2 +- src/simulation/SaveRenderer.cpp | 36 +++++++++++++++++++-------------- src/simulation/SaveRenderer.h | 4 ++-- 7 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/client/ThumbnailBroker.cpp b/src/client/ThumbnailBroker.cpp index c81ccc6ec..e884a980b 100644 --- a/src/client/ThumbnailBroker.cpp +++ b/src/client/ThumbnailBroker.cpp @@ -28,16 +28,16 @@ ThumbnailBroker::~ThumbnailBroker() void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener) { - RenderThumbnail(gameSave, true, width, height, tListener); + RenderThumbnail(gameSave, true, true, width, height, tListener); } -void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, bool decorations, int width, int height, ThumbnailListener * tListener) +void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, int width, int height, ThumbnailListener * tListener) { AttachThumbnailListener(tListener); pthread_mutex_lock(&thumbnailQueueMutex); bool running = thumbnailQueueRunning; thumbnailQueueRunning = true; - renderRequests.push_back(ThumbRenderRequest(new GameSave(*gameSave), decorations, width, height, ListenerHandle(tListener->ListenerRand, tListener))); + renderRequests.push_back(ThumbRenderRequest(new GameSave(*gameSave), decorations, fire, width, height, ListenerHandle(tListener->ListenerRand, tListener))); pthread_mutex_unlock(&thumbnailQueueMutex); if(!running) @@ -122,7 +122,7 @@ void ThumbnailBroker::thumbnailQueueProcessTH() std::cout << typeid(*this).name() << " Processing render request" << std::endl; #endif - Thumbnail * thumbnail = SaveRenderer::Ref().Render(req.Save, req.Decorations); + Thumbnail * thumbnail = SaveRenderer::Ref().Render(req.Save, req.Decorations, req.Fire); delete req.Save; if(thumbnail) diff --git a/src/client/ThumbnailBroker.h b/src/client/ThumbnailBroker.h index cc736ef9e..ba6d3ae58 100644 --- a/src/client/ThumbnailBroker.h +++ b/src/client/ThumbnailBroker.h @@ -59,11 +59,12 @@ private: public: int Width, Height; bool Decorations; + bool Fire; GameSave * Save; ListenerHandle CompletedListener; - ThumbRenderRequest(GameSave * save, bool decorations, int width, int height, ListenerHandle completedListener) : - Save(save), Width(width), Height(height), CompletedListener(completedListener), Decorations(decorations) {} - ThumbRenderRequest() : Save(0), Decorations(true), Width(0), Height(0), CompletedListener(ListenerHandle(0, (ThumbnailListener*)NULL)) {} + ThumbRenderRequest(GameSave * save, bool decorations, bool fire, int width, int height, ListenerHandle completedListener) : + Save(save), Width(width), Height(height), CompletedListener(completedListener), Decorations(decorations), Fire(fire) {} + ThumbRenderRequest() : Save(0), Decorations(true), Fire(true), Width(0), Height(0), CompletedListener(ListenerHandle(0, (ThumbnailListener*)NULL)) {} }; //Thumbnail retreival @@ -96,7 +97,7 @@ public: virtual ~ThumbnailBroker(); void FlushThumbQueue(); - void RenderThumbnail(GameSave * gameSave, bool decorations, int width, int height, ThumbnailListener * tListener); + void RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, 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 41a80bd53..445142ae0 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -397,7 +397,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender) if(save->GetGameSave()) { - savePreview = SaveRenderer::Ref().Render(save->GetGameSave(), false); + savePreview = SaveRenderer::Ref().Render(save->GetGameSave(), false, true); if(savePreview && savePreview->Data && !(savePreview->Size.X == XRES/2 && savePreview->Size.Y == YRES/2)) { diff --git a/src/save/LocalSaveActivity.cpp b/src/save/LocalSaveActivity.cpp index fab71f27c..740fabee2 100644 --- a/src/save/LocalSaveActivity.cpp +++ b/src/save/LocalSaveActivity.cpp @@ -70,7 +70,7 @@ LocalSaveActivity::LocalSaveActivity(SaveFile save) : SetOkayButton(okayButton); if(save.GetGameSave()) - ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), Size.X-16, -1, this); + ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), true, false, Size.X-16, -1, this); } void LocalSaveActivity::Save() diff --git a/src/save/ServerSaveActivity.cpp b/src/save/ServerSaveActivity.cpp index ef674e237..f5caf779e 100644 --- a/src/save/ServerSaveActivity.cpp +++ b/src/save/ServerSaveActivity.cpp @@ -128,7 +128,7 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp SetOkayButton(okayButton); if(save.GetGameSave()) - ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), false, (Size.X/2)-16, -1, this); + ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), false, true, (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 3e5c971c4..fc30a281d 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 e54517e07..be4a83bb1 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, 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: