author | unc0rr |
Wed, 28 Dec 2005 22:18:11 +0000 | |
changeset 32 | 78bff13b11c0 |
parent 24 | 79c411363184 |
child 39 | b78e7185ed13 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
||
44 |
GameState : TGameState = gsLandGen; |
|
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; |
|
54 |
cTimerInterval : Cardinal = 15; |
|
55 |
cScreenWidth : integer = 1024; |
|
56 |
cScreenHeight : integer = 768; |
|
57 |
cBits : integer = 16; |
|
58 |
cWaterLine : integer = 1024; |
|
59 |
cVisibleWater : integer = 64; |
|
60 |
cScreenEdgesDist : integer = 240; |
|
61 |
||
62 |
GameTicks : LongWord = 0; |
|
63 |
||
64 |
cSkyColor : Cardinal = 0; |
|
65 |
cWaterColor : Cardinal = $32397A; |
|
66 |
cMapBackColor : Cardinal = $FFFFFF; |
|
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 |
||
92 |
AttackBar : integer = 0; // 0 - îòñóòñòâóåò, 1 - âíèçó, 2 - êàê â wwp |
|
93 |
||
94 |
function Sign(r: real): integer; |
|
95 |
function Min(a, b: integer): integer; |
|
96 |
function Max(a, b: integer): integer; |
|
97 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
98 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
99 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
100 |
function IntToStr(n: integer): shortstring; |
|
101 |
function FloatToStr(n: real): shortstring; |
|
102 |
function arctan(const Y, X: real): real; |
|
103 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
104 |
procedure AdjustColor(var Color: Longword); |
|
105 |
{$IFDEF DEBUGFILE} |
|
106 |
procedure AddFileLog(s: shortstring); |
|
24 | 107 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
4 | 108 |
{$ENDIF} |
109 |
||
110 |
var CursorPoint: TPoint; |
|
111 |
TargetPoint: TPoint = (X: NoPointX; Y: 0); |
|
112 |
||
113 |
implementation |
|
114 |
uses uConsole, uStore; |
|
115 |
{$IFDEF DEBUGFILE} |
|
116 |
var f: textfile; |
|
117 |
{$ENDIF} |
|
118 |
||
119 |
||
120 |
function Sign(r: real): integer; |
|
121 |
begin |
|
122 |
if r < 0 then Result:= -1 else Result:= 1 |
|
123 |
end; |
|
124 |
||
125 |
function Min(a, b: integer): integer; |
|
126 |
begin |
|
127 |
if a < b then Result:= a else Result:= b |
|
128 |
end; |
|
129 |
||
130 |
function Max(a, b: integer): integer; |
|
131 |
begin |
|
132 |
if a > b then Result:= a else Result:= b |
|
133 |
end; |
|
134 |
||
135 |
procedure OutError(Msg: String; const isFatalError: boolean=false); |
|
136 |
begin |
|
137 |
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
138 |
if isFatalError then |
|
139 |
begin |
|
140 |
WriteLn(Msg); |
|
141 |
SDL_Quit; |
|
24 | 142 |
// Readln; |
4 | 143 |
halt(1) |
144 |
end else WriteLnToConsole(Msg) |
|
145 |
end; |
|
146 |
||
147 |
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean); |
|
148 |
begin |
|
149 |
if not Assert then OutError(msg, isFatal) |
|
150 |
end; |
|
151 |
||
152 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
153 |
begin |
|
154 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
155 |
end; |
|
156 |
||
157 |
procedure AdjustColor(var Color: Cardinal); |
|
158 |
begin |
|
159 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
160 |
end; |
|
161 |
||
162 |
function IntToStr(n: integer): shortstring; |
|
163 |
begin |
|
164 |
str(n, Result) |
|
165 |
end; |
|
166 |
||
167 |
function FloatToStr(n: real): shortstring; |
|
168 |
begin |
|
169 |
str(n, Result) |
|
170 |
end; |
|
171 |
||
172 |
function arctan(const Y, X: real): real; |
|
173 |
asm |
|
174 |
fld Y |
|
175 |
fld X |
|
176 |
fpatan |
|
177 |
fwait |
|
178 |
end; |
|
179 |
||
180 |
function DxDy2Angle32(const _dY, _dX: Extended): integer; |
|
181 |
const piDIV32: Extended = pi/32; |
|
182 |
asm |
|
183 |
fld _dY |
|
184 |
fld _dX |
|
185 |
fpatan |
|
186 |
fld piDIV32 |
|
187 |
fdiv |
|
188 |
sub esp, 4 |
|
189 |
fistp dword ptr [esp] |
|
190 |
pop eax |
|
191 |
shr eax, 1 |
|
192 |
and eax, $1F |
|
193 |
end; |
|
194 |
||
195 |
||
196 |
{$IFDEF DEBUGFILE} |
|
197 |
procedure AddFileLog(s: shortstring); |
|
198 |
begin |
|
199 |
writeln(f, GameTicks: 6, ': ', s); |
|
200 |
flush(f) |
|
201 |
end; |
|
202 |
||
24 | 203 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
204 |
begin |
|
205 |
Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
206 |
end; |
|
207 |
||
4 | 208 |
initialization |
209 |
assignfile(f, 'debug.txt'); |
|
210 |
rewrite(f); |
|
17 | 211 |
|
4 | 212 |
finalization |
213 |
writeln(f, '-= halt at ',GameTicks,' ticks =-'); |
|
214 |
Flush(f); |
|
215 |
closefile(f) |
|
216 |
{$ENDIF} |
|
217 |
||
218 |
end. |