DEADSOFTWARE

net: tried to spawn a "real" player only after it requested the first full state...
[d2df-sdl.git] / src / game / g_player.pas
index d6914b1c6fd40425ca90bfcfe7e3434e514ba162..cc6afb07be47661fa320584d0d6ecb2f80f5df1e 100644 (file)
@@ -268,6 +268,7 @@ type
     FDummy:     Boolean;
     FFireTime:  Integer;
     FHandicap:  Integer;
+    FWaitForFirstSpawn: Boolean; // set to `true` in server, used to spawn a player on first full state request
 
     // debug: viewport offset
     viewPortX, viewPortY, viewPortW, viewPortH: Integer;
@@ -555,7 +556,8 @@ var
   gFly: Boolean = False;
   gAimLine: Boolean = False;
   gChatBubble: Byte = 0;
-  gPlayerIndicator: Byte = 1;
+  gPlayerIndicator: Integer = 1;
+  gPlayerIndicatorStyle: Integer = 0;
   gNumBots: Word = 0;
   gLMSPID1: Word = 0;
   gLMSPID2: Word = 0;
@@ -2177,6 +2179,8 @@ begin
   FJustTeleported := False;
   FNetTime := 0;
 
+  FWaitForFirstSpawn := false;
+
   resetWeaponQueue();
 end;
 
@@ -2331,24 +2335,68 @@ procedure TPlayer.DrawIndicator(Color: TRGB);
 var
   indX, indY: Integer;
   indW, indH: Word;
+  indA: Single;
+  a: TDFPoint;
+  nW, nH: Byte;
   ID: DWORD;
   c: TRGB;
 begin
   if FAlive then
-  begin
-    if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
-    begin
-      e_GetTextureSize(ID, @indW, @indH);
-      indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2;
-      indY := FObj.Y;
-
-      c := e_Colors;
-      e_Colors := Color;
-      e_Draw(ID, indX, indY - indH, 0, True, False);
-      e_Colors := c;
+    case gPlayerIndicatorStyle of
+      0:
+        begin
+          if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
+          begin
+            e_GetTextureSize(ID, @indW, @indH);
+            a.X := indW div 2;
+            a.Y := indH div 2;
+
+            if (FObj.X + FObj.Rect.X) < 0 then
+            begin
+              indA := 90;
+              indX := FObj.X + FObj.Rect.X + FObj.Rect.Width;
+              indY := FObj.Y + FObj.Rect.Y + (FObj.Rect.Height - indW) div 2;
+            end
+
+            else if (FObj.X + FObj.Rect.X + FObj.Rect.Width) > Max(gMapInfo.Width, gPlayerScreenSize.X) then
+            begin
+              indA := 270;
+              indX := FObj.X + FObj.Rect.X - indH;
+              indY := FObj.Y + FObj.Rect.Y + (FObj.Rect.Height - indW) div 2;
+            end
+
+            else if (fObj.Y - indH) < 0 then
+            begin
+              indA := 180;
+              indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2;
+              indY := FObj.Y + FObj.Rect.Y + FObj.Rect.Height;
+            end
+
+            else
+            begin
+              indA := 0;
+              indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2;
+              indY := FObj.Y - indH;
+            end;
+
+            indX := EnsureRange(indX, 0, Max(gMapInfo.Width, gPlayerScreenSize.X) - indW);
+            indY := EnsureRange(indY, 0, Max(gMapInfo.Height, gPlayerScreenSize.Y) - indH);
+
+            c := e_Colors;
+            e_Colors := Color;
+            e_DrawAdv(ID, indX, indY, 0, True, False, indA, @a);
+            e_Colors := c;
+          end;
+        end;
+
+      1:
+        begin
+          e_TextureFontGetSize(gStdFont, nW, nH);
+          indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - Length(FName) * nW) div 2;
+          indY := FObj.Y - nH;
+          e_TextureFontPrintEx(indX, indY, FName, gStdFont, Color.R, Color.G, Color.B, 1.0, True);
+        end;
     end;
-  end;
-  //e_TextureFontPrintEx(indX, indY, FName, gStdFont, 0, 0, 255, 1.0, true); // Shows player name overhead
 end;
 
 procedure TPlayer.DrawBubble();
@@ -7898,4 +7946,6 @@ end;
 
 begin
   conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '',  true, true);
+  conRegVar('player_indicator', @gPlayerIndicator, 'Draw indicator only for current player, also for teammates, or not at all', 'Draw indicator only for current player, also for teammates, or not at all');
+  conRegVar('player_indicator_style', @gPlayerIndicatorStyle, 'Visual appearance of indicator', 'Visual appearance of indicator');
 end.