|
Thread: ERA II - Source code - Help and discussion | This thread is pages long: 1 2 3 4 5 6 7 8 9 10 11 · NEXT» |
|
gamemaster
Adventuring Hero
|
posted August 15, 2019 10:13 PM |
|
|
ERA II - Source code - Help and discussion
I just thought that some discussion of ERM source code should be somewhere. It is probably not interesting for script writes and moders. So, this thread is for everything connected with ERA coding. Idea is to keep other post clean of questions not important to scripting and erm.
Actual reason to start this topic is try to port era to newer versions of delphi . Like some of you know main problem is default unicode type used for strings in latest delphi versions.
I know that many bugs can be introduced by inproper porting. At this moment i have port that compile and run under 10.3.2.
So back to topic... ERA source code
@Bersy
Regarding era v2.8.7 Heroes.pas line:506
SecSkillNames: PSecSkillNames = Ptr($698BC4);
SecSkillDescs: PSecSkillDescs = Ptr($698C30);
SecSkillTexts: PSecSkillTexts = Ptr($698D88);
Can you confirm that SecSkillDescs addres is $698C30 and not $698C34.
As far as i can see SecSkillNames is 28 entry long and last element is overlaped with SecSkillDescs.
|
|
Bersy
Honorable
Supreme Hero
|
posted August 15, 2019 10:32 PM |
|
|
Glad to see you again, gamemaster!
I've tried to use higher Delphi versions, but was not able to ensure same sizes/memory model (char => AnsiChar, string => AnsiString, changed default API, etc). So I wish you luck with this challenging task :-)
Thank you for bug reporting. You're right, 698C34 is valid address. Fixed. Will include update in the next release (this week, I hope).
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
gamemaster
Adventuring Hero
|
posted August 16, 2019 10:40 PM |
|
|
For now my main concern is that all work without crash or errors . I expected many more problems to even make it run.
#1:
Just to confirm.
h3era.exe from Era 2.8.6.exe instaler is heavily patched in compare, to let say 2.8.3 version. There are lot NOPs at places that jump at location $7712B0. Is that true or i just make some mess in my head .
What is purpose of that patches? To bypass internal error reporting?
#2:
I noticed that there is problem with "get current hero". Only on first day until some other calls don't populate variable (End turn, enter hero screen...). So variable is empty or it is wiped out before game start but not repopulate on first hero select.
Let say that there is
!?CM0&1000;
!!IF:W-1;
After clicking on monster on map i got "IF:W" - cannot find hero.
Dont know is that known problem.
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted August 16, 2019 10:47 PM |
|
|
Yeah, I got it also, if no hero is selected, no ID return. Well known issue.
|
|
Bersy
Honorable
Supreme Hero
|
posted August 17, 2019 12:24 AM |
|
|
#1. I removed WoG debug code include "tmpl.h" and RETURNV, used in almost every WoG function. They have no meaning for us, nops are safe.
#2. Current hero, afair, is a simple global variable. It's initialized in any trigger, where hero is actively present. Many triggers don't set it. So we should call !!HE-1:N?[some storage] in trigger with acting hero and forget about -1 furthermore. Or better use other ERM commands to get stable hero number, for instance current town visitor.
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
gamemaster
Adventuring Hero
|
posted August 22, 2019 10:13 PM |
|
|
#3
One minor thing in Heroes.Pas Line:248
Align_0: integer; _Types_: array [0..2] of integer; // +00
Align_1: integer; _Position_: array [0..2] of integer; // +10
Align_2: array [0..3] of integer; // DEFы // +20
Align_3: integer; _ArtRes_: array [0..2] of integer; // +30
Align_4: integer; _Monster_: array [0..2] of integer; // +40
Probably you should remove this character from source to keep it in ASCII form. This is typo?
#4
What software do you use for debuging and exploring game code? I mean beyond source code. Ida, olly... ?
#5
Here are link to 2 dlls for anyone that are willing to test. Era.dll and vfs.dll are included. To test just replace original dlls. Ofcourse, backup old ones .
Files are recompiled 2.8.8 version in new delphi. Game should work exacly same as old one. New features or bugfix are not inside.
At this point i am interested in information is new dll make any problems that are not presented in original one.
New dlls are larger than old one, 2+Mb each.
https://nitroflare.com/view/F0AB08E49DF4F18/era-288-dlls.zip
|
|
Bersy
Honorable
Supreme Hero
|
posted August 23, 2019 08:29 PM |
|
|
|
gamemaster
Adventuring Hero
|
posted August 23, 2019 08:48 PM |
|
|
#4 hehe i hoped "ida" will be answer
#5 Strange. Can you try link again. That premium stuff always make mess.
#6
Should this text be colored in HD mode? Red and gold?
Or it is only available in regular game.
|
|
RoseKavalier
Admirable
Supreme Hero
|
posted August 23, 2019 11:16 PM |
|
|
|
Bersy
Honorable
Supreme Hero
|
posted August 24, 2019 10:24 AM |
|
|
Quote: #4 hehe i hoped "ida" will be answer
IDA is great for analysis and as knowledge base.
#6 No support for HD 32bits mod and no official API for implementing it.
RoseCavalier wrote nice plugin, we could ask him to extract only HD 32 bits hooks into a separate dll for Era.
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
gamemaster
Adventuring Hero
|
posted August 24, 2019 09:43 PM |
|
|
@RoseKavalier
Thanks on idb database. That will help a lot.
I quickly tried to replicated two hooks you mentioned. For now i fail. Did not menage to find destination to patch. Seems that "southneedle" is not same in my version of dll (provided with 2.8.8). But i will keep tryng .
@Bersy
#7
Can you tell me what part of era strings are mention to be widestring. Only file paths? It is important only if few things are widestring and all other ansistrings.
At first place i changed almost all strings to ansistrings.
Now, i should revert some ansistring to widestring. There are two path i can go.
1. Revert all strings that dont go directly in game to unicode. This will make true port to new delphi versions,
2. Keep all as ansistring, and only file handeling revert back to widestring. This will be faster way. But can limit some special character functionality and make some problem with other languages.
I assume that option 1 is far better.
Did you tried ported dlls. Do provided link still report "premium only" error.
|
|
Bersy
Honorable
Supreme Hero
|
posted August 25, 2019 09:16 AM |
|
|
#7
vfs.dll does not need to be ported at all. It's a standalone project, which I don't change.
Other units are using String/AnsiString as AnsiString, Char as AnsiChar, WideChar as WideChar and WideString as WideString. Just don't change API with WideString in signatures. For instance, StrLib.pas has functions for both AnsiStrings and WideStrings.
Most common sources of problems will be if sizeof(char) <> 1, sizeof(integer) <> 4, sizeof(pointer) <> 4.
I tried your dlls, they work At least I was able to run game with mods, save and load and use a few dialogs without errors or crashes.
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
gamemaster
Adventuring Hero
|
posted August 25, 2019 01:39 PM |
|
|
Hehe, i see now that era use only vseimport.pas . Did not figure out that before.
But there is another problem. Both era and vfs use b2 library. If i port only era+b2 than vfs will need unported b2 library. So we will have 2 versions of b2 library. D2006 for vfs and D10.3.2 for era.
Actually, i started from era and ported all dependenceis that compiler find. At the end he found era+vfs+d2 . Anyway, for now all is ported.
I will check that "sizeof" problem. That is one thing i did not check. But all char types are changed to ansichar so 99% places should be ok by default.
Why you think that integer and pointer might be problem? i keept 32bit application so all should be 4bytes as before. Or i miss something ...
#8
I see on some places use of Ptr() and on some places use of casting to pointer.
ZvsAppliedDamage: pinteger = Ptr($2811888);
CurrentMp3Track: pchar = pointer($6A33F4);
Is there any reason why not everywhere use casting to pointer?
This is not important for now, just my curiosity...
|
|
Bersy
Honorable
Supreme Hero
|
posted August 25, 2019 02:49 PM |
|
Edited by Bersy at 14:50, 25 Aug 2019.
|
Ok, for 32-bits application sizeof(integer) must be 4 always. It's a problem if application should be portable to 64-bits.
System.Ptr function is really inlined cast to pointer, so I use it mostly because of short syntax in many places. It's a matter of taste, nothing critical.
Do you use automatic code processing script/tool?
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
gamemaster
Adventuring Hero
|
posted August 25, 2019 03:16 PM |
|
|
#8 Ok. Just need to know if i missed something
#9
Hmm i did not consider port to 64bit. Do we have any advantage to use 64bit dll in 32bit heroes application?
I mean is there any reason why i should consider 64bit? If there are advantages i can try that.
#10
Regarding code processing tools.
I do not have any. All i do is follow strict rule and examine code.
If you know any tool pleas share . I will use it for doublechecking.
For now i did:
-change types: string and char to ansi versions (including pointers),
-revert windows api callst to ansi versions
-TInterfaceAwareObject fix added. Do no know is that fix done correctly. So we will discuse abouth that soon.
|
|
RoseKavalier
Admirable
Supreme Hero
|
posted August 25, 2019 03:20 PM |
|
|
gamemaster said:
I quickly tried to replicated two hooks you mentioned. For now i fail. Did not menage to find destination to patch. Seems that "southneedle" is not same in my version of dll (provided with 2.8.8).
The needles are for the most recent version (HD_MCR 2.8), things might be slightly different in the ERA shipped version (1.9), the initial needle is likely the same but the second part different. Check it out with Olly and you can probably find a suitable candidate.
Also if the ERA-HDmod version is not going to be updated in the future then you can probably find the correct location and "hardcode" it with an offset.
____________
My Let's Plays: Metataxer's Revenge - The Empire of The World 2
|
|
Bersy
Honorable
Supreme Hero
|
posted August 25, 2019 03:35 PM |
|
|
#9 No need, Heroes is 32-bits application, it's ok.
#10 I had intention to write PHP parser for pascal, but didn't implemented it. Perhaps, if your port succeeds, I'll consider same task in the future, but currently bug hunting process is not most wanted ))
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
gamemaster
Adventuring Hero
|
posted August 25, 2019 04:01 PM |
|
|
@RoseKavalier
Yeah, i planed to make it hard-coded for now. When i had some time i'll try again. Compare you patch with source and replicate same patch to my version of dll at right location. Probably won't be problem, but for now i go with era porting.
@Bersy
I can write steps that i pass in this port. If, at the end, that provide good port it can be replicated in PHP script if needed for other projects. I do bug hunt because there are lots tiny places that could pass undetected and make problems later.
|
|
Bersy
Honorable
Supreme Hero
|
posted August 25, 2019 04:09 PM |
|
|
|
gamemaster
Adventuring Hero
|
posted August 25, 2019 04:31 PM |
|
|
#11
Any suggestion what 5 or 6 mods should i use for testing.
I need mods with minimal bugs and extensive usage of era capabilities.
You know, what mods to use to check any corner of era code but to avoid 100 mods with internal bugs that will make test much harder.
|
|
|