A bit of refactoring (elements)

This commit is contained in:
Simon Robertshaw 2012-05-07 17:59:50 +01:00
parent fb111f42d0
commit 51b17badf4
260 changed files with 12606 additions and 4204 deletions

View File

@ -1,11 +1,15 @@
HEADERS := $(wildcard src/*.h) $(wildcard src/*/*.h)
HEADERS := $(wildcard src/*.h) $(wildcard src/*/*.h) $(wildcard generated/*.h)
SOURCES := $(wildcard src/*.cpp) $(wildcard src/*/*.cpp)
SOURCES := $(wildcard src/*.cpp) $(wildcard src/*/*.cpp) $(wildcard src/*/*/*.cpp) $(wildcard generated/*.cpp)
OBJS := $(patsubst src/%.cpp,build/obj/%.o,$(SOURCES))
NEWLINE := $(`echo "d\nd"`)
ELEMENTFILES := $(patsubst src/simulation/%,\#include "%"$(NEWLINE),$(wildcard src/simulation/elements/*.cpp))
#ELEMENTFILES := \#include "elements/watr.cpp"
FOLDERS :=
CFLAGS := -w -Isrc/ -Idata/
CFLAGS := -w -Isrc/ -Idata/ -Igenerated/
OFLAGS := -fkeep-inline-functions
CPPC := g++
@ -59,7 +63,7 @@ buildpaths-powder:
$(shell mkdir -p build/obj/powder/)
$(shell mkdir -p $(sort $(dir $(patsubst build/obj/%.o,build/obj/powder/%.o,$(OBJS)))))
build/powder-x: buildpaths-powder-x $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS))
build/powder-x: buildpaths-powder-x generate $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS))
$(CPPC) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS)) SDLmain.m $(LFLAGS) -o $@ -ggdb
build/obj/powder-x/%.o: src/%.cpp $(HEADERS)
$(CPPC) -c $(CFLAGS) $(OFLAGS) -o $@ $< -ggdb
@ -67,6 +71,9 @@ buildpaths-powder-x:
$(shell mkdir -p build/obj/powder-x/)
$(shell mkdir -p $(sort $(dir $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS)))))
generate:
python generator.py
clean:
rm -r build/obj/*
rm build/*.exe

78
generator.py Normal file
View File

@ -0,0 +1,78 @@
import re, os, shutil, string
if os.path.isdir("generated/"):
shutil.rmtree("generated/")
os.mkdir("generated")
elementClasses = dict()
elementHeader = """#ifndef ELEMENTCLASSES_H
#define ELEMENTCLASSES_H
#include <vector>
#include "simulation/Element.h"
#include "simulation/elements/Element.h"
"""
directives = []
elementFiles = os.listdir("src/simulation/Elements")
for elementFile in elementFiles:
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 = []
for d in directives:
if d[0] == "ElementClass":
elementClasses[d[1]] = []
elementHeader += "#define %s %s\n" % (d[2], d[3])
d[3] = string.atoi(d[3])
classDirectives.append(d)
for d in directives:
if d[0] == "ElementHeader":
elementClasses[d[1]].append(string.join(d[2:], " ")+";")
for className, classMembers in elementClasses.items():
elementHeader += """class {0}: public Element
{{
public:
{0}();
virtual ~{0}();
{1}
}};
""".format(className, string.join(classMembers, "\n"))
elementHeader += """std::vector<Element> GetElements();
#endif
"""
elementContent = """#include "ElementClasses.h"
std::vector<Element> GetElements()
{
std::vector<Element> elements;
""";
elementIDs = sorted(classDirectives, key=lambda directive: directive[3])
for d in elementIDs:
elementContent += """ elements.push_back(%s());
""" % (d[1])
elementContent += """ return elements;
}
""";
f = open("generated/ElementClasses.h", "w")
f.write(elementHeader)
f.close()
f = open("generated/ElementClasses.cpp", "w")
f.write(elementContent)
f.close()

View File

@ -1,6 +1,6 @@
#include <string>
#include <math.h>
#include <cmath>
#include "Console.h"
int Console::ParsePartref(char * txt)

View File

@ -1,4 +1,4 @@
#include <math.h>
#include <cmath>
#include <SDL/SDL.h>
#include <bzlib.h>
#include <string>

View File

@ -3,7 +3,7 @@
#include <string.h>
#include <regex.h>
#include <sys/types.h>
#include <math.h>
#include <cmath>
#include "Config.h"
#include "Misc.h"
#include "icondoc.h"

View File

@ -5,7 +5,7 @@
* Author: Simon
*/
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <stdio.h>
@ -14,7 +14,6 @@
#include "Renderer.h"
#include "Graphics.h"
#include "simulation/Elements.h"
#include "simulation/ElementFunctions.h"
#include "simulation/ElementGraphics.h"
#include "simulation/Air.h"
extern "C"
@ -840,12 +839,11 @@ void Renderer::render_parts()
float gradv, flicker, fnx, fny;
Particle * parts;
part_transition *ptransitions;
part_type *ptypes;
Element *elements;
if(!sim)
return;
parts = sim->parts;
ptransitions = sim->ptransitions;
ptypes = sim->ptypes;
elements = sim->elements;
#ifdef OGLR
int cfireV = 0, cfireC = 0, cfire = 0;
int csmokeV = 0, csmokeC = 0, csmoke = 0;
@ -884,15 +882,15 @@ void Renderer::render_parts()
fnx = sim->parts[i].x;
fny = sim->parts[i].y;
if((sim->photons[ny][nx]&0xFF) && !(ptypes[t].properties & TYPE_ENERGY))
if((sim->photons[ny][nx]&0xFF) && !(elements[t].Properties & TYPE_ENERGY))
continue;
//Defaults
pixel_mode = 0 | PMODE_FLAT;
cola = 255;
colr = PIXR(ptypes[t].pcolors);
colg = PIXG(ptypes[t].pcolors);
colb = PIXB(ptypes[t].pcolors);
colr = PIXR(elements[t].Colour);
colg = PIXG(elements[t].Colour);
colb = PIXB(elements[t].Colour);
firea = 0;
deca = (sim->parts[i].dcolour>>24)&0xFF;
@ -915,9 +913,9 @@ void Renderer::render_parts()
}
else if(!(colour_mode & COLOUR_BASC))
{
if (ptypes[t].graphics_func)
if (elements[t].Graphics)
{
if ((*(ptypes[t].graphics_func))(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better
if ((*(elements[t].Graphics))(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better
{
graphicscache[t].isready = 1;
graphicscache[t].pixel_mode = pixel_mode;
@ -933,25 +931,22 @@ void Renderer::render_parts()
}
else
{
if(graphics_DEFAULT(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb))
{
graphicscache[t].isready = 1;
graphicscache[t].pixel_mode = pixel_mode;
graphicscache[t].cola = cola;
graphicscache[t].colr = colr;
graphicscache[t].colg = colg;
graphicscache[t].colb = colb;
graphicscache[t].firea = firea;
graphicscache[t].firer = firer;
graphicscache[t].fireg = fireg;
graphicscache[t].fireb = fireb;
}
graphicscache[t].isready = 1;
graphicscache[t].pixel_mode = pixel_mode;
graphicscache[t].cola = cola;
graphicscache[t].colr = colr;
graphicscache[t].colg = colg;
graphicscache[t].colb = colb;
graphicscache[t].firea = firea;
graphicscache[t].firer = firer;
graphicscache[t].fireg = fireg;
graphicscache[t].fireb = fireb;
}
}
if((ptypes[t].properties & PROP_HOT_GLOW) && sim->parts[i].temp>(ptransitions[t].thv-800.0f))
if((elements[t].Properties & PROP_HOT_GLOW) && sim->parts[i].temp>(elements[t].HighTemperature-800.0f))
{
gradv = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f));
caddress = (sim->parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):sim->parts[i].temp-(ptransitions[t].thv-800.0f);
gradv = 3.1415/(2*elements[t].HighTemperature-(elements[t].HighTemperature-800.0f));
caddress = (sim->parts[i].temp>elements[t].HighTemperature)?elements[t].HighTemperature-(elements[t].HighTemperature-800.0f):sim->parts[i].temp-(elements[t].HighTemperature-800.0f);
colr += sin(gradv*caddress) * 226;;
colg += sin(gradv*caddress*4.55 +3.14) * 34;
colb += sin(gradv*caddress*2.22 +3.14) * 64;
@ -994,9 +989,9 @@ void Renderer::render_parts()
}
else if(colour_mode & COLOUR_BASC)
{
colr = PIXR(ptypes[t].pcolors);
colg = PIXG(ptypes[t].pcolors);
colb = PIXB(ptypes[t].pcolors);
colr = PIXR(elements[t].Colour);
colg = PIXG(elements[t].Colour);
colb = PIXB(elements[t].Colour);
pixel_mode = PMODE_FLAT;
}
@ -1066,9 +1061,9 @@ void Renderer::render_parts()
{
if (cplayer->elem<PT_NUM)
{
colr = PIXR(ptypes[cplayer->elem].pcolors);
colg = PIXG(ptypes[cplayer->elem].pcolors);
colb = PIXB(ptypes[cplayer->elem].pcolors);
colr = PIXR(elements[cplayer->elem].Colour);
colg = PIXG(elements[cplayer->elem].Colour);
colb = PIXB(elements[cplayer->elem].Colour);
}
else
{

View File

@ -88,14 +88,14 @@ int CommandInterface::GetParticleType(std::string type)
char * txt = (char*)type.c_str();
//Scope
part_type *ptypes = m->GetSimulation()->ptypes;
Element * elements = m->GetSimulation()->elements;
// alternative names for some elements
if (strcasecmp(txt,"C4")==0) i = PT_PLEX;
else if (strcasecmp(txt,"C5")==0) i = PT_C5;
else if (strcasecmp(txt,"NONE")==0) i = PT_NONE;
for (i=1; i<PT_NUM; i++) {
if (strcasecmp(txt, ptypes[i].name)==0 && ptypes[i].enabled)
if (strcasecmp(txt, elements[i].Name)==0 && elements[i].Enabled)
{
return i;
}

View File

@ -165,9 +165,9 @@ tpt.partsdata = nil");
tptElements = lua_gettop(l);
for(i = 1; i < PT_NUM; i++)
{
for(j = 0; j < strlen(luacon_sim->ptypes[i].name); j++)
tmpname[j] = tolower(luacon_sim->ptypes[i].name[j]);
tmpname[strlen(luacon_sim->ptypes[i].name)] = 0;
for(j = 0; j < strlen(luacon_sim->elements[i].Name); j++)
tmpname[j] = tolower(luacon_sim->elements[i].Name[j]);
tmpname[strlen(luacon_sim->elements[i].Name)] = 0;
lua_newtable(l);
currentElement = lua_gettop(l);
@ -190,9 +190,9 @@ tpt.partsdata = nil");
tptElementTransitions = lua_gettop(l);
for(i = 1; i < PT_NUM; i++)
{
for(j = 0; j < strlen(luacon_sim->ptypes[i].name); j++)
tmpname[j] = tolower(luacon_sim->ptypes[i].name[j]);
tmpname[strlen(luacon_sim->ptypes[i].name)] = 0;
for(j = 0; j < strlen(luacon_sim->elements[i].Name); j++)
tmpname[j] = tolower(luacon_sim->elements[i].Name[j]);
tmpname[strlen(luacon_sim->elements[i].Name)] = 0;
lua_newtable(l);
currentElement = lua_gettop(l);
@ -488,11 +488,11 @@ int luacon_transitionread(lua_State* l){
switch(format)
{
case 0:
tempinteger = *((int*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset));
tempinteger = *((int*)(((unsigned char*)&luacon_sim->elements[i])+offset));
lua_pushnumber(l, tempinteger);
break;
case 1:
tempfloat = *((float*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset));
tempfloat = *((float*)(((unsigned char*)&luacon_sim->elements[i])+offset));
lua_pushnumber(l, tempfloat);
break;
}
@ -522,10 +522,10 @@ int luacon_transitionwrite(lua_State* l){
switch(format)
{
case 0:
*((int*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset)) = luaL_optinteger(l, 3, 0);
*((int*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optinteger(l, 3, 0);
break;
case 1:
*((float*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset)) = luaL_optnumber(l, 3, 0);
*((float*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optnumber(l, 3, 0);
break;
}
return 0;
@ -675,19 +675,19 @@ int luacon_elementread(lua_State* l){
switch(format)
{
case 0:
tempinteger = *((int*)(((unsigned char*)&luacon_sim->ptypes[i])+offset));
tempinteger = *((int*)(((unsigned char*)&luacon_sim->elements[i])+offset));
lua_pushnumber(l, tempinteger);
break;
case 1:
tempfloat = *((float*)(((unsigned char*)&luacon_sim->ptypes[i])+offset));
tempfloat = *((float*)(((unsigned char*)&luacon_sim->elements[i])+offset));
lua_pushnumber(l, tempfloat);
break;
case 2:
tempstring = *((char**)(((unsigned char*)&luacon_sim->ptypes[i])+offset));
tempstring = *((char**)(((unsigned char*)&luacon_sim->elements[i])+offset));
lua_pushstring(l, tempstring);
break;
case 3:
tempinteger = *((unsigned char*)(((unsigned char*)&luacon_sim->ptypes[i])+offset));
tempinteger = *((unsigned char*)(((unsigned char*)&luacon_sim->elements[i])+offset));
lua_pushnumber(l, tempinteger);
break;
}
@ -719,10 +719,10 @@ int luacon_elementwrite(lua_State* l){
switch(format)
{
case 0:
*((int*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = luaL_optinteger(l, 3, 0);
*((int*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optinteger(l, 3, 0);
break;
case 1:
*((float*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = luaL_optnumber(l, 3, 0);
*((float*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optnumber(l, 3, 0);
break;
case 2:
tempstring = mystrdup((char*)luaL_optstring(l, 3, ""));
@ -745,11 +745,11 @@ int luacon_elementwrite(lua_State* l){
return luaL_error(l, "Name in use");
}
}
*((char**)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = tempstring;
*((char**)(((unsigned char*)&luacon_sim->elements[i])+offset)) = tempstring;
//Need some way of cleaning up previous values
break;
case 3:
*((unsigned char*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = luaL_optinteger(l, 3, 0);
*((unsigned char*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optinteger(l, 3, 0);
break;
}
if (modified_stuff)
@ -953,7 +953,7 @@ int luatpt_create(lua_State* l)
if(x < XRES && y < YRES){
if(lua_isnumber(l, 3)){
t = luaL_optint(l, 3, 0);
if (t<0 || t >= PT_NUM || !luacon_sim->ptypes[t].enabled)
if (t<0 || t >= PT_NUM || !luacon_sim->elements[t].Enabled)
return luaL_error(l, "Unrecognised element number '%d'", t);
} else {
name = (char*)luaL_optstring(l, 3, "dust");

View File

@ -1,30 +0,0 @@
#include "simulation/Element.h"
int update_O2(UPDATE_FUNC_ARGS)
{
int r,rx,ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_FIRE)
{
parts[r>>8].temp+=(rand()/(RAND_MAX/100));
if(parts[r>>8].tmp&0x01)
parts[r>>8].temp=3473;
parts[r>>8].tmp |= 2;
}
if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM)
{
sim->create_part(i,x,y,PT_FIRE);
parts[i].temp+=(rand()/(RAND_MAX/100));
parts[i].tmp |= 2;
}
}
return 0;
}

View File

@ -1,58 +0,0 @@
#include "simulation/Element.h"
int update_ACEL(UPDATE_FUNC_ARGS) {
int r, rx, ry;
parts[i].tmp = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry) && !(rx && ry))
{
r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if(sim->ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{
parts[r>>8].vx *= 1.1f;
parts[r>>8].vy *= 1.1f;
parts[i].tmp = 1;
}
}
return 0;
}
int graphics_ACEL(GRAPHICS_FUNC_ARGS)
{
if(cpart->tmp)
*pixel_mode |= PMODE_GLOW;
return 0;
}
int update_DCEL(UPDATE_FUNC_ARGS) {
int r, rx, ry;
parts[i].tmp = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry) && !(rx && ry))
{
r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if(sim->ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{
parts[r>>8].vx *= 0.9f;
parts[r>>8].vy *= 0.9f;
parts[i].tmp = 1;
}
}
return 0;
}
int graphics_DCEL(GRAPHICS_FUNC_ARGS)
{
if(cpart->tmp)
*pixel_mode |= PMODE_GLOW;
return 0;
}

View File

@ -1,76 +0,0 @@
#include "simulation/Element.h"
int update_ACID(UPDATE_FUNC_ARGS) {
int r, rx, ry, trade, np;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_ACID && (r&0xFF)!=PT_CAUS)
{
if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD)
{
sim->part_change_type(i,x,y,PT_FIRE);
sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE);
parts[i].life = 4;
parts[r>>8].life = 4;
}
else if ((r&0xFF)==PT_WTRV)
{
if(!(rand()%250))
{
sim->part_change_type(i, x, y, PT_CAUS);
parts[i].life = (rand()%50)+25;
sim->kill_part(r>>8);
}
}
else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50)
{
if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid
{
float newtemp = ((60.0f-(float)sim->ptypes[r&0xFF].hardness))*7.0f;
if(newtemp < 0){
newtemp = 0;
}
parts[i].temp += newtemp;
parts[i].life--;
sim->kill_part(r>>8);
}
}
else if (parts[i].life<=50)
{
sim->kill_part(i);
return 1;
}
}
}
for ( trade = 0; trade<2; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if ((r&0xFF)==PT_ACID&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
{
int temp = parts[i].life - parts[r>>8].life;
if (temp ==1)
{
parts[r>>8].life ++;
parts[i].life --;
}
else if (temp>0)
{
parts[r>>8].life += temp/2;
parts[i].life -= temp/2;
}
}
}
}
return 0;
}

View File

@ -1,28 +0,0 @@
#include "simulation/Element.h"
int update_AMTR(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO)
{
parts[i].life++;
if (parts[i].life==4)
{
sim->kill_part(i);
return 1;
}
if (10>(rand()/(RAND_MAX/100)))
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT);
else
sim->kill_part(r>>8);
sim->pv[y/CELL][x/CELL] -= 2.0f;
}
}
return 0;
}

View File

@ -1,27 +0,0 @@
#include "simulation/Element.h"
int update_ANAR(UPDATE_FUNC_ARGS) {
int r, rx, ry;
//if (parts[i].temp >= 0.23)
// parts[i].temp --;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_HFLM)
{
if (1>rand()%22)
{
sim->part_change_type(i,x,y,PT_HFLM);
parts[i].life = rand()%150+50;
parts[r>>8].temp = parts[i].temp = 0;
sim->pv[y/CELL][x/CELL] -= 0.5;
}
}
}
return 0;
}

View File

@ -1,40 +0,0 @@
#include "simulation/Element.h"
int update_BCLN(UPDATE_FUNC_ARGS) {
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f)
parts[i].life = rand()%40+80;
if (parts[i].life)
{
float advection = 0.1f;
parts[i].vx += advection*sim->vx[y/CELL][x/CELL];
parts[i].vy += advection*sim->vy[y/CELL][x/CELL];
}
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&
(r&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_PBCN &&
(r&0xFF)<PT_NUM)
{
parts[i].ctype = r&0xFF;
if ((r&0xFF)==PT_LIFE)
parts[i].tmp = parts[r>>8].ctype;
}
}
}
else {
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8));
else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
}
return 0;
}

View File

@ -1,68 +0,0 @@
#include "simulation/Element.h"
int update_BCOL(UPDATE_FUNC_ARGS) {
int r, rx, ry, trade, temp;
if (parts[i].life<=0) {
sim->create_part(i, x, y, PT_FIRE);
return 1;
} else if (parts[i].life < 100) {
parts[i].life--;
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{
if (parts[i].life>100) {
parts[i].life = 99;
}
}
if ((r&0xFF)==PT_LAVA && 1>(rand()%500))
{
if (parts[r>>8].ctype == PT_IRON) {
parts[r>>8].ctype = PT_METL;
sim->kill_part(i);
return 1;
}
}
}
/*if(100-parts[i].life > parts[i].tmp2)
parts[i].tmp2 = 100-parts[i].life;
if(parts[i].tmp2 < 0) parts[i].tmp2 = 0;
for ( trade = 0; trade<4; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{
int temp = parts[i].tmp2 - parts[r>>8].tmp2;
if(temp < 10)
continue;
if (temp ==1)
{
parts[r>>8].tmp2 ++;
parts[i].tmp2 --;
}
else if (temp>0)
{
parts[r>>8].tmp2 += temp/2;
parts[i].tmp2 -= temp/2;
}
}
}
}*/
if(parts[i].temp > parts[i].tmp2)
parts[i].tmp2 = parts[i].temp;
return 0;
}

View File

@ -1,44 +0,0 @@
#include "simulation/Element.h"
//Used by ALL 3 BIZR states
int update_BIZR(UPDATE_FUNC_ARGS) {
int r, rx, ry, nr, ng, nb, na;
float tr, tg, tb, ta, mr, mg, mb, ma;
float blend;
if(parts[i].dcolour){
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS)
{
blend = 0.95f;
tr = (parts[r>>8].dcolour>>16)&0xFF;
tg = (parts[r>>8].dcolour>>8)&0xFF;
tb = (parts[r>>8].dcolour)&0xFF;
ta = (parts[r>>8].dcolour>>24)&0xFF;
mr = (parts[i].dcolour>>16)&0xFF;
mg = (parts[i].dcolour>>8)&0xFF;
mb = (parts[i].dcolour)&0xFF;
ma = (parts[i].dcolour>>24)&0xFF;
nr = (tr*blend) + (mr*(1-blend));
ng = (tg*blend) + (mg*(1-blend));
nb = (tb*blend) + (mb*(1-blend));
na = (ta*blend) + (ma*(1-blend));
parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24;
}
}
}
if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT)
{
sim->part_change_type(r>>8, x, y, PT_ELEC);
parts[r>>8].ctype = 0;
}
return 0;
}

View File

@ -1,29 +0,0 @@
#include "simulation/Element.h"
int update_BMTL(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt, tempFactor;
if (parts[i].tmp>1)
{
parts[i].tmp--;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100)))
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL);
parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
}
}
}
else if (parts[i].tmp==1 && 1>rand()%1000)
{
parts[i].tmp = 0;
sim->part_change_type(i,x,y,PT_BRMT);
}
return 0;
}

View File

@ -1,34 +0,0 @@
#include "simulation/Element.h"
int update_BRMT(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt, tempFactor;
if (parts[i].temp > (250.0f+273.15f))
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
tempFactor = 1000 - (((250.0f+273.15f)-parts[i].temp)*2);
if(tempFactor < 2)
tempFactor = 2;
if ((rt==PT_BREC) && 1 > (rand()%tempFactor))
{
if(rand()%2)
{
sim->create_part(r>>8, x+rx, y+ry, PT_THRM);
}
else
{ sim->create_part(i, x, y, PT_THRM);
}
return 1;
//part_change_type(r>>8,x+rx,y+ry,PT_BMTL);
//parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
}
}
}
return 0;
}

