Commit graph

1971 commits

Author SHA1 Message Date
Yamagi Burmeister
158fbbe559 Enable the numpad * key.
All other keys were already enabled. Reported by @m-x-d, closes #420.
2019-07-11 14:12:14 +02:00
Yamagi Burmeister
3b641e481d Trigger the SDL bug #4700 only if we're in fullscreen. 2019-07-11 14:04:14 +02:00
Yamagi Burmeister
2681276fa1 Remove unused variable and statement.
Reported by @m-x-d. Closes #420.
2019-07-11 14:02:05 +02:00
Yamagi
c1ccb95026
Merge pull request #416 from 0lvin/for_review
Fix overrun in RE_BufferDifferenceStart
2019-07-11 07:45:03 +02:00
Daniel Gibson
b9d8ceba0b Reset vid_rate when using fallback display mode 2019-07-06 19:44:27 +02:00
Denis Pauk
af27d68483 Remove unused sw_partialflush flag 2019-07-06 13:25:29 +03:00
Denis Pauk
5b98640dd2 use pixel position for skip unchanged 2019-07-06 11:43:01 +03:00
Denis Pauk
c6b31d1b46 change 2d buffer damage before frame flush 2019-07-06 10:33:15 +03:00
Denis Pauk
a7199f95db Always flush whole texture to render 2019-07-05 22:28:48 +03:00
Denis Pauk
ceb7fd03b1 fix issue with back_max in RE_BufferDifferenceStart 2019-07-05 22:28:48 +03:00
Yamagi Burmeister
6db1203f22 Evil hack to work around SDL bug 4700.
Check if we're in the requested mode after the fullscreen window was
created. If not: Try to switch again in the requested mode by calling
SDL_SetWindowDisplayMode(). If that's successfull set the new window
size with SDL_SetWindowSize(). That shouldn't be necessary, at least to
SDLs crappy doku, but without the subsequent SDL_GetWindowDisplayMode()
call fails with 'Invalid Window'. Use that call to check if we're now
in the requested mode. If yes, process. If not abort and trigger the
fallback magic. It'll set `r_mode 4` and `vid_fullscreen 0`.

Caveat: In the worst case this will switch the display mode 3 times.
To create the window, to work around the bug and to set a refresh rate.
No problem for flat panels, but my unforgotten Trinitron CRT would
have cried in pain.
2019-07-05 14:12:27 +02:00
Yamagi Burmeister
890d708085 Add a new cvar vid_rate and make sure that we're at the requested mode.
* Normaly SDL chooses a sane refresh rate for fullscreen windows. Users
  may want to override that, so provide a new cvar `vid_rate`. If it's
  set to a value greater than 0, we're trying to get a mode close to the
  requested resolution and refresh rate and switch to that.
* A bug in SDL may leave us in the wrong mode, detect that condition and
  abort. See https://bugzilla.libsdl.org/show_bug.cgi?id=4700 for details.

This is part of issue #302.
2019-07-02 19:04:13 +02:00
Yamagi Burmeister
aeca570a96 Fix code style after latest changes.
Since it's apperently too hard to stay within the style and I'm sick of
discussing it, I fix it by myself.
2019-07-02 17:52:17 +02:00
Yamagi Burmeister
b5f3a79f5d Print SDL display modes.
Print a list of all available modes as soon as SDLs video backend
initializes and the real display mode after the window was created
or altered.

