Banner left   Banner center   Banner right

Germanenglish Home · News · Diary · Screenshots · Documentation (Wiki) · Downloads · Guestbook · Forum

Home · Benutzer registrieren · Suchen · Statistik · FAQ · Benutzerliste

Zur Zeit online: keiner ausser dir

 X-Force - Fight For Destiny - Forum —› Quellcode / Programmierung —› Qestion about functions in sourcecode

Autor Mitteilung
verfasst am: 22.08.2009, 13:21
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Greetings.

Sorry for post, but I have two stupid question about sourcecode:

1. Infiltration.
I try to understood functions TTown.Infiltrate and TTown.GetInfiltration in OrganisationList.pas.
In Town.Infiltration (from 0910final) is exist limitation to max amount of infiltrated (invaded?) population:

  if fInfiltration>100 then
  begin
    fInfiltration:=100;
    result:=true;
    exit;
  end;
Looks like it is limitation to avoid hyper-invaded town (120% invaded) But in TTown.GetInfiltration fInfiltration is used as total, not percentage, amount of people.
function TTown.GetInfiltration: double;
begin
  if fEinwohner>0 then
    result:=fInfiltration/fEinwohner
  else
    result:=0;
end;
Also, fInfiltration is register as Integer, not as Double. What fragment have a truth? May be so infiltration level of towns never increase more than 0? And may be that there was planned something like this:
  if fInfiltration>fEinwohner then
  begin
    fInfiltration:=fEinwohner;
    result:=true;
    exit;
  end;
2. Wait for move I tried to wrote function TGameFigure.WaitForMove (sorry, I used TimeDelay function from WaitForWeapObj) and recieve this:
procedure TGameFigure.WaitForMove (NumberOfSteps:Integer);
var
  TU,count:integer;

  procedure TimeDelay(mSecs:Integer);
  var
    Time: Cardinal;
  begin
    Time:=GetTickCount;
    repeat Application.HandleMessage;
    until GetTickCount-Time>(mSecs);
  end;

begin
  if not (usMoveUnit in fstate) then exit;
  if (NumberOfSteps>0) then
  begin
    for count:=0 to NumberOfSteps-1 do
    begin
      TU:=fTimeUnits;
      while (TU=fTimeUnits) and (usMoveUnit in fstate) do TimeDelay(50);
    end;
    StopMove;
  end;
  while (usMoveUnit in fstate) do TimeDelay(50);
end;                                



Unit must do given amount of steps to its target and then stop. If NumberOfStep =0 if go until TU is over or game events is happened.
Will it work? And can it be useful?

Best regards.
verfasst am: 22.08.2009, 15:41
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
1) Yeah - it is pretty stupid. I myself stumbled about this. But it works. You have to check, where/when GetInfiltration is used. fInfiltration and Infiltration are used differently.
But I didn't change this one, because for now Infiltration has no consequence in X-Force.

2)This is dangerous. The game wil freeze, if TGamefigure stops befor reaching the destination (maybe (usMoveUnit in fstate) would prevent a freeze - but I'm not sure). Even if this works -what do you want to do with TGameFigure.WaitForMove? Normaly it is better, to use events.
verfasst am: 22.08.2009, 16:57
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Thanks
1) >>now Infiltration has no consequence in X-Force.
Sorry, I don't knew this. I think that GetInfiltration is useful parametr. Now I check it and find that TTown.Infiltration=TTown.GetInfiltration used only at town statistic :-(. Sorry, I had to check it earler.

2) Early I think that it can be used for non-repeating single operation in AI scripts. For example, hit_and_run or avoiding melee combat. Yes, all this can be done with events. Sorry. Damn, I need to think much more before I began to do something.

Sorry for trouble and waste time. This was really stupid questions.
verfasst am: 22.08.2009, 17:12
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
Zitat: gnfalex
Sorry for trouble and waste time. This was really stupid questions.

You are welcome ;)
verfasst am: 23.09.2009, 09:03
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
@Natter
Greetings.
About base repair - sorry what You mean as reassign?
If to open room repair dialog and change worker on this room - this is done.
Sorry that I very bad in english/description/code comment.

I check this feature on home-build and its work: if room currently in repair, then it show greenbox around repair symbol. If You click on room with low HP then show list of technicians and You can select it to repair this room (no matter is technic assigned to it or not). If someone is already work with this room, then he is marked as free (not assigned to project). Now I cannot think, how to show what technic are curently work with room, but it is may be can be solved at time.

If this feature is may be usefull, please take one more look at base.zip . In archive root is placed diff, in dirs - complete changed *.pas. If code commited in base.zip is not work please said - I will re-check and re-post it.

Best regards.
P.S. Sorry, where is best to post (hmm... doubtful?) messages like this?
verfasst am: 23.09.2009, 10:26
Admin, Spielsatz GalWar

Registrierdatum: 31.08.2005, 21:51

 Beiträge: 5595
Zitat: gnfalex
P.S. Sorry, where is best to post (hmm... doubtful?) messages like this?

