Commit graph

2081 commits

Author SHA1 Message Date
Yamagi
b1e3c90a51 Merge pull request #215 from 0lvin/joystick
Add joystick support
2017-09-25 19:41:15 +02:00
Yamagi Burmeister
f9c7d57180 Bump version number to 7.03pre. 2017-09-25 19:39:46 +02:00
Yamagi Burmeister
a8aad9a38a Bump version number to 7.02. 2017-09-25 19:21:04 +02:00
Yamagi Burmeister
aa4f3e39a5 CHANGELOG entries for 7.02. 2017-09-23 14:05:18 +02:00
Yamagi Burmeister
e5c39eeb7f Set -ffloat-store when building with gcc for i386.
This helps the old and crappy x87 FPU to produce correct values. And
finally implement compiler detection in the Makefile.
2017-09-21 18:40:12 +02:00
Yamagi Burmeister
ce2c3292c6 Force the x87 FPU to double precision mode.
The original client used single precision mode on Windows and the
default mode on all other platforms. Most platform (at least OS X,
FreeBSD, NetBSD up to 6.0, OpenBSD and Solaris) set double precision
as default, Linux sets extended double precision... When playing a
network game there're several possibilities:

* Same precision on both sides: This one is okay, of course.
* single precision <-> double precision: This one is okay, too. I guess
  this is because the code allows a small deviation between client and
  server to work around imprecisions introduced be the network protocol.
* double precision <-> extended double precision: This one is okay,
  likely for the same reasons given above.
* single precision <-> extended double precision: This one gives a lot
  of misspredictions at client side.

All of these are more or less academic these days. Yamagi Quake II used
the platforms default mode for ages. And both gcc and clang default to
SSE2 math (with double precision as default on all platforms) when
compiling for amd64. So the only reasonable case is Linux/i386 on one
side and the original client or another source port on Windows/i386 at
the other side.

Work around this by forcing the x87 to double precision mode.
2017-09-20 21:55:43 +02:00
Denis Pauk
e7199f5c41 Add support for joystick/gamecontroller(axis/buttons/hats)/haptic.
By default joystick "in_joystick" and haptic feedback haptic ("joy_haptic_magnitude")
are disabled. And can be anabled by menu in options section. Joystick/Haptic
options are showed only if have found any.

By default axis is mapped in such way:
 * Left X(joy_axis_leftx): sidemove
 * Left Y(joy_axis_lefty): forwardmove
 * Right X(joy_axis_rightx): yaw
 * Right Y(joy_axis_righty): pitch
 * Trigger Left(joy_axis_triggerleft): triggerleft
 * Trigger Right(joy_axis_triggerright): triggerright

Joystick sensitivity varibales:
 * joy_yawsensitivity,
 * joy_pitchsensitivity,
 * joy_forwardsensitivity,
 * joy_sidesensitivity,
 * joy_upsensitivity.

For change joystick axis mapping to gamecontoller axis export SDL_GAMECONTROLLERCONFIG before run,
e.g.: SDL_GAMECONTROLLERCONFIG='<joystick guid>,<joystick name>,leftx:a0,lefty:a1,rightx:a2,righty:a3,'

Add menu navigation by dpad and thresholds:
 * Add threshold for axis (based on ioquake3), 0.15 by defaults.
 * Navigate in menus by dpad (up/down, left/right, any joystick button for enter).

Defaults:
 * in_joystick "0.0"
 * joy_haptic_magnitude "0.0"
 * joy_axis_leftx "sidemove"
 * joy_axis_leftx_threshold "0.15"
 * joy_axis_lefty "forwardmove"
 * joy_axis_lefty_threshold "0.15"
 * joy_axis_rightx "yaw"
 * joy_axis_rightx_threshold "0.15"
 * joy_axis_righty "pitch"
 * joy_axis_righty_threshold "0.15"
 * joy_axis_triggerleft "triggerleft"
 * joy_axis_triggerleft_threshold "0.15"
 * joy_axis_triggerright "triggerright"
 * joy_axis_triggerright_threshold "0.15"
 * joy_forwardsensitivity "1.0"
 * joy_pitchsensitivity "1.0"
 * joy_sidesensitivity "1.0"
 * joy_upsensitivity "1.0"
 * joy_yawsensitivity "1.0"
