Commit graph

2165 commits

Author SHA1 Message Date
Yamagi Burmeister
0286cdcd0b Fix floater melee / zap damage getting applied if enemy is out of range.
Found by @BjossiAlfreds, closes #454.
2019-09-23 17:32:43 +02:00
Yamagi
a942ca4bba
Merge pull request #459 from BjossiAlfreds/pathcorner
Triggered spawned monsters use path_corner correctly
2019-09-23 14:08:16 +02:00
Daniel Gibson
4e68ea13b2 Fix loading .cfg's without trailing newline
.. by adding a newline character to the end of the loaded file.
fixes #453
2019-09-22 19:11:07 +02:00
Daniel Gibson
77493e6e5b Don't call SDL_GetWindowDisplayIndex() with window == NULL
I got an SDL assertion because of this.
The problem was that PrintDisplayModes() was called at startup before a
window was created.
2019-09-22 19:09:10 +02:00
BjossiAlfreds
03c96b3fa3 Triggered spawned monsters use path_corner correctly 2019-09-21 08:15:42 +00:00
BjossiAlfreds
80c9976899 Fix for insane marines not always playing pain sounds 2019-09-15 13:16:21 +00:00
Yamagi
990e4f6989
Merge pull request #450 from bibendovsky/fix/448_pendingplays
Fix the pending sound list sorting
2019-09-15 09:41:01 +02:00
Yamagi
cf742c0228
Merge pull request #452 from BjossiAlfreds/monster-viewheight-bugfix
Full bugfix for monsters not fighting parasites
2019-09-14 10:20:16 +02:00
BjossiAlfreds
223ab4d7b2 Full bugfix for monsters not fighting parasites 2019-09-14 01:33:47 +00:00
Boris I. Bendovsky
16ee0073d4
Fix the pending sound list sorting 2019-09-13 19:48:44 +03:00
Denis Pauk
129da805a1 Make static C code analysis tool little more happy(#426)
sw_image.c:
	203: The potential null pointer is passed into 'memcpy' function. Inspect the first argument. Check lines: 203, 192.
	368: The null pointer is passed into 'free' function. Inspect the first argument.
	401: Expression '!pic' is always false.
	401: There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 394, 401.
	565: The potential null pointer is passed into 'memcpy' function. Inspect the first argument. Check lines: 565, 564.

sw_model.c:
	215: The 'model' pointer was used unsafely after it was verified against nullptr. Check lines: 210, 215.
	985: The 'header->lumps[12].filelen / sizeof (int)' expression was implicitly cast from 'size_t' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;.
	1277: Function 'RE_BeginRegistration' argument 1 names different: declaration 'map' definition 'model'.

sw_surf.c:
	239: There might be dereferencing of a potential null pointer 'sc_base'. Check lines: 239, 236.

sw_main.c:
	1345: The if condition is the same as the previous if condition
	1466: Function 'R_GammaCorrectAndSetPalette' argument 1 names different: declaration 'pal' definition 'palette'
	2063: The 'swap_buffers' pointer in the expression could be nullptr. In such case, resulting value of arithmetic operations on this pointer will be senseless and it should not be used. Check lines: 2063, 2061.

sw_aclip.c:
	180: Variable 'j' is reassigned a value before the old one has been used.

sw_alias.c:
	209: Function 'R_AliasTransformVector' argument 3 names different: declaration 'm' definition 'xf'.

sw_draw.c:
	78: Function 'RE_Draw_CharScaled' argument 3 names different: declaration 'c' definition 'num'.
	149: Function 'RE_Draw_GetPicSize' argument 3 names different: declaration 'name' definition 'pic'.
	173: The scope of the variable 'u' can be reduced.
	267: Function 'RE_Draw_PicScaled' argument 4 names different: declaration 'factor' definition 'scale'.

sw_scan.c
	593: Function 'D_DrawSpansPow2' argument 1 names different: declaration 'pspans' definition 'pspan'.
	745: Function 'D_DrawZSpans' argument 1 names different: declaration 'pspans' definition 'pspan'.
2019-09-12 22:36:13 +03:00
Yamagi
5d97bbff8a
Merge pull request #442 from 0lvin/for_review
Add zBuffer damage logic
2019-09-12 10:05:32 +02:00
Yamagi Burmeister
7d28dbbc54 Add telepport and listentities commands as forward to server cmds.
This makes them available for autocompletion. Closes issue #430.
2019-09-12 09:35:38 +02:00
Denis Pauk
0bace327f8 Add zbuffer damage checks
Save current player position and compare with a position in the previous
frame, if position is same refresh only changed rectangle in zbuffer.
zBuffer can be damaged by models, particles and static transparent spans.

zBuffer damage is not useful for the screen refresh minimize for now,
as result of explosion can change texture light value.
2019-09-10 08:20:48 +03:00
Denis Pauk
aba398c1b9 dump current possition in world 2019-09-10 08:20:48 +03:00
Denis Pauk
7435283213 Skip flush screen after palette change
Fixes issue with black screen on new game after show the introduction video
2019-09-10 08:20:48 +03:00
Yamagi Burmeister
90c2ac8946 Make sure that the entity to be printed is valid.
Especially after savegame load not all slots in the edicts array may be
used. Check if the current entity has a classname string. This is
another part of #430.
2019-09-07 14:27:21 +02:00
Yamagi Burmeister
c41f61f8fb Fix long standing bug of dead parasites falling through the world model.
It's unclear were this comes from, maybe it's a bug in the collision
detection. Because the collision detection is ununderstandable for
people without 'special brain type game programming' like me and even
bugfixes to it have a very high chance to break things, work around
it. Save current position, perform move, check if we're in the world
model. If we are revert to old position.

Debugged and work arounf suggested by @BjossiAlfreds. Fixes #443.
2019-09-06 07:46:59 +02:00
Yamagi Burmeister
281aaeebbd Fix current health being reset to 100 if >100 at level change.
This is another code inconsistency, we must not clamp the current health
to the client max health (which apparently is always 100) but to the
current max health of the player entity.

Analyzed and fix suggest by @BjossiAlfreds, fixes #441.
2019-09-06 07:04:53 +02:00
Yamagi Burmeister
34c27cd2c7 Fix monsters not fighting back when attacked by a a parasite.
This is another corner case. Parasites have a bbox height of 24,
walkmonster_start_go() hardcodes a viewheight of 25. Therefor most
traces in other functions like visible() overshoot the parasite.
Fix this by not overriding the monster viewheight.

Analyzed and fix suggested by @BjossiAlfreds. Closes issue #440.
2019-09-06 06:52:55 +02:00
Yamagi Burmeister
cd93737eb7 Add 'listentities' command.
This rather sophisticated command prints all entities of one or more
given classes and their coordinates. Possible classes are:

* ammo
* items
* keys
* monsters
* weapons

Classes can be combined into one command, e.g. `listentities ammo keys'
would print all ammunition and all keys. The special class `all` prints
all entities, regardless of their class.

The command is protected by `cheats 1`.

This is part of issue #430.
2019-09-05 17:48:07 +02:00
Yamagi
f75b1c24b5
Merge pull request #439 from devnexen/curl_little_chg
Little code changes proposal.
2019-09-05 08:30:01 +02:00
Yamagi Burmeister
41134fa204 Add a new command 'teleport'.
A command that teleports the player to abitrary locations was often
requested and may be helpfull for debugging, so finally add it. It works
like a normal teleporter: It moves the player to the requested location,
clears all movements, tells the server and clients that the entity just
teleported and telefrags everything that's in the target location.

The implementation does not verify if the requested location is save,
the player may teleport into the world model or even the void. But the
requested Z coordinate is elevated by 10 units to prevent the player
getting stuck in the floor.

The command is protected by sv_cheats.

This is part of issue #430.
2019-09-05 08:18:20 +02:00
David Carlier
28e22f15d5 Little code changes proposal. 2019-09-04 21:56:22 +01:00
Yamagi Burmeister
5ae4a73acd Fix stupid endless loop in HTTP->UDP Fallback handling.
The fallback logic is: r1q2 style URLs -> q2pro style URLs -> UDP. In
case that an r1q2 or q2pro server is missing files, we may fall through
to UDP and download files over abysmal slow UDP that are available over
HTTP. To work around this problem we reset the precacher iterations back
to 0 and start over with r1q2 style URLs. This works as long as we're
able to download all files. But if one or more files are unavailable
over all three download options we'll run into an endless loop. Mitigate
this by starting over only once. This comes with the drawback that on
servers that miss more than one file downloads might done over UDP were
HTTP is available. In that case the server should be fixed.

This closes #429.
2019-09-04 18:02:06 +02:00
Yamagi Burmeister
b7bb9f2550 Reset paused_at_load after loading has finished. 2019-09-03 08:45:59 +02:00
Yamagi Burmeister
fc5c2788a1 Put the client into pause mode when loading save games.
This prevenits the worlds from advancing during client connect. The
player won't get attacked by monsters or hurt by the environment. Note
that in baseq2 there're still 4 world frames processed by the game and
100 world frames if the player enters a level that he or she already
visited. Both aren't a big problem, 4 world frames are hardly enough
for monsters starting to attack and in most levels the starting area
can't be reached by monsters and is free from environmental effects.

Pause mode is only entered for local servers and only in single player
mode. This should prevent problems with coop and deathmatch games.

The behaviour can be controlled by `cl_loadpaused`:
* `0`: Do not enter pause mode, Vanilla Quake I behaviour.
* `1`: Enter pause mode at load and leave it at first regular server
       frame.
* `2`: Enter pause mode at load, never leave it. The player must leave
       it by hand.

This was requested in issue #417.
2019-09-03 08:42:05 +02:00
Yamagi Burmeister
81a36bb3ad Add 'dec' and 'inc' operations.
'dec' decrements and 'inc' increments a given cvar either by 1 or a
given value.

The code was taken from q2pro.

This closes issue #414.
2019-09-02 17:57:02 +02:00
Yamagi Burmeister
d1981e7edf Add 'toggle' cvar operation.
The 'toggle' operation allows toggling a cvar between `0` and `1` or two
custom values.

This code was taken from q2pro.

This is part of issue #414.
2019-09-02 17:29:00 +02:00
Yamagi Burmeister
66ca44e040 Add new cvar operation 'reset' and 'resetall'.
cvar operations are special commands that allow the programmatic
manipulation of cvar values. 'reset' resets a given cvar to it's
default value, e.g. `reset r_mode' would reset `r_mode` to `4`.
'resetall' resets all known cvar with the exception of `game`.

The code is based upon q2pro.

This is part of issue #414.
2019-09-02 17:28:41 +02:00
Yamagi Burmeister
5136ceb123 Try to fix monsters getting stuck by waiting forever for their enemy.
44472722e added some sanity checks to the AI code. The checks in
ai_run() are likely wrong because the enemy entity might be already
NULL if we arrive their. By aborting early the code is unable to
determine a new enemy or return the monster to idle state, so the
monster will wait forever for an enemy that'll never come.

This happens only in monster vs. monster fights. Never in monster vs.
player, that game ends if the player dies.

In theory this change should be harmless, because if the enemy entity is
gone it won't generate sound targets now be visible. If the game crashes
by self->enemy being NULL we've got a problem elsewere.

This was reported by @BjossiAlfreds in #483. He also suggested the fix.
2019-08-31 10:56:50 +02:00
Yamagi Burmeister
5c17eb0132 Fix monsters being unable to see the player if he generates noise.
When searching for the player FinTarget() always goes after sound
targets and aborts as soon as it finds one. So if the player is
constantly generating sounds - for example firing the machine gun -
there's a high chance that monsters will only hear but never see
him. Work around this by adding a small timeout to player noises, make
sure that at least 3 frames passed since the last noise. This gives
monsters 2 frames to see the player.

This bug was present in the original code, this is a small gameplay
change.

The problem was analysed by @BjossiAlfreds in #436. He also suggested
the fix.
2019-08-31 10:40:13 +02:00
Yamagi Burmeister
35547d813a Fix berserker fidget animation aborting attack.
M_MoveFrame() calls first the AI functions that decide if a monster
should attack or not. After that the monsters think function is called
which walks through berserk_frames_stand[]. Even if the AI function found
an enemy and decided to attack, the monster is still standing for this
frame and berserker_fidget() is called. It may override the earlier
earlier decision, aborting the attack. Even worse this may let the
berserker stuck, because AI_STAND_GROUND may be cleared which prevents
further attacks.

This bug was present in the original code, so this is small gameplay
change. It's likely also present in both addons.

Reported and analyzed by @BjossiAlfreds in issue #433. He also suggested
the fix.
2019-08-31 10:23:18 +02: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
Daniel Gibson
f9c77b98af YQ2_ALIGNAS_*() in common.h 2019-08-24 20:38:42 -01:00
Daniel Gibson
bebd9e73b3 YQ2_COM_CHECK_OOM() macro to check if malloc() etc was successful 2019-08-21 21:07:31 -01:00
David Carlier
97e66dfd9b Silence deprecation warning with OpenGL.
on Darwin, Mojabe has deprecated it in favor of Metal,
here we silent the lengthy build warning.
2019-08-01 20:01:43 +01:00
Daniel Gibson
95983f08cf Fixes for PVS Studio warnings: Sound stuff 2019-07-21 05:29:05 +02:00
Daniel Gibson
d368a67976 Fixes for PVS Studio warnings: most of src/common/
except for frame.c, I'd like Yamagi's input on that
2019-07-21 03:14:21 +02:00
Daniel Gibson
90d0fe07e2 Fixes for PVS Studio warnings: (q)menu.c, glimp_sdl.c 2019-07-21 03:08:52 +02:00
Daniel Gibson
4c265d448f Fixes for PVS Studio warnings: client/cl_*.c and curl/download.c
except for cl_cin.c that'll need some actual refactorings

see #426
2019-07-21 03:02:22 +02:00
Yamagi Burmeister
eaa4aa46ce Don't screw up if 'sensitivity' is set to non-integral values.
Like most other cvars 'sensitivity' allowes for float values. But until
now mouse events were handled as integers which led to some confusing
problems. This was especially noticeable at values lower than 1, small
mouse movements were cut to 0 and discarded. Since the clients movement
code is written in floats and we're already using floats for joystick
movement switch the mouse event handling over to them, too.

This should have any impact on configs were 'sensitivity' is ste to
integral values. If it was set to decimal values the behaviour is now
correct.

This fixes #419.
2019-07-20 16:19:35 +02:00
Yamagi Burmeister
e3d4038233 Remove S_RegisterSexedModel().
I new that it was unused, I left it in the code because I thought it
might be usefull one day. It wasn't, so finally remove it. Closes #425.
2019-07-20 16:19:15 +02:00
David Carlier
78a5a819c6 curl buffer resizing lost fix proposal. 2019-07-14 13:08:40 +01:00
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
Yamagi Burmeister
c06af7de57 Reset error state when getting a new download server. 2019-01-30 17:14:13 +01:00
Yamagi Burmeister
1d9acffe0b Ensure that internal pathes are always starting with a /.
Otherwise the URL generator might generate invalid URLs...
2019-01-30 17:14:13 +01:00
Yamagi Burmeister
d38929170b Download the generic filelist only once.
Cleaning the download queue as soon as a file finished downloading leads
in combination with only one parallel download and multiple precacher
runs to an ugly problem: The generic filelist is requested several time
which can lead to cycles. Hack around this by rembering if we already
requested it and reset set reminder as soon as the precacher finished.

Yes, I'm feeling dirty.
2019-01-30 17:14:13 +01:00
Yamagi Burmeister
5e67596d56 Strip trailing slashes from download server URL.
If the server sends us an URL with trailing slash we're generating URIs
like http://example.com//maps/foo.bsp. While double // are perfectly
valid they might me rejected by some servers. So let's play save.
2019-01-30 17:14:13 +01:00
Yamagi Burmeister
e05f95e3fb Don't free() the download queues last element twice.
While at it replace the crappy Z_TagMalloc() with the standard malloc().
Z_TagMalloc() ist just a wrapper arround malloc(), there's no functional
change.
2019-01-30 17:14:13 +01:00
Yamagi Burmeister
eb048e8611 Implement fallback logic from HTTP downloading to UDP.
This looks easy, but is rather hacky... Downloading is implemented
through the precacher. The server sends an asset list, while loading
the map another one is generated. CL_RequestNextDownload() goes
through this list, in the order models / maps -> sounds -> images,
calls CL_CheckOrDownloadFile() for each file. CL_CheckOrDownloadFile()
checks if the file is already there, return true if it is and false
if not. If the return code is false CL_RequestNextDownload() itself
returns, it's called again by CL_ParseDownload() as soon as the just
queued file finished downloading. This way all missing files are
downloaded one after the other, when CL_RequestNextDownload() finally
reaches it's end (all files are there) it send 'begin' to the server,
thus putting the client into the game.

HTTP downloads are parallel, so CL_RequestNextDownload() cannot track
which files are there and which are missing. The work around for that is
to queue the file but have CL_CheckOrDownloadFile() return true. So
CL_RequestNextDownload() thinks the file is already there, continues
with the next one, until all missing files are queued. After that it
polls CL_PendingHTTPDownloads() and sends the 'begin' as soon as all
HTTP downloads are finished.

If a HTTP download fails we cannot just queue it as UDP download,
because the precacher things that the file is already there. And we
can't tell the precacher that it's not because the precacher tracks
files only by the number of downloaded files per asste type and not
their name. Just decreasing the number of downloaded files isn't
possible since the precacher may have progressed to the next asset
type.

So: On the HTTP side it's tracked if there was an error or not.  After
CL_RequestNextDownload() has queued all files and waited for all HTTP
downloads to finish it checks the HTTP error status. If there was an
error the precacher state is reset and CL_RequestNextDownload() recurses
into itself to take another run. All files that couldn't be downloaded
are queued again, this time as UDP downloads.
2019-01-30 17:14:13 +01:00
Yamagi
78366472f9
Merge pull request #351 from CanntAim/master
Fixed menu code to correctly parse maps.lst file.
2019-01-19 16:53:52 +01:00
Denis Pauk
a1773b91d7 Use separator instead action in menu header 2019-01-16 23:23:48 +02: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
7d9016510e Fix snd_restart. it should restore the OGG playback state.
My solution to this problem is somewhat hacky. A newly added function
OGG_SaveState() can be called to save the state and OGG_RecoverState()
at a later time to restore it. There's only one state and it works
only iff OGG is state playing.

This closes #347.
2019-01-05 19:26:50 +01:00
Yamagi Burmeister
ec6e0ee392 Provide a write callback to cURL.
If we're passing file handles to libcurl to write the data into, the
game may crash under Windows due to incompatible C runtimes between cURL
and quake2. This is even mentioned in the official cURL doku.
2019-01-03 17:42:22 +01:00
Yamagi Burmeister
2199b67a39 Limit the number of parallel downloads to just 1.
Since the moment I took a very first look at the download code I wasn't
a friend of parallel downloads. There're several reasons for that:

- Parallel downloading needs some ugly hacks. For example downloading a
  pak file has a high chance to make asset downloads running in parallel
  unnecessary.
- Parallel downloads are hard to debug.
- There's just no need for them. I've tested several connection, 1
  GBit/s LAN, 50 MBit/s DSL, 6 MBit/s DSL, and there wasn't a
  significant difference between 1, 4 or even 16 parallel downloads.

I'm leaving the parallel download code in place. I someone really wants
parallel downloads he can bump the MAX_HTTP_HANDLES define.
2019-01-03 17:40:06 +01:00
Ivan Pozdnyakov
d43a77029c
Fixed menu code to correctly parse maps.lst file. 2018-12-22 01:14:47 -05: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
95c1bb9972 Some alterations to the libcurl search pathes.
- On Linux try libcurl.so last, because that one is for linking only.
- Support libcurl.dll on Windows.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
537e6d8de3 Port the server side of HTTP downloading from q2dos. 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
Daniel Gibson
49bb6bf9f0 Don't leak download queue entries, remove them as soon ans file is done.
Until now download queues entries were created for each file, but only
removed in the unlikely event of changed download server. This leaked
about 4200 byte per file. Fix this by:

- Create a new function CL_RemoveFromQueue() that removes a queue entry
  and call it everytime when a download either finished, failed or
  aborted.
- Retire the 'download done' state, just the queue entries associated
  with a download handle to NULL to communicate that the handle is
  unused.
- Cleanup the full queue at shutdown.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
da8bb7f7ee Add header guards and all necessary includes to download.h. 2018-12-20 18:01:38 +01:00
Yamagi Burmeister
f0d244e7b4 Rename cl_http.c to curl/download.c and http.h to download.h.
This is more in line with our file structure and other changes that
added functionality to the client.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
c0a6e4270f Load libcurl.so at runtime.
Loading libcurl at runtime instead of linking it at compile time makes
things a lot easier and more reliable on Windows. On other platform
libcurl can be installed as optional dependency instead as an hard one.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
cd1b67e489 Whitespace and indention cleanups to the HTTP download code. 2018-12-20 18:01:38 +01:00
Yamagi Burmeister
0ad406a95f Rework HTTP download console output.
We're printing only the two relevant informations: A download was queued
and a download finished or failed. That's enough to see what's going on
and not too noisy.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
29f9f48a06 Remove canceling of all downloads if the bsp failed to download...
...and fix the bugs, that were worked around with that crap, instead.
This removes some corner cases like cancelation of all HTTP downloads
and fallback to UDP if too many 404 errors were generated. If this is
still a problem in reality - for example HTTP servers blocking the
client after too many 404 or even crashing HTTP server - fix the server
and don't force the clients to work around that.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
7f085db431 Remove prioritization of pak file download.
We aren't in 1997 anymore, todays broadband connections are fast enough
to handle multiple large files. This may download some assets twice if
the server provides both a pak file with all assets and the assets as
plain files.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
df82598984 Rewrite memory buffer used by CURL.
There's no need to parse the HTTP header on our side of things, CURL can
do that. And the old buffer code was overcomplicated, simplify it. While
at it switch to normal malloc().
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
9ba97177ea General cleanup of the ported download code.
- A lot of style fixes.
- Remove unused code.
- Simplify things.
- Fix some obvious bugs.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
3a24b9d6cf Remove the download speed calculation.
While the download speed calculations may be useful their implementation
is crappy and the integration into the console is rather fragile. If we
really want to support the progress bar with HTTP downloads this needs
to be reimplemented.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
f51661133d Fix URL generation.
The URL generation logic was buggy, it took the local fs_gamedir into
account when determining the files path on the server. That could have
worked in r1q2 or q2dos since they assume that the executable dir is
also the config dir. But it breaks in YQ2 were the executable dir and
the config dir differ.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
5d9aefd4ef Implement missing client interfaces.
These are:
- CL_ResetPrecacheCheck(): Resets the precacher, forces it to reevaluate
  which assets are available and what needs to be downloaded.
- FS_FileInGamedir(): Checks if a file (and only a real file, not
  somthing in a pak) is available in fs_gamedir.
- FS_AddPAKFromGamedir(): Adds a pak in fs_gamedir to the search path.
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
0a94a8ee92 Port the HTTP / CURL download stuff from q2dos.
This is a very first cut:
* It compiles
* It doesn't crash

What's missing:
* cmake integration
* CURL should be loaded dynamically
* Integration between download code and filesystem
* Likely UTF-8 stuff
* cl_http.c needs cleanup
* Windows support
2018-12-20 18:01:38 +01:00
Yamagi Burmeister
380642468b Use %z modifiert to print a size_t.
This fixes a gcc warning on Win32.
2018-12-20 17:59:19 +01:00
Yamagi Burmeister
aa57ec9f7b Fix oversight in last commit, the '/ 2' is evil. 2018-11-22 21:15:09 +01:00
Yamagi Burmeister
e137ff1168 Fix stupid bug in brush model indix block size calculations.
We're taking indices and converting them to pointer relative to the
hunks base. Yes, that's dirty. Since the indices are stored as 32 bit
values and hunks are generally small using 32 bit pointers is enough,
even on 64 bit platforms. So the code took the size of void* / 2...
See the problem? Yes, that's not a good idea on 32 bit platforms. Bite
the bullet and just take the size of void*. Shouldn't be a problem,
because the indices are the first thing that's loaded and the hunk is
trimmed right after it anyways. If, and just if, we really need each and
every byte in the early stages of map loading we need two cases. One for
64 bit and one for 32 bit.

This fixes issue #346. Kudos to @ricardosdl for the analysis.
2018-11-22 17:41:55 +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
Yamagi
ee4135fd0a
Merge pull request #343 from 0lvin/cppcheck
Cppcheck fixes
2018-11-14 19:04:27 +01:00
Yamagi Burmeister
587382644c Fix lost time calculation.
Lost time is time that we spend but didn't account. So the lost time
doesn't shorten a second (in fact that would mean that we'll lose the
time twice), it lengthen a second. Since has a small but noticeable
impact on timing when running with vsync enabled.
2018-11-12 22:17:10 +01:00
Denis Pauk
25498be7ca Support retextured images.
Code based on www.quakewiki.net/quakesrc/39.html
Code ignores skin images, and is disabled by default.
2018-11-12 23:02:23 +02:00
Denis Pauk
0307361101 Remove unused cvars 2018-11-12 23:01:08 +02: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
bbdd3f1d60
Merge pull request #342 from earth-metal/master
Add support for CTF options to "start network server" menu.
2018-11-07 18:04:22 +01:00
Yamagi Burmeister
37a840ba0b Bump the default value of vid_maxfps to 300.
This should be save now that the async client is working more or less
flawlessly and is required for high performance displays.
2018-11-06 17:55:05 +01:00
Yamagi Burmeister
3c21575a01 Describe the limitiations of GLimp_GetRefreshRate(). 2018-11-06 12:26:56 +01:00
Yamagi Burmeister
8d5734ce9d Only account pure packet frames for average paket frame times.
With this change the code matches the comment. While most packet frames
are renderer frames, we must not take the render frame time into account
when calculating the average time spend processing the packet frames. I
dont's think that this change makes any measureable difference since the
packet frame time is just a very small fraction of the renderer frame
time.
2018-11-06 11:45:36 +01:00
earth-metal
77dbf36b40 Add support for CTF options to "start network server" menu.
Allow numeric input of "capturelimit" cvar and toggling of CTF dmflags
via menu system.
2018-11-01 21:50:31 -04:00
Yamagi
4155e8c26d
Merge pull request #340 from earth-metal/master
Minor bug-fixes: Case-insensitive file loading & Rogue dmflags display
2018-11-01 17:29:57 +01: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
earth-metal
feeba61721 Fix typo preventing display of Rogue "dmflag" options. 2018-11-01 08:58:18 -04:00
earth-metal
31627ef68b Fix case-insensitive file loading.
Allow usage of capitalization in directory names above the YQ2 working
dir when loading non-PAK/PK3 assets with capitalized "name" criteria.
2018-11-01 08:54:37 -04: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
60c12228c9 Correct average render / packet time calculations.
We need to reset the avgrenderframetime and avgpacketframetime variables
when we recalculate the average times spend rendering frame and / or
processing package frames. Otherwise the result will be much too high,
leading to lost frames down below. I wonder why nobody complained about
this until now.

