@@ -36,6 +36,9 @@ struct graphic_tile //could do just 31x31 and be done, but it's nicer to have fl
3636 int8_t fore;
3737 int8_t back;
3838 int8_t bright;
39+ uint32_t graphics_tile;
40+ uint32_t overlay_tile;
41+ uint32_t unk_tile;// ???
3942};
4043struct workshop_hack_data
4144{
@@ -260,9 +263,9 @@ struct work_hook : df::building_workshopst{
260263 }
261264 INTERPOSE_NEXT (updateAction)();
262265 }
263- DEFINE_VMETHOD_INTERPOSE (void , drawBuilding, (df::building_drawbuffer *db, int16_t unk ))
266+ DEFINE_VMETHOD_INTERPOSE (void , drawBuilding, (int32_t unk1, df::building_drawbuffer *db, int16_t unk2 ))
264267 {
265- INTERPOSE_NEXT (drawBuilding)(db, unk );
268+ INTERPOSE_NEXT (drawBuilding)(unk1, db, unk2 );
266269
267270 if (auto def = find_def ())
268271 {
@@ -289,15 +292,22 @@ struct work_hook : df::building_workshopst{
289292 std::vector<graphic_tile> &cur_frame=def->frames [frame];
290293 for (size_t i=0 ;i<cur_frame.size ();i++)
291294 {
292- if (cur_frame[i].tile >=0 )
295+ int tx = i % w;
296+ int ty = i / w;
297+ const auto & cf = cur_frame[i];
298+ if (cf.tile >=0 )
293299 {
294- int tx=i % w;
295- int ty=i / w;
296- db->tile [tx][ty]=cur_frame[i].tile ;
297- db->back [tx][ty]=cur_frame[i].back ;
298- db->bright [tx][ty]=cur_frame[i].bright ;
299- db->fore [tx][ty]=cur_frame[i].fore ;
300+ db->tile [tx][ty]= cf.tile ;
301+ db->back [tx][ty]= cf.back ;
302+ db->bright [tx][ty]= cf.bright ;
303+ db->fore [tx][ty]= cf.fore ;
300304 }
305+ if (cf.graphics_tile >= 0 )
306+ db->texpos1 [tx][ty] = cf.graphics_tile ;
307+ if (cf.overlay_tile >= 0 )
308+ db->texpos2 [tx][ty] = cf.overlay_tile ;
309+ if (cf.unk_tile >= 0 )
310+ db->texpos3 [tx][ty] = cf.unk_tile ;
301311 }
302312 }
303313 }
@@ -332,8 +342,8 @@ static void loadFrames(lua_State* L,workshop_hack_data& def,int stack_pos)
332342 std::vector<graphic_tile> frame;
333343 while (lua_next (L, -2 ) != 0 ) {
334344 graphic_tile t;
335- lua_pushnumber (L, 1 );
336- lua_gettable (L,- 2 );
345+
346+ lua_geti (L, - 1 , 1 );
337347 if (lua_isnil (L,-1 ))
338348 {
339349 t.tile =-1 ;
@@ -344,21 +354,29 @@ static void loadFrames(lua_State* L,workshop_hack_data& def,int stack_pos)
344354 t.tile =lua_tonumber (L,-1 );
345355 lua_pop (L,1 );
346356
347- lua_pushnumber (L,2 );
348- lua_gettable (L,-2 );
357+ lua_geti (L, -1 , 2 );
349358 t.fore =lua_tonumber (L,-1 );
350359 lua_pop (L,1 );
351360
352- lua_pushnumber (L,3 );
353- lua_gettable (L,-2 );
361+ lua_geti (L, -1 , 3 );
354362 t.back =lua_tonumber (L,-1 );
355363 lua_pop (L,1 );
356364
357- lua_pushnumber (L,4 );
358- lua_gettable (L,-2 );
365+ lua_geti (L, -1 , 4 );
359366 t.bright =lua_tonumber (L,-1 );
360367 lua_pop (L,1 );
361368
369+ lua_geti (L, -1 , 5 );
370+ t.graphics_tile = luaL_optinteger (L, -1 ,-1 );
371+ lua_pop (L, 1 );
372+
373+ lua_geti (L, -1 , 6 );
374+ t.overlay_tile = luaL_optinteger (L, -1 , -1 );
375+ lua_pop (L, 1 );
376+
377+ lua_geti (L, -1 , 7 );
378+ t.unk_tile = luaL_optinteger (L, -1 , -1 );
379+ lua_pop (L, 1 );
362380 }
363381 frame.push_back (t);
364382 lua_pop (L,1 );
0 commit comments