Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy

This commit is contained in:
Simon Robertshaw 2011-12-30 02:06:53 +00:00
commit 5b21f4a66c
7 changed files with 46 additions and 13 deletions

View File

@ -19,6 +19,11 @@
#define LUACON_KDOWN 1
#define LUACON_KUP 2
//Bitmasks for things that might need recalculating after changes to tpt.el
#define LUACON_EL_MODIFIED_CANMOVE 0x1
#define LUACON_EL_MODIFIED_GRAPHICS 0x2
#define LUACON_EL_MODIFIED_MENUS 0x4
int *lua_el_func, *lua_el_mode;
void luacon_open();
@ -39,7 +44,7 @@ int luacon_transitionread(lua_State* l);
int luacon_transitionwrite(lua_State* l);
int luacon_particle_getproperty(char * key, int * format);
int luacon_transition_getproperty(char * key, int * format);
int luacon_element_getproperty(char * key, int * format);
int luacon_element_getproperty(char * key, int * format, unsigned int * modified_stuff);
int process_command_lua(pixel *vid_buf, char *console, char *console_error);
int getPartIndex_curIdx;

View File

@ -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;
}

View File

@ -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

View File

@ -93,12 +93,19 @@ 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++)
{
if (ptypes[i].menusection<SC_TOTAL)
{
msections[ptypes[i].menusection].itemcount+=ptypes[i].menu;
}
}
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;