summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.h4
-rw-r--r--src/PowderToySDL.cpp56
-rw-r--r--src/cat/CommandInterface.cpp8
-rw-r--r--src/cat/LuaScriptInterface.cpp7
-rw-r--r--src/cat/TPTScriptInterface.cpp6
-rw-r--r--src/client/Client.cpp25
-rw-r--r--src/client/Client.h1
-rw-r--r--src/client/ThumbnailBroker.cpp8
-rw-r--r--src/client/ThumbnailBroker.h9
-rw-r--r--src/game/GameController.cpp22
-rw-r--r--src/game/GameModel.cpp23
-rw-r--r--src/game/GameModel.h6
-rw-r--r--src/game/GameView.cpp35
-rw-r--r--src/game/GameView.h4
-rw-r--r--src/game/QuickOptions.h29
-rw-r--r--src/game/SignTool.cpp2
-rw-r--r--src/graphics/Renderer.cpp2
-rw-r--r--src/interface/Engine.cpp5
-rw-r--r--src/interface/Engine.h5
-rw-r--r--src/interface/Textbox.cpp5
-rw-r--r--src/localbrowser/LocalBrowserController.cpp30
-rw-r--r--src/localbrowser/LocalBrowserController.h2
-rw-r--r--src/localbrowser/LocalBrowserModel.cpp5
-rw-r--r--src/localbrowser/LocalBrowserModel.h1
-rw-r--r--src/localbrowser/LocalBrowserView.cpp15
-rw-r--r--src/localbrowser/LocalBrowserView.h1
-rw-r--r--src/options/OptionsController.cpp5
-rw-r--r--src/options/OptionsController.h1
-rw-r--r--src/options/OptionsModel.cpp11
-rw-r--r--src/options/OptionsModel.h2
-rw-r--r--src/options/OptionsView.cpp31
-rw-r--r--src/options/OptionsView.h2
-rw-r--r--src/pim/Scanner.cpp1
-rw-r--r--src/preview/PreviewView.cpp2
-rw-r--r--src/save/LocalSaveActivity.cpp2
-rw-r--r--src/save/ServerSaveActivity.cpp13
-rw-r--r--src/simulation/Sample.h4
-rw-r--r--src/simulation/SaveRenderer.cpp36
-rw-r--r--src/simulation/SaveRenderer.h4
-rw-r--r--src/simulation/Sign.cpp2
-rw-r--r--src/simulation/Simulation.cpp75
-rw-r--r--src/simulation/Simulation.h7
-rw-r--r--src/simulation/Snapshot.h2
-rw-r--r--src/simulation/elements/BANG.cpp7
-rw-r--r--src/simulation/elements/CO2.cpp6
-rw-r--r--src/simulation/elements/LOLZ.cpp22
-rw-r--r--src/simulation/elements/LOVE.cpp22
47 files changed, 447 insertions, 126 deletions
diff --git a/src/Config.h b/src/Config.h
index e58f119..8baefd2 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -21,11 +21,11 @@
#endif
#ifndef MINOR_VERSION
-#define MINOR_VERSION 4
+#define MINOR_VERSION 9
#endif
#ifndef BUILD_NUM
-#define BUILD_NUM 213
+#define BUILD_NUM 232
#endif
#ifndef SNAPSHOT_ID
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
index 75c1861..74d8bc5 100644
--- a/src/PowderToySDL.cpp
+++ b/src/PowderToySDL.cpp
@@ -296,6 +296,9 @@ ui::Engine * engine = NULL;
void EngineProcess()
{
+ int frameStart;
+ float frameTime;
+ float frameTimeAvg = 0.0f, correctedFrameTimeAvg = 0.0f;
SDL_Event event;
while(engine->Running())
{
@@ -306,7 +309,8 @@ void EngineProcess()
switch (event.type)
{
case SDL_QUIT:
- engine->Exit();
+ if (engine->GetFastQuit() || engine->CloseWindow())
+ engine->Exit();
break;
case SDL_KEYDOWN:
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_LSHIFT, event.key.keysym.mod&KEY_MOD_LCONTROL, event.key.keysym.mod&KEY_MOD_LALT);
@@ -363,13 +367,30 @@ void EngineProcess()
}
if(engine->Broken()) { engine->UnBreak(); break; }
+ frameStart = SDL_GetTicks();
engine->Tick();
engine->Draw();
+ frameTime = SDL_GetTicks() - frameStart;
- if(SDL_GetTicks()-lastTick>250)
+ frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime);
+ if(ui::Engine::Ref().FpsLimit > 2.0f)
+ {
+ float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit);
+ if(targetFrameTime - frameTimeAvg > 0)
+ {
+ SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f);
+ frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg);
+ }
+ }
+
+ correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime);
+ fps = 1000.0f/correctedFrameTimeAvg;
+ engine->SetFps(fps);
+
+ if(frameStart-lastTick>250)
{
//Run client tick every second
- lastTick = SDL_GetTicks();
+ lastTick = frameStart;
Client::Ref().Tick();
}
@@ -387,34 +408,6 @@ void EngineProcess()
else
blit(engine->g->vid);
#endif
-
- currentFrame++;
- currentTime = SDL_GetTicks();
- elapsedTime = currentTime - lastTime;
- if(ui::Engine::Ref().FpsLimit > 2.0f && (currentFrame>2 || elapsedTime > 1000*2/ui::Engine::Ref().FpsLimit) && elapsedTime && currentFrame*1000/elapsedTime > ui::Engine::Ref().FpsLimit)
- {
- while (currentFrame*1000/elapsedTime > ui::Engine::Ref().FpsLimit)
- {
- SDL_Delay(1);
- currentTime = SDL_GetTicks();
- elapsedTime = currentTime-lastTime;
- }
- }
- if(elapsedTime>=1000)
- {
- fps = (((float)currentFrame)/((float)elapsedTime))*1000.0f;
- currentFrame = 0;
- lastTime = currentTime;
- if(ui::Engine::Ref().FpsLimit > 2.0f)
- {
- delta = ui::Engine::Ref().FpsLimit/fps;
- }
- else
- {
- delta = 1.0f;
- }
- }
- engine->SetFps(fps);
}
#ifdef DEBUG
std::cout << "Breaking out of EngineProcess" << std::endl;
@@ -499,6 +492,7 @@ int main(int argc, char * argv[])
engine = &ui::Engine::Ref();
engine->SetMaxSize(desktopWidth, desktopHeight);
engine->Begin(XRES+BARSIZE, YRES+MENUSIZE);
+ engine->SetFastQuit(Client::Ref().GetPrefBool("FastQuit", true));
GameController * gameController = new GameController();
engine->ShowWindow(gameController->GetView());
diff --git a/src/cat/CommandInterface.cpp b/src/cat/CommandInterface.cpp
index 240e7e4..3ebc795 100644
--- a/src/cat/CommandInterface.cpp
+++ b/src/cat/CommandInterface.cpp
@@ -96,16 +96,16 @@ int CommandInterface::GetParticleType(std::string type)
Element * elements = m->GetSimulation()->elements;
// alternative names for some elements
- if (strcasecmp(txt,"C4")==0) i = PT_PLEX;
- else if (strcasecmp(txt,"C5")==0) i = PT_C5;
- else if (strcasecmp(txt,"NONE")==0) i = PT_NONE;
+ if (strcasecmp(txt,"C4")==0) return PT_PLEX;
+ else if (strcasecmp(txt,"C5")==0) return PT_C5;
+ else if (strcasecmp(txt,"NONE")==0) return PT_NONE;
for (i=1; i<PT_NUM; i++) {
if (strcasecmp(txt, elements[i].Name)==0 && elements[i].Enabled)
{
return i;
}
}
- return i;
+ return -1;
}
std::string CommandInterface::GetLastError()
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 5de7f46..b9124c5 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -307,10 +307,9 @@ tpt.partsdata = nil");
void LuaScriptInterface::Init()
{
- if(luacon_eval("dofile(\"autorun.lua\")"))
- {
- luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
- }
+ if(Client::Ref().FileExists("autorun.lua"))
+ if(luacon_eval("dofile(\"autorun.lua\")"))
+ luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
}
void LuaScriptInterface::SetWindow(ui::Window * window)
diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp
index 9cfba07..2f250a5 100644
--- a/src/cat/TPTScriptInterface.cpp
+++ b/src/cat/TPTScriptInterface.cpp
@@ -211,9 +211,15 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
if(value.GetType() == TypeNumber)
newValue = ((NumberType)value).Value();
else if(value.GetType() == TypeString)
+ {
newValue = GetParticleType(((StringType)value).Value());
+ if (newValue < 0 || newValue >= PT_NUM)
+ throw GeneralException("Invalid element");
+ }
else
throw GeneralException("Invalid value for assignment");
+ if (property.Value() == "type" && (newValue < 0 || newValue >= PT_NUM))
+ throw GeneralException("Invalid element");
if(selector.GetType() == TypePoint || selector.GetType() == TypeNumber)
{
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 238c216..b35c292 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <deque>
#include <fstream>
+#include <dirent.h>
#ifdef MACOSX
#include <mach-o/dyld.h>
@@ -849,6 +850,8 @@ void Client::DeleteStamp(std::string stampID)
return;
}
}
+
+ updateStamps();
}
std::string Client::AddStamp(GameSave * saveData)
@@ -910,6 +913,28 @@ void Client::updateStamps()
return;
}
+void Client::RescanStamps()
+{
+ DIR * directory;
+ struct dirent * entry;
+ directory = opendir("stamps");
+ if (directory != NULL)
+ {
+ stampIDs.clear();
+ while (entry = readdir(directory))
+ {
+ if(strncmp(entry->d_name, "..", 3) && strncmp(entry->d_name, ".", 2) && strstr(entry->d_name, ".stm") && strlen(entry->d_name) == 14)
+ {
+ char stampname[11];
+ strncpy(stampname, entry->d_name, 10);
+ stampIDs.push_front(stampname);
+ }
+ }
+ closedir(directory);
+ updateStamps();
+ }
+}
+
int Client::GetStampsCount()
{
return stampIDs.size();
diff --git a/src/client/Client.h b/src/client/Client.h
index 95ae952..4f65788 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -112,6 +112,7 @@ public:
void DeleteStamp(std::string stampID);
std::string AddStamp(GameSave * saveData);
std::vector<std::string> GetStamps(int start, int count);
+ void RescanStamps();
int GetStampsCount();
SaveFile * GetFirstStamp();
diff --git a/src/client/ThumbnailBroker.cpp b/src/client/ThumbnailBroker.cpp
index c81ccc6..e884a98 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 360c386..ba6d3ae 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, 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/game/GameController.cpp b/src/game/GameController.cpp
index a1c4965..99315b0 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -146,6 +146,7 @@ GameController::GameController():
{
gameView = new GameView();
gameModel = new GameModel();
+ gameModel->BuildQuickOptionMenu(this);
gameView->AttachController(this);
gameModel->AddObserver(gameView);
@@ -536,7 +537,7 @@ bool GameController::MouseUp(int x, int y, unsigned button)
(*iter).pos(signx, signy, signw, signh);
if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
{
- if (sregexp((*iter).text.c_str(), "^{c:[0-9]*|.*}$")==0)
+ if (sregexp((*iter).text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0)
{
const char * signText = (*iter).text.c_str();
char buff[256];
@@ -550,8 +551,17 @@ bool GameController::MouseUp(int x, int y, unsigned button)
buff[sldr-3] = '\0';
int tempSaveID = format::StringToNumber<int>(std::string(buff));
- if(tempSaveID)
- OpenSavePreview(tempSaveID, 0);
+ if (tempSaveID)
+ {
+ if ((*iter).text.c_str()[1] == 'c')
+ OpenSavePreview(tempSaveID, 0);
+ else if ((*iter).text.c_str()[1] == 't')
+ {
+ char url[256];
+ sprintf(url, "http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=%i", tempSaveID);
+ OpenURI(url);
+ }
+ }
break;
}
}
@@ -744,8 +754,7 @@ void GameController::SwitchAir()
void GameController::ToggleAHeat()
{
- gameModel->GetSimulation()->aheat_enable = !gameModel->GetSimulation()->aheat_enable;
- gameModel->UpdateQuickOptions();
+ gameModel->SetAHeatEnable(!gameModel->GetAHeatEnable());
}
@@ -1101,8 +1110,7 @@ void GameController::SaveAsCurrent()
virtual ~SaveUploadedCallback() {};
virtual void SaveUploaded(SaveInfo save)
{
- //Don't do anything
- //c->LoadSave(&save);
+ c->LoadSave(&save);
}
};
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 6f30b5e..49e031f 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -98,7 +98,6 @@ GameModel::GameModel():
}
BuildMenus();
- BuildQuickOptionMenu();
//Set default decoration colour
unsigned char colourR = min(Client::Ref().GetPrefInteger("Decoration.Red", 200), 255);
@@ -173,7 +172,7 @@ void GameModel::UpdateQuickOptions()
}
}
-void GameModel::BuildQuickOptionMenu()
+void GameModel::BuildQuickOptionMenu(GameController * controller)
{
for(std::vector<QuickOption*>::iterator iter = quickOptions.begin(), end = quickOptions.end(); iter != end; ++iter)
{
@@ -186,6 +185,7 @@ void GameModel::BuildQuickOptionMenu()
quickOptions.push_back(new DecorationsOption(this));
quickOptions.push_back(new NGravityOption(this));
quickOptions.push_back(new AHeatOption(this));
+ quickOptions.push_back(new ConsoleShowOption(this, controller));
notifyQuickOptionsChanged();
UpdateQuickOptions();
@@ -754,6 +754,10 @@ void GameModel::SetDecoration(bool decorationState)
ren->decorations_enable = decorationState?1:0;
notifyDecorationChanged();
UpdateQuickOptions();
+ if (decorationState)
+ SetInfoTip("Decorations Layer: On");
+ else
+ SetInfoTip("Decorations Layer: Off");
}
bool GameModel::GetDecoration()
@@ -761,6 +765,21 @@ bool GameModel::GetDecoration()
return ren->decorations_enable?true:false;
}
+void GameModel::SetAHeatEnable(bool aHeat)
+{
+ sim->aheat_enable = aHeat;
+ UpdateQuickOptions();
+ if (aHeat)
+ SetInfoTip("Ambient Heat: On");
+ else
+ SetInfoTip("Ambient Heat: Off");
+}
+
+bool GameModel::GetAHeatEnable()
+{
+ return sim->aheat_enable;
+}
+
void GameModel::FrameStep(int frames)
{
sim->framerender += frames;
diff --git a/src/game/GameModel.h b/src/game/GameModel.h
index 61d0c93..311f89c 100644
--- a/src/game/GameModel.h
+++ b/src/game/GameModel.h
@@ -8,6 +8,7 @@
#include "interface/Colour.h"
#include "graphics/Renderer.h"
#include "GameView.h"
+#include "GameController.h"
#include "Brush.h"
#include "client/User.h"
#include "Notification.h"
@@ -18,6 +19,7 @@
using namespace std;
class GameView;
+class GameController;
class Simulation;
class Renderer;
@@ -126,7 +128,7 @@ public:
std::string GetInfoTip();
void BuildMenus();
- void BuildQuickOptionMenu();
+ void BuildQuickOptionMenu(GameController * controller);
std::deque<Snapshot*> GetHistory();
void SetHistory(std::deque<Snapshot*> newHistory);
@@ -156,6 +158,8 @@ public:
void SetPaused(bool pauseState);
bool GetDecoration();
void SetDecoration(bool decorationState);
+ bool GetAHeatEnable();
+ void SetAHeatEnable(bool aHeat);
void ClearSimulation();
vector<Menu*> GetMenuList();
vector<Tool*> GetUnlistedTools();
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 74a2b5a..7ba1fe7 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -1629,10 +1629,7 @@ void GameView::enableShiftBehaviour()
shiftBehaviour = true;
if(isMouseDown)
{
- if(!ctrlBehaviour)
- c->SetToolStrength(10.0f);
- else
- c->SetToolStrength(1.0f);
+ c->SetToolStrength(10.0f);
}
}
}
@@ -1681,7 +1678,7 @@ void GameView::enableCtrlBehaviour()
if(!shiftBehaviour)
c->SetToolStrength(.1f);
else
- c->SetToolStrength(1.0f);
+ c->SetToolStrength(10.0f);
}
}
}
@@ -1885,11 +1882,22 @@ void GameView::OnDraw()
{
if(showDebug)
{
- sampleInfo << c->ElementResolve(sample.particle.type);
- if(sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM)
- sampleInfo << " (" << c->ElementResolve(sample.particle.ctype) << ")";
+ int ctype = sample.particle.ctype;
+ if (sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP)
+ ctype = sample.particle.tmp;
+
+ if (sample.particle.type == PT_LAVA && ctype > 0 && ctype < PT_NUM)
+ sampleInfo << "Molten " << c->ElementResolve(ctype);
+ else if((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
+ sampleInfo << c->ElementResolve(sample.particle.type) << " with " << c->ElementResolve(ctype);
else
- sampleInfo << " ()";
+ {
+ sampleInfo << c->ElementResolve(sample.particle.type);
+ if(ctype > 0 && ctype < PT_NUM)
+ sampleInfo << " (" << c->ElementResolve(ctype) << ")";
+ else
+ sampleInfo << " ()";
+ }
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f;
sampleInfo << ", Life: " << sample.particle.life;
sampleInfo << ", Tmp: " << sample.particle.tmp;
@@ -1897,8 +1905,10 @@ void GameView::OnDraw()
}
else
{
- if(sample.particle.type == PT_LAVA && sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM)
+ if (sample.particle.type == PT_LAVA && sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM)
sampleInfo << "Molten " << c->ElementResolve(sample.particle.ctype);
+ else if((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && sample.particle.tmp > 0 && sample.particle.tmp < PT_NUM)
+ sampleInfo << c->ElementResolve(sample.particle.type) << " with " << c->ElementResolve(sample.particle.tmp);
else
sampleInfo << c->ElementResolve(sample.particle.type);
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f;
@@ -1987,6 +1997,11 @@ void GameView::OnDraw()
#endif
fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps();
+ if (showDebug)
+ fpsInfo << " Parts: " << sample.NumParts;
+ if (ren->GetGridSize())
+ fpsInfo << " [GRID: " << ren->GetGridSize() << "]";
+
textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str());
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
g->drawtext(16, 16, (const char*)fpsInfo.str().c_str(), 32, 216, 255, 255*0.75);
diff --git a/src/game/GameView.h b/src/game/GameView.h
index 7c77dc0..f36aef3 100644
--- a/src/game/GameView.h
+++ b/src/game/GameView.h
@@ -62,7 +62,7 @@ private:
std::string infoTip;
int toolTipPresence;
-queue<ui::Point> pointQueue;
+ queue<ui::Point> pointQueue;
GameController * c;
Renderer * ren;
Brush * activeBrush;
@@ -168,7 +168,7 @@ public:
virtual void OnDraw();
virtual void OnBlur();
- //Top-level handers, for Lua interface
+ //Top-level handlers, for Lua interface
virtual void DoDraw();
virtual void DoMouseMove(int x, int y, int dx, int dy);
virtual void DoMouseDown(int x, int y, unsigned button);
diff --git a/src/game/QuickOptions.h b/src/game/QuickOptions.h
index 61a6de8..5455051 100644
--- a/src/game/QuickOptions.h
+++ b/src/game/QuickOptions.h
@@ -47,11 +47,11 @@ public:
}
virtual bool GetToggle()
{
- return m->GetRenderer()->decorations_enable;
+ return m->GetDecoration();
}
virtual void perform()
{
- m->GetRenderer()->decorations_enable = !m->GetRenderer()->decorations_enable;
+ m->SetDecoration(!m->GetDecoration());
}
};
@@ -72,10 +72,12 @@ public:
if(m->GetSimulation()->grav->ngrav_enable)
{
m->GetSimulation()->grav->stop_grav_async();
+ m->SetInfoTip("Newtonian Gravity: Off");
}
else
{
m->GetSimulation()->grav->start_grav_async();
+ m->SetInfoTip("Newtonian Gravity: On");
}
}
};
@@ -90,10 +92,29 @@ public:
}
virtual bool GetToggle()
{
- return m->GetSimulation()->aheat_enable;
+ return m->GetAHeatEnable();
}
virtual void perform()
{
- m->GetSimulation()->aheat_enable = !m->GetSimulation()->aheat_enable;
+ m->SetAHeatEnable(!m->GetAHeatEnable());
+ }
+};
+
+class ConsoleShowOption: public QuickOption
+{
+ GameController * c;
+public:
+ ConsoleShowOption(GameModel * m, GameController * c_):
+ QuickOption("C", "Show Console", m, Toggle)
+ {
+ c = c_;
+ }
+ virtual bool GetToggle()
+ {
+ return 0;
+ }
+ virtual void perform()
+ {
+ c->ShowConsole();
}
};
diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp
index 4a5fc69..eb1ef57 100644
--- a/src/game/SignTool.cpp
+++ b/src/game/SignTool.cpp
@@ -199,7 +199,7 @@ void SignWindow::DoDraw()
sprintf(buff, "Temp: 0.00"); //...temperature
g->drawtext(x+3, y+3, buff, 255, 255, 255, 255);
}
- else if (sregexp(currentSign.text.c_str(), "^{c:[0-9]*|.*}$")==0)
+ else if (sregexp(currentSign.text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0)
{
int sldr, startm;
memset(buff, 0, sizeof(buff));
diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp
index f20d442..95a44d8 100644
--- a/src/graphics/Renderer.cpp
+++ b/src/graphics/Renderer.cpp
@@ -848,7 +848,7 @@ void Renderer::DrawSigns()
sprintf(buff, "Temp: 0.00"); //...temperature
drawtext(x+3, y+3, buff, 255, 255, 255, 255);
}
- else if (sregexp(signs[i].text.c_str(), "^{c:[0-9]*|.*}$")==0)
+ else if (sregexp(signs[i].text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0)
{
int sldr, startm;
memset(buff, 0, sizeof(buff));
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index 643a023..cdfadc8 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -30,6 +30,7 @@ Engine::Engine():
FrameIndex(0),
Fullscreen(false),
Scale(1),
+ FastQuit(1),
break_(false),
lastTick(0)
{
@@ -109,7 +110,7 @@ void Engine::ShowWindow(Window * window)
}
-void Engine::CloseWindow()
+int Engine::CloseWindow()
{
if(!windows.empty())
{
@@ -139,10 +140,12 @@ void Engine::CloseWindow()
mousexp_ = mousex_;
mouseyp_ = mousey_;
}
+ return 0;
}
else
{
state_ = NULL;
+ return 1;
}
}
diff --git a/src/interface/Engine.h b/src/interface/Engine.h
index b825eb8..fb110e4 100644
--- a/src/interface/Engine.h
+++ b/src/interface/Engine.h
@@ -22,7 +22,7 @@ namespace ui
~Engine();
void ShowWindow(Window * window);
- void CloseWindow();
+ int CloseWindow();
void onMouseMove(int x, int y);
void onMouseClick(int x, int y, unsigned button);
@@ -46,6 +46,8 @@ namespace ui
inline bool GetFullscreen() { return Fullscreen; }
void SetScale(int scale) { Scale = scale; }
inline int GetScale() { return Scale; }
+ void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
+ inline bool GetFastQuit() {return FastQuit; }
void Tick();
void Draw();
@@ -88,6 +90,7 @@ namespace ui
bool running_;
bool break_;
+ bool FastQuit;
int lastTick;
int mouseb_;
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index 7b79974..383f07b 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -283,6 +283,11 @@ bool Textbox::CharacterValid(Uint16 character)
void Textbox::Tick(float dt)
{
Label::Tick(dt);
+ if(!IsFocused())
+ {
+ keyDown = 0;
+ characterDown = 0;
+ }
if((keyDown || characterDown) && repeatTime <= clock())
{
OnVKeyPress(keyDown, characterDown, false, false, false);
diff --git a/src/localbrowser/LocalBrowserController.cpp b/src/localbrowser/LocalBrowserController.cpp
index 9565759..0f6ec76 100644
--- a/src/localbrowser/LocalBrowserController.cpp
+++ b/src/localbrowser/LocalBrowserController.cpp
@@ -53,10 +53,10 @@ void LocalBrowserController::RemoveSelected()
};
std::stringstream desc;
- desc << "Are you sure you want to delete " << browserModel->GetSelected().size() << " saves";
+ desc << "Are you sure you want to delete " << browserModel->GetSelected().size() << " stamp";
if(browserModel->GetSelected().size()>1)
desc << "s";
- new ConfirmPrompt("Delete saves", desc.str(), new RemoveSelectedConfirmation(this));
+ new ConfirmPrompt("Delete stamps", desc.str(), new RemoveSelectedConfirmation(this));
}
void LocalBrowserController::removeSelectedC()
@@ -72,7 +72,7 @@ void LocalBrowserController::removeSelectedC()
for(int i = 0; i < saves.size(); i++)
{
std::stringstream saveName;
- saveName << "Deleting save [" << saves[i] << "] ...";
+ saveName << "Deleting stamp [" << saves[i] << "] ...";
notifyStatus(saveName.str());
Client::Ref().DeleteStamp(saves[i]);
notifyProgress((float(i+1)/float(saves.size())*100));
@@ -89,6 +89,30 @@ void LocalBrowserController::removeSelectedC()
new TaskWindow("Removing saves", new RemoveSavesTask(this, selected));
}
+void LocalBrowserController::RescanStamps()
+{
+ class RescanConfirmation: public ConfirmDialogueCallback {
+ public:
+ LocalBrowserController * c;
+ RescanConfirmation(LocalBrowserController * c_) { c = c_; }
+ virtual void ConfirmCallback(ConfirmPrompt::DialogueResult result) {
+ if (result == ConfirmPrompt::ResultOkay)
+ c->rescanStampsC();
+ }
+ virtual ~RescanConfirmation() { }
+ };
+
+ std::stringstream desc;
+ desc << "Rescanning the stamps folder can find stamps added to the stamps folder or recover stamps when the stamps.def file has been lost or damaged. However, be warned that this may mess up the current sorting order";
+ new ConfirmPrompt("Rescan", desc.str(), new RescanConfirmation(this));
+}
+
+void LocalBrowserController::rescanStampsC()
+{
+ browserModel->RescanStamps();
+ browserModel->UpdateSavesList(browserModel->GetPageNum());
+}
+
void LocalBrowserController::RefreshSavesList()
{
ClearSelection();
diff --git a/src/localbrowser/LocalBrowserController.h b/src/localbrowser/LocalBrowserController.h
index 1f81ab6..efa9c93 100644
--- a/src/localbrowser/LocalBrowserController.h
+++ b/src/localbrowser/LocalBrowserController.h
@@ -27,6 +27,8 @@ public:
void removeSelectedC();
void ClearSelection();
void Selected(std::string stampID, bool selected);
+ void RescanStamps();
+ void rescanStampsC();
void RefreshSavesList();
void OpenSave(SaveFile * stamp);
void SetStamp();
diff --git a/src/localbrowser/LocalBrowserModel.cpp b/src/localbrowser/LocalBrowserModel.cpp
index a38ca1f..9e869cc 100644
--- a/src/localbrowser/LocalBrowserModel.cpp
+++ b/src/localbrowser/LocalBrowserModel.cpp
@@ -87,6 +87,11 @@ void LocalBrowserModel::UpdateSavesList(int pageNumber)
notifySavesListChanged();
}
+void LocalBrowserModel::RescanStamps()
+{
+ Client::Ref().RescanStamps();
+}
+
int LocalBrowserModel::GetPageCount()
{
return std::max(1, (int)(std::ceil(float(Client::Ref().GetStampsCount())/20.0f)));
diff --git a/src/localbrowser/LocalBrowserModel.h b/src/localbrowser/LocalBrowserModel.h
index e6b6905..c2a6f9b 100644
--- a/src/localbrowser/LocalBrowserModel.h
+++ b/src/localbrowser/LocalBrowserModel.h
@@ -32,6 +32,7 @@ public:
void AddObserver(LocalBrowserView * observer);
std::vector<SaveFile *> GetSavesList();
void UpdateSavesList(int pageNumber);
+ void RescanStamps();
SaveFile * GetSave();
void SetSave(SaveFile * newStamp);
std::vector<std::string> GetSelected() { return selected; }
diff --git a/src/localbrowser/LocalBrowserView.cpp b/src/localbrowser/LocalBrowserView.cpp
index cbb98bf..a6efc4c 100644
--- a/src/localbrowser/LocalBrowserView.cpp
+++ b/src/localbrowser/LocalBrowserView.cpp
@@ -16,6 +16,7 @@
#include "interface/Keys.h"
#include "dialogues/ErrorMessage.h"
+#include "dialogues/ConfirmPrompt.h"
#include "LocalBrowserController.h"
#include "LocalBrowserModel.h"
#include "LocalBrowserModelException.h"
@@ -25,10 +26,12 @@ LocalBrowserView::LocalBrowserView():
{
nextButton = new ui::Button(ui::Point(XRES+BARSIZE-52, YRES+MENUSIZE-18), ui::Point(50, 16), "Next \x95");
previousButton = new ui::Button(ui::Point(1, YRES+MENUSIZE-18), ui::Point(50, 16), "\x96 Prev");
+ undeleteButton = new ui::Button(ui::Point(XRES+BARSIZE-122, YRES+MENUSIZE-18), ui::Point(60, 16), "Rescan");
infoLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "Loading...");
AddComponent(infoLabel);
AddComponent(nextButton);
AddComponent(previousButton);
+ AddComponent(undeleteButton);
class NextPageAction : public ui::ButtonAction
{
@@ -58,6 +61,18 @@ LocalBrowserView::LocalBrowserView():
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ class UndeleteAction : public ui::ButtonAction
+ {
+ LocalBrowserView * v;
+ public:
+ UndeleteAction(LocalBrowserView * _v) { v = _v; }
+ void ActionCallback(ui::Button * sender)
+ {
+ v->c->RescanStamps();
+ }
+ };
+ undeleteButton->SetActionCallback(new UndeleteAction(this));
+
class RemoveSelectedAction : public ui::ButtonAction
{
LocalBrowserView * v;
diff --git a/src/localbrowser/LocalBrowserView.h b/src/localbrowser/LocalBrowserView.h
index 71c20ee..7a8c813 100644
--- a/src/localbrowser/LocalBrowserView.h
+++ b/src/localbrowser/LocalBrowserView.h
@@ -23,6 +23,7 @@ class LocalBrowserModel;
class LocalBrowserView: public ui::Window {
LocalBrowserController * c;
std::vector<ui::SaveButton*> stampButtons;
+ ui::Button * undeleteButton;
ui::Button * previousButton;
ui::Button * nextButton;
ui::Label * infoLabel;
diff --git a/src/options/OptionsController.cpp b/src/options/OptionsController.cpp
index 579ad73..3973fed 100644
--- a/src/options/OptionsController.cpp
+++ b/src/options/OptionsController.cpp
@@ -78,6 +78,11 @@ void OptionsController::SetScale(bool scale)
}
+void OptionsController::SetFastQuit(bool fastquit)
+{
+ model->SetFastQuit(fastquit);
+}
+
OptionsView * OptionsController::GetView()
{
return view;
diff --git a/src/options/OptionsController.h b/src/options/OptionsController.h
index 43db1f8..1df92ba 100644
--- a/src/options/OptionsController.h
+++ b/src/options/OptionsController.h
@@ -33,6 +33,7 @@ public:
void SetEdgeMode(int airMode);
void SetFullscreen(bool fullscreen);
void SetScale(bool scale);
+ void SetFastQuit(bool fastquit);
void Exit();
OptionsView * GetView();
virtual ~OptionsController();
diff --git a/src/options/OptionsModel.cpp b/src/options/OptionsModel.cpp
index f9cef2f..c3517fa 100644
--- a/src/options/OptionsModel.cpp
+++ b/src/options/OptionsModel.cpp
@@ -120,6 +120,17 @@ void OptionsModel::SetFullscreen(bool fullscreen)
notifySettingsChanged();
}
+bool OptionsModel::GetFastQuit()
+{
+ return ui::Engine::Ref().GetFastQuit();
+}
+void OptionsModel::SetFastQuit(bool fastquit)
+{
+ ui::Engine::Ref().SetFastQuit(fastquit);
+ Client::Ref().SetPref("FastQuit", bool(fastquit));
+ notifySettingsChanged();
+}
+
void OptionsModel::notifySettingsChanged()
{
for(int i = 0; i < observers.size(); i++)
diff --git a/src/options/OptionsModel.h b/src/options/OptionsModel.h
index 52b7fa5..c15fb88 100644
--- a/src/options/OptionsModel.h
+++ b/src/options/OptionsModel.h
@@ -38,6 +38,8 @@ public:
void SetGravityMode(int gravityMode);
bool GetFullscreen();
void SetFullscreen(bool fullscreen);
+ bool GetFastQuit();
+ void SetFastQuit(bool fastquit);
bool GetScale();
void SetScale(bool scale);
virtual ~OptionsModel();
diff --git a/src/options/OptionsView.cpp b/src/options/OptionsView.cpp
index 9811154..3adf7d7 100644
--- a/src/options/OptionsView.cpp
+++ b/src/options/OptionsView.cpp
@@ -12,7 +12,7 @@
#include "interface/DropDown.h"
OptionsView::OptionsView():
- ui::Window(ui::Point(-1, -1), ui::Point(300, 270)){
+ ui::Window(ui::Point(-1, -1), ui::Point(300, 290)){
ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
tempLabel->SetTextColour(style::Colour::InformationTitle);
@@ -146,8 +146,12 @@ OptionsView::OptionsView():
scale = new ui::Checkbox(ui::Point(8, 210), ui::Point(Size.X-6, 16), "Large screen", "");
scale->SetActionCallback(new ScaleAction(this));
+ tempLabel = new ui::Label(ui::Point(scale->Position.X+Graphics::textwidth(scale->GetText().c_str())+20, scale->Position.Y), ui::Point(Size.X-28, 16), "\bg- Double window size for smaller screen");
+ tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ AddComponent(tempLabel);
AddComponent(scale);
+
class FullscreenAction: public ui::CheckboxAction
{
OptionsView * v;
@@ -158,8 +162,27 @@ OptionsView::OptionsView():
fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen", "");
fullscreen->SetActionCallback(new FullscreenAction(this));
+ tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText().c_str())+20, fullscreen->Position.Y), ui::Point(Size.X-28, 16), "\bg- Use the entire screen");
+ tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ AddComponent(tempLabel);
AddComponent(fullscreen);
+
+ class FastQuitAction: public ui::CheckboxAction
+ {
+ OptionsView * v;
+ public:
+ FastQuitAction(OptionsView * v_){ v = v_; }
+ virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetFastQuit(sender->GetChecked()); }
+ };
+
+ fastquit = new ui::Checkbox(ui::Point(8, 250), ui::Point(Size.X-6, 16), "Fast Quit", "");
+ fastquit->SetActionCallback(new FastQuitAction(this));
+ tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText().c_str())+20, fastquit->Position.Y), ui::Point(Size.X-28, 16), "\bg- Always exit completely when hitting close");
+ tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ AddComponent(tempLabel);
+ AddComponent(fastquit);
+
class CloseAction: public ui::ButtonAction
{
public:
@@ -189,6 +212,7 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
edgeMode->SetOption(sender->GetEdgeMode());
scale->SetChecked(sender->GetScale());
fullscreen->SetChecked(sender->GetFullscreen());
+ fastquit->SetChecked(sender->GetFastQuit());
}
void OptionsView::AttachController(OptionsController * c_)
@@ -204,6 +228,11 @@ void OptionsView::OnDraw()
g->draw_line(Position.X+1, Position.Y+scale->Position.Y-4, Position.X+Size.X-1, Position.Y+scale->Position.Y-4, 255, 255, 255, 180);
}
+void OptionsView::OnTryExit(ExitMethod method)
+{
+ c->Exit();
+}
+
OptionsView::~OptionsView() {
// TODO Auto-generated destructor stub
diff --git a/src/options/OptionsView.h b/src/options/OptionsView.h
index d0a99ab..a4c9854 100644
--- a/src/options/OptionsView.h
+++ b/src/options/OptionsView.h
@@ -27,11 +27,13 @@ class OptionsView: public ui::Window {
ui::DropDown * edgeMode;
ui::Checkbox * scale;
ui::Checkbox * fullscreen;
+ ui::Checkbox * fastquit;
public:
OptionsView();
void NotifySettingsChanged(OptionsModel * sender);
void AttachController(OptionsController * c_);
void OnDraw();
+ void OnTryExit(ExitMethod method);
virtual ~OptionsView();
};
diff --git a/src/pim/Scanner.cpp b/src/pim/Scanner.cpp
index b56d2b6..e6d145a 100644
--- a/src/pim/Scanner.cpp
+++ b/src/pim/Scanner.cpp
@@ -1,5 +1,6 @@
//Lexical analyser
#include <algorithm>
+#include <cctype>
#include "Scanner.h"
namespace pim
diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp
index 41a80bd..445142a 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 fab71f2..740fabe 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 ef674e2..d336ea1 100644
--- a/src/save/ServerSaveActivity.cpp
+++ b/src/save/ServerSaveActivity.cpp
@@ -33,7 +33,6 @@ public:
}
};
-//Currently, reading is done on another thread, we can't render outside the main thread due to some bullshit with OpenGL
class SaveUploadTask: public Task
{
SaveInfo save;
@@ -128,7 +127,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) :
@@ -151,11 +150,19 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, bool saveNow, ServerSaveAc
void ServerSaveActivity::NotifyDone(Task * task)
{
- Exit();
if(!task->GetSuccess())
{
+ Exit();
new ErrorMessage("Error", Client::Ref().GetLastError());
}
+ else
+ {
+ if(callback)
+ {
+ callback->SaveUploaded(save);
+ }
+ Exit();
+ }
}
void ServerSaveActivity::Save()
diff --git a/src/simulation/Sample.h b/src/simulation/Sample.h
index 0e67331..3605a5d 100644
--- a/src/simulation/Sample.h
+++ b/src/simulation/Sample.h
@@ -21,7 +21,9 @@ public:
float GravityVelocityX;
float GravityVelocityY;
- SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0) {}
+ int NumParts;
+
+ SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0), NumParts(0) {}
};
#endif \ No newline at end of file
diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp
index 3e5c971..fc30a28 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 e54517e..be4a83b 100644
--- a/src/simulation/SaveRenderer.h
+++ b/src/simulation/SaveRenderer.h
@@ -24,8 +24,8 @@ class SaveRenderer: public Singleton<SaveRenderer> {
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:
diff --git a/src/simulation/Sign.cpp b/src/simulation/Sign.cpp
index 01d388f..2caf6c3 100644
--- a/src/simulation/Sign.cpp
+++ b/src/simulation/Sign.cpp
@@ -28,7 +28,7 @@ void sign::pos(int & x0, int & y0, int & w, int & h)
{
w = Graphics::textwidth("Temp: 0000.00");
}
- else if (sregexp(text.c_str(), "^{c:[0-9]*|.*}$")==0)
+ else if (sregexp(text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0)
{
int sldr, startm;
char buff[256];
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 682d3e0..61b0944 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -230,6 +230,7 @@ Snapshot * Simulation::CreateSnapshot()
snap->AirPressure.insert(snap->AirPressure.begin(), &pv[0][0], &pv[0][0]+((XRES/CELL)*(YRES/CELL)));
snap->AirVelocityX.insert(snap->AirVelocityX.begin(), &vx[0][0], &vx[0][0]+((XRES/CELL)*(YRES/CELL)));
snap->AirVelocityY.insert(snap->AirVelocityY.begin(), &vy[0][0], &vy[0][0]+((XRES/CELL)*(YRES/CELL)));
+ snap->AmbientHeat.insert(snap->AmbientHeat.begin(), &hv[0][0], &hv[0][0]+((XRES/CELL)*(YRES/CELL)));
snap->Particles.insert(snap->Particles.begin(), parts, parts+NPART);
snap->PortalParticles.insert(snap->PortalParticles.begin(), &portalp[0][0][0], &portalp[CHANNELS-1][8-1][80-1]);
snap->WirelessData.insert(snap->WirelessData.begin(), &wireless[0][0], &wireless[CHANNELS-1][2-1]);
@@ -250,6 +251,7 @@ void Simulation::Restore(const Snapshot & snap)
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]);
+ std::copy(snap.AmbientHeat.begin(), snap.AmbientHeat.end(), &hv[0][0]);
std::copy(snap.Particles.begin(), snap.Particles.end(), parts);
std::copy(snap.PortalParticles.begin(), snap.PortalParticles.end(), &portalp[0][0][0]);
std::copy(snap.WirelessData.begin(), snap.WirelessData.end(), &wireless[0][0]);
@@ -437,6 +439,8 @@ SimulationSample Simulation::Get(int x, int y)
sample.GravityVelocityX = gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
sample.GravityVelocityY = gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
}
+
+ sample.NumParts = NUM_PARTS;
return sample;
}
@@ -3269,6 +3273,77 @@ void Simulation::update_particles_i(int start, int inc)
}
}
+ if (ISLOVE || ISLOLZ) //LOVE and LOLZ element handling
+ {
+ int nx, nnx, ny, nny, r, rt;
+ ISLOVE = 0;
+ ISLOLZ = 0;
+ for (ny=0; ny<YRES-4; ny++)
+ {
+ for (nx=0; nx<XRES-4; nx++)
+ {
+ r=pmap[ny][nx];
+ if (!r)
+ {
+ continue;
+ }
+ else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&(parts[r>>8].type==PT_LOVE||parts[r>>8].type==PT_LOLZ))
+ kill_part(r>>8);
+ else if (parts[r>>8].type==PT_LOVE)
+ {
+ love[nx/9][ny/9] = 1;
+ }
+ else if (parts[r>>8].type==PT_LOLZ)
+ {
+ lolz[nx/9][ny/9] = 1;
+ }
+ }
+ }
+ for (nx=9; nx<=XRES-18; nx++)
+ {
+ for (ny=9; ny<=YRES-7; ny++)
+ {
+ if (love[nx/9][ny/9]==1)
+ {
+ for ( nnx=0; nnx<9; nnx++)
+ for ( nny=0; nny<9; nny++)
+ {
+ if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if (!rt&&Element_LOVE::RuleTable[nnx][nny]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOVE);
+ else if (!rt)
+ continue;
+ else if (parts[rt>>8].type==PT_LOVE&&Element_LOVE::RuleTable[nnx][nny]==0)
+ kill_part(rt>>8);
+ }
+ }
+ }
+ love[nx/9][ny/9]=0;
+ if (lolz[nx/9][ny/9]==1)
+ {
+ for ( nnx=0; nnx<9; nnx++)
+ for ( nny=0; nny<9; nny++)
+ {
+ if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if (!rt&&Element_LOLZ::RuleTable[nny][nnx]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
+ else if (!rt)
+ continue;
+ else if (parts[rt>>8].type==PT_LOLZ&&Element_LOLZ::RuleTable[nny][nnx]==0)
+ kill_part(rt>>8);
+
+ }
+ }
+ }
+ lolz[nx/9][ny/9]=0;
+ }
+ }
+ }
+
//wire!
if(elementCount[PT_WIRE] > 0)
{
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index ba9fa1a..98c5025 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -117,6 +117,12 @@ public:
int pretty_powder;
int sandcolour;
int sandcolour_frame;
+ static int loverule[9][9];
+ bool ISLOVE;
+ int love[XRES/9][YRES/9];
+ static int lolzrule[9][9];
+ bool ISLOLZ;
+ int lolz[XRES/9][YRES/9];
int Load(GameSave * save);
int Load(int x, int y, GameSave * save);
@@ -204,6 +210,7 @@ public:
Simulation();
~Simulation();
};
+
//#endif
#endif /* SIMULATION_H_ */
diff --git a/src/simulation/Snapshot.h b/src/simulation/Snapshot.h
index a1c34fa..d47f363 100644
--- a/src/simulation/Snapshot.h
+++ b/src/simulation/Snapshot.h
@@ -10,6 +10,7 @@ public:
std::vector<float> AirPressure;
std::vector<float> AirVelocityX;
std::vector<float> AirVelocityY;
+ std::vector<float> AmbientHeat;
std::vector<Particle> Particles;
std::vector<Particle> PortalParticles;
@@ -31,6 +32,7 @@ public:
AirPressure(),
AirVelocityX(),
AirVelocityY(),
+ AmbientHeat(),
Particles(),
PortalParticles(),
WirelessData(),
diff --git a/src/simulation/elements/BANG.cpp b/src/simulation/elements/BANG.cpp
index 2dc660a..b0ff983 100644
--- a/src/simulation/elements/BANG.cpp
+++ b/src/simulation/elements/BANG.cpp
@@ -75,8 +75,11 @@ int Element_BANG::update(UPDATE_FUNC_ARGS)
}
else if(parts[i].tmp==1)
{
- int tempvalue = 2;
- sim->flood_prop(x, y, offsetof(Particle, tmp), &tempvalue, StructProperty::Integer);
+ if ((pmap[y][x]>>8 == i))
+ {
+ int tempvalue = 2;
+ sim->flood_prop(x, y, offsetof(Particle, tmp), &tempvalue, StructProperty::Integer);
+ }
parts[i].tmp = 2;
}
else if(parts[i].tmp==2)
diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp
index 4e29286..ca5cc31 100644
--- a/src/simulation/elements/CO2.cpp
+++ b/src/simulation/elements/CO2.cpp
@@ -71,11 +71,11 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
}
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250))
{
- sim->part_change_type(i,x,y,PT_CBNW);
+ sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW);
if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet
- sim->create_part(r>>8, x+rx, y+ry, PT_CBNW);
+ sim->create_part(i, x, y, PT_WATR);
else
- sim->kill_part(r>>8);
+ sim->kill_part(i);
}
}
if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f)
diff --git a/src/simulation/elements/LOLZ.cpp b/src/simulation/elements/LOLZ.cpp
index 6feae3f..a5e8371 100644
--- a/src/simulation/elements/LOLZ.cpp
+++ b/src/simulation/elements/LOLZ.cpp
@@ -46,16 +46,24 @@ Element_LOLZ::Element_LOLZ()
}
+//#TPT-Directive ElementHeader Element_LOLZ static int RuleTable[9][9]
+int Element_LOLZ::RuleTable[9][9] =
+{
+ {0,0,0,0,0,0,0,0,0},
+ {1,0,0,0,0,0,1,0,0},
+ {1,0,0,0,0,0,1,0,0},
+ {1,0,0,1,1,0,0,1,0},
+ {1,0,1,0,0,1,0,1,0},
+ {1,0,1,0,0,1,0,1,0},
+ {0,1,0,1,1,0,0,1,0},
+ {0,1,0,0,0,0,0,1,0},
+ {0,1,0,0,0,0,0,1,0},
+};
+
//#TPT-Directive ElementHeader Element_LOLZ static int update(UPDATE_FUNC_ARGS)
int Element_LOLZ::update(UPDATE_FUNC_ARGS)
{
- /*int t = parts[i].type;
- if (t==PT_LOVE)
- ISLOVE=1;
- else if (t==PT_LOLZ)
- ISLOLZ=1;
- else if (t==PT_GRAV)
- ISGRAV=1;*/
+ sim->ISLOLZ = true;
return 0;
}
diff --git a/src/simulation/elements/LOVE.cpp b/src/simulation/elements/LOVE.cpp
index 28a20b7..3e7b3d4 100644
--- a/src/simulation/elements/LOVE.cpp
+++ b/src/simulation/elements/LOVE.cpp
@@ -46,16 +46,24 @@ Element_LOVE::Element_LOVE()
}
+//#TPT-Directive ElementHeader Element_LOVE static int RuleTable[9][9]
+int Element_LOVE::RuleTable[9][9] =
+{
+ {0,0,1,1,0,0,0,0,0},
+ {0,1,0,0,1,1,0,0,0},
+ {1,0,0,0,0,0,1,0,0},
+ {1,0,0,0,0,0,0,1,0},
+ {0,1,0,0,0,0,0,0,1},
+ {1,0,0,0,0,0,0,1,0},
+ {1,0,0,0,0,0,1,0,0},
+ {0,1,0,0,1,1,0,0,0},
+ {0,0,1,1,0,0,0,0,0},
+};
+
//#TPT-Directive ElementHeader Element_LOVE static int update(UPDATE_FUNC_ARGS)
int Element_LOVE::update(UPDATE_FUNC_ARGS)
{
- /*int t = parts[i].type;
- if (t==PT_LOVE)
- ISLOVE=1;
- else if (t==PT_LOLZ)
- ISLOLZ=1;
- else if (t==PT_GRAV)
- ISGRAV=1;*/
+ sim->ISLOVE = true;
return 0;
}