summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PowderToySDL.cpp2
-rw-r--r--src/cat/LegacyLuaAPI.cpp2
-rw-r--r--src/cat/LuaScriptInterface.cpp31
-rw-r--r--src/cat/TPTScriptInterface.cpp2
-rw-r--r--src/client/Client.cpp2
-rw-r--r--src/client/GameSave.cpp26
-rw-r--r--src/client/GameSave.h1
-rw-r--r--src/gui/game/GameController.cpp5
-rw-r--r--src/gui/game/GameModel.cpp13
-rw-r--r--src/gui/game/Tool.cpp18
-rw-r--r--src/gui/game/Tool.h2
-rw-r--r--src/gui/interface/Keys.h2
-rw-r--r--src/simulation/Simulation.cpp724
-rw-r--r--src/simulation/Simulation.h58
-rw-r--r--src/simulation/SimulationData.cpp24
-rw-r--r--src/simulation/SimulationData.h26
-rw-r--r--src/simulation/elements/BOMB.cpp2
-rw-r--r--src/simulation/elements/NEUT.cpp2
-rw-r--r--src/simulation/elements/NONE.cpp4
-rw-r--r--src/simulation/elements/PIPE.cpp14
-rw-r--r--src/simulation/elements/PLNT.cpp2
-rw-r--r--src/virtualmachine/Syscalls.cpp2
22 files changed, 485 insertions, 479 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
index 618fdec..f49ed55 100644
--- a/src/PowderToySDL.cpp
+++ b/src/PowderToySDL.cpp
@@ -5,7 +5,7 @@
#include <time.h>
#include "SDL.h"
#ifdef WIN
-#define _WIN32_WINNT 0x0501 //Necessary for some macros and functions
+#define _WIN32_WINNT 0x0501 //Necessary for some macros and functions, tells windows.h to include functions only available in Windows XP or later
#include "SDL_syswm.h"
#include <direct.h>
#endif
diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp
index b9afd7e..c8f02d1 100644
--- a/src/cat/LegacyLuaAPI.cpp
+++ b/src/cat/LegacyLuaAPI.cpp
@@ -1571,7 +1571,7 @@ int luatpt_delete(lua_State* l)
}
arg2 = abs(arg2);
if(arg2 < YRES && arg1 < XRES){
- luacon_sim->delete_part(arg1, arg2, 0);
+ luacon_sim->delete_part(arg1, arg2);
return 0;
}
return luaL_error(l,"Invalid coordinates or particle ID");
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 365d5ce..1653e28 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -782,7 +782,7 @@ int LuaScriptInterface::simulation_partProperty(lua_State * l)
int LuaScriptInterface::simulation_partKill(lua_State * l)
{
if(lua_gettop(l)==2)
- luacon_sim->delete_part(lua_tointeger(l, 1), lua_tointeger(l, 2), 0);
+ luacon_sim->delete_part(lua_tointeger(l, 1), lua_tointeger(l, 2));
else
luacon_sim->kill_part(lua_tointeger(l, 1));
return 0;
@@ -977,7 +977,7 @@ int LuaScriptInterface::simulation_createParts(lua_State * l)
int ry = luaL_optint(l,4,5);
int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID());
int brush = luaL_optint(l,6,CIRCLE_BRUSH);
- int flags = luaL_optint(l,7,0);
+ int flags = luaL_optint(l,7,luacon_sim->replaceModeFlags);
vector<Brush*> brushList = luacon_model->GetBrushList();
if (brush < 0 || brush >= brushList.size())
@@ -985,7 +985,7 @@ int LuaScriptInterface::simulation_createParts(lua_State * l)
ui::Point tempRadius = brushList[brush]->GetRadius();
brushList[brush]->SetRadius(ui::Point(rx, ry));
- int ret = luacon_sim->CreateParts(x, y, c, brushList[brush]);
+ int ret = luacon_sim->CreateParts(x, y, c, brushList[brush], flags);
brushList[brush]->SetRadius(tempRadius);
lua_pushinteger(l, ret);
return 1;
@@ -1001,7 +1001,7 @@ int LuaScriptInterface::simulation_createLine(lua_State * l)
int ry = luaL_optint(l,6,5);
int c = luaL_optint(l,7,luacon_model->GetActiveTool(0)->GetToolID());
int brush = luaL_optint(l,8,CIRCLE_BRUSH);
- int flags = luaL_optint(l,9,0);
+ int flags = luaL_optint(l,9,luacon_sim->replaceModeFlags);
vector<Brush*> brushList = luacon_model->GetBrushList();
if (brush < 0 || brush >= brushList.size())
@@ -1009,7 +1009,7 @@ int LuaScriptInterface::simulation_createLine(lua_State * l)
ui::Point tempRadius = brushList[brush]->GetRadius();
brushList[brush]->SetRadius(ui::Point(rx, ry));
- luacon_sim->CreateLine(x1, y1, x2, y2, c, brushList[brush]);
+ luacon_sim->CreateLine(x1, y1, x2, y2, c, brushList[brush], flags);
brushList[brush]->SetRadius(tempRadius);
return 0;
}
@@ -1021,7 +1021,7 @@ int LuaScriptInterface::simulation_createBox(lua_State * l)
int x2 = luaL_optint(l,3,-1);
int y2 = luaL_optint(l,4,-1);
int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID());
- int flags = luaL_optint(l,6,0);
+ int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
luacon_sim->CreateBox(x1, y1, x2, y2, c, flags);
return 0;
@@ -1034,7 +1034,7 @@ int LuaScriptInterface::simulation_floodParts(lua_State * l)
int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID());
int cm = luaL_optint(l,4,-1);
int bm = luaL_optint(l,5,-1);
- int flags = luaL_optint(l,6,0);
+ int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
int ret = luacon_sim->FloodParts(x, y, c, cm, bm, flags);
lua_pushinteger(l, ret);
return 1;
@@ -1047,11 +1047,11 @@ int LuaScriptInterface::simulation_createWalls(lua_State * l)
int rx = luaL_optint(l,3,0);
int ry = luaL_optint(l,4,0);
int c = luaL_optint(l,5,8);
- int flags = luaL_optint(l,6,0);
+ int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
if (c < 0 || c >= UI_WALLCOUNT)
return luaL_error(l, "Unrecognised wall id '%d'", c);
- int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, flags);
+ int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, NULL, flags);
lua_pushinteger(l, ret);
return 1;
}
@@ -1065,11 +1065,11 @@ int LuaScriptInterface::simulation_createWallLine(lua_State * l)
int rx = luaL_optint(l,5,0);
int ry = luaL_optint(l,6,0);
int c = luaL_optint(l,7,8);
- int flags = luaL_optint(l,8,0);
+ int flags = luaL_optint(l,8,luacon_sim->replaceModeFlags);
if (c < 0 || c >= UI_WALLCOUNT)
return luaL_error(l, "Unrecognised wall id '%d'", c);
- luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, flags);
+ luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, NULL, flags);
return 0;
}
@@ -1080,7 +1080,7 @@ int LuaScriptInterface::simulation_createWallBox(lua_State * l)
int x2 = luaL_optint(l,3,-1);
int y2 = luaL_optint(l,4,-1);
int c = luaL_optint(l,5,8);
- int flags = luaL_optint(l,6,0);
+ int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
if (c < 0 || c >= UI_WALLCOUNT)
return luaL_error(l, "Unrecognised wall id '%d'", c);
@@ -1095,7 +1095,7 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l)
int c = luaL_optint(l,3,8);
int cm = luaL_optint(l,4,-1);
int bm = luaL_optint(l,5,-1);
- int flags = luaL_optint(l,6,0);
+ int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
if (c < 0 || c >= UI_WALLCOUNT)
return luaL_error(l, "Unrecognised wall id '%d'", c);
int ret = luacon_sim->FloodWalls(x, y, c, cm, bm, flags);
@@ -1366,13 +1366,14 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l)
}
if (tempfile)
{
- if (luacon_sim->Load(x, y, tempfile->GetGameSave()))
+ if (!luacon_sim->Load(x, y, tempfile->GetGameSave()))
{
//luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0;
lua_pushinteger(l, 1);
}
else
lua_pushnil(l);
+ delete tempfile;
}
else
lua_pushnil(l);
@@ -1845,6 +1846,7 @@ void LuaScriptInterface::initElementsAPI()
SETCONST(l, SC_WALL);
SETCONST(l, SC_ELEC);
SETCONST(l, SC_POWERED);
+ SETCONST(l, SC_SENSOR);
SETCONST(l, SC_FORCE);
SETCONST(l, SC_EXPLOSIVE);
SETCONST(l, SC_GAS);
@@ -1856,7 +1858,6 @@ void LuaScriptInterface::initElementsAPI()
SETCONST(l, SC_LIFE);
SETCONST(l, SC_TOOL);
SETCONST(l, SC_DECO);
- SETCONST(l, SC_SENSOR);
//Element identifiers
for(int i = 0; i < PT_NUM; i++)
diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp
index 34d1927..a91f2d8 100644
--- a/src/cat/TPTScriptInterface.cpp
+++ b/src/cat/TPTScriptInterface.cpp
@@ -406,7 +406,7 @@ AnyType TPTScriptInterface::tptS_delete(std::deque<std::string> * words)
ui::Point deletePoint = ((PointType)partRef).Value();
if(deletePoint.X<0 || deletePoint.Y<0 || deletePoint.Y >= YRES || deletePoint.X >= XRES)
throw GeneralException("Invalid position");
- sim->delete_part(deletePoint.X, deletePoint.Y, 0);
+ sim->delete_part(deletePoint.X, deletePoint.Y);
}
else if(partRef.GetType() == TypeNumber)
{
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index b508d9f..2a091aa 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -1338,7 +1338,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
}
catch (json::Exception &e)
{
- lastError = "Server responded with crap";
+ lastError = "Could not read response";
return LoginError;
}
}
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index 2a7c996..3d271a2 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -20,6 +20,7 @@ legacyEnable(save.legacyEnable),
gravityEnable(save.gravityEnable),
paused(save.paused),
gravityMode(save.gravityMode),
+aheatEnable(save.aheatEnable),
airMode(save.airMode),
signs(save.signs),
expanded(save.expanded),
@@ -171,10 +172,11 @@ void GameSave::Expand()
{
if(hasOriginalData && !expanded)
{
- waterEEnabled = 0;
- legacyEnable = 0;
- gravityEnable = 0;
- paused = 0;
+ waterEEnabled = false;
+ legacyEnable = false;
+ gravityEnable = false;
+ aheatEnable = false;
+ paused = false;
gravityMode = 0;
airMode = 0;
expanded = true;
@@ -618,6 +620,17 @@ void GameSave::readOPS(char * data, int dataLength)
fprintf(stderr, "Wrong type for %s\n", bson_iterator_key(&iter));
}
}
+ else if(!strcmp(bson_iterator_key(&iter), "aheat_enable"))
+ {
+ if(bson_iterator_type(&iter)==BSON_BOOL)
+ {
+ aheatEnable = bson_iterator_bool(&iter);
+ }
+ else
+ {
+ fprintf(stderr, "Wrong type for %s\n", bson_iterator_key(&iter));
+ }
+ }
else if(strcmp(bson_iterator_key(&iter), "waterEEnabled")==0)
{
if(bson_iterator_type(&iter)==BSON_BOOL)
@@ -1962,8 +1975,8 @@ char * GameSave::serialiseOPS(int & dataLength)
bson_append_start_object(&b, "origin");
bson_append_int(&b, "majorVersion", SAVE_VERSION);
bson_append_int(&b, "minorVersion", MINOR_VERSION);
- bson_append_int(&b, "buildNum", MINOR_VERSION);
- bson_append_int(&b, "snapshotId", MINOR_VERSION);
+ bson_append_int(&b, "buildNum", BUILD_NUM);
+ bson_append_int(&b, "snapshotId", SNAPSHOT_ID);
bson_append_string(&b, "releaseType", IDENT_RELTYPE);
bson_append_string(&b, "platform", IDENT_PLATFORM);
bson_append_string(&b, "builtType", IDENT_BUILD);
@@ -1973,6 +1986,7 @@ char * GameSave::serialiseOPS(int & dataLength)
bson_append_bool(&b, "waterEEnabled", waterEEnabled);
bson_append_bool(&b, "legacyEnable", legacyEnable);
bson_append_bool(&b, "gravityEnable", gravityEnable);
+ bson_append_bool(&b, "aheat_enable", aheatEnable);
bson_append_bool(&b, "paused", paused);
bson_append_int(&b, "gravityMode", gravityMode);
bson_append_int(&b, "airMode", airMode);
diff --git a/src/client/GameSave.h b/src/client/GameSave.h
index cbabb3e..559b3a0 100644
--- a/src/client/GameSave.h
+++ b/src/client/GameSave.h
@@ -42,6 +42,7 @@ public:
bool waterEEnabled;
bool legacyEnable;
bool gravityEnable;
+ bool aheatEnable;
bool paused;
int gravityMode;
int airMode;
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
index 852a433..815c7a4 100644
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -150,6 +150,8 @@ GameController::GameController():
gameView->AttachController(this);
gameModel->AddObserver(gameView);
+ gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false));
+
#ifdef LUACONSOLE
commandInterface = new LuaScriptInterface(this, gameModel);
((LuaScriptInterface*)commandInterface)->SetWindow(gameView);
@@ -1016,6 +1018,7 @@ void GameController::OpenLocalSaveWindow(bool asCurrent)
gameSave->legacyEnable = sim->legacy_enable;
gameSave->waterEEnabled = sim->water_equal_test;
gameSave->gravityEnable = sim->grav->ngrav_enable;
+ gameSave->aheatEnable = sim->aheat_enable;
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");
@@ -1227,6 +1230,7 @@ void GameController::OpenSaveWindow()
gameSave->legacyEnable = sim->legacy_enable;
gameSave->waterEEnabled = sim->water_equal_test;
gameSave->gravityEnable = sim->grav->ngrav_enable;
+ gameSave->aheatEnable = sim->aheat_enable;
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");
@@ -1278,6 +1282,7 @@ void GameController::SaveAsCurrent()
gameSave->legacyEnable = sim->legacy_enable;
gameSave->waterEEnabled = sim->water_equal_test;
gameSave->gravityEnable = sim->grav->ngrav_enable;
+ gameSave->aheatEnable = sim->aheat_enable;
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");
diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp
index 4353316..efb7d78 100644
--- a/src/gui/game/GameModel.cpp
+++ b/src/gui/game/GameModel.cpp
@@ -83,6 +83,11 @@ GameModel::GameModel():
//Load config into simulation
edgeMode = Client::Ref().GetPrefInteger("Simulation.EdgeMode", 0);
sim->SetEdgeMode(edgeMode);
+ int ngrav_enable = Client::Ref().GetPrefInteger("Simulation.NewtonianGravity", 0);
+ if (ngrav_enable)
+ sim->grav->start_grav_async();
+ sim->aheat_enable = Client::Ref().GetPrefInteger("Simulation.AmbientHeat", 0);
+ sim->pretty_powder = Client::Ref().GetPrefInteger("Simulation.PrettyPowder", 0);
//Load last user
if(Client::Ref().GetAuthUser().ID)
@@ -155,8 +160,12 @@ GameModel::~GameModel()
Client::Ref().SetPref("Renderer.GravityField", (bool)ren->gravityFieldEnabled);
Client::Ref().SetPref("Renderer.Decorations", (bool)ren->decorations_enable);
+ Client::Ref().SetPref("Renderer.DebugMode", ren->debugLines); //These two should always be equivalent, even though they are different things
Client::Ref().SetPref("Simulation.EdgeMode", sim->edgeMode);
+ Client::Ref().SetPref("Simulation.NewtonianGravity", sim->grav->ngrav_enable);
+ Client::Ref().SetPref("Simulation.AmbientHeat", sim->aheat_enable);
+ Client::Ref().SetPref("Simulation.PrettyPowder", sim->pretty_powder);
Client::Ref().SetPref("Decoration.Red", (int)colour.Red);
Client::Ref().SetPref("Decoration.Green", (int)colour.Green);
@@ -312,7 +321,7 @@ void GameModel::BuildMenus()
menuList[SC_TOOL]->AddTool(tempTool);
}
//Add special sign and prop tools
- menuList[SC_TOOL]->AddTool(new WindTool(0, "WIND", "Create air movement.", 64, 64, 64, "DEFAULT_UI_WIND"));
+ menuList[SC_TOOL]->AddTool(new WindTool(0, "WIND", "Creates air movement.", 64, 64, 64, "DEFAULT_UI_WIND"));
menuList[SC_TOOL]->AddTool(new PropertyTool());
menuList[SC_TOOL]->AddTool(new SignTool());
menuList[SC_TOOL]->AddTool(new SampleTool(this));
@@ -566,6 +575,7 @@ void GameModel::SetSave(SaveInfo * newSave)
sim->air->airMode = saveData->airMode;
sim->legacy_enable = saveData->legacyEnable;
sim->water_equal_test = saveData->waterEEnabled;
+ sim->aheat_enable = saveData->aheatEnable;
if(saveData->gravityEnable)
sim->grav->start_grav_async();
else
@@ -607,6 +617,7 @@ void GameModel::SetSaveFile(SaveFile * newSave)
sim->air->airMode = saveData->airMode;
sim->legacy_enable = saveData->legacyEnable;
sim->water_equal_test = saveData->waterEEnabled;
+ sim->aheat_enable = saveData->aheatEnable;
if(saveData->gravityEnable && !sim->grav->ngrav_enable)
{
sim->grav->start_grav_async();
diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp
index 2ff1a1b..bdc1801 100644
--- a/src/gui/game/Tool.cpp
+++ b/src/gui/game/Tool.cpp
@@ -62,10 +62,10 @@ void ElementTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1,
sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush);
}
void ElementTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
- sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID, 0);
+ sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID);
}
void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
- sim->FloodParts(position.X, position.Y, toolID, -1, -1, 0);
+ sim->FloodParts(position.X, position.Y, toolID, -1, -1);
}
@@ -75,8 +75,8 @@ Tool(id, name, description, r, g, b, identifier, textureGen)
resolution = CELL;
}
WallTool::~WallTool() {}
-void WallTool::Draw(Simulation * sim, Brush * brush, ui::Point position){
- sim->CreateWalls(position.X, position.Y, 1, 1, toolID, 0, brush);
+void WallTool::Draw(Simulation * sim, Brush * brush, ui::Point position) {
+ sim->CreateWalls(position.X, position.Y, 1, 1, toolID, brush);
}
void WallTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) {
int wallX = position1.X/CELL;
@@ -99,15 +99,15 @@ void WallTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui
}
else
{
- sim->CreateWallLine(position1.X, position1.Y, position2.X, position2.Y, 1, 1, toolID, 0, brush);
+ sim->CreateWallLine(position1.X, position1.Y, position2.X, position2.Y, 1, 1, toolID, brush);
}
}
void WallTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
- sim->CreateWallBox(position1.X, position1.Y, position2.X, position2.Y, toolID, 0);
+ sim->CreateWallBox(position1.X, position1.Y, position2.X, position2.Y, toolID);
}
void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
if (toolID != WL_STREAM)
- sim->FloodWalls(position.X, position.Y, toolID, -1, -1, 0);
+ sim->FloodWalls(position.X, position.Y, toolID, -1, -1);
}
WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
@@ -181,11 +181,11 @@ void Element_TESC_Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point posi
}
void Element_TESC_Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
- sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8), 0);
+ sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8));
}
void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
- sim->FloodParts(position.X, position.Y, toolID | (radiusInfo << 8), -1, -1, 0);
+ sim->FloodParts(position.X, position.Y, toolID | (radiusInfo << 8), -1, -1);
}
diff --git a/src/gui/game/Tool.h b/src/gui/game/Tool.h
index 8b75f3f..7ee105f 100644
--- a/src/gui/game/Tool.h
+++ b/src/gui/game/Tool.h
@@ -45,7 +45,7 @@ class SignTool: public Tool
{
public:
SignTool():
- Tool(0, "SIGN", "Sign. Click a sign to edit or anywhere else to create a new one.", 0, 0, 0, "DEFAULT_UI_SIGN", SignTool::GetIcon)
+ Tool(0, "SIGN", "Sign. Displays text. Click on a sign to edit it or anywhere else to place a new one.", 0, 0, 0, "DEFAULT_UI_SIGN", SignTool::GetIcon)
{
}
static VideoBuffer * GetIcon(int toolID, int width, int height);
diff --git a/src/gui/interface/Keys.h b/src/gui/interface/Keys.h
index cd265f9..424dd86 100644
--- a/src/gui/interface/Keys.h
+++ b/src/gui/interface/Keys.h
@@ -1,6 +1,6 @@
#if defined(USE_SDL)
-#include "SDL/SDL.h"
+#include "SDL.h"
#define KEY_UP SDLK_UP
#define KEY_DOWN SDLK_DOWN
#define KEY_RIGHT SDLK_RIGHT
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 0fff552..e45f5a8 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -38,7 +38,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
{
int blockX, blockY, x, y, r;
- if(!save) return 0;
+ if(!save) return 1;
save->Expand();
//Align to blockMap
@@ -360,7 +360,7 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h)
gravWallChanged = true;
bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
emap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
- delete_part(cx+area_x, cy+area_y, 0);
+ delete_part(cx+area_x, cy+area_y);
}
}
for(int i = 0; i < MAXSIGNS && i < signs.size(); i++)
@@ -372,46 +372,6 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h)
}
}
-void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags)
-{
- int i, j;
- if (x1>x2)
- {
- i = x2;
- x2 = x1;
- x1 = i;
- }
- if (y1>y2)
- {
- j = y2;
- y2 = y1;
- y1 = j;
- }
- for (j=y1; j<=y2; j++)
- for (i=x1; i<=x2; i++)
- CreateParts(i, j, 0, 0, c, flags);
-}
-
-void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int c, int flags)
-{
- int i, j;
- if (x1>x2)
- {
- i = x2;
- x2 = x1;
- x1 = i;
- }
- if (y1>y2)
- {
- j = y2;
- y2 = y1;
- y1 = j;
- }
- for (j=y1; j<=y2; j++)
- for (i=x1; i<=x2; i++)
- CreateWalls(i, j, 0, 0, c, flags);
-}
-
int Simulation::flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap)
{
int x1, x2, i, dy = 1;
@@ -669,165 +629,6 @@ int Simulation::FloodINST(int x, int y, int fullc, int cm)
return created_something;
}
-
-int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
-{
- int c = fullc&0xFF;
- int x1, x2, dy = (c<PT_NUM)?1:CELL;
- int co = c;
- int coord_stack_limit = XRES*YRES;
- unsigned short (*coord_stack)[2];
- int coord_stack_size = 0;
- int created_something = 0;
-
- if (cm==-1)
- {
- if (c==0)
- {
- cm = pmap[y][x]&0xFF;
- if (!cm)
- return 0;
- }
- else
- cm = 0;
- }
- if (bm==-1)
- {
- bm = bmap[y/CELL][x/CELL];
- }
-
- if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm ))
- return 1;
-
- coord_stack = (short unsigned int (*)[2])malloc(sizeof(unsigned short)*2*coord_stack_limit);
- coord_stack[coord_stack_size][0] = x;
- coord_stack[coord_stack_size][1] = y;
- coord_stack_size++;
-
- do
- {
- coord_stack_size--;
- x = coord_stack[coord_stack_size][0];
- y = coord_stack[coord_stack_size][1];
- x1 = x2 = x;
- // go left as far as possible
- while (x1>=CELL)
- {
- if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
- {
- break;
- }
- x1--;
- }
- // go right as far as possible
- while (x2<XRES-CELL)
- {
- if ((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
- {
- break;
- }
- x2++;
- }
- // fill span
- for (x=x1; x<=x2; x++)
- {
- if (CreateParts(x, y, 0, 0, fullc, flags))
- created_something = 1;
- }
-
- if (y>=CELL+dy)
- for (x=x1; x<=x2; x++)
- if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
- {
- coord_stack[coord_stack_size][0] = x;
- coord_stack[coord_stack_size][1] = y-dy;
- coord_stack_size++;
- if (coord_stack_size>=coord_stack_limit)
- {
- free(coord_stack);
- return -1;
- }
- }
-
- if (y<YRES-CELL-dy)
- for (x=x1; x<=x2; x++)
- if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
- {
- coord_stack[coord_stack_size][0] = x;
- coord_stack[coord_stack_size][1] = y+dy;
- coord_stack_size++;
- if (coord_stack_size>=coord_stack_limit)
- {
- free(coord_stack);
- return -1;
- }
- }
- } while (coord_stack_size>0);
- free(coord_stack);
- return created_something;
-}
-
-int Simulation::FloodWalls(int x, int y, int c, int cm, int bm, int flags)
-{
- int x1, x2, dy = CELL;
- int co = c;
- if (cm==-1)
- {
- cm = pmap[y][x]&0xFF;
- }
- if (bm==-1)
- {
- if (c==WL_ERASE)
- {
- bm = bmap[y/CELL][x/CELL];
- if (!bm)
- return 0;
- }
- else
- bm = 0;
- }
-
- if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )/*||( (flags&BRUSH_SPECIFIC_DELETE) && cm!=SLALT)*/)
- return 1;
-
- // go left as far as possible
- x1 = x2 = x;
- while (x1>=CELL)
- {
- if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
- {
- break;
- }
- x1--;
- }
- while (x2<XRES-CELL)
- {
- if ((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
- {
- break;
- }
- x2++;
- }
-
- // fill span
- for (x=x1; x<=x2; x++)
- {
- if (!CreateWalls(x, y, 0, 0, c, flags))
- return 0;
- }
- // fill children
- if (y>=CELL+dy)
- for (x=x1; x<=x2; x++)
- if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
- if (!FloodWalls(x, y-dy, c, cm, bm, flags))
- return 0;
- if (y<YRES-CELL-dy)
- for (x=x1; x<=x2; x++)
- if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
- if (!FloodWalls(x, y+dy, c, cm, bm, flags))
- return 0;
- return 1;
-}
int Simulation::flood_water(int x, int y, int i, int originaly, int check)
{
int x1 = 0,x2 = 0;
@@ -1036,8 +837,6 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_,
void Simulation::ApplyDecorationPoint(int positionX, int positionY, int colR, int colG, int colB, int colA, int mode, Brush * cBrush)
{
- int i, j;
-
if(cBrush)
{
int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y;
@@ -1056,32 +855,11 @@ void Simulation::ApplyDecorationPoint(int positionX, int positionY, int colR, in
}
}
-void Simulation::ApplyDecorationBox(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode)
-{
- int i, j;
-
- if (x1>x2)
- {
- i = x2;
- x2 = x1;
- x1 = i;
- }
- if (y1>y2)
- {
- j = y2;
- y2 = y1;
- y1 = j;
- }
- for (j=y1; j<=y2; j++)
- for (i=x1; i<=x2; i++)
- ApplyDecoration(i, j, colR, colG, colB, colA, mode);
-}
-
void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode, Brush * cBrush)
{
bool reverseXY = abs(y2-y1) > abs(x2-x1);
int x, y, dx, dy, sy, rx, ry;
- float e, de;
+ float e = 0.0f, de;
if(cBrush)
{
@@ -1109,7 +887,6 @@ void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, i
}
dx = x2 - x1;
dy = abs(y2 - y1);
- e = 0.0f;
if (dx)
de = dy/(float)dx;
else
@@ -1138,6 +915,27 @@ void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, i
}
}
+void Simulation::ApplyDecorationBox(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode)
+{
+ int i, j;
+
+ if (x1>x2)
+ {
+ i = x2;
+ x2 = x1;
+ x1 = i;
+ }
+ if (y1>y2)
+ {
+ j = y2;
+ y2 = y1;
+ y1 = j;
+ }
+ for (j=y1; j<=y2; j++)
+ for (i=x1; i<=x2; i++)
+ ApplyDecoration(i, j, colR, colG, colB, colA, mode);
+}
+
int Simulation::Tool(int x, int y, int tool, float strength)
{
if(tools[tool])
@@ -1171,7 +969,7 @@ void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBru
{
bool reverseXY = abs(y2-y1) > abs(x2-x1);
int x, y, dx, dy, sy, rx = cBrush->GetRadius().X, ry = cBrush->GetRadius().Y;
- float e, de;
+ float e = 0.0f, de;
if (reverseXY)
{
y = x1;
@@ -1192,7 +990,6 @@ void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBru
}
dx = x2 - x1;
dy = abs(y2 - y1);
- e = 0.0f;
if (dx)
de = dy/(float)dx;
else
@@ -1240,146 +1037,64 @@ void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, float strengt
Tool(i, j, tool, strength);
}
-int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush)
-{
- if(cBrush)
- {
- int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y, fn;
- unsigned char *bitmap = cBrush->GetBitmap();
-
- if (c == 0)// && !(flags&BRUSH_REPLACEMODE)) // delete
- fn = 0;
- //else if ((flags&BRUSH_SPECIFIC_DELETE) && !(flags&BRUSH_REPLACEMODE)) // specific delete
- // fn = 1;
- //else if (flags&BRUSH_REPLACEMODE) // replace
- // fn = 2;
- else // normal draw
- fn = 3;
-
- for(int y = 0; y < sizeY; y++)
- {
- for(int x = 0; x < sizeX; x++)
- {
- if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES))
- {
- CreatePartFlags(positionX+(x-radiusX), positionY+(y-radiusY), c, fn, 0);
- }
- }
- }
- }
- return 0;
-}
-
-int Simulation::CreateParts(int x, int y, int rx, int ry, int c, int flags)
-{
- int i, j, f = 0, fn;
-
- if (c == 0)// && !(flags&BRUSH_REPLACEMODE)) // delete
- fn = 0;
- //else if ((flags&BRUSH_SPECIFIC_DELETE) && !(flags&BRUSH_REPLACEMODE)) // specific delete
- // fn = 1;
- //else if (flags&BRUSH_REPLACEMODE) // replace
- // fn = 2;
- else // normal draw
- fn = 3;
-
- for (j=-ry; j<=ry; j++)
- for (i=-rx; i<=rx; i++)
- if (CreatePartFlags(x+i, y+j, c, fn, flags))
- f = 1;
- return !f;
-}
-
-int Simulation::CreatePartFlags(int x, int y, int c, int fn, int flags)
-{
- if (fn == 0) //delete
- delete_part(x, y, 0);
- else if (fn == 1) //specific delete
- delete_part(x, y, flags);
- else if (fn == 2) //replace mode
- {
- if (x<0 || y<0 || x>=XRES || y>=YRES)
- return 0;
- //if ((pmap[y][x]&0xFF)!=SLALT&&SLALT!=0)
- // return 0;
- if ((pmap[y][x]))
- {
- delete_part(x, y, 0);
- if (c!=0)
- create_part(-2, x, y, c);
- }
- }
- else if (fn == 3) //normal draw
- if (create_part(-2, x, y, c) == -1)
- return 1;
- return 0;
-}
-
-int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush)
+int Simulation::CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBrush, int flags)
{
- int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
-
if(cBrush)
{
rx = cBrush->GetRadius().X;
ry = cBrush->GetRadius().Y;
}
-
- int wall = c;
-
if (wall == WL_ERASE)
- b = 0;
- else
- b = wall;
+ wall = 0;
+ if (flags == -1)
+ flags = replaceModeFlags;
ry = ry/CELL;
rx = rx/CELL;
x = x/CELL;
y = y/CELL;
- x -= rx;///2;
- y -= ry;///2;
- for (ox=x; ox<=x+rx+rx; ox++)
+ x -= rx;
+ y -= ry;
+ for (int wallX = x; wallX <= x+rx+rx; wallX++)
{
- for (oy=y; oy<=y+ry+ry; oy++)
+ for (int wallY = y; wallY <= y+ry+ry; wallY++)
{
- if (ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
+ if (wallX >= 0 && wallX < XRES/CELL && wallY >= 0 && wallY < YRES/CELL)
{
- i = ox;
- j = oy;
- if (b==WL_FAN)
- {
- fvx[j][i] = 0.0f;
- fvy[j][i] = 0.0f;
- }
- if (b==WL_GRAV || bmap[j][i]==WL_GRAV)
+ if ((flags&SPECIFIC_DELETE) && wall != WL_FLOODHELPER && wall == replaceModeSelected)
+ wall = 0;
+
+ if (wall == WL_FAN)
{
- gravWallChanged = true;
+ fvx[wallY][wallX] = 0.0f;
+ fvy[wallY][wallX] = 0.0f;
}
- if (b==WL_STREAM)
+ else if (wall == WL_STREAM)
{
- i = x + rx;///2;
- j = y + ry;///2;
- for (v=-1; v<2; v++)
- for (u=-1; u<2; u++)
- if (i+u>=0 && i+u<XRES/CELL &&
- j+v>=0 && j+v<YRES/CELL &&
- bmap[j+v][i+u] == WL_STREAM)
+ wallX = x + rx;
+ wallY = y + ry;
+ //streamlines can't be drawn next to each other
+ for (int tempY = wallY-1; tempY < wallY+2; tempY++)
+ for (int tempX = wallX-1; tempX < wallX+2; tempX++)
+ {
+ if (tempX >= 0 && tempX < XRES/CELL && tempY >= 0 && tempY < YRES/CELL && bmap[tempY][tempX] == WL_STREAM)
return 1;
- bmap[j][i] = WL_STREAM;
- continue;
+ }
}
- bmap[j][i] = b;
+ if (wall == WL_GRAV || bmap[wallY][wallX] == WL_GRAV)
+ gravWallChanged = true;
+ bmap[wallY][wallX] = wall;
}
}
}
return 1;
}
-void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush)
+void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int wall, Brush * cBrush, int flags)
{
- int x, y, dx, dy, sy, rx = cBrush->GetRadius().X, ry = cBrush->GetRadius().Y;
+ int x, y, dx, dy, sy;
bool reverseXY = abs(y2-y1) > abs(x2-x1);
- float e, de;
+ float e = 0.0f, de;
if (reverseXY)
{
y = x1;
@@ -1400,7 +1115,6 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrus
}
dx = x2 - x1;
dy = abs(y2 - y1);
- e = 0.0f;
if (dx)
de = dy/(float)dx;
else
@@ -1410,9 +1124,9 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrus
for (x=x1; x<=x2; x++)
{
if (reverseXY)
- CreateParts(y, x, c, cBrush);
+ CreateWalls(y, x, rx, ry, wall, cBrush, flags);
else
- CreateParts(x, y, c, cBrush);
+ CreateWalls(x, y, rx, ry, wall, cBrush, flags);
e += de;
if (e >= 0.5f)
{
@@ -1420,21 +1134,172 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrus
if (!(rx+ry) && ((y1<y2) ? (y<=y2) : (y>=y2)))
{
if (reverseXY)
- CreateParts(y, x, c, cBrush);
+ CreateWalls(y, x, rx, ry, wall, cBrush, flags);
else
- CreateParts(x, y, c, cBrush);
+ CreateWalls(x, y, rx, ry, wall, cBrush, flags);
}
e -= 1.0f;
}
}
}
-//Now simply creates a 0 pixel radius line without all the complicated flags / other checks
-void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
+void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int wall, int flags)
+{
+ int i, j;
+ if (x1>x2)
+ {
+ i = x2;
+ x2 = x1;
+ x1 = i;
+ }
+ if (y1>y2)
+ {
+ j = y2;
+ y2 = y1;
+ y1 = j;
+ }
+ for (j=y1; j<=y2; j++)
+ for (i=x1; i<=x2; i++)
+ CreateWalls(i, j, 0, 0, wall, NULL, flags);
+}
+
+int Simulation::FloodWalls(int x, int y, int wall, int cm, int bm, int flags)
+{
+ int x1, x2, dy = CELL;
+ if (cm==-1)
+ {
+ cm = pmap[y][x]&0xFF;
+ }
+ if (bm==-1)
+ {
+ if (wall==WL_ERASE)
+ {
+ bm = bmap[y/CELL][x/CELL];
+ if (!bm)
+ return 0;
+ }
+ else
+ bm = 0;
+ if (flags == -1)
+ flags = replaceModeFlags;
+ }
+
+ if ((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm || ((flags&SPECIFIC_DELETE) && cm != replaceModeSelected))
+ return 1;
+
+ // go left as far as possible
+ x1 = x2 = x;
+ while (x1>=CELL)
+ {
+ if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
+ {
+ break;
+ }
+ x1--;
+ }
+ while (x2<XRES-CELL)
+ {
+ if ((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
+ {
+ break;
+ }
+ x2++;
+ }
+
+ // fill span
+ for (x=x1; x<=x2; x++)
+ {
+ if (!CreateWalls(x, y, 0, 0, wall, NULL, flags))
+ return 0;
+ }
+ // fill children
+ if (y>=CELL+dy)
+ for (x=x1; x<=x2; x++)
+ if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
+ if (!FloodWalls(x, y-dy, wall, cm, bm, flags))
+ return 0;
+ if (y<YRES-CELL-dy)
+ for (x=x1; x<=x2; x++)
+ if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
+ if (!FloodWalls(x, y+dy, wall, cm, bm, flags))
+ return 0;
+ return 1;
+}
+
+int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush, int flags)
+{
+ if (flags == -1)
+ flags = replaceModeFlags;
+ if(cBrush)
+ {
+ int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y;
+ unsigned char *bitmap = cBrush->GetBitmap();
+
+ for(int y = 0; y < sizeY; y++)
+ {
+ for(int x = 0; x < sizeX; x++)
+ {
+ if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES))
+ {
+ CreatePartFlags(positionX+(x-radiusX), positionY+(y-radiusY), c, flags);
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+int Simulation::CreateParts(int x, int y, int rx, int ry, int c, int flags)
+{
+ int i, j, f = 0;
+
+ if (flags == -1)
+ flags = replaceModeFlags;
+
+ for (j=-ry; j<=ry; j++)
+ for (i=-rx; i<=rx; i++)
+ if (CreatePartFlags(x+i, y+j, c, flags))
+ f = 1;
+ return !f;
+}
+
+int Simulation::CreatePartFlags(int x, int y, int c, int flags)
+{
+ //delete
+ if (c == 0 && !(flags&REPLACE_MODE))
+ delete_part(x, y);
+ //specific delete
+ else if ((flags&SPECIFIC_DELETE) && !(flags&REPLACE_MODE))
+ {
+ if (!replaceModeSelected || (pmap[y][x]&0xFF) == replaceModeSelected || (photons[y][x]&0xFF) == replaceModeSelected)
+ delete_part(x, y);
+ }
+ //replace mode
+ else if (flags&REPLACE_MODE)
+ {
+ if (x<0 || y<0 || x>=XRES || y>=YRES)
+ return 0;
+ if (replaceModeSelected && (pmap[y][x]&0xFF) != replaceModeSelected && (photons[y][x]&0xFF) != replaceModeSelected)
+ return 0;
+ if ((pmap[y][x]))
+ {
+ delete_part(x, y);
+ if (c!=0)
+ create_part(-2, x, y, c);
+ }
+ }
+ //normal draw
+ else
+ if (create_part(-2, x, y, c) == -1)
+ return 1;
+ return 0;
+}
+
+void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush, int flags)
{
+ int x, y, dx, dy, sy, rx = cBrush->GetRadius().X, ry = cBrush->GetRadius().Y;
bool reverseXY = abs(y2-y1) > abs(x2-x1);
- int x, y, dx, dy, sy;
- float e, de;
+ float e = 0.0f, de;
if (reverseXY)
{
y = x1;
@@ -1455,7 +1320,6 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
}
dx = x2 - x1;
dy = abs(y2 - y1);
- e = 0.0f;
if (dx)
de = dy/(float)dx;
else
@@ -1465,30 +1329,32 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
for (x=x1; x<=x2; x++)
{
if (reverseXY)
- create_part(-2, y, x, c);
+ CreateParts(y, x, c, cBrush, flags);
else
- create_part(-2, x, y, c);
+ CreateParts(x, y, c, cBrush, flags);
e += de;
if (e >= 0.5f)
{
y += sy;
- if ((y1<y2) ? (y<=y2) : (y>=y2))
+ if (!(rx+ry) && ((y1<y2) ? (y<=y2) : (y>=y2)))
{
if (reverseXY)
- create_part(-2, y, x, c);
+ CreateParts(y, x, c, cBrush, flags);
else
- create_part(-2, x, y, c);
+ CreateParts(x, y, c, cBrush, flags);
}
e -= 1.0f;
}
}
}
-void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush)
+//Now simply creates a 0 pixel radius line without all the complicated flags / other checks
+void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
{
- int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
+ bool reverseXY = abs(y2-y1) > abs(x2-x1);
+ int x, y, dx, dy, sy;
float e, de;
- if (cp)
+ if (reverseXY)
{
y = x1;
x1 = y1;
@@ -1517,26 +1383,143 @@ void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry,
sy = (y1<y2) ? 1 : -1;
for (x=x1; x<=x2; x++)
{
- if (cp)
- CreateWalls(y, x, rx, ry, c, flags, cBrush);
+ if (reverseXY)
+ create_part(-2, y, x, c);
else
- CreateWalls(x, y, rx, ry, c, flags, cBrush);
+ create_part(-2, x, y, c);
e += de;
if (e >= 0.5f)
{
y += sy;
- if (!(rx+ry) && ((y1<y2) ? (y<=y2) : (y>=y2)))
+ if ((y1<y2) ? (y<=y2) : (y>=y2))
{
- if (cp)
- CreateWalls(y, x, rx, ry, c, flags, cBrush);
+ if (reverseXY)
+ create_part(-2, y, x, c);
else
- CreateWalls(x, y, rx, ry, c, flags, cBrush);
+ create_part(-2, x, y, c);
}
e -= 1.0f;
}
}
}
+void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags)
+{
+ int i, j;
+ if (x1>x2)
+ {
+ i = x2;
+ x2 = x1;
+ x1 = i;
+ }
+ if (y1>y2)
+ {
+ j = y2;
+ y2 = y1;
+ y1 = j;
+ }
+ for (j=y1; j<=y2; j++)
+ for (i=x1; i<=x2; i++)
+ CreateParts(i, j, 0, 0, c, flags);
+}
+
+int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
+{
+ int c = fullc&0xFF;
+ int x1, x2, dy = (c<PT_NUM)?1:CELL;
+ int co = c;
+ int coord_stack_limit = XRES*YRES;
+ unsigned short (*coord_stack)[2];
+ int coord_stack_size = 0;
+ int created_something = 0;
+
+ if (cm==-1)
+ {
+ if (c==0)
+ {
+ cm = pmap[y][x]&0xFF;
+ if (!cm)
+ return 0;
+ }
+ else
+ cm = 0;
+ }
+ if (bm==-1)
+ {
+ bm = bmap[y/CELL][x/CELL];
+ }
+
+ if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm ))
+ return 1;
+
+ coord_stack = (short unsigned int (*)[2])malloc(sizeof(unsigned short)*2*coord_stack_limit);
+ coord_stack[coord_stack_size][0] = x;
+ coord_stack[coord_stack_size][1] = y;
+ coord_stack_size++;
+
+ do
+ {
+ coord_stack_size--;
+ x = coord_stack[coord_stack_size][0];
+ y = coord_stack[coord_stack_size][1];
+ x1 = x2 = x;
+ // go left as far as possible
+ while (x1>=CELL)
+ {
+ if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
+ {
+ break;
+ }
+ x1--;
+ }
+ // go right as far as possible
+ while (x2<XRES-CELL)
+ {
+ if ((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
+ {
+ break;
+ }
+ x2++;
+ }
+ // fill span
+ for (x=x1; x<=x2; x++)
+ {
+ if (CreateParts(x, y, 0, 0, fullc, flags))
+ created_something = 1;
+ }
+
+ if (y>=CELL+dy)
+ for (x=x1; x<=x2; x++)
+ if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
+ {
+ coord_stack[coord_stack_size][0] = x;
+ coord_stack[coord_stack_size][1] = y-dy;
+ coord_stack_size++;
+ if (coord_stack_size>=coord_stack_limit)
+ {
+ free(coord_stack);
+ return -1;
+ }
+ }
+
+ if (y<YRES-CELL-dy)
+ for (x=x1; x<=x2; x++)
+ if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
+ {
+ coord_stack[coord_stack_size][0] = x;
+ coord_stack[coord_stack_size][1] = y+dy;
+ coord_stack_size++;
+ if (coord_stack_size>=coord_stack_limit)
+ {
+ free(coord_stack);
+ return -1;
+ }
+ }
+ } while (coord_stack_size>0);
+ free(coord_stack);
+ return created_something;
+}
+
void *Simulation::transform_save(void *odata, int *size, matrix2d transform, vector2d translate)
{
void *ndata;
@@ -2013,7 +1996,7 @@ void Simulation::init_can_move()
}
for (movingType = 1; movingType < PT_NUM; movingType++)
{
- // everything "swaps" with VACU and BHOL to make them eat things
+ //everything "swaps" with VACU and BHOL to make them eat things
can_move[movingType][PT_BHOL] = 1;
can_move[movingType][PT_NBHL] = 1;
//nothing goes through stickmen
@@ -2022,7 +2005,7 @@ void Simulation::init_can_move()
can_move[movingType][PT_FIGH] = 0;
//INVS behaviour varies with pressure
can_move[movingType][PT_INVIS] = 3;
- //stop CNCT being displaced by other particles
+ //stop CNCT from being displaced by other particles
can_move[movingType][PT_CNCT] = 0;
//VOID and PVOD behaviour varies with powered state and ctype
can_move[movingType][PT_PVOD] = 3;
@@ -3171,7 +3154,7 @@ void Simulation::create_cherenkov_photon(int pp)//photons from NEUT going throug
parts[i].vy *= r;
}
-void Simulation::delete_part(int x, int y, int flags)//calls kill_part with the particle located at x,y
+void Simulation::delete_part(int x, int y)//calls kill_part with the particle located at x,y
{
unsigned i;
@@ -4775,8 +4758,9 @@ Simulation::Simulation():
lighting_recreate(0),
force_stacking_check(0),
ISWIRE(0),
- VINE_MODE(0),
- gravWallChanged(false)
+ gravWallChanged(false),
+ replaceModeSelected(0),
+ replaceModeFlags(0)
{
int tportal_rx[] = {-1, 0, 1, 1, 1, 0,-1,-1};
int tportal_ry[] = {-1,-1,-1, 0, 1, 1, 1, 0};
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index 67f297e..31bb5e4 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -1,5 +1,5 @@
-#ifndef SIMULATION_H_
-#define SIMULATION_H_
+#ifndef SIMULATION_H
+#define SIMULATION_H
#include <cstring>
#include <cstddef>
#include <vector>
@@ -30,10 +30,8 @@ class Gravity;
class Air;
class GameSave;
-//#ifdef _cplusplus
class Simulation
{
-private:
public:
Gravity * grav;
@@ -51,9 +49,11 @@ public:
menu_section msections[SC_TOTAL];
int currentTick;
+ int replaceModeSelected;
+ int replaceModeFlags;
char can_move[PT_NUM][PT_NUM];
- int parts_lastActiveIndex;// = NPART-1;
+ int parts_lastActiveIndex;
int pfree;
int NUM_PARTS;
bool elementRecount;
@@ -108,7 +108,6 @@ public:
int gravityMode;
int legacy_enable;
int aheat_enable;
- int VINE_MODE;
int water_equal_test;
int sys_pause;
int framerender;
@@ -142,12 +141,13 @@ public:
int flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype);
int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap);
int flood_water(int x, int y, int i, int originaly, int check);
+ int FloodINST(int x, int y, int fullc, int cm);
TPT_NO_INLINE void detach(int i);
TPT_NO_INLINE void part_change_type(int i, int x, int y, int t);
//int InCurrentBrush(int i, int j, int rx, int ry);
//int get_brush_flags();
TPT_NO_INLINE int create_part(int p, int x, int y, int t);
- TPT_NO_INLINE void delete_part(int x, int y, int flags);
+ TPT_NO_INLINE void delete_part(int x, int y);
void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
TPT_NO_INLINE int is_wire(int x, int y);
TPT_NO_INLINE int is_wire_off(int x, int y);
@@ -162,31 +162,33 @@ public:
void SetEdgeMode(int newEdgeMode);
+ //Drawing Deco
+ void ApplyDecoration(int x, int y, int colR, int colG, int colB, int colA, int mode);
+ void ApplyDecorationPoint(int x, int y, int colR, int colG, int colB, int colA, int mode, Brush * cBrush = NULL);
+ void ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode, Brush * cBrush = NULL);
+ void ApplyDecorationBox(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode);
+
+ //Drawing Tools like HEAT, AIR, and GRAV
int Tool(int x, int y, int tool, float strength = 1.0f);
int ToolBrush(int x, int y, int tool, Brush * cBrush, float strength = 1.0f);
void ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength = 1.0f);
void ToolBox(int x1, int y1, int x2, int y2, int tool, float strength = 1.0f);
- void CreateBox(int x1, int y1, int x2, int y2, int c, int flags);
- int FloodINST(int x, int y, int fullc, int cm);
- int FloodParts(int x, int y, int c, int cm, int bm, int flags);
- //Create particles from brush/mask
- int CreateParts(int positionX, int positionY, int c, Brush * cBrush);
- //Old particle creation, will create a crappy square, do not use
- int CreateParts(int x, int y, int rx, int ry, int c, int flags);
- int CreatePartFlags(int x, int y, int c, int fn, int flags);
- void CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush);
+ //Drawing Walls
+ int CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBrush = NULL, int flags = -1);
+ void CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int wall, Brush * cBrush = NULL, int flags = -1);
+ void CreateWallBox(int x1, int y1, int x2, int y2, int wall, int flags = -1);
+ int FloodWalls(int x, int y, int wall, int cm, int bm, int flags = -1);
+
+ //Drawing Particles
+ int CreateParts(int positionX, int positionY, int c, Brush * cBrush, int flags = -1);
+ int CreateParts(int x, int y, int rx, int ry, int c, int flags = -1);
+ int CreatePartFlags(int x, int y, int c, int flags);
+ void CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush, int flags = -1);
void CreateLine(int x1, int y1, int x2, int y2, int c);
-
- void CreateWallBox(int x1, int y1, int x2, int y2, int c, int flags);
- int FloodWalls(int x, int y, int c, int cm, int bm, int flags);
- int CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
- void CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
-
- void ApplyDecoration(int x, int y, int colR, int colG, int colB, int colA, int mode);
- void ApplyDecorationPoint(int x, int y, int colR, int colG, int colB, int colA, int mode, Brush * cBrush = NULL);
- void ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode, Brush * cBrush = NULL);
- void ApplyDecorationBox(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode);
+ void CreateBox(int x1, int y1, int x2, int y2, int c, int flags = -1);
+ int FloodParts(int x, int y, int c, int cm, int bm, int flags = -1);
+
void GetGravityField(int x, int y, float particleGrav, float newtonGrav, float & pGravX, float & pGravY);
@@ -204,6 +206,4 @@ public:
~Simulation();
};
-//#endif
-
-#endif /* SIMULATION_H_ */
+#endif /* SIMULATION_H */
diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp
index 12f6ca8..d3c74fe 100644
--- a/src/simulation/SimulationData.cpp
+++ b/src/simulation/SimulationData.cpp
@@ -115,21 +115,21 @@ wall_type * LoadWalls(int & wallCount)
wall_type wtypes[] =
{
{PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "ERASE", "Erases walls."},
- {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, Renderer::WallIcon, "CONDUCTIVE WALL","Wall. Indestructible. Blocks everything. Conductive."},
+ {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, Renderer::WallIcon, "CONDUCTIVE WALL","Blocks everything. Conductive."},
{PIXPACK(0x808080), PIXPACK(0x808080), 0, Renderer::WallIcon, "EWALL", "E-Wall. Becomes transparent when electricity is connected."},
{PIXPACK(0xFF8080), PIXPACK(0xFF2008), 1, Renderer::WallIcon, "DETECTOR", "Detector. Generates electricity when a particle is inside."},
{PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "STREAMLINE", "Streamline. Set start point of a streamline."},
- {PIXPACK(0x8080FF), PIXPACK(0x000000), 1, Renderer::WallIcon, "FAN", "Fan. Accelerates air. Use line tool to set direction and strength."},
- {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, Renderer::WallIcon, "LIQUID WALL", "Wall. Blocks most particles but lets liquids through. Conductive."},
- {PIXPACK(0x808080), PIXPACK(0x000000), 1, Renderer::WallIcon, "ABSORB WALL", "Wall. Absorbs particles but lets air currents through."},
- {PIXPACK(0x808080), PIXPACK(0x000000), 3, Renderer::WallIcon, "WALL", "Wall. Indestructible. Blocks everything."},
- {PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, Renderer::WallIcon, "AIRONLY WALL", "Wall. Indestructible. Blocks particles, allows air"},
- {PIXPACK(0x575757), PIXPACK(0x000000), 1, Renderer::WallIcon, "POWDER WALL", "Wall. Indestructible. Blocks liquids and gasses, allows powders"},
- {PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, Renderer::WallIcon, "CONDUCTOR", "Conductor, allows particles, conducts electricity"},
- {PIXPACK(0x242424), PIXPACK(0x101010), 0, Renderer::WallIcon, "EHOLE", "E-Hole, absorbs particles, release them when powered"},
- {PIXPACK(0x579777), PIXPACK(0x000000), 1, Renderer::WallIcon, "GAS WALL", "Wall. Indestructible. Blocks liquids and solids, allows gasses"},
- {PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, Renderer::WallIcon, "GRAVITY WALL", "Gravity wall"},
- {PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, Renderer::WallIcon, "ENERGY WALL", "Energy wall, allows only energy type particles to pass"},
+ {PIXPACK(0x8080FF), PIXPACK(0x000000), 1, Renderer::WallIcon, "FAN", "Fan. Accelerates air. Use the line tool to set direction and strength."},
+ {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, Renderer::WallIcon, "LIQUID WALL", "Allows liquids, blocks all other particles. Conductive."},
+ {PIXPACK(0x808080), PIXPACK(0x000000), 1, Renderer::WallIcon, "ABSORB WALL", "Absorbs particles but lets air currents through."},
+ {PIXPACK(0x808080), PIXPACK(0x000000), 3, Renderer::WallIcon, "WALL", "Basic wall, blocks everything."},
+ {PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, Renderer::WallIcon, "AIRONLY WALL", "Allows air, but blocks all particles."},
+ {PIXPACK(0x575757), PIXPACK(0x000000), 1, Renderer::WallIcon, "POWDER WALL", "Allows powders, blocks all other particles."},
+ {PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, Renderer::WallIcon, "CONDUCTOR", "Conductor. Allows all particles to pass through and conducts electricity."},
+ {PIXPACK(0x242424), PIXPACK(0x101010), 0, Renderer::WallIcon, "EHOLE", "E-Hole. absorbs particles, releases them when powered."},
+ {PIXPACK(0x579777), PIXPACK(0x000000), 1, Renderer::WallIcon, "GAS WALL", "Allows gases, blocks all other particles."},
+ {PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, Renderer::WallIcon, "GRAVITY WALL", "Gravity wall. Newtonian Gravity has no effect inside a box drawn with this."},
+ {PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, Renderer::WallIcon, "ENERGY WALL", "Allows energy particles, blocks all other particles."},
};
wallCount = UI_WALLCOUNT;
wall_type * wtypesT = (wall_type*)malloc(UI_WALLCOUNT*sizeof(wall_type));
diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h
index 219db51..2dc275f 100644
--- a/src/simulation/SimulationData.h
+++ b/src/simulation/SimulationData.h
@@ -19,8 +19,6 @@
#define SC_CRACKER2 16
#define SC_TOTAL 15
-#define UI_WALLCOUNT 16
-
#define O_WL_WALLELEC 122
#define O_WL_EWALL 123
#define O_WL_DETECT 124
@@ -40,7 +38,6 @@
#define O_WL_GRAV 142
#define O_WL_ALLOWENERGY 145
-
#define WL_ERASE 0
#define WL_WALLELEC 1
#define WL_EWALL 2
@@ -59,6 +56,8 @@
#define WL_ALLOWENERGY 15
#define WL_FLOODHELPER 255
+#define UI_WALLCOUNT 16
+
#define OLD_SPC_AIR 236
#define SPC_AIR 256
@@ -122,30 +121,21 @@
#define NGT_FROG 22
#define NGT_BRAN 23
-#ifndef SIMULATIONDATA_H_
-#define SIMULATIONDATA_H_
-
-//#include "elements/NULLElement.h"
-//#include "Simulation.h"
+//replace mode / specific delete flags
+#define REPLACE_MODE 0x1
+#define SPECIFIC_DELETE 0x2
-/*class Simulation;
-class Renderer;
-struct Particle;*/
+#ifndef SIMULATIONDATA_H
+#define SIMULATIONDATA_H
struct part_type;
-
struct part_transition;
struct wall_type;
-
struct gol_menu;
-
struct menu_section;
-struct wall_type;
-
class SimTool;
-
class Element;
gol_menu * LoadGOLMenu(int & golMenuCount);
@@ -160,4 +150,4 @@ menu_section * LoadMenus(int & menuCount);
unsigned int * LoadLatent(int & elementCount);
-#endif /* SIMULATIONDATA_H_ */
+#endif /* SIMULATIONDATA_H */
diff --git a/src/simulation/elements/BOMB.cpp b/src/simulation/elements/BOMB.cpp
index ad1a193..303ceb5 100644
--- a/src/simulation/elements/BOMB.cpp
+++ b/src/simulation/elements/BOMB.cpp
@@ -69,7 +69,7 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS)
if ((pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2))<=1)
if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_VIBR)
{
- sim->delete_part(x+nxi, y+nxj, 0);
+ sim->delete_part(x+nxi, y+nxj);
sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
nb = sim->create_part(-3, x+nxi, y+nxj, PT_EMBR);
if (nb!=-1)
diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp
index 1d65a33..9e47e7e 100644
--- a/src/simulation/elements/NEUT.cpp
+++ b/src/simulation/elements/NEUT.cpp
@@ -53,7 +53,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL];
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
- if (BOUNDS_CHECK && (rx || ry))
+ if (BOUNDS_CHECK)
{
r = pmap[y+ry][x+rx];
switch (r&0xFF)
diff --git a/src/simulation/elements/NONE.cpp b/src/simulation/elements/NONE.cpp
index b2bcd12..2fdb261 100644
--- a/src/simulation/elements/NONE.cpp
+++ b/src/simulation/elements/NONE.cpp
@@ -26,8 +26,8 @@ Element_NONE::Element_NONE()
Weight = 100;
- Temperature = R_TEMP+0.0f +273.15f;
- HeatConduct = 251;
+ Temperature = R_TEMP+273.15f;
+ HeatConduct = 0;
Description = "Erases particles.";
State = ST_NONE;
diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp
index a470e6c..14dbee0 100644
--- a/src/simulation/elements/PIPE.cpp
+++ b/src/simulation/elements/PIPE.cpp
@@ -192,7 +192,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
np = sim->create_part(-1,x+rx,y+ry,parts[i].tmp&0xFF);
if (np!=-1)
{
- transfer_pipe_to_part(parts+i, parts+np);
+ transfer_pipe_to_part(sim, parts+i, parts+np);
}
}
//try eating particle at entrance
@@ -374,8 +374,8 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
return 0;
}
-//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_part(Particle *pipe, Particle *part)
-void Element_PIPE::transfer_pipe_to_part(Particle *pipe, Particle *part)
+//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part)
+void Element_PIPE::transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part)
{
part->type = (pipe->tmp & 0xFF);
part->temp = pipe->temp;
@@ -384,7 +384,7 @@ void Element_PIPE::transfer_pipe_to_part(Particle *pipe, Particle *part)
part->ctype = pipe->pavg[1];
pipe->tmp &= ~0xFF;
- if (part->type != PT_PHOT && part->type != PT_ELEC && part->type != PT_NEUT)
+ if (!(sim->elements[part->type].Properties & TYPE_ENERGY))
{
part->vx = 0.0f;
part->vy = 0.0f;
@@ -456,7 +456,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
for (nnx=0; nnx<80; nnx++)
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
{
- transfer_pipe_to_part(sim->parts+i, &(sim->portalp[sim->parts[r>>8].tmp][count][nnx]));
+ transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[sim->parts[r>>8].tmp][count][nnx]));
count++;
break;
}
@@ -482,7 +482,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
for (nnx=0; nnx<80; nnx++)
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
{
- transfer_pipe_to_part(sim->parts+i, &(sim->portalp[sim->parts[r>>8].tmp][count][nnx]));
+ transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[sim->parts[r>>8].tmp][count][nnx]));
count++;
break;
}
@@ -494,7 +494,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
np = sim->create_part(-1,x+rx,y+ry,sim->parts[i].tmp&0xFF);
if (np!=-1)
{
- transfer_pipe_to_part(sim->parts+i, sim->parts+np);
+ transfer_pipe_to_part(sim, sim->parts+i, sim->parts+np);
}
}
diff --git a/src/simulation/elements/PLNT.cpp b/src/simulation/elements/PLNT.cpp
index 61218d5..99890e6 100644
--- a/src/simulation/elements/PLNT.cpp
+++ b/src/simulation/elements/PLNT.cpp
@@ -81,7 +81,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
}
break;
case PT_WOOD:
- if (surround_space && !(rand()%4) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1))
+ if (surround_space && !(rand()%4) && (abs(rx+ry)<=2) && parts[i].tmp==1)
{
int nnx = rand()%3 -1;
int nny = rand()%3 -1;
diff --git a/src/virtualmachine/Syscalls.cpp b/src/virtualmachine/Syscalls.cpp
index 31b7dd4..e4ca7ca 100644
--- a/src/virtualmachine/Syscalls.cpp
+++ b/src/virtualmachine/Syscalls.cpp
@@ -87,7 +87,7 @@ namespace vm
TRAPDEF(deletePart)
{
- sim->delete_part(ARG(0).int4, ARG(1).int4, ARG(2).int4);
+ sim->delete_part(ARG(0).int4, ARG(1).int4);
return 0;
}