Merge pull request #57 from jacob1/test
Bug fixes + Some stuff from jacob1's mod
This commit is contained in:
commit
7a454d4d72
192
README
192
README
@ -34,9 +34,9 @@ Controls:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Caps Lock Specific Element Erase
|
||||
Insert Replace mode
|
||||
TAB Circle/Square Brush
|
||||
Space Pause
|
||||
Insert Replace mode
|
||||
TAB Switch between circle/square/triangle brush
|
||||
Space Pause
|
||||
Q Quit
|
||||
Esc Quit
|
||||
Z Zoom
|
||||
@ -49,29 +49,40 @@ P Save screenshot to .ppm
|
||||
F Pause and go to next frame
|
||||
G Grid
|
||||
H Show/Hide HUD
|
||||
Ctrl + H Show intro text
|
||||
F1 Show intro text
|
||||
D Debug mode (+ Shift when STK2 is out)
|
||||
I Invert Pressure and Velocity map
|
||||
T Vine mode
|
||||
W Toggle gravity modes (+ Ctrl when STK2 is out)
|
||||
R Reset LIFE generation (when in Debug mode)
|
||||
Y Toggle air modes
|
||||
R Reset LIFE generation
|
||||
N "Sand effect" for drawing powders
|
||||
B Decoration editor
|
||||
Ctrl + B Toggle decorations on/off
|
||||
U Toggle ambient heat on/off
|
||||
M switch left and right selected elements
|
||||
N Toggle pretty powders
|
||||
Ctrl + I Install powder toy for loading saves/stamps by double clicking
|
||||
~ Console
|
||||
= Reset pressure and velocity map
|
||||
[ Decrase brush size
|
||||
] Increase brush size
|
||||
[ Decrease brush size
|
||||
] Increase brush size
|
||||
Alt + [ Decrease brush size by 1
|
||||
Alt + ] Increase brush size by 1
|
||||
|
||||
Ctrl + C/V/X Copy/Paste/Cut
|
||||
Ctrl + Z Undo
|
||||
Ctrl + Cursor drag Rectangle
|
||||
Shift + Cursor drag Line
|
||||
Ctrl + C/V/X Copy/Paste/Cut
|
||||
Ctrl + Z Undo
|
||||
Ctrl + Cursor drag Rectangle
|
||||
Shift + Cursor drag Line
|
||||
MMB / Alt + LMB click Sample element
|
||||
Mouse scroll Change brush size
|
||||
Ctrl + Mouse scroll Change vertical brush size
|
||||
Shift + Mouse scroll Change horizontal brush size
|
||||
Shift + Ctrl + R Horizontal mirror for selected area
|
||||
Ctrl + R Rotate selected area counterclockwise
|
||||
Ctrl + Left Alt Select subject for Specific Element erase
|
||||
Ctrl + = Reset Electricity
|
||||
Mouse scroll Change brush size
|
||||
Ctrl + Mouse scroll Change vertical brush size
|
||||
Shift + Mouse scroll Change horizontal brush size
|
||||
Shift + Ctrl + R Horizontal mirror for selected area
|
||||
Ctrl + R Rotate selected area counterclockwise
|
||||
Ctrl + Left Alt Select element for Specific Element erase
|
||||
Ctrl + = Reset Electricity
|
||||
|
||||
|
||||
Command Line:
|
||||
@ -84,13 +95,92 @@ kiosk - Fullscreen mode
|
||||
proxy:<server>:<port> (ie, proxy:wwwcache.lancs.ac.uk:8080)
|
||||
open <file> - Opens the file as a stamp or game save
|
||||
ddir <directory> - Directory used for saving stamps and preferences
|
||||
nohud - disables the hud
|
||||
sound - enable sound to be played from console
|
||||
scripts - enable scripts to be run from old console
|
||||
|
||||
History:
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
* Version 65.4
|
||||
o "Sand" effect for drawing powders, activate with "N"
|
||||
* Version 73.0
|
||||
o New elements: FRAY - Similar to ARAY but applies force, RPEL - Attract and repel particles
|
||||
o DEUT can be compressed by gravitational fields
|
||||
o Fix for "bumpy" streams of photons coming from PCLN
|
||||
o Lua methods for writing and reading the bmap and emap
|
||||
* Version 72.0
|
||||
o More consistent spark speed (possibly affects existing circuits)
|
||||
o BRAY fire speed (Only shoots once per spark)
|
||||
o DLAY blocked by INSL
|
||||
o WIFI will always take one frame to transmit SPRK
|
||||
o Ambient heat blocked by walls.
|
||||
* Version 71.3
|
||||
o OPS format fixes
|
||||
o Figh drawn correctly in stamps
|
||||
* Version 71.2
|
||||
o Enable use of caching server to improve performance or thumbnail retrieval
|
||||
* Version 71.1
|
||||
o Fixes to OPS format
|
||||
o Fix issue where LRBD/RBDM isn't ignited by WATR
|
||||
o Fix crash on rotating a stamp with walls as wide as the window
|
||||
o Fix Invisible photons
|
||||
o Fix bug where WARP+SING destroys DMND
|
||||
o Fix issue where Lua can't create photons in glass
|
||||
* Version 71.0
|
||||
o Update can_move, recount menu items, and clear graphics cache when tpt.el is changed
|
||||
o Fix creation of invalid sign walls
|
||||
o Added OPS format, disabled and not used
|
||||
* Version 70.1
|
||||
o Support element names and hex constants in PROP tool
|
||||
o Fix TNT bug
|
||||
o Fix crash in clear_sim if gravity is not initialized
|
||||
* Version 70.0
|
||||
o New element: ignition cord
|
||||
o Stickmen and fighter fixes
|
||||
o Fixed WIRE graphics
|
||||
o New elements: ACEL and DCEL, accelerate nearby photons
|
||||
* Version 69.1
|
||||
o New Lua API features, ability to edit particle properties from tpt.el... array, particles are exposed as an array now
|
||||
* Version 69.0
|
||||
o New element: TNT
|
||||
o Bug fix for LCRY and ELEC
|
||||
o Restore old LCRY/DECO rendering
|
||||
o Fix display modes on number hotkeys not saving correctly
|
||||
* Version 68.7
|
||||
o Additions to Lua API:
|
||||
o tpt.el: Table of element types, tpt.el.none = 0, tpt.el.dust = 1, etc.
|
||||
o tpt.version: Table of version info, tpt.el.major, minor, build
|
||||
o int tpt.element(string name): returns numeric ID of given element name, tpt.element("WATR") = tpt.el.watr
|
||||
o tpt.element_func(function func, int element, [boolean replace]) : Sets the update function for a specific element
|
||||
o tpt.element_func has the following args: (int index, int x, int y, int surround, int nt)
|
||||
* Version 68.6
|
||||
o Add back number key hotkeys to change display modes
|
||||
o Add back blob and heat gradient display
|
||||
o Correct icons in render_ui
|
||||
o Add back portal effects
|
||||
* Version 68.5
|
||||
o fix decorations
|
||||
* Version 68.4
|
||||
o Stamp browser fixes
|
||||
o Remove some stuff from HUD to make it fit
|
||||
o Fix grid mode
|
||||
o Replace cmode with flexible render options
|
||||
* Version 68.3
|
||||
o Pixel grid and cursor in zoom
|
||||
* Version 68.1
|
||||
o CAUS killes stickmen they can also have gas powers now
|
||||
o Fix air inversion
|
||||
* Version 68.0
|
||||
o Decorations appear on gases
|
||||
o Stickmen and fighter fixes
|
||||
o Fixed WIRE graphics
|
||||
o New elements: ACEL and DCEL, accelerate nearby photons
|
||||
* Version 67.0
|
||||
o New element: ELEC
|
||||
o Changed now LCRY works
|
||||
* Version 66.1
|
||||
o Massive overhaul of graphics code, appearance of many elements changed
|
||||
* Version 65.5
|
||||
o Elements from Maksprog's mod
|
||||
o LIGH - Lightning
|
||||
o DEST - Variation of BOMB
|
||||
@ -99,6 +189,70 @@ History:
|
||||
o Fix bug with infinite temperature
|
||||
o Fix beta enrolling
|
||||
o Add a new mode to filter, subtract (tmp of 3)
|
||||
o Quick options menu in top right, can toggle various options quickly
|
||||
o Lots and lots of fixes
|
||||
* Version 64.3
|
||||
o Decoration editor tool menu, with lighten and darken tools
|
||||
o Can type in decoration editor color boxes for specific RGB values, hit enter after typing a number to confirm
|
||||
o SOAP removes decoration, opposite of BIZR
|
||||
o Water equalization, turn on in options menu, or with tpt.watertest()
|
||||
o BUBW changes to be more realistic, can explode
|
||||
o New element CAUS, an acid like gas, created from ACID+WTRV
|
||||
o Can see selected elements from Lua, tpt.selectedl or tpt.selectedr
|
||||
o Saved settings are in JSON format, replaces powder.def
|
||||
o Can opt in to receive beta updates
|
||||
o QRTZ scatters photons.
|
||||
o New Tool, PROP, edit properties easily without console.
|
||||
o FILT has modes with .tmp (0,1,2). 0 is convert (old method). 1 will filter (only close color can pass). 2 is add color
|
||||
o 'Sign out' button in the login menu, instead of submitting blank data
|
||||
o Fancy colored powders, hit 'n' to toggle
|
||||
* Version 61.2
|
||||
o Fixed a Lua mouse event bug
|
||||
o Can set decoration layer "dcolour" property
|
||||
o Fixed some possible cases where particles disappear randomly
|
||||
* Version 61.1
|
||||
o Fix some memory leaks
|
||||
o STOR will absorb anything when no ctype set, and it's ctype can't be a solid element
|
||||
* Version 61.0
|
||||
o Added energy only wall (Photons, Neutrons, etc.) as replacement for gas only wall fix
|
||||
o STOR will change appearance when it holds a particle
|
||||
* Version 60.1
|
||||
o Tools menu for AIR, HEAT, COOL, etc.
|
||||
o tpt.getscript() to download from official script repository (not used)
|
||||
o tpt.setwindowsize(scale,fullscreen) to change scale (1 or 2) and fullscreen (0 or 1)
|
||||
o Selection for stamp/copy now by pixel
|
||||
o Water puts out fire better
|
||||
o New elements: CO2, BUBW, DRIC, STOR, PVOD, CONV
|
||||
o Zoom toggle: alt+z
|
||||
o BIZR acts as a dye
|
||||
o Many other various fixes and improvements
|
||||
* Version 57.5
|
||||
o Fix Lua keyevent function
|
||||
* Version 57.4
|
||||
o Fix STKM2 spaz
|
||||
o Fix bug where electrode (ETRD) would delete particles in replace mode
|
||||
* Version 57.3
|
||||
o Fix coal being invisible when first drawn
|
||||
* Version 57.2
|
||||
o Allow scrolling in the special menu
|
||||
* Version 57.1
|
||||
o Stops the client launching DDos attack on server when checking for updates
|
||||
* Version 57
|
||||
o Gravity tools (NGRV and PGRV)
|
||||
o Allow reloading of directly opened files
|
||||
o Graphical changes to coal
|
||||
* Version 56
|
||||
o New element: GBMB (gravity bomb), requires newtonian gravity
|
||||
* Version 55
|
||||
o New element: WIRE
|
||||
o Extra line tool info if you type tpt.setdebug(4) into the console
|
||||
* Version 53.3
|
||||
o New Lua API functions to get keyboard/mouse presses
|
||||
* Version 53.1
|
||||
o Fix old GOL + clone saves and other life visual imprivements
|
||||
o Fancy lensing for mewtonian gravity in fancy (7) display
|
||||
o New element: DLAY
|
||||
o New Lua API functions from me4502
|
||||
* Version 47.3
|
||||
o Enhanced visual effects for Portals
|
||||
o Glow now has more stimuli (Green: Pressure, Blue: Movement, Red: Heat)
|
||||
|
@ -166,6 +166,7 @@ extern int active_menu;
|
||||
extern int hud_enable;
|
||||
extern int pretty_powder;
|
||||
extern int drawgrav_enable;
|
||||
extern int ngrav_enable;
|
||||
int limitFPS;
|
||||
int water_equal_test;
|
||||
extern int quickoptions_tooltip_fade;
|
||||
|
@ -77,6 +77,8 @@ static quick_option quickmenu[] =
|
||||
{"P", "Sand effect", QM_TOGGLE, &pretty_powder},
|
||||
{"G", "Draw gravity grid", QM_TOGGLE, &drawgrav_enable},
|
||||
{"D", "Show decorations", QM_TOGGLE, &decorations_enable},
|
||||
{"N", "Newtonian gravity", QM_TOGGLE, &ngrav_enable},
|
||||
{"A", "Ambient heat", QM_TOGGLE, &aheat_enable},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@ -101,12 +103,14 @@ static menu_wall colorlist[] =
|
||||
#define DECO_DRAW 0
|
||||
#define DECO_LIGHTEN 1
|
||||
#define DECO_DARKEN 2
|
||||
#define DECO_SMUDGE 3
|
||||
|
||||
static menu_wall toollist[] =
|
||||
{
|
||||
{PIXPACK(0xFF0000), "Draw"},
|
||||
{PIXPACK(0xDDDDDD), "Lighten"},
|
||||
{PIXPACK(0x111111), "Darken"},
|
||||
{PIXPACK(0x00FF00), "Smudge"},
|
||||
};
|
||||
|
||||
struct ui_edit
|
||||
@ -289,7 +293,7 @@ int save_filename_ui(pixel *vid_buf);
|
||||
|
||||
void menu_ui(pixel *vid_buf, int i, int *sl, int *sr);
|
||||
|
||||
void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq, int mx, int my);
|
||||
void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *su, int *dae, int b, int bq, int mx, int my);
|
||||
|
||||
int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int bq, int mx, int my, int * tool);
|
||||
|
||||
|
@ -371,6 +371,7 @@ int update_ICEI(UPDATE_FUNC_ARGS);
|
||||
int update_ISZ(UPDATE_FUNC_ARGS);
|
||||
int update_LCRY(UPDATE_FUNC_ARGS);
|
||||
int update_MORT(UPDATE_FUNC_ARGS);
|
||||
int update_NBLE(UPDATE_FUNC_ARGS);
|
||||
int update_NEUT(UPDATE_FUNC_ARGS);
|
||||
int update_NPTCT(UPDATE_FUNC_ARGS);
|
||||
int update_PCLN(UPDATE_FUNC_ARGS);
|
||||
@ -792,7 +793,7 @@ void create_box(int x1, int y1, int x2, int y2, int c, int flags);
|
||||
|
||||
int flood_parts(int x, int y, int c, int cm, int bm, int flags);
|
||||
|
||||
int create_parts(int x, int y, int rx, int ry, int c, int flags);
|
||||
int create_parts(int x, int y, int rx, int ry, int c, int flags, int fill);
|
||||
|
||||
void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define EFFECT 0xFF000000
|
||||
#define EFFECT_GRAVIN 0x01000000
|
||||
#define EFFECT_GRAVOUT 0x02000000
|
||||
#define EFFECT_LINES 0x04000000
|
||||
|
||||
#define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE
|
||||
#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND | FIREMODE
|
||||
|
File diff suppressed because one or more lines are too long
@ -62,7 +62,7 @@ part_type ptypes[PT_NUM] =
|
||||
{"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, 10000.0f +273.15f, 5, "Plasma, extremely hot.", ST_NONE, TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_PYRO, &graphics_PLSM},
|
||||
{"ETRD", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)", ST_NONE, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC, NULL, NULL},
|
||||
{"NICE", PIXPACK(0xC0E0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0005f* CFDS, 0, 0, 0, 0, 20, 1, 1, 100, SC_SOLIDS, 35.0f, 46, "Nitrogen Ice.", ST_SOLID, TYPE_SOLID, NULL, NULL},
|
||||
{"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when introduced to electricity", ST_GAS, TYPE_GAS|PROP_CONDUCTS|PROP_LIFE_DEC, NULL, NULL},
|
||||
{"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when introduced to electricity", ST_GAS, TYPE_GAS|PROP_CONDUCTS|PROP_LIFE_DEC, &update_NBLE, NULL},
|
||||
{"BTRY", PIXPACK(0x858505), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Generates Electricity.", ST_SOLID, TYPE_SOLID, &update_BTRY, NULL},
|
||||
{"LCRY", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)", ST_SOLID, TYPE_SOLID, &update_LCRY, &graphics_LCRY},
|
||||
{"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM, &graphics_STKM},
|
||||
@ -353,4 +353,4 @@ part_transition ptransitions[PT_NUM] =
|
||||
#undef ITL
|
||||
#undef ITH
|
||||
#undef NT
|
||||
#undef ST
|
||||
#undef ST
|
||||
|
@ -27,5 +27,20 @@ int update_CO2(UPDATE_FUNC_ARGS) {
|
||||
kill_part(r>>8);
|
||||
}
|
||||
}
|
||||
if (parts[i].temp > 9773.15 && pv[y/CELL][x/CELL] > 200.0f)
|
||||
{
|
||||
if (rand()%5 < 1)
|
||||
{
|
||||
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;
|
||||
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; }
|
||||
|
||||
parts[i].temp += 15000;
|
||||
pv[y/CELL][x/CELL] += 100;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
|
||||
kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
if (ptypes[r&0xFF].properties & PROP_CONDUCTS)
|
||||
if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_H2||parts[i].tmp!=1))
|
||||
{
|
||||
create_part(-1, x+rx, y+ry, PT_SPRK);
|
||||
kill_part(i);
|
||||
|
@ -3,6 +3,8 @@
|
||||
int update_H2(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r,rx,ry,rt;
|
||||
if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f)
|
||||
parts[i].tmp = 1;
|
||||
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))
|
||||
@ -16,19 +18,51 @@ int update_H2(UPDATE_FUNC_ARGS)
|
||||
part_change_type(r>>8,x+rx,y+ry,PT_WATR);
|
||||
part_change_type(i,x,y,PT_OIL);
|
||||
}
|
||||
if ((r&0xFF)==PT_FIRE)
|
||||
if (parts[r>>8].temp > 2273.15)// && pv[y/CELL][x/CELL] > 50.0f)
|
||||
continue;
|
||||
if (parts[i].tmp != 1)
|
||||
{
|
||||
parts[r>>8].temp=2473.15;
|
||||
if(parts[r>>8].tmp&0x02)
|
||||
parts[r>>8].temp=3473;
|
||||
parts[r>>8].tmp |= 1;
|
||||
}
|
||||
if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)
|
||||
{
|
||||
create_part(i,x,y,PT_FIRE);
|
||||
parts[i].temp+=(rand()/(RAND_MAX/100));
|
||||
parts[i].tmp |= 1;
|
||||
if (rt==PT_FIRE)
|
||||
{
|
||||
parts[r>>8].temp=2473.15;
|
||||
if(parts[r>>8].tmp&0x02)
|
||||
parts[r>>8].temp=3473;
|
||||
parts[r>>8].tmp |= 1;
|
||||
}
|
||||
if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_LAVA)
|
||||
{
|
||||
create_part(i,x,y,PT_FIRE);
|
||||
parts[i].temp+=(rand()/(RAND_MAX/100));
|
||||
parts[i].tmp |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
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_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; }
|
||||
|
||||
if (rand()%2)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
|
||||
parts[i].temp += 6000;
|
||||
pv[y/CELL][x/CELL] += 30;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
26
src/elements/nble.c
Normal file
26
src/elements/nble.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <element.h>
|
||||
|
||||
int update_NBLE(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].temp > 5273.15 && pv[y/CELL][x/CELL] > 100.0f)
|
||||
{
|
||||
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;
|
||||
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_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;
|
||||
|
||||
parts[i].temp += 10000;
|
||||
pv[y/CELL][x/CELL] += 30;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -164,6 +164,7 @@ int graphics_WIFI(GRAPHICS_FUNC_ARGS)
|
||||
*colr = sin(frequency*q + 0) * 127 + 128;
|
||||
*colg = sin(frequency*q + 2) * 127 + 128;
|
||||
*colb = sin(frequency*q + 4) * 127 + 128;
|
||||
*pixel_mode |= EFFECT_LINES;
|
||||
return 0;
|
||||
}
|
||||
int graphics_PRTI(GRAPHICS_FUNC_ARGS)
|
||||
@ -173,6 +174,7 @@ int graphics_PRTI(GRAPHICS_FUNC_ARGS)
|
||||
*fireg = 0;
|
||||
*fireb = 0;
|
||||
*pixel_mode |= EFFECT_GRAVIN;
|
||||
*pixel_mode |= EFFECT_LINES;
|
||||
*pixel_mode &= ~PMODE;
|
||||
*pixel_mode |= PMODE_ADD;
|
||||
return 1;
|
||||
@ -184,6 +186,7 @@ int graphics_PRTO(GRAPHICS_FUNC_ARGS)
|
||||
*fireg = 0;
|
||||
*fireb = 255;
|
||||
*pixel_mode |= EFFECT_GRAVOUT;
|
||||
*pixel_mode |= EFFECT_LINES;
|
||||
*pixel_mode &= ~PMODE;
|
||||
*pixel_mode |= PMODE_ADD;
|
||||
return 1;
|
||||
|
@ -55,8 +55,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
|
||||
if (fe) {
|
||||
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
|
||||
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
|
||||
if (!parts[i].life) parts[i].life = rand();
|
||||
if (!parts[i].ctype) parts[i].ctype = rand();
|
||||
if (!parts[i].life) parts[i].life = rand()*rand()*rand();
|
||||
if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
|
||||
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
|
||||
for (r = 0; r < 4; r++) {
|
||||
if (orbd[r]>1) {
|
||||
|
@ -85,8 +85,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
|
||||
if (fe) {
|
||||
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
|
||||
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
|
||||
if (!parts[i].life) parts[i].life = rand();
|
||||
if (!parts[i].ctype) parts[i].life = rand();
|
||||
if (!parts[i].life) parts[i].life = rand()*rand()*rand();
|
||||
if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
|
||||
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
|
||||
for (r = 0; r < 4; r++) {
|
||||
if (orbd[r]<254) {
|
||||
@ -94,9 +94,10 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
|
||||
if (orbd[r]>254) {
|
||||
orbd[r] = 0;
|
||||
orbl[r] = rand()%255;
|
||||
} else {
|
||||
orbl[r] += 1;
|
||||
orbl[r] = orbl[r]%255;
|
||||
}
|
||||
//orbl[r] += 1;
|
||||
//orbl[r] = orbl[r]%255;
|
||||
} else {
|
||||
orbd[r] = 0;
|
||||
orbl[r] = rand()%255;
|
||||
|
@ -46,6 +46,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)) &&
|
||||
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);
|
||||
|
@ -44,7 +44,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
||||
parts[nearp].ctype = PT_ETRD;
|
||||
}
|
||||
}
|
||||
else if (ct==PT_NBLE&&parts[i].life<=1)
|
||||
else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].tmp!=1)
|
||||
{
|
||||
parts[i].life = rand()%150+50;
|
||||
part_change_type(i,x,y,PT_PLSM);
|
||||
@ -179,6 +179,8 @@ 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)
|
||||
conduct_sprk = 0;
|
||||
|
||||
if (conduct_sprk) {
|
||||
if (rt==PT_WATR||rt==PT_SLTW) {
|
||||
@ -221,9 +223,9 @@ int graphics_SPRK(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
*firea = 80;
|
||||
|
||||
*firer = *colr = 170;
|
||||
*fireg = *colg = 200;
|
||||
*fireb = *colb = 220;
|
||||
*firer = 170;
|
||||
*fireg = 200;
|
||||
*fireb = 220;
|
||||
//*pixel_mode |= FIRE_ADD;
|
||||
*pixel_mode |= FIRE_ADD;
|
||||
return 1;
|
||||
|
@ -257,7 +257,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
|
||||
{
|
||||
int np = -1;
|
||||
if (playerp->elem == SPC_AIR)
|
||||
create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
|
||||
create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0, 1);
|
||||
else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate
|
||||
np = -1;
|
||||
else
|
||||
|
160
src/graphics.c
160
src/graphics.c
@ -887,11 +887,7 @@ inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
|
||||
return x + w;
|
||||
}
|
||||
|
||||
#if defined(WIN32) && !defined(__GNUC__)
|
||||
_inline int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
|
||||
#else
|
||||
inline int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
|
||||
#endif
|
||||
int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
|
||||
{
|
||||
int i, j, w, bn = 0, ba = 0;
|
||||
char *rp = font_data + font_ptrs[c];
|
||||
@ -1318,14 +1314,19 @@ void draw_air(pixel *vid)
|
||||
clamp_flt(pv[y][x], 0.0f, 8.0f),//pressure adds green
|
||||
clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
|
||||
}
|
||||
else if (display_mode & DISPLAY_AIRH)
|
||||
else if ((display_mode & DISPLAY_AIRH))
|
||||
{
|
||||
float ttemp = hv[y][x]+(-MIN_TEMP);
|
||||
int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
|
||||
c = PIXRGB((int)((unsigned char)color_data[caddress]*0.7f), (int)((unsigned char)color_data[caddress+1]*0.7f), (int)((unsigned char)color_data[caddress+2]*0.7f));
|
||||
//c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
|
||||
// clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green
|
||||
// clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
|
||||
if (aheat_enable)
|
||||
{
|
||||
float ttemp = hv[y][x]+(-MIN_TEMP);
|
||||
int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
|
||||
c = PIXRGB((int)((unsigned char)color_data[caddress]*0.7f), (int)((unsigned char)color_data[caddress+1]*0.7f), (int)((unsigned char)color_data[caddress+2]*0.7f));
|
||||
//c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
|
||||
// clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green
|
||||
// clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
|
||||
}
|
||||
else
|
||||
c = PIXRGB(0,0,0);
|
||||
}
|
||||
else if (display_mode & DISPLAY_AIRC)
|
||||
{
|
||||
@ -1934,6 +1935,11 @@ void render_parts(pixel *vid)
|
||||
#endif
|
||||
|
||||
//Pixel rendering
|
||||
if (t==PT_SOAP)
|
||||
{
|
||||
if ((parts[i].ctype&7) == 7)
|
||||
draw_line(vid, nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), 245, 245, 220, XRES+BARSIZE);
|
||||
}
|
||||
if(pixel_mode & PSPEC_STICKMAN)
|
||||
{
|
||||
char buff[20]; //Buffer for HP
|
||||
@ -2403,9 +2409,9 @@ void render_parts(pixel *vid)
|
||||
for (r = 0; r < 4; r++) {
|
||||
ddist = ((float)orbd[r])/16.0f;
|
||||
drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f;
|
||||
nxo = ddist*cos(drad);
|
||||
nyo = ddist*sin(drad);
|
||||
if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES)
|
||||
nxo = (int)(ddist*cos(drad));
|
||||
nyo = (int)(ddist*sin(drad));
|
||||
if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES && (pmap[ny+nyo][nx+nxo]&0xFF) != PT_PRTI)
|
||||
addpixel(vid, nx+nxo, ny+nyo, colr, colg, colb, 255-orbd[r]);
|
||||
}
|
||||
}
|
||||
@ -2421,12 +2427,31 @@ void render_parts(pixel *vid)
|
||||
for (r = 0; r < 4; r++) {
|
||||
ddist = ((float)orbd[r])/16.0f;
|
||||
drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f;
|
||||
nxo = ddist*cos(drad);
|
||||
nyo = ddist*sin(drad);
|
||||
if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES)
|
||||
nxo = (int)(ddist*cos(drad));
|
||||
nyo = (int)(ddist*sin(drad));
|
||||
if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES && (pmap[ny+nyo][nx+nxo]&0xFF) != PT_PRTO)
|
||||
addpixel(vid, nx+nxo, ny+nyo, colr, colg, colb, 255-orbd[r]);
|
||||
}
|
||||
}
|
||||
if ((pixel_mode & EFFECT_LINES) && DEBUG_MODE)
|
||||
{
|
||||
if (mousex==(nx) && mousey==(ny))//draw lines connecting wifi/portal channels
|
||||
{
|
||||
int z;
|
||||
int type = parts[i].type;
|
||||
if (type == PT_PRTI)
|
||||
type = PT_PRTO;
|
||||
else if (type == PT_PRTO)
|
||||
type = PT_PRTI;
|
||||
for (z = 0; z<NPART; z++) {
|
||||
if (parts[z].type)
|
||||
{
|
||||
if (parts[z].type==type&&parts[z].tmp==parts[i].tmp)
|
||||
xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fire effects
|
||||
if(firea && (pixel_mode & FIRE_BLEND))
|
||||
{
|
||||
@ -2917,7 +2942,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c
|
||||
}
|
||||
void create_decoration(int x, int y, int r, int g, int b, int click, int tool)
|
||||
{
|
||||
int rp, tr,tg,tb;
|
||||
int rp, tr = 0, tg = 0, tb = 0;
|
||||
rp = pmap[y][x];
|
||||
if (!rp)
|
||||
return;
|
||||
@ -2946,6 +2971,31 @@ void create_decoration(int x, int y, int r, int g, int b, int click, int tool)
|
||||
tb = (parts[rp>>8].dcolour)&0xFF;
|
||||
parts[rp>>8].dcolour = ((parts[rp>>8].dcolour&0xFF000000)|(clamp_flt(tr-(tr)*0.02, 0,255)<<16)|(clamp_flt(tg-(tg)*0.02, 0,255)<<8)|clamp_flt(tb-(tb)*0.02, 0,255));
|
||||
}
|
||||
else if (tool == DECO_SMUDGE)
|
||||
{
|
||||
int rx, ry, num = 0, ta = 0;
|
||||
for (rx=-2; rx<3; rx++)
|
||||
for (ry=-2; ry<3; ry++)
|
||||
{
|
||||
if ((pmap[y+ry][x+rx]&0xFF) && parts[pmap[y+ry][x+rx]>>8].dcolour)
|
||||
{
|
||||
num++;
|
||||
ta += (parts[pmap[y+ry][x+rx]>>8].dcolour>>24)&0xFF;
|
||||
tr += (parts[pmap[y+ry][x+rx]>>8].dcolour>>16)&0xFF;
|
||||
tg += (parts[pmap[y+ry][x+rx]>>8].dcolour>>8)&0xFF;
|
||||
tb += (parts[pmap[y+ry][x+rx]>>8].dcolour)&0xFF;
|
||||
}
|
||||
}
|
||||
if (num == 0)
|
||||
return;
|
||||
ta = min(255,(int)((float)ta/num+.5));
|
||||
tr = min(255,(int)((float)tr/num+.5));
|
||||
tg = min(255,(int)((float)tg/num+.5));
|
||||
tb = min(255,(int)((float)tb/num+.5));
|
||||
if (!parts[rp>>8].dcolour)
|
||||
ta = max(0,ta-3);
|
||||
parts[rp>>8].dcolour = ((ta<<24)|(tr<<16)|(tg<<8)|tb);
|
||||
}
|
||||
}
|
||||
void line_decorations(int x1, int y1, int x2, int y2, int rx, int ry, int r, int g, int b, int click, int tool)
|
||||
{
|
||||
@ -3588,7 +3638,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
|
||||
{
|
||||
#ifdef OGLR
|
||||
int i;
|
||||
if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV)
|
||||
if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV||t==SPC_PROP)
|
||||
{
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||
glEnable(GL_COLOR_LOGIC_OP);
|
||||
@ -3628,49 +3678,39 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
|
||||
}
|
||||
#else
|
||||
int i,j,c;
|
||||
if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV)
|
||||
if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV||t==SPC_PROP)
|
||||
{
|
||||
if (rx<=0)
|
||||
xor_pixel(x, y, vid);
|
||||
else if (ry<=0)
|
||||
xor_pixel(x, y, vid);
|
||||
if (rx+ry<=0)
|
||||
xor_pixel(x, y, vid);
|
||||
else if (CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for (j = y - ry; j <= y + ry; j++)
|
||||
xor_pixel(x, j, vid);
|
||||
else
|
||||
{
|
||||
for (j=0; j<=ry; j++)
|
||||
for (i=0; i<=rx; i++)
|
||||
if (i*j<=ry*rx && ((i+1)>rx || (j+1)>ry))
|
||||
{
|
||||
xor_pixel(x+i, y+j, vid);
|
||||
xor_pixel(x-i, y-j, vid);
|
||||
if (i&&j)xor_pixel(x+i, y-j, vid);
|
||||
if (i&&j)xor_pixel(x-i, y+j, vid);
|
||||
}
|
||||
}
|
||||
else if (CURRENT_BRUSH==CIRCLE_BRUSH)
|
||||
{
|
||||
for (j=0; j<=ry; j++)
|
||||
for (i=0; i<=rx; i++)
|
||||
if (pow(i,2)*pow(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2) &&
|
||||
(pow(i+1,2)*pow(ry,2)+pow(j,2)*pow(rx,2)>pow(rx,2)*pow(ry,2) ||
|
||||
pow(i,2)*pow(ry,2)+pow(j+1,2)*pow(rx,2)>pow(rx,2)*pow(ry,2)))
|
||||
{
|
||||
xor_pixel(x+i, y+j, vid);
|
||||
if (j) xor_pixel(x+i, y-j, vid);
|
||||
if (i) xor_pixel(x-i, y+j, vid);
|
||||
if (i&&j) xor_pixel(x-i, y-j, vid);
|
||||
}
|
||||
}
|
||||
else if (CURRENT_BRUSH==TRI_BRUSH)
|
||||
{
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=0; i++)
|
||||
if ((j <= ry ) && ( j >= (((-2.0*ry)/(rx))*i)-ry ) && (j+1>ry || ( j-1 < (((-2.0*ry)/(rx))*i)-ry )) )
|
||||
{
|
||||
xor_pixel(x+i, y+j, vid);
|
||||
if (i) xor_pixel(x-i, y+j, vid);
|
||||
}
|
||||
int tempy = y, i, j, jmax, oldy;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
tempy = y + ry;
|
||||
for (i = x - rx; i <= x; i++) {
|
||||
oldy = tempy;
|
||||
while (InCurrentBrush(i-x,tempy-y,rx,ry))
|
||||
tempy = tempy - 1;
|
||||
tempy = tempy + 1;
|
||||
jmax = 2*y - tempy;
|
||||
if (oldy != tempy && CURRENT_BRUSH != SQUARE_BRUSH)
|
||||
oldy--;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
oldy = tempy;
|
||||
for (j = tempy; j <= oldy; j++) {
|
||||
int i2 = 2*x-i, j2 = 2*y-j;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
j2 = y+ry;
|
||||
xor_pixel(i, j, vid);
|
||||
if (i2 != i)
|
||||
xor_pixel(i2, j, vid);
|
||||
if (j2 != j)
|
||||
xor_pixel(i, j2, vid);
|
||||
if (i2 != i && j2 != j)
|
||||
xor_pixel(i2, j2, vid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //wall cursor
|
||||
|
@ -2219,7 +2219,7 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
|
||||
}
|
||||
*/
|
||||
//current menu function
|
||||
void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq, int mx, int my)
|
||||
void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *su, int *dae, int b, int bq, int mx, int my)
|
||||
{
|
||||
int h,x,y,n=0,height,width,sy,rows=0,xoff=0,fwidth;
|
||||
SEC = SEC2;
|
||||
@ -2458,7 +2458,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
SEC2 = -1;
|
||||
}
|
||||
else {
|
||||
*sl = h;
|
||||
*sl = *su = h;
|
||||
*dae = 51;
|
||||
}
|
||||
}
|
||||
@ -2478,7 +2478,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
SEC2 = -1;
|
||||
}
|
||||
else {
|
||||
*sr = h;
|
||||
*sr = *su = h;
|
||||
*dae = 51;
|
||||
}
|
||||
}
|
||||
@ -2537,7 +2537,7 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
|
||||
float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
|
||||
xoff = (int)(overflow / location);
|
||||
}
|
||||
for (n = 0; n<3; n++)
|
||||
for (n = 0; n<4; n++)
|
||||
{
|
||||
for (a=1; a<15; a++)
|
||||
{
|
||||
@ -2547,6 +2547,8 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
|
||||
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(PIXR(toollist[n].colour)-10*a, PIXG(toollist[n].colour)-10*a, PIXB(toollist[n].colour)-10*a);
|
||||
else if (n == DECO_DARKEN)
|
||||
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(PIXR(toollist[n].colour)+10*a, PIXG(toollist[n].colour)+10*a, PIXB(toollist[n].colour)+10*a);
|
||||
else if (n == DECO_SMUDGE)
|
||||
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(PIXR(toollist[n].colour), PIXG(toollist[n].colour)-5*c, PIXB(toollist[n].colour)+5*c);
|
||||
else if (n == DECO_DRAW)
|
||||
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(*cr,*cg,*cb);
|
||||
else
|
||||
@ -2619,7 +2621,15 @@ void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y)
|
||||
quickoptions_tooltip_y = (i*16)+5;
|
||||
if(b && !bq)
|
||||
{
|
||||
*(quickmenu[i].variable) = !(*(quickmenu[i].variable));
|
||||
if (!strcmp(quickmenu[i].name,"Newtonian gravity"))
|
||||
{
|
||||
if(!ngrav_enable)
|
||||
start_grav_async();
|
||||
else
|
||||
stop_grav_async();
|
||||
}
|
||||
else
|
||||
*(quickmenu[i].variable) = !(*(quickmenu[i].variable));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2884,6 +2894,11 @@ void set_cmode(int cm) // sets to given view mode
|
||||
{
|
||||
colour_mode = COLOUR_HEAT;
|
||||
strcpy(itc_msg, "Heat Display");
|
||||
free(display_modes);
|
||||
display_modes = calloc(2, sizeof(unsigned int));
|
||||
display_mode |= DISPLAY_AIRH;
|
||||
display_modes[0] = DISPLAY_AIRH;
|
||||
display_modes[1] = 0;
|
||||
}
|
||||
else if (cmode==CM_FANCY)
|
||||
{
|
||||
|
@ -1286,9 +1286,9 @@ int luatpt_set_property(lua_State* l)
|
||||
}
|
||||
i = r>>8;
|
||||
if(format==2){
|
||||
*((float*)(((void*)&parts[i])+offset)) = f;
|
||||
*((float*)(((char*)&parts[i])+offset)) = f;
|
||||
} else {
|
||||
*((int*)(((void*)&parts[i])+offset)) = t;
|
||||
*((int*)(((char*)&parts[i])+offset)) = t;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1310,9 +1310,9 @@ int luatpt_set_property(lua_State* l)
|
||||
if (partsel && partsel != parts[i].type)
|
||||
return 0;
|
||||
if(format==2){
|
||||
*((float*)(((void*)&parts[i])+offset)) = f;
|
||||
*((float*)(((char*)&parts[i])+offset)) = f;
|
||||
} else {
|
||||
*((int*)(((void*)&parts[i])+offset)) = t;
|
||||
*((int*)(((char*)&parts[i])+offset)) = t;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
19
src/main.c
19
src/main.c
@ -355,6 +355,12 @@ void stamp_update(void)
|
||||
{
|
||||
fwrite(stamps[i].name, 1, 10, f);
|
||||
}
|
||||
else
|
||||
{
|
||||
char name[30] = {0};
|
||||
sprintf(name,"stamps%s%s.stm",PATH_SEP,stamps[i].name);
|
||||
remove(name);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
@ -1755,7 +1761,7 @@ int main(int argc, char *argv[])
|
||||
active_menu = i;
|
||||
}
|
||||
}
|
||||
menu_ui_v3(vid_buf, active_menu, &sl, &sr, &dae, b, bq, x, y); //draw the elements in the current menu
|
||||
menu_ui_v3(vid_buf, active_menu, &sl, &sr, &su, &dae, b, bq, x, y); //draw the elements in the current menu
|
||||
if (zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy //change mouse position while it is in a zoom window
|
||||
&& x<sdl_scale*(zoom_wx+ZFACTOR*ZSIZE)
|
||||
&& y<sdl_scale*(zoom_wy+ZFACTOR*ZSIZE))
|
||||
@ -1833,7 +1839,10 @@ int main(int argc, char *argv[])
|
||||
sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]);
|
||||
if (DEBUG_MODE)
|
||||
{
|
||||
sprintf(coordtext, "X:%d Y:%d. GX: %.2f GY: %.2f", x/sdl_scale, y/sdl_scale, gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)], gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]);
|
||||
if (ngrav_enable)
|
||||
sprintf(coordtext, "X:%d Y:%d. GX: %.2f GY: %.2f", x/sdl_scale, y/sdl_scale, gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)], gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]);
|
||||
else
|
||||
sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2221,7 +2230,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
|
||||
{
|
||||
render_ui(vid_buf, XRES+BARSIZE-(510-491), YRES+(MENUSIZE-19), 3);
|
||||
render_ui(vid_buf, XRES+BARSIZE-(510-491), YRES-2, 3);
|
||||
}
|
||||
if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
|
||||
sys_pause = !sys_pause;
|
||||
@ -2365,7 +2374,7 @@ int main(int argc, char *argv[])
|
||||
if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE&&c!=SPC_WIND&&c!=SPC_PGRV&&c!=SPC_NGRV)
|
||||
flood_parts(x, y, c, -1, -1, get_brush_flags());
|
||||
if (c==SPC_HEAT || c==SPC_COOL)
|
||||
create_parts(x, y, bsx, bsy, c, get_brush_flags());
|
||||
create_parts(x, y, bsx, bsy, c, get_brush_flags(), 1);
|
||||
lx = x;
|
||||
ly = y;
|
||||
lb = 0;
|
||||
@ -2418,7 +2427,7 @@ int main(int argc, char *argv[])
|
||||
cb_bmap[cby][cbx] = bmap[cby][cbx];
|
||||
cb_emap[cby][cbx] = emap[cby][cbx];
|
||||
}
|
||||
create_parts(x, y, bsx, bsy, c, get_brush_flags());
|
||||
create_parts(x, y, bsx, bsy, c, get_brush_flags(), 1);
|
||||
lx = x;
|
||||
ly = y;
|
||||
lb = b;
|
||||
|
240
src/powder.c
240
src/powder.c
@ -318,43 +318,17 @@ int try_move(int i, int x, int y, int nx, int ny)
|
||||
|
||||
if (parts[i].type==PT_NEUT && (ptypes[r&0xFF].properties&PROP_NEUTABSORB))
|
||||
{
|
||||
parts[i].type=PT_NONE;
|
||||
kill_part(i);
|
||||
return 0;
|
||||
}
|
||||
if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_PVOD) //this is where void eats particles
|
||||
{
|
||||
if (parts[i].type == PT_STKM)
|
||||
{
|
||||
player.spwn = 0;
|
||||
}
|
||||
if (parts[i].type == PT_STKM2)
|
||||
{
|
||||
player2.spwn = 0;
|
||||
}
|
||||
if (parts[i].type == PT_FIGH)
|
||||
{
|
||||
fighters[(unsigned char)parts[i].tmp].spwn = 0;
|
||||
fighcount--;
|
||||
}
|
||||
parts[i].type=PT_NONE;
|
||||
kill_part(i);
|
||||
return 0;
|
||||
}
|
||||
if ((r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) //this is where blackhole eats particles
|
||||
{
|
||||
if (parts[i].type == PT_STKM)
|
||||
{
|
||||
player.spwn = 0;
|
||||
}
|
||||
if (parts[i].type == PT_STKM2)
|
||||
{
|
||||
player2.spwn = 0;
|
||||
}
|
||||
if (parts[i].type == PT_FIGH)
|
||||
{
|
||||
fighters[(unsigned char)parts[i].tmp].spwn = 0;
|
||||
fighcount--;
|
||||
}
|
||||
parts[i].type=PT_NONE;
|
||||
kill_part(i);
|
||||
if (!legacy_enable)
|
||||
{
|
||||
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP);//3.0f;
|
||||
@ -364,7 +338,7 @@ int try_move(int i, int x, int y, int nx, int ny)
|
||||
}
|
||||
if (((r&0xFF)==PT_WHOL||(r&0xFF)==PT_NWHL) && parts[i].type==PT_ANAR) //whitehole eats anar
|
||||
{
|
||||
parts[i].type=PT_NONE;
|
||||
kill_part(i);
|
||||
if (!legacy_enable)
|
||||
{
|
||||
parts[r>>8].temp = restrict_flt(parts[r>>8].temp- (MAX_TEMP-parts[i].temp)/2, MIN_TEMP, MAX_TEMP);
|
||||
@ -415,8 +389,10 @@ int try_move(int i, int x, int y, int nx, int ny)
|
||||
// try to move particle, and if successful update pmap and parts[i].x,y
|
||||
int do_move(int i, int x, int y, float nxf, float nyf)
|
||||
{
|
||||
int nx = (int)(nxf+0.5f), ny = (int)(nyf+0.5f);
|
||||
int result = try_move(i, x, y, nx, ny);
|
||||
int nx = (int)(nxf+0.5f), ny = (int)(nyf+0.5f), result;
|
||||
if (parts[i].type == PT_NONE)
|
||||
return 0;
|
||||
result = try_move(i, x, y, nx, ny);
|
||||
if (result)
|
||||
{
|
||||
int t = parts[i].type;
|
||||
@ -613,6 +589,9 @@ void kill_part(int i)//kills particle number i
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (parts[i].type == PT_NONE) //This shouldn't happen anymore, but it's here just in case
|
||||
return;
|
||||
|
||||
x = (int)(parts[i].x+0.5f);
|
||||
y = (int)(parts[i].y+0.5f);
|
||||
if (parts[i].type == PT_STKM)
|
||||
@ -2284,13 +2263,15 @@ killed:
|
||||
if (stagnant)//FLAG_STAGNANT set, was reflected on previous frame
|
||||
{
|
||||
// cast coords as int then back to float for compatibility with existing saves
|
||||
if (!do_move(i, x, y, (float)fin_x, (float)fin_y)) {
|
||||
if (!do_move(i, x, y, (float)fin_x, (float)fin_y) && parts[i].type) {
|
||||
kill_part(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (!do_move(i, x, y, fin_xf, fin_yf))
|
||||
{
|
||||
if (parts[i].type == PT_NONE)
|
||||
continue;
|
||||
// reflection
|
||||
parts[i].flags |= FLAG_STAGNANT;
|
||||
if (t==PT_NEUT && 100>(rand()%1000))
|
||||
@ -2350,6 +2331,8 @@ killed:
|
||||
// gasses and solids (but not powders)
|
||||
if (!do_move(i, x, y, fin_xf, fin_yf))
|
||||
{
|
||||
if (parts[i].type == PT_NONE)
|
||||
continue;
|
||||
// can't move there, so bounce off
|
||||
// TODO
|
||||
if (fin_x>x+ISTP) fin_x=x+ISTP;
|
||||
@ -2381,6 +2364,8 @@ killed:
|
||||
// liquids and powders
|
||||
if (!do_move(i, x, y, fin_xf, fin_yf))
|
||||
{
|
||||
if (parts[i].type == PT_NONE)
|
||||
continue;
|
||||
if (fin_x!=x && do_move(i, x, y, fin_xf, clear_yf))
|
||||
{
|
||||
parts[i].vx *= ptypes[t].collision;
|
||||
@ -2724,7 +2709,7 @@ void create_box(int x1, int y1, int x2, int y2, int c, int flags)
|
||||
}
|
||||
for (j=y1; j<=y2; j++)
|
||||
for (i=x1; i<=x2; i++)
|
||||
create_parts(i, j, 0, 0, c, flags);
|
||||
create_parts(i, j, 0, 0, c, flags, 1);
|
||||
}
|
||||
|
||||
int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, int proptype, int parttype, char * bitmap)
|
||||
@ -2849,7 +2834,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
|
||||
if (create_part(-1,x, y, fullc)==-1)
|
||||
return 0;
|
||||
}
|
||||
else if (!create_parts(x, y, 0, 0, fullc, flags))
|
||||
else if (!create_parts(x, y, 0, 0, fullc, flags, 1))
|
||||
return 0;
|
||||
}
|
||||
// fill children
|
||||
@ -2972,9 +2957,9 @@ int create_part_add_props(int p, int x, int y, int tv, int rx, int ry)
|
||||
}
|
||||
|
||||
//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)
|
||||
int create_parts(int x, int y, int rx, int ry, int c, int flags, int fill)
|
||||
{
|
||||
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
|
||||
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p, fn;
|
||||
|
||||
int wall = c - 100;
|
||||
if (c==SPC_WIND || c==PT_FIGH)
|
||||
@ -2984,6 +2969,8 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
|
||||
prop_edit_ui(vid_buf, x, y);
|
||||
return 0;
|
||||
}
|
||||
if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV)
|
||||
fill = 1;
|
||||
for (r=UI_ACTUALSTART; r<=UI_ACTUALSTART+UI_WALLCOUNT; r++)
|
||||
{
|
||||
if (wall==r)
|
||||
@ -3075,114 +3062,102 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//eraser
|
||||
if (c == 0 && !(flags&BRUSH_REPLACEMODE))
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
{
|
||||
delete_part(x, y, 0);
|
||||
}
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
delete_part(x+i, y+j, 0);
|
||||
return 1;
|
||||
}
|
||||
if (c == 0 && !(flags&BRUSH_REPLACEMODE)) // delete
|
||||
fn = 0;
|
||||
else if ((flags&BRUSH_SPECIFIC_DELETE) && !(flags&BRUSH_REPLACEMODE)) // specific delete
|
||||
fn = 1;
|
||||
else if (flags&BRUSH_REPLACEMODE) // replace
|
||||
fn = 2;
|
||||
else // normal draw
|
||||
fn = 3;
|
||||
|
||||
//specific deletion
|
||||
if ((flags&BRUSH_SPECIFIC_DELETE)&& !(flags&BRUSH_REPLACEMODE))
|
||||
if (rx<=0) //workaround for rx == 0 crashing. todo: find a better fix later.
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
{
|
||||
delete_part(x, y, flags);
|
||||
}
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
delete_part(x+i, y+j, flags);
|
||||
return 1;
|
||||
for (j = y - ry; j <= y + ry; j++)
|
||||
if (create_parts2(fn,x,j,c,rx,ry,flags))
|
||||
f = 1;
|
||||
}
|
||||
|
||||
//why do these need a special if
|
||||
if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV)
|
||||
else
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
{
|
||||
create_part(-2, x, y, c);
|
||||
}
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
{
|
||||
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
|
||||
continue;
|
||||
if (!REPLACE_MODE)
|
||||
create_part(-2, x+i, y+j, c);
|
||||
else if ((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
|
||||
create_part(-2, x+i, y+j, c);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (flags&BRUSH_REPLACEMODE)
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
{
|
||||
if ((pmap[y][x]&0xFF)==SLALT || SLALT==0)
|
||||
int tempy = y, i, j, jmax, oldy;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
tempy = y + ry;
|
||||
for (i = x - rx; i <= x; i++) {
|
||||
oldy = tempy;
|
||||
while (InCurrentBrush(i-x,tempy-y,rx,ry))
|
||||
tempy = tempy - 1;
|
||||
tempy = tempy + 1;
|
||||
jmax = 2*y - tempy;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
jmax = y + ry;
|
||||
if (fill)
|
||||
{
|
||||
if ((pmap[y][x]))
|
||||
{
|
||||
delete_part(x, y, 0);
|
||||
if (c!=0)
|
||||
create_part_add_props(-2, x, y, c, rx, ry);
|
||||
for (j = tempy; j <= jmax; j++) {
|
||||
if (create_parts2(fn,i,j,c,rx,ry,flags))
|
||||
f = 1;
|
||||
if (create_parts2(fn,2*x-i,j,c,rx,ry,flags))
|
||||
f = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((oldy != tempy && CURRENT_BRUSH != SQUARE_BRUSH) || i == x-rx)
|
||||
oldy--;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
oldy = tempy;
|
||||
for (j = tempy; j <= oldy+1; j++) {
|
||||
int i2 = 2*x-i, j2 = 2*y-j;
|
||||
if (CURRENT_BRUSH == TRI_BRUSH)
|
||||
j2 = y+ry;
|
||||
if (create_parts2(fn,i,j,c,rx,ry,flags))
|
||||
f = 1;
|
||||
if (create_parts2(fn,i2,j,c,rx,ry,flags))
|
||||
f = 1;
|
||||
if (create_parts2(fn,i,j2,c,rx,ry,flags))
|
||||
f = 1;
|
||||
if (create_parts2(fn,i2,j2,c,rx,ry,flags))
|
||||
f = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
{
|
||||
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
|
||||
continue;
|
||||
if ((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
|
||||
continue;
|
||||
if ((pmap[y+j][x+i]))
|
||||
{
|
||||
delete_part(x+i, y+j, 0);
|
||||
if (c!=0)
|
||||
create_part_add_props(-2, x+i, y+j, c, rx, ry);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
//else, no special modes, draw element like normal.
|
||||
if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later.
|
||||
{
|
||||
if (create_part_add_props(-2, x, y, c, rx, ry)==-1)
|
||||
f = 1;
|
||||
}
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
if (create_part_add_props(-2, x+i, y+j, c, rx, ry)==-1)
|
||||
f = 1;
|
||||
return !f;
|
||||
}
|
||||
|
||||
int create_parts2(int f, int x, int y, int c, int rx, int ry, int flags)
|
||||
{
|
||||
if (f == 0) //delete
|
||||
delete_part(x, y, 0);
|
||||
else if (f == 1) //specific delete
|
||||
delete_part(x, y, flags);
|
||||
else if (f == 2) //replace mode
|
||||
{
|
||||
if (x<0 || y<0 || x>=XRES || y>=YRES)
|
||||
return 0;
|
||||
if ((pmap[y][x]&0xFF)!=SLALT&&SLALT!=0)
|
||||
return 0;
|
||||
if ((pmap[y][x]))
|
||||
{
|
||||
delete_part(x, y, 0);
|
||||
if (c!=0)
|
||||
create_part_add_props(-2, x, y, c, rx, ry);
|
||||
}
|
||||
}
|
||||
else if (f == 3) //normal draw
|
||||
if (create_part_add_props(-2, x, y, c, rx, ry)==-1)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int InCurrentBrush(int i, int j, int rx, int ry)
|
||||
{
|
||||
switch(CURRENT_BRUSH)
|
||||
{
|
||||
case CIRCLE_BRUSH:
|
||||
return (pow(i,2)*pow(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2));
|
||||
return (pow((double)i,2)*pow((double)ry,2)+pow((double)j,2)*pow((double)rx,2)<=pow((double)rx,2)*pow((double)ry,2));
|
||||
break;
|
||||
case SQUARE_BRUSH:
|
||||
return (i*j<=ry*rx);
|
||||
return (abs(i) <= rx && abs(j) <= ry);
|
||||
break;
|
||||
case TRI_BRUSH:
|
||||
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ;
|
||||
@ -3205,7 +3180,7 @@ int get_brush_flags()
|
||||
}
|
||||
void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags)
|
||||
{
|
||||
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
|
||||
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy, fill = 1;
|
||||
float e, de;
|
||||
if (c==SPC_PROP)
|
||||
return;
|
||||
@ -3239,9 +3214,10 @@ void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flag
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
if (cp)
|
||||
create_parts(y, x, rx, ry, c, flags);
|
||||
create_parts(y, x, rx, ry, c, flags, fill);
|
||||
else
|
||||
create_parts(x, y, rx, ry, c, flags);
|
||||
create_parts(x, y, rx, ry, c, flags, fill);
|
||||
fill = 0;
|
||||
e += de;
|
||||
if (e >= 0.5f)
|
||||
{
|
||||
@ -3250,9 +3226,9 @@ void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flag
|
||||
&& ((y1<y2) ? (y<=y2) : (y>=y2)))
|
||||
{
|
||||
if (cp)
|
||||
create_parts(y, x, rx, ry, c, flags);
|
||||
create_parts(y, x, rx, ry, c, flags, fill);
|
||||
else
|
||||
create_parts(x, y, rx, ry, c, flags);
|
||||
create_parts(x, y, rx, ry, c, flags, fill);
|
||||
}
|
||||
e -= 1.0f;
|
||||
}
|
||||
|
274
src/save.c
274
src/save.c
@ -52,11 +52,42 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
|
||||
return 1;
|
||||
}
|
||||
|
||||
int change_wall(int wt)
|
||||
{
|
||||
if (wt == 1)
|
||||
return WL_WALL;
|
||||
else if (wt == 2)
|
||||
return WL_DESTROYALL;
|
||||
else if (wt == 3)
|
||||
return WL_ALLOWLIQUID;
|
||||
else if (wt == 4)
|
||||
return WL_FAN;
|
||||
else if (wt == 5)
|
||||
return WL_STREAM;
|
||||
else if (wt == 6)
|
||||
return WL_DETECT;
|
||||
else if (wt == 7)
|
||||
return WL_EWALL;
|
||||
else if (wt == 8)
|
||||
return WL_WALLELEC;
|
||||
else if (wt == 9)
|
||||
return WL_ALLOWAIR;
|
||||
else if (wt == 10)
|
||||
return WL_ALLOWSOLID;
|
||||
else if (wt == 11)
|
||||
return WL_ALLOWALLELEC;
|
||||
else if (wt == 12)
|
||||
return WL_EHOLE;
|
||||
else if (wt == 13)
|
||||
return WL_ALLOWGAS;
|
||||
return wt;
|
||||
}
|
||||
|
||||
pixel *prerender_save_OPS(void *save, int size, int *width, int *height)
|
||||
{
|
||||
unsigned char * inputData = save, *bsonData = NULL, *partsData = NULL, *partsPosData = NULL, *wallData = NULL;
|
||||
int inputDataLen = size, bsonDataLen = 0, partsDataLen, partsPosDataLen, wallDataLen;
|
||||
int i, x, y, j;
|
||||
int i, x, y, j, wt, pc, gc;
|
||||
int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
|
||||
int bsonInitialised = 0;
|
||||
pixel * vidBuf = NULL;
|
||||
@ -177,14 +208,65 @@ pixel *prerender_save_OPS(void *save, int size, int *width, int *height)
|
||||
{
|
||||
if(wallData[y*blockW+x])
|
||||
{
|
||||
for(i = 0; i < CELL; i++)
|
||||
wt = wallData[y*blockW+x];
|
||||
pc = wtypes[wt-UI_ACTUALSTART].colour;
|
||||
gc = wtypes[wt-UI_ACTUALSTART].eglow;
|
||||
if (wtypes[wt-UI_ACTUALSTART].drawstyle==1)
|
||||
{
|
||||
for(j = 0; j < CELL; j++)
|
||||
{
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = PIXPACK(0xCCCCCC);
|
||||
}
|
||||
for (i=0; i<CELL; i+=2)
|
||||
for (j=(i>>1)&1; j<CELL; j+=2)
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = pc;
|
||||
}
|
||||
};
|
||||
else if (wtypes[wt-UI_ACTUALSTART].drawstyle==2)
|
||||
{
|
||||
for (i=0; i<CELL; i+=2)
|
||||
for (j=0; j<CELL; j+=2)
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = pc;
|
||||
}
|
||||
else if (wtypes[wt-UI_ACTUALSTART].drawstyle==3)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = pc;
|
||||
}
|
||||
else if (wtypes[wt-UI_ACTUALSTART].drawstyle==4)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
if(i == j)
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = pc;
|
||||
else if (j == i+1 || (j == 0 && i == CELL-1))
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = gc;
|
||||
else
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = PIXPACK(0x202020);
|
||||
}
|
||||
|
||||
// special rendering for some walls
|
||||
if (wt==WL_EWALL)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
if (!(i&j&1))
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = pc;
|
||||
}
|
||||
else if (wt==WL_WALLELEC)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
{
|
||||
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = pc;
|
||||
else
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = PIXPACK(0x808080);
|
||||
}
|
||||
}
|
||||
else if (wt==WL_EHOLE)
|
||||
{
|
||||
for (i=0; i<CELL; i+=2)
|
||||
for (j=0; j<CELL; j+=2)
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = PIXPACK(0x242424);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,7 +474,7 @@ void *build_save_OPS(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h
|
||||
wallData[(y-blockY)*blockW+(x-blockX)] = bmap[y][x];
|
||||
if(bmap[y][x] && !wallDataFound)
|
||||
wallDataFound = 1;
|
||||
if(bmap[y][x]==WL_FAN || bmap[y][x]==4)
|
||||
if(bmap[y][x]==WL_FAN)
|
||||
{
|
||||
i = (int)(fvx[y][x]*64.0f+127.5f);
|
||||
if (i<0) i=0;
|
||||
@ -990,8 +1072,9 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
|
||||
{
|
||||
for(y = 0; y < blockH; y++)
|
||||
{
|
||||
bmap[blockY+y][blockX+x] = wallData[y*blockW+x];
|
||||
if((bmap[blockY+y][blockX+x]==WL_FAN || bmap[blockY+y][blockX+x]==4) && fanData)
|
||||
if (wallData[y*blockW+x])
|
||||
bmap[blockY+y][blockX+x] = wallData[y*blockW+x];
|
||||
if (wallData[y*blockW+x] == WL_FAN && fanData)
|
||||
{
|
||||
if(j+1 >= fanDataLen)
|
||||
{
|
||||
@ -1222,7 +1305,7 @@ fin:
|
||||
pixel *prerender_save_PSv(void *save, int size, int *width, int *height)
|
||||
{
|
||||
unsigned char *d,*c=save;
|
||||
int i,j,k,x,y,rx,ry,p=0;
|
||||
int i,j,k,x,y,rx,ry,p=0, wt, pc, gc;
|
||||
int bw,bh,w,h,new_format = 0;
|
||||
pixel *fb;
|
||||
|
||||
@ -1269,93 +1352,68 @@ pixel *prerender_save_PSv(void *save, int size, int *width, int *height)
|
||||
for (y=0; y<bh; y++)
|
||||
for (x=0; x<bw; x++)
|
||||
{
|
||||
int wt = change_wall(d[p]);
|
||||
rx = x*CELL;
|
||||
ry = y*CELL;
|
||||
switch (d[p])
|
||||
pc = wtypes[wt-UI_ACTUALSTART].colour;
|
||||
gc = wtypes[wt-UI_ACTUALSTART].eglow;
|
||||
if (wtypes[wt-UI_ACTUALSTART].drawstyle==1)
|
||||
{
|
||||
case 1:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case 2:
|
||||
for (j=0; j<CELL; j+=2)
|
||||
for (i=(j>>1)&1; i<CELL; i+=2)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case 3:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
if (!(j%2) && !(i%2))
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0);
|
||||
break;
|
||||
case 4:
|
||||
for (j=0; j<CELL; j+=2)
|
||||
for (i=(j>>1)&1; i<CELL; i+=2)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF);
|
||||
k++;
|
||||
break;
|
||||
case 6:
|
||||
for (j=0; j<CELL; j+=2)
|
||||
for (i=(j>>1)&1; i<CELL; i+=2)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xFF8080);
|
||||
break;
|
||||
case 7:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
if (!(i&j&1))
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case 8:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
if (!(j%2) && !(i%2))
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0);
|
||||
else
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case WL_WALL:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case WL_DESTROYALL:
|
||||
for (j=0; j<CELL; j+=2)
|
||||
for (i=(j>>1)&1; i<CELL; i+=2)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case WL_ALLOWLIQUID:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
if (!(j%2) && !(i%2))
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0);
|
||||
break;
|
||||
case WL_FAN:
|
||||
for (j=0; j<CELL; j+=2)
|
||||
for (i=(j>>1)&1; i<CELL; i+=2)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF);
|
||||
k++;
|
||||
break;
|
||||
case WL_DETECT:
|
||||
for (j=0; j<CELL; j+=2)
|
||||
for (i=(j>>1)&1; i<CELL; i+=2)
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xFF8080);
|
||||
break;
|
||||
case WL_EWALL:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
if (!(i&j&1))
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
case WL_WALLELEC:
|
||||
for (j=0; j<CELL; j++)
|
||||
for (i=0; i<CELL; i++)
|
||||
if (!(j%2) && !(i%2))
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0);
|
||||
else
|
||||
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
|
||||
break;
|
||||
for (i=0; i<CELL; i+=2)
|
||||
for (j=(i>>1)&1; j<CELL; j+=2)
|
||||
fb[(i+ry)*w+(j+rx)] = pc;
|
||||
}
|
||||
else if (wtypes[wt-UI_ACTUALSTART].drawstyle==2)
|
||||
{
|
||||
for (i=0; i<CELL; i+=2)
|
||||
for (j=0; j<CELL; j+=2)
|
||||
fb[(i+ry)*w+(j+rx)] = pc;
|
||||
}
|
||||
else if (wtypes[wt-UI_ACTUALSTART].drawstyle==3)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
fb[(i+ry)*w+(j+rx)] = pc;
|
||||
}
|
||||
else if (wtypes[wt-UI_ACTUALSTART].drawstyle==4)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
if(i == j)
|
||||
fb[(i+ry)*w+(j+rx)] = pc;
|
||||
else if (j == i+1 || (j == 0 && i == CELL-1))
|
||||
fb[(i+ry)*w+(j+rx)] = gc;
|
||||
else
|
||||
fb[(i+ry)*w+(j+rx)] = PIXPACK(0x202020);
|
||||
}
|
||||
|
||||
// special rendering for some walls
|
||||
if (wt==WL_EWALL)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
if (!(i&j&1))
|
||||
fb[(i+ry)*w+(j+rx)] = pc;
|
||||
}
|
||||
else if (wt==WL_WALLELEC)
|
||||
{
|
||||
for (i=0; i<CELL; i++)
|
||||
for (j=0; j<CELL; j++)
|
||||
{
|
||||
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
|
||||
fb[(i+ry)*w+(j+rx)] = pc;
|
||||
else
|
||||
fb[(i+ry)*w+(j+rx)] = PIXPACK(0x808080);
|
||||
}
|
||||
}
|
||||
else if (wt==WL_EHOLE)
|
||||
{
|
||||
for (i=0; i<CELL; i+=2)
|
||||
for (j=0; j<CELL; j+=2)
|
||||
fb[(i+ry)*w+(j+rx)] = PIXPACK(0x242424);
|
||||
}
|
||||
else if (wt==WL_FAN)
|
||||
k++;
|
||||
p++;
|
||||
}
|
||||
p += 2*k;
|
||||
@ -1757,33 +1815,7 @@ int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned c
|
||||
continue;
|
||||
}
|
||||
|
||||
bmap[y][x] = d[p];
|
||||
if (bmap[y][x]==1)
|
||||
bmap[y][x]=WL_WALL;
|
||||
if (bmap[y][x]==2)
|
||||
bmap[y][x]=WL_DESTROYALL;
|
||||
if (bmap[y][x]==3)
|
||||
bmap[y][x]=WL_ALLOWLIQUID;
|
||||
if (bmap[y][x]==4)
|
||||
bmap[y][x]=WL_FAN;
|
||||
if (bmap[y][x]==5)
|
||||
bmap[y][x]=WL_STREAM;
|
||||
if (bmap[y][x]==6)
|
||||
bmap[y][x]=WL_DETECT;
|
||||
if (bmap[y][x]==7)
|
||||
bmap[y][x]=WL_EWALL;
|
||||
if (bmap[y][x]==8)
|
||||
bmap[y][x]=WL_WALLELEC;
|
||||
if (bmap[y][x]==9)
|
||||
bmap[y][x]=WL_ALLOWAIR;
|
||||
if (bmap[y][x]==10)
|
||||
bmap[y][x]=WL_ALLOWSOLID;
|
||||
if (bmap[y][x]==11)
|
||||
bmap[y][x]=WL_ALLOWALLELEC;
|
||||
if (bmap[y][x]==12)
|
||||
bmap[y][x]=WL_EHOLE;
|
||||
if (bmap[y][x]==13)
|
||||
bmap[y][x]=WL_ALLOWGAS;
|
||||
bmap[y][x] = change_wall(d[p]);
|
||||
}
|
||||
|
||||
p++;
|
||||
|
Loading…
Reference in New Issue
Block a user