This has been broken since b1c5307eb1
changed the type of gr_palette from `uint8_t[256*3]` to
`array<rgb_t, 256>`. Remove it, since no one has reported it in 10
years.
Due to original game bugs, which Rebirth intentionally replicates in
order to match the balance of the original game, the logic looks odd.
Add comments explaining that the oddity is intentional.
Prefer creating a copy explicitly, then appending or extending it as
needed, rather than using `__add__` and allowing it to duplicate the
sequence. `__add__` has two undesirable properties in this script:
- Using `A + B + C` can create multiple temporaries unnecessarily.
- `A + B` typically requires that `A` and `B` be the same type of
sequence, but this script does not need to require that. Using an
explicit copy+extend allows `A` and `B` to be different types of
sequence.
Make use of the latter property to turn some member variables that were
`list` for the sake of `__add__`'s type requirement into `tuple`, since
they are never rewritten.
The link line is not used by clang, but is recorded in the hope that it
is useful for other tools. Stabilize the output by requesting the
`str`, not the `repr`, of the input nodes. `repr` in scons-4.4
generates a bare Python repr, rather than any useful text. In addition
to not being useful, the bare repr exposes the memory address of the
`SCons.Node.FS.File`, which can vary from run to run even with no
changes to the code, causing needless rebuilds of the compilation
database. The `str` of a node is its filename, which is stable across
runs.
env['CPPDEFINES'] may return a deque object in scons 4.5.0+ (see
SCons/scons#4321).
Explicitly convert it to a list where needed.
Tested with scons 4.4.0, 4.5.0, 4.5.1 and 4.5.2.
According to `timeit`, this is slightly faster. Also, `.copy()` will
work when `V` is a `collections.deque`, but `[:]` fails in that case.
SCons issue https://github.com/SCons/scons/issues/3876 (first released
in SCons 4.5.0) changed the storage of the `CPPDEFINES` variable from a
`list` to a `deque`, which broke use of `env.get(name, [])[:]`, since
`deque` cannot copy itself using `[:]`. Switch to using `.copy()` to
obtain a shallow copy.
```
>>> # timing comparison
>>> timeit.timeit(stmt='a.copy()', setup='a = [1, 2, 3, 4]')
0.05652548000216484
>>> timeit.timeit(stmt='a[:]', setup='a = [1, 2, 3, 4]')
0.06801111809909344
```
```
>>> # deque cannot copy using slice notation
>>> a = [1, 2, 3]
>>> from collections import deque
>>> b = deque([1, 2, 3])
>>> a.copy()
[1, 2, 3]
>>> a[:]
[1, 2, 3]
>>> b.copy()
deque([1, 2, 3])
>>> b[:]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence index must be integer, not 'slice'
```
Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/704>
Switch from showing the Python tuple, which is unambiguous but hard to
run at a prompt, to showing the output of `shlex.join`, which is
normally correct for use at a shell prompt, and should still be
reasonably unambiguous.
clang-15 warns for a write-only parameter. The parameter is only used
in a debug print, which has been commented out since the code was
originally imported. Remove the parameter and the commented print.