View File

@ -1,24 +0,0 @@
#include "simulation/Element.h"
int update_BTRY(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL)
{
if ((sim->ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4)
{
parts[r>>8].life = 4;
parts[r>>8].ctype = rt;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
}
}
}
return 0;
}

View File

@ -1,24 +0,0 @@
#include "simulation/Element.h"
int update_C5(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100)||(r&0xFF)==PT_HFLM)
{
if (1>rand()%6)
{
sim->part_change_type(i,x,y,PT_HFLM);
parts[r>>8].temp = parts[i].temp = 0;
parts[i].life = rand()%150+50;
sim->pv[y/CELL][x/CELL] += 1.5;
}
}
}
return 0;
}

View File

@ -1,35 +0,0 @@
#include "simulation/Element.h"
int update_CAUS(UPDATE_FUNC_ARGS) {
int r, rx, ry, trade, np;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_ACID && (r&0xFF)!=PT_CAUS)
{
if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50)
{
if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid
{
float newtemp = ((60.0f-(float)sim->ptypes[r&0xFF].hardness))*7.0f;
if(newtemp < 0){
newtemp = 0;
}
parts[i].temp += newtemp;
parts[i].life--;
sim->kill_part(r>>8);
}
}
else if (parts[i].life<=50)
{
sim->kill_part(i);
return 1;
}
}
}
return 0;
}

View File

@ -1,32 +0,0 @@
#include "simulation/Element.h"
int update_CLNE(UPDATE_FUNC_ARGS) {
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&
(r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 &&
(r&0xFF)<PT_NUM)
{
parts[i].ctype = r&0xFF;
if ((r&0xFF)==PT_LIFE)
parts[i].tmp = parts[r>>8].ctype;
}
}
}
else {
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8));
else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
}
return 0;
}

View File

@ -1,38 +0,0 @@
#include "simulation/Element.h"
int update_CLST(UPDATE_FUNC_ARGS) {
int r, rx, ry;
float cxy;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR && 1>(rand()%1500))
{
sim->part_change_type(i,x,y,PT_PSTS);
sim->kill_part(r>>8);
}
if ((r&0xFF)==PT_NITR)
{
sim->create_part(i, x, y, PT_BANG);
sim->create_part(r>>8, x+rx, y+ry, PT_BANG);
}
if ((r&0xFF)==PT_CLST)
{
if(parts[i].temp <195)
cxy = 0.05;
if(parts[i].temp >= 195 && parts[i].temp <295)
cxy = 0.015;
if(parts[i].temp >= 295 && parts[i].temp <350)
cxy = 0.01;
if(parts[i].temp > 350)
cxy = 0.005;
parts[i].vx += cxy*rx;
parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005.
}
}
return 0;
}

View File

@ -1,75 +0,0 @@
#include "simulation/Element.h"
int update_COAL(UPDATE_FUNC_ARGS) {
int r, rx, ry, trade, temp;
if (parts[i].life<=0) {
sim->create_part(i, x, y, PT_FIRE);
return 1;
} else if (parts[i].life < 100) {
parts[i].life--;
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
}
if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40)
parts[i].tmp=39;
else if (parts[i].tmp<40&&parts[i].tmp>0)
parts[i].tmp--;
else if (parts[i].tmp<=0) {
sim->create_part(i, x, y, PT_BCOL);
return 1;
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{
if (parts[i].life>100) {
parts[i].life = 99;
}
}
if ((r&0xFF)==PT_LAVA && 1>(rand()%500))
{
if (parts[r>>8].ctype == PT_IRON) {
parts[r>>8].ctype = PT_METL;
sim->kill_part(i);
return 1;
}
}
}
/*if(100-parts[i].life > parts[i].tmp2)
parts[i].tmp2 = 100-parts[i].life;
if(parts[i].tmp2 < 0) parts[i].tmp2 = 0;
for ( trade = 0; trade<4; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{
int temp = parts[i].tmp2 - parts[r>>8].tmp2;
if(temp < 10)
continue;
if (temp ==1)
{
parts[r>>8].tmp2 ++;
parts[i].tmp2 --;
}
else if (temp>0)
{
parts[r>>8].tmp2 += temp/2;
parts[i].tmp2 -= temp/2;
}
}
}
}*/
if(parts[i].temp > parts[i].tmp2)
parts[i].tmp2 = parts[i].temp;
return 0;
}

View File

@ -1,66 +0,0 @@
#include "simulation/Element.h"
int update_DEST(UPDATE_FUNC_ARGS) {
int r,rx,ry,topv;
rx=rand()%5-2;
ry=rand()%5-2;
r = pmap[y+ry][x+rx];
if (!r || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN)
return 0;
if (parts[i].life<=0 || parts[i].life>37)
{
parts[i].life=30+rand()%20;
parts[i].temp+=20000;
sim->pv[y/CELL][x/CELL]+=60.0f;
}
parts[i].temp+=10000;
if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT)
{
sim->pv[y/CELL][x/CELL]+=20.0f;
parts[i].temp+=18000;
if (rand()%2==0)
{
float orig_temp = parts[r>>8].temp;
sim->create_part(r>>8, x+rx, y+ry, PT_NEUT);
parts[r>>8].temp = restrict_flt(orig_temp+40000.0f, MIN_TEMP, MAX_TEMP);
sim->pv[y/CELL][x/CELL] += 10.0f;
parts[i].life-=4;
}
}
else if ((r&0xFF)==PT_INSL)
{
sim->create_part(r>>8, x+rx, y+ry, PT_PLSM);
}
else if (rand()%3==0)
{
sim->kill_part(r>>8);
parts[i].life -= 4*((sim->ptypes[r&0xFF].properties&TYPE_SOLID)?3:1);
if (parts[i].life<=0)
parts[i].life=1;
parts[i].temp+=10000;
}
else
{
if (sim->ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP);
}
topv=sim->pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900;
if (topv>40.0f)
topv=40.0f;
sim->pv[y/CELL][x/CELL]+=40.0f+topv;
parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP);
return 0;
}
int graphics_DEST(GRAPHICS_FUNC_ARGS)
{
if(cpart->life)
{
*pixel_mode |= PMODE_LFLARE;
}
else
{
*pixel_mode |= PMODE_SPARK;
}
return 0;
}

View File

@ -1,48 +0,0 @@
#include "simulation/Element.h"
int update_DLAY(UPDATE_FUNC_ARGS) {
int r, rx, ry, oldl;
oldl = parts[i].life;
if (parts[i].life>0)
parts[i].life--;
//if (parts[i].life==1)
//{
if (parts[i].temp>=MAX_TEMP+273.15f)
parts[i].temp = MAX_TEMP+273.15f;
if (parts[i].temp<= 1.0f+273.15f)
parts[i].temp = 1.0f+273.15f;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r || sim->parts_avg(r>>8, i,PT_INSL)==PT_INSL)
continue;
if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN)
{
parts[i].life = (int)(parts[i].temp-273.15);
}
else if ((r&0xFF)==PT_DLAY)
{
if(!parts[i].life && parts[r>>8].life)
{
parts[i].life = parts[r>>8].life;
if((r>>8)>i) //If the other particle hasn't been life updated
parts[i].life--;
}
else if(parts[i].life && !parts[r>>8].life)
{
parts[r>>8].life = parts[i].life;
if((r>>8)>i) //If the other particle hasn't been life updated
parts[r>>8].life++;
}
}
else if((r&0xFF)==PT_NSCN && oldl==1)
{
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
}
}
//}
return 0;
}

View File

@ -1,39 +0,0 @@
#include "simulation/Element.h"
int update_DSTW(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%250))
{
sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_WATR);
}
if ((r&0xFF)==PT_SLTW && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_SLTW);
}
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
}
if ((r&0xFF)==PT_FIRE){
sim->kill_part(r>>8);
if(1>(rand()%150)){
sim->kill_part(i);
return 1;
}
}
}
return 0;
}

View File

@ -1,12 +0,0 @@
#include "simulation/Element.h"
int update_MISC(UPDATE_FUNC_ARGS) {
/*int t = parts[i].type;
if (t==PT_LOVE)
ISLOVE=1;
else if (t==PT_LOLZ)
ISLOLZ=1;
else if (t==PT_GRAV)
ISGRAV=1;*/
return 0;
}

View File

@ -1,19 +0,0 @@
#include "simulation/Element.h"
int graphics_FIRE(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];
*colg = (unsigned char)ren->flm_data[caddress+1];
*colb = (unsigned char)ren->flm_data[caddress+2];
*firea = 255;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode = PMODE_NONE; //Clear default, don't draw pixel
*pixel_mode |= FIRE_ADD;
//Returning 0 means dynamic, do not cache
return 0;
}

View File

@ -1,65 +0,0 @@
#include "simulation/Element.h"
int update_FIRW(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt, np;
if (parts[i].tmp==0) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
{
parts[i].tmp = 1;
parts[i].life = rand()%50+60;
}
}
}
else if (parts[i].tmp==1) {
if (parts[i].life==0) {
parts[i].tmp=2;
} else {
float newVel = parts[i].life/25;
parts[i].flags &= ~FLAG_STAGNANT;
/* TODO:
if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) {
parts[i].vy = -newVel;
ly-=newVel;
iy-=newVel;
}*/
parts[i].vy = -newVel;
}
}
else if (parts[i].tmp==2) {
int col = rand()%200+4;
int tmul;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
tmul = rand()%7;
np = sim->create_part(-1, x+rx, y+ry, PT_FIRW);
if (np>-1)
{
parts[np].vx = (rand()%3-1)*tmul;
parts[np].vy = (rand()%3-1)*tmul;
parts[np].tmp = col;
parts[np].life = rand()%100+100;
parts[np].temp = 6000.0f;
parts[np].dcolour = parts[i].dcolour;
}
}
sim->pv[y/CELL][x/CELL] += 20;
sim->kill_part(i);
return 1;
} else if (parts[i].tmp>=3) {
if (parts[i].life<=0) {
sim->kill_part(i);
return 1;
}
}
return 0;
}

View File

@ -1,22 +0,0 @@
#include "simulation/Element.h"
int update_FOG(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->ptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN?
{
sim->part_change_type(i,x,y,PT_RIME);
}
if ((r&0xFF)==PT_SPRK)
{
parts[i].life += rand()%20;
}
}
return 0;
}

View File

@ -1,29 +0,0 @@
#include "simulation/Element.h"
int update_FRAY(UPDATE_FUNC_ARGS) {
int r, nxx, nyy, docontinue, len, nxi, nyi, rx, ry, nr, ry1, rx1;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK) {
for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; docontinue; nyy+=nyi, nxx+=nxi, len++) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>10) {
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
if (!r)
r = sim->photons[y+nyi+nyy][x+nxi+nxx];
if (r && !(sim->ptypes[r&0xFF].properties & TYPE_SOLID)){
parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f);
parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f);
}
}
}
}
return 0;
}

View File

@ -1,30 +0,0 @@
#include "simulation/Element.h"
int update_FRZW(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>rand()%70)
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW);
}
}
if (parts[i].life==0&&13>rand()%2500)
{
sim->part_change_type(i,x,y,PT_ICEI);
parts[i].ctype=PT_FRZW;
parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP);
}
else if ((100-(parts[i].life))>rand()%50000)
{
sim->part_change_type(i,x,y,PT_ICEI);
parts[i].ctype=PT_FRZW;
parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP);
}
return 0;
}

View File

@ -1,25 +0,0 @@
#include "simulation/Element.h"
int update_FRZZ(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>rand()%100)
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW);
parts[r>>8].life = 100;
parts[i].type = PT_NONE;
}
}
if (parts[i].type==PT_NONE) {
sim->kill_part(i);
return 1;
}
return 0;
}

View File

@ -1,35 +0,0 @@
#include "simulation/Element.h"
int update_FSEP(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if (parts[i].life<=0) {
r = sim->create_part(i, x, y, PT_PLSM);
if (r!=-1)
parts[r].life = 50;
return 1;
} else if (parts[i].life < 40) {
parts[i].life--;
if ((rand()%10)==0) {
r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM);
if (r!=-1)
parts[r].life = 50;
}
}
else {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15))
{
if (parts[i].life>40) {
parts[i].life = 39;
}
}
}
}
return 0;
}

