Water level equalization test! In options menu, or tpt.watertest() .
This commit is contained in:
parent
c3d7f694f2
commit
a73fc9db06
@ -162,6 +162,7 @@ extern int decorations_enable;
|
||||
extern int hud_enable;
|
||||
extern int debug_flags;
|
||||
int limitFPS;
|
||||
int water_equal_test;
|
||||
|
||||
extern int active_menu;
|
||||
|
||||
|
@ -34,6 +34,7 @@ int luatpt_drawtext(lua_State* l);
|
||||
int luatpt_create(lua_State* l);
|
||||
int luatpt_setpause(lua_State* l);
|
||||
int luatpt_togglepause(lua_State* l);
|
||||
int luatpt_togglewater(lua_State* l);
|
||||
int luatpt_setconsole(lua_State* l);
|
||||
int luatpt_log(lua_State* l);
|
||||
int luatpt_set_pressure(lua_State* l);
|
||||
|
@ -5818,7 +5818,7 @@ openfin:
|
||||
void simulation_ui(pixel * vid_buf)
|
||||
{
|
||||
int xsize = 300;
|
||||
int ysize = 164;
|
||||
int ysize = 192;
|
||||
int x0=(XRES-xsize)/2,y0=(YRES-MENUSIZE-ysize)/2,b=1,bq,mx,my;
|
||||
int new_scale, new_kiosk;
|
||||
ui_checkbox cb;
|
||||
@ -5826,6 +5826,7 @@ void simulation_ui(pixel * vid_buf)
|
||||
ui_checkbox cb3;
|
||||
ui_checkbox cb4;
|
||||
ui_checkbox cb5;
|
||||
ui_checkbox cb6;
|
||||
|
||||
cb.x = x0+xsize-16; //Heat simulation
|
||||
cb.y = y0+23;
|
||||
@ -5838,12 +5839,12 @@ void simulation_ui(pixel * vid_buf)
|
||||
cb2.checked = ngrav_enable;
|
||||
|
||||
cb3.x = x0+xsize-16; //Large window
|
||||
cb3.y = y0+113;
|
||||
cb3.y = y0+143;
|
||||
cb3.focus = 0;
|
||||
cb3.checked = (sdl_scale==2)?1:0;
|
||||
|
||||
cb4.x = x0+xsize-16; //Fullscreen
|
||||
cb4.y = y0+129;
|
||||
cb4.y = y0+157;
|
||||
cb4.focus = 0;
|
||||
cb4.checked = (kiosk_enable==1)?1:0;
|
||||
|
||||
@ -5852,6 +5853,11 @@ void simulation_ui(pixel * vid_buf)
|
||||
cb5.focus = 0;
|
||||
cb5.checked = aheat_enable;
|
||||
|
||||
cb6.x = x0+xsize-16; //Ambient heat
|
||||
cb6.y = y0+107;
|
||||
cb6.focus = 0;
|
||||
cb6.checked = water_equal_test;
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
@ -5881,14 +5887,18 @@ void simulation_ui(pixel * vid_buf)
|
||||
drawtext(vid_buf, x0+8, y0+82, "Newtonian gravity", 255, 255, 255, 255);
|
||||
drawtext(vid_buf, x0+12+textwidth("Newtonian gravity"), y0+82, "Introduced in version 48.", 255, 255, 255, 180);
|
||||
drawtext(vid_buf, x0+12, y0+96, "May also cause slow performance on older computers", 255, 255, 255, 120);
|
||||
|
||||
drawtext(vid_buf, x0+8, y0+110, "Water Equalization Test", 255, 255, 255, 255);
|
||||
drawtext(vid_buf, x0+12+textwidth("Water Equalization Test"), y0+110, "Introduced in version 61.", 255, 255, 255, 180);
|
||||
drawtext(vid_buf, x0+12, y0+124, "May lag with lots of water.", 255, 255, 255, 120);
|
||||
|
||||
draw_line(vid_buf, x0, y0+110, x0+xsize, y0+110, 150, 150, 150, XRES+BARSIZE);
|
||||
draw_line(vid_buf, x0, y0+138, x0+xsize, y0+138, 150, 150, 150, XRES+BARSIZE);
|
||||
|
||||
drawtext(vid_buf, x0+8, y0+116, "Large window", 255, 255, 255, 255);
|
||||
drawtext(vid_buf, x0+12+textwidth("Large window"), y0+116, "Double window size for small screens", 255, 255, 255, 180);
|
||||
drawtext(vid_buf, x0+8, y0+144, "Large window", 255, 255, 255, 255);
|
||||
drawtext(vid_buf, x0+12+textwidth("Large window"), y0+144, "Double window size for small screens", 255, 255, 255, 180);
|
||||
|
||||
drawtext(vid_buf, x0+8, y0+132, "Fullscreen", 255, 255, 255, 255);
|
||||
drawtext(vid_buf, x0+12+textwidth("Fullscreen"), y0+132, "Fill the entire screen", 255, 255, 255, 180);
|
||||
drawtext(vid_buf, x0+8, y0+158, "Fullscreen", 255, 255, 255, 255);
|
||||
drawtext(vid_buf, x0+12+textwidth("Fullscreen"), y0+158, "Fill the entire screen", 255, 255, 255, 180);
|
||||
|
||||
//TODO: Options for Air and Normal gravity
|
||||
//Maybe save/load defaults too.
|
||||
@ -5901,12 +5911,14 @@ void simulation_ui(pixel * vid_buf)
|
||||
ui_checkbox_draw(vid_buf, &cb3);
|
||||
ui_checkbox_draw(vid_buf, &cb4);
|
||||
ui_checkbox_draw(vid_buf, &cb5);
|
||||
ui_checkbox_draw(vid_buf, &cb6);
|
||||
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
|
||||
ui_checkbox_process(mx, my, b, bq, &cb);
|
||||
ui_checkbox_process(mx, my, b, bq, &cb2);
|
||||
ui_checkbox_process(mx, my, b, bq, &cb3);
|
||||
ui_checkbox_process(mx, my, b, bq, &cb4);
|
||||
ui_checkbox_process(mx, my, b, bq, &cb5);
|
||||
ui_checkbox_process(mx, my, b, bq, &cb6);
|
||||
|
||||
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
|
||||
break;
|
||||
@ -5917,6 +5929,7 @@ void simulation_ui(pixel * vid_buf)
|
||||
break;
|
||||
}
|
||||
|
||||
water_equal_test = cb6.checked;
|
||||
legacy_enable = !cb.checked;
|
||||
aheat_enable = cb5.checked;
|
||||
new_scale = (cb3.checked)?2:1;
|
||||
|
61
src/powder.c
61
src/powder.c
@ -2175,6 +2175,11 @@ killed:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (water_equal_test && ptypes[t].falldown == 2 && 1>= rand()%400)//checking stagnant is cool, but then it doesn't update when you change it later.
|
||||
{
|
||||
if (!flood_water(x,y,i,y, parts[i].tmp2))
|
||||
goto movedone;
|
||||
}
|
||||
// liquids and powders
|
||||
if (!do_move(i, x, y, fin_xf, fin_yf))
|
||||
{
|
||||
@ -2640,6 +2645,62 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int flood_water(int x, int y, int i, int originaly, int check)
|
||||
{
|
||||
int x1 = 0,x2 = 0;
|
||||
// go left as far as possible
|
||||
x1 = x2 = x;
|
||||
if (!pmap[y][x])
|
||||
return 1;
|
||||
|
||||
while (x1>=CELL)
|
||||
{
|
||||
if ((ptypes[(pmap[y][x1-1]&0xFF)].falldown)!=2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
x1--;
|
||||
}
|
||||
while (x2<XRES-CELL)
|
||||
{
|
||||
if ((ptypes[(pmap[y][x2+1]&0xFF)].falldown)!=2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
x2++;
|
||||
}
|
||||
|
||||
// fill span
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
parts[pmap[y][x]>>8].tmp2 = !check;//flag it as checked, maybe shouldn't use .tmp2
|
||||
//check above, maybe around other sides too?
|
||||
if ( ((y-1) > originaly) && !pmap[y-1][x])
|
||||
{
|
||||
int oldx = (int)(parts[i].x + 0.5f);
|
||||
int oldy = (int)(parts[i].y + 0.5f);
|
||||
pmap[y-1][x] = pmap[oldy][oldx];
|
||||
pmap[oldy][oldx] = 0;
|
||||
parts[i].x = x;
|
||||
parts[i].y = y-1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// fill children
|
||||
|
||||
if (y>=CELL+1)
|
||||
for (x=x1; x<=x2; x++)
|
||||
if ((ptypes[(pmap[y-1][x]&0xFF)].falldown)==2 && parts[pmap[y-1][x]>>8].tmp2 == check)
|
||||
if (!flood_water(x, y-1, i, originaly, check))
|
||||
return 0;
|
||||
if (y<YRES-CELL-1)
|
||||
for (x=x1; x<=x2; x++)
|
||||
if ((ptypes[(pmap[y+1][x]&0xFF)].falldown)==2 && parts[pmap[y+1][x]>>8].tmp2 == check)
|
||||
if (!flood_water(x, y+1, i, originaly, check))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//this creates particles from a brush, don't use if you want to create one particle
|
||||
int create_parts(int x, int y, int rx, int ry, int c, int flags)
|
||||
{
|
||||
|
Reference in New Issue
Block a user