hedgewars/uWorld.pas
changeset 6580 6155187bf599
parent 6492 71db3c0daa0a
child 6601 5965e2927b3d
equal deleted inserted replaced
6579:fc52f7c22c9b 6580:6155187bf599
   108     g: ansistring;
   108     g: ansistring;
   109 begin
   109 begin
   110 missionTimer:= 0;
   110 missionTimer:= 0;
   111 
   111 
   112 if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
   112 if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
   113    begin
   113     begin
   114    for i:= 0 to ClansCount * 4 do
   114     for i:= 0 to ClansCount * 4 do
   115       begin
   115         begin
   116       t:= GetRandom(ClansCount);
   116         t:= GetRandom(ClansCount);
   117       if t <> 0 then
   117         if t <> 0 then
   118          begin
   118             begin
   119          cp:= ClansArray[0];
   119             cp:= ClansArray[0];
   120          ClansArray[0]:= ClansArray[t];
   120             ClansArray[0]:= ClansArray[t];
   121          ClansArray[t]:= cp;
   121             ClansArray[t]:= cp;
   122          ClansArray[t]^.ClanIndex:= t;
   122             ClansArray[t]^.ClanIndex:= t;
   123          ClansArray[0]^.ClanIndex:= 0;
   123             ClansArray[0]^.ClanIndex:= 0;
   124          if (LocalClan = t) then LocalClan:= 0
   124             if (LocalClan = t) then
   125          else if (LocalClan = 0) then LocalClan:= t
   125                 LocalClan:= 0
   126          end;
   126             else if (LocalClan = 0) then
   127       end;
   127                 LocalClan:= t
   128    CurrentTeam:= ClansArray[0]^.Teams[0];
   128             end;
   129    end;
   129         end;
       
   130     CurrentTeam:= ClansArray[0]^.Teams[0];
       
   131     end;
   130 
   132 
   131 // if special game flags/settings are changed, add them to the game mode notice window and then show it
   133 // if special game flags/settings are changed, add them to the game mode notice window and then show it
   132 g:= ''; // no text/things to note yet
   134 g:= ''; // no text/things to note yet
   133 
   135 
   134 // add custom goals from lua script if there are any
   136 // add custom goals from lua script if there are any
   135 if LuaGoals <> '' then g:= LuaGoals + '|';
   137 if LuaGoals <> '' then
       
   138     g:= LuaGoals + '|';
   136 
   139 
   137 // check different game flags (goals/game modes first for now)
   140 // check different game flags (goals/game modes first for now)
   138 g:= AddGoal(g, gfKing, gidKing); // king?
   141 g:= AddGoal(g, gfKing, gidKing); // king?
   139 g:= AddGoal(g, gfTagTeam, gidTagTeam); // tag team mode?
   142 g:= AddGoal(g, gfTagTeam, gidTagTeam); // tag team mode?
   140 
   143 
   173     else
   176     else
   174         g:= AddGoal(g, gfAny, gidMineTimer, cMinesTime div 1000);
   177         g:= AddGoal(g, gfAny, gidMineTimer, cMinesTime div 1000);
   175     end;
   178     end;
   176 
   179 
   177 // if the string has been set, show it for (default timeframe) seconds
   180 // if the string has been set, show it for (default timeframe) seconds
   178 if g <> '' then ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0);
   181 if g <> '' then
       
   182     ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0);
   179 
   183 
   180 cWaveWidth:= SpritesData[sprWater].Width;
   184 cWaveWidth:= SpritesData[sprWater].Width;
   181 //cWaveHeight:= SpritesData[sprWater].Height;
   185 //cWaveHeight:= SpritesData[sprWater].Height;
   182 cWaveHeight:= 32;
   186 cWaveHeight:= 32;
   183 
   187 
   231 const BORDERSIZE = 2;
   235 const BORDERSIZE = 2;
   232 var x, y, i, t, g: LongInt;
   236 var x, y, i, t, g: LongInt;
   233     Slot, Pos, STurns: LongInt;
   237     Slot, Pos, STurns: LongInt;
   234     Ammo: PHHAmmo;
   238     Ammo: PHHAmmo;
   235 begin
   239 begin
   236     if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or
   240     if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil)
   237        ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
   241     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
   238         bShowAmmoMenu:= false;
   242         bShowAmmoMenu:= false;
   239 
   243 
   240     if bShowAmmoMenu then
   244     if bShowAmmoMenu then
   241     // show ammo menu
   245     // show ammo menu
   242         begin
   246         begin
   243         FollowGear:= nil;
   247         FollowGear:= nil;
   244         if AMxShift = AMWidth then prevPoint.X:= 0;
   248         if AMxShift = AMWidth then
   245         if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= 0
   249             prevPoint.X:= 0;
       
   250         if (cReducedQuality and rqSlowMenu) <> 0 then
       
   251             AMxShift:= 0
   246         else
   252         else
   247             if AMxShift > MENUSPEED then dec(AMxShift, MENUSPEED)
   253             if AMxShift > MENUSPEED then
   248             else AMxShift:= 0;
   254                 dec(AMxShift, MENUSPEED)
       
   255             else
       
   256                 AMxShift:= 0;
   249         end
   257         end
   250     else
   258     else
   251     // hide ammo menu
   259     // hide ammo menu
   252         begin
   260         begin
   253         if AMxShift = 0 then
   261         if AMxShift = 0 then
   254             begin
   262             begin
   255             CursorPoint.X:= cScreenWidth shr 1;
   263             CursorPoint.X:= cScreenWidth shr 1;
   256             CursorPoint.Y:= cScreenHeight shr 1;
   264             CursorPoint.Y:= cScreenHeight shr 1;
   257             prevPoint:= CursorPoint;
   265             prevPoint:= CursorPoint;
   258             end;
   266             end;
   259         if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= AMWidth+2
   267         if (cReducedQuality and rqSlowMenu) <> 0 then
       
   268             AMxShift:= AMWidth+2
   260         else
   269         else
   261             if AMxShift < (AMWidth - MENUSPEED) then inc(AMxShift, MENUSPEED)
   270             if AMxShift < (AMWidth - MENUSPEED) then
   262             else AMxShift:= AMWidth;
   271                 inc(AMxShift, MENUSPEED)
       
   272             else
       
   273                 AMxShift:= AMWidth;
   263         end;
   274         end;
   264 
   275 
   265     // give the assigned ammo to hedgehog
   276     // give the assigned ammo to hedgehog
   266     Ammo:= nil;
   277     Ammo:= nil;
   267     if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and
   278     if (CurrentTeam <> nil) and (CurrentHedgehog <> nil)
   268        (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
   279     and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
   269         Ammo:= CurrentHedgehog^.Ammo
   280         Ammo:= CurrentHedgehog^.Ammo
   270     else if (LocalAmmo <> -1) then
   281     else if (LocalAmmo <> -1) then
   271         Ammo:= GetAmmoByNum(LocalAmmo);
   282         Ammo:= GetAmmoByNum(LocalAmmo);
   272     Pos:= -1;
   283     Pos:= -1;
   273     if Ammo = nil then
   284     if Ammo = nil then
   290     inc(y, BORDERSIZE);
   301     inc(y, BORDERSIZE);
   291 
   302 
   292     for i:= 0 to cMaxSlotIndex do
   303     for i:= 0 to cMaxSlotIndex do
   293         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   304         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   294             begin
   305             begin
   295             if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then Slot:= i;
   306             if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then
       
   307                 Slot:= i;
   296             inc(SlotsNum);
   308             inc(SlotsNum);
   297             DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   309             DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   298             t:= 0;
   310             t:= 0;
   299             g:= 0;
   311             g:= 0;
   300             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   312             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   305                     STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   317                     STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   306 
   318 
   307                     if STurns >= 0 then
   319                     if STurns >= 0 then
   308                         begin
   320                         begin
   309                         DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   321                         DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   310                         if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
   322                         if STurns < 100 then
       
   323                             DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
   311                         end
   324                         end
   312                     else
   325                     else
   313                         DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   326                         DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   314                     if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
   327                     if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
   315                        (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
   328                        (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
   316                         begin
   329                         begin
   317                         if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
   330                         if (STurns < 0) then
       
   331                             DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
   318                         Pos:= t;
   332                         Pos:= t;
   319                         end;
   333                         end;
   320                     inc(g)
   334                     inc(g)
   321                     end;
   335                     end;
   322                 inc(t)
   336                 inc(t)
   327             inc(y, AMSlotSize);
   341             inc(y, AMSlotSize);
   328             end;
   342             end;
   329 
   343 
   330     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   344     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   331     for i:= 0 to cMaxSlotAmmoIndex do
   345     for i:= 0 to cMaxSlotAmmoIndex do
   332 	DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   346         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   333     DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
   347     DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
   334 {$ELSE}
   348 {$ELSE}
   335     Slot:= 0;
   349     Slot:= 0;
   336     y:= cScreenHeight - AMyOffset;
   350     y:= cScreenHeight - AMyOffset;
   337     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   351     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   346     DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
   360     DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
   347 
   361 
   348     for i:= cMaxSlotIndex downto 0 do
   362     for i:= cMaxSlotIndex downto 0 do
   349         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   363         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   350             begin
   364             begin
   351             if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then Slot:= i;
   365             if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then
       
   366                 Slot:= i;
   352             dec(y, AMSlotSize);
   367             dec(y, AMSlotSize);
   353             inc(SlotsNum);
   368             inc(SlotsNum);
   354             DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   369             DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   355             DrawSprite(sprAMSlot, x, y, 1);
   370             DrawSprite(sprAMSlot, x, y, 1);
   356             DrawSprite(sprAMSlotKeys, x, y + 1, i);
   371             DrawSprite(sprAMSlotKeys, x, y + 1, i);
   364                     STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   379                     STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   365 
   380 
   366                     if STurns >= 0 then
   381                     if STurns >= 0 then
   367                         begin
   382                         begin
   368                         DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   383                         DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   369                         if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
   384                         if STurns < 100 then
       
   385                             DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
   370                         end else
   386                         end else
   371                         DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   387                         DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   372                     if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
   388                     if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
   373                        (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
   389                        (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
   374                         begin
   390                         begin
   375                         if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
   391                         if (STurns < 0) then
       
   392                             DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
   376                         Pos:= t;
   393                         Pos:= t;
   377                         end;
   394                         end;
   378                     inc(g)
   395                     inc(g)
   379                     end;
   396                     end;
   380                     inc(t)
   397                     inc(t)
   430 {$ELSE}
   447 {$ELSE}
   431         ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
   448         ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
   432 {$ENDIF}
   449 {$ENDIF}
   433 
   450 
   434     bSelected:= false;
   451     bSelected:= false;
   435     if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   452     if AMxShift = 0 then
       
   453         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   436 end;
   454 end;
   437 
   455 
   438 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   456 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   439 var VertexBuffer: array [0..3] of TVertex2f;
   457 var VertexBuffer: array [0..3] of TVertex2f;
   440     r: TSDL_Rect;
   458     r: TSDL_Rect;
   441     lw, lh: GLfloat;
   459     lw, lh: GLfloat;
   442 begin
   460 begin
   443     if SuddenDeathDmg then
   461 if SuddenDeathDmg then
   444         begin
   462     begin
   445         SDWaterColorArray[0].a := Alpha;
   463     SDWaterColorArray[0].a := Alpha;
   446         SDWaterColorArray[1].a := Alpha;
   464     SDWaterColorArray[1].a := Alpha;
   447         SDWaterColorArray[2].a := Alpha;
   465     SDWaterColorArray[2].a := Alpha;
   448         SDWaterColorArray[3].a := Alpha
   466     SDWaterColorArray[3].a := Alpha
   449         end
   467     end
   450     else
   468 else
   451         begin
   469     begin
   452         WaterColorArray[0].a := Alpha;
   470     WaterColorArray[0].a := Alpha;
   453         WaterColorArray[1].a := Alpha;
   471     WaterColorArray[1].a := Alpha;
   454         WaterColorArray[2].a := Alpha;
   472     WaterColorArray[2].a := Alpha;
   455         WaterColorArray[3].a := Alpha
   473     WaterColorArray[3].a := Alpha
   456         end;
   474     end;
   457 
   475 
   458     lw:= cScreenWidth / cScaleFactor;
   476 lw:= cScreenWidth / cScaleFactor;
   459     lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16;
   477 lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16;
   460 
   478 
   461     // Water
   479     // Water
   462     r.y:= OffsetY + WorldDy + cWaterLine;
   480 r.y:= OffsetY + WorldDy + cWaterLine;
   463     if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then
   481 if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then
   464     begin
   482     begin
   465         if r.y < 0 then
   483         if r.y < 0 then
   466             r.y:= 0;
   484             r.y:= 0;
   467 
   485 
   468         glDisable(GL_TEXTURE_2D);
   486         glDisable(GL_TEXTURE_2D);
   557 end;
   575 end;
   558 
   576 
   559 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt);
   577 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt);
   560 var i, w, h, lw, lh, rw, rh, sw: LongInt;
   578 var i, w, h, lw, lh, rw, rh, sw: LongInt;
   561 begin
   579 begin
   562     sw:= round(cScreenWidth / cScaleFactor);
   580 sw:= round(cScreenWidth / cScaleFactor);
   563     if (SpritesData[sprL].Texture = nil) and (SpritesData[spr].Texture <> nil) then
   581 if (SpritesData[sprL].Texture = nil) and (SpritesData[spr].Texture <> nil) then
   564         begin
   582     begin
   565         w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
   583     w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
   566         h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
   584     h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
   567         i:= Shift mod w;
   585     i:= Shift mod w;
   568         if i > 0 then dec(i, w);
   586     if i > 0 then
   569         dec(i, w * (sw div w + 1));
   587         dec(i, w);
   570         repeat
   588     dec(i, w * (sw div w + 1));
   571             DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
   589     repeat
   572             inc(i, w)
   590     DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
   573         until i > sw
   591     inc(i, w)
   574         end
   592     until i > sw
   575     else if SpritesData[spr].Texture <> nil then
   593     end
   576         begin
   594 else if SpritesData[spr].Texture <> nil then
   577         w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
   595     begin
   578         h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
   596     w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
   579         lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale;
   597     h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
   580         lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale;
   598     lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale;
   581         if SpritesData[sprR].Texture <> nil then
   599     lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale;
       
   600     if SpritesData[sprR].Texture <> nil then
       
   601         begin
       
   602         rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale;
       
   603         rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale
       
   604         end;
       
   605     dec(Shift, w div 2);
       
   606     DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
       
   607 
       
   608     i:= Shift - lw;
       
   609     while i >= -sw - lw do
       
   610         begin
       
   611         DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
       
   612         dec(i, lw);
       
   613         end;
       
   614 
       
   615     i:= Shift + w;
       
   616     if SpritesData[sprR].Texture <> nil then
       
   617         while i <= sw do
   582             begin
   618             begin
   583             rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale;
   619             DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale);
   584             rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale
   620             inc(i, rw)
   585             end;
   621             end
   586         dec(Shift, w div 2);
   622     else
   587         DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
   623         while i <= sw do
   588 
       
   589         i:= Shift - lw;
       
   590         while i >= -sw - lw do
       
   591             begin
   624             begin
   592             DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
   625             DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
   593             dec(i, lw);
   626             inc(i, lw)
   594             end;
   627             end
   595 
   628     end
   596         i:= Shift + w;
       
   597         if SpritesData[sprR].Texture <> nil then
       
   598             while i <= sw do
       
   599                 begin
       
   600                 DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale);
       
   601                 inc(i, rw)
       
   602                 end
       
   603         else
       
   604             while i <= sw do
       
   605                 begin
       
   606                 DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
       
   607                 inc(i, lw)
       
   608                 end
       
   609         end
       
   610 end;
   629 end;
   611 
   630 
   612 
   631 
   613 procedure DrawWorld(Lag: LongInt);
   632 procedure DrawWorld(Lag: LongInt);
   614 begin
   633 begin
   615     if not isPaused then
   634 if not isPaused then
   616     begin
   635     begin
   617         if ZoomValue < zoom then
   636         if ZoomValue < zoom then
   618         begin
   637         begin
   619             zoom:= zoom - 0.002 * Lag;
   638             zoom:= zoom - 0.002 * Lag;
   620             if ZoomValue > zoom then
   639             if ZoomValue > zoom then
   621                 zoom:= ZoomValue
   640                 zoom:= ZoomValue
   622         end
   641         end
   623         else
   642         else
   624         if ZoomValue > zoom then
   643             if ZoomValue > zoom then
   625         begin
   644             begin
   626             zoom:= zoom + 0.002 * Lag;
   645             zoom:= zoom + 0.002 * Lag;
   627             if ZoomValue < zoom then
   646             if ZoomValue < zoom then
   628                 zoom:= ZoomValue
   647                 zoom:= ZoomValue
   629             end
   648             end
   630         end
   649         end
   760 {$IFDEF S3D_DISABLED}
   779 {$IFDEF S3D_DISABLED}
   761     rm:= rm; d:= d; // avoid hint
   780     rm:= rm; d:= d; // avoid hint
   762     exit;
   781     exit;
   763 {$ELSE}
   782 {$ELSE}
   764     d:= d / 5;
   783     d:= d / 5;
   765     if rm = rmDefault then exit
   784     if rm = rmDefault then
   766     else if rm = rmLeftEye then d:= -d;
   785         exit
       
   786     else if rm = rmLeftEye then
       
   787         d:= -d;
   767     stereoDepth:= stereoDepth + d;
   788     stereoDepth:= stereoDepth + d;
   768     glMatrixMode(GL_PROJECTION);
   789     glMatrixMode(GL_PROJECTION);
   769     glTranslatef(d, 0, 0);
   790     glTranslatef(d, 0, 0);
   770     glMatrixMode(GL_MODELVIEW);
   791     glMatrixMode(GL_MODELVIEW);
   771 {$ENDIF}
   792 {$ENDIF}
   775 begin
   796 begin
   776 {$IFDEF S3D_DISABLED}
   797 {$IFDEF S3D_DISABLED}
   777     rm:= rm; // avoid hint
   798     rm:= rm; // avoid hint
   778     exit;
   799     exit;
   779 {$ELSE}
   800 {$ELSE}
   780     if rm = rmDefault then exit;
   801     if rm = rmDefault then
       
   802         exit;
   781     glMatrixMode(GL_PROJECTION);
   803     glMatrixMode(GL_PROJECTION);
   782     glTranslatef(-stereoDepth, 0, 0);
   804     glTranslatef(-stereoDepth, 0, 0);
   783     glMatrixMode(GL_MODELVIEW);
   805     glMatrixMode(GL_MODELVIEW);
   784     stereoDepth:= 0;
   806     stereoDepth:= 0;
   785 {$ENDIF}
   807 {$ENDIF}
   792     s: string[15];
   814     s: string[15];
   793     highlight: Boolean;
   815     highlight: Boolean;
   794     smallScreenOffset, offsetX, offsetY, screenBottom: LongInt;
   816     smallScreenOffset, offsetX, offsetY, screenBottom: LongInt;
   795     VertexBuffer: array [0..3] of TVertex2f;
   817     VertexBuffer: array [0..3] of TVertex2f;
   796 begin
   818 begin
   797     if (cReducedQuality and rqNoBackground) = 0 then
   819 if (cReducedQuality and rqNoBackground) = 0 then
   798     begin
   820     begin
   799         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
   821         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
   800         ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
   822         ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
   801         offsetY:= 10 * Min(0, -145 - ScreenBottom);
   823         offsetY:= 10 * Min(0, -145 - ScreenBottom);
   802         SkyOffset:= offsetY div 35 + cWaveHeight;
   824         SkyOffset:= offsetY div 35 + cWaveHeight;
   804         if ScreenBottom > SkyOffset then
   826         if ScreenBottom > SkyOffset then
   805             HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20);
   827             HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20);
   806 
   828 
   807         // background
   829         // background
   808         ChangeDepth(RM, cStereo_Sky);
   830         ChangeDepth(RM, cStereo_Sky);
   809         if SuddenDeathDmg then Tint(SDTint, SDTint, SDTint, $FF);
   831         if SuddenDeathDmg then
       
   832             Tint(SDTint, SDTint, SDTint, $FF);
   810         DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset);
   833         DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset);
   811         ChangeDepth(RM, -cStereo_Horizon);
   834         ChangeDepth(RM, -cStereo_Horizon);
   812         DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset);
   835         DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset);
   813         if SuddenDeathDmg then Tint($FF, $FF, $FF, $FF);
   836         if SuddenDeathDmg then
       
   837             Tint($FF, $FF, $FF, $FF);
   814     end;
   838     end;
   815 
   839 
   816     DrawVisualGears(0);
   840 DrawVisualGears(0);
   817     ChangeDepth(RM, -cStereo_MidDistance);
   841 ChangeDepth(RM, -cStereo_MidDistance);
   818     DrawVisualGears(4);
   842 DrawVisualGears(4);
   819 
   843 
   820     if (cReducedQuality and rq2DWater) = 0 then
   844 if (cReducedQuality and rq2DWater) = 0 then
   821     begin
   845     begin
   822         // Waves
   846         // Waves
   823         DrawWater(255, SkyOffset); 
   847         DrawWater(255, SkyOffset); 
   824         ChangeDepth(RM, -cStereo_Water_distant);
   848         ChangeDepth(RM, -cStereo_Water_distant);
   825         DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
   849         DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
   828         ChangeDepth(RM, -cStereo_Water_distant);
   852         ChangeDepth(RM, -cStereo_Water_distant);
   829         DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
   853         DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
   830         ChangeDepth(RM, -cStereo_Water_distant);
   854         ChangeDepth(RM, -cStereo_Water_distant);
   831         DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24);
   855         DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24);
   832     end
   856     end
   833     else
   857 else
   834         DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
   858         DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
   835 
   859 
   836     changeDepth(RM, cStereo_Land);
   860     changeDepth(RM, cStereo_Land);
   837     DrawVisualGears(5);
   861     DrawVisualGears(5);
   838     DrawLand(WorldDx, WorldDy);
   862     DrawLand(WorldDx, WorldDy);
   859                             hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
   883                             hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
   860                             i)
   884                             i)
   861                 end
   885                 end
   862         end;
   886         end;
   863 
   887 
   864     DrawVisualGears(1);
   888 DrawVisualGears(1);
   865     DrawGears;
   889 DrawGears;
   866     DrawVisualGears(6);
   890 DrawVisualGears(6);
   867 
   891 
       
   892 if SuddenDeathDmg then
       
   893     DrawWater(cSDWaterOpacity, 0)
       
   894 else
       
   895     DrawWater(cWaterOpacity, 0);
       
   896 
       
   897     // Waves
       
   898 ChangeDepth(RM, cStereo_Water_near);
       
   899 DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
       
   900 
       
   901 if (cReducedQuality and rq2DWater) = 0 then
       
   902     begin
       
   903     //DrawWater(cWaterOpacity, - offsetY div 40);
       
   904     ChangeDepth(RM, cStereo_Water_near);
       
   905     DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8);
   868     if SuddenDeathDmg then
   906     if SuddenDeathDmg then
   869         DrawWater(cSDWaterOpacity, 0)
   907         DrawWater(cSDWaterOpacity, - offsetY div 20)
   870     else
   908     else
   871         DrawWater(cWaterOpacity, 0);
   909         DrawWater(cWaterOpacity, - offsetY div 20);
   872 
       
   873     // Waves
       
   874     ChangeDepth(RM, cStereo_Water_near);
   910     ChangeDepth(RM, cStereo_Water_near);
   875     DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
   911     DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2);
   876 
       
   877     if (cReducedQuality and rq2DWater) = 0 then
       
   878     begin
       
   879         //DrawWater(cWaterOpacity, - offsetY div 40);
       
   880         ChangeDepth(RM, cStereo_Water_near);
       
   881         DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8);
       
   882         if SuddenDeathDmg then
       
   883             DrawWater(cSDWaterOpacity, - offsetY div 20)
       
   884         else
       
   885             DrawWater(cWaterOpacity, - offsetY div 20);
       
   886         ChangeDepth(RM, cStereo_Water_near);
       
   887         DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2);
       
   888         if SuddenDeathDmg then
   912         if SuddenDeathDmg then
   889             DrawWater(cSDWaterOpacity, - offsetY div 10)
   913             DrawWater(cSDWaterOpacity, - offsetY div 10)
   890         else
   914         else
   891             DrawWater(cWaterOpacity, - offsetY div 10);
   915             DrawWater(cWaterOpacity, - offsetY div 10);
   892         ChangeDepth(RM, cStereo_Water_near);
   916         ChangeDepth(RM, cStereo_Water_near);
   893         DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
   917         DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
   894     end
   918         end
   895     else
   919     else
   896         DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
   920         DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
   897 
   921 
   898 // everything after this ChangeDepth will be drawn outside the screen
   922 // everything after this ChangeDepth will be drawn outside the screen
   899 // note: negative parallax gears should last very little for a smooth stereo effect
   923 // note: negative parallax gears should last very little for a smooth stereo effect
   934     if ReadyTimeLeft <> 0 then
   958     if ReadyTimeLeft <> 0 then
   935         i:= Succ(Pred(ReadyTimeLeft) div 1000)
   959         i:= Succ(Pred(ReadyTimeLeft) div 1000)
   936     else
   960     else
   937         i:= Succ(Pred(TurnTimeLeft) div 1000);
   961         i:= Succ(Pred(TurnTimeLeft) div 1000);
   938    
   962    
   939    if i>99 then t:= 112
   963     if i>99 then
   940       else if i>9 then t:= 96
   964         t:= 112
   941                   else t:= 80;
   965     else if i>9 then
   942    DrawSprite(sprFrame, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, 1);
   966         t:= 96
   943    while i > 0 do
   967     else
   944          begin
   968         t:= 80;
   945          dec(t, 32);
   969     DrawSprite(sprFrame, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, 1);
   946          DrawSprite(sprBigDigit, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, i mod 10);
   970     while i > 0 do
   947          i:= i div 10
   971         begin
   948          end;
   972         dec(t, 32);
   949    DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0);
   973         DrawSprite(sprBigDigit, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, i mod 10);
   950    end;
   974         i:= i div 10
       
   975         end;
       
   976     DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0);
       
   977     end;
   951 
   978 
   952 // Captions
   979 // Captions
   953 DrawCaptions;
   980 DrawCaptions;
   954 
   981 
   955 {$IFDEF ANDROID}
   982 {$IFDEF ANDROID}
   959 // Teams Healths
   986 // Teams Healths
   960 if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
   987 if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
   961     begin
   988     begin
   962     SetScale(1.5);
   989     SetScale(1.5);
   963     smallScreenOffset:= cScreenHeight div 6;
   990     smallScreenOffset:= cScreenHeight div 6;
   964     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80);
   991     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
       
   992         Tint($FF,$FF,$FF,$80);
   965     end
   993     end
   966 else smallScreenOffset:= 0;
   994 else smallScreenOffset:= 0;
   967 for t:= 0 to Pred(TeamsCount) do
   995 for t:= 0 to Pred(TeamsCount) do
   968    with TeamsArray[t]^ do
   996     with TeamsArray[t]^ do
   969       begin
   997         begin
   970       highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
   998         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
   971 
   999 
   972       if highlight then
  1000         if highlight then
   973          Tint(Clan^.Color shl 8 or $FF);
  1001             Tint(Clan^.Color shl 8 or $FF);
   974 
       
   975       // draw name
       
   976       DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset, NameTagTex);
       
   977 
       
   978       // draw flag
       
   979       DrawTexture(-14, cScreenHeight + DrawHealthY + smallScreenOffset, FlagTex);
       
   980 
       
   981       // draw health bar
       
   982       r.x:= 0;
       
   983       r.y:= 0;
       
   984       r.w:= 2 + TeamHealthBarWidth;
       
   985       r.h:= HealthTex^.h;
       
   986       DrawFromRect(14, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
       
   987 
       
   988       // draw health bars right border
       
   989       inc(r.x, cTeamHealthWidth + 2);
       
   990       r.w:= 3;
       
   991       DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
       
   992 
       
   993       // draw ai kill counter for gfAISurvival
       
   994       if (GameFlags and gfAISurvival) <> 0 then begin
       
   995           DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset,
       
   996               AIKillsTex);
       
   997       end;
       
   998 
       
   999       // if highlighted, draw flag and other contents again to keep their colors
       
  1000       // this approach should be faster than drawing all borders one by one tinted or not
       
  1001       if highlight then
       
  1002          begin
       
  1003          if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80)
       
  1004          else Tint($FF, $FF, $FF, $FF);
       
  1005 
  1002 
  1006          // draw name
  1003          // draw name
  1007          r.x:= 2;
  1004         DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset, NameTagTex);
  1008          r.y:= 2;
  1005 
  1009          r.w:= NameTagTex^.w - 4;
  1006         // draw flag
  1010          r.h:= NameTagTex^.h - 4;
  1007         DrawTexture(-14, cScreenHeight + DrawHealthY + smallScreenOffset, FlagTex);
  1011          DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex);
  1008 
  1012          // draw flag
  1009         // draw health bar
  1013          r.w:= 22;
  1010         r.x:= 0;
  1014          r.h:= 15;
  1011         r.y:= 0;
  1015          DrawFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex);
  1012         r.w:= 2 + TeamHealthBarWidth;
  1016          // draw health bar
  1013         r.h:= HealthTex^.h;
  1017          r.w:= TeamHealthBarWidth + 1;
  1014         DrawFromRect(14, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
  1018          r.h:= HealthTex^.h - 4;
  1015 
  1019          DrawFromRect(16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, HealthTex);
  1016         // draw health bars right border
  1020          end;
  1017         inc(r.x, cTeamHealthWidth + 2);
  1021       end;
  1018         r.w:= 3;
       
  1019         DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
       
  1020 
       
  1021         // draw ai kill counter for gfAISurvival
       
  1022         if (GameFlags and gfAISurvival) <> 0 then
       
  1023             begin
       
  1024             DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset, AIKillsTex);
       
  1025             end;
       
  1026 
       
  1027         // if highlighted, draw flag and other contents again to keep their colors
       
  1028         // this approach should be faster than drawing all borders one by one tinted or not
       
  1029         if highlight then
       
  1030             begin
       
  1031             if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
       
  1032                 Tint($FF,$FF,$FF,$80)
       
  1033             else Tint($FF, $FF, $FF, $FF);
       
  1034 
       
  1035             // draw name
       
  1036             r.x:= 2;
       
  1037             r.y:= 2;
       
  1038             r.w:= NameTagTex^.w - 4;
       
  1039             r.h:= NameTagTex^.h - 4;
       
  1040             DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex);
       
  1041             // draw flag
       
  1042             r.w:= 22;
       
  1043             r.h:= 15;
       
  1044             DrawFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex);
       
  1045             // draw health bar
       
  1046             r.w:= TeamHealthBarWidth + 1;
       
  1047             r.h:= HealthTex^.h - 4;
       
  1048             DrawFromRect(16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, HealthTex);
       
  1049             end;
       
  1050         end;
  1022 if smallScreenOffset <> 0 then
  1051 if smallScreenOffset <> 0 then
  1023     begin
  1052     begin
  1024     SetScale(cDefaultZoomLevel);
  1053     SetScale(cDefaultZoomLevel);
  1025     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$FF);
  1054     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
       
  1055         Tint($FF,$FF,$FF,$FF);
  1026     end;
  1056     end;
  1027 
  1057 
  1028 // Lag alert
  1058 // Lag alert
  1029 if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
  1059 if isInLag then
       
  1060     DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
  1030 
  1061 
  1031 // Wind bar
  1062 // Wind bar
  1032 {$IFDEF MOBILE}
  1063 {$IFDEF MOBILE}
  1033     offsetX:= cScreenHeight - 13;
  1064     offsetX:= cScreenHeight - 13;
  1034     offsetY:= (cScreenWidth shr 1) + 74;
  1065     offsetY:= (cScreenWidth shr 1) + 74;
  1036     offsetX:= 30;
  1067     offsetX:= 30;
  1037     offsetY:= 180;
  1068     offsetY:= 180;
  1038 {$ENDIF}
  1069 {$ENDIF}
  1039     DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0);
  1070     DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0);
  1040     if WindBarWidth > 0 then
  1071     if WindBarWidth > 0 then
  1041     begin
  1072         begin
  1042         {$WARNINGS OFF}
  1073         {$WARNINGS OFF}
  1043         r.x:= 8 - (RealTicks shr 6) mod 8;
  1074         r.x:= 8 - (RealTicks shr 6) mod 8;
  1044         {$WARNINGS ON}
  1075         {$WARNINGS ON}
  1045         r.y:= 0;
  1076         r.y:= 0;
  1046         r.w:= WindBarWidth;
  1077         r.w:= WindBarWidth;
  1047         r.h:= 13;
  1078         r.h:= 13;
  1048         DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0);
  1079         DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0);
  1049     end
  1080         end
  1050     else
  1081     else
  1051         if WindBarWidth < 0 then
  1082         if WindBarWidth < 0 then
  1052         begin
  1083         begin
  1053             {$WARNINGS OFF}
  1084             {$WARNINGS OFF}
  1054             r.x:= (Longword(WindBarWidth) + RealTicks shr 6) mod 8;
  1085             r.x:= (Longword(WindBarWidth) + RealTicks shr 6) mod 8;
  1058             r.h:= 13;
  1089             r.h:= 13;
  1059             DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0);
  1090             DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0);
  1060         end;
  1091         end;
  1061 
  1092 
  1062 // AmmoMenu
  1093 // AmmoMenu
  1063 if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu;
  1094 if (AMxShift < AMWidth) or bShowAmmoMenu then
       
  1095     ShowAmmoMenu;
  1064 
  1096 
  1065 // Cursor
  1097 // Cursor
  1066 if isCursorVisible and bShowAmmoMenu then
  1098 if isCursorVisible and bShowAmmoMenu then
  1067    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
  1099     DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
  1068 
  1100 
  1069 // Chat
  1101 // Chat
  1070 DrawChat;
  1102 DrawChat;
  1071 
  1103 
  1072 // various captions
  1104 // various captions
  1073 if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
  1105 if fastUntilLag then
  1074 if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
  1106     DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
       
  1107 if isPaused then
       
  1108     DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
  1075 if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then
  1109 if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then
  1076     begin
  1110     begin
  1077     if (ReadyTimeLeft = 0) and (missionTimer > 0) then dec(missionTimer, Lag);
  1111     if (ReadyTimeLeft = 0) and (missionTimer > 0) then
  1078     if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0
  1112         dec(missionTimer, Lag);
       
  1113     if missionTimer < 0 then
       
  1114         missionTimer:= 0; // avoid subtracting below 0
  1079     if missionTex <> nil then
  1115     if missionTex <> nil then
  1080         DrawCentered(0, Min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex);
  1116         DrawCentered(0, Min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex);
  1081     end;
  1117     end;
  1082 
  1118 
  1083 // fps
  1119 // fps
  1086 {$ELSE}
  1122 {$ELSE}
  1087 offsetX:= 10;
  1123 offsetX:= 10;
  1088 {$ENDIF}
  1124 {$ENDIF}
  1089 offsetY:= cOffsetY;
  1125 offsetY:= cOffsetY;
  1090 if (RM = rmDefault) or (RM = rmRightEye) then
  1126 if (RM = rmDefault) or (RM = rmRightEye) then
  1091 begin
  1127     begin
  1092     inc(Frames);
  1128     inc(Frames);
  1093 
  1129 
  1094     if cShowFPS or (GameType = gmtDemo) then
  1130     if cShowFPS or (GameType = gmtDemo) then
  1095         inc(CountTicks, Lag);
  1131         inc(CountTicks, Lag);
  1096     if (GameType = gmtDemo) and (CountTicks >= 1000) then
  1132     if (GameType = gmtDemo) and (CountTicks >= 1000) then
  1097     begin
  1133         begin
  1098         i:=GameTicks div 1000;
  1134         i:=GameTicks div 1000;
  1099         t:= i mod 60;
  1135         t:= i mod 60;
  1100         s:= inttostr(t);
  1136         s:= inttostr(t);
  1101         if t < 10 then s:= '0' + s;
  1137         if t < 10 then
       
  1138             s:= '0' + s;
  1102         i:= i div 60;
  1139         i:= i div 60;
  1103         t:= i mod 60;
  1140         t:= i mod 60;
  1104         s:= inttostr(t) + ':' + s;
  1141         s:= inttostr(t) + ':' + s;
  1105         if t < 10 then s:= '0' + s;
  1142         if t < 10 then
       
  1143             s:= '0' + s;
  1106         s:= inttostr(i div 60) + ':' + s;
  1144         s:= inttostr(i div 60) + ':' + s;
  1107    
  1145    
  1108     
  1146     
  1109         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1147         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1110         tmpSurface:= doSurfaceConversion(tmpSurface);
  1148         tmpSurface:= doSurfaceConversion(tmpSurface);
  1111         FreeTexture(timeTexture);
  1149         FreeTexture(timeTexture);
  1112         timeTexture:= Surface2Tex(tmpSurface, false);
  1150         timeTexture:= Surface2Tex(tmpSurface, false);
  1113         SDL_FreeSurface(tmpSurface)
  1151         SDL_FreeSurface(tmpSurface)
  1114     end;
  1152         end;
  1115 
  1153 
  1116     if timeTexture <> nil then
  1154     if timeTexture <> nil then
  1117         DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
  1155         DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
  1118 
  1156 
  1119     if cShowFPS then
  1157     if cShowFPS then
  1120     begin
  1158         begin
  1121         if CountTicks >= 1000 then
  1159         if CountTicks >= 1000 then
  1122         begin
  1160             begin
  1123             FPS:= Frames;
  1161             FPS:= Frames;
  1124             Frames:= 0;
  1162             Frames:= 0;
  1125             CountTicks:= 0;
  1163             CountTicks:= 0;
  1126             s:= inttostr(FPS) + ' fps';
  1164             s:= inttostr(FPS) + ' fps';
  1127             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1165             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1128             tmpSurface:= doSurfaceConversion(tmpSurface);
  1166             tmpSurface:= doSurfaceConversion(tmpSurface);
  1129             FreeTexture(fpsTexture);
  1167             FreeTexture(fpsTexture);
  1130             fpsTexture:= Surface2Tex(tmpSurface, false);
  1168             fpsTexture:= Surface2Tex(tmpSurface, false);
  1131             SDL_FreeSurface(tmpSurface)
  1169             SDL_FreeSurface(tmpSurface)
  1132         end;
  1170             end;
  1133         if fpsTexture <> nil then
  1171         if fpsTexture <> nil then
  1134             DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
  1172             DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
  1135     end;
  1173         end;
  1136 
  1174 
  1137     if CountTicks >= 1000 then CountTicks:= 0;
  1175     if CountTicks >= 1000 then
       
  1176         CountTicks:= 0;
  1138 
  1177 
  1139     // lag warning (?)
  1178     // lag warning (?)
  1140     inc(SoundTimerTicks, Lag);
  1179     inc(SoundTimerTicks, Lag);
  1141 end;
  1180 end;
  1142 
  1181 
  1187         glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
  1226         glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
  1188         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
  1227         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
  1189 
  1228 
  1190         glEnable(GL_TEXTURE_2D);
  1229         glEnable(GL_TEXTURE_2D);
  1191         Tint($FF, $FF, $FF, $FF);
  1230         Tint($FF, $FF, $FF, $FF);
  1192         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone
  1231         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then
       
  1232             ScreenFade:= sfNone
  1193         end
  1233         end
  1194     end;
  1234     end;
  1195 
  1235 
  1196 SetScale(zoom);
  1236 SetScale(zoom);
  1197 
  1237 
  1198 // Cursor
  1238 // Cursor
  1199 if isCursorVisible then
  1239 if isCursorVisible then
  1200    begin
  1240     begin
  1201    if not bShowAmmoMenu then
  1241     if not bShowAmmoMenu then
  1202      begin
  1242         begin
  1203      with CurrentHedgehog^ do
  1243         with CurrentHedgehog^ do
  1204        if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
  1244             if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
  1205          begin
  1245                 begin
  1206          if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then
  1246             if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then
  1207            DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
  1247                 DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
  1208          i:= GetAmmoEntry(CurrentHedgehog^)^.Pos;
  1248             i:= GetAmmoEntry(CurrentHedgehog^)^.Pos;
  1209          with Ammoz[CurAmmoType] do
  1249             with Ammoz[CurAmmoType] do
  1210            if PosCount > 1 then
  1250                 if PosCount > 1 then
  1211              DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
  1251                     DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
  1212          end;
  1252                 end;
  1213      DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
  1253         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
  1214      end
  1254         end
  1215    end;
  1255     end;
  1216 isFirstFrame:= false
  1256 isFirstFrame:= false
  1217 end;
  1257 end;
  1218 
  1258 
  1219 procedure MoveCamera;
  1259 procedure MoveCamera;
  1220 var EdgesDist, wdy, shs,z: LongInt;
  1260 var EdgesDist, wdy, shs,z: LongInt;
  1240         else
  1280         else
  1241             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
  1281             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
  1242         end;
  1282         end;
  1243 
  1283 
  1244 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
  1284 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
  1245 if WorldDy < wdy then WorldDy:= wdy;
  1285 if WorldDy < wdy then
  1246 
  1286     WorldDy:= wdy;
  1247 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit;
  1287 
       
  1288 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then
       
  1289     exit;
  1248 
  1290 
  1249 if AMxShift < AMWidth then
  1291 if AMxShift < AMWidth then
  1250 begin
  1292 begin
  1251 {$IFDEF MOBILE}
  1293 {$IFDEF MOBILE}
  1252     if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth;
  1294     if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth then
  1253     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
  1295         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth;
  1254     if CursorPoint.Y < cScreenHeight - AMyOffset - SlotsNum * AMSlotSize then CursorPoint.Y:= cScreenHeight - AMyOffset - SlotsNum * AMSlotSize;
  1296     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then
  1255     if CursorPoint.Y > cScreenHeight - AMyOffset then CursorPoint.Y:= cScreenHeight - AMyOffset;
  1297         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
       
  1298     if CursorPoint.Y < cScreenHeight - AMyOffset - SlotsNum * AMSlotSize then
       
  1299         CursorPoint.Y:= cScreenHeight - AMyOffset - SlotsNum * AMSlotSize;
       
  1300     if CursorPoint.Y > cScreenHeight - AMyOffset then
       
  1301         CursorPoint.Y:= cScreenHeight - AMyOffset;
  1256 {$ELSE}
  1302 {$ELSE}
  1257     if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize;
  1303     if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize then
  1258     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
  1304         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize;
  1259     if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize;
  1305     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then
  1260     if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize;
  1306         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
       
  1307     if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then
       
  1308         CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize;
       
  1309     if CursorPoint.Y < AMyOffset + AMSlotSize then
       
  1310         CursorPoint.Y:= AMyOffset + AMSlotSize;
  1261 {$ENDIF}
  1311 {$ENDIF}
  1262     prevPoint:= CursorPoint;
  1312     prevPoint:= CursorPoint;
  1263     //if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
  1313     //if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
  1264     exit
  1314     exit
  1265 end;
  1315 end;
  1266 
  1316 
  1267 if isCursorVisible then
  1317 if isCursorVisible then
  1268 begin
  1318     begin
  1269     if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then
  1319     if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then
  1270     begin
  1320         begin
  1271         SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy);
  1321         SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy);
  1272         PrevSentPointTime:= GameTicks
  1322         PrevSentPointTime:= GameTicks
  1273     end;
  1323         end;
  1274     EdgesDist:= cCursorEdgesDist
  1324     EdgesDist:= cCursorEdgesDist
  1275 end
  1325     end
  1276 else
  1326 else
  1277     EdgesDist:= cGearScrEdgesDist;
  1327     EdgesDist:= cGearScrEdgesDist;
  1278 
  1328 
  1279 // this generates the border around the screen that moves the camera when cursor is near it
  1329 // this generates the border around the screen that moves the camera when cursor is near it
  1280 if isCursorVisible or (FollowGear <> nil) then
  1330 if isCursorVisible or (FollowGear <> nil) then
  1281 begin
  1331     begin
  1282     if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then
  1332     if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then
  1283     begin
  1333         begin
  1284         WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist;
  1334         WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist;
  1285         CursorPoint.X:= - cScreenWidth div 2 + EdgesDist
  1335         CursorPoint.X:= - cScreenWidth div 2 + EdgesDist
  1286     end
  1336         end
  1287     else
  1337     else
  1288         if CursorPoint.X > cScreenWidth div 2 - EdgesDist then
  1338         if CursorPoint.X > cScreenWidth div 2 - EdgesDist then
  1289         begin
  1339             begin
  1290             WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist;
  1340             WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist;
  1291             CursorPoint.X:= cScreenWidth div 2 - EdgesDist
  1341             CursorPoint.X:= cScreenWidth div 2 - EdgesDist
  1292         end;
  1342             end;
  1293 
  1343 
  1294     shs:= min(cScreenHeight div 2 - trunc(cScreenHeight / cScaleFactor) + EdgesDist, cScreenHeight - EdgesDist);
  1344     shs:= min(cScreenHeight div 2 - trunc(cScreenHeight / cScaleFactor) + EdgesDist, cScreenHeight - EdgesDist);
  1295     if CursorPoint.Y < shs then
  1345     if CursorPoint.Y < shs then
  1296     begin
  1346         begin
  1297         WorldDy:= WorldDy + CursorPoint.Y - shs;
  1347         WorldDy:= WorldDy + CursorPoint.Y - shs;
  1298         CursorPoint.Y:= shs;
  1348         CursorPoint.Y:= shs;
  1299     end
  1349         end
  1300     else
  1350     else
  1301         if (CursorPoint.Y > cScreenHeight - EdgesDist) then
  1351         if (CursorPoint.Y > cScreenHeight - EdgesDist) then
  1302         begin
  1352             begin
  1303            WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist;
  1353            WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist;
  1304            CursorPoint.Y:= cScreenHeight - EdgesDist
  1354            CursorPoint.Y:= cScreenHeight - EdgesDist
  1305         end;
  1355             end;
  1306 end
  1356     end
  1307 else
  1357 else
  1308     if cHasFocus then
  1358     if cHasFocus then
  1309     begin
  1359         begin
  1310         WorldDx:= WorldDx - CursorPoint.X + prevPoint.X;
  1360         WorldDx:= WorldDx - CursorPoint.X + prevPoint.X;
  1311         WorldDy:= WorldDy + CursorPoint.Y - prevPoint.Y;
  1361         WorldDy:= WorldDy + CursorPoint.Y - prevPoint.Y;
  1312         CursorPoint.X:= 0;
  1362         CursorPoint.X:= 0;
  1313         CursorPoint.Y:= cScreenHeight div 2;
  1363         CursorPoint.Y:= cScreenHeight div 2;
  1314     end;
  1364         end;
  1315 
  1365 
  1316 // this moves the camera according to CursorPoint X and Y
  1366 // this moves the camera according to CursorPoint X and Y
  1317 prevPoint:= CursorPoint;
  1367 prevPoint:= CursorPoint;
  1318 //if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
  1368 //if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
  1319 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
  1369 if WorldDy > LAND_HEIGHT + 1024 then
  1320 if WorldDy < wdy then WorldDy:= wdy;
  1370     WorldDy:= LAND_HEIGHT + 1024;
  1321 if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
  1371 if WorldDy < wdy then
  1322 if WorldDx > 1024 then WorldDx:= 1024;
  1372     WorldDy:= wdy;
       
  1373 if WorldDx < - LAND_WIDTH - 1024 then
       
  1374     WorldDx:= - LAND_WIDTH - 1024;
       
  1375 if WorldDx > 1024 then
       
  1376     WorldDx:= 1024;
  1323 end;
  1377 end;
  1324 
  1378 
  1325 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
  1379 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
  1326 var r: TSDL_Rect;
  1380 var r: TSDL_Rect;
  1327 begin
  1381 begin
  1328 r.w:= 32;
  1382 r.w:= 32;
  1329 r.h:= 32;
  1383 r.h:= 32;
  1330 
  1384 
  1331 if time = 0 then time:= 5000;
  1385 if time = 0 then
       
  1386     time:= 5000;
  1332 missionTimer:= time;
  1387 missionTimer:= time;
  1333 FreeTexture(missionTex);
  1388 FreeTexture(missionTex);
  1334 
  1389 
  1335 if icon > -1 then
  1390 if icon > -1 then
  1336     begin
  1391     begin
  1351     missionTimer:= 0;
  1406     missionTimer:= 0;
  1352 end;
  1407 end;
  1353 
  1408 
  1354 procedure ShakeCamera(amount: LongInt);
  1409 procedure ShakeCamera(amount: LongInt);
  1355 begin
  1410 begin
  1356     if isCursorVisible then exit;
  1411 if isCursorVisible then
  1357     amount:= Max(1, round(amount*zoom/2));
  1412     exit;
  1358     WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2));
  1413 amount:= Max(1, round(amount*zoom/2));
  1359     WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2));
  1414 WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2));
  1360     //CursorPoint.X:= CursorPoint.X - amount + LongInt(random(1 + amount * 2));
  1415 WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2));
  1361     //CursorPoint.Y:= CursorPoint.Y - amount + LongInt(random(1 + amount * 2))
  1416 //CursorPoint.X:= CursorPoint.X - amount + LongInt(random(1 + amount * 2));
       
  1417 //CursorPoint.Y:= CursorPoint.Y - amount + LongInt(random(1 + amount * 2))
  1362 end;
  1418 end;
  1363 
  1419 
  1364 
  1420 
  1365 procedure onFocusStateChanged;
  1421 procedure onFocusStateChanged;
  1366 begin
  1422 begin
  1369 end;
  1425 end;
  1370 
  1426 
  1371 
  1427 
  1372 procedure initModule;
  1428 procedure initModule;
  1373 begin
  1429 begin
  1374     fpsTexture:= nil;
  1430 fpsTexture:= nil;
  1375     FollowGear:= nil;
  1431 FollowGear:= nil;
  1376     WindBarWidth:= 0;
  1432 WindBarWidth:= 0;
  1377     bShowAmmoMenu:= false;
  1433 bShowAmmoMenu:= false;
  1378     bSelected:= false;
  1434 bSelected:= false;
  1379     bShowFinger:= false;
  1435 bShowFinger:= false;
  1380     Frames:= 0;
  1436 Frames:= 0;
  1381     WorldDx:= -512;
  1437 WorldDx:= -512;
  1382     WorldDy:= -256;
  1438 WorldDy:= -256;
  1383 
  1439 
  1384     FPS:= 0;
  1440 FPS:= 0;
  1385     CountTicks:= 0;
  1441 CountTicks:= 0;
  1386     SoundTimerTicks:= 0;
  1442 SoundTimerTicks:= 0;
  1387     prevPoint.X:= 0;
  1443 prevPoint.X:= 0;
  1388     prevPoint.Y:= 0;
  1444 prevPoint.Y:= 0;
  1389     missionTimer:= 0;
  1445 missionTimer:= 0;
  1390     missionTex:= nil;
  1446 missionTex:= nil;
  1391     cOffsetY:= 0;
  1447 cOffsetY:= 0;
  1392     stereoDepth:= 0;
  1448 stereoDepth:= 0;
  1393 end;
  1449 end;
  1394 
  1450 
  1395 procedure freeModule;
  1451 procedure freeModule;
  1396 begin
  1452 begin
  1397     stereoDepth:= stereoDepth; // avoid hint
  1453 stereoDepth:= stereoDepth; // avoid hint
  1398     FreeTexture(fpsTexture);
  1454 FreeTexture(fpsTexture);
  1399     fpsTexture:= nil;
  1455 fpsTexture:= nil;
  1400     FreeTexture(timeTexture);
  1456 FreeTexture(timeTexture);
  1401     timeTexture:= nil;
  1457 timeTexture:= nil;
  1402     FreeTexture(missionTex);
  1458 FreeTexture(missionTex);
  1403     missionTex:= nil
  1459 missionTex:= nil
  1404 end;
  1460 end;
  1405 
  1461 
  1406 end.
  1462 end.