Объявления

Друзья, если не получается зарегистрироваться, напишите на почту vdv_forever@bk.ru.
Я оторву свою задницу от всех дел и обязательно Вас активирую! :smile10:
Добро пожаловать на геройский форум! :smile25:

H3API by RoseKavalier

Герои Меча и Магии III: Возрождение Эрафии, Герои Меча и Магии III Дыхание Смерти, Герои Меча и Магии III Клинок Армагеддона, Герои Меча и Магии III Хроники Героев
offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: H3API by RoseKavalier

Сообщение RoseKavalier » 28 сен 2020, 13:02

Some of these were deprecated at some point () as I try to standardize everything so it flows better, all enums are now ALL_CAPS format for example.
You can find replacements here when I completely remove the old versions from the api.

1. H3MsgCustom seems to have been deleted by accident at some point :o Let me go dig it out, I'll update post afterwards.
EDIT: I removed H3MsgCustom since it only had a single member function, use `H3Msg::GetDlg()`
H3Msg::MessageCommand::MC_MOUSE_BUTTON
2. H3StreamBuf -> H3ZStream
3. NH3Constants::NH3Combat::COMBATSQUARE_WIDTH ...
4. All H3Manager-derived classes have `::SetPreviousManager(H3Manager*)` and `::SetNextManager(H3Manager*)` instead of a single function. You probably don't need to do any casting anymore to get it working.

EDIT: done.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: H3API by RoseKavalier

Сообщение as239 » 30 сен 2020, 09:15

Fully switched to current H3API and VS2019.
But having the problem - crush after load any save.

If you remove these hooks, everything is fine:
Код: Выделить всё
   _PI->WriteLoHook(0x4BE1B4, SaveGame);
   _PI->WriteLoHook(0x4BCC8A, LoadGame);


SaveGame code:
Код: Выделить всё
_LHF_(SaveGame)
{
   H3ZStream *s = (H3ZStream*)c->ecx;

   _FreshData_ FreshData;
   FreshData.GamePlayChangesOn = GamePlayChangesOn;
   FreshData.HWRulesOn = HWRulesOn;
   FreshData.ItsRAI = ItsRAI;
   FreshData.RandomSeed = RandomSeed;
   for (int i = 0; i < 48; i++)
   {
      FreshData.GM_Rebuild_Counts[i] = GM_Rebuild_Counts[i];
   }
   
   s->Save(&FreshData, sizeof(FreshData));

    return EXEC_DEFAULT;
}


LoadGame code:
Код: Выделить всё
_LHF_(LoadGame)
{
   H3ZStream*s = (H3ZStream*)c->ecx;
   _FreshData_ FreshData;
   s->Load(&FreshData, sizeof(FreshData));

   GamePlayChangesOn = FreshData.GamePlayChangesOn;
   HWRulesOn = FreshData.HWRulesOn;
   RandomSeed = FreshData.RandomSeed;
   ItsRAI = FreshData.ItsRAI;

   for (int i = 0; i < 48; i++)
   {
      GM_Rebuild_Counts[i] = FreshData.GM_Rebuild_Counts[i];
   }

   RememberOriginalSpellsChances();
   DisabledSpellsAfterLoad();
   SetNecromancyKt();
   //проверить дату при загрузке
   SetRandomGeneratorSeed(RandomSeed, true);

   SetCampaignHeroesArmy(GamePlayChangesOn);

   return EXEC_DEFAULT;
}

Whats wrong with it?
Вложения
HD_CRASH_LOG.TXT
(8.3 КБ) Скачиваний: 170
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: H3API by RoseKavalier

Сообщение as239 » 30 сен 2020, 09:18

Made the following edits to H3API.
It would be nice to include them in one form or another:

1. H3Structures.hpp (№1011)
Код: Выделить всё
   _H3API_ int GetMageLevel() { return mageLevel; };


2. H3Dialogs.hpp (№44)
Код: Выделить всё
   typedef INT32(__fastcall* H3DlgButton_proc)(H3Msg*);


3. H3RMG.hpp (№273) (CopyPaste?)
Код: Выделить всё
   _H3API_ASSERT_SIZE_(RMG_Object, 0x1C);


4. H3RMG.hpp (№290)
Код: Выделить всё
   struct RMG_Obj_Seer : public RMG_Object {
      INT32 art_id;
      INT32 experienceAmount;
      INT32 resourceId;
      INT32 resourceAmount;
      INT32 creatureRewardType;
      INT32 creatureRewardNumber;
   };
   _H3API_ASSERT_SIZE_(RMG_Obj_Seer, 0x34);

5. H3RMG.hpp (№317)
Код: Выделить всё
   #pragma pack(push, 1)
   struct RMG_LocalMap : RMG_Map // this line gives all members from RMG_Map to RMG_LocalMap, as well as member functions
   {
      h3unk _f_18[16];
      H3Vector<RMG_Object*> localObjects;
   };
#pragma pack(pop)

