Commit graph

320 commits

Author SHA1 Message Date
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
Yamagi Burmeister
95bdec447d Include wchar.h, required by wmemset(). 2019-02-04 17:10:28 +01:00
Neil Richardson
a83add6ea9 Fix case error for linux -> win32 cross compile 2019-01-13 20:40:58 +01:00
Jonathan Bergeron
d82708b448 added windows implementation of sys_removedir and used snprintf in the unix one 2019-01-13 20:33:30 +01:00
JBerg
867046bb8b requested fixes my last commit: proper null checks + undid my removal of a slash + fixed my previous use of va() 2019-01-13 20:32:39 +01:00
JBerg
be8bab6603 added feature to delete savegames 2019-01-13 20:32:39 +01:00
Yamagi Burmeister
7b200208c5 Fix the signal handler.
The signal handler was always fishy since it modified the global process
state but worked on all common platforms. libcurl turns the process into
a multithreaded environment, thus breaking that fragile construction.
After the signal handler was called the global state is inconsistent and
there's a high chance of things going wrong. For example at the net curl
download or when setjmp() is called in Qcommon_Frame().
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
5b44c9f3b4 Make the (new and old) download code UTF-8 compatible.
- Replace all remove() with Sys_Remove().
- Implement Sys_Rename() and replace all rename() with it.

This is believed to close #348.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
4443d0a2eb Fix Windows build.
Note to me: Ask contributors if they've tested their changes on Windows.
2018-11-22 16:55:08 +01:00
Denis Pauk
1b2708c06e cppcheck fixes.
In src/backends/unix/network.c:
* line 181: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
* line 276: The scope of the variable 'tmp' can be reduced.
* line 665: The scope of the variable 'mcast_addr' can be reduced.
* line 665: The scope of the variable 'mcast_port' can be reduced.
* line 666: The scope of the variable 'error' can be reduced.
* line 775: The scope of the variable 'i' can be reduced.

In src/backends/windows/network.c:
* line 186: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
* line 287: The scope of the variable 'tmp' can be reduced.
* line 707: The scope of the variable 'mcast_addr' can be reduced.
* line 707: The scope of the variable 'mcast_port' can be reduced.
* line 1049: The scope of the variable 'err' can be reduced.
* line 1163: The scope of the variable 'i' can be reduced.

In src/client/menu/menu.c

arrayIndexOutOfBounds:
* line 1921: Array 'creditsIndex[256]' accessed at index 256, which is out of bounds.

variableScope:
* line 332: The scope of the variable 'item' can be reduced.
* line 533: The scope of the variable 'x' can be reduced.
* line 533: The scope of the variable 'y' can be reduced.
* line 838: The scope of the variable 'b' can be reduced.
* line 864: The scope of the variable 'b' can be reduced.
* line 1910: The scope of the variable 'n' can be reduced.
* line 2199: The scope of the variable 'str' can be reduced.
* line 2812: The scope of the variable 'length' can be reduced.
* line 2813: The scope of the variable 'i' can be reduced.
* line 3838: The scope of the variable 'c' can be reduced.
* line 4112: The scope of the variable 'scratch' can be reduced.
* line 4181: The scope of the variable 'i' can be reduced.
* line 4345: The scope of the variable 's' can be reduced.

In src/game/player/hud.c

arrayIndexOutOfBounds:
* line 132: Array itemlist[43] accessed at index 255 which is out of bounds.
Itemlist assigned only once, and has only 43 items, better ignore unexisted items.

variableScope:
* line 82: The scope of the variable 'n' can be reduced.
* line 217: The scope of the variable 'x' can be reduced.
* line 217: The scope of the variable 'y' can be reduced.
* line 218: The scope of the variable 'cl' can be reduced.
* line 583: The scope of the variable 'cl' can be reduced.
2018-11-12 22:59:10 +02:00
Yamagi Burmeister
bfebcf0055 Remove unnecessary enforcement of the EUID and EGID.
I guess that these calls were added since dlopen() might ignore the
global LD_LIBRARY_PATH if EUID != UID. In Yamagi Quake II this isn't
a problem because we're enforcing EUID == UID in main() and don't use
LD_LIBRARY_PATH anyways.

These calls broke the jack audio server and maybe some other programs.
The problem was debugged by @ScrelliCopter. This commit closes issue
#270.
2018-11-01 17:09:53 +01:00
Yamagi Burmeister
b9e5306c84 Fix memory allocation on Windows.
* Take the cache line roundings into account when allocating a hunk.
* Use size_t were apropriate.
* remove some unnecessary and likely broken calls.

Another case of: "How could this ever work"?
2018-10-25 18:44:24 +02:00
Yamagi Burmeister
80ef326927 Fix map loading on OS X.
@DanielGibson pointed out that _SC_PAGESIZE itself is too big,
_SC_PAGESIZE - 1 is correct. Also apply a small performance
optimization by querying _SC_PAGESIZE only once.
2018-10-09 19:11:47 +02:00
Yamagi Burmeister
b876579d4d Hunk allocation for FreeBSD 2018-10-08 22:29:45 +03:00
Denis Pauk
64babe9422 Allocate hunk equal to filesize 2018-10-08 22:29:45 +03:00
Denis Pauk
659d8e15c5 Add support for 32k+ marksurfaces in map 2018-10-08 22:29:45 +03:00
Yamagi
881d9afda6
Merge pull request #322 from Smilo-platform/master
Fix IPV6 networking
2018-10-01 17:33:04 +02:00
Yamagi Burmeister
012ab85b31 On Windows we need to pass wchar strings to remove().
Until now the server just called remove() to delete the servers state
from the HDD. That was fine on Linux were UTF-8 is used but failed
silently on Windows in case that the working dir path had some Unicode
characters. Replace remove() by Sys_Remove(), on Linux it's just a
wrapper around remove() on Windows it does a UTF8->UTF-16 conversion
and calls _wremove(). This fixes issue 318.
2018-09-30 18:57:06 +02:00
Unknown
79bcd35a3d Changed ipv6 address 2018-09-12 08:55:13 +02:00
Unknown
220f0a940a Fixed ipv6 address to use 0.0.0.0 instead of 127.0.0.1 2018-09-11 15:35:21 +02:00
Unknown
b5b491710c Fixed incorrect ipv6 local address 2018-09-11 15:07:37 +02:00