separate t and v argument in create_part, fix LIGH not defaulting to .life of 30 with clones / console
This commit is contained in:
parent
d3c44dbffa
commit
f6d82b6f8a
@ -163,5 +163,5 @@ void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point posi
|
||||
|
||||
void PlopTool::Click(Simulation * sim, Brush * brush, ui::Point position)
|
||||
{
|
||||
sim->create_part(-2, position.X, position.Y, toolID);
|
||||
sim->create_part(-2, position.X, position.Y, toolID&0xFF, toolID>>8);
|
||||
}
|
||||
|
@ -895,7 +895,14 @@ int LuaScriptInterface::simulation_partCreate(lua_State * l)
|
||||
lua_pushinteger(l, -1);
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger(l, luacon_sim->create_part(newID, lua_tointeger(l, 2), lua_tointeger(l, 3), lua_tointeger(l, 4)));
|
||||
int type = lua_tointeger(l, 4);
|
||||
int v = -1;
|
||||
if (type>>8)
|
||||
{
|
||||
v = type>>8;
|
||||
type = type&0xFF;
|
||||
}
|
||||
lua_pushinteger(l, luacon_sim->create_part(newID, lua_tointeger(l, 2), lua_tointeger(l, 3), type, v));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,13 @@ AnyType TPTScriptInterface::tptS_create(std::deque<std::string> * words)
|
||||
if(tempPoint.X<0 || tempPoint.Y<0 || tempPoint.Y >= YRES || tempPoint.X >= XRES)
|
||||
throw GeneralException("Invalid position");
|
||||
|
||||
int returnValue = sim->create_part(-1, tempPoint.X, tempPoint.Y, type);
|
||||
int v = -1;
|
||||
if (type>>8)
|
||||
{
|
||||
v = type>>8;
|
||||
type = type&0xFF;
|
||||
}
|
||||
int returnValue = sim->create_part(-1, tempPoint.X, tempPoint.Y, type, v);
|
||||
|
||||
return NumberType(returnValue);
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ int Simulation::FloodINST(int x, int y, int fullc, int cm)
|
||||
// fill span
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
if (create_part(-1, x, y, fullc)>=0)
|
||||
if (create_part(-1, x, y, c, fullc>>8)>=0)
|
||||
created_something = 1;
|
||||
}
|
||||
|
||||
@ -1440,12 +1440,12 @@ int Simulation::CreatePartFlags(int x, int y, int c, int flags)
|
||||
{
|
||||
delete_part(x, y);
|
||||
if (c!=0)
|
||||
create_part(-2, x, y, c);
|
||||
create_part(-2, x, y, c&0xFF, c>>8);
|
||||
}
|
||||
}
|
||||
//normal draw
|
||||
else
|
||||
if (create_part(-2, x, y, c) == -1)
|
||||
if (create_part(-2, x, y, c&0xFF, c>>8) == -1)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@ -1509,6 +1509,8 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
|
||||
bool reverseXY = abs(y2-y1) > abs(x2-x1);
|
||||
int x, y, dx, dy, sy;
|
||||
float e, de;
|
||||
int v = c>>8;
|
||||
c = c&0xFF;
|
||||
if (reverseXY)
|
||||
{
|
||||
y = x1;
|
||||
@ -1539,9 +1541,9 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
if (reverseXY)
|
||||
create_part(-1, y, x, c);
|
||||
create_part(-1, y, x, c, v);
|
||||
else
|
||||
create_part(-1, x, y, c);
|
||||
create_part(-1, x, y, c, v);
|
||||
e += de;
|
||||
if (e >= 0.5f)
|
||||
{
|
||||
@ -1549,9 +1551,9 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c)
|
||||
if ((y1<y2) ? (y<=y2) : (y>=y2))
|
||||
{
|
||||
if (reverseXY)
|
||||
create_part(-1, y, x, c);
|
||||
create_part(-1, y, x, c, v);
|
||||
else
|
||||
create_part(-1, x, y, c);
|
||||
create_part(-1, x, y, c, v);
|
||||
}
|
||||
e -= 1.0f;
|
||||
}
|
||||
@ -2763,19 +2765,16 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type
|
||||
|
||||
//the function for creating a particle, use p=-1 for creating a new particle, -2 is from a brush, or a particle number to replace a particle.
|
||||
//tv = Type (8 bits) + Var (24 bits), var is usually 0
|
||||
int Simulation::create_part(int p, int x, int y, int tv)
|
||||
int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
{
|
||||
int i;
|
||||
|
||||
int t = tv & 0xFF;
|
||||
int v = (tv >> 8) & 0xFFFFFF;
|
||||
|
||||
if (x<0 || y<0 || x>=XRES || y>=YRES)
|
||||
return -1;
|
||||
if (t>=0 && t<PT_NUM && !elements[t].Enabled)
|
||||
return -1;
|
||||
|
||||
if (tv == SPC_AIR)
|
||||
if (t == SPC_AIR)
|
||||
{
|
||||
pv[y/CELL][x/CELL] += 0.03f;
|
||||
if (y+CELL<YRES)
|
||||
@ -2788,8 +2787,7 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (t==PT_SPRK)
|
||||
else if (t==PT_SPRK)
|
||||
{
|
||||
int type = pmap[y][x]&0xFF;
|
||||
int index = pmap[y][x]>>8;
|
||||
@ -2818,10 +2816,11 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
parts[index].temp = parts[index].temp+10.0f;
|
||||
return index;
|
||||
}
|
||||
if (t==PT_SPAWN&&elementCount[PT_SPAWN])
|
||||
else if (t==PT_SPAWN && elementCount[PT_SPAWN])
|
||||
return -1;
|
||||
if (t==PT_SPAWN2&&elementCount[PT_SPAWN2])
|
||||
else if (t==PT_SPAWN2 && elementCount[PT_SPAWN2])
|
||||
return -1;
|
||||
|
||||
if (p==-1)//creating from anything but brush
|
||||
{
|
||||
// If there is a particle, only allow creation if the new particle can occupy the same space as the existing particle
|
||||
@ -4701,7 +4700,7 @@ void Simulation::SimulateGoL()
|
||||
}
|
||||
}
|
||||
if (creategol<0xFF)
|
||||
create_part(-1, nx, ny, PT_LIFE|((creategol-1)<<8));
|
||||
create_part(-1, nx, ny, PT_LIFE, creategol-1);
|
||||
}
|
||||
else if (grule[golnum][neighbors-1]==0 || grule[golnum][neighbors-1]==2)//subtract 1 because it counted itself
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
void part_change_type(int i, int x, int y, int t);
|
||||
//int InCurrentBrush(int i, int j, int rx, int ry);
|
||||
//int get_brush_flags();
|
||||
int create_part(int p, int x, int y, int t);
|
||||
int create_part(int p, int x, int y, int t, int v = -1);
|
||||
void delete_part(int x, int y);
|
||||
void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
|
||||
int is_wire(int x, int y);
|
||||
|
@ -139,7 +139,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
for (int rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1 - rx1 + 1)
|
||||
{
|
||||
int np = sim->create_part(-1, x + nxi + nxx + rx1, y + nyi + nyy + ry1, parts[r].tmp);
|
||||
int np = sim->create_part(-1, x + nxi + nxx + rx1, y + nyi + nyy + ry1, parts[r].tmp&0xFF);
|
||||
if (np != -1)
|
||||
{
|
||||
parts[np].temp = parts[r].temp;
|
||||
|
@ -81,10 +81,10 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
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));
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -72,10 +72,10 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
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));
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -85,7 +85,7 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=ctype)
|
||||
{
|
||||
sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype);
|
||||
sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype&0xFF, parts[i].ctype>>8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
||||
if (!sim->IsWallBlocking(x+nxi+nxx, y+nyi+nyy, parts[i].ctype) && (!sim->pmap[y+nyi+nyy][x+nxi+nxx] || createSpark)) { // create, also set color if it has passed through FILT
|
||||
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype);
|
||||
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype&0xFF, parts[i].ctype>>8);
|
||||
if (nr!=-1) {
|
||||
if (colored)
|
||||
parts[nr].dcolour = colored;
|
||||
|
@ -114,7 +114,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
|
||||
for (ry = -1; ry < 2; ry++)
|
||||
if (rx || ry)
|
||||
{
|
||||
int r = sim->create_part(-1, x + rx, y + ry,parts[i].ctype);
|
||||
int r = sim->create_part(-1, x + rx, y + ry, PT_PHOT);
|
||||
if (r != -1)
|
||||
{
|
||||
parts[r].vx = rx * 3;
|
||||
@ -130,11 +130,11 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
|
||||
else if (parts[i].ctype==PT_LIFE)//create life a different way
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
|
||||
sim->create_part(-1, x+rx, y+ry, PT_LIFE, parts[i].tmp);
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || !(rand()%30))
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF, parts[i].ctype>>8);
|
||||
if (np>-1)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -105,7 +105,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
|
||||
for (ry = -1; ry < 2; ry++)
|
||||
if (rx || ry)
|
||||
{
|
||||
int r = sim->create_part(-1, x + rx, y + ry, parts[i].ctype);
|
||||
int r = sim->create_part(-1, x + rx, y + ry, PT_PHOT);
|
||||
if (r != -1)
|
||||
{
|
||||
parts[r].vx = rx * 3;
|
||||
@ -121,11 +121,11 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
|
||||
else if (parts[i].ctype==PT_LIFE)//create life a different way
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
|
||||
sim->create_part(-1, x+rx, y+ry, PT_LIFE, parts[i].tmp);
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -75,7 +75,7 @@ int Element_STOR::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
for(ry1 = 1; ry1 >= -1; ry1--){
|
||||
for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscillate 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);
|
||||
np = sim->create_part(-1,x+rx1,y+ry1,parts[i].tmp&0xFF);
|
||||
if (np!=-1)
|
||||
{
|
||||
parts[np].temp = parts[i].temp;
|
||||
|
Loading…
Reference in New Issue
Block a user