Commit graph

3706 commits

Author SHA1 Message Date
Bill Currie
d139640755 Make fs_userpath default to ~/quakeforge on windows.
The ~ gets expanded to CSIDL_LOCAL_APPDATA, $HOME, $USERPROFILE or just
".", whichever succeeds first. The usual location will be:
"C:\windows\profiles\<user>\Local Settings\Application Data".

"." is now the fallback for *nix systems too.
2013-01-23 11:10:19 +09:00
Bill Currie
47c2d3cb2c Include stdint.h in regex.c
It seems stdint.h gets included automatically in windows builds.
2013-01-22 21:02:50 +09:00
Bill Currie
e27d7cbd2d Handle alloca "correctly".
Use AC_FUNC_ALLOCA and the #ifdef mess suggested by the autoconf docs
(hidden in qfalloca.h).
2013-01-22 21:02:50 +09:00
Bill Currie
f1aefc969d Fix some 64-bit mingw compile issues.
Just one more issue to fix (alloca), but with a hack, QF compiles (no clue
yet if it works: wine doesn't seem to be an option at this stage)
2013-01-22 21:02:49 +09:00
Bill Currie
cb45d248c4 Use the Mersenne Twister for particles.
The seed is currently 0xdeadbeef, but I intend on fixing that soon. Now the
particle velocities and origins use fully independent bits (though a big
chunk is wasted right now).
2013-01-21 20:06:54 +09:00
Bill Currie
5188644e75 Implement the Mersenne Twister PRNG.
This gives QF a consistent qualilty PRNG on all platforms. The
implementation is slightly different from the standard, but gives the same
results for the same speed (details in mersenne.c).
2013-01-21 20:05:16 +09:00
Bill Currie
3de67589a3 Fix random particle origin/velocity z component.
This is a quick fix until I get a random number generator into QF.

Mingw's RAND_MAX is only 0x7fff and so the (((rnd >> 10) & 63) - 31.5) / 63.0
used for the z component of origin and velocity would never go positive.
For now, change the 10 to 9 (reusing another bit from Y). I plan on
implementing a full 32-bit PRNG in QF so we always have a reliable
generator.
2013-01-21 14:53:13 +09:00
Bill Currie
f3682069e2 Ensure the float pointer to SND_Convert is aligned.
This should fix johnny's SIGBUS.
2013-01-19 16:09:32 +09:00
Bill Currie
22ca96ea46 Put the key_dest default back to key_console.
For now, anyway. This is a quick emergency fix for qw-client crashing when
a key is pressed while the client is waiting at the console on startup.
2013-01-19 12:17:57 +09:00
Bill Currie
6b05a7e964 Add (%Ec) to OP_ADDRESS's format specifier.
This makes OP_ADDRESS and OP_LOAD_* consistent.
2013-01-17 16:43:54 +09:00
Bill Currie
c25e68ecaf Use hex output for %E opcode format specifier.
This makes %E's addresses consistent with other address output.
2013-01-17 16:42:28 +09:00
Bill Currie
3c67e8f020 Fix the vector/quaternion scaling instructions.
It was pointed out by Blub\w (gmqcc) that OP_MUL_FV and friends were buggy
when the operands overlapped (eg, x = x.x * x) as the result would become
'x.x*x.x x.y*x.x*x.x x.z*x.x*x.x' (note the x.x squared for y and z). On
testing, sure enough the bug was present (and is a nice demonstration that
QF's VM does NOT have strict-aliasing bugs). As a very nice benefit: the
code produced by the fixes is actually faster than the broken version :).

The ruamoko code used for testing:
void (string fmt, ...) printf = #0;

vector foo (vector x)
{
    x = x * x.x;
    return x;
}

vector bar (vector x)
{
    x = x.x * x;
    return x;
}

int main ()
{
    vector x = '2 3 4';
    vector y = foo (x);
    vector z = bar (x);
    printf ("x=%v y=%v z=%v 2*x=%v\n", x, y, z, 2*x);
    return 0;
}
2013-01-17 10:23:02 +09:00
Bill Currie
ace8d9ebc5 Implement dynamic IMTs.
Now the user can create and destroy IMTs at will, though currently
destroying IMTs is currently all or nothing (imt_drop_all).

An IMT is created via imt_create which takes the keydest name (key_game
etc), the name of the IMT (must be unique for all IMTs) and optionally the
name of the IMT to which the key binding search will fall back if there is
no binding in the current IMT, but must be already defined and on the same
keydest. This means that IMTs now have user determined fallback paths. The
requirements for the fallback IMT prevent loops and other weird behaviour.

Actual key binding via in_bind is unaffected. This is why the IMT name must
be unique across all IMTs.

The "imt" command works with the key_game keydest, but imt_keydest is
provided for specifying the active IMT for a specific keydest.

At startup, default IMTs are setup to emulate the previous static IMTs so
old configs will continue to work (mostly). New config files will be
written with commands to drop all of the current IMTs and build new ones,
with the bindings and active IMT set as well.
2013-01-16 19:48:54 +09:00
Bill Currie
ec6ba8a03c Make key_dest private to keys.c
This has the bonus feature of making nq pause the game when input focus is
lost (same conditions as dropping the console or bringing up the menu).
2013-01-16 19:48:54 +09:00
Bill Currie
2a3986368e Use callbacks for key repeat control. 2013-01-16 19:48:54 +09:00
Bill Currie
cf0729c818 Support more than one keydest callback. 2013-01-16 19:48:54 +09:00
Bill Currie
8975dd95fe Recalculate the refdef when leaving a menu.
A tad brute force, but this should fix the status bar not refreshing when
exiting the menus.
2013-01-16 15:40:47 +09:00
Bill Currie
3cb0f3e183 Remove viddef in favor of vid in the renderers.
This fixes the status bar refresh issues in sw. The problem was that with
two viddef's hanging around, things got a little confused and recalc_refdef
wasn't getting into the renderer.
2013-01-16 11:23:47 +09:00
Ozkan Sezer
cdbb2ad030 Fix incorrect parsing of comments.
Parsing /*..*/ style comments would stop at the first *.
2013-01-16 10:31:02 +09:00
Bill Currie
cf5a3d805b Ensure menu is valid before doing anything. 2013-01-13 21:49:43 +09:00
Bill Currie
a05e7253e4 Force a full update when the fade screen is drawn. 2013-01-13 20:34:39 +09:00
Bill Currie
a8542c2d48 Correct the spelling of QFK_HIRAGANA_KATAKANA.
'twas QFK_HIRAGANA_kATAKANA. Took a while to spot it :P
2013-01-13 18:54:23 +09:00
Bill Currie
e8450f6c97 Add builtins to handle menu next/prev/enter. 2013-01-13 18:53:21 +09:00
Bill Currie
e3b8157469 Create a new imt_menu imt.
It seems to work nicely as F10 no longer tries to quit while the menu is
displayed.
2013-01-13 18:19:00 +09:00
Bill Currie
b18305351e Rename game_target to key_target.
Much better name :P
2013-01-13 18:14:16 +09:00
Bill Currie
b1ddae927b Add a command to clear specific IMTs.
in_clear <imt>... where each argument to in_clear is an imt identifier. If
any identifiers are incorrect, the incorrect ones will be displayed and no
tables will be cleared. All or nothing.
2013-01-13 18:05:41 +09:00
Bill Currie
0c81364da8 Fix scr_copyeverything in gl and glsl.
Now the gl renderers unconditionally set it to 1. This is required because
the screen is cleared every frame.
2013-01-13 17:23:00 +09:00
Bill Currie
4a95f89760 Correct the handling of r_viewsize and lineadj.
r_viewsize is meant to be clamped to 100, but not limit linadj.
2013-01-13 16:53:22 +09:00
Bill Currie
86b95629cf Complete the move of some vars into vid_render_data.
scr_fullupdate and scr_copyeverything were missed. Possibly others too, but
this is enough for the moment.
2013-01-13 16:46:41 +09:00
Bill Currie
9c812f39ce Apply some wart remover.
hungarian notation... *twitch*
2013-01-13 16:07:11 +09:00
Bill Currie
ed8b289315 Make sdl's VID_SetPalette only queue a palette change.
It seems that SDL_SetColors causes a page flip, so VID_SetPalette only
queue a palette change (by checking for the need to change and storing the
requested palete) and VID_Update now checks for a queued palette change and
updates SDL's palette if required. This fixes the flickering console in sw
-sdl introduced by the cshift/centerprint change.
2013-01-13 14:55:15 +09:00
Bill Currie
82a6861233 Move the call to VID_Update out of the if blocks.
This makes it obvious that VID_Update is unconditionally called when
SCR_UpdateScreen is called.
2013-01-13 14:43:19 +09:00
Bill Currie
5bbb76194f Use stdlib.h instead of alloca.h.
While the manpage does say alloca.h, that's not very portable, it seems.
stdlib.h seems to be better (at least for mingw, anyway)
2013-01-10 21:54:37 +09:00
Bill Currie
6b97967a68 Use g instead of e for the fp values.
Need to up the precision by one due to the difference between g and e, but
much prettier. Might need to rename that function :P I wish I'd thought to
check if g would work, but thanks to divVerent for the suggestion.
2013-01-08 20:15:24 +09:00
Bill Currie
b096a0242e Write fp values to saved games with enough precision.
That is, enough precision to uniquely identify the fp values. No drifts!
2013-01-08 18:50:44 +09:00
Bill Currie
d6bb5bec86 Use the already calculated string length.
No point doing it twice.
2013-01-08 18:10:27 +09:00
Bill Currie
9155338404 Add support for int and quaternion values in saved games. 2013-01-08 18:09:22 +09:00
Bill Currie
3e2a40684c Use dstring in PR_UglyValueString().
I should have done this a long time ago:P. This removes the really silly
255 char limit from strings in saved games (and thus fixes books in ITS).
2013-01-08 17:20:58 +09:00
Bill Currie
a4714ac9b5 Correctly parse octal escapes for plist strings.
It seems the code expected octal escapes to always start with 0. This is
not the case. Also, octal escapes are limited to 3 digits (and hex to 2).

This fixes the garbled bold text in ITS.
2013-01-08 16:54:23 +09:00
Bill Currie
febb615580 Create a test for octal chars in plist strings.
Both reading and writing.
2013-01-08 16:32:57 +09:00
Bill Currie
751417ffb2 Rename R_RecursiveWorldNode to R_VisitWorldNodes.
Finally, the name reflects its actual purpose.
2013-01-07 19:59:49 +09:00
Bill Currie
a852eeb711 Remove the recursive versions of R_RecursiveWorldNode.
They seem to not be needed any more.
2013-01-07 19:57:21 +09:00
Bill Currie
9758302023 Fix sw and sw32's R_RecursiveWorldNode node stack.
I guess I had forgotten to make the node stack dynamically allocated for
these renderers. Now ITS works in all four renderers.
2013-01-07 19:51:36 +09:00
Bill Currie
43702580f5 Clear the texture element chain after drawing.
It was properly cleared after drawing water chains and sky chains, but I
had missed normal surfaces. It took the use of the same texture for both
normal surfaces and water surfaces to trigger the bug. Thanks go to Simon
'Sock' O'Callaghan and his In The Shadows mod.
2013-01-06 20:05:59 +09:00
Bill Currie
49d07ce452 Implement MH's version of Sys_DoubleTime for windows.
From http://forums.inside3d.com/viewtopic.php?p=36239
2013-01-05 17:52:54 +09:00
Bill Currie
e0e69ac71a Fix some signed/unsigned comparison warnings.
It seems mingw's gcc treats pointer subtraction differently to how linux's
gcc does.
2013-01-05 17:52:48 +09:00
Bill Currie
7206756952 Produce a vidmode list for developer output.
vidmode is starting to show its age. Modern X doesn't need a config file,
and when one is not available, the list of available resolutions is quite
strange. Time to look into randr support.
2013-01-01 15:13:27 +09:00
Bill Currie
9d6954efb7 Fixup extended bsp when loading the file.
It turns out the tools need the node conversions too, so doing it in
bspfile seems to be best as it is used by everything that reads a bsp file.
2012-12-30 13:29:24 +09:00
Bill Currie
7a86ea2d41 Do not use the bsp2 header when byteswapping the header.
The bsp2 header is not necessarily correct (or even present), but the bsp29
header is: it was setup via set_bsp32_write. This fixes the bsp corruption
when vising a map (and, I expect, any problems with qfbsp on a big-endian
machine).
2012-12-29 20:57:55 +09:00
Bill Currie
a4d95f3f53 Move Mod_FindClipDepth and recurse_clip_tree into clip_hull.c.
Since the hull depth needs to be set for the hull to be useful, it makes
sense to move the code into the same place that allocates new hulls (to me,
anyway).
2012-12-29 16:25:47 +09:00
Bill Currie
3b63c31b5d Use pr_return for the null pointer check.
The params come after the return slot :P. Getting a null pointer exception
for movep from .return wasn't very funny.
2012-12-26 11:47:53 +09:00
Bill Currie
1fdc32bb39 Check for null VM pointer accesses.
Currently only four words of "null pointer protection" are available, but
it's a start.
2012-12-22 14:24:11 +09:00
Bill Currie
6eb6b6c0ba Change pointer_t to unsigned and clean up the mess.
It doesn't make sense to have negative pointers. The size of the commit is
from enabling gcc's -Wtype-limits warning and cleaning up that mess too.
2012-12-21 21:53:13 +09:00
Bill Currie
84a68b139e Rename set_iter_t's value to element.
Correct terminology and all :)
2012-12-21 14:09:00 +09:00
Bill Currie
427d52511c Fix an uninitialized variable warning.
It's a false positive, but best to be safe.
2012-12-19 17:13:32 +09:00
Bill Currie
7b38b0b339 Make S_Init safe to use with a null viewentity.
Current work in qwaq doesn't need 3d spacialization, so it wants to pass
null for the viewentity pointer.
2012-12-17 15:07:49 +09:00
Bill Currie
e17d8ac9db Add ruamoko wrappers for the set api.
This includes both normal functions and a Set class (and SetIterator
class). Most of the methods are implemented as builtins.
2012-12-16 13:48:36 +09:00
Bill Currie
3a9fe196b6 Get the return param right for messages to nil.
R_INT(pr) = R_(INT)(pr); is not exactly what I had intended :P
2012-12-16 13:39:59 +09:00
Bill Currie
f631f514e9 Fix the obj_error family of functions.
It seems they were written before quaternion support was added and were not
updated to take into account the variable size of parameters. Now at least
Object's -error: works.
2012-12-16 13:19:31 +09:00
Bill Currie
11b991cf9d Print the error message before the state dump.
Normally, the order doesn't matter, but when tracing code, it becomes very
difficult to tell where the trace ends and the dump begins. Printing the
message first puts the message between the trace and the dump: much easier
:)
2012-12-16 12:27:15 +09:00
Bill Currie
101ca22b5a Fix a couple of warnings found by the mxe gcc.
Finally, a recent gcc for our mingw builds :)
2012-12-14 17:07:53 +09:00
Bill Currie
3e38c4aa48 Merge branch 'qfcc-cse'
qfcc now does local common subexpression elimination. It seems to work, but
is optional (default off): use -O to enable. Also, uninitialized variable
detection is finally back :)

