254 inc(rate, Score * (Radius - r)) |
254 inc(rate, Score * (Radius - r)) |
255 end; |
255 end; |
256 RatePlace:= rate; |
256 RatePlace:= rate; |
257 end; |
257 end; |
258 |
258 |
|
259 function CheckBounds(x, y, r: Longint): boolean; inline; |
|
260 begin |
|
261 CheckBounds := (((x-r) and LAND_WIDTH_MASK) = 0) and |
|
262 (((x+r) and LAND_WIDTH_MASK) = 0) and |
|
263 (((y-r) and LAND_HEIGHT_MASK) = 0) and |
|
264 (((y+r) and LAND_HEIGHT_MASK) = 0); |
|
265 end; |
|
266 |
|
267 |
|
268 function TestCollWithEverything(x, y, r: LongInt): boolean; inline; |
|
269 begin |
|
270 if not CheckBounds(x, y, r) then |
|
271 exit(false); |
|
272 |
|
273 if (Land[y-r, x-r] <> 0) or |
|
274 (Land[y+r, x-r] <> 0) or |
|
275 (Land[y-r, x+r] <> 0) or |
|
276 (Land[y+r, x+r] <> 0) then |
|
277 exit(true); |
|
278 |
|
279 TestCollWithEverything := false; |
|
280 end; |
|
281 |
|
282 function TestCollExcludingObjects(x, y, r: LongInt): boolean; inline; |
|
283 begin |
|
284 if not CheckBounds(x, y, r) then |
|
285 exit(false); |
|
286 |
|
287 if (Land[y-r, x-r] > lfAllObjMask) or |
|
288 (Land[y+r, x-r] > lfAllObjMask) or |
|
289 (Land[y-r, x+r] > lfAllObjMask) or |
|
290 (Land[y+r, x+r] > lfAllObjMask) then |
|
291 exit(true); |
|
292 |
|
293 TestCollExcludingObjects:= false; |
|
294 end; |
|
295 |
|
296 function TestColl(x, y, r: LongInt): boolean; inline; |
|
297 begin |
|
298 if not CheckBounds(x, y, r) then |
|
299 exit(false); |
|
300 |
|
301 if (Land[y-r, x-r] and lfNotCurrentMask <> 0) or |
|
302 (Land[y+r, x-r] and lfNotCurrentMask <> 0) or |
|
303 (Land[y-r, x+r] and lfNotCurrentMask <> 0) or |
|
304 (Land[y+r, x+r] and lfNotCurrentMask <> 0) then |
|
305 exit(true); |
|
306 |
|
307 TestColl:= false; |
|
308 end; |
|
309 |
|
310 function TestCollWithLand(x, y, r: LongInt): boolean; inline; |
|
311 begin |
|
312 if not CheckBounds(x, y, r) then |
|
313 exit(false); |
|
314 |
|
315 if (Land[y-r, x-r] > lfAllObjMask) or |
|
316 (Land[y+r, x-r] > lfAllObjMask) or |
|
317 (Land[y-r, x+r] > lfAllObjMask) or |
|
318 (Land[y+r, x+r] > lfAllObjMask) then |
|
319 exit(true); |
|
320 |
|
321 TestCollWithLand:= false; |
|
322 end; |
|
323 |
|
324 |
259 // Wrapper to test various approaches. If it works reasonably, will just replace. |
325 // Wrapper to test various approaches. If it works reasonably, will just replace. |
260 // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with... |
326 // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with... |
261 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline; |
327 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline; |
262 var MeX, MeY: LongInt; |
328 var MeX, MeY: LongInt; |
263 begin |
329 begin |
264 if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then |
330 if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then |
265 begin |
331 begin |
266 MeX:= hwRound(Me^.X); |
332 MeX:= hwRound(Me^.X); |
267 MeY:= hwRound(Me^.Y); |
333 MeY:= hwRound(Me^.Y); |
268 // We are still inside the hog. Skip radius test |
334 // We are still inside the hog. Skip radius test |
269 if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and (Land[y, x] <= lfAllObjMask) and ((Land[y, x] and lfObjMask) < 2) then |
335 if ((sqr(x-MeX) + sqr(y-MeY)) < 256) and (Land[y, x] and lfObjMask = 0) then |
270 exit(false); |
336 exit(false); |
271 end; |
337 end; |
272 TestCollExcludingMe:= TestColl(x, y, r) |
338 TestCollExcludingMe:= TestCollWithEverything(x, y, r) |
273 end; |
339 end; |
274 |
340 |
275 function TestCollExcludingObjects(x, y, r: LongInt): boolean; inline; |
341 |
276 var b: boolean; |
|
277 begin |
|
278 b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] > lfAllObjMask); |
|
279 if b then |
|
280 exit(true); |
|
281 |
|
282 b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] > lfAllObjMask); |
|
283 if b then |
|
284 exit(true); |
|
285 |
|
286 b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] > lfAllObjMask); |
|
287 if b then |
|
288 exit(true); |
|
289 |
|
290 b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] > lfAllObjMask); |
|
291 if b then |
|
292 exit(true); |
|
293 |
|
294 TestCollExcludingObjects:= false; |
|
295 end; |
|
296 |
|
297 function TestColl(x, y, r: LongInt): boolean; inline; |
|
298 var b: boolean; |
|
299 begin |
|
300 b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] and lfNotCurrentMask <> 0); |
|
301 if b then |
|
302 exit(true); |
|
303 |
|
304 b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] and lfNotCurrentMask <> 0); |
|
305 if b then |
|
306 exit(true); |
|
307 |
|
308 b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] and lfNotCurrentMask <> 0); |
|
309 if b then |
|
310 exit(true); |
|
311 |
|
312 b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] and lfNotCurrentMask <> 0); |
|
313 if b then |
|
314 exit(true); |
|
315 |
|
316 TestColl:= false; |
|
317 end; |
|
318 |
|
319 function TestCollWithLand(x, y, r: LongInt): boolean; inline; |
|
320 var b: boolean; |
|
321 begin |
|
322 b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] > lfAllObjMask); |
|
323 if b then |
|
324 exit(true); |
|
325 |
|
326 b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] > lfAllObjMask); |
|
327 if b then |
|
328 exit(true); |
|
329 |
|
330 b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] > lfAllObjMask); |
|
331 if b then |
|
332 exit(true); |
|
333 |
|
334 b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] > lfAllObjMask); |
|
335 if b then |
|
336 exit(true); |
|
337 |
|
338 TestCollWithLand:= false; |
|
339 end; |
|
340 |
342 |
341 function TraceFall(eX, eY: LongInt; x, y, dX, dY: Real; r: LongWord): LongInt; |
343 function TraceFall(eX, eY: LongInt; x, y, dX, dY: Real; r: LongWord): LongInt; |
342 var skipLandCheck: boolean; |
344 var skipLandCheck: boolean; |
343 rCorner: real; |
345 rCorner: real; |
344 dmg: LongInt; |
346 dmg: LongInt; |