@@ -484,47 +484,35 @@ class DrawDistanceIncrease : public Hook
484484};
485485DrawDistanceIncrease DrawDistanceIncrease::instance;
486486
487- // TODO: move this to game.h, should probably remove the resize function
488- struct TDrawBuffer
489- {
490- int NumBuffers_0;
491- int MaxBuffers_4;
492- int unk_8[1 ];
493- int MaxBuffers_C;
494- struct TDrawEntry ** BufferPtrs_10;
495- struct TDrawEntry * Buffer_14;
496- void * UnkBuffer_18;
497-
498- void resize (int new_size)
499- {
500- int bufferPtrsSize_Imm = new_size * 4 ;
501- int buffersSize_Imm = new_size * 0x3C ;
502- int unkbuffersSize_Imm = new_size * 0x40 ;
503-
504- MaxBuffers_4 = new_size;
505- MaxBuffers_C = new_size;
506-
507- BufferPtrs_10 = (TDrawEntry**)malloc (bufferPtrsSize_Imm);
508- Buffer_14 = (TDrawEntry*)malloc (buffersSize_Imm);
509- UnkBuffer_18 = malloc (unkbuffersSize_Imm);
510- }
511- };
512-
513487class DrawBufferExtension : public Hook
514488{
515489 inline static SafetyHookInline drawbufferinit_hook = {};
516490 static void drawbufferinit_dest ()
517491 {
518492 drawbufferinit_hook.call ();
519493
520- TDrawBuffer * s_ImmDrawBuffer = Module::exe_ptr<TDrawBuffer >(0x00464EF8 );
521- TDrawBuffer * s_AftDrawBuffer = Module::exe_ptr<TDrawBuffer >(0x004612D8 );
494+ DrawBuffer * s_ImmDrawBuffer = Module::exe_ptr<DrawBuffer >(0x00464EF8 );
495+ DrawBuffer * s_AftDrawBuffer = Module::exe_ptr<DrawBuffer >(0x004612D8 );
522496
523497 constexpr int s_ImmDrawBufferSizeVanilla = 0x100 ;
524498 constexpr int s_AftDrawBufferSizeVanilla = 0x600 ;
525499
526- s_ImmDrawBuffer->resize (s_ImmDrawBufferSizeVanilla * 0x10 );
527- s_AftDrawBuffer->resize (s_AftDrawBufferSizeVanilla * 2 );
500+ auto resize_buffer = [](DrawBuffer* buffer, int max_size)
501+ {
502+ int bufferPtrsSize_Imm = max_size * 4 ;
503+ int buffersSize_Imm = max_size * 0x3C ;
504+ int unkbuffersSize_Imm = max_size * 0x40 ;
505+
506+ buffer->MaxBuffers_4 = max_size;
507+ buffer->MaxBuffers_C = max_size;
508+
509+ buffer->BufferPtrs_10 = (DrawEntry**)malloc (bufferPtrsSize_Imm);
510+ buffer->Buffer_14 = (DrawEntry*)malloc (buffersSize_Imm);
511+ buffer->UnkBuffer_18 = malloc (unkbuffersSize_Imm);
512+ };
513+
514+ resize_buffer (s_ImmDrawBuffer, s_ImmDrawBufferSizeVanilla * 0x10 );
515+ resize_buffer (s_AftDrawBuffer, s_AftDrawBufferSizeVanilla * 2 );
528516 }
529517
530518public:
0 commit comments