diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 4745e0b7bd9..8d3a4f8afe5 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -91,7 +91,7 @@ if(BUILD_SUPPORTED) dfhack_plugin(autoslab autoslab.cpp) dfhack_plugin(blueprint blueprint.cpp LINK_LIBRARIES lua) dfhack_plugin(burrow burrow.cpp LINK_LIBRARIES lua) - #dfhack_plugin(building-hacks building-hacks.cpp LINK_LIBRARIES lua) + dfhack_plugin(building-hacks building-hacks.cpp LINK_LIBRARIES lua) add_subdirectory(buildingplan) dfhack_plugin(changeitem changeitem.cpp) dfhack_plugin(changelayer changelayer.cpp) diff --git a/plugins/building-hacks.cpp b/plugins/building-hacks.cpp index 635d99261ce..778118efb87 100644 --- a/plugins/building-hacks.cpp +++ b/plugins/building-hacks.cpp @@ -36,6 +36,9 @@ struct graphic_tile //could do just 31x31 and be done, but it's nicer to have fl int8_t fore; int8_t back; int8_t bright; + uint32_t graphics_tile; + uint32_t overlay_tile; + uint32_t unk_tile;//??? }; struct workshop_hack_data { @@ -260,9 +263,9 @@ struct work_hook : df::building_workshopst{ } INTERPOSE_NEXT(updateAction)(); } - DEFINE_VMETHOD_INTERPOSE(void, drawBuilding, (df::building_drawbuffer *db, int16_t unk)) + DEFINE_VMETHOD_INTERPOSE(void, drawBuilding, (int32_t unk1,df::building_drawbuffer *db, int16_t unk2)) { - INTERPOSE_NEXT(drawBuilding)(db, unk); + INTERPOSE_NEXT(drawBuilding)(unk1,db, unk2); if (auto def = find_def()) { @@ -289,15 +292,22 @@ struct work_hook : df::building_workshopst{ std::vector &cur_frame=def->frames[frame]; for(size_t i=0;i=0) + int tx = i % w; + int ty = i / w; + const auto& cf = cur_frame[i]; + if(cf.tile>=0) { - int tx=i % w; - int ty=i / w; - db->tile[tx][ty]=cur_frame[i].tile; - db->back[tx][ty]=cur_frame[i].back; - db->bright[tx][ty]=cur_frame[i].bright; - db->fore[tx][ty]=cur_frame[i].fore; + db->tile[tx][ty]= cf.tile; + db->back[tx][ty]= cf.back; + db->bright[tx][ty]= cf.bright; + db->fore[tx][ty]= cf.fore; } + if (cf.graphics_tile >= 0) + db->texpos1[tx][ty] = cf.graphics_tile; + if (cf.overlay_tile >= 0) + db->texpos2[tx][ty] = cf.overlay_tile; + if (cf.unk_tile >= 0) + db->texpos3[tx][ty] = cf.unk_tile; } } } @@ -332,8 +342,8 @@ static void loadFrames(lua_State* L,workshop_hack_data& def,int stack_pos) std::vector frame; while (lua_next(L, -2) != 0) { graphic_tile t; - lua_pushnumber(L,1); - lua_gettable(L,-2); + + lua_geti(L, -1, 1); if(lua_isnil(L,-1)) { t.tile=-1; @@ -344,21 +354,29 @@ static void loadFrames(lua_State* L,workshop_hack_data& def,int stack_pos) t.tile=lua_tonumber(L,-1); lua_pop(L,1); - lua_pushnumber(L,2); - lua_gettable(L,-2); + lua_geti(L, -1, 2); t.fore=lua_tonumber(L,-1); lua_pop(L,1); - lua_pushnumber(L,3); - lua_gettable(L,-2); + lua_geti(L, -1, 3); t.back=lua_tonumber(L,-1); lua_pop(L,1); - lua_pushnumber(L,4); - lua_gettable(L,-2); + lua_geti(L, -1, 4); t.bright=lua_tonumber(L,-1); lua_pop(L,1); + lua_geti(L, -1, 5); + t.graphics_tile = luaL_optinteger(L, -1,-1); + lua_pop(L, 1); + + lua_geti(L, -1, 6); + t.overlay_tile = luaL_optinteger(L, -1, -1); + lua_pop(L, 1); + + lua_geti(L, -1, 7); + t.unk_tile = luaL_optinteger(L, -1, -1); + lua_pop(L, 1); } frame.push_back(t); lua_pop(L,1);