Skip to content

Remove globals from fov_diamond and fov_restrictive algorithms#48

Merged
HexDecimal merged 2 commits intolibtcod:developfrom
taiyu-len:reentrant_fov
Apr 4, 2020
Merged

Remove globals from fov_diamond and fov_restrictive algorithms#48
HexDecimal merged 2 commits intolibtcod:developfrom
taiyu-len:reentrant_fov

Conversation

@taiyu-len
Copy link
Copy Markdown
Contributor

For issue #47.
makes diamond raycasting fov, and restrictive fov algorithms reentrant.

for diamond fov, adds a fov_t struct to store all relevant state; the globals, and pointer to the map.
also simplified 2 for loops (the expandPerimiter, and set fov loops).

for restrictive fov, adds 2 double* parameters to the compute_quadrant function, instead of reusing the globals.
also made the compute_quadrant a static function as its not exposed in the headers or used elsewhere.

- place globals and map* into a fov_t object, and modify local functions
  to use it.
- clean up 2 for loops to make them simpler.
- pass in angle arrays as parameters, instead of reusing global.
- make compute_quadrant a static function as its only used locally
- simplify fov clearing loop.
@HexDecimal HexDecimal self-requested a review April 4, 2020 01:33
@HexDecimal HexDecimal merged commit 3fd3fd1 into libtcod:develop Apr 4, 2020
@HexDecimal
Copy link
Copy Markdown
Collaborator

This looks good. Thanks for the extra refactoring and for making this pull request!

@taiyu-len taiyu-len deleted the reentrant_fov branch April 4, 2020 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants