YQ2 has a much more precise Sys_Milliseconds() than Vanilla Quake II and
it always start at 0, not some other semirandom value. If the client is
started by `./quake2 +connect example.com" or all user just walk their
way to the menu there's a very high propability that two ore more
clients end up with the same qport... We can't use rand(), because we're
always starting with the same seed, so all clients generate more or less
the same random numbers and we end up in the same situation.
So just call time(). It's portable and more or less in line what the
original code did for Windows. It may be necessary to implement some
kind of fallback logic just in case that still two clients end up with
the same qport, but that's a task for another day.
Closes#537.
This was introduced in 220f0a9 as fix. The submitter, @DanielGibson and
myself missunderstood the code:
* If net_interface is NULL (which in the current code can never happen),
an empty string (the user sets the `ip` cvar to an empty string) or
"localhost" (the default) we want to set `Host` to the unspecified
address. getaddrinfo() will return in6addr_any fot it and we'll bind
to any available address.
* "0.0.0.0" isn't the IPv4 any address, it's the unspecified address.
Thats correct and the code was working fine for IPv4. But at least
the submitter and me confused it with the any address (which is
0.0.0.0/0). So setting `Host` in the IPv6 to `::/128` (the lowest IPv6
address) or `::/0` (any IPv6) is wrong, it must be `::` (unspecified
IPv6 address)!
Have a look at RFC 3493 for the details.
I'm doing the change only for the Unix code path, not for Windows. For
some reason everything besides `::/128` or `::1` doesn't really work on
Windows and I don't know why. Even more scary is that changes to the
IPv6 case also break IPv4 sockets. Since the whole network.c for Windows
is confuse and rather hard to understand (there's still IPX support in
it) I'm leaving things as they are.
This was requested several times, the last time in pull request #523.
Only the optimization level, warning level and debug stuff may be
overridden. All other options are enforces because they're required.
While here add a new variable to force a debug build: `make DEBUG=1`.
C11 _Noreturn is only accepted on function declarations, not on function
pointers, so we can't use it on callbacks like game_import_t.error and
refimport_t.Sys_Error. Use a separate macro for those.
The problematic situation doesn't currently happen because the Makefile
hard-codes -std=gnu99, which disables C11 features; but removing
-std=gnu99 (resulting in the compiler's default, currently gnu11) causes
compilation failures with at least gcc 9.x.
Signed-off-by: Simon McVittie <smcv@debian.org>
Until now CFGDIR was hardcoded to YamagiQ2 on Windows and .yq2 on
everything else. Sometimes it's desireable to have a separate dir
for some tasks, for example whentesting things that introduce new
cvars. Add -cfgdir to override CFGDIR.
This allows for longer arguments passed to cvars, gl_nolerp_list is a
good example for a case were a token length of 128 is too short. Keep
the mapname[] buffer in the server struct at 128 bytes to preserve
savegame compatibility.
Closes#526.
In the vanilla code show_hostile was a qboolean what's clearly wrong.
For wome reasons I don't remember I changed it to an integer and added
the casts. This is problematic because show_hostile is derived from
level.time which is a float. The loss in precision broke some corner
cases like monsters becoming activated when they shouldn't.
Found, analyzed and reported by @BjossiAlfreds #525. Closes#525.
Until this commit a cinematic was aborted as soon as any key were
marked down when finishing the user command and sending it to the
server. The whole logic to detect if a key is down is broken, for
example `vid_restart` may leave keys marked down that are in fact
up. And there's the possibility to inject fake key events from
nearly everywhere. I'm not really sure but I suspect that even the
server may be able to inject key events.
Therefore untangle the cinematic abort code from the user command
processing, it should depend only on real key strokes:
1. Introduce a new global variable `abort_cinamatic` and set it to
`cls.realtime` as soon as a key down event is detected. The only
exceptions are Escape and Shift, because opening the menu and
toggeling the console should never abort a cinematic.
2. When starting a cinematic `abort_cinamatic` is set to INT_MAX,
because it needs to be higher than the current `cls.realtime`.
3. When a cinematic is running, `cls.key_dest` is set to `key_game`
(`key_menu` and `key_console` are ignored, keys send to the menu
or the console should never abort a cinematic; `key_message`
can / should never happen while a cinematic is running) and
`abort_cinamatic` is less than `cls.realtime` the cinematic is
aborted.
`abort_cinamatic` less than `cls.realtime` is necessary because the
client needs one frame to pop up the menu or toggle the console and set
the `cls.key_dest` accordingly. `abort_cinamatic == cls.realtime - 1`
is not possible because not every frame finishes a user command.
This closes#502.
An option like this was often requested since I fixed the gun field of
view in e466554. Since the software renderer is missing the ability to
alter the persepective matrix (e.g. something like glFrustrum()) this
fix fakes the offset by manipulating the guns transformation marix.
That's not perfect, the gun distorts if `sw_gunzposition` is set to
anything but `0`. Values up to `8` are more or less okay. Defaults
to `8` which matches the GL renderer default.
Pushing all entities slightly away from non-horizontal may let items to
slide to unreachable locations, or let monsters getting stuck.
This is part of yquake2/xatrix#50