Commit Graph

960 Commits

Author SHA1 Message Date
Kevin Shanahan
92adc9f0c7 trivial: remove unnecessary snprintf buffer termination checks
Lost my mind for a while there - snprintf always terminates the
buffer. A couple of minor tidy ups in nearby code while I was looking
over all the calls.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 12:19:08 +10:30
Kevin Shanahan
ee389ca9a3 common: make COM_StripExtension work in-place
Rather than needing external checks on the output buffer, or adding a
"max length" parameter and needing to check for overflow, etc., make
COM_StripExtension modify the existing string.

Callers updated as needed.

A personal note that I finally realised that snprintf always zero
terminates the output buffer! So that should tidy up existing code a
little more and makes it an even better replacement for strncpy in
almost every case.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 11:50:17 +10:30
Kevin Shanahan
6ea7d078bb common: trivial MSG_ReadString cleanups
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 09:36:45 +10:30
Kevin Shanahan
24b4673eef net: MSG_ReadString auditing in net_dgrm.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 09:19:12 +10:30
Kevin Shanahan
11590ac3d4 net: consolidate error handling in _Datagram_Connect
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 09:18:29 +10:30
Kevin Shanahan
c3816ee74a net: tidy up _Datagram_SearchForHosts
Use a pointer to the hostcache entry, rather than indexing into the
hostcache array over and over again - improves readability. Attempt to
make the name conflict resolution a little nicer, but it's still damn
ugly.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 09:02:31 +10:30
Kevin Shanahan
7b5f57da91 client: MSG_ReadString auditing in NQ/cl_parse.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-19 08:32:40 +10:30
Kevin Shanahan
5ca9e3f44c client: tidy up snprintf handling in CL_ProcessUserInfo
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 21:18:25 +10:30
Kevin Shanahan
0ebd2471f1 client: clean up handling of MSG_ReadString buffers in cl_parse.c
Generally try to consistently handle buffers where MSG_ReadString is
concerned. Scary the number of places where buffer sizes are
incorrectly handled.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 21:13:37 +10:30
Kevin Shanahan
f2a0768356 client: protect against lightstyle overflow
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 20:27:29 +10:30
Kevin Shanahan
644367c3ef client: remove temp buffer from A2C_CLIENT_COMMAND
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 20:17:21 +10:30
Kevin Shanahan
0d60116657 common: use shared string buffers for va and MSG_ReadString{,Line}
Extend the shared string buffers set up for va() use to the
MSG_ReadString and MSG_ReadStringLine functions. Means that subsequent
calls to MSG_ReadString don't immediately invalidate the results of
the previous call (4 rotating buffers).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 19:00:18 +10:30
Kevin Shanahan
bd2a7d493e cmd: make Cbuf_AddText accept printf formatted strings
Reduces a bit of the extra buffer copying and reliance on va(). Buffer
length checks for a few cases now consolidated into one place.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 15:35:38 +10:30
Kevin Shanahan
d1087300b0 input: don't mess with key repeat handling in sdl driver
We don't really care about key repeats at this level, they are handled
by the key subsystem anyway. Probably should drop this from the other
input drivers as well.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 14:36:21 +10:30
Kevin Shanahan
1e81ac5c05 keys: make the toggle console key work again during demo playback
I broke this when I wanted to be able to use the ~ and ` keys within
the console. Now check the bindings directly so no matter what key is
bound to it, you can toggle the console.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 14:15:59 +10:30
Kevin Shanahan
7a9781d91e client: remove stufftext debugging printf
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 13:27:56 +10:30
Kevin Shanahan
6c51091dd4 trivial: cast data to correct type for CL_StartUpload
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 13:15:52 +10:30
Kevin Shanahan
00a3e9d26e client: reset any active palette shift on disconnect
Noticed sometimes (usually when playing a demo, then loading a level)
that the active palette shift remains when starting a new level.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 13:14:32 +10:30
Kevin Shanahan
fe2b85b1c5 screen: fix colours in gl remote screenshots
Fix a typo in the RGB orderings. Also switch to format GL_RGBA for
glReadPixels, as that's the only format that's guaranteed to be
available by the OpenGL ES spec (although we're not using that for
now, may as well be compatible).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 13:11:31 +10:30
Kevin Shanahan
7906b99af7 screen: fix location of screenshot text for glquake
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 12:47:41 +10:30
Kevin Shanahan
5ab2db165e screen: fix filename generation for remote screenshot
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 12:46:34 +10:30
Kevin Shanahan
6e9cee5b49 screen: make local private functions/variables static
Reduce the surface area of the interfaces again. Turns out
SCR_BringDownConsole was never used (though I suspect we still want to
add back something to reset palette shift on disconnect, etc.)

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 09:18:40 +10:30
Kevin Shanahan
3bfba9541c screen: rename screen_common.c back to screen.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 08:51:59 +10:30
Kevin Shanahan
8df366f04d screen: merge SCR_UpdateScreen functions and move to common file
This one looks pretty ugly with all it's conditional bits but should
be able to clean that up more later.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 08:48:18 +10:30
Kevin Shanahan
465a6401ed screen: move loading plaque code to common file
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 08:05:06 +10:30
Kevin Shanahan
637f047809 screen: bit of re-ordering in SCR_UpdateScreen
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-18 07:05:57 +10:30
Kevin Shanahan
b54d1777b8 screen: move screenshot code to shared file
Starting to see that I should have just merged everything into
screen.c. That's pretty much where I expect this will end up.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 21:24:38 +10:30
Kevin Shanahan
b509e815a4 screen: move SCR_DrawConsole to common file
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 20:55:03 +10:30
Kevin Shanahan
5512afe6f1 screen: move more shared code to screen_common.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 20:44:15 +10:30
Kevin Shanahan
cb597d1120 screen: move scr_copy{top,everything} set in GL SCR_UpdateScreen
In glquake, this is set but never read so doesn't really matter where
it get's set. Let's match the software renderer's ordering.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 15:47:51 +10:30
Kevin Shanahan
c1de06175c screen: move shared refdef functions to screen_common.c
Minor differences in SCR_CalcRefdef worked around with an #ifdef GLQUAKE.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 15:37:26 +10:30
Kevin Shanahan
240cca9cdf screen: move r_refdef.fov_{x,y} calculation
Makes it easier to share the common SW/GL code.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 15:14:55 +10:30
Kevin Shanahan
a2d10fbadc screen: factor out gl refdef vrect calculations, similar to sw renderer
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 14:55:00 +10:30
Kevin Shanahan
ceb8c8efdd screen: re-organise GL SCR_CalcRefdef to be more like R_SetVrect
Looks like the R_SetVrect code was pulled inside this function at some
point and massaged for the GL version. Make it look more like the
original code (without changing the behaviour at all).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 14:09:32 +10:30
Kevin Shanahan
62f08b09ce screen: make CalcFov static
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 14:09:15 +10:30
Kevin Shanahan
b2afdc3b59 render: mark input vrect const in R_SetVrect
Also, fix the argument names in the header file - an invitation for errors!

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 13:40:58 +10:30
Kevin Shanahan
f9a17a97a6 screen: #ifdef out the unused loading plaque code for QW/GL
The loading plaque code is never triggered in QW, so remove it from
the GL renderer in the same way it had been removed from the software
renderer.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 12:06:02 +10:30
Kevin Shanahan
8303aea9a1 screen: move some more shared code to screen_common.h
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 11:41:44 +10:30
Kevin Shanahan
4a5095252a screen: make private centerstring variables static
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 11:41:13 +10:30
Kevin Shanahan
990a106826 screen: fold SCR_CheckDrawCenterString into SCR_DrawCenterString
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 11:16:47 +10:30
Kevin Shanahan
ee4ae2d209 screen: pull common centerprint code into shared file
start pulling the common screen code into a shared file and leave only
the parts that need to differ between the renderers in the other
files.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 11:13:12 +10:30
Kevin Shanahan
7ee1a77cec input: take into account magnitude of scroll wheel event
SDL can deliver a variable amount of scroll wheel movment - not 100%
sure this is the correct way to handle it, but seems to work on all my
test boxes. Only on my Mac does the wheel event deliver a variable
magnitude depending on how far you scroll.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 10:15:08 +10:30
svdijk
087f489d54 SDL2ize mousewheel support (verify: up/down correct on windows/os x?).
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 09:56:08 +10:30
Kevin Shanahan
c36babc0b4 screen: constify SCR_CenterPrint(), fix truncation of long text
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 09:52:14 +10:30
Kevin Shanahan
a95b64a41b screen: rename block_drawing -> scr_block_drawing
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 09:11:19 +10:30
Kevin Shanahan
8a5607ef0a screen: constify argument to SCR_ModalMessage()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 09:06:33 +10:30
Kevin Shanahan
ab8cc408d3 screen: make WritePCXFile always take the upload parameter
Even though always false for NQ, make the API consistent to reduce
differences between NQ/QW. Constify the arguments as well.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 09:02:10 +10:30
Kevin Shanahan
bdef5d75ba screen: move screen.c file to common dir
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 08:55:52 +10:30
Kevin Shanahan
5a740d010c screen: merge differences between screen.c files
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 08:55:05 +10:30
Kevin Shanahan
72f8fd974d screen: remove duplicate definition of sb_lines
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 08:18:22 +10:30