Commit graph

2026 commits

Author SHA1 Message Date
Yamagi
c68aade396
Merge pull request #275 from 0lvin/3dhaptic
Use  SDL_HAPTIC_CARTESIAN as effect direction.
2018-02-15 07:35:58 +01:00
Daniel Gibson
3acf5f0cba VID_WriteScreenshot() PNG compression level must be < 10
10 is no valid zlib compression level, so make sure it's not used

Thanks to @maraakate for pointing this out!
2018-02-15 00:39:43 +01:00
Denis Pauk
80616a418e Reuse SWimp_Init from refresh.c 2018-02-14 23:07:20 +02:00
Denis Pauk
b376c7e0d2 correctly exit if have not found console fonts 2018-02-14 23:07:20 +02:00
Denis Pauk
24b7cb3529 Remove unused K_WORLD_* from Q_KEYS 2018-02-14 23:07:20 +02:00
Denis Pauk
c68fd0be5b Add 3d haptic/SDL_HAPTIC_CARTESIAN with distance and orientation 2018-02-14 23:07:20 +02:00
Yamagi Burmeister
ec1733fb97 Rename 'intensity' to 'gl1_intensity', 2018-02-14 09:35:54 +01:00
Yamagi Burmeister
fe6e147c2b Update cvar documentation.
* Explain command line arguments.
* Document busywait and datadir.
* Distinguish between all renderers and all GL renders.
2018-02-14 09:11:51 +01:00
Yamagi Burmeister
278ff83ad4 Always initialize the busywait cvar. 2018-02-13 21:37:50 +01:00
Yamagi Burmeister
dd43f88450 Take time used to process render and packetframes into account.
Until now we did an easy calculation to determine the frame timing:
1000000 microseconds (== 1 second) / targetframerate == delay between
frames. This works if the CPU and GPU are fast enough since the time
process to process the frame is negligible. But if one of them is too
slow or the GPU driver takes too long (see issue #277 for an example)
we render too few frames.

Work around this by calculating the average time used to process the
last 60 render oder packet frames and take that into account when
determining the delay between the frames. With this change even my
rotten AMD Radeon and it's broken Windows GL driver is able to hold
the displays famerate (enforced by vsync) just fine.

While here add a 5% security margin to our target packet frame rate if
the vsync is enabled. Just to be sure that we never process more render
than packet frames.
2018-02-13 17:36:15 +01:00
Yamagi Burmeister
b80ff7f40c Implement a 'busywait' cvar to force the client and server to busy wait.
Sleeping with Sys_Nanosleep() is fair enough but has the problem that we
may get scheduled away and the hosts power management inteferes with our
interal timings. While this wasn't a big issue on FreeBSD and Linux it
let to serious timing issues in Windows.

There're several reports in the net, apperently everything below 5ms is
very inaccurate on Windows:
* https://stackoverflow.com/questions/7827062/ \
   is-there-a-windows-equivalent-of-nanosleep/7827446#7827446
* https://lists.gnu.org/archive/html/bug-gnulib/2010-04/msg00045.html
2018-02-13 17:36:15 +01:00
Yamagi Burmeister
832f3f6497 Implement vid_displayrefreshrate to override the displays refresh rate.
Modern LCD displays often haven't itegral refresh rates like 60hz but
fractional ones  like 59.95hz. SDL communicates the refresh rate as
integer. On X11 the rate is rounded up or down with round(), but on
Windows it's (at least on my system with an AMD Radeon) truncated...
So on an 59.95hz display it's just 59hz, Quake II renders 0.95 frames
too few and the user sees microstutters.

And return the actual / requested display frame rate increased by one
to work around inaccuracies in Quake IIs internal timing. It should be
a problem if we're running a little bit too fast.

This is belived to fix at least a part of issue #277.

Refreshrate 2
2018-02-13 17:36:15 +01:00
Yamagi
f0240af308
Merge pull request #278 from DanielGibson/remember-addressbook
Don't forget entries of Multiplayer "Address Book"
2018-02-13 17:35:59 +01:00
Daniel Gibson
c2061e8c83 Use const char* instead of char* in NET_StringToAdr() 2018-02-12 13:37:58 +01:00
Daniel Gibson
1c7b02cc85 Make sure Q2 doesn't "forget" contents of server "address book"
The problem was that the cvars were only initialized (with CVar_Get())
if you opened the address book menu.
So if you start (and possibly run) and quit the game /without/ opening
that menu (or at least the "join network server" menu), the game will
not save those cvars to the config when it next writes it.

To prevent this, *always* initialize the cvars in M_Init().
2018-02-12 01:03:06 +01:00
Yamagi Burmeister
a1aac4e56d Fix stupid bug in e30f824. :(
It's VectorCopy(src, dest) and not the other way round. Clion noticed
that, but neither clang nor gcc complained that tmp was used
unitialized.
2018-02-07 19:02:13 +01:00
Yamagi Burmeister
17a5106492 Unicode compatibility for zlib on Windows.
There were two ways to implement this. One was to go with the stuff
already included in minizip and one to implement our own wrapper around
fopen(). This is the second options since @DanielGibson convinced me
that it would be safer.
2018-02-06 18:44:44 +01:00
Yamagi Burmeister
716d72a295 Update minizip to version 1.2.11. 2018-02-06 15:11:36 +01:00
Yamagi Burmeister
495b7c5d6b Save some CPU cycles and apply the cvar replacements only once. 2018-02-05 18:30:45 +01:00
Yamagi Burmeister
582c1062cb Fix an "Unused variable" warning. 2018-02-05 18:29:29 +01:00
Yamagi Burmeister
ba4f91f619 Fix a compiler warning on 32 bit.
Hopefully we'll never allocate more than 2^32 bytes of memory for
surfaces. :)
2018-02-05 18:27:34 +01:00
Yamagi Burmeister
68e1cb6d00 Add stb_image_write.h to cmake. 2018-02-05 18:25:55 +01:00
Yamagi Burmeister
1e6f790d51 Make the stdout and stderr redirects unicode aware. 2018-02-05 18:20:41 +01:00
Yamagi Burmeister
3b810ba51e Convert stb_image_write.h to Q_fopen() to be able to create screenshots. 2018-02-05 18:10:22 +01:00
Yamagi Burmeister
6b13d77c36 Change the current working directory before writing save games.
We can't rely on the game.dll being unicode conformant. Work around
that by changing the current working directory before calling into
the game.dll, pass a non unicode string to it and chang back after
we return.
2018-02-05 18:00:28 +01:00
Yamagi Burmeister
3634ed7013 Implement -datadir, deprecate the basedir cvar.
To be able to pass UTF-8 encoded pathes through cvars both the cvar
subsystem and the command parser would need a fair amount of UTF-8
understanding. And I'm not the poor soul that's going to implement
that. Therefor pass the datadir trough a global variable.
2018-02-05 16:19:02 +01:00
Yamagi Burmeister
efcaf17f69 Make SetExecutablePath() on Windows unicode compatible. 2018-02-05 10:01:21 +01:00
Yamagi Burmeister
a87e34906c Implement Q_fopen() for Windows.
This is done in shared.c so that's available for both the client /
server / renderer and the game. A work around for older game DLL will
be added at a later time.
2018-02-05 09:36:33 +01:00
Yamagi Burmeister
37ea3e1d58 Introduce a wrapper Q_fopen() and replace fopen() with it.
On Unix platforms unicode is implemented through UTF-8 which is
transparent for applications. But on Windows a UTF-16 dialect is
used which needs alteration at application side. This wrapper is
another step to unicode support on Windows, now we can replace
fopen() by a function that converts our internal UTF-8 pathes to
Windows UTF-16 dialect.

This is a noop for Unix platforms. The Windows build is broken,
the compiler errors out in shared.h. This will be fixed in a
later commit.

Caveats:
* fopen() calls in 3rd party code (std_* and unzip) are not replaced.
  This may become a problem. We need to check that.
* In the Unix specific code fopen() isn't replaced since it's not
  necessayry.
2018-02-05 07:43:26 +01:00
Yamagi Burmeister
bcb7364507 Convert library loading to widechars. 2018-02-04 17:06:49 +01:00
Yamagi Burmeister
a1ba33e6d9 Declare is_portable only once in frame.c and not in each backend. 2018-02-04 16:48:40 +01:00
Yamagi Burmeister
b3562015b0 Remove Sys_SendKeyEvents().
That function did nothing, we can just call IN_Update() directly...
2018-02-04 16:45:32 +01:00
Yamagi Burmeister
54ab3f75db Don't use a DOS path for the home directory, but a UTF-8 path.
With this commit YQ2 is able to start and run on ReFS volumes. :) At
least as long as neither the binary path, the game data path nor the
path to the users home directory contain anything but ASCII characters.