2017-09-16 14:23:12 +03:00
Yamagi Burmeister
e1ec177dbe Remove miscframe altogether.
Miscframes are coupled to renderframes and are just checking for
renderer changes (very cheap) and advancing CD audio if implemented.
There's no reason not to that at every frame.
2017-09-09 09:39:56 +02:00
Yamagi Burmeister
eb4fdb56de Miscframes must be synchronized with renderframes.
Otherwise vid_restart triggers only if misc- and renderframes match by
luck.
2017-09-08 19:43:54 +02:00
Yamagi Burmeister
b88b3cb85d Add back function call to Cvar_Fini() removed by git in branch merge.
Don't know why git removed it.
2017-09-07 18:31:49 +02:00
Yamagi Burmeister
a0db877031 Merge remote-tracking branch 'memleak/small_mem_leak_fixes' 2017-09-07 18:30:03 +02:00
Yamagi Burmeister
6c7039af80 Revert "Remove empty function Qcommon_shutdown()."
This reverts commit ec428bb752. Looks like
the function is usefull for pull request #232.
2017-09-07 18:19:45 +02:00
Yamagi Burmeister
f3df541b79 Fix a potential crash in ai_run_melee() and ai_run_missile().
This was found and fixed by Maraakate.
2017-09-07 18:13:01 +02:00
Yamagi Burmeister
f107a77edb Fix an undefined function warning on Windows.
shared.h is needed on all platforms so include it unconditionally.
2017-09-07 18:02:31 +02:00
Yamagi Burmeister
42dfd3dbdd Refactor curtime to be set at one defined point.
Until now the curtime variable was set at every call Sys_*seconds().
That's a little bit unfortunate because calls to that functions are
scattered around the code. Instead set it once every frame in
Qcommon_Frame().
2017-09-07 17:12:58 +02:00
Yamagi Burmeister
5fa6fa9175 Sleep 850 microseconds between dedicated server frames.
The dedicated server runs at cl_maxfps frames per second. Een with very
large values one server frame can never be shorter than 1 milliseconds.
And the timing doesn't need to be very precise since the network
latency adds a lot of more jitter.
2017-09-07 14:53:00 +02:00
Yamagi Burmeister
950e581103 Untangle global variables between dedicated only and normal build. 2017-09-07 14:37:51 +02:00
Yamagi Burmeister
70f678fb80 Implement distinct versions of Qcommon_Frame() for both build types.
Yes, this duplicates some code. But it's at least 100 times more
readable to have two distinct functions for distinct purposes instead
of about 25 #ifdef.
2017-09-07 14:24:09 +02:00
Yamagi Burmeister
85890da3bb Cleanup Qcommon_Init(). 2017-09-07 13:51:52 +02:00
Yamagi Burmeister
1fc565a33b Remove unused "error" command.
"error" was a debug command to test emergency shutdowns. It's not needed
any more. Since users may complain that "error" crashes their game
remove it.
2017-09-07 13:36:17 +02:00
Yamagi Burmeister
6ab2b3227a Rename common/misc.c to common/frame.c.
Now that we moved the CRC stuff to crc.c only the frame handling is
left in this files.
2017-09-07 13:31:52 +02:00
Yamagi Burmeister
801695cf35 Move several CRC function from misc.c to crc.c.
While here remove several unused functions and variables.
2017-09-07 13:22:36 +02:00
Yamagi Burmeister
629683ab40 Also print errors when build with DEDICATED_ONLY. 2017-09-07 13:17:02 +02:00
Yamagi Burmeister
ec428bb752 Remove empty function Qcommon_shutdown(). 2017-09-07 13:05:49 +02:00
Yamagi Burmeister
143c5d1e40 Merge branch 'framecounter_5th_try'
Like the branch name suggests this was a rather hard ride. Lessons
learned:

* Quake IIs timing is one big clusterfuck.
* The Radeon driver for Windows has a questionable vsync implementation.

What should be done:

* Get rid of the global currenttime.
* DEDICATED_ONLY needs to be refactored.

This commit closes issue #222.
2017-09-06 19:34:52 +02:00
Yamagi Burmeister
d0cb89ff52 Change Windows mainloop to microseconds.
While at it have another look at it's Sys_*seconds() implementations.
Also add a Sys_Nanosleep() and use it to throttle the game a litte bit.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
0c3c2976cf Fix timedemos. 2017-09-06 18:36:51 +02:00
Yamagi Burmeister
5ece000c18 Insert 5 microseconds sleep time each frame.
This shouldn't have any noteable impact on timing (besides the machine
is way too slow for Quake II) and saves a lot of CPU cycles. 100% load
vs. 17% load on my desktop.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
a3ce70d2e3 Fix dedicated server build. 2017-09-06 18:36:51 +02:00
Yamagi Burmeister
465963a1a5 Reconnect the server to the global timing.
Having the server in an own timing zone seems to simplify things but
introduces slight timing discrepancies. The most visible effect is that
the game runs a little bit too fast, especially in the first cl_maxfps
frames.

Therefor: Remove timeframes, they're unnecessary. Track the time since
the last (client|server) frame instead and pass it to the client and
server when it's called.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
0a3c6f3786 Fix timing debug cvars and don't run the terminal console too often. 2017-09-06 18:36:51 +02:00
Yamagi Burmeister
4ac97f8a2b Remove the brake from the mainloop.
It's longer necessary now that we've refactored the global timing.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
c32f4b0e4a Move timing from CL_Frame() to Qcommon_Frame().
This allows us to implement the global timing without an artificial
brake slowing the game unnecessary down. This is only partial working,
more changes and fixes are coming.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
a0aa1c87c7 Change the global timing in main() from milli- to microseconds.
This is a no-op for now. We need this to get a much higher precision
when calculating the frame times. This changes the fixedtime cvar from
milli- to microseconds.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
f16242e923 Determine svs.realtime from curtime and not the global timing.
This is the same as the client does for it's realtime. It looks at least
somewhat more correct since it pevents rounding errors. And things are
simplified a litte bit since the server timing is now independent of the
global timing.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
79f73da62b Implement a much better / more accurate framecounter.
The old framecounter had two problems:

* It measured only the time of the current render frame, not the total
  time spend between the last and the current render frame. Therefor the
  calculated value was too high.
* It was based upon milliseconds and rather inaccurate.

This new frame counter solves both problems. The total time spend
between two render frames is measured and the measurement done in
microseconds.

There're three modes:

* cl_drawfps 1 displayes the average frame rate calculated over the last
  60 frames.
* cl_drawfps 2 displays a nice string with minimal framerate, maximum
  framerate and average framerate. All three values are calculated over
  the last 60 frames.
* cl_drawfps 3 is the same as number 2 but with a second line showing the
  raw values.

TODO:

* Discuss if cl_drawfps should be renamed to cl_showfps. All other
  status displays are named cl_show*.

While at it remove several unsused drawing functions.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
0fafaf735f Implement a Sys_Microsecond().
This is the same as the well known Sys_Milliseconds() but like the name
suggests with microsecond precision. To be used in the upcoming new
framecounter.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
406857f57a Make the Linux / Unix backend year 2038 compliant. 2017-09-06 18:36:51 +02:00
Yamagi
e869223e7f Merge pull request #235 from 0lvin/ctb_image-update
update stb_image.h v2.02->v2.16
2017-09-05 20:54:05 +02:00
Denis Pauk
95e02d99cf update stb_image.h v2.02->v2.16 2017-09-05 21:30:37 +03:00
Daniel Gibson
0051c6b8d2 If renderer init fails and MSAA is on, disable it and try again
For some fucking reason, if you set an unsupported
SDL_GL_MULTISAMPLESAMPLES value on Windows (at least Win10 with Intel GPU
drivers, there 16 is unsupported), creating the Window and OpenGL context
will succeed, but you'll get Microsofts stupid GDI OpenGL software
implementation that only supports OpenGL 1.1.
Before these fixes, the GL3 renderer would just crash and the GL1 renderer
would fail to load, which caused the game to run in the background:
No Window, no Input, but sound was playing..

Now this problem should be handled properly and if initialization fails,
the rendering backend will be considered not working, and it will
try the gl1 backend next, and if that also fails it'll give up and exit
the game.
2017-09-04 00:21:10 +02:00
Daniel Gibson
36ef1e6bb8 Exit game if loading renderer fails
it's no fun without a  window, even if sound works you don't have input..
2017-09-04 00:18:13 +02:00
Yamagi Burmeister
aa5f63e0dc Since mkdir() isn't recursive we need to create .yq2/$moddir. 2017-08-31 17:26:32 +02:00
Yamagi Burmeister
503ab368a2 Decouple horplus and fov in the video menu.
Until now the video menu enforced:

* fov set to 90 and horplus set to 1
* fov set to something other than 90 and horplus to 0

If the user hat configured another configuration through the console the
menu would reset it, even if only unrelated changes are applied. With
this change horplus is ignored by the menu and only fov is altered. The
rationale behind this is that most users want horplus enabled and all
others can disable it through the console.

This is believed to fix issue #225.
2017-08-30 15:05:02 +02:00
David Carlier
9f71d55258 fixing couple of small memory leaks 2017-08-27 01:00:57 +01:00
Daniel Gibson
50b0e97332 README: don't tell people to delete maps.lst 2017-08-26 22:55:07 +02:00
Yamagi Burmeister
7f46d808d2 Second part of Developer_searchpath() removal.
This was forgotten in the first commit. :(
2017-08-07 18:10:32 +02:00
Daniel Gibson
11b3a0515a Merge branch 'searchpath' 2017-08-05 18:40:44 +02:00
Daniel Gibson
f38d3475df Add documentation for package maintainers 2017-08-05 18:28:33 +02:00
Yamagi Burmeister
db2cde0325 Remove disgusting and broken Developer_searchpath() function.
It's mush better and safer to query the "game" cvar instead. It's always
set to the mods name and get's the baseq2 special case right.
2017-08-04 09:20:44 +02:00