The progs engine now has very basic valgrind-like functionality for
checking pointer accesses. Enable with pr_boundscheck 2
2012-12-13 20:17:28 +09:00
Bill Currie
95c249e8b9 Scale the glsl crosshairs to match gl. 2012-12-12 22:34:49 +09:00
Bill Currie
2ce65d931e Use exact texture coords for 2d pics in glsl.
Moving the texture coordinates in 1/4 pixel made a mess of the 2d pics
(very noticable on the round crosshair).
2012-12-12 22:34:43 +09:00
Bill Currie
cb259823af Scale the glsl crosshairs to match gl. 2012-12-12 21:37:55 +09:00
Bill Currie
f71affdfba Use exact texture coords for 2d pics in glsl.
Moving the texture coordinates in 1/4 pixel made a mess of the 2d pics
(very noticable on the round crosshair).
2012-12-12 21:34:37 +09:00
Bill Currie
a372efee5c Add a new crosshair.
Now all 4 slots of the crosshair table are used :)

Also, fix the offset for pic based crosshairs in glsl, and use just one
func for them.
2012-12-12 19:36:50 +09:00
Bill Currie
814f902e88 Add a new crosshair.
Now all 4 slots of the crosshair table are used :)

Also, fix the offset for pic based crosshairs in glsl, and use just one
func for them.
2012-12-12 19:36:18 +09:00
Bill Currie
6473951daa Make the set notation more correct.
The empty set is now {}, the set of everything is now {...} and the rest
now have {} around the members.
2012-12-09 22:17:55 +09:00
Bill Currie
061e2be5d4 Re-write the set testing code.
Getting everything right with an enum proved to be too difficult if not
impossible. Also use better tests for equivalence and intersection.

