library ErrataBS2; {$mode objfpc}{$H+} {$R *.res} uses Classes { you can add units after this } , uHCDefines , uHCGCI, uHCGlobals, uHCTypeDefs, uHCEventHelpers, uHCDateTime , uHCAnnexDefs, uHCAnnexHelpers, uLazGUIGlobals, uHCUtils , Windows, ShellAPI, SysUtils; const DLLVERN = 1; DLLVERINTN = 45; var HCannex_id_to_disk_id: THCannex_id_to_disk_id; HCdisk_id_to_annex_id: THCdisk_id_to_annex_id; AnnexData: PHCAnnexes_disk; PStartGroup: PHCGroup; gintBSNum: Integer; {*** Return DLL internal version, i.e. revision 5 of my DLL ***} function DLLVer():word;export;cdecl; begin result := DLLVERN; end; {*** Return DLL interface version, i.e. revision 1 of my HCE interface spec ***} function DLLVerInt():word;export;cdecl; begin result := DLLVERINTN; end; {*** Return DLL description, 255 characters max ***} function DLLDesc():PAnsiChar;export;cdecl; begin result := 'perform corrrective tasks for BS#2 DB at game start by Don Thomas'; end; {*** Free DLL ***} procedure DLLFree();export;cdecl; begin // Do any cleanup here, this is the end end; {*** Init DLL ***} procedure DLLInit(hwndHC: HWND; pathHC: PAnsiChar; verHC: PAnsiChar; verSaveGame: LongWord; funcRefs: PHCDLL_FUNC_REF; PGEClosing: Pointer; PDLLBusy: Pointer; verInterface: LongWord; srandSeed: longword; harpoon_uuid_session: PAnsiChar; hclicense_dt_expire: Int64; hclicense_licensee: PAnsiChar; usblicense_desc: PAnsiChar; RESRSRStructureVersion: ulong; AnnexVersion: ushort);export;cdecl; var funcTmp: PHCDLL_FUNC_REF; begin uLazGUIGlobals.PDLLBusy:=PDLLBusy; uLazGUIGlobals.intVerInterface:=verInterface; uLazGUIGlobals.intVerSaveGame:=verSaveGame; funcTmp := funcRefs; while (funcTmp <> nil) do begin if (funcTmp^.funcName = 'annex_id_to_disk_id') then HCannex_id_to_disk_id := THCannex_id_to_disk_id(funcTmp^.funcPtr) else if (funcTmp^.funcName = 'disk_id_to_annex_id') then HCdisk_id_to_annex_id := THCdisk_id_to_annex_id(funcTmp^.funcPtr) ; funcTmp := funcTmp^.next; end; end; Procedure AmendUnitData; var lPThisUnit: PHCUnit; lPThisGroup: PHCGroup; lPThisMnt: PHCMntRec; begin // if (gintBSNum = 2) then // begin lPThisGroup := PStartGroup; while (lPThisGroup <> nil) do // look thru all groups begin lPThisUnit:= lPThisGroup^.Units; while (lPThisUnit <> nil) do // look thru all group units begin lPThisMnt:= lPThisUnit^.Mnts; while (lPThisMnt <> nil) do // look at unit mnts begin if (lPThisMnt^.MntId = 59713) // SA-N9 launcher then lPThisMnt^.WepId:= 18477; // SA-N9 lPThisMnt:= lPThisMnt^.next; end; // looked at mnts lPThisUnit:= lPThisUnit^.next; end; // finnished looking at group units lPThisGroup := lPThisGroup^.toSouth; end; // finished looking at groups // end; end; procedure ProcessAnnexAmends(); // this is guts of library edit for individual - also processUnit var pMissile: PHCAnnexD1_disk; pMnt: PHCAnnexZ1_disk; pThisAir: PHCAnnexB1_disk; pThisLoadout: PHCAnnexY1_disk; pThisECM: PHCAnnexG2_disk; intLoadID: Integer; begin // do NACV // pThisAir:= HCAnnexHelper.HCGetAnnexB1(10272); // if pThisAir^.ClassName = 'Tu-16 Badger J' if gintBSNum = 2 then begin pMnt:= HCAnnexHelper.HCGetAnnexZ1(59713); // sa-n9 launcher pMnt^.WepId:= 18477; // sa-n9 // pThisLoadOut:= HCAnnexHelper.HCGetAnnexY1(55507); // patrol LO BadgerJ pThisLoadOut^.WepId[0]:= 34820; // ALQ99 EW original has no weps pThisLoadout^.WepQty[0]:= 3; // guessing AmendUnitData; end else // do GIUK needs EW // begin // pThisAir:= HCAnnexHelper.HCGetAnnexB1(10286); // if pThisAir^.ClassName = 'Tu-16 Badger J' if gintBSNum = 1 then begin pThisLoadOut:= HCAnnexHelper.HCGetAnnexY1(55579); // patrol LO BadgerJ pThisLoadOut^.WepId[0]:= 34819; // ALQ99 EW original has no weps pThisLoadout^.WepQty[0]:= 3; // guessing end else // do IOPG needs radar if gintBSNum = 4 then begin pThisAir:= HCAnnexHelper.HCGetAnnexB1(10306); // if pThisAir^.ClassName = 'Tu-16 Badger J' // then // begin pThisAir^.SensId[0]:= 43134; // Short Horn SS pThisAir^.SensId[1]:= 43132; // Mushroom SS end; end; procedure StartGroup(StartGroup: PHCGroup);export;cdecl; begin PStartGroup:=StartGroup; // if (intGameTime = 100000) now have bsNum in dbloaded // then AmendUnitData(); //250223 250206 one off for eg damage mounts end; procedure ScenLoad(strHarpPath: PAnsiChar; intScenNum: SmallInt; strScenFPath: PAnsiChar; intBSNum: ShortInt; strBSFName: PAnsiChar; intSide: byte; intGameTimeIn: Long; intGameTimeLeftIn: Long; AnnexDataIn: PHCAnnexes_disk; DatabaseVersionDBIn: PHCDATABASE_VERSION; ScenDataIn: PHCSCENARIO_DATA; ScenSaveDataIn: PHCSCENARIO_SAVE_DATA; GlobalsIn: PHCGlobals);export;cdecl; begin // gintBSNum:=intBSNum; moved to dbloaded AnnexData:= AnnexDataIn; HCAnnexHelper := THCAnnexHelper.Create(AnnexDataIn, HCannex_id_to_disk_id, uLazGUIGlobals.intVerInterface, uLazGUIGlobals.intVerSaveGame); end; procedure DBLoaded(AnnexDataIn: PHCAnnexes_disk; AnnexDataMemIn: PHCAnnexes_mem; intBSNum: shortint; DatabaseVersionDBIn: PHCDATABASE_VERSION) export; cdecl; begin if (AnnexDataMemIn = nil) then begin AnnexData := AnnexDataIn; gintBSNum:= intBSNum; HCAnnexHelper := THCAnnexHelper.Create(AnnexDataIn, HCannex_id_to_disk_id, uLazGUIGlobals.intVerInterface, uLazGUIGlobals.intVerSaveGame); if gintBSNum < 5 then ProcessAnnexAmends(); end else begin // AnnexData_mem := AnnexDataMemIn; // HCAnnexMemHelper := THCAnnexMemHelper.Create(AnnexDataMemIn, frmMain.HCannex_id_to_disk_id); end; end; exports DLLVer, DLLVerInt, DLLDesc, DLLFree, DLLInit, ScenLoad, StartGroup, DBLoaded ; end.