mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 10:49:53 +02:00
fix set_property not checking stacked particles, add dcolor property setting/getting
This commit is contained in:
@@ -1326,7 +1326,7 @@ int luatpt_set_property(lua_State* l)
|
|||||||
} else if (strcmp(prop,"y")==0){
|
} else if (strcmp(prop,"y")==0){
|
||||||
offset = offsetof(particle, y);
|
offset = offsetof(particle, y);
|
||||||
format = 2;
|
format = 2;
|
||||||
} else if (strcmp(prop,"dcolour")==0){
|
} else if (strcmp(prop,"dcolour")==0 || strcmp(prop,"dcolor")==0){
|
||||||
offset = offsetof(particle, dcolour);
|
offset = offsetof(particle, dcolour);
|
||||||
format = 1;
|
format = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -1367,22 +1367,22 @@ int luatpt_set_property(lua_State* l)
|
|||||||
w = XRES-x;
|
w = XRES-x;
|
||||||
if(y+h > YRES)
|
if(y+h > YRES)
|
||||||
h = YRES-y;
|
h = YRES-y;
|
||||||
for (nx = x; nx<x+w; nx++)
|
for (i = 0; i < NPART; i++)
|
||||||
for (ny = y; ny<y+h; ny++){
|
{
|
||||||
r = pmap[ny][nx];
|
if (parts[i].type)
|
||||||
if (!r || (partsel && partsel != parts[r>>8].type))
|
{
|
||||||
|
nx = (int)(parts[i].x + .5f);
|
||||||
|
ny = (int)(parts[i].y + .5f);
|
||||||
|
if (nx >= x && nx < x+w && ny >= y && ny < y+h && (!partsel || partsel == parts[i].type))
|
||||||
{
|
{
|
||||||
r = photons[ny][nx];
|
|
||||||
if (!r || (partsel && partsel != parts[r>>8].type))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i = r>>8;
|
|
||||||
if(format==2){
|
if(format==2){
|
||||||
*((float*)(((char*)&parts[i])+offset)) = f;
|
*((float*)(((char*)&parts[i])+offset)) = f;
|
||||||
} else {
|
} else {
|
||||||
*((int*)(((char*)&parts[i])+offset)) = t;
|
*((int*)(((char*)&parts[i])+offset)) = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Got coords or particle index
|
// Got coords or particle index
|
||||||
if(i != -1 && y != -1){
|
if(i != -1 && y != -1){
|
||||||
|
Reference in New Issue
Block a user