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