Merge pull request #57 from jacob1/test

Bug fixes + Some stuff from jacob1's mod
This commit is contained in:
Simon Robertshaw 2012-03-14 18:52:23 -07:00
commit 7a454d4d72
23 changed files with 689 additions and 374 deletions

190
README
View File

@ -34,9 +34,9 @@ Controls:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Caps Lock Specific Element Erase Caps Lock Specific Element Erase
Insert Replace mode Insert Replace mode
TAB Circle/Square Brush TAB Switch between circle/square/triangle brush
Space Pause Space Pause
Q Quit Q Quit
Esc Quit Esc Quit
Z Zoom Z Zoom
@ -49,29 +49,40 @@ P Save screenshot to .ppm
F Pause and go to next frame F Pause and go to next frame
G Grid G Grid
H Show/Hide HUD H Show/Hide HUD
Ctrl + H Show intro text
F1 Show intro text
D Debug mode (+ Shift when STK2 is out) D Debug mode (+ Shift when STK2 is out)
I Invert Pressure and Velocity map I Invert Pressure and Velocity map
T Vine mode T Vine mode
W Toggle gravity modes (+ Ctrl when STK2 is out) 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 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 ~ Console
= Reset pressure and velocity map = Reset pressure and velocity map
[ Decrase brush size [ Decrease brush size
] Increase 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 + C/V/X Copy/Paste/Cut
Ctrl + Z Undo Ctrl + Z Undo
Ctrl + Cursor drag Rectangle Ctrl + Cursor drag Rectangle
Shift + Cursor drag Line Shift + Cursor drag Line
MMB / Alt + LMB click Sample element MMB / Alt + LMB click Sample element
Mouse scroll Change brush size Mouse scroll Change brush size
Ctrl + Mouse scroll Change vertical brush size Ctrl + Mouse scroll Change vertical brush size
Shift + Mouse scroll Change horizontal brush size Shift + Mouse scroll Change horizontal brush size
Shift + Ctrl + R Horizontal mirror for selected area Shift + Ctrl + R Horizontal mirror for selected area
Ctrl + R Rotate selected area counterclockwise Ctrl + R Rotate selected area counterclockwise
Ctrl + Left Alt Select subject for Specific Element erase Ctrl + Left Alt Select element for Specific Element erase
Ctrl + = Reset Electricity Ctrl + = Reset Electricity
Command Line: Command Line:
@ -84,13 +95,92 @@ kiosk - Fullscreen mode
proxy:<server>:<port> (ie, proxy:wwwcache.lancs.ac.uk:8080) proxy:<server>:<port> (ie, proxy:wwwcache.lancs.ac.uk:8080)
open <file> - Opens the file as a stamp or game save open <file> - Opens the file as a stamp or game save
ddir <directory> - Directory used for saving stamps and preferences 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: History:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
* Version 65.4 * Version 73.0
o "Sand" effect for drawing powders, activate with "N" 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 Elements from Maksprog's mod
o LIGH - Lightning o LIGH - Lightning
o DEST - Variation of BOMB o DEST - Variation of BOMB
@ -99,6 +189,70 @@ History:
o Fix bug with infinite temperature o Fix bug with infinite temperature
o Fix beta enrolling o Fix beta enrolling
o Add a new mode to filter, subtract (tmp of 3) 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 * Version 47.3
o Enhanced visual effects for Portals o Enhanced visual effects for Portals
o Glow now has more stimuli (Green: Pressure, Blue: Movement, Red: Heat) o Glow now has more stimuli (Green: Pressure, Blue: Movement, Red: Heat)

View File

@ -166,6 +166,7 @@ extern int active_menu;
extern int hud_enable; extern int hud_enable;
extern int pretty_powder; extern int pretty_powder;
extern int drawgrav_enable; extern int drawgrav_enable;
extern int ngrav_enable;
int limitFPS; int limitFPS;
int water_equal_test; int water_equal_test;
extern int quickoptions_tooltip_fade; extern int quickoptions_tooltip_fade;

View File

@ -77,6 +77,8 @@ static quick_option quickmenu[] =
{"P", "Sand effect", QM_TOGGLE, &pretty_powder}, {"P", "Sand effect", QM_TOGGLE, &pretty_powder},
{"G", "Draw gravity grid", QM_TOGGLE, &drawgrav_enable}, {"G", "Draw gravity grid", QM_TOGGLE, &drawgrav_enable},
{"D", "Show decorations", QM_TOGGLE, &decorations_enable}, {"D", "Show decorations", QM_TOGGLE, &decorations_enable},
{"N", "Newtonian gravity", QM_TOGGLE, &ngrav_enable},
{"A", "Ambient heat", QM_TOGGLE, &aheat_enable},
{NULL} {NULL}
}; };
@ -101,12 +103,14 @@ static menu_wall colorlist[] =
#define DECO_DRAW 0 #define DECO_DRAW 0
#define DECO_LIGHTEN 1 #define DECO_LIGHTEN 1
#define DECO_DARKEN 2 #define DECO_DARKEN 2
#define DECO_SMUDGE 3
static menu_wall toollist[] = static menu_wall toollist[] =
{ {
{PIXPACK(0xFF0000), "Draw"}, {PIXPACK(0xFF0000), "Draw"},
{PIXPACK(0xDDDDDD), "Lighten"}, {PIXPACK(0xDDDDDD), "Lighten"},
{PIXPACK(0x111111), "Darken"}, {PIXPACK(0x111111), "Darken"},
{PIXPACK(0x00FF00), "Smudge"},
}; };
struct ui_edit 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(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); 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);

