Commit graph

340 commits

Author SHA1 Message Date
Yamagi
df845e0f67 Avoid the use of wcscat_s() since it's unavailable under Win XP.
Code around it by using `wcsncpy()` and `wcscat()` combined with a
manual length check. This should be enough to make YQ2 working on Win
XP again.  Please note, that we don't support any Windows older than
10. However we still try to avoid breaking them.

Based on an idea by @ carlo-bramini, closes #994.
2023-04-22 16:44:26 +02:00
Yamagi
8b12b017f7 Handle SIGBUS. Or at least try it.
I was reported a strange problem were GL3 is crashing with SIGBUS while
enumerating the GL extensions. To me it looks like a problem in Nvidias
FreeBSD driver, which for some reason doesn't reproduce on my machine.
However it' hard to tell what exactly happens without a full backtrace
and the user is unable to provide one... For the future try to handle
SIGBUS to catch those problems.
2022-11-14 21:37:47 +01:00
Denis Pauk
c890e59aaa Reset to default font settings instead white on black 2022-10-23 22:44:30 +03:00
Denis Pauk
66d0751caf Linux: Add color output for console
Usecase: show map name on level load.

Add colorterminal cvar for disable.

xfce4-terminal has:
 * TERM=xterm-256color
 * COLORTERM=truecolor
2022-10-23 22:44:30 +03:00
Yamagi
72ec12f8df Fix two 'comparison will always be false' warnings:
* Check the return value for `_wfullpath()`, not the returned pointer.
* Check first byte of char array, not the array itself.
2022-10-09 11:21:21 +02:00
Daniel Gibson
86811a4c24 Fix fallback when window couldn't be created because renderer is unsupported
For example, on Windows with AMDs drivers, GLES3 isn't supported,
so CreateSDLWindow() will fail. We should just try the regular GL3
renderer then instead of exiting with Com_Error()