View File

@ -1,41 +0,0 @@
#include "simulation/Element.h"
int update_FUSE(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if (parts[i].life<=0) {
r = sim->create_part(i, x, y, PT_PLSM);
if (r!=-1)
parts[r].life = 50;
return 1;
} else if (parts[i].life < 40) {
parts[i].life--;
if ((rand()%100)==0) {
r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM);
if (r!=-1)
parts[r].life = 50;
}
}
if ((sim->pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40)
parts[i].tmp=39;
else if (parts[i].tmp<40&&parts[i].tmp>0)
parts[i].tmp--;
else if (parts[i].tmp<=0) {
sim->create_part(i, x, y, PT_FSEP);
return 1;
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)))
{
if (parts[i].life>40) {
parts[i].life = 39;
}
}
}
return 0;
}

View File

@ -1,26 +0,0 @@
#include "simulation/Element.h"
int update_GBMB(UPDATE_FUNC_ARGS) {
int rx,ry,r;
if (parts[i].life<=0)
{
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
{
r = pmap[y+ry][x+rx];
if(!r)
continue;
if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB &&
(r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_DMND)
{
parts[i].life=60;
break;
}
}
}
if(parts[i].life>20)
sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 20;
if(parts[i].life<20 && parts[i].life>=1)
sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = -80;
return 0;
}

View File

@ -1,68 +0,0 @@
#include "simulation/Element.h"
int update_GEL(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
//Desaturation
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_CBNW)
&& parts[i].tmp<100)
{
parts[i].tmp = (100+parts[i].tmp)/2;
sim->kill_part(r>>8);
}
char gel = 0;
if ((r&0xFF)==PT_GEL)
gel = 1;
//Concentration diffusion
if (gel && (parts[r>>8].tmp+1)<parts[i].tmp)
{
parts[r>>8].tmp++;
parts[i].tmp--;
}
if ((r&0xFF)==PT_SPNG && (parts[r>>8].life+1)<parts[i].tmp)
{
parts[r>>8].life++;
parts[i].tmp--;
}
float dx, dy;
dx = parts[i].x - parts[r>>8].x;
dy = parts[i].y - parts[r>>8].y;
//Stickness
if ((dx*dx + dy*dy)>1.5 && (gel || !sim->ptypes[r&0xFF].falldown || (fabs(rx)<2 && fabs(ry)<2)))
{
float per, nd;
nd = dx*dx + dy*dy - 0.5;
per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5);
if (sim->ptypes[r&0xFF].state==ST_LIQUID)
per *= 0.1;
dx *= per; dy *= per;
parts[i].vx += dx; parts[r>>8].vx -= dx;
parts[i].vy += dy; parts[r>>8].vy -= dy;
}
}
return 0;
}
int graphics_GEL(GRAPHICS_FUNC_ARGS)
{
int q = cpart->tmp;
*colr = q*(32-255)/120+255;
*colg = q*(48-186)/120+186;
*colb = q*208/120;
return 0;
}

View File

@ -1,11 +0,0 @@
#include "simulation/Element.h"
int update_GLAS(UPDATE_FUNC_ARGS) {
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f)
{
sim->part_change_type(i,x,y,PT_BGLA);
}
return 0;
}

View File

@ -1,28 +0,0 @@
#include "simulation/Element.h"
int update_GLOW(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>(rand()%2000))
{
parts[i].type = PT_NONE;
sim->part_change_type(r>>8,x+rx,y+ry,PT_DEUT);
parts[r>>8].life = 10;
}
}
parts[i].ctype = sim->pv[y/CELL][x/CELL]*16;
parts[i].tmp = abs((int)((sim->vx[y/CELL][x/CELL]+sim->vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f));
//printf("%f %f\n", parts[i].vx, parts[i].vy);
if (parts[i].type==PT_NONE) {
sim->kill_part(i);
return 1;
}
return 0;
}

View File

@ -1,13 +0,0 @@
#include "simulation/Element.h"
int update_GOO(UPDATE_FUNC_ARGS) {
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f)
parts[i].life = rand()%80+300;
if (parts[i].life)
{
float advection = 0.1f;
parts[i].vx += advection*sim->vx[y/CELL][x/CELL];
parts[i].vy += advection*sim->vy[y/CELL][x/CELL];
}
return 0;
}

View File

@ -1,34 +0,0 @@
#include "simulation/Element.h"
int update_GPMP(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
if (parts[i].life==10)
{
if (parts[i].temp>=256.0+273.15)
parts[i].temp=256.0+273.15;
if (parts[i].temp<= -256.0+273.15)
parts[i].temp = -256.0+273.15;
sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 0.2f*(parts[i].temp-273.15);
if (y+CELL<YRES && sim->pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
sim->gravmap[(y/CELL+1)*(XRES/CELL)+(x/CELL)] += 0.1f*((parts[i].temp-273.15)-sim->gravmap[(y/CELL+1)*(XRES/CELL)+(x/CELL)]);
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_GPMP)
{
if (parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
else if (parts[r>>8].life==0)
parts[r>>8].life = 10;
}
}
}
return 0;
}

View File

@ -1,23 +0,0 @@
#include "simulation/Element.h"
int graphics_DEFAULT(GRAPHICS_FUNC_ARGS)
{
int t = cpart->type;
//Property based defaults
if(ren->sim->ptypes[t].properties & PROP_RADIOACTIVE) *pixel_mode |= PMODE_GLOW;
if(ren->sim->ptypes[t].properties & TYPE_LIQUID)
{
*pixel_mode |= PMODE_BLUR;
}
if(ren->sim->ptypes[t].properties & TYPE_GAS)
{
*pixel_mode &= ~PMODE;
*pixel_mode |= FIRE_BLEND;
*firer = *colr/2;
*fireg = *colg/2;
*fireb = *colb/2;
*firea = 125;
*pixel_mode |= DECO_FIRE;
}
return 1;
}

View File

@ -1,26 +0,0 @@
#include "simulation/Element.h"
int update_HSWC(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
if (parts[i].life==10)
{
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_HSWC)
{
if (parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
else if (parts[r>>8].life==0)
parts[r>>8].life = 10;
}
}
}
return 0;
}

View File

@ -1,23 +0,0 @@
#include "simulation/Element.h"
int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well
int r, rx, ry;
if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW
{
parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP);
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000))
{
sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
}
return 0;
}

View File

@ -1,44 +0,0 @@
#include "simulation/Element.h"
int update_IGNT(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if(parts[i].tmp==0)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM)
{
parts[i].tmp = 1;
}
else if ((r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH || ((r&0xFF)==PT_IGNT && parts[r>>8].life==1))
{
parts[i].tmp = 1;
}
}
}
else if(parts[i].life > 0)
{
if(rand()%3)
{
int nb = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_BOMB);
if (nb!=-1) {
parts[nb].tmp = 1;
parts[nb].life = 30;
parts[nb].vx = rand()%20-10;
parts[nb].vy = rand()%20-10;
parts[nb].temp = restrict_flt(400.0f+parts[i].temp-273.15, MIN_TEMP, MAX_TEMP);
}
}
else
{
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
}
parts[i].life--;
}
return 0;
}

View File

@ -1,25 +0,0 @@
#include "simulation/Element.h"
int update_IRON(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) ||
((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) ||
((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) ||
((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) ||
((r&0xFF) == PT_LO2))&&
(!(parts[i].life))
)
{
sim->part_change_type(i,x,y,PT_BMTL);
parts[i].tmp=(rand()/(RAND_MAX/10))+20;
}
}
return 0;
}

View File

@ -1,14 +0,0 @@
#include "simulation/Element.h"
int update_ISZ(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ
float rr, rrr;
if (1>rand()%200 && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000))
{
sim->create_part(i, x, y, PT_PHOT);
rr = (rand()%228+128)/127.0f;
rrr = (rand()%360)*3.14159f/180.0f;
parts[i].vx = rr*cosf(rrr);
parts[i].vy = rr*sinf(rrr);
}
return 0;
}

View File

@ -1,19 +0,0 @@
#include "simulation/Element.h"
int graphics_LAVA(GRAPHICS_FUNC_ARGS)
{
*colr = cpart->life * 2 + 0xE0;
*colg = cpart->life * 1 + 0x50;
*colb = cpart->life / 2 + 0x10;
if (*colr>255) *colr = 255;
if (*colg>192) *colg = 192;
if (*colb>128) *colb = 128;
*firea = 40;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode |= FIRE_ADD;
*pixel_mode |= PMODE_BLUR;
//Returning 0 means dynamic, do not cache
return 0;
}

View File

@ -1,61 +0,0 @@
#include "simulation/Element.h"
int update_LCRY(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if(parts[i].tmp==1 || parts[i].tmp==0)
{
if(parts[i].tmp==1)
{
if(parts[i].life<=0)
parts[i].tmp = 0;
else
{
parts[i].life-=2;
if(parts[i].life < 0)
parts[i].life = 0;
parts[i].tmp2 = parts[i].life;
}
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == 3)
{
parts[r>>8].tmp = 1;
}
}
}
else if(parts[i].tmp==2 || parts[i].tmp==3)
{
if(parts[i].tmp==2)
{
if(parts[i].life>=10)
parts[i].tmp = 3;
else
{
parts[i].life+=2;
if(parts[i].life > 10)
parts[i].life = 10;
parts[i].tmp2 = parts[i].life;
}
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == 0)
{
parts[r>>8].tmp = 2;
}
}
}
return 0;
}

View File

@ -1,120 +0,0 @@
#include "simulation/Element.h"
// Interactions which only occur when legacy_enable is on
int update_legacy_all(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt;
int t = parts[i].type;
if (!sim->legacy_enable) return 0;
if (t==PT_WTRV) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 &&
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000))
{
sim->part_change_type(i,x,y,PT_WATR);
sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR);
}
if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000))
{
sim->part_change_type(i,x,y,PT_WATR);
if (1>(rand()%1000))
sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR);
}
}
}
else if (t==PT_WATR) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 &&
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
{
sim->part_change_type(i,x,y,PT_WTRV);
}
}
}
else if (t==PT_SLTW) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 &&
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
{
sim->part_change_type(i,x,y,PT_SALT);
sim->part_change_type(r>>8,x+rx,y+ry,PT_WTRV);
}
}
}
else if (t==PT_DSTW) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 &&
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
{
sim->part_change_type(i,x,y,PT_WTRV);
}
}
}
else if (t==PT_ICEI) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
{
sim->part_change_type(i,x,y,PT_ICEI);
sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI);
}
}
}
else if (t==PT_SNOW) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
{
sim->part_change_type(i,x,y,PT_ICEI);
sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI);
}
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000))
sim->part_change_type(i,x,y,PT_WATR);
}
}
if (t==PT_WTRV && sim->pv[y/CELL][x/CELL]>4.0f)
sim->part_change_type(i,x,y,PT_DSTW);
if (t==PT_OIL && sim->pv[y/CELL][x/CELL]<-6.0f)
sim->part_change_type(i,x,y,PT_GAS);
if (t==PT_GAS && sim->pv[y/CELL][x/CELL]>6.0f)
sim->part_change_type(i,x,y,PT_OIL);
if (t==PT_DESL && sim->pv[y/CELL][x/CELL]>12.0f)
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = rand()%50+120;
}
return 0;
}

View File

@ -1,6 +0,0 @@
#include "simulation/Element.h"
int update_MORT(UPDATE_FUNC_ARGS) {
sim->create_part(-1, x, y-1, PT_SMKE);
return 0;
}

View File

@ -1,6 +0,0 @@
#include "simulation/Element.h"
int update_NBHL(UPDATE_FUNC_ARGS) {
sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += 0.1f;
return 0;
}

View File

@ -1,27 +0,0 @@
#include "simulation/Element.h"
int update_NBLE(UPDATE_FUNC_ARGS)
{
if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f)
{
parts[i].tmp = 1;
if (rand()%5 < 1)
{
int j;
float temp = parts[i].temp;
sim->part_change_type(i,x,y,PT_PLSM);
parts[i].life = rand()%150+50;
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1)
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1)
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT);
if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; }
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2);
if (j != -1) parts[j].temp = temp-1000;
parts[i].temp += 10000;
sim->pv[y/CELL][x/CELL] += 30;
}
}
return 0;
}

View File

