SZ_Print is really meant for occasions where we need to build up a
string via strcat into the sizebuf - MSG_WriteString is more
appropriate in the cases fixed here, usually following a
MSG_WriteByte() anyway, so nothing to append to. Use the
MSG_WriteStringf variant where appropriate to reduce reliance on the
va() buffers.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Presumably a simple anti-cheat precaution to stop people running "strings"
on the binaries in the days before the source was available. The
de-obfuscated strings are sent over the wire in the net protocol anyway.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The menu files hadn't been updated for the now expanded keysets.
Reported-by: Sander van Dijk <a.h.vandijk@gmail.com>
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Re-order things, and generally force this squarish peg into the round
hole. Will want to factor out some of the fundamental differences into
different files later to reduce the #ifdef tangles, but at least some
benefit to be gained by having the common code shared.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Re-arrange order of functions, where functions are similar add a few
ifdefs to share common code and then add the client/server independent
bits to each file.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
When using SDL video/input, the game hangs when we select "New Game" from
the menu and the "Are you sure you want to start a new game?" prompt is
displayed, because we stop processing input events.
This is a bit of a hackish workaround, but will try to untangle this a bit
more later.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Simplifies access to the player colors later. Update the sbar usage of
colors to be consistent between NQ/QW as well.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Used only during development of the game when working over slow
connections remotely - doesn't seem relevant to doing development
today.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
...which is a lot! This ended up touching a lot of code, especially
when it spread to Cmd_Argv, etc. Mostly just propogating the correct
const qualifiers on pointers, but in some cases it was appropriate to
copy the buffer to e.g. lowercase filename in SV_BeginDownload_f or
re-write parts of functions where the buffer modifications was not
strictly needed (e.g. the *Say* functions).
I guess of note is that I now accept a const pointer into Z_Free,
which shouldn't be a problem since it doesn't modify the data pointed
to at all, just marks it as free.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Make as many arguments to functions in common.h as possible const so
the compiler knows we shouldn't be modifying some buffers/strings
passed down here.
Also fixed (but not tested) the COM_BlockSequenceCheckByte function in
QW/common/common.c which has been #if 0'd for a while. Probably won't
keep it around, but fixed for completeness.
I skipped COM_Parse in this patch, will be constified in the following
patch.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Wrap the vector macros that don't return a value in do {} while (0)
and fix a couple of missing semicolons detected in the process.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Pass over the source and make as many references to entities as possible
const. This makes it much more obvious where we are actually making
modifications to the entity_t structure.
Mostly trivial, the only place where I did something other than add the
keyword "const" was in R_DrawBrushModel where we were working around the
reversed pitch bug.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
QW was saving the whole visedicts list to scan for origins of objects
during the previous frame so that particle trails can be placed correctly
behind rockets, grenades, etc.
Save the origins and keynums in a simpler struct and remove the double
buffering of the cl_visedicts array.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
oldscr_viewsize was a duplicated check for changes in the scr_viewsize
cvar. Remove it and make the check consistent across all screen.c files.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Have the helper struct do the renderer specific alias model skin
processing. Will probably want to relocate the code to a more appropraite
place later, but just get the factoring done for now.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Create a model loader structure which can be used to pass callbacks down
from the renderer code. This will allow us to have the render do some
processing on the loaded data at appropriate points and let us make the
actual loading code generic.
In the first instance, pass down the aliashdr_t padding value required by
the renderer.
Note that to remove a circular dependency introduced in the headers, I had
to stop including render.h in model.h/gl_model.h and that change
propogated some more changes to includes across the tree...
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Update comment in the Makefile - one aspect fixed... now to tackle the
duplication between model.c and gl_model.c...
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Removes visibility of the areadnode_t structure from world.h and makes
sv_areanodes private again. pmove_mins and pmove_maxs no longer need to
be globals in sv_user.c either.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Apart from this function, sv_areanodes are private to world.c, so prepare
this function to be moved across.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Import fixes related to signed/unsigned shorts from the client BSP model
loading code. Would in theory allow the QW server to load huge maps with
e.g. > 32767 marksurfaces or clipnodes.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Pull in improvements from the client code and minimise syntactic
differences.
- Tidy up the header byte swapping
- Tighter checks on lump sizes and bounds against each other and the size
of the file
- Zero the flags field
- Calculate the model radius
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The struct qsockaddr used in NQ assumes some things about the binary
comptibility with the OS struct sockaddr_in, which caused some problems
with the networking on at least OpenBSD. Use the same netadr_t structure
that we currently have in QW.
Would have been nice to split this into smaller sub-patches, but it just
got messy each time I tried to do that.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
COM_FindFile now just calls COM_FOpenFile, so rename it and get rid of
the former. Remove use of Sys_FileOpen integer handles and use FILE *
instead. Fix the comment above the funcion in both nq and qw.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Instead of interger handles from sys_*, use standard C FILE * operations,
same as we do for qw already.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
No problem with circular dependency anymore. Also folded in some whitespace
changes to reduce the QW/NQ diff.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Remove the definition from QW/common/common.c and add it to common.h and
include the header. Remove the definitions from quakedef.h files.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Previous implementation of COM_ScanDirPak completely ignored any path
component in the pak filename. Switch to snprintf in COM_ScanDir as well
while we're at it.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Factor out the texture resampling routines for the player skins. QW
needs the extra "stride" parameter because it only uses a
sub-rectangle of the full skin texture.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Reduces the indentation of the rest of the function by one tab stop
and makes it easier to see the real differences between the qw and nq
implementations.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The structures used to buffer the edict info which enables the QW
prediction logic can be hidden away inside cl_ent.c.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Again, quite a few silly "hacks" in there but can start to shake out some
of the differences as we go along.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Make the QW version more similar to the NQ version in structure. Once
re-ordered, the small differences are clear.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
NQ always used the high-precision timer API, and since I added a fallback
mode it should be fine to try for high precision first on all platforms
and fall back if necessary.
Also fixes some incorrect math in the timer wraparound case which
previously existed in QW client (wrong operator precedence).
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Remove this seemingly harmless check for something silly like time going
backwards - it happens a lot. Very confusing because it doesn't happen on
debug builds, but only when code optimisation is enabled.
It's very possible for a time arguement of zero to be passed in here.
However, when opimisation is enabled the FP math gets a bit looser and
ordering of operations can shift such that the float passed in is a very
small negative number.
When that happens and we reset the oldrealtime, we get tricked into
running too many simulation frames and the game speed gets screwed up.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
QW/client/gl_ngraph.c was declaring the extern, but it's already in draw.h
QW/client/gl_screen.c was defining a second copy! Not sure how we never
triggered duplicate symbol errors in the linker with that one...
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
While trying to fix a bug with screenshots (which I now cannot reproduce),
I noticed that the palette type in the PCX spec file says '1' represents
Colour/BW and '2' represents Grayscale. Seems Quake was doing the opposite
- although changing this made no difference to viewing the images in Gimp.
Also allowed some code formatting changes to creep in - at least the
function is as consistent as possible between QW/NQ and GL/SW now.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
In case one of the command's execution fails and causes a longjmp()
call such as by way of a Host_Error(), we would segfault because we
haven't saved the stack context/environment. This was the case with a
command line like "tyr-quake +connect localhost" without any servers
running. So, added a setjmp() call before Cbuf_Execute().
While we're at it, set host_initialized to true before exec of
quake.rc and we'll rename host_abortserver in NQ to host_abort, in
line with QW.
Modified version of patch by O.Sezer <sezero@users.sourceforge.net>
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
They are still quite different, but remove a few cosmetic points of
difference so it's easier to see the real differences.
NQ/host.c::_Host_Frame() vs. QW/client/cl_main.c::Host_Frame()
Allow netmask to be specified for greater control, e.g.:
addip 10.128.0.0/9
addip 172.16.192/18
Also fixed a couple of "dereferencing type-punned pointer will break
strict-aliasing rules" warnings.
Timegraph was not displaying anything for me so fix it, making it look
like netgraph. Graph rendering times in milliseconds. It looks like
this was a function used to quickly hack in different graph measures
during development, so perhaps make this more generic at some point?
Contrary to the comments, the QW server ignores the qport supplied by
the client. Make a note in the code in case I want to correct the code
or comments at a later stage...
clang pointed out a number of "unused" variables. These are "used" in
the sense that we do assign things to them, but the results are never
looked at.
As far as I can tell, all the cases included in this commit don't
point to any subtle bugs and should be safe to remove.
clang found a number of places where we redundantly set a variable to
some value and never read it back (before it is assigned
again). Remove those cases. A couple were cases of trying to silence
the compiler, but modern versions of gcc seem to have made some of
these unneccessary.
clang correctly points out that we store the return value from our
fread calls, but never check for success/failure. Don't bother storing
it for now, but go back and fix this later...
Quakeworld server command line parameters were not getting executed because by
calling the Cmd_StuffCmds() function directly, the cmd_argc variable was not
getting set correctly - causing Cmd_StuffCmds to just print the help text!
Thanks to Frank Haeseler <cryptus@cryptus.de> for reporting the breakage.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Fix a bug in the software renderer where we write past the end of the
rendering context if the end of episode text extends off the bottom of the
screen. The bug had actually been fixed in QW but not NQ, so this patch fixes
both consistently. Thanks to Sander van Dijk <a.h.vandijk@gmail.com> for both
reporting the problem and finding the cause.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Host_Error and Host_Endgame never return, so mark them as such and cleanup a
few unnecessary statements previously used to quiet compiler warnings.
Signed-off-by: Tyrann <tyrann@disenchant.net>
viddef_t vid resides in vid_* files and since it's a global it is *not*
supposed to live in multiple files. fixed that stupidity.
Signed-off-by: O.Sezer <sezero@users.sourceforge.net>
Signed-off-by: Tyrann <tyrann@disenchant.net>
MAX_MOD_KNOWN had already been raised from 256 -> 512 in glquake, but not in
the software renderer or in qwsv. Some maps/mods hit the 256 limit these days
(Contract Revoked was reported to have problems - thanks Sander).
Reported-by: Sander van Dijk <a.h.vandijk@gmail.com>
Signed-off-by: Tyrann <tyrann@disenchant.net>
Since we're resetting len to 0, may as well shorten the string in the text
buffer too. Patch from O.Sezer <sezero@users.sourceforge.net>.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Do some more careful checking on model names string length.
Based on a patch from O.Sezer <sezero@users.sourceforge.net>.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Fix a bunch of incorrect uses and type mismatches in our printf-like functions,
revealed by the previous gcc attribute patches.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Annotate our varargs "printf" style functions with the gcc "format" attribute.
This shows up a whole bunch of incorrect usage in our code, so we'll start to
clean that up in subsequent patches. We've also constified the format string
arguments here.
Based on a patch from O.Sezer <sezero@users.sourceforge.net>
Signed-off-by: Tyrann <tyrann@disenchant.net>
Seems silly to have the Con_{D,}Printf functions duplicated in different
headers, so just use the definition from console.h. QW server actually
implements the functions in sv_send.c, so this is a little messy, but I still
see it as a small improvement.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Annotate a few functions (BOPS_Error, Sys_Error, Sys_Quit and SV_Error) with
the gcc attribute "noreturn" and clean up a few lines of dead code which were
only there previously to quiet the corresponding compiler warnings.
Based on a patch from O.Sezer <sezero@users.sourceforge.net>
Signed-off-by: Tyrann <tyrann@disenchant.net>
Prepare pr_exec.c for merging - all differences are either trivial whitespace
or just differences in the error functions called.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Use the new Z_Realloc function to grow the progs string table dynamically as
needed. Some large maps need significantly more than the 2048 entries I had
allocated statically before.
Based on the uHexenII implementation.
Thanks to O.Sezer <sezero@users.sourceforge.net>.
Signed-off-by: Tyrann <tyrann@disenchant.net>
min/max clashes with another macro in the mingw headers, so just rename ours
to qmin/qmax. Move the definitions to mathlib.h so they can be shared between
QW and NQ.
Signed-off-by: Tyrann <tyrann@disenchant.net>
AFAICT this little snippet of code is for compatability with the first
"Intellimouse" drivers, back when mouse wheels were just new. There still
seems to be something wrong with mouse wheel handling in NQ during gameplay
(works in the menu for setting the bindings and on the console for scrolling
the text - just not in the game...)
Anyway, with this patch both vid_win.c files are identical, ready for
merging...
Signed-off-by: Tyrann <tyrann@disenchant.net>