My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
LoadingPMSFile_in_Delphi  
Updated Jan 21, 2008 by Anatoly....@gmail.com

Get it from mapmaker source

Details

// ------------------------------------------------------------------- //////// MAP LOADING /////////////////////////////////// // ------------------------------------------------------------------- procedure TForm1.LoadFromFile2(filename : string); var

F : file; i, j, k : integer; x, y : integer; kolor : TColor; Header : TMapFile_Header; Options : TMapFile_Options; Polygon_Start : TMapFile_Polygon_Start; Polygon : TMapFile_Polygon; Sector_Start : TMapFile_Sector_Start; Sector_New : TMapFile_Sector_New; Sector_PolyNum : TMapFile_Sector_PolyNum; Prop_Start : TMapFile_Prop_Start; Prop_New : TMapFile_Prop; Scenery_Start : TMapFile_Scenery_Start; Scenery_New : TMapFile_Scenery; Collider_Start : TMapFile_Collider_Start; Collider_New : TMapFile_Collider; SpawnPoint_Start : TMapFile_SpawnPoint_Start; SpawnPoint_New : TMapFile_SpawnPoint; WayPoint_Start : TMapFile_WayPoint_Start; WayPoint_New : TMapFile_WayPoint; b : integer;
begin
Compiled:= true;