While at it lower the security margin from 2% to just 1%. On the one
hand we need a small security margin, because Quake II is not that
precise and out average times spend may be too low. On the other hand
the margin must not be too large, because the bigger the margin is the
bigger is the risk of missing frames... Both 2% and 1% is very small,
in fact often they don't even make a difference because of float ->
int conversations. For example 16 * 0,02 = 0,32 -> cut to 0. But there
are some extrem cases were it matters and my empirical testing showed
that 1% is slighty better then 2%. At least on my system. An it's
better to f*ck up the timing for a small number of frames than missing
a frame. A broken timing is hard to recognize, a missed frame is much
more annoying.
2018-10-23 18:37:25 +02:00
Yamagi Burmeister
861cf25ddf Fix ogg_shuffle display in menu.
In issue #296 it was pointed out that the menu shows ogg_shuffle
always as disabled, even if it's set to 1. This was an oversight,
the menu code was still checking the ogg_squence cvar removed in
the big OGG/Vorbis refactoring. Update it to match reality.
2018-10-22 20:25:16 +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
Denis Pauk
316918c29b cleanup code in sw_surf 2018-10-08 22:29:45 +03:00
Denis Pauk
26e9c6e5c4 cleanup code in sw_polyse 2018-10-08 22:29:45 +03:00
Denis Pauk
c30cffd1ed Use local currentmodel 2018-10-08 22:29:45 +03:00
Denis Pauk
0ff5dc804d Use local currententity 2018-10-08 22:29:45 +03:00
Yamagi Burmeister
9e4bde0803 Reset debristhisframe at level end.
This shoouldn't be necessary but won't hurt either.
2018-10-07 12:19:33 +02:00
Yamagi Burmeister
bf6f2bd1e1 Give gibs and debris 250 health points.
This prevents gibs and debris being easily destroyed with the rocket
launcher but leaves enough room for the entities being destroyed by
elevators, doors and the like if necessary.
2018-10-07 11:47:06 +02:00
Yamagi Burmeister
ef55042cef Split the gibs per frame limit between gibs and debris.
The gibs and debris per frame must be limited to prevent server mem
map overflows. Until now debris and gibs were handled the same, the
debris spawned by rockets and grenates could prevent the actual gibs
of the killed monster from spawning.

Before this change 20 entities were spawned at max. Now up tp 40
enties can be spawned. This needs some testings.

Fixes issue 323.
2018-10-07 11:47:06 +02:00
Yamagi Burmeister
9525dc35a8 Some small cleanups to entity file support.
- Fix some compiler warning about wrong format strings.
- Comply to code style.
- Remove unnecessary comments.
2018-10-07 09:51:19 +02:00
NeonKnightOA
d036868600 Add support for external entity files (.ent files).
This was ported from KMQ2.
2018-10-07 09:50:54 +02:00
Yamagi Burmeister
08037e7328 Don't accelerate upper entities, let them be pushed by the lower ent.
A long time ago in 2b4f223 I introduced a small logic change to the
handling of stacked entities. If two entities were standing on each
other the original code set the movement speed of the upper entity
to 0. It would be pushed or dragged by the lower entity. I changed
that in way that the upper entity got the same speed as the lower
entity. With that change it wasn't pushed or dragged but moving on
it's own. I hoped to fix some of the 'elevator hurts player or monster'
bugs.

That hope was wrong, at a later time we quirked all elevators that hurt
the player. Additionally the change lead to physics bugs if entities are
standing on high speed elevators (more than 200 units per seconds). So
revert it.

The actual fix was already committed as part of 69b6e5a. This is just a
little cleanup commit, mainly for documentation purposes.

This closes #320.
2018-10-07 09:31:31 +02:00
Daniel Gibson
f2a73b3919 Switch to Enforcers bloody skin when he's killed, fixes #331
When killing the enforcer with one shot (instead of damaging him first
without killing, which will switch to the bloody skin), the skin wasn't
changed. Now it is.
2018-10-03 17:44:32 +02:00
Yamagi
881d9afda6
Merge pull request #322 from Smilo-platform/master
Fix IPV6 networking
2018-10-01 17:33:04 +02:00
Yamagi Burmeister
2909710b8c Don't stop processing dlights if one of them had a radius of 0.
I don't know if this has any visible effects. This was reported in
issue #333.
2018-09-30 19:59:07 +02:00
Yamagi Burmeister
69b6e5ad48 Redo 95bbb99 in a more correct manner.
1) Do not increment the frame rate returned by SDL by 1. Incrementing
   is unnessecary, more or less up to date versions on Nvidias, AMDs
   and Intels GPU driver on relevant platform return an value that's
   either correct or rounded up to next integer. And SDL itself also
   rounds up to the next integer. At least in current versions. In fact,
   incrementing the value by one is harmfull, it messes our internal
   timing up and leads to subtile miss predictions. Working around that
   in frame.c would add another bunch of fragile magic... So just do
   it correctly. If someone still has broken GPU drivers or SDL versions
   that are rounding down the could set vid_displayrefreshrate.
