author | unc0rr |
Thu, 12 Jan 2006 16:33:26 +0000 | |
changeset 47 | 8daf1ee0b9a3 |
parent 43 | e297fea1a2f3 |
child 53 | 0e27949850e3 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
47 | 3 |
* Copyright (c) 2004, 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
5 |
* Distributed under the terms of the BSD-modified licence: |
|
6 |
* |
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
* of this software and associated documentation files (the "Software"), to deal |
|
9 |
* with the Software without restriction, including without limitation the |
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is |
|
12 |
* furnished to do so, subject to the following conditions: |
|
13 |
* |
|
14 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
15 |
* this list of conditions and the following disclaimer. |
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer in the documentation |
|
18 |
* and/or other materials provided with the distribution. |
|
19 |
* 3. The name of the author may not be used to endorse or promote products |
|
20 |
* derived from this software without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*) |
|
33 |
||
34 |
unit uMisc; |
|
35 |
interface |
|
36 |
uses uConsts, SDLh; |
|
37 |
{$INCLUDE options.inc} |
|
38 |
var isCursorVisible : boolean = false; |
|
39 |
isTerminated : boolean = false; |
|
40 |
isInLag : boolean = false; |
|
41 |
isSoundEnabled : boolean = true; |
|
42 |
isInMultiShoot : boolean = false; |
|
43 |
||
39 | 44 |
GameState : TGameState = Low(TGameState); |
4 | 45 |
GameType : TGameType = gmtLocal; |
46 |
GameFlags : Longword = 0; |
|
47 |
TurnTimeLeft : Longword = 0; |
|
48 |
cHedgehogTurnTime: Longword = 30000; |
|
49 |
||
50 |
cLandYShift : integer = 888; |
|
51 |
cCloudsNumber : integer = 9; |
|
52 |
cConsoleHeight : integer = 320; |
|
53 |
cConsoleYAdd : integer = 0; |
|
39 | 54 |
cTimerInterval : Cardinal = 5; |
4 | 55 |
cScreenWidth : integer = 1024; |
56 |
cScreenHeight : integer = 768; |
|
57 |
cBits : integer = 16; |
|
58 |
cWaterLine : integer = 1024; |
|
59 |
cVisibleWater : integer = 64; |
|
60 |
cScreenEdgesDist : integer = 240; |
|
47 | 61 |
cTeamHealthWidth : integer = 128; |
4 | 62 |
|
63 |
GameTicks : LongWord = 0; |
|
64 |
||
65 |
cSkyColor : Cardinal = 0; |
|
66 |
cWaterColor : Cardinal = $32397A; |
|
67 |
cMapBackColor : Cardinal = $FFFFFF; |
|
68 |
cWhiteColor : Cardinal = $FFFFFF; |
|
69 |
cConsoleSplitterColor : Cardinal = $FF0000; |
|
70 |
cColorNearBlack : Cardinal = 16; |
|
71 |
cExplosionBorderColor : LongWord = $808080; |
|
72 |
||
73 |
cDrownSpeed : Real = 0.06; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset
|
74 |
cMaxWindSpeed : Real = 0.0005; |
4 | 75 |
cWindSpeed : Real = 0.0001; |
76 |
cGravity : Real = 0.0005; |
|
77 |
||
78 |
cShowFPS : boolean = true; |
|
79 |
cFullScreen : boolean = true; |
|
80 |
||
81 |
const |
|
82 |
cMaxPower = 1500; |
|
83 |
cMaxAngle = 2048; |
|
84 |
cPowerDivisor = 1500; |
|
85 |
||
86 |
var |
|
87 |
cSendEmptyPacketTime : LongWord = 2000; |
|
88 |
cSendCursorPosTime : LongWord = 50; |
|
13 | 89 |
ShowCrosshair : boolean; |
4 | 90 |
|
91 |
flagMakeCapture: boolean = false; |
|
92 |
||
93 |
AttackBar : integer = 0; // 0 - îòñóòñòâóåò, 1 - âíèçó, 2 - êàê â wwp |
|
94 |
||
95 |
function Sign(r: real): integer; |
|
96 |
function Min(a, b: integer): integer; |
|
97 |
function Max(a, b: integer): integer; |
|
98 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
99 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
100 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
101 |
function IntToStr(n: integer): shortstring; |
|
102 |
function FloatToStr(n: real): shortstring; |
|
103 |
function arctan(const Y, X: real): real; |
|
104 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
105 |
procedure AdjustColor(var Color: Longword); |
|
106 |
{$IFDEF DEBUGFILE} |
|
107 |
procedure AddFileLog(s: shortstring); |
|
24 | 108 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
4 | 109 |
{$ENDIF} |
110 |
||
111 |
var CursorPoint: TPoint; |
|
112 |
TargetPoint: TPoint = (X: NoPointX; Y: 0); |
|
113 |
||
114 |
implementation |
|
43 | 115 |
uses uConsole, uStore, uIO; |
4 | 116 |
{$IFDEF DEBUGFILE} |
117 |
var f: textfile; |
|
118 |
{$ENDIF} |
|
119 |
||
120 |
||
121 |
function Sign(r: real): integer; |
|
122 |
begin |
|
123 |
if r < 0 then Result:= -1 else Result:= 1 |
|
124 |
end; |
|
125 |
||
126 |
function Min(a, b: integer): integer; |
|
127 |
begin |
|
128 |
if a < b then Result:= a else Result:= b |
|
129 |
end; |
|
130 |
||
131 |
function Max(a, b: integer): integer; |
|
132 |
begin |
|
133 |
if a > b then Result:= a else Result:= b |
|
134 |
end; |
|
135 |
||
136 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
137 |
begin |
|
138 |
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
139 |
if isFatalError then |
|
140 |
begin |
|
43 | 141 |
SendIPC('E' + Msg); |
4 | 142 |
WriteLn(Msg); |
143 |
SDL_Quit; |
|
24 | 144 |
// Readln; |
4 | 145 |
halt(1) |
146 |
end else WriteLnToConsole(Msg) |
|
147 |
end; |
|
148 |
||
149 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
150 |
begin |
|
151 |
if not Assert then OutError(msg, isFatal) |
|
152 |
end; |
|
153 |
||
154 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
155 |
begin |
|
156 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
157 |
end; |
|
158 |
||
159 |
procedure AdjustColor(var Color: Cardinal); |
|
160 |
begin |
|
161 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
162 |
end; |
|
163 |
||
164 |
function IntToStr(n: integer): shortstring; |
|
165 |
begin |
|
166 |
str(n, Result) |
|
167 |
end; |
|
168 |
||
169 |
function FloatToStr(n: real): shortstring; |
|
170 |
begin |
|
171 |
str(n, Result) |
|
172 |
end; |
|
173 |
||
174 |
function arctan(const Y, X: real): real; |
|
175 |
asm |
|
176 |
fld Y |
|
177 |
fld X |
|
178 |
fpatan |
|
179 |
fwait |
|
180 |
end; |
|
181 |
||
182 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
183 |
const piDIV32: Extended = pi/32; |
|
184 |
asm |
|
185 |
fld _dY |
|
186 |
fld _dX |
|
187 |
fpatan |
|
188 |
fld piDIV32 |
|
189 |
fdiv |
|
190 |
sub esp, 4 |
|
191 |
fistp dword ptr [esp] |
|
192 |
pop eax |
|
193 |
shr eax, 1 |
|
194 |
and eax, $1F |
|
195 |
end; |
|
196 |
||
197 |
||
198 |
{$IFDEF DEBUGFILE} |
|
199 |
procedure AddFileLog(s: shortstring); |
|
200 |
begin |
|
201 |
writeln(f, GameTicks: 6, ': ', s); |
|
202 |
flush(f) |
|
203 |
end; |
|
204 |
||
24 | 205 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
206 |
begin |
|
207 |
Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
208 |
end; |
|
209 |
||
4 | 210 |
initialization |
211 |
assignfile(f, 'debug.txt'); |
|
212 |
rewrite(f); |
|
17 | 213 |
|
4 | 214 |
finalization |
215 |
writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
|
216 |
Flush(f); |
|
217 |
closefile(f) |
|
218 |
{$ENDIF} |
|
219 |
||
220 |
end. |