From 32fe184351e7bc44fd8577739c14a0c422456dac Mon Sep 17 00:00:00 2001 From: mniip Date: Fri, 17 May 2013 17:30:44 +0400 Subject: [PATCH 01/10] sdl-dir scons parameter --- SConscript | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/SConscript b/SConscript index 1a5576fdd..d8c13a0e8 100755 --- a/SConscript +++ b/SConscript @@ -74,21 +74,21 @@ if GetOption("toolprefix"): #Check for headers and libraries if not GetOption("macosx"): conf = Configure(env) - - try: - env.ParseConfig('sdl-config --cflags') - env.ParseConfig('sdl-config --libs') - except: - if not conf.CheckLib("SDL"): - print "libSDL not found or not installed" + if(GetOption("sdl-dir")): + if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'): + print "sdl headers not found or not installed" raise SystemExit(1) - - if(GetOption("sdl-dir")): - if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'): - print "sdl headers not found or not installed" + else: + env.Append(CPPPATH=[GetOption("sdl-dir")]) + else: + try: + env.ParseConfig('sdl-config --cflags') + env.ParseConfig('sdl-config --libs') + except: + if not conf.CheckLib("SDL"): + print "libSDL not found or not installed" raise SystemExit(1) - else: - env.Append(CPPPATH=[GetOption("sdl-dir")]) + #Find correct lua include dir if not GetOption("nolua"): From 3a640fee3f20cbc82e2557271039d65c852a4817 Mon Sep 17 00:00:00 2001 From: mniip Date: Fri, 17 May 2013 18:32:41 +0400 Subject: [PATCH 02/10] some more compiling fixes --- src/PowderToySDL.cpp | 5 ++++- src/gui/game/GameView.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index f61a55e94..81c309308 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -667,6 +667,7 @@ void BlueScreen(char * detailMessage){ } } +#ifndef WIN void SigHandler(int signal) { switch(signal){ @@ -684,6 +685,7 @@ void SigHandler(int signal) break; } } +#endif int main(int argc, char * argv[]) { @@ -781,12 +783,13 @@ int main(int argc, char * argv[]) engine->SetFastQuit(Client::Ref().GetPrefBool("FastQuit", true)); #ifndef DEBUG +#ifndef WIN //Get ready to catch any dodgy errors signal(SIGSEGV, SigHandler); signal(SIGFPE, SigHandler); signal(SIGILL, SigHandler); signal(SIGABRT, SigHandler); - +#endif #endif GameController * gameController = NULL; diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 12414c71f..883435ec3 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1212,7 +1212,7 @@ void GameView::BeginStampSelection() { selectMode = SelectStamp; selectPoint1 = ui::Point(-1, -1); - buttonTip = "\x0F\xEF\xEF\x10\Click-and-drag to specify an area to create a stamp (right click = cancel)"; + buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to create a stamp (right click = cancel)"; buttonTipShow = 120; } @@ -1392,7 +1392,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { selectMode = SelectCopy; selectPoint1 = ui::Point(-1, -1); - buttonTip = "\x0F\xEF\xEF\x10\Click-and-drag to specify an area to copy (right click = cancel)"; + buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to copy (right click = cancel)"; buttonTipShow = 120; } break; @@ -1401,7 +1401,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { selectMode = SelectCut; selectPoint1 = ui::Point(-1, -1); - buttonTip = "\x0F\xEF\xEF\x10\Click-and-drag to specify an area to copy then cut (right click = cancel)"; + buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to copy then cut (right click = cancel)"; buttonTipShow = 120; } break; From 3979395e651a5b45fa1b96a19646b72e4a20e2f8 Mon Sep 17 00:00:00 2001 From: mniip Date: Sun, 19 May 2013 10:02:42 +0400 Subject: [PATCH 03/10] reenable sighandlers for winderp --- src/PowderToySDL.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 81c309308..94559b232 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -16,8 +16,8 @@ #include "graphics/Graphics.h" #if defined(LIN) #include "icon.h" -#include #endif +#include #ifndef WIN #include @@ -667,7 +667,6 @@ void BlueScreen(char * detailMessage){ } } -#ifndef WIN void SigHandler(int signal) { switch(signal){ @@ -685,7 +684,6 @@ void SigHandler(int signal) break; } } -#endif int main(int argc, char * argv[]) { @@ -783,13 +781,11 @@ int main(int argc, char * argv[]) engine->SetFastQuit(Client::Ref().GetPrefBool("FastQuit", true)); #ifndef DEBUG -#ifndef WIN //Get ready to catch any dodgy errors signal(SIGSEGV, SigHandler); signal(SIGFPE, SigHandler); signal(SIGILL, SigHandler); signal(SIGABRT, SigHandler); -#endif #endif GameController * gameController = NULL; From 826b966668fe37d836de91cf29a6db0d1afee1f4 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 20 May 2013 11:26:51 -0400 Subject: [PATCH 04/10] reduce rand() chances to 5x the old values in elements that were changed to 3x3 loop checks instead of 5x5. Also some other fixes I found when looking at what had been changed. --- src/simulation/elements/ANAR.cpp | 2 +- src/simulation/elements/BCOL.cpp | 78 +--------------------- src/simulation/elements/CBNW.cpp | 4 +- src/simulation/elements/CO2.cpp | 6 +- src/simulation/elements/COAL.cpp | 19 +++--- src/simulation/elements/DSTW.cpp | 14 ++-- src/simulation/elements/ICEI.cpp | 4 +- src/simulation/elements/PLNT.cpp | 8 +-- src/simulation/elements/PQRT.cpp | 111 +------------------------------ src/simulation/elements/QRTZ.cpp | 23 ++++--- src/simulation/elements/SLTW.cpp | 8 +-- src/simulation/elements/WATR.cpp | 12 ++-- src/simulation/elements/WTRV.cpp | 2 +- src/simulation/elements/YEST.cpp | 2 +- 14 files changed, 64 insertions(+), 229 deletions(-) diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index 5a5ea33bc..150c2ccef 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -60,7 +60,7 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_CFLM && !(rand()%7)) + if ((r&0xFF)==PT_CFLM && !(rand()%4)) { sim->part_change_type(i,x,y,PT_CFLM); parts[i].life = rand()%150+50; diff --git a/src/simulation/elements/BCOL.cpp b/src/simulation/elements/BCOL.cpp index 9c90ff3e9..3fb85af65 100644 --- a/src/simulation/elements/BCOL.cpp +++ b/src/simulation/elements/BCOL.cpp @@ -42,82 +42,8 @@ Element_BCOL::Element_BCOL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BCOL::update; - Graphics = &Element_BCOL::graphics; + Update = &Element_COAL::update; + Graphics = &Element_COAL::graphics; } -//#TPT-Directive ElementHeader Element_BCOL static int update(UPDATE_FUNC_ARGS) -int Element_BCOL::update(UPDATE_FUNC_ARGS) - { - int r, rx, ry, trade, temp; - if (parts[i].life<=0) { - sim->create_part(i, x, y, PT_FIRE); - return 1; - } else if (parts[i].life < 100) { - parts[i].life--; - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - /*if(100-parts[i].life > parts[i].tmp2) - parts[i].tmp2 = 100-parts[i].life; - if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (BOUNDS_CHECK && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion - { - int temp = parts[i].tmp2 - parts[r>>8].tmp2; - if(temp < 10) - continue; - if (temp ==1) - { - parts[r>>8].tmp2 ++; - parts[i].tmp2 --; - } - else if (temp>0) - { - parts[r>>8].tmp2 += temp/2; - parts[i].tmp2 -= temp/2; - } - } - } - }*/ - if(parts[i].temp > parts[i].tmp2) - parts[i].tmp2 = parts[i].temp; - return 0; -} - - -//#TPT-Directive ElementHeader Element_BCOL static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BCOL::graphics(GRAPHICS_FUNC_ARGS) - //Both COAL and Broken Coal -{ - *colr += (cpart->tmp2-295.15f)/3; - - if (*colr > 170) - *colr = 170; - if (*colr < *colg) - *colr = *colg; - - *colg = *colb = *colr; - - if((cpart->temp-295.15f) > 300.0f-200.0f) - { - float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); - int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); - - *colr += sin(frequency*q) * 226; - *colg += sin(frequency*q*4.55 +3.14) * 34; - *colb += sin(frequency*q*2.22 +3.14) * 64; - } - return 0; -} - - - Element_BCOL::~Element_BCOL() {} diff --git a/src/simulation/elements/CBNW.cpp b/src/simulation/elements/CBNW.cpp index 3f07730bd..ed01cf565 100644 --- a/src/simulation/elements/CBNW.cpp +++ b/src/simulation/elements/CBNW.cpp @@ -96,7 +96,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) //Start explode parts[i].tmp = rand()%25;//(rand()%100)+50; } - else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%13333)) + else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%6667)) { sim->part_change_type(i,x,y,PT_CO2); parts[i].ctype = 5; @@ -131,7 +131,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) } else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ sim->kill_part(r>>8); - if(1>(rand()%50)){ + if(!(rand()%50)){ sim->kill_part(i); return 1; } diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp index c3bb7c9a6..3e982b563 100644 --- a/src/simulation/elements/CO2.cpp +++ b/src/simulation/elements/CO2.cpp @@ -57,7 +57,7 @@ int Element_CO2::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) { - if (parts[i].ctype==5 && !(rand()%27)) + if (parts[i].ctype==5 && !(rand()%2000)) { if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0) parts[i].ctype = 0; @@ -66,12 +66,12 @@ int Element_CO2::update(UPDATE_FUNC_ARGS) } if ((r&0xFF)==PT_FIRE){ sim->kill_part(r>>8); - if(!(rand()%50)){ + if(!(rand()%30)){ sim->kill_part(i); return 1; } } - else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%83)) + else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%50)) { sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW); if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet diff --git a/src/simulation/elements/COAL.cpp b/src/simulation/elements/COAL.cpp index 318616797..b2cc89cb7 100644 --- a/src/simulation/elements/COAL.cpp +++ b/src/simulation/elements/COAL.cpp @@ -49,7 +49,7 @@ Element_COAL::Element_COAL() //#TPT-Directive ElementHeader Element_COAL static int update(UPDATE_FUNC_ARGS) int Element_COAL::update(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, temp; + int r, rx, ry, trade, temp, t = parts[i].type; if (parts[i].life<=0) { sim->create_part(i, x, y, PT_FIRE); return 1; @@ -57,13 +57,16 @@ int Element_COAL::update(UPDATE_FUNC_ARGS) parts[i].life--; sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); } - if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if (parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if (parts[i].tmp<=0) { - sim->create_part(i, x, y, PT_BCOL); - return 1; + if (t == PT_COAL) + { + if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if (parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if (parts[i].tmp<=0) { + sim->create_part(i, x, y, PT_BCOL); + return 1; + } } /*if(100-parts[i].life > parts[i].tmp2) parts[i].tmp2 = 100-parts[i].life; diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp index d077f2547..d6b879fa2 100644 --- a/src/simulation/elements/DSTW.cpp +++ b/src/simulation/elements/DSTW.cpp @@ -58,7 +58,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) switch (r&0xFF) { case PT_SALT: - if (!(rand()%83)) + if (!(rand()%50)) { sim->part_change_type(i,x,y,PT_SLTW); // on average, convert 3 DSTW to SLTW before SALT turns into SLTW @@ -67,20 +67,24 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) } break; case PT_SLTW: - if (!(rand()%3333)) + if (!(rand()%100)) + { + sim->part_change_type(i,x,y,PT_WATR); + } + if (!(rand()%2000)) { sim->part_change_type(i,x,y,PT_SLTW); break; } case PT_WATR: - if (!(rand()%166)) + if (!(rand()%100)) { sim->part_change_type(i,x,y,PT_WATR); } break; case PT_RBDM: case PT_LRBD: - if ((sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%166)) + if ((sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%100)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; @@ -88,7 +92,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) break; case PT_FIRE: sim->kill_part(r>>8); - if(!(rand()%50)){ + if(!(rand()%30)){ sim->kill_part(i); return 1; } diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp index 7edfd2230..a9c87b65b 100644 --- a/src/simulation/elements/ICEI.cpp +++ b/src/simulation/elements/ICEI.cpp @@ -63,14 +63,14 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS) continue; if ((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) { - if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%333)) + if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200)) { sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); return 0; } } - else if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && !(rand()%333)) + else if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && !(rand()%200)) sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); } return 0; diff --git a/src/simulation/elements/PLNT.cpp b/src/simulation/elements/PLNT.cpp index da03a4a52..61218d582 100644 --- a/src/simulation/elements/PLNT.cpp +++ b/src/simulation/elements/PLNT.cpp @@ -58,7 +58,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS) switch (r&0xFF) { case PT_WATR: - if (!(rand()%83)) + if (!(rand()%50)) { np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT); if (np<0) continue; @@ -66,7 +66,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS) } break; case PT_LAVA: - if (!(rand()%83)) + if (!(rand()%50)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; @@ -74,14 +74,14 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS) break; case PT_SMKE: case PT_CO2: - if (!(rand()%83)) + if (!(rand()%50)) { sim->kill_part(r>>8); parts[i].life = rand()%60 + 60; } break; case PT_WOOD: - if (surround_space && !(rand()%7) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1)) + if (surround_space && !(rand()%4) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1)) { int nnx = rand()%3 -1; int nny = rand()%3 -1; diff --git a/src/simulation/elements/PQRT.cpp b/src/simulation/elements/PQRT.cpp index 665f5a44f..5510c7ae1 100644 --- a/src/simulation/elements/PQRT.cpp +++ b/src/simulation/elements/PQRT.cpp @@ -26,7 +26,7 @@ Element_PQRT::Element_PQRT() Weight = 90; - Temperature = R_TEMP+0.0f +273.15f; + Temperature = R_TEMP+273.15f; HeatConduct = 3; Description = "Powdered quartz, broken form of QRTZ."; @@ -42,113 +42,8 @@ Element_PQRT::Element_PQRT() HighTemperature = 2573.15f; HighTemperatureTransition = PT_LAVA; - Update = &Element_PQRT::update; - Graphics = &Element_PQRT::graphics; + Update = &Element_QRTZ::update; + Graphics = &Element_QRTZ::graphics; } -//#TPT-Directive ElementHeader Element_PQRT static int update(UPDATE_FUNC_ARGS) -int Element_PQRT::update(UPDATE_FUNC_ARGS) -{ - int r, tmp, trade, rx, ry, np; - // absorb SLTW - if (parts[i].ctype!=-1) - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (BOUNDS_CHECK && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - else if ((r&0xFF)==PT_SLTW && !(rand()%833)) - { - sim->kill_part(r>>8); - parts[i].ctype ++; - } - } - // grow and diffuse - if (parts[i].ctype>0) - { - bool stopgrow=false; - int rnd, sry, srx; - for ( trade = 0; trade<9; trade ++) - { - rnd = rand()%0x3FF; - rx = (rnd%5)-2; - srx = (rnd%3)-1; - rnd = rnd>>3; - ry = (rnd%5)-2; - sry = (rnd%3)-1; - if (BOUNDS_CHECK && (rx || ry)) - { - if (!stopgrow)//try to grow - { - if (!pmap[y+sry][x+srx] && parts[i].ctype!=0) - { - np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ); - if (np>-1) - { - parts[np].tmp = parts[i].tmp; - parts[i].ctype--; - if (rand()%2) - { - parts[np].ctype=-1;//dead qrtz - } - else if (!parts[i].ctype && !(rand()%15)) - { - parts[i].ctype=-1; - } - stopgrow=true; - } - } - } - //diffusion - r = pmap[y+ry][x+rx]; - if (!r) - continue; - else if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 ) - { - tmp = parts[i].ctype - parts[r>>8].ctype; - if (tmp ==1) - { - parts[r>>8].ctype ++; - parts[i].ctype --; - break; - } - if (tmp>0) - { - parts[r>>8].ctype += tmp/2; - parts[i].ctype -= tmp/2; - break; - } - } - } - } - } - return 0; -} - - -//#TPT-Directive ElementHeader Element_PQRT static int graphics(GRAPHICS_FUNC_ARGS) -int Element_PQRT::graphics(GRAPHICS_FUNC_ARGS) - //QRTZ and PQRT -{ - int t = cpart->type, z = cpart->tmp - 5;//speckles! - /*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz - { - float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); - *colr += sin(frequency*q) * 226 + (z * 16); - *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); - *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); - } - else*/ - { - *colr += z * 16; - *colg += z * 16; - *colb += z * 16; - } - return 0; -} - - Element_PQRT::~Element_PQRT() {} diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp index a9510b12c..5eec6d679 100644 --- a/src/simulation/elements/QRTZ.cpp +++ b/src/simulation/elements/QRTZ.cpp @@ -26,7 +26,7 @@ Element_QRTZ::Element_QRTZ() Weight = 100; - Temperature = R_TEMP+0.0f +273.15f; + Temperature = R_TEMP+273.15f; HeatConduct = 3; Description = "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures."; @@ -49,23 +49,26 @@ Element_QRTZ::Element_QRTZ() //#TPT-Directive ElementHeader Element_QRTZ static int update(UPDATE_FUNC_ARGS) int Element_QRTZ::update(UPDATE_FUNC_ARGS) { - int r, tmp, trade, rx, ry, np; - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = sim->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)) + int r, tmp, trade, rx, ry, np, t = parts[i].type; + if (t == PT_QRTZ) { - sim->part_change_type(i,x,y,PT_PQRT); + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = sim->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)) + { + sim->part_change_type(i,x,y,PT_PQRT); + } } // absorb SLTW if (parts[i].ctype!=-1) - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; if (!r) continue; - else if ((r&0xFF)==PT_SLTW && !(rand()%2500)) + else if ((r&0xFF)==PT_SLTW && !(rand()%500)) { sim->kill_part(r>>8); parts[i].ctype ++; @@ -111,7 +114,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 ) + else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0) { tmp = parts[i].ctype - parts[r>>8].ctype; if (tmp ==1) diff --git a/src/simulation/elements/SLTW.cpp b/src/simulation/elements/SLTW.cpp index 7c3828621..75757509b 100644 --- a/src/simulation/elements/SLTW.cpp +++ b/src/simulation/elements/SLTW.cpp @@ -58,16 +58,16 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS) switch (r&0xFF) { case PT_SALT: - if (!(rand()%3333)) + if (!(rand()%2000)) sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); break; case PT_PLNT: - if (!(rand()%66)) + if (!(rand()%40)) sim->kill_part(r>>8); break; case PT_RBDM: case PT_LRBD: - if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%166)) + if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; @@ -78,7 +78,7 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS) if (parts[r>>8].ctype!=PT_WATR) { sim->kill_part(r>>8); - if(!(rand()%150)){ + if(!(rand()%30)){ sim->kill_part(i); return 1; } diff --git a/src/simulation/elements/WATR.cpp b/src/simulation/elements/WATR.cpp index ab5b81452..17289e0b4 100644 --- a/src/simulation/elements/WATR.cpp +++ b/src/simulation/elements/WATR.cpp @@ -57,14 +57,14 @@ int Element_WATR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SALT && !(rand()%83)) + if ((r&0xFF)==PT_SALT && !(rand()%50)) { sim->part_change_type(i,x,y,PT_SLTW); // on average, convert 3 WATR to SLTW before SALT turns into SLTW if (!(rand()%3)) sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); } - else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%166)) + else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; @@ -72,12 +72,16 @@ int Element_WATR::update(UPDATE_FUNC_ARGS) } else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ sim->kill_part(r>>8); - if(!(rand()%50)){ + if(!(rand()%30)){ sim->kill_part(i); return 1; } } - /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular + else if ((r&0xFF)==PT_SLTW && !(rand()%2000)) + { + sim->part_change_type(i,x,y,PT_SLTW); + } + /*if ((r&0xFF)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular { part_change_type(i,x,y,PT_PSTE); sim.kill_part(r>>8); diff --git a/src/simulation/elements/WTRV.cpp b/src/simulation/elements/WTRV.cpp index b49ef67ba..73b0808ca 100644 --- a/src/simulation/elements/WTRV.cpp +++ b/src/simulation/elements/WTRV.cpp @@ -57,7 +57,7 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%166)) + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%100)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; diff --git a/src/simulation/elements/YEST.cpp b/src/simulation/elements/YEST.cpp index 0d82eeb4c..3987cd6c5 100644 --- a/src/simulation/elements/YEST.cpp +++ b/src/simulation/elements/YEST.cpp @@ -57,7 +57,7 @@ int Element_YEST::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_DYST && !(rand()%10) && !sim->legacy_enable) + if ((r&0xFF)==PT_DYST && !(rand()%6) && !sim->legacy_enable) { sim->part_change_type(i,x,y,PT_DYST); } From 6fec955f41468025eb4fad028925f4b09d8647d3 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 20 May 2013 16:50:49 -0400 Subject: [PATCH 05/10] TPT: Stop STKM being able to jump on the bottom of the screen 509b84b4f --- src/simulation/elements/STKM.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 7767266c9..67d8cdfd4 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -210,7 +210,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { bool moved = false; if (dl>dr) { - if (!sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) + if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) { playerp->accs[2] = -3*gvy-3*gvx; playerp->accs[3] = 3*gvx-3*gvy; @@ -221,7 +221,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { } else { - if (!sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) + if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) { playerp->accs[6] = -3*gvy-3*gvx; playerp->accs[7] = 3*gvx-3*gvy; @@ -260,7 +260,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { bool moved = false; if (dleval_move(t, playerp->legs[4], playerp->legs[5], NULL)) + if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) { playerp->accs[2] = 3*gvy-3*gvx; playerp->accs[3] = -3*gvx-3*gvy; @@ -271,7 +271,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { } else { - if (!sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) + if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) { playerp->accs[6] = 3*gvy-3*gvx; playerp->accs[7] = -3*gvx-3*gvy; @@ -337,7 +337,8 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { } } } - else if (!sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL) || !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) + else if ((INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) || + (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))) { parts[i].vx -= 4*gvx; parts[i].vy -= 4*gvy; From e1d85858710b603d5f024c5c4ddc328f4f43f628 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Tue, 21 May 2013 17:54:37 -0300 Subject: [PATCH 06/10] Jacob can't into switches --- src/simulation/elements/DSTW.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp index d6b879fa2..b8b412461 100644 --- a/src/simulation/elements/DSTW.cpp +++ b/src/simulation/elements/DSTW.cpp @@ -67,10 +67,6 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) } break; case PT_SLTW: - if (!(rand()%100)) - { - sim->part_change_type(i,x,y,PT_WATR); - } if (!(rand()%2000)) { sim->part_change_type(i,x,y,PT_SLTW); From 2735a80d280a3f968885e815d5e0892b7fdd4a69 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Tue, 21 May 2013 18:19:05 -0400 Subject: [PATCH 07/10] Fix STKM spawns, fix cases. --- src/simulation/Simulation.cpp | 142 ++++++++++++++++------------------ 1 file changed, 65 insertions(+), 77 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 4c1a54323..77cb586b6 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2915,6 +2915,7 @@ int Simulation::create_part(int p, int x, int y, int tv) } else { + parts[i].type=0; return -1; } create_part(-3,x,y,PT_SPAWN); @@ -2930,6 +2931,7 @@ int Simulation::create_part(int p, int x, int y, int tv) } else { + parts[i].type=0; return -1; } create_part(-3,x,y,PT_SPAWN2); @@ -2943,84 +2945,70 @@ int Simulation::create_part(int p, int x, int y, int tv) case PT_TSNS: parts[i].tmp2 = 2; break; + case PT_FIGH:{ + unsigned char fcount = 0; + while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++; + if (fcount < 100 && fighters[fcount].spwn==0) + { + parts[i].life = 100; + parts[i].tmp = fcount; + Element_STKM::STKM_init_legs(this, &fighters[fcount], i); + fighters[fcount].spwn = 1; + fighters[fcount].elem = PT_DUST; + fighters[fcount].rocketBoots = false; + fighcount++; + return i; + } + parts[i].type=0; + return -1;} + case PT_PHOT:{ + float a = (rand()%8) * 0.78540f; + parts[i].life = 680; + parts[i].ctype = 0x3FFFFFFF; + parts[i].vx = 3.0f*cosf(a); + parts[i].vy = 3.0f*sinf(a); + break;} + case PT_ELEC:{ + float a = (rand()%360)*3.14159f/180.0f; + parts[i].life = 680; + parts[i].vx = 2.0f*cosf(a); + parts[i].vy = 2.0f*sinf(a); + break;} + case PT_NEUT:{ + float r = (rand()%128+128)/127.0f; + float a = (rand()%360)*3.14159f/180.0f; + parts[i].life = rand()%480+480; + parts[i].vx = r*cosf(a); + parts[i].vy = r*sinf(a); + break;} + case PT_TRON:{ + int randhue = rand()%360; + int randomdir = rand()%4; + parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction + parts[i].tmp2 = 4;//tail + parts[i].life = 5; + break;} + case PT_LIGH:{ + float gx, gy, gsize; + if (p!=-2) + { + parts[i].life=30; + parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting + } + GetGravityField(x, y, 1.0f, 1.0f, gx, gy); + gsize = gx*gx+gy*gy; + if (gsize<0.0016f) + { + float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) + gsize = sqrtf(gsize); + // randomness in weak gravity fields (more randomness with weaker fields) + gx += cosf(angle)*(0.04f-gsize); + gy += sinf(angle)*(0.04f-gsize); + } + parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360; + parts[i].tmp2 = 4; + break;} default: - if (t==PT_FIGH) - { - unsigned char fcount = 0; - while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++; - if (fcount < 100 && fighters[fcount].spwn==0) - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_FIGH; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 100; - parts[i].ctype = 0; - parts[i].tmp = fcount; - parts[i].temp = elements[t].Temperature; - Element_STKM::STKM_init_legs(this, &fighters[fcount], i); - fighters[fcount].spwn = 1; - fighters[fcount].elem = PT_DUST; - fighters[fcount].rocketBoots = false; - fighcount++; - - return i; - } - return -1; - } - if (t==PT_PHOT) - { - float a = (rand()%8) * 0.78540f; - parts[i].life = 680; - parts[i].ctype = 0x3FFFFFFF; - parts[i].vx = 3.0f*cosf(a); - parts[i].vy = 3.0f*sinf(a); - } - if (t==PT_ELEC) - { - float a = (rand()%360)*3.14159f/180.0f; - parts[i].life = 680; - parts[i].vx = 2.0f*cosf(a); - parts[i].vy = 2.0f*sinf(a); - } - if (t==PT_NEUT) - { - float r = (rand()%128+128)/127.0f; - float a = (rand()%360)*3.14159f/180.0f; - parts[i].life = rand()%480+480; - parts[i].vx = r*cosf(a); - parts[i].vy = r*sinf(a); - } - if (t==PT_TRON) - { - int randhue = rand()%360; - int randomdir = rand()%4; - parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction - parts[i].tmp2 = 4;//tail - parts[i].life = 5; - } - if (t==PT_LIGH) - { - float gx, gy, gsize; - if (p!=-2) - { - parts[i].life=30; - parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting - } - GetGravityField(x, y, 1.0f, 1.0f, gx, gy); - gsize = gx*gx+gy*gy; - if (gsize<0.0016f) - { - float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) - gsize = sqrtf(gsize); - // randomness in weak gravity fields (more randomness with weaker fields) - gx += cosf(angle)*(0.04f-gsize); - gy += sinf(angle)*(0.04f-gsize); - } - parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360; - parts[i].tmp2 = 4; - } break; } //and finally set the pmap/photon maps to the newly created particle From 4e9ee3a3a36f94738036b2628a44a41328a17646 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Tue, 21 May 2013 23:05:27 -0400 Subject: [PATCH 08/10] Fix incorrect FPS counter, need to count blit too. 2x scale gets a massive *real* fps boost, the fps lied before. --- src/PowderToySDL.cpp | 45 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 94559b232..44971793a 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -495,30 +495,7 @@ void EngineProcess() frameStart = SDL_GetTicks(); engine->Tick(); engine->Draw(); - frameTime = SDL_GetTicks() - frameStart; - frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime); - if(ui::Engine::Ref().FpsLimit > 2.0f) - { - float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit); - if(targetFrameTime - frameTimeAvg > 0) - { - SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f); - frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg); - } - } - - correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime); - fps = 1000.0f/correctedFrameTimeAvg; - engine->SetFps(fps); - - if(frameStart-lastTick>250) - { - //Run client tick every second - lastTick = frameStart; - Client::Ref().Tick(); - } - if(scale != engine->Scale || fullscreen != engine->Fullscreen) { sdl_scrn = SDLSetScreen(engine->Scale, engine->Fullscreen); @@ -533,6 +510,28 @@ void EngineProcess() else blit(engine->g->vid); #endif + + frameTime = SDL_GetTicks() - frameStart; + frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime); + if(ui::Engine::Ref().FpsLimit > 2.0f) + { + float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit); + if(targetFrameTime - frameTimeAvg > 0) + { + SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f); + frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg); + } + } + correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime); + fps = 1000.0f/correctedFrameTimeAvg; + engine->SetFps(fps); + + if(frameStart-lastTick>250) + { + //Run client tick every second + lastTick = frameStart; + Client::Ref().Tick(); + } } #ifdef DEBUG std::cout << "Breaking out of EngineProcess" << std::endl; From 1588226120a03fc6dd79c2a7f950693b59b4adfe Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 21 May 2013 23:23:57 -0400 Subject: [PATCH 09/10] move frameStart to right after the fps is limited (counts everything, including mouse/key functions now) --- src/PowderToySDL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 44971793a..618fdec88 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -377,7 +377,7 @@ ui::Engine * engine = NULL; float currentWidth, currentHeight; void EngineProcess() { - int frameStart; + int frameStart = SDL_GetTicks(); float frameTime; float frameTimeAvg = 0.0f, correctedFrameTimeAvg = 0.0f; SDL_Event event; @@ -492,7 +492,6 @@ void EngineProcess() } if(engine->Broken()) { engine->UnBreak(); break; } - frameStart = SDL_GetTicks(); engine->Tick(); engine->Draw(); @@ -525,6 +524,7 @@ void EngineProcess() correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime); fps = 1000.0f/correctedFrameTimeAvg; engine->SetFps(fps); + frameStart = SDL_GetTicks(); if(frameStart-lastTick>250) { From 41e369e68eac7b05f8cda312f9668942dc688aa7 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 22 May 2013 18:21:17 -0400 Subject: [PATCH 10/10] mniip: add back missing easter egg --- src/cat/TPTScriptInterface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp index 43bb67b8d..34d1927c0 100644 --- a/src/cat/TPTScriptInterface.cpp +++ b/src/cat/TPTScriptInterface.cpp @@ -261,6 +261,9 @@ AnyType TPTScriptInterface::tptS_set(std::deque * words) newValue = GetParticleType(((StringType)value).Value()); if (newValue < 0 || newValue >= PT_NUM) { + // TODO: add element CAKE to invalidate this + if (!strcasecmp(((StringType)value).Value().c_str(),"cake")) + throw GeneralException("Cake is a lie, not an element"); throw GeneralException("Invalid element"); } }