`oldsegnum` is `const`, so the address computed from it cannot change.
Lift the computation of `auto &children` out of the loop.
Reduce the scope of `biggest_val`, since it does not need to outlive the
loop.
- Inline MAX_FCD_CACHE into the definition of Fcd_cache, then rely on
Fcd_cache.size() later.
- Make Fcd_index unsigned. As an index, a negative number is invalid.
- Change flush_fcd_cache to update Last_fcd_flush_time, rather than
requiring callers to do it. Most callers did not update this.
- Change add_to_fcd_cache to validate and reset Fcd_index before use,
rather than resetting after increment. This allows Fcd_index to
become invalid after a write, but it will be reset to a valid value
before it is used again.
- Fix original game bug in add_to_fcd_cache that caused the cache
expiration path to clear the wrong cache entry.
Zero the entire array, rather than adjusting the loop to account for the
count of segments in the level. The array may not need to be zeroed at
all, but this is cheap and guarantees consistent results.
Iterating over it returns each side number in turn. This allows
converting many loops of the form:
```
for (int i = 0; i < MAX_SIDES_PER_SEGMENT; ++i)
```
to the compact form:
```
for (const auto i : MAX_SIDES_PER_SEGMENT)
```
The compact form brings the usual benefit of range-based for: delegating
iteration to the compiler prevents the loop body from skipping a step,
and makes clear in the code that this is the case.
Define separate enum values for rotation data in both the high bits,
where it is usually kept, and the low bits, where it is sometimes used
for math or comparisons.
Define an enum value to represent the composite of the index and the
rotation, since the composite is not suitable for use as an array
subscript. Add helper functions to extract the component pieces.
segment inherits unique_segment, so unique_segment members can be
referenced from an instance of segment. Eventually, segment will be
removed. Adjust references to go through unique_segment to support this
change.
segment inherits unique_segment, so unique_segment members can be
referenced from an instance of segment. Eventually, segment will be
removed. Adjust references to go through unique_segment to support this
change.