hedgewars/uLand.pas
changeset 37 2b7f2a43b999
parent 35 9367f246fb5f
child 51 b6e3ae05857f
equal deleted inserted replaced
36:a803a00a3272 37:2b7f2a43b999
    38 type TLandArray = packed array[0..1023, 0..2047] of LongWord;
    38 type TLandArray = packed array[0..1023, 0..2047] of LongWord;
    39 
    39 
    40 var  Land: TLandArray;
    40 var  Land: TLandArray;
    41      LandSurface: PSDL_Surface;
    41      LandSurface: PSDL_Surface;
    42 
    42 
    43 procedure GenLandSurface;
       
    44 procedure MakeFortsMap;
       
    45 procedure AddHHPoint(_x, _y: integer);
    43 procedure AddHHPoint(_x, _y: integer);
    46 procedure GetHHPoint(out _x, _y: integer);
    44 procedure GetHHPoint(out _x, _y: integer);
    47 procedure RandomizeHHPoints;
    45 procedure RandomizeHHPoints;
       
    46 procedure GenMap;
    48 
    47 
    49 implementation
    48 implementation
    50 uses uConsole, uStore, uMisc, uConsts, uRandom, uTeams, uIO, uLandTemplates, uLandObjects;
    49 uses uConsole, uStore, uMisc, uConsts, uRandom, uTeams, uIO, uLandTemplates, uLandObjects, uSHA;
    51 
    50 
    52 type TPixAr = record
    51 type TPixAr = record
    53               Count: Longword;
    52               Count: Longword;
    54               ar: array[0..Pred(cMaxEdgePoints)] of TPoint;
    53               ar: array[0..Pred(cMaxEdgePoints)] of TPoint;
    55               end;
    54               end;
    56 
    55 
    57 var HHPoints: record
    56 var HHPoints: record
    58               First, Last: word;
    57               First, Last: word;
    59               ar: array[1..Pred(cMaxSpawnPoints)] of TPoint
    58               ar: array[1..Pred(cMaxSpawnPoints)] of TPoint
    60               end = (First: 1);
    59               end = (First: 1);
       
    60 
       
    61 procedure LogLandDigest;
       
    62 var ctx: TSHA1Context;
       
    63     dig: TSHA1Digest;
       
    64 begin
       
    65 SHA1Init(ctx);
       
    66 SHA1Update(ctx, @Land, sizeof(Land));
       
    67 dig:= SHA1Final(ctx);
       
    68 AddFileLog('SHA1 Land digest: {'+inttostr(dig.LongWords[0])+':'
       
    69            +inttostr(dig.LongWords[1])+':'+inttostr(dig.LongWords[2])+':'
       
    70            +inttostr(dig.LongWords[3])+':'+inttostr(dig.LongWords[4])+'}');
       
    71 end;
    61 
    72 
    62 procedure DrawBezierEdge(var pa: TPixAr);
    73 procedure DrawBezierEdge(var pa: TPixAr);
    63 var x, y, i: integer;
    74 var x, y, i: integer;
    64     tx, ty, vx, vy, vlen, t: real;
    75     tx, ty, vx, vy, vlen, t: real;
    65     r1, r2, r3, r4: real;
    76     r1, r2, r3, r4: real;
   481 begin
   492 begin
   482 p:= TeamsList;
   493 p:= TeamsList;
   483 TryDo(p <> nil, 'No teams on map!', true);
   494 TryDo(p <> nil, 'No teams on map!', true);
   484 with PixelFormat^ do
   495 with PixelFormat^ do
   485      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0);
   496      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0);
       
   497 SDL_FillRect(LandSurface, nil, 0);
   486 tmpsurf:= LoadImage(Pathz[ptForts] + p.FortName + 'L.png', false);
   498 tmpsurf:= LoadImage(Pathz[ptForts] + p.FortName + 'L.png', false);
   487 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface);
   499 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface);
   488 SDL_FreeSurface(tmpsurf);
   500 SDL_FreeSurface(tmpsurf);
   489 LoadFortPoints(p.FortName, false, TeamSize(p));
   501 LoadFortPoints(p.FortName, false, TeamSize(p));
   490 p:= p.Next;
   502 p:= p.Next;
   493 BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface);
   505 BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface);
   494 SDL_FreeSurface(tmpsurf);
   506 SDL_FreeSurface(tmpsurf);
   495 LoadFortPoints(p.FortName, true, TeamSize(p));
   507 LoadFortPoints(p.FortName, true, TeamSize(p));
   496 p:= p.Next;
   508 p:= p.Next;
   497 TryDo(p = nil, 'More than 2 teams on map in forts mode!', true);
   509 TryDo(p = nil, 'More than 2 teams on map in forts mode!', true);
       
   510 end;
       
   511 
       
   512 procedure GenMap;
       
   513 begin
       
   514 if (GameFlags and gfForts) = 0 then GenLandSurface
       
   515                                else MakeFortsMap;
       
   516 AddProgress;
       
   517 {$IFDEF DEBUGFILE}LogLandDigest{$ENDIF}
   498 end;
   518 end;
   499 
   519 
   500 procedure AddHHPoint(_x, _y: integer);
   520 procedure AddHHPoint(_x, _y: integer);
   501 begin
   521 begin
   502 with HHPoints do
   522 with HHPoints do