author | unc0rr |
Fri, 23 Jun 2006 20:02:41 +0000 | |
changeset 70 | 82d93eeecebe |
parent 56 | a29135563e94 |
child 72 | aeb2ac1878dc |
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; |
|
56 | 66 |
cWaterColor : Cardinal = $005ACE; |
4 | 67 |
cWhiteColor : Cardinal = $FFFFFF; |
68 |
cConsoleSplitterColor : Cardinal = $FF0000; |
|
69 |
cColorNearBlack : Cardinal = 16; |
|
70 |
cExplosionBorderColor : LongWord = $808080; |
|
71 |
||
72 |
cDrownSpeed : Real = 0.06; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset
|
73 |
cMaxWindSpeed : Real = 0.0005; |
4 | 74 |
cWindSpeed : Real = 0.0001; |
75 |
cGravity : Real = 0.0005; |
|
76 |
||
77 |
cShowFPS : boolean = true; |
|
78 |
cFullScreen : boolean = true; |
|
79 |
||
80 |
const |
|
81 |
cMaxPower = 1500; |
|
82 |
cMaxAngle = 2048; |
|
83 |
cPowerDivisor = 1500; |
|
84 |
||
85 |
var |
|
86 |
cSendEmptyPacketTime : LongWord = 2000; |
|
87 |
cSendCursorPosTime : LongWord = 50; |
|
13 | 88 |
ShowCrosshair : boolean; |
4 | 89 |
|
90 |
flagMakeCapture: boolean = false; |
|
91 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
92 |
InitStepsFlags: Longword = 0; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
93 |
|
4 | 94 |
AttackBar : integer = 0; // 0 - îòñóòñòâóåò, 1 - âíèçó, 2 - êàê â wwp |
95 |
||
96 |
function Sign(r: real): integer; |
|
97 |
function Min(a, b: integer): integer; |
|
98 |
function Max(a, b: integer): integer; |
|
99 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
100 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
101 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
102 |
function IntToStr(n: integer): shortstring; |
|
103 |
function FloatToStr(n: real): shortstring; |
|
104 |
function arctan(const Y, X: real): real; |
|
105 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
106 |
procedure AdjustColor(var Color: Longword); |
|
107 |
{$IFDEF DEBUGFILE} |
|
108 |
procedure AddFileLog(s: shortstring); |
|
24 | 109 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
4 | 110 |
{$ENDIF} |
111 |
||
112 |
var CursorPoint: TPoint; |
|
113 |
TargetPoint: TPoint = (X: NoPointX; Y: 0); |
|
114 |
||
115 |
implementation |
|
43 | 116 |
uses uConsole, uStore, uIO; |
4 | 117 |
{$IFDEF DEBUGFILE} |
118 |
var f: textfile; |
|
119 |
{$ENDIF} |
|
120 |
||
121 |
||
122 |
function Sign(r: real): integer; |
|
123 |
begin |
|
124 |
if r < 0 then Result:= -1 else Result:= 1 |
|
125 |
end; |
|
126 |
||
127 |
function Min(a, b: integer): integer; |
|
128 |
begin |
|
129 |
if a < b then Result:= a else Result:= b |
|
130 |
end; |
|
131 |
||
132 |
function Max(a, b: integer): integer; |
|
133 |
begin |
|
134 |
if a > b then Result:= a else Result:= b |
|
135 |
end; |
|
136 |
||
137 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
138 |
begin |
|
139 |
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
53 | 140 |
WriteLnToConsole(Msg); |
4 | 141 |
if isFatalError then |
142 |
begin |
|
53 | 143 |
SendIPC('E' + GetLastConsoleLine); |
4 | 144 |
SDL_Quit; |
145 |
halt(1) |
|
53 | 146 |
end |
4 | 147 |
end; |
148 |
||
149 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
150 |
begin |
|
70 | 151 |
if not Assert then OutError(Msg, isFatal) |
4 | 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 |
|
53 | 171 |
str(n:5:5, Result) |
4 | 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. |