summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryan Hoyle <starfoxprime@gmail.com>2011-08-24 00:29:26 (GMT)
committer Bryan Hoyle <starfoxprime@gmail.com>2011-08-24 00:29:26 (GMT)
commit578144c48a1b35ae8d0763637752d935169663ac (patch)
treead0407b144aca61502e8419c96fc385a9f5aea28 /src
parentf577c319db982e6b3d3b3731f1980c89182da982 (diff)
parent6581c29bf7eaf07483178804199f090b1c0e43ff (diff)
downloadpowder-578144c48a1b35ae8d0763637752d935169663ac.zip
powder-578144c48a1b35ae8d0763637752d935169663ac.tar.gz
Merge remote branch 'origin/master'
Diffstat (limited to 'src')
-rw-r--r--src/elements/bomb.c2
-rw-r--r--src/elements/prti.c28
-rw-r--r--src/elements/prto.c43
-rw-r--r--src/elements/sprk.c4
-rw-r--r--src/elements/stkm.c60
-rw-r--r--src/graphics.c16
-rw-r--r--src/interface.c20
-rw-r--r--src/luaconsole.c28
-rw-r--r--src/main.c48
-rw-r--r--src/powder.c132
-rw-r--r--src/pythonconsole.c2
11 files changed, 207 insertions, 176 deletions
diff --git a/src/elements/bomb.c b/src/elements/bomb.c
index 8115a88..de10fcc 100644
--- a/src/elements/bomb.c
+++ b/src/elements/bomb.c
@@ -44,7 +44,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
for (nxi=-rad; nxi<=rad; nxi++)
if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1)
if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) {
- delete_part(x+nxi, y+nxj);//it SHOULD kill anything but the exceptions above, doesn't seem to always work
+ delete_part(x+nxi, y+nxj, 0);//it SHOULD kill anything but the exceptions above, doesn't seem to always work
pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
if (nb!=-1) {
diff --git a/src/elements/prti.c b/src/elements/prti.c
index f7599bf..7038412 100644
--- a/src/elements/prti.c
+++ b/src/elements/prti.c
@@ -1,26 +1,27 @@
#include <element.h>
-/*these are the count vaules of where the particle gets stored, depending on where it came from
- 1 4 6
- 2 . 7
- 3 5 8
- PRTO counts backwards, so that it will come out at the opposite place of where it came in
- 8 5 3
- 7 . 2
- 6 4 1
+/*these are the count values of where the particle gets stored, depending on where it came from
+ 0 1 2
+ 7 . 3
+ 6 5 4
+ PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
+int portal_rx[8] = {-1, 0, 1, 1, 1, 0,-1,-1};
+int portal_ry[8] = {-1,-1,-1, 0, 1, 1, 1, 0};
+
int update_PRTI(UPDATE_FUNC_ARGS) {
int r, nnx, rx, ry, fe = 0;
int count =0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
- for (rx=-1; rx<2; rx++)
- for (ry=-1; ry<2; ry++)
+ for (count=0; count<8; count++)
+ {
+ rx = portal_rx[count];
+ ry = portal_ry[count];
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- count ++;
if (!r)
fe = 1;
if ((r>>8)>=NPART)
@@ -38,9 +39,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
detach(r>>8);
for ( nnx=0; nnx<80; nnx++)
- if (!portalp[parts[i].tmp][count-1][nnx].type)
+ if (!portalp[parts[i].tmp][count][nnx].type)
{
- portalp[parts[i].tmp][count-1][nnx] = parts[r>>8];
+ portalp[parts[i].tmp][count][nnx] = parts[r>>8];
if ((r&0xFF)==PT_SPRK)
part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
else
@@ -49,6 +50,7 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
break;
}
}
+ }
if (fe) {
diff --git a/src/elements/prto.c b/src/elements/prto.c
index 38718a5..880de20 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -1,12 +1,9 @@
#include <element.h>
-/*these are the count vaules of where the particle gets stored, depending on where it came from
- 1 4 6
- 2 . 7
- 3 5 8
- PRTO counts backwards, so that it will come out at the opposite place of where it came in
- 8 5 3
- 7 . 2
- 6 4 1
+/*these are the count values of where the particle gets stored, depending on where it came from
+ 0 1 2
+ 7 . 3
+ 6 5 4
+ PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
int update_PRTO(UPDATE_FUNC_ARGS) {
@@ -15,12 +12,13 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
- for (rx=1; rx>-2; rx--)
- for (ry=1; ry>-2; ry--)
+ for (count=0; count<8; count++)
+ {
+ rx = portal_rx[count];
+ ry = portal_ry[count];
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- count ++;
if (!r)
fe = 1;
if ((r>>8)>=NPART || r)
@@ -29,12 +27,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
{
for ( nnx =0 ; nnx<80; nnx++)
{
- int randomness = count + rand()%3-1;//add -1,0,or 1 to count
- if (randomness<1)
- randomness=1;
- if (randomness>8)
- randomness=8;
- if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
+ int randomness = (count + rand()%3-1 + 4)%8;//add -1,0,or 1 to count
+ if (portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
{
create_part(-1,x+1,y,PT_SPRK);
create_part(-1,x+1,y+1,PT_SPRK);
@@ -44,26 +38,27 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
create_part(-1,x-1,y+1,PT_SPRK);
create_part(-1,x-1,y,PT_SPRK);
create_part(-1,x-1,y-1,PT_SPRK);
- portalp[parts[i].tmp][randomness-1][nnx] = emptyparticle;
+ portalp[parts[i].tmp][randomness][nnx] = emptyparticle;
break;
}
- else if (portalp[parts[i].tmp][randomness-1][nnx].type)
+ else if (portalp[parts[i].tmp][randomness][nnx].type)
{
- if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM)
+ if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
player[27] = 0;
- if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM2)
+ if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
player2[27] = 0;
- np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness-1][nnx].type);
+ np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type);
if (np<0) continue;
- parts[np] = portalp[parts[i].tmp][randomness-1][nnx];
+ parts[np] = portalp[parts[i].tmp][randomness][nnx];
parts[np].x = x+rx;
parts[np].y = y+ry;
- portalp[parts[i].tmp][randomness-1][nnx] = emptyparticle;
+ portalp[parts[i].tmp][randomness][nnx] = emptyparticle;
break;
}
}
}
}
+ }
if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
diff --git a/src/elements/sprk.c b/src/elements/sprk.c
index 039453f..0f3d8e9 100644
--- a/src/elements/sprk.c
+++ b/src/elements/sprk.c
@@ -35,7 +35,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
nearp = nearest_part(i, PT_ETRD);
if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
- create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM);
+ create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
part_change_type(i,x,y,ct);
ct = parts[i].ctype = PT_NONE;
parts[i].life = 20;
@@ -152,7 +152,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
else if (rt==PT_INST) {
if (parts[i].life>=3&&parts[r>>8].life==0)
{
- flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1);//spark the wire
+ flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1, 0);//spark the wire
}
}
else if (parts[r>>8].life==0 && (parts[i].life<3 || ((r>>8)<i && parts[i].life<4))) {
diff --git a/src/elements/stkm.c b/src/elements/stkm.c
index 4b43f57..6873ef5 100644
--- a/src/elements/stkm.c
+++ b/src/elements/stkm.c
@@ -240,7 +240,7 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
{
int np = -1;
if (playerp[2] == SPC_AIR)
- create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR);
+ create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
else
np = create_part(-1, rx, ry, playerp[2]);
if ( (np < NPART) && np>=0 && playerp[2] != PT_PHOT && playerp[2] != SPC_AIR)
@@ -389,21 +389,23 @@ void STKM_interact(float* playerp, int i, int x, int y)
if ((r&0xFF)==PT_PLUT) //If on plut
parts[i].life -= 1;
+
+ if (ptypes[r&0xFF].properties&PROP_DEADLY)
+ parts[i].life -= 1;
if ((r&0xFF)==PT_PRTI && parts[i].type)
{
- int nnx, count;
+ int nnx, count=1;//gives rx=0, ry=1 in update_PRTO
parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
- for (count=1; count<=8; count++)
- for (nnx=0; nnx<80; nnx++)
- if (!portalp[parts[r>>8].tmp][count-1][nnx].type)
- {
- portalp[parts[r>>8].tmp][count-1][nnx] = parts[i];
- kill_part(i);
- playerp[27] = 1;//stop SPWN creating a new STKM while he is in portal
- }
+ for (nnx=0; nnx<80; nnx++)
+ if (!portalp[parts[r>>8].tmp][count][nnx].type)
+ {
+ portalp[parts[r>>8].tmp][count][nnx] = parts[i];
+ kill_part(i);
+ playerp[27] = 1;//stop SPWN creating a new STKM while he is in portal
+ }
}
}
}
@@ -415,23 +417,23 @@ void STKM_init_legs(float* playerp, int i)
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
- player[3] = x-1;
- player[4] = y+6;
- player[5] = x-1;
- player[6] = y+6;
-
- player[7] = x-3;
- player[8] = y+12;
- player[9] = x-3;
- player[10] = y+12;
-
- player[11] = x+1;
- player[12] = y+6;
- player[13] = x+1;
- player[14] = y+6;
-
- player[15] = x+3;
- player[16] = y+12;
- player[17] = x+3;
- player[18] = y+12;
+ playerp[3] = x-1;
+ playerp[4] = y+6;
+ playerp[5] = x-1;
+ playerp[6] = y+6;
+
+ playerp[7] = x-3;
+ playerp[8] = y+12;
+ playerp[9] = x-3;
+ playerp[10] = y+12;
+
+ playerp[11] = x+1;
+ playerp[12] = y+6;
+ playerp[13] = x+1;
+ playerp[14] = y+6;
+
+ playerp[15] = x+3;
+ playerp[16] = y+12;
+ playerp[17] = x+3;
+ playerp[18] = y+12;
}
diff --git a/src/graphics.c b/src/graphics.c
index fb354d7..3ea811f 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -4453,22 +4453,22 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
if (j==PT_STKM) lc = PIXRGB(255, 255, 255);
else lc = PIXRGB(100, 100, 255);
//only need to check upper bound of y coord - lower bounds and x<w are checked in draw_line
- draw_line(fb , x-2, y-2, x+2, y-2, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ draw_line(fb , x-2, y-2, x+2, y-2, PIXR(hc), PIXG(hc), PIXB(hc), w);
if (y+2<h)
{
- draw_line(fb , x-2, y+2, x+2, y+2, PIXR(lc), PIXG(lc), PIXB(lc), w);
- draw_line(fb , x-2, y-2, x-2, y+2, PIXR(lc), PIXG(lc), PIXB(lc), w);
- draw_line(fb , x+2, y-2, x+2, y+2, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ draw_line(fb , x-2, y+2, x+2, y+2, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ draw_line(fb , x-2, y-2, x-2, y+2, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ draw_line(fb , x+2, y-2, x+2, y+2, PIXR(hc), PIXG(hc), PIXB(hc), w);
}
if (y+6<h)
{
- draw_line(fb , x, y+3, x-1, y+6, PIXR(hc), PIXG(hc), PIXB(hc), w);
- draw_line(fb , x, y+3, x+1, y+6, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ draw_line(fb , x, y+3, x-1, y+6, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ draw_line(fb , x, y+3, x+1, y+6, PIXR(lc), PIXG(lc), PIXB(lc), w);
}
if (y+12<h)
{
- draw_line(fb , x-1, y+6, x-3, y+12, PIXR(hc), PIXG(hc), PIXB(hc), w);
- draw_line(fb , x+1, y+6, x+3, y+12, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ draw_line(fb , x-1, y+6, x-3, y+12, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ draw_line(fb , x+1, y+6, x+3, y+12, PIXR(lc), PIXG(lc), PIXB(lc), w);
}
}
else
diff --git a/src/interface.c b/src/interface.c
index de226f3..bb07f98 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -26,7 +26,7 @@
#endif
SDLMod sdl_mod;
-int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
+int sdl_key, sdl_rkey, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11)
SDL_SysWMinfo sdl_wminfo;
Atom XA_CLIPBOARD, XA_TARGETS;
@@ -1945,12 +1945,8 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
}
}
}
- else if (i==SC_SPECIAL)//special menu
+ else if (i==SC_TOOL)//tools menu
{
- if (fwidth > XRES-BARSIZE) { //fancy scrolling
- float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
- xoff = (int)(overflow / location);
- }
for (n = UI_WALLSTART; n<UI_WALLSTART+UI_WALLCOUNT; n++)
{
if (n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM||n==SPC_WIND||n==SPC_PGRV||n==SPC_NGRV)
@@ -1985,6 +1981,13 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
}
}
}
+ }
+ else if (i==SC_SPECIAL)//special menu
+ {
+ if (fwidth > XRES-BARSIZE) { //fancy scrolling
+ float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
+ xoff = (int)(overflow / location);
+ }
for (n = 0; n<PT_NUM; n++)
{
if (ptypes[n].menusection==i&&ptypes[n].menu==1)
@@ -2100,7 +2103,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
{
drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy-10, (char *)msections[i].name, 255, 255, 255, 255);
}
- else if (i==SC_WALL||(i==SC_SPECIAL&&h>=UI_WALLSTART))
+ else if (i==SC_WALL||i==SC_TOOL)
{
drawtext(vid_buf, XRES-textwidth((char *)wtypes[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)wtypes[h-UI_WALLSTART].descs, 255, 255, 255, 255);
}
@@ -2205,7 +2208,7 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
int sdl_poll(void)
{
SDL_Event event;
- sdl_key=sdl_wheel=sdl_ascii=0;
+ sdl_key=sdl_rkey=sdl_wheel=sdl_ascii=0;
while (SDL_PollEvent(&event))
{
switch (event.type)
@@ -2265,6 +2268,7 @@ int sdl_poll(void)
break;
case SDL_KEYUP:
+ sdl_rkey=event.key.keysym.sym;
if (event.key.keysym.sym == SDLK_CAPSLOCK)
sdl_caps = 0;
if (event.key.keysym.sym == 'z')
diff --git a/src/luaconsole.c b/src/luaconsole.c
index c56c1a3..709c015 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -44,6 +44,10 @@ void luacon_open(){
{"unregister_mouseclick", &luatpt_unregister_mouseclick},
{"register_keypress", &luatpt_register_keypress},
{"unregister_keypress", &luatpt_unregister_keypress},
+ {"register_mouseevent", &luatpt_register_mouseclick},
+ {"unregister_mouseevent", &luatpt_unregister_mouseclick},
+ {"register_keyevent", &luatpt_register_keypress},
+ {"unregister_keyevent", &luatpt_unregister_keypress},
{"input", &luatpt_input},
{"message_box", &luatpt_message_box},
{"get_numOfParts", &luatpt_get_numOfParts},
@@ -76,15 +80,17 @@ void luacon_open(){
lua_pushinteger(l, 0);
lua_setfield(l, tptProperties, "mousey");
}
-int luacon_keypress(char key, int modifier){
+int luacon_keyevent(int key, int modifier, int event){
int i = 0, kpcontinue = 1;
+ char tempkey[] = {key, 0};
if(keypress_function_count){
for(i = 0; i < keypress_function_count && kpcontinue; i++){
lua_rawgeti(l, LUA_REGISTRYINDEX, keypress_functions[i]);
- lua_pushstring(l, &key);
+ lua_pushstring(l, tempkey);
lua_pushinteger(l, key);
lua_pushinteger(l, modifier);
- lua_pcall(l, 3, 1, 0);
+ lua_pushinteger(l, event);
+ lua_pcall(l, 4, 1, 0);
if(lua_isboolean(l, -1)){
kpcontinue = lua_toboolean(l, -1);
}
@@ -93,15 +99,15 @@ int luacon_keypress(char key, int modifier){
}
return kpcontinue;
}
-int luacon_mouseclick(int mx, int my, int mb, int mbq){
+int luacon_mouseevent(int mx, int my, int mb, int event){
int i = 0, mpcontinue = 1;
if(mouseclick_function_count){
for(i = 0; i < mouseclick_function_count && mpcontinue; i++){
lua_rawgeti(l, LUA_REGISTRYINDEX, mouseclick_functions[i]);
- lua_pushinteger(l, mbq);
- lua_pushinteger(l, mb);
lua_pushinteger(l, mx);
lua_pushinteger(l, my);
+ lua_pushinteger(l, mb);
+ lua_pushinteger(l, event);
lua_pcall(l, 4, 1, 0);
if(lua_isboolean(l, -1)){
mpcontinue = lua_toboolean(l, -1);
@@ -113,12 +119,12 @@ int luacon_mouseclick(int mx, int my, int mb, int mbq){
}
int luacon_step(int mx, int my){
int tempret = 0, tempb, i, callret;
+ lua_pushinteger(l, my);
+ lua_pushinteger(l, mx);
+ lua_setfield(l, tptProperties, "mousex");
+ lua_setfield(l, tptProperties, "mousey");
if(step_functions[0]){
//Set mouse globals
- lua_pushinteger(l, my);
- lua_pushinteger(l, mx);
- lua_setfield(l, tptProperties, "mousex");
- lua_setfield(l, tptProperties, "mousey");
for(i = 0; i<6; i++){
if(step_functions[i]){
lua_rawgeti(l, LUA_REGISTRYINDEX, step_functions[i]);
@@ -752,7 +758,7 @@ int luatpt_delete(lua_State* l)
}
arg2 = abs(arg2);
if(arg2 < YRES && arg1 < XRES){
- delete_part(arg1, arg2);
+ delete_part(arg1, arg2, 0);
return 0;
}
return luaL_error(l,"Invalid coordinates or particle ID");
diff --git a/src/main.c b/src/main.c
index 6de8abe..9bff1e5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1576,7 +1576,7 @@ int main(int argc, char *argv[])
void *http_ver_check, *http_session_check = NULL;
char *ver_data=NULL, *check_data=NULL, *tmp;
//char console_error[255] = "";
- int result, i, j, bq, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, old_ver_len, new_message_len=0;
+ int result, i, j, bq, bc, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, old_ver_len, new_message_len=0;
#ifdef INTERNAL
int vs = 0;
#endif
@@ -2003,9 +2003,13 @@ int main(int argc, char *argv[])
}
#ifdef LUACONSOLE
if(sdl_key){
- if(!luacon_keypress(sdl_key, sdl_mod))
+ if(!luacon_keyevent(sdl_key, sdl_mod, LUACON_KDOWN))
sdl_key = 0;
}
+ if(sdl_rkey){
+ if(!luacon_keyevent(sdl_rkey, sdl_mod, LUACON_KUP))
+ sdl_rkey = 0;
+ }
#endif
#ifdef PYCONSOLE
if(sdl_key){
@@ -2515,11 +2519,21 @@ int main(int argc, char *argv[])
}
bq = b; // bq is previous mouse state
- b = SDL_GetMouseState(&x, &y); // b is current mouse state
+ bc = b = SDL_GetMouseState(&x, &y); // b is current mouse state
#ifdef LUACONSOLE
- if(b){
- if(!luacon_mouseclick(x/sdl_scale, y/sdl_scale, b, bq)){
+ if(bc && bq){
+ if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bc, LUACON_MPRESS)){
+ b = 0;
+ }
+ }
+ else if(bc && !bq){
+ if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bc, LUACON_MDOWN)){
+ b = 0;
+ }
+ }
+ else if(!bc && bq){
+ if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bq, LUACON_MUP)){
b = 0;
}
}
@@ -2561,6 +2575,16 @@ int main(int argc, char *argv[])
{
sprintf(nametext, "%s (%s)", ptypes[cr&0xFF].name, gmenu[parts[cr>>8].ctype].name);
}
+ else if ((cr&0xFF)==PT_LAVA && parts[cr>>8].ctype > 0 && parts[cr>>8].ctype < PT_NUM )
+ {
+ char lowername[6];
+ strcpy(lowername, ptypes[parts[cr>>8].ctype].name);
+ int ix;
+ for (ix = 0; lowername[ix]; ix++)
+ lowername[ix] = tolower(lowername[ix]);
+
+ sprintf(nametext, "Molten %s", lowername);
+ }
else if (DEBUG_MODE)
{
int tctype = parts[cr>>8].ctype;
@@ -3047,7 +3071,7 @@ int main(int argc, char *argv[])
{
nfvx = (line_x-lx)*0.005f;
nfvy = (line_y-ly)*0.005f;
- flood_parts(lx, ly, WL_FANHELPER, -1, WL_FAN);
+ flood_parts(lx, ly, WL_FANHELPER, -1, WL_FAN, 0);
for (j=0; j<YRES/CELL; j++)
for (i=0; i<XRES/CELL; i++)
if (bmap[j][i] == WL_FANHELPER)
@@ -3089,7 +3113,7 @@ int main(int argc, char *argv[])
}
else
{
- create_line(lx, ly, x, y, bsx, bsy, c);
+ create_line(lx, ly, x, y, bsx, bsy, c, get_brush_flags());
}
lx = x;
ly = y;
@@ -3119,9 +3143,9 @@ int main(int argc, char *argv[])
if (sdl_mod & (KMOD_CAPS))
c = 0;
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);
+ flood_parts(x, y, c, -1, -1, get_brush_flags());
if (c==SPC_HEAT || c==SPC_COOL)
- create_parts(x, y, bsx, bsy, c);
+ create_parts(x, y, bsx, bsy, c, get_brush_flags());
lx = x;
ly = y;
lb = 0;
@@ -3174,7 +3198,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);
+ create_parts(x, y, bsx, bsy, c, get_brush_flags());
lx = x;
ly = y;
lb = b;
@@ -3194,10 +3218,10 @@ int main(int argc, char *argv[])
if (lm == 1)//line
{
if (c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN)
- create_line(lx, ly, line_x, line_y, bsx, bsy, c);
+ create_line(lx, ly, line_x, line_y, bsx, bsy, c, get_brush_flags());
}
else//box
- create_box(lx, ly, x, y, c);
+ create_box(lx, ly, x, y, c, get_brush_flags());
lm = 0;
}
lb = 0;
diff --git a/src/powder.c b/src/powder.c
index 36f10e7..e9b3e62 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -213,7 +213,7 @@ int try_move(int i, int x, int y, int nx, int ny)
if ((r & 0xFF) == PT_COAL || (r & 0xFF) == PT_BCOL)
parts[r>>8].temp = parts[i].temp;
- if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct)
+ if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10) && (r&0xFF)!=PT_FILT)
parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP);
}
if (parts[i].type==PT_NEUT && ((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_PBCN)) {
@@ -223,30 +223,19 @@ int try_move(int i, int x, int y, int nx, int ny)
if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT))
{
int nnx, count;
- if (nx-x<0)
+ for (count=0; count<8; count++)
{
- if (ny-y<0) count = 1;
- else if (ny-y==0) count = 2;
- else count = 3;
- }
- else if (nx-x==0)
- {
- if (ny-y<0) count = 4;
- else count = 5;
- }
- else
- {
- if (ny-y<0) count = 6;
- else if (ny-y==0) count = 7;
- else count = 8;
+ if (isign(x-nx)==isign(portal_rx[count]) && isign(y-ny)==isign(portal_ry[count]))
+ break;
}
+ count = count%8;
parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
for ( nnx=0; nnx<80; nnx++)
- if (!portalp[parts[r>>8].tmp][count-1][nnx].type)
+ if (!portalp[parts[r>>8].tmp][count][nnx].type)
{
- portalp[parts[r>>8].tmp][count-1][nnx] = parts[i];
+ portalp[parts[r>>8].tmp][count][nnx] = parts[i];
parts[i].type=PT_NONE;
break;
}
@@ -1068,9 +1057,9 @@ static void create_cherenkov_photon(int pp)//photons from NEUT going through GLA
}
#if defined(WIN32) && !defined(__GNUC__)
-_inline void delete_part(int x, int y)
+_inline void delete_part(int x, int y, int flags)//calls kill_part with the particle located at x,y
#else
-inline void delete_part(int x, int y)//calls kill_part with the particle located at x,y
+inline void delete_part(int x, int y, int flags)//calls kill_part with the particle located at x,y
#endif
{
unsigned i;
@@ -1085,7 +1074,7 @@ inline void delete_part(int x, int y)//calls kill_part with the particle located
if (!i || (i>>8)>=NPART)
return;
- if ((parts[i>>8].type==SLALT)||SLALT==0)//specific deletiom
+ if (!(flags&BRUSH_SPECIFIC_DELETE) || parts[i>>8].type==SLALT || SLALT==0)//specific deletiom
{
kill_part(i>>8);
}
@@ -1249,7 +1238,7 @@ int nearest_part(int ci, int t)
return id;
}
-void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type)
+void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags)
{
int i;
float xint, yint;
@@ -1277,7 +1266,7 @@ void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int
xmid[i+1] += (rand()%variance)-voffset;
ymid[i+1] += (rand()%variance)-voffset;
}
- create_line(xmid[i], ymid[i], xmid[i+1], ymid[i+1], 0, 0, type);
+ create_line(xmid[i], ymid[i], xmid[i+1], ymid[i+1], 0, 0, type, flags);
}
free(xmid);
free(ymid);
@@ -2484,12 +2473,12 @@ void clear_area(int area_x, int area_y, int area_w, int area_h)
for (cx=0; cx<area_w; cx++)
{
bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
- delete_part(cx+area_x, cy+area_y);
+ delete_part(cx+area_x, cy+area_y, 0);
}
}
}
-void create_box(int x1, int y1, int x2, int y2, int c)
+void create_box(int x1, int y1, int x2, int y2, int c, int flags)
{
int i, j;
if (x1>x2)
@@ -2506,10 +2495,10 @@ void create_box(int x1, int y1, int x2, int y2, int c)
}
for (j=y1; j<=y2; j++)
for (i=x1; i<=x2; i++)
- create_parts(i, j, 0, 0, c);
+ create_parts(i, j, 0, 0, c, flags);
}
-int flood_parts(int x, int y, int fullc, int cm, int bm)
+int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
{
int c = fullc&0xFF;
int x1, x2, dy = (c<PT_NUM)?1:CELL;
@@ -2524,7 +2513,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
cm = pmap[y][x]&0xFF;
if (!cm)
return 0;
- if (REPLACE_MODE && cm!=SLALT)
+ if ((flags&BRUSH_REPLACEMODE) && cm!=SLALT)
return 0;
}
else
@@ -2544,7 +2533,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
bm = 0;
}
- if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (sdl_mod & (KMOD_CAPS)) && cm!=SLALT && !(cm==PT_INST&&co==PT_SPRK)))
+ if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (flags&BRUSH_SPECIFIC_DELETE) && cm!=SLALT))
return 1;
// go left as far as possible
@@ -2574,7 +2563,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
if (create_part(-1,x, y, fullc)==-1)
return 0;
}
- else if (!create_parts(x, y, 0, 0, fullc))
+ else if (!create_parts(x, y, 0, 0, fullc, flags))
return 0;
}
// fill children
@@ -2583,7 +2572,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
if (y>=CELL+dy && x1==x2 &&
((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
(pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y-2, fullc, cm, bm);
+ flood_parts(x1, y-2, fullc, cm, bm, flags);
else if (y>=CELL+dy)
for (x=x1; x<=x2; x++)
if ((pmap[y-1][x]&0xFF)!=PT_SPRK)
@@ -2591,14 +2580,14 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
if (x==x1 || x==x2 || y>=YRES-CELL-1 ||
(pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
(pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y-dy, fullc, cm, bm);
+ flood_parts(x, y-dy, fullc, cm, bm, flags);
}
if (y<YRES-CELL-dy && x1==x2 &&
((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
(pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y+2, fullc, cm, bm);
+ flood_parts(x1, y+2, fullc, cm, bm, flags);
else if (y<YRES-CELL-dy)
for (x=x1; x<=x2; x++)
if ((pmap[y+1][x]&0xFF)!=PT_SPRK)
@@ -2606,7 +2595,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
if (x==x1 || x==x2 || y<0 ||
(pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
(pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y+dy, fullc, cm, bm);
+ flood_parts(x, y+dy, fullc, cm, bm, flags);
}
}
@@ -2615,12 +2604,12 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
if (y>=CELL+dy)
for (x=x1; x<=x2; x++)
if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
- if (!flood_parts(x, y-dy, fullc, cm, bm))
+ if (!flood_parts(x, y-dy, fullc, cm, bm, flags))
return 0;
if (y<YRES-CELL-dy)
for (x=x1; x<=x2; x++)
if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
- if (!flood_parts(x, y+dy, fullc, cm, bm))
+ if (!flood_parts(x, y+dy, fullc, cm, bm, flags))
return 0;
}
if (!(cm==PT_INST&&co==PT_SPRK))
@@ -2628,7 +2617,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm)
}
//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 create_parts(int x, int y, int rx, int ry, int c, int flags)
{
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n;
@@ -2672,7 +2661,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
i = ox;
j = oy;
- if (((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))|| ((sdl_mod & (KMOD_CAPS)) && b!=WL_FANHELPER) ))
+ if ((flags&BRUSH_SPECIFIC_DELETE) && b!=WL_FANHELPER)
{
if (bmap[j][i]==SLALT-100)
{
@@ -2708,18 +2697,33 @@ int create_parts(int x, int y, int rx, int ry, int c)
return 1;
}
- //if CTRL+ALT or CAPSLOCK is on, specific delete
- if (((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE)
+ //eraser
+ if (c == 0 && !(flags&BRUSH_REPLACEMODE))
{
if (rx==0&&ry==0)
{
- delete_part(x, y);
+ 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);
+ delete_part(x+i, y+j, 0);
+ return 1;
+ }
+
+ //specific deletion
+ if ((flags&BRUSH_SPECIFIC_DELETE)&& !(flags&BRUSH_REPLACEMODE))
+ {
+ if (rx==0&&ry==0)
+ {
+ delete_part(x, y, flags);
+ }
+ else
+ for (j=-ry; j<=ry; j++)
+ for (i=-rx; i<=rx; i++)
+ if (InCurrentBrush(i ,j ,rx ,ry))
+ delete_part(x+i, y+j, flags);
return 1;
}
@@ -2745,24 +2749,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
return 1;
}
- //eraser
- if (c == 0 && !REPLACE_MODE)
- {
- stemp = SLALT;
- SLALT = 0;//temporarily clear specific deletion element
- if (rx==0&&ry==0)
- {
- delete_part(x, y);
- }
- 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);
- SLALT = stemp;
- return 1;
- }
- if (REPLACE_MODE)
+ if (flags&BRUSH_REPLACEMODE)
{
if (rx==0&&ry==0)
{
@@ -2770,7 +2757,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
if ((pmap[y][x]))
{
- delete_part(x, y);
+ delete_part(x, y, 0);
if (c!=0)
create_part(-2, x, y, c);
}
@@ -2787,7 +2774,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
continue;
if ((pmap[y+j][x+i]))
{
- delete_part(x+i, y+j);
+ delete_part(x+i, y+j, 0);
if (c!=0)
create_part(-2, x+i, y+j, c);
}
@@ -2827,7 +2814,18 @@ int InCurrentBrush(int i, int j, int rx, int ry)
break;
}
}
-void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c)
+int get_brush_flags()
+{
+ int flags = 0;
+ if (REPLACE_MODE)
+ flags |= BRUSH_REPLACEMODE;
+ if (sdl_mod & (KMOD_CAPS))
+ flags |= BRUSH_SPECIFIC_DELETE;
+ if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))
+ flags |= BRUSH_SPECIFIC_DELETE;
+ return 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;
float e, de;
@@ -2861,9 +2859,9 @@ void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c)
for (x=x1; x<=x2; x++)
{
if (cp)
- create_parts(y, x, rx, ry, c);
+ create_parts(y, x, rx, ry, c, flags);
else
- create_parts(x, y, rx, ry, c);
+ create_parts(x, y, rx, ry, c, flags);
e += de;
if (e >= 0.5f)
{
@@ -2871,9 +2869,9 @@ void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c)
if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC || !(rx+ry))
{
if (cp)
- create_parts(y, x, rx, ry, c);
+ create_parts(y, x, rx, ry, c, flags);
else
- create_parts(x, y, rx, ry, c);
+ create_parts(x, y, rx, ry, c, flags);
}
e -= 1.0f;
}
diff --git a/src/pythonconsole.c b/src/pythonconsole.c
index 4dc5072..c7d7d51 100644
--- a/src/pythonconsole.c
+++ b/src/pythonconsole.c
@@ -847,7 +847,7 @@ static PyObject* emb_delete(PyObject *self, PyObject *args)
int x,y;
if (!PyArg_ParseTuple(args, "ii:delete",&x,&y))
return NULL;
- delete_part(x,y);
+ delete_part(x,y, 0);
return Py_BuildValue("i",1);
}