If you don't know where to post something, make a new discussion. Just choose a title that will tell what's discussed inside.
verfasst am: 23.09.2009, 18:21 · Edited by: Natter
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
Zitat: gnfalex
If to open room repair dialog and change worker on this room - this is done.

Right, I wasn't able to find this simple solution^^ (you need to have some free technicans).


Zitat: gnfalex


If this feature is may be usefull, please take one more look at base.zip . In archive root is placed diff, in dirs - complete changed *.pas. If code commited in base.zip is not work please said - I will re-check and re-post it.

It works fine for me too, so I added this for v0.915b05
verfasst am: 25.09.2009, 14:55
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Greetings.
Thanks.
I have two more question
1. Is still need base building image refresh after research new building (procedure TDXBaseBuilder.ProjektEndHandler in DXBaseBuilder.pas)? If all images loading at spielstart, then it will cause only slowdown at basescreen open (around 5 seconds in Apocalypse 0.48). Is safe to comment content of this procedure?
2. Why TGamefigure.AIGroup.fCompleteEnemyList is filling only at the end of frist round? This will cause error (game crash if soldier see alien at first round) in TGameFigure.MoveUnit (lines 1734-1738 in GameFigure.pas r615). It is possible to add checkup like this?
if Self.AIGroup.fCompleteEnemyList.Count>0 then  
for i := 0 to Self.... //and so on from line 1734  

Best regards.
verfasst am: 25.09.2009, 23:33 · Edited by: Natter
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
Zitat: gnfalex
1. Is still need base building image refresh after research new building (procedure TDXBaseBuilder.ProjektEndHandler in DXBaseBuilder.pas)? If all images loading at spielstart, then it will cause only slowdown at basescreen open (around 5 seconds in Apocalypse 0.48). Is safe to comment content of this procedure?

1849
You are right - I will change this for 0.915b05.

Zitat: gnfalex
. Why TGamefigure.AIGroup.fCompleteEnemyList is filling only at the end of frist round? This will cause error (game crash if soldier see alien at first round) in TGameFigure.MoveUnit (lines 1734-1738 in GameFigure.pas r615). It is possible to add checkup like this?

I think so. Do you know, when fCompleteEnemyList is cleared (maybe it could contain units of a preview groundcombat)? Could you reproduce this crash, or do you only think, it would crash?
verfasst am: 26.09.2009, 00:06 · Edited by: gnfalex
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
1. Sorry, I don't know.
2. This is stable crash to desktop. Appeared in r615. Don't check it on Debug mode, only in PublicRelease. Cannot post errorlogs before Monday. Sorry.
verfasst am: 26.09.2009, 00:29 · Edited by: Natter
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
Zitat: gnfalex
2. This is stable crash to desktop. Appeared in r615. Don't check it on Debug mode, only in PublicRelease. Cannot post errorlogs before Monday. Sorry.

I don't need an error-log. If you say so, I believe you. I will check it.

I have found a problem with the repair of basebuildings. Maybe I made a mistake while adding your code, but as soon, as a room is added to the repairlist, it is not possible to reassign a technican (even if I free all technikans the button is still deactivated), because the room is still on the repairlist. I fixed this in function TBasisListe.CanRoomRepair
  result:=(Room.AktHitpoints<Room.Hitpoints) and (RoomInRepair(Room)<=0); //instead of =-1);
Do you see any problems with this change? What about:
function TVerBasis.BaseBuilderButtonRepair(
  Room: PEinrichtung): TBaseBuildButtonOption;
begin
  if SaveGame.BasisListe.CanRoomRepair(Room) then
    result:=bbboActive
  else
    if (SaveGame.BasisListe.RoomInRepair(Room)>=0) then
    begin
      result:=bbboImageOnly;
      if (SaveGame.BasisListe.RoomInRepair(Room)>=1) then result:=bbboInWork;
    end
  else
    result:=bbboInvisible;
end;

For what is bbboImageOnly (as far as I see it, my change prevents this status)?
verfasst am: 26.09.2009, 09:48
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Ok.
For activate button need to change line in DXBaseBuilder with 'AvailableProc(Info.Objekt)=bbboActive' to 'AvailableProc(Info.Objekt)<>bbboInvisible'. Or so on. Please, look at diff.
Active- damaged, not in repairlist.
ImageOnly - in repair list, not under work.
InWork - in repair list, under work.
Invisible - undamaged.
Please, don't remove ImageOnly.
Sorry, I have not now access to comp. Please check button, if not - can You, please send lastest variant of changed files?
Best regards.
verfasst am: 26.09.2009, 11:25 · Edited by: Natter
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
I rechecked the diff-file. There is only a change for TDXBaseBuilder.MouseMove, but it is missing for TDXBaseBuilder.MouseUp. This should solve the problem, thanks.
verfasst am: 27.09.2009, 17:58
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Greetings.
I understood what was happened.
Diff was created with DXBaseBuilder r614. r616 some longer, so changes from TDXBaseBuilder.MouseUp was come accurate into position of very similar (identical) strings in TDXBaseBuilder.MouseMove. In posted DXBaseBuilder.pas changes are in right place (MouseUp). Just coincidence...
Sorry that I don't think about possibility of this situation.
Will it work now?
Best regards.
verfasst am: 27.09.2009, 23:55
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
Zitat: gnfalex
Will it work now?

