Update can_move, recount menu items and clear graphics cache when tpt.el is changed
This commit is contained in:
parent
23d6823bc3
commit
2553dac942
@ -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;
|
||||
|
@ -92,11 +92,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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user