@ -1,542 +0,0 @@
#include "simulation/Element.h"
#include "hmap.h"
int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT
{
int t = cpart->type, z = cpart->tmp - 5;//speckles!
/*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz
{
float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f));
int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f);
*colr += sin(frequency*q) * 226 + (z * 16);
*colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16);
*colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16);
}
else*/
{
*colr += z * 16;
*colg += z * 16;
*colb += z * 16;
}
return 0;
}
int graphics_CLST(GRAPHICS_FUNC_ARGS)
{
int z = cpart->tmp - 5;//speckles!
*colr += z * 16;
*colg += z * 16;
*colb += z * 16;
return 0;
}
int graphics_CBNW(GRAPHICS_FUNC_ARGS)
{
int z = cpart->tmp2 - 20;//speckles!
*colr += z * 1;
*colg += z * 2;
*colb += z * 8;
return 0;
}
int graphics_SPNG(GRAPHICS_FUNC_ARGS)
{
*colr -= cpart->life*15;
*colg -= cpart->life*15;
*colb -= cpart->life*15;
if (*colr<=50)
*colr = 50;
if (*colg<=50)
*colg = 50;
if (*colb<=20)
*colb = 20;
return 0;
}
int graphics_LIFE(GRAPHICS_FUNC_ARGS)
{
pixel pc;
if (cpart->ctype==NGT_LOTE)//colors for life states
{
if (cpart->tmp==2)
pc = PIXRGB(255, 128, 0);
else if (cpart->tmp==1)
pc = PIXRGB(255, 255, 0);
else
pc = PIXRGB(255, 0, 0);
}
else if (cpart->ctype==NGT_FRG2)//colors for life states
{
if (cpart->tmp==2)
pc = PIXRGB(0, 100, 50);
else
pc = PIXRGB(0, 255, 90);
}
else if (cpart->ctype==NGT_STAR)//colors for life states
{
if (cpart->tmp==4)
pc = PIXRGB(0, 0, 128);
else if (cpart->tmp==3)
pc = PIXRGB(0, 0, 150);
else if (cpart->tmp==2)
pc = PIXRGB(0, 0, 190);
else if (cpart->tmp==1)
pc = PIXRGB(0, 0, 230);
else
pc = PIXRGB(0, 0, 70);
}
else if (cpart->ctype==NGT_FROG)//colors for life states
{
if (cpart->tmp==2)
pc = PIXRGB(0, 100, 0);
else
pc = PIXRGB(0, 255, 0);
}
else if (cpart->ctype==NGT_BRAN)//colors for life states
{
if (cpart->tmp==1)
pc = PIXRGB(150, 150, 0);
else
pc = PIXRGB(255, 255, 0);
} else {
pc = PIXRGB(255, 255, 0);//sim->gmenu[cpart->ctype].colour;
}
*colr = PIXR(pc);
*colg = PIXG(pc);
*colb = PIXB(pc);
return 0;
}
int graphics_DUST(GRAPHICS_FUNC_ARGS)
{
if(cpart->life >= 1)
{
*firea = 120;
*firer = *colr = cpart->flags;
*fireg = *colg = cpart->tmp;
*fireb = *colb = cpart->ctype;
if (ren->decorations_enable && cpart->dcolour)
{
int a = (cpart->dcolour>>24)&0xFF;
*firer = *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8;
*fireg = *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8;
*fireb = *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8;
}
*pixel_mode |= PMODE_GLOW | FIRE_ADD;
/**firea = 255;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;*/
}
return 0;
}
int graphics_GRAV(GRAPHICS_FUNC_ARGS)
{
int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2;
*colr = 20;
*colg = 20;
*colb = 20;
if (cpart->vx>0)
{
*colr += (cpart->vx)*GRAV_R;
*colg += (cpart->vx)*GRAV_G;
*colb += (cpart->vx)*GRAV_B;
}
if (cpart->vy>0)
{
*colr += (cpart->vy)*GRAV_G;
*colg += (cpart->vy)*GRAV_B;
*colb += (cpart->vy)*GRAV_R;
}
if (cpart->vx<0)
{
*colr -= (cpart->vx)*GRAV_B;
*colg -= (cpart->vx)*GRAV_R;
*colb -= (cpart->vx)*GRAV_G;
}
if (cpart->vy<0)
{
*colr -= (cpart->vy)*GRAV_R2;
*colg -= (cpart->vy)*GRAV_G2;
*colb -= (cpart->vy)*GRAV_B2;
}
return 0;
}
int graphics_WIFI(GRAPHICS_FUNC_ARGS)
{
float frequency = 0.0628;
int q = cpart->tmp;
*colr = sin(frequency*q + 0) * 127 + 128;
*colg = sin(frequency*q + 2) * 127 + 128;
*colb = sin(frequency*q + 4) * 127 + 128;
return 0;
}
int graphics_PRTI(GRAPHICS_FUNC_ARGS)
{
*firea = 8;
*firer = 255;
*fireg = 0;
*fireb = 0;
*pixel_mode |= EFFECT_GRAVIN;
*pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_ADD;
return 1;
}
int graphics_PRTO(GRAPHICS_FUNC_ARGS)
{
*firea = 8;
*firer = 0;
*fireg = 0;
*fireb = 255;
*pixel_mode |= EFFECT_GRAVOUT;
*pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_ADD;
return 1;
}
int graphics_BIZR(GRAPHICS_FUNC_ARGS) //BIZR, BIZRG, BIZRS
{
int x = 0;
*colg = 0;
*colb = 0;
*colr = 0;
for (x=0; x<12; x++) {
*colr += (cpart->ctype >> (x+18)) & 1;
*colb += (cpart->ctype >> x) & 1;
}
for (x=0; x<12; x++)
*colg += (cpart->ctype >> (x+9)) & 1;
x = 624/(*colr+*colg+*colb+1);
*colr *= x;
*colg *= x;
*colb *= x;
if(fabs(cpart->vx)+fabs(cpart->vy)>0)
{
*firea = 255;
*fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy);
*fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy);
*firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy);
*pixel_mode |= FIRE_ADD;
}
return 0;
}
int graphics_INVS(GRAPHICS_FUNC_ARGS)
{
//pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f
if(cpart->tmp)
{
*cola = 100;
*colr = 15;
*colg = 0;
*colb = 150;
*pixel_mode &= PMODE;
*pixel_mode |= PMODE_BLEND;
}
return 0;
}
int graphics_ACID(GRAPHICS_FUNC_ARGS)
{
int s = cpart->life;
if (s>75) s = 75; //These two should not be here.
if (s<49) s = 49;
s = (s-49)*3;
if (s==0) s = 1;
*colr += s*4;
*colg += s*1;
*colb += s*2;
*pixel_mode |= PMODE_BLUR;
return 0;
}
int graphics_FILT(GRAPHICS_FUNC_ARGS)
{
int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f);
if (temp_bin < 0) temp_bin = 0;
if (temp_bin > 25) temp_bin = 25;
cpart->ctype = 0x1F << temp_bin;
*colg = 0;
*colb = 0;
*colr = 0;
for (x=0; x<12; x++) {
*colr += (cpart->ctype >> (x+18)) & 1;
*colb += (cpart->ctype >> x) & 1;
}
for (x=0; x<12; x++)
*colg += (cpart->ctype >> (x+9)) & 1;
x = 624/(*colr+*colg+*colb+1);
*cola = 127;
*colr *= x;
*colg *= x;
*colb *= x;
*pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_BLEND;
return 0;
}
int graphics_BRAY(GRAPHICS_FUNC_ARGS)
{
int x, trans = 255;
if(cpart->tmp==0)
{
trans = cpart->life * 7;
if (trans>255) trans = 255;
if (cpart->ctype) {
*colg = 0;
*colb = 0;
*colr = 0;
for (x=0; x<12; x++) {
*colr += (cpart->ctype >> (x+18)) & 1;
*colb += (cpart->ctype >> x) & 1;
}
for (x=0; x<12; x++)
*colg += (cpart->ctype >> (x+9)) & 1;
x = 624/(*colr+*colg+*colb+1);
*colr *= x;
*colg *= x;
*colb *= x;
}
}
else if(cpart->tmp==1)
{
trans = cpart->life/4;
if (trans>255) trans = 255;
if (cpart->ctype) {
*colg = 0;
*colb = 0;
*colr = 0;
for (x=0; x<12; x++) {
*colr += (cpart->ctype >> (x+18)) & 1;
*colb += (cpart->ctype >> x) & 1;
}
for (x=0; x<12; x++)
*colg += (cpart->ctype >> (x+9)) & 1;
x = 624/(*colr+*colg+*colb+1);
*colr *= x;
*colg *= x;
*colb *= x;
}
}
else if(cpart->tmp==2)
{
trans = cpart->life*100;
if (trans>255) trans = 255;
*colr = 255;
*colg = 150;
*colb = 50;
}
*cola = trans;
*pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_BLEND | PMODE_GLOW;
return 0;
}
int graphics_SWCH(GRAPHICS_FUNC_ARGS)
{
if(cpart->life >= 10)
{
*colr = 17;
*colg = 217;
*colb = 24;
*pixel_mode |= PMODE_GLOW;
}
return 0;
}
int graphics_THDR(GRAPHICS_FUNC_ARGS)
{
*firea = 160;
*fireg = 192;
*fireb = 255;
*firer = 144;
*pixel_mode |= FIRE_ADD;
return 1;
}
int graphics_GLOW(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;
*fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f;
*colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255);
*colg = restrict_flt(64.0f+cpart->ctype, 0, 255);
*colb = restrict_flt(64.0f+cpart->tmp, 0, 255);
*pixel_mode |= FIRE_ADD;
return 0;
}
int graphics_LCRY(GRAPHICS_FUNC_ARGS)
{
if(ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000))
{
*colr = (cpart->dcolour>>16)&0xFF;
*colg = (cpart->dcolour>>8)&0xFF;
*colb = (cpart->dcolour)&0xFF;
if(cpart->tmp2<10){
*colr /= 10-cpart->tmp2;
*colg /= 10-cpart->tmp2;
*colb /= 10-cpart->tmp2;
}
}
else
{
*colr = *colg = *colb = 0x50+((cpart->tmp2>10?10:cpart->tmp2)*10);
}
*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;*/
}
int graphics_PCLN(GRAPHICS_FUNC_ARGS)
{
int lifemod = ((cpart->life>10?10:cpart->life)*10);
*colr += lifemod;
*colg += lifemod;
return 0;
}
int graphics_PBCN(GRAPHICS_FUNC_ARGS)
{
int lifemod = ((cpart->life>10?10:cpart->life)*10);
*colr += lifemod;
*colg += lifemod/2;
return 0;
}
int graphics_DLAY(GRAPHICS_FUNC_ARGS)
{
int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f);
*colr += stage;
*colg += stage;
*colb += stage;
return 0;
}
int graphics_HSWC(GRAPHICS_FUNC_ARGS)
{
int lifemod = ((cpart->life>10?10:cpart->life)*19);
*colr += lifemod;
return 0;
}
int graphics_PVOD(GRAPHICS_FUNC_ARGS)
{
int lifemod = ((cpart->life>10?10:cpart->life)*16);
*colr += lifemod;
return 0;
}
int graphics_STOR(GRAPHICS_FUNC_ARGS)
{
if(cpart->tmp){
*pixel_mode |= PMODE_GLOW;
*colr = 0x50;
*colg = 0xDF;
*colb = 0xDF;
} else {
*colr = 0x20;
*colg = 0xAF;
*colb = 0xAF;
}
return 0;
}
int graphics_PUMP(GRAPHICS_FUNC_ARGS)
{
int lifemod = ((cpart->life>10?10:cpart->life)*19);
*colb += lifemod;
return 0;
}
int graphics_GPMP(GRAPHICS_FUNC_ARGS)
{
int lifemod = ((cpart->life>10?10:cpart->life)*19);
*colg += lifemod;
*colb += lifemod;
return 0;
}
int graphics_HFLM(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 = (unsigned char)hflm_data[caddress];
*colg = (unsigned char)hflm_data[caddress+1];
*colb = (unsigned char)hflm_data[caddress+2];
*firea = 255;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode = PMODE_NONE; //Clear default, don't draw pixel
*pixel_mode |= FIRE_ADD;
//Returning 0 means dynamic, do not cache
return 0;
}
int graphics_FIRW(GRAPHICS_FUNC_ARGS)
{
if(cpart->tmp>=3)
{
int caddress = restrict_flt(restrict_flt((float)(cpart->tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
*colr = (unsigned char)firw_data[caddress];
*colg = (unsigned char)firw_data[caddress+1];
*colb = (unsigned char)firw_data[caddress+2];
if (ren->decorations_enable && cpart->dcolour)
{
int a = (cpart->dcolour>>24)&0xFF;
*colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8;
*colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8;
*colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8;
}
*firea = cpart->life*4;
if(*firea > 240)
*firea = 240;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode = PMODE_NONE; //Clear default, don't draw pixel
*pixel_mode |= FIRE_ADD;
//Returning 0 means dynamic, do not cache
}
else if(cpart->tmp > 0)
{
*pixel_mode |= PMODE_GLOW;
}
return 0;
}
int graphics_GBMB(GRAPHICS_FUNC_ARGS)
{
if (cpart->life <= 0) {
*pixel_mode |= PMODE_FLARE;
}
else
{
*pixel_mode |= PMODE_SPARK;
}
return 0;
}
int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal
{
*colr += (cpart->tmp2-295.15f)/3;
if (*colr > 170)
*colr = 170;
if (*colr < *colg)
*colr = *colg;
*colg = *colb = *colr;
if((cpart->temp-295.15f) > 300.0f-200.0f)
{
float frequency = 3.1415/(2*300.0f-(300.0f-200.0f));
int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f);
*colr += sin(frequency*q) * 226;
*colg += sin(frequency*q*4.55 +3.14) * 34;
*colb += sin(frequency*q*2.22 +3.14) * 64;
}
return 0;
}

View File

@ -1,6 +0,0 @@
#include "simulation/Element.h"
int update_(UPDATE_FUNC_ARGS) {
return 0;
}

View File

@ -1,7 +0,0 @@
#include "simulation/Element.h"
int update_NPTCT(UPDATE_FUNC_ARGS) {
if (parts[i].temp>295.0f)
parts[i].temp -= 2.5f;
return 0;
}

View File

@ -1,6 +0,0 @@
#include "simulation/Element.h"
int update_NWHL(UPDATE_FUNC_ARGS) {
sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] -= 0.1f;
return 0;
}

View File

@ -1,20 +0,0 @@
#include "simulation/Element.h"
#include "hmap.h"
int graphics_PLSM(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];
*colg = (unsigned char)ren->plasma_data[caddress+1];
*colb = (unsigned char)ren->plasma_data[caddress+2];
*firea = 255;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode = PMODE_GLOW | PMODE_ADD; //Clear default, don't draw pixel
*pixel_mode |= FIRE_ADD;
//Returning 0 means dynamic, do not cache
return 0;
}

View File

@ -1,9 +0,0 @@
#include "simulation/Element.h"
int update_PLUT(UPDATE_FUNC_ARGS) {
if (1>rand()%100 && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(rand()%1000))
{
sim->create_part(i, x, y, PT_NEUT);
}
return 0;
}

View File

@ -1,80 +0,0 @@
#include "simulation/Element.h"
/*these are the count values of where the particle gets stored, depending on where it came from
0 1 2
7 . 3
6 5 4
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
int update_PRTI(UPDATE_FUNC_ARGS) {
int r, nnx, rx, ry, fe = 0;
int count =0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (count=0; count<8; count++)
{
rx = sim->portal_rx[count];
ry = sim->portal_ry[count];
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
fe = 1;
if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (sim->ptypes[r&0xFF].falldown== 0 && sim->ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK))
{
r = sim->photons[y+ry][x+rx];
if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (sim->ptypes[r&0xFF].falldown== 0 && sim->ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK))
continue;
}
if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH)
continue;// Handling these is a bit more complicated, and is done in STKM_interact()
if ((r&0xFF) == PT_SOAP)
sim->detach(r>>8);
for ( nnx=0; nnx<80; nnx++)
if (!sim->portalp[parts[i].tmp][count][nnx].type)
{
sim->portalp[parts[i].tmp][count][nnx] = parts[r>>8];
if ((r&0xFF)==PT_SPRK)
sim->part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
else
sim->kill_part(r>>8);
fe = 1;
break;
}
}
}
if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
if (!sim->parts[i].life) parts[i].life = rand()*rand()*rand();
if (!sim->parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (r = 0; r < 4; r++) {
if (orbd[r]>1) {
orbd[r] -= 12;
if (orbd[r]<1) {
orbd[r] = (rand()%128)+128;
orbl[r] = rand()%255;
} else {
orbl[r] += 2;
orbl[r] = orbl[r]%255;
}
} else {
orbd[r] = (rand()%128)+128;
orbl[r] = rand()%255;
}
}
sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
} else {
parts[i].life = 0;
parts[i].ctype = 0;
}
return 0;
}

View File

@ -1,41 +0,0 @@
#include "simulation/Element.h"
int update_PUMP(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
if (parts[i].life==10)
{
if (parts[i].temp>=256.0+273.15)
parts[i].temp=256.0+273.15;
if (parts[i].temp<= -256.0+273.15)
parts[i].temp = -256.0+273.15;
if (sim->pv[y/CELL][x/CELL]<(parts[i].temp-273.15))
sim->pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL][x/CELL]);
if (y+CELL<YRES && sim->pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
sim->pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL+1][x/CELL]);
if (x+CELL<XRES)
{
sim->pv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL][x/CELL+1]);
if (y+CELL<YRES)
sim->pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL+1][x/CELL+1]);
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_PUMP)
{
if (parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
else if (parts[r>>8].life==0)
parts[r>>8].life = 10;
}
}
}
return 0;
}

View File

@ -1,30 +0,0 @@
#include "simulation/Element.h"
int update_PVOD(UPDATE_FUNC_ARGS) {
int r, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4)
{
if (parts[r>>8].ctype==PT_PSCN)
parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN)
parts[i].life = 9;
}
if ((r&0xFF)==PT_PVOD)
{
if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
else if (parts[i].life==0&&parts[r>>8].life==10)
parts[i].life = 10;
}
}
return 0;
}

View File

@ -1,94 +0,0 @@
#include "simulation/Element.h"
int update_QRTZ(UPDATE_FUNC_ARGS) {
int r, tmp, trade, rx, ry, np, t;
t = parts[i].type;
if (t == PT_QRTZ)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
sim->part_change_type(i,x,y,PT_PQRT);
}
}
// absorb SLTW
if (parts[i].ctype!=-1)
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_SLTW && (1>rand()%2500))
{
sim->kill_part(r>>8);
parts[i].ctype ++;
}
}
// grow if absorbed SLTW
if (parts[i].ctype>0)
{
for ( trade = 0; trade<5; trade ++)
{
rx = rand()%3-1;
ry = rand()%3-1;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r && parts[i].ctype!=0)
{
np = sim->create_part(-1,x+rx,y+ry,PT_QRTZ);
if (np>-1)
{
parts[np].tmp = parts[i].tmp;
parts[i].ctype--;
if (5>rand()%10)
{
parts[np].ctype=-1;//dead qrtz
}
else if (!parts[i].ctype && 1>rand()%15)
{
parts[i].ctype=-1;
}
break;
}
}
}
}
}
// diffuse absorbed SLTW
if (parts[i].ctype>0)
{
for ( trade = 0; trade<9; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
{
tmp = parts[i].ctype - parts[r>>8].ctype;
if (tmp ==1)
{
parts[r>>8].ctype ++;
parts[i].ctype --;
break;
}
if (tmp>0)
{
parts[r>>8].ctype += tmp/2;
parts[i].ctype -= tmp/2;
break;
}
}
}
}
}
return 0;
}

View File

@ -1,22 +0,0 @@
#include "simulation/Element.h"
int update_REPL(UPDATE_FUNC_ARGS) {
int r, rx, ry, ri;
for(ri = 0; ri <= 10; ri++)
{
rx = (rand()%20)-10;
ry = (rand()%20)-10;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (r && !(sim->ptypes[r&0xFF].properties & TYPE_SOLID)){
parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f);
parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f);
}
}
}
return 0;
}

View File

@ -1,26 +0,0 @@
#include "simulation/Element.h"
int update_RIME(UPDATE_FUNC_ARGS) {
int r, rx, ry;
parts[i].vx = 0;
parts[i].vy = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK)
{
sim->part_change_type(i,x,y,PT_FOG);
parts[i].life = rand()%50 + 60;
}
else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0)
{
sim->part_change_type(i,x,y,PT_FOG);
parts[i].life = parts[r>>8].life;
}
}
return 0;
}

View File

@ -1,162 +0,0 @@
#include "simulation/Element.h"
int update_SHLD1(UPDATE_FUNC_ARGS) {
int r, nnx, nny, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
if (55>rand()%200&&parts[i].life==0)
{
sim->part_change_type(i,x,y,PT_SHLD2);
parts[i].life = 7;
}
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
//parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
}
}
}
else if ((r&0xFF)==PT_SHLD3&&4>rand()%10)
{
sim->part_change_type(i,x,y,PT_SHLD2);
parts[i].life = 7;
}
}
return 0;
}
int update_SHLD2(UPDATE_FUNC_ARGS) {
int r, nnx, nny, rx, ry, np;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r && parts[i].life>0)
sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (!r)
continue;
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
if (25>rand()%200&&parts[i].life==0)
{
sim->part_change_type(i,x,y,PT_SHLD3);
parts[i].life = 7;
}
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
}
}
}
else if ((r&0xFF)==PT_SHLD4&&4>rand()%10)
{
sim->part_change_type(i,x,y,PT_SHLD3);
parts[i].life = 7;
}
}
return 0;
}
int update_SHLD3(UPDATE_FUNC_ARGS) {
int r, nnx, nny, rx, ry, np;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
{
if (1>rand()%2500)
{
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
sim->part_change_type(i,x,y,PT_SHLD2);
}
else
continue;
}
if ((r&0xFF)==PT_SHLD1 && parts[i].life>3)
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD2);
parts[r>>8].life=7;
}
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
if (18>rand()%3000&&parts[i].life==0)
{
sim->part_change_type(i,x,y,PT_SHLD4);
parts[i].life = 7;
}
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
}
}
}
}
return 0;
}
int update_SHLD4(UPDATE_FUNC_ARGS) {
int r, nnx, nny, rx, ry, np;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
{
if (1>rand()%5500)
{
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
sim->part_change_type(i,x,y,PT_SHLD2);
}
else
continue;
}
if ((r&0xFF)==PT_SHLD2 && parts[i].life>3)
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD3);
parts[r>>8].life = 7;
}
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
}
}
}
return 0;
}

View File

@ -1,30 +0,0 @@
#include "simulation/Element.h"
int update_SLTW(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%10000))
sim->kill_part(r>>8);
if ((r&0xFF)==PT_PLNT&&5>(rand()%1000))
sim->kill_part(r>>8);
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
}
if ((r&0xFF)==PT_FIRE){
sim->kill_part(r>>8);
if(1>(rand()%150)){
sim->kill_part(i);
return 1;
}
}
}
return 0;
}

View File

@ -1,18 +0,0 @@
#include "simulation/Element.h"
int graphics_SMKE(GRAPHICS_FUNC_ARGS)
{
*colr = 55;
*colg = 55;
*colb = 55;
*firea = 75;
*firer = 55;
*fireg = 55;
*fireb = 55;
*pixel_mode = PMODE_NONE; //Clear default, don't draw pixel
*pixel_mode |= FIRE_BLEND;
//Returning 1 means static, cache as we please
return 1;
}

View File

@ -1,29 +0,0 @@
#include "simulation/Element.h"
int update_SPAWN2(UPDATE_FUNC_ARGS) {
if (!sim->player2.spwn)
sim->create_part(-1, x, y, PT_STKM2);
return 0;
}
int update_STKM2(UPDATE_FUNC_ARGS) {
run_stickman(&sim->player2, UPDATE_FUNC_SUBCALL_ARGS);
return 0;
}
int graphics_STKM2(GRAPHICS_FUNC_ARGS)
{
/**pixel_mode = PSPEC_STICKMAN;
if ((int)sim->player2.elem<PT_NUM)
{
*colr = PIXR(ptypes[sim->player2.elem].pcolors);
*colg = PIXG(ptypes[sim->player2.elem].pcolors);
*colb = PIXB(ptypes[sim->player2.elem].pcolors);
}
else*/
{
*colr = *colg = *colb = 255;
}
return 1;
}

