summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/los.cc
Commit message (Collapse)AuthorAgeFilesLines
* Trim unnecessary #includes.Adam Borowski2010-01-131-2/+0
|
* Remove unnecessary header-header includes.Robert Vollmert2009-11-271-0/+1
|
* Fix ray_def::on_corner not getting initialized in los.cc:fallback_ray.Robert Vollmert2009-11-161-0/+1
| | | | | This was eventually causing not _valid() asserts in the smoky arena (BR 2898267).
* Replace calc_show_los by you.update_los.Robert Vollmert2009-11-131-6/+0
|
* Move trans_wall_blocking into player.Robert Vollmert2009-11-131-6/+0
|
* Replace observe_cell by you.see_cell.Robert Vollmert2009-11-131-7/+0
|
* Hack player LOS routines for arena.Robert Vollmert2009-11-131-3/+1
| | | | Player now sees everything in the arena.
* Fix compiler warning.Robert Vollmert2009-11-101-1/+1
| | | | | | 12:00 < Napkin> los.cc: In constructor `los_ray::los_ray(geom::ray)': 12:00 < Napkin> los.cc:154: warning: converting of negative value `-0x000000001' to `unsigned int'
* Remove obsolete losight_permissive.Robert Vollmert2009-11-081-13/+0
|
* Get rid of los_param::appearance.Robert Vollmert2009-11-081-7/+2
| | | | | This is not required anymore since we just store bools in los_grid.
* env_show_grid is now only used inside the LOS code.Robert Vollmert2009-11-081-36/+10
| | | | | It's also called los_grid, and is a SquareArray of boolean since it doesn't need to store "objects" any more.
* Move see_cell_no_trans into player.Robert Vollmert2009-11-081-13/+1
| | | | Also collect actor/player LOS code in actor-los.cc.
* Add opc_no_trans and use that for see_cell_no_trans.Robert Vollmert2009-11-081-2/+1
| | | | | | | | | The difference between no_trans and solid is whether granite statues are considered opaque. Granite statues are somewhat weird in that they behave completely differently from other statues: You can't shoot missiles at or past them, no items can be in their cell, etc.
* Replace bounds_func with circle_def.Robert Vollmert2009-11-081-16/+15
| | | | | | | The various LOS objects and functions now accept a circle_def instead of a bounds_func. This is a little less generic, but should eventually help with iterating over coordinates in any los_def.
* los.cc: Get rid of uninitialized warningMatthew Cline2009-11-071-1/+1
|
* Split los_def implementation out into los_def.cc.Robert Vollmert2009-11-071-76/+0
|
* Get rid of env.show_los.Robert Vollmert2009-11-071-6/+1
|
* Make player use actor LOS instead of env.show_los.Robert Vollmert2009-11-071-1/+1
|
* los_def: Implement default constructor and initialize field show.Robert Vollmert2009-11-071-1/+7
|
* Replace global see_cell by observe_cell and disambiguate old uses.Robert Vollmert2009-11-061-3/+4
| | | | | | | Calls to plain see_cell(pos) were replaced with either observe_cell(pos) or you.see_cell(pos). observe_cell where related to drawing the interface and messaging, you.see_cell for game mechanics, and one or the other in less clear cases (targetting, say).
* Split up view.cc.Robert Vollmert2009-11-041-1/+1
|
* Get rid of multiple-meaning "int object" in env.show.Robert Vollmert2009-11-041-5/+5
| | | | | | | | | | | | | env.show is now a class show_def that stores tagged unions of type show_type. For the moment, there's also env.show_los for use in LOS determination, but that should become an array of boolean at some point. This breaks save compatibility. Tiles and console version build and appear to work fine, but this kind of change is likely to have some side-effects.
* Quick fix for arena dispersal assertions.Robert Vollmert2009-11-021-0/+2
| | | | | | The issue is blink referencing player posistion, which is invalid. Better random_near_space fix will come.
* Permit rays to go from diamond directly to diamond.Robert Vollmert2009-11-011-2/+2
| | | | | | | Also recenter the cardinal direction rays. Before, we didn't have centered rays going straight north/south or east/west, which was awkward for shift-firing.
* Adapt los.cc to new ray_defs.Robert Vollmert2009-11-011-74/+55
| | | | | | | | | | | * Adapt los_ray. * Register rays using geom::ray. * Change cellray comparison functions (remove slope_diff which I didn't understand, add first_diag which prefers rays that start on diagonals for easier meph cloud targetting) The rays that are actually being cast may need changing. For now, rays that hit diamond corners are simply discarded.
* Remove ray antialiasing.Robert Vollmert2009-11-011-6/+10
| | | | | | | | | | | | | | | | | | | | | | Previously, rays were always cut short at corners: If a ray really went like ..... @**.. ..*** ..... it was cut short (for find_ray/targetting/shooting purposes) to ..... @*... ..*** ..... Note that a wall at the removed cell would still block the given ray! This makes ray footprint length matter, so rays are sorted to prefer those that pass through fewer cells. However, this gives quite a few ugly beams, in particular around corners.
* Special case source==target in num_feats_between.Robert Vollmert2009-11-011-0/+3
| | | | | This was causing a crash through monsters::mon_see_cell. Also special case monster position there.
* Add whitespace fixes.David Lawrence Ramsey2009-10-311-1/+1
|
* Splitting up stuff.cc.Robert Vollmert2009-10-301-0/+2
| | | | New: colour.cc, coord.cc, coordit.cc, random.cc, rng.cc.
* Rewrite los_def to handle function parameters sensibly.Robert Vollmert2009-10-261-16/+51
| | | | | | | | | | | | | Previously, it was holding on to pointers to objects it didn't own, causing various bugs. los_def now copies the opacity_func and bounds_func parameters. Making them copyable required introducing opacity_func::clone(). Also implement los_def copy constructor and copy assignment operator. Finally, update travel exclusions and monster patrolling to these changes.
* Wrap losight() in class los_def together with env_show_grid.Robert Vollmert2009-10-221-0/+39
|
* Split actors and env from externs.h.Robert Vollmert2009-10-211-0/+1
|
* versioning: remove SVN-specific revision data, add Git versioningSteven Noonan2009-10-181-1/+0
| | | | Signed-off-by: Steven Noonan <steven@uplinklabs.net>
* Assert that find_ray isn't called with bad bounds_func.Robert Vollmert2009-10-181-0/+2
|
* Ensure precalculations are done before find_ray is called.Robert Vollmert2009-10-181-0/+3
| | | | | | | Fixes BR 2881139. Arena mode doesn't result in a call to losight() anymore, which was doing the precalculations before.
* Fix see_cell for tighter ENV_SHOW_OFFSET.Robert Vollmert2009-10-181-3/+3
| | | | This was causing see_cell to fail for cells at the edge of LOS.
* Make default LOS configurable.Robert Vollmert2009-10-171-7/+8
| | | | | | Setting LOS_RADIUS in defines.h now works. Fixed a couple of things to allow this, including an apparent off-by-one error in crawl_view -- not quite sure this doesn't break anything.
* Clean up LOS precalculation settings.Robert Vollmert2009-10-171-9/+12
| | | | | | The maximal boundary within which losight/find_ray will work is now clearly defined at the start of los.cc. By default, it's the circle with radius LOS_MAX_RADIUS == LOS_RADIUS.
* Globally replace see_grid by see_cell.Robert Vollmert2009-10-171-9/+9
|
* Rewrite cell_see_cell using exists_ray.Robert Vollmert2009-10-161-6/+2
| | | | For this, add new opacity_func that disregards half-opaque things.
* Some find_ray related cleanup.Robert Vollmert2009-10-161-5/+37
| | | | | Introduce a function exists_ray when the ray is not actually needed. Also factor out part of _blocked_ray from directn.cc to ray_blocker.
* Generalize find_ray to accept opacity_func and bounds_func parameters.Robert Vollmert2009-10-161-57/+47
|
* Get rid of los_param outside of los.cc/losparam.cc.Robert Vollmert2009-10-161-7/+7
| | | | | | | | | | | The nicer interface to losight is now void losight(env_show_grid& sh, const coord_def& center, const opacity_func &opc = opc_default, const bounds_func &bds = bds_default); bounds_func provides the LOS boundary (usually just a circle with radius the current LOS radius). opacity_func is a mapping of grid coordinates to opacity values.
* On the way to a simplified losight interface.Robert Vollmert2009-10-161-1/+35
| | | | | | | | | | Added a function void losight(env_show_grid& sh, const coord_def& center, opacity_func opc, bounds_func bounds) with sensible defaults for opc and bounds. It's not necessary to abstract away the geometry as I initially did with los_param.
* Rewrite find_ray to use precomputed cellrays.Robert Vollmert2009-10-161-143/+128
| | | | | | | | | | | | | | | | | | | | | During precomputation, we store the minimal cellrays by target and sort them according to niceness. find_ray now simply picks the first non-blocked ray to a target, which means looping through the 10 or so minimal cellrays with that target -- this should be a lot more efficient. (An extended findray test went from 150s to 40s (debug) and 40s to 26s (profile)). The interface to find_ray has changed: cycle_dir=-1,0,1 was changed to cyle=false/true since we never cycle in the other direction anyway. find_shortest was removed: all rays to a target had the same length all along, but now we also return the straightest one automatically. The change also eliminates the duplicate corner-cutting code between ray_def::advance and find_ray as imbalance calculation now relies on ray_def::advance.
* Comments.Robert Vollmert2009-10-161-10/+12
|
* los.cc: fix _find_minimal_cellrays iterationSteven Noonan2009-10-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From an earlier email about this bug: It bombed on the min_it++, which was odd. Looking at the loop, I suspect what happens is this: - Erases the last item in the 'min' list, setting min_it to min.end(), - Attempts to increment min_it (which isn't valid on the end iterator) The patch at the bottom of this mail avoids the crash, but DOES NOT fix the root bug. The root bug is a bit more insidous (imagine that, MSVC helped us catch a real bug!). Consider the following test case: -- BEGIN -- #include <iostream> #include <list> int main() { std::list<int> ilist; for (int i = 1; i < 10; i++) { ilist.push_back(i); } for (std::list<int>::iterator l_it = ilist.begin(); l_it != ilist.end(); l_it++) { std::cout << *l_it << " "; if (*l_it == 4) l_it = ilist.erase(l_it); } std::cout << std::endl; return 0; } -- EOF -- Here's the output: $ ./test 1 2 3 4 6 7 8 9 Note that it skipped over '5'. The reason is because the iterator ends up being incremented _twice_ (the erase() moves the iterator one forward of the previous position). So the obvious solution might be to decrement the iterator immediately after erase(), right? Wrong. If you erased the last element in the list, your iterator will be == list.end(), which is an iterator you should NEVER use ++ or -- on. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
* More sanity checks in find_ray.Robert Vollmert2009-10-151-1/+3
|
* Remove outdated comment.Robert Vollmert2009-10-151-1/+0
|
* Simplify ray handling in directn.cc.Robert Vollmert2009-10-151-4/+1
| | | | | | | | | | | | Existence of a valid ray is now tracked with a separate boolean have_beam. fallback_ray has been removed almost completely. The change appears fine in console crawl; tiles untested at the moment. find_ray now correctly returns false for rays with source == target. Also rename CMD_TARGET_HIDE_BEAM to CMD_TARGET_TOGGLE_BEAM.