This hopefully helps debbuging problem with display mode selection, see
issue #302 for an example.
2019-06-29 21:11:44 +02:00
Yamagi
40b5fbe87a
Merge pull request #412 from Spirrwell/master
Multi-Monitor Management
2019-06-29 21:06:37 +02:00
Spirrwell
4f5de01d8e (Code Formatting)Fix Indentation 2019-06-29 13:54:59 -04:00
Denis Pauk
f8c73ca731 Flush only frame difference. 2019-06-24 21:47:42 +03:00
Denis Pauk
60f9af27f5 Dynamicly allocate lights 2019-06-24 21:47:42 +03:00
Denis Pauk
9783e7955f correctly check limits in RE_Draw 2019-06-24 21:47:42 +03:00
Denis Pauk
65888e6b9b fix distance selection for mip level 2019-06-24 21:47:42 +03:00
Denis Pauk
a2af07c9fc make d_ziorigin, d_zistepu, d_zistepv local 2019-06-24 21:47:42 +03:00
Denis Pauk
25a2aff688 render code cleanup and allocate spans at once 2019-06-24 21:47:41 +03:00
Denis Pauk
5f2293bf0d limit surfaces amount to unsigned short 2019-06-24 21:47:41 +03:00
Spirrwell
39728eb5d4 (Multi-Monitor)Hide "display index" Option If Single Display
-The "display index" option will now no longer show up in the "VIDEO" menu if user only has a single display
2019-06-16 17:35:55 -04:00
Spirrwell
fc78aefee3 (Multi-Monitor)Better Handling
-Add back use of last_position_x and last_position_y
-last_position_x and last_position_y will be set to undefined when the window is shutdown IF the current display used is not the desired display
-last_display will be set to desired display at window shutdown if not the same
-vid_displayindex clamped using ClampDisplayIndexCvar() at startup and window shutdown
2019-06-16 17:34:00 -04:00
Spirrwell
0da8099de8 (Multi-Monitor)Code Cleanup
-We only need to init the display indices once in GLimp_Init
-We only need to clear the display indices once in GLimp_Shutdown
-Remove extra 'displayindex' variable
2019-06-16 01:11:20 -04:00
Spirrwell
03e3c6bf71 Move 'num_displays' Initialization
-SDL_GetNumVideoDisplays() will always remain the same after the call to SDL_Init(SDL_INIT_VIDEO), so it makes sense to set in GLimp_Init where we do this.
2019-06-16 01:02:53 -04:00
Spirrwell
f6a9690a36 (Multi-Monitor)Can Choose Which Monitor to Use
-Adds option in the "VIDEO" menu for "display index" that lets you specify which monitor you would like to use.
2019-06-16 00:50:15 -04:00
Yamagi Burmeister
1f1a45a562 Push entitie slightly away from non horizontal surfaces.
Otherwise the entities origin might be in the surface, which causes it
to be rendered in full black. This fix is a port from KMQuake2, reported
by @m-x-d. Closes #407.
2019-06-15 17:39:51 +02:00
Max Crofts
bc565030a5 Allow scrolling with mouse in console
Mouse keycodes have been added to consolekeys. Unbound key warnings now only print when in-game.
2019-06-04 19:36:37 +10:00
Daniel Gibson
ebb6b9fce6 Fix link to cvar documentation in --help
also add a link to the new location in the old location, for existing
releases
2019-06-02 19:28:49 +02:00
Yamagi Burmeister
1668f5950e Fix missleading console message.
Reported by @m-x-d, closes #402.
2019-05-30 11:14:23 +02:00
Yamagi Burmeister
8e779bfb87 Remove superfluous statements.
`while (*s != '\\' && *s)` already checks for `s` being valid. This was
reported by @m-x-d, closes #401.
2019-05-30 11:14:11 +02:00
Yamagi Burmeister
4573e9639e Bump version number to 7.42pre. 2019-05-26 09:14:30 +02:00
Yamagi Burmeister
8bcb8f849c Bump version number to 7.41. 2019-05-26 08:43:11 +02:00
Yamagi
33bfd28ebc
Merge pull request #400 from DanielGibson/wrapper-foreground
quake2.exe wrapper puts Q2 window in foreground
2019-05-09 18:12:31 +02:00
Yamagi Burmeister
9b80745d5d Fix cursor position in the 'name' field in the player setup menu.
This closes #396.
2019-05-09 18:01:36 +02:00
Daniel Gibson
7db5c71f3a quake2.exe wrapper puts Q2 window in foreground
because it sucks when you start quake2.exe and the game starts in the
background
2019-05-08 03:04:12 +02:00
Daniel Gibson
f5d9c49f20 Allow second layer of keybindings for controllers, refs #387
There's an "enable alt joy keys" command now. If a key is bound to that
command, all joystick buttons (incl. hat and triggers) are turned from
K_JOYx into K_JOYx_ALT, which allows two keybindings on the same key,
one with the altselector pressed and one without.
If there's no keybinding for K_JOYx_ALT, it will use the binding for
just K_JOYx as a fallback (if it exists).

This is especially handy to create direct bindings for all the weapons
on the (limited amount of) Joystick buttons.
2019-05-05 18:10:10 -01:00
Daniel Gibson
c57befe80d When opening file make sure it's actually a file, fixes #394
... and not a directory, which can cause crashes.
2019-05-04 19:55:38 +02:00
Daniel Gibson
107d044da2 Make AMD performance workaround conditional per driver version 2019-05-04 17:37:16 +02:00
Daniel Gibson
cdf533f995 Fix overbright models in GL3, refs #393
also some dumb bug with using i in two nested loops
2019-05-04 17:37:16 +02:00
Daniel Gibson
26a461575b Try to make GL3_BufferAndDraw3D() faster on AMD/Windows
Seems like AMDs Windows driver doesn't like it when we call
glBufferData() *a lot* (other drivers, incl. Intels, don't seem to
care as much).
Even on an i7-4771 with a Radeon RX 580 I couldn't get stable 60fps
on Windows without this workaround (the open source Linux driver is ok).

This workaround can be enabled/disabled with the gl3_usebigvbo cvar;
by default it's -1 which means "enable if AMD driver is detected".

Enabling it when using a nvidia GPU with their proprietary drivers
reduces the performance to 1/3 of the fps we get without it, so it
indeed needs to be conditional...
2019-05-04 17:37:16 +02:00
Daniel Gibson
7b4dc000ad Unify buffering data and drawing with gl3state.v[ab]ao3D
use GL3_BufferAndDraw3D() instead of glBufferData() and glDrawArrays()
in each place it's needed.
This by itself doesn't make anything faster, but it will make trying out
different ways to upload data easier.
2019-05-04 17:37:16 +02:00
Yamagi Burmeister
401ec04691 Make the SURF_DRAWSKY fix committed in 325e893 optional.
The developers tested their maps without the fix and decided that it
looked good. Add a new cvar gl_fixsurfsky defaulting to 0 that enables
the fix if someone really want it.
2019-05-04 17:23:20 +02:00
Yamagi Burmeister
325e893376 Don't create lightmaps and set SURF_DRAWSKY for SURF_SKY surfaces.
The software renderer already did this, but not the GL renderers. Maybe
the logic was lost somewhere on the long way... Without this change a
fullbright lightmap is generated for SURF_SKY surfaces and without the
SURF_DRAWSKY flags the surfaces aren't skipped in RecursiveLightPoint()
and GL3_LM_CreateSurfaceLightmap(). This isn't a problem under real
skyboxes, but in cases were SURF_SKY is abused fpr interior lightning.
rmine2.bsp in rogue is a good place to see the problem

Reported by @m-x-d, fixes #393.
2019-05-01 19:32:30 +02:00
Yamagi Burmeister
2c11d02b80 Fix Com_VPrintf() for messages longer then 4096 chars.
At least with MinGW on Windows vsnprintf() treats buffer < size as an
error, returning -1 instead of the number of characters that would have
been printed without size restrictions. Therefor msgLen may be wrong,
leading to all kind of funny mistakes further down below... Buffer
overflow included. Work around this by handling the msgLen < 0 case and
adding an explicit terminating \0.

This is another case of "I wonder why nobody has never noticed this",
the GL1 renderers extension string triggered the buffer overflow each
time the game started.
2019-04-28 13:57:46 +02:00
Yamagi Burmeister
193a5b7a5c Don't allow 'give health 0' or even less.
Giving the player < -1 health and increasing it to something above 0
without closing the console breaks the player state.
2019-04-27 19:15:38 +02:00
Daniel Gibson
98b24654b6 Make square particles gamma-correct, work around Intel Windows bug
I guess it makes sense to apply gamma to the color, we do the same
for the standard round particles.
Also, this way the fragment shader for square particles references the
uniCommon UBO (gamma is part of it) - apparently the Intel HD4000
(from Ivy Bridge) GPU driver for Windows has a bug that uniform blocks
that exist in the shader source but aren't actually used can't be found
(with glGetUniformBlockIndex(prog, name)), which we treat as an error
in  gl3_shaders.c initShader3D().

fixes #391
2019-04-25 18:38:16 +02:00
Daniel Gibson
0ef064b21d Fix GL1 and GL3 stencil buffer setup
This broke during refactoring (in b8a062e36), reported in #391

(SDL_GL_[SG]etAttribute() return 0 on success and -1 on failure)
2019-04-22 04:05:04 +02:00
Yamagi Burmeister
f9108db668 Fix stupid c&p braino, initialize vid_gamma.
This closes #385.
2019-04-08 14:05:54 +02:00
Yamagi
06c4735fbb
Merge pull request #382 from 0lvin/for_review
Add auto detect resolution
2019-04-08 14:00:52 +02: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
b2874ab656 Some more fixes to the timing calculations.
If the vsync is enabled missuse it to slow the client down, e.g.
calculate the target framerate, add an security margin of 20% and
let the vsync handle the rest. This hopefully solves some problems
with frametime spikes. This is an idea by @DanielGibson.

If the vsync is disabled use a simple 1s / fps calculation.
2019-04-08 13:56:56 +02:00
Yamagi Burmeister
5bb5e52879 Fix vid_displayrefreshrate reset.
Until now it wasn't possible to reset vid_displayrefreshrate to -1 once
it was changed to something else. Fix that.
2019-04-08 13:56:56 +02:00
Yamagi Burmeister
cda565d044 Rename msec to usec, because it holds microseconds.
Requested by @DanielGibson.
2019-04-08 13:56:56 +02:00
Yamagi Burmeister
49cc1b9789 Fix typos and grammar in comments, clarify some points. 2019-04-08 13:56:56 +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
Daniel Gibson
178fcff36e GL3: Fix missing dynamic lights on floor for grenades/rockets
Apparently the lightsource for exploding rockets/grenades is very close
to the surface, so the dot-Product between surface-normal and the
vector between the light and the pixel returns 0, basically disabling
the dynamic light for that surface.
As a workaround, move the lightposition (only for that dot product)
a bit above the surface, 32*surfaceNormal looks good.

fixes #386
2019-04-03 19:38:39 +02:00
David Carlier
65357c9ba5 hunk api mremap supported by NetBSD as well. 2019-03-29 17:24:07 +00:00
Denis Pauk
eea1cd30e8 Fix segfault in about menu 2019-03-23 23:23:54 +02:00
Denis Pauk
e568e3ff0e Save original window position before recreate 2019-03-22 23:29:17 +02:00
Denis Pauk
f0dc7bd6f9 Move GetDesktopMode to client/vid/vid.c 2019-03-21 21:32:34 +02:00
Denis Pauk
f105047540 make cppcheck little more happy 2019-03-20 22:01:14 +02:00
Denis Pauk
025764db79 make cppcheck little more happy 2019-03-20 21:56:28 +02:00
Denis Pauk
0f9e3cc69a Move patches authors to about menu
With whole respect to original authors
2019-03-20 21:28:42 +02:00
Denis Pauk
fbe42511c1 Add resolution autodetect 2019-03-20 20:59:34 +02:00
Denis Pauk
0ab41ee0df Use boolean for r_outof* 2019-03-20 20:45:15 +02:00
Denis Pauk
5e7082e72d Fix for light without current entity 2019-03-20 20:43:54 +02:00
Daniel Gibson
3b296c43a0 GL1, SW: Calculate needed hunk size in Mod_LoadBrushModel()
same as last commit but for the other renderers
2019-03-17 20:24:40 +01:00
Daniel Gibson
ec6d743d46 GL3: Calculate needed hunk size in Mod_LoadBrushModel()
The real needed size can't be derived from the .bsp file size, because
* many generated structs contain pointers
* there's lots of data generated per face..
* _especially_ for warped faces that are subdivided
2019-03-17 18:10:07 +01:00
Daniel Gibson
d2d87025fa Fix case of map savegames name (save/bla/MAPNAME.sav/sv2)
introduced FS_GetFilenameForHandle(fileHandle_t) for this

