author | unc0rr |
Mon, 24 Jul 2006 14:03:51 +0000 | |
changeset 83 | 207c85fbef51 |
parent 81 | d74e0e914b50 |
child 95 | 1ef5e2c41115 |
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; |
|
72 | 42 |
isSEBackup : boolean = true; |
4 | 43 |
isInMultiShoot : boolean = false; |
44 |
||
39 | 45 |
GameState : TGameState = Low(TGameState); |
4 | 46 |
GameType : TGameType = gmtLocal; |
47 |
GameFlags : Longword = 0; |
|
48 |
TurnTimeLeft : Longword = 0; |
|
49 |
cHedgehogTurnTime: Longword = 30000; |
|
50 |
||
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; |
|
74 | 58 |
cBitsStr : string[2] = '16'; |
59 |
||
4 | 60 |
cWaterLine : integer = 1024; |
75 | 61 |
cVisibleWater : integer = 128; |
4 | 62 |
cScreenEdgesDist : integer = 240; |
47 | 63 |
cTeamHealthWidth : integer = 128; |
4 | 64 |
|
65 |
GameTicks : LongWord = 0; |
|
66 |
||
67 |
cSkyColor : Cardinal = 0; |
|
56 | 68 |
cWaterColor : Cardinal = $005ACE; |
4 | 69 |
cWhiteColor : Cardinal = $FFFFFF; |
70 |
cConsoleSplitterColor : Cardinal = $FF0000; |
|
71 |
cColorNearBlack : Cardinal = 16; |
|
72 |
cExplosionBorderColor : LongWord = $808080; |
|
73 |
||
74 |
cDrownSpeed : Real = 0.06; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset
|
75 |
cMaxWindSpeed : Real = 0.0005; |
4 | 76 |
cWindSpeed : Real = 0.0001; |
77 |
cGravity : Real = 0.0005; |
|
78 |
||
79 |
cShowFPS : boolean = true; |
|
80 |
cFullScreen : boolean = true; |
|
80 | 81 |
cLocaleFName : shortstring = 'en.txt'; |
81 | 82 |
cSeed : shortstring = ''; |
4 | 83 |
|
84 |
const |
|
85 |
cMaxPower = 1500; |
|
86 |
cMaxAngle = 2048; |
|
87 |
cPowerDivisor = 1500; |
|
88 |
||
89 |
var |
|
90 |
cSendEmptyPacketTime : LongWord = 2000; |
|
91 |
cSendCursorPosTime : LongWord = 50; |
|
13 | 92 |
ShowCrosshair : boolean; |
4 | 93 |
|
94 |
flagMakeCapture: boolean = false; |
|
95 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
96 |
InitStepsFlags: Longword = 0; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
97 |
|
79 | 98 |
AttackBar: integer = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP |
4 | 99 |
|
100 |
function Sign(r: real): integer; |
|
101 |
function Min(a, b: integer): integer; |
|
102 |
function Max(a, b: integer): integer; |
|
103 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
104 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
105 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
106 |
function IntToStr(n: integer): shortstring; |
|
107 |
function FloatToStr(n: real): shortstring; |
|
108 |
function arctan(const Y, X: real): real; |
|
109 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
110 |
procedure AdjustColor(var Color: Longword); |
|
111 |
{$IFDEF DEBUGFILE} |
|
112 |
procedure AddFileLog(s: shortstring); |
|
24 | 113 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
4 | 114 |
{$ENDIF} |
115 |
||
116 |
var CursorPoint: TPoint; |
|
117 |
TargetPoint: TPoint = (X: NoPointX; Y: 0); |
|
118 |
||
119 |
implementation |
|
43 | 120 |
uses uConsole, uStore, uIO; |
4 | 121 |
{$IFDEF DEBUGFILE} |
122 |
var f: textfile; |
|
123 |
{$ENDIF} |
|
124 |
||
125 |
||
126 |
function Sign(r: real): integer; |
|
127 |
begin |
|
128 |
if r < 0 then Result:= -1 else Result:= 1 |
|
129 |
end; |
|
130 |
||
131 |
function Min(a, b: integer): integer; |
|
132 |
begin |
|
133 |
if a < b then Result:= a else Result:= b |
|
134 |
end; |
|
135 |
||
136 |
function Max(a, b: integer): integer; |
|
137 |
begin |
|
138 |
if a > b then Result:= a else Result:= b |
|
139 |
end; |
|
140 |
||
141 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
142 |
begin |
|
143 |
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
53 | 144 |
WriteLnToConsole(Msg); |
4 | 145 |
if isFatalError then |
146 |
begin |
|
53 | 147 |
SendIPC('E' + GetLastConsoleLine); |
4 | 148 |
SDL_Quit; |
149 |
halt(1) |
|
53 | 150 |
end |
4 | 151 |
end; |
152 |
||
153 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
154 |
begin |
|
70 | 155 |
if not Assert then OutError(Msg, isFatal) |
4 | 156 |
end; |
157 |
||
158 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
159 |
begin |
|
160 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
161 |
end; |
|
162 |
||
163 |
procedure AdjustColor(var Color: Cardinal); |
|
164 |
begin |
|
165 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
166 |
end; |
|
167 |
||
168 |
function IntToStr(n: integer): shortstring; |
|
169 |
begin |
|
170 |
str(n, Result) |
|
171 |
end; |
|
172 |
||
173 |
function FloatToStr(n: real): shortstring; |
|
174 |
begin |
|
53 | 175 |
str(n:5:5, Result) |
4 | 176 |
end; |
177 |
||
178 |
function arctan(const Y, X: real): real; |
|
179 |
asm |
|
180 |
fld Y |
|
181 |
fld X |
|
182 |
fpatan |
|
183 |
fwait |
|
184 |
end; |
|
185 |
||
186 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
187 |
const piDIV32: Extended = pi/32; |
|
188 |
asm |
|
189 |
fld _dY |
|
190 |
fld _dX |
|
191 |
fpatan |
|
192 |
fld piDIV32 |
|
193 |
fdiv |
|
194 |
sub esp, 4 |
|
195 |
fistp dword ptr [esp] |
|
196 |
pop eax |
|
197 |
shr eax, 1 |
|
198 |
and eax, $1F |
|
199 |
end; |
|
200 |
||
201 |
||
202 |
{$IFDEF DEBUGFILE} |
|
203 |
procedure AddFileLog(s: shortstring); |
|
204 |
begin |
|
205 |
writeln(f, GameTicks: 6, ': ', s); |
|
206 |
flush(f) |
|
207 |
end; |
|
208 |
||
24 | 209 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
210 |
begin |
|
211 |
Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
212 |
end; |
|
213 |
||
4 | 214 |
initialization |
215 |
assignfile(f, 'debug.txt'); |
|
216 |
rewrite(f); |
|
17 | 217 |
|
4 | 218 |
finalization |
219 |
writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
|
220 |
Flush(f); |
|
221 |
closefile(f) |
|
222 |
{$ENDIF} |
|
223 |
||
224 |
end. |