p_maputl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. // Movement/collision utility functions,
  21. // as used by function in p_map.c.
  22. // BLOCKMAP Iterator functions,
  23. // and some PIT_* functions to use for iteration.
  24. //
  25. //-----------------------------------------------------------------------------
  26. static const char
  27. rcsid[] = "$Id: p_maputl.c,v 1.5 1997/02/03 22:45:11 b1 Exp $";
  28. #include <stdlib.h>
  29. #include "m_bbox.h"
  30. #include "doomdef.h"
  31. #include "p_local.h"
  32. // State.
  33. #include "r_state.h"
  34. //
  35. // P_AproxDistance
  36. // Gives an estimation of distance (not exact)
  37. //
  38. fixed_t
  39. P_AproxDistance
  40. ( fixed_t dx,
  41. fixed_t dy )
  42. {
  43. dx = abs(dx);
  44. dy = abs(dy);
  45. if (dx < dy)
  46. return dx+dy-(dx>>1);
  47. return dx+dy-(dy>>1);
  48. }
  49. //
  50. // P_PointOnLineSide
  51. // Returns 0 or 1
  52. //
  53. int
  54. P_PointOnLineSide
  55. ( fixed_t x,
  56. fixed_t y,
  57. line_t* line )
  58. {
  59. fixed_t dx;
  60. fixed_t dy;
  61. fixed_t left;
  62. fixed_t right;
  63. if (!line->dx)
  64. {
  65. if (x <= line->v1->x)
  66. return line->dy > 0;
  67. return line->dy < 0;
  68. }
  69. if (!line->dy)
  70. {
  71. if (y <= line->v1->y)
  72. return line->dx < 0;
  73. return line->dx > 0;
  74. }
  75. dx = (x - line->v1->x);
  76. dy = (y - line->v1->y);
  77. left = FixedMul ( line->dy>>FRACBITS , dx );
  78. right = FixedMul ( dy , line->dx>>FRACBITS );
  79. if (right < left)
  80. return 0; // front side
  81. return 1; // back side
  82. }
  83. //
  84. // P_BoxOnLineSide
  85. // Considers the line to be infinite
  86. // Returns side 0 or 1, -1 if box crosses the line.
  87. //
  88. int
  89. P_BoxOnLineSide
  90. ( fixed_t* tmbox,
  91. line_t* ld )
  92. {
  93. int p1;
  94. int p2;
  95. switch (ld->slopetype)
  96. {
  97. case ST_HORIZONTAL:
  98. p1 = tmbox[BOXTOP] > ld->v1->y;
  99. p2 = tmbox[BOXBOTTOM] > ld->v1->y;
  100. if (ld->dx < 0)
  101. {
  102. p1 ^= 1;
  103. p2 ^= 1;
  104. }
  105. break;
  106. case ST_VERTICAL:
  107. p1 = tmbox[BOXRIGHT] < ld->v1->x;
  108. p2 = tmbox[BOXLEFT] < ld->v1->x;
  109. if (ld->dy < 0)
  110. {
  111. p1 ^= 1;
  112. p2 ^= 1;
  113. }
  114. break;
  115. case ST_POSITIVE:
  116. p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld);
  117. p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld);
  118. break;
  119. case ST_NEGATIVE:
  120. p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld);
  121. p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld);
  122. break;
  123. }
  124. if (p1 == p2)
  125. return p1;
  126. return -1;
  127. }
  128. //
  129. // P_PointOnDivlineSide
  130. // Returns 0 or 1.
  131. //
  132. int
  133. P_PointOnDivlineSide
  134. ( fixed_t x,
  135. fixed_t y,
  136. divline_t* line )
  137. {
  138. fixed_t dx;
  139. fixed_t dy;
  140. fixed_t left;
  141. fixed_t right;
  142. if (!line->dx)
  143. {
  144. if (x <= line->x)
  145. return line->dy > 0;
  146. return line->dy < 0;
  147. }
  148. if (!line->dy)
  149. {
  150. if (y <= line->y)
  151. return line->dx < 0;
  152. return line->dx > 0;
  153. }
  154. dx = (x - line->x);
  155. dy = (y - line->y);
  156. // try to quickly decide by looking at sign bits
  157. if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 )
  158. {
  159. if ( (line->dy ^ dx) & 0x80000000 )
  160. return 1; // (left is negative)
  161. return 0;
  162. }
  163. left = FixedMul ( line->dy>>8, dx>>8 );
  164. right = FixedMul ( dy>>8 , line->dx>>8 );
  165. if (right < left)
  166. return 0; // front side
  167. return 1; // back side
  168. }
  169. //
  170. // P_MakeDivline
  171. //
  172. void
  173. P_MakeDivline
  174. ( line_t* li,
  175. divline_t* dl )
  176. {
  177. dl->x = li->v1->x;
  178. dl->y = li->v1->y;
  179. dl->dx = li->dx;
  180. dl->dy = li->dy;
  181. }
  182. //
  183. // P_InterceptVector
  184. // Returns the fractional intercept point
  185. // along the first divline.
  186. // This is only called by the addthings
  187. // and addlines traversers.
  188. //
  189. fixed_t
  190. P_InterceptVector
  191. ( divline_t* v2,
  192. divline_t* v1 )
  193. {
  194. #if 1
  195. fixed_t frac;
  196. fixed_t num;
  197. fixed_t den;
  198. den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy);
  199. if (den == 0)
  200. return 0;
  201. // I_Error ("P_InterceptVector: parallel");
  202. num =
  203. FixedMul ( (v1->x - v2->x)>>8 ,v1->dy )
  204. +FixedMul ( (v2->y - v1->y)>>8, v1->dx );
  205. frac = FixedDiv (num , den);
  206. return frac;
  207. #else // UNUSED, float debug.
  208. float frac;
  209. float num;
  210. float den;
  211. float v1x;
  212. float v1y;
  213. float v1dx;
  214. float v1dy;
  215. float v2x;
  216. float v2y;
  217. float v2dx;
  218. float v2dy;
  219. v1x = (float)v1->x/FRACUNIT;
  220. v1y = (float)v1->y/FRACUNIT;
  221. v1dx = (float)v1->dx/FRACUNIT;
  222. v1dy = (float)v1->dy/FRACUNIT;
  223. v2x = (float)v2->x/FRACUNIT;
  224. v2y = (float)v2->y/FRACUNIT;
  225. v2dx = (float)v2->dx/FRACUNIT;
  226. v2dy = (float)v2->dy/FRACUNIT;
  227. den = v1dy*v2dx - v1dx*v2dy;
  228. if (den == 0)
  229. return 0; // parallel
  230. num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx;
  231. frac = num / den;
  232. return frac*FRACUNIT;
  233. #endif
  234. }
  235. //
  236. // P_LineOpening
  237. // Sets opentop and openbottom to the window
  238. // through a two sided line.
  239. // OPTIMIZE: keep this precalculated
  240. //
  241. fixed_t opentop;
  242. fixed_t openbottom;
  243. fixed_t openrange;
  244. fixed_t lowfloor;
  245. void P_LineOpening (line_t* linedef)
  246. {
  247. sector_t* front;
  248. sector_t* back;
  249. if (linedef->sidenum[1] == -1)
  250. {
  251. // single sided line
  252. openrange = 0;
  253. return;
  254. }
  255. front = linedef->frontsector;
  256. back = linedef->backsector;
  257. if (front->ceilingheight < back->ceilingheight)
  258. opentop = front->ceilingheight;
  259. else
  260. opentop = back->ceilingheight;
  261. if (front->floorheight > back->floorheight)
  262. {
  263. openbottom = front->floorheight;
  264. lowfloor = back->floorheight;
  265. }
  266. else
  267. {
  268. openbottom = back->floorheight;
  269. lowfloor = front->floorheight;
  270. }
  271. openrange = opentop - openbottom;
  272. }
  273. //
  274. // THING POSITION SETTING
  275. //
  276. //
  277. // P_UnsetThingPosition
  278. // Unlinks a thing from block map and sectors.
  279. // On each position change, BLOCKMAP and other
  280. // lookups maintaining lists ot things inside
  281. // these structures need to be updated.
  282. //
  283. void P_UnsetThingPosition (mobj_t* thing)
  284. {
  285. int blockx;
  286. int blocky;
  287. if ( ! (thing->flags & MF_NOSECTOR) )
  288. {
  289. // inert things don't need to be in blockmap?
  290. // unlink from subsector
  291. if (thing->snext)
  292. thing->snext->sprev = thing->sprev;
  293. if (thing->sprev)
  294. thing->sprev->snext = thing->snext;
  295. else
  296. thing->subsector->sector->thinglist = thing->snext;
  297. }
  298. if ( ! (thing->flags & MF_NOBLOCKMAP) )
  299. {
  300. // inert things don't need to be in blockmap
  301. // unlink from block map
  302. if (thing->bnext)
  303. thing->bnext->bprev = thing->bprev;
  304. if (thing->bprev)
  305. thing->bprev->bnext = thing->bnext;
  306. else
  307. {
  308. blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
  309. blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
  310. if (blockx>=0 && blockx < bmapwidth
  311. && blocky>=0 && blocky <bmapheight)
  312. {
  313. blocklinks[blocky*bmapwidth+blockx] = thing->bnext;
  314. }
  315. }
  316. }
  317. }
  318. //
  319. // P_SetThingPosition
  320. // Links a thing into both a block and a subsector
  321. // based on it's x y.
  322. // Sets thing->subsector properly
  323. //
  324. void
  325. P_SetThingPosition (mobj_t* thing)
  326. {
  327. subsector_t* ss;
  328. sector_t* sec;
  329. int blockx;
  330. int blocky;
  331. mobj_t** link;
  332. // link into subsector
  333. ss = R_PointInSubsector (thing->x,thing->y);
  334. thing->subsector = ss;
  335. if ( ! (thing->flags & MF_NOSECTOR) )
  336. {
  337. // invisible things don't go into the sector links
  338. sec = ss->sector;
  339. thing->sprev = NULL;
  340. thing->snext = sec->thinglist;
  341. if (sec->thinglist)
  342. sec->thinglist->sprev = thing;
  343. sec->thinglist = thing;
  344. }
  345. // link into blockmap
  346. if ( ! (thing->flags & MF_NOBLOCKMAP) )
  347. {
  348. // inert things don't need to be in blockmap
  349. blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
  350. blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
  351. if (blockx>=0
  352. && blockx < bmapwidth
  353. && blocky>=0
  354. && blocky < bmapheight)
  355. {
  356. link = &blocklinks[blocky*bmapwidth+blockx];
  357. thing->bprev = NULL;
  358. thing->bnext = *link;
  359. if (*link)
  360. (*link)->bprev = thing;
  361. *link = thing;
  362. }
  363. else
  364. {
  365. // thing is off the map
  366. thing->bnext = thing->bprev = NULL;
  367. }
  368. }
  369. }
  370. //
  371. // BLOCK MAP ITERATORS
  372. // For each line/thing in the given mapblock,
  373. // call the passed PIT_* function.
  374. // If the function returns false,
  375. // exit with false without checking anything else.
  376. //
  377. //
  378. // P_BlockLinesIterator
  379. // The validcount flags are used to avoid checking lines
  380. // that are marked in multiple mapblocks,
  381. // so increment validcount before the first call
  382. // to P_BlockLinesIterator, then make one or more calls
  383. // to it.
  384. //
  385. boolean
  386. P_BlockLinesIterator
  387. ( int x,
  388. int y,
  389. boolean(*func)(line_t*) )
  390. {
  391. int offset;
  392. short* list;
  393. line_t* ld;
  394. if (x<0
  395. || y<0
  396. || x>=bmapwidth
  397. || y>=bmapheight)
  398. {
  399. return true;
  400. }
  401. offset = y*bmapwidth+x;
  402. offset = *(blockmap+offset);
  403. for ( list = blockmaplump+offset ; *list != -1 ; list++)
  404. {
  405. ld = &lines[*list];
  406. if (ld->validcount == validcount)
  407. continue; // line has already been checked
  408. ld->validcount = validcount;
  409. if ( !func(ld) )
  410. return false;
  411. }
  412. return true; // everything was checked
  413. }
  414. //
  415. // P_BlockThingsIterator
  416. //
  417. boolean
  418. P_BlockThingsIterator
  419. ( int x,
  420. int y,
  421. boolean(*func)(mobj_t*) )
  422. {
  423. mobj_t* mobj;
  424. if ( x<0
  425. || y<0
  426. || x>=bmapwidth
  427. || y>=bmapheight)
  428. {
  429. return true;
  430. }
  431. for (mobj = blocklinks[y*bmapwidth+x] ;
  432. mobj ;
  433. mobj = mobj->bnext)
  434. {
  435. if (!func( mobj ) )
  436. return false;
  437. }
  438. return true;
  439. }
  440. //
  441. // INTERCEPT ROUTINES
  442. //
  443. intercept_t intercepts[MAXINTERCEPTS];
  444. intercept_t* intercept_p;
  445. divline_t trace;
  446. boolean earlyout;
  447. int ptflags;
  448. //
  449. // PIT_AddLineIntercepts.
  450. // Looks for lines in the given block
  451. // that intercept the given trace
  452. // to add to the intercepts list.
  453. //
  454. // A line is crossed if its endpoints
  455. // are on opposite sides of the trace.
  456. // Returns true if earlyout and a solid line hit.
  457. //
  458. boolean
  459. PIT_AddLineIntercepts (line_t* ld)
  460. {
  461. int s1;
  462. int s2;
  463. fixed_t frac;
  464. divline_t dl;
  465. // avoid precision problems with two routines
  466. if ( trace.dx > FRACUNIT*16
  467. || trace.dy > FRACUNIT*16
  468. || trace.dx < -FRACUNIT*16
  469. || trace.dy < -FRACUNIT*16)
  470. {
  471. s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace);
  472. s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace);
  473. }
  474. else
  475. {
  476. s1 = P_PointOnLineSide (trace.x, trace.y, ld);
  477. s2 = P_PointOnLineSide (trace.x+trace.dx, trace.y+trace.dy, ld);
  478. }
  479. if (s1 == s2)
  480. return true; // line isn't crossed
  481. // hit the line
  482. P_MakeDivline (ld, &dl);
  483. frac = P_InterceptVector (&trace, &dl);
  484. if (frac < 0)
  485. return true; // behind source
  486. // try to early out the check
  487. if (earlyout
  488. && frac < FRACUNIT
  489. && !ld->backsector)
  490. {
  491. return false; // stop checking
  492. }
  493. intercept_p->frac = frac;
  494. intercept_p->isaline = true;
  495. intercept_p->d.line = ld;
  496. intercept_p++;
  497. return true; // continue
  498. }
  499. //
  500. // PIT_AddThingIntercepts
  501. //
  502. boolean PIT_AddThingIntercepts (mobj_t* thing)
  503. {
  504. fixed_t x1;
  505. fixed_t y1;
  506. fixed_t x2;
  507. fixed_t y2;
  508. int s1;
  509. int s2;
  510. boolean tracepositive;
  511. divline_t dl;
  512. fixed_t frac;
  513. tracepositive = (trace.dx ^ trace.dy)>0;
  514. // check a corner to corner crossection for hit
  515. if (tracepositive)
  516. {
  517. x1 = thing->x - thing->radius;
  518. y1 = thing->y + thing->radius;
  519. x2 = thing->x + thing->radius;
  520. y2 = thing->y - thing->radius;
  521. }
  522. else
  523. {
  524. x1 = thing->x - thing->radius;
  525. y1 = thing->y - thing->radius;
  526. x2 = thing->x + thing->radius;
  527. y2 = thing->y + thing->radius;
  528. }
  529. s1 = P_PointOnDivlineSide (x1, y1, &trace);
  530. s2 = P_PointOnDivlineSide (x2, y2, &trace);
  531. if (s1 == s2)
  532. return true; // line isn't crossed
  533. dl.x = x1;
  534. dl.y = y1;
  535. dl.dx = x2-x1;
  536. dl.dy = y2-y1;
  537. frac = P_InterceptVector (&trace, &dl);
  538. if (frac < 0)
  539. return true; // behind source
  540. intercept_p->frac = frac;
  541. intercept_p->isaline = false;
  542. intercept_p->d.thing = thing;
  543. intercept_p++;
  544. return true; // keep going
  545. }
  546. //
  547. // P_TraverseIntercepts
  548. // Returns true if the traverser function returns true
  549. // for all lines.
  550. //
  551. boolean
  552. P_TraverseIntercepts
  553. ( traverser_t func,
  554. fixed_t maxfrac )
  555. {
  556. int count;
  557. fixed_t dist;
  558. intercept_t* scan;
  559. intercept_t* in;
  560. count = intercept_p - intercepts;
  561. in = 0; // shut up compiler warning
  562. while (count--)
  563. {
  564. dist = MAXINT;
  565. for (scan = intercepts ; scan<intercept_p ; scan++)
  566. {
  567. if (scan->frac < dist)
  568. {
  569. dist = scan->frac;
  570. in = scan;
  571. }
  572. }
  573. if (dist > maxfrac)
  574. return true; // checked everything in range
  575. #if 0 // UNUSED
  576. {
  577. // don't check these yet, there may be others inserted
  578. in = scan = intercepts;
  579. for ( scan = intercepts ; scan<intercept_p ; scan++)
  580. if (scan->frac > maxfrac)
  581. *in++ = *scan;
  582. intercept_p = in;
  583. return false;
  584. }
  585. #endif
  586. if ( !func (in) )
  587. return false; // don't bother going farther
  588. in->frac = MAXINT;
  589. }
  590. return true; // everything was traversed
  591. }
  592. //
  593. // P_PathTraverse
  594. // Traces a line from x1,y1 to x2,y2,
  595. // calling the traverser function for each.
  596. // Returns true if the traverser function returns true
  597. // for all lines.
  598. //
  599. boolean
  600. P_PathTraverse
  601. ( fixed_t x1,
  602. fixed_t y1,
  603. fixed_t x2,
  604. fixed_t y2,
  605. int flags,
  606. boolean (*trav) (intercept_t *))
  607. {
  608. fixed_t xt1;
  609. fixed_t yt1;
  610. fixed_t xt2;
  611. fixed_t yt2;
  612. fixed_t xstep;
  613. fixed_t ystep;
  614. fixed_t partial;
  615. fixed_t xintercept;
  616. fixed_t yintercept;
  617. int mapx;
  618. int mapy;
  619. int mapxstep;
  620. int mapystep;
  621. int count;
  622. earlyout = flags & PT_EARLYOUT;
  623. validcount++;
  624. intercept_p = intercepts;
  625. if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
  626. x1 += FRACUNIT; // don't side exactly on a line
  627. if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
  628. y1 += FRACUNIT; // don't side exactly on a line
  629. trace.x = x1;
  630. trace.y = y1;
  631. trace.dx = x2 - x1;
  632. trace.dy = y2 - y1;
  633. x1 -= bmaporgx;
  634. y1 -= bmaporgy;
  635. xt1 = x1>>MAPBLOCKSHIFT;
  636. yt1 = y1>>MAPBLOCKSHIFT;
  637. x2 -= bmaporgx;
  638. y2 -= bmaporgy;
  639. xt2 = x2>>MAPBLOCKSHIFT;
  640. yt2 = y2>>MAPBLOCKSHIFT;
  641. if (xt2 > xt1)
  642. {
  643. mapxstep = 1;
  644. partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
  645. ystep = FixedDiv (y2-y1,abs(x2-x1));
  646. }
  647. else if (xt2 < xt1)
  648. {
  649. mapxstep = -1;
  650. partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
  651. ystep = FixedDiv (y2-y1,abs(x2-x1));
  652. }
  653. else
  654. {
  655. mapxstep = 0;
  656. partial = FRACUNIT;
  657. ystep = 256*FRACUNIT;
  658. }
  659. yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep);
  660. if (yt2 > yt1)
  661. {
  662. mapystep = 1;
  663. partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
  664. xstep = FixedDiv (x2-x1,abs(y2-y1));
  665. }
  666. else if (yt2 < yt1)
  667. {
  668. mapystep = -1;
  669. partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
  670. xstep = FixedDiv (x2-x1,abs(y2-y1));
  671. }
  672. else
  673. {
  674. mapystep = 0;
  675. partial = FRACUNIT;
  676. xstep = 256*FRACUNIT;
  677. }
  678. xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep);
  679. // Step through map blocks.
  680. // Count is present to prevent a round off error
  681. // from skipping the break.
  682. mapx = xt1;
  683. mapy = yt1;
  684. for (count = 0 ; count < 64 ; count++)
  685. {
  686. if (flags & PT_ADDLINES)
  687. {
  688. if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts))
  689. return false; // early out
  690. }
  691. if (flags & PT_ADDTHINGS)
  692. {
  693. if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts))
  694. return false; // early out
  695. }
  696. if (mapx == xt2
  697. && mapy == yt2)
  698. {
  699. break;
  700. }
  701. if ( (yintercept >> FRACBITS) == mapy)
  702. {
  703. yintercept += ystep;
  704. mapx += mapxstep;
  705. }
  706. else if ( (xintercept >> FRACBITS) == mapx)
  707. {
  708. xintercept += xstep;
  709. mapy += mapystep;
  710. }
  711. }
  712. // go through the sorted list
  713. return P_TraverseIntercepts ( trav, FRACUNIT );
  714. }