2) The calculation of the 5% security margin to pfps in frame.c was
   wrong. It didn't take into account that rfps can be slightly wrong
   in the first place, e.g. 60 on an 59.95hz display. Correct it by
   comparing against rfps including the margin and not the plain value.
2018-09-30 19:47:48 +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
Yamagi Burmeister
70ee5bcc4a Revert "Rework GLimp_GetRefreshRate(), fix a stupid bug."
After some pondering I realised that the changes was stupid. It
introduces some new subtile bugs, for example in some cases SDL
still rounds 59.95hz down to 59hz...
2018-09-30 18:42:21 +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
Yamagi Burmeister
95bbb9900b Rework GLimp_GetRefreshRate(), fix a stupid bug.
In the old world GLimp_GetRefreshRate() was called once at renderer
startup. Now in the new world with SDL 2.0 only it's called every frame
and thus the target framerate git increased by one every frame... That
lead to subtile timin problem in case that the vsync is enabled.

While here remove the hack added for some Windows GPU drivers by AMD.
Older versions returned 59 on 59.95hz displays, leading to small timing
problems. This is fixed in newer version so we don't need to work around
it. Removing the hack gives us somewhat more overall timing precision.

If someone really needs the hack vid_displayrefresh can be set to 60 to
get the old behaviour.
2018-09-08 19:05:10 +02:00
Yamagi Burmeister
3c349d6078 Bump version number to 7.31pre. 2018-09-05 17:17:47 +02:00
Yamagi Burmeister
a6b85eaac8 Bump version number to 7.30. 2018-09-05 17:17:28 +02:00
Yamagi Burmeister
a896e17efa Fix a compiler warning, do not assign a variable to itself. 2018-09-05 17:07:42 +02:00
Yamagi
7b0bcec11e
Merge pull request #317 from 0lvin/render_speedup_review
Cleanup code in soft render
2018-09-05 14:39:24 +02:00
Denis Pauk
c45e1e7f8c correct check for zstep 2018-09-04 22:51:20 +03:00
Yamagi Burmeister
0caefdecf2 Always print the full help for the 'ogg' command. 2018-09-04 14:17:49 +02:00
Denis Pauk
6adc4cc81c Revert "rename gl_anisotropic to r_anisotropic"
This reverts commit 49af62477a.
2018-09-03 21:22:01 +03:00
Denis Pauk
e265252170 Remove unused function parameter 2018-09-03 21:16:36 +03:00
Denis Pauk
a52db8bc85 support for lower version of SDL 2018-09-03 21:16:05 +03:00
Denis Pauk
1a0c6fe05c add check for overwrite triangle_spans 2018-09-03 21:15:58 +03:00
Denis Pauk
3b4c6c41c1 get rid separate surface usage 2018-09-03 21:15:51 +03:00
Denis Pauk
136d6890ff small cleanups 2018-09-03 21:15:40 +03:00
Denis Pauk
aa3a688495 remove all aliases for vid.width 2018-09-03 21:15:33 +03:00
Daniel Gibson
67bb061741 Add missing newline in message printed by --help cmdline arg 2018-09-03 04:31:14 +02:00
Yamagi Burmeister
f15d4181eb Do not throw last 12 seconds of a Vorbis file away when looping.
Until now we just called OGG_Stop() as soon as we read the last samples
from a Vorbis files. OGG_Stop() flushed all unplayed samples (about 12
seconds of playback) from the OpenAL playback queue... Instead just set
our internal state of STOPPED, open the next file and be done.
2018-09-02 09:39:57 +02:00
Denis Pauk
01ca7db6f4 remove unused functions 2018-08-28 23:22:40 +03:00
Denis Pauk
2812ef30dd Reuse GLimp_InitGraphics for create window 2018-08-28 23:22:40 +03:00
Denis Pauk
8fc5bafb64 move render prepere staff to separate function 2018-08-28 23:22:40 +03:00
Denis Pauk
f1bf4d2b44 Directly use of currentpalette
* remove conversion currentpalette to SDL pixel format
* create textures with RGBA format with same struct as currentpalette
2018-08-28 23:22:40 +03:00
Yamagi Burmeister
25a1f08656 Merge branch 'buildcleanup' 2018-08-15 17:48:30 +02:00
Yamagi
135b243b74
Merge pull request #314 from 0lvin/render_speedup_review
Render speedup
2018-08-15 17:41:23 +02:00
Yamagi Burmeister
93aa8270ad No need to print that the renderer as retexturing support.
Retexturing support has been non-optional for years.
2018-08-14 11:53:35 +02:00
Yamagi Burmeister
cf09fb2a99 Remove support for static linked OpenAL.
We haven't used that for years and it just complicates things.
2018-08-14 11:51:55 +02:00
Yamagi Burmeister
daf3dc6f41 Remove ZIP compile time option.
Having ZIP optional only complicates things and is unnecessary now that
the dependency to zlib is gone.
2018-08-14 11:12:38 +02:00
Yamagi Burmeister
0264c6d946 Remove DOGG compile time option.
Having OGG optional only complicates things and is unnecessary now that
the dependencies to libvorbis and libogg are gone.
2018-08-14 10:40:50 +02:00
Denis Pauk
49af62477a rename gl_anisotropic to r_anisotropic 2018-08-10 23:33:46 +03:00
Denis Pauk
ba38bf4f88 Small cleanups
* Use window width as maximum value for spancount
* Reuse GLimp_Shutdown
2018-08-10 23:04:19 +03:00