View File

@ -1,43 +0,0 @@
#include "simulation/Element.h"
int update_STOR(UPDATE_FUNC_ARGS) {
int r, rx, ry, np, rx1, ry1;
if(parts[i].life && !parts[i].tmp)
parts[i].life--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->ptypes[(r&0xFF)].properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype))
{
parts[i].tmp = parts[r>>8].type;
parts[i].temp = parts[r>>8].temp;
parts[i].tmp2 = parts[r>>8].life;
parts[i].pavg[0] = parts[r>>8].tmp;
parts[i].pavg[1] = parts[r>>8].ctype;
sim->kill_part(r>>8);
}
if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life>0 && parts[r>>8].life<4)
{
for(ry1 = 1; ry1 >= -1; ry1--){
for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscilate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1)
np = sim->create_part(-1,x+rx1,y+ry1,parts[i].tmp);
if (np!=-1)
{
parts[np].temp = parts[i].temp;
parts[np].life = parts[i].tmp2;
parts[np].tmp = parts[i].pavg[0];
parts[np].ctype = parts[i].pavg[1];
parts[i].tmp = 0;
parts[i].life = 10;
break;
}
}
}
}
}
return 0;
}

View File

@ -1,38 +0,0 @@
#include "simulation/Element.h"
int update_THDR(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((sim->ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK)
{
parts[i].type = PT_NONE;
parts[r>>8].ctype = parts[r>>8].type;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
parts[r>>8].life = 4;
}
else if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF))
{
sim->pv[y/CELL][x/CELL] += 100.0f;
if (sim->legacy_enable&&1>(rand()%200))
{
parts[i].life = rand()%50+120;
sim->part_change_type(i,x,y,PT_FIRE);
}
else
{
parts[i].type = PT_NONE;
}
}
}
if (parts[i].type==PT_NONE) {
sim->kill_part(i);
return 1;
}
return 0;
}

View File

@ -1,29 +0,0 @@
#include "simulation/Element.h"
int update_THRM(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) // TODO: could this go in update_PYRO?
{
if (1>(rand()%500)) {
sim->part_change_type(i,x,y,PT_LAVA);
parts[i].ctype = PT_BMTL;
parts[i].temp = 3500.0f;
sim->pv[y/CELL][x/CELL] += 50.0f;
} else {
sim->part_change_type(i,x,y,PT_LAVA);
parts[i].life = 400;
parts[i].ctype = PT_THRM;
parts[i].temp = 3500.0f;
parts[i].tmp = 20;
}
}
}
return 0;
}

View File

@ -1,10 +0,0 @@
#include "simulation/Element.h"
int update_URAN(UPDATE_FUNC_ARGS) {
if (!sim->legacy_enable && sim->pv[y/CELL][x/CELL]>0.0f)
{
float atemp = parts[i].temp + (-MIN_TEMP);
parts[i].temp = restrict_flt((atemp*(1+(sim->pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP);
}
return 0;
}

View File

@ -1,19 +0,0 @@
#include "simulation/Element.h"
int update_VINE(UPDATE_FUNC_ARGS) {
int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (1>rand()%15)
sim->part_change_type(i,x,y,PT_PLNT);
else if (!r)
{
np = sim->create_part(-1,x+rx,y+ry,PT_VINE);
if (np<0) return 0;
parts[np].temp = parts[i].temp;
sim->part_change_type(i,x,y,PT_PLNT);
}
}
return 0;
}

View File

@ -1,28 +0,0 @@
#include "simulation/Element.h"
int update_WARP(UPDATE_FUNC_ARGS) {
int trade, r, rx, ry;
for ( trade = 0; trade<5; trade ++)
{
rx = rand()%3-1;
ry = rand()%3-1;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN&&(10>=rand()%200))
{
parts[i].x = parts[r>>8].x;
parts[i].y = parts[r>>8].y;
parts[r>>8].x = x;
parts[r>>8].y = y;
parts[i].life += 4;
pmap[y][x] = r;
pmap[y+ry][x+rx] = (i<<8)|parts[i].type;
trade = 5;
}
}
}
return 0;
}

View File

@ -1,37 +0,0 @@
#include "simulation/Element.h"
int update_WATR(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%250))
{
sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
parts[i].ctype = PT_WATR;
}
if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
sim->kill_part(r>>8);
if(1>(rand()%150)){
sim->kill_part(i);
return 1;
}
}
/*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular
{
part_change_type(i,x,y,PT_PSTE);
sim.kill_part(r>>8);
}*/
}
return 0;
}

View File

@ -1,36 +0,0 @@
#include "simulation/Element.h"
int update_WIFI(UPDATE_FUNC_ARGS) {
int r, rx, ry;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
// wireless[][0] - whether channel is active on this frame
// wireless[][1] - whether channel should be active on next frame
if (sim->wireless[parts[i].tmp][0])
{
if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[r>>8].life==0 && sim->wireless[parts[i].tmp][0])
{
parts[r>>8].ctype = r&0xFF;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
parts[r>>8].life = 4;
}
}
else
{
if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3)
{
sim->wireless[parts[i].tmp][1] = 1;
sim->ISWIRE = 2;
}
}
}
return 0;
}

View File

@ -1,72 +0,0 @@
#include "simulation/Element.h"
int update_WIRE(UPDATE_FUNC_ARGS) {
int s,r,rx,ry,count;
/*
0: wire
1: spark head
2: spark tail
tmp is previous state, ctype is current state
*/
//parts[i].tmp=parts[i].ctype;
parts[i].ctype=0;
if(parts[i].tmp==1)
{
parts[i].ctype=2;
}
if(parts[i].tmp==2)
{
parts[i].ctype=0;
}
count=0;
for(rx=-1; rx<2; rx++)
for(ry=-1; ry<2; ry++)
{
if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if((r&0xFF)==PT_SPRK && parts[r>>8].life==3 && parts[r>>8].ctype==PT_PSCN)
{
parts[i].ctype=1;
return 0;
}
else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){sim->create_part(-1, x+rx, y+ry, PT_SPRK);}
else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;}
}
}
if(count==1 || count==2)
parts[i].ctype=1;
return 0;
}
int graphics_WIRE(GRAPHICS_FUNC_ARGS)
{
if (cpart->ctype==0)
{
*colr = 255;
*colg = 204;
*colb = 0;
return 0;
}
if (cpart->ctype==1)
{
*colr = 50;
*colg = 100;
*colb = 255;
//*pixel_mode |= PMODE_GLOW;
return 0;
}
if (cpart->ctype==2)
{
*colr = 255;
*colg = 100;
*colb = 50;
//*pixel_mode |= PMODE_GLOW;
return 0;
}
return 0;
}

View File

@ -1,22 +0,0 @@
#include "simulation/Element.h"
int update_WTRV(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
parts[i].ctype = PT_WATR;
}
}
if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE)
parts[i].temp-=parts[i].temp/1000;
return 0;
}

View File

@ -1,21 +0,0 @@
#include "simulation/Element.h"
int update_YEST(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_DYST && 1>(rand()%30) && !sim->legacy_enable)
{
sim->part_change_type(i,x,y,PT_DYST);
}
}
if (parts[i].temp>303&&parts[i].temp<317) {
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST);
}
return 0;
}

View File

@ -8,6 +8,7 @@
#ifndef ELIPSEBRUSH_H_
#define ELIPSEBRUSH_H_
#include <cmath>
#include "Brush.h"
class EllipseBrush: public Brush
@ -29,7 +30,7 @@ public:
{
for(int y = 0; y <= radius.Y*2; y++)
{
if((pow(x-radius.X,2)*pow(ry,2)+pow(y-radius.Y,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2)))
if((pow(x-radius.X,2.0f)*pow(ry,2.0f)+pow(y-radius.Y,2.0f)*pow(rx,2.0f)<=pow(rx,2.0f)*pow(ry,2.0f)))
{
bitmap[y*(size.X)+x] = 255;
}

View File

@ -580,8 +580,8 @@ void GameController::ReloadSim()
std::string GameController::ElementResolve(int type)
{
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->ptypes && type >= 0 && type < PT_NUM)
return std::string(gameModel->GetSimulation()->ptypes[type].name);
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->elements && type >= 0 && type < PT_NUM)
return std::string(gameModel->GetSimulation()->elements[type].Name);
else
return "";
}

View File

@ -71,10 +71,10 @@ GameModel::GameModel():
//Build menus from Simulation elements
for(int i = 0; i < PT_NUM; i++)
{
if(sim->ptypes[i].menusection < 12 && sim->ptypes[i].enabled && sim->ptypes[i].menu)
if(sim->elements[i].MenuSection < 12 && sim->elements[i].Enabled && sim->elements[i].MenuVisible)
{
Tool * tempTool = new ElementTool(i, sim->ptypes[i].name, PIXR(sim->ptypes[i].pcolors), PIXG(sim->ptypes[i].pcolors), PIXB(sim->ptypes[i].pcolors));
menuList[sim->ptypes[i].menusection]->AddTool(tempTool);
Tool * tempTool = new ElementTool(i, sim->elements[i].Name, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
menuList[sim->elements[i].MenuSection]->AddTool(tempTool);
}
}
@ -106,8 +106,8 @@ GameModel::GameModel():
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
//Set default tools
activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
//activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
//activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
//Set default menu
activeMenu = menuList[SC_POWDERS];

View File

@ -6,7 +6,7 @@
*/
#include <math.h>
#include <cmath>
#include <iostream>
#include "Spinner.h"

View File

@ -4,7 +4,7 @@
#include <vector>
#include <string>
#include <pthread.h>
#include <math.h>
#include <cmath>
#include "Save.h"
#include "SearchView.h"

View File

@ -1,4 +1,4 @@
#include <math.h>
#include <cmath>
#include "Config.h"
#include "Air.h"
//#include <powder.h>

View File

@ -5,10 +5,19 @@
#include <cmath>
#include "Simulation.h"
#include "Renderer.h"
#include "ElementFunctions.h"
//#include "powder.h"
#include "Gravity.h"
#include "Misc.h"
#include "ElementGraphics.h"
#define IPL -257.0f
#define IPH 257.0f
#define ITL MIN_TEMP-1
#define ITH MAX_TEMP+1
// no transition (PT_NONE means kill part)
#define NT -1
// special transition - lava ctypes etc need extra code, which is only found and run if ST is given
#define ST PT_NUM
#endif

View File

@ -1,175 +0,0 @@
/*
* ElementFunctions.h
*
* Created on: Jan 5, 2012
* Author: Simon
*/
#ifndef ELEMENTFUNCTIONS_H_
#define ELEMENTFUNCTIONS_H_
#include "Elements.h"
int update_ACID(UPDATE_FUNC_ARGS);
int update_ANAR(UPDATE_FUNC_ARGS);
int update_AMTR(UPDATE_FUNC_ARGS);
int update_ARAY(UPDATE_FUNC_ARGS);
int update_BCLN(UPDATE_FUNC_ARGS);
int update_BCOL(UPDATE_FUNC_ARGS);
int update_BMTL(UPDATE_FUNC_ARGS);
int update_BRMT(UPDATE_FUNC_ARGS);
int update_BOMB(UPDATE_FUNC_ARGS);
int update_BOYL(UPDATE_FUNC_ARGS);
int update_BTRY(UPDATE_FUNC_ARGS);
int update_C5(UPDATE_FUNC_ARGS);
int update_CLNE(UPDATE_FUNC_ARGS);
int update_COAL(UPDATE_FUNC_ARGS);
int update_DEUT(UPDATE_FUNC_ARGS);
int update_DSTW(UPDATE_FUNC_ARGS);
int update_FOG(UPDATE_FUNC_ARGS);
int update_FRZW(UPDATE_FUNC_ARGS);
int update_FRZZ(UPDATE_FUNC_ARGS);
int update_FSEP(UPDATE_FUNC_ARGS);
int update_FUSE(UPDATE_FUNC_ARGS);
int update_FIRW(UPDATE_FUNC_ARGS);
int update_FWRK(UPDATE_FUNC_ARGS);
int update_GLAS(UPDATE_FUNC_ARGS);
int update_GLOW(UPDATE_FUNC_ARGS);
int update_GOO(UPDATE_FUNC_ARGS);
int update_HSWC(UPDATE_FUNC_ARGS);
int update_IRON(UPDATE_FUNC_ARGS);
int update_ICEI(UPDATE_FUNC_ARGS);
int update_ISZ(UPDATE_FUNC_ARGS);
int update_LCRY(UPDATE_FUNC_ARGS);
int update_MORT(UPDATE_FUNC_ARGS);
int update_NEUT(UPDATE_FUNC_ARGS);
int update_NPTCT(UPDATE_FUNC_ARGS);
int update_PCLN(UPDATE_FUNC_ARGS);
int update_PHOT(UPDATE_FUNC_ARGS);
int update_PIPE(UPDATE_FUNC_ARGS);
int update_PLNT(UPDATE_FUNC_ARGS);
int update_PLUT(UPDATE_FUNC_ARGS);
int update_PRTI(UPDATE_FUNC_ARGS);
int update_PRTO(UPDATE_FUNC_ARGS);
int update_PYRO(UPDATE_FUNC_ARGS);
int update_PUMP(UPDATE_FUNC_ARGS);
int update_QRTZ(UPDATE_FUNC_ARGS);
int update_RIME(UPDATE_FUNC_ARGS);
int update_SHLD1(UPDATE_FUNC_ARGS);
int update_SHLD2(UPDATE_FUNC_ARGS);
int update_SHLD3(UPDATE_FUNC_ARGS);
int update_SHLD4(UPDATE_FUNC_ARGS);
int update_SING(UPDATE_FUNC_ARGS);
int update_SLTW(UPDATE_FUNC_ARGS);
int update_SPAWN(UPDATE_FUNC_ARGS);
int update_SPAWN2(UPDATE_FUNC_ARGS);
int update_SPNG(UPDATE_FUNC_ARGS);
int update_SPRK(UPDATE_FUNC_ARGS);
int update_STKM(UPDATE_FUNC_ARGS);
int update_STKM2(UPDATE_FUNC_ARGS);
int update_SWCH(UPDATE_FUNC_ARGS);
int update_THDR(UPDATE_FUNC_ARGS);
int update_THRM(UPDATE_FUNC_ARGS);
int update_URAN(UPDATE_FUNC_ARGS);
int update_VINE(UPDATE_FUNC_ARGS);
int update_WARP(UPDATE_FUNC_ARGS);
int update_WATR(UPDATE_FUNC_ARGS);
int update_WIFI(UPDATE_FUNC_ARGS);
int update_WTRV(UPDATE_FUNC_ARGS);
int update_YEST(UPDATE_FUNC_ARGS);
int update_SOAP(UPDATE_FUNC_ARGS);
int update_O2(UPDATE_FUNC_ARGS);
int update_H2(UPDATE_FUNC_ARGS);
int update_NBHL(UPDATE_FUNC_ARGS);
int update_NWHL(UPDATE_FUNC_ARGS);
int update_MERC(UPDATE_FUNC_ARGS);
int update_PBCN(UPDATE_FUNC_ARGS);
int update_GPMP(UPDATE_FUNC_ARGS);
int update_CLST(UPDATE_FUNC_ARGS);
int update_DLAY(UPDATE_FUNC_ARGS);
int update_WIRE(UPDATE_FUNC_ARGS);
int update_GBMB(UPDATE_FUNC_ARGS);
int update_CO2(UPDATE_FUNC_ARGS);
int update_CBNW(UPDATE_FUNC_ARGS);
int update_STOR(UPDATE_FUNC_ARGS);
int update_BIZR(UPDATE_FUNC_ARGS);
int update_PVOD(UPDATE_FUNC_ARGS);
int update_CONV(UPDATE_FUNC_ARGS);
int update_CAUS(UPDATE_FUNC_ARGS);
int update_DEST(UPDATE_FUNC_ARGS);
int update_EMP(UPDATE_FUNC_ARGS);
int update_LIGH(UPDATE_FUNC_ARGS);
int update_FIGH(UPDATE_FUNC_ARGS);
int update_ELEC(UPDATE_FUNC_ARGS);
int update_ACEL(UPDATE_FUNC_ARGS);
int update_DCEL(UPDATE_FUNC_ARGS);
int update_BANG(UPDATE_FUNC_ARGS);
int update_IGNT(UPDATE_FUNC_ARGS);
int update_MISC(UPDATE_FUNC_ARGS);
int update_FRAY(UPDATE_FUNC_ARGS);
int update_REPL(UPDATE_FUNC_ARGS);
int update_NBLE(UPDATE_FUNC_ARGS);
int update_GEL(UPDATE_FUNC_ARGS);
int update_TRON(UPDATE_FUNC_ARGS);
int update_legacy_PYRO(UPDATE_FUNC_ARGS);
int update_legacy_all(UPDATE_FUNC_ARGS);
int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS);
void STKM_init_legs(Simulation * sim, playerst* playerp, int i);
void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y);
int graphics_FIRE(GRAPHICS_FUNC_ARGS);
int graphics_SMKE(GRAPHICS_FUNC_ARGS);
int graphics_PLSM(GRAPHICS_FUNC_ARGS);
int graphics_DEUT(GRAPHICS_FUNC_ARGS);
int graphics_PHOT(GRAPHICS_FUNC_ARGS);
int graphics_NEUT(GRAPHICS_FUNC_ARGS);
int graphics_LAVA(GRAPHICS_FUNC_ARGS);
int graphics_SPRK(GRAPHICS_FUNC_ARGS);
int graphics_QRTZ(GRAPHICS_FUNC_ARGS);
int graphics_CLST(GRAPHICS_FUNC_ARGS);
int graphics_CBNW(GRAPHICS_FUNC_ARGS);
int graphics_SPNG(GRAPHICS_FUNC_ARGS);
int graphics_LIFE(GRAPHICS_FUNC_ARGS);
int graphics_DUST(GRAPHICS_FUNC_ARGS);
int graphics_GRAV(GRAPHICS_FUNC_ARGS);
int graphics_WIFI(GRAPHICS_FUNC_ARGS);
int graphics_PRTI(GRAPHICS_FUNC_ARGS);
int graphics_PRTO(GRAPHICS_FUNC_ARGS);
int graphics_BIZR(GRAPHICS_FUNC_ARGS);
int graphics_PIPE(GRAPHICS_FUNC_ARGS);
int graphics_INVS(GRAPHICS_FUNC_ARGS);
int graphics_ACID(GRAPHICS_FUNC_ARGS);
int graphics_FILT(GRAPHICS_FUNC_ARGS);
int graphics_BRAY(GRAPHICS_FUNC_ARGS);
int graphics_SWCH(GRAPHICS_FUNC_ARGS);
int graphics_THDR(GRAPHICS_FUNC_ARGS);
int graphics_GLOW(GRAPHICS_FUNC_ARGS);
int graphics_LCRY(GRAPHICS_FUNC_ARGS);
int graphics_PCLN(GRAPHICS_FUNC_ARGS);
int graphics_PBCN(GRAPHICS_FUNC_ARGS);
int graphics_DLAY(GRAPHICS_FUNC_ARGS);
int graphics_HSWC(GRAPHICS_FUNC_ARGS);
int graphics_PVOD(GRAPHICS_FUNC_ARGS);
int graphics_STOR(GRAPHICS_FUNC_ARGS);
int graphics_PUMP(GRAPHICS_FUNC_ARGS);
int graphics_GPMP(GRAPHICS_FUNC_ARGS);
int graphics_HFLM(GRAPHICS_FUNC_ARGS);
int graphics_FIRW(GRAPHICS_FUNC_ARGS);
int graphics_BOMB(GRAPHICS_FUNC_ARGS);
int graphics_GBMB(GRAPHICS_FUNC_ARGS);
int graphics_COAL(GRAPHICS_FUNC_ARGS);
int graphics_STKM(GRAPHICS_FUNC_ARGS);
int graphics_STKM2(GRAPHICS_FUNC_ARGS);
int graphics_DEST(GRAPHICS_FUNC_ARGS);
int graphics_EMP(GRAPHICS_FUNC_ARGS);
int graphics_LIGH(GRAPHICS_FUNC_ARGS);
int graphics_FIGH(GRAPHICS_FUNC_ARGS);
int graphics_ELEC(GRAPHICS_FUNC_ARGS);
int graphics_WIRE(GRAPHICS_FUNC_ARGS);
int graphics_ACEL(GRAPHICS_FUNC_ARGS);
int graphics_DCEL(GRAPHICS_FUNC_ARGS);
int graphics_GEL(GRAPHICS_FUNC_ARGS);
int graphics_TRON(GRAPHICS_FUNC_ARGS);
int graphics_DEFAULT(GRAPHICS_FUNC_ARGS);
#endif /* ELEMENTFUNCTIONS_H_ */

