Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 3.5 - WoG and Beyond > Thread: ERA II - Source code - Help and discussion
Thread: ERA II - Source code - Help and discussion This thread is 11 pages long: 1 2 3 4 5 6 7 8 9 10 11 · «PREV / NEXT»
gamemaster
gamemaster


Adventuring Hero
posted February 01, 2020 11:50 PM

Nice.
I just stumped on it and remember that FU was changed recently, while line 619 remain same.

Good to know that all is under control

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted February 04, 2020 07:16 PM
Edited by gamemaster at 19:30, 04 Feb 2020.

Hi

Anything changed in d2 library in new patch 2.9.8?
Can you upload to git if it changed.

What is meaning of tags in code:
{U} {n} {!} {O} ...
Are they added by third party software?
Perhaps GExperts or CnPack?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted February 04, 2020 08:20 PM

Hi, nothing changed.
Tags are custom way to mark memory ownage.
{O} means unit or procedure Owns class instance/heap pointer. It's responsible for item creation/freeing.
{U} means, that procedure or unit Uses reference to resource, but is not responsible for its deallocation.
{n} means, that pointer can be Nil (it's allowed and no need in asserting, that it's not nil).
{!} simple comment to highlight assertion or some other construction like critical section enter/leave.
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted February 09, 2020 02:05 PM

Hi,

I come to Heroes.pas file.
It seems that Delphi XE has small problem with one structure

Is there any consequence if we make separate record and use it instead declaring record in place.
For example

TGlobalEvents = packed record
 First, Last, Dummy: PGlobalEvent;
end;
...
GlobalEvents: TGlobalEvents;
...


Problem is related to cosmetic and productivity. In this file half of code can not be folded and Ctr+click does not work for all declarations below this record.
It is delphi bug i guess.
Also you should avoid inplace record declaration if possible to avoid future problems.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted February 09, 2020 05:10 PM

Inplace declarations of arrays and records were not a problem. It's definitely IDE issue with folding only, but ok.
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted February 16, 2020 09:47 PM

Hi


Do you know what is meaning of exclamation mark near interface in structure tree?
I can not find any reason why compiler make that note.
There is no warning or hint related to interfaces. It compile and game work (at least first few days i tested ).

Just need to know is that something that need investigation or i can skip it.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Archer30
Archer30


Adventuring Hero
posted February 27, 2020 04:50 AM
Edited by Archer30 at 06:29, 27 Feb 2020.

Hi, sorry for my noob question but where can I find the latest ERA source code? It seems ...Tools/era/sources is only updated to 2.6.x.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted February 27, 2020 11:11 AM

gamemaster, sorry, hard to say )
Archer30, https://github.com/ethernidee/era
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Archer30
Archer30


Adventuring Hero
posted February 27, 2020 12:13 PM

Thanks Bersy!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted February 27, 2020 06:53 PM
Edited by gamemaster at 18:55, 27 Feb 2020.

Bersy said:
gamemaster, sorry, hard to say )
Archer30, https://github.com/ethernidee/era

i agree.
Until we officially use port as base, it is best to use D2006 version.

Anyway. I recheck Era source again. Vfs and b2 will be rechecked as side project. It is good to know that 2nd check did not show any leftover problems from 1st time. At this moment modifications on source are minimal to keep it as much as possible similar to original.
By that i concluded phase 1.

In phase 2 i plan to debug all functions one by one. Focus will be on data structure, align, string/ansistring automatic conversion, wrong pointers .... That will not be easy...

Other way of action can be in depth focus only on newly added receivers. And all other function check where needed. That way important mater will be check first.

Phase 2 probably introduce code formatting and removing unused variables and uses. Perhaps some other improvements.
Also i will make git for that. Doing that trough delphi integration is pure evvviiiil. So i will make it manually.

Anyway in this phase i finally must write scripts for testing , until now i successfully avoid that .

Barsy, if you have any particular concern about port i can first check that mater. You once mentioned align problem of some records. That can be first point of interest...

Also, i noticed that you gone silence like you prepare something major

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted February 27, 2020 08:15 PM

Great plans!

Probably it's safe, but it should be checked, whether pointer(Str) casts are still safe in newer Delphi versions. Same as pointer(dyn. array variable). The rest should be ok, I think. I try to use types instead of magic constants whenever possible like sizeof(integer) or sizeof(v^[1]).
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted March 01, 2020 03:30 PM
Edited by gamemaster at 15:31, 01 Mar 2020.

Ported 2.9.12

I did quick checks. And as exacted pointer(str) work as it should be.
If str is unicode (by default string) it point to unicode memory. If it is ansi then memory is ansi. That is reason why it is best to always use proxy type (myAStr) to avoid typecast at right points.
I did not check if some optimization by compiler can occur that will make mess. But it is hardly expected to mix unicode and ansi.

Pointer to dynamic arrays work as it should. Like
Erm.MonNamesSingularTable:UtilsB2.PEndlessPcharArr = Ptr($7C8240); for example. Also, pointer to that pointer work alright.

sizeof(v^[1]) return 4 as it should so probably no problems with that also.

