diff -r fcbdee9cdd74 -r b894922d58cc hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Tue Sep 08 19:20:58 2015 +0300 +++ b/hedgewars/uVariables.pas Mon Nov 16 22:57:24 2015 +0300 @@ -21,7 +21,7 @@ unit uVariables; interface -uses SDLh, uTypes, uFloat, GLunit, uConsts, Math, uUtils, uMatrix; +uses SDLh, uTypes, uFloat, GLunit, uConsts, Math, uUtils{$IFDEF GL2}, uMatrix{$ENDIF}; var /////// init flags /////// @@ -235,14 +235,12 @@ LuaTemplateNumber : LongWord; - LastVoice : TVoice = ( snd: sndNone; voicepack: nil ); + LastVoice : TVoice; mobileRecord: TMobileRecord; MaxTextureSize: LongInt; - ChatPasteBuffer: shortstring; - ///////////////////////////////////// //Buttons {$IFDEF USE_TOUCH_INTERFACE} @@ -256,7 +254,10 @@ var // these consts are here because they would cause circular dependencies in uConsts/uTypes - cPathz: array[TPathType] of shortstring = ( + cPathz: array[TPathType] of shortstring; + +const + cPathzInit: array[TPathType] of shortstring = ( '', // ptNone '/', // ptData '/Graphics', // ptGraphics @@ -284,7 +285,10 @@ ); var - Fontz: array[THWFont] of THHFont = ( + Fontz: array[THWFont] of THHFont; + +const + FontzInit: array[THWFont] of THHFont = ( (Handle: nil; Height: 12; style: TTF_STYLE_NORMAL; @@ -314,7 +318,10 @@ ); var - SpritesData: array[TSprite] of TSpriteData = ( + SpritesData: array[TSprite] of TSpriteData; + +const + SpritesDataInit: array[TSprite] of TSpriteData = ( (FileName: 'BlueWater'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: true; getImageDimensions: true),// sprWater (FileName: 'Clouds'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; @@ -416,13 +423,13 @@ {$IFDEF USE_TOUCH_INTERFACE} (FileName: 'firebutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprFireButton - (FileName: 'arrowUp'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + (FileName: 'arrowup'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowUp - (FileName: 'arrowDown'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + (FileName: 'arrowdown'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowDown - (FileName: 'arrowLeft'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + (FileName: 'arrowleft'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowLeft - (FileName: 'arrowRight'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + (FileName: 'arrowright'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowRight (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprAMWidget @@ -430,10 +437,12 @@ Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprJumpWidget (FileName: 'pause'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; Width: 120; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprPauseButton - (FileName: 'pause'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;//TODO correct image - Width: 120; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTimerButton - (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;//TODO correct image - Width: 120; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTargetButton + (FileName: 'timerbutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTimerButton + (FileName: 'targetbutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTargetButton + (FileName: 'switchbutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprSwitchButton {$ENDIF} (FileName: 'Flake'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil; Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprFlake @@ -711,7 +720,9 @@ (FileName: 'custom2'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom2 (FileName: 'AirMine'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true)// sprAirMine + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true), // sprAirMine + (FileName: 'amAirMine'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true) // sprHandAirMine ); const @@ -732,8 +743,8 @@ (Sprite: sprJuggle; FramesCount: 49; Interval: 38; cmd: '/juggle'; Voice: sndNone; VoiceDelay: 0) ); -var - Ammoz: array [TAmmoType] of record +type + TAmmozRec = record NameId: TAmmoStrId; NameTex: PTexture; Probability, NumberInCase: Longword; @@ -746,7 +757,13 @@ PosCount: Longword; PosSprite: TSprite; ejectX, ejectY: Longint; - end = ( + end; + +var + Ammoz: array [TAmmoType] of TAmmozRec; + +const + AmmozInit: array [TAmmoType] of TAmmozRec = ( (NameId: sidNothing; NameTex: nil; Probability: 0; @@ -1344,7 +1361,7 @@ NameTex: nil; Probability: 100; NumberInCase: 4; - Ammo: (Propz: 0; + Ammo: (Propz: ammoprop_NeedUpDown; Count: 4; NumPerTurn: 0; Timer: 0; @@ -2135,6 +2152,7 @@ NumberInCase: 1; Ammo: (Propz: ammoprop_Power or ammoprop_AltUse or + ammoprop_NeedUpDown or ammoprop_NoRoundEnd; Count: 2; NumPerTurn: 0; @@ -2216,6 +2234,7 @@ Probability: 20; NumberInCase: 1; Ammo: (Propz: ammoprop_NoRoundEnd or + ammoprop_NeedUpDown or ammoprop_Utility; Count: 1; NumPerTurn: 0; @@ -2488,7 +2507,19 @@ procedure initModule; var s: shortstring; + i: integer; begin + // init LastVoice + LastVoice.snd:= sndNone; + LastVoice.voicepack:= nil; + + // init arrays + Move(cPathzInit, cPathz, sizeof(cPathz)); + Move(FontzInit, Fontz, sizeof(Fontz)); + Move(SpritesDataInit, SpritesData, sizeof(SpritesData)); + Move(AmmozInit, Ammoz, sizeof(Ammoz)); + + cLocale:= cLocaleFName; SplitByChar(cLocale, s, '.'); @@ -2669,8 +2700,13 @@ vobSDVelocity:= 15; vobSDFallSpeed:= 250; +{$IFDEF MOBILE} + cMinScreenWidth := min(cScreenWidth, 480); + cMinScreenHeight := min(cScreenHeight, 320); +{$ELSE} cMinScreenWidth := min(cScreenWidth, 640); cMinScreenHeight := min(cScreenHeight, 480); +{$ENDIF} cNewScreenWidth := cScreenWidth; cNewScreenHeight := cScreenHeight; @@ -2696,7 +2732,42 @@ cViewLimitsDebug:= false; 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;