hedgewars/uVariables.pas
branchios-develop
changeset 13413 ba39a1d396c0
parent 13405 4c813650fe17
child 13457 38814954a248
equal deleted inserted replaced
13411:6e8b807bda4b 13413:ba39a1d396c0
    49     cShowFPS           : boolean;
    49     cShowFPS           : boolean;
    50     cFlattenFlakes     : boolean;
    50     cFlattenFlakes     : boolean;
    51     cFlattenClouds     : boolean;
    51     cFlattenClouds     : boolean;
    52     cIce               : boolean;
    52     cIce               : boolean;
    53     cSnow              : boolean;
    53     cSnow              : boolean;
       
    54     isInChatMode       : boolean;
    54 
    55 
    55     cAltDamage         : boolean;
    56     cAltDamage         : boolean;
    56     cReducedQuality    : LongWord;
    57     cReducedQuality    : LongWord;
    57     UserNick           : shortstring;
    58     UserNick           : shortstring;
    58     recordFileName     : shortstring;
    59     recordFileName     : shortstring;
   121 
   122 
   122     cCloudsNumber    : LongWord;
   123     cCloudsNumber    : LongWord;
   123     cSDCloudsNumber  : LongWord;
   124     cSDCloudsNumber  : LongWord;
   124 
   125 
   125     cTagsMask        : byte;
   126     cTagsMask        : byte;
       
   127     cPrevTagsMask    : byte;
   126     zoom             : GLfloat;
   128     zoom             : GLfloat;
   127     ZoomValue        : GLfloat;
   129     ZoomValue        : GLfloat;
   128 
   130 
   129     cWaterLine       : LongInt;
   131     cWaterLine       : LongInt;
   130     cGearScrEdgesDist: LongInt;
   132     cGearScrEdgesDist: LongInt;
   163 
   165 
   164     cScriptName     : shortstring;
   166     cScriptName     : shortstring;
   165     cScriptParam    : shortstring;
   167     cScriptParam    : shortstring;
   166     cSeed           : shortstring;
   168     cSeed           : shortstring;
   167     cVolumeDelta    : LongInt;
   169     cVolumeDelta    : LongInt;
       
   170     cMuteToggle     : boolean; // Mute toggle requested
   168     cHasFocus       : boolean;
   171     cHasFocus       : boolean;
   169     cInactDelay     : Longword;
   172     cInactDelay     : Longword;
   170 
   173 
   171     bBetweenTurns   : boolean;
   174     bBetweenTurns   : boolean;
   172     bWaterRising    : boolean;
   175     bWaterRising    : boolean;
   188     cBuildMaxDist   : LongInt;
   191     cBuildMaxDist   : LongInt;
   189     cDamageModifier : hwFloat;
   192     cDamageModifier : hwFloat;
   190     cLaserSighting  : boolean;
   193     cLaserSighting  : boolean;
   191     cLaserSightingSniper : boolean;
   194     cLaserSightingSniper : boolean;
   192     cVampiric       : boolean;
   195     cVampiric       : boolean;
   193     cArtillery      : boolean;
       
   194     WeaponTooltipTex: PTexture;
   196     WeaponTooltipTex: PTexture;
   195     AmmoMenuInvalidated: boolean;
   197     AmmoMenuInvalidated: boolean;
   196     AmmoRect        : TSDL_Rect;
   198     AmmoRect        : TSDL_Rect;
   197     HHTexture       : PTexture;
   199     HHTexture       : PTexture;
   198     cMaxZoomLevel   : real;
   200     cMaxZoomLevel   : real;
   249     LuaTemplateNumber : LongWord;
   251     LuaTemplateNumber : LongWord;
   250 
   252 
   251     // for EndTurn Lua call
   253     // for EndTurn Lua call
   252     LuaEndTurnRequested: boolean;
   254     LuaEndTurnRequested: boolean;
   253     LuaNoEndTurnTaunts: boolean;
   255     LuaNoEndTurnTaunts: boolean;
       
   256 
       
   257     MaskedSounds : array[TSound] of boolean;
   254 
   258 
   255     LastVoice : TVoice;
   259     LastVoice : TVoice;
   256 
   260 
   257     mobileRecord: TMobileRecord;
   261     mobileRecord: TMobileRecord;
   258 
   262 
   700             // sprNapalmBomb
   704             // sprNapalmBomb
   701             (FileName:  'BulletHit'; Path: ptGraphics; AltPath: ptNone;
   705             (FileName:  'BulletHit'; Path: ptGraphics; AltPath: ptNone;
   702                 Texture: nil; Surface: nil; Width:  32; Height: 32;
   706                 Texture: nil; Surface: nil; Width:  32; Height: 32;
   703                 imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority:
   707                 imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority:
   704                 tpMedium; getDimensions: false; getImageDimensions: true),
   708                 tpMedium; getDimensions: false; getImageDimensions: true),
   705             // sprNapalmBomb
   709             // sprBulletHit
   706             (FileName:  'Snowball'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
   710             (FileName:  'Snowball'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
   707             Width:  16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprSnowball
   711             Width:  16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprSnowball
   708             (FileName:  'amSnowball'; Path: ptCurrTheme; AltPath: ptHedgehog; Texture: nil; Surface: nil;
   712             (FileName:  'amSnowball'; Path: ptCurrTheme; AltPath: ptHedgehog; Texture: nil; Surface: nil;
   709             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprHandSnowball
   713             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprHandSnowball
   710             (FileName:  'Snow'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
   714             (FileName:  'Snow'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
   755             Width:   0; Height:  0; imageWidth: 0; imageHeight: 0; saveSurf: true; critical: true; checkSum: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom6
   759             Width:   0; Height:  0; imageWidth: 0; imageHeight: 0; saveSurf: true; critical: true; checkSum: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom6
   756             (FileName:       'custom7'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
   760             (FileName:       'custom7'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
   757             Width:   0; Height:  0; imageWidth: 0; imageHeight: 0; saveSurf: true; critical: true; checkSum: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom7
   761             Width:   0; Height:  0; imageWidth: 0; imageHeight: 0; saveSurf: true; critical: true; checkSum: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom7
   758             (FileName:       'custom8'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
   762             (FileName:       'custom8'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
   759             Width:   0; Height:  0; imageWidth: 0; imageHeight: 0; saveSurf: true; critical: true; checkSum: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom8
   763             Width:   0; Height:  0; imageWidth: 0; imageHeight: 0; saveSurf: true; critical: true; checkSum: true; priority: tpLow; getDimensions: true; getImageDimensions: true), // sprCustom8
       
   764             (FileName:      'FrozenAirMine'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
       
   765             Width:  32; Height: 32; imageWidth: 32; imageHeight: 32; saveSurf: true; critical: true; checkSum: true; priority: tpHighest; getDimensions: false; getImageDimensions: true), // sprFrozenAirMine
   760             (FileName:      'AirMine'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
   766             (FileName:      'AirMine'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
   761             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpHighest; getDimensions: false; getImageDimensions: true), // sprAirMine
   767             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpHighest; getDimensions: false; getImageDimensions: true), // sprAirMine
   762             (FileName:  'amAirMine'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
   768             (FileName:  'amAirMine'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
   763             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), // sprHandAirMine
   769             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), // sprHandAirMine
   764             (FileName:      'FlakeL'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil;
   770             (FileName:      'FlakeL'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil;
   770             (FileName:     'SDCloudsL'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
   776             (FileName:     'SDCloudsL'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
   771             Width: 256; Height:128; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: false; checkSum: false; priority: tpHigh; getDimensions: false; getImageDimensions: true),// sprSDCloudL
   777             Width: 256; Height:128; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: false; checkSum: false; priority: tpHigh; getDimensions: false; getImageDimensions: true),// sprSDCloudL
   772             (FileName:     'Duck'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
   778             (FileName:     'Duck'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
   773             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprDuck
   779             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprDuck
   774             (FileName:    'amDuck'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
   780             (FileName:    'amDuck'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
   775             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true) // sprHandDuck
   781             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), // sprHandDuck
       
   782             (FileName: 'amMinigun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
       
   783             Width:  64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true) // sprMinigun
   776             );
   784             );
   777 
   785 
   778 const
   786 const
   779     Wavez: array [TWave] of record
   787     Wavez: array [TWave] of record
   780             Sprite: TSprite;
   788             Sprite: TSprite;
  2436             isDamaging: true;
  2444             isDamaging: true;
  2437             SkipTurns: 0;
  2445             SkipTurns: 0;
  2438             PosCount: 1;
  2446             PosCount: 1;
  2439             PosSprite: sprWater;
  2447             PosSprite: sprWater;
  2440             ejectX: 15;
  2448             ejectX: 15;
  2441             ejectY: -7)
  2449             ejectY: -7),
       
  2450 // Minigun
       
  2451             (NameId: sidMinigun;
       
  2452             NameTex: nil;
       
  2453             Probability: 100;
       
  2454             NumberInCase: 1;
       
  2455             Ammo: (Propz: ammoprop_NeedUpDown;
       
  2456                 Count: 1;
       
  2457                 NumPerTurn: 0;
       
  2458                 Timer: 0;
       
  2459                 Pos: 0;
       
  2460                 AmmoType: amMinigun;
       
  2461                 AttackVoice: sndNone;
       
  2462                 Bounciness: 1000);
       
  2463             Slot: 2;
       
  2464             TimeAfterTurn: 3000;
       
  2465             minAngle: cMaxAngle div 6;
       
  2466             maxAngle: 5 * cMaxAngle div 6;
       
  2467             isDamaging: true;
       
  2468             SkipTurns: 0;
       
  2469             PosCount: 1;
       
  2470             PosSprite: sprWater;
       
  2471             ejectX: 0; //23;
       
  2472             ejectY: 0) //-6;
  2442         );
  2473         );
  2443 
  2474 
  2444 var
  2475 var
  2445     Land: TCollisionArray;
  2476     Land: TCollisionArray;
  2446     LandPixels: TLandArray;
  2477     LandPixels: TLandArray;
  2453     lastGearByUID: PGear;
  2484     lastGearByUID: PGear;
  2454     GearsList: PGear;
  2485     GearsList: PGear;
  2455     AllInactive: boolean;
  2486     AllInactive: boolean;
  2456     PrvInactive: boolean;
  2487     PrvInactive: boolean;
  2457     KilledHHs: Longword;
  2488     KilledHHs: Longword;
  2458     SuddenDeath: Boolean;
  2489     SuddenDeath: Boolean; // If the Sudden Death check has been made
  2459     SuddenDeathDmg: Boolean;
  2490     SuddenDeathActive: Boolean; // Is in Sudden Death with any gameplay effect
       
  2491     SuddenDeathDmg: Boolean; // Is in Sudden Death with damage
  2460     SpeechType: Longword;
  2492     SpeechType: Longword;
  2461     SpeechText: shortstring;
  2493     SpeechText: shortstring;
  2462     PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress
  2494     PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress
  2463     StepSoundTimer: LongInt;
  2495     StepSoundTimer: LongInt;
  2464     StepSoundChannel: LongInt;
  2496     StepSoundChannel: LongInt;
  2465 
  2497 
  2466     CurrentTeam: PTeam;
  2498     CurrentTeam: PTeam;
  2467     PreviousTeam: PTeam;
  2499     PreviousTeam: PTeam;
  2468     CurrentHedgehog: PHedgehog;
  2500     CurrentHedgehog: PHedgehog;
  2469     TeamsArray: array[0..Pred(cMaxTeams)] of PTeam;
  2501     TeamsArray: array[0..Pred(cMaxTeams)] of PTeam;
  2470     TeamsCount: Longword;
  2502     TeamsCount: Longword; // number of teams on game start
       
  2503     VisibleTeamsCount: Longword; // number of teams visible in team bar
  2471     ClansArray, SpawnClansArray: TClansArray;
  2504     ClansArray, SpawnClansArray: TClansArray;
  2472     ClansCount: Longword;
  2505     ClansCount: Longword;
  2473     LocalClan: LongInt;  // last non-bot, non-extdriven clan
  2506     LocalClan: LongInt;  // last non-bot, non-extdriven clan
  2474     LocalTeam: LongInt;  // last non-bot, non-extdriven clan first team
  2507     LocalTeam: LongInt;  // last non-bot, non-extdriven clan first team
  2475     LocalAmmo: LongInt;  // last non-bot, non-extdriven clan's first team's ammo index, updated to next upcoming hog for per-hog-ammo
  2508     LocalAmmo: LongInt;  // last non-bot, non-extdriven clan's first team's ammo index, updated to next upcoming hog for per-hog-ammo
  2544     trammod: array[TAmmoStrId] of ansistring;   // description of the weapon
  2577     trammod: array[TAmmoStrId] of ansistring;   // description of the weapon
  2545     trluaammo: array[TAmmoStrId] of ansistring; // name of the weapon (Lua overwrite)
  2578     trluaammo: array[TAmmoStrId] of ansistring; // name of the weapon (Lua overwrite)
  2546     trluaammoc: array[TAmmoStrId] of ansistring; // caption of the weapon (Lua overwrite)
  2579     trluaammoc: array[TAmmoStrId] of ansistring; // caption of the weapon (Lua overwrite)
  2547     trluaammod: array[TAmmoStrId] of ansistring;  // description of the weapon (Lua overwrite)
  2580     trluaammod: array[TAmmoStrId] of ansistring;  // description of the weapon (Lua overwrite)
  2548     trluaammoa: array[TAmmoStrId] of ansistring; // description appendix of the weapon (Lua only)
  2581     trluaammoa: array[TAmmoStrId] of ansistring; // description appendix of the weapon (Lua only)
       
  2582     trluaammoe: array[TAmmoStrId] of boolean;   // whether to render extra text (Lua overwrite)
  2549     trmsg:   array[TMsgStrId]  of ansistring;   // message of the event
  2583     trmsg:   array[TMsgStrId]  of ansistring;   // message of the event
  2550     trgoal:  array[TGoalStrId] of ansistring;   // message of the goal
  2584     trgoal:  array[TGoalStrId] of ansistring;   // message of the goal
  2551     cTestLua : Boolean;
  2585     cTestLua : Boolean;
  2552 
  2586 
  2553 procedure preInitModule;
  2587 procedure preInitModule;
  2596     cVideoQuality      := 0;
  2630     cVideoQuality      := 0;
  2597     cAudioCodec        := '';
  2631     cAudioCodec        := '';
  2598 {$ENDIF}
  2632 {$ENDIF}
  2599 
  2633 
  2600     cTagsMask:= htTeamName or htName or htHealth;
  2634     cTagsMask:= htTeamName or htName or htHealth;
       
  2635     cPrevTagsMask:= cTagsMask;
  2601 end;
  2636 end;
  2602 
  2637 
  2603 procedure initScreenSpaceVars();
  2638 procedure initScreenSpaceVars();
  2604 begin
  2639 begin
  2605     // those values still are not perfect
  2640     // those values still are not perfect
  2609 end;
  2644 end;
  2610 
  2645 
  2611 procedure initModule;
  2646 procedure initModule;
  2612 var s: shortstring;
  2647 var s: shortstring;
  2613     i: integer;
  2648     i: integer;
       
  2649     t: TSound;
       
  2650     a: TAmmoStrId;
  2614 begin
  2651 begin
  2615     // init LastVoice
  2652     // init LastVoice
  2616     LastVoice.snd:= sndNone;
  2653     LastVoice.snd:= sndNone;
  2617     LastVoice.voicepack:= nil;
  2654     LastVoice.voicepack:= nil;
  2618 
  2655 
  2631     cIce                := false;
  2668     cIce                := false;
  2632     cSnow               := false;
  2669     cSnow               := false;
  2633     lastVisualGearByUID := nil;
  2670     lastVisualGearByUID := nil;
  2634     lastGearByUID       := nil;
  2671     lastGearByUID       := nil;
  2635     cReadyDelay         := 5000;
  2672     cReadyDelay         := 5000;
       
  2673     isInChatMode        := false;
  2636 
  2674 
  2637         {*  REFERENCE
  2675         {*  REFERENCE
  2638       4096 -> $FFFFF000
  2676       4096 -> $FFFFF000
  2639       2048 -> $FFFFF800
  2677       2048 -> $FFFFF800
  2640       1024 -> $FFFFFC00
  2678       1024 -> $FFFFFC00
  2729     cZoomDelta:= 0.20;
  2767     cZoomDelta:= 0.20;
  2730 {$ELSE}
  2768 {$ELSE}
  2731     cMaxZoomLevel:= 1.0;
  2769     cMaxZoomLevel:= 1.0;
  2732     cMinZoomLevel:= 3.0;
  2770     cMinZoomLevel:= 3.0;
  2733     cZoomDelta:= 0.25;
  2771     cZoomDelta:= 0.25;
  2734 {$ENDIF}
  2772     {$ENDIF}
       
  2773 
       
  2774     aVertex:= 0;
       
  2775     aTexCoord:= 1;
       
  2776     aColor:= 2;
       
  2777 
  2735 
  2778 
  2736     cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel;
  2779     cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel;
  2737 
  2780 
  2738     // int, longint longword and byte
  2781     // int, longint longword and byte
  2739     CursorMovementX     := 0;
  2782     CursorMovementX     := 0;
  2785     ZoomValue       := cDefaultZoomLevel;
  2828     ZoomValue       := cDefaultZoomLevel;
  2786     WeaponTooltipTex:= nil;
  2829     WeaponTooltipTex:= nil;
  2787     cLaserSighting  := false;
  2830     cLaserSighting  := false;
  2788     cLaserSightingSniper := false;
  2831     cLaserSightingSniper := false;
  2789     cVampiric       := false;
  2832     cVampiric       := false;
  2790     cArtillery      := false;
       
  2791     flagMakeCapture := false;
  2833     flagMakeCapture := false;
  2792     flagDumpLand    := false;
  2834     flagDumpLand    := false;
  2793     bBetweenTurns   := false;
  2835     bBetweenTurns   := false;
  2794     bWaterRising    := false;
  2836     bWaterRising    := false;
  2795     isCursorVisible := false;
  2837     isCursorVisible := false;
  2802     fastUntilLag    := false;
  2844     fastUntilLag    := false;
  2803     fastScrolling   := false;
  2845     fastScrolling   := false;
  2804     autoCameraOn    := true;
  2846     autoCameraOn    := true;
  2805     cSeed           := '';
  2847     cSeed           := '';
  2806     cVolumeDelta    := 0;
  2848     cVolumeDelta    := 0;
       
  2849     cMuteToggle     := false;
  2807     cHasFocus       := true;
  2850     cHasFocus       := true;
  2808     cInactDelay     := 100;
  2851     cInactDelay     := 100;
  2809     ReadyTimeLeft   := 0;
  2852     ReadyTimeLeft   := 0;
  2810 
  2853 
  2811     disableLandBack := false;
  2854     disableLandBack := false;
  2863 
  2906 
  2864     LuaTemplateNumber:= 0;
  2907     LuaTemplateNumber:= 0;
  2865 
  2908 
  2866     LuaEndTurnRequested:= false;
  2909     LuaEndTurnRequested:= false;
  2867     LuaNoEndTurnTaunts:= false;
  2910     LuaNoEndTurnTaunts:= false;
       
  2911 
       
  2912     for t:= Low(TSound) to High(TSound) do
       
  2913         MaskedSounds[t]:= false;
       
  2914 
       
  2915     for a:= Low(TAmmoStrId) to High(TAmmoStrId) do
       
  2916         trluaammoe[a]:= true;
  2868 
  2917 
  2869     UIDisplay:= uiAll;
  2918     UIDisplay:= uiAll;
  2870     LocalMessage:= 0;
  2919     LocalMessage:= 0;
  2871 
  2920 
  2872     cStereoDepth:= 0;
  2921     cStereoDepth:= 0;