21 unit uMisc; |
21 unit uMisc; |
22 interface |
22 interface |
23 |
23 |
24 uses SDLh, uConsts, uFloat, GLunit, Math, uTypes; |
24 uses SDLh, uConsts, uFloat, GLunit, Math, uTypes; |
25 |
25 |
26 var |
26 |
27 /////// init flags /////// |
|
28 cScreenWidth : LongInt = 1024; |
|
29 cScreenHeight : LongInt = 768; |
|
30 cBits : LongInt = 32; |
|
31 //ipcPort is in uIO |
|
32 cFullScreen : boolean = false; |
|
33 isSoundEnabled : boolean = true; |
|
34 isMusicEnabled : boolean = false; |
|
35 cLocaleFName : shortstring = 'en.txt'; |
|
36 cInitVolume : LongInt = 100; |
|
37 cTimerInterval : LongInt = 8; |
|
38 PathPrefix : shortstring = './'; |
|
39 cShowFPS : boolean = false; |
|
40 cAltDamage : boolean = true; |
|
41 cReducedQuality : LongWord = rqNone; |
|
42 //userNick is in uChat |
|
43 recordFileName : shortstring = ''; |
|
44 cReadyDelay : Longword = 0; |
|
45 cLogfileBase : shortstring = 'debug'; |
|
46 ////////////////////////// |
|
47 |
|
48 isCursorVisible : boolean; |
|
49 isTerminated : boolean; |
|
50 isInLag : boolean; |
|
51 isPaused : boolean; |
|
52 |
|
53 isSEBackup : boolean; |
|
54 isInMultiShoot : boolean; |
|
55 isSpeed : boolean; |
|
56 isFirstFrame : boolean; |
|
57 |
|
58 fastUntilLag : boolean; |
|
59 |
|
60 GameState : TGameState; |
|
61 GameType : TGameType; |
|
62 GameFlags : Longword; |
|
63 TrainingFlags : Longword; |
|
64 TurnTimeLeft : Longword; |
|
65 ReadyTimeLeft : Longword; |
|
66 cSuddenDTurns : LongInt; |
|
67 cDamagePercent : LongInt; |
|
68 cMineDudPercent : LongWord; |
|
69 cTemplateFilter : LongInt; |
|
70 cMapGen : LongInt; |
|
71 cMazeSize : LongInt; |
|
72 |
|
73 cHedgehogTurnTime: Longword; |
|
74 cMinesTime : LongInt; |
|
75 cMaxAIThinkTime : Longword; |
|
76 |
|
77 cHealthCaseProb : LongInt; |
|
78 cHealthCaseAmount: LongInt; |
|
79 cWaterRise : LongInt; |
|
80 cHealthDecrease : LongInt; |
|
81 |
|
82 cCloudsNumber : LongInt; |
|
83 |
|
84 cTagsMask : byte; |
|
85 zoom : GLfloat; |
|
86 ZoomValue : GLfloat; |
|
87 |
|
88 cWaterLine : LongInt; |
|
89 cGearScrEdgesDist: LongInt; |
|
90 |
|
91 GameTicks : LongWord; |
|
92 TrainingTimeInc : Longword; |
|
93 TrainingTimeInD : Longword; |
|
94 TrainingTimeInM : Longword; |
|
95 TrainingTimeMax : Longword; |
|
96 |
|
97 TimeTrialStartTime: Longword; |
|
98 TimeTrialStopTime : Longword; |
|
99 |
|
100 // originally from uConsts |
|
101 Pathz: array[TPathType] of shortstring; |
|
102 CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture; |
|
103 LAND_WIDTH : LongInt; |
|
104 LAND_HEIGHT : LongInt; |
|
105 LAND_WIDTH_MASK : LongWord; |
|
106 LAND_HEIGHT_MASK : LongWord; |
|
107 cMaxCaptions : LongInt; |
|
108 |
|
109 cLeftScreenBorder : LongInt; |
|
110 cRightScreenBorder : LongInt; |
|
111 cScreenSpace : LongInt; |
|
112 |
|
113 cCaseFactor : Longword; |
|
114 cLandMines : Longword; |
|
115 cExplosives : Longword; |
|
116 |
|
117 cSeed : shortstring; |
|
118 cVolumeDelta : LongInt; |
|
119 cHasFocus : boolean; |
|
120 cInactDelay : Longword; |
|
121 |
|
122 bBetweenTurns : boolean; |
|
123 bWaterRising : boolean; |
|
124 |
|
125 ShowCrosshair : boolean; |
|
126 CursorMovementX : LongInt; |
|
127 CursorMovementY : LongInt; |
|
128 cDrownSpeed : hwFloat; |
|
129 cDrownSpeedf : float; |
|
130 cMaxWindSpeed : hwFloat; |
|
131 cWindSpeed : hwFloat; |
|
132 cWindSpeedf : float; |
|
133 cGravity : hwFloat; |
|
134 cGravityf : float; |
|
135 cDamageModifier : hwFloat; |
|
136 cLaserSighting : boolean; |
|
137 cVampiric : boolean; |
|
138 cArtillery : boolean; |
|
139 WeaponTooltipTex : PTexture; |
|
140 |
|
141 flagMakeCapture : boolean; |
|
142 |
|
143 InitStepsFlags : Longword; |
|
144 RealTicks : Longword; |
|
145 AttackBar : LongInt; |
|
146 |
|
147 WaterColorArray : array[0..3] of HwColor4f; |
|
148 |
|
149 CursorPoint : TPoint; |
|
150 TargetPoint : TPoint; |
|
151 |
|
152 TextureList : PTexture; |
|
153 |
|
154 ScreenFade : TScreenFade; |
|
155 ScreenFadeValue : LongInt; |
|
156 ScreenFadeSpeed : LongInt; |
|
157 |
|
158 {$IFDEF SDL13} |
|
159 SDLwindow : PSDL_Window; |
|
160 {$ENDIF} |
|
161 |
|
162 procedure initModule; |
|
163 procedure freeModule; |
|
164 procedure SplitBySpace(var a, b: shortstring); |
27 procedure SplitBySpace(var a, b: shortstring); |
165 procedure SplitByChar(var a, b: ansistring; c: char); |
28 procedure SplitByChar(var a, b: ansistring; c: char); |
166 function EnumToStr(const en : TGearType) : shortstring; overload; |
29 function EnumToStr(const en : TGearType) : shortstring; overload; |
167 function EnumToStr(const en : TSound) : shortstring; overload; |
30 function EnumToStr(const en : TSound) : shortstring; overload; |
168 function EnumToStr(const en : TAmmoType) : shortstring; overload; |
31 function EnumToStr(const en : TAmmoType) : shortstring; overload; |
701 |
565 |
702 |
566 |
703 procedure initModule; |
567 procedure initModule; |
704 {$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF} |
568 {$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF} |
705 begin |
569 begin |
706 Pathz:= cPathz; |
|
707 {* REFERENCE |
|
708 4096 -> $FFFFF000 |
|
709 2048 -> $FFFFF800 |
|
710 1024 -> $FFFFFC00 |
|
711 512 -> $FFFFFE00 *} |
|
712 if (cReducedQuality and rqLowRes) <> 0 then |
|
713 begin |
|
714 LAND_WIDTH:= 2048; |
|
715 LAND_HEIGHT:= 1024; |
|
716 LAND_WIDTH_MASK:= $FFFFF800; |
|
717 LAND_HEIGHT_MASK:= $FFFFFC00; |
|
718 end |
|
719 else |
|
720 begin |
|
721 LAND_WIDTH:= 4096; |
|
722 LAND_HEIGHT:= 2048; |
|
723 LAND_WIDTH_MASK:= $FFFFF000; |
|
724 LAND_HEIGHT_MASK:= $FFFFF800 |
|
725 end; |
|
726 |
|
727 cDrownSpeed.QWordValue := 257698038; // 0.06 |
|
728 cDrownSpeedf := 0.06; |
|
729 cMaxWindSpeed.QWordValue:= 1073742; // 0.00025 |
|
730 cWindSpeed.QWordValue := 429496; // 0.0001 |
|
731 cWindSpeedf := 0.0001; |
|
732 cGravity := cMaxWindSpeed * 2; |
|
733 cGravityf := 0.00025 * 2; |
|
734 cDamageModifier := _1; |
|
735 TargetPoint := cTargetPointRef; |
|
736 TextureList := nil; |
|
737 |
|
738 // int, longint longword and byte |
|
739 CursorMovementX := 0; |
|
740 CursorMovementY := 0; |
|
741 GameTicks := 0; |
|
742 TrainingTimeInc := 10000; |
|
743 TrainingTimeInD := 500; |
|
744 TrainingTimeInM := 5000; |
|
745 TrainingTimeMax := 60000; |
|
746 TimeTrialStartTime := 0; |
|
747 TimeTrialStopTime := 0; |
|
748 cWaterLine := LAND_HEIGHT; |
|
749 cGearScrEdgesDist := 240; |
|
750 |
|
751 GameFlags := 0; |
|
752 TrainingFlags := 0; |
|
753 TurnTimeLeft := 0; |
|
754 cSuddenDTurns := 15; |
|
755 cDamagePercent := 100; |
|
756 cMineDudPercent := 0; |
|
757 cTemplateFilter := 0; |
|
758 cMapGen := 0; // MAPGEN_REGULAR |
|
759 cMazeSize := 0; |
|
760 cHedgehogTurnTime := 45000; |
|
761 cMinesTime := 3; |
|
762 cMaxAIThinkTime := 9000; |
|
763 cCloudsNumber := 9; |
|
764 cHealthCaseProb := 35; |
|
765 cHealthCaseAmount := 25; |
|
766 cWaterRise := 47; |
|
767 cHealthDecrease := 5; |
|
768 |
|
769 cTagsMask := 0; |
|
770 KBnum := 0; |
570 KBnum := 0; |
771 InitStepsFlags := 0; |
|
772 RealTicks := 0; |
|
773 AttackBar := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - from weapon |
|
774 cCaseFactor := 5; {0..9} |
|
775 cLandMines := 4; |
|
776 cExplosives := 2; |
|
777 |
|
778 GameState := Low(TGameState); |
|
779 GameType := gmtLocal; |
|
780 zoom := cDefaultZoomLevel; |
|
781 ZoomValue := cDefaultZoomLevel; |
|
782 WeaponTooltipTex:= nil; |
|
783 cLaserSighting := false; |
|
784 cVampiric := false; |
|
785 cArtillery := false; |
|
786 flagMakeCapture := false; |
|
787 bBetweenTurns := false; |
|
788 bWaterRising := false; |
|
789 isCursorVisible := false; |
|
790 isTerminated := false; |
|
791 isInLag := false; |
|
792 isPaused := false; |
|
793 isInMultiShoot := false; |
|
794 isSpeed := false; |
|
795 fastUntilLag := false; |
|
796 isFirstFrame := true; |
|
797 isSEBackup := true; |
|
798 cSeed := ''; |
|
799 cVolumeDelta := 0; |
|
800 cHasFocus := true; |
|
801 cInactDelay := 1250; |
|
802 ReadyTimeLeft := 0; |
|
803 |
|
804 ScreenFade := sfNone; |
|
805 |
|
806 {$IFDEF SDL13} |
|
807 SDLwindow := nil; |
|
808 {$ENDIF} |
|
809 |
|
810 // those values still aren't perfect |
|
811 cLeftScreenBorder:= round(-cMinZoomLevel * cScreenWidth); |
|
812 cRightScreenBorder:= round(cMinZoomLevel * cScreenWidth + LAND_WIDTH); |
|
813 cScreenSpace:= cRightScreenBorder - cLeftScreenBorder; |
|
814 |
|
815 if isPhone() then |
|
816 cMaxCaptions:= 3 |
|
817 else |
|
818 cMaxCaptions:= 4; |
|
819 |
571 |
820 {$IFDEF DEBUGFILE} |
572 {$IFDEF DEBUGFILE} |
821 {$I-} |
573 {$I-} |
822 {$IFDEF IPHONEOS} |
574 {$IFDEF IPHONEOS} |
823 Assign(f,'../Documents/hw-' + cLogfileBase + '.log'); |
575 Assign(f,'../Documents/hw-' + cLogfileBase + '.log'); |