diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-24 18:53:50 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-24 18:53:50 (GMT) |
| commit | 8196d2a645d386b5c97134c446e959e5e50a345b (patch) | |
| tree | 33e729715a6122fa5b8dac6f9abf7b784bfbfbc3 /src/elements | |
| parent | 5a117c2d27f513942d7621980a79d357af122ba4 (diff) | |
| parent | 1fb778724329782bb5616da032742dce4dbea131 (diff) | |
| download | powder-8196d2a645d386b5c97134c446e959e5e50a345b.zip powder-8196d2a645d386b5c97134c446e959e5e50a345b.tar.gz | |
Merge pull request #66 from jacob1/Modstuff
Code structure improvements for graphics/drawing, improvements to prevent accidental infinite loops in Lua, Fixes for fusion, improvements for VOID types. And other minor improvements
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/O2.c | 59 | ||||
| -rw-r--r-- | src/elements/co2.c | 5 | ||||
| -rw-r--r-- | src/elements/elec.c | 2 | ||||
| -rw-r--r-- | src/elements/gel.c | 5 | ||||
| -rw-r--r-- | src/elements/h2.c | 12 | ||||
| -rw-r--r-- | src/elements/nble.c | 10 | ||||
| -rw-r--r-- | src/elements/pyro.c | 2 | ||||
| -rw-r--r-- | src/elements/sprk.c | 4 |
8 files changed, 59 insertions, 40 deletions
diff --git a/src/elements/O2.c b/src/elements/O2.c index 8ca0f46..5152478 100644 --- a/src/elements/O2.c +++ b/src/elements/O2.c @@ -18,28 +18,47 @@ 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) + if (parts[i].temp < 9273.15) + { + 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)) { - create_part(i,x,y,PT_FIRE); - parts[i].temp+=(rand()/(RAND_MAX/100)); - parts[i].tmp |= 2; + 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) + { + create_part(i,x,y,PT_FIRE); + parts[i].temp+=(rand()/(RAND_MAX/100)); + parts[i].tmp |= 2; + } + } + } + else if (parts[i].temp > 9973.15 && pv[y/CELL][x/CELL] > 250.0f && abs(gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) + abs(gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) > 20) + { + if (rand()%5 < 1) + { + int j; + part_change_type(i,x,y,PT_PLSM); + parts[i].life = rand()%150+50; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_BRMT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = rand()%25+50; } - } + parts[i].temp += 15000; + pv[y/CELL][x/CELL] += 300; + } + } return 0; } diff --git a/src/elements/co2.c b/src/elements/co2.c index 77a92b0..acdbc99 100644 --- a/src/elements/co2.c +++ b/src/elements/co2.c @@ -49,12 +49,13 @@ int update_CO2(UPDATE_FUNC_ARGS) { int j; kill_part(i); j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; + if (!(rand()%50)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; } j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_O2); if (j != -1) parts[j].temp = 15000; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = rand()%100+450; } + if (rand()%1000 < 1) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = 3; } } parts[i].temp += 15000; pv[y/CELL][x/CELL] += 100; + return 1; } } return 0; diff --git a/src/elements/elec.c b/src/elements/elec.c index 667499f..919ee87 100644 --- a/src/elements/elec.c +++ b/src/elements/elec.c @@ -94,7 +94,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) { kill_part(i); return 1; } - if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_H2||parts[i].tmp!=1)) + if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_NBLE||parts[i].temp<2273.15)) { create_part(-1, x+rx, y+ry, PT_SPRK); kill_part(i); diff --git a/src/elements/gel.c b/src/elements/gel.c index e558342..c64591a 100644 --- a/src/elements/gel.c +++ b/src/elements/gel.c @@ -17,6 +17,8 @@ int update_GEL(UPDATE_FUNC_ARGS) { int r, rx, ry; + float dx, dy; + char gel; if (parts[i].tmp>100) parts[i].tmp = 100; if (parts[i].tmp<0) parts[i].tmp = 0; for (rx=-2; rx<3; rx++) @@ -41,7 +43,7 @@ int update_GEL(UPDATE_FUNC_ARGS) { parts[i].tmp++; } - char gel = 0; + gel = 0; if ((r&0xFF)==PT_GEL) gel = 1; @@ -58,7 +60,6 @@ int update_GEL(UPDATE_FUNC_ARGS) { parts[i].tmp--; } - float dx, dy; dx = parts[i].x - parts[r>>8].x; dy = parts[i].y - parts[r>>8].y; diff --git a/src/elements/h2.c b/src/elements/h2.c index 212e56e..86c3be3 100644 --- a/src/elements/h2.c +++ b/src/elements/h2.c @@ -35,7 +35,7 @@ int update_H2(UPDATE_FUNC_ARGS) } if (parts[r>>8].temp > 2273.15)// && pv[y/CELL][x/CELL] > 50.0f) continue; - if (parts[i].tmp != 1) + if (parts[i].temp < 2273.15) { if (rt==PT_FIRE) { @@ -54,20 +54,18 @@ int update_H2(UPDATE_FUNC_ARGS) } if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f) { - parts[i].tmp = 1; if (rand()%5 < 1) { int j; float temp = parts[i].temp; part_change_type(i,x,y,PT_PLSM); parts[i].life = rand()%150+50; - create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); - create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; + if (!(rand()%10)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; } j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFFFF00; parts[j].temp = temp; } - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NBLE); - if (j != -1) { parts[j].tmp = 1; parts[j].temp = temp; } + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NBLE); if (j != -1) parts[j].temp = temp; if (rand()%2) { @@ -75,7 +73,7 @@ int update_H2(UPDATE_FUNC_ARGS) if (j != -1) { parts[j].tmp = 1; parts[j].temp = temp; } } - parts[i].temp += 6000; + parts[i].temp += 750+rand()%500; pv[y/CELL][x/CELL] += 30; } } diff --git a/src/elements/nble.c b/src/elements/nble.c index bca0291..0c118ed 100644 --- a/src/elements/nble.c +++ b/src/elements/nble.c @@ -25,16 +25,16 @@ int update_NBLE(UPDATE_FUNC_ARGS) float temp = parts[i].temp; part_change_type(i,x,y,PT_PLSM); parts[i].life = rand()%150+50; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; + if (!(rand()%25)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; } j = 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 = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2); - if (j != -1) parts[j].temp = temp - 1000; + if (j != -1) parts[j].temp = temp; - parts[i].temp += 10000; - pv[y/CELL][x/CELL] += 30; + parts[i].temp += 1750+rand()%500; + pv[y/CELL][x/CELL] += 50; } } return 0; diff --git a/src/elements/pyro.c b/src/elements/pyro.c index 854e62d..c09dd63 100644 --- a/src/elements/pyro.c +++ b/src/elements/pyro.c @@ -61,7 +61,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) { (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) && (t!=PT_PHOT || rt!=PT_INSL) && (rt!=PT_SPNG || parts[r>>8].life==0) && - (rt!=PT_H2 || (parts[r>>8].temp < 2273.15 && pv[y/CELL][x/CELL] < 50.0f)) && + (rt!=PT_H2 || parts[r>>8].temp < 2273.15) && ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) { part_change_type(r>>8,x+rx,y+ry,PT_FIRE); diff --git a/src/elements/sprk.c b/src/elements/sprk.c index d7ee0f0..f1c8c8e 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -59,7 +59,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { parts[nearp].ctype = PT_ETRD; } } - else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].tmp!=1) + else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].temp<5273.15) { parts[i].life = rand()%150+50; part_change_type(i,x,y,PT_PLSM); @@ -194,7 +194,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { conduct_sprk = 0; if (rt==PT_INST&&ct!=PT_PSCN) conduct_sprk = 0; - if (rt == PT_NBLE && parts[r>>8].tmp == 1) + if (rt == PT_NBLE && parts[r>>8].temp > 5273.15) conduct_sprk = 0; if (conduct_sprk) { |