Many more tests have been added. All pass :)
2012-12-09 13:52:48 +09:00
Bill Currie
94e804d786 Make some more set_test fixes.
Two inverted sets can never be disjoint.
2012-12-07 22:25:36 +09:00
Bill Currie
56956fc370 Rewrite the intersection tests.
The early bailout proved to be difficult to get right, so don't bother.
2012-12-07 22:16:51 +09:00
Bill Currie
98c9e4f8c0 White space. 2012-12-07 22:16:22 +09:00
Bill Currie
f3328a61c7 More tests and update a comment. 2012-12-07 22:16:07 +09:00
Bill Currie
b053edee17 Fix the handling of size in set_expand.
It was correct for set_add, but not for other ops :/ (out by 1)
2012-12-07 20:44:09 +09:00
Bill Currie
770a40cef0 Add a bunch more tests.
Even found some bugs :)
2012-12-07 20:43:11 +09:00
Bill Currie
39920a4ea7 Fix the type when converting set of everything to string. 2012-12-07 19:35:37 +09:00
Bill Currie
c76231ca30 Add some very basic tests for sets.
They test creation, empty, everything and inversion. Already found a bug
(typo: "everythign" :P)
2012-12-07 19:34:34 +09:00
Bill Currie
e0c92b6089 Rename set_iter_t's member to value.
Makes more sense now that the membership of the value depends on the
inversion of the set.
2012-12-06 21:11:38 +09:00
Bill Currie
eb8fd55677 Move set.c into libQFutil.
Also move the ALLOC/FREE macros from qfcc.h to QF/alloc.h (needed to for
set.c).

