summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorSavely Skresanov <savask@yandex.ru>2012-05-26 11:49:40 (GMT)
committer Savely Skresanov <savask@yandex.ru>2012-05-26 12:01:14 (GMT)
commitab8eeb6dd9691e55ef82e62f60a62497cb24b3d1 (patch)
tree9014d0d819657ad18906af44a9f10adb4072b39c /src/elements
parentfd868032feff77fa7abf0f507821101929fb2e7a (diff)
downloadpowder-ab8eeb6dd9691e55ef82e62f60a62497cb24b3d1.zip
powder-ab8eeb6dd9691e55ef82e62f60a62497cb24b3d1.tar.gz
Soap bubbles are easily formed now. Also they inherit soap's
decoration color.
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/soap.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/src/elements/soap.c b/src/elements/soap.c
index c8b5078..6b69778 100644
--- a/src/elements/soap.c
+++ b/src/elements/soap.c
@@ -15,6 +15,27 @@
#include <element.h>
+void attach(int i1, int i2)
+{
+ if (!(parts[i2].ctype&4))
+ {
+ parts[i1].ctype |= 2;
+ parts[i1].tmp = i2;
+
+ parts[i2].ctype |= 4;
+ parts[i2].tmp2 = i1;
+ }
+ else
+ if (!(parts[i2].ctype&2))
+ {
+ parts[i1].ctype |= 4;
+ parts[i1].tmp2= i2;
+
+ parts[i2].ctype |= 2;
+ parts[i2].tmp = i1;
+ }
+}
+
int update_SOAP(UPDATE_FUNC_ARGS)
{
int r, rx, ry, nr, ng, nb, na;
@@ -25,7 +46,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
//0x02 - first mate yes/no
//0x04 - "back" mate yes/no
- if ((parts[i].ctype&1) == 1)
+ if (parts[i].ctype&1)
{
if (parts[i].temp>0)
{
@@ -39,13 +60,13 @@ int update_SOAP(UPDATE_FUNC_ARGS)
while((parts[target].ctype&6) != 6 && (parts[target].ctype&6))
{
- if ((parts[target].ctype&2) == 2)
+ if (parts[target].ctype&2)
{
target = parts[target].tmp;
detach(target);
}
- if ((parts[target].ctype&4) == 4)
+ if (parts[target].ctype&4)
{
target = parts[target].tmp2;
detach(target);
@@ -66,7 +87,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
parts[i].vx *= 0.5f;
}
- if((parts[i].ctype&2) != 2)
+ if (!(parts[i].ctype&2))
{
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
@@ -76,29 +97,8 @@ int update_SOAP(UPDATE_FUNC_ARGS)
if (!r)
continue;
- if ((parts[r>>8].type == PT_SOAP) && ((parts[r>>8].ctype&1) == 1)
- && ((parts[r>>8].ctype&4) != 4))
- {
- if ((parts[r>>8].ctype&2) == 2)
- {
- parts[i].tmp = r>>8;
- parts[r>>8].tmp2 = i;
-
- parts[i].ctype |= 2;
- parts[r>>8].ctype |= 4;
- }
- else
- {
- if ((parts[i].ctype&2) != 2)
- {
- parts[i].tmp = r>>8;
- parts[r>>8].tmp2 = i;
-
- parts[i].ctype |= 2;
- parts[r>>8].ctype |= 4;
- }
- }
- }
+ if ((parts[r>>8].type == PT_SOAP) && (parts[r>>8].ctype&1) && !(parts[r>>8].ctype&4))
+ attach(i, r>>8);
}
}
else
@@ -116,9 +116,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
{
if (bmap[(y+ry)/CELL][(x+rx)/CELL]
|| (r && ptypes[r&0xFF].state != ST_GAS
- && (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS)
- || (parts[r>>8].ctype == 0 && (r&0xFF) == PT_SOAP
- && (abs(parts[r>>8].vx)<2 || abs(parts[r>>8].vy)<2)))
+ && (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS))
{
detach(i);
continue;
@@ -150,7 +148,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
}
}
- if((parts[i].ctype&2) == 2)
+ if(parts[i].ctype&2)
{
float d, dx, dy;
@@ -165,8 +163,8 @@ int update_SOAP(UPDATE_FUNC_ARGS)
parts[i].vx += dx*d;
parts[i].vy += dy*d;
- if (((parts[parts[i].tmp].ctype&2) == 2) && ((parts[parts[i].tmp].ctype&1) == 1)
- && ((parts[parts[parts[i].tmp].tmp].ctype&2) == 2) && ((parts[parts[parts[i].tmp].tmp].ctype&1) == 1))
+ if ((parts[parts[i].tmp].ctype&2) && (parts[parts[i].tmp].ctype&1)
+ && (parts[parts[parts[i].tmp].tmp].ctype&2) && (parts[parts[parts[i].tmp].tmp].ctype&1))
{
int ii;