Problem with sizeof and length may occur in procedures that accept "array of const" as parameter. Strings that are passed to those parameters must be cast to ansi.
Like
Hints[myAStr('object')] or
Core.p.WriteDataPatch(Ptr($711F4F), [myAStr('8B451425FFFFFF048945149090909090909090')]);
That is only place where easy error can be made.  If not they will be by default string (Unicode). That is why i added exception to unicode type so it will be easily located if miss-used.

For now i can summarize port to: cast all characters to ansistring/ansichar and use ansi version of functions. Beside that i had few minor modifications.

Anyway porting goes better than i exacted

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted March 01, 2020 05:16 PM

Nice work and investigation!

It's sad a bit, that in const parameters string are Unicode by default, which requires typecasting, but it's not very often to use array of const, so the solution is quite acceptable. I will probably manually typecast to AnsiString const arguments in new code too.
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted March 01, 2020 06:28 PM
Edited by gamemaster at 18:35, 01 Mar 2020.

Bersy said:

It's sad a bit, that in const parameters string are Unicode by default, which requires typecasting, but it's not very often to use array of const, so the solution is quite acceptable. I will probably manually typecast to AnsiString const arguments in new code too.


Indeed, that is not big problem.
Especially because only constant string parameters are problem. if ansistring is variable there is no problem because delphi can determinate right type.

Also i noticed that in most of code you use full qualifier names for functions (like "EventMan.GetInstance.On(...);" instead "GetInstance.On(...);"). That can be helpful in port and it is clear to read.
Perhaps that style can be encourage for all delphi native functions. So in one point cleanup can be made. Then all functions from delphi can be collected to one wrapper unit where it will be easier to maintain. That wrapper can contain all ansistring functions together with all other functions that need to be adapted to work safe with ansi. Something like Legacy.pas .

That have few benefits. If function is from Legacy... then we know that is safe, and if it has SysUtils... it should be made safe.
If function has no qualifier then it can be problematic.

Take this as example
Uses SysUtils, Legacy;
...
Format('xxx',[]); // This return ansistring


Or this
Uses Legacy, SysUtils;
...
Format('xxx',[]); // This return unicode


In some cases compiler wont warn that string type is different. Like in this dummy situation Hints[ Format('xxx',[]) ]
If we had qualifier (Sysutils or Legacy we will be warn and know what to do...). This is just one example where qualifier can help and it dont make big mess in code. Some long qualifiers should be avoided to make code clear
This is just suggestion.

In port i already use this approach. For example all Format are Legacy.Format...
Actually one of steps that i made is to check from what units function is called to be sure is that right version. Especially when uses list is larger and multiple options for one function exists.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted March 01, 2020 07:43 PM

To say the truth after years I began using IntToStr, Format and sometimes FillChar without unit prefix, because it's really annoying to right long expressions with most often used system functions. Would it be ok if only IntToStr and Format are used prefix-less and all other functions are fully qualified?
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted March 01, 2020 09:08 PM


For now i use ansistring verion of IntToStr.

function IntToStr(Value: Integer): myAStr;
begin
 AnsiStrings.FmtStr(Result, '%d', [Value]);
end;

That is actually wrapper. Perhaps we change how it work so it will be easier in wrapper function.
Regular intostr function has only string version and not ansistring so cast will be needed anyway.

So regarding port it must not call original function but "fixed" one.

But you should not much pay attention to port. Just code as usual. It is not big deal to port because i always compare old and new version and copy only difference. That way i can do port in 1-2h.

I preparing git. Currently i am in processes of learning so some time will be needed to do it proper .

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
gamemaster
gamemaster


Adventuring Hero
posted March 07, 2020 02:20 PM
Edited by gamemaster at 14:23, 07 Mar 2020.

This function is from Eventman.pas
function TEventInfo.GetNumHandlers: integer;
begin
 //result := Utils.IfThen(Self.fHandlers <> nil, Self.fHandlers.Count, 0);
 if Self.fHandlers <> nil
   then result := Self.fHandlers.Count
   else result := 0;
end;


Commented part is from original version and rest is ported.
In some cases original version raise exception. When fHandle=nil then second argument (Self.fHandlers.Count) can not be evaluated.

How this work in D2009 and not i XE?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
majaczek
majaczek


Supreme Hero
Work at Magic Dimmension
posted March 25, 2020 11:04 PM

how to compile the delphi source of era.dll ?

what free program to use?

I am clueless

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted March 26, 2020 12:20 AM

gamemaster, that was my try to implement ternary operator at least for simple expressions (IfThen function is inline and condition can be short-evaluated), but seems, that there is still no stable way to do it. Will replace the code with if ... then ... end block everywhere, thanks.

I also invite you guys on English forum (http://wforum.heroes35.net/forumdisplay.php?fid=64), there is language switch in the right upper corner. HC stopped working for me in Firefox and can shutdown any time.

majaczek, you need commersial Delphi 2007 to compile Era code. gamemaster posrted the code to Delphi XE, but the port is not fully released currently.
____________
Heroes 3 Era and everything for it. Releases folder for releases.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
majaczek
majaczek


Supreme Hero
Work at Magic Dimmension
posted March 26, 2020 10:29 AM
Edited by majaczek at 10:31, 26 Mar 2020.

screenshot

it doesn't work when trying to compile

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 11 pages long: 1 2 3 4 5 6 7 8 9 10 11 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.1244 seconds