Both modules are more generally useful than just for qfcc (eg, set
builtins for ruamoko).
2012-12-06 20:52:53 +09:00
Bill Currie
34e3ac1468 Fix jumpb's operand types.
Aliasing the jump table to an integer broke statement_get_targetlist with
the new alias def handling, and was really wrong anyway. I probably did
that due to being fed up with things and wanting to get qfcc working again
rather than spending time getting jumpb right.
2012-12-05 22:20:55 +09:00
Bill Currie
a12eb940f1 Remove the hard-coded bsp maximum depths.
The depth limits in the gl and glsl renderers and in the trace code really
bothered me, but then the fix hit me: at load-time, recurse the trees
normally and record the depth in the appropriate place. The node stacks can
then be allocated as necessary (I chose to add a paranoia buffer of 2, but
I expect the maximum depth will rarely be used).
2012-11-28 21:29:03 +09:00
Bill Currie
67b796f851 Fix a silly error in bsp extents checking.
Found while hunting for rhinodemons.
2012-11-23 14:38:15 +09:00
Bill Currie
fe9fb41f93 Correct some very suspicious looking code.
While accessing short foo[2][4]; as foo[0][0..7] should work in theory, who
knows what gcc does with it when optimizing. I don't know if this will fix
johnnyonflame's bsp loading problem, but no point in having rhinodemonic
code hanging around.
2012-11-23 14:35:34 +09:00
Bill Currie
4b503c7f72 Store the requested size in the block.
This necessitated disabling the id2 padding, but it's only commented out
incase there's more growth. Now the (compiler) error in -addObjectNoRetain
is caught ealier.
2012-11-19 21:50:42 +09:00
Bill Currie
8ee98e1ef5 Rename memblock_s's size to block_size.
In order to improve the pointer checking, I plan on adding a size field to
represent the requested size.
2012-11-19 21:35:27 +09:00
Bill Currie
49ad301d3d Add improved memory checking to progs.
With pr_boundscheck >= 2, pointer access will be checked against allocated
blocks (qfvalgrind?:). Currently extremely basic, but it seems to work.
2012-11-19 20:03:21 +09:00
Bill Currie
d0c37bbc51 Change the int<->float conversion opcode string.
Using "=" was rather confusing, so changing it to "<CONV>" seems to be a
good idea. As the string is used only for selecting opcodes at compile
time, only qfcc is affected.
2012-11-16 14:47:54 +09:00
Bill Currie
b8b626ee81 Change the int<->float conversion opcode string.
Using "=" was rather confusing, so changing it to "<CONV>" seems to be a
good idea. As the string is used only for selecting opcodes at compile
time, only qfcc is affected.
2012-11-16 14:45:11 +09:00
Bill Currie
d5c831b6da Add a little test case for accessing types.
Using ruamoko to access ruamoko type encodings is actually quite pleasant
:)
2012-11-15 13:40:11 +09:00
Bill Currie
6b46cde7c8 Move retainCount out of Object.
Going by "standard" Objective-C, retainCount really doesn't belong in
Object itself. The way GNUStep does it is to stash retainCount in memory
just below the object by allocating extra bytes for the count and returning
a pointer just beyond those extra bytes. Now Ruamoko does the same. This
fixes the inconsistencies in structure layouts for Protocol and class
structs between qfcc generated (internal) structs and user visible structs.
2012-11-08 20:24:25 +09:00
Bill Currie
1f9735d0cb Correct the dump format for conj.q. 2012-10-27 11:45:10 +09:00
Bill Currie
ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Ozkan Sezer
6e04fd5ff6 signed int viddef_t members
The attached patch (against quakeforge git) changes the [con]width,
[con]height, and most importantly the rowbytes members of viddef_t
from unsigned to signed int, like in q2.  This allows for a properly
negative vid.rowbytes which may be needed in, e.g. a DIB sections
windows driver if needed.  Along with it, I changed a few places
where unsigned int is used along with comparisons against the relevant
vid.* members.
One thing I am not 100% sure is the signedness requirements of
d_zrowbytes and d_zwidth: q2 has them as unsigned but I am not sure
whether that is because they are needed as unsigned or it was just an
oversight of the id developers. They do look like they should be OK
as signed int to me, though: comments?

