|
Thread: ERA II - Source code - Help and discussion | This thread is pages long: 1 2 3 4 5 6 7 8 9 10 11 · «PREV / NEXT» |
|
Bersy
Honorable
Supreme Hero
|
posted March 29, 2020 01:37 PM |
|
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted March 29, 2020 03:08 PM |
|
|
Bersy said: The last DL parameter (redraw) is not mentioned in help, but without it many dialogs randomly crash. So I advice to use it almost always or at least once after loop.
nice to know
|
|
gamemaster
Adventuring Hero
|
posted March 29, 2020 03:22 PM |
|
|
@majaczek
Quote: EDIT:
Quote:
ZVSE
!?PI;
!!SN:L^era.dll^/?y66 Ay66/^PluginExists^/?y77 Ey77/1/^Skirmish^; !!VRy99:Sv1; [majaczek]
!!FU&v1<>0:E;
!!VRz1:S^Choose Skirmish Name^;
!!VRz9:S^Skirmish^;
!!IF99/0/1/0/0/0/0/0/0/0/0/0/0/0/0/0;
!!IF:F99/////0; !!IF:E1/99; !!VRz999:Sz1;
this script doesn't work on DLL you provided
(it skips dialog and z999 is empty)
but it works on original 2.9.12
Problem is in different size of function result.
Old version return 4 bytes and new one return 1 byte.
Then that number is copied over v1. In latest case that will produce number >0 (xxxxxx00).
For now i can fix that but i need better solution for all potential locations in future.
https://dropmefiles.com/jM0XT
There are 2 test dll.
-Removed fix for division by zero. I assume that you fixed scripts by adding 4th parameter to DL:A.
-Fixed "Skirmish" problem.
@Bersy
Is possible to make "AdvErm.CallProc" function aware of above problem. I mean is possible to copy to V1 right size of bytes from function result instead of entire EAX?
EDIT:
Pleas push b2 library to github.
I need StrLib.SkipCharsetEx
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted March 29, 2020 10:36 PM |
|
Edited by majaczek at 22:47, 29 Mar 2020.
|
Exception
{
Module: h3era HD.exe
Adress: [ 0x0043E1F9 ]
Code: EXCEPTION_ACCESS_VIOLATION
Flags: 0x00000000
Information: read of address: 0x00000030
}
EDIT: yes the "Skirmish bug" is fixed
|
|
gamemaster
Adventuring Hero
|
posted March 29, 2020 10:53 PM |
|
|
Can you post how to reproduce bug
or pack debug folder so i can try to reproduce it.
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted March 29, 2020 11:15 PM |
|
Edited by majaczek at 00:11, 30 Mar 2020.
|
gamemaster said: Can you post how to reproduce bug
or pack debug folder so i can try to reproduce it.
it didn't repeat after reload from save
edit:
crash after trying to save via default menu
|
|
Bersy
Honorable
Supreme Hero
|
posted March 30, 2020 01:04 AM |
|
|
|
gamemaster
Adventuring Hero
|
posted March 30, 2020 10:44 PM |
|
|
@majaczek
Do you have same error with original dll and ported ones?
I make quick check and get error on both dlls.
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted March 31, 2020 08:11 AM |
|
Edited by majaczek at 14:07, 31 Mar 2020.
|
gamemaster said: @majaczek
Do you have same error with original dll and ported ones?
I make quick check and get error on both dlls.
I think yes. It's (sometimes) when pressing System Menu -> Save Game
EDIT:
Quote:
!?CM2; Hero Screen,
!!HE-1:N?y-10;
!!FU&y-10<>117:E; Korbac
!!SN:W^Amethyst Upgrades^/?y22; check if Amethyst Upgrades is present
!!HE117&y22=0:X1/105; Dragon Flies
!!HE117&y22=1:X1/277; Deadly Wasps
!!CM:I?y1 S?y2 F?y3;
!!if&y1>=68/y1<=74:;
!!VRy3:Sy1 -68; y3=troop slot, 0-6
!!HE117:C0/y3/?v1/?v3; v1=type, v3=number
!!FU|v1<0/v3<1:E; exit if slot empty
!!VRv2:S-1;
!!VRv2|v1=104/v1=105:S105;
!!VRv2&v2=105/y22=1:S222;
!!VRv2|v2=222/v1=222:S277;
!!HE117&v2>0:X6/v1/v1/v2;
!!en:;
!!if&y1=118:;
!!IF&y22=0:M^Korbac upgrades Serpent Flies into {Dragon Flies}, which get additional bonuses under her commmand^;
!!IF&y22=1:M^Korbac upgrades Serpent Flies and Dragon Flies and Blood Hornets into {Deadly Wasps}, which get additional bonuses under her commmand^;
!_!CM:R0;
!!en:;
doesn't work on test build but works on 2.9.12
in test build it upgrades to pikeman (creature 0)
on 2.9.12 it upgrades properly to deadly wasps
|
|
gamemaster
Adventuring Hero
|
posted March 31, 2020 09:07 PM |
|
|
@Bersy
#1
Pleas look at AdvErm.ApplyIntParam. There is another potential division by zero.
Just noticed and report, without confirmed problem.
#2
How to brake script at desired location in delphi?
I mean how to find and brake for example at trigger start (e.g start of !?CM2). Or brake at an line in script (e.g line 526 of script xxxx)?
Any suggestion how to get control of script debug?
I have some methods but take time...
#3
Just one tough.
How hard it will be to make new command. For example !!DB:G;
That will be debug command not meant for script writers but for code debugging.
It will simple hit code brakepoint (asm INT 3; or "DebugBreak").
Few local variable should point to vital parts.
For example to ingame variables, current cmd that are executed, all other info that is available and can be helpful.
You get idea.
Make script to brake code, and take all important pointers in one function for easier debug and problem hunting.
In above situation i could go to script and put "!!DB:G" then i will brake at exact location with all needed info.
Just wondering...
@majaczek
I reproduce error but need some time to get control over situation
Today i had long day
|
|
Bersy
Honorable
Supreme Hero
|
posted April 01, 2020 01:19 AM |
|
|
#1. Thanks, done.
#2-3. Usually no need to debug line by line.
a) Look at DebugEraerm tracing.erm with all executed triggers and commands tracing. erm_memory.txt will have variables on crash.
F11 generates both files, same as SN:F^GenerateDebugInfo^.
b) Modify any SN command or extend AdvErm.SN_Receiver with smth like "V":
while FindNextSubcmd(['P', 'S', 'G', 'Q', 'L', 'A', 'E', 'D', 'H', 'T', 'I', 'F', 'X', 'M', 'K', 'W', 'D', 'O', 'R', 'U']) do begin
here /|
and here:
'V': begin Success := SN_V(NumParams, @Params, Error); end;
and add simple function:
function SN_V (NumParams: integer; Params: PServiceParams; var Error: string): boolean;
begin
asm int 3 end;
result := true;
end;
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted April 01, 2020 01:43 PM |
|
|
How is it possible to use ERA API to add new erm commands from plugin ?
|
|
Bersy
Honorable
Supreme Hero
|
posted April 01, 2020 02:38 PM |
|
|
It's definitely not recommended to extend ERM with new commands (better write library scripts with !?FU(name)).
But if you wish anyway, use: RegisterErmReceiver
typedef int (__stdcall *TRegisterErmReceiver)(char name[2], ErmInnerHandler handler, int type);
typedef int (__cdecl *ErmInnerHandler)(char, int, void*, void*);
or (char Cmd,int NumParams,_ToDo_*sp,Mes *Mp) from WoG Sources (see all structures their).
type is what receiver expects as parameters before ":" and can be:
CMD_PARAMS_CONFIG_NONE = 0;
CMD_PARAMS_CONFIG_SINGLE_INT = 1;
CMD_PARAMS_CONFIG_ONE_TO_FIVE_INTS = 2;
CMD_PARAMS_CONFIG_SINGLE_INT_AS_STRUCT_PTR = 3;
CMD_PARAMS_CONFIG_FOUR_INTS = 4;
CMD_PARAMS_CONFIG_TWO_VARS = 5;
You'll also need different functions like:
ZvsApply: function (Dest: pinteger; Size: integer; Cmd: PErmSubCmd; ParamInd: integer): longbool cdecl = Ptr($74195D);
ZvsGetVarValIndex: function (Param: PErmCmdParam): integer cdecl = Ptr($72DCB0);
ZvsGetVarVal: function (Param: PErmCmdParam): integer cdecl = Ptr($72DEA5);
ZvsSetVarVal: function (Param: PErmCmdParam; NewValue: integer): integer cdecl = Ptr($72E301);
ZvsGetParamValue: function (var Param: TErmCmdParam): integer cdecl = Ptr($72DEA5);
ZvsReparseParam: function (var Param: TErmCmdParam): integer cdecl = Ptr($72D573);
--------------------------
I still recommend you to write exported functions and ERM handlers.
Call GetArgXVars to get pointer to up to 16 x-arguments to set before FireErmEvent, then call GetRetXVars to get pointer to up to 16 resulting x-vars after.
____________
Heroes 3 Era and everything for it. Releases folder for releases.
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted April 01, 2020 03:24 PM |
|
|
Bersy said: ...
You'll also need different functions like:
ZvsApply: function (Dest: pinteger; Size: integer; Cmd: PErmSubCmd; ParamInd: integer): longbool cdecl = Ptr($74195D);
ZvsGetVarValIndex: function (Param: PErmCmdParam): integer cdecl = Ptr($72DCB0);
ZvsGetVarVal: function (Param: PErmCmdParam): integer cdecl = Ptr($72DEA5);
ZvsSetVarVal: function (Param: PErmCmdParam; NewValue: integer): integer cdecl = Ptr($72E301);
ZvsGetParamValue: function (var Param: TErmCmdParam): integer cdecl = Ptr($72DEA5);
ZvsReparseParam: function (var Param: TErmCmdParam): integer cdecl = Ptr($72D573);
...
How will this look like in C/C++ syntax (I believe you put here pascal/delphi syntax by mistake) ?
|
|
gamemaster
Adventuring Hero
|
posted April 01, 2020 06:40 PM |
|
|
@Bersy
In last github version there are two redundant functions:
Quote: ZvsStringSet_Clear: procedure () cdecl = Ptr($7764F2);
ZvsStringSet_GetText: function (Index: integer): myPChar cdecl = Ptr($776620);
Look few lines above, or search by address and you will find it.
Any reason for that?
Regarding to debuging brake:
Thanks for idea. I will try it...
EDIT
Actually it went well.
I managed to make debug dump in any situation not just at on key event. All you need after brake to call debug dump trough delphi evaluate/modify.
Also, i manage to add SN:V as you suggest.
That seems useful to me .
|
|
Hawaiing
Adventuring Hero
|
posted April 03, 2020 08:46 AM |
|
|
Hi Bersy
Hi gamemaster
Would you please tell me what the following code does and how it work?
Core.p.WriteDataPatch(Ptr($74C1AE + 2), ['%d', @@AdditionalCmds[0].Handler]); // Patched command
$74C1AE+2 -> [027f9990]??
0074C1AE - 8b 15 90 99 7f 02 - mov edx,[027f9990]
|
|
gamemaster
Adventuring Hero
|
posted April 03, 2020 08:40 PM |
|
|
No sure what you plan with that...
It patch address $74C1BO ($74C1AE+2).
Replacing original value with address of handler from first item in list. List contain command letters and pointer to function (handler) which that letters represent.
For example
Quote: ((('C', 'D'), 17475), $70C1D7, 0)
Represent 'CD' command that is linked to function (handler) at address $70C1D7.
I am not sure what is original value $027f9990. Probably old structure that is replaced with ERA equivalent or just deture.
Also i am not sure what code at patched location do.
EDIT
@majaczek
Quote: 01 !?CM2; Hero Screen,
02 !!HE-1:N?y-10;
03 !!FU&y-10<>117:E; Korbac
04 !!SN:W^Amethyst Upgrades^/?y22; check if Amethyst Upgrades is present
05 !!HE117&y22=0:X1/105; Dragon Flies
06 !!HE117&y22=1:X1/277; Deadly Wasps
07 !!CM:I?y1 S?y2 F?y3;
08 !!if&y1>=68/y1<=74:;
09 !!VRy3:Sy1 -68; y3=troop slot, 0-6
10 !!HE117:C0/y3/?v1/?v3; v1=type, v3=number
11 !!FU|v1<0/v3<1:E; exit if slot empty
12 !!VRv2:S-1;
13 !!VRv2|v1=104/v1=105:S105;
14 !!VRv2&v2=105/y22=1:S222;
15 !!VRv2|v2=222/v1=222:S277;
16 !!HE117&v2>0:X6/v1/v1/v2;
17 !!en:;
18 !!if&y1=118:;
19 !!IF&y22=0:M^Korbac upgrades Serpent Flies into {Dragon Flies}, which get additional bonuses under her commmand^;
20 !!IF&y22=1:M^Korbac upgrades Serpent Flies and Dragon Flies and Blood Hornets into {Deadly Wasps}, which get additional bonuses under her commmand^;
21 !_!CM:R0;
22 !!en:
i tested your problem
up to line 16 all seems all right to me. All parameters are in place.
Here i need some info to proceed.
1. Line 16 make actual upgrade? So it upgrade creature 104 to 277 ?
2. What should happens after line 16? it goes to 17, 18 .... Or it should exit function and skip lines from 17 to 22? I exacted that control go to 17 but from some reason it exit from function and skip rest.
So problematic is line 16 that make wrong update and wrong flow after that. Need your opinion so can investigate further.
Perhaps it is related to hero specialty too...
Problem exist only on this test build. Era 2.9.12 seems to work ok.
I used your last version from 4/4/2020
|
|
majaczek
Supreme Hero
Work at Magic Dimmension
|
posted April 05, 2020 11:00 AM |
|
Edited by majaczek at 11:02, 05 Apr 2020.
|
gamemaster said:
....
@majaczek
...
i tested your problem
up to line 16 all seems all right to me. All parameters are in place.
Here i need some info to proceed.
1. Line 16 make actual upgrade? So it upgrade creature 104 to 277 ?
2. What should happens after line 16? it goes to 17, 18 .... Or it should exit function and skip lines from 17 to 22? I exacted that control go to 17 but from some reason it exit from function and skip rest.
So problematic is line 16 that make wrong update and wrong flow after that. Need your opinion so can investigate further.
Perhaps it is related to hero specialty too...
Problem exist only on this test build. Era 2.9.12 seems to work ok.
I used your last version from 4/4/2020
1) yes. creature 277 is provided with amethyst
2) if upgrade exits. else if clicking specialty shows the info about specialty.
|
|
gamemaster
Adventuring Hero
|
posted April 05, 2020 06:12 PM |
|
|
@majaczek
1. ok
2. Debugged it bad . Work as exacted.
I tracked problem. It is related to new function introduced after 2.9.12. My port is up to date with new era so it has that function and problem.
It is important to me that port and original has same errors . In that case port is good
Now i will try to fix problem.
@Bersy
Problem is introduced with Erm.Hook_HE_X function. Not sure at this point but SpecRecord.Setup is populated wrong.
this line for example
!!HE117:X6/104/104/277;
when it works (2.9.12 version), SpecRecord.Setup look like this
(6, 104, 0, 0, 0, 104, 277)
but it is now
(6, 104, 104, 277, 0, 0, 0)
Not sure what is SpecRecord.Setup structure. Is that related to two versions of HE:X6 command
Anyway if Erm.Hook_HE_X is disabled all work well
|
|
Hawaiing
Adventuring Hero
|
posted April 06, 2020 05:19 AM |
|
|
gamemaster said: No sure what you plan with that...
It patch address $74C1BO ($74C1AE+2).
Replacing original value with address of handler from first item in list. List contain command letters and pointer to function (handler) which that letters represent.
For example
Quote: ((('C', 'D'), 17475), $70C1D7, 0)
Represent 'CD' command that is linked to function (handler) at address $70C1D7.
I am not sure what is original value $027f9990. Probably old structure that is replaced with ERA equivalent or just deture.
Also i am not sure what code at patched location do.
EDIT
@majaczek
Quote: 01 !?CM2; Hero Screen,
02 !!HE-1:N?y-10;
03 !!FU&y-10<>117:E; Korbac
04 !!SN:W^Amethyst Upgrades^/?y22; check if Amethyst Upgrades is present
05 !!HE117&y22=0:X1/105; Dragon Flies
06 !!HE117&y22=1:X1/277; Deadly Wasps
07 !!CM:I?y1 S?y2 F?y3;
08 !!if&y1>=68/y1<=74:;
09 !!VRy3:Sy1 -68; y3=troop slot, 0-6
10 !!HE117:C0/y3/?v1/?v3; v1=type, v3=number
11 !!FU|v1<0/v3<1:E; exit if slot empty
12 !!VRv2:S-1;
13 !!VRv2|v1=104/v1=105:S105;
14 !!VRv2&v2=105/y22=1:S222;
15 !!VRv2|v2=222/v1=222:S277;
16 !!HE117&v2>0:X6/v1/v1/v2;
17 !!en:;
18 !!if&y1=118:;
19 !!IF&y22=0:M^Korbac upgrades Serpent Flies into {Dragon Flies}, which get additional bonuses under her commmand^;
20 !!IF&y22=1:M^Korbac upgrades Serpent Flies and Dragon Flies and Blood Hornets into {Deadly Wasps}, which get additional bonuses under her commmand^;
21 !_!CM:R0;
22 !!en:
i tested your problem
up to line 16 all seems all right to me. All parameters are in place.
Here i need some info to proceed.
1. Line 16 make actual upgrade? So it upgrade creature 104 to 277 ?
2. What should happens after line 16? it goes to 17, 18 .... Or it should exit function and skip lines from 17 to 22? I exacted that control go to 17 but from some reason it exit from function and skip rest.
So problematic is line 16 that make wrong update and wrong flow after that. Need your opinion so can investigate further.
Perhaps it is related to hero specialty too...
Problem exist only on this test build. Era 2.9.12 seems to work ok.
I used your last version from 4/4/2020
Thanks you gamemaster!
I still have no idea about that
@majaczek
HE.X must fill fully parameters in ERA,don't use the shorter one
|
|
|