clang rejects the entire database if any entry lacks a 'file' key,
regardless of whether the entry is used.
Fixes: bc6d043f5d ("Extend SConstruct compilation_database support to cover Program()")
The existing handling always wrote to slot 0, but did so in a convoluted
way. The variable names suggest this was not intended, but no one has
ever reported it as broken, and some otherwise valid data files may
depend on this quirk.
D1 and D2 used logically equivalent code, but it was not the same text,
so the unification project split this with a `#ifdef`. Since the code
does the same thing in both games, combine it into a non-guarded
statement.
Two tests in series examined the object for a type of OBJ_ROBOT. Fold
the test together.
The next test also examines ->type. Move that to an else since it
cannot be true if the first test was true.
The segment list is written to `hit_data`, but `hit_data` goes out of
scope before the segment list is read back. Skip collecting it, since
it was effectively write-only on this path.
Commit 1a9fba804d made an incorrect simplification. It observed that
thief robots are not boss robots and vice versa, and from that changed:
```
if (is_thief) { drop_stolen_items(); }
if (is_boss) { start_boss_death_sequence(); }
else if (death_roll) { start_robot_death_sequence(); }
else { regular_death(); }
```
to
```
if (is_thief) { drop_stolen_items(); }
else if (is_boss) { start_boss_death_sequence(); }
else if (death_roll) { start_robot_death_sequence(); }
else { regular_death(); }
```
This was incorrect, because although a thief is not a boss, a thief does
need to proceed through the other non-boss if tests. This error caused
a thief not to explode on death, and instead continue to fly around and
absorb weapon fire.
Fix the logic error by removing the incorrect `else`, so that a thief
can be tested for is_boss, get false, and then proceed through the
non-boss death logic.
Fixes: 1a9fba804d ("Avoid repeated valptridx dereferences in multibot.cpp")
gcc-12 warns that the snprintf to initialize `tempname` may be
truncated. The variable is never used after it is initialized, so
delete the initialization and declaration.
Previously, the supplied pointer was converted to an array index, then
passed to valptridx::idx for validation. If the index_type is smaller
than std::size_t, this would truncate the value before validation.
Certain out-of-range indexes would be in-range after truncation, and
incorrectly not be reported.
Reorder the check to validate the index against the array size before
truncation.
Players are not robots, but the show-path cheat tried to pretend they
are, and triggered a BUG warning[1] when looking up robot information
from the player object. Fix this by passing in the robot_info when the
caller is providing a robot, and a named `nullptr` value (as
`create_path_unused_robot_info`) when the caller is providing a
non-robot object.
[1] As below, but repeated many times
```
similar/main/ai.cpp:1905: BUG: object 0x555555858550 has type 4, expected 2
similar/main/ai.cpp:1974: BUG: object 0x555555858550 has type 4, expected 2
```
Zero the entire array, then overwrite the leading portion with the
received data. This permits the compiler to do a fixed number of large
stores, instead of a variable number of small stores.
The type aliases are sufficient. Individual bytebuffer_t
implementations can define a `static constexpr` member `endian` from the
type alias and rely on `std::integral_constant<T, V>::operator()`
instead of defining a `static` method just to return an instance of the
`std::integral_constant`.