Also make (Windows') Sys_Error() print to stdout (in addition to stderr),
so errors end up in stdout.txt as well (like all other messages).
2022-06-11 17:57:29 +02:00
David Carlier
7ce0964b9b saving data into Haiku system user config. 2022-04-02 04:22:55 +00:00
Daniel Gibson
d0507ef04a Win32 Sys_Quit(): Don't use printf() after fclose(stdout)
causes an assertion in MSVC's CRT
2022-03-12 17:01:37 +01:00
Daniel Gibson
37b1b708c6 Fix some legitimate warnings from MSVC
MultiByteToWideChar() and other functions handlings WCHAR strings usually
expect length-like arguments in number of WCHARs, not in size in bytes
2022-03-12 17:01:37 +01:00
Simon McVittie
d17c00dbd2 backends: Only enable ARM "RunFast" mode when targeting hardware FPU
Older ARM ABIs like Debian armel (ARMv5 EABI softfloat) don't use
or require a hardware FPU, so they can't execute the fmrx and fmxr
instructions. Only do this in hardfloat configurations that guarantee
VFP instructions are available.

The client might not be practically usable on ARM softfloat (although
nobody has reported that it isn't...) but the dedicated server is probably
fine, and ceasing to be able to build either would be a regression.

Signed-off-by: Simon McVittie <smcv@debian.org>
2021-10-05 14:05:15 +01:00
Yamagi
fb080fc32c Add missing semicolon, Windows build fix 1/2. 2021-06-29 08:58:40 +02:00
Yamagi
61c08eee13 Fix ASAN and UBSAN builds, enhance sanitizers a little bit.
At least for LLVM / Clang the -fsanitize= option must be passed to the
linker before any objects or libraries, otherwise the sanitizers will
either noch link or are disfunctional. Split LDFLAGS into LDFLAGS for
flags and LDLIBS for librariers, pass LDFLAGS before any objects and
LDLIBS after all objects. While at it set RTLD_NODELETE so that shared
libs opened by dlopen() are never deleted from memory when building
with sanitizers.
2021-06-26 16:28:08 +02:00
Yamagi
c9f7faa7b1 Add logic to mark search path entries as required or optional.
Until 7.45 we supported adding non existent dirs to the search path,
8.00 bails out if it cannot at a dir. It turned out that some users
install the binary through their package management (SYSTEMWIDE is set),
but use local game data. This case was broken, because the SYSTEMDIR
doesn't exist. Fix this by marking the SYSTEMDIR as optional.

Closes #724.
2021-06-20 18:24:22 +02:00
David Carlier
53c684525f solairs/illumos build fix proposal. 2021-06-13 08:25:56 +01:00
Yamagi
33148a3085 Revert "unix network little change proposal. socket port fits within unsigned 16 bits type."
This reverts commit df3b2307f2.
2021-04-10 17:40:03 +02:00
Yamagi
1bae4e679f
Merge pull request #695 from devnexen/arm_runfast_mode
Little optimisation attempt targeted only for ARM 32 bits,
2021-04-07 09:32:18 +02:00
David Carlier
159f5e3ae4 Little optimisation attempt targeted only for ARM 32 bits,
enabling "RunFast" mode ; benefits might depend on the board
 at hand.
2021-04-04 13:15:42 +01:00
David Carlier
df3b2307f2 unix network little change proposal. socket port fits within unsigned 16 bits type. 2021-04-01 19:39:23 +01:00
Vasily Postnicov
8ba25e82c9 Fix segmentation fault on FreeBSD.
Specify correct protection flags when calling mmap() on FreeBSD.
prot | PROT_MAX (prot) are the correct flags because just PROT_MAX
(prot) leaves current protection flags set to PROT_NONE which causes
segmentation fault when reading or writing to the mapped region.
2021-02-17 22:16:58 +03:00
Yamagi
69ba055c2c Minimal error checking for Sys_Mkdir() on windows. 2020-12-31 09:09:09 +01:00
Yamagi
60d881437b Minimal error handling for Sys_Mkdir() under unixlike platforms. 2020-12-31 08:55:09 +01:00
Yamagi
8e223b2743 Make sure that the config dir exists.
Since 1a913eb we're calling realpath() on every dir and bail out if the
real path isn't available. If the game is started the first time, the
configuration dir doesn't exist at the first realpath() call and the
game errors out. Always create the configuration dir when determining
it's path.

This didn't happen on Windows because the configuration dir was created
when opening stdout.txt right after we entered main().

TODO: Sys_Mkdir() should grow at leas a little bit error handling. We're
silently ending up in -portable mode if the configuration dir couldn't
created.
2020-12-30 18:45:16 +01:00
Simon McVittie
45b922372a signalhandler: Fix a typo
Detected by Lintian, a QA tool used in Debian.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-10-31 11:59:22 +00:00
Yamagi
93008da0eb Make sure that the config dir exists before reopening stdout.
Without this to stdout.txt and stderr.txt are created at the first
start.
2020-10-20 09:38:26 +02:00
Yamagi
21d7c85044 Mark path passed to Sys_Mkdir as const. 2020-10-20 09:35:07 +02:00
Yamagi
1a913eb7d1 Resolve pathes before adding them to the search path.
Working with canonical fullpathes everywhere makes debugging easier.
And it will be used in a later commit to make sure, that each path is
added only once.
2020-10-20 08:20:20 +02:00
David Carlier
915c680f52 DragonFlyBSD build fix. 2020-10-10 14:29:28 +01:00
Yamagi
d5dcf3a772 Fix several inconsistencies and typos in console output. 2020-10-08 12:38:29 +02:00
Yamagi
dfaf33e478 Force stdout and standerr on Windows to unbuffered mode.
Normally stdout and stderr are buffered. In case of a crash the last
lines aren't written to the stdout.txt, making post mortem debugging
difficult. Forcing both FDs to unbuffered mode ensures that everything
gets written. The performance impact is negliable.
2020-10-06 17:22:50 +02:00
Yamagi
741ffcdb1c
Merge pull request #604 from devnexen/last_bit_for_haiku
Last bit for proper Haiku support.
2020-10-06 16:55:41 +02:00
David Carlier
800cdf9617 Last bit for proper Haiku support.
Even tough it is a multi user os, due to BeOs heritage and being backwards
compatible with, the desktop runs as root, thus its dog get eaten after all...
2020-10-02 14:36:57 +00:00
David Carlier
6bb23c908f Little simplification for NetBSD, sysctl works just fine too. 2020-09-30 22:56:19 +01:00
David Carlier
e4fac541a9 Haiku support, code simplification.
using more straightforward approach to get the current binary path.
Actual approach more fit to get other infos (e.g. address mappings and so on).
2020-09-01 11:27:26 +00:00
David Carlier
5e89f96067 Hunk: FreeBSD set the map permission to max read and write
which cannot be made executable afterwards.
2020-08-24 23:45:54 +01:00
David Carlier
0200434187 backtrace support rework proposal.
Linux/Solaris supports it in the libc however, BSD in general, Haiku
relies on an external library.
2020-08-03 10:19:41 +00:00
David Carlier
6c4187a6e3 using custom sting copy fn instead 2020-06-21 11:00:20 +00:00
David Carlier
a2b274d1a5 Haiku porting proposal. 2020-06-20 19:05:55 +00:00
Linux User
c4e43f0403 musl libc and uclibc do not have backtrace() 2020-04-25 20:30:55 -07:00
David Carlier
e50fb5dbe4 macos also support backtrace api. 2020-03-27 19:01:36 +00:00
Yamagi
16ea835aa1 Fix partial broken connection to IPv6 / q2ded listening on IPv6 addrs.
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.
2020-03-24 13:38:06 +01:00
Yamagi
a5eb0b16da Fix build on Windows after last commit. 2020-03-16 16:02:03 +01:00
Yamagi
b2f0430c9f Hack a simple way to specify the CFGDIR at command line.
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.
2020-03-16 15:49:04 +01:00
David Carlier
0c1afcdfc1 Hunk API, using FreeBSD super page for large requests. 2020-02-08 20:55:50 +00:00
Denis Pauk
9f2f249aaa use snprintf in unix/system 2020-01-30 22:28:52 +02:00
Denis Pauk
b1d3ddebbc use vsnprint in Com_Printf functions 2020-01-30 22:28:13 +02:00
David Carlier
28b65d11f8 unix network little change proposals/few possible leaks fixes 2020-01-26 11:43:22 +00:00
Daniel Gibson
d615190e36 Fixes for PVS Studio warnings: warnings in unix/main.c and sv_send.c 2019-08-24 20:40:06 -01:00
Yamagi
d24335a97c
Merge pull request #384 from devnexen/netbsd_little_update
hunk api mremap supported by NetBSD as well.
2019-04-08 14:00:16 +02:00
Yamagi Burmeister
209bd9d529 Replace GetSystemTimeAsFileTime() with GetPerformanceCounter().
GetSystemTimeAsFileTime() is okay as long as the game runs fullscreen.
For some reasons it's resolution degraded to ~16ms as soon as the game
runs widowed... Better use GetPerformanceCounter(), its more reliable
and the recommended API for timecounters.
2019-04-08 13:56:56 +02:00
David Carlier
65357c9ba5 hunk api mremap supported by NetBSD as well. 2019-03-29 17:24:07 +00:00