summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-12-30 02:06:53 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-12-30 02:06:53 (GMT)
commit5b21f4a66c77dbeaceb54b7a3ce3cde5efd7af3f (patch)
tree3000d7b1d85f6a031181454377f2c0920d319868 /src
parent86369670aaa11b8cd2ddcbd46413fb9482e4e58f (diff)
parentf04577598b48c9e294b102395afc94023df8c92c (diff)
downloadpowder-5b21f4a66c77dbeaceb54b7a3ce3cde5efd7af3f.zip
powder-5b21f4a66c77dbeaceb54b7a3ce3cde5efd7af3f.tar.gz
Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src')
-rw-r--r--src/elements/bang.c6
-rw-r--r--src/elements/ignt.c2
-rw-r--r--src/interface.c9
-rw-r--r--src/luaconsole.c28
-rw-r--r--src/main.c5
-rw-r--r--src/powder.c2
6 files changed, 40 insertions, 12 deletions
diff --git a/src/elements/bang.c b/src/elements/bang.c
index 2c5c904..9a374c2 100644
--- a/src/elements/bang.c
+++ b/src/elements/bang.c
@@ -45,12 +45,12 @@ int update_BANG(UPDATE_FUNC_ARGS) {
if(!(rand()%2))
{
create_part(i, x, y, PT_FIRE);
- parts[i].temp = (MAX_TEMP/4)+otemp;
+ parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP);
}
else
{
create_part(i, x, y, PT_SMKE);
- parts[i].temp = (MAX_TEMP/4)+otemp;
+ parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP);
}
}
else
@@ -60,7 +60,7 @@ int update_BANG(UPDATE_FUNC_ARGS) {
create_part(i, x, y, PT_BOMB);
parts[i].tmp = 1;
parts[i].life = 50;
- parts[i].temp = (MAX_TEMP/3)+otemp;
+ parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP);
parts[i].vx = rand()%20-10;
parts[i].vy = rand()%20-10;
}
diff --git a/src/elements/ignt.c b/src/elements/ignt.c
index c11fccf..f002e2d 100644
--- a/src/elements/ignt.c
+++ b/src/elements/ignt.c
@@ -31,7 +31,7 @@ int update_IGNT(UPDATE_FUNC_ARGS) {
parts[nb].life = 30;
parts[nb].vx = rand()%20-10;
parts[nb].vy = rand()%20-10;
- parts[nb].temp = 400.0f+parts[i].temp-273.15;
+ parts[nb].temp = restrict_flt(400.0f+parts[i].temp-273.15, MIN_TEMP, MAX_TEMP);
}
}
else
diff --git a/src/interface.c b/src/interface.c
index bb34c15..858af23 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -93,11 +93,18 @@ int drawgrav_enable = 0;
void menu_count(void)//puts the number of elements in each section into .itemcount
{
int i=0;
+ for (i=0;i<SC_TOTAL;i++)
+ {
+ msections[i].itemcount = 0;
+ }
msections[SC_LIFE].itemcount = NGOLALT;
msections[SC_WALL].itemcount = UI_WALLCOUNT-4;
for (i=0; i<PT_NUM; i++)
{
- msections[ptypes[i].menusection].itemcount+=ptypes[i].menu;
+ if (ptypes[i].menusection<SC_TOTAL)
+ {
+ msections[ptypes[i].menusection].itemcount+=ptypes[i].menu;
+ }
}
}
diff --git a/src/luaconsole.c b/src/luaconsole.c
index e7632dd..65bda4d 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -431,7 +431,7 @@ int luacon_transitionwrite(lua_State* l){
}
return 0;
}
-int luacon_element_getproperty(char * key, int * format)
+int luacon_element_getproperty(char * key, int * format, unsigned int * modified_stuff)
{
int offset;
if (strcmp(key, "name")==0){
@@ -441,10 +441,14 @@ int luacon_element_getproperty(char * key, int * format)
else if (strcmp(key, "color")==0){
offset = offsetof(part_type, pcolors);
*format = 0;
+ if (modified_stuff)
+ *modified_stuff |= LUACON_EL_MODIFIED_GRAPHICS;
}
else if (strcmp(key, "colour")==0){
offset = offsetof(part_type, pcolors);
*format = 0;
+ if (modified_stuff)
+ *modified_stuff |= LUACON_EL_MODIFIED_GRAPHICS;
}
else if (strcmp(key, "advection")==0){
offset = offsetof(part_type, advection);
@@ -501,6 +505,8 @@ int luacon_element_getproperty(char * key, int * format)
else if (strcmp(key, "menu")==0){
offset = offsetof(part_type, menu);
*format = 0;
+ if (modified_stuff)
+ *modified_stuff |= LUACON_EL_MODIFIED_MENUS;
}
else if (strcmp(key, "enabled")==0){
offset = offsetof(part_type, enabled);
@@ -509,10 +515,14 @@ int luacon_element_getproperty(char * key, int * format)
else if (strcmp(key, "weight")==0){
offset = offsetof(part_type, weight);
*format = 0;
+ if (modified_stuff)
+ *modified_stuff |= LUACON_EL_MODIFIED_CANMOVE;
}
else if (strcmp(key, "menusection")==0){
offset = offsetof(part_type, menusection);
*format = 0;
+ if (modified_stuff)
+ *modified_stuff |= LUACON_EL_MODIFIED_MENUS;
}
else if (strcmp(key, "heat")==0){
offset = offsetof(part_type, heat);
@@ -529,6 +539,8 @@ int luacon_element_getproperty(char * key, int * format)
else if (strcmp(key, "properties")==0){
offset = offsetof(part_type, properties);
*format = 0;
+ if (modified_stuff)
+ *modified_stuff |= LUACON_EL_MODIFIED_GRAPHICS | LUACON_EL_MODIFIED_CANMOVE;
}
else if (strcmp(key, "description")==0){
offset = offsetof(part_type, descs);
@@ -546,7 +558,7 @@ int luacon_elementread(lua_State* l){
float tempfloat;
int i;
char * key = mystrdup(luaL_optstring(l, 2, ""));
- offset = luacon_element_getproperty(key, &format);
+ offset = luacon_element_getproperty(key, &format, NULL);
free(key);
//Get Raw Index value for element
@@ -588,8 +600,9 @@ int luacon_elementwrite(lua_State* l){
int tempinteger;
float tempfloat;
int i;
+ unsigned int modified_stuff = 0;
char * key = mystrdup(luaL_optstring(l, 2, ""));
- offset = luacon_element_getproperty(key, &format);
+ offset = luacon_element_getproperty(key, &format, &modified_stuff);
//Get Raw Index value for element
lua_pushstring(l, "id");
@@ -640,6 +653,15 @@ int luacon_elementwrite(lua_State* l){
*((unsigned char*)(((void*)&ptypes[i])+offset)) = luaL_optinteger(l, 3, 0);
break;
}
+ if (modified_stuff)
+ {
+ if (modified_stuff & LUACON_EL_MODIFIED_MENUS)
+ menu_count();
+ if (modified_stuff & LUACON_EL_MODIFIED_CANMOVE)
+ init_can_move();
+ if (modified_stuff & LUACON_EL_MODIFIED_GRAPHICS)
+ memset(graphicscache, 0, sizeof(gcache_item)*PT_NUM);
+ }
free(key);
return 0;
}
diff --git a/src/main.c b/src/main.c
index a835e3e..5abc139 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1014,7 +1014,7 @@ int main(int argc, char *argv[])
gravity_update_async(); //Check for updated velocity maps from gravity thread
if (!sys_pause||framerender) //Only update if not paused
- memset(gravmap, 0, sizeof(gravmap)); //Clear the old gravmap
+ memset(gravmap, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float)); //Clear the old gravmap
if (framerender) {
framerender = 0;
@@ -2258,8 +2258,7 @@ int main(int argc, char *argv[])
if (!bq)
add_sign_ui(vid_buf, x, y);
}
-
- if (c==PT_FIGH)
+ else if (c==PT_FIGH)
{
if (!bq)
create_part(-1, x, y, PT_FIGH);
diff --git a/src/powder.c b/src/powder.c
index 4acd334..ca629cf 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -2940,7 +2940,7 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
{
if (wall==r)
{
- if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV)
+ if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV || wall == WL_SIGN)
break;
if (wall == WL_ERASE)
b = 0;