this helps if a map has been started with "wrong" case, which doesn't
immediately fail if it has been loaded from a pack, but will result
in invalid savegame names that (with case-sensitive FSs) will fail to
load (when going back to a formerly played level)
2019-02-17 18:46:57 +01:00
Yamagi Burmeister
3296b7a1a2 Add back pak prioritization to HTTP download code.
The r1q2 code prioritized pak files over all other files, e.g. as soon
as a pak file was requested no more file were added to the download
queue until it finished downloading. That way one could be sure that
assets included in the pak file weren't downloaded in parallel as single
files.

This is a better, bugfixed and more robust implementation of the same
logic. With this back in place we can switch back to parallel downloads
which gives a nice speedup on Windows. Maybe, just maybe some day
Microsoft will fix Windows crappy I/O...
2019-02-17 10:03:17 +01:00
Yamagi Burmeister
f96a82010e Combine all HTTP download quirks into a strict dlquirks_t.
Working with getter and setters was a good idea as long as we had one or
two quirks. Now we're at three with maybe more to come so it's easier to
use a struct to communicate quirks between the precacher and the HTTP
download code.
2019-02-17 09:38:11 +01:00
Yamagi Burmeister
b1629fb768 Prevent buffer overflows console if vertical resolution > 2048.
The stores it's text in the key_lines array which is NUM_KEY_LINES *
MAXCMDLINE chars long. The code never checked for overflows, it just
assumed that a line will never be longer then 256 chars * 8 = 2048
pixel. With modern displays we can have higher vertical resolutions,
so the array will overflow sooner or later.

Fix it by clamping the maximum line width to MAXCMDLINE - 2 chars (1
for the prompt and 1 for the terminating \0). While at it increase
MAXCMDLINE to 1024 chars * 8 = 8192 pixel, which is more then 8k
resolution and should be enough for the years to come.

This is belived tot fix at least a part of issue #368.
2019-02-16 08:57:44 +01:00
Yamagi Burmeister
b49f2bda6d Reconnect entity states of clients >1 when running in coop mode.
While loading a savegame the global edict arrays is free()ed and newly
malloc()ed to reset all entity states. When the game puts the first
client into the server it sends it's entity state to us, so as long as
there's only one client everything's okay. But when there're more
clients the entity states if all clients >1 are dangeling. Hack around
that by reconnecting the clients >1 entity states "manually".
2019-02-15 19:50:56 +01:00
Yamagi Burmeister
8c60939bd5 Use correct path to filelists when downloading for a mod.
I'm not 100% sure if this is okay for q2pro, but at least in my simple
tests r1q2, q2pro and now yq2 generate the same URL. Nevertheless it's
somewhat inconssistent to search generic files at /moddir/... and the
filelist at /moddir.filelist

This closes issue #370.
2019-02-11 19:27:34 +01:00
Yamagi Burmeister
32d9119cff CL_HTTP_EnableGenericFilelist() needs curl/download.c linked in.
Reported by @LoneFox78 in issue #369.
2019-02-11 19:20:55 +01:00
Yamagi Burmeister
e049717ac3 Bump version to 7.41pre. 2019-02-07 17:27:09 +01:00
Yamagi Burmeister
25bf4d3e02 Bump version to 7.40. 2019-02-07 17:25:36 +01:00
Yamagi Burmeister
86d438708e Not all libc support the %z format modifier added in C99... 2019-02-05 17:18:01 +01:00
Yamagi Burmeister
f7706b2c06 Fix indention after b44fd32. 2019-02-05 09:15:11 +01:00
Yamagi Burmeister
95bdec447d Include wchar.h, required by wmemset(). 2019-02-04 17:10:28 +01:00
Yamagi Burmeister
e4665547a8 Try to fix gun fov calculations in the softrenderer.
Until now the softrenderer calculated the fov relative to a hard coded
aspect of 4/3. That's wrong, because we're supporting arbitrary aspects
and we aren't calculating a fov but just a scaling factor to the global
fov which takes the aspect into the account.