View File

@ -371,6 +371,7 @@ int update_ICEI(UPDATE_FUNC_ARGS);
int update_ISZ(UPDATE_FUNC_ARGS); int update_ISZ(UPDATE_FUNC_ARGS);
int update_LCRY(UPDATE_FUNC_ARGS); int update_LCRY(UPDATE_FUNC_ARGS);
int update_MORT(UPDATE_FUNC_ARGS); int update_MORT(UPDATE_FUNC_ARGS);
int update_NBLE(UPDATE_FUNC_ARGS);
int update_NEUT(UPDATE_FUNC_ARGS); int update_NEUT(UPDATE_FUNC_ARGS);
int update_NPTCT(UPDATE_FUNC_ARGS); int update_NPTCT(UPDATE_FUNC_ARGS);
int update_PCLN(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 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); void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags);

View File

@ -25,6 +25,7 @@
#define EFFECT 0xFF000000 #define EFFECT 0xFF000000
#define EFFECT_GRAVIN 0x01000000 #define EFFECT_GRAVIN 0x01000000
#define EFFECT_GRAVOUT 0x02000000 #define EFFECT_GRAVOUT 0x02000000
#define EFFECT_LINES 0x04000000
#define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE #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 #define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND | FIREMODE

File diff suppressed because one or more lines are too long

View File

@ -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}, {"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}, {"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}, {"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}, {"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}, {"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}, {"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},

View File

@ -27,5 +27,20 @@ int update_CO2(UPDATE_FUNC_ARGS) {
kill_part(r>>8); 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; return 0;
} }

View File

@ -79,7 +79,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
kill_part(i); kill_part(i);
return 1; 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); create_part(-1, x+rx, y+ry, PT_SPRK);
kill_part(i); kill_part(i);

View File

