55 cWaterColor : Longword = $005ACE; |
55 cWaterColor : Longword = $005ACE; |
56 cWhiteColor : Longword = $FFFFFF; |
56 cWhiteColor : Longword = $FFFFFF; |
57 cConsoleSplitterColor : Longword = $FF0000; |
57 cConsoleSplitterColor : Longword = $FF0000; |
58 cColorNearBlack : Longword = 16; |
58 cColorNearBlack : Longword = 16; |
59 cExplosionBorderColor : LongWord = $808080; |
59 cExplosionBorderColor : LongWord = $808080; |
60 |
|
61 cDrownSpeed : Double = 0.06; |
|
62 cMaxWindSpeed : Double = 0.0005; |
|
63 cWindSpeed : Double = 0.0001; |
|
64 cGravity : Double = 0.0005; |
|
65 |
60 |
66 cShowFPS : boolean = true; |
61 cShowFPS : boolean = true; |
67 cCaseFactor : Longword = 3; {1..10} |
62 cCaseFactor : Longword = 3; {1..10} |
68 cFullScreen : boolean = true; |
63 cFullScreen : boolean = true; |
69 cLocaleFName : shortstring = 'en.txt'; |
64 cLocaleFName : shortstring = 'en.txt'; |
70 cSeed : shortstring = ''; |
65 cSeed : shortstring = ''; |
71 cInitVolume : integer = 128; |
66 cInitVolume : integer = 128; |
72 cVolumeDelta : integer = 0; |
67 cVolumeDelta : integer = 0; |
73 cTimerInterval : Longword = 5; |
68 cTimerInterval : Longword = 5; |
74 cHasFocus : boolean = true; |
69 cHasFocus : boolean = true; |
75 |
70 |
76 var |
71 var |
77 cSendEmptyPacketTime : LongWord = 2000; |
72 cSendEmptyPacketTime : LongWord = 2000; |
78 cSendCursorPosTime : LongWord = 50; |
73 cSendCursorPosTime : LongWord = 50; |
79 ShowCrosshair : boolean; |
74 ShowCrosshair : boolean; |
|
75 cDrownSpeed, |
|
76 cMaxWindSpeed, |
|
77 cWindSpeed, |
|
78 cGravity: hwFloat; |
80 |
79 |
81 flagMakeCapture: boolean = false; |
80 flagMakeCapture: boolean = false; |
82 |
81 |
83 InitStepsFlags: Longword = 0; |
82 InitStepsFlags: Longword = 0; |
84 |
83 |
85 AttackBar: integer = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP |
84 AttackBar: integer = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP |
86 |
85 |
87 function hwSign(r: Double): integer; |
86 function hwSign(r: hwFloat): integer; |
88 function Min(a, b: integer): integer; |
87 function Min(a, b: integer): integer; |
89 function Max(a, b: integer): integer; |
88 function Max(a, b: integer): integer; |
90 procedure OutError(Msg: String; const isFatalError: boolean=false); |
89 function rndSign(num: hwFloat): hwFloat; |
|
90 procedure OutError(Msg: String; isFatalError: boolean); |
91 procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
91 procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
92 procedure SDLTry(Assert: boolean; isFatal: boolean); |
92 procedure SDLTry(Assert: boolean; isFatal: boolean); |
93 function IntToStr(n: LongInt): shortstring; |
93 function IntToStr(n: LongInt): shortstring; |
94 function FloatToStr(n: Double): shortstring; |
94 function FloatToStr(n: hwFloat): shortstring; |
95 function DxDy2Angle32(const _dY, _dX: Extended): integer; |
95 function DxDy2Angle32(const _dY, _dX: Extended): integer; |
96 function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
96 function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
97 procedure AdjustColor(var Color: Longword); |
97 procedure AdjustColor(var Color: Longword); |
98 {$IFDEF DEBUGFILE} |
98 {$IFDEF DEBUGFILE} |
99 procedure AddFileLog(s: shortstring); |
99 procedure AddFileLog(s: shortstring); |
100 function RectToStr(Rect: TSDL_Rect): shortstring; |
100 function RectToStr(Rect: TSDL_Rect): shortstring; |
101 {$ENDIF} |
101 {$ENDIF} |
102 procedure SetKB(n: Longword); |
102 procedure SetKB(n: Longword); |
103 procedure SendKB; |
103 procedure SendKB; |
104 procedure SetLittle(var r: Double); |
104 procedure SetLittle(var r: hwFloat); |
105 procedure SendStat(sit: TStatInfoType; s: shortstring); |
105 procedure SendStat(sit: TStatInfoType; s: shortstring); |
|
106 function Str2PChar(var s: shortstring): PChar; |
106 |
107 |
107 var CursorPoint: TPoint; |
108 var CursorPoint: TPoint; |
108 TargetPoint: TPoint = (X: NoPointX; Y: 0); |
109 TargetPoint: TPoint = (X: NoPointX; Y: 0); |
109 |
110 |
110 implementation |
111 implementation |
111 uses uConsole, uStore, uIO{$IFDEF FPC}, Math{$ENDIF}; |
112 uses uConsole, uStore, uIO, Math, uRandom; |
112 var KBnum: Longword = 0; |
113 var KBnum: Longword = 0; |
113 {$IFDEF DEBUGFILE} |
114 {$IFDEF DEBUGFILE} |
114 var f: textfile; |
115 var f: textfile; |
115 {$ENDIF} |
116 {$ENDIF} |
116 |
117 |
117 function hwSign(r: Double): integer; |
118 function hwSign(r: hwFloat): integer; |
118 begin |
119 begin |
119 if r < 0 then Result:= -1 else Result:= 1 |
120 if r.isNegative then hwSign:= -1 else hwSign:= 1 |
120 end; |
121 end; |
121 |
122 |
122 function Min(a, b: integer): integer; |
123 function Min(a, b: integer): integer; |
123 begin |
124 begin |
124 if a < b then Result:= a else Result:= b |
125 if a < b then Min:= a else Min:= b |
125 end; |
126 end; |
126 |
127 |
127 function Max(a, b: integer): integer; |
128 function Max(a, b: integer): integer; |
128 begin |
129 begin |
129 if a > b then Result:= a else Result:= b |
130 if a > b then Max:= a else Max:= b |
130 end; |
131 end; |
131 |
132 |
132 procedure OutError(Msg: String; const isFatalError: boolean=false); |
133 procedure OutError(Msg: String; isFatalError: boolean); |
133 begin |
134 begin |
134 {$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
135 {$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
135 WriteLnToConsole(Msg); |
136 WriteLnToConsole(Msg); |
136 if isFatalError then |
137 if isFatalError then |
137 begin |
138 begin |
202 s:= 'K' + inttostr(KBnum); |
202 s:= 'K' + inttostr(KBnum); |
203 SendIPCRaw(@s, Length(s) + 1) |
203 SendIPCRaw(@s, Length(s) + 1) |
204 end |
204 end |
205 end; |
205 end; |
206 |
206 |
207 procedure SetLittle(var r: Double); |
207 procedure SetLittle(var r: hwFloat); |
208 begin |
208 begin |
209 if r >= 0 then r:= cLittle else r:= - cLittle |
209 if not r.isNegative then r:= cLittle else r:= - cLittle |
210 end; |
210 end; |
211 |
211 |
212 procedure SendStat(sit: TStatInfoType; s: shortstring); |
212 procedure SendStat(sit: TStatInfoType; s: shortstring); |
213 const stc: array [TStatInfoType] of char = 'rDK'; |
213 const stc: array [TStatInfoType] of char = 'rDK'; |
214 begin |
214 begin |
215 SendIPC('i' + stc[sit] + s) |
215 SendIPC('i' + stc[sit] + s) |
216 end; |
216 end; |
217 |
217 |
|
218 function rndSign(num: hwFloat): hwFloat; |
|
219 begin |
|
220 num.isNegative:= getrandom(2) = 0; |
|
221 rndSign:= num |
|
222 end; |
|
223 |
|
224 function Str2PChar(var s: shortstring): PChar; |
|
225 const CharArray: array[byte] of Char = ''; |
|
226 begin |
|
227 CharArray:= s; |
|
228 CharArray[Length(s)]:= #0; |
|
229 Str2PChar:= @CharArray |
|
230 end; |
|
231 |
218 {$IFDEF DEBUGFILE} |
232 {$IFDEF DEBUGFILE} |
219 procedure AddFileLog(s: shortstring); |
233 procedure AddFileLog(s: shortstring); |
220 begin |
234 begin |
221 writeln(f, GameTicks: 6, ': ', s); |
235 writeln(f, GameTicks: 6, ': ', s); |
222 flush(f) |
236 flush(f) |
223 end; |
237 end; |
224 |
238 |
225 function RectToStr(Rect: TSDL_Rect): shortstring; |
239 function RectToStr(Rect: TSDL_Rect): shortstring; |
226 begin |
240 begin |
227 Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
241 RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
228 end; |
242 end; |
229 |
243 |
230 |
244 |
231 var i: integer; |
245 var i: integer; |
232 |
246 |
233 initialization |
247 initialization |
|
248 cDrownSpeed.QWordValue:= 257698038;// 0.06 |
|
249 cMaxWindSpeed.QWordValue:= 2147484;// 0.0005 |
|
250 cWindSpeed.QWordValue:= 429496;// 0.0001 |
|
251 cGravity:= cMaxWindSpeed; |
|
252 |
|
253 |
234 {$I-} |
254 {$I-} |
235 for i:= 0 to 7 do |
255 for i:= 0 to 7 do |
236 begin |
256 begin |
237 AssignFile(f, 'debug' + inttostr(i) + '.txt'); |
257 Assign(f, 'debug' + inttostr(i) + '.txt'); |
238 rewrite(f); |
258 rewrite(f); |
239 if IOResult = 0 then break |
259 if IOResult = 0 then break |
240 end; |
260 end; |
241 {$I+} |
261 {$I+} |
242 |
262 |
243 finalization |
263 finalization |
244 writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
264 writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
245 Flush(f); |
265 Flush(f); |
246 closefile(f) |
266 close(f) |
247 {$ENDIF} |
267 {$ENDIF} |
248 |
268 |
249 end. |
269 end. |