View File

@ -5,21 +5,12 @@
* Author: Simon
*/
//#ifndef ELEMENTS_H_
//#define ELEMENTS_H_
#ifndef ELEMENTS_H_
#define ELEMENTS_H_
//#include "Config.h"
//#include "Simulation.h"
#define IPL -257.0f
#define IPH 257.0f
#define ITL MIN_TEMP-1
#define ITH MAX_TEMP+1
// no transition (PT_NONE means kill part)
#define NT -1
// special transition - lava ctypes etc need extra code, which is only found and run if ST is given
#define ST PT_NUM
#define R_TEMP 22
#define MAX_TEMP 9999
#define MIN_TEMP 0
@ -55,7 +46,6 @@
#define ST_GAS 3
#define UPDATE_FUNC_ARGS Simulation* sim, int i, int x, int y, int surround_space, int nt, Particle *parts, int pmap[YRES][XRES]
// to call another update function with same arguments:
#define UPDATE_FUNC_SUBCALL_ARGS sim, i, x, y, surround_space, nt, parts, pmap
#define GRAPHICS_FUNC_ARGS Renderer * ren, Particle *cpart, int nx, int ny, int *pixel_mode, int* cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb
@ -119,168 +109,14 @@
#define NGT_FROG 22
#define NGT_BRAN 23
#define PT_NONE 0
#define PT_DUST 1
#define PT_WATR 2
#define PT_OIL 3
#define PT_FIRE 4
#define PT_STNE 5
#define PT_LAVA 6
#define PT_GUNP 7
#define PT_NITR 8
#define PT_CLNE 9
#define PT_GAS 10
#define PT_PLEX 11
#define PT_GOO 12
#define PT_ICEI 13
#define PT_METL 14
#define PT_SPRK 15
#define PT_SNOW 16
#define PT_WOOD 17
#define PT_NEUT 18
#define PT_PLUT 19
#define PT_PLNT 20
#define PT_ACID 21
#define PT_VOID 22
#define PT_WTRV 23
#define PT_CNCT 24
#define PT_DSTW 25
#define PT_SALT 26
#define PT_SLTW 27
#define PT_DMND 28
#define PT_BMTL 29
#define PT_BRMT 30
#define PT_PHOT 31
#define PT_URAN 32
#define PT_WAX 33
#define PT_MWAX 34
#define PT_PSCN 35
#define PT_NSCN 36
#define PT_LNTG 37
#define PT_INSL 38
#define PT_BHOL 39
#define PT_WHOL 40
#define PT_RBDM 41
#define PT_LRBD 42
#define PT_NTCT 43
#define PT_SAND 44
#define PT_GLAS 45
#define PT_PTCT 46
#define PT_BGLA 47
#define PT_THDR 48
#define PT_PLSM 49
#define PT_ETRD 50
#define PT_NICE 51
#define PT_NBLE 52
#define PT_BTRY 53
#define PT_LCRY 54
#define PT_STKM 55
#define PT_SWCH 56
#define PT_SMKE 57
#define PT_DESL 58
#define PT_COAL 59
#define PT_LO2 60
#define PT_O2 61
#define PT_INWR 62
#define PT_YEST 63
#define PT_DYST 64
#define PT_THRM 65
#define PT_GLOW 66
#define PT_BRCK 67
#define PT_HFLM 68
#define PT_FIRW 69
#define PT_FUSE 70
#define PT_FSEP 71
#define PT_AMTR 72
#define PT_BCOL 73
#define PT_PCLN 74
#define PT_HSWC 75
#define PT_IRON 76
#define PT_MORT 77
#define PT_LIFE 78
#define PT_DLAY 79
#define PT_CO2 80
#define PT_DRIC 81
#define PT_CBNW 82
#define PT_STOR 83
#define PT_PVOD 84
#define PT_CONV 85
#define PT_CAUS 86
#define PT_LIGH 87
#define PT_TESC 88
#define PT_DEST 89
#define PT_SPNG 90
#define PT_RIME 91
#define PT_FOG 92
#define PT_BCLN 93
#define PT_LOVE 94
#define PT_DEUT 95
#define PT_WARP 96
#define PT_PUMP 97
#define PT_FWRK 98
#define PT_PIPE 99
#define PT_FRZZ 100
#define PT_FRZW 101
#define PT_GRAV 102
#define PT_BIZR 103
#define PT_BIZRG 104
#define PT_BIZRS 105
#define PT_INST 106
#define PT_ISOZ 107
#define PT_ISZS 108
#define PT_PRTI 109
#define PT_PRTO 110
#define PT_PSTE 111
#define PT_PSTS 112
#define PT_ANAR 113
#define PT_VINE 114
#define PT_INVIS 115
#define PT_EQUALVEL 116 //all particles equal their velocities
#define PT_SPAWN2 117
#define PT_SPAWN 118
#define PT_SHLD1 119
#define PT_SHLD2 120
#define PT_SHLD3 121
#define PT_SHLD4 122
#define PT_LOLZ 123
#define PT_WIFI 124
#define PT_FILT 125
#define PT_ARAY 126
#define PT_BRAY 127
#define PT_STKM2 128
#define PT_BOMB 129
#define PT_C5 130
#define PT_SING 131
#define PT_QRTZ 132
#define PT_PQRT 133
#define PT_EMP 134
#define PT_BREC 135
#define PT_ELEC 136
#define PT_ACEL 137
#define PT_DCEL 138
#define PT_BANG 139
#define PT_IGNT 140
#define PT_BOYL 141
#define PT_GEL 142
#define PT_TRON 143
#define OLD_PT_WIND 147
#define PT_H2 148
#define PT_SOAP 149
#define PT_NBHL 150
#define PT_NWHL 151
#define PT_MERC 152
#define PT_PBCN 153
#define PT_GPMP 154
#define PT_CLST 155
#define PT_WIRE 156
#define PT_GBMB 157
#define PT_FIGH 158
#define PT_FRAY 159
#define PT_REPL 160
#define PT_NUM 161
//#define PT_NUM 161
#define PT_NUM 256
struct playerst;
#include "ElementClasses.h"
//#endif /* ELEMENTS_H_ */
#endif /* ELEMENTS_H_ */

View File

@ -1,4 +1,4 @@
#include <math.h>
#include <cmath>
#include <sys/types.h>
#include <pthread.h>
#include "Config.h"
@ -237,9 +237,9 @@ void Gravity::grav_fft_init()
for (x=0; x<xblock2; x++)
{
if (x==XRES/CELL && y==YRES/CELL) continue;
distance = sqrtf(pow(x-(XRES/CELL), 2) + pow(y-(YRES/CELL), 2));
th_ptgravx[y*xblock2+x] = scaleFactor*(x-(XRES/CELL)) / pow(distance, 3);
th_ptgravy[y*xblock2+x] = scaleFactor*(y-(YRES/CELL)) / pow(distance, 3);
distance = sqrtf(pow(x-(XRES/CELL), 2.0f) + pow(y-(YRES/CELL), 2.0f));
th_ptgravx[y*xblock2+x] = scaleFactor*(x-(XRES/CELL)) / pow(distance, 3.0f);
th_ptgravy[y*xblock2+x] = scaleFactor*(y-(YRES/CELL)) / pow(distance, 3.0f);
}
}
th_ptgravx[yblock2*xblock2/2+xblock2/2] = 0.0f;

View File

@ -6,7 +6,7 @@
*/
#include <bzlib.h>
#include <math.h>
#include <cmath>
#include "SaveLoader.h"
//!TODO: enum for LoadSave return
@ -497,7 +497,7 @@ int SaveLoader::PSVLoad(unsigned char * data, int dataLength, Simulation * sim,
}
else
{
parts[i-1].temp = sim->ptypes[parts[i-1].type].heat;
parts[i-1].temp = sim->elements[parts[i-1].type].Temperature;
}
}
}
@ -607,7 +607,7 @@ int SaveLoader::PSVLoad(unsigned char * data, int dataLength, Simulation * sim,
parts[i-1].tmp2 = parts[i-1].life;
}
}
if (!sim->ptypes[parts[i-1].type].enabled)
if (!sim->elements[parts[i-1].type].Enabled)
parts[i-1].type = PT_NONE;
}
}

View File