@ -3,6 +3,8 @@
int update_H2(UPDATE_FUNC_ARGS) int update_H2(UPDATE_FUNC_ARGS)
{ {
int r,rx,ry,rt; 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 (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++) for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || 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(r>>8,x+rx,y+ry,PT_WATR);
part_change_type(i,x,y,PT_OIL); 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 (rt==PT_FIRE)
if(parts[r>>8].tmp&0x02) {
parts[r>>8].temp=3473; parts[r>>8].temp=2473.15;
parts[r>>8].tmp |= 1; if(parts[r>>8].tmp&0x02)
} parts[r>>8].temp=3473;
if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA) parts[r>>8].tmp |= 1;
{ }
create_part(i,x,y,PT_FIRE); if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_LAVA)
parts[i].temp+=(rand()/(RAND_MAX/100)); {
parts[i].tmp |= 1; 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; return 0;
} }

26
src/elements/nble.c Normal file
View 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;
}

View File

@ -164,6 +164,7 @@ int graphics_WIFI(GRAPHICS_FUNC_ARGS)
*colr = sin(frequency*q + 0) * 127 + 128; *colr = sin(frequency*q + 0) * 127 + 128;
*colg = sin(frequency*q + 2) * 127 + 128; *colg = sin(frequency*q + 2) * 127 + 128;
*colb = sin(frequency*q + 4) * 127 + 128; *colb = sin(frequency*q + 4) * 127 + 128;
*pixel_mode |= EFFECT_LINES;
return 0; return 0;
} }
int graphics_PRTI(GRAPHICS_FUNC_ARGS) int graphics_PRTI(GRAPHICS_FUNC_ARGS)
@ -173,6 +174,7 @@ int graphics_PRTI(GRAPHICS_FUNC_ARGS)
*fireg = 0; *fireg = 0;
*fireb = 0; *fireb = 0;
*pixel_mode |= EFFECT_GRAVIN; *pixel_mode |= EFFECT_GRAVIN;
*pixel_mode |= EFFECT_LINES;
*pixel_mode &= ~PMODE; *pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_ADD; *pixel_mode |= PMODE_ADD;
return 1; return 1;
@ -184,6 +186,7 @@ int graphics_PRTO(GRAPHICS_FUNC_ARGS)
*fireg = 0; *fireg = 0;
*fireb = 255; *fireb = 255;
*pixel_mode |= EFFECT_GRAVOUT; *pixel_mode |= EFFECT_GRAVOUT;
*pixel_mode |= EFFECT_LINES;
*pixel_mode &= ~PMODE; *pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_ADD; *pixel_mode |= PMODE_ADD;
return 1; return 1;

View File

