A few things about these files should be noted... 1. Additional Documentation has been added so people know what I am doing in some of the routines. 2. Read the information before attempting to use these. It explains quite a bit. 3. These files were created a few years ago, so that may be a tad sloppy with all the extra variables I have had to add to Admiral over the 12-15 version I have done. I have tried to take out all of the Admiral specific variables, but I may have missed a few. There are several sets of integers and longints that I use as generic markers. 4. The putload systems transfers the main host files to temporary files. This was orignially made so I wouldn't have to back up data on any crashes, this adds several seconds of processing time, but allows you to ensure the user that if a crash happens they usually won't have to reset their files as only the temporary files are modified. 5. FOMsg and FOMsg2 were created for message sending. There is only one small difference and that is the file name extension '.TMP', which is used during the auxhost phases, and '.EXT' which is used externally for configuration files. 6. I use big variable names so you should be able to make out what most of the variables are for. 7. This should cover most of the structures used in VGAP during hosting auxhost phases and extrenal setup. 8. There are a few redundant not used USES (usually Dos,Crt,Global, and PutLoad.) in the files. Basically, I had set it up so that all the new .pas files I had were set to be able use global and putload even if they didn't actually use them. For any specific questions email me. I wouldn't be offended at all if you were to mention if you use my routines in your programs, as I am providing them for free. Ken. admiral1@execpc.com All my addons can be found at... http://www.execpc.com {$O+,F+} unit Global; { I believe I have all the Admiral Specific Variables out. } { The types are self explanatory, and directly plagarised from the cplayer text for compatibility, except where noted. } interface type UFOTYPE = Record marker : Integer; { Does Ufo Exist And Color of Ufo } nm, info1, info2 : array[1..20] of char; X, Y, warp, heading, rangeP, rangeS, edge, parent : Integer; { Not Sure If This Needs 0 or Not } end; SUBSPACE = record { Message Pointer Structure } ID : Integer; MPos : LongInt; MLngth : Integer; end; MESSAGE = record { Basic Message } m : string[255]; end; MINEXY = record Mx, My, Owner : Integer; Mines : longint; Web : Integer; end; PLANXY = record Px, Py, Owner : Integer; end; SHIPXY = record Sx, { X Coordinate } Sy, { Y Coordinate } Own, { Owner Number } Mass : Integer; { Current Mass KTs } end; TRUEHULL = record Hull : array[1..20] of integer; end; VerChar = Record { I didn't remove these as I'm not sure if any thing uses these. They were used for quick first byte/integer verification of counters } V : Char; end; VerByte = Record V : Byte; end; { Size is 2 Bytes } VerRec = Record SByte : Integer; end; { Size is 2 Bytes } VerRec2 = Record PByte : Integer; end; { Size of shiptype is 107 bytes } SHIPTYPE = record ID, { ID number of ship } pNum : Integer; { Player ID number } fCode : array [1..3] of char; { Friend ID code } warp, { Warp factor } xWay, { DX to waypoint from X } yWay, { DY to waypoint from Y } xShip, { X cor. } yShip, { Y cor. } eng, { engine type } hull, { hull type } weapon, { weapon type } wbanks, { number of weapon banks } bays, { number of fighter bays } { if bays>0 then tube and tbanks are ignored } { a ship may have fighter or torpedoes } { NOT both } tube, { torpedoe launcher type } torp, { number of torpedoes/fighters } tbanks, { number of torpedoe banks } mission, { ship mission type } enemy, { primary enemy ID number } tow, { ID # of ship in tow } damage, { amount of damage done to ship } crew, { number of crew } col : Integer; { number of clans } nm : array [1..20] of char; { name of ship } eleN, { Neutronium } eleT, { Tritanium } eleD, { Duranium } eleM, { Molybdenum } eleS, { supplies (Carbon Matrix) } unN, { unload Neutronium } unT, { unload Tritanium } unD, { unload Duranium } unM, { unload Molybdenum } unCol, { unload Colonists } unS, { unload Supplies } unplanet, { unload on to planet target number } transN, { transport Neutronium } transT, { transport Tritanium } transD, { transport Duranium } transM, { transport Molybdenum } transC, { transport Colonists } transS, { transport Supplies } transtarget, { transport target ship ID number } iTarget, { intercept target ship ID number } cash : Integer; { the amount of cash on board the ship } end; { size=60 } HULLSPEC = record nm : array [1..30] of char; { hull class name } bin, { the bin resource file slot image } doa, { the image of a heavily damaged ship } eleT, { amount of Tritanium needed to build } eleD, { amount of Duranium needed to build } eleM, { amount of Molybdenum needed to build } eleN, { maximun Neutronium that can be carried } crew, { maximum crew } engines, { number of engines required to build } mass, { mass of hull } tech, { tech level of ship } cargo, { maximum cargo (does not include neutronium) } bays, { maximum number of fighter bays } torp, { maximum number of torp tubes } weapon, { maximum number of beam weapons } cost : INTEGER; { cost to build } end; ENGSPEC = record nm : array [1..20] of char; { name of engine } cost, { cost to build one } eleT, { amount needed to build one } eleD, { amount needed to build one } eleM, { amount needed to build one } tech : Integer; { tech level needed to build one } ec : Array[1..9] of longint; { energy cost to go all warp speeds per 10,000 mt } { energy cost is in mts } end; TORPSPEC = record nm : array [1..20] of char; cost, { cost of one torpedoe } tubecost, { cost of the launch tube } eleT, { needed to build tube } eleD, { needed to build tube } eleM, { needed to build tube } mass, { mass of the weapon bank } tech, { tech level } kill, { the life killing power of the weapon } smash : INTEGER; { the ablity to smash a ship to bits } end; BEAMSPEC = record nm : array [1..20] of char; cost, { cost to build } eleT, eleD, eleM, mass, { mass of the weapon bank } tech, { tech level } kill, { the life killing power of the weapon } smash : Integer; { the ablity to smash a ship to bits } end; { Size of plantype is 85 bytes } PLANTYPE = record pNum, { the player race of this planet } ID : INTEGER; { the ID number of this planet } fCode : array [1..3] of char; { the friendly code } mines, { number of mines on planet } factories, { number of factories on planet } SDI : INTEGER; { SDI factor (planetary defenses) } eleN, { KT s of Neutronium ready for use } eleT, { KT s of Tritanium ready for use } eleD, { KT s of Duranium ready for use } eleM, { KT s of Molybdenum ready for use } eleC, { number of colony clans } eleS, { KT s of supplies ready for use } money, { the planets money reserves } resN, { eleN contained within planet } resT, { eleT contained within planet } resD, { eleD contained within planet } resM : longint; { eleM contained within planet } easyN, { (0-100) odds of mining eleN } easyT, { (0-100) odds of mining eleT } easyD, { (0-100) odds of mining eleD } easyM, { (0-100) odds of mining eleM } taxC, { tax rate of colonists } taxN, { tax rate of natives } happynessC, { happyness of colonists } happynessN, { happyness of natives } SPI : Integer; { socio political index } native : longint; { native population } species, { type of native population } climate, { weather conditions } bStarbase : INTEGER; { build a starbase! } end; { size=156 } BASETYPE = record ID, { same as planet ID # } pNum, { race ID number of base } defense, { defense power } damage, techE, { engine tech level } techH, { hull tech level } techW, { weapon tech level } techT : Integer; { torpedoe tech level } storeE : Array[1..9] of Integer; { count of engines in storeage } storeH : Array[1..20] of Integer;{ count of hulls in storeage } storeW : Array[1..10] of Integer;{ count of weapons in storeage } storeT : Array[1..10] of Integer;{ count of tubes in storeage } storeTorps : Array[1..10] of Integer; { count of torps in storeage } storeF, { count of fighters in storeage } workonshipID, { id of ship to work on } workonshipAction, { action flag 1=fix 2=scrap } mission, { mission number } makeshipH, { make ship with this hull } makeshipE, { make ship with this engine } makeshipW, { make ship with this weapon } makeshipWc, { (this many of em weapons) } makeshipT, { make ship with this type launcher } makeshipTc, { (this many of em launchers) } makeshipFc : Integer; { make ship with this many fighters ***** NEVER USE makeshipFc ***** } end; { Version 3.2.Current } CONFIGTYPE = record recycle, { % of ore recovered from colonizing ships } meteor, { % odds of one large meteor impact } mine, { flag mine fields yes (1) or no (0) } Alchemy, { flag alchemy yes (1) or no (0) } delold, { flag delete old messages yes (1) } nopassword : Integer; { flag disable passwords yes (1) } gkill : Array[0..11] of Integer; { ground combat kill ratios } opkill : Array[0..11] of Integer; { ground combat defense factor } freefighter : Array[0..11] of Integer; { number of free fighters } minerates : Array[0..11] of Integer; { mineral mining rates } taxrate : Array[0..11] of Integer; { tax 50% to 500% } rebelbfs, { build fighters in space } coloniesbfs, { build fighters in space } robotbfs, { build fighters in space } cloakshipopps , { 0% - 50% cloak ship falure } robcloaked, { rob cloaked ships (yes/no) } shipscan, { ship scan range limit } darkrange, { range of dark sence } hiss, { hiss mission on and off } rebelga, { rebel ground attack on and off } fedsr, { super refit on and off } web, { web mines on and off } cloakburn, { cloaked ship fuel burn 1 to 50 kt } sensorrange, { range of the sensor mission } nativenew, { add new natives } planetattack, { planets attack ships (yes/no) } cyborga, { cyborg assimulation rate (1-100) } webdecay, { web mine decay rate } minedecay, { mine field decay rate } maxmine, { max mine field radius in lightyears } isotope, { new mineral form rate } decay, { decay of structures on underpop planet } overpop, { eat supplies? (yes/no) } nofuelmove, { ships without fuel can move (yes/no) } oddsmine, { odds of hitting a mine } oddsweb, { odds of hitting a web mine } mineseerange, { range that you can see mines } antimine, { mines distroy enemy mines } shieldbonus, { engine shield bonus shield } sbrate, { engine shield bonus % rate } cfsweeprate, { colonies fighter sweep rate } cfsweepweb, { colonies fighter sweep web mines (yes/no) } minesweeprate, { rate that weapons sweep mines } websweeprate, { rate that weapons sweep web mines } lizardmaxhiss, { the max that a hiss mission can effect planet } robfailrate, { the odds that the rob mission will fail } rebelnoatt, { planets can attack rebels (yes/no) } fascistnoatt, { planets can attack fascists (yes/no) } minesweeprange, { the range that a mine field can be sweeped } websweeprange, { the range that a web field can be sweeped } sciencemissions, { ship science missions } cloakedmineodds, { the odds that a cloaked ship will hit a mine } nocloakdamage, { the amount of damage that prevents cloaking } fedcrewbonus, { fed ships get a combat bonus (yes/no) } oddssm : Integer; { odds of small meteor impacts } smminN, { minimum Neutronium in meteor } smminD, smminT, smminM, smmaxN, { maximum Neutronium in meteor } smmaxD, smmaxT, smmaxM : longint; numlg : INTEGER; { number of large meteors to impact } lgminN, { minimum Neutronium in meteor } lgminD, lgminT, lgminM, lgmaxN, { maximum Neutronium in meteor } lgmaxD, lgmaxT, lgmaxM : longint; meteormess, { send meteor messages? } onetow, { a ship with one engine can tow another } hyper, { hyper space jumps } cdeathrate, { colonist death rate } gwell, { grivity wells } crysclim, { crystals immune to bad climates } nweb, { normal mines destroy web mines } clpop : INTEGER; { climate limits population } maxincome : longint; { max income that the planet can make per turn } ionstorm, { 0%-100% The activity rating of Ion storms } chunnel, { warp chunnel } spiboost, { super spi bonus } ionminehide, { ion storms hide mines } glory, { glory device (D19, Saber) } loki, { loki anti-cloaking } lady, { laby royal gambing } cloakattack, { cloaked ships can attack } clone, { ships can be cloned } boarding, { crystals and privateers can capture with tow } imperialAssult : Integer; { super star destroyer can take planets with 10 clans } Cobol, { Cobol Fuel Scoop Per LY 0-4 } Aries, { Aries Advanced Alchemy } Bio, { Bio Scanners } HullSlow, { Hull Slow # } LokiDeCloakBird : Integer; { As with all Yes no in this file 0=No 1=Yes } end; Var { It gets a little sloppy here where I threw in a few extra variables when I needed them for Admiral or another Addon. } Checker, MSend, ParmCnt, MsgCounter : Integer; { These are being used for my log files, for how many parameters/ParmCnt and MSend is used when I blank out certain messages to shorten run time. } NumRead,NumWritten : Word; { Blockwriting Variables } QS : Array[1..500] of Char; { Data Transfer Array (See PutLoad) } BT,BT2 : byte; ch : char; { Standard Char Usage } msg2 : Array[1..255] of char; msg : Message; mout : array[1..255] of Char; hostmessage : Array[1..18] of string[40]; hostmsgs : Integer; LogMode, s,st,st1,st2,st3,st4,st5 : String; { generic strings used to paste together message information. } i,j,k,l,m,ii,jj,kk,ll,mm : integer; { All are generic counters except for l which is used as the load record number for *.DAT files. See the PutLoad for usage. } { My Files } TFC : file; { Transfer File } SUBSPACEMSG : file; { Used for Mesaage Pointer and Sending Messages with FOMsg and FOMsg2 } VERC : file of VerRec; VERC2: file of VerRec2; VERB : file of VerByte; VERCH : file of VerChar; LOG : file; { My Log File structure, as I was having problems with Win95 and a text file. } SF : file; { Transfer Files } SF2 : file; { VGAP Files } VSHIP : file of SHIPTYPE; VHULL : file of HULLSPEC; VENG : file of ENGSPEC; VTORP : file of TORPSPEC; VBEAM : file of BEAMSPEC; VPLAN : file of PLANTYPE; VBASE : file of BASETYPE; VCONFIG : file of CONFIGTYPE; VTHULL : file of TRUEHULL; VSHIPXY : file of SHIPXY; VPLANXY : file of PLANXY; VMINEXY : file of MINEXY; UF : file of UFOTYPE; { My File Var } SSMsg : SubSpace; { Messages } vr : VerRec; vr2: VerRec2; VB : VerByte; vc : VerChar; { VGAP Files Var } sh : SHIPTYPE; s2 : SHIPTYPE; { Necessary if you are going to transfer between ships } hl : HULLSPEC; en : ENGSPEC; tr : TORPSPEC; bm : BEAMSPEC; pl : PLANTYPE; ba : BASETYPE; cf : CONFIGTYPE; th : array[1..11] of TRUEHULL; { This is to get the hulls being used in your game by races 1..11 } SXY : array[1..500] of SHIPXY; { Speed up processing having them all in memory } PXY : array[1..500] of PLANXY; MXY : array[1..500] of MINEXY; ufo : UFOTYPE; InGame : array[1..11] of Integer; { Race handling variables } ActivePlayers : array[1..11] of Integer; TRNFound : array[1..11] of Integer; TFName : string; { Turn file name string } nk1,nk2,nk3 : Array[1..11] of Integer; Turn : Integer; msgpt : Integer; { message pointer } MainFlag : Integer; { MainFlag is used on the main program normally I check for missing files and if there are any missing files then I set mainflag to state which files are missing and stop the program from attempting to run. } x1,x2,x3,x4,x5,x6,x7,x8, { These are counters and I use them for processing things like Messages and high values. x4 is needed in FOMsg and FOMsg2 } n,n0,n1,n2,n3 : Longint; r,r1,r2, { Generic Real variables, these are used in my standard calculations for distances. } Dx1,Dy1,Dx,Dy : Real; path, { These are used by the setpath routine to set the necessary information to pick the correct path. Path is the current directory and is not neccessay to use when loading data as unless you change the path for some reason. Path2 is the host file directory, and you will need to use this on all of your specific data files and host files... Assign(path2+'MyData.Dat); for example. drive and direct simply comply with the tp standar to get file path information. } path2, drive, direct : string; RGU : integer; { Registered User Flag, This is sometimes used after verification of reg user status to allow access to certain commands that are not reg user functions. I'm not posting any of my reg keys, so don't ask. } XMin, { This is very helpful and used with the setminmax routine to set the boundaries for objects such as ufos. You will be able to tell if they are out of the cluster and should be moved back in or erased, depending on your program. } YMin, XMax, YMax, Dist1, { Min and Max Distance or used for multiple distance settings } Dist2, race, { Race } PlSlot, { Planet Slot } shSlot, { Ship Slot } ShSlot2, bsSlot, { Base Slot } Distance : Integer; { Distance } Procedure SetPath; Procedure SetFCode; Procedure PlanetMinMax; Procedure GetStartSet; implementation procedure GetStartSet; { This has bee provided so you can see how I Get my path and turn number data. This is quite old, but it still works good. I Usually use this as the begining of the main program. I have noted the common structure I use too.} begin Randomize; for i:=1 to 11 do begin ActivePlayers[i]:=0; end; i:=0; j:=0; k:=0; l:=0; m:=0; SPMess:=0; MainFlag:=0; msg.m:=''; path:=''; path2:=''; Drive:=''; Direct:=''; Checker:=0; GetDir(0,Drive); Direct:=ParamStr(1); SetPath; Assign(VERC,path2+'nextturn.hst'); Reset(VERC); Seek(VERC,9); Read(VERC,vr); Turn:=vr.SByte; RandSeed:=(vr.SByte+2); Randomize; Str(vr.SByte,st); Close(VERC); OpenLOG; msg.m:=' Turn : '+st; ShowMessage; { check for missing files } LoadBasicData; { See PutLoad } { Do all program running data and routines } ReturnHSTData; { See PutLoad } end; procedure SetPath; begin i:=0;j:=0;k:=0;l:=0;x6:=0; if (length(drive)=3) then path:=drive else path:=drive+'\'; if Pos(':',direct) <> 0 then i:=1; if (i<>0) then path2:=direct+'\'; if direct='' then path2:=path; if (direct<>'') and (i=0) then path2:=drive+'\'+direct+'\'; end; procedure PlanetMinMax; begin XMin:=30000; YMin:=30000; XMax:=0; YMax:=0; for mm:=1 to 500 do begin if PXY[mm].PxXMax then XMax:=PXY[mm].Px; if PXY[mm].PyYMax then YMax:=PXY[mm].Py; end; end; procedure SetFCode; begin sh.fcode[1]:=Chr(random(32)+32); sh.fcode[2]:=Chr(random(61)+65); sh.fcode[3]:=Chr(random(94)+32); end; End. {$I-,F+} unit PutLoad; interface Uses Crt,Dos,Global; procedure OpenLOG; procedure CloseLOG; procedure ShowMessage; procedure LoadBasicData; procedure LoadHULL; procedure LoadENG; procedure LoadBEAM; procedure LoadTORP; procedure LoadBASE; procedure LoadPLAN; procedure LoadSHIP; procedure LoadSHIP2; procedure PutBASE; procedure PutPLAN; procedure PutSHIP; procedure PutSHIP2; procedure ReturnHSTData; procedure OpenFiles; Procedure CloseFiles; Procedure LoadSHIPXY; Procedure PutSHIPXY; Procedure LoadPLANXY; implementation procedure OpenLOG; begin Assign(LOG,path2+lg); Erase(LOG); if IOResult<>0 then n:=1; Assign(LOG,path2+lg); Reset(LOG,1); if IOResult=0 then begin Rename(LOG,path2+lg); end; Close(LOG); if IOResult<>0 then n:=1; Assign(LOG,path2+lg); ReWrite(LOG,1); end; procedure CloseLOG; begin Close(LOG); end; procedure ShowMessage; { This is a bit ineffecient, but it worked when I was having trouble writing log files in win95. Im still not sure why the text files didn't work, but I never changed it because I don't fix what isn't broken. :) } begin Writeln(msg.m); msg.m:=msg.m+#13+#10; for x4:=1 to 255 do begin Msg2[x4]:=#0; end; x5:=Length(msg.m); for x4:=1 to x5 do begin Msg2[x4]:=msg.m[x4]; end; for x4:=1 to x5 do begin BlockWrite(LOG,msg2[x4],1,NumWritten); end; end; procedure OpenFiles; begin Assign(VSHIP,path2+'ALPHA.TMP'); Reset(VSHIP); Assign(VBASE,path2+'BETA.TMP'); Reset(VBASE); Assign(VPLAN,path2+'GAMMA.TMP'); Reset(VPLAN); Assign(VHULL,'HULLSPEC.DAT'); Reset(VHULL); Assign(VENG,path+'ENGSPEC.DAT'); Reset(VENG); Assign(VTORP,path+'TORPSPEC.DAT'); Reset(VTORP); Assign(VBEAM,path+'BEAMSPEC.DAT'); Reset(VBEAM); end; procedure CloseFiles; begin Close(VSHIP); Close(VBASE); Close(VPLAN); Close(VHULL); Close(VENG); Close(VTORP); Close(VBEAM); end; procedure PutSHIP; begin Seek(VSHIP,ShSlot-1); Write(VSHIP,sh); end; procedure PutSHIP2; begin Seek(VSHIP,ShSlot2-1); Write(VSHIP,s2); end; procedure PutPLAN; begin Seek(VPLAN,PlSlot-1); Write(VPLAN,pl); end; procedure PutBASE; begin Seek(VBASE,BsSlot-1); Write(VBASE,ba); end; procedure ReturnHSTData; { This returns the data from the temp files and closes the files. } begin CloseFiles; { Temp Ship File } msg.m:='Storing Temporary Data'; ShowMessage; Assign(SF,path2+'SHIP.HST'); Assign(SF2,path2+'ALPHA.TMP'); Reset(SF,1); Reset(SF2,1); Seek(SF,2); for n:=1 to 107 do begin BlockRead(SF2,QS,SizeOf(QS),NumRead); BlockWrite(SF,QS,NumRead,NumWritten); end; Close(SF); Close(SF2); { Temp Base File } msg.m:='Storing Temporary Data'; ShowMessage; Assign(SF,path2+'BDATA.HST'); Assign(SF2,path2+'BETA.TMP'); Reset(SF,1); Reset(SF2,1); Seek(SF,2); for n:=1 to 156 do begin BlockRead(SF2,QS,SizeOf(QS),NumRead); BlockWrite(SF,QS,NumRead,NumWritten); end; Close(SF); Close(SF2); { Temp Planet File } msg.m:='Storing Temporary Data'; ShowMessage; Assign(SF,path2+'PDATA.HST'); Assign(SF2,path2+'GAMMA.TMP'); Reset(SF,1); Reset(SF2,1); Seek(SF,2); for n:=1 to 85 do begin BlockRead(SF2,QS,SizeOf(QS),NumRead); BlockWrite(SF,QS,NumRead,NumWritten); end; Close(SF); Close(SF2); Assign(SF,path2+'ALPHA.TMP'); ReWrite(SF,1); Close(SF); Assign(SF,path2+'BETA.TMP'); ReWrite(SF,1); Close(SF); Assign(SF,path2+'GAMMA.TMP'); ReWrite(SF,1); Close(SF); end; procedure LoadTrueHull; begin msg.m:='Loading Data'; ShowMessage; if RGU=0 then begin Assign(VTHULL,path+'TRUEHULL.DAT'); Reset(VTHULL); for i:=1 to 11 do begin Read(VTHULL,th[i]); end; Close(VTHULL); end; end; procedure LoadHostConfig; begin msg.m:='Loading Data'; ShowMessage; Assign(VCONFIG,path2+'HCONFIG.HST'); Reset(VCONFIG); Read(VCONFIG,cf); Close(VCONFIG); end; procedure LoadSHIPXY; begin msg.m:='Loading Data'; {ShowMessage;} Assign(VSHIPXY,path2+'SHIPXY.HST'); Reset(VSHIPXY); for i:=1 to 500 do begin Read(VSHIPXY,SXY[i]); end; Close(VSHIPXY); msg.m:='Organizing Data'; {ShowMessage;} for i:=1 to 500 do begin if SXY[i].Own=0 then begin SXY[i].Sx:=0; SXY[i].Sy:=0; SXY[i].Mass:=0; end; end; end; procedure PutSHIPXY; begin msg.m:='Loading Data'; {ShowMessage;} Assign(VSHIPXY,path2+'SHIPXY.HST'); Reset(VSHIPXY); Seek(VSHIPXY,0); for i:=1 to 500 do begin Write(VSHIPXY,SXY[i]); end; Close(VSHIPXY); end; procedure LoadPLANXY; begin msg.m:='Loading Data'; {ShowMessage;} Assign(VPLANXY,path2+'XYPLAN.HST'); Reset(VPLANXY); for i:=1 to 500 do begin Read(VPLANXY,PXY[i]); end; Close(VPLANXY); end; procedure LoadMINEXY; begin msg.m:='Loading Data'; ShowMessage; Assign(VMINEXY,path2+'MINES.HST'); Reset(VMINEXY); for i:=1 to 500 do begin Read(VMINEXY,MXY[i]); end; Close(VMINEXY); msg.m:='Organizing Data'; ShowMessage; for i:=1 to 500 do begin if MXY[i].Owner=0 then begin MXY[i].Mx:=0; MXY[i].My:=0; MXY[i].Mines:=0; MXY[i].Web:=0; end; end; end; procedure LoadSHIP; { The loading routines are quite easy due to the transfering of data. } begin Seek(VSHIP,ShSlot-1); Read(VSHIP,sh); end; procedure LoadSHIP2; begin Seek(VSHIP,ShSlot2-1); Read(VSHIP,s2); end; procedure LoadPLAN; begin Seek(VPLAN,PlSlot-1); Read(VPLAN,pl); end; procedure LoadBASE; begin Seek(VBASE,BsSlot-1); Read(VBASE,ba); end; procedure LoadHULL; { The letter 'l' is used for all SPEC.DAT file loading. If you want slot #9 engines l:=9; LoadENG; for hull #103 l:=103; LoadHULL; The main reason 'l' was used for all of these is that this information is generally disposable. You use it to check information, and usually don't modify the DAT files as that can cause crashes. } begin Seek(VHULL,l-1); Read(VHULL,hl); end; procedure LoadENG; begin Seek(VENG,l-1); Read(VENG,en); end; procedure LoadTORP; begin Seek(VTORP,l-1); Read(VTORP,tr); end; procedure LoadBEAM; begin Seek(VBEAM,l-1); Read(VBEAM,bm); end; procedure LoadBasicData; { Load and transfer data to proper files and memory being used. } begin msg.m:='Loading Data'; ShowMessage; Assign(VERC,path2+'GEN.HST'); Reset(VERC); for i:=1 to 11 do begin Seek(VERC,22+i); Read(VERC,vr); InGame[i]:=vr.SByte; end; Close(VERC); LoadTRUEHULL; { Use the brackets to mark off what you do not need to use in each program. } LoadSHIPXY; LoadPLANXY; LoadMINEXY; LoadHostConfig; { Temp Ship File } { This section transfer the data to temporary files it help out in the early stages in two ways. One you don't have to back up information on crashes so it saves quite a bit of time. Two the files that are set up allow direct use of the READ/WRITE commands rather than the blockread/bloackwrite. } msg.m:='Setting Temporary Data'; ShowMessage; Assign(SF,path2+'SHIP.HST'); Assign(SF2,path2+'ALPHA.TMP'); Reset(SF,1); ReWrite(SF2,1); Seek(SF,2); for n:=1 to 107 do begin BlockRead(SF,QS,SizeOf(QS),NumRead); BlockWrite(SF2,QS,NumRead,NumWritten); end; Close(SF); Close(SF2); { Temp Base File } msg.m:='Setting Temporary Data'; ShowMessage; Assign(SF,path2+'BDATA.HST'); Assign(SF2,path2+'BETA.TMP'); Reset(SF,1); ReWrite(SF2,1); Seek(SF,2); for n:=1 to 156 do begin BlockRead(SF,QS,SizeOf(QS),NumRead); BlockWrite(SF2,QS,NumRead,NumWritten); end; Close(SF); Close(SF2); { Temp Planet File } msg.m:='Setting Temporary Data'; ShowMessage; Assign(SF,path2+'PDATA.HST'); Assign(SF2,path2+'GAMMA.TMP'); Reset(SF,1); ReWrite(SF2,1); Seek(SF,2); for n:=1 to 85 do begin BlockRead(SF,QS,SizeOf(QS),NumRead); BlockWrite(SF2,QS,NumRead,NumWritten); end; Close(SF); Close(SF2); OpenFiles; { This opens all the mainfiles see the above routine } end; End. Unit FOMsg; { Internal Messages for Auxhost Phases Use FOMsg2 for extrenal and configuration messages } { For all the variable structures read Global.pas also FOMsg2.pas is identical, except for the file where the messages are sent FOMsg = .TMP and FOMsg2 = .EXT see the read me for further explanation } { The opening and closing was used to keep the # of open files down. } interface Uses Dos,Crt,Global,PutLoad; Procedure SendMessage; implementation var aa,bb,cc : integer; procedure SendMessage; begin if id<>0 then { If id=0 then you are sending the message to race 0 and the program would normally crash or cause a host error. } begin for aa:=1 to 255 do { I never needed big messages so to simplify I used the 255 character string. } begin Msg1[aa]:=#0; { Clean the outgoing message buffer } end; bb:=Length(mes); for aa:=1 to bb do begin Msg1[aa]:=Chr(Ord(mes[aa])+13); { Put the message into the outgoing variable shifting it for the encryption } end; Assign(SUBSPACEMSG,path2+'MESSPNT.TMP'); { Check the Pointer File } Reset(SUBSPACEMSG,1); BlockRead(SUBSPACEMSG,hostmsgs,SizeOf(hostmsgs),NumRead); if hostmsgs>0 then { If messages already exist find the pointer information and load it } begin n1:=(((hostmsgs-1)*8)+2); Seek(SUBSPACEMSG,n1); BlockRead(SUBSPACEMSG,SSMsg,SizeOf(SSMsg),NumRead); end; if hostmsgs=0 then { If no message exist set the pointers } begin SSMsg.MPos:=1; SSMsg.MLngth:=1; end; Close(SUBSPACEMSG); aa:=hostmsgs; { This is how many messages are currently in the file } x4:=SSMsg.MPos+(SSMsg.MLngth)+1; { Add the message position to the length and add 1 to get the proper byte to start writing the message at. } aa:=aa+1; SSMsg.ID:=id; { Set the race that the message goes to } SSMsg.MPos:=x4; { Set the starting position of the message } SSMsg.MLngth:=bb; { Set the length of the message } Assign(SUBSPACEMSG,path2+'MESSPNT.TMP'); { Open file and write the pointer information } Reset(SUBSPACEMSG,1); Seek(SUBSPACEMSG,0); BlockWrite(SUBSPACEMSG,aa,2,NumRead); Seek(SUBSPACEMSG,(((aa-1)*8)+2)); BlockWrite(SUBSPACEMSG,SSMsg,SizeOf(SSMsg),NumRead); Close(SUBSPACEMSG); Assign(SUBSPACEMSG,path2+'MESS.TMP'); { Open the message file } if hostmsgs=0 then ReWrite(SUBSPACEMSG,1) { If file doesn't exist create it } else Reset(SUBSPACEMSG,1); Seek(SUBSPACEMSG,(SSMSg.MPos-1)); { Go to the proper byte position } for cc:=1 to bb do begin BlockWrite(SUBSPACEMSG,Msg1[cc],1,NumRead); { Write in the message } end; Close(SUBSPACEMSG); { Close the file } end; end; End. Unit FOMsg2; interface Uses Dos,Crt,Global,PutLoad; Procedure SendMessage; implementation var aa,bb,cc : integer; procedure SendMessage; begin if id<>0 then begin for aa:=1 to 255 do begin Msg1[aa]:=#0; end; bb:=Length(mes); for aa:=1 to bb do begin Msg1[aa]:=Chr(Ord(mes[aa])+13); end; Assign(SUBSPACEMSG,path2+'MESSPNT.EXT'); Reset(SUBSPACEMSG,1); BlockRead(SUBSPACEMSG,hostmsgs,SizeOf(hostmsgs),NumRead); if hostmsgs>0 then begin n1:=(((hostmsgs-1)*8)+2); Seek(SUBSPACEMSG,n1); BlockRead(SUBSPACEMSG,SSMsg,SizeOf(SSMsg),NumRead); end; if hostmsgs=0 then begin SSMsg.MPos:=1; SSMsg.MLngth:=1; end; Close(SUBSPACEMSG); aa:=hostmsgs; x4:=SSMsg.MPos+(SSMsg.MLngth)+1; aa:=aa+1; SSMsg.ID:=id; SSMsg.MPos:=x4; SSMsg.MLngth:=bb; Assign(SUBSPACEMSG,path2+'MESSPNT.EXT'); Reset(SUBSPACEMSG,1); Seek(SUBSPACEMSG,0); BlockWrite(SUBSPACEMSG,aa,2,NumRead); Seek(SUBSPACEMSG,(((aa-1)*8)+2)); BlockWrite(SUBSPACEMSG,SSMsg,SizeOf(SSMsg),NumRead); Close(SUBSPACEMSG); Assign(SUBSPACEMSG,path2+'MESS.EXT'); if hostmsgs=0 then ReWrite(SUBSPACEMSG,1) else Reset(SUBSPACEMSG,1); Seek(SUBSPACEMSG,(SSMSg.MPos-1)); for cc:=1 to bb do begin BlockWrite(SUBSPACEMSG,Msg1[cc],1,NumRead); end; Close(SUBSPACEMSG); end; end; Begin End.