6. H3RMG.hpp (№173)
Код: Выделить всё
   struct RMG_ZoneGenerator
   {
      RMG_Zone         *zoneInfo;         /**< @brief [00]*/
Последний раз редактировалось as239 01 ноя 2020, 10:39, всего редактировалось 1 раз.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: H3API by RoseKavalier

Сообщение as239 » 01 ноя 2020, 10:32

По прежнему не могу решить проблему с вылетом при загрузке сохранения, не работает даже такой простейший код:
Код: Выделить всё
   _PI->WriteLoHook(0x4BE1B4, SaveGame);
   _PI->WriteLoHook(0x4BCC8A, LoadGame);
LHF_(SaveGame)
{
   H3ZStream *s = (H3ZStream*)c->ecx;
   int test = 1;
   s->Save(&test, sizeof(test));
    return EXEC_DEFAULT;
}
_LHF_(LoadGame){
   H3ZStream*s = (H3ZStream*)c->ecx;
   int test = 0;
   s->Load(&test, sizeof(test));
   return EXEC_DEFAULT;
}


Со старыми заголовочниками все было ок.
Причем реализация save и load одинаковая, что в старых заголовочниках, что в новых.
Единственно, отличие - это то что я отключил "Выравнивание структур = 1 байт", может это влиять?
Проверить со включенным параметром не могу т.к. с ним у меня проект не компилируется.
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: H3API by RoseKavalier

Сообщение RoseKavalier » 02 ноя 2020, 01:36

Sorry I'm travelling quite a bit lately, not much time for hobbies unfortunately. "doesn't work" is not very helpful in debugging, could be anything really.=S

I have something on my schedule related to save/load anyway so that'll get looked at as soon as I can; I'll do the necessary work to be certain things compile with VS2008 also.
Structure alignment shouldn't have any effect from what I can tell, the only member used is the virtual table and its contents which are 4-bytes aligned.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: H3API by RoseKavalier

Сообщение as239 » 02 ноя 2020, 11:36

A strange situation. I am using the latest headers and VS 2019. So I am as close as possible to SOD SP.
However, it doesn't have this problem.
Made a clean project with a reproduction of the problem.
1. Create any random map.
2. Save the game.
3. Load the game = crash.

Sometimes the save is loaded, but without the starting hero.
And if you then restart the game, then there will always be a crash, afrer save load.

Code:
Код: Выделить всё
// dllmain.cpp : Определяет точку входа для приложения DLL.
//#include "pch.h"


#include "../TestSaveLoad/H3API-master/include/H3API.hpp"
Patcher* _P;
PatcherInstance* _PI;
static BOOL plugin_On = 0;
using namespace h3;

_LHF_(SaveGame)
{
   H3ZStream* s = (H3ZStream*)c->ecx;

   int Test = 1;
   
   s->Save(&Test, sizeof(Test));

   return EXEC_DEFAULT;
}


_LHF_(LoadGame)
{
   H3ZStream* s = (H3ZStream*)c->ecx;
   int Test = 1;
   s->Load(&Test, sizeof(Test));

   return EXEC_DEFAULT;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
   if (DLL_PROCESS_ATTACH == ul_reason_for_call)
   {
      if (!plugin_On)
      {
         plugin_On = 1;
         _P = GetPatcher();
         _PI = _P->CreateInstance("HD.Plugin.TestSaveLoad");
         _PI->WriteLoHook(0x4BE1B4, SaveGame);
         _PI->WriteLoHook(0x4BCC8A, LoadGame);

      }
   }

   return TRUE;
}
Вложения
HD_CRASH_LOG_2.TXT
(8.92 КБ) Скачиваний: 185
HD_CRASH_LOG_1.TXT
(7.47 КБ) Скачиваний: 169
TestSaveLoadProject.zip
(3.19 МБ) Скачиваний: 155
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: H3API by RoseKavalier

Сообщение RoseKavalier » 27 дек 2020, 20:41

At long last, I have had time to update H3API, it is once again fully compatible with VS2008.

as239 писал(а):

Made the following edits to H3API.
It would be nice to include them in one form or another:
[...]



1. mageLevel is a public member, in which case there is no get/set method
2. Unsure when this was added but it was already there when I checked
3. Changed, thanks!
4. Added, thanks!
5. Added, thanks!
6. Modified, thanks!

Also the stream->Save bug was fixed a few updates ago, stupid copy/paste error.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: H3API by RoseKavalier

Сообщение as239 » 28 дек 2020, 11:53

Thanks!

1. Maybe I don't understand something:
 
Изображение


And one more little moment. I should always add this line.
 
Изображение

Why isn't it enabled by default?
This is not a big problem, but when, after many months, you update the api and see a lot of errors, you don't immediately remember about this line.
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: H3API by RoseKavalier

Сообщение RoseKavalier » 28 дек 2020, 17:31

1. My bad, I am blind :smile13:
Fixed now!

Preprocessor macros are left to the user to decide what they wish to include, patcher_x86 is not part of H3API and the version provided with it has some minor modifications from the one provided by bara.
On my end I just add them directly to the project configuration as such:
Изображение
Вернуться к началу

offlineigrik  
Подмастерье
Подмастерье
 
Сообщения: 108
Зарегистрирован: 14 сен 2017, 12:35
Пол: Не указан
Поблагодарили: 84 раз.

Re: H3API by RoseKavalier

Сообщение igrik » 10 мар 2021, 21:58

RoseKavalier, hello!
I can't figure out what I'm doing wrong?

Код: Выделить всё
INT32 __fastcall showSelectDialog_Proc(H3Dlg* dlg, int, H3Msg* msg)
{

    return dlg->DefaultProc(msg);
}


H3Dlg dlg(width, height, -1, -1, FALSE, showSelectDialog_Proc);


Код: Выделить всё
era dialogs.cpp(73) : error C2664: h3::H3Dlg::H3Dlg(int,int,int,int,BOOL,h3::H3Dlg_proc,BOOL,INT32): the parameter cannot be converted 6 to 'INT32 (__fastcall *)(h3::H3Dlg *,int,h3::H3Msg *)' в 'h3::H3Dlg_proc'
Вернуться к началу

Пред.След.

Вернуться в Общий раздел

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4