author | unc0rr |
Fri, 20 Jan 2006 19:02:50 +0000 | |
changeset 54 | 839fd258ae6f |
parent 53 | 0e27949850e3 |
child 55 | e09f7c952a40 |
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} |
|
53 | 139 |
WriteLnToConsole(Msg); |
4 | 140 |
if isFatalError then |
141 |
begin |
|
53 | 142 |
SendIPC('E' + GetLastConsoleLine); |
4 | 143 |
SDL_Quit; |
144 |
halt(1) |
|
53 | 145 |
end |
4 | 146 |
end; |
147 |
||
148 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
149 |
begin |
|
150 |
if not Assert then OutError(msg, isFatal) |
|
151 |
end; |
|
152 |
||
153 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
154 |
begin |
|
155 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
156 |
end; |
|
157 |
||
158 |
procedure AdjustColor(var Color: Cardinal); |
|
159 |
begin |
|
160 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
161 |
end; |
|
162 |
||
163 |
function IntToStr(n: integer): shortstring; |
|
164 |
begin |
|
165 |
str(n, Result) |
|
166 |
end; |
|
167 |
||
168 |
function FloatToStr(n: real): shortstring; |
|
169 |
begin |
|
53 | 170 |
str(n:5:5, Result) |
4 | 171 |
end; |
172 |
||
173 |
function arctan(const Y, X: real): real; |
|
174 |
asm |
|
175 |
fld Y |
|
176 |
fld X |
|
177 |
fpatan |
|
178 |
fwait |
|
179 |
end; |
|
180 |
||
181 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
182 |
const piDIV32: Extended = pi/32; |
|
183 |
asm |
|
184 |
fld _dY |
|
185 |
fld _dX |
|
186 |
fpatan |
|
187 |
fld piDIV32 |
|
188 |
fdiv |
|
189 |
sub esp, 4 |
|
190 |
fistp dword ptr [esp] |
|
191 |
pop eax |
|
192 |
shr eax, 1 |
|
193 |
and eax, $1F |
|
194 |
end; |
|
195 |
||
196 |
||
197 |
{$IFDEF DEBUGFILE} |
|
198 |
procedure AddFileLog(s: shortstring); |
|
199 |
begin |
|
200 |
writeln(f, GameTicks: 6, ': ', s); |
|
201 |
flush(f) |
|
202 |
end; |
|
203 |
||
24 | 204 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
205 |
begin |
|
206 |
Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
207 |
end; |
|
208 |
||
4 | 209 |
initialization |
210 |
assignfile(f, 'debug.txt'); |
|
211 |
rewrite(f); |
|
17 | 212 |
|
4 | 213 |
finalization |
214 |
writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
|
215 |
Flush(f); |
|
216 |
closefile(f) |
|
217 |
{$ENDIF} |
|
218 |
||
219 |
end. |