==
Note from Bill Currie: I had to do some extra changes as many
signed/unsigned comparisons were somehow missed.
2012-10-21 09:00:50 +09:00
Bill Currie
eccc1b5b51 Put the over-size range back to its original value.
This fixes the horribly different results between optimized and unoptimized
qfbsp (there is still a difference of 1 brushface). Unfortunately, it also
severely limits the maximum size of a map.
2012-09-18 09:25:10 +09:00
Bill Currie
709da6e7d7 Rotate the skybox -90 degrees on the z axis (gl)
Now gl and glsl match again, and quake's skies are now "correct" (assuming
fitzquake is the standard).
2012-09-13 08:36:28 +09:00
Bill Currie
14f089d08e Correct the orientation of the skybox (for glsl).
It turns out the expected orientation of the sky cube is exactly that of
Blender's default cube looked at from the front view (num-1) and the front
face being the nearest face. This put's Marcher's sun nicely in the view
when exiting the cave.
2012-09-12 19:06:07 +09:00
Bill Currie
536ee48a97 Some minor skybox improvements suggested by mh.
Rearrange the sky_suffix and sky_coords arrays and remove the sky_target
array such that the faces can be loaded using
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i (apparently certain drivers break if
the faces aren't loaded in the correct order).

Also, the nomalization of the direction vector in the fragment isn't
necessary.
2012-09-12 15:20:35 +09:00
Bill Currie
433d9d138b Hook up the pointfile loader in glsl.
I was always wondering what that was for (never bothered looking at the
command registration, I guess :P).
2012-09-12 09:54:24 +09:00
Bill Currie
45c48a6215 Fix bsp2 loading.
Just some problems with the handling of extended bsp29 files. I'm not
quite happy with the code, but it will do for now.
2012-09-08 09:41:00 +09:00