@ -55,8 +55,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
if (fe) { if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations int orbl[4] = {0, 0, 0, 0}; //Orbital locations
if (!parts[i].life) parts[i].life = rand(); if (!parts[i].life) parts[i].life = rand()*rand()*rand();
if (!parts[i].ctype) parts[i].ctype = rand(); if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (r = 0; r < 4; r++) { for (r = 0; r < 4; r++) {
if (orbd[r]>1) { if (orbd[r]>1) {

View File

@ -85,8 +85,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
if (fe) { if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations int orbl[4] = {0, 0, 0, 0}; //Orbital locations
if (!parts[i].life) parts[i].life = rand(); if (!parts[i].life) parts[i].life = rand()*rand()*rand();
if (!parts[i].ctype) parts[i].life = rand(); if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (r = 0; r < 4; r++) { for (r = 0; r < 4; r++) {
if (orbd[r]<254) { if (orbd[r]<254) {
@ -94,9 +94,10 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
if (orbd[r]>254) { if (orbd[r]>254) {
orbd[r] = 0; orbd[r] = 0;
orbl[r] = rand()%255; orbl[r] = rand()%255;
} else {
orbl[r] += 1;
orbl[r] = orbl[r]%255;
} }
//orbl[r] += 1;
//orbl[r] = orbl[r]%255;
} else { } else {
orbd[r] = 0; orbd[r] = 0;
orbl[r] = rand()%255; orbl[r] = rand()%255;

View File

@ -46,6 +46,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) {
(t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) && (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) &&
(t!=PT_PHOT || rt!=PT_INSL) && (t!=PT_PHOT || rt!=PT_INSL) &&
(rt!=PT_SPNG || parts[r>>8].life==0) && (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)) 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); part_change_type(r>>8,x+rx,y+ry,PT_FIRE);

View File

@ -44,7 +44,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
parts[nearp].ctype = PT_ETRD; 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; parts[i].life = rand()%150+50;
part_change_type(i,x,y,PT_PLSM); part_change_type(i,x,y,PT_PLSM);
@ -179,6 +179,8 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
conduct_sprk = 0; conduct_sprk = 0;
if (rt==PT_INST&&ct!=PT_PSCN) if (rt==PT_INST&&ct!=PT_PSCN)
conduct_sprk = 0; conduct_sprk = 0;
if (rt == PT_NBLE && parts[r>>8].tmp == 1)
conduct_sprk = 0;
if (conduct_sprk) { if (conduct_sprk) {
if (rt==PT_WATR||rt==PT_SLTW) { if (rt==PT_WATR||rt==PT_SLTW) {
@ -221,9 +223,9 @@ int graphics_SPRK(GRAPHICS_FUNC_ARGS)
{ {
*firea = 80; *firea = 80;
*firer = *colr = 170; *firer = 170;
*fireg = *colg = 200; *fireg = 200;
*fireb = *colb = 220; *fireb = 220;
//*pixel_mode |= FIRE_ADD; //*pixel_mode |= FIRE_ADD;
*pixel_mode |= FIRE_ADD; *pixel_mode |= FIRE_ADD;
return 1; return 1;

View File

@ -257,7 +257,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
{ {
int np = -1; int np = -1;
if (playerp->elem == SPC_AIR) 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 else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate
np = -1; np = -1;
else else

View File

@ -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; return x + w;
} }
#if defined(WIN32) && !defined(__GNUC__) int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
_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 i, j, w, bn = 0, ba = 0; int i, j, w, bn = 0, ba = 0;
char *rp = font_data + font_ptrs[c]; 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(pv[y][x], 0.0f, 8.0f),//pressure adds green
clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue 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); if (aheat_enable)
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)); float ttemp = hv[y][x]+(-MIN_TEMP);
//c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red 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);
// clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green 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));
// clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue //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) else if (display_mode & DISPLAY_AIRC)
{ {
@ -1934,6 +1935,11 @@ void render_parts(pixel *vid)
#endif #endif
//Pixel rendering //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) if(pixel_mode & PSPEC_STICKMAN)
{ {
char buff[20]; //Buffer for HP char buff[20]; //Buffer for HP
@ -2403,9 +2409,9 @@ void render_parts(pixel *vid)
for (r = 0; r < 4; r++) { for (r = 0; r < 4; r++) {
ddist = ((float)orbd[r])/16.0f; ddist = ((float)orbd[r])/16.0f;
drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f; drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f;
nxo = ddist*cos(drad); nxo = (int)(ddist*cos(drad));
nyo = ddist*sin(drad); nyo = (int)(ddist*sin(drad));
if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES) 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]); 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++) { for (r = 0; r < 4; r++) {
ddist = ((float)orbd[r])/16.0f; ddist = ((float)orbd[r])/16.0f;
drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f; drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f;
nxo = ddist*cos(drad); nxo = (int)(ddist*cos(drad));
nyo = ddist*sin(drad); nyo = (int)(ddist*sin(drad));
if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES) 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]); 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 //Fire effects
if(firea && (pixel_mode & FIRE_BLEND)) 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) 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]; rp = pmap[y][x];
if (!rp) if (!rp)
return; 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; 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)); 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) 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 #ifdef OGLR
int i; 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); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
glEnable(GL_COLOR_LOGIC_OP); 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 #else
int i,j,c; 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) if (rx<=0)
xor_pixel(x, y, vid); for (j = y - ry; j <= y + ry; j++)
else if (ry<=0) xor_pixel(x, j, vid);
xor_pixel(x, y, vid); else
if (rx+ry<=0)
xor_pixel(x, y, vid);
else if (CURRENT_BRUSH==SQUARE_BRUSH)
{ {
for (j=0; j<=ry; j++) int tempy = y, i, j, jmax, oldy;
for (i=0; i<=rx; i++) if (CURRENT_BRUSH == TRI_BRUSH)
if (i*j<=ry*rx && ((i+1)>rx || (j+1)>ry)) tempy = y + ry;
{ for (i = x - rx; i <= x; i++) {
xor_pixel(x+i, y+j, vid); oldy = tempy;
xor_pixel(x-i, y-j, vid); while (InCurrentBrush(i-x,tempy-y,rx,ry))
if (i&&j)xor_pixel(x+i, y-j, vid); tempy = tempy - 1;
if (i&&j)xor_pixel(x-i, y+j, vid); tempy = tempy + 1;
} jmax = 2*y - tempy;
} if (oldy != tempy && CURRENT_BRUSH != SQUARE_BRUSH)
else if (CURRENT_BRUSH==CIRCLE_BRUSH) oldy--;
{ if (CURRENT_BRUSH == TRI_BRUSH)
for (j=0; j<=ry; j++) oldy = tempy;
for (i=0; i<=rx; i++) for (j = tempy; j <= oldy; j++) {
if (pow(i,2)*pow(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2) && int i2 = 2*x-i, j2 = 2*y-j;
(pow(i+1,2)*pow(ry,2)+pow(j,2)*pow(rx,2)>pow(rx,2)*pow(ry,2) || if (CURRENT_BRUSH == TRI_BRUSH)
pow(i,2)*pow(ry,2)+pow(j+1,2)*pow(rx,2)>pow(rx,2)*pow(ry,2))) j2 = y+ry;
{ xor_pixel(i, j, vid);
xor_pixel(x+i, y+j, vid); if (i2 != i)
if (j) xor_pixel(x+i, y-j, vid); xor_pixel(i2, j, vid);
if (i) xor_pixel(x-i, y+j, vid); if (j2 != j)
if (i&&j) xor_pixel(x-i, y-j, vid); xor_pixel(i, j2, vid);
} if (i2 != i && j2 != j)
} xor_pixel(i2, j2, 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);
}
} }
} }
else //wall cursor else //wall cursor

View File

@ -2219,7 +2219,7 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
} }
*/ */
//current menu function //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; int h,x,y,n=0,height,width,sy,rows=0,xoff=0,fwidth;
SEC = SEC2; 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; SEC2 = -1;
} }
else { else {
*sl = h; *sl = *su = h;
*dae = 51; *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; SEC2 = -1;
} }
else { else {
*sr = h; *sr = *su = h;
*dae = 51; *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))); float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
xoff = (int)(overflow / location); xoff = (int)(overflow / location);
} }
for (n = 0; n<3; n++) for (n = 0; n<4; n++)
{ {
for (a=1; a<15; a++) 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); 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) 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); 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) else if (n == DECO_DRAW)
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(*cr,*cg,*cb); vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(*cr,*cg,*cb);
else 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; quickoptions_tooltip_y = (i*16)+5;
if(b && !bq) 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; colour_mode = COLOUR_HEAT;
strcpy(itc_msg, "Heat Display"); 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) else if (cmode==CM_FANCY)
{ {

View File

@ -1286,9 +1286,9 @@ int luatpt_set_property(lua_State* l)
} }
i = r>>8; i = r>>8;
if(format==2){ if(format==2){
*((float*)(((void*)&parts[i])+offset)) = f; *((float*)(((char*)&parts[i])+offset)) = f;
} else { } else {
*((int*)(((void*)&parts[i])+offset)) = t; *((int*)(((char*)&parts[i])+offset)) = t;
} }
} }
} else { } else {
@ -1310,9 +1310,9 @@ int luatpt_set_property(lua_State* l)
if (partsel && partsel != parts[i].type) if (partsel && partsel != parts[i].type)
return 0; return 0;
if(format==2){ if(format==2){
*((float*)(((void*)&parts[i])+offset)) = f; *((float*)(((char*)&parts[i])+offset)) = f;
} else { } else {
*((int*)(((void*)&parts[i])+offset)) = t; *((int*)(((char*)&parts[i])+offset)) = t;
} }
} }
return 0; return 0;

