diff --git a/SConscript b/SConscript index 1bc069a75..62dd2b2c1 100644 --- a/SConscript +++ b/SConscript @@ -170,7 +170,7 @@ if GetOption('universal'): env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64']) env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64']) -env.Append(CPPPATH=['src/', 'data/', 'generated/']) +env.Append(CPPPATH=['src/', 'data/']) if GetOption("msvc"): if GetOption("static"): env.Append(LIBPATH=['StaticLibs/']) @@ -385,11 +385,7 @@ def findLibs(env, conf): FatalError("Cocoa framework not found or not installed") if GetOption('clean'): - import shutil - try: - shutil.rmtree("generated/") - except: - print("couldn't remove build/generated/") + pass elif not GetOption('help'): conf = Configure(env) conf.AddTest('CheckFramework', CheckFramework) diff --git a/SConstruct b/SConstruct index f79c089e8..95e57aeef 100644 --- a/SConstruct +++ b/SConstruct @@ -1,13 +1,3 @@ -import sys -#run generator.py -if not GetOption('clean'): - if sys.version_info[0] < 3: - execfile("generator.py") - else: - with open("generator.py") as f: - code = compile(f.read(), "generator.py", 'exec') - exec(code) - AddOption('--builddir',dest="builddir",default="build",help="Directory to build to.") SConscript('SConscript', variant_dir=GetOption('builddir'), duplicate=0) if GetOption('clean'): diff --git a/generator.py b/generator.py deleted file mode 100644 index 27c5d2d85..000000000 --- a/generator.py +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/env python3 -import re, os, shutil, string, sys - -def generateElements(elementFiles, outputCpp, outputH): - - elementClasses = {} - baseClasses = {} - - elementHeader = """// This file is automatically generated by generator.py - -#ifndef ELEMENTCLASSES_H -#define ELEMENTCLASSES_H - -#include - -#include "simulation/SimulationData.h" -#include "simulation/elements/Element.h" - -""" - - directives = [] - - for elementFile in elementFiles: - try: - f = open(elementFile, "r") - except: - f = open("src/simulation/elements/"+elementFile, "r") - - fileData = f.read() - f.close() - - directiveMatcher = '//#TPT-Directive\s+([^\r\n]+)' - matcher = re.compile(directiveMatcher) - directiveMatches = matcher.findall(fileData) - - for match in directiveMatches: - directives.append(match.split(" ")) - - classDirectives = [] - usedIDs = [] - for d in directives: - if d[0] == "ElementClass": - d[3] = int(d[3]) - classDirectives.append(d) - if d[3] in usedIDs: - print("WARNING: duplicate element ID {} ({})".format(d[3],d[2])) - usedIDs.append(d[3]) - - elementIDs = sorted(classDirectives, key=lambda directive: directive[3]) - - for d in elementIDs: - tmpClass = d[1] - newClass = "" - baseClass = "Element" - if ':' in tmpClass: - classBits = tmpClass.split(':') - newClass = classBits[0] - baseClass = classBits[1] - else: - newClass = tmpClass - - elementClasses[newClass] = [] - baseClasses[newClass] = baseClass - elementHeader += "#define %s %s\n" % (d[2], d[3]) - - for d in directives: - if d[0] == "ElementHeader": - tmpClass = d[1] - newClass = "" - baseClass = "Element" - if ':' in tmpClass: - classBits = tmpClass.split(':') - newClass = classBits[0] - baseClass = classBits[1] - else: - newClass = tmpClass - elementClasses[newClass].append(" ".join(d[2:])+";") - - #for className, classMembers in elementClasses.items(): - for d in elementIDs: - tmpClass = d[1] - newClass = "" - baseClass = "Element" - if ':' in tmpClass: - classBits = tmpClass.split(':') - newClass = classBits[0] - baseClass = classBits[1] - else: - newClass = tmpClass - - className = newClass - classMembers = elementClasses[newClass] - elementBase = baseClass - elementHeader += """ -class {0}: public {1} -{{ -public: - {0}(); - virtual ~{0}(); - {2} -}}; -""".format(className, elementBase, str.join("\n\t", classMembers)) - - elementHeader += """ -std::vector GetElements(); - -#endif -""" - - elementContent = """#include "simulation/ElementDefs.h" -#include "ElementClasses.h" - -std::vector GetElements() -{ - std::vector elements; - """; - - for d in elementIDs: - tmpClass = d[1] - newClass = "" - baseClass = "Element" - if ':' in tmpClass: - classBits = tmpClass.split(':') - newClass = classBits[0] - baseClass = classBits[1] - else: - newClass = tmpClass - elementContent += """elements.push_back(%s()); - """ % (newClass) - - elementContent += """return elements; -} -"""; - - outputPath, outputFile = os.path.split(outputH) - if not os.path.exists(outputPath): - os.makedirs(outputPath) - - f = open(outputH, "w") - f.write(elementHeader) - f.close() - - f = open(outputCpp, "w") - f.write(elementContent) - f.close() - -def generateTools(toolFiles, outputCpp, outputH): - toolClasses = {} - - toolHeader = """#ifndef TOOLCLASSES_H -#define TOOLCLASSES_H - -#include - -#include "simulation/simtools/SimTool.h" - -""" - - directives = [] - - for toolFile in toolFiles: - try: - f = open(toolFile, "r") - except: - f = open("src/simulation/simtools/"+toolFile, "r") - fileData = f.read() - f.close() - - directiveMatcher = '//#TPT-Directive\s+([^\r\n]+)' - matcher = re.compile(directiveMatcher) - directiveMatches = matcher.findall(fileData) - - for match in directiveMatches: - directives.append(match.split(" ")) - - classDirectives = [] - usedIDs = [] - for d in directives: - if d[0] == "ToolClass": - toolClasses[d[1]] = [] - toolHeader += "#define %s %s\n" % (d[2], d[3]) - d[3] = int(d[3]) - classDirectives.append(d) - if d[3] in usedIDs: - print("WARNING: duplicate tool ID {} ({})".format(d[3],d[2])) - usedIDs.append(d[3]) - - for d in directives: - if d[0] == "ToolHeader": - toolClasses[d[1]].append(" ".join(d[2:])+";") - - for className, classMembers in list(toolClasses.items()): - toolHeader += """ -class {0}: public SimTool -{{ -public: - {0}(); - virtual ~{0}(); - int Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) override; -}}; -""".format(className, str.join("\n", classMembers)) - - toolHeader += """ -std::vector GetTools(); - -#endif -""" - - toolContent = """#include "ToolClasses.h" -std::vector GetTools() -{ - std::vector tools; -"""; - - toolIDs = sorted(classDirectives, key=lambda directive: directive[3]) - for d in toolIDs: - toolContent += """ tools.push_back(new %s()); -""" % (d[1]) - - toolContent += """ return tools; -} -"""; - - outputPath, outputFile = os.path.split(outputH) - if not os.path.exists(outputPath): - os.makedirs(outputPath) - - f = open(outputH, "w") - f.write(toolHeader) - f.close() - - f = open(outputCpp, "w") - f.write(toolContent) - f.close() - -generateElements(os.listdir("src/simulation/elements"), "generated/ElementClasses.cpp", "generated/ElementClasses.h") -generateTools(os.listdir("src/simulation/simtools"), "generated/ToolClasses.cpp", "generated/ToolClasses.h") diff --git a/newelement.py b/newelement.py index aa9e6b6aa..1fba01ca9 100755 --- a/newelement.py +++ b/newelement.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import sys import re -import os if len(sys.argv) != 2: name = input('element name: ') @@ -13,24 +12,30 @@ if re.search('[^A-Z0-9-]', name): path = 'src/simulation/elements/' + name + '.cpp' -if os.path.isfile(path): +def get_elements(): + elements = dict() + with open('src/simulation/ElementNumbers.h', 'r') as numbers: + for nm, pt in re.findall('ELEMENT_DEFINE\\s*\\(\\s*(\\S+)\\s*,\\s*(\\d+)\\s*\\)', numbers.read()): + elements[nm] = int(pt) + return elements + +elements = get_elements() +if name in elements: sys.exit('element already exists') - -with open("generator.py") as f: - exec(compile(f.read(), "generator.py", 'exec')) - max_id = 0 -with open('generated/ElementClasses.h', 'r') as classes: - for pt in re.findall('#define PT_\\S+ (\\d+)', classes.read()): - pt_id = int(pt) - if max_id < pt_id: - max_id = pt_id +for nm, pt in elements.items(): + pt_id = int(pt) + if max_id < pt_id: + max_id = pt_id +new_id = max_id + 1 with open(path, 'w') as elem: elem.write(r"""#include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_{0} PT_{0} {1} -Element_{0}::Element_{0}() +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_{0}() {{ Identifier = "DEFAULT_PT_{0}"; Name = "{0}"; @@ -41,20 +46,18 @@ Element_{0}::Element_{0}() // element properties here - Update = &Element_{0}::update; - Graphics = &Element_{0}::graphics; + Update = &update; + Graphics = &graphics; }} -//#TPT-Directive ElementHeader Element_{0} static int update(UPDATE_FUNC_ARGS) -int Element_{0}::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) {{ // update code here return 0; }} -//#TPT-Directive ElementHeader Element_{0} static int graphics(GRAPHICS_FUNC_ARGS) -int Element_{0}::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) {{ // graphics code here // return 1 if nothing dymanic happens here @@ -62,9 +65,13 @@ int Element_{0}::graphics(GRAPHICS_FUNC_ARGS) return 0; }} -Element_{0}::~Element_{0}() {{}} -""".format(name, str(max_id + 1))) +""".format(name)) elem.close() -with open("generator.py") as f: - exec(compile(f.read(), "generator.py", 'exec')) +print('element file \'{0}\' successfully created '.format(path)) +input('now add \'ELEMENT_DEFINE({0}, {1});\' to \'src/simulation/ElementNumbers.h\', then press enter'.format(name, str(new_id))) +while True: + elements = get_elements() + if name in elements and elements[name] == new_id: + break + input('nope; try doing that again, then press enter') diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index 786c50b0e..b13d34afe 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -13,7 +13,7 @@ #include "hmap.h" #include "simulation/Simulation.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" GameSave::GameSave(GameSave & save): majorVersion(save.majorVersion), diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 00a929a2d..1b79994ce 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -18,7 +18,7 @@ #include "simulation/ElementGraphics.h" #include "simulation/Air.h" #include "simulation/Gravity.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" #ifdef LUACONSOLE #include "lua/LuaScriptInterface.h" @@ -1201,7 +1201,7 @@ void Renderer::render_parts() if(!sim) return; parts = sim->parts; - elements = sim->elements; + elements = sim->elements.data(); #ifdef OGLR float fnx, fny; int cfireV = 0, cfireC = 0, cfire = 0; diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index a9aec0e51..3183e0761 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -72,7 +72,7 @@ #include "simulation/SimulationData.h" #include "simulation/Air.h" #include "simulation/Snapshot.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" #ifdef GetUserName # undef GetUserName // dammit windows @@ -930,10 +930,11 @@ void GameController::Update() rightSelected = sr; } + void Element_STKM_set_element(Simulation *sim, playerst *playerp, int element); if (!sim->player.spwn) - Element_STKM::STKM_set_element(sim, &sim->player, rightSelected); + Element_STKM_set_element(sim, &sim->player, rightSelected); if (!sim->player2.spwn) - Element_STKM::STKM_set_element(sim, &sim->player2, rightSelected); + Element_STKM_set_element(sim, &sim->player2, rightSelected); } if(renderOptions && renderOptions->HasExited) { diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 6e4ca976b..2023abd5f 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -3,7 +3,7 @@ #include "GameView.h" #include "GameController.h" -#include "ToolClasses.h" +#include "simulation/ToolClasses.h" #include "EllipseBrush.h" #include "TriangleBrush.h" #include "BitmapBrush.h" @@ -26,7 +26,7 @@ #include "simulation/Snapshot.h" #include "simulation/Gravity.h" #include "simulation/ElementGraphics.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" #include "gui/game/DecorationTool.h" #include "gui/interface/Engine.h" @@ -339,8 +339,15 @@ void GameModel::BuildMenus() //Build menu for tools for (size_t i = 0; i < sim->tools.size(); i++) { - Tool * tempTool; - tempTool = new Tool(i, sim->tools[i]->Name, sim->tools[i]->Description, PIXR(sim->tools[i]->Colour), PIXG(sim->tools[i]->Colour), PIXB(sim->tools[i]->Colour), sim->tools[i]->Identifier); + Tool *tempTool = new Tool( + i, + sim->tools[i].Name, + sim->tools[i].Description, + PIXR(sim->tools[i].Colour), + PIXG(sim->tools[i].Colour), + PIXB(sim->tools[i].Colour), + sim->tools[i].Identifier + ); menuList[SC_TOOL]->AddTool(tempTool); } //Add special sign and prop tools diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 28422d004..b992057f6 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -36,7 +36,7 @@ #include "simulation/SaveRenderer.h" #include "simulation/SimulationData.h" #include "simulation/ElementDefs.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" #ifdef GetUserName # undef GetUserName // dammit windows diff --git a/src/gui/game/SampleTool.cpp b/src/gui/game/SampleTool.cpp index 1e4cdc046..3a0cd9079 100644 --- a/src/gui/game/SampleTool.cpp +++ b/src/gui/game/SampleTool.cpp @@ -7,7 +7,7 @@ #include "gui/interface/Colour.h" #include "simulation/Simulation.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" #include "Menu.h" diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index 6f01c2cd0..59263519f 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -4,7 +4,7 @@ #include "simulation/Simulation.h" #include "simulation/SimulationData.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" Tool::Tool(int id, String name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)): textureGen(textureGen), diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index e6d2542e0..308bb49b0 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -37,8 +37,8 @@ #include "simulation/ElementCommon.h" #include "simulation/Air.h" -#include "ToolClasses.h" -#include "ElementClasses.h" +#include "simulation/ToolClasses.h" +#include "simulation/ElementClasses.h" #include "client/GameSave.h" #include "client/SaveFile.h" @@ -2582,7 +2582,7 @@ int LuaScriptInterface::elements_loadDefault(lua_State * l) lua_pushnil(l); lua_setfield(l, -2, luacon_sim->elements[id].Identifier.c_str()); - std::vector elementList = GetElements(); + auto const &elementList = GetElements(); if (id < (int)elementList.size()) luacon_sim->elements[id] = elementList[id]; else @@ -2594,7 +2594,7 @@ int LuaScriptInterface::elements_loadDefault(lua_State * l) } else { - std::vector elementList = GetElements(); + auto const &elementList = GetElements(); for (int i = 0; i < PT_NUM; i++) { if (i < (int)elementList.size()) diff --git a/src/lua/TPTScriptInterface.cpp b/src/lua/TPTScriptInterface.cpp index 4ed537f01..4596a7ac2 100644 --- a/src/lua/TPTScriptInterface.cpp +++ b/src/lua/TPTScriptInterface.cpp @@ -11,7 +11,7 @@ #include "simulation/Simulation.h" #include "simulation/Air.h" -#include "ElementClasses.h" +#include "simulation/ElementClasses.h" #include "gui/game/GameController.h" #include "gui/game/GameModel.h" diff --git a/src/simulation/elements/Element.cpp b/src/simulation/Element.cpp similarity index 99% rename from src/simulation/elements/Element.cpp rename to src/simulation/Element.cpp index 831fe87d1..177ab21b9 100644 --- a/src/simulation/elements/Element.cpp +++ b/src/simulation/Element.cpp @@ -1,5 +1,5 @@ -#include "simulation/ElementCommon.h" -#include "simulation/StructProperty.h" +#include "ElementCommon.h" +#include "StructProperty.h" Element::Element(): Identifier("DEFAULT_INVALID"), diff --git a/src/simulation/elements/Element.h b/src/simulation/Element.h similarity index 95% rename from src/simulation/elements/Element.h rename to src/simulation/Element.h index 5967f7ef8..34c41ce29 100644 --- a/src/simulation/elements/Element.h +++ b/src/simulation/Element.h @@ -74,6 +74,10 @@ public: /** Returns a list of properties, their type and offset within the structure that can be changed by higher-level processes referring to them by name such as Lua or the property tool **/ static std::vector const &GetProperties(); + +#define ELEMENT_NUMBERS_DECLARE +#include "ElementNumbers.h" +#undef ELEMENT_NUMBERS_DECLARE }; #endif diff --git a/src/simulation/ElementClasses.cpp b/src/simulation/ElementClasses.cpp new file mode 100644 index 000000000..74ed3bbee --- /dev/null +++ b/src/simulation/ElementClasses.cpp @@ -0,0 +1,19 @@ +#include "ElementCommon.h" + +std::vector const &GetElements() +{ + struct DoOnce + { + std::vector elements; + + DoOnce() : elements(PT_NUM) + { +#define ELEMENT_NUMBERS_CALL +#include "ElementNumbers.h" +#undef ELEMENT_NUMBERS_CALL + } + }; + + static DoOnce doOnce; + return doOnce.elements; +} diff --git a/src/simulation/ElementClasses.h b/src/simulation/ElementClasses.h new file mode 100644 index 000000000..329b894a0 --- /dev/null +++ b/src/simulation/ElementClasses.h @@ -0,0 +1,15 @@ +#ifndef ELEMENTCLASSES_H +#define ELEMENTCLASSES_H + +#include + +#include "SimulationData.h" +#include "Element.h" + +#define ELEMENT_NUMBERS_ENUMERATE +#include "ElementNumbers.h" +#undef ELEMENT_NUMBERS_ENUMERATE + +std::vector const &GetElements(); + +#endif diff --git a/src/simulation/ElementNumbers.h b/src/simulation/ElementNumbers.h new file mode 100644 index 000000000..5fe343a5d --- /dev/null +++ b/src/simulation/ElementNumbers.h @@ -0,0 +1,199 @@ +#ifdef ELEMENT_NUMBERS_CALL +# define ELEMENT_DEFINE(name, id) elements[id].Element_ ## name () +#endif +#ifdef ELEMENT_NUMBERS_DECLARE +# define ELEMENT_DEFINE(name, id) void Element_ ## name () +#endif +#ifdef ELEMENT_NUMBERS_ENUMERATE +# define ELEMENT_DEFINE(name, id) constexpr int PT_ ## name = id +#endif + +ELEMENT_DEFINE(NONE, 0); +ELEMENT_DEFINE(DUST, 1); +ELEMENT_DEFINE(WATR, 2); +ELEMENT_DEFINE(OIL, 3); +ELEMENT_DEFINE(FIRE, 4); +ELEMENT_DEFINE(STNE, 5); +ELEMENT_DEFINE(LAVA, 6); +ELEMENT_DEFINE(GUNP, 7); +ELEMENT_DEFINE(NITR, 8); +ELEMENT_DEFINE(CLNE, 9); +ELEMENT_DEFINE(GAS, 10); +ELEMENT_DEFINE(PLEX, 11); +ELEMENT_DEFINE(GOO, 12); +ELEMENT_DEFINE(ICEI, 13); +ELEMENT_DEFINE(METL, 14); +ELEMENT_DEFINE(SPRK, 15); +ELEMENT_DEFINE(SNOW, 16); +ELEMENT_DEFINE(WOOD, 17); +ELEMENT_DEFINE(NEUT, 18); +ELEMENT_DEFINE(PLUT, 19); +ELEMENT_DEFINE(PLNT, 20); +ELEMENT_DEFINE(ACID, 21); +ELEMENT_DEFINE(VOID, 22); +ELEMENT_DEFINE(WTRV, 23); +ELEMENT_DEFINE(CNCT, 24); +ELEMENT_DEFINE(DSTW, 25); +ELEMENT_DEFINE(SALT, 26); +ELEMENT_DEFINE(SLTW, 27); +ELEMENT_DEFINE(DMND, 28); +ELEMENT_DEFINE(BMTL, 29); +ELEMENT_DEFINE(BRMT, 30); +ELEMENT_DEFINE(PHOT, 31); +ELEMENT_DEFINE(URAN, 32); +ELEMENT_DEFINE(WAX, 33); +ELEMENT_DEFINE(MWAX, 34); +ELEMENT_DEFINE(PSCN, 35); +ELEMENT_DEFINE(NSCN, 36); +ELEMENT_DEFINE(LNTG, 37); +ELEMENT_DEFINE(INSL, 38); +ELEMENT_DEFINE(BHOL, 39); +ELEMENT_DEFINE(WHOL, 40); +ELEMENT_DEFINE(RBDM, 41); +ELEMENT_DEFINE(LRBD, 42); +ELEMENT_DEFINE(NTCT, 43); +ELEMENT_DEFINE(SAND, 44); +ELEMENT_DEFINE(GLAS, 45); +ELEMENT_DEFINE(PTCT, 46); +ELEMENT_DEFINE(BGLA, 47); +ELEMENT_DEFINE(THDR, 48); +ELEMENT_DEFINE(PLSM, 49); +ELEMENT_DEFINE(ETRD, 50); +ELEMENT_DEFINE(NICE, 51); +ELEMENT_DEFINE(NBLE, 52); +ELEMENT_DEFINE(BTRY, 53); +ELEMENT_DEFINE(LCRY, 54); +ELEMENT_DEFINE(STKM, 55); +ELEMENT_DEFINE(SWCH, 56); +ELEMENT_DEFINE(SMKE, 57); +ELEMENT_DEFINE(DESL, 58); +ELEMENT_DEFINE(COAL, 59); +ELEMENT_DEFINE(LO2, 60); +ELEMENT_DEFINE(O2, 61); +ELEMENT_DEFINE(INWR, 62); +ELEMENT_DEFINE(YEST, 63); +ELEMENT_DEFINE(DYST, 64); +ELEMENT_DEFINE(THRM, 65); +ELEMENT_DEFINE(GLOW, 66); +ELEMENT_DEFINE(BRCK, 67); +ELEMENT_DEFINE(CFLM, 68); +ELEMENT_DEFINE(FIRW, 69); +ELEMENT_DEFINE(FUSE, 70); +ELEMENT_DEFINE(FSEP, 71); +ELEMENT_DEFINE(AMTR, 72); +ELEMENT_DEFINE(BCOL, 73); +ELEMENT_DEFINE(PCLN, 74); +ELEMENT_DEFINE(HSWC, 75); +ELEMENT_DEFINE(IRON, 76); +ELEMENT_DEFINE(MORT, 77); +ELEMENT_DEFINE(LIFE, 78); +ELEMENT_DEFINE(DLAY, 79); +ELEMENT_DEFINE(CO2, 80); +ELEMENT_DEFINE(DRIC, 81); +ELEMENT_DEFINE(CBNW, 82); +ELEMENT_DEFINE(STOR, 83); +ELEMENT_DEFINE(PVOD, 84); +ELEMENT_DEFINE(CONV, 85); +ELEMENT_DEFINE(CAUS, 86); +ELEMENT_DEFINE(LIGH, 87); +ELEMENT_DEFINE(TESC, 88); +ELEMENT_DEFINE(DEST, 89); +ELEMENT_DEFINE(SPNG, 90); +ELEMENT_DEFINE(RIME, 91); +ELEMENT_DEFINE(FOG, 92); +ELEMENT_DEFINE(BCLN, 93); +ELEMENT_DEFINE(LOVE, 94); +ELEMENT_DEFINE(DEUT, 95); +ELEMENT_DEFINE(WARP, 96); +ELEMENT_DEFINE(PUMP, 97); +ELEMENT_DEFINE(FWRK, 98); +ELEMENT_DEFINE(PIPE, 99); +ELEMENT_DEFINE(FRZZ, 100); +ELEMENT_DEFINE(FRZW, 101); +ELEMENT_DEFINE(GRAV, 102); +ELEMENT_DEFINE(BIZR, 103); +ELEMENT_DEFINE(BIZRG, 104); +ELEMENT_DEFINE(BIZRS, 105); +ELEMENT_DEFINE(INST, 106); +ELEMENT_DEFINE(ISOZ, 107); +ELEMENT_DEFINE(ISZS, 108); +ELEMENT_DEFINE(PRTI, 109); +ELEMENT_DEFINE(PRTO, 110); +ELEMENT_DEFINE(PSTE, 111); +ELEMENT_DEFINE(PSTS, 112); +ELEMENT_DEFINE(ANAR, 113); +ELEMENT_DEFINE(VINE, 114); +ELEMENT_DEFINE(INVIS, 115); +ELEMENT_DEFINE(E116, 116); +ELEMENT_DEFINE(SPAWN2, 117); +ELEMENT_DEFINE(SPAWN, 118); +ELEMENT_DEFINE(SHLD1, 119); +ELEMENT_DEFINE(SHLD2, 120); +ELEMENT_DEFINE(SHLD3, 121); +ELEMENT_DEFINE(SHLD4, 122); +ELEMENT_DEFINE(LOLZ, 123); +ELEMENT_DEFINE(WIFI, 124); +ELEMENT_DEFINE(FILT, 125); +ELEMENT_DEFINE(ARAY, 126); +ELEMENT_DEFINE(BRAY, 127); +ELEMENT_DEFINE(STKM2, 128); +ELEMENT_DEFINE(BOMB, 129); +ELEMENT_DEFINE(C5, 130); +ELEMENT_DEFINE(SING, 131); +ELEMENT_DEFINE(QRTZ, 132); +ELEMENT_DEFINE(PQRT, 133); +ELEMENT_DEFINE(EMP, 134); +ELEMENT_DEFINE(BREC, 135); +ELEMENT_DEFINE(ELEC, 136); +ELEMENT_DEFINE(ACEL, 137); +ELEMENT_DEFINE(DCEL, 138); +ELEMENT_DEFINE(BANG, 139); +ELEMENT_DEFINE(IGNT, 140); +ELEMENT_DEFINE(BOYL, 141); +ELEMENT_DEFINE(GEL, 142); +ELEMENT_DEFINE(TRON, 143); +ELEMENT_DEFINE(TTAN, 144); +ELEMENT_DEFINE(EXOT, 145); +ELEMENT_DEFINE(E146, 146); +ELEMENT_DEFINE(EMBR, 147); +ELEMENT_DEFINE(H2, 148); +ELEMENT_DEFINE(SOAP, 149); +ELEMENT_DEFINE(NBHL, 150); +ELEMENT_DEFINE(NWHL, 151); +ELEMENT_DEFINE(MERC, 152); +ELEMENT_DEFINE(PBCN, 153); +ELEMENT_DEFINE(GPMP, 154); +ELEMENT_DEFINE(CLST, 155); +ELEMENT_DEFINE(WIRE, 156); +ELEMENT_DEFINE(GBMB, 157); +ELEMENT_DEFINE(FIGH, 158); +ELEMENT_DEFINE(FRAY, 159); +ELEMENT_DEFINE(RPEL, 160); +ELEMENT_DEFINE(PPIP, 161); +ELEMENT_DEFINE(DTEC, 162); +ELEMENT_DEFINE(DMG, 163); +ELEMENT_DEFINE(TSNS, 164); +ELEMENT_DEFINE(VIBR, 165); +ELEMENT_DEFINE(BVBR, 166); +ELEMENT_DEFINE(CRAY, 167); +ELEMENT_DEFINE(PSTN, 168); +ELEMENT_DEFINE(FRME, 169); +ELEMENT_DEFINE(GOLD, 170); +ELEMENT_DEFINE(TUNG, 171); +ELEMENT_DEFINE(PSNS, 172); +ELEMENT_DEFINE(PROT, 173); +ELEMENT_DEFINE(VIRS, 174); +ELEMENT_DEFINE(VRSS, 175); +ELEMENT_DEFINE(VRSG, 176); +ELEMENT_DEFINE(GRVT, 177); +ELEMENT_DEFINE(DRAY, 178); +ELEMENT_DEFINE(CRMC, 179); +ELEMENT_DEFINE(HEAC, 180); +ELEMENT_DEFINE(SAWD, 181); +ELEMENT_DEFINE(POLO, 182); +ELEMENT_DEFINE(RFRG, 183); +ELEMENT_DEFINE(RFGL, 184); +ELEMENT_DEFINE(LSNS, 185); +ELEMENT_DEFINE(LDTC, 186); + +#undef ELEMENT_DEFINE diff --git a/src/simulation/simtools/SimTool.cpp b/src/simulation/SimTool.cpp similarity index 100% rename from src/simulation/simtools/SimTool.cpp rename to src/simulation/SimTool.cpp diff --git a/src/simulation/simtools/SimTool.h b/src/simulation/SimTool.h similarity index 56% rename from src/simulation/simtools/SimTool.h rename to src/simulation/SimTool.h index aa787bf48..cd5fe700c 100644 --- a/src/simulation/simtools/SimTool.h +++ b/src/simulation/SimTool.h @@ -14,9 +14,13 @@ public: pixel Colour; String Description; + int (*Perform)(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + SimTool(); - virtual ~SimTool() {} - virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { return 0; } + +#define TOOL_NUMBERS_DECLARE +#include "ToolNumbers.h" +#undef TOOL_NUMBERS_DECLARE }; #endif diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 48b6bd1d6..dc0d6be02 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -35,6 +35,12 @@ #include "lua/LuaScriptHelper.h" #endif +extern int Element_PPIP_ppip_changed; +extern int Element_LOLZ_RuleTable[9][9]; +extern int Element_LOLZ_lolz[XRES/9][YRES/9]; +extern int Element_LOVE_RuleTable[9][9]; +extern int Element_LOVE_love[XRES/9][YRES/9]; + int Simulation::Load(GameSave * save, bool includePressure) { return Load(save, includePressure, 0, 0); @@ -110,7 +116,8 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY continue; if ((tempPart.type == PT_SPAWN && elementCount[PT_SPAWN]) || (tempPart.type == PT_SPAWN2 && elementCount[PT_SPAWN2])) continue; - if (tempPart.type == PT_FIGH && !Element_FIGH::CanAlloc(this)) + bool Element_FIGH_CanAlloc(Simulation *sim); + if (tempPart.type == PT_FIGH && !Element_FIGH_CanAlloc(this)) continue; if (!elements[tempPart.type].Enabled) continue; @@ -169,10 +176,11 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY elementCount[tempPart.type]++; } + void Element_STKM_init_legs(Simulation * sim, playerst *playerp, int i); switch (parts[i].type) { case PT_STKM: - Element_STKM::STKM_init_legs(this, &player, i); + Element_STKM_init_legs(this, &player, i); player.spwn = 1; player.elem = PT_DUST; @@ -187,7 +195,7 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY player.fan = true; break; case PT_STKM2: - Element_STKM::STKM_init_legs(this, &player2, i); + Element_STKM_init_legs(this, &player2, i); player2.spwn = 1; player2.elem = PT_DUST; if ((save->majorVersion < 93 && parts[i].ctype == SPC_AIR) || @@ -209,7 +217,8 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY case PT_FIGH: { unsigned int oldTmp = parts[i].tmp; - parts[i].tmp = Element_FIGH::Alloc(this); + int Element_FIGH_Alloc(Simulation *sim); + parts[i].tmp = Element_FIGH_Alloc(this); if (parts[i].tmp >= 0) { bool fan = false; @@ -219,7 +228,8 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY fan = true; parts[i].ctype = 0; } - Element_FIGH::NewFighter(this, parts[i].tmp, i, parts[i].ctype); + void Element_FIGH_NewFighter(Simulation *sim, int fighterID, int i, int elem); + Element_FIGH_NewFighter(this, parts[i].tmp, i, parts[i].ctype); if (fan) fighters[parts[i].tmp].fan = true; for (unsigned int fighNum : save->stkm.rocketBootsFigh) @@ -260,7 +270,7 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY } parts_lastActiveIndex = NPART-1; force_stacking_check = true; - Element_PPIP::ppip_changed = 1; + Element_PPIP_ppip_changed = 1; RecalcFreeParticles(false); // fix SOAP links using soapList, a map of old particle ID -> new particle ID @@ -1324,17 +1334,13 @@ void Simulation::ApplyDecorationFill(Renderer *ren, int x, int y, int colR, int int Simulation::Tool(int x, int y, int tool, int brushX, int brushY, float strength) { - if(tools[tool]) - { - Particle * cpart = NULL; - int r; - if ((r = pmap[y][x])) - cpart = &(parts[ID(r)]); - else if ((r = photons[y][x])) - cpart = &(parts[ID(r)]); - return tools[tool]->Perform(this, cpart, x, y, brushX, brushY, strength); - } - return 0; + Particle * cpart = NULL; + int r; + if ((r = pmap[y][x])) + cpart = &(parts[ID(r)]); + else if ((r = photons[y][x])) + cpart = &(parts[ID(r)]); + return tools[tool].Perform(this, cpart, x, y, brushX, brushY, strength); } int Simulation::ToolBrush(int positionX, int positionY, int tool, Brush * cBrush, float strength) @@ -2583,6 +2589,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny) return 0; } + int Element_FILT_interactWavelengths(Particle* cpart, int origWl); if (e == 2) //if occupy same space { switch (parts[i].type) @@ -2599,7 +2606,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny) } break; case PT_FILT: - parts[i].ctype = Element_FILT::interactWavelengths(&parts[ID(r)], parts[i].ctype); + parts[i].ctype = Element_FILT_interactWavelengths(&parts[ID(r)], parts[i].ctype); break; case PT_C5: if (parts[ID(r)].life > 0 && (parts[ID(r)].ctype & parts[i].ctype & 0xFFFFFFC0)) @@ -2698,7 +2705,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny) case PT_BIZR: case PT_BIZRG: if (TYP(r) == PT_FILT) - parts[i].ctype = Element_FILT::interactWavelengths(&parts[ID(r)], parts[i].ctype); + parts[i].ctype = Element_FILT_interactWavelengths(&parts[ID(r)], parts[i].ctype); break; } return 1; @@ -5002,11 +5009,11 @@ void Simulation::BeforeSim() kill_part(ID(r)); else if (parts[ID(r)].type==PT_LOVE) { - Element_LOVE::love[nx/9][ny/9] = 1; + Element_LOVE_love[nx/9][ny/9] = 1; } else if (parts[ID(r)].type==PT_LOLZ) { - Element_LOLZ::lolz[nx/9][ny/9] = 1; + Element_LOLZ_lolz[nx/9][ny/9] = 1; } } } @@ -5014,7 +5021,7 @@ void Simulation::BeforeSim() { for (ny=9; ny<=YRES-7; ny++) { - if (Element_LOVE::love[nx/9][ny/9]==1) + if (Element_LOVE_love[nx/9][ny/9]==1) { for ( nnx=0; nnx<9; nnx++) for ( nny=0; nny<9; nny++) @@ -5022,17 +5029,17 @@ void Simulation::BeforeSim() if (ny+nny>0&&ny+nny=0&&nx+nnx0&&ny+nny=0&&nx+nnxhv; msections = LoadMenus(); - wtypes = LoadWalls(); - platent = LoadLatent(); - - std::vector elementList = GetElements(); - for(int i = 0; i < PT_NUM; i++) - { - if (i < (int)elementList.size()) - elements[i] = elementList[i]; - else - elements[i] = Element(); - } - + std::copy(GetElements().begin(), GetElements().end(), elements.begin()); tools = GetTools(); - grule = LoadGOLRules(); - gmenu = LoadGOLMenu(); player.comm = 0; diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index cdb32b186..c81f715d6 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "Particle.h" #include "Stickman.h" @@ -15,7 +16,7 @@ #include "CoordStack.h" -#include "elements/Element.h" +#include "Element.h" #define CHANNELS ((int)(MAX_TEMP-73)/100+2) @@ -40,9 +41,9 @@ public: Air * air; std::vector signs; - Element elements[PT_NUM]; + std::array elements; //Element * elements; - std::vector tools; + std::vector tools; std::vector platent; std::vector wtypes; std::vector gmenu; diff --git a/src/simulation/ToolClasses.cpp b/src/simulation/ToolClasses.cpp new file mode 100644 index 000000000..de8732a66 --- /dev/null +++ b/src/simulation/ToolClasses.cpp @@ -0,0 +1,19 @@ +#include "ToolClasses.h" + +std::vector const &GetTools() +{ + struct DoOnce + { + std::vector tools; + + DoOnce() + { +#define TOOL_NUMBERS_CALL +#include "ToolNumbers.h" +#undef TOOL_NUMBERS_CALL + } + }; + + static DoOnce doOnce; + return doOnce.tools; +} diff --git a/src/simulation/ToolClasses.h b/src/simulation/ToolClasses.h new file mode 100644 index 000000000..07256e27c --- /dev/null +++ b/src/simulation/ToolClasses.h @@ -0,0 +1,15 @@ +#ifndef TOOLCLASSES_H +#define TOOLCLASSES_H + +#include +#include + +#include "SimTool.h" + +#define TOOL_NUMBERS_ENUMERATE +#include "ToolNumbers.h" +#undef TOOL_NUMBERS_ENUMERATE + +std::vector const &GetTools(); + +#endif diff --git a/src/simulation/ToolNumbers.h b/src/simulation/ToolNumbers.h new file mode 100644 index 000000000..0d1d6cfa9 --- /dev/null +++ b/src/simulation/ToolNumbers.h @@ -0,0 +1,20 @@ +#ifdef TOOL_NUMBERS_CALL +# define TOOL_DEFINE(name, id) tools.push_back(SimTool()), tools.back().Tool_ ## name () +#endif +#ifdef TOOL_NUMBERS_DECLARE +# define TOOL_DEFINE(name, id) void Tool_ ## name () +#endif +#ifdef TOOL_NUMBERS_ENUMERATE +# define TOOL_DEFINE(name, id) constexpr int TOOL_ ## name = id +#endif + +TOOL_DEFINE(HEAT, 0); +TOOL_DEFINE(COOL, 1); +TOOL_DEFINE(AIR, 2); +TOOL_DEFINE(VAC, 3); +TOOL_DEFINE(PGRV, 4); +TOOL_DEFINE(NGRV, 5); +TOOL_DEFINE(MIX, 6); +TOOL_DEFINE(CYCL, 7); + +#undef TOOL_DEFINE diff --git a/src/simulation/elements/ACEL.cpp b/src/simulation/elements/ACEL.cpp index 329a29f9f..c0d50a053 100644 --- a/src/simulation/elements/ACEL.cpp +++ b/src/simulation/elements/ACEL.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ACEL PT_ACEL 137 -Element_ACEL::Element_ACEL() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_ACEL() { Identifier = "DEFAULT_PT_ACEL"; Name = "ACEL"; @@ -40,12 +43,11 @@ Element_ACEL::Element_ACEL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_ACEL::update; - Graphics = &Element_ACEL::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_ACEL static int update(UPDATE_FUNC_ARGS) -int Element_ACEL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; float multiplier; @@ -78,16 +80,9 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_ACEL static int graphics(GRAPHICS_FUNC_ARGS) -int Element_ACEL::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->tmp) *pixel_mode |= PMODE_GLOW; return 0; } - - -Element_ACEL::~Element_ACEL() {} diff --git a/src/simulation/elements/ACID.cpp b/src/simulation/elements/ACID.cpp index 0c2b23959..009c5f86a 100644 --- a/src/simulation/elements/ACID.cpp +++ b/src/simulation/elements/ACID.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ACID PT_ACID 21 -Element_ACID::Element_ACID() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_ACID() { Identifier = "DEFAULT_PT_ACID"; Name = "ACID"; @@ -43,12 +46,11 @@ Element_ACID::Element_ACID() DefaultProperties.life = 75; - Update = &Element_ACID::update; - Graphics = &Element_ACID::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_ACID static int update(UPDATE_FUNC_ARGS) -int Element_ACID::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, trade; for (rx=-2; rx<3; rx++) @@ -125,9 +127,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_ACID static int graphics(GRAPHICS_FUNC_ARGS) -int Element_ACID::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int s = cpart->life; if (s>75) s = 75; //These two should not be here. @@ -140,5 +140,3 @@ int Element_ACID::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_BLUR; return 0; } - -Element_ACID::~Element_ACID() {} diff --git a/src/simulation/elements/AMTR.cpp b/src/simulation/elements/AMTR.cpp index c02f47637..bcf4428d4 100644 --- a/src/simulation/elements/AMTR.cpp +++ b/src/simulation/elements/AMTR.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_AMTR PT_AMTR 72 -Element_AMTR::Element_AMTR() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_AMTR() { Identifier = "DEFAULT_PT_AMTR"; Name = "AMTR"; @@ -40,12 +43,11 @@ Element_AMTR::Element_AMTR() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_AMTR::update; - Graphics = &Element_AMTR::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_AMTR static int update(UPDATE_FUNC_ARGS) -int Element_AMTR::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; for (rx=-1; rx<2; rx++) @@ -74,13 +76,9 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_AMTR static int graphics(GRAPHICS_FUNC_ARGS) -int Element_AMTR::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { // don't render AMTR as a gas // this function just overrides the default graphics return 1; } - -Element_AMTR::~Element_AMTR() {} diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index 2a1fd9a20..6864a75cf 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ANAR PT_ANAR 113 -Element_ANAR::Element_ANAR() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_ANAR() { Identifier = "DEFAULT_PT_ANAR"; Name = "ANAR"; @@ -41,11 +43,10 @@ Element_ANAR::Element_ANAR() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_ANAR::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_ANAR static int update(UPDATE_FUNC_ARGS) -int Element_ANAR::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; @@ -68,6 +69,3 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_ANAR::~Element_ANAR() {} diff --git a/src/simulation/elements/ARAY.cpp b/src/simulation/elements/ARAY.cpp index 5388d2a16..5bc8c3de8 100644 --- a/src/simulation/elements/ARAY.cpp +++ b/src/simulation/elements/ARAY.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ARAY PT_ARAY 126 -Element_ARAY::Element_ARAY() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_ARAY() { Identifier = "DEFAULT_PT_ARAY"; Name = "ARAY"; @@ -40,11 +42,10 @@ Element_ARAY::Element_ARAY() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_ARAY::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_ARAY static int update(UPDATE_FUNC_ARGS) -int Element_ARAY::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (!parts[i].life) { @@ -122,7 +123,8 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS) { if (parts[r].tmp != 6) { - colored = Element_FILT::interactWavelengths(&parts[r], colored); + int Element_FILT_interactWavelengths(Particle* cpart, int origWl); + colored = Element_FILT_interactWavelengths(&parts[r], colored); if (!colored) break; } @@ -206,6 +208,3 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_ARAY::~Element_ARAY() {} diff --git a/src/simulation/elements/BANG.cpp b/src/simulation/elements/BANG.cpp index 9b091bad0..4dd5098a5 100644 --- a/src/simulation/elements/BANG.cpp +++ b/src/simulation/elements/BANG.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BANG PT_BANG 139 -Element_BANG::Element_BANG() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BANG() { Identifier = "DEFAULT_PT_BANG"; Name = "TNT"; @@ -40,11 +42,10 @@ Element_BANG::Element_BANG() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BANG::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_BANG static int update(UPDATE_FUNC_ARGS) -int Element_BANG::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if(parts[i].tmp==0) @@ -119,6 +120,3 @@ int Element_BANG::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_BANG::~Element_BANG() {} diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp index 46a83db42..cb0591851 100644 --- a/src/simulation/elements/BCLN.cpp +++ b/src/simulation/elements/BCLN.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BCLN PT_BCLN 93 -Element_BCLN::Element_BCLN() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BCLN() { Identifier = "DEFAULT_PT_BCLN"; Name = "BCLN"; @@ -40,14 +42,13 @@ Element_BCLN::Element_BCLN() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BCLN::update; + Update = &update; CtypeDraw = &Element::ctypeDrawVInTmp; } -#define ADVECTION 0.1f +constexpr float ADVECTION = 0.1f; -//#TPT-Directive ElementHeader Element_BCLN static int update(UPDATE_FUNC_ARGS) -int Element_BCLN::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f) parts[i].life = RNG::Ref().between(80, 119); @@ -95,6 +96,3 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_BCLN::~Element_BCLN() {} diff --git a/src/simulation/elements/BCOL.cpp b/src/simulation/elements/BCOL.cpp index 3d0f84a28..2c78791ae 100644 --- a/src/simulation/elements/BCOL.cpp +++ b/src/simulation/elements/BCOL.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BCOL PT_BCOL 73 -Element_BCOL::Element_BCOL() + +int Element_COAL_update(UPDATE_FUNC_ARGS); +int Element_COAL_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BCOL() { Identifier = "DEFAULT_PT_BCOL"; Name = "BCOL"; @@ -43,8 +46,6 @@ Element_BCOL::Element_BCOL() DefaultProperties.life = 110; - Update = &Element_COAL::update; - Graphics = &Element_COAL::graphics; + Update = &Element_COAL_update; + Graphics = &Element_COAL_graphics; } - -Element_BCOL::~Element_BCOL() {} diff --git a/src/simulation/elements/BGLA.cpp b/src/simulation/elements/BGLA.cpp index 99082c9ca..66a5c7f76 100644 --- a/src/simulation/elements/BGLA.cpp +++ b/src/simulation/elements/BGLA.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BGLA PT_BGLA 47 -Element_BGLA::Element_BGLA() + +void Element::Element_BGLA() { Identifier = "DEFAULT_PT_BGLA"; Name = "BGLA"; @@ -39,8 +39,4 @@ Element_BGLA::Element_BGLA() LowTemperatureTransition = NT; HighTemperature = 1973.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_BGLA::~Element_BGLA() {} diff --git a/src/simulation/elements/BHOL.cpp b/src/simulation/elements/BHOL.cpp index 7b2ae7a53..bad62d00b 100644 --- a/src/simulation/elements/BHOL.cpp +++ b/src/simulation/elements/BHOL.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BHOL PT_BHOL 39 -Element_BHOL::Element_BHOL() + +void Element::Element_BHOL() { Identifier = "DEFAULT_PT_BHOL"; Name = "VACU"; @@ -40,8 +40,4 @@ Element_BHOL::Element_BHOL() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_BHOL::~Element_BHOL() {} diff --git a/src/simulation/elements/BIZR.cpp b/src/simulation/elements/BIZR.cpp index 334641968..92eae129a 100644 --- a/src/simulation/elements/BIZR.cpp +++ b/src/simulation/elements/BIZR.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BIZR PT_BIZR 103 -Element_BIZR::Element_BIZR() + +int Element_BIZR_update(UPDATE_FUNC_ARGS); +int Element_BIZR_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BIZR() { Identifier = "DEFAULT_PT_BIZR"; Name = "BIZR"; @@ -42,14 +45,13 @@ Element_BIZR::Element_BIZR() DefaultProperties.ctype = 0x47FFFF; - Update = &Element_BIZR::update; - Graphics = &Element_BIZR::graphics; + Update = &Element_BIZR_update; + Graphics = &Element_BIZR_graphics; } -#define BLEND 0.95f +constexpr float BLEND = 0.95f; -//#TPT-Directive ElementHeader Element_BIZR static int update(UPDATE_FUNC_ARGS) -int Element_BIZR::update(UPDATE_FUNC_ARGS) +int Element_BIZR_update(UPDATE_FUNC_ARGS) { int r, rx, ry, nr, ng, nb, na; float tr, tg, tb, ta, mr, mg, mb, ma; @@ -85,9 +87,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_BIZR static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BIZR::graphics(GRAPHICS_FUNC_ARGS) +int Element_BIZR_graphics(GRAPHICS_FUNC_ARGS) //BIZR, BIZRG, BIZRS { int x = 0; @@ -121,6 +121,3 @@ int Element_BIZR::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_BLUR; return 0; } - - -Element_BIZR::~Element_BIZR() {} diff --git a/src/simulation/elements/BIZRG.cpp b/src/simulation/elements/BIZRG.cpp index b8c5c717a..33e2fd509 100644 --- a/src/simulation/elements/BIZRG.cpp +++ b/src/simulation/elements/BIZRG.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BIZRG PT_BIZRG 104 -Element_BIZRG::Element_BIZRG() + +int Element_BIZR_update(UPDATE_FUNC_ARGS); +int Element_BIZR_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BIZRG() { Identifier = "DEFAULT_PT_BIZRG"; Name = "BIZG"; @@ -43,8 +46,6 @@ Element_BIZRG::Element_BIZRG() DefaultProperties.ctype = 0x47FFFF; - Update = &Element_BIZR::update; - Graphics = &Element_BIZR::graphics; + Update = &Element_BIZR_update; + Graphics = &Element_BIZR_graphics; } -//BIZRG update is in BIZR.cpp -Element_BIZRG::~Element_BIZRG() {} diff --git a/src/simulation/elements/BIZRS.cpp b/src/simulation/elements/BIZRS.cpp index 659ad4c27..77757e1e8 100644 --- a/src/simulation/elements/BIZRS.cpp +++ b/src/simulation/elements/BIZRS.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BIZRS PT_BIZRS 105 -Element_BIZRS::Element_BIZRS() + +int Element_BIZR_update(UPDATE_FUNC_ARGS); +int Element_BIZR_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BIZRS() { Identifier = "DEFAULT_PT_BIZRS"; Name = "BIZS"; @@ -43,8 +46,6 @@ Element_BIZRS::Element_BIZRS() DefaultProperties.ctype = 0x47FFFF; - Update = &Element_BIZR::update; - Graphics = &Element_BIZR::graphics; + Update = &Element_BIZR_update; + Graphics = &Element_BIZR_graphics; } -//BIZRS update is in BIZR.cpp -Element_BIZRS::~Element_BIZRS() {} diff --git a/src/simulation/elements/BMTL.cpp b/src/simulation/elements/BMTL.cpp index f4157b858..aafaf0a1c 100644 --- a/src/simulation/elements/BMTL.cpp +++ b/src/simulation/elements/BMTL.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BMTL PT_BMTL 29 -Element_BMTL::Element_BMTL() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BMTL() { Identifier = "DEFAULT_PT_BMTL"; Name = "BMTL"; @@ -40,11 +42,10 @@ Element_BMTL::Element_BMTL() HighTemperature = 1273.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_BMTL::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_BMTL static int update(UPDATE_FUNC_ARGS) -int Element_BMTL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].tmp>1) @@ -71,6 +72,3 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_BMTL::~Element_BMTL() {} diff --git a/src/simulation/elements/BOMB.cpp b/src/simulation/elements/BOMB.cpp index b748c130f..a6ef4f59c 100644 --- a/src/simulation/elements/BOMB.cpp +++ b/src/simulation/elements/BOMB.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BOMB PT_BOMB 129 -Element_BOMB::Element_BOMB() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BOMB() { Identifier = "DEFAULT_PT_BOMB"; Name = "BOMB"; @@ -41,12 +44,11 @@ Element_BOMB::Element_BOMB() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BOMB::update; - Graphics = &Element_BOMB::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_BOMB static int update(UPDATE_FUNC_ARGS) -int Element_BOMB::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt, nb; @@ -108,14 +110,8 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_BOMB static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BOMB::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *pixel_mode |= PMODE_FLARE; return 1; } - - -Element_BOMB::~Element_BOMB() {} diff --git a/src/simulation/elements/BOYL.cpp b/src/simulation/elements/BOYL.cpp index 3ca6b50a3..831970f94 100644 --- a/src/simulation/elements/BOYL.cpp +++ b/src/simulation/elements/BOYL.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BOYL PT_BOYL 141 -Element_BOYL::Element_BOYL() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BOYL() { Identifier = "DEFAULT_PT_BOYL"; Name = "BOYL"; @@ -41,11 +43,10 @@ Element_BOYL::Element_BOYL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BOYL::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_BOYL static int update(UPDATE_FUNC_ARGS) -int Element_BOYL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; float limit = parts[i].temp / 100; @@ -85,6 +86,3 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_BOYL::~Element_BOYL() {} diff --git a/src/simulation/elements/BRAY.cpp b/src/simulation/elements/BRAY.cpp index ba540cb42..e8d11546d 100644 --- a/src/simulation/elements/BRAY.cpp +++ b/src/simulation/elements/BRAY.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BRAY PT_BRAY 127 -Element_BRAY::Element_BRAY() + +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BRAY() { Identifier = "DEFAULT_PT_BRAY"; Name = "BRAY"; @@ -42,13 +44,10 @@ Element_BRAY::Element_BRAY() DefaultProperties.life = 30; - Update = NULL; - Graphics = &Element_BRAY::graphics; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_BRAY static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BRAY::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int x, trans = 255; if(cpart->tmp==0) @@ -104,6 +103,3 @@ int Element_BRAY::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_BLEND | PMODE_GLOW; return 0; } - - -Element_BRAY::~Element_BRAY() {} diff --git a/src/simulation/elements/BRCK.cpp b/src/simulation/elements/BRCK.cpp index 474e64ed8..18216e40d 100644 --- a/src/simulation/elements/BRCK.cpp +++ b/src/simulation/elements/BRCK.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BRCK PT_BRCK 67 -Element_BRCK::Element_BRCK() + +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BRCK() { Identifier = "DEFAULT_PT_BRCK"; Name = "BRCK"; @@ -40,12 +42,10 @@ Element_BRCK::Element_BRCK() HighTemperature = 1223.0f; HighTemperatureTransition = PT_LAVA; - Update = NULL; - Graphics = &Element_BRCK::graphics; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_BRCK static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BRCK::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { if (cpart->tmp == 1) { @@ -59,5 +59,3 @@ int Element_BRCK::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_BRCK::~Element_BRCK() {} diff --git a/src/simulation/elements/BREC.cpp b/src/simulation/elements/BREC.cpp index 528122b9a..070514599 100644 --- a/src/simulation/elements/BREC.cpp +++ b/src/simulation/elements/BREC.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BREC PT_BREC 135 -Element_BREC::Element_BREC() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BREC() { Identifier = "DEFAULT_PT_BREC"; Name = "BREL"; @@ -40,11 +42,10 @@ Element_BREC::Element_BREC() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BREC::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_BREC static int update(UPDATE_FUNC_ARGS) -int Element_BREC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].life) { @@ -61,5 +62,3 @@ int Element_BREC::update(UPDATE_FUNC_ARGS) } return 0; } - -Element_BREC::~Element_BREC() {} diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp index b593b098d..318ea889e 100644 --- a/src/simulation/elements/BRMT.cpp +++ b/src/simulation/elements/BRMT.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BRMT PT_BRMT 30 -Element_BRMT::Element_BRMT() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BRMT() { Identifier = "DEFAULT_PT_BRMT"; Name = "BRMT"; @@ -40,11 +42,10 @@ Element_BRMT::Element_BRMT() HighTemperature = 1273.0f; HighTemperatureTransition = ST; - Update = &Element_BRMT::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_BRMT static int update(UPDATE_FUNC_ARGS) -int Element_BRMT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, tempFactor; if (parts[i].temp > 523.15f)//250.0f+273.15f @@ -72,6 +73,3 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_BRMT::~Element_BRMT() {} diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp index 2232574b6..f3511bac7 100644 --- a/src/simulation/elements/BTRY.cpp +++ b/src/simulation/elements/BTRY.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BTRY PT_BTRY 53 -Element_BTRY::Element_BTRY() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_BTRY() { Identifier = "DEFAULT_PT_BTRY"; Name = "BTRY"; @@ -40,11 +42,10 @@ Element_BTRY::Element_BTRY() HighTemperature = 2273.0f; HighTemperatureTransition = PT_PLSM; - Update = &Element_BTRY::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_BTRY static int update(UPDATE_FUNC_ARGS) -int Element_BTRY::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; for (rx=-2; rx<3; rx++) @@ -67,6 +68,3 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_BTRY::~Element_BTRY() {} diff --git a/src/simulation/elements/BVBR.cpp b/src/simulation/elements/BVBR.cpp index a7fbea4ce..b32ead1e0 100644 --- a/src/simulation/elements/BVBR.cpp +++ b/src/simulation/elements/BVBR.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_BVBR PT_BVBR 166 -Element_BVBR::Element_BVBR() + +int Element_VIBR_update(UPDATE_FUNC_ARGS); +int Element_VIBR_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BVBR() { Identifier = "DEFAULT_PT_BVBR"; Name = "BVBR"; @@ -41,8 +44,6 @@ Element_BVBR::Element_BVBR() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_VIBR::update; - Graphics = &Element_VIBR::graphics; + Update = &Element_VIBR_update; + Graphics = &Element_VIBR_graphics; } - -Element_BVBR::~Element_BVBR() {} diff --git a/src/simulation/elements/C5.cpp b/src/simulation/elements/C5.cpp index 5358c8c8d..908eac6e9 100644 --- a/src/simulation/elements/C5.cpp +++ b/src/simulation/elements/C5.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_C5 PT_C5 130 -Element_C5::Element_C5() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_C5() { Identifier = "DEFAULT_PT_C5"; Name = "C-5"; @@ -40,12 +43,11 @@ Element_C5::Element_C5() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_C5::update; - Graphics = &Element_C5::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_C5 static int update(UPDATE_FUNC_ARGS) -int Element_C5::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-2; rx<3; rx++) @@ -89,9 +91,7 @@ int Element_C5::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_C5 static int graphics(GRAPHICS_FUNC_ARGS) -int Element_C5::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(!cpart->ctype) return 0; @@ -118,5 +118,3 @@ int Element_C5::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_ADD | PMODE_ADD | NO_DECO; return 0; } - -Element_C5::~Element_C5() {} diff --git a/src/simulation/elements/CAUS.cpp b/src/simulation/elements/CAUS.cpp index e026635ea..9aaec5e57 100644 --- a/src/simulation/elements/CAUS.cpp +++ b/src/simulation/elements/CAUS.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CAUS PT_CAUS 86 -Element_CAUS::Element_CAUS() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_CAUS() { Identifier = "DEFAULT_PT_CAUS"; Name = "CAUS"; @@ -42,11 +44,10 @@ Element_CAUS::Element_CAUS() DefaultProperties.life = 75; - Update = &Element_CAUS::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_CAUS static int update(UPDATE_FUNC_ARGS) -int Element_CAUS::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { for (int rx = -2; rx <= 2; rx++) for (int ry = -2; ry <= 2; ry++) @@ -87,6 +88,3 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_CAUS::~Element_CAUS() {} diff --git a/src/simulation/elements/CBNW.cpp b/src/simulation/elements/CBNW.cpp index a6a66d288..3a9438ca5 100644 --- a/src/simulation/elements/CBNW.cpp +++ b/src/simulation/elements/CBNW.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CBNW PT_CBNW 82 -Element_CBNW::Element_CBNW() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_CBNW() { Identifier = "DEFAULT_PT_CBNW"; Name = "BUBW"; @@ -41,12 +44,11 @@ Element_CBNW::Element_CBNW() HighTemperature = 373.0f; HighTemperatureTransition = PT_WTRV; - Update = &Element_CBNW::update; - Graphics = &Element_CBNW::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_CBNW static int update(UPDATE_FUNC_ARGS) -int Element_CBNW::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (sim->pv[y/CELL][x/CELL]<=3) @@ -134,10 +136,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_CBNW static int graphics(GRAPHICS_FUNC_ARGS) -int Element_CBNW::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int z = cpart->tmp2 - 20;//speckles! *colr += z * 1; @@ -145,6 +144,3 @@ int Element_CBNW::graphics(GRAPHICS_FUNC_ARGS) *colb += z * 8; return 0; } - - -Element_CBNW::~Element_CBNW() {} diff --git a/src/simulation/elements/CFLM.cpp b/src/simulation/elements/CFLM.cpp index f90448b69..2ea9beca9 100644 --- a/src/simulation/elements/CFLM.cpp +++ b/src/simulation/elements/CFLM.cpp @@ -1,8 +1,10 @@ #include "simulation/ElementCommon.h" #include "hmap.h" -//#TPT-Directive ElementClass Element_CFLM PT_CFLM 68 -Element_CFLM::Element_CFLM() +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_CFLM() { Identifier = "DEFAULT_PT_HFLM"; Name = "CFLM"; @@ -43,14 +45,11 @@ Element_CFLM::Element_CFLM() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Graphics = &Element_CFLM::graphics; - Create = &Element_CFLM::create; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_CFLM static int graphics(GRAPHICS_FUNC_ARGS) -int Element_CFLM::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = hflm_data[caddress]; @@ -68,10 +67,7 @@ int Element_CFLM::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_CFLM static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_CFLM::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].life = RNG::Ref().between(50, 199); } - -Element_CFLM::~Element_CFLM() {} diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp index 098199fe6..a59353ae8 100644 --- a/src/simulation/elements/CLNE.cpp +++ b/src/simulation/elements/CLNE.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CLNE PT_CLNE 9 -Element_CLNE::Element_CLNE() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_CLNE() { Identifier = "DEFAULT_PT_CLNE"; Name = "CLNE"; @@ -40,12 +42,11 @@ Element_CLNE::Element_CLNE() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_CLNE::update; + Update = &update; CtypeDraw = &Element::ctypeDrawVInTmp; } -//#TPT-Directive ElementHeader Element_CLNE static int update(UPDATE_FUNC_ARGS) -int Element_CLNE::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOL))) { @@ -86,5 +87,3 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS) } return 0; } - -Element_CLNE::~Element_CLNE() {} diff --git a/src/simulation/elements/CLST.cpp b/src/simulation/elements/CLST.cpp index b5344d163..83ff51f53 100644 --- a/src/simulation/elements/CLST.cpp +++ b/src/simulation/elements/CLST.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CLST PT_CLST 155 -Element_CLST::Element_CLST() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_CLST() { Identifier = "DEFAULT_PT_CLST"; Name = "CLST"; @@ -40,13 +44,12 @@ Element_CLST::Element_CLST() HighTemperature = 1256.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_CLST::update; - Graphics = &Element_CLST::graphics; - Create = &Element_CLST::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_CLST static int update(UPDATE_FUNC_ARGS) -int Element_CLST::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; float cxy = 0; @@ -87,10 +90,7 @@ int Element_CLST::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_CLST static int graphics(GRAPHICS_FUNC_ARGS) -int Element_CLST::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int z = (cpart->tmp - 5) * 16;//speckles! *colr += z; @@ -99,10 +99,7 @@ int Element_CLST::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_CLST static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_CLST::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].tmp = RNG::Ref().between(0, 6); } - -Element_CLST::~Element_CLST() {} diff --git a/src/simulation/elements/CNCT.cpp b/src/simulation/elements/CNCT.cpp index 8e2544aa4..6f8645754 100644 --- a/src/simulation/elements/CNCT.cpp +++ b/src/simulation/elements/CNCT.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CNCT PT_CNCT 24 -Element_CNCT::Element_CNCT() + +void Element::Element_CNCT() { Identifier = "DEFAULT_PT_CNCT"; Name = "CNCT"; @@ -39,8 +39,4 @@ Element_CNCT::Element_CNCT() LowTemperatureTransition = NT; HighTemperature = 1123.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_CNCT::~Element_CNCT() {} diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp index 478f24121..ca99fe5fb 100644 --- a/src/simulation/elements/CO2.cpp +++ b/src/simulation/elements/CO2.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CO2 PT_CO2 80 -Element_CO2::Element_CO2() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_CO2() { Identifier = "DEFAULT_PT_CO2"; Name = "CO2"; @@ -40,11 +42,10 @@ Element_CO2::Element_CO2() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_CO2::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_CO2 static int update(UPDATE_FUNC_ARGS) -int Element_CO2::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -106,6 +107,3 @@ int Element_CO2::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_CO2::~Element_CO2() {} diff --git a/src/simulation/elements/COAL.cpp b/src/simulation/elements/COAL.cpp index d72d6e9e5..a87930831 100644 --- a/src/simulation/elements/COAL.cpp +++ b/src/simulation/elements/COAL.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_COAL PT_COAL 59 -Element_COAL::Element_COAL() + +int Element_COAL_update(UPDATE_FUNC_ARGS); +int Element_COAL_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_COAL() { Identifier = "DEFAULT_PT_COAL"; Name = "COAL"; @@ -44,12 +47,11 @@ Element_COAL::Element_COAL() DefaultProperties.life = 110; DefaultProperties.tmp = 50; - Update = &Element_COAL::update; - Graphics = &Element_COAL::graphics; + Update = &Element_COAL_update; + Graphics = &Element_COAL_graphics; } -//#TPT-Directive ElementHeader Element_COAL static int update(UPDATE_FUNC_ARGS) -int Element_COAL::update(UPDATE_FUNC_ARGS) +int Element_COAL_update(UPDATE_FUNC_ARGS) { if (parts[i].life<=0) { sim->create_part(i, x, y, PT_FIRE); @@ -74,10 +76,9 @@ int Element_COAL::update(UPDATE_FUNC_ARGS) return 0; } -#define FREQUENCY 3.1415/(2*300.0f-(300.0f-200.0f)) +constexpr float FREQUENCY = 3.1415/(2*300.0f-(300.0f-200.0f)); -//#TPT-Directive ElementHeader Element_COAL static int graphics(GRAPHICS_FUNC_ARGS) -int Element_COAL::graphics(GRAPHICS_FUNC_ARGS) +int Element_COAL_graphics(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal { *colr += (cpart->tmp2-295.15f)/3; @@ -101,7 +102,3 @@ int Element_COAL::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - - -Element_COAL::~Element_COAL() {} diff --git a/src/simulation/elements/CONV.cpp b/src/simulation/elements/CONV.cpp index 0724a51ca..c3be318ad 100644 --- a/src/simulation/elements/CONV.cpp +++ b/src/simulation/elements/CONV.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CONV PT_CONV 85 -Element_CONV::Element_CONV() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_CONV() { Identifier = "DEFAULT_PT_CONV"; Name = "CONV"; @@ -40,12 +42,11 @@ Element_CONV::Element_CONV() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_CONV::update; + Update = &update; CtypeDraw = &Element::ctypeDrawVInCtype; } -//#TPT-Directive ElementHeader Element_CONV static int update(UPDATE_FUNC_ARGS) -int Element_CONV::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; int ctype = TYP(parts[i].ctype), ctypeExtra = ID(parts[i].ctype); @@ -92,5 +93,3 @@ int Element_CONV::update(UPDATE_FUNC_ARGS) } return 0; } - -Element_CONV::~Element_CONV() {} diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp index 838a78122..5e8ae6d2a 100644 --- a/src/simulation/elements/CRAY.cpp +++ b/src/simulation/elements/CRAY.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CRAY PT_CRAY 167 -Element_CRAY::Element_CRAY() + +static int update(UPDATE_FUNC_ARGS); +static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS); +static unsigned int wavelengthToDecoColour(int wavelength); + +void Element::Element_CRAY() { Identifier = "DEFAULT_PT_CRAY"; Name = "CRAY"; @@ -40,12 +44,11 @@ Element_CRAY::Element_CRAY() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_CRAY::update; - CtypeDraw = &Element_CRAY::ctypeDraw; + Update = &update; + CtypeDraw = &ctypeDraw; } -//#TPT-Directive ElementHeader Element_CRAY static int update(UPDATE_FUNC_ARGS) -int Element_CRAY::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int nxx, nyy, docontinue, nxi, nyi; // set ctype to things that touch it if it doesn't have one already @@ -107,7 +110,8 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS) colored = 0xFF000000; else if (parts[ID(r)].tmp==0) { - colored = wavelengthToDecoColour(Element_FILT::getWavelengths(&parts[ID(r)])); + int Element_FILT_getWavelengths(Particle* cpart); + colored = wavelengthToDecoColour(Element_FILT_getWavelengths(&parts[ID(r)])); } else if (colored==0xFF000000) colored = 0; @@ -129,8 +133,8 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS) } return 0; } -//#TPT-Directive ElementHeader Element_CRAY static unsigned int wavelengthToDecoColour(int wavelength) -unsigned int Element_CRAY::wavelengthToDecoColour(int wavelength) + +static unsigned int wavelengthToDecoColour(int wavelength) { int colr = 0, colg = 0, colb = 0, x; for (x=0; x<12; x++) { @@ -154,8 +158,7 @@ unsigned int Element_CRAY::wavelengthToDecoColour(int wavelength) return (255<<24) | (colr<<16) | (colg<<8) | colb; } -//#TPT-Directive ElementHeader Element_CRAY static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) -bool Element_CRAY::ctypeDraw(CTYPEDRAW_FUNC_ARGS) +static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) { if (!Element::ctypeDrawVInCtype(CTYPEDRAW_FUNC_SUBCALL_ARGS)) { @@ -168,5 +171,3 @@ bool Element_CRAY::ctypeDraw(CTYPEDRAW_FUNC_ARGS) sim->parts[i].temp = sim->elements[t].DefaultProperties.temp; return true; } - -Element_CRAY::~Element_CRAY() {} diff --git a/src/simulation/elements/CRMC.cpp b/src/simulation/elements/CRMC.cpp index 5f90f7a9f..452947c42 100644 --- a/src/simulation/elements/CRMC.cpp +++ b/src/simulation/elements/CRMC.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_CRMC PT_CRMC 179 -Element_CRMC::Element_CRMC() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_CRMC() { Identifier = "DEFAULT_PT_CRMC"; Name = "CRMC"; @@ -40,21 +44,19 @@ Element_CRMC::Element_CRMC() HighTemperature = 2887.15f; HighTemperatureTransition = ST; - Update = &Element_CRMC::update; - Graphics = &Element_CRMC::graphics; - Create = &Element_CRMC::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_CRMC static int update(UPDATE_FUNC_ARGS) -int Element_CRMC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (sim->pv[y/CELL][x/CELL] < -30.0f) sim->create_part(i, x, y, PT_CLST); return 0; } -//#TPT-Directive ElementHeader Element_CRMC static int graphics(GRAPHICS_FUNC_ARGS) -int Element_CRMC::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int z = (cpart->tmp2 - 2) * 8; *colr += z; @@ -63,11 +65,7 @@ int Element_CRMC::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_CRMC static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_CRMC::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].tmp2 = RNG::Ref().between(0, 4); } - -Element_CRMC::~Element_CRMC() {} - diff --git a/src/simulation/elements/DCEL.cpp b/src/simulation/elements/DCEL.cpp index 0dbea2db5..f23a52740 100644 --- a/src/simulation/elements/DCEL.cpp +++ b/src/simulation/elements/DCEL.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DCEL PT_DCEL 138 -Element_DCEL::Element_DCEL() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_DCEL() { Identifier = "DEFAULT_PT_DCEL"; Name = "DCEL"; @@ -40,12 +43,11 @@ Element_DCEL::Element_DCEL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_DCEL::update; - Graphics = &Element_DCEL::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_DCEL static int update(UPDATE_FUNC_ARGS) -int Element_DCEL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; float multiplier = 1.0f/1.1f; @@ -73,16 +75,9 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_DCEL static int graphics(GRAPHICS_FUNC_ARGS) -int Element_DCEL::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->tmp) *pixel_mode |= PMODE_GLOW; return 0; } - - -Element_DCEL::~Element_DCEL() {} diff --git a/src/simulation/elements/DESL.cpp b/src/simulation/elements/DESL.cpp index 6422dc598..bf3eee9d6 100644 --- a/src/simulation/elements/DESL.cpp +++ b/src/simulation/elements/DESL.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DESL PT_DESL 58 -Element_DESL::Element_DESL() + +void Element::Element_DESL() { Identifier = "DEFAULT_PT_DESL"; Name = "DESL"; @@ -39,8 +39,4 @@ Element_DESL::Element_DESL() LowTemperatureTransition = NT; HighTemperature = 335.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_DESL::~Element_DESL() {} diff --git a/src/simulation/elements/DEST.cpp b/src/simulation/elements/DEST.cpp index d772c6a0c..f7331e616 100644 --- a/src/simulation/elements/DEST.cpp +++ b/src/simulation/elements/DEST.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DEST PT_DEST 89 -Element_DEST::Element_DEST() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_DEST() { Identifier = "DEFAULT_PT_DEST"; Name = "DEST"; @@ -40,12 +43,11 @@ Element_DEST::Element_DEST() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_DEST::update; - Graphics = &Element_DEST::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_DEST static int update(UPDATE_FUNC_ARGS) -int Element_DEST::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int rx = RNG::Ref().between(-2, 2); int ry = RNG::Ref().between(-2, 2); @@ -90,10 +92,7 @@ int Element_DEST::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_DEST static int graphics(GRAPHICS_FUNC_ARGS) -int Element_DEST::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->life) { @@ -105,6 +104,3 @@ int Element_DEST::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_DEST::~Element_DEST() {} diff --git a/src/simulation/elements/DEUT.cpp b/src/simulation/elements/DEUT.cpp index 1e2926a84..748020cca 100644 --- a/src/simulation/elements/DEUT.cpp +++ b/src/simulation/elements/DEUT.cpp @@ -1,7 +1,10 @@ #include "simulation/ElementCommon.h" #include "common/tpt-minmax.h" -//#TPT-Directive ElementClass Element_DEUT PT_DEUT 95 -Element_DEUT::Element_DEUT() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_DEUT() { Identifier = "DEFAULT_PT_DEUT"; Name = "DEUT"; @@ -44,12 +47,11 @@ Element_DEUT::Element_DEUT() DefaultProperties.life = 10; - Update = &Element_DEUT::update; - Graphics = &Element_DEUT::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_DEUT static int update(UPDATE_FUNC_ARGS) -int Element_DEUT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, trade, np; float gravtot = fabs(sim->gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(sim->gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]); @@ -129,11 +131,7 @@ trade: return 0; } - - -//#TPT-Directive ElementHeader Element_DEUT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_DEUT::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->life>=240) { @@ -156,6 +154,3 @@ int Element_DEUT::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_DEUT::~Element_DEUT() {} diff --git a/src/simulation/elements/DLAY.cpp b/src/simulation/elements/DLAY.cpp index 346549e37..ea7f73efe 100644 --- a/src/simulation/elements/DLAY.cpp +++ b/src/simulation/elements/DLAY.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DLAY PT_DLAY 79 -Element_DLAY::Element_DLAY() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_DLAY() { Identifier = "DEFAULT_PT_DLAY"; Name = "DLAY"; @@ -41,12 +44,11 @@ Element_DLAY::Element_DLAY() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_DLAY::update; - Graphics = &Element_DLAY::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_DLAY static int update(UPDATE_FUNC_ARGS) -int Element_DLAY::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, oldl; oldl = parts[i].life; @@ -92,10 +94,7 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_DLAY static int graphics(GRAPHICS_FUNC_ARGS) -int Element_DLAY::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f); *colr += stage; @@ -103,6 +102,3 @@ int Element_DLAY::graphics(GRAPHICS_FUNC_ARGS) *colb += stage; return 0; } - - -Element_DLAY::~Element_DLAY() {} diff --git a/src/simulation/elements/DMG.cpp b/src/simulation/elements/DMG.cpp index ba9aa1c91..86af71246 100644 --- a/src/simulation/elements/DMG.cpp +++ b/src/simulation/elements/DMG.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DMG PT_DMG 163 -Element_DMG::Element_DMG() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_DMG() { Identifier = "DEFAULT_PT_DMG"; Name = "DMG"; @@ -41,12 +44,11 @@ Element_DMG::Element_DMG() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_DMG::update; - Graphics = &Element_DMG::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_DMG static int update(UPDATE_FUNC_ARGS) -int Element_DMG::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rr, rx, ry, nxi, nxj, t, dist; int rad = 25; @@ -107,14 +109,8 @@ int Element_DMG::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_DMG static int graphics(GRAPHICS_FUNC_ARGS) -int Element_DMG::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *pixel_mode |= PMODE_FLARE; return 1; } - - -Element_DMG::~Element_DMG() {} diff --git a/src/simulation/elements/DMND.cpp b/src/simulation/elements/DMND.cpp index 08713fd12..291e9d44e 100644 --- a/src/simulation/elements/DMND.cpp +++ b/src/simulation/elements/DMND.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DMND PT_DMND 28 -Element_DMND::Element_DMND() + +void Element::Element_DMND() { Identifier = "DEFAULT_PT_DMND"; Name = "DMND"; @@ -39,8 +39,4 @@ Element_DMND::Element_DMND() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_DMND::~Element_DMND() {} diff --git a/src/simulation/elements/DRAY.cpp b/src/simulation/elements/DRAY.cpp index 2987cc6a4..c543919e7 100644 --- a/src/simulation/elements/DRAY.cpp +++ b/src/simulation/elements/DRAY.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DRAY PT_DRAY 178 -Element_DRAY::Element_DRAY() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_DRAY() { Identifier = "DEFAULT_PT_DRAY"; Name = "DRAY"; @@ -40,19 +42,18 @@ Element_DRAY::Element_DRAY() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_DRAY::update; - Graphics = nullptr; + Update = &update; + Graphics = nullptr; // is this needed? CtypeDraw = &Element::ctypeDrawVInCtype; } //should probably be in Simulation.h -bool InBounds(int x, int y) +static bool InBounds(int x, int y) { return (x>=0 && y>=0 && x 25) parts[i].tmp2 = rd = 25; @@ -117,7 +118,3 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS) } return 0; } - - - -Element_DTEC::~Element_DTEC() {} diff --git a/src/simulation/elements/DUST.cpp b/src/simulation/elements/DUST.cpp index 6f917c7fa..3a43c7463 100644 --- a/src/simulation/elements/DUST.cpp +++ b/src/simulation/elements/DUST.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DUST PT_DUST 1 -Element_DUST::Element_DUST() + +void Element::Element_DUST() { Identifier = "DEFAULT_PT_DUST"; Name = "DUST"; @@ -41,8 +41,5 @@ Element_DUST::Element_DUST() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Graphics = NULL; + Graphics = NULL; // it this needed? } - -Element_DUST::~Element_DUST() {} diff --git a/src/simulation/elements/DYST.cpp b/src/simulation/elements/DYST.cpp index 9bd70d8d8..0530a1d47 100644 --- a/src/simulation/elements/DYST.cpp +++ b/src/simulation/elements/DYST.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_DYST PT_DYST 64 -Element_DYST::Element_DYST() + +void Element::Element_DYST() { Identifier = "DEFAULT_PT_DYST"; Name = "DYST"; @@ -39,8 +39,4 @@ Element_DYST::Element_DYST() LowTemperatureTransition = NT; HighTemperature = 473.0f; HighTemperatureTransition = PT_DUST; - - Update = NULL; } - -Element_DYST::~Element_DYST() {} diff --git a/src/simulation/elements/116.cpp b/src/simulation/elements/E116.cpp similarity index 85% rename from src/simulation/elements/116.cpp rename to src/simulation/elements/E116.cpp index d199c1d25..a05476e49 100644 --- a/src/simulation/elements/116.cpp +++ b/src/simulation/elements/E116.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_116 PT_116 116 -Element_116::Element_116() + +void Element::Element_E116() { Identifier = "DEFAULT_PT_116"; Name = "EQVE"; @@ -39,8 +39,4 @@ Element_116::Element_116() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_116::~Element_116() {} diff --git a/src/simulation/elements/146.cpp b/src/simulation/elements/E146.cpp similarity index 85% rename from src/simulation/elements/146.cpp rename to src/simulation/elements/E146.cpp index b9108d4ec..315e2cc7b 100644 --- a/src/simulation/elements/146.cpp +++ b/src/simulation/elements/E146.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_146 PT_146 146 -Element_146::Element_146() + +void Element::Element_E146() { Identifier = "DEFAULT_PT_146"; Name = "BRAN"; @@ -40,8 +40,4 @@ Element_146::Element_146() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_146::~Element_146() {} diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp index a384d3f72..f4d9a687a 100644 --- a/src/simulation/elements/ELEC.cpp +++ b/src/simulation/elements/ELEC.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ELEC PT_ELEC 136 -Element_ELEC::Element_ELEC() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_ELEC() { Identifier = "DEFAULT_PT_ELEC"; Name = "ELEC"; @@ -41,13 +45,12 @@ Element_ELEC::Element_ELEC() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_ELEC::update; - Graphics = &Element_ELEC::graphics; - Create = &Element_ELEC::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_ELEC static int update(UPDATE_FUNC_ARGS) -int Element_ELEC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rt, rx, ry, nb, rrx, rry; for (rx=-2; rx<=2; rx++) @@ -123,9 +126,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_ELEC static int graphics(GRAPHICS_FUNC_ARGS) -int Element_ELEC::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 70; *firer = *colr; @@ -136,13 +137,10 @@ int Element_ELEC::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_ELEC static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_ELEC::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f; sim->parts[i].life = 680; sim->parts[i].vx = 2.0f * cosf(a); sim->parts[i].vy = 2.0f * sinf(a); } - -Element_ELEC::~Element_ELEC() {} diff --git a/src/simulation/elements/EMBR.cpp b/src/simulation/elements/EMBR.cpp index 22cbba78c..a1a340712 100644 --- a/src/simulation/elements/EMBR.cpp +++ b/src/simulation/elements/EMBR.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_EMBR PT_EMBR 147 -Element_EMBR::Element_EMBR() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_EMBR() { Identifier = "DEFAULT_PT_EMBR"; Name = "EMBR"; @@ -43,12 +46,12 @@ Element_EMBR::Element_EMBR() DefaultProperties.life = 50; - Update = &Element_EMBR::update; - Graphics = &Element_EMBR::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_EMBR static int update(UPDATE_FUNC_ARGS) -int Element_EMBR::update(UPDATE_FUNC_ARGS) { +static int update(UPDATE_FUNC_ARGS) +{ int r, rx, ry; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) @@ -66,8 +69,7 @@ int Element_EMBR::update(UPDATE_FUNC_ARGS) { return 0; } -//#TPT-Directive ElementHeader Element_EMBR static int graphics(GRAPHICS_FUNC_ARGS) -int Element_EMBR::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { if (cpart->ctype&0xFFFFFF) { @@ -120,5 +122,3 @@ int Element_EMBR::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_EMBR::~Element_EMBR() {} diff --git a/src/simulation/elements/EMP.cpp b/src/simulation/elements/EMP.cpp index ba1aa2416..8a9a67978 100644 --- a/src/simulation/elements/EMP.cpp +++ b/src/simulation/elements/EMP.cpp @@ -1,8 +1,9 @@ #include "simulation/ElementCommon.h" #include "Probability.h" -//#TPT-Directive ElementClass Element_EMP PT_EMP 134 -Element_EMP::Element_EMP() +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_EMP() { Identifier = "DEFAULT_PT_EMP"; Name = "EMP"; @@ -42,8 +43,7 @@ Element_EMP::Element_EMP() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Graphics = &Element_EMP::graphics; + Graphics = &graphics; } class DeltaTempGenerator @@ -70,8 +70,7 @@ public: } }; -//#TPT-Directive ElementHeader Element_EMP static int Trigger(Simulation *sim, int triggerCount) -int Element_EMP::Trigger(Simulation *sim, int triggerCount) +void Element_EMP_Trigger(Simulation *sim, int triggerCount) { /* Known differences from original one-particle-at-a-time version: * - SPRK that disappears during a frame (such as SPRK with life==0 on that frame) will not cause destruction around it. @@ -205,13 +204,9 @@ int Element_EMP::Trigger(Simulation *sim, int triggerCount) } } } - return 0; } - -//#TPT-Directive ElementHeader Element_EMP static int graphics(GRAPHICS_FUNC_ARGS) -int Element_EMP::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->life) { @@ -221,6 +216,3 @@ int Element_EMP::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_EMP::~Element_EMP() {} diff --git a/src/simulation/elements/ETRD.cpp b/src/simulation/elements/ETRD.cpp index 4dcfdfe98..37903ca07 100644 --- a/src/simulation/elements/ETRD.cpp +++ b/src/simulation/elements/ETRD.cpp @@ -1,8 +1,10 @@ #include #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ETRD PT_ETRD 50 -Element_ETRD::Element_ETRD() +static void initDeltaPos(); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); + +void Element::Element_ETRD() { Identifier = "DEFAULT_PT_ETRD"; Name = "ETRD"; @@ -42,14 +44,12 @@ Element_ETRD::Element_ETRD() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - ChangeType = &Element_ETRD::changeType; + ChangeType = &changeType; - Element_ETRD::initDeltaPos(); + initDeltaPos(); } -//#TPT-Directive ElementHeader Element_ETRD static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_ETRD::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (sim->etrd_count_valid) { @@ -77,13 +77,7 @@ public: const int maxLength = 12; std::vector deltaPos; -bool compareFunc(const ETRD_deltaWithLength &a, const ETRD_deltaWithLength &b) -{ - return a.length < b.length; -} - -//#TPT-Directive ElementHeader Element_ETRD static void initDeltaPos() -void Element_ETRD::initDeltaPos() +static void initDeltaPos() { deltaPos.clear(); for (int ry = -maxLength; ry <= maxLength; ry++) @@ -93,11 +87,12 @@ void Element_ETRD::initDeltaPos() if (std::abs(d.X) + std::abs(d.Y) <= maxLength) deltaPos.push_back(ETRD_deltaWithLength(d, std::abs(d.X) + std::abs(d.Y))); } - std::stable_sort(deltaPos.begin(), deltaPos.end(), compareFunc); + std::stable_sort(deltaPos.begin(), deltaPos.end(), [](const ETRD_deltaWithLength &a, const ETRD_deltaWithLength &b) { + return a.length < b.length; + }); } -//#TPT-Directive ElementHeader Element_ETRD static int nearestSparkablePart(Simulation *sim, int targetId) -int Element_ETRD::nearestSparkablePart(Simulation *sim, int targetId) +int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId) { if (!sim->elementCount[PT_ETRD]) return -1; @@ -180,5 +175,3 @@ int Element_ETRD::nearestSparkablePart(Simulation *sim, int targetId) } return foundI; } - -Element_ETRD::~Element_ETRD() {} diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp index 4a4dd6c47..5665ae92a 100644 --- a/src/simulation/elements/EXOT.cpp +++ b/src/simulation/elements/EXOT.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_EXOT PT_EXOT 145 -Element_EXOT::Element_EXOT() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_EXOT() { Identifier = "DEFAULT_PT_EXOT"; Name = "EXOT"; @@ -44,12 +47,11 @@ Element_EXOT::Element_EXOT() DefaultProperties.life = 1000; DefaultProperties.tmp = 244; - Update = &Element_EXOT::update; - Graphics = &Element_EXOT::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS) -int Element_EXOT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rt, rx, ry, trade, tym; for (rx=-2; rx<=2; rx++) @@ -178,11 +180,9 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) parts[i].tmp--; } return 0; - } -//#TPT-Directive ElementHeader Element_EXOT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_EXOT::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int q = cpart->temp; int b = cpart->tmp; @@ -237,5 +237,3 @@ int Element_EXOT::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_EXOT::~Element_EXOT() {} diff --git a/src/simulation/elements/FIGH.cpp b/src/simulation/elements/FIGH.cpp index b08600b0e..3d3a3cdc2 100644 --- a/src/simulation/elements/FIGH.cpp +++ b/src/simulation/elements/FIGH.cpp @@ -1,6 +1,17 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FIGH PT_FIGH 158 -Element_FIGH::Element_FIGH() + +static int update(UPDATE_FUNC_ARGS); +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); +static void Free(Simulation *sim, unsigned char i); +bool Element_FIGH_CanAlloc(Simulation *sim); +int Element_FIGH_Alloc(Simulation *sim); +void Element_FIGH_NewFighter(Simulation *sim, int fighterID, int i, int elem); +int Element_STKM_graphics(GRAPHICS_FUNC_ARGS); +void Element_STKM_init_legs(Simulation * sim, playerst *playerp, int i); +int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS); + +void Element::Element_FIGH() { Identifier = "DEFAULT_PT_FIGH"; Name = "FIGH"; @@ -44,14 +55,13 @@ Element_FIGH::Element_FIGH() DefaultProperties.life = 100; - Update = &Element_FIGH::update; - Graphics = &Element_STKM::graphics; - CreateAllowed = &Element_FIGH::createAllowed; - ChangeType = &Element_FIGH::changeType; + Update = &update; + Graphics = &Element_STKM_graphics; + CreateAllowed = &createAllowed; + ChangeType = &changeType; } -//#TPT-Directive ElementHeader Element_FIGH static int update(UPDATE_FUNC_ARGS) -int Element_FIGH::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].tmp < 0 || parts[i].tmp >= MAX_FIGHTERS) { @@ -141,24 +151,22 @@ int Element_FIGH::update(UPDATE_FUNC_ARGS) figh->pcomm = figh->comm; - Element_STKM::run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS); + Element_STKM_run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS); return 0; } -//#TPT-Directive ElementHeader Element_FIGH static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) -bool Element_FIGH::createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) { - return CanAlloc(sim); + return Element_FIGH_CanAlloc(sim); } -//#TPT-Directive ElementHeader Element_FIGH static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_FIGH::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (to == PT_FIGH) { - sim->parts[i].tmp = Alloc(sim); + sim->parts[i].tmp = Element_FIGH_Alloc(sim); if (sim->parts[i].tmp >= 0) - NewFighter(sim, sim->parts[i].tmp, i, PT_DUST); + Element_FIGH_NewFighter(sim, sim->parts[i].tmp, i, PT_DUST); } else { @@ -166,14 +174,12 @@ void Element_FIGH::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) } } -//#TPT-Directive ElementHeader Element_FIGH static bool CanAlloc(Simulation *sim) -bool Element_FIGH::CanAlloc(Simulation *sim) +bool Element_FIGH_CanAlloc(Simulation *sim) { return sim->fighcount < MAX_FIGHTERS; } -//#TPT-Directive ElementHeader Element_FIGH static int Alloc(Simulation *sim) -int Element_FIGH::Alloc(Simulation *sim) +int Element_FIGH_Alloc(Simulation *sim) { if (sim->fighcount >= MAX_FIGHTERS) return -1; @@ -190,8 +196,7 @@ int Element_FIGH::Alloc(Simulation *sim) else return -1; } -//#TPT-Directive ElementHeader Element_FIGH static void Free(Simulation *sim, unsigned char i) -void Element_FIGH::Free(Simulation *sim, unsigned char i) +static void Free(Simulation *sim, unsigned char i) { if (sim->fighters[i].spwn) { @@ -200,13 +205,10 @@ void Element_FIGH::Free(Simulation *sim, unsigned char i) } } -//#TPT-Directive ElementHeader Element_FIGH static void NewFighter(Simulation *sim, int fighterID, int i, int elem) -void Element_FIGH::NewFighter(Simulation *sim, int fighterID, int i, int elem) +void Element_FIGH_NewFighter(Simulation *sim, int fighterID, int i, int elem) { - Element_STKM::STKM_init_legs(sim, &sim->fighters[fighterID], i); + Element_STKM_init_legs(sim, &sim->fighters[fighterID], i); if (elem >= 0 && elem < PT_NUM) sim->fighters[fighterID].elem = elem; sim->fighters[fighterID].spwn = 1; } - -Element_FIGH::~Element_FIGH() {} diff --git a/src/simulation/elements/FILT.cpp b/src/simulation/elements/FILT.cpp index 7cc1c57a1..c377396db 100644 --- a/src/simulation/elements/FILT.cpp +++ b/src/simulation/elements/FILT.cpp @@ -1,6 +1,11 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FILT PT_FILT 125 -Element_FILT::Element_FILT() + +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +int Element_FILT_interactWavelengths(Particle* cpart, int origWl); +int Element_FILT_getWavelengths(Particle* cpart); + +void Element::Element_FILT() { Identifier = "DEFAULT_PT_FILT"; Name = "FILT"; @@ -40,15 +45,13 @@ Element_FILT::Element_FILT() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Graphics = &Element_FILT::graphics; - Create = &Element_FILT::create; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_FILT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_FILT::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { - int x, wl = Element_FILT::getWavelengths(cpart); + int x, wl = Element_FILT_getWavelengths(cpart); *colg = 0; *colb = 0; *colr = 0; @@ -71,19 +74,17 @@ int Element_FILT::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_FILT static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_FILT::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].tmp = v; } -//#TPT-Directive ElementHeader Element_FILT static int interactWavelengths(Particle* cpart, int origWl) // Returns the wavelengths in a particle after FILT interacts with it (e.g. a photon) // cpart is the FILT particle, origWl the original wavelengths in the interacting particle -int Element_FILT::interactWavelengths(Particle* cpart, int origWl) +int Element_FILT_interactWavelengths(Particle* cpart, int origWl) { const int mask = 0x3FFFFFFF; - int filtWl = getWavelengths(cpart); + int filtWl = Element_FILT_getWavelengths(cpart); switch (cpart->tmp) { case 0: @@ -134,8 +135,7 @@ int Element_FILT::interactWavelengths(Particle* cpart, int origWl) } } -//#TPT-Directive ElementHeader Element_FILT static int getWavelengths(Particle* cpart) -int Element_FILT::getWavelengths(Particle* cpart) +int Element_FILT_getWavelengths(Particle* cpart) { if (cpart->ctype&0x3FFFFFFF) { @@ -149,5 +149,3 @@ int Element_FILT::getWavelengths(Particle* cpart) return (0x1F << temp_bin); } } - -Element_FILT::~Element_FILT() {} diff --git a/src/simulation/elements/FIRE.cpp b/src/simulation/elements/FIRE.cpp index 1dade6908..30364f60e 100644 --- a/src/simulation/elements/FIRE.cpp +++ b/src/simulation/elements/FIRE.cpp @@ -1,8 +1,12 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FIRE PT_FIRE 4 -Element_FIRE::Element_FIRE() +int Element_FIRE_update(UPDATE_FUNC_ARGS); +static int updateLegacy(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_FIRE() { Identifier = "DEFAULT_PT_FIRE"; Name = "FIRE"; @@ -43,13 +47,12 @@ Element_FIRE::Element_FIRE() HighTemperature = 2773.0f; HighTemperatureTransition = PT_PLSM; - Update = &Element_FIRE::update; - Graphics = &Element_FIRE::graphics; - Create = &Element_FIRE::create; + Update = &Element_FIRE_update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_FIRE static int update(UPDATE_FUNC_ARGS) -int Element_FIRE::update(UPDATE_FUNC_ARGS) +int Element_FIRE_update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt, t = parts[i].type; switch (t) @@ -173,8 +176,8 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_FIRE static int updateLegacy(UPDATE_FUNC_ARGS) -int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) { +static int updateLegacy(UPDATE_FUNC_ARGS) +{ int r, rx, ry, rt, lpv, t = parts[i].type; for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) @@ -246,9 +249,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) { return 0; } - -//#TPT-Directive ElementHeader Element_FIRE static int graphics(GRAPHICS_FUNC_ARGS) -int Element_FIRE::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)ren->flm_data[caddress]; @@ -266,10 +267,7 @@ int Element_FIRE::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_FIRE static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_FIRE::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].life = RNG::Ref().between(120, 169); } - -Element_FIRE::~Element_FIRE() {} diff --git a/src/simulation/elements/FIRW.cpp b/src/simulation/elements/FIRW.cpp index 0e3cbed5b..6135f3fd3 100644 --- a/src/simulation/elements/FIRW.cpp +++ b/src/simulation/elements/FIRW.cpp @@ -1,7 +1,10 @@ #include "simulation/ElementCommon.h" #include "hmap.h" -//#TPT-Directive ElementClass Element_FIRW PT_FIRW 69 -Element_FIRW::Element_FIRW() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_FIRW() { Identifier = "DEFAULT_PT_FIRW"; Name = "FIRW"; @@ -41,12 +44,11 @@ Element_FIRW::Element_FIRW() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_FIRW::update; - Graphics = &Element_FIRW::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_FIRW static int update(UPDATE_FUNC_ARGS) -int Element_FIRW::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt, np; if (parts[i].tmp<=0) { @@ -113,10 +115,7 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_FIRW static int graphics(GRAPHICS_FUNC_ARGS) -int Element_FIRW::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->tmp > 0) { @@ -124,6 +123,3 @@ int Element_FIRW::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_FIRW::~Element_FIRW() {} diff --git a/src/simulation/elements/FOG.cpp b/src/simulation/elements/FOG.cpp index 8a84aa688..9b655e1f7 100644 --- a/src/simulation/elements/FOG.cpp +++ b/src/simulation/elements/FOG.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FOG PT_FOG 92 -Element_FOG::Element_FOG() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FOG() { Identifier = "DEFAULT_PT_FOG"; Name = "FOG"; @@ -41,11 +43,10 @@ Element_FOG::Element_FOG() HighTemperature = 373.15f; HighTemperatureTransition = PT_WTRV; - Update = &Element_FOG::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FOG static int update(UPDATE_FUNC_ARGS) -int Element_FOG::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -66,6 +67,3 @@ int Element_FOG::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_FOG::~Element_FOG() {} diff --git a/src/simulation/elements/FRAY.cpp b/src/simulation/elements/FRAY.cpp index 9d979f138..0a678143e 100644 --- a/src/simulation/elements/FRAY.cpp +++ b/src/simulation/elements/FRAY.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FRAY PT_FRAY 159 -Element_FRAY::Element_FRAY() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FRAY() { Identifier = "DEFAULT_PT_FRAY"; Name = "FRAY"; @@ -41,11 +43,10 @@ Element_FRAY::Element_FRAY() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_FRAY::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FRAY static int update(UPDATE_FUNC_ARGS) -int Element_FRAY::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int curlen; if (parts[i].tmp > 0) @@ -77,6 +78,3 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_FRAY::~Element_FRAY() {} diff --git a/src/simulation/elements/FRME.cpp b/src/simulation/elements/FRME.cpp index ccdeee5bf..0f09ced90 100644 --- a/src/simulation/elements/FRME.cpp +++ b/src/simulation/elements/FRME.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FRME PT_FRME 169 -Element_FRME::Element_FRME() + +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_FRME() { Identifier = "DEFAULT_PT_FRME"; Name = "FRME"; @@ -40,11 +42,10 @@ Element_FRME::Element_FRME() HighTemperature = ITH; HighTemperatureTransition = NT; - Graphics = &Element_FRME::graphics; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_FRME static int graphics(GRAPHICS_FUNC_ARGS) -int Element_FRME::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->tmp) { @@ -54,5 +55,3 @@ int Element_FRME::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_FRME::~Element_FRME() {} diff --git a/src/simulation/elements/FRZW.cpp b/src/simulation/elements/FRZW.cpp index 4fdb21dd9..a5306bbae 100644 --- a/src/simulation/elements/FRZW.cpp +++ b/src/simulation/elements/FRZW.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FRZW PT_FRZW 101 -Element_FRZW::Element_FRZW() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FRZW() { Identifier = "DEFAULT_PT_FRZW"; Name = "FRZW"; @@ -43,11 +45,10 @@ Element_FRZW::Element_FRZW() DefaultProperties.life = 100; - Update = &Element_FRZW::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FRZW static int update(UPDATE_FUNC_ARGS) -int Element_FRZW::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -70,6 +71,3 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_FRZW::~Element_FRZW() {} diff --git a/src/simulation/elements/FRZZ.cpp b/src/simulation/elements/FRZZ.cpp index 484b254b1..2cafa88f9 100644 --- a/src/simulation/elements/FRZZ.cpp +++ b/src/simulation/elements/FRZZ.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FRZZ PT_FRZZ 100 -Element_FRZZ::Element_FRZZ() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FRZZ() { Identifier = "DEFAULT_PT_FRZZ"; Name = "FRZZ"; @@ -41,11 +43,10 @@ Element_FRZZ::Element_FRZZ() HighTemperature = 273.15; HighTemperatureTransition = PT_FRZW; - Update = &Element_FRZZ::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FRZZ static int update(UPDATE_FUNC_ARGS) -int Element_FRZZ::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -65,6 +66,3 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_FRZZ::~Element_FRZZ() {} diff --git a/src/simulation/elements/FSEP.cpp b/src/simulation/elements/FSEP.cpp index 2c288d61e..e5d7b6b3b 100644 --- a/src/simulation/elements/FSEP.cpp +++ b/src/simulation/elements/FSEP.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FSEP PT_FSEP 71 -Element_FSEP::Element_FSEP() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FSEP() { Identifier = "DEFAULT_PT_FSEP"; Name = "FSEP"; @@ -42,11 +44,10 @@ Element_FSEP::Element_FSEP() DefaultProperties.life = 50; - Update = &Element_FSEP::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FSEP static int update(UPDATE_FUNC_ARGS) -int Element_FSEP::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life<=0) { @@ -79,6 +80,3 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_FSEP::~Element_FSEP() {} diff --git a/src/simulation/elements/FUSE.cpp b/src/simulation/elements/FUSE.cpp index 27278d656..4d00aecaa 100644 --- a/src/simulation/elements/FUSE.cpp +++ b/src/simulation/elements/FUSE.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FUSE PT_FUSE 70 -Element_FUSE::Element_FUSE() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FUSE() { Identifier = "DEFAULT_PT_FUSE"; Name = "FUSE"; @@ -43,11 +45,10 @@ Element_FUSE::Element_FUSE() DefaultProperties.life = 50; DefaultProperties.tmp = 50; - Update = &Element_FUSE::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FUSE static int update(UPDATE_FUNC_ARGS) -int Element_FUSE::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life<=0) { @@ -88,6 +89,3 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_FUSE::~Element_FUSE() {} diff --git a/src/simulation/elements/FWRK.cpp b/src/simulation/elements/FWRK.cpp index cb6f73320..34165217e 100644 --- a/src/simulation/elements/FWRK.cpp +++ b/src/simulation/elements/FWRK.cpp @@ -1,8 +1,9 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_FWRK PT_FWRK 98 -Element_FWRK::Element_FWRK() +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_FWRK() { Identifier = "DEFAULT_PT_FWRK"; Name = "FWRK"; @@ -42,11 +43,10 @@ Element_FWRK::Element_FWRK() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_FWRK::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_FWRK static int update(UPDATE_FUNC_ARGS) -int Element_FWRK::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && RNG::Ref().chance(9+parts[i].temp/40, 100000)) || parts[i].ctype == PT_DUST)) { @@ -112,6 +112,3 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS) parts[i].life=0; return 0; } - - -Element_FWRK::~Element_FWRK() {} diff --git a/src/simulation/elements/GAS.cpp b/src/simulation/elements/GAS.cpp index 1a5e33bfd..2c68e6039 100644 --- a/src/simulation/elements/GAS.cpp +++ b/src/simulation/elements/GAS.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GAS PT_GAS 10 -Element_GAS::Element_GAS() + +void Element::Element_GAS() { Identifier = "DEFAULT_PT_GAS"; Name = "GAS"; @@ -40,8 +40,4 @@ Element_GAS::Element_GAS() LowTemperatureTransition = NT; HighTemperature = 573.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_GAS::~Element_GAS() {} diff --git a/src/simulation/elements/GBMB.cpp b/src/simulation/elements/GBMB.cpp index 50e3324df..b99c9678e 100644 --- a/src/simulation/elements/GBMB.cpp +++ b/src/simulation/elements/GBMB.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GBMB PT_GBMB 157 -Element_GBMB::Element_GBMB() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_GBMB() { Identifier = "DEFAULT_PT_GBMB"; Name = "GBMB"; @@ -41,12 +44,11 @@ Element_GBMB::Element_GBMB() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_GBMB::update; - Graphics = &Element_GBMB::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_GBMB static int update(UPDATE_FUNC_ARGS) -int Element_GBMB::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int rx,ry,r; if (parts[i].life<=0) @@ -76,10 +78,7 @@ int Element_GBMB::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_GBMB static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GBMB::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if (cpart->life <= 0) { *pixel_mode |= PMODE_FLARE; @@ -90,6 +89,3 @@ int Element_GBMB::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_GBMB::~Element_GBMB() {} diff --git a/src/simulation/elements/GEL.cpp b/src/simulation/elements/GEL.cpp index ac72a1f8e..bf4c7f0e6 100644 --- a/src/simulation/elements/GEL.cpp +++ b/src/simulation/elements/GEL.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GEL PT_GEL 142 -Element_GEL::Element_GEL() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_GEL() { Identifier = "DEFAULT_PT_GEL"; Name = "GEL"; @@ -41,12 +44,11 @@ Element_GEL::Element_GEL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_GEL::update; - Graphics = &Element_GEL::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_GEL static int update(UPDATE_FUNC_ARGS) -int Element_GEL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; bool gel; @@ -151,11 +153,7 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_GEL static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GEL::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int q = cpart->tmp; *colr = q*(32-255)/120+255; @@ -164,7 +162,3 @@ int Element_GEL::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_BLUR; return 0; } - - - -Element_GEL::~Element_GEL() {} diff --git a/src/simulation/elements/GLAS.cpp b/src/simulation/elements/GLAS.cpp index b430276c8..3f8f2cbac 100644 --- a/src/simulation/elements/GLAS.cpp +++ b/src/simulation/elements/GLAS.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GLAS PT_GLAS 45 -Element_GLAS::Element_GLAS() + +static int update(UPDATE_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_GLAS() { Identifier = "DEFAULT_PT_GLAS"; Name = "GLAS"; @@ -40,12 +43,11 @@ Element_GLAS::Element_GLAS() HighTemperature = 1973.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_GLAS::update; - Create = &Element_GLAS::create; + Update = &update; + Create = &create; } -//#TPT-Directive ElementHeader Element_GLAS static int update(UPDATE_FUNC_ARGS) -int Element_GLAS::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { parts[i].pavg[0] = parts[i].pavg[1]; parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; @@ -57,10 +59,7 @@ int Element_GLAS::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_GLAS static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_GLAS::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; } - -Element_GLAS::~Element_GLAS() {} diff --git a/src/simulation/elements/GLOW.cpp b/src/simulation/elements/GLOW.cpp index da22a7907..ac03a3f13 100644 --- a/src/simulation/elements/GLOW.cpp +++ b/src/simulation/elements/GLOW.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GLOW PT_GLOW 66 -Element_GLOW::Element_GLOW() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_GLOW() { Identifier = "DEFAULT_PT_GLOW"; Name = "GLOW"; @@ -41,12 +44,11 @@ Element_GLOW::Element_GLOW() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_GLOW::update; - Graphics = &Element_GLOW::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_GLOW static int update(UPDATE_FUNC_ARGS) -int Element_GLOW::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -70,10 +72,7 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_GLOW static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GLOW::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f; *fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f; @@ -86,6 +85,3 @@ int Element_GLOW::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_ADD; return 0; } - - -Element_GLOW::~Element_GLOW() {} diff --git a/src/simulation/elements/GOLD.cpp b/src/simulation/elements/GOLD.cpp index 4ad1af7ef..3908bba13 100644 --- a/src/simulation/elements/GOLD.cpp +++ b/src/simulation/elements/GOLD.cpp @@ -1,7 +1,10 @@ #include "simulation/ElementCommon.h" #include "simulation/Air.h" -//#TPT-Directive ElementClass Element_GOLD PT_GOLD 170 -Element_GOLD::Element_GOLD() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_GOLD() { Identifier = "DEFAULT_PT_GOLD"; Name = "GOLD"; @@ -42,12 +45,11 @@ Element_GOLD::Element_GOLD() HighTemperature = 1337.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_GOLD::update; - Graphics = &Element_GOLD::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_GOLD static int update(UPDATE_FUNC_ARGS) -int Element_GOLD::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int rx, ry, r, rndstore; static int checkCoordsX[] = { -4, 4, 0, 0 }; @@ -96,8 +98,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_GOLD static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GOLD::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int rndstore = RNG::Ref().gen(); *colr += (rndstore % 10) - 5; @@ -107,5 +108,3 @@ int Element_GOLD::graphics(GRAPHICS_FUNC_ARGS) *colb += (rndstore % 10) - 5; return 0; } - -Element_GOLD::~Element_GOLD() {} diff --git a/src/simulation/elements/GOO.cpp b/src/simulation/elements/GOO.cpp index 17f956f7b..2916c9ba0 100644 --- a/src/simulation/elements/GOO.cpp +++ b/src/simulation/elements/GOO.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GOO PT_GOO 12 -Element_GOO::Element_GOO() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_GOO() { Identifier = "DEFAULT_PT_GOO"; Name = "GOO"; @@ -41,13 +43,12 @@ Element_GOO::Element_GOO() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_GOO::update; + Update = &update; } -#define ADVECTION 0.1f +constexpr float ADVECTION = 0.1f; -//#TPT-Directive ElementHeader Element_GOO static int update(UPDATE_FUNC_ARGS) -int Element_GOO::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f) parts[i].life = RNG::Ref().between(300, 379); @@ -58,6 +59,3 @@ int Element_GOO::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_GOO::~Element_GOO() {} diff --git a/src/simulation/elements/GPMP.cpp b/src/simulation/elements/GPMP.cpp index 5c28cf12d..845baa9b2 100644 --- a/src/simulation/elements/GPMP.cpp +++ b/src/simulation/elements/GPMP.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GPMP PT_GPMP 154 -Element_GPMP::Element_GPMP() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_GPMP() { Identifier = "DEFAULT_PT_GPMP"; Name = "GPMP"; @@ -42,12 +45,11 @@ Element_GPMP::Element_GPMP() DefaultProperties.life = 10; - Update = &Element_GPMP::update; - Graphics = &Element_GPMP::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_GPMP static int update(UPDATE_FUNC_ARGS) -int Element_GPMP::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life!=10) @@ -82,16 +84,10 @@ int Element_GPMP::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_GPMP static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GPMP::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int lifemod = ((cpart->life>10?10:cpart->life)*19); *colg += lifemod; *colb += lifemod; return 0; } - - -Element_GPMP::~Element_GPMP() {} diff --git a/src/simulation/elements/GRAV.cpp b/src/simulation/elements/GRAV.cpp index c854a8be3..51bc907bd 100644 --- a/src/simulation/elements/GRAV.cpp +++ b/src/simulation/elements/GRAV.cpp @@ -1,8 +1,10 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GRAV PT_GRAV 102 -Element_GRAV::Element_GRAV() +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_GRAV() { Identifier = "DEFAULT_PT_GRAV"; Name = "GRAV"; @@ -42,12 +44,11 @@ Element_GRAV::Element_GRAV() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_GRAV::update; - Graphics = &Element_GRAV::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS) -int Element_GRAV::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && RNG::Ref().chance(1, 512)) { @@ -58,8 +59,7 @@ int Element_GRAV::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_GRAV static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2; @@ -115,6 +115,3 @@ int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) return 0; } - - -Element_GRAV::~Element_GRAV() {} diff --git a/src/simulation/elements/GRVT.cpp b/src/simulation/elements/GRVT.cpp index 64799463d..c12e90898 100644 --- a/src/simulation/elements/GRVT.cpp +++ b/src/simulation/elements/GRVT.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GRVT PT_GRVT 177 -Element_GRVT::Element_GRVT() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_GRVT() { Identifier = "DEFAULT_PT_GRVT"; Name = "GRVT"; @@ -42,13 +46,12 @@ Element_GRVT::Element_GRVT() DefaultProperties.tmp = 7; - Update = &Element_GRVT::update; - Graphics = &Element_GRVT::graphics; - Create = &Element_GRVT::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_GRVT static int update(UPDATE_FUNC_ARGS) -int Element_GRVT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { //at higher tmps they just go completely insane if (parts[i].tmp >= 100) @@ -60,8 +63,7 @@ int Element_GRVT::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_GRVT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_GRVT::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 5; *firer = 0; @@ -72,13 +74,10 @@ int Element_GRVT::graphics(GRAPHICS_FUNC_ARGS) return 1; } -//#TPT-Directive ElementHeader Element_GRVT static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_GRVT::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f; sim->parts[i].life = 250 + RNG::Ref().between(0, 199); sim->parts[i].vx = 2.0f*cosf(a); sim->parts[i].vy = 2.0f*sinf(a); } - -Element_GRVT::~Element_GRVT() {} diff --git a/src/simulation/elements/GUNP.cpp b/src/simulation/elements/GUNP.cpp index 9379237cb..63cbe96ce 100644 --- a/src/simulation/elements/GUNP.cpp +++ b/src/simulation/elements/GUNP.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_GUNP PT_GUNP 7 -Element_GUNP::Element_GUNP() + +void Element::Element_GUNP() { Identifier = "DEFAULT_PT_GUNP"; Name = "GUN"; @@ -39,8 +39,4 @@ Element_GUNP::Element_GUNP() LowTemperatureTransition = NT; HighTemperature = 673.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_GUNP::~Element_GUNP() {} diff --git a/src/simulation/elements/H2.cpp b/src/simulation/elements/H2.cpp index c8038008d..35004ae59 100644 --- a/src/simulation/elements/H2.cpp +++ b/src/simulation/elements/H2.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_H2 PT_H2 148 -Element_H2::Element_H2() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_H2() { Identifier = "DEFAULT_PT_H2"; Name = "HYGN"; @@ -40,11 +42,10 @@ Element_H2::Element_H2() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_H2::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_H2 static int update(UPDATE_FUNC_ARGS) -int Element_H2::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r,rx,ry,rt; for (rx=-2; rx<3; rx++) @@ -131,6 +132,3 @@ int Element_H2::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_H2::~Element_H2() {} diff --git a/src/simulation/elements/HEAC.cpp b/src/simulation/elements/HEAC.cpp index f2508314a..0a11cee77 100644 --- a/src/simulation/elements/HEAC.cpp +++ b/src/simulation/elements/HEAC.cpp @@ -1,9 +1,9 @@ -#include -#include #include "simulation/ElementCommon.h" #include "simulation/Air.h" -//#TPT-Directive ElementClass Element_HEAC PT_HEAC 180 -Element_HEAC::Element_HEAC() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_HEAC() { Identifier = "DEFAULT_PT_HEAC"; Name = "HEAC"; @@ -44,23 +44,16 @@ Element_HEAC::Element_HEAC() HighTemperature = 1887.15f; HighTemperatureTransition = NT; - Update = &Element_HEAC::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_HEAC struct IsInsulator -struct Element_HEAC::IsInsulator : public std::binary_function { - bool operator() (Simulation* a, int b) - { - return b && (a->elements[TYP(b)].HeatConduct == 0 || (TYP(b) == PT_HSWC && a->parts[ID(b)].life != 10)); - } +static const auto isInsulator = [](Simulation* a, int b) -> bool { + return b && (a->elements[TYP(b)].HeatConduct == 0 || (TYP(b) == PT_HSWC && a->parts[ID(b)].life != 10)); }; -//#TPT-Directive ElementHeader Element_HEAC static IsInsulator isInsulator -Element_HEAC::IsInsulator Element_HEAC::isInsulator = Element_HEAC::IsInsulator(); // If this is used elsewhere (GOLD), it should be moved into Simulation.h -//#TPT-Directive ElementHeader Element_HEAC template static bool CheckLine(Simulation* sim, int x1, int y1, int x2, int y2, BinaryPredicate func) template -bool Element_HEAC::CheckLine(Simulation* sim, int x1, int y1, int x2, int y2, BinaryPredicate func) +bool CheckLine(Simulation* sim, int x1, int y1, int x2, int y2, BinaryPredicate func) { bool reverseXY = abs(y2-y1) > abs(x2-x1); int x, y, dx, dy, sy; @@ -123,8 +116,7 @@ bool Element_HEAC::CheckLine(Simulation* sim, int x1, int y1, int x2, int y2, Bi return false; } -//#TPT-Directive ElementHeader Element_HEAC static int update(UPDATE_FUNC_ARGS) -int Element_HEAC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { const int rad = 4; int rry, rrx, r, count = 0; @@ -135,7 +127,7 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS) { rry = ry * rad; rrx = rx * rad; - if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine(sim, x, y, x+rrx, y+rry, isInsulator)) + if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !CheckLine(sim, x, y, x+rrx, y+rry, isInsulator)) { r = pmap[y+rry][x+rrx]; if (r && sim->elements[TYP(r)].HeatConduct > 0 && (TYP(r) != PT_HSWC || parts[ID(r)].life == 10)) @@ -163,7 +155,7 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS) { rry = ry * rad; rrx = rx * rad; - if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine(sim, x, y, x+rrx, y+rry, isInsulator)) + if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !CheckLine(sim, x, y, x+rrx, y+rry, isInsulator)) { r = pmap[y+rry][x+rrx]; if (r && sim->elements[TYP(r)].HeatConduct > 0 && (TYP(r) != PT_HSWC || parts[ID(r)].life == 10)) @@ -182,6 +174,3 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS) return 0; } - - -Element_HEAC::~Element_HEAC() {} diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp index a0648d4a5..8f4b34dd1 100644 --- a/src/simulation/elements/HSWC.cpp +++ b/src/simulation/elements/HSWC.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_HSWC PT_HSWC 75 -Element_HSWC::Element_HSWC() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_HSWC() { Identifier = "DEFAULT_PT_HSWC"; Name = "HSWC"; @@ -40,12 +43,11 @@ Element_HSWC::Element_HSWC() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_HSWC::update; - Graphics = &Element_HSWC::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_HSWC static int update(UPDATE_FUNC_ARGS) -int Element_HSWC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life!=10) @@ -84,15 +86,9 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_HSWC static int graphics(GRAPHICS_FUNC_ARGS) -int Element_HSWC::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int lifemod = ((cpart->life>10?10:cpart->life)*19); *colr += lifemod; return 0; } - - -Element_HSWC::~Element_HSWC() {} diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp index 1b54129da..5445783f8 100644 --- a/src/simulation/elements/ICEI.cpp +++ b/src/simulation/elements/ICEI.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ICEI PT_ICEI 13 -Element_ICEI::Element_ICEI() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_ICEI() { Identifier = "DEFAULT_PT_ICEI"; Name = "ICE"; @@ -43,12 +45,11 @@ Element_ICEI::Element_ICEI() DefaultProperties.ctype = PT_WATR; - Update = &Element_ICEI::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_ICEI static int update(UPDATE_FUNC_ARGS) -int Element_ICEI::update(UPDATE_FUNC_ARGS) - { //currently used for snow as well +static int update(UPDATE_FUNC_ARGS) +{ int r, rx, ry; if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW { @@ -78,6 +79,3 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_ICEI::~Element_ICEI() {} diff --git a/src/simulation/elements/IGNT.cpp b/src/simulation/elements/IGNT.cpp index e522c9ff8..6f8e8ec6e 100644 --- a/src/simulation/elements/IGNT.cpp +++ b/src/simulation/elements/IGNT.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_IGNT PT_IGNT 140 -Element_IGNT::Element_IGNT() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_IGNT() { Identifier = "DEFAULT_PT_IGNT"; Name = "IGNC"; @@ -42,11 +44,10 @@ Element_IGNT::Element_IGNT() DefaultProperties.life = 3; - Update = &Element_IGNT::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_IGNT static int update(UPDATE_FUNC_ARGS) -int Element_IGNT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; if(parts[i].tmp==0) @@ -86,6 +87,3 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_IGNT::~Element_IGNT() {} diff --git a/src/simulation/elements/INSL.cpp b/src/simulation/elements/INSL.cpp index cfeb9ab5c..980edbed2 100644 --- a/src/simulation/elements/INSL.cpp +++ b/src/simulation/elements/INSL.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_INSL PT_INSL 38 -Element_INSL::Element_INSL() + +void Element::Element_INSL() { Identifier = "DEFAULT_PT_INSL"; Name = "INSL"; @@ -39,8 +39,4 @@ Element_INSL::Element_INSL() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_INSL::~Element_INSL() {} diff --git a/src/simulation/elements/INST.cpp b/src/simulation/elements/INST.cpp index 5febdc986..3e50ceeb1 100644 --- a/src/simulation/elements/INST.cpp +++ b/src/simulation/elements/INST.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_INST PT_INST 106 -Element_INST::Element_INST() + +void Element::Element_INST() { Identifier = "DEFAULT_PT_INST"; Name = "INST"; @@ -39,8 +39,4 @@ Element_INST::Element_INST() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_INST::~Element_INST() {} diff --git a/src/simulation/elements/INVIS.cpp b/src/simulation/elements/INVIS.cpp index defc5bda2..d03373de1 100644 --- a/src/simulation/elements/INVIS.cpp +++ b/src/simulation/elements/INVIS.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_INVIS PT_INVIS 115 -Element_INVIS::Element_INVIS() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_INVIS() { Identifier = "DEFAULT_PT_INVIS"; Name = "INVS"; @@ -40,12 +43,11 @@ Element_INVIS::Element_INVIS() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_INVIS::update; - Graphics = &Element_INVIS::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_INVIS static int update(UPDATE_FUNC_ARGS) -int Element_INVIS::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { float pressureResistance = 0.0f; if (parts[i].tmp > 0) @@ -60,8 +62,7 @@ int Element_INVIS::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_INVIS static int graphics(GRAPHICS_FUNC_ARGS) -int Element_INVIS::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { //pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f if(cpart->tmp2) @@ -74,6 +75,3 @@ int Element_INVIS::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_INVIS::~Element_INVIS() {} diff --git a/src/simulation/elements/INWR.cpp b/src/simulation/elements/INWR.cpp index 75ed3d77d..9d1137ec8 100644 --- a/src/simulation/elements/INWR.cpp +++ b/src/simulation/elements/INWR.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_INWR PT_INWR 62 -Element_INWR::Element_INWR() + +void Element::Element_INWR() { Identifier = "DEFAULT_PT_INWR"; Name = "INWR"; @@ -39,8 +39,4 @@ Element_INWR::Element_INWR() LowTemperatureTransition = NT; HighTemperature = 1687.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_INWR::~Element_INWR() {} diff --git a/src/simulation/elements/IRON.cpp b/src/simulation/elements/IRON.cpp index e480db0c9..45ef6c76d 100644 --- a/src/simulation/elements/IRON.cpp +++ b/src/simulation/elements/IRON.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_IRON PT_IRON 76 -Element_IRON::Element_IRON() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_IRON() { Identifier = "DEFAULT_PT_IRON"; Name = "IRON"; @@ -40,11 +42,10 @@ Element_IRON::Element_IRON() HighTemperature = 1687.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_IRON::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_IRON static int update(UPDATE_FUNC_ARGS) -int Element_IRON::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life) @@ -84,6 +85,3 @@ succ: parts[i].tmp = RNG::Ref().between(20, 29); return 0; } - - -Element_IRON::~Element_IRON() {} diff --git a/src/simulation/elements/ISOZ.cpp b/src/simulation/elements/ISOZ.cpp index 3fbfdeed7..63ee50ace 100644 --- a/src/simulation/elements/ISOZ.cpp +++ b/src/simulation/elements/ISOZ.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ISOZ PT_ISOZ 107 -Element_ISOZ::Element_ISOZ() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_ISOZ() { Identifier = "DEFAULT_PT_ISOZ"; Name = "ISOZ"; @@ -41,12 +43,11 @@ Element_ISOZ::Element_ISOZ() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_ISOZ::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_ISOZ static int update(UPDATE_FUNC_ARGS) -int Element_ISOZ::update(UPDATE_FUNC_ARGS) - { // for both ISZS and ISOZ +static int update(UPDATE_FUNC_ARGS) +{ float rr, rrr; if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(-4.0f * sim->pv[y/CELL][x/CELL], 1000)) { @@ -58,6 +59,3 @@ int Element_ISOZ::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_ISOZ::~Element_ISOZ() {} diff --git a/src/simulation/elements/ISZS.cpp b/src/simulation/elements/ISZS.cpp index db3dbb6f5..61cbe0e63 100644 --- a/src/simulation/elements/ISZS.cpp +++ b/src/simulation/elements/ISZS.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_ISZS PT_ISZS 108 -Element_ISZS::Element_ISZS() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_ISZS() { Identifier = "DEFAULT_PT_ISZS"; Name = "ISZS"; @@ -41,12 +43,11 @@ Element_ISZS::Element_ISZS() HighTemperature = 300.0f; HighTemperatureTransition = PT_ISOZ; - Update = &Element_ISZS::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_ISZS static int update(UPDATE_FUNC_ARGS) -int Element_ISZS::update(UPDATE_FUNC_ARGS) - { // for both ISZS and ISOZ +static int update(UPDATE_FUNC_ARGS) +{ float rr, rrr; if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(-4.0f * sim->pv[y/CELL][x/CELL], 1000)) { @@ -58,6 +59,3 @@ int Element_ISZS::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_ISZS::~Element_ISZS() {} diff --git a/src/simulation/elements/LAVA.cpp b/src/simulation/elements/LAVA.cpp index 296ca974d..be5cf197f 100644 --- a/src/simulation/elements/LAVA.cpp +++ b/src/simulation/elements/LAVA.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LAVA PT_LAVA 6 -Element_LAVA::Element_LAVA() + +int Element_FIRE_update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_LAVA() { Identifier = "DEFAULT_PT_LAVA"; Name = "LAVA"; @@ -42,15 +46,12 @@ Element_LAVA::Element_LAVA() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_FIRE::update; - Graphics = &Element_LAVA::graphics; - Create = &Element_LAVA::create; + Update = &Element_FIRE_update; + Graphics = &graphics; + Create = &create; } - -//#TPT-Directive ElementHeader Element_LAVA static int graphics(GRAPHICS_FUNC_ARGS) -int Element_LAVA::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *colr = cpart->life * 2 + 0xE0; *colg = cpart->life * 1 + 0x50; @@ -68,10 +69,7 @@ int Element_LAVA::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_LAVA static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_LAVA::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].life = RNG::Ref().between(240, 359); } - -Element_LAVA::~Element_LAVA() {} diff --git a/src/simulation/elements/LCRY.cpp b/src/simulation/elements/LCRY.cpp index aabb32310..2c1891009 100644 --- a/src/simulation/elements/LCRY.cpp +++ b/src/simulation/elements/LCRY.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LCRY PT_LCRY 54 -Element_LCRY::Element_LCRY() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_LCRY() { Identifier = "DEFAULT_PT_LCRY"; Name = "LCRY"; @@ -40,13 +43,11 @@ Element_LCRY::Element_LCRY() HighTemperature = 1273.0f; HighTemperatureTransition = PT_BGLA; - Update = &Element_LCRY::update; - Graphics = &Element_LCRY::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_LCRY static int update(UPDATE_FUNC_ARGS) -int Element_LCRY::update(UPDATE_FUNC_ARGS) - +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, check, setto; switch (parts[i].tmp) @@ -99,9 +100,7 @@ int Element_LCRY::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_LCRY static int graphics(GRAPHICS_FUNC_ARGS) -int Element_LCRY::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { bool deco = false; if (ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) @@ -131,23 +130,5 @@ int Element_LCRY::graphics(GRAPHICS_FUNC_ARGS) } *pixel_mode |= NO_DECO; return 0; - - /*int lifemod = ((cpart->tmp2>10?10:cpart->tmp2)*10); - *colr += lifemod; - *colg += lifemod; - *colb += lifemod; - if(decorations_enable && cpart->dcolour && cpart->dcolour&0xFF000000) - { - lifemod *= 2.5f; - if(lifemod < 40) - lifemod = 40; - *colr = (lifemod*((cpart->dcolour>>16)&0xFF) + (255-lifemod)**colr) >> 8; - *colg = (lifemod*((cpart->dcolour>>8)&0xFF) + (255-lifemod)**colg) >> 8; - *colb = (lifemod*((cpart->dcolour)&0xFF) + (255-lifemod)**colb) >> 8; - } - *pixel_mode |= NO_DECO; - return 0;*/ } - -Element_LCRY::~Element_LCRY() {} diff --git a/src/simulation/elements/LDTC.cpp b/src/simulation/elements/LDTC.cpp index 66e186fc9..260a9e839 100644 --- a/src/simulation/elements/LDTC.cpp +++ b/src/simulation/elements/LDTC.cpp @@ -1,8 +1,9 @@ #include "simulation/ElementCommon.h" #include -//#TPT-Directive ElementClass Element_LDTC PT_LDTC 186 -Element_LDTC::Element_LDTC() +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_LDTC() { Identifier = "DEFAULT_PT_LDTC"; Name = "LDTC"; @@ -42,18 +43,14 @@ Element_LDTC::Element_LDTC() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_LDTC::update; + Update = &update; CtypeDraw = &Element::ctypeDrawVInTmp; } -//#TPT-Directive ElementHeader Element_LDTC static const int FLAG_INVERT_FILTER -//#TPT-Directive ElementHeader Element_LDTC static const int FLAG_IGNORE_ENERGY -//#TPT-Directive ElementHeader Element_LDTC static const int FLAG_NO_COPY_COLOR -//#TPT-Directive ElementHeader Element_LDTC static const int FLAG_KEEP_SEARCHING -const int Element_LDTC::FLAG_INVERT_FILTER = 0x1; -const int Element_LDTC::FLAG_IGNORE_ENERGY = 0x2; -const int Element_LDTC::FLAG_NO_COPY_COLOR = 0x4; -const int Element_LDTC::FLAG_KEEP_SEARCHING = 0x8; +constexpr int FLAG_INVERT_FILTER = 0x1; +constexpr int FLAG_IGNORE_ENERGY = 0x2; +constexpr int FLAG_NO_COPY_COLOR = 0x4; +constexpr int FLAG_KEEP_SEARCHING = 0x8; //NOTES: // ctype is used to store the target element, if any. (NONE is treated as a wildcard) @@ -66,17 +63,15 @@ const int Element_LDTC::FLAG_KEEP_SEARCHING = 0x8; // 0x08: Keep searching even after finding a particle -//#TPT-Directive ElementHeader Element_LDTC static bool phot_data_type(int rt); /* Returns true for particles that activate the special FILT color copying mode */ -bool Element_LDTC::phot_data_type(int rt) +static bool phot_data_type(int rt) { return rt == PT_FILT || rt == PT_PHOT || rt == PT_BRAY; } -//#TPT-Directive ElementHeader Element_LDTC static bool accepted_conductor(Simulation *sim, int rt); /* Returns true for particles that start a ray search ("dtec" mode) */ -bool Element_LDTC::accepted_conductor(Simulation* sim, int r) +static bool accepted_conductor(Simulation* sim, int r) { int rt = TYP(r); return (sim->elements[rt].Properties & PROP_CONDUCTS) && @@ -85,14 +80,13 @@ bool Element_LDTC::accepted_conductor(Simulation* sim, int r) sim->parts[ID(r)].life == 0; } -//#TPT-Directive ElementHeader Element_LDTC static int update(UPDATE_FUNC_ARGS) -int Element_LDTC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int ctype = TYP(parts[i].ctype), ctypeExtra = ID(parts[i].ctype), detectLength = parts[i].tmp, detectSpaces = parts[i].tmp2; - bool copyColor = !(parts[i].tmp2 & Element_LDTC::FLAG_NO_COPY_COLOR); - bool ignoreEnergy = parts[i].tmp2 & Element_LDTC::FLAG_IGNORE_ENERGY; - bool invertFilter = parts[i].tmp2 & Element_LDTC::FLAG_INVERT_FILTER; - bool keepSearching = parts[i].tmp2 & Element_LDTC::FLAG_KEEP_SEARCHING; + bool copyColor = !(parts[i].tmp2 & FLAG_NO_COPY_COLOR); + bool ignoreEnergy = parts[i].tmp2 & FLAG_IGNORE_ENERGY; + bool invertFilter = parts[i].tmp2 & FLAG_INVERT_FILTER; + bool keepSearching = parts[i].tmp2 & FLAG_KEEP_SEARCHING; if (detectSpaces < 0) detectSpaces = parts[i].tmp2 = 0; if (detectLength < 0) @@ -106,7 +100,7 @@ int Element_LDTC::update(UPDATE_FUNC_ARGS) int r = pmap[y+ry][x+rx]; if (!r) continue; - bool boolMode = Element_LDTC::accepted_conductor(sim, r); + bool boolMode = accepted_conductor(sim, r); bool filtMode = copyColor && TYP(r) == PT_FILT; if (!boolMode && !filtMode) continue; @@ -150,12 +144,13 @@ int Element_LDTC::update(UPDATE_FUNC_ARGS) if (filtMode) { - if (!Element_LDTC::phot_data_type(TYP(rr))) + if (!phot_data_type(TYP(rr))) continue; int nx = x + rx, ny = y + ry; + int Element_FILT_getWavelengths(Particle* cpart); int photonWl = TYP(rr) == PT_FILT ? - Element_FILT::getWavelengths(&parts[ID(rr)]) : + Element_FILT_getWavelengths(&parts[ID(rr)]) : parts[ID(rr)].ctype; while (TYP(r) == PT_FILT) { @@ -174,5 +169,3 @@ int Element_LDTC::update(UPDATE_FUNC_ARGS) } return 0; } - -Element_LDTC::~Element_LDTC() {} diff --git a/src/simulation/elements/LIFE.cpp b/src/simulation/elements/LIFE.cpp index 4b543b3a6..566c9c982 100644 --- a/src/simulation/elements/LIFE.cpp +++ b/src/simulation/elements/LIFE.cpp @@ -3,8 +3,10 @@ bool Element_GOL_colourInit = false; pixel Element_GOL_colour[NGOL]; -//#TPT-Directive ElementClass Element_LIFE PT_LIFE 78 -Element_LIFE::Element_LIFE() +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_LIFE() { Identifier = "DEFAULT_PT_LIFE"; Name = "LIFE"; @@ -45,9 +47,8 @@ Element_LIFE::Element_LIFE() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Graphics = &Element_LIFE::graphics; - Create = &Element_LIFE::create; + Graphics = &graphics; + Create = &create; if (!Element_GOL_colourInit) { @@ -61,9 +62,7 @@ Element_LIFE::Element_LIFE() } } -//#TPT-Directive ElementHeader Element_LIFE static int graphics(GRAPHICS_FUNC_ARGS) -int Element_LIFE::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { pixel pc; if (cpart->ctype==NGT_LOTE)//colors for life states @@ -121,8 +120,7 @@ int Element_LIFE::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_LIFE static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_LIFE::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { if (v >= 0 && v < NGOL) { @@ -130,5 +128,3 @@ void Element_LIFE::create(ELEMENT_CREATE_FUNC_ARGS) sim->parts[i].ctype = v; } } - -Element_LIFE::~Element_LIFE() {} diff --git a/src/simulation/elements/LIGH.cpp b/src/simulation/elements/LIGH.cpp index ab512fcc2..b7e1c571e 100644 --- a/src/simulation/elements/LIGH.cpp +++ b/src/simulation/elements/LIGH.cpp @@ -1,7 +1,11 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LIGH PT_LIGH 87 -Element_LIGH::Element_LIGH() +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2); + +void Element::Element_LIGH() { Identifier = "DEFAULT_PT_LIGH"; Name = "LIGH"; @@ -41,16 +45,14 @@ Element_LIGH::Element_LIGH() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_LIGH::update; - Graphics = &Element_LIGH::graphics; - Create = &Element_LIGH::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -#define LIGHTING_POWER 0.65 - -//#TPT-Directive ElementHeader Element_LIGH static int update(UPDATE_FUNC_ARGS) -int Element_LIGH::update(UPDATE_FUNC_ARGS) +constexpr float LIGHTING_POWER = 0.65f; +static int update(UPDATE_FUNC_ARGS) { /* * @@ -170,45 +172,6 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) return 1; } - //Completely broken and laggy function, possibly can be fixed later - /*int pNear = LIGH_nearest_part(sim, i, parts[i].life*2.5); - if (pNear!=-1) - { - int t=parts[pNear].type; - float n_angle; // angle to nearest part - float angle_diff; - rx=parts[pNear].x-x; - ry=parts[pNear].y-y; - if (rx!=0 || ry!=0) - n_angle = atan2f(-ry, rx); - else - n_angle = 0; - if (n_angle<0) - n_angle+=M_PI*2; - angle_diff = fabsf(n_angle-parts[i].tmp*M_PI/180); - if (angle_diff>M_PI) - angle_diff = M_PI*2 - angle_diff; - if (parts[i].life<5 || angle_diffparts[ci].x; - int cy = (int)sim->parts[ci].y; - for (i=0; i<=sim->parts_lastActiveIndex; i++) - { - if (sim->parts[i].type && sim->parts[i].life && i!=ci && sim->parts[i].type!=PT_LIGH && sim->parts[i].type!=PT_THDR && sim->parts[i].type!=PT_NEUT && sim->parts[i].type!=PT_PHOT) - { - ndistance = std::abs(cx-sim->parts[i].x)+std::abs(cy-sim->parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2)); - if (ndistanceparts[i].x, y=sim->parts[i].y; - int r,rx,ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>=0 && x+rxpmap[y+ry][x+rx]; - if (!r) - continue; - if (TYP(r)==tp) - return ID(r); - } - return -1; -} - -//#TPT-Directive ElementHeader Element_LIGH static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2, bool last) -bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2, bool last) +static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2, bool last) { int p = sim->create_part(-1, x, y,c); if (p != -1) @@ -297,8 +217,7 @@ bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp, return false; } -//#TPT-Directive ElementHeader Element_LIGH static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) -void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) +static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) { bool reverseXY = abs(y2-y1) > abs(x2-x1), back = false; int x, y, dx, dy, Ystep; @@ -364,10 +283,7 @@ void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int } } - -//#TPT-Directive ElementHeader Element_LIGH static int graphics(GRAPHICS_FUNC_ARGS) -int Element_LIGH::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 120; *firer = *colr = 235; @@ -377,8 +293,7 @@ int Element_LIGH::graphics(GRAPHICS_FUNC_ARGS) return 1; } -//#TPT-Directive ElementHeader Element_LIGH static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_LIGH::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { float gx, gy, gsize; if (v >= 0) @@ -403,5 +318,3 @@ void Element_LIGH::create(ELEMENT_CREATE_FUNC_ARGS) sim->parts[i].tmp = (static_cast(atan2f(-gy, gx) * (180.0f / M_PI)) + RNG::Ref().between(-20, 20) + 360) % 360; sim->parts[i].tmp2 = 4; } - -Element_LIGH::~Element_LIGH() {} diff --git a/src/simulation/elements/LNTG.cpp b/src/simulation/elements/LNTG.cpp index e9b6ce73a..ac566e3a3 100644 --- a/src/simulation/elements/LNTG.cpp +++ b/src/simulation/elements/LNTG.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LNTG PT_LNTG 37 -Element_LNTG::Element_LNTG() + +void Element::Element_LNTG() { Identifier = "DEFAULT_PT_LNTG"; Name = "LN2"; @@ -40,8 +40,4 @@ Element_LNTG::Element_LNTG() LowTemperatureTransition = PT_NICE; HighTemperature = 77.0f; HighTemperatureTransition = PT_NONE; - - Update = NULL; } - -Element_LNTG::~Element_LNTG() {} diff --git a/src/simulation/elements/LO2.cpp b/src/simulation/elements/LO2.cpp index 22f79ba1f..9efc2acb7 100644 --- a/src/simulation/elements/LO2.cpp +++ b/src/simulation/elements/LO2.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LO2 PT_LO2 60 -Element_LO2::Element_LO2() + +void Element::Element_LO2() { Identifier = "DEFAULT_PT_LO2"; Name = "LOXY"; @@ -40,8 +40,4 @@ Element_LO2::Element_LO2() LowTemperatureTransition = NT; HighTemperature = 90.1f; HighTemperatureTransition = PT_O2; - - Update = NULL; } - -Element_LO2::~Element_LO2() {} diff --git a/src/simulation/elements/LOLZ.cpp b/src/simulation/elements/LOLZ.cpp index 959d74cff..abd9d598e 100644 --- a/src/simulation/elements/LOLZ.cpp +++ b/src/simulation/elements/LOLZ.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LOLZ PT_LOLZ 123 -Element_LOLZ::Element_LOLZ() + +void Element::Element_LOLZ() { Identifier = "DEFAULT_PT_LOLZ"; Name = "LOLZ"; @@ -42,8 +42,7 @@ Element_LOLZ::Element_LOLZ() HighTemperatureTransition = NT; } -//#TPT-Directive ElementHeader Element_LOLZ static int RuleTable[9][9] -int Element_LOLZ::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}, @@ -56,7 +55,4 @@ int Element_LOLZ::RuleTable[9][9] = {0,1,0,0,0,0,0,1,0}, }; -//#TPT-Directive ElementHeader Element_LOLZ static int lolz[XRES/9][YRES/9]; -int Element_LOLZ::lolz[XRES/9][YRES/9]; - -Element_LOLZ::~Element_LOLZ() {} +int Element_LOLZ_lolz[XRES/9][YRES/9]; diff --git a/src/simulation/elements/LOVE.cpp b/src/simulation/elements/LOVE.cpp index 710cc762f..9e1c6c040 100644 --- a/src/simulation/elements/LOVE.cpp +++ b/src/simulation/elements/LOVE.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LOVE PT_LOVE 94 -Element_LOVE::Element_LOVE() + +void Element::Element_LOVE() { Identifier = "DEFAULT_PT_LOVE"; Name = "LOVE"; @@ -42,8 +42,7 @@ Element_LOVE::Element_LOVE() HighTemperatureTransition = NT; } -//#TPT-Directive ElementHeader Element_LOVE static int RuleTable[9][9] -int Element_LOVE::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}, @@ -56,7 +55,4 @@ int Element_LOVE::RuleTable[9][9] = {0,0,1,1,0,0,0,0,0}, }; -//#TPT-Directive ElementHeader Element_LOVE static int love[XRES/9][YRES/9]; -int Element_LOVE::love[XRES/9][YRES/9]; - -Element_LOVE::~Element_LOVE() {} +int Element_LOVE_love[XRES/9][YRES/9]; diff --git a/src/simulation/elements/LRBD.cpp b/src/simulation/elements/LRBD.cpp index 639c93ca5..b7716ac86 100644 --- a/src/simulation/elements/LRBD.cpp +++ b/src/simulation/elements/LRBD.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LRBD PT_LRBD 42 -Element_LRBD::Element_LRBD() + +void Element::Element_LRBD() { Identifier = "DEFAULT_PT_LRBD"; Name = "LRBD"; @@ -40,8 +40,4 @@ Element_LRBD::Element_LRBD() LowTemperatureTransition = PT_RBDM; HighTemperature = 961.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_LRBD::~Element_LRBD() {} diff --git a/src/simulation/elements/LSNS.cpp b/src/simulation/elements/LSNS.cpp index 7530f4ec6..e8e2cb1ec 100644 --- a/src/simulation/elements/LSNS.cpp +++ b/src/simulation/elements/LSNS.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_LSNS PT_LSNS 185 -Element_LSNS::Element_LSNS() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_LSNS() { Identifier = "DEFAULT_PT_LSNS"; Name = "LSNS"; @@ -43,11 +45,10 @@ Element_LSNS::Element_LSNS() DefaultProperties.tmp2 = 2; - Update = &Element_LSNS::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_LSNS static int update(UPDATE_FUNC_ARGS) -int Element_LSNS::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int rd = parts[i].tmp2; if (rd > 25) parts[i].tmp2 = rd = 25; @@ -153,5 +154,3 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS) return 0; } - -Element_LSNS::~Element_LSNS() {} diff --git a/src/simulation/elements/MERC.cpp b/src/simulation/elements/MERC.cpp index 607efdc61..d64e5afa7 100644 --- a/src/simulation/elements/MERC.cpp +++ b/src/simulation/elements/MERC.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_MERC PT_MERC 152 -Element_MERC::Element_MERC() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_MERC() { Identifier = "DEFAULT_PT_MERC"; Name = "MERC"; @@ -42,11 +44,10 @@ Element_MERC::Element_MERC() DefaultProperties.tmp = 10; - Update = &Element_MERC::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_MERC static int update(UPDATE_FUNC_ARGS) -int Element_MERC::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, trade, np; // Max number of particles that can be condensed into one @@ -131,6 +132,3 @@ int Element_MERC::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_MERC::~Element_MERC() {} diff --git a/src/simulation/elements/METL.cpp b/src/simulation/elements/METL.cpp index 82b5ccfb6..44ff6a98a 100644 --- a/src/simulation/elements/METL.cpp +++ b/src/simulation/elements/METL.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_METL PT_METL 14 -Element_METL::Element_METL() + +void Element::Element_METL() { Identifier = "DEFAULT_PT_METL"; Name = "METL"; @@ -39,8 +39,4 @@ Element_METL::Element_METL() LowTemperatureTransition = NT; HighTemperature = 1273.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_METL::~Element_METL() {} diff --git a/src/simulation/elements/MORT.cpp b/src/simulation/elements/MORT.cpp index 6052b0f4e..925056ad6 100644 --- a/src/simulation/elements/MORT.cpp +++ b/src/simulation/elements/MORT.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_MORT PT_MORT 77 -Element_MORT::Element_MORT() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_MORT() { Identifier = "DEFAULT_PT_MORT"; Name = "MORT"; @@ -44,15 +46,11 @@ Element_MORT::Element_MORT() // CHOO CHOO DefaultProperties.vx = 2.0f; - Update = &Element_MORT::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_MORT static int update(UPDATE_FUNC_ARGS) -int Element_MORT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { sim->create_part(-1, x, y-1, PT_SMKE); return 0; } - - -Element_MORT::~Element_MORT() {} diff --git a/src/simulation/elements/MWAX.cpp b/src/simulation/elements/MWAX.cpp index 3ac4eb431..64d0d3e26 100644 --- a/src/simulation/elements/MWAX.cpp +++ b/src/simulation/elements/MWAX.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_MWAX PT_MWAX 34 -Element_MWAX::Element_MWAX() + +void Element::Element_MWAX() { Identifier = "DEFAULT_PT_MWAX"; Name = "MWAX"; @@ -40,8 +40,4 @@ Element_MWAX::Element_MWAX() LowTemperatureTransition = PT_WAX; HighTemperature = 673.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_MWAX::~Element_MWAX() {} diff --git a/src/simulation/elements/NBHL.cpp b/src/simulation/elements/NBHL.cpp index 17d5bf873..f0f7fe45d 100644 --- a/src/simulation/elements/NBHL.cpp +++ b/src/simulation/elements/NBHL.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NBHL PT_NBHL 150 -Element_NBHL::Element_NBHL() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_NBHL() { Identifier = "DEFAULT_PT_NBHL"; Name = "BHOL"; @@ -40,11 +42,10 @@ Element_NBHL::Element_NBHL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_NBHL::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_NBHL static int update(UPDATE_FUNC_ARGS) -int Element_NBHL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].tmp) sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += restrict_flt(0.001f*parts[i].tmp, 0.1f, 51.2f); @@ -52,6 +53,3 @@ int Element_NBHL::update(UPDATE_FUNC_ARGS) sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += 0.1f; return 0; } - - -Element_NBHL::~Element_NBHL() {} diff --git a/src/simulation/elements/NBLE.cpp b/src/simulation/elements/NBLE.cpp index 8130675ec..baa6de670 100644 --- a/src/simulation/elements/NBLE.cpp +++ b/src/simulation/elements/NBLE.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NBLE PT_NBLE 52 -Element_NBLE::Element_NBLE() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_NBLE() { Identifier = "DEFAULT_PT_NBLE"; Name = "NBLE"; @@ -42,11 +44,10 @@ Element_NBLE::Element_NBLE() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_NBLE::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_NBLE static int update(UPDATE_FUNC_ARGS) -int Element_NBLE::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f) { @@ -89,6 +90,3 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_NBLE::~Element_NBLE() {} diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp index 3677e030d..7dbc2993a 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -1,6 +1,12 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NEUT PT_NEUT 18 -Element_NEUT::Element_NEUT() + +int Element_FIRE_update(UPDATE_FUNC_ARGS); +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +static int DeutExplosion(Simulation * sim, int n, int x, int y, float temp, int t); + +void Element::Element_NEUT() { Identifier = "DEFAULT_PT_NEUT"; Name = "NEUT"; @@ -41,13 +47,12 @@ Element_NEUT::Element_NEUT() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_NEUT::update; - Graphics = &Element_NEUT::graphics; - Create = &Element_NEUT::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_NEUT static int update(UPDATE_FUNC_ARGS) -int Element_NEUT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; unsigned int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL]; @@ -85,7 +90,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy; } sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough - Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); + Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS); } break; #ifdef SDEUT @@ -182,11 +187,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_NEUT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_NEUT::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 120; *firer = 10; @@ -197,8 +198,7 @@ int Element_NEUT::graphics(GRAPHICS_FUNC_ARGS) return 1; } -//#TPT-Directive ElementHeader Element_NEUT static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_NEUT::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { float r = RNG::Ref().between(128, 255) / 127.0f; float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f; @@ -207,8 +207,7 @@ void Element_NEUT::create(ELEMENT_CREATE_FUNC_ARGS) sim->parts[i].vy = r * sinf(a); } -//#TPT-Directive ElementHeader Element_NEUT static int DeutExplosion(Simulation * sim, int n, int x, int y, float temp, int t) -int Element_NEUT::DeutExplosion(Simulation * sim, int n, int x, int y, float temp, int t)//testing a new deut create part +static int DeutExplosion(Simulation * sim, int n, int x, int y, float temp, int t)//testing a new deut create part { int i; n = (n/50); @@ -228,5 +227,3 @@ int Element_NEUT::DeutExplosion(Simulation * sim, int n, int x, int y, float tem sim->pv[y/CELL][x/CELL] += (6.0f * CFDS)*n; return 0; } - -Element_NEUT::~Element_NEUT() {} diff --git a/src/simulation/elements/NICE.cpp b/src/simulation/elements/NICE.cpp index 0a2901268..5dd893f24 100644 --- a/src/simulation/elements/NICE.cpp +++ b/src/simulation/elements/NICE.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NICE PT_NICE 51 -Element_NICE::Element_NICE() + +void Element::Element_NICE() { Identifier = "DEFAULT_PT_NICE"; Name = "NICE"; @@ -40,8 +40,4 @@ Element_NICE::Element_NICE() LowTemperatureTransition = NT; HighTemperature = 63.1f; HighTemperatureTransition = PT_LNTG; - - Update = NULL; } - -Element_NICE::~Element_NICE() {} diff --git a/src/simulation/elements/NITR.cpp b/src/simulation/elements/NITR.cpp index 4362066fc..df3c1dc84 100644 --- a/src/simulation/elements/NITR.cpp +++ b/src/simulation/elements/NITR.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NITR PT_NITR 8 -Element_NITR::Element_NITR() + +void Element::Element_NITR() { Identifier = "DEFAULT_PT_NITR"; Name = "NITR"; @@ -40,8 +40,4 @@ Element_NITR::Element_NITR() LowTemperatureTransition = NT; HighTemperature = 673.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_NITR::~Element_NITR() {} diff --git a/src/simulation/elements/NONE.cpp b/src/simulation/elements/NONE.cpp index 497a2abb4..c8df7a257 100644 --- a/src/simulation/elements/NONE.cpp +++ b/src/simulation/elements/NONE.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NONE PT_NONE 0 -Element_NONE::Element_NONE() + +static VideoBuffer *iconGen(int wallID, int width, int height); + +void Element::Element_NONE() { Identifier = "DEFAULT_PT_NONE"; Name = ""; @@ -40,12 +42,10 @@ Element_NONE::Element_NONE() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - IconGenerator = &Element_NONE::iconGen; + IconGenerator = &iconGen; } -//#TPT-Directive ElementHeader Element_NONE static VideoBuffer * iconGen(int, int, int) -VideoBuffer * Element_NONE::iconGen(int wallID, int width, int height) +static VideoBuffer *iconGen(int wallID, int width, int height) { VideoBuffer * newTexture = new VideoBuffer(width, height); @@ -59,6 +59,3 @@ VideoBuffer * Element_NONE::iconGen(int wallID, int width, int height) return newTexture; } - - -Element_NONE::~Element_NONE() {} diff --git a/src/simulation/elements/NSCN.cpp b/src/simulation/elements/NSCN.cpp index 0b2d65444..f0e45749b 100644 --- a/src/simulation/elements/NSCN.cpp +++ b/src/simulation/elements/NSCN.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NSCN PT_NSCN 36 -Element_NSCN::Element_NSCN() + +void Element::Element_NSCN() { Identifier = "DEFAULT_PT_NSCN"; Name = "NSCN"; @@ -40,8 +40,4 @@ Element_NSCN::Element_NSCN() LowTemperatureTransition = NT; HighTemperature = 1687.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_NSCN::~Element_NSCN() {} diff --git a/src/simulation/elements/NTCT.cpp b/src/simulation/elements/NTCT.cpp index aeb3d9a35..df7888467 100644 --- a/src/simulation/elements/NTCT.cpp +++ b/src/simulation/elements/NTCT.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NTCT PT_NTCT 43 -Element_NTCT::Element_NTCT() + +int Element_NTCT_update(UPDATE_FUNC_ARGS); + +void Element::Element_NTCT() { Identifier = "DEFAULT_PT_NTCT"; Name = "NTCT"; @@ -40,16 +42,12 @@ Element_NTCT::Element_NTCT() HighTemperature = 1687.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_NTCT::update; + Update = &Element_NTCT_update; } -//#TPT-Directive ElementHeader Element_NTCT static int update(UPDATE_FUNC_ARGS) -int Element_NTCT::update(UPDATE_FUNC_ARGS) +int Element_NTCT_update(UPDATE_FUNC_ARGS) { if (parts[i].temp>295.0f) parts[i].temp -= 2.5f; return 0; } - - -Element_NTCT::~Element_NTCT() {} diff --git a/src/simulation/elements/NWHL.cpp b/src/simulation/elements/NWHL.cpp index b6f024c46..8906b8709 100644 --- a/src/simulation/elements/NWHL.cpp +++ b/src/simulation/elements/NWHL.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_NWHL PT_NWHL 151 -Element_NWHL::Element_NWHL() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_NWHL() { Identifier = "DEFAULT_PT_NWHL"; Name = "WHOL"; @@ -40,11 +42,10 @@ Element_NWHL::Element_NWHL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_NWHL::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_NWHL static int update(UPDATE_FUNC_ARGS) -int Element_NWHL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].tmp) sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] -= restrict_flt(0.001f*parts[i].tmp, 0.1f, 51.2f); @@ -52,6 +53,3 @@ int Element_NWHL::update(UPDATE_FUNC_ARGS) sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] -= 0.1f; return 0; } - - -Element_NWHL::~Element_NWHL() {} diff --git a/src/simulation/elements/O2.cpp b/src/simulation/elements/O2.cpp index ef8469b84..2f114de65 100644 --- a/src/simulation/elements/O2.cpp +++ b/src/simulation/elements/O2.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_O2 PT_O2 61 -Element_O2::Element_O2() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_O2() { Identifier = "DEFAULT_PT_O2"; Name = "OXYG"; @@ -40,11 +42,10 @@ Element_O2::Element_O2() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_O2::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_O2 static int update(UPDATE_FUNC_ARGS) -int Element_O2::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r,rx,ry; for (rx=-2; rx<3; rx++) @@ -114,6 +115,3 @@ int Element_O2::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_O2::~Element_O2() {} diff --git a/src/simulation/elements/OIL.cpp b/src/simulation/elements/OIL.cpp index 9a66e0cfc..69d2f2983 100644 --- a/src/simulation/elements/OIL.cpp +++ b/src/simulation/elements/OIL.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_OIL PT_OIL 3 -Element_OIL::Element_OIL() + +void Element::Element_OIL() { Identifier = "DEFAULT_PT_OIL"; Name = "OIL"; @@ -39,8 +39,4 @@ Element_OIL::Element_OIL() LowTemperatureTransition = NT; HighTemperature = 333.0f; HighTemperatureTransition = PT_GAS; - - Update = NULL; } - -Element_OIL::~Element_OIL() {} diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp index 0af1698ef..31b2e85dc 100644 --- a/src/simulation/elements/PBCN.cpp +++ b/src/simulation/elements/PBCN.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PBCN PT_PBCN 153 -Element_PBCN::Element_PBCN() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +bool Element_PCLN_ctypeDraw(CTYPEDRAW_FUNC_ARGS); + +void Element::Element_PBCN() { Identifier = "DEFAULT_PT_PBCN"; Name = "PBCN"; @@ -40,15 +44,14 @@ Element_PBCN::Element_PBCN() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PBCN::update; - Graphics = &Element_PBCN::graphics; - CtypeDraw = &Element_PCLN::ctypeDraw; + Update = &update; + Graphics = &graphics; + CtypeDraw = &Element_PCLN_ctypeDraw; } -#define ADVECTION 0.1f +constexpr float ADVECTION = 0.1f; -//#TPT-Directive ElementHeader Element_PBCN static int update(UPDATE_FUNC_ARGS) -int Element_PBCN::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; if (!parts[i].tmp2 && sim->pv[y/CELL][x/CELL]>4.0f) @@ -147,16 +150,10 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_PBCN static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PBCN::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int lifemod = ((cpart->life>10?10:cpart->life)*10); *colr += lifemod; *colg += lifemod/2; return 0; } - - -Element_PBCN::~Element_PBCN() {} diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp index 8f568cd0c..af8f05b15 100644 --- a/src/simulation/elements/PCLN.cpp +++ b/src/simulation/elements/PCLN.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PCLN PT_PCLN 74 -Element_PCLN::Element_PCLN() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +bool Element_PCLN_ctypeDraw(CTYPEDRAW_FUNC_ARGS); + +void Element::Element_PCLN() { Identifier = "DEFAULT_PT_PCLN"; Name = "PCLN"; @@ -40,13 +44,12 @@ Element_PCLN::Element_PCLN() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PCLN::update; - Graphics = &Element_PCLN::graphics; - CtypeDraw = &Element_PCLN::ctypeDraw; + Update = &update; + Graphics = &graphics; + CtypeDraw = &Element_PCLN_ctypeDraw; } -//#TPT-Directive ElementHeader Element_PCLN static int update(UPDATE_FUNC_ARGS) -int Element_PCLN::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; if (parts[i].life>0 && parts[i].life!=10) @@ -136,10 +139,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_PCLN static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PCLN::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int lifemod = ((cpart->life>10?10:cpart->life)*10); *colr += lifemod; @@ -147,8 +147,7 @@ int Element_PCLN::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PCLN static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) -bool Element_PCLN::ctypeDraw(CTYPEDRAW_FUNC_ARGS) +bool Element_PCLN_ctypeDraw(CTYPEDRAW_FUNC_ARGS) { if (t == PT_PSCN || t == PT_NSCN || t == PT_SPRK) { @@ -156,5 +155,3 @@ bool Element_PCLN::ctypeDraw(CTYPEDRAW_FUNC_ARGS) } return Element::ctypeDrawVInTmp(CTYPEDRAW_FUNC_SUBCALL_ARGS); } - -Element_PCLN::~Element_PCLN() {} diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index a7de41cc1..82d5468d9 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -1,6 +1,11 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PHOT PT_PHOT 31 -Element_PHOT::Element_PHOT() + +int Element_FIRE_update(UPDATE_FUNC_ARGS); +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_PHOT() { Identifier = "DEFAULT_PT_PHOT"; Name = "PHOT"; @@ -44,13 +49,12 @@ Element_PHOT::Element_PHOT() DefaultProperties.life = 680; DefaultProperties.ctype = 0x3FFFFFFF; - Update = &Element_PHOT::update; - Graphics = &Element_PHOT::graphics; - Create = &Element_PHOT::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_PHOT static int update(UPDATE_FUNC_ARGS) -int Element_PHOT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; float rr, rrr; @@ -60,7 +64,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) } if (parts[i].temp > 506) if (RNG::Ref().chance(1, 10)) - Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); + Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS); for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (BOUNDS_CHECK) { @@ -112,11 +116,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_PHOT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PHOT::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int x = 0; *colr = *colg = *colb = 0; @@ -145,14 +145,12 @@ int Element_PHOT::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PHOT static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_PHOT::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { float a = RNG::Ref().between(0, 7) * 0.78540f; sim->parts[i].vx = 3.0f * cosf(a); sim->parts[i].vy = 3.0f * sinf(a); + int Element_FILT_interactWavelengths(Particle* cpart, int origWl); if (TYP(sim->pmap[y][x]) == PT_FILT) - sim->parts[i].ctype = Element_FILT::interactWavelengths(&sim->parts[ID(sim->pmap[y][x])], sim->parts[i].ctype); + sim->parts[i].ctype = Element_FILT_interactWavelengths(&sim->parts[ID(sim->pmap[y][x])], sim->parts[i].ctype); } - -Element_PHOT::~Element_PHOT() {} diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index 610377231..526bcd6d7 100644 --- a/src/simulation/elements/PIPE.cpp +++ b/src/simulation/elements/PIPE.cpp @@ -2,8 +2,15 @@ //Temp particle used for graphics Particle tpart; -//#TPT-Directive ElementClass Element_PIPE PT_PIPE 99 -Element_PIPE::Element_PIPE() +int Element_PIPE_update(UPDATE_FUNC_ARGS); +int Element_PIPE_graphics(GRAPHICS_FUNC_ARGS); +void Element_PIPE_transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR); +static void transfer_part_to_pipe(Particle *part, Particle *pipe); +static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR); +static void pushParticle(Simulation * sim, int i, int count, int original); +void Element_SOAP_detach(Simulation * sim, int i); + +void Element::Element_PIPE() { Identifier = "DEFAULT_PT_PIPE"; Name = "PIPE"; @@ -46,8 +53,8 @@ Element_PIPE::Element_PIPE() DefaultProperties.life = 60; - Update = &Element_PIPE::update; - Graphics = &Element_PIPE::graphics; + Update = &Element_PIPE_update; + Graphics = &Element_PIPE_graphics; memset(&tpart, 0, sizeof(Particle)); } @@ -60,24 +67,24 @@ Element_PIPE::Element_PIPE() // 0x0001C000 reverse single pixel pipe direction // 0x000E0000 PIPE color data stored here -#define PFLAG_NORMALSPEED 0x00010000 -#define PFLAG_INITIALIZING 0x00020000 // colors haven't been set yet -#define PFLAG_COLOR_RED 0x00040000 -#define PFLAG_COLOR_GREEN 0x00080000 -#define PFLAG_COLOR_BLUE 0x000C0000 -#define PFLAG_COLORS 0x000C0000 +constexpr int PFLAG_NORMALSPEED = 0x00010000; +constexpr int PFLAG_INITIALIZING = 0x00020000; // colors haven't been set yet +constexpr int PFLAG_COLOR_RED = 0x00040000; +constexpr int PFLAG_COLOR_GREEN = 0x00080000; +constexpr int PFLAG_COLOR_BLUE = 0x000C0000; +constexpr int PFLAG_COLORS = 0x000C0000; -#define PPIP_TMPFLAG_REVERSED 0x01000000 -#define PPIP_TMPFLAG_PAUSED 0x02000000 -#define PPIP_TMPFLAG_TRIGGER_REVERSE 0x04000000 -#define PPIP_TMPFLAG_TRIGGER_OFF 0x08000000 -#define PPIP_TMPFLAG_TRIGGER_ON 0x10000000 -#define PPIP_TMPFLAG_TRIGGERS 0x1C000000 +constexpr int PPIP_TMPFLAG_REVERSED = 0x01000000; +constexpr int PPIP_TMPFLAG_PAUSED = 0x02000000; +constexpr int PPIP_TMPFLAG_TRIGGER_REVERSE = 0x04000000; +constexpr int PPIP_TMPFLAG_TRIGGER_OFF = 0x08000000; +constexpr int PPIP_TMPFLAG_TRIGGER_ON = 0x10000000; +constexpr int PPIP_TMPFLAG_TRIGGERS = 0x1C000000; signed char pos_1_rx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; signed char pos_1_ry[] = {-1, 0, 1,-1, 1,-1, 0, 1}; -unsigned int prevColor(unsigned int flags) +static unsigned int prevColor(unsigned int flags) { unsigned int color = flags & PFLAG_COLORS; if (color == PFLAG_COLOR_RED) @@ -89,7 +96,7 @@ unsigned int prevColor(unsigned int flags) return PFLAG_COLOR_RED; } -unsigned int nextColor(unsigned int flags) +static unsigned int nextColor(unsigned int flags) { unsigned int color = flags & PFLAG_COLORS; if (color == PFLAG_COLOR_RED) @@ -101,8 +108,7 @@ unsigned int nextColor(unsigned int flags) return PFLAG_COLOR_GREEN; } -//#TPT-Directive ElementHeader Element_PIPE static int update(UPDATE_FUNC_ARGS) -int Element_PIPE::update(UPDATE_FUNC_ARGS) +int Element_PIPE_update(UPDATE_FUNC_ARGS) { int r, rx, ry, np; int rnd, rndstore; @@ -236,14 +242,14 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) np = sim->create_part(-1, x+rx, y+ry, TYP(parts[i].ctype)); if (np!=-1) { - transfer_pipe_to_part(sim, parts+i, parts+np); + Element_PIPE_transfer_pipe_to_part(sim, parts+i, parts+np, false); } } //try eating particle at entrance else if (!TYP(parts[i].ctype) && (sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) { if (TYP(r)==PT_SOAP) - Element_SOAP::detach(sim, ID(r)); + Element_SOAP_detach(sim, ID(r)); transfer_part_to_pipe(parts+(ID(r)), parts+i); sim->kill_part(ID(r)); } @@ -314,10 +320,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_PIPE static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS) +int Element_PIPE_graphics(GRAPHICS_FUNC_ARGS) { int t = TYP(cpart->ctype); if (t>0 && tsim->elements[t].Enabled) @@ -389,8 +392,7 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR=false) -void Element_PIPE::transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR) +void Element_PIPE_transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR) { // STOR also calls this function to move particles from STOR to PRTI // PIPE was changed, so now PIPE and STOR don't use the same particle storage format @@ -421,8 +423,7 @@ void Element_PIPE::transfer_pipe_to_part(Simulation * sim, Particle *pipe, Parti part->dcolour = 0; } -//#TPT-Directive ElementHeader Element_PIPE static void transfer_part_to_pipe(Particle *part, Particle *pipe) -void Element_PIPE::transfer_part_to_pipe(Particle *part, Particle *pipe) +static void transfer_part_to_pipe(Particle *part, Particle *pipe) { pipe->ctype = part->type; pipe->temp = part->temp; @@ -431,8 +432,7 @@ void Element_PIPE::transfer_part_to_pipe(Particle *part, Particle *pipe) pipe->pavg[1] = part->ctype; } -//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR=false) -void Element_PIPE::transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR) +static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR) { // STOR to PIPE if (STOR) @@ -451,8 +451,7 @@ void Element_PIPE::transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STO dest->pavg[1] = src->pavg[1]; } -//#TPT-Directive ElementHeader Element_PIPE static void pushParticle(Simulation * sim, int i, int count, int original) -void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original) +static void pushParticle(Simulation * sim, int i, int count, int original) { int rndstore, rnd, rx, ry, r, x, y, np, q; unsigned int notctype = nextColor(sim->parts[i].tmp); @@ -480,7 +479,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original continue; else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && (sim->parts[ID(r)].tmp&PFLAG_COLORS) != notctype && !TYP(sim->parts[ID(r)].ctype)) { - transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r))); + transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)), false); if (ID(r) > original) sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed count++; @@ -496,7 +495,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original for (int nnx = 0; nnx < 80; nnx++) if (!sim->portalp[portaltmp][count][nnx].type) { - transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx])); + Element_PIPE_transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx]), false); count++; break; } @@ -510,7 +509,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && (sim->parts[ID(r)].tmp&PFLAG_COLORS) != notctype && !TYP(sim->parts[ID(r)].ctype)) { - transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r))); + transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)), false); if (ID(r) > original) sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed count++; @@ -526,7 +525,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original for (int nnx = 0; nnx < 80; nnx++) if (!sim->portalp[portaltmp][count][nnx].type) { - transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx])); + Element_PIPE_transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx]), false); count++; break; } @@ -538,13 +537,10 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original np = sim->create_part(-1,x+rx,y+ry,TYP(sim->parts[i].ctype)); if (np!=-1) { - transfer_pipe_to_part(sim, sim->parts+i, sim->parts+np); + Element_PIPE_transfer_pipe_to_part(sim, sim->parts+i, sim->parts+np, false); } } } return; } - - -Element_PIPE::~Element_PIPE() {} diff --git a/src/simulation/elements/PLEX.cpp b/src/simulation/elements/PLEX.cpp index 5a33530c6..579955471 100644 --- a/src/simulation/elements/PLEX.cpp +++ b/src/simulation/elements/PLEX.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PLEX PT_PLEX 11 -Element_PLEX::Element_PLEX() + +void Element::Element_PLEX() { Identifier = "DEFAULT_PT_PLEX"; Name = "C-4"; @@ -40,8 +40,4 @@ Element_PLEX::Element_PLEX() LowTemperatureTransition = NT; HighTemperature = 673.0f; HighTemperatureTransition = PT_FIRE; - - Update = NULL; } - -Element_PLEX::~Element_PLEX() {} diff --git a/src/simulation/elements/PLNT.cpp b/src/simulation/elements/PLNT.cpp index df6f40506..72be9aad9 100644 --- a/src/simulation/elements/PLNT.cpp +++ b/src/simulation/elements/PLNT.cpp @@ -1,8 +1,10 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PLNT PT_PLNT 20 -Element_PLNT::Element_PLNT() +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_PLNT() { Identifier = "DEFAULT_PT_PLNT"; Name = "PLNT"; @@ -43,12 +45,11 @@ Element_PLNT::Element_PLNT() HighTemperature = 573.0f; HighTemperatureTransition = PT_FIRE; - Update = &Element_PLNT::update; - Graphics = &Element_PLNT::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_PLNT static int update(UPDATE_FUNC_ARGS) -int Element_PLNT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, np, rndstore; for (rx=-1; rx<2; rx++) @@ -120,8 +121,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PLNT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PLNT::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { float maxtemp = std::max((float)cpart->tmp2, cpart->temp); if (maxtemp > 300) @@ -137,6 +137,3 @@ int Element_PLNT::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_PLNT::~Element_PLNT() {} diff --git a/src/simulation/elements/PLSM.cpp b/src/simulation/elements/PLSM.cpp index 397c3e8a6..660e941ee 100644 --- a/src/simulation/elements/PLSM.cpp +++ b/src/simulation/elements/PLSM.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PLSM PT_PLSM 49 -Element_PLSM::Element_PLSM() + +int Element_FIRE_update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_PLSM() { Identifier = "DEFAULT_PT_PLSM"; Name = "PLSM"; @@ -41,14 +45,12 @@ Element_PLSM::Element_PLSM() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_FIRE::update; - Graphics = &Element_PLSM::graphics; - Create = &Element_PLSM::create; + Update = &Element_FIRE_update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_PLSM static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PLSM::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)ren->plasma_data[caddress]; @@ -66,10 +68,7 @@ int Element_PLSM::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PLSM static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_PLSM::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].life = RNG::Ref().between(50, 199); } - -Element_PLSM::~Element_PLSM() {} diff --git a/src/simulation/elements/PLUT.cpp b/src/simulation/elements/PLUT.cpp index 545732e65..bb2914780 100644 --- a/src/simulation/elements/PLUT.cpp +++ b/src/simulation/elements/PLUT.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PLUT PT_PLUT 19 -Element_PLUT::Element_PLUT() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_PLUT() { Identifier = "DEFAULT_PT_PLUT"; Name = "PLUT"; @@ -42,11 +44,10 @@ Element_PLUT::Element_PLUT() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PLUT::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_PLUT static int update(UPDATE_FUNC_ARGS) -int Element_PLUT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (RNG::Ref().chance(1, 100) && RNG::Ref().chance(5.0f*sim->pv[y/CELL][x/CELL], 1000)) { @@ -54,6 +55,3 @@ int Element_PLUT::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_PLUT::~Element_PLUT() {} diff --git a/src/simulation/elements/POLO.cpp b/src/simulation/elements/POLO.cpp index 4875193c9..fdd8ba8ca 100644 --- a/src/simulation/elements/POLO.cpp +++ b/src/simulation/elements/POLO.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_POLO PT_POLO 182 -Element_POLO::Element_POLO() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_POLO() { Identifier = "DEFAULT_PT_POLO"; Name = "POLO"; @@ -42,15 +45,14 @@ Element_POLO::Element_POLO() HighTemperature = 526.95f; HighTemperatureTransition = PT_LAVA; - Update = &Element_POLO::update; - Graphics = &Element_POLO::graphics; + Update = &update; + Graphics = &graphics; } -#define COOLDOWN 15 -#define LIMIT 5 +constexpr int COOLDOWN = 15; +constexpr int LIMIT = 5; -//#TPT-Directive ElementHeader Element_POLO static int update(UPDATE_FUNC_ARGS) -int Element_POLO::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r = sim->photons[y][x]; if (parts[i].tmp < LIMIT && !parts[i].life) @@ -103,8 +105,7 @@ int Element_POLO::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_POLO static int graphics(GRAPHICS_FUNC_ARGS) -int Element_POLO::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { if (cpart->tmp >= LIMIT) { @@ -117,5 +118,3 @@ int Element_POLO::graphics(GRAPHICS_FUNC_ARGS) return 0; } - -Element_POLO::~Element_POLO() {} diff --git a/src/simulation/elements/PPIP.cpp b/src/simulation/elements/PPIP.cpp index 938060d6a..bd49414fb 100644 --- a/src/simulation/elements/PPIP.cpp +++ b/src/simulation/elements/PPIP.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PPIP PT_PPIP 161 -Element_PPIP::Element_PPIP() + +int Element_PIPE_update(UPDATE_FUNC_ARGS); +int Element_PIPE_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_PPIP() { Identifier = "DEFAULT_PT_PPIP"; Name = "PPIP"; @@ -43,20 +46,20 @@ Element_PPIP::Element_PPIP() DefaultProperties.life = 60; - Update = &Element_PIPE::update; - Graphics = &Element_PIPE::graphics; + Update = &Element_PIPE_update; + Graphics = &Element_PIPE_graphics; } -#define PFLAG_NORMALSPEED 0x00010000 +constexpr int PFLAG_NORMALSPEED = 0x00010000; // parts[].tmp flags // trigger flags to be processed this frame (trigger flags for next frame are shifted 3 bits to the left): -#define PPIP_TMPFLAG_TRIGGER_ON 0x10000000 -#define PPIP_TMPFLAG_TRIGGER_OFF 0x08000000 -#define PPIP_TMPFLAG_TRIGGER_REVERSE 0x04000000 -#define PPIP_TMPFLAG_TRIGGERS 0x1C000000 +constexpr int PPIP_TMPFLAG_TRIGGER_ON = 0x10000000; +constexpr int PPIP_TMPFLAG_TRIGGER_OFF = 0x08000000; +constexpr int PPIP_TMPFLAG_TRIGGER_REVERSE = 0x04000000; +constexpr int PPIP_TMPFLAG_TRIGGERS = 0x1C000000; // current status of the pipe -#define PPIP_TMPFLAG_PAUSED 0x02000000 -#define PPIP_TMPFLAG_REVERSED 0x01000000 +constexpr int PPIP_TMPFLAG_PAUSED = 0x02000000; +constexpr int PPIP_TMPFLAG_REVERSED = 0x01000000; // 0x000000FF element // 0x00000100 is single pixel pipe // 0x00000200 will transfer like a single pixel pipe when in forward mode @@ -64,11 +67,9 @@ Element_PPIP::Element_PPIP() // 0x00002000 will transfer like a single pixel pipe when in reverse mode // 0x0001C000 reverse single pixel pipe direction -//#TPT-Directive ElementHeader Element_PPIP static int ppip_changed -int Element_PPIP::ppip_changed = 0; +int Element_PPIP_ppip_changed = 0; -//#TPT-Directive ElementHeader Element_PPIP static void flood_trigger(Simulation * sim, int x, int y, int sparkedBy) -void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy) +void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy) { int coord_stack_limit = XRES*YRES; unsigned short (*coord_stack)[2]; @@ -121,7 +122,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy) for (x=x1; x<=x2; x++) { if (!(parts[ID(pmap[y][x])].tmp & prop)) - ppip_changed = 1; + Element_PPIP_ppip_changed = 1; parts[ID(pmap[y][x])].tmp |= prop; } @@ -157,5 +158,3 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy) } while (coord_stack_size>0); delete[] coord_stack; } - -Element_PPIP::~Element_PPIP() {} diff --git a/src/simulation/elements/PQRT.cpp b/src/simulation/elements/PQRT.cpp index 242375d57..99962a0f0 100644 --- a/src/simulation/elements/PQRT.cpp +++ b/src/simulation/elements/PQRT.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PQRT PT_PQRT 133 -Element_PQRT::Element_PQRT() + +int Element_QRTZ_update(UPDATE_FUNC_ARGS); +int Element_QRTZ_graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_PQRT() { Identifier = "DEFAULT_PT_PQRT"; Name = "PQRT"; @@ -40,15 +44,12 @@ Element_PQRT::Element_PQRT() HighTemperature = 2573.15f; HighTemperatureTransition = PT_LAVA; - Update = &Element_QRTZ::update; - Graphics = &Element_QRTZ::graphics; - Create = &Element_PQRT::create; + Update = &Element_QRTZ_update; + Graphics = &Element_QRTZ_graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_PQRT static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_PQRT::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].tmp2 = RNG::Ref().between(0, 10); } - -Element_PQRT::~Element_PQRT() {} diff --git a/src/simulation/elements/PROT.cpp b/src/simulation/elements/PROT.cpp index 24613828b..992de405a 100644 --- a/src/simulation/elements/PROT.cpp +++ b/src/simulation/elements/PROT.cpp @@ -1,6 +1,11 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PROT PT_PROT 173 -Element_PROT::Element_PROT() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +static int DeutImplosion(Simulation * sim, int n, int x, int y, float temp, int t); + +void Element::Element_PROT() { Identifier = "DEFAULT_PT_PROT"; Name = "PROT"; @@ -42,13 +47,12 @@ Element_PROT::Element_PROT() DefaultProperties.life = 75; - Update = &Element_PROT::update; - Graphics = &Element_PROT::graphics; - Create = &Element_PROT::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_PROT static int update(UPDATE_FUNC_ARGS) -int Element_PROT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { sim->pv[y/CELL][x/CELL] -= .003f; int under = pmap[y][x]; @@ -171,8 +175,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PROT static int DeutImplosion(Simulation * sim, int n, int x, int y, float temp, int t) -int Element_PROT::DeutImplosion(Simulation * sim, int n, int x, int y, float temp, int t) +static int DeutImplosion(Simulation * sim, int n, int x, int y, float temp, int t) { int i; n = (n/50); @@ -193,8 +196,7 @@ int Element_PROT::DeutImplosion(Simulation * sim, int n, int x, int y, float tem return 0; } -//#TPT-Directive ElementHeader Element_PROT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PROT::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 7; *firer = 250; @@ -205,13 +207,10 @@ int Element_PROT::graphics(GRAPHICS_FUNC_ARGS) return 1; } -//#TPT-Directive ElementHeader Element_PROT static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_PROT::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { float a = RNG::Ref().between(0, 35) * 0.17453f; sim->parts[i].life = 680; sim->parts[i].vx = 2.0f * cosf(a); sim->parts[i].vy = 2.0f * sinf(a); } - -Element_PROT::~Element_PROT() {} diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp index 56a853bb1..90a933409 100644 --- a/src/simulation/elements/PRTI.cpp +++ b/src/simulation/elements/PRTI.cpp @@ -1,6 +1,11 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PRTI PT_PRTI 109 -Element_PRTI::Element_PRTI() + +void Element_PIPE_transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR); +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +void Element_SOAP_detach(Simulation * sim, int i); + +void Element::Element_PRTI() { Identifier = "DEFAULT_PT_PRTI"; Name = "PRTI"; @@ -40,8 +45,8 @@ Element_PRTI::Element_PRTI() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PRTI::update; - Graphics = &Element_PRTI::graphics; + Update = &update; + Graphics = &graphics; } /*these are the count values of where the particle gets stored, depending on where it came from @@ -52,8 +57,7 @@ Element_PRTI::Element_PRTI() PRTO does +/-1 to the count, so it doesn't jam as easily */ -//#TPT-Directive ElementHeader Element_PRTI static int update(UPDATE_FUNC_ARGS) -int Element_PRTI::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int fe = 0; @@ -83,7 +87,7 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS) continue;// Handling these is a bit more complicated, and is done in STKM_interact() if (TYP(r) == PT_SOAP) - Element_SOAP::detach(sim, ID(r)); + Element_SOAP_detach(sim, ID(r)); for (int nnx=0; nnx<80; nnx++) if (!sim->portalp[parts[i].tmp][count][nnx].type) @@ -93,7 +97,7 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS) if (sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) { // STOR uses same format as PIPE, so we can use this function to do the transfer - Element_PIPE::transfer_pipe_to_part(sim, parts+(ID(r)), &sim->portalp[parts[i].tmp][count][nnx], true); + Element_PIPE_transfer_pipe_to_part(sim, parts+(ID(r)), &sim->portalp[parts[i].tmp][count][nnx], true); break; } } @@ -141,10 +145,7 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_PRTI static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PRTI::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 8; *firer = 255; @@ -156,6 +157,3 @@ int Element_PRTI::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_ADD; return 1; } - - -Element_PRTI::~Element_PRTI() {} diff --git a/src/simulation/elements/PRTO.cpp b/src/simulation/elements/PRTO.cpp index 2d6a99ad8..7dfbd38f1 100644 --- a/src/simulation/elements/PRTO.cpp +++ b/src/simulation/elements/PRTO.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PRTO PT_PRTO 110 -Element_PRTO::Element_PRTO() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_PRTO() { Identifier = "DEFAULT_PT_PRTO"; Name = "PRTO"; @@ -40,8 +43,8 @@ Element_PRTO::Element_PRTO() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PRTO::update; - Graphics = &Element_PRTO::graphics; + Update = &update; + Graphics = &graphics; } /*these are the count values of where the particle gets stored, depending on where it came from @@ -52,8 +55,7 @@ Element_PRTO::Element_PRTO() PRTO does +/-1 to the count, so it doesn't jam as easily */ -//#TPT-Directive ElementHeader Element_PRTO static int update(UPDATE_FUNC_ARGS) -int Element_PRTO::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, nnx, rx, ry, np, fe = 0; int count = 0; @@ -170,10 +172,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_PRTO static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PRTO::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 8; *firer = 0; @@ -185,6 +184,3 @@ int Element_PRTO::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_ADD; return 1; } - - -Element_PRTO::~Element_PRTO() {} diff --git a/src/simulation/elements/PSCN.cpp b/src/simulation/elements/PSCN.cpp index cb2adc59e..b5a5900c9 100644 --- a/src/simulation/elements/PSCN.cpp +++ b/src/simulation/elements/PSCN.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PSCN PT_PSCN 35 -Element_PSCN::Element_PSCN() + +void Element::Element_PSCN() { Identifier = "DEFAULT_PT_PSCN"; Name = "PSCN"; @@ -40,8 +40,4 @@ Element_PSCN::Element_PSCN() LowTemperatureTransition = NT; HighTemperature = 1687.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_PSCN::~Element_PSCN() {} diff --git a/src/simulation/elements/PSNS.cpp b/src/simulation/elements/PSNS.cpp index e1b57b0f3..371d9d4a2 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PSNS PT_PSNS 172 -Element_PSNS::Element_PSNS() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_PSNS() { Identifier = "DEFAULT_PT_PSNS"; Name = "PSNS"; @@ -41,11 +43,10 @@ Element_PSNS::Element_PSNS() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PSNS::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_PSNS static int update(UPDATE_FUNC_ARGS) -int Element_PSNS::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; if ((parts[i].tmp == 0 && sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f) || (parts[i].tmp == 2 && sim->pv[y/CELL][x/CELL] < parts[i].temp-273.15f)) @@ -101,7 +102,3 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS) } return 0; } - - - -Element_PSNS::~Element_PSNS() {} diff --git a/src/simulation/elements/PSTE.cpp b/src/simulation/elements/PSTE.cpp index 2af802704..09b3791c3 100644 --- a/src/simulation/elements/PSTE.cpp +++ b/src/simulation/elements/PSTE.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PSTE PT_PSTE 111 -Element_PSTE::Element_PSTE() + +void Element::Element_PSTE() { Identifier = "DEFAULT_PT_PSTE"; Name = "PSTE"; @@ -40,8 +40,4 @@ Element_PSTE::Element_PSTE() LowTemperatureTransition = NT; HighTemperature = 747.0f; HighTemperatureTransition = PT_BRCK; - - Update = NULL; } - -Element_PSTE::~Element_PSTE() {} diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index 199110242..94693d528 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -1,8 +1,14 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PSTN PT_PSTN 168 -Element_PSTN::Element_PSTN() +struct StackData; +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS); +static StackData CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block); +static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block, bool sticky, int callDepth = 0); + +void Element::Element_PSTN() { Identifier = "DEFAULT_PT_PSTN"; Name = "PSTN"; @@ -43,13 +49,12 @@ Element_PSTN::Element_PSTN() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PSTN::update; - Graphics = &Element_PSTN::graphics; - CtypeDraw = &Element_PSTN::ctypeDraw; + Update = &update; + Graphics = &graphics; + CtypeDraw = &ctypeDraw; } -//#TPT-Directive ElementHeader Element_PSTN struct StackData -struct Element_PSTN::StackData +struct StackData { int pushed; int spaces; @@ -61,18 +66,16 @@ struct Element_PSTN::StackData } }; -//#TPT-Directive ElementHeader Element_PSTN static int tempParts[XRES] -int Element_PSTN::tempParts[XRES]; +int tempParts[XRES]; -#define PISTON_INACTIVE 0x00 -#define PISTON_RETRACT 0x01 -#define PISTON_EXTEND 0x02 -#define MAX_FRAME 0x0F -#define DEFAULT_LIMIT 0x1F -#define DEFAULT_ARM_LIMIT 0xFF +constexpr int PISTON_INACTIVE = 0x00; +constexpr int PISTON_RETRACT = 0x01; +constexpr int PISTON_EXTEND = 0x02; +constexpr int MAX_FRAME = 0x0F; +constexpr int DEFAULT_LIMIT = 0x1F; +constexpr int DEFAULT_ARM_LIMIT = 0xFF; -//#TPT-Directive ElementHeader Element_PSTN static int update(UPDATE_FUNC_ARGS) -int Element_PSTN::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if(parts[i].life) return 0; @@ -191,8 +194,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PSTN static StackData CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block) -Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block) +static StackData CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block) { int posX, posY, r, spaces = 0, currentPos = 0; if (amount <= 0) @@ -223,8 +225,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX, return StackData(currentPos - spaces, spaces); } -//#TPT-Directive ElementHeader Element_PSTN static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block, bool sticky, int callDepth = 0) -int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block, bool sticky, int callDepth) +static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block, bool sticky, int callDepth) { int posX, posY, r; r = sim->pmap[stackY][stackX]; @@ -337,9 +338,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct return 0; } - -//#TPT-Directive ElementHeader Element_PSTN static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PSTN::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->life) { @@ -349,8 +348,7 @@ int Element_PSTN::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_PSTN static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) -bool Element_PSTN::ctypeDraw(CTYPEDRAW_FUNC_ARGS) +static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) { if (t == PT_FRME) { @@ -358,5 +356,3 @@ bool Element_PSTN::ctypeDraw(CTYPEDRAW_FUNC_ARGS) } return Element::basicCtypeDraw(CTYPEDRAW_FUNC_SUBCALL_ARGS); } - -Element_PSTN::~Element_PSTN() {} diff --git a/src/simulation/elements/PSTS.cpp b/src/simulation/elements/PSTS.cpp index 00a1c9162..816f046f0 100644 --- a/src/simulation/elements/PSTS.cpp +++ b/src/simulation/elements/PSTS.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PSTS PT_PSTS 112 -Element_PSTS::Element_PSTS() + +void Element::Element_PSTS() { Identifier = "DEFAULT_PT_PSTS"; Name = "PSTS"; @@ -40,8 +40,4 @@ Element_PSTS::Element_PSTS() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_PSTS::~Element_PSTS() {} diff --git a/src/simulation/elements/PTCT.cpp b/src/simulation/elements/PTCT.cpp index 012b953e9..bc5dadb69 100644 --- a/src/simulation/elements/PTCT.cpp +++ b/src/simulation/elements/PTCT.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PTCT PT_PTCT 46 -Element_PTCT::Element_PTCT() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_PTCT() { Identifier = "DEFAULT_PT_PTCT"; Name = "PTCT"; @@ -40,16 +42,12 @@ Element_PTCT::Element_PTCT() HighTemperature = 1687.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_PTCT::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_PTCT static int update(UPDATE_FUNC_ARGS) -int Element_PTCT::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].temp>295.0f) parts[i].temp -= 2.5f; return 0; } - - -Element_PTCT::~Element_PTCT() {} diff --git a/src/simulation/elements/PUMP.cpp b/src/simulation/elements/PUMP.cpp index 1af14c3d0..a0bef227e 100644 --- a/src/simulation/elements/PUMP.cpp +++ b/src/simulation/elements/PUMP.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PUMP PT_PUMP 97 -Element_PUMP::Element_PUMP() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_PUMP() { Identifier = "DEFAULT_PT_PUMP"; Name = "PUMP"; @@ -43,12 +46,11 @@ Element_PUMP::Element_PUMP() DefaultProperties.life = 10; - Update = &Element_PUMP::update; - Graphics = &Element_PUMP::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_PUMP static int update(UPDATE_FUNC_ARGS) -int Element_PUMP::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life != 10) @@ -103,15 +105,9 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_PUMP static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PUMP::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int lifemod = ((cpart->life>10?10:cpart->life)*19); *colb += lifemod; return 0; } - - -Element_PUMP::~Element_PUMP() {} diff --git a/src/simulation/elements/PVOD.cpp b/src/simulation/elements/PVOD.cpp index 28f4411fe..457c06bf9 100644 --- a/src/simulation/elements/PVOD.cpp +++ b/src/simulation/elements/PVOD.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_PVOD PT_PVOD 84 -Element_PVOD::Element_PVOD() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_PVOD() { Identifier = "DEFAULT_PT_PVOD"; Name = "PVOD"; @@ -40,12 +43,11 @@ Element_PVOD::Element_PVOD() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_PVOD::update; - Graphics = &Element_PVOD::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_PVOD static int update(UPDATE_FUNC_ARGS) -int Element_PVOD::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; if (parts[i].life>0 && parts[i].life!=10) @@ -78,15 +80,9 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_PVOD static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PVOD::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { int lifemod = ((cpart->life>10?10:cpart->life)*16); *colr += lifemod; return 0; } - - -Element_PVOD::~Element_PVOD() {} diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp index 4e7281fce..8f49f2ba6 100644 --- a/src/simulation/elements/QRTZ.cpp +++ b/src/simulation/elements/QRTZ.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_QRTZ PT_QRTZ 132 -Element_QRTZ::Element_QRTZ() + +int Element_QRTZ_update(UPDATE_FUNC_ARGS); +int Element_QRTZ_graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_QRTZ() { Identifier = "DEFAULT_PT_QRTZ"; Name = "QRTZ"; @@ -40,13 +44,12 @@ Element_QRTZ::Element_QRTZ() HighTemperature = 2573.15f; HighTemperatureTransition = PT_LAVA; - Update = &Element_QRTZ::update; - Graphics = &Element_QRTZ::graphics; - Create = &Element_QRTZ::create; + Update = &Element_QRTZ_update; + Graphics = &Element_QRTZ_graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_QRTZ static int update(UPDATE_FUNC_ARGS) -int Element_QRTZ::update(UPDATE_FUNC_ARGS) +int Element_QRTZ_update(UPDATE_FUNC_ARGS) { int r, tmp, trade, rx, ry, np, t = parts[i].type; if (t == PT_QRTZ) @@ -144,9 +147,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_QRTZ static int graphics(GRAPHICS_FUNC_ARGS) -int Element_QRTZ::graphics(GRAPHICS_FUNC_ARGS) +int Element_QRTZ_graphics(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT { int z = (cpart->tmp2 - 5) * 16;//speckles! @@ -156,11 +157,8 @@ int Element_QRTZ::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_QRTZ static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_QRTZ::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].tmp2 = RNG::Ref().between(0, 10); sim->parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; } - -Element_QRTZ::~Element_QRTZ() {} diff --git a/src/simulation/elements/RBDM.cpp b/src/simulation/elements/RBDM.cpp index c3e3b2cf1..395274b81 100644 --- a/src/simulation/elements/RBDM.cpp +++ b/src/simulation/elements/RBDM.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_RBDM PT_RBDM 41 -Element_RBDM::Element_RBDM() + +void Element::Element_RBDM() { Identifier = "DEFAULT_PT_RBDM"; Name = "RBDM"; @@ -39,8 +39,4 @@ Element_RBDM::Element_RBDM() LowTemperatureTransition = NT; HighTemperature = 312.0f; HighTemperatureTransition = PT_LRBD; - - Update = NULL; } - -Element_RBDM::~Element_RBDM() {} diff --git a/src/simulation/elements/RFGL.cpp b/src/simulation/elements/RFGL.cpp index 196ec45a0..16a95ae69 100644 --- a/src/simulation/elements/RFGL.cpp +++ b/src/simulation/elements/RFGL.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_RFGL PT_RFGL 184 -Element_RFGL::Element_RFGL() + +int Element_RFRG_update(UPDATE_FUNC_ARGS); + +void Element::Element_RFGL() { Identifier = "DEFAULT_PT_RFGL"; Name = "RFGL"; @@ -40,7 +42,5 @@ Element_RFGL::Element_RFGL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_RFRG::update; + Update = &Element_RFRG_update; } - -Element_RFGL::~Element_RFGL() {} diff --git a/src/simulation/elements/RFRG.cpp b/src/simulation/elements/RFRG.cpp index d5865fde2..f072b3a88 100644 --- a/src/simulation/elements/RFRG.cpp +++ b/src/simulation/elements/RFRG.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_RFRG PT_RFRG 183 -Element_RFRG::Element_RFRG() + +int Element_RFRG_update(UPDATE_FUNC_ARGS); + +void Element::Element_RFRG() { Identifier = "DEFAULT_PT_RFRG"; Name = "RFRG"; @@ -40,11 +42,10 @@ Element_RFRG::Element_RFRG() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_RFRG::update; + Update = &Element_RFRG_update; } -//#TPT-Directive ElementHeader Element_RFRG static int update(UPDATE_FUNC_ARGS) -int Element_RFRG::update(UPDATE_FUNC_ARGS) +int Element_RFRG_update(UPDATE_FUNC_ARGS) { float new_pressure = sim->pv[y/CELL][x/CELL]; float *old_pressure = (float *)&parts[i].tmp; @@ -62,6 +63,3 @@ int Element_RFRG::update(UPDATE_FUNC_ARGS) *old_pressure = new_pressure; return 0; } - - -Element_RFRG::~Element_RFRG() {} diff --git a/src/simulation/elements/RIME.cpp b/src/simulation/elements/RIME.cpp index 8300be81c..1bee19ea1 100644 --- a/src/simulation/elements/RIME.cpp +++ b/src/simulation/elements/RIME.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_RIME PT_RIME 91 -Element_RIME::Element_RIME() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_RIME() { Identifier = "DEFAULT_PT_RIME"; Name = "RIME"; @@ -41,11 +43,10 @@ Element_RIME::Element_RIME() HighTemperature = 273.15f; HighTemperatureTransition = PT_WATR; - Update = &Element_RIME::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_RIME static int update(UPDATE_FUNC_ARGS) -int Element_RIME::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -68,6 +69,3 @@ int Element_RIME::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_RIME::~Element_RIME() {} diff --git a/src/simulation/elements/RPEL.cpp b/src/simulation/elements/RPEL.cpp index 42e1343e6..a1dfdf351 100644 --- a/src/simulation/elements/RPEL.cpp +++ b/src/simulation/elements/RPEL.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_RPEL PT_RPEL 160 -Element_RPEL::Element_RPEL() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_RPEL() { Identifier = "DEFAULT_PT_RPEL"; Name = "RPEL"; @@ -41,12 +43,11 @@ Element_RPEL::Element_RPEL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_RPEL::update; + Update = &update; CtypeDraw = &Element::basicCtypeDraw; } -//#TPT-Directive ElementHeader Element_RPEL static int update(UPDATE_FUNC_ARGS) -int Element_RPEL::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, ri; for(ri = 0; ri <= 10; ri++) @@ -69,6 +70,3 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_RPEL::~Element_RPEL() {} diff --git a/src/simulation/elements/SALT.cpp b/src/simulation/elements/SALT.cpp index 45d0c2417..9e4f0c89a 100644 --- a/src/simulation/elements/SALT.cpp +++ b/src/simulation/elements/SALT.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SALT PT_SALT 26 -Element_SALT::Element_SALT() + +void Element::Element_SALT() { Identifier = "DEFAULT_PT_SALT"; Name = "SALT"; @@ -39,8 +39,4 @@ Element_SALT::Element_SALT() LowTemperatureTransition = NT; HighTemperature = 1173.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_SALT::~Element_SALT() {} diff --git a/src/simulation/elements/SAND.cpp b/src/simulation/elements/SAND.cpp index db3e5cd33..14c6e50db 100644 --- a/src/simulation/elements/SAND.cpp +++ b/src/simulation/elements/SAND.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SAND PT_SAND 44 -Element_SAND::Element_SAND() + +void Element::Element_SAND() { Identifier = "DEFAULT_PT_SAND"; Name = "SAND"; @@ -39,8 +39,4 @@ Element_SAND::Element_SAND() LowTemperatureTransition = NT; HighTemperature = 1973.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_SAND::~Element_SAND() {} diff --git a/src/simulation/elements/SAWD.cpp b/src/simulation/elements/SAWD.cpp index fb50a168e..cbbd8378d 100644 --- a/src/simulation/elements/SAWD.cpp +++ b/src/simulation/elements/SAWD.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SAWD PT_SAWD 181 -Element_SAWD::Element_SAWD() + +void Element::Element_SAWD() { Identifier = "DEFAULT_PT_SAWD"; Name = "SAWD"; @@ -40,8 +40,5 @@ Element_SAWD::Element_SAWD() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Graphics = NULL; + Graphics = NULL; // is this needed? } - -Element_SAWD::~Element_SAWD() {} diff --git a/src/simulation/elements/SHLD1.cpp b/src/simulation/elements/SHLD1.cpp index d0a232b4e..5dc8b8ed8 100644 --- a/src/simulation/elements/SHLD1.cpp +++ b/src/simulation/elements/SHLD1.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SHLD1 PT_SHLD1 119 -Element_SHLD1::Element_SHLD1() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_SHLD1() { Identifier = "DEFAULT_PT_SHLD1"; Name = "SHLD"; @@ -40,11 +42,10 @@ Element_SHLD1::Element_SHLD1() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SHLD1::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_SHLD1 static int update(UPDATE_FUNC_ARGS) -int Element_SHLD1::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, nnx, nny, rx, ry; for (rx=-1; rx<2; rx++) @@ -79,7 +80,3 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS) } return 0; } - - - -Element_SHLD1::~Element_SHLD1() {} diff --git a/src/simulation/elements/SHLD2.cpp b/src/simulation/elements/SHLD2.cpp index 86128ddd2..d9b081d1c 100644 --- a/src/simulation/elements/SHLD2.cpp +++ b/src/simulation/elements/SHLD2.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SHLD2 PT_SHLD2 120 -Element_SHLD2::Element_SHLD2() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_SHLD2() { Identifier = "DEFAULT_PT_SHLD2"; Name = "SHD2"; @@ -40,11 +42,10 @@ Element_SHLD2::Element_SHLD2() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SHLD2::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_SHLD2 static int update(UPDATE_FUNC_ARGS) -int Element_SHLD2::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, nnx, nny, rx, ry, np; for (rx=-1; rx<2; rx++) @@ -84,7 +85,3 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS) } return 0; } - - - -Element_SHLD2::~Element_SHLD2() {} diff --git a/src/simulation/elements/SHLD3.cpp b/src/simulation/elements/SHLD3.cpp index 69bc916e8..882a5f56f 100644 --- a/src/simulation/elements/SHLD3.cpp +++ b/src/simulation/elements/SHLD3.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SHLD3 PT_SHLD3 121 -Element_SHLD3::Element_SHLD3() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_SHLD3() { Identifier = "DEFAULT_PT_SHLD3"; Name = "SHD3"; @@ -40,11 +42,10 @@ Element_SHLD3::Element_SHLD3() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SHLD3::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_SHLD3 static int update(UPDATE_FUNC_ARGS) -int Element_SHLD3::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, nnx, nny, rx, ry, np; for (rx=-1; rx<2; rx++) @@ -90,7 +91,3 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS) } return 0; } - - - -Element_SHLD3::~Element_SHLD3() {} diff --git a/src/simulation/elements/SHLD4.cpp b/src/simulation/elements/SHLD4.cpp index 70b7288c6..e57d18c5a 100644 --- a/src/simulation/elements/SHLD4.cpp +++ b/src/simulation/elements/SHLD4.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SHLD4 PT_SHLD4 122 -Element_SHLD4::Element_SHLD4() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_SHLD4() { Identifier = "DEFAULT_PT_SHLD4"; Name = "SHD4"; @@ -40,11 +42,10 @@ Element_SHLD4::Element_SHLD4() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SHLD4::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_SHLD4 static int update(UPDATE_FUNC_ARGS) -int Element_SHLD4::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, nnx, nny, rx, ry, np; for (rx=-1; rx<2; rx++) @@ -83,6 +84,3 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_SHLD4::~Element_SHLD4() {} diff --git a/src/simulation/elements/SING.cpp b/src/simulation/elements/SING.cpp index 26a2b56d5..99619085f 100644 --- a/src/simulation/elements/SING.cpp +++ b/src/simulation/elements/SING.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SING PT_SING 131 -Element_SING::Element_SING() + +static int update(UPDATE_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_SING() { Identifier = "DEFAULT_PT_SING"; Name = "SING"; @@ -40,12 +43,11 @@ Element_SING::Element_SING() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SING::update; - Create = &Element_SING::create; + Update = &update; + Create = &create; } -//#TPT-Directive ElementHeader Element_SING static int update(UPDATE_FUNC_ARGS) -int Element_SING::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, cry, crx, nb, spawncount; int singularity = -parts[i].life; @@ -141,10 +143,7 @@ int Element_SING::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_SING static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_SING::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].life = RNG::Ref().between(60, 109); } - -Element_SING::~Element_SING() {} diff --git a/src/simulation/elements/SLTW.cpp b/src/simulation/elements/SLTW.cpp index 134aa41be..da58ba4d0 100644 --- a/src/simulation/elements/SLTW.cpp +++ b/src/simulation/elements/SLTW.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SLTW PT_SLTW 27 -Element_SLTW::Element_SLTW() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_SLTW() { Identifier = "DEFAULT_PT_SLTW"; Name = "SLTW"; @@ -40,11 +42,10 @@ Element_SLTW::Element_SLTW() HighTemperature = 383.0f; HighTemperatureTransition = ST; - Update = &Element_SLTW::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_SLTW static int update(UPDATE_FUNC_ARGS) -int Element_SLTW::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -90,6 +91,3 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_SLTW::~Element_SLTW() {} diff --git a/src/simulation/elements/SMKE.cpp b/src/simulation/elements/SMKE.cpp index e7a744668..82fde602e 100644 --- a/src/simulation/elements/SMKE.cpp +++ b/src/simulation/elements/SMKE.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SMKE PT_SMKE 57 -Element_SMKE::Element_SMKE() + +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_SMKE() { Identifier = "DEFAULT_PT_SMKE"; Name = "SMKE"; @@ -41,13 +43,10 @@ Element_SMKE::Element_SMKE() HighTemperature = 625.0f; HighTemperatureTransition = PT_FIRE; - Update = NULL; - Graphics = &Element_SMKE::graphics; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_SMKE static int graphics(GRAPHICS_FUNC_ARGS) -int Element_SMKE::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *colr = 55; *colg = 55; @@ -63,5 +62,3 @@ int Element_SMKE::graphics(GRAPHICS_FUNC_ARGS) //Returning 1 means static, cache as we please return 1; } - -Element_SMKE::~Element_SMKE() {} diff --git a/src/simulation/elements/SNOW.cpp b/src/simulation/elements/SNOW.cpp index eaa9140db..33c6be4d3 100644 --- a/src/simulation/elements/SNOW.cpp +++ b/src/simulation/elements/SNOW.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SNOW PT_SNOW 16 -Element_SNOW::Element_SNOW() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_SNOW() { Identifier = "DEFAULT_PT_SNOW"; Name = "SNOW"; @@ -42,12 +44,11 @@ Element_SNOW::Element_SNOW() HighTemperature = 252.05f; HighTemperatureTransition = ST; - Update = &Element_SNOW::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_SNOW static int update(UPDATE_FUNC_ARGS) -int Element_SNOW::update(UPDATE_FUNC_ARGS) - { //currently used for snow as well +static int update(UPDATE_FUNC_ARGS) +{ int r, rx, ry; if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW { @@ -68,6 +69,3 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_SNOW::~Element_SNOW() {} diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index 830e6243b..7a183db92 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SOAP PT_SOAP 149 -Element_SOAP::Element_SOAP() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); + +void Element::Element_SOAP() { Identifier = "DEFAULT_PT_SOAP"; Name = "SOAP"; @@ -44,13 +48,12 @@ Element_SOAP::Element_SOAP() DefaultProperties.tmp = -1; DefaultProperties.tmp2 = -1; - Update = &Element_SOAP::update; - Graphics = &Element_SOAP::graphics; - ChangeType = &Element_SOAP::changeType; + Update = &update; + Graphics = &graphics; + ChangeType = &changeType; } -//#TPT-Directive ElementHeader Element_SOAP static void detach(Simulation * sim, int i) -void Element_SOAP::detach(Simulation * sim, int i) +void Element_SOAP_detach(Simulation * sim, int i) { if ((sim->parts[i].ctype&2) == 2 && sim->parts[i].tmp >= 0 && sim->parts[i].tmp < NPART && sim->parts[sim->parts[i].tmp].type == PT_SOAP) { @@ -67,8 +70,7 @@ void Element_SOAP::detach(Simulation * sim, int i) sim->parts[i].ctype = 0; } -//#TPT-Directive ElementHeader Element_SOAP static void attach(Particle * parts, int i1, int i2) -void Element_SOAP::attach(Particle * parts, int i1, int i2) +static void attach(Particle * parts, int i1, int i2) { if (!(parts[i2].ctype&4)) { @@ -88,12 +90,10 @@ void Element_SOAP::attach(Particle * parts, int i1, int i2) } } -#define FREEZING 248.15f -#define BLEND 0.85f - -//#TPT-Directive ElementHeader Element_SOAP static int update(UPDATE_FUNC_ARGS) -int Element_SOAP::update(UPDATE_FUNC_ARGS) +constexpr float FREEZING = 248.15f; +constexpr float BLEND = 0.85f; +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, nr, ng, nb, na; float tr, tg, tb, ta; @@ -124,19 +124,19 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) if (parts[target].ctype&2) { target = parts[target].tmp; - detach(sim, target); + Element_SOAP_detach(sim, target); } if (parts[target].ctype&4) { target = parts[target].tmp2; - detach(sim, target); + Element_SOAP_detach(sim, target); } } } if ((parts[i].ctype&6) != 6) parts[i].ctype = 0; if ((parts[i].ctype&6) == 6 && (parts[parts[i].tmp].ctype&6) == 6 && parts[parts[i].tmp].tmp == i) - detach(sim, i); + Element_SOAP_detach(sim, i); } parts[i].vy = (parts[i].vy-0.1f)*0.5f; parts[i].vx *= 0.5f; @@ -151,7 +151,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) if (!r) continue; if ((parts[ID(r)].type == PT_SOAP) && (parts[ID(r)].ctype&1) && !(parts[ID(r)].ctype&4)) - Element_SOAP::attach(parts, i, ID(r)); + attach(parts, i, ID(r)); } } else @@ -170,7 +170,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) || (r && !(sim->elements[TYP(r)].Properties&TYPE_GAS) && TYP(r) != PT_SOAP && TYP(r) != PT_GLAS)) { - detach(sim, i); + Element_SOAP_detach(sim, i); continue; } } @@ -275,21 +275,16 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_SOAP static int graphics(GRAPHICS_FUNC_ARGS) -int Element_SOAP::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *pixel_mode |= EFFECT_LINES|PMODE_BLUR; return 1; } -//#TPT-Directive ElementHeader Element_SOAP static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_SOAP::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (from == PT_SOAP && to != PT_SOAP) { - detach(sim, i); + Element_SOAP_detach(sim, i); } } - -Element_SOAP::~Element_SOAP() {} diff --git a/src/simulation/elements/SPAWN.cpp b/src/simulation/elements/SPAWN.cpp index fc027847c..2641151ac 100644 --- a/src/simulation/elements/SPAWN.cpp +++ b/src/simulation/elements/SPAWN.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SPAWN PT_SPAWN 118 -Element_SPAWN::Element_SPAWN() + +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); + +void Element::Element_SPAWN() { Identifier = "DEFAULT_PT_SPAWN"; Name = "SPWN"; @@ -40,19 +43,16 @@ Element_SPAWN::Element_SPAWN() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - CreateAllowed = &Element_SPAWN::createAllowed; - ChangeType = &Element_SPAWN::changeType; + CreateAllowed = &createAllowed; + ChangeType = &changeType; } -//#TPT-Directive ElementHeader Element_SPAWN static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) -bool Element_SPAWN::createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) { return sim->player.spawnID == -1; } -//#TPT-Directive ElementHeader Element_SPAWN static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_SPAWN::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (to == PT_SPAWN) { @@ -65,5 +65,3 @@ void Element_SPAWN::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) sim->player.spawnID = -1; } } - -Element_SPAWN::~Element_SPAWN() {} diff --git a/src/simulation/elements/SPAWN2.cpp b/src/simulation/elements/SPAWN2.cpp index a247cffff..db5d66bd7 100644 --- a/src/simulation/elements/SPAWN2.cpp +++ b/src/simulation/elements/SPAWN2.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SPAWN2 PT_SPAWN2 117 -Element_SPAWN2::Element_SPAWN2() + +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); + +void Element::Element_SPAWN2() { Identifier = "DEFAULT_PT_SPAWN2"; Name = "SPWN2"; @@ -40,19 +43,16 @@ Element_SPAWN2::Element_SPAWN2() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - CreateAllowed = &Element_SPAWN2::createAllowed; - ChangeType = &Element_SPAWN2::changeType; + CreateAllowed = &createAllowed; + ChangeType = &changeType; } -//#TPT-Directive ElementHeader Element_SPAWN2 static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) -bool Element_SPAWN2::createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) { return sim->player2.spawnID == -1; } -//#TPT-Directive ElementHeader Element_SPAWN2 static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_SPAWN2::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (to == PT_SPAWN2) { @@ -65,5 +65,3 @@ void Element_SPAWN2::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) sim->player2.spawnID = -1; } } - -Element_SPAWN2::~Element_SPAWN2() {} diff --git a/src/simulation/elements/SPNG.cpp b/src/simulation/elements/SPNG.cpp index 800d22528..e44687ad5 100644 --- a/src/simulation/elements/SPNG.cpp +++ b/src/simulation/elements/SPNG.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SPNG PT_SPNG 90 -Element_SPNG::Element_SPNG() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_SPNG() { Identifier = "DEFAULT_PT_SPNG"; Name = "SPNG"; @@ -40,12 +43,11 @@ Element_SPNG::Element_SPNG() HighTemperature = 2730.0f; HighTemperatureTransition = PT_FIRE; - Update = &Element_SPNG::update; - Graphics = &Element_SPNG::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_SPNG static int update(UPDATE_FUNC_ARGS) -int Element_SPNG::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, trade, rx, ry, tmp, np; int limit = 50; @@ -188,10 +190,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_SPNG static int graphics(GRAPHICS_FUNC_ARGS) -int Element_SPNG::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *colr -= cpart->life*15; *colg -= cpart->life*15; @@ -204,6 +203,3 @@ int Element_SPNG::graphics(GRAPHICS_FUNC_ARGS) *colb = 20; return 0; } - - -Element_SPNG::~Element_SPNG() {} diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 0f5db0e7e..ebfcf8080 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SPRK PT_SPRK 15 -Element_SPRK::Element_SPRK() + +int Element_FIRE_update(UPDATE_FUNC_ARGS); +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_SPRK() { Identifier = "DEFAULT_PT_SPRK"; Name = "SPRK"; @@ -41,15 +45,14 @@ Element_SPRK::Element_SPRK() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SPRK::update; - Graphics = &Element_SPRK::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_SPRK static int update(UPDATE_FUNC_ARGS) -int Element_SPRK::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, nearp, pavg, ct = parts[i].ctype, sender, receiver; - Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); + Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS); if (parts[i].life<=0) { @@ -77,12 +80,14 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) return 1; case PT_NTCT: case PT_PTCT: - Element_NTCT::update(UPDATE_FUNC_SUBCALL_ARGS); + int Element_NTCT_update(UPDATE_FUNC_ARGS); + Element_NTCT_update(UPDATE_FUNC_SUBCALL_ARGS); break; case PT_ETRD: if (parts[i].life==1) { - nearp = Element_ETRD::nearestSparkablePart(sim, i); + int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId); + nearp = Element_ETRD_nearestSparkablePart(sim, i); if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL) { sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), PT_PLSM); @@ -229,8 +234,9 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) case PT_PPIP: if (parts[i].life == 3 && pavg!=PT_INSL) { + void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy); if (sender == PT_NSCN || sender == PT_PSCN || sender == PT_INST) - Element_PPIP::flood_trigger(sim, x+rx, y+ry, sender); + Element_PPIP_flood_trigger(sim, x+rx, y+ry, sender); } continue; case PT_NTCT: case PT_PTCT: case PT_INWR: @@ -359,11 +365,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_SPRK static int graphics(GRAPHICS_FUNC_ARGS) -int Element_SPRK::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 60; *firer = *colr/2; @@ -372,6 +374,3 @@ int Element_SPRK::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_SPARK; return 1; } - - -Element_SPRK::~Element_SPRK() {} diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 07277dcab..7a3469aea 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -1,6 +1,16 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_STKM PT_STKM 55 -Element_STKM::Element_STKM() + +static int update(UPDATE_FUNC_ARGS); +int Element_STKM_graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); +void Element_STKM_init_legs(Simulation * sim, playerst *playerp, int i); +int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS); +void Element_STKM_set_element(Simulation *sim, playerst *playerp, int element); +void Element_STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int y); + +void Element::Element_STKM() { Identifier = "DEFAULT_PT_STKM"; Name = "STKM"; @@ -44,50 +54,43 @@ Element_STKM::Element_STKM() DefaultProperties.life = 100; - Update = &Element_STKM::update; - Graphics = &Element_STKM::graphics; - Create = &Element_STKM::create; - CreateAllowed = &Element_STKM::createAllowed; - ChangeType = &Element_STKM::changeType; + Update = &update; + Graphics = &Element_STKM_graphics; + Create = &create; + CreateAllowed = &createAllowed; + ChangeType = &changeType; } -//#TPT-Directive ElementHeader Element_STKM static int update(UPDATE_FUNC_ARGS) -int Element_STKM::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { - run_stickman(&sim->player, UPDATE_FUNC_SUBCALL_ARGS); + Element_STKM_run_stickman(&sim->player, UPDATE_FUNC_SUBCALL_ARGS); return 0; } - - -//#TPT-Directive ElementHeader Element_STKM static int graphics(GRAPHICS_FUNC_ARGS) -int Element_STKM::graphics(GRAPHICS_FUNC_ARGS) +int Element_STKM_graphics(GRAPHICS_FUNC_ARGS) { *colr = *colg = *colb = *cola = 0; *pixel_mode = PSPEC_STICKMAN; return 1; } -//#TPT-Directive ElementHeader Element_STKM static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_STKM::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { int spawnID = sim->create_part(-3, x, y, PT_SPAWN); if (spawnID >= 0) sim->player.spawnID = spawnID; } -//#TPT-Directive ElementHeader Element_STKM static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) -bool Element_STKM::createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) { return sim->elementCount[PT_STKM] <= 0 && !sim->player.spwn; } -//#TPT-Directive ElementHeader Element_STKM static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_STKM::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (to == PT_STKM) { - Element_STKM::STKM_init_legs(sim, &sim->player, i); + Element_STKM_init_legs(sim, &sim->player, i); sim->player.spwn = 1; } else @@ -96,8 +99,8 @@ void Element_STKM::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) #define INBOND(x, y) ((x)>=0 && (y)>=0 && (x)fan && parts[i].ctype && sim->IsValidElement(parts[i].ctype)) - STKM_set_element(sim, playerp, parts[i].ctype); + Element_STKM_set_element(sim, playerp, parts[i].ctype); playerp->frames++; //Temperature handling @@ -399,7 +402,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL]) continue; - STKM_set_element(sim, playerp, TYP(r)); + Element_STKM_set_element(sim, playerp, TYP(r)); if (TYP(r) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP { if (parts[i].life<=95) @@ -422,7 +425,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_GRAV /* && parts[i].type!=PT_FIGH */) playerp->rocketBoots = true; if (TYP(r)==PT_PRTI) - Element_STKM::STKM_interact(sim, playerp, i, rx, ry); + Element_STKM_interact(sim, playerp, i, rx, ry); if (!parts[i].type)//STKM_interact may kill STKM return 1; } @@ -601,10 +604,10 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { } //If legs touch something - Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)(playerp->legs[5]+0.5)); - Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)(playerp->legs[13]+0.5)); - Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)playerp->legs[5]); - Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)playerp->legs[13]); + Element_STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)(playerp->legs[5]+0.5)); + Element_STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)(playerp->legs[13]+0.5)); + Element_STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)playerp->legs[5]); + Element_STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)playerp->legs[13]); if (!parts[i].type) return 1; @@ -612,8 +615,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { return 0; } -//#TPT-Directive ElementHeader Element_STKM static void STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int y) -void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int y) +void Element_STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int y) { int r; if (x<0 || y<0 || x>=XRES || y>=YRES || !sim->parts[i].type) @@ -679,8 +681,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int } } -//#TPT-Directive ElementHeader Element_STKM static void STKM_init_legs(Simulation * sim, playerst *playerp, int i) -void Element_STKM::STKM_init_legs(Simulation * sim, playerst *playerp, int i) +void Element_STKM_init_legs(Simulation * sim, playerst *playerp, int i) { int x, y; @@ -717,8 +718,7 @@ void Element_STKM::STKM_init_legs(Simulation * sim, playerst *playerp, int i) playerp->rocketBoots = false; } -//#TPT-Directive ElementHeader Element_STKM static void STKM_set_element(Simulation *sim, playerst *playerp, int element) -void Element_STKM::STKM_set_element(Simulation *sim, playerst *playerp, int element) +void Element_STKM_set_element(Simulation *sim, playerst *playerp, int element) { if (sim->elements[element].Falldown != 0 || sim->elements[element].Properties&TYPE_GAS @@ -738,6 +738,3 @@ void Element_STKM::STKM_set_element(Simulation *sim, playerst *playerp, int elem playerp->fan = false; } } - - -Element_STKM::~Element_STKM() {} diff --git a/src/simulation/elements/STKM2.cpp b/src/simulation/elements/STKM2.cpp index 0929add3f..dd1501ffb 100644 --- a/src/simulation/elements/STKM2.cpp +++ b/src/simulation/elements/STKM2.cpp @@ -1,6 +1,14 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_STKM2 PT_STKM2 128 -Element_STKM2::Element_STKM2() + +static int update(UPDATE_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS); +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS); +int Element_STKM_graphics(GRAPHICS_FUNC_ARGS); +void Element_STKM_init_legs(Simulation * sim, playerst *playerp, int i); +int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS); + +void Element::Element_STKM2() { Identifier = "DEFAULT_PT_STKM2"; Name = "STK2"; @@ -44,44 +52,38 @@ Element_STKM2::Element_STKM2() DefaultProperties.life = 100; - Update = &Element_STKM2::update; - Graphics = &Element_STKM::graphics; - Create = &Element_STKM2::create; - CreateAllowed = &Element_STKM2::createAllowed; - ChangeType = &Element_STKM2::changeType; + Update = &update; + Graphics = &Element_STKM_graphics; + Create = &create; + CreateAllowed = &createAllowed; + ChangeType = &changeType; } -//#TPT-Directive ElementHeader Element_STKM2 static int update(UPDATE_FUNC_ARGS) -int Element_STKM2::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { - Element_STKM::run_stickman(&sim->player2, UPDATE_FUNC_SUBCALL_ARGS); + Element_STKM_run_stickman(&sim->player2, UPDATE_FUNC_SUBCALL_ARGS); return 0; } -//#TPT-Directive ElementHeader Element_STKM2 static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_STKM2::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { int spawnID = sim->create_part(-3, x, y, PT_SPAWN2); if (spawnID >= 0) sim->player2.spawnID = spawnID; } -//#TPT-Directive ElementHeader Element_STKM2 static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) -bool Element_STKM2::createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) +static bool createAllowed(ELEMENT_CREATE_ALLOWED_FUNC_ARGS) { return sim->elementCount[PT_STKM2] <= 0 && !sim->player2.spwn; } -//#TPT-Directive ElementHeader Element_STKM2 static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) -void Element_STKM2::changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) +static void changeType(ELEMENT_CHANGETYPE_FUNC_ARGS) { if (to == PT_STKM2) { - Element_STKM::STKM_init_legs(sim, &sim->player2, i); + Element_STKM_init_legs(sim, &sim->player2, i); sim->player2.spwn = 1; } else sim->player2.spwn = 0; } - -Element_STKM2::~Element_STKM2() {} diff --git a/src/simulation/elements/STNE.cpp b/src/simulation/elements/STNE.cpp index 8d265a759..a2cad3952 100644 --- a/src/simulation/elements/STNE.cpp +++ b/src/simulation/elements/STNE.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_STNE PT_STNE 5 -Element_STNE::Element_STNE() + +void Element::Element_STNE() { Identifier = "DEFAULT_PT_STNE"; Name = "STNE"; @@ -39,8 +39,4 @@ Element_STNE::Element_STNE() LowTemperatureTransition = NT; HighTemperature = 983.0f; HighTemperatureTransition = PT_LAVA; - - Update = NULL; } - -Element_STNE::~Element_STNE() {} diff --git a/src/simulation/elements/STOR.cpp b/src/simulation/elements/STOR.cpp index 2318ae54e..cab1280e2 100644 --- a/src/simulation/elements/STOR.cpp +++ b/src/simulation/elements/STOR.cpp @@ -1,6 +1,11 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_STOR PT_STOR 83 -Element_STOR::Element_STOR() + +void Element_SOAP_detach(Simulation * sim, int i); +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS); + +void Element::Element_STOR() { Identifier = "DEFAULT_PT_STOR"; Name = "STOR"; @@ -40,13 +45,12 @@ Element_STOR::Element_STOR() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_STOR::update; - Graphics = &Element_STOR::graphics; - CtypeDraw = &Element_STOR::ctypeDraw; + Update = &update; + Graphics = &graphics; + CtypeDraw = &ctypeDraw; } -//#TPT-Directive ElementHeader Element_STOR static int update(UPDATE_FUNC_ARGS) -int Element_STOR::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, np, rx1, ry1; if (!sim->IsValidElement(parts[i].tmp)) @@ -63,7 +67,7 @@ int Element_STOR::update(UPDATE_FUNC_ARGS) if (!parts[i].tmp && !parts[i].life && TYP(r)!=PT_STOR && !(sim->elements[TYP(r)].Properties&TYPE_SOLID) && (!parts[i].ctype || TYP(r)==parts[i].ctype)) { if (TYP(r) == PT_SOAP) - Element_SOAP::detach(sim, ID(r)); + Element_SOAP_detach(sim, ID(r)); parts[i].tmp = parts[ID(r)].type; parts[i].temp = parts[ID(r)].temp; parts[i].tmp2 = parts[ID(r)].life; @@ -93,10 +97,7 @@ int Element_STOR::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_STOR static int graphics(GRAPHICS_FUNC_ARGS) -int Element_STOR::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->tmp){ *pixel_mode |= PMODE_GLOW; @@ -111,8 +112,7 @@ int Element_STOR::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_STOR static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) -bool Element_STOR::ctypeDraw(CTYPEDRAW_FUNC_ARGS) +static bool ctypeDraw(CTYPEDRAW_FUNC_ARGS) { if (sim->elements[t].Properties & TYPE_SOLID) { @@ -120,5 +120,3 @@ bool Element_STOR::ctypeDraw(CTYPEDRAW_FUNC_ARGS) } return Element::basicCtypeDraw(CTYPEDRAW_FUNC_SUBCALL_ARGS); } - -Element_STOR::~Element_STOR() {} diff --git a/src/simulation/elements/SWCH.cpp b/src/simulation/elements/SWCH.cpp index a6cdfe5c3..6e84b9004 100644 --- a/src/simulation/elements/SWCH.cpp +++ b/src/simulation/elements/SWCH.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_SWCH PT_SWCH 56 -Element_SWCH::Element_SWCH() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_SWCH() { Identifier = "DEFAULT_PT_SWCH"; Name = "SWCH"; @@ -40,17 +43,16 @@ Element_SWCH::Element_SWCH() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_SWCH::update; - Graphics = &Element_SWCH::graphics; + Update = &update; + Graphics = &graphics; } -bool isRedBRAY(UPDATE_FUNC_ARGS, int xc, int yc) +static bool isRedBRAY(UPDATE_FUNC_ARGS, int xc, int yc) { return TYP(pmap[yc][xc]) == PT_BRAY && parts[ID(pmap[yc][xc])].tmp == 2; } -//#TPT-Directive ElementHeader Element_SWCH static int update(UPDATE_FUNC_ARGS) -int Element_SWCH::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rt, rx, ry; if (parts[i].life>0 && parts[i].life!=10) @@ -92,10 +94,7 @@ int Element_SWCH::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_SWCH static int graphics(GRAPHICS_FUNC_ARGS) -int Element_SWCH::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if(cpart->life >= 10) { @@ -106,6 +105,3 @@ int Element_SWCH::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_SWCH::~Element_SWCH() {} diff --git a/src/simulation/elements/TESC.cpp b/src/simulation/elements/TESC.cpp index c7bf47016..4333ee154 100644 --- a/src/simulation/elements/TESC.cpp +++ b/src/simulation/elements/TESC.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_TESC PT_TESC 88 -Element_TESC::Element_TESC() + +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_TESC() { Identifier = "DEFAULT_PT_TESC"; Name = "TESC"; @@ -40,12 +42,10 @@ Element_TESC::Element_TESC() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; - Create = &Element_TESC::create; + Create = &create; } -//#TPT-Directive ElementHeader Element_TESC static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_TESC::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { if (v >= 0) { @@ -54,5 +54,3 @@ void Element_TESC::create(ELEMENT_CREATE_FUNC_ARGS) sim->parts[i].tmp = 300; } } - -Element_TESC::~Element_TESC() {} diff --git a/src/simulation/elements/THDR.cpp b/src/simulation/elements/THDR.cpp index 00060f97d..e716317a2 100644 --- a/src/simulation/elements/THDR.cpp +++ b/src/simulation/elements/THDR.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_THDR PT_THDR 48 -Element_THDR::Element_THDR() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_THDR() { Identifier = "DEFAULT_PT_THDR"; Name = "THDR"; @@ -41,12 +44,11 @@ Element_THDR::Element_THDR() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_THDR::update; - Graphics = &Element_THDR::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_THDR static int update(UPDATE_FUNC_ARGS) -int Element_THDR::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; bool kill=false; @@ -84,10 +86,7 @@ int Element_THDR::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_THDR static int graphics(GRAPHICS_FUNC_ARGS) -int Element_THDR::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { *firea = 160; *fireg = 192; @@ -96,6 +95,3 @@ int Element_THDR::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_ADD; return 1; } - - -Element_THDR::~Element_THDR() {} diff --git a/src/simulation/elements/THRM.cpp b/src/simulation/elements/THRM.cpp index 8f56d7b9c..c421f0269 100644 --- a/src/simulation/elements/THRM.cpp +++ b/src/simulation/elements/THRM.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_THRM PT_THRM 65 -Element_THRM::Element_THRM() + +void Element::Element_THRM() { Identifier = "DEFAULT_PT_THRM"; Name = "THRM"; @@ -39,8 +39,4 @@ Element_THRM::Element_THRM() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_THRM::~Element_THRM() {} diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp index ac98895a2..873596edc 100644 --- a/src/simulation/elements/TRON.cpp +++ b/src/simulation/elements/TRON.cpp @@ -1,6 +1,14 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_TRON PT_TRON 143 -Element_TRON::Element_TRON() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); +static void init_graphics(); +static int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len); +static bool canmovetron(Simulation * sim, int r, int len); +static int new_tronhead(Simulation * sim, int x, int y, int i, int direction); + +void Element::Element_TRON() { Identifier = "DEFAULT_PT_TRON"; Name = "TRON"; @@ -41,11 +49,11 @@ Element_TRON::Element_TRON() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_TRON::update; - Graphics = &Element_TRON::graphics; - Create = &Element_TRON::create; + Update = &update; + Graphics = &graphics; + Create = &create; - Element_TRON::init_graphics(); + init_graphics(); } /* TRON element is meant to resemble a tron bike (or worm) moving around and trying to avoid obstacles itself. @@ -76,8 +84,7 @@ int tron_rx[4] = {-1, 0, 1, 0}; int tron_ry[4] = { 0,-1, 0, 1}; unsigned int tron_colours[32]; -//#TPT-Directive ElementHeader Element_TRON static void init_graphics() -void Element_TRON::init_graphics() +static void init_graphics() { int i; int r, g, b; @@ -88,8 +95,7 @@ void Element_TRON::init_graphics() } } -//#TPT-Directive ElementHeader Element_TRON static int update(UPDATE_FUNC_ARGS) -int Element_TRON::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].tmp&TRON_WAIT) { @@ -112,7 +118,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS) //check in front //do sight check - firstdircheck = Element_TRON::trymovetron(sim,x,y,direction,i,parts[i].tmp2); + firstdircheck = trymovetron(sim,x,y,direction,i,parts[i].tmp2); if (firstdircheck < parts[i].tmp2) { if (parts[i].tmp & TRON_NORANDOM) @@ -139,7 +145,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS) if (lastdircheck > seconddircheck && lastdircheck > firstdircheck) direction = lastdir; //now try making new head, even if it fails - if (Element_TRON::new_tronhead(sim,x + tron_rx[direction],y + tron_ry[direction],i,direction) == -1) + if (new_tronhead(sim,x + tron_rx[direction],y + tron_ry[direction],i,direction) == -1) { //ohgod crash parts[i].tmp |= TRON_DEATH; @@ -159,8 +165,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_TRON static int graphics(GRAPHICS_FUNC_ARGS) -int Element_TRON::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { unsigned int col = tron_colours[(cpart->tmp&0xF800)>>11]; if(cpart->tmp & TRON_HEAD) @@ -185,8 +190,7 @@ int Element_TRON::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_TRON static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_TRON::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { int randhue = RNG::Ref().between(0, 359); int randomdir = RNG::Ref().between(0, 3); @@ -197,8 +201,7 @@ void Element_TRON::create(ELEMENT_CREATE_FUNC_ARGS) sim->parts[i].life = 5; } -//#TPT-Directive ElementHeader Element_TRON static int new_tronhead(Simulation * sim, int x, int y, int i, int direction) -int Element_TRON::new_tronhead(Simulation * sim, int x, int y, int i, int direction) +static int new_tronhead(Simulation * sim, int x, int y, int i, int direction) { int np = sim->create_part(-1, x , y ,PT_TRON); if (np==-1) @@ -220,8 +223,7 @@ int Element_TRON::new_tronhead(Simulation * sim, int x, int y, int i, int direct return 1; } -//#TPT-Directive ElementHeader Element_TRON static int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) -int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) +static int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) { int k,j,r,rx,ry,tx,ty,count; count = 0; @@ -266,8 +268,7 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in return count; } -//#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len) -bool Element_TRON::canmovetron(Simulation * sim, int r, int len) +static bool canmovetron(Simulation * sim, int r, int len) { if (!r || (TYP(r) == PT_SWCH && sim->parts[ID(r)].life >= 10) || (TYP(r) == PT_INVIS && sim->parts[ID(r)].tmp2 == 1)) return true; @@ -275,5 +276,3 @@ bool Element_TRON::canmovetron(Simulation * sim, int r, int len) return true; return false; } - -Element_TRON::~Element_TRON() {} diff --git a/src/simulation/elements/TSNS.cpp b/src/simulation/elements/TSNS.cpp index ef262d48e..198ab79d1 100644 --- a/src/simulation/elements/TSNS.cpp +++ b/src/simulation/elements/TSNS.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_TSNS PT_TSNS 164 -Element_TSNS::Element_TSNS() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_TSNS() { Identifier = "DEFAULT_PT_TSNS"; Name = "TSNS"; @@ -42,11 +44,10 @@ Element_TSNS::Element_TSNS() DefaultProperties.tmp2 = 2; - Update = &Element_TSNS::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_TSNS static int update(UPDATE_FUNC_ARGS) -int Element_TSNS::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int rd = parts[i].tmp2; if (rd > 25) @@ -119,7 +120,3 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS) } return 0; } - - - -Element_TSNS::~Element_TSNS() {} diff --git a/src/simulation/elements/TTAN.cpp b/src/simulation/elements/TTAN.cpp index 24a499a9d..0b9c46a00 100644 --- a/src/simulation/elements/TTAN.cpp +++ b/src/simulation/elements/TTAN.cpp @@ -1,7 +1,9 @@ #include "simulation/ElementCommon.h" #include "simulation/Air.h" -//#TPT-Directive ElementClass Element_TTAN PT_TTAN 144 -Element_TTAN::Element_TTAN() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_TTAN() { Identifier = "DEFAULT_PT_TTAN"; Name = "TTAN"; @@ -41,11 +43,10 @@ Element_TTAN::Element_TTAN() HighTemperature = 1941.0f; HighTemperatureTransition = PT_LAVA; - Update = &Element_TTAN::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_TTAN static int update(UPDATE_FUNC_ARGS) -int Element_TTAN::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int ttan = 0; if (nt <= 2) @@ -70,6 +71,3 @@ int Element_TTAN::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_TTAN::~Element_TTAN() {} diff --git a/src/simulation/elements/TUNG.cpp b/src/simulation/elements/TUNG.cpp index 7e90cd689..b50801b04 100644 --- a/src/simulation/elements/TUNG.cpp +++ b/src/simulation/elements/TUNG.cpp @@ -1,7 +1,10 @@ #include "simulation/ElementCommon.h" #include "simulation/Air.h" -//#TPT-Directive ElementClass Element_TUNG PT_TUNG 171 -Element_TUNG::Element_TUNG() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_TUNG() { Identifier = "DEFAULT_PT_TUNG"; Name = "TUNG"; @@ -41,12 +44,11 @@ Element_TUNG::Element_TUNG() HighTemperature = 3695.0f;// TUNG melts in its update function instead of in the normal way, but store the threshold here so that it can be changed from Lua HighTemperatureTransition = NT; - Update = &Element_TUNG::update; - Graphics = &Element_TUNG::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_TUNG static int update(UPDATE_FUNC_ARGS) -int Element_TUNG::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { bool splode = false; const float MELTING_POINT = sim->elements[PT_TUNG].HighTemperature; @@ -103,9 +105,7 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS) return 0; } - -//#TPT-Directive ElementHeader Element_TUNG static int graphics(GRAPHICS_FUNC_ARGS) -int Element_TUNG::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { const float MELTING_POINT = ren->sim->elements[PT_TUNG].HighTemperature; double startTemp = (MELTING_POINT - 1500.0); @@ -127,5 +127,3 @@ int Element_TUNG::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_TUNG::~Element_TUNG() {} diff --git a/src/simulation/elements/URAN.cpp b/src/simulation/elements/URAN.cpp index 80fdd3eba..e7fd50dca 100644 --- a/src/simulation/elements/URAN.cpp +++ b/src/simulation/elements/URAN.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_URAN PT_URAN 32 -Element_URAN::Element_URAN() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_URAN() { Identifier = "DEFAULT_PT_URAN"; Name = "URAN"; @@ -42,11 +44,10 @@ Element_URAN::Element_URAN() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_URAN::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_URAN static int update(UPDATE_FUNC_ARGS) -int Element_URAN::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (!sim->legacy_enable && sim->pv[y/CELL][x/CELL]>0.0f) { @@ -61,6 +62,3 @@ int Element_URAN::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_URAN::~Element_URAN() {} diff --git a/src/simulation/elements/VIBR.cpp b/src/simulation/elements/VIBR.cpp index a4fb6864e..7862016e9 100644 --- a/src/simulation/elements/VIBR.cpp +++ b/src/simulation/elements/VIBR.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_VIBR PT_VIBR 165 -Element_VIBR::Element_VIBR() + +int Element_VIBR_update(UPDATE_FUNC_ARGS); +int Element_VIBR_graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_VIBR() { Identifier = "DEFAULT_PT_VIBR"; Name = "VIBR"; @@ -41,12 +44,12 @@ Element_VIBR::Element_VIBR() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_VIBR::update; - Graphics = &Element_VIBR::graphics; + Update = &Element_VIBR_update; + Graphics = &Element_VIBR_graphics; } -//#TPT-Directive ElementHeader Element_VIBR static int update(UPDATE_FUNC_ARGS) -int Element_VIBR::update(UPDATE_FUNC_ARGS) { +int Element_VIBR_update(UPDATE_FUNC_ARGS) +{ int r, rx, ry, rndstore = 0; int trade, transfer; if (!parts[i].life) //if not exploding @@ -211,8 +214,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { return 0; } -//#TPT-Directive ElementHeader Element_VIBR static int graphics(GRAPHICS_FUNC_ARGS) -int Element_VIBR::graphics(GRAPHICS_FUNC_ARGS) +int Element_VIBR_graphics(GRAPHICS_FUNC_ARGS) { int gradient = cpart->tmp/10; if (gradient >= 100 || cpart->life) @@ -249,5 +251,3 @@ int Element_VIBR::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_VIBR::~Element_VIBR() {} diff --git a/src/simulation/elements/VINE.cpp b/src/simulation/elements/VINE.cpp index 16b4ccbe4..566d7c1de 100644 --- a/src/simulation/elements/VINE.cpp +++ b/src/simulation/elements/VINE.cpp @@ -1,8 +1,10 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_VINE PT_VINE 114 -Element_VINE::Element_VINE() +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_VINE() { Identifier = "DEFAULT_PT_VINE"; Name = "VINE"; @@ -44,11 +46,11 @@ Element_VINE::Element_VINE() DefaultProperties.tmp = 1; - Update = &Element_VINE::update; + Update = &update; + Graphics = &graphics; // this used to be missing, maybe for a reason? } -//#TPT-Directive ElementHeader Element_VINE static int update(UPDATE_FUNC_ARGS) -int Element_VINE::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, np, rx, ry, rndstore = RNG::Ref().gen(); rx = (rndstore % 3) - 1; @@ -73,8 +75,7 @@ int Element_VINE::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_VINE static int graphics(GRAPHICS_FUNC_ARGS) -int Element_VINE::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { float maxtemp = std::max((float)cpart->tmp2, cpart->temp); if (maxtemp > 300) @@ -90,6 +91,3 @@ int Element_VINE::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_VINE::~Element_VINE() {} diff --git a/src/simulation/elements/VIRS.cpp b/src/simulation/elements/VIRS.cpp index f13c9d20b..a3c820b54 100644 --- a/src/simulation/elements/VIRS.cpp +++ b/src/simulation/elements/VIRS.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_VIRS PT_VIRS 174 -Element_VIRS::Element_VIRS() + +int Element_VIRS_update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_VIRS() { Identifier = "DEFAULT_PT_VIRS"; Name = "VIRS"; @@ -43,12 +46,11 @@ Element_VIRS::Element_VIRS() DefaultProperties.pavg[1] = 250; - Update = &Element_VIRS::update; - Graphics = &Element_VIRS::graphics; + Update = &Element_VIRS_update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_VIRS static int update(UPDATE_FUNC_ARGS) -int Element_VIRS::update(UPDATE_FUNC_ARGS) +int Element_VIRS_update(UPDATE_FUNC_ARGS) { //pavg[0] measures how many frames until it is cured (0 if still actively spreading and not being cured) //pavg[1] measures how many frames until it dies @@ -142,12 +144,9 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_VIRS static int graphics(GRAPHICS_FUNC_ARGS) -int Element_VIRS::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { *pixel_mode |= PMODE_BLUR; *pixel_mode |= NO_DECO; return 1; } - -Element_VIRS::~Element_VIRS() {} diff --git a/src/simulation/elements/VOID.cpp b/src/simulation/elements/VOID.cpp index 7d86d6ad8..39b9d9a64 100644 --- a/src/simulation/elements/VOID.cpp +++ b/src/simulation/elements/VOID.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_VOID PT_VOID 22 -Element_VOID::Element_VOID() + +void Element::Element_VOID() { Identifier = "DEFAULT_PT_VOID"; Name = "VOID"; @@ -39,8 +39,4 @@ Element_VOID::Element_VOID() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_VOID::~Element_VOID() {} diff --git a/src/simulation/elements/VRSG.cpp b/src/simulation/elements/VRSG.cpp index 6dec94b4a..189f452da 100644 --- a/src/simulation/elements/VRSG.cpp +++ b/src/simulation/elements/VRSG.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_VRSG PT_VRSG 176 -Element_VRSG::Element_VRSG() + +int Element_VIRS_update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_VRSG() { Identifier = "DEFAULT_PT_VRSG"; Name = "VRSG"; @@ -43,13 +46,11 @@ Element_VRSG::Element_VRSG() DefaultProperties.pavg[1] = 250; - Update = &Element_VIRS::update; - Graphics = &Element_VRSG::graphics; + Update = &Element_VIRS_update; + Graphics = &graphics; } - -//#TPT-Directive ElementHeader Element_VRSG static int graphics(GRAPHICS_FUNC_ARGS) -int Element_VRSG::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { *pixel_mode &= ~PMODE; *pixel_mode |= FIRE_BLEND; @@ -60,5 +61,3 @@ int Element_VRSG::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= NO_DECO; return 1; } - -Element_VRSG::~Element_VRSG() {} diff --git a/src/simulation/elements/VRSS.cpp b/src/simulation/elements/VRSS.cpp index ac5d1d7d0..42424e6f8 100644 --- a/src/simulation/elements/VRSS.cpp +++ b/src/simulation/elements/VRSS.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_VRSS PT_VRSS 175 -Element_VRSS::Element_VRSS() + +int Element_VIRS_update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_VRSS() { Identifier = "DEFAULT_PT_VRSS"; Name = "VRSS"; @@ -43,15 +46,12 @@ Element_VRSS::Element_VRSS() DefaultProperties.pavg[1] = 250; - Update = &Element_VIRS::update; - Graphics = &Element_VRSS::graphics; + Update = &Element_VIRS_update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_VRSS static int graphics(GRAPHICS_FUNC_ARGS) -int Element_VRSS::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { *pixel_mode |= NO_DECO; return 1; } - -Element_VRSS::~Element_VRSS() {} diff --git a/src/simulation/elements/WARP.cpp b/src/simulation/elements/WARP.cpp index 1878260a7..6aa2687f6 100644 --- a/src/simulation/elements/WARP.cpp +++ b/src/simulation/elements/WARP.cpp @@ -1,6 +1,10 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WARP PT_WARP 96 -Element_WARP::Element_WARP() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); +static void create(ELEMENT_CREATE_FUNC_ARGS); + +void Element::Element_WARP() { Identifier = "DEFAULT_PT_WARP"; Name = "WARP"; @@ -40,13 +44,12 @@ Element_WARP::Element_WARP() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_WARP::update; - Graphics = &Element_WARP::graphics; - Create = &Element_WARP::create; + Update = &update; + Graphics = &graphics; + Create = &create; } -//#TPT-Directive ElementHeader Element_WARP static int update(UPDATE_FUNC_ARGS) -int Element_WARP::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int trade, r, rx, ry; if (parts[i].tmp2>2000) @@ -83,18 +86,14 @@ int Element_WARP::update(UPDATE_FUNC_ARGS) return 0; } -//#TPT-Directive ElementHeader Element_WARP static int graphics(GRAPHICS_FUNC_ARGS) -int Element_WARP::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { *colr = *colg = *colb = *cola = 0; *pixel_mode &= ~PMODE; return 0; } -//#TPT-Directive ElementHeader Element_WARP static void create(ELEMENT_CREATE_FUNC_ARGS) -void Element_WARP::create(ELEMENT_CREATE_FUNC_ARGS) +static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].life = RNG::Ref().between(70, 164); } - -Element_WARP::~Element_WARP() {} diff --git a/src/simulation/elements/WATR.cpp b/src/simulation/elements/WATR.cpp index 34ac26f3f..8fe00c977 100644 --- a/src/simulation/elements/WATR.cpp +++ b/src/simulation/elements/WATR.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WATR PT_WATR 2 -Element_WATR::Element_WATR() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_WATR() { Identifier = "DEFAULT_PT_WATR"; Name = "WATR"; @@ -41,11 +43,10 @@ Element_WATR::Element_WATR() HighTemperature = 373.0f; HighTemperatureTransition = PT_WTRV; - Update = &Element_WATR::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_WATR static int update(UPDATE_FUNC_ARGS) -int Element_WATR::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -84,5 +85,3 @@ int Element_WATR::update(UPDATE_FUNC_ARGS) } return 0; } - -Element_WATR::~Element_WATR() {} diff --git a/src/simulation/elements/WAX.cpp b/src/simulation/elements/WAX.cpp index 4c9880346..ba5ab7c5c 100644 --- a/src/simulation/elements/WAX.cpp +++ b/src/simulation/elements/WAX.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WAX PT_WAX 33 -Element_WAX::Element_WAX() + +void Element::Element_WAX() { Identifier = "DEFAULT_PT_WAX"; Name = "WAX"; @@ -39,8 +39,4 @@ Element_WAX::Element_WAX() LowTemperatureTransition = NT; HighTemperature = 319.0f; HighTemperatureTransition = PT_MWAX; - - Update = NULL; } - -Element_WAX::~Element_WAX() {} diff --git a/src/simulation/elements/WHOL.cpp b/src/simulation/elements/WHOL.cpp index 9c7af4747..bbf6f159e 100644 --- a/src/simulation/elements/WHOL.cpp +++ b/src/simulation/elements/WHOL.cpp @@ -1,6 +1,6 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WHOL PT_WHOL 40 -Element_WHOL::Element_WHOL() + +void Element::Element_WHOL() { Identifier = "DEFAULT_PT_WHOL"; Name = "VENT"; @@ -40,8 +40,4 @@ Element_WHOL::Element_WHOL() LowTemperatureTransition = NT; HighTemperature = ITH; HighTemperatureTransition = NT; - - Update = NULL; } - -Element_WHOL::~Element_WHOL() {} diff --git a/src/simulation/elements/WIFI.cpp b/src/simulation/elements/WIFI.cpp index 022996d08..f63c132ce 100644 --- a/src/simulation/elements/WIFI.cpp +++ b/src/simulation/elements/WIFI.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WIFI PT_WIFI 124 -Element_WIFI::Element_WIFI() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_WIFI() { Identifier = "DEFAULT_PT_WIFI"; Name = "WIFI"; @@ -40,12 +43,11 @@ Element_WIFI::Element_WIFI() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_WIFI::update; - Graphics = &Element_WIFI::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_WIFI static int update(UPDATE_FUNC_ARGS) -int Element_WIFI::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); @@ -78,10 +80,9 @@ int Element_WIFI::update(UPDATE_FUNC_ARGS) return 0; } -#define FREQUENCY 0.0628f +constexpr float FREQUENCY = 0.0628f; -//#TPT-Directive ElementHeader Element_WIFI static int graphics(GRAPHICS_FUNC_ARGS) -int Element_WIFI::graphics(GRAPHICS_FUNC_ARGS) +static int graphics(GRAPHICS_FUNC_ARGS) { int q = (int)((cpart->temp-73.15f)/100+1); *colr = sin(FREQUENCY*q + 0) * 127 + 128; @@ -90,6 +91,3 @@ int Element_WIFI::graphics(GRAPHICS_FUNC_ARGS) *pixel_mode |= EFFECT_DBGLINES; return 0; } - - -Element_WIFI::~Element_WIFI() {} diff --git a/src/simulation/elements/WIRE.cpp b/src/simulation/elements/WIRE.cpp index d1ad9c82d..47ee8bf11 100644 --- a/src/simulation/elements/WIRE.cpp +++ b/src/simulation/elements/WIRE.cpp @@ -1,6 +1,9 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WIRE PT_WIRE 156 -Element_WIRE::Element_WIRE() + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_WIRE() { Identifier = "DEFAULT_PT_WIRE"; Name = "WWLD"; @@ -40,12 +43,11 @@ Element_WIRE::Element_WIRE() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_WIRE::update; - Graphics = &Element_WIRE::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_WIRE static int update(UPDATE_FUNC_ARGS) -int Element_WIRE::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r,rx,ry,count=0; /* @@ -89,11 +91,7 @@ int Element_WIRE::update(UPDATE_FUNC_ARGS) return 0; } - - -//#TPT-Directive ElementHeader Element_WIRE static int graphics(GRAPHICS_FUNC_ARGS) -int Element_WIRE::graphics(GRAPHICS_FUNC_ARGS) - +static int graphics(GRAPHICS_FUNC_ARGS) { if (cpart->ctype==0) { @@ -120,6 +118,3 @@ int Element_WIRE::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - - -Element_WIRE::~Element_WIRE() {} diff --git a/src/simulation/elements/WOOD.cpp b/src/simulation/elements/WOOD.cpp index c46e82f06..627c9f717 100644 --- a/src/simulation/elements/WOOD.cpp +++ b/src/simulation/elements/WOOD.cpp @@ -1,8 +1,10 @@ #include "common/tpt-minmax.h" #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WOOD PT_WOOD 17 -Element_WOOD::Element_WOOD() +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_WOOD() { Identifier = "DEFAULT_PT_WOOD"; Name = "WOOD"; @@ -42,19 +44,18 @@ Element_WOOD::Element_WOOD() HighTemperature = 873.0f; HighTemperatureTransition = PT_FIRE; - Update = &Element_WOOD::update; - Graphics = &Element_WOOD::graphics; + Update = &update; + Graphics = &graphics; } -//#TPT-Directive ElementHeader Element_WOOD static int update(UPDATE_FUNC_ARGS) -int Element_WOOD::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { if (parts[i].temp > 450 && parts[i].temp > parts[i].tmp) parts[i].tmp = (int)parts[i].temp; return 0; } -//#TPT-Directive ElementHeader Element_WOOD static int graphics(GRAPHICS_FUNC_ARGS) -int Element_WOOD::graphics(GRAPHICS_FUNC_ARGS) + +static int graphics(GRAPHICS_FUNC_ARGS) { float maxtemp = std::max((float)cpart->tmp, cpart->temp); if (maxtemp > 400) @@ -71,5 +72,3 @@ int Element_WOOD::graphics(GRAPHICS_FUNC_ARGS) } return 0; } - -Element_WOOD::~Element_WOOD() {} diff --git a/src/simulation/elements/WTRV.cpp b/src/simulation/elements/WTRV.cpp index a8767eb0a..3ea937082 100644 --- a/src/simulation/elements/WTRV.cpp +++ b/src/simulation/elements/WTRV.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_WTRV PT_WTRV 23 -Element_WTRV::Element_WTRV() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_WTRV() { Identifier = "DEFAULT_PT_WTRV"; Name = "WTRV"; @@ -41,11 +43,10 @@ Element_WTRV::Element_WTRV() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_WTRV::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_WTRV static int update(UPDATE_FUNC_ARGS) -int Element_WTRV::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -66,6 +67,3 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS) parts[i].temp-=parts[i].temp/1000; return 0; } - - -Element_WTRV::~Element_WTRV() {} diff --git a/src/simulation/elements/YEST.cpp b/src/simulation/elements/YEST.cpp index 3038f1ee6..772b90175 100644 --- a/src/simulation/elements/YEST.cpp +++ b/src/simulation/elements/YEST.cpp @@ -1,6 +1,8 @@ #include "simulation/ElementCommon.h" -//#TPT-Directive ElementClass Element_YEST PT_YEST 63 -Element_YEST::Element_YEST() + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_YEST() { Identifier = "DEFAULT_PT_YEST"; Name = "YEST"; @@ -40,11 +42,10 @@ Element_YEST::Element_YEST() HighTemperature = 373.0f; HighTemperatureTransition = PT_DYST; - Update = &Element_YEST::update; + Update = &update; } -//#TPT-Directive ElementHeader Element_YEST static int update(UPDATE_FUNC_ARGS) -int Element_YEST::update(UPDATE_FUNC_ARGS) +static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; for (rx=-1; rx<2; rx++) @@ -64,6 +65,3 @@ int Element_YEST::update(UPDATE_FUNC_ARGS) } return 0; } - - -Element_YEST::~Element_YEST() {} diff --git a/src/simulation/simtools/AirTool.cpp b/src/simulation/simtools/AIR.cpp similarity index 62% rename from src/simulation/simtools/AirTool.cpp rename to src/simulation/simtools/AIR.cpp index b90e4646c..8ecfd7f24 100644 --- a/src/simulation/simtools/AirTool.cpp +++ b/src/simulation/simtools/AIR.cpp @@ -1,16 +1,18 @@ #include "simulation/ToolCommon.h" #include "simulation/Air.h" -//#TPT-Directive ToolClass Tool_Air TOOL_AIR 2 -Tool_Air::Tool_Air() +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_AIR() { Identifier = "DEFAULT_TOOL_AIR"; Name = "AIR"; Colour = PIXPACK(0xFFFFFF); Description = "Air, creates airflow and pressure."; + Perform = &perform; } -int Tool_Air::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { sim->air->pv[y/CELL][x/CELL] += strength*0.05f; @@ -20,5 +22,3 @@ int Tool_Air::Perform(Simulation * sim, Particle * cpart, int x, int y, int brus sim->air->pv[y/CELL][x/CELL] = -256.0f; return 1; } - -Tool_Air::~Tool_Air() {} diff --git a/src/simulation/simtools/Cool.cpp b/src/simulation/simtools/COOL.cpp similarity index 61% rename from src/simulation/simtools/Cool.cpp rename to src/simulation/simtools/COOL.cpp index 05ed9c54b..651b0827d 100644 --- a/src/simulation/simtools/Cool.cpp +++ b/src/simulation/simtools/COOL.cpp @@ -1,15 +1,17 @@ #include "simulation/ToolCommon.h" -//#TPT-Directive ToolClass Tool_Cool TOOL_COOL 1 -Tool_Cool::Tool_Cool() +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_COOL() { Identifier = "DEFAULT_TOOL_COOL"; Name = "COOL"; Colour = PIXPACK(0x00DDFF); Description = "Cools the targeted element."; + Perform = &perform; } -int Tool_Cool::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { if(!cpart) return 0; @@ -24,5 +26,3 @@ int Tool_Cool::Perform(Simulation * sim, Particle * cpart, int x, int y, int bru cpart->temp = 0; return 1; } - -Tool_Cool::~Tool_Cool() {} diff --git a/src/simulation/simtools/Cyclone.cpp b/src/simulation/simtools/CYCL.cpp similarity index 77% rename from src/simulation/simtools/Cyclone.cpp rename to src/simulation/simtools/CYCL.cpp index 768d16b06..368ff5c0e 100644 --- a/src/simulation/simtools/Cyclone.cpp +++ b/src/simulation/simtools/CYCL.cpp @@ -3,17 +3,18 @@ #include +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); -//#TPT-Directive ToolClass Tool_Cycl TOOL_CYCL 7 -Tool_Cycl::Tool_Cycl() +void SimTool::Tool_CYCL() { Identifier = "DEFAULT_TOOL_CYCL"; Name = "CYCL"; Colour = PIXPACK(0x132f5b); Description = "Cyclone, produces swirling air currents"; + Perform = &perform; } -int Tool_Cycl::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { /* Air velocity calculation. @@ -49,5 +50,3 @@ int Tool_Cycl::Perform(Simulation * sim, Particle * cpart, int x, int y, int bru return 1; } - -Tool_Cycl::~Tool_Cycl() {} diff --git a/src/simulation/simtools/Heat.cpp b/src/simulation/simtools/HEAT.cpp similarity index 61% rename from src/simulation/simtools/Heat.cpp rename to src/simulation/simtools/HEAT.cpp index 5b564a094..417295cf0 100644 --- a/src/simulation/simtools/Heat.cpp +++ b/src/simulation/simtools/HEAT.cpp @@ -1,15 +1,17 @@ #include "simulation/ToolCommon.h" -//#TPT-Directive ToolClass Tool_Heat TOOL_HEAT 0 -Tool_Heat::Tool_Heat() +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_HEAT() { Identifier = "DEFAULT_TOOL_HEAT"; Name = "HEAT"; Colour = PIXPACK(0xFFDD00); Description = "Heats the targeted element."; + Perform = &perform; } -int Tool_Heat::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { if(!cpart) return 0; @@ -24,5 +26,3 @@ int Tool_Heat::Perform(Simulation * sim, Particle * cpart, int x, int y, int bru cpart->temp = 0; return 1; } - -Tool_Heat::~Tool_Heat() {} diff --git a/src/simulation/simtools/Mix.cpp b/src/simulation/simtools/MIX.cpp old mode 100755 new mode 100644 similarity index 76% rename from src/simulation/simtools/Mix.cpp rename to src/simulation/simtools/MIX.cpp index 562401117..71cb8ec9c --- a/src/simulation/simtools/Mix.cpp +++ b/src/simulation/simtools/MIX.cpp @@ -3,16 +3,18 @@ #include "common/tpt-rand.h" #include -//#TPT-Directive ToolClass Tool_Mix TOOL_MIX 6 -Tool_Mix::Tool_Mix() +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_MIX() { Identifier = "DEFAULT_TOOL_MIX"; Name = "MIX"; Colour = PIXPACK(0xFFD090); Description = "Mixes particles."; + Perform = &perform; } -int Tool_Mix::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { int thisPart = sim->pmap[y][x]; if(!thisPart) @@ -49,5 +51,3 @@ int Tool_Mix::Perform(Simulation * sim, Particle * cpart, int x, int y, int brus return 1; } - -Tool_Mix::~Tool_Mix() {} diff --git a/src/simulation/simtools/NGRV.cpp b/src/simulation/simtools/NGRV.cpp new file mode 100644 index 000000000..526aa8c90 --- /dev/null +++ b/src/simulation/simtools/NGRV.cpp @@ -0,0 +1,18 @@ +#include "simulation/ToolCommon.h" + +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushYy, float strength); + +void SimTool::Tool_NGRV() +{ + Identifier = "DEFAULT_TOOL_NGRV"; + Name = "NGRV"; + Colour = PIXPACK(0xAACCFF); + Description = "Creates a short-lasting negative gravity well."; + Perform = &perform; +} + +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushYy, float strength) +{ + sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] = strength*-5.0f; + return 1; +} diff --git a/src/simulation/simtools/NGrv.cpp b/src/simulation/simtools/NGrv.cpp deleted file mode 100644 index b9ed258d6..000000000 --- a/src/simulation/simtools/NGrv.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "simulation/ToolCommon.h" - -//#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5 -Tool_NGrv::Tool_NGrv() -{ - Identifier = "DEFAULT_TOOL_NGRV"; - Name = "NGRV"; - Colour = PIXPACK(0xAACCFF); - Description = "Creates a short-lasting negative gravity well."; -} - -int Tool_NGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushYy, float strength) -{ - sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] = strength*-5.0f; - return 1; -} - -Tool_NGrv::~Tool_NGrv() {} diff --git a/src/simulation/simtools/PGRV.cpp b/src/simulation/simtools/PGRV.cpp new file mode 100644 index 000000000..a9eddbb1f --- /dev/null +++ b/src/simulation/simtools/PGRV.cpp @@ -0,0 +1,18 @@ +#include "simulation/ToolCommon.h" + +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_PGRV() +{ + Identifier = "DEFAULT_TOOL_PGRV"; + Name = "PGRV"; + Colour = PIXPACK(0xCCCCFF); + Description = "Creates a short-lasting gravity well."; + Perform = &perform; +} + +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +{ + sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] = strength*5.0f; + return 1; +} diff --git a/src/simulation/simtools/PGrv.cpp b/src/simulation/simtools/PGrv.cpp deleted file mode 100644 index fb27ce568..000000000 --- a/src/simulation/simtools/PGrv.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "simulation/ToolCommon.h" - -//#TPT-Directive ToolClass Tool_PGrv TOOL_PGRV 4 -Tool_PGrv::Tool_PGrv() -{ - Identifier = "DEFAULT_TOOL_PGRV"; - Name = "PGRV"; - Colour = PIXPACK(0xCCCCFF); - Description = "Creates a short-lasting gravity well."; -} - -int Tool_PGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) -{ - sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] = strength*5.0f; - return 1; -} - -Tool_PGrv::~Tool_PGrv() {} diff --git a/src/simulation/simtools/Vac.cpp b/src/simulation/simtools/VAC.cpp similarity index 62% rename from src/simulation/simtools/Vac.cpp rename to src/simulation/simtools/VAC.cpp index 6f3e0b4e1..83892cbc0 100644 --- a/src/simulation/simtools/Vac.cpp +++ b/src/simulation/simtools/VAC.cpp @@ -1,16 +1,18 @@ #include "simulation/ToolCommon.h" #include "simulation/Air.h" -//#TPT-Directive ToolClass Tool_Vac TOOL_VAC 3 -Tool_Vac::Tool_Vac() +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_VAC() { Identifier = "DEFAULT_TOOL_VAC"; Name = "VAC"; Colour = PIXPACK(0x303030); Description = "Vacuum, reduces air pressure."; + Perform = &perform; } -int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) { sim->air->pv[y/CELL][x/CELL] -= strength*0.05f; @@ -20,5 +22,3 @@ int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, int brus sim->air->pv[y/CELL][x/CELL] = -256.0f; return 1; } - -Tool_Vac::~Tool_Vac() {} diff --git a/vsproject.py b/vsproject.py index 0747fd40e..b02a3f66c 100755 --- a/vsproject.py +++ b/vsproject.py @@ -107,21 +107,21 @@ vcxproj.write(r""" false $(SolutionDir)Build\ Powder - $(ProjectDir)includes;$(ProjectDir)includes/SDL2;$(ProjectDir)includes/luajit-2.0;$(ProjectDir)data;$(ProjectDir)src;$(ProjectDir)generated;$(ProjectDir)resources;$(IncludePath) + $(ProjectDir)includes;$(ProjectDir)includes/SDL2;$(ProjectDir)includes/luajit-2.0;$(ProjectDir)data;$(ProjectDir)src;$(ProjectDir)resources;$(IncludePath) $(ProjectDir)Libraries;$(LibraryPath) false $(SolutionDir)Build\ Powder - $(ProjectDir)includes;$(ProjectDir)includes/SDL2;$(ProjectDir)includes/luajit-2.0;$(ProjectDir)data;$(ProjectDir)src;$(ProjectDir)generated;$(ProjectDir)resources;$(IncludePath) + $(ProjectDir)includes;$(ProjectDir)includes/SDL2;$(ProjectDir)includes/luajit-2.0;$(ProjectDir)data;$(ProjectDir)src;$(ProjectDir)resources;$(IncludePath) $(ProjectDir)Libraries;$(LibraryPath) false $(SolutionDir)Build\ Powder - $(ProjectDir)includes;$(ProjectDir)includes/SDL2;$(ProjectDir)includes/luajit-2.0;$(ProjectDir)data;$(ProjectDir)src;$(ProjectDir)generated;$(ProjectDir)resources;$(IncludePath) + $(ProjectDir)includes;$(ProjectDir)includes/SDL2;$(ProjectDir)includes/luajit-2.0;$(ProjectDir)data;$(ProjectDir)src;$(ProjectDir)resources;$(IncludePath) $(ProjectDir)Staticlibs;$(LibraryPath) @@ -134,6 +134,7 @@ vcxproj.write(r""" Disabled Fast true + $(IntDir)\%(RelativeDir) MachineX86 @@ -152,6 +153,7 @@ vcxproj.write(r""" Fast true StreamingSIMDExtensions2 + $(IntDir)\%(RelativeDir) MachineX86 @@ -172,6 +174,7 @@ vcxproj.write(r""" Fast true StreamingSIMDExtensions2 + $(IntDir)\%(RelativeDir) MachineX86 @@ -191,8 +194,6 @@ vcxproj.write(r""" - - """) vcxproj.write('\n '.join([('') for p in cl_compile])) vcxproj.write(r""" @@ -205,8 +206,6 @@ vcxproj.write(r""" - - """) vcxproj.write('\n '.join([('') for p in cl_include])) @@ -216,7 +215,6 @@ vcxproj.write(r""" - @@ -249,31 +247,16 @@ filters.write(r""" {fc5911e1-d5ba-4da3-9cfa-5631c6914487} - - {bfb47e29-68f3-48bd-86c2-46b9f63d2597} - """) filters.write('\n '.join([('\n {' + str(uuid.uuid4()) + '}\n ') for p in source_dirs])) filters.write(r""" - - generated - - - generated - """) filters.write('\n '.join([('\n ' + os.path.dirname(p) + '\n ') for p in cl_compile])) filters.write(r""" - - generated - - - generated - src\simulation @@ -320,7 +303,6 @@ filters.write(r""" src\graphics -