Yes.
verfasst am: 28.09.2009, 17:09
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Greetings.
Sorry, once more about TBase.RepairRoom.
Im not fully understood, but, please dont use fRepairList[high(RepairList)] (lines 2958 and 2968) This strings arent need, but will cause a errors (last bulding sometimes exluding from repair list).
And please, can You add parametr to SetTechnicansForRepair to be able force assign given techniker to repair from training or projekt? Or return werkstatt_api_setrepairstatus(werkstatt_api_GetTechnikerIndex(Technike rID)) to 'if TechnikerID<>0'
Best regards.
verfasst am: 29.09.2009, 21:03 · Edited by: gnfalex
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Greetings.
About Self.AIGroup.fCompleteEnemyList: sorry, it is my error.
Self.AIGroup.fCompleteEnemyList.Count does not lead to error.
Error is caused by something in this two string (TGameFigure.MoveUnit, 1737-1738) during first (at least I got error only at first) move, when soldier see alien or alien see soldier.
if TGameFigure(Self.AIGroup.fCompleteEnemyList[i]).IsMoving then
TGameFigure(Self.AIGroup.fCompleteEnemyList[i]).StopMove;
Several times I got error during IsMoving (at subfunction TWay.GetHasPath), several StopMove (TWay.GetReached). Sometimes it work normally. I cannot catch it. Sorry. Errorlogs is here:http://rapidshare.de/files/48441017/error.zip.html PS. Is exist way to make errorfiles more verbose (show call stack)? And is changing in source code can prevent to decode errorlog? For random case I rewrite first 8 strings from call stack from both variant of error.
// first variant of error
:7c812aeb kernel32.RaiseExeption + 0x52
:0066c03d HookedRaiseExeption +$51
:00404b00 NotifyNonDelphiExeption +$1C
:7c90327a ntdll.RtlConvertUlongToLagreInteger + 0x3c
PathFinder.TWay.GetReached
GameFigure.GameFigure.StopMove
GameFigure.TGameFigure.MoveUnit(1)
DXIsoEngine.TDXIsoEngine.PerformFrame($D2FDA0,1)
////////////////////////////
// second variant of error
:7c812aeb kernel32.RaiseExeption + 0x52
:0066c03d HookedRaiseExeption +$51
:00404b00 NotifyNonDelphiExeption +$1C
:7c90327a ntdll.RtlConvertUlongToLagreInteger + 0x3c
PathFinder.TWay.GetHasPath
GameFigure.GameFigure.GetMoving
GameFigure.TGameFigure.MoveUnit(1240956)
DXIsoEngine.TDXIsoEngine.PerformFrame($D2FDA0,2)
Best regards Edited: find error in basisliste.pas. To avoid situation of all technicians assigned to single building must be
 // Alten Techniker freistellen (falls noch nicht verkauft)
      if (fRepairList[Dummy].Techniker<>0)  then
      begin
        werkstatt_api_FreeTechniker(werkstatt_api_GetTechnikerIndex(fRepairLis t[Dummy].Techniker));  //// this string was lost to somewhere
        fRepairList[Dummy].Techniker:=0;
      end;


I understood nothing. Sorry
verfasst am: 30.09.2009, 01:23 · Edited by: Natter
Programmierer, allgemeines

Registrierdatum: 06.06.2004, 17:19

 Beiträge: 3186
Zitat: gnfalex
PS. Is exist way to make errorfiles more verbose (show call stack)? And is changing in source code can prevent to decode errorlog? For random case I rewrite first 8 strings from call stack from both variant of error.

You need to compile map2sma and ErrorAnalyse. Both files need an INI-File (included in SVN - of course you have to change paths). The first file is needed to make a *.sma-File of the XForce.map. This is needed after each Code-Change. With this sma-File you can use errorAnalyse to decode your error.txts.
verfasst am: 02.10.2009, 10:43
Programming

Registrierdatum: 01.07.2008, 07:53

 Beiträge: 109
Greetings.
Thanks. Sorry, I don't know this.
Reloaded error files (2 with first error, 1 with second).: error2.zip
And - about Geoscape message system. Please look at TakticPlugin.fun in error2.zip. I change it to fill Geoscape screen by messages only by one third and make addon to megre similar message into one. Commentaries inside. I dont touch savegame, so MaxMessages in options still inactive.
Best regards.



Du musst dich registrieren um auf dieses Thema zu antworten.
Login :: » Name » Passwort

Ladezeit (sec.): 0.017 · Powered by miniBB 1.6 with parts of 1.7 © 2001-2003