Current time: 22.11.2024, 05:56 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Плагины. Обсуждение
» Plugins. Discussion & Questions
Author Message
igrik Offline
Administrators

Posts: 2819
Post: #421

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 );


game bug fixes extended.dll || My Plugins || My GitHub
21.05.2021 18:47
Visit this user's website Find all posts by this user Quote this message in a reply
Raistlin Away
Moderators

Posts: 1349
Post: #422
Сердце 
Рано или поздно я обязательно всему научусь, большое спасибо! 132


Создал новый глобальный мод: WoG Ultra Edition
21.05.2021 19:09
Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #423

@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...
21.05.2021 19:36
Find all posts by this user Quote this message in a reply
Raistlin Away
Moderators

Posts: 1349
Post: #424

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:


Создал новый глобальный мод: WoG Ultra Edition
21.05.2021 20:21
Find all posts by this user Quote this message in a reply
igrik Offline
Administrators

Posts: 2819
Post: #425

(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.


game bug fixes extended.dll || My Plugins || My GitHub
22.05.2021 20:02
Visit this user's website Find all posts by this user Quote this message in a reply
daemon_n Offline
Administrators

Posts: 4343
Post: #426

(20.05.2021 22:45)Raistlin Wrote:  «Дверь измерений» игнорирует щелчки по клеткам с водой

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

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

Данный плагин учитывает героя, находящегося в лодке?
Напомню, что "Дверь Измерений" работает, если ты "прыгаешь" с воды на воду.


Image: widget.png?style=banner2

Новейший Heroes Launcher
24.05.2021 08:54
Visit this user's website Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1175
Post: #427

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


Latest ERA mods and scripts in development - My GitHub
24.05.2021 21:22
Find all posts by this user Quote this message in a reply
igrik Offline
Administrators

Posts: 2819
Post: #428

(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!


game bug fixes extended.dll || My Plugins || My GitHub
24.05.2021 21:28
Visit this user's website Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1175
Post: #429

Thank you igrik, that's unexpected :O


Latest ERA mods and scripts in development - My GitHub
24.05.2021 21:58
Find all posts by this user Quote this message in a reply
Raistlin Away
Moderators

Posts: 1349
Post: #430

(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

Данный плагин учитывает героя, находящегося в лодке?
Напомню, что "Дверь Измерений" работает, если ты "прыгаешь" с воды на воду.
Да, должен учитывать.


Создал новый глобальный мод: WoG Ultra Edition
27.05.2021 00:38
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1175
Post: #431

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


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 28.05.2021 14:44 by Archer30.)
28.05.2021 14:31
Find all posts by this user Quote this message in a reply
XEPOMAHT Offline
Moderators

Posts: 2356
Post: #432

(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.
(This post was last modified: 28.05.2021 15:55 by XEPOMAHT.)
28.05.2021 15:52
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1175
Post: #433

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.


Latest ERA mods and scripts in development - My GitHub
28.05.2021 16:15
Find all posts by this user Quote this message in a reply
XEPOMAHT Offline
Moderators

Posts: 2356
Post: #434

(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 грузится позже.
28.05.2021 16:42
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16657
Post: #435

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 )


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
28.05.2021 16:42
Find all posts by this user Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Forum Jump:

Powered by MyBB Copyright © 2002-2024 MyBB Group