@ -3,10 +3,11 @@
#include "Config.h"
#include "Simulation.h"
#include "Elements.h"
#include "ElementFunctions.h"
//#include "ElementFunctions.h"
#include "Air.h"
#include "Gravity.h"
#include "SaveLoader.h"
#include "elements/Element.h"
#undef LUACONSOLE
//#include "cat/LuaScriptHelper.h"
@ -263,7 +264,7 @@ int Simulation::flood_water(int x, int y, int i, int originaly, int check)
while (x1>=CELL)
{
if ((ptypes[(pmap[y][x1-1]&0xFF)].falldown)!=2)
if ((elements[(pmap[y][x1-1]&0xFF)].Falldown)!=2)
{
break;
}
@ -271,7 +272,7 @@ int Simulation::flood_water(int x, int y, int i, int originaly, int check)
}
while (x2<XRES-CELL)
{
if ((ptypes[(pmap[y][x2+1]&0xFF)].falldown)!=2)
if ((elements[(pmap[y][x2+1]&0xFF)].Falldown)!=2)
{
break;
}
@ -298,12 +299,12 @@ int Simulation::flood_water(int x, int y, int i, int originaly, int check)
if (y>=CELL+1)
for (x=x1; x<=x2; x++)
if ((ptypes[(pmap[y-1][x]&0xFF)].falldown)==2 && parts[pmap[y-1][x]>>8].tmp2 == check)
if ((elements[(pmap[y-1][x]&0xFF)].Falldown)==2 && parts[pmap[y-1][x]>>8].tmp2 == check)
if (!flood_water(x, y-1, i, originaly, check))
return 0;
if (y<YRES-CELL-1)
for (x=x1; x<=x2; x++)
if ((ptypes[(pmap[y+1][x]&0xFF)].falldown)==2 && parts[pmap[y+1][x]>>8].tmp2 == check)
if ((elements[(pmap[y+1][x]&0xFF)].Falldown)==2 && parts[pmap[y+1][x]>>8].tmp2 == check)
if (!flood_water(x, y+1, i, originaly, check))
return 0;
return 1;
@ -1175,16 +1176,16 @@ void Simulation::init_can_move()
for (rt=1;rt<PT_NUM;rt++)
{
// weight check, also prevents particles of same type displacing each other
if (ptypes[t].weight <= ptypes[rt].weight || rt==PT_GEL) can_move[t][rt] = 0;
if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTPASS))
if (elements[t].Weight <= elements[rt].Weight || rt==PT_GEL) can_move[t][rt] = 0;
if (t==PT_NEUT && (elements[rt].Properties&PROP_NEUTPASS))
can_move[t][rt] = 2;
if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTABSORB))
if (t==PT_NEUT && (elements[rt].Properties&PROP_NEUTABSORB))
can_move[t][rt] = 1;
if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTPENETRATE))
if (t==PT_NEUT && (elements[rt].Properties&PROP_NEUTPENETRATE))
can_move[t][rt] = 1;
if ((ptypes[t].properties&PROP_NEUTPENETRATE) && rt==PT_NEUT)
if ((elements[t].Properties&PROP_NEUTPENETRATE) && rt==PT_NEUT)
can_move[t][rt] = 0;
if ((ptypes[t].properties&TYPE_ENERGY) && (ptypes[rt].properties&TYPE_ENERGY))
if ((elements[t].Properties&TYPE_ENERGY) && (elements[rt].Properties&TYPE_ENERGY))
can_move[t][rt] = 2;
}
}
@ -1284,13 +1285,13 @@ int Simulation::eval_move(int pt, int nx, int ny, unsigned *rr)
}
if (bmap[ny/CELL][nx/CELL])
{
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && !(ptypes[pt].properties&TYPE_GAS))// && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && !(elements[pt].Properties&TYPE_GAS))// && elements[pt].Falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWENERGY && !(ptypes[pt].properties&TYPE_ENERGY))// && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWENERGY && !(elements[pt].Properties&TYPE_ENERGY))// && elements[pt].Falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID && ptypes[pt].falldown!=2)
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID && elements[pt].Falldown!=2)
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID && ptypes[pt].falldown!=1)
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID && elements[pt].Falldown!=1)
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR || bmap[ny/CELL][nx/CELL]==WL_WALL || bmap[ny/CELL][nx/CELL]==WL_WALLELEC)
return 0;
@ -1331,7 +1332,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
if ((r & 0xFF) == PT_COAL || (r & 0xFF) == PT_BCOL)
parts[r>>8].temp = parts[i].temp;
if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10) && (r&0xFF)!=PT_FILT)
if ((r & 0xFF) < PT_NUM && elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10) && (r&0xFF)!=PT_FILT)
parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP);
}
if ((parts[i].type==PT_NEUT || parts[i].type==PT_ELEC) && ((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_PBCN)) {
@ -1403,7 +1404,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
}
//else e=1 , we are trying to swap the particles, return 0 no swap/move, 1 is still overlap/move, because the swap takes place later
if (parts[i].type == PT_NEUT && (ptypes[r & 0xFF].properties & PROP_NEUTABSORB))
if (parts[i].type == PT_NEUT && (elements[r & 0xFF].Properties & PROP_NEUTABSORB))
{
kill_part(i);
return 0;
@ -1447,7 +1448,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
if (parts[i].type==PT_NEUT) {
// target material is NEUTPENETRATE, meaning it gets moved around when neutron passes
unsigned s = pmap[y][x];
if (!(ptypes[s&0xFF].properties&PROP_NEUTPENETRATE))
if (!(elements[s&0xFF].Properties&PROP_NEUTPENETRATE))
return 1; // if the element currently underneath neutron isn't NEUTPENETRATE, don't move anything except the neutron
// if nothing is currently underneath neutron, only move target particle
if (s)
@ -1746,7 +1747,7 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type
{
if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM)
return;
if (!ptypes[t].enabled)
if (!elements[t].Enabled)
t = PT_NONE;
if (parts[i].type == PT_STKM)
@ -1785,7 +1786,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
if (x<0 || y<0 || x>=XRES || y>=YRES || ((t<0 || t>=PT_NUM)&&t!=SPC_HEAT&&t!=SPC_COOL&&t!=SPC_AIR&&t!=SPC_VACUUM&&t!=SPC_PGRV&&t!=SPC_NGRV))
return -1;
if (t>=0 && t<PT_NUM && !ptypes[t].enabled)
if (t>=0 && t<PT_NUM && !elements[t].Enabled)
return -1;
if(t==SPC_PROP) {
return -1; //Prop tool works on a mouse click basic, make sure it doesn't do anything here
@ -1865,7 +1866,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
if((pmap[y][x]&0xFF)==PT_WIRE){
parts[pmap[y][x]>>8].ctype=PT_DUST;
}
if (!((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS)))
if (!((pmap[y][x]&0xFF)==PT_INST||(elements[pmap[y][x]&0xFF].Properties&PROP_CONDUCTS)))
return -1;
if (parts[pmap[y][x]>>8].life!=0)
return -1;
@ -1905,7 +1906,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
if (pmap[y][x])
{
if ((
((pmap[y][x]&0xFF)==PT_STOR&&!(ptypes[t].properties&TYPE_SOLID))||
((pmap[y][x]&0xFF)==PT_STOR&&!(elements[t].Properties&TYPE_SOLID))||
(pmap[y][x]&0xFF)==PT_CLNE||
(pmap[y][x]&0xFF)==PT_BCLN||
(pmap[y][x]&0xFF)==PT_CONV||
@ -1973,7 +1974,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
parts[i].vy = 0;
parts[i].life = 0;
parts[i].ctype = 0;
parts[i].temp = ptypes[t].heat;
parts[i].temp = elements[t].Temperature;
parts[i].tmp = 0;
parts[i].tmp2 = 0;
}
@ -2016,7 +2017,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
parts[i].life = 50;
parts[i].tmp = 50;
}
/*if (ptypes[t].properties&PROP_LIFE) {
/*if (elements[t].Properties&PROP_LIFE) {
int r;
for (r = 0; r<NGOL; r++)
if (t==goltype[r])
@ -2116,8 +2117,8 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
parts[i].vy = 0;
parts[i].life = 100;
parts[i].ctype = 0;
parts[i].temp = ptypes[t].heat;
STKM_init_legs(this, &player, i);
parts[i].temp = elements[t].Temperature;
//STKM_init_legs(this, &player, i);
player.spwn = 1;
}
else
@ -2137,8 +2138,8 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
parts[i].vy = 0;
parts[i].life = 100;
parts[i].ctype = 0;
parts[i].temp = ptypes[t].heat;
STKM_init_legs(this, &player2, i);
parts[i].temp = elements[t].Temperature;
//STKM_init_legs(this, &player2, i);
player2.spwn = 1;
}
else
@ -2161,8 +2162,8 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
parts[i].life = 100;
parts[i].ctype = 0;
parts[i].tmp = fcount;
parts[i].temp = ptypes[t].heat;
STKM_init_legs(this, &fighters[fcount], i);
parts[i].temp = elements[t].Temperature;
//STKM_init_legs(this, &fighters[fcount], i);
fighters[fcount].spwn = 1;
fighters[fcount].elem = PT_DUST;
fighcount++;
@ -2180,13 +2181,13 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
pmap[y][x] = t|(i<<8);
//Fancy dust effects for powder types
if((ptypes[t].properties & TYPE_PART) && pretty_powder)
if((elements[t].Properties & TYPE_PART) && pretty_powder)
{
int colr, colg, colb, randa;
randa = (rand()%30)-15;
colr = (PIXR(ptypes[t].pcolors)+sandcolour_r+(rand()%20)-10+randa);
colg = (PIXG(ptypes[t].pcolors)+sandcolour_g+(rand()%20)-10+randa);
colb = (PIXB(ptypes[t].pcolors)+sandcolour_b+(rand()%20)-10+randa);
colr = (PIXR(elements[t].Colour)+sandcolour_r+(rand()%20)-10+randa);
colg = (PIXG(elements[t].Colour)+sandcolour_g+(rand()%20)-10+randa);
colb = (PIXB(elements[t].Colour)+sandcolour_b+(rand()%20)-10+randa);
colr = colr>255 ? 255 : (colr<0 ? 0 : colr);
colg = colg>255 ? 255 : (colg<0 ? 0 : colg);
colb = colb>255 ? 255 : (colb<0 ? 0 : colb);
@ -2463,7 +2464,7 @@ void Simulation::update_particles_i(int start, int inc)
continue;
}
elem_properties = ptypes[t].properties;
elem_properties = elements[t].Properties;
if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC))
{
// automatically decrease life
@ -2499,10 +2500,10 @@ void Simulation::update_particles_i(int start, int inc)
bmap[y/CELL][x/CELL]==WL_WALLELEC ||
bmap[y/CELL][x/CELL]==WL_ALLOWAIR ||
(bmap[y/CELL][x/CELL]==WL_DESTROYALL) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && ptypes[t].falldown!=2) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(ptypes[t].properties&TYPE_GAS)) || //&& ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWENERGY && !(ptypes[t].properties&TYPE_ENERGY)) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && elements[t].Falldown!=2) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && elements[t].Falldown!=1) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(elements[t].Properties&TYPE_GAS)) || //&& elements[t].Falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWENERGY && !(elements[t].Properties&TYPE_ENERGY)) ||
(bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) ||
(bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2) && (t!=PT_FIGH)))
{
@ -2513,33 +2514,33 @@ void Simulation::update_particles_i(int start, int inc)
set_emap(x/CELL, y/CELL);
//adding to velocity from the particle's velocity
vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vx;
vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vy;
vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vx;
vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vy;
if (t==PT_GAS||t==PT_NBLE)
{
if (pv[y/CELL][x/CELL]<3.5f)
pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
pv[y/CELL][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL]);
if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
pv[y/CELL+1][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL+1][x/CELL]);
if (x+CELL<XRES)
{
if (pv[y/CELL][x/CELL+1]<3.5f)
pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
pv[y/CELL][x/CELL+1] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL+1]);
if (y+CELL<YRES && pv[y/CELL+1][x/CELL+1]<3.5f)
pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
pv[y/CELL+1][x/CELL+1] += elements[t].HotAir*(3.5f-pv[y/CELL+1][x/CELL+1]);
}
}
else//add the hotair variable to the pressure map, like black hole, or white hole.
{
pv[y/CELL][x/CELL] += ptypes[t].hotair;
pv[y/CELL][x/CELL] += elements[t].HotAir;
if (y+CELL<YRES)
pv[y/CELL+1][x/CELL] += ptypes[t].hotair;
pv[y/CELL+1][x/CELL] += elements[t].HotAir;
if (x+CELL<XRES)
{
pv[y/CELL][x/CELL+1] += ptypes[t].hotair;
pv[y/CELL][x/CELL+1] += elements[t].HotAir;
if (y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair;
pv[y/CELL+1][x/CELL+1] += elements[t].HotAir;
}
}
@ -2549,15 +2550,15 @@ void Simulation::update_particles_i(int start, int inc)
default:
case 0:
pGravX = 0.0f;
pGravY = ptypes[t].gravity;
pGravY = elements[t].Gravity;
break;
case 1:
pGravX = pGravY = 0.0f;
break;
case 2:
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
pGravX = elements[t].Gravity * ((float)(x - XCNTR) / pGravD);
pGravY = elements[t].Gravity * ((float)(y - YCNTR) / pGravD);
break;
}
//Get some gravity from the gravity map
@ -2567,7 +2568,7 @@ void Simulation::update_particles_i(int start, int inc)
pGravX -= gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
pGravY -= gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
}
else if(t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH && !(ptypes[t].properties & TYPE_SOLID))
else if(t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH && !(elements[t].Properties & TYPE_SOLID))
{
pGravX += gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
pGravY += gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
@ -2575,23 +2576,23 @@ void Simulation::update_particles_i(int start, int inc)
//velocity updates for the particle
if (!(parts[i].flags&FLAG_MOVABLE))
{
parts[i].vx *= ptypes[t].loss;
parts[i].vy *= ptypes[t].loss;
parts[i].vx *= elements[t].Loss;
parts[i].vy *= elements[t].Loss;
}
//particle gets velocity from the vx and vy maps
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL] + pGravX;
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + pGravY;
parts[i].vx += elements[t].Advection*vx[y/CELL][x/CELL] + pGravX;
parts[i].vy += elements[t].Advection*vy[y/CELL][x/CELL] + pGravY;
if (ptypes[t].diffusion)//the random diffusion that gasses have
if (elements[t].Diffusion)//the random diffusion that gasses have
{
#ifdef REALISTIC
//The magic number controlls diffusion speed
parts[i].vx += 0.05*sqrtf(parts[i].temp)*ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
parts[i].vy += 0.05*sqrtf(parts[i].temp)*ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
#else
parts[i].vx += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
parts[i].vy += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
parts[i].vx += elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
parts[i].vy += elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
#endif
}
@ -2614,7 +2615,7 @@ void Simulation::update_particles_i(int start, int inc)
if (!legacy_enable)
{
if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale>(1+rand()%255))) {//some heat convection for liquids
if (y-2 >= 0 && y-2 < YRES && (elements[t].Properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale>(1+rand()%255))) {//some heat convection for liquids
r = pmap[y-2][x];
if (!(!r || parts[i].type != (r&0xFF))) {
if (parts[i].temp>parts[r>>8].temp) {
@ -2628,19 +2629,19 @@ void Simulation::update_particles_i(int start, int inc)
//heat transfer code
h_count = 0;
#ifdef REALISTIC
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale))
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale))
{
float c_Cm = 0.0f;
#else
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)>(rand()%250))
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(rand()%250))
{
float c_Cm = 0.0f;
#endif
if (aheat_enable)
{
#ifdef REALISTIC
c_heat = parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256;
c_Cm = 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256;
c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256;
c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256;
pt = c_heat/c_Cm;
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
parts[i].temp = pt;
@ -2663,7 +2664,7 @@ void Simulation::update_particles_i(int start, int inc)
if (!r)
continue;
rt = r&0xFF;
if (rt&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10)
if (rt&&elements[rt].HeatConduct&&(rt!=PT_HSWC||parts[r>>8].life==10)
&&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG))
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG)))
{
@ -2673,8 +2674,8 @@ void Simulation::update_particles_i(int start, int inc)
gel_scale = parts[r>>8].tmp*2.55f;
else gel_scale = 1.0f;
c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight);
c_Cm += 96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight);
c_heat += parts[r>>8].temp*96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight);
c_Cm += 96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight);
#else
c_heat += parts[r>>8].temp;
#endif
@ -2689,10 +2690,10 @@ void Simulation::update_particles_i(int start, int inc)
if (t == PT_PHOT)
pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645);
else
pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight));
pt = (c_heat+parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight))/(c_Cm+96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight));
c_heat += parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight);
c_Cm += 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight);
c_heat += parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight);
c_Cm += 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight);
parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
#else
pt = (c_heat+parts[i].temp)/(h_count+1);
@ -2705,10 +2706,10 @@ void Simulation::update_particles_i(int start, int inc)
ctemph = ctempl = pt;
// change boiling point with pressure
if ((ptypes[t].state==ST_LIQUID && ptransitions[t].tht>-1 && ptransitions[t].tht<PT_NUM && ptypes[ptransitions[t].tht].state==ST_GAS)
if ((elements[t].State==ST_LIQUID && elements[t].HighTemperatureTransition>-1 && elements[t].HighTemperatureTransition<PT_NUM && elements[elements[t].HighTemperatureTransition].State==ST_GAS)
|| t==PT_LNTG || t==PT_SLTW)
ctemph -= 2.0f*pv[y/CELL][x/CELL];
else if ((ptypes[t].state==ST_GAS && ptransitions[t].tlt>-1 && ptransitions[t].tlt<PT_NUM && ptypes[ptransitions[t].tlt].state==ST_LIQUID)
else if ((elements[t].State==ST_GAS && elements[t].LowTemperatureTransition>-1 && elements[t].LowTemperatureTransition<PT_NUM && elements[elements[t].LowTemperatureTransition].State==ST_LIQUID)
|| t==PT_WTRV)
ctempl -= 2.0f*pv[y/CELL][x/CELL];
s = 1;
@ -2717,34 +2718,34 @@ void Simulation::update_particles_i(int start, int inc)
if (t==PT_ICEI && (parts[i].ctype==0 || parts[i].ctype>=PT_NUM || parts[i].ctype==PT_ICEI))
parts[i].ctype = PT_WATR;
if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) {
if (ctemph>elements[t].HighTemperature&&elements[t].HighTemperatureTransition>-1) {
// particle type change due to high temperature
#ifdef REALISTIC
float dbt = ctempl - pt;
if (ptransitions[t].tht!=PT_NUM)
if (elements[t].HighTemperatureTransition!=PT_NUM)
{
if (platent[t] <= (c_heat - (ptransitions[t].thv - dbt)*c_Cm))
if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
{
pt = (c_heat - platent[t])/c_Cm;
t = ptransitions[t].tht;
t = elements[t].HighTemperatureTransition;
}
else
{
parts[i].temp = restrict_flt(ptransitions[t].thv - dbt, MIN_TEMP, MAX_TEMP);
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
}
#else
if (ptransitions[t].tht!=PT_NUM)
t = ptransitions[t].tht;
if (elements[t].HighTemperatureTransition!=PT_NUM)
t = elements[t].HighTemperatureTransition;
#endif
else if (t==PT_ICEI) {
if (parts[i].ctype<PT_NUM&&parts[i].ctype!=PT_ICEI) {
if (ptransitions[parts[i].ctype].tlt==PT_ICEI&&pt<=ptransitions[parts[i].ctype].tlv) s = 0;
if (elements[parts[i].ctype].LowTemperatureTransition==PT_ICEI&&pt<=elements[parts[i].ctype].LowTemperature) s = 0;
else {
#ifdef REALISTIC
//One ice table value for all it's kinds
if (platent[t] <= (c_heat - (ptransitions[parts[i].ctype].tlv - dbt)*c_Cm))
if (platent[t] <= (c_heat - (elements[parts[i].ctype].LowTemperature - dbt)*c_Cm))
{
pt = (c_heat - platent[t])/c_Cm;
t = parts[i].ctype;
@ -2753,7 +2754,7 @@ void Simulation::update_particles_i(int start, int inc)
}
else
{
parts[i].temp = restrict_flt(ptransitions[parts[i].ctype].tlv - dbt, MIN_TEMP, MAX_TEMP);
parts[i].temp = restrict_flt(elements[parts[i].ctype].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
#else
@ -2767,7 +2768,7 @@ void Simulation::update_particles_i(int start, int inc)
}
else if (t==PT_SLTW) {
#ifdef REALISTIC
if (platent[t] <= (c_heat - (ptransitions[t].thv - dbt)*c_Cm))
if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
{
pt = (c_heat - platent[t])/c_Cm;
@ -2776,7 +2777,7 @@ void Simulation::update_particles_i(int start, int inc)
}
else
{
parts[i].temp = restrict_flt(ptransitions[t].thv - dbt, MIN_TEMP, MAX_TEMP);
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
#else
@ -2785,26 +2786,26 @@ void Simulation::update_particles_i(int start, int inc)
#endif
}
else s = 0;
} else if (ctempl<ptransitions[t].tlv&&ptransitions[t].tlt>-1) {
} else if (ctempl<elements[t].LowTemperature&&elements[t].LowTemperatureTransition>-1) {
// particle type change due to low temperature
#ifdef REALISTIC
float dbt = ctempl - pt;
if (ptransitions[t].tlt!=PT_NUM)
if (elements[t].LowTemperatureTransition!=PT_NUM)
{
if (platent[ptransitions[t].tlt] >= (c_heat - (ptransitions[t].tlv - dbt)*c_Cm))
if (platent[elements[t].LowTemperatureTransition] >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm))
{
pt = (c_heat + platent[ptransitions[t].tlt])/c_Cm;
t = ptransitions[t].tlt;
pt = (c_heat + platent[elements[t].LowTemperatureTransition])/c_Cm;
t = elements[t].LowTemperatureTransition;
}
else
{
parts[i].temp = restrict_flt(ptransitions[t].tlv - dbt, MIN_TEMP, MAX_TEMP);
parts[i].temp = restrict_flt(elements[t].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
}
#else
if (ptransitions[t].tlt!=PT_NUM)
t = ptransitions[t].tlt;
if (elements[t].LowTemperatureTransition!=PT_NUM)
t = elements[t].LowTemperatureTransition;
#endif
else if (t==PT_WTRV) {
if (pt<273.0f) t = PT_RIME;
@ -2812,9 +2813,9 @@ void Simulation::update_particles_i(int start, int inc)
}
else if (t==PT_LAVA) {
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_LAVA) {
if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0;
else if (ptransitions[parts[i].ctype].tht==PT_LAVA) {
if (pt>=ptransitions[parts[i].ctype].thv) s = 0;
if (parts[i].ctype==PT_THRM&&pt>=elements[PT_BMTL].HighTemperature) s = 0;
else if (elements[parts[i].ctype].HighTemperatureTransition==PT_LAVA) {
if (pt>=elements[parts[i].ctype].HighTemperature) s = 0;
}
else if (pt>=973.0f) s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype
if (s) {
@ -2848,7 +2849,7 @@ void Simulation::update_particles_i(int start, int inc)
if (t==PT_ICEI||t==PT_LAVA)
parts[i].ctype = parts[i].type;
if (!(t==PT_ICEI&&parts[i].ctype==PT_FRZW)) parts[i].life = 0;
if (ptypes[t].state==ST_GAS&&ptypes[parts[i].type].state!=ST_GAS)
if (elements[t].State==ST_GAS&&elements[parts[i].type].State!=ST_GAS)
pv[y/CELL][x/CELL] += 0.50f;
part_change_type(i,x,y,t);
if (t==PT_FIRE||t==PT_PLSM||t==PT_HFLM)
@ -2894,7 +2895,7 @@ void Simulation::update_particles_i(int start, int inc)
//wire_placed = 1;
}
//spark updates from walls
if ((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK)
if ((elements[t].Properties&PROP_CONDUCTS) || t==PT_SPRK)
{
nx = x % CELL;
if (nx == 0)
@ -2928,10 +2929,10 @@ void Simulation::update_particles_i(int start, int inc)
}
//the basic explosion, from the .explosive variable
if ((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f)
if ((elements[t].Explosive&2) && pv[y/CELL][x/CELL]>2.5f)
{
parts[i].life = rand()%80+180;
parts[i].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[t].flammable/2), MIN_TEMP, MAX_TEMP);
parts[i].temp = restrict_flt(elements[PT_FIRE].Temperature + (elements[t].Flammable/2), MIN_TEMP, MAX_TEMP);
t = PT_FIRE;
part_change_type(i,x,y,t);
pv[y/CELL][x/CELL] += 0.25f * CFDS;
@ -2940,10 +2941,10 @@ void Simulation::update_particles_i(int start, int inc)
s = 1;
gravtot = fabs(gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]);
if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) {
if (pv[y/CELL][x/CELL]>elements[t].HighPressure&&elements[t].HighPressureTransition>-1) {
// particle type change due to high pressure
if (ptransitions[t].pht!=PT_NUM)
t = ptransitions[t].pht;
if (elements[t].HighPressureTransition!=PT_NUM)
t = elements[t].HighPressureTransition;
else if (t==PT_BMTL) {
if (pv[y/CELL][x/CELL]>2.5f)
t = PT_BRMT;
@ -2952,15 +2953,15 @@ void Simulation::update_particles_i(int start, int inc)
else s = 0;
}
else s = 0;
} else if (pv[y/CELL][x/CELL]<ptransitions[t].plv&&ptransitions[t].plt>-1) {
} else if (pv[y/CELL][x/CELL]<elements[t].LowPressure&&elements[t].LowPressureTransition>-1) {
// particle type change due to low pressure
if (ptransitions[t].plt!=PT_NUM)
t = ptransitions[t].plt;
if (elements[t].LowPressureTransition!=PT_NUM)
t = elements[t].LowPressureTransition;
else s = 0;
} else if (gravtot>(ptransitions[t].phv/4.0f)&&ptransitions[t].pht>-1) {
} else if (gravtot>(elements[t].HighPressure/4.0f)&&elements[t].HighPressureTransition>-1) {
// particle type change due to high gravity
if (ptransitions[t].pht!=PT_NUM)
t = ptransitions[t].pht;
if (elements[t].HighPressureTransition!=PT_NUM)
t = elements[t].HighPressureTransition;
else if (t==PT_BMTL) {
if (gravtot>0.625f)
t = PT_BRMT;
@ -2983,12 +2984,12 @@ void Simulation::update_particles_i(int start, int inc)
//call the particle update function, if there is one
#ifdef LUACONSOLE
if (ptypes[t].update_func && lua_el_mode[t] != 2)
if (elements[t].Update && lua_el_mode[t] != 2)
#else
if (ptypes[t].update_func)
if (elements[t].Update)
#endif
{
if ((*(ptypes[t].update_func))(this, i,x,y,surround_space,nt, parts, pmap))
if ((*(elements[t].Update))(this, i,x,y,surround_space,nt, parts, pmap))
continue;
else if (t==PT_WARP)
{
@ -3007,8 +3008,8 @@ void Simulation::update_particles_i(int start, int inc)
y = (int)(parts[i].y+0.5f);
}
#endif
if (legacy_enable)//if heat sim is off
update_legacy_all(this, i,x,y,surround_space,nt, parts, pmap);
//if (legacy_enable)//if heat sim is off
//update_legacy_all(this, i,x,y,surround_space,nt, parts, pmap); //TODO:pop
killed:
if (parts[i].type == PT_NONE)//if its dead, skip to next particle
@ -3191,7 +3192,7 @@ killed:
}
}
}
else if (ptypes[t].falldown==0)
else if (elements[t].Falldown==0)
{
// gasses and solids (but not powders)
if (!do_move(i, x, y, fin_xf, fin_yf))
@ -3207,22 +3208,22 @@ killed:
if (fin_y<y-ISTP) fin_y=y-ISTP;
if (do_move(i, x, y, 0.25f+(float)(2*x-fin_x), 0.25f+fin_y))
{
parts[i].vx *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
}
else if (do_move(i, x, y, 0.25f+fin_x, 0.25f+(float)(2*y-fin_y)))
{
parts[i].vy *= ptypes[t].collision;
parts[i].vy *= elements[t].Collision;
}
else
{
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
}
}
}
else
{
if (water_equal_test && ptypes[t].falldown == 2 && 1>= rand()%400)//checking stagnant is cool, but then it doesn't update when you change it later.
if (water_equal_test && elements[t].Falldown == 2 && 1>= rand()%400)//checking stagnant is cool, but then it doesn't update when you change it later.
{
if (!flood_water(x,y,i,y, parts[i].tmp2))
goto movedone;
@ -3234,13 +3235,13 @@ killed:
continue;
if (fin_x!=x && do_move(i, x, y, fin_xf, clear_yf))
{
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
}
else if (fin_y!=y && do_move(i, x, y, clear_xf, fin_yf))
{
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
}
else
{
@ -3261,8 +3262,8 @@ killed:
dy /= mv;
if (do_move(i, x, y, clear_xf+dx, clear_yf+dy))
{
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
goto movedone;
}
swappage = dx;
@ -3270,12 +3271,12 @@ killed:
dy = -swappage*r;
if (do_move(i, x, y, clear_xf+dx, clear_yf+dy))
{
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
goto movedone;
}
}
if (ptypes[t].falldown>1 && !ngrav_enable && gravityMode==0 && parts[i].vy>fabsf(parts[i].vx))
if (elements[t].Falldown>1 && !ngrav_enable && gravityMode==0 && parts[i].vy>fabsf(parts[i].vx))
{
s = 0;
// stagnant is true if FLAG_STAGNANT was set for this particle in previous frame
@ -3321,12 +3322,12 @@ killed:
else if (s==-1) {} // particle is out of bounds
else if ((clear_x!=x||clear_y!=y) && do_move(i, x, y, clear_xf, clear_yf)) {}
else parts[i].flags |= FLAG_STAGNANT;
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
}
else if (ptypes[t].falldown>1 && fabsf(pGravX*parts[i].vx+pGravY*parts[i].vy)>fabsf(pGravY*parts[i].vx-pGravX*parts[i].vy))
else if (elements[t].Falldown>1 && fabsf(pGravX*parts[i].vx+pGravY*parts[i].vy)>fabsf(pGravY*parts[i].vx-pGravX*parts[i].vy))
{
float nxf, nyf, prev_pGravX, prev_pGravY, ptGrav = ptypes[t].gravity;
float nxf, nyf, prev_pGravX, prev_pGravY, ptGrav = elements[t].Gravity;
s = 0;
// stagnant is true if FLAG_STAGNANT was set for this particle in previous frame
if (!stagnant || nt) //nt is if there is an something else besides the current particle type, around the particle
@ -3439,16 +3440,16 @@ killed:
else if (s==-1) {} // particle is out of bounds
else if ((clear_x!=x||clear_y!=y) && do_move(i, x, y, clear_xf, clear_yf)) {}
else parts[i].flags |= FLAG_STAGNANT;
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
}
else
{
// if interpolation was done, try moving to last clear position
if ((clear_x!=x||clear_y!=y) && do_move(i, x, y, clear_xf, clear_yf)) {}
else parts[i].flags |= FLAG_STAGNANT;
parts[i].vx *= ptypes[t].collision;
parts[i].vy *= ptypes[t].collision;
parts[i].vx *= elements[t].Collision;
parts[i].vy *= elements[t].Collision;
}
}
}
@ -3615,20 +3616,18 @@ Simulation::Simulation():
memcpy(wtypes, wtypesT, wallCount * sizeof(wall_type));
free(wtypesT);
int elementCount;
part_type * ptypesT = LoadElements(elementCount);
memcpy(ptypes, ptypesT, elementCount * sizeof(part_type));
free(ptypesT);
platent = new unsigned[PT_NUM];
int latentCount;
unsigned int * platentT = LoadLatent(latentCount);
memcpy(platent, platentT, latentCount * sizeof(unsigned int));
free(platentT);
int transitionCount;
part_transition * ptransitionsT = LoadTransitions(transitionCount);
memcpy(ptransitions, ptransitionsT, sizeof(part_transition) * transitionCount);
free(ptransitionsT);
elements = new Element[PT_NUM];
std::vector<Element> elementList = GetElements();
for(int i = 0; i < elementList.size(); i++)
{
elements[i] = elementList[i];
}
int golRulesCount;
int * golRulesT = LoadGOLRules(golRulesCount);

View File

@ -139,9 +139,8 @@ public:
Gravity * grav;
Air * air;
part_type ptypes[PT_NUM];
unsigned int platent[PT_NUM];
part_transition ptransitions[PT_NUM];
Element * elements;
unsigned int * platent;
wall_type wtypes[UI_WALLCOUNT];
gol_menu gmenu[NGOL];
int goltype[NGOL];

View File

@ -5,9 +5,22 @@
* Author: Simon
*/
#include "SimulationData.h"
#include "ElementFunctions.h"
//#include "ElementFunctions.h"
#include "ElementGraphics.h"
std::vector<Element*> GetDefaultElements()
{
std::vector<Element*> elements;
//class Element;
//elements.push_back(dynamic_cast<Element*>(new NULLElement()));
//elements.push_back(dynamic_cast<Element*>(new DUSTElement()));
//elements.push_back(dynamic_cast<Element*>(new WATRElement()));
//for(int i = 3; i < PT_NUM; i++)
// elements.push_back(dynamic_cast<Element*>(new DUSTElement()));
return elements;
}
gol_menu * LoadGOLMenu(int & golMenuCount)
{
gol_menu golMenu[NGOL] =
@ -185,7 +198,7 @@ part_type * LoadElements(int & elementCount)
part_type ptypes[PT_NUM] =
{
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description
{"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL, NULL},
/*{"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL, NULL},
{"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, NULL, &graphics_DUST},
{"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_WATR, NULL},
{"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", ST_LIQUID, TYPE_LIQUID, NULL, NULL},
@ -333,10 +346,10 @@ part_type * LoadElements(int & elementCount)
{"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL},
{"GEL", PIXPACK(0xFF9900), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Gel. A liquid with variable viscosity and heat conductivity", ST_LIQUID, TYPE_LIQUID|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_GEL, &graphics_GEL},
{"TRON", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, 0.0f, 40, "Smart particles, Travels in straight lines and avoids obstacles. Grows with time.", ST_NONE, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_TRON, &graphics_TRON},
/*FREE*/{"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
/*FREE*/{"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
/*FREE*/{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
/*FREE*/{"WIND", PIXPACK(0x101010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_SPECIAL, 0.0f, 40, "", ST_NONE, ST_NONE, NULL, NULL},
{"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
{"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
{"WIND", PIXPACK(0x101010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_SPECIAL, 0.0f, 40, "", ST_NONE, ST_NONE, NULL, NULL},
{"HYGN", PIXPACK(0x5070FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.10f, 0.00f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 251, "Combines with O2 to make WATR", ST_GAS, TYPE_GAS, &update_H2, NULL},
{"SOAP", PIXPACK(0xF5F5DC), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Soap. Creates bubbles.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE|PROP_LIFE_DEC, &update_SOAP, NULL},
{"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Black hole (Requires newtonian gravity)", ST_SOLID, TYPE_SOLID, &update_NBHL, NULL},
@ -349,7 +362,7 @@ part_type * LoadElements(int & elementCount)
{"GBMB", PIXPACK(0x1144BB), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Sticks to first object it touches then produces strong gravity push.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_GBMB, &graphics_GBMB},
{"FIGH", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Fighter. Tries to kill stickmen.", ST_NONE, 0, &update_FIGH, &graphics_FIGH},
{"FRAY", PIXPACK(0x00BBFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Force Emitter. Push or pull objects based on temp value, use like ARAY", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_FRAY, NULL},
{"RPEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Repel or attract particles based on temp value.", ST_NONE, TYPE_SOLID, &update_REPL, NULL},
{"RPEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Repel or attract particles based on temp value.", ST_NONE, TYPE_SOLID, &update_REPL, NULL},*/
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description
};
elementCount = PT_NUM;

View File

@ -5,6 +5,8 @@
* Author: Simon
*/
#include <vector>
#define SC_WALL 0
#define SC_ELEC 1
#define SC_POWERED 2
@ -118,6 +120,7 @@
#ifndef SIMULATIONDATA_H_
#define SIMULATIONDATA_H_
//#include "elements/NULLElement.h"
#include "Simulation.h"
/*class Simulation;
@ -136,6 +139,9 @@ struct menu_section;
struct wall_type;
class Element;
std::vector<Element*> GetDefaultElements();
gol_menu * LoadGOLMenu(int & golMenuCount);
int * LoadGOLTypes(int & golTypeCount);

View File

@ -0,0 +1,49 @@
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_116 PT_116 116
Element_116::Element_116()
{
Identifier = "DEFAULT_PT_116";
Name = "EQVE";
Colour = PIXPACK(0xFFE0A0);
MenuVisible = 0;
MenuSection = SC_CRACKER2;
Enabled = 1;
Advection = 0.7f;
AirDrag = 0.02f * CFDS;
AirLoss = 0.96f;
Loss = 0.80f;
Collision = 0.0f;
Gravity = 0.1f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 1;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 30;
Weight = 85;
Temperature = R_TEMP+0.0f +273.15f;
HeatConduct = 70;
Description = "Shared velocity test";
State = ST_SOLID;
Properties = TYPE_PART;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = NULL;
Graphics = NULL;
}
Element_116::~Element_116() {}

View File

@ -0,0 +1,49 @@
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_144 PT_144 144
Element_144::Element_144()
{
Identifier = "DEFAULT_PT_144";
Name = "STAR";
Colour = PIXPACK(0x0000FF);
MenuVisible = 0;
MenuSection = SC_LIFE;
Enabled = 0;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.90f;
Loss = 0.00f;
Collision = 0.0f;
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = 100;
Temperature = 9000.0f;
HeatConduct = 40;
Description = "Like Star Wars rule S3456/B278/6";
State = ST_NONE;
Properties = TYPE_SOLID|PROP_LIFE;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = NULL;
Graphics = NULL;
}
Element_144::~Element_144() {}

View File

@ -0,0 +1,49 @@
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_145 PT_145 145
Element_145::Element_145()
{
Identifier = "DEFAULT_PT_145";
Name = "FROG";
Colour = PIXPACK(0x00AA00);
MenuVisible = 0;
MenuSection = SC_LIFE;
Enabled = 0;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.90f;
Loss = 0.00f;
Collision = 0.0f;
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = 100;
Temperature = 9000.0f;
HeatConduct = 40;
Description = "Frogs S12/B34/3";
State = ST_NONE;
Properties = TYPE_SOLID|PROP_LIFE;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = NULL;
Graphics = NULL;
}
Element_145::~Element_145() {}

View File

@ -0,0 +1,49 @@
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_146 PT_146 146
Element_146::Element_146()
{
Identifier = "DEFAULT_PT_146";
Name = "BRAN";
Colour = PIXPACK(0xCCCC00);
MenuVisible = 0;
MenuSection = SC_LIFE;
Enabled = 0;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.90f;
Loss = 0.00f;
Collision = 0.0f;
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = 100;
Temperature = 9000.0f;
HeatConduct = 40;
Description = "Brian 6 S6/B246/3";
State = ST_NONE;
Properties = TYPE_SOLID|PROP_LIFE;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = NULL;
Graphics = NULL;
}
Element_146::~Element_146() {}

Some files were not shown because too many files have changed in this diff Show More