View File

@ -355,6 +355,12 @@ void stamp_update(void)
{ {
fwrite(stamps[i].name, 1, 10, f); 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); fclose(f);
} }
@ -1755,7 +1761,7 @@ int main(int argc, char *argv[])
active_menu = i; 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 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) && x<sdl_scale*(zoom_wx+ZFACTOR*ZSIZE)
&& y<sdl_scale*(zoom_wy+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]); sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]);
if (DEBUG_MODE) 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) 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) if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
sys_pause = !sys_pause; 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) 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()); flood_parts(x, y, c, -1, -1, get_brush_flags());
if (c==SPC_HEAT || c==SPC_COOL) 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; lx = x;
ly = y; ly = y;
lb = 0; lb = 0;
@ -2418,7 +2427,7 @@ int main(int argc, char *argv[])
cb_bmap[cby][cbx] = bmap[cby][cbx]; cb_bmap[cby][cbx] = bmap[cby][cbx];
cb_emap[cby][cbx] = emap[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; lx = x;
ly = y; ly = y;
lb = b; lb = b;

View File

@ -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)) if (parts[i].type==PT_NEUT && (ptypes[r&0xFF].properties&PROP_NEUTABSORB))
{ {
parts[i].type=PT_NONE; kill_part(i);
return 0; return 0;
} }
if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_PVOD) //this is where void eats particles if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_PVOD) //this is where void eats particles
{ {
if (parts[i].type == PT_STKM) kill_part(i);
{
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;
return 0; return 0;
} }
if ((r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) //this is where blackhole eats particles if ((r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) //this is where blackhole eats particles
{ {
if (parts[i].type == PT_STKM) kill_part(i);
{
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;
if (!legacy_enable) if (!legacy_enable)
{ {
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP);//3.0f; 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 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) if (!legacy_enable)
{ {
parts[r>>8].temp = restrict_flt(parts[r>>8].temp- (MAX_TEMP-parts[i].temp)/2, MIN_TEMP, MAX_TEMP); 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 // 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 do_move(int i, int x, int y, float nxf, float nyf)
{ {
int nx = (int)(nxf+0.5f), ny = (int)(nyf+0.5f); int nx = (int)(nxf+0.5f), ny = (int)(nyf+0.5f), result;
int result = try_move(i, x, y, nx, ny); if (parts[i].type == PT_NONE)
return 0;
result = try_move(i, x, y, nx, ny);
if (result) if (result)
{ {
int t = parts[i].type; int t = parts[i].type;
@ -613,6 +589,9 @@ void kill_part(int i)//kills particle number i
{ {
int x, y; 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); x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f); y = (int)(parts[i].y+0.5f);
if (parts[i].type == PT_STKM) if (parts[i].type == PT_STKM)
@ -2284,13 +2263,15 @@ killed:
if (stagnant)//FLAG_STAGNANT set, was reflected on previous frame if (stagnant)//FLAG_STAGNANT set, was reflected on previous frame
{ {
// cast coords as int then back to float for compatibility with existing saves // 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); kill_part(i);
continue; continue;
} }
} }
else if (!do_move(i, x, y, fin_xf, fin_yf)) else if (!do_move(i, x, y, fin_xf, fin_yf))
{ {
if (parts[i].type == PT_NONE)
continue;
// reflection // reflection
parts[i].flags |= FLAG_STAGNANT; parts[i].flags |= FLAG_STAGNANT;
if (t==PT_NEUT && 100>(rand()%1000)) if (t==PT_NEUT && 100>(rand()%1000))
@ -2350,6 +2331,8 @@ killed:
// gasses and solids (but not powders) // gasses and solids (but not powders)
if (!do_move(i, x, y, fin_xf, fin_yf)) if (!do_move(i, x, y, fin_xf, fin_yf))
{ {
if (parts[i].type == PT_NONE)
continue;
// can't move there, so bounce off // can't move there, so bounce off
// TODO // TODO
if (fin_x>x+ISTP) fin_x=x+ISTP; if (fin_x>x+ISTP) fin_x=x+ISTP;
@ -2381,6 +2364,8 @@ killed:
// liquids and powders // liquids and powders
if (!do_move(i, x, y, fin_xf, fin_yf)) 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)) if (fin_x!=x && do_move(i, x, y, fin_xf, clear_yf))
{ {
parts[i].vx *= ptypes[t].collision; 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 (j=y1; j<=y2; j++)
for (i=x1; i<=x2; i++) 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) 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) if (create_part(-1,x, y, fullc)==-1)
return 0; 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; return 0;
} }
// fill children // 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 //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; int wall = c - 100;
if (c==SPC_WIND || c==PT_FIGH) 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); prop_edit_ui(vid_buf, x, y);
return 0; 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++) for (r=UI_ACTUALSTART; r<=UI_ACTUALSTART+UI_WALLCOUNT; r++)
{ {
if (wall==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; return 1;
} }
//eraser if (c == 0 && !(flags&BRUSH_REPLACEMODE)) // delete
if (c == 0 && !(flags&BRUSH_REPLACEMODE)) fn = 0;
{ else if ((flags&BRUSH_SPECIFIC_DELETE) && !(flags&BRUSH_REPLACEMODE)) // specific delete
if (rx==0&&ry==0) fn = 1;
{ else if (flags&BRUSH_REPLACEMODE) // replace
delete_part(x, y, 0); fn = 2;
} else // normal draw
else fn = 3;
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;
}
//specific deletion if (rx<=0) //workaround for rx == 0 crashing. todo: find a better fix later.
if ((flags&BRUSH_SPECIFIC_DELETE)&& !(flags&BRUSH_REPLACEMODE))
{ {
if (rx==0&&ry==0) for (j = y - ry; j <= y + ry; j++)
{ if (create_parts2(fn,x,j,c,rx,ry,flags))
delete_part(x, y, flags); f = 1;
}
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;
} }
else
//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)
{ {
if (rx==0&&ry==0) int tempy = y, i, j, jmax, oldy;
{ if (CURRENT_BRUSH == TRI_BRUSH)
create_part(-2, x, y, c); tempy = y + ry;
} for (i = x - rx; i <= x; i++) {
else oldy = tempy;
for (j=-ry; j<=ry; j++) while (InCurrentBrush(i-x,tempy-y,rx,ry))
for (i=-rx; i<=rx; i++) tempy = tempy - 1;
if (InCurrentBrush(i ,j ,rx ,ry)) tempy = tempy + 1;
{ jmax = 2*y - tempy;
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES) if (CURRENT_BRUSH == TRI_BRUSH)
continue; jmax = y + ry;
if (!REPLACE_MODE) if (fill)
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)
{ {
if ((pmap[y][x])) for (j = tempy; j <= jmax; j++) {
{ if (create_parts2(fn,i,j,c,rx,ry,flags))
delete_part(x, y, 0); f = 1;
if (c!=0) if (create_parts2(fn,2*x-i,j,c,rx,ry,flags))
create_part_add_props(-2, x, y, c, rx, ry); 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; 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) int InCurrentBrush(int i, int j, int rx, int ry)
{ {
switch(CURRENT_BRUSH) switch(CURRENT_BRUSH)
{ {
case CIRCLE_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; break;
case SQUARE_BRUSH: case SQUARE_BRUSH:
return (i*j<=ry*rx); return (abs(i) <= rx && abs(j) <= ry);
break; break;
case TRI_BRUSH: case TRI_BRUSH:
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ; 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) 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; float e, de;
if (c==SPC_PROP) if (c==SPC_PROP)
return; 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++) for (x=x1; x<=x2; x++)
{ {
if (cp) if (cp)
create_parts(y, x, rx, ry, c, flags); create_parts(y, x, rx, ry, c, flags, fill);
else else
create_parts(x, y, rx, ry, c, flags); create_parts(x, y, rx, ry, c, flags, fill);
fill = 0;
e += de; e += de;
if (e >= 0.5f) 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))) && ((y1<y2) ? (y<=y2) : (y>=y2)))
{ {
if (cp) if (cp)
create_parts(y, x, rx, ry, c, flags); create_parts(y, x, rx, ry, c, flags, fill);
else else
create_parts(x, y, rx, ry, c, flags); create_parts(x, y, rx, ry, c, flags, fill);
} }
e -= 1.0f; e -= 1.0f;
} }

View File

@ -52,11 +52,42 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
return 1; 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) pixel *prerender_save_OPS(void *save, int size, int *width, int *height)
{ {
unsigned char * inputData = save, *bsonData = NULL, *partsData = NULL, *partsPosData = NULL, *wallData = NULL; unsigned char * inputData = save, *bsonData = NULL, *partsData = NULL, *partsPosData = NULL, *wallData = NULL;
int inputDataLen = size, bsonDataLen = 0, partsDataLen, partsPosDataLen, wallDataLen; 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 blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
int bsonInitialised = 0; int bsonInitialised = 0;
pixel * vidBuf = NULL; pixel * vidBuf = NULL;
@ -177,14 +208,65 @@ pixel *prerender_save_OPS(void *save, int size, int *width, int *height)
{ {
if(wallData[y*blockW+x]) 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++) 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))] = PIXPACK(0xCCCCCC); 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]; wallData[(y-blockY)*blockW+(x-blockX)] = bmap[y][x];
if(bmap[y][x] && !wallDataFound) if(bmap[y][x] && !wallDataFound)
wallDataFound = 1; 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); i = (int)(fvx[y][x]*64.0f+127.5f);
if (i<0) i=0; 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++) for(y = 0; y < blockH; y++)
{ {
bmap[blockY+y][blockX+x] = wallData[y*blockW+x]; if (wallData[y*blockW+x])
if((bmap[blockY+y][blockX+x]==WL_FAN || bmap[blockY+y][blockX+x]==4) && fanData) bmap[blockY+y][blockX+x] = wallData[y*blockW+x];
if (wallData[y*blockW+x] == WL_FAN && fanData)
{ {
if(j+1 >= fanDataLen) if(j+1 >= fanDataLen)
{ {
@ -1222,7 +1305,7 @@ fin:
pixel *prerender_save_PSv(void *save, int size, int *width, int *height) pixel *prerender_save_PSv(void *save, int size, int *width, int *height)
{ {
unsigned char *d,*c=save; 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; int bw,bh,w,h,new_format = 0;
pixel *fb; 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 (y=0; y<bh; y++)
for (x=0; x<bw; x++) for (x=0; x<bw; x++)
{ {
int wt = change_wall(d[p]);
rx = x*CELL; rx = x*CELL;
ry = y*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 (i=0; i<CELL; i+=2)
for (j=0; j<CELL; j++) for (j=(i>>1)&1; j<CELL; j+=2)
for (i=0; i<CELL; i++) fb[(i+ry)*w+(j+rx)] = pc;
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;
} }
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++;
} }
p += 2*k; p += 2*k;
@ -1757,33 +1815,7 @@ int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned c
continue; continue;
} }
bmap[y][x] = d[p]; bmap[y][x] = change_wall(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;
} }
p++; p++;