AssignFile(F, filename); Reset(F, 1);
{load header} BlockRead(F, Header, sizeof(Header));
{load options} BlockRead(F, Options, sizeof(Options));
MapName.Text:= Options.MapName;
Map.BackgroundColor:= Options.BackgroundColor; Map.BackgroundColor2:= Options.BackgroundColor2;
kolor:= RGB(getBValue(Map.Backgroundcolor),getGValue(Map.Backgroundcolor),getRValue(Map.Backgroundcolor)); ColorBox4.Selected:= kolor; kolor:= RGB(getBValue(Map.Backgroundcolor2),getGValue(Map.Backgroundcolor2),getRValue(Map.Backgroundcolor2)); ColorBox5.Selected:= kolor;
Map.LoadTexture(RootDirectory+'..\Textures\'+Options.TextureName); TexName:= Options.TextureName;
JetBox.ItemIndex:= 7; case Options.StartJet of
0 : JetBox.ItemIndex:= 0;
  1. : JetBox.ItemIndex:= 1;
45 : JetBox.ItemIndex:= 2; 95 : JetBox.ItemIndex:= 3;
  1. 0 : JetBox.ItemIndex:= 4;
320 : JetBox.ItemIndex:= 5; 800 : JetBox.ItemIndex:= 6;
end;
JetBar.Position:= Options.StartJet;
GrenadeBox.Text:= inttostr(Options.GrenadePacks); MedicBox.Text:= inttostr(Options.Medikits); WeatherBox.ItemIndex:= Options.Weather; StepBox.ItemIndex:= Options.Steps;
{load polygon start} BlockRead(F, Polygon_Start, sizeof(Polygon_Start));
Map.PolyCount:= Polygon_Start.PolyCount;
{load polygons} for i:= 1 to Map.PolyCount do begin
BlockRead(F, Polygon, sizeof(Polygon));
Map.Polysi:= Polygon.Poly; for j:= 1 to 3 do
Map.Perpij:= Polygon.Perpj;
Map.PolyTypei:= Polygon.PolyType;
end;
{load sectors start} BlockRead(F, Sector_Start, sizeof(Sector_Start));
Map.SectorsDivision:= Sector_Start.SectorsDivision; SECTOR_NUM:= Sector_Start.SectorNum;
b:= 0;
{load sectors} for x:= -SECTOR_NUM to SECTOR_NUM do
for y:= -SECTOR_NUM to SECTOR_NUM do begin
{load new sector} BlockRead(F, Sector_New, sizeof(Sector_New));
Map.Sectors[x, y].PolyCount:= Sector_New.PolyCount;
{load sectors polygon nums}
for j:= 1 to Map.Sectors[x, y].PolyCount do begin
BlockRead(F, Sector_PolyNum, sizeof(Sector_PolyNum));
Map.Sectors[x, y].Polysj:= Sector_PolyNum.Polys;
end;
inc(b);
end;
with Map do begin
BackPoly1.Vertices1:= GetCustomVertex(NMIN_SECTOR*SectorsDivision,NMIN_SECTOR*SectorsDivision,0, 1, 0.0, 0.0, BackgroundColor, 0, 0); BackPoly1.Vertices2:= GetCustomVertex(NMAX_SECTOR*SectorsDivision,NMIN_SECTOR*SectorsDivision,0, 1, 0.0, 0.0, BackgroundColor, 0, 0); BackPoly1.Vertices3:= GetCustomVertex(NMAX_SECTOR*SectorsDivision,NMAX_SECTOR*SectorsDivision,0, 1, 0.0, 0.0, BackgroundColor2, 0, 0); BackPoly2.Vertices1:= GetCustomVertex(NMAX_SECTOR*SectorsDivision,NMAX_SECTOR*SectorsDivision,0, 1, 0.0, 0.0, BackgroundColor2, 0, 0); BackPoly2.Vertices2:= GetCustomVertex(NMIN_SECTOR*SectorsDivision,NMAX_SECTOR*SectorsDivision,0, 1, 0.0, 0.0, BackgroundColor2, 0, 0); BackPoly2.Vertices3:= GetCustomVertex(NMIN_SECTOR*SectorsDivision,NMIN_SECTOR*SectorsDivision,0, 1, 0.0, 0.0, BackgroundColor, 0, 0);
end;
ColorBox4Change(nil); ColorBox5Change(nil);
{load prop start} BlockRead(F, Prop_Start, sizeof(Prop_Start));
j:= Prop_Start.Num;
{load prop} for i:= 1 to j do begin
BlockRead(F, Prop_New, sizeof(Prop_New));
Propi:= Prop_New.Prop;
{ Propi.Active:= Prop_New.Prop.Active;
Propi.Style:= Prop_New.Prop.Style; Propi.Width:= Prop_New.Prop.Width; Propi.Height:= Prop_New.Prop.Height; Propi.X:= Prop_New.Prop.X; Propi.Y:= Prop_New.Prop.Y; Propi.Rotation:= Prop_New.Prop.Rotation; Propi.ScaleX:= Prop_New.Prop.ScaleX; Propi.ScaleY:= Prop_New.Prop.ScaleY; Propi.Alpha:= Prop_New.Prop.Alpha; Propi.Color:= Prop_New.Prop.Color; Propi.Level:= Prop_New.Prop.Level;}
end;
{load scenery start} BlockRead(F, Scenery_Start, sizeof(Scenery_Start));
{load scenery new}
PropBox.Items.Clear; PropBox.Items.Add('');
SceneryElements:= 0;
for i:= 1 to Scenery_Start.Num do begin
BlockRead(F, Scenery_New, sizeof(Scenery_New));
AddCustomScenery(Scenery_New.Name);
end;
{load collider start} BlockRead(F, Collider_Start, sizeof(Collider_Start));
j:= Collider_Start.Num;
{load collider} for i:= 1 to j do begin
BlockRead(F, Collider_New, sizeof(Collider_New));
Collideri:= Collider_New.Collider;
end;
{load spawnpoint start} BlockRead(F, SpawnPoint_Start, sizeof(SpawnPoint_Start));
j:= SpawnPoint_Start.Num;
{load spawnpoint} for i:= 1 to j do begin
BlockRead(F, SpawnPoint_New, sizeof(SpawnPoint_New));
SpawnPointsi:= SpawnPoint_New.SpawnPoint;
end;
{load waypoint start} BlockRead(F, WayPoint_Start, sizeof(WayPoint_Start));
j:= WayPoint_Start.Num;
{load waypoint} for i:= 1 to j do begin
BlockRead(F, WayPoint_New, sizeof(WayPoint_New));
Map.Path.WayPointi:= WayPoint_New.WayPoint;

{ Map.Path.WayPointi.Active:= WayPoint_New.WayPoint.Active;
Map.Path.WayPointi.id:= WayPoint_New.WayPoint.id; Map.Path.WayPointi.X:= WayPoint_New.WayPoint.X; Map.Path.WayPointi.Y:= WayPoint_New.WayPoint.Y; Map.Path.WayPointi.left:= WayPoint_New.WayPoint.left; Map.Path.WayPointi.right:= WayPoint_New.WayPoint.right; Map.Path.WayPointi.up:= WayPoint_New.WayPoint.up; Map.Path.WayPointi.down:= WayPoint_New.WayPoint.down; Map.Path.WayPointi.m2:= WayPoint_New.WayPoint.m2; Map.Path.WayPointi.PathNum:= WayPoint_New.WayPoint.PathNum; Map.Path.WayPointi.ConnectionsNum:= WayPoint_New.WayPoint.ConnectionsNum; for k:= 1 to MAX_CONNECTIONS do Map.Path.WayPointi.Connectionsk:= WayPoint_New.WayPoint.Connectionsk;

Map.Path.WayPointi.C1:= 0; Map.Path.WayPointi.C2:= 0; Map.Path.WayPointi.C3:= 0; }
end;

CloseFile(F);

if not Map.UpdateVertexBuffer then begin hHalt(ERR03); exit; end;
MakeUndo;

end;

Powered by Google Project Hosting