Wake of Gods Forum | Форум Во Имя Богов

Full Version: Плагины. Обсуждение
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Raistlin, ну ты чего? Не используй asm вовсе. Это:
Code:
_asm
{
    push    0
    push    0
    push    0
    push    1
    push    1
    mov     ecx, edi
    mov eax, 0x4136F0
    call eax
}

Аналогично этому:
Code:
// void __thiscall AdvMgr_Draw_Minimap_current_coords(_AdvMgr_ *this, char a2, int a3, char a4, char a5, char a6)
CALL_6(void, __thiscall, 0x4136F0, o_AdvMgr, 1, 1, 0, 0, 0 );
Рано или поздно я обязательно всему научусь, большое спасибо! 132
@Raistlin
To add to what igrik posted while I was typing this...
Don't use inline ASM to acquire registers unless you declare the function __declspec(naked), you never know how compiler will act exactly.
However if you do declare it __declspec(naked) then you have to handle all of the stack yourself, not the most intuitive when working with LoHook. (So best thing, avoid assembly whenever possible)
The guaranteed safe way to do your way with C++ and the LoHook function would be:
Code:
//THISCALL_6(void, 0x4136F0, c->edi, 1, 1, 0, 0, 0);
CALL_6(void, __thiscall, 0x4136F0, c->edi, 1, 1, 0, 0, 0);
Or use igrik's version 132
Or add it as a member function of AdvMgr and use it directly... AdvMgr->UpdateScreen();

However there is another issue in this code, by jumping to 0x41D474 you are skipping over
Code:
0x41D46B POP EDI
Which means you are not restoring EDI which was pushed on stack at 0x41D232; this is highly likely to cause all sorts of problems including crashes.
Code:
int __stdcall DisableManaUsage(LoHook* hook, HookContext* c)
{
    /* insert update screen code */
    c->edi = c->Pop(); // missing line, pop the top stack value back to edi
    c->return_address = 0x41D474;
    return NO_EXEC_DEFAULT;
}

@igrik
As we previously discussed, you can create your own custom format that inherits from an existing control, and do two modifications:
1- add a DlgItem* field (linkedItem) to link it with the control beneath it
2- modify the virtual table with your own by changing the ProcessMsg(H3Msg& msg) function (+08) with your own.

This can be accomplished either by properly writing virtual function for all controls or using similar style to Wog dialogs / Baratorch dialogs of creating a custom virtual table and inserting it after the control is created (effectively more C-style).

C++style
Code:
struct MyCustomControl : DlgItem
{
    DlgItem* linkedControl;

    virtual int ProcessMsg(H3Msg& msg) override
     {
           if (linkedControl)
                return linkedControl->ProcessMsg(msg);
           return 2; // stop processing the current msg
           return THISCALL_2(int, /*insert_original_address*/, this, &msg); // call original message process
     };
     // add in constructor etc.
};

C-style
Code:
struct MyCustomControl : DlgItem
{
    DlgItem* linkedControl;
     // add in constructor etc.

    static int __fastcall CustomProcessMsg(MyCustomControl* control, int unused, H3Msg& msg)
    {
       if (control->linkedItem) // can add some more checks if needed
           return  control->linkedItem->ProcessMsg(msg);
       return 2; // stop processing the current msg
       return THISCALL_2(int, /*insert_original_address*/, control, &msg); // call original message process
    }

   static int customVT[] = {
      0x123456, // use the actual function addresses
      0x222222,
      (int)MyCustomControl::CustomProcessMsg,
      0xABCDEF,
      ...
   };
}
...and set custom virtual table after creation...
Code:
MyCustomControl* customControl = new MyCustomControl(.......) (in whatever way you pick to create it)
*(int*)(customControl) = (int)MyCustomControl::customVT; // set new virtual table

Whichever way you pick, anytime you perform an action on the overlaying transparent control the message is instead transferred to the linked control.

###

Making properly overloaded controls is, imo, easier, more versatile and does not take a considerable amount of time really since you can simply make a virtual function call the original one. Something I am planning to add in the api when I get time...
RoseKavalier, thank you very much! I did not know how to use __declspec(naked), but now I have understood 132

Plugin got updated (hopefully last time), the code is here:
(21.05.2021 19:36)RoseKavalier Wrote: [ -> ]@igrik
As we previously discussed, you can create your own custom format that inherits from an existing control, and do two modifications:
1- add a DlgItem* field (linkedItem) to link it with the control beneath it
2- modify the virtual table with your own by changing the ProcessMsg(H3Msg& msg) function (+08) with your own.

...

