Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
This commit is contained in:
commit
6254d4064d
166
README
166
README
@ -35,7 +35,7 @@ Controls:
|
||||
|
||||
Caps Lock Specific Element Erase
|
||||
Insert Replace mode
|
||||
TAB Circle/Square Brush
|
||||
TAB Switch between circle/square/triangle brush
|
||||
Space Pause
|
||||
Q Quit
|
||||
Esc Quit
|
||||
@ -49,16 +49,27 @@ 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
|
||||
[ 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
|
||||
@ -70,7 +81,7 @@ 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 + Left Alt Select element for Specific Element erase
|
||||
Ctrl + = Reset Electricity
|
||||
|
||||
|
||||
@ -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
|
||||
@ -37,6 +38,7 @@
|
||||
#define COLOUR_HEAT 0x00000001
|
||||
#define COLOUR_LIFE 0x00000002
|
||||
#define COLOUR_GRAD 0x00000004
|
||||
#define COLOUR_BASC 0x00000008
|
||||
|
||||
#define COLOUR_DEFAULT 0x00000000
|
||||
|
||||
|
5
includes/squares.h
Normal file
5
includes/squares.h
Normal file
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},
|
||||
|
@ -44,12 +44,11 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
|
||||
} else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT
|
||||
colored = parts[r>>8].ctype;
|
||||
//this if prevents BRAY from stopping on certain materials
|
||||
} else if ((r&0xFF)!=PT_STOR && (r&0xFF)!=PT_INWR && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) {
|
||||
} else if ((r&0xFF)!=PT_STOR && (r&0xFF)!=PT_INWR && ((r&0xFF)!=PT_SPRK || parts[r>>8].ctype!=PT_INWR) && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) {
|
||||
if (nyy!=0 || nxx!=0) {
|
||||
create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
|
||||
}
|
||||
//if (!(nostop && (ptypes[r&0xFF].properties&PROP_CONDUCTS))) {
|
||||
if (!(nostop && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) {
|
||||
if (!(nostop && parts[r>>8].type==PT_SPRK && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) {
|
||||
docontinue = 0;
|
||||
} else {
|
||||
docontinue = 1;
|
||||
|
@ -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);
|
||||
|
@ -4,41 +4,41 @@ int update_FIGH(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
playerst* figh = &fighters[(unsigned char)parts[i].tmp];
|
||||
|
||||
float tarx, tary;
|
||||
unsigned int tarx, tary;
|
||||
|
||||
parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man
|
||||
|
||||
//Set target cords
|
||||
if (player.spwn)
|
||||
if (player.spwn && player2.spwn)
|
||||
{
|
||||
if (player2.spwn)
|
||||
if ((pow(player.legs[2]-x, 2) + pow(player.legs[3]-y, 2))<=
|
||||
(pow(player2.legs[2]-x, 2) + pow(player2.legs[3]-y, 2)))
|
||||
{
|
||||
tarx = player.legs[2];
|
||||
tary = player.legs[3];
|
||||
tarx = (unsigned int)player.legs[2];
|
||||
tary = (unsigned int)player.legs[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
tarx = player2.legs[2];
|
||||
tary = player2.legs[3];
|
||||
tarx = (unsigned int)player2.legs[2];
|
||||
tary = (unsigned int)player2.legs[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
tarx = player.legs[2];
|
||||
tary = player.legs[3];
|
||||
}
|
||||
|
||||
parts[i].tmp2 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.spwn)
|
||||
{
|
||||
tarx = (unsigned int)player.legs[2];
|
||||
tary = (unsigned int)player.legs[3];
|
||||
parts[i].tmp2 = 1;
|
||||
}
|
||||
if (player2.spwn)
|
||||
{
|
||||
tarx = player2.legs[2];
|
||||
tary = player2.legs[3];
|
||||
|
||||
tarx = (unsigned int)player2.legs[2];
|
||||
tary = (unsigned int)player2.legs[3];
|
||||
parts[i].tmp2 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (parts[i].tmp2)
|
||||
{
|
||||
@ -51,9 +51,10 @@ int update_FIGH(UPDATE_FUNC_ARGS)
|
||||
figh->comm = (int)figh->comm | 0x08;
|
||||
}
|
||||
else
|
||||
if (tarx<x )
|
||||
if (tarx<x)
|
||||
{
|
||||
if(!eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+6, NULL))
|
||||
if(!(eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+6, NULL)
|
||||
&& eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+3, NULL)))
|
||||
figh->comm = 0x01;
|
||||
else
|
||||
figh->comm = 0x02;
|
||||
@ -65,7 +66,8 @@ int update_FIGH(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+6, NULL))
|
||||
if (!(eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+6, NULL)
|
||||
&& eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+3, NULL)))
|
||||
figh->comm = 0x02;
|
||||
else
|
||||
figh->comm = 0x01;
|
||||
|
@ -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)
|
||||
{
|
||||
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 ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)
|
||||
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;
|
||||
|
@ -31,6 +31,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH)
|
||||
continue;// Handling these is a bit more complicated, and is done in STKM_interact()
|
||||
|
||||
if ((r&0xFF) == PT_SOAP)
|
||||
detach(r>>8);
|
||||
|
||||
@ -52,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) {
|
||||
|
@ -47,8 +47,31 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
|
||||
player.spwn = 0;
|
||||
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
|
||||
player2.spwn = 0;
|
||||
if (portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH)
|
||||
{
|
||||
fighcount--;
|
||||
fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 0;
|
||||
}
|
||||
np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type);
|
||||
if (np<0) continue;
|
||||
if (np<0)
|
||||
{
|
||||
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
|
||||
player.spwn = 1;
|
||||
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
|
||||
player2.spwn = 1;
|
||||
if (portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH)
|
||||
{
|
||||
fighcount++;
|
||||
fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (parts[np].type==PT_FIGH)
|
||||
{
|
||||
// Release the fighters[] element allocated by create_part, the one reserved when the fighter went into the portal will be used
|
||||
fighters[(unsigned char)parts[np].tmp].spwn = 0;
|
||||
fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
|
||||
}
|
||||
parts[np] = portalp[parts[i].tmp][randomness][nnx];
|
||||
parts[np].x = x+rx;
|
||||
parts[np].y = y+ry;
|
||||
@ -62,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) {
|
||||
@ -71,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
|
||||
@ -451,7 +451,10 @@ void STKM_interact(playerst* playerp, int i, int x, int y)
|
||||
{
|
||||
portalp[parts[r>>8].tmp][count][nnx] = parts[i];
|
||||
kill_part(i);
|
||||
playerp->spwn = 1;//stop SPWN creating a new STKM while he is in portal
|
||||
//stop new STKM/fighters being created to replace the ones in the portal:
|
||||
playerp->spwn = 1;
|
||||
if (portalp[parts[r>>8].tmp][count][nnx].type==PT_FIGH)
|
||||
fighcount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
170
src/graphics.c
170
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,7 +1314,9 @@ 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))
|
||||
{
|
||||
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);
|
||||
@ -1327,6 +1325,9 @@ void draw_air(pixel *vid)
|
||||
// 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)
|
||||
{
|
||||
int r;
|
||||
@ -1806,7 +1807,7 @@ void render_parts(pixel *vid)
|
||||
fireg = graphicscache[t].fireg;
|
||||
fireb = graphicscache[t].fireb;
|
||||
}
|
||||
else
|
||||
else if(!(colour_mode & COLOUR_BASC)) //Don't get special effects for BASIC colour mode
|
||||
{
|
||||
if (ptypes[t].graphics_func)
|
||||
{
|
||||
@ -1885,18 +1886,16 @@ void render_parts(pixel *vid)
|
||||
cola = 255;
|
||||
if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR;
|
||||
}
|
||||
else if (colour_mode & COLOUR_GRAD)
|
||||
else if (colour_mode & COLOUR_BASC)
|
||||
{
|
||||
float frequency = 0.05;
|
||||
int q = parts[i].temp-40;
|
||||
colr = sin(frequency*q) * 16 + colr;
|
||||
colg = sin(frequency*q) * 16 + colg;
|
||||
colb = sin(frequency*q) * 16 + colb;
|
||||
if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR;
|
||||
colr = PIXR(ptypes[t].pcolors);
|
||||
colg = PIXG(ptypes[t].pcolors);
|
||||
colb = PIXB(ptypes[t].pcolors);
|
||||
pixel_mode = PMODE_FLAT;
|
||||
}
|
||||
|
||||
//Apply decoration colour
|
||||
if(!colour_mode)
|
||||
if(!(colour_mode & ~COLOUR_GRAD))
|
||||
{
|
||||
if(!(pixel_mode & NO_DECO) && decorations_enable)
|
||||
{
|
||||
@ -1913,6 +1912,16 @@ void render_parts(pixel *vid)
|
||||
}
|
||||
}
|
||||
|
||||
if (colour_mode & COLOUR_GRAD)
|
||||
{
|
||||
float frequency = 0.05;
|
||||
int q = parts[i].temp-40;
|
||||
colr = sin(frequency*q) * 16 + colr;
|
||||
colg = sin(frequency*q) * 16 + colg;
|
||||
colb = sin(frequency*q) * 16 + colb;
|
||||
if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR;
|
||||
}
|
||||
|
||||
#ifndef OGLR
|
||||
//All colours are now set, check ranges
|
||||
if(colr>255) colr = 255;
|
||||
@ -1926,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
|
||||
@ -2395,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]);
|
||||
}
|
||||
}
|
||||
@ -2413,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))
|
||||
{
|
||||
@ -2909,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;
|
||||
@ -2938,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)
|
||||
{
|
||||
@ -3580,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);
|
||||
@ -3620,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);
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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,6 +2621,14 @@ void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y)
|
||||
quickoptions_tooltip_y = (i*16)+5;
|
||||
if(b && !bq)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -6426,10 +6441,10 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
|
||||
int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A, -1};
|
||||
char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent", "Effects"};
|
||||
|
||||
int colour_optioncount = 3;
|
||||
int colour_options[] = {COLOUR_LIFE, COLOUR_HEAT, COLOUR_GRAD};
|
||||
int colour_optionicons[] = {0xE0, 0xBE, 0xD3};
|
||||
char * colour_desc[] = {"Life", "Heat", "Heat Gradient"};
|
||||
int colour_optioncount = 4;
|
||||
int colour_options[] = {COLOUR_BASC, COLOUR_LIFE, COLOUR_HEAT, COLOUR_GRAD};
|
||||
int colour_optionicons[] = {0xDB, 0xE0, 0xBE, 0xD3};
|
||||
char * colour_desc[] = {"Basic", "Life", "Heat", "Heat Gradient"};
|
||||
|
||||
yoffset = 16;
|
||||
xoffset = 0;
|
||||
|
@ -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;
|
||||
|
17
src/main.c
17
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)
|
||||
{
|
||||
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;
|
||||
|
269
src/powder.c
269
src/powder.c
@ -1,6 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <defines.h>
|
||||
#include <squares.h>
|
||||
#include <powder.h>
|
||||
#include <air.h>
|
||||
#include <misc.h>
|
||||
@ -317,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;
|
||||
@ -363,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);
|
||||
@ -414,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;
|
||||
@ -612,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)
|
||||
@ -1831,8 +1811,14 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
|
||||
if (ptypes[t].diffusion)//the random diffusion that gasses have
|
||||
{
|
||||
#ifdef REALISTIC
|
||||
//The magic number controlls diffusion speed
|
||||
parts[i].vx += 0.05*squares[(unsigned int)round(parts[i].temp)]*ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vy += 0.05*squares[(unsigned int)round(parts[i].temp)]*ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
#else
|
||||
parts[i].vx += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vy += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
j = surround_space = nt = 0;//if nt is 1 after this, then there is a particle around the current particle, that is NOT the current particle's type, for water movement.
|
||||
@ -1863,8 +1849,8 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
|
||||
//heat transfer code
|
||||
h_count = 0;
|
||||
#ifdef REALHEAT
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10))
|
||||
#ifdef REALISTIC
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct)
|
||||
{
|
||||
float c_Cm = 0.0f;
|
||||
#else
|
||||
@ -1874,12 +1860,25 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
#endif
|
||||
if (aheat_enable)
|
||||
{
|
||||
#ifdef REALISTIC
|
||||
c_heat = parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight)
|
||||
+ hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256;
|
||||
c_Cm = 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight)
|
||||
+ 100*(pv[y/CELL][x/CELL]+273.15f)/256;
|
||||
pt = c_heat/c_Cm;
|
||||
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||
parts[i].temp = pt;
|
||||
//Pressure increase from heat (temporary)
|
||||
pv[y/CELL][x/CELL] += (pt-hv[y/CELL][x/CELL])*0.004;
|
||||
hv[y/CELL][x/CELL] = pt;
|
||||
#else
|
||||
c_heat = (hv[y/CELL][x/CELL]-parts[i].temp)*0.04;
|
||||
c_heat = restrict_flt(c_heat, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||
parts[i].temp += c_heat;
|
||||
hv[y/CELL][x/CELL] -= c_heat;
|
||||
#endif
|
||||
}
|
||||
c_heat = 0.0f;
|
||||
c_heat = 0.0f; c_Cm = 0.0f;
|
||||
for (j=0; j<8; j++)
|
||||
{
|
||||
surround_hconduct[j] = i;
|
||||
@ -1892,7 +1891,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG)))
|
||||
{
|
||||
surround_hconduct[j] = r>>8;
|
||||
#ifdef REALHEAT
|
||||
#ifdef REALISTIC
|
||||
c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight);
|
||||
c_Cm += 96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight);
|
||||
#else
|
||||
@ -1901,7 +1900,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
h_count++;
|
||||
}
|
||||
}
|
||||
#ifdef REALHEAT
|
||||
#ifdef REALISTIC
|
||||
if (t == PT_PHOT)
|
||||
pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645);
|
||||
else
|
||||
@ -2196,7 +2195,7 @@ killed:
|
||||
clear_y = (int)(clear_yf+0.5f);
|
||||
break;
|
||||
}
|
||||
if (fin_x<CELL || fin_y<CELL || fin_x>=XRES-CELL || fin_y>=YRES-CELL || pmap[fin_y][fin_x] || (bmap[fin_y/CELL][fin_x/CELL] && (bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL || bmap[fin_y/CELL][fin_x/CELL]==WL_DETECT || !eval_move(t,fin_x,fin_y,NULL))))
|
||||
if (fin_x<CELL || fin_y<CELL || fin_x>=XRES-CELL || fin_y>=YRES-CELL || pmap[fin_y][fin_x] || (bmap[fin_y/CELL][fin_x/CELL] && (bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL || !eval_move(t,fin_x,fin_y,NULL))))
|
||||
{
|
||||
// found an obstacle
|
||||
clear_xf = fin_xf-dx;
|
||||
@ -2205,7 +2204,8 @@ killed:
|
||||
clear_y = (int)(clear_yf+0.5f);
|
||||
break;
|
||||
}
|
||||
|
||||
if (bmap[fin_y/CELL][fin_x/CELL]==WL_DETECT && emap[fin_y/CELL][fin_x/CELL]<8)
|
||||
set_emap(fin_x/CELL, fin_y/CELL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2263,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))
|
||||
@ -2329,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;
|
||||
@ -2360,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;
|
||||
@ -2703,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)
|
||||
@ -2828,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
|
||||
@ -2951,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)
|
||||
@ -2963,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)
|
||||
@ -3054,64 +3062,80 @@ 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 (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;
|
||||
|
||||
if (rx<=0) //workaround for rx == 0 crashing. todo: find a better fix later.
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
for (j = y - ry; j <= y + ry; j++)
|
||||
if (create_parts2(fn,x,j,c,rx,ry,flags))
|
||||
f = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
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 ((flags&BRUSH_SPECIFIC_DELETE)&& !(flags&BRUSH_REPLACEMODE))
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
{
|
||||
else if (f == 1) //specific delete
|
||||
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;
|
||||
}
|
||||
|
||||
//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)
|
||||
{
|
||||
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)
|
||||
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);
|
||||
@ -3119,49 +3143,21 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
|
||||
create_part_add_props(-2, x, y, c, rx, ry);
|
||||
}
|
||||
}
|
||||
}
|
||||
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.
|
||||
{
|
||||
else if (f == 3) //normal draw
|
||||
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 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 ) ;
|
||||
@ -3184,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;
|
||||
@ -3218,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)
|
||||
{
|
||||
@ -3229,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;
|
||||
}
|
||||
|
285
src/save.c
285
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++)
|
||||
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)
|
||||
{
|
||||
vidBuf[(fullY+i+(y*CELL))*fullW+(fullX+j+(x*CELL))] = PIXPACK(0xCCCCCC);
|
||||
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++)
|
||||
{
|
||||
if (wallData[y*blockW+x])
|
||||
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] == 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++;
|
||||
@ -2299,6 +2331,7 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
||||
float (*pvn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float));
|
||||
int i, x, y, nx, ny, w, h, nw, nh;
|
||||
vector2d pos, tmp, ctl, cbr;
|
||||
vector2d vel;
|
||||
vector2d cornerso[4];
|
||||
unsigned char *odatac = odata;
|
||||
if (parse_save(odata, *size, 0, 0, 0, bmapo, vxo, vyo, pvo, fvxo, fvyo, signst, partst, pmapt))
|
||||
@ -2373,6 +2406,10 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
||||
}
|
||||
partst[i].x = nx;
|
||||
partst[i].y = ny;
|
||||
vel = v2d_new(partst[i].vx, partst[i].vy);
|
||||
vel = m2d_multiply_v2d(transform, vel);
|
||||
partst[i].vx = vel.x;
|
||||
partst[i].vy = vel.y;
|
||||
}
|
||||
for (y=0; y<YRES/CELL; y++)
|
||||
for (x=0; x<XRES/CELL; x++)
|
||||
@ -2388,12 +2425,16 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
|
||||
bmapn[ny][nx] = bmapo[y][x];
|
||||
if (bmapo[y][x]==WL_FAN)
|
||||
{
|
||||
fvxn[ny][nx] = fvxo[y][x];
|
||||
fvyn[ny][nx] = fvyo[y][x];
|
||||
vel = v2d_new(fvxo[y][x], fvyo[y][x]);
|
||||
vel = m2d_multiply_v2d(transform, vel);
|
||||
fvxn[ny][nx] = vel.x;
|
||||
fvyn[ny][nx] = vel.y;
|
||||
}
|
||||
}
|
||||
vxn[ny][nx] = vxo[y][x];
|
||||
vyn[ny][nx] = vyo[y][x];
|
||||
vel = v2d_new(vxo[y][x], vyo[y][x]);
|
||||
vel = m2d_multiply_v2d(transform, vel);
|
||||
vxn[ny][nx] = vel.x;
|
||||
vyn[ny][nx] = vel.y;
|
||||
pvn[ny][nx] = pvo[y][x];
|
||||
}
|
||||
ndata = build_save(size,0,0,nw,nh,bmapn,vxn,vyn,pvn,fvxn,fvyn,signst,partst);
|
||||
|
Loading…
Reference in New Issue
Block a user