@@ -36,6 +36,9 @@ struct graphic_tile //could do just 31x31 and be done, but it's nicer to have fl
36
36
int8_t fore;
37
37
int8_t back;
38
38
int8_t bright;
39
+ uint32_t graphics_tile;
40
+ uint32_t overlay_tile;
41
+ uint32_t unk_tile;// ???
39
42
};
40
43
struct workshop_hack_data
41
44
{
@@ -260,9 +263,9 @@ struct work_hook : df::building_workshopst{
260
263
}
261
264
INTERPOSE_NEXT (updateAction)();
262
265
}
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 ))
264
267
{
265
- INTERPOSE_NEXT (drawBuilding)(db, unk );
268
+ INTERPOSE_NEXT (drawBuilding)(unk1, db, unk2 );
266
269
267
270
if (auto def = find_def ())
268
271
{
@@ -289,15 +292,22 @@ struct work_hook : df::building_workshopst{
289
292
std::vector<graphic_tile> &cur_frame=def->frames [frame];
290
293
for (size_t i=0 ;i<cur_frame.size ();i++)
291
294
{
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 )
293
299
{
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 ;
300
304
}
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 ;
301
311
}
302
312
}
303
313
}
@@ -332,8 +342,8 @@ static void loadFrames(lua_State* L,workshop_hack_data& def,int stack_pos)
332
342
std::vector<graphic_tile> frame;
333
343
while (lua_next (L, -2 ) != 0 ) {
334
344
graphic_tile t;
335
- lua_pushnumber (L, 1 );
336
- lua_gettable (L,- 2 );
345
+
346
+ lua_geti (L, - 1 , 1 );
337
347
if (lua_isnil (L,-1 ))
338
348
{
339
349
t.tile =-1 ;
@@ -344,21 +354,29 @@ static void loadFrames(lua_State* L,workshop_hack_data& def,int stack_pos)
344
354
t.tile =lua_tonumber (L,-1 );
345
355
lua_pop (L,1 );
346
356
347
- lua_pushnumber (L,2 );
348
- lua_gettable (L,-2 );
357
+ lua_geti (L, -1 , 2 );
349
358
t.fore =lua_tonumber (L,-1 );
350
359
lua_pop (L,1 );
351
360
352
- lua_pushnumber (L,3 );
353
- lua_gettable (L,-2 );
361
+ lua_geti (L, -1 , 3 );
354
362
t.back =lua_tonumber (L,-1 );
355
363
lua_pop (L,1 );
356
364
357
- lua_pushnumber (L,4 );
358
- lua_gettable (L,-2 );
365
+ lua_geti (L, -1 , 4 );
359
366
t.bright =lua_tonumber (L,-1 );
360
367
lua_pop (L,1 );
361
368
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 );
362
380
}
363
381
frame.push_back (t);
364
382
lua_pop (L,1 );
0 commit comments