Making properly overloaded controls is, imo, easier, more versatile and does not take a considerable amount of time really since you can simply make a virtual function call the original one. Something I am planning to add in the api when I get time...
RoseKavalier, thank you again. I remember that we discussed this point, and I'm even moving in that direction. But the lack of time did not allow me to finish what i am started, and so far there is no result. But it will be mandatory!
Thank you again for your help.
(20.05.2021 22:45)Raistlin Wrote: [ -> ]«Дверь измерений» игнорирует щелчки по клеткам с водой

Автор: Raistlin
Язык: не имеет значения
Поддерживаемые версии: SoD, ERA
Способ установки: Класть в EraPlugins любого мода

Скачать: https://drive.google.com/file/d/1kWUMTcw...sp=sharing

Данный плагин учитывает героя, находящегося в лодке?
Напомню, что "Дверь Измерений" работает, если ты "прыгаешь" с воды на воду.
igrik, I'm looking for help with your plugin WoG Native Dialogue for 283.

Debug + save

exception context.txt
Quote:> Callstack
Wog native dialogs.8472 (?setYellowFrames@@YAXPAV_CustomDlg_@@H@Z + 1474)

With ERA 2.9.14 + WoG Native Dialogue for 283, the game crashes when the hero visits Witch Huts.

Everything's fine with ERA 2.9.14 + WND build-in with ERA release.

Is WND for 283 incompatible with 2914, or is it possible to improve?

Thanks for your help Yes
(24.05.2021 21:22)Archer30 Wrote: [ -> ]Is WND for 283 incompatible with 2914, or is it possible to improve?
No, they are not compatible!
Thank you igrik, that's unexpected :O
(24.05.2021 08:54)daemon_n Wrote: [ -> ]
(20.05.2021 22:45)Raistlin Wrote: [ -> ]«Дверь измерений» игнорирует щелчки по клеткам с водой

Автор: Raistlin
Язык: не имеет значения
Поддерживаемые версии: SoD, ERA
Способ установки: Класть в EraPlugins любого мода

Скачать: https://drive.google.com/file/d/1kWUMTcw...sp=sharing

Данный плагин учитывает героя, находящегося в лодке?
Напомню, что "Дверь Измерений" работает, если ты "прыгаешь" с воды на воду.
Да, должен учитывать.
XEPOMAHT, Увеличение лимита первичных навыков с 99 до 249, what a great plugin you wrote 132

I wonder if this plugin could possibly conflict with some mods/plugins. Got one report from the player saying he's got negative spell damage with Spell Power > 127, but I couldn't get more details from him. I also couldn't reproduce the problem.

If everything's fine, will this plugin be added to the next release of ERA? 102
(28.05.2021 14:31)Archer30 Wrote: [ -> ]I wonder if this plugin could possibly conflict with some mods/plugins. Got one report from the player saying he's got negative spell damage with Spell Power > 127, but I couldn't get more details from him. I also couldn't reproduce the problem.

Только если установлены плагины, изменяющие урон от заклинаний, то там возможен отрицательный урон от заклинаний - он будет и без prima.dll. ERM такие баги вызывать не должен - в prima.dll воговский код так же пропатчен весь, что в нём нашлось.

(28.05.2021 14:31)Archer30 Wrote: [ -> ]If everything's fine, will this plugin be added to the next release of ERA? 102

Берсеркер скорее против. Данный плагин и так является частью ERA+, более экстремального набора плагинов, чем базовая ERA.
XEPOMAHT, thanks for clarifying!

I would really like this plugin to be embedded in ERA, at least the part preventing overflow of stats > 127 is very necessary.

ERA has got an optional bin patch for stats max at 127 (which is worse than this one) anyway.
(28.05.2021 16:15)Archer30 Wrote: [ -> ]I would really like this plugin to be embedded in ERA, at least the part preventing overflow of stats > 127 is very necessary.

Авторам сборок не запрещено добавлять prima.dll. Например, в сборку Панды он добавлен, но только выключен. Лично я глубоко не тестировал prima.dll - у меня нет на это времени. Мне пока никаких баг-репоров, связанных с prima.dll, не приходило ни одного. Поэтому - пока только на свой страх и риск, теоретически, в нём всё должно работать, но что и как на практике - время покажет: плагин новый, написан был за 3 дня. Через год наверное узнаем что-да как в нём... 148

(28.05.2021 16:15)Archer30 Wrote: [ -> ]ERA has got an optional bin patch for stats max at 127 (which is worse than this one) anyway.

Это устаревший патч, возможно когда-нибудь Берсеркер осмелится заменить его на prima.dll, но друг другу они не мешают, т.к. prima.dll перетирает этот патч целиком в памяти игры - по крайней мере если prima.dll грузится позже.
Archer30, for now I think base implementation with unsigned byte a much safier variant for core package. But everyone can use new plugins in assemblies, being ready for testing and bug reports, of course )
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Reference URL's