author | unc0rr |
Tue, 20 Jun 2006 21:18:49 +0000 | |
changeset 66 | 9643d75baf1e |
parent 56 | a29135563e94 |
child 70 | 82d93eeecebe |
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 |
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 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
93 |
InitStepsFlags: Longword = 0; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
94 |
|
4 | 95 |
AttackBar : integer = 0; // 0 - îòñóòñòâóåò, 1 - âíèçó, 2 - êàê â wwp |
96 |
||
97 |
function Sign(r: real): integer; |
|
98 |
function Min(a, b: integer): integer; |
|
99 |
function Max(a, b: integer): integer; |
|
100 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
101 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
102 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
103 |
function IntToStr(n: integer): shortstring; |
|
104 |
function FloatToStr(n: real): shortstring; |
|
105 |
function arctan(const Y, X: real): real; |
|
106 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
107 |
procedure AdjustColor(var Color: Longword); |
|
108 |
{$IFDEF DEBUGFILE} |
|
109 |
procedure AddFileLog(s: shortstring); |
|
24 | 110 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
4 | 111 |
{$ENDIF} |
112 |
||
113 |
var CursorPoint: TPoint; |
|
114 |
TargetPoint: TPoint = (X: NoPointX; Y: 0); |
|
115 |
||
116 |
implementation |
|
43 | 117 |
uses uConsole, uStore, uIO; |
4 | 118 |
{$IFDEF DEBUGFILE} |
119 |
var f: textfile; |
|
120 |
{$ENDIF} |
|
121 |
||
122 |
||
123 |
function Sign(r: real): integer; |
|
124 |
begin |
|
125 |
if r < 0 then Result:= -1 else Result:= 1 |
|
126 |
end; |
|
127 |
||
128 |
function Min(a, b: integer): integer; |
|
129 |
begin |
|
130 |
if a < b then Result:= a else Result:= b |
|
131 |
end; |
|
132 |
||
133 |
function Max(a, b: integer): integer; |
|
134 |
begin |
|
135 |
if a > b then Result:= a else Result:= b |
|
136 |
end; |
|
137 |
||
138 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
139 |
begin |
|
140 |
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
53 | 141 |
WriteLnToConsole(Msg); |
4 | 142 |
if isFatalError then |
143 |
begin |
|
53 | 144 |
SendIPC('E' + GetLastConsoleLine); |
4 | 145 |
SDL_Quit; |
146 |
halt(1) |
|
53 | 147 |
end |
4 | 148 |
end; |
149 |
||
150 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
151 |
begin |
|
152 |
if not Assert then OutError(msg, isFatal) |
|
153 |
end; |
|
154 |
||
155 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
156 |
begin |
|
157 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
158 |
end; |
|
159 |
||
160 |
procedure AdjustColor(var Color: Cardinal); |
|
161 |
begin |
|
162 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
163 |
end; |
|
164 |
||
165 |
function IntToStr(n: integer): shortstring; |
|
166 |
begin |
|
167 |
str(n, Result) |
|
168 |
end; |
|
169 |
||
170 |
function FloatToStr(n: real): shortstring; |
|
171 |
begin |
|
53 | 172 |
str(n:5:5, Result) |
4 | 173 |
end; |
174 |
||
175 |
function arctan(const Y, X: real): real; |
|
176 |
asm |
|
177 |
fld Y |
|
178 |
fld X |
|
179 |
fpatan |
|
180 |
fwait |
|
181 |
end; |
|
182 |
||
183 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
184 |
const piDIV32: Extended = pi/32; |
|
185 |
asm |
|
186 |
fld _dY |
|
187 |
fld _dX |
|
188 |
fpatan |
|
189 |
fld piDIV32 |
|
190 |
fdiv |
|
191 |
sub esp, 4 |
|
192 |
fistp dword ptr [esp] |
|
193 |
pop eax |
|
194 |
shr eax, 1 |
|
195 |
and eax, $1F |
|
196 |
end; |
|
197 |
||
198 |
||
199 |
{$IFDEF DEBUGFILE} |
|
200 |
procedure AddFileLog(s: shortstring); |
|
201 |
begin |
|
202 |
writeln(f, GameTicks: 6, ': ', s); |
|
203 |
flush(f) |
|
204 |
end; |
|
205 |
||
24 | 206 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
207 |
begin |
|
208 |
Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
209 |
end; |
|
210 |
||
4 | 211 |
initialization |
212 |
assignfile(f, 'debug.txt'); |
|
213 |
rewrite(f); |
|
17 | 214 |
|
4 | 215 |
finalization |
216 |
writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
|
217 |
Flush(f); |
|
218 |
closefile(f) |
|
219 |
{$ENDIF} |
|
220 |
||
221 |
end. |