Please note: This make break some corner cases with hore directories
containting unicode characters. They worked until now by pure luck.
A better solution providing full unicode support will be committed
in the next few days.
2018-02-04 13:22:27 +01:00
Yamagi Burmeister
4ca38f92fa Convert Sys_Mkdir from DOS to WinAPI.
With this we're able to create directorys with Unicode characters
anywhere in the path.
2018-02-04 13:04:31 +01:00
Yamagi Burmeister
e8c3686e4c Use MAX_OSPATH instead of MAX_QPATH.
Those are external pathes, not internal ones. MAX_QPATH with only 64
characters is much to small for them.
2018-02-04 12:59:10 +01:00
Yamagi Burmeister
0eca30cb96 Convert the Sys_Find*() functions from the old DOS interface to WinAPI.
This brings at least two big advantages:

* No more 8.3 filename fuckups. Until know base0.pak and base0.pak_bak
  was the same file for Quake II because only the first 3 characters of
  the file extension were taken into account.
* Search pathes can contain any Unicode character.
2018-02-04 12:53:50 +01:00
Yamagi Burmeister
e9615608a8 Remove CompareAtributes().
There's no need to exclude directories from search by flags. In fact
the Unix backend has worked nicely for years without it... Sadly we
can't remove the now superfluous 'canhave' and 'musthave' attributes
from Sys_FindFirst() and Sys_FindNext() since they're defined in
shared.h and may be used from custom game DLLs.
2018-02-04 11:49:03 +01:00
Yamagi Burmeister
a65401d1af Rename mem.c to hunk.c.
hunk.c better describes the purpose of the code and matches the unix
backend.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
2096d57eb8 Cleanup the system specific code.
* Remove a bunch of unnecessary functions.
* Reorder functions into logical groups. The orderig is now the same
  on Unix and Windows.

While at it add several TODOs to the code. There's not need for special
library loading functions for the game, the Windows backend still uses
a lot of old and fishy DOS functions, etc. All this will be done at a
later time.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
acb50c6907 Move the platform independent stuff from main() into Qcommon_*().
There's no need to duplicate machine independent parts of the client
initialization and the main loop for every platform.

While at it remove the nearly empty unix.h header and move Windows
main() into an own file. Not both platform have the same basic layout.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
bed6439d19 Convert the quake2.exe wrapper to a Windows GUI application.
While building the wrapper as a console application is completely fine
there're some advantages by creating a "real" Windows GUI Application:

* Console applications always spawn an annoying console window.
* Windows GUI applications seem to have a much lower chance to trigger
  my new best friend, the Windows Defender. As a console application
  quake.exe triggered every time I started it, as Windows GUI
  application not only once.

Use WinMain() instead of wWinMain() because MinGW doesn't know about
the later and it doesn't matter anyways.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
7ee34acae8 Remove winquake.h
The only thing that header did was to include windows.h.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
cfddff132b Switch the windows backend SDLmain.
libSDLmain.a has to be linked and must run anyways. So there's no need
for us to reinvent the wheel, just rely on SDLs process setup, argument
parsing, message handling and so on. As a nice side effect this may fix
some strange bugs related to message handling and argument parsing...
2018-02-04 11:35:10 +01:00
Daniel Gibson
d107d999da
LICENSE: Properly document stb_image(_write).h
It's not stb.h and the github project should probably be linked
And now the licensing is a bit more verbose (Dual-Licensed under Unlicense and MIT 
instead of custom Public Domain license).
2018-02-04 05:15:20 +01:00
Daniel Gibson
833738b7e7 Update stb_image_write.h to latest release (1.08)
My modifications (jpeg writing and supplying zlib compressor for better
PNG compression) have been merged upstream, so from now on updates
should be easy and painless.

(Sean renamed my stbi_png_level to stbi_write_png_compression_level)
2018-02-04 00:03:51 +01:00
Yamagi Burmeister
601a06f728 Introduce in_grab 3, always ungrap the mouse in console, menu, etc.
Until now we had 3 modes:
 0 -> never grab the mouse.
 1 -> always grab the mouse
 2 -> ungrab the mouse if the game is windowed and the console or the
      menu is opened or a cinematic is playing.

The 3rd mode is the same as the 2nd one, but without the "game is
windowed" constrained. Please note that release the mouse grab in
fullscreen may have side effects like the game loosing focus and being
unable to regain it. Especially under X11.

This was requested by @prg318 in issue #271.
2018-02-03 09:20:58 +01:00
Yamagi Burmeister
a496ad8d62 Update HandmadeMath.h to it's latest version. 2018-02-03 08:41:46 +01:00
Yamagi Burmeister
5763784c20 Update stb_image.h to it's latest version. 2018-02-03 08:38:32 +01:00
Yamagi Burmeister
20f49f515b Don't compare a qboolean against an integer.
That only works by accident.
2018-02-03 08:36:07 +01:00
Yamagi Burmeister
21fcb48565 Fullscreen has been an integer for some time now.
At least since we introduced support for mod changing and for scaling
fullscreen.
2018-02-03 08:33:16 +01:00