make uVariables not depend on implicit one-time initialization by FPC
authorsheepluva
Fri, 11 Sep 2015 05:54:17 +0200
changeset 11154 1d08386a7c0f
parent 11152 3ac7f6d43200
child 11155 a10143c3d87d
make uVariables not depend on implicit one-time initialization by FPC
hedgewars/uVariables.pas
--- a/hedgewars/uVariables.pas	Thu Sep 10 18:50:39 2015 +0200
+++ b/hedgewars/uVariables.pas	Fri Sep 11 05:54:17 2015 +0200
@@ -2493,6 +2493,7 @@
 
 procedure initModule;
 var s: shortstring;
+    i: integer;
 begin
     cLocale:= cLocaleFName;
     SplitByChar(cLocale, s, '.');
@@ -2707,6 +2708,43 @@
     AprilOne := false;
 
     ChatPasteBuffer:= '';
+
+    // initialize pointers to nil
+    // (don't rely on implicit init of fpc, because that one only happens ONCE when used as lib)
+    CurAmmoGear:= nil;
+    lastGearByUID:= nil;
+    GearsList:= nil;
+    CurrentTeam:= nil;
+    PreviousTeam:= nil;
+    CurrentHedgehog:= nil;
+    FollowGear:= nil;
+    lastVisualGearByUID:= nil;
+
+    ChefHatTexture:= nil;
+    CrosshairTexture:= nil;
+    GenericHealthTexture:= nil;
+    WeaponTooltipTex:= nil;
+    HHTexture:= nil;
+    LandBackSurface:= nil;
+    ConfirmTexture:= nil;
+    MissionIcons:= nil;
+    ropeIconTex:= nil;
+
+    for i:= Low(ClansArray) to High(ClansArray) do
+        begin
+        ClansArray[i]:= nil;
+        end;
+
+    for i:= Low(TeamsArray) to High(TeamsArray) do
+        begin
+        TeamsArray[i]:= nil;
+        end;
+
+    for i:= Low(CountTexz) to High(CountTexz) do
+        begin
+        CountTexz[i]:= nil;
+        end;
+
 end;
 
 procedure freeModule;