Fix this by not taking any aspect calculations into account. BUT: While
this renders the gun with a correct perspective it's positioned much
nearer to the camera / player then in the GL renderers. The GL renderers
work around that problem by enforcing a minimal Z distance of 4 units,
which can't do because we're just calculating a scaling factor...
2019-02-04 13:43:34 +01:00
Yamagi
9c549f1cd2
Merge pull request #363 from 0lvin/image_resize
Soft Render: Image resize
2019-02-04 13:41:54 +01:00
Daniel Gibson
04a33c9837 Fix loading Coop savegames without starting server first 2019-02-03 19:35:38 +01:00
Daniel Gibson
b44fd32572 Save gclient_t::resp.coop_respawn.*weapon to fix coop savegames
This fixed bug #357 - the problem was that
client->resp.coop_respawn.weapon and .lastweapon (pointers to gitem)
were not properly initialized when loading a savegame.
Now those fields are saved (=> we had to bump the savegame version)
and for old savegames client->resp.coop_rewspawn is initialized
from client->pers, as a hack for backwards-compatibility.
2019-02-03 19:01:03 +01:00
Denis Pauk
2a19bfe6cd make variables local 2019-01-31 22:40:16 +02:00
Denis Pauk
3a85943118 Show func in .Sys_Error and .R_Printf 2019-01-31 22:09:33 +02:00
Denis Pauk
b7cac7f8aa Use INT_MIN instead -999999 2019-01-30 23:27:59 +02:00
Denis Pauk
c80820500b Fast lights clean 2019-01-30 23:22:00 +02:00
Denis Pauk
e43859de4a Fast lights clean 2019-01-30 23:19:10 +02:00
Denis Pauk
dcc2892de0 Use resize stb image 2019-01-30 23:06:25 +02:00
Denis Pauk
1dfb54bf38 Add code for retore mips 2019-01-30 23:03:38 +02:00
Denis Pauk
203bc4b202 Update stb_image and add stb_image_resize code 2019-01-30 22:43:54 +02:00
Denis Pauk
07c472cfd2 Remove adivtab 2019-01-30 22:42:21 +02:00
Yamagi Burmeister
29bb6e5c6c Fix last commit, pack can be NULL. 2019-01-30 17:14:14 +01:00
Yamagi Burmeister
5ddab0e4bf Allow UDP download from paks that are not numbered.
Until now the UDP download code prohibited downloading of maps from all
pak files. That was some kind of copy protection, without the limitation
demo users could download assets from the full version. Don't apply that
protection for all paks, but only for numbered .pak files.

This could be enhanced by limiting the protection to pak0 to pak2 for
baseq2 and pak0 for both xatrix and rogue.
2019-01-30 17:14:14 +01:00
Yamagi Burmeister
900d35ef27 Hack in support for q2pro filelists.
r1q2 places the global filelist at /.filelist, q2pro at
/gamedir/.filelist...

Now I'm feeling even more dirty.
2019-01-30 17:14:13 +01:00
Yamagi Burmeister
67b1a8fd95 Implement q2pro URL scheme.
The r1q2 URL generator was, like everything in this game, buggy. It took
cl.gamedir into account when generating the URLs, but overlooked that it
is only set when 'gamedir != BASEDIR'. So baseq2 assets ended up with
/maps/foo.bsp and mod assets with /mod/maps/foo.bsp. q2pro fixed that
to always include the gamedir...

Work around this by refactoring the HTTP -> UDP fallback logic to be
more generic: Count the number of iterations and depending on the
iteration set the gamedir to be used by the URL generator or force
UDP downloads.
2019-01-30 17:14:13 +01:00