summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-08 19:36:27 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-08 19:39:17 (GMT)
commit7f83cb10611e6073c72a38eb97116a2895871435 (patch)
tree54df0cc2146eb09c0ba1d8fe66ca8e7e593a3077 /src/elements
parent692e2ba86d694103bfcad00ddd6816fc96d595bd (diff)
downloadpowder-7f83cb10611e6073c72a38eb97116a2895871435.zip
powder-7f83cb10611e6073c72a38eb97116a2895871435.tar.gz
Function pointers + minor adjustments.
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/misc.c52
-rw-r--r--src/elements/phot.c60
2 files changed, 112 insertions, 0 deletions
diff --git a/src/elements/misc.c b/src/elements/misc.c
new file mode 100644
index 0000000..38ae49f
--- /dev/null
+++ b/src/elements/misc.c
@@ -0,0 +1,52 @@
+#include <powder.h>
+
+int update_MISC(UPDATE_FUNC_ARGS) { // should probably get their own functions later
+ int t = parts[i].type;
+ if ((t==PT_PTCT||t==PT_NTCT)&&parts[i].temp>295.0f)
+ {
+ parts[i].temp -= 2.5f;
+ }
+ if (t==PT_GLAS)
+ {
+ parts[i].pavg[0] = parts[i].pavg[1];
+ parts[i].pavg[1] = 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)
+ {
+ parts[i].type = PT_BGLA;
+ }
+ }
+ else if (t==PT_QRTZ)
+ {
+ parts[i].pavg[0] = parts[i].pavg[1];
+ parts[i].pavg[1] = 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))
+ {
+ parts[i].type = PT_PQRT;
+ }
+ }
+ else if (t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000))
+ {
+ parts[i].type = PT_NEUT;
+ create_part(i, x, y, parts[i].type);
+ }
+ else if (t==PT_MORT) {
+ create_part(-1, x, y-1, PT_SMKE);
+ }
+ else if (t==PT_LOVE)
+ ISLOVE=1;
+ else if (t==PT_LOLZ)
+ ISLOLZ=1;
+ else if (t==PT_GRAV)
+ ISGRAV=1;
+
+
+ if (!legacy_enable) {
+ if (t==PT_URAN && pv[y/CELL][x/CELL]>0.0f)
+ {
+ float atemp = parts[i].temp + (-MIN_TEMP);
+ parts[i].temp = restrict_flt((atemp*(1+(pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP);
+ }
+ }
+
+ return 0;
+}
diff --git a/src/elements/phot.c b/src/elements/phot.c
index 12f0b50..36a67bf 100644
--- a/src/elements/phot.c
+++ b/src/elements/phot.c
@@ -2,6 +2,66 @@
int update_PHOT(UPDATE_FUNC_ARGS) {
if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
+ int r, rt;
+ float rr, rrr;
+ for (nx=0; nx<1; nx++)
+ for (ny=0; ny<1; ny++)
+ if (x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || !r)
+ continue;
+ if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
+ {
+ parts[i].vx *= 0.995;
+ parts[i].vy *= 0.995;
+ }
+ }
+ for (nx=-1; nx<2; nx++)
+ for (ny=-1; ny<2; ny++)
+ if (x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || !r)
+ continue;
+ if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
+ parts[i].vy *= 0.90;
+ parts[r>>8].type = PT_PHOT;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ rr = (rand()%128+128)/127.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(rrr);
+ parts[r>>8].vy = rr*sinf(rrr);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ if ((r&0xFF)==PT_ISZS && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
+ parts[i].vy *= 0.90;
+ parts[r>>8].type = PT_PHOT;
+ rr = (rand()%228+128)/127.0f;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(rrr);
+ parts[r>>8].vy = rr*sinf(rrr);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ }
+
+ r = pmap[ny][nx];
+ rt = r&0xFF;
+ if (rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN) {
+
+ if (!parts[r>>8].ctype)
+ parts[r>>8].ctype = PT_PHOT;
+ }
+
// TODO
return 0;