Commit graph

4168 commits

Author SHA1 Message Date
Bill Currie
62b541793d [gamecode] Remove all use of va
With this, the VA is very close to being safe to use in a threaded
environment (so long as each VM is used by only one thread). Just the
debug file hash and source paths to sort out.
2020-02-26 19:30:10 +09:00
Bill Currie
ddd007e2d5 [dstring] Return the string instead of printed size
Other than consistency with printf(), I'm not sure why we went with the
printed size as the return value; returning the resultant strings makes
much more sense as dsprintf() (etc) can then be used as a safe va()
2020-02-26 19:00:19 +09:00
Bill Currie
36bc139b27 Avoid use of va in PR_Sprintf
With this, progs strings are thread safe so long as only one thread
tries to use the VM.
2020-02-26 18:35:19 +09:00
Bill Currie
0f4d89a832 Move free_fmt_items into strings resources
This will make it per-thread.
2020-02-26 18:19:21 +09:00
Bill Currie
383a7fe5e1 Remove File_Open
Other than its blocking of access to certain files, it really wasn't
that useful compared to the functions in qfs, and pointless with access
to qfs anyway.
2020-02-26 13:45:14 +09:00
Bill Currie
225a375ab9 Extend the lifetime of return-strings
This is done by putting the most recently used return-string at the end
of the queue for recycling.
2020-02-26 13:43:03 +09:00
Bill Currie
aa02069dd1 Add a breakpoint flag to opcodes
The progs execution code will call a breakpoint handler just before
executing an instruction with the flag set. This means there's no need
for the breakpoint handler to mess with execution state or even the
instruction in order to continue past the breakpoint.

The flag being set in a progs file is invalid.
2020-02-26 13:40:26 +09:00
Bill Currie
d60291a73e Clean up a lot of va usage
va is not thread-safe (it's not save even without threads), and I want
to be able to run progs in threads.
2020-02-26 09:46:59 +09:00
Bill Currie
42713cad8b Make script much friendlier to use
It now simply sets an error message pointer and returns false if there's
an error.
2020-02-26 09:39:03 +09:00
Bill Currie
4c1b6ce76c Make pr_parse thread safe
Or at least, conversion to property list is thread safe.
2020-02-26 01:55:56 +09:00
Bill Currie
35c9d6ee38 Make pr_obcode.c mostly thread safe
Its public data is all read-only, and once set up, its private data is
too (just don't call init in multiple threads).
2020-02-26 01:20:28 +09:00
Bill Currie
3577d27a45 Move the ObjQC data into a resource block
This makes it nice and private (though with the cached pointer, ObjQC is
still a first-class component).
2020-02-25 23:14:18 +09:00
Bill Currie
66dd3ef070 Make a bunch of count things positive-only
This fixes a pile of FIXMEs, because some things should never be
negative.
2020-02-25 21:23:13 +09:00
Bill Currie
282132958f Relocate local def type encodings in debug load
For technical reasons (programmer laziness), qfcc does not fix up local
def type encodings when writing the debug symbols file (type encoding
location not readily accessible).
2020-02-25 20:46:01 +09:00
Bill Currie
89e83d7d73 Move the debug info out of progs_t
The debug subsystem now uses the resources system to ensure it cleans
up, and its data is now semi-private. Unfortunately, PR_LoadDebug had to
remain public for qfprogs because using PR_RunLoadFuncs would cause
builtin resolution to complain.
2020-02-25 20:07:29 +09:00
Bill Currie
a55b9544ac Improve handling of pr_argc
It is now set to 0 when progs are loaded and every time
PR_ExecuteProgram() returns. This takes care of the default case, but
when setting parameters, pr_argc needs to be set correctly in case a
vararg function is called.
2020-02-25 17:36:29 +09:00
Bill Currie
e3953be8f8 Ensure execution state is initialized on progs load 2020-02-25 15:25:10 +09:00
Bill Currie
61d7f4f9c4 Dump locals stack when dumping main stack
Any shutdown functions in progs will need locals too.
2020-02-25 15:18:15 +09:00
Bill Currie
6a4ef598ab Allow progs num_edicts and reserved_edicts to be null
Really, while there are edict related instructions, edict support should
probably not be in the VM itself.
2020-02-25 15:00:33 +09:00
Bill Currie
6e56c9a4aa Ensure edict_parse is reset on progs load
A server switching from a game that sets edict_parse to one that does
not could go badly when it comes time to loading a level.
2020-02-25 14:40:03 +09:00
Bill Currie
9bb68f2d8c Allow nested use of PR_SaveParams()
PR_SaveParams() is required for implementing the +initialize diversion
used by Objective-QuakeC because builtins do not have local def spaces
(of course, a normal stack calling convention would help). However, it
is entirely possible for a call to +initialize to trigger another call
to +initialize, thus the need for stacking parameter stashes. As a
bonus, this implementation cleans up some fields in progs_t.
2020-02-25 14:30:26 +09:00
Bill Currie
99c818adcc Ensure progs zone is always set on load 2020-02-25 00:25:24 +09:00
Bill Currie
256dee98a1 Make progs string resources management private
Strangely enough, using the progs resources system. This is a step
towards having progs that can be reset properly, or even dynamically
created VMs.
2020-02-25 00:23:08 +09:00
Bill Currie
3720956d88 Speed up two of the three deletion cases
The initial code was pretty much a port of the code in the editor I
wrote 25 years ago. Either I didn't think of the optimization back then,
or I tried to implement it, failed, and figured it wasn't worth it
(despite using it on a 386dx33). However, I noticed it now and it was
easy enough to get working, and it's always good to not do something
that's not needed.
2020-02-24 18:52:46 +09:00
Bill Currie
f7493fe8fb Add a buffer-gap text buffer
This should be good for text editing and working with text files in
general.
2020-02-24 17:30:33 +09:00
Bill Currie
7406e0308e Fix some warnings picked up in an optimized build 2020-02-24 11:28:43 +09:00
Bill Currie
dda045bf96 Do lazy computation of def sizes from type encodings
The size is calculated when needed and cached.
2020-02-23 23:29:58 +09:00
Bill Currie
23573953a7 Change pr_type_size to pr_ushort_t 2020-02-23 22:25:08 +09:00
Bill Currie
c3c55f0bcc Fix some source formatting 2020-02-23 19:05:43 +09:00
Bill Currie
d0dc0e15fb Handle alias types in debug prints 2020-02-23 19:02:16 +09:00
Bill Currie
b173c35eb4 Rework progs debug to use the type encodings
It's only a start: the output is, if anything, slightly worse than
before, but it does have the basics going.
2020-02-23 19:01:59 +09:00
Bill Currie
4b7ecdf74a Make PR_Init take an instance to initialize
This allows internal sub-systems to do per-instance initializations
without other engine systems having to know about them.
2020-02-23 18:32:16 +09:00
Bill Currie
f8b1a3a89f Return the previous sys print callbacks
This allows for temporary overrides.
2020-02-23 11:41:19 +09:00
Bill Currie
806af85447 Remove reference to ddef_t from progs.h
This cleans up some horrible names and redundant fields that were a
result of the transition to pr_def_t
2020-02-22 22:44:08 +09:00
Bill Currie
81083698a8 Move to using an in-memory form of ddef_t
This allows the VM to work with extended ddefs transparently. It seems
to have uncovered a typedef alias relocation bug, though.
2020-02-22 22:33:44 +09:00
Bill Currie
c296514b95 Make pr.load_file 'return' the file size 2020-02-21 21:17:28 +09:00
Bill Currie
2db5d04e3f Reduce the ephemeral nature of str_mid
When the substring is the tail of the supplied string, return a
"pointer" to within the supplied string rather than a new "return"
string. This means that tail-end substrings of string constants are
themselves constants.
2020-02-19 21:41:46 +09:00
Bill Currie
ad175d054b Sanitize pipelines
wow, talk about doing things the wrong way. I guess that's the problem
with following a book targeted for C++: you get all that safety-goat
nonsense.
2020-02-18 22:38:01 +09:00
Bill Currie
264c4ccdac Sanitize descriptors
I'm sure it will end soon, I think pipelines is the end of it.
2020-02-18 21:18:03 +09:00
Bill Currie
c740dea212 Use the correct constant for "infinity" 2020-02-18 19:44:40 +09:00
Bill Currie
0a0035e5e5 Use the render pass to clear the window
Very satisfying to get to this point.
2020-02-18 17:48:22 +09:00
Bill Currie
ba654b09f7 Create and destroy render pass and frame buffers 2020-02-18 17:18:37 +09:00
Bill Currie
1f4c019abc Create and destroy color/depth resources 2020-02-18 14:28:28 +09:00
Bill Currie
89d48b5650 Output first pixels
Just clearing the screen to 0xbada55, but the validation layer is quiet.
2020-02-18 01:03:36 +09:00
Bill Currie
73fde40cad Sanitize some more structs 2020-02-17 23:30:25 +09:00
Bill Currie
94565c2382 Rework much of the Vulkan array handling
So much for all those little wrappers hiding the device. Some survived,
but mostly just the bigger things like device, swapchain, etc.
2020-02-17 20:29:35 +09:00
Bill Currie
0cb04dc490 Add a set of macros for dynamic arrays
Includes docs and test cases.
2020-02-17 16:17:21 +09:00
Bill Currie
e37aba364a Correct an apparent typo
Black makes much more sense than Slack, especially if the text is from a
quake mod (no idea where, though).
2020-02-17 12:58:23 +09:00
Bill Currie
916e57de37 Get the swapchain image switching sort of working
The render pass isn't set up yet, so the validation layer is having a
fit, but cycling through the swapchain images does seem to be working.
2020-02-17 00:50:39 +09:00
Bill Currie
ce72135e70 Fix incorrect init of command buffer set 2020-02-17 00:10:59 +09:00
Bill Currie
4b152a4492 Rework semaphore sets 2020-02-17 00:10:32 +09:00
Bill Currie
559bd2e636 Create command pool and frame timing fences
Nothing is actually done yet, so the reported fps is around 172k (yes,
k), but startup and shutdown seems to be clean (yay validation layers).
2020-02-16 22:45:27 +09:00
Bill Currie
b947cc1791 Rework command buffer and fence-set management
I found command buffer handling to be totally redundant and fence-set
management to be a bit awkward.
2020-02-16 22:43:57 +09:00
Bill Currie
9ff4eefe65 Merge branch 'master' into vulkan 2020-02-16 18:17:50 +09:00
Bill Currie
ed283a9e7f Copy only the necessary number of vararg parameters 2020-02-16 18:00:29 +09:00
Bill Currie
12d2a0ff75 Copy the correct number of words for rcall 2020-02-16 17:58:36 +09:00
Bill Currie
f5741a979e Implement parameter alignment in the engine
The engine now requires non-v6 progs to store the log2 alignment for the
param struct in .param_alignment.

PR_EnterFunction is clearer and possibly more efficient.
2020-02-16 17:13:45 +09:00
Bill Currie
32c21ec559 Make gcc accept the bitwise-boolean magic
Forgot to compile check...
2020-02-16 12:08:08 +09:00
Bill Currie
b4fd804e4e Implement true modulo in the engine 2020-02-16 11:53:56 +09:00
Bill Currie
4269c8cb07 Rename the mod instruction to rem
Because % really implements remainder rather than true modulo, and I
plan on adding %% to implement true modulo.
2020-02-16 11:04:30 +09:00
Bill Currie
bab3752e98 Add missed overridden math functions
And fix misspelled ones too.
2020-02-15 23:49:12 +09:00
Bill Currie
533fb8acc9 Implement double constants 2020-02-15 23:49:12 +09:00
Bill Currie
2cd62fe01b Fix several double-related bug
float is promoted to double through ... for non-v6 code.
PR_Sprintf has custom param access via P_*, messed up doubles.
2020-02-15 23:49:12 +09:00
Bill Currie
df7c08a010 Add support for doubles to Ruamoko
Only as scalars, I still need to think about what to do for vectors and
quaternions due to param size issues. Also, doubles are not yet
guaranteed to be correctly aligned.
2020-02-15 23:49:12 +09:00
Bill Currie
13b608f40c Don't truncat float % float
This allows full usage, eg, x % pi, but otherwise maintains
compatibility with integer %
2020-02-15 23:49:12 +09:00
Bill Currie
d56f88f779 Implement swapchain image acquisition 2020-02-15 17:56:02 +09:00
Bill Currie
53b46f0541 Implement pipeline stuff 2020-02-13 04:21:35 +09:00
Bill Currie
69c110193a Fix a thinko
Wrong var for computing number of slots used.
2020-02-13 04:20:54 +09:00
Bill Currie
61036378e2 Implement render pass stuff 2020-02-12 18:55:51 +09:00
Bill Currie
44f5b134e6 Free custom descriptor structs
Forgot this earlier
2020-02-12 18:55:22 +09:00
Bill Currie
85a2f9f621 Implement descriptor stuff 2020-02-12 16:36:01 +09:00
Bill Currie
de64be1d67 Show more info when dumping x11 video modes
Found in an old stash. Probably the start of xrandr support.
2020-02-12 11:04:28 +09:00
Bill Currie
6e96b91aa1 Fix a couple more optimization warnings 2020-02-11 15:59:12 +09:00
Bill Currie
9248e8cf01 Update for doxygen 1.8.16 2020-02-11 15:22:42 +09:00
Bill Currie
fbd79963bb Update for doxygen 1.8.16 2020-02-11 15:20:49 +09:00
Bill Currie
3144443a82 Allow vulkan_draw to compile when optimizing
Even though it's nowhere near done
2020-02-11 12:19:16 +09:00
Bill Currie
29b1d6baf8 Finish up memory stuff
For now, of course.
2020-02-11 09:37:04 +09:00
Bill Currie
1baee0cbba Implement mem mapping and buffer/image copying 2020-02-10 20:42:19 +09:00
Bill Currie
43e37aa31e Separate out the generic memory stuff 2020-02-10 18:33:29 +09:00
Bill Currie
9fdc15c439 Implement image stuff up to view creation 2020-02-10 18:18:37 +09:00
Bill Currie
f4c0d0ebcf Implement buffer view creation
And rename memory allocation as it's buffer-specific.
2020-02-10 18:17:58 +09:00
Bill Currie
2f9ad73f78 Implement buffer memory up to barriers
Still lots to go (views, destruction, transfer...) and I'm uncertain
about the location of the pipeline barrier function.
2020-02-10 15:07:35 +09:00
Bill Currie
8148f256f5 Rework object device caching
It turned out I needed access to the physical device from a buffer
object, so rather than storing the vulkan logical device directly in
buffer (and other) objects, store the qfv logical device.
2020-02-07 11:45:05 +09:00
Bill Currie
d3b4e4653e Cache physical devices in the instance 2020-02-06 19:04:28 +09:00
Bill Currie
6ce87497f3 Fix a potential buffer overflow
Highly unlikely to have that many sub models, but it does keep gcc
quiet.
2020-02-06 17:42:21 +09:00
Bill Currie
494f673def Fix a potential buffer overflow
Highly unlikely to have that many sub models, but it does keep gcc
quiet.
2020-02-06 17:38:51 +09:00
Bill Currie
8819d26c95 Fix a compile error
not sure how that one got through
2019-10-16 20:57:39 +09:00
Bill Currie
4957c4f31a Implement the rest of the command stuff 2019-07-23 13:05:32 +09:00
Bill Currie
a165d67dfa Add a queue type 2019-07-23 12:37:47 +09:00
Bill Currie
411b897f09 Implement most of the stuff for command submission 2019-07-23 12:28:57 +09:00
Bill Currie
e164002050 Make QuatToMat faster and more accurate
The better accuracy is for specific cases (90 degree rotations around a
main axis: the matrix element for that axis is now 1 instead of
0.99999994). The speedup comes from doing fewer additions (multiply
seems to be faster than add for fp, at least in this situation).
2019-07-23 08:52:15 +09:00
Bill Currie
1f24a1408a Destroy the surface 2019-07-13 01:20:02 +09:00
Bill Currie
dd1c2db249 Clean up the swapchain
And be a little safer about it
2019-07-13 01:14:21 +09:00
Bill Currie
b4dc746a66 Clean up the debug callback 2019-07-13 01:11:34 +09:00
Bill Currie
1eafc33052 Ensure vulkan gets shut down 2019-07-13 00:36:21 +09:00
Bill Currie
4e4d1b99b4 Clean up all the system shutdown calls
I added Sys_RegisterShutdown years ago and never really did anything
with it: now any system that needs to be shutdown can ensure it gets
shutdown on program exit, and in the correct order (ie, reverse to init
order).
2019-07-12 23:15:26 +09:00
Bill Currie
b2e12d701b Fix up swapchain creation
Things are working again.
2019-07-12 14:09:42 +09:00
Bill Currie
66e7336b62 Initialize device extension checks early
They need to be initialized before attempting to load the function
pointers.
2019-07-12 13:37:30 +09:00
Bill Currie
75f19f7243 Completely rework the vulkan related api
Things don't work yet, but this feels much cleaner.
2019-07-12 13:34:31 +09:00
Bill Currie
b5828bc2ce Output validation message severity
It's nice knowing if something is an error or otherwise.
2019-07-11 00:58:37 +09:00
Bill Currie
c0bc5cfad6 Implement swapchain creation 2019-07-11 00:58:14 +09:00
Bill Currie
302a462c32 Make SetMouse timeout after 2 seconds
This makes sure that some unchecked event doesn't cause a lockup.
However, blocking input is really not the way to go: need to implement a
state machine and use non-blocking event reads.
2019-07-10 22:28:33 +09:00
Bill Currie
980cf58ac5 Wait for the window to be visible before mouse warping
This fixes the hang during fullscreen startup on my system (the motion
events weren't being generated because there was no window to see the
motion).
2019-07-10 22:28:33 +09:00
Bill Currie
a4f963f67b Add a cvar to block use of x11 vidmode
Or really, allow it if the user specifically requests it: the default is
blocked. Modern systems (particularly displays) do not really like
changing resolution, so doing so by default seems rather wrong.
2019-07-10 22:28:33 +09:00
Bill Currie
4eb6cf6f9e Make SetMouse timeout after 2 seconds
This makes sure that some unchecked event doesn't cause a lockup.
However, blocking input is really not the way to go: need to implement a
state machine and use non-blocking event reads.
2019-07-10 22:24:11 +09:00
Bill Currie
203d981675 Wait for the window to be visible before mouse warping
This fixes the hang during fullscreen startup on my system (the motion
events weren't being generated because there was no window to see the
motion).
2019-07-10 22:18:51 +09:00
Bill Currie
d5cb432911 Add a cvar to block use of x11 vidmode
Or really, allow it if the user specifically requests it: the default is
blocked. Modern systems (particularly displays) do not really like
changing resolution, so doing so by default seems rather wrong.
2019-07-10 22:15:39 +09:00
Bill Currie
2771e9c573 Correct extension handling
I had missed a critical bit from the cookbook.
2019-07-10 13:16:46 +09:00
Bill Currie
ed3c5cb9ec Add a strset "class"
It's just a wrapper around hashtab, but it makes checking if a string is
in a set easy. Way overkill when only a few extensions are enabled, but
more might come later.
2019-07-10 13:09:16 +09:00
Bill Currie
3191604641 Uncomment already implemented functions 2019-07-09 21:07:59 +09:00
Bill Currie
452eb5a83d Preserve parsed cvar values when string is same
Fixes parsed developer flags on the command line getting reset.
2019-07-09 20:16:08 +09:00
Bill Currie
8c238d3def Parse developer flag names when cvar is set
So much easier to remember "vulkan" instead of which power of two it
is.
2019-07-09 20:14:57 +09:00
Bill Currie
8a3cd224a3 Add vulkan developer flag 2019-07-09 20:14:30 +09:00
Bill Currie
68449d0f6f Create a window and a surface for vulkan
Yay, segfaults in R_Init :)
2019-07-09 16:33:44 +09:00
Bill Currie
0f511e8342 Move the string list funcs to their own file
They're not (at this stage, at least) worthy of being promoted out to
the utils lib.
2019-07-09 14:24:55 +09:00
Bill Currie
b3d982bfc3 Remove global vulkan_ctx
While I can't say that I'm happy with the details of vulkan_ctx_t, I am
pretty sure I don't want to be limited to having only one.
2019-07-09 11:54:23 +09:00
Bill Currie
707bdfc5f2 Get vulkan back to where it was 2019-07-09 09:06:35 +09:00
Bill Currie
8ee06d75a9 Separate render and presentation initialization
This paves the way for clean initialization of the Vulkan renderer, and
very much cleans up the older renderer initialization code as gl and sw
are no longer intertwined.
2019-07-09 01:00:47 +09:00
Bill Currie
cb10175824 Pass vid_internal to R_LoadModule
This fixes the segfault and pushes things very much in the desired
direction of proper system independence for rendering and presentation
separation (though things were headed in the right direction before).
2019-07-08 14:04:03 +09:00
Bill Currie
6ee2df8445 Move vid callbacks into vid_internal
Currently segfaults because viddef is an alias for *r_data->vid, which
has not yet been initialized (chicken and egg).
2019-07-08 13:40:29 +09:00
Bill Currie
3e1520c246 Move vid callback access into vid
The plan is to move the callbacks into a "private" struct.
2019-07-08 12:46:22 +09:00
Bill Currie
6137795682 Use deep binding for the vulkan loader
This fixes the problem with using vkGetInstanceProcAddr to find global
vulkan functions.
2019-07-07 16:48:53 +09:00
Bill Currie
7137d61c36 Add some extensions needed for presentation 2019-07-07 16:27:55 +09:00
Bill Currie
a755e50c84 Clean up vid access a little
Things are still a mess, but a proper cleanup will be a lot of work and
will, really, involve properly splitting quake-specific code* out from
the rest of the renderer.

* data loading and format specific stuff
2019-07-07 15:38:29 +09:00
Bill Currie
d95e9f9af3 Correct vulkan plugin strings 2019-07-07 14:59:20 +09:00
Bill Currie
77afc30486 Fix vid renderer plugin types
I guess that plugin type is currently not checked, otherwise I doubt the
mistake would have gone unnoticed.
2019-07-07 14:57:56 +09:00
Bill Currie
940ef833ae Shutdown Vulkan properly
Well, as properly as can be considering how little is started up :P
2019-07-07 14:34:02 +09:00
Bill Currie
ab08e4f207 Create a logical device with a single queue
A single graphics-capable queue should be enough for now. However, I'm
not sure I'm happy with a lot of the code: it's a bit difficult to write
flexibly configured code for Vulkan (or seems to be at this stage),
especially in C.
2019-07-07 01:28:05 +09:00
Bill Currie
2bc78e7f0a Start work on a Vulkan-based renderer
Doesn't do much other than create an instance and enumerate some stuff,
but the build system is working.
2019-07-06 14:56:15 +09:00
Bill Currie
c727f6a130 Rewrite QuatMultVec to be faster
Could be faster still using SSE, but that's another project.
2019-07-06 14:45:40 +09:00
Bill Currie
f68129dc0f Try to use type encodings for function return type
Now return statements in traces make much more sense.
2019-06-09 18:11:56 +09:00
Bill Currie
0f5f2a125a Use a reliable reference for calculating progs offsets.
Now that pr->zone can be null, it cannot be used as a reference. Fixes
random crashes when using qfprogs (random due to heap randomization).
2018-10-13 23:23:45 +09:00
Bill Currie
f58c2fef5a Switch QF's quaterions from wxyz to xyzw.
After messing with SIMD stuff for a little, I think I now understand why
the industry went with xyzw instead of the mathematical wxyz. Anyway, this
will make for less pain in the future (assuming I got everything).
2018-10-12 14:33:55 +09:00
Bill Currie
b7aa5bb8fe Fix an oops messing up edict size. 2018-10-12 14:33:26 +09:00
Bill Currie
33cbc500e8 Fix a segfault when setting up the stack.
Yup, putting {}s around even single statements under flow control (if, etc)
is a good idea. Wonder if there's a gcc warning for that...
2018-10-11 13:34:08 +09:00
Bill Currie
6252faa069 Fix a size error in OP_LOAD_Q.
C&P from OP_LOAD_V :/
2018-10-11 13:25:32 +09:00
Bill Currie
364c2d2c2b Add a stack and push and pop instructions.
The stack is for data, not return addresses.
2018-10-11 13:24:03 +09:00
Bill Currie
61185813fa Cleaner handling of zone_size/zone. 2018-10-11 10:22:10 +09:00
Bill Currie
82809eb856 Simplify the call to PR_LoadProgsFile.
I've decided that setting pr.max_edicts and pr.zone_size as part of the
local progs initialization rather than in PR_LoadProgsFile makes more
sense. For one, it is unlikely for the limits to change every time progs is
reloaded. Also, they seem to be a property of the VM rather than the progs.
However, there is nothing stopping the caller from updating max_edicts and
zone_size every call.
2018-10-11 10:06:48 +09:00
Bill Currie
6f28ab2a68 Add basic quaternion multiplication tests. 2018-10-09 12:44:46 +09:00
Bill Currie
34bcf7faab Do a pure/const/noreturn/format attribute pass.
I always wanted these, but as gcc now provides warnings for functions that
could do with such attributes, finding all the functions is much easier.
2018-10-09 12:42:21 +09:00
Bill Currie
db3df6f8a7 Fix a bunch of dead increments. 2018-09-09 11:12:04 +09:00
Bill Currie
3f638d95ba Remove a possibly spurious break.
I'm not certain despair actually meant for the break to be there. It
certainly would have sped up the game a bit but at the expense of proper
blood trails in the software renderers.
2018-09-09 10:54:38 +09:00
Bill Currie
62793b2dc2 Fix some potentially garbage assignments.
These are the ones where I could easily make scan-build happy. They do seem
to be potential holes where invalid data in one place could result in use
of uninitialized values.
2018-09-09 09:54:16 +09:00
Bill Currie
59e85b7d5e Fix a pile of dead assignments.
Some were actual bugs!
2018-09-08 22:23:57 +09:00
Bill Currie
f75ff2d269 Fix some null argument issues. 2018-09-07 22:30:44 +09:00
Bill Currie
1eb1622420 Fix some strncat issues. 2018-09-07 21:27:34 +09:00
Bill Currie
8f028b8a0d Fix some double frees. 2018-09-07 20:03:19 +09:00
Bill Currie
8fd5be0ee0 Fix a pile of sizeof goofs.
While scan-build wasn't what I was looking for, it has proven useful
anyway: many of the sizeof errors were just noise, but a few were actual
bugs (allocating too much or too little memory).
2018-09-07 20:00:57 +09:00
Bill Currie
575a67b2a1 mat4 test case fixes.
The tests cases themselves were buggy.
2018-08-26 15:06:08 +09:00
Bill Currie
4f58429137 Fix an unhealthy pile of gcc 8 warnings.
While some of the warnings were merely annoying, some where actual bugs or
unearthed bugs in related code.
2018-08-20 00:05:00 +09:00
Bill Currie
0de0eb2fc7 Fix a bunch of bit-rot. 2018-06-08 13:21:30 +09:00
Bill Currie
2329fb1885 Fix some warnings and bitrot. 2016-10-25 00:10:30 +09:00
Bill Currie
f163e35f21 Add a builtin to get keydown. 2016-01-10 13:33:05 +09:00
Bill Currie
1ea74c6269 Fix the gl skin segfault.
This was caused by an out-by one error when setting up the skin: if cmap
was 0 then the gl_skin struct would be taken from index -1 of the array and
thus cause all sorts of grief.
2016-01-04 22:04:39 +09:00
Bill Currie
9cb23ba67e Clean up some error messages.
The contractions took the emphasis off where it needed to be.
2016-01-04 16:12:36 +09:00
Bill Currie
aecea5c350 Document most of they key binding system. 2016-01-04 16:11:15 +09:00
Bill Currie
59f60d1ba7 Enable the Key_StringToKeynum builtin.
I don't know why I didn't do it earlier other than lack of need.
2016-01-04 16:10:22 +09:00
Bill Currie
7c16acf4aa Make Key_GetBinding take an imt instead of a name. 2016-01-04 16:06:48 +09:00
Bill Currie
546e333a3c Allow Sys_Error to be hooked.
This makes debugging builtins that wrap normal functions a little easier by
giving a progs dump when such an error occurs.
2016-01-03 23:04:00 +09:00
Bill Currie
735fcf68d5 Clean up usage of va_copy.
AC_TYPE_VA_LIST is no longer necessary, and the code is easier to read.
2016-01-03 21:16:23 +09:00
Bill Currie
2cbb7cb0c8 Remove a redundant va_start/va_end pair.
Found while checking how many places use va_copy.
2016-01-03 18:38:41 +09:00
Bill Currie
61c6a4b68e Include config.h in model tests.
The gcc inlining changes made it necessary.
2016-01-03 16:18:14 +09:00
Bill Currie
7b350b2a1b Indicate calls to builtins when tracing.
This makes following progs traces a little easier.
2016-01-03 16:13:59 +09:00
Bill Currie
331b054d4a Fix an inappropriate reuse of a variable.
Using "ax"is for the joystick "var"iable is a bit confusing.
2015-06-18 21:22:31 +09:00
Jeff Teunissen
890c83ff6e Fix crash in classic GL
GL sometimes crashes when building skins. This probably isn't the correct
fix (finding the situation where fb->tex can become NULL despite fb being
non-null is), but it does kill the segfault. Luckily, this is git and this
commit can just be reverted when the real fix shows up. :)
2014-10-16 13:45:39 -04:00
Bill Currie
d1f1375df5 Increase number of supported joystick buttons.
Also fix a bug where despite supporting 32 buttons, only 18 were actually
supported, and a similar issue for the number of axes.

My saitek x52 has 34 buttons and 10 axes. Whee.
2014-08-17 11:35:40 +09:00
Johnny
d1a8c1b277 Color swizzle & software lighting fix 2014-02-03 16:20:54 +09:00
Bill Currie
d80342e0a8 Fix some compile errors from Johnny's patch.
Turns out he has to compile without -Werror.
2014-02-02 16:42:08 +09:00
Johnny
850382eed4 Fixes crashes when sw32_r_pixbytes is set to 2 or 4 2014-02-02 16:22:53 +09:00
Bill Currie
9d71d9bb7a Remove maxwarpwidth and maxwarpheight.
Only the sw32 renderer even tried to use them, and they didn't get set
properly. This fixes JohnnyonFlame's waterwarp issue.
2014-02-02 14:41:58 +09:00
Bill Currie
946561ba44 Don't bail out prematurely when searching for files.
This fixes the problem of not finding files without a .gz extension when
gzip support is enabled (most of my quake data is compressed, so it took a
while for me to notice the problem).
2014-01-29 16:13:24 +09:00
Bill Currie
99678a571b Remove *.slc on make clean. 2014-01-28 16:26:24 +09:00
Bill Currie
ab3f554a0e Limit the search for lit and ent files.
The search for these files will stop in the vpath that contains the .bsp
file to which they belong. This will prevent problems with
id1/maps/start.lit being used for shadows/maps/start.bsp.
2014-01-28 16:22:05 +09:00
Bill Currie
8bea6a66ca Create _QFS_VOpenFile and QFS_VOpenFile.
_QFS_VOpenFile is actually _QFS_FOpenFile reimplemented to take vpath start
and end parameters so the search can be limited. QFS_VOpenFile,
_QFS_FOpenFile, and QFS_FOpenFile are all wrappers for _QFS_VOpenFile.
2014-01-28 16:22:05 +09:00
Bill Currie
3efb0c538f Separate file search from loading.
QFS_LoadFile (and its wrappers) now  take a file handle rather than a
path. This will make vpath usage a little cleaner to implement.
2014-01-28 16:22:05 +09:00
Bill Currie
328b997843 Save the vpath in the model.
This will be used for restricting searches for auxiliary model files.
2014-01-28 16:22:05 +09:00
Bill Currie
83c47aacef Remove the stack loading from QFS_LoadFile. 2014-01-28 16:22:05 +09:00
Bill Currie
a561477274 Nuke QFS_LoadStackFile().
It was used in only one place and is really not necessary (these days,
anyway).
2014-01-28 16:22:05 +09:00
Bill Currie
25a060f369 Remove the foundname param from _QFS_FOpenFile.
It's now obsolete with qfs_foundfile.
2014-01-28 16:22:05 +09:00
Bill Currie
576c73cf7c Replace qfs_file_from_pak with qfs_foundfile.
This exposes the found name, vpath and in_pak status.
2014-01-28 16:22:05 +09:00
Bill Currie
e5148493db Prepend qfs_ to file_from_pak.
A little better name-spacing.
2014-01-28 16:22:05 +09:00
Bill Currie
82ded3fbe5 Fix some bitrot resulting from a rebase. 2014-01-28 16:22:05 +09:00
Bill Currie
5560696a65 Fix some unused variables. 2014-01-28 16:22:05 +09:00
Bill Currie
4b18501b00 Fix an uninitialized variable. 2014-01-28 16:22:05 +09:00
Bill Currie
40206904ba Reimplement _QFS_FOpenFile using QFS_FindFile's internals.
_QFS_FOpenFile does a full search, however.
2014-01-28 16:22:05 +09:00
Bill Currie
6b87ddbb7c Add QFS_FindFile.
QFS_FindFile's search can be constrained to begin or end at a certain
vpath.
2014-01-28 16:22:04 +09:00
Bill Currie
8bc2f7f6df Print the vpath name when dumping the paths. 2014-01-28 16:22:04 +09:00
Bill Currie
098821e35d Fix QFS_FilelistFill to work with vpaths. 2014-01-28 16:22:04 +09:00
Bill Currie
f05c7179c3 Split up the search paths into vpath chunks.
A vpath is the union of all locations searched for a file in a single
gamedir (eg, shadows, id1 etc). This is a necessary step to preventing
problems like id1/maps/start.lit being used for shadows/maps/start.bsp.

However, QFS_FilelistFill still needs to be reworked as it does not compile
yet (testing was done with a gutted QFS_FilelistFill).
2014-01-28 16:22:04 +09:00
Bill Currie
6910c50a43 Clean up the #ifdef mess in _QFS_FOpenFile
With proper initialization, only the one chunk of #ifdefs is needed. Now
the code is much easier to read.
2014-01-28 16:22:04 +09:00
Bill Currie
4d59282641 Find the remaining vertex attribute order issues.
I hope. I do need to figure out why I made sprite blend an attribute
rather than a uniform.
2014-01-28 16:22:04 +09:00
Bill Currie
a5db0b1a65 Remove the now unnecessary GLSL_CompileShaderS().
Now that the transition to using shader effects is comlete, there's no
need for the wrapper.
2014-01-28 16:22:04 +09:00
Bill Currie
57d2198140 Use the new shader system for iqm models. 2014-01-28 16:22:04 +09:00
Bill Currie
385175ca65 Use the new shader system for 2d drawing. 2014-01-28 16:22:04 +09:00
Bill Currie
c89e612cd4 Remove redundant fog and palette shader code. 2014-01-28 16:22:04 +09:00
Bill Currie
50bb40be29 Use the new shader system for sprites. 2014-01-28 16:22:04 +09:00
Bill Currie
68bd7e643d Remove the long dead text vertex shader. 2014-01-28 16:22:04 +09:00
Bill Currie
1d67f8f0c3 Use the new shader system for textured particles. 2014-01-28 16:22:04 +09:00
Bill Currie
1a7b532927 Use the new shader system for point particles. 2014-01-28 16:22:04 +09:00
Bill Currie
3af6a640fe Missed the old turb frag shader. 2014-01-28 16:22:04 +09:00
Bill Currie
a419fb2c92 Ensure the vertex coord attribute is attribute 0.
It seems mesa still has the bug where non-array attributes don't work
when set as attribute 0, and that the allocation order changed sometime
since I last tested with mesa. This fixes the black world and flickering
alias models on my eeepc.
2014-01-28 16:22:04 +09:00
Bill Currie
042d6e5728 Remove a couple of stale files.
Missed these in the bsp related commit.
2014-01-28 16:22:04 +09:00
Bill Currie
26fc0b74e6 Fix bsp water surfaces.
Everything seems to be working for the bsp renderer.
2014-01-28 16:22:04 +09:00
Bill Currie
f43592589d Use the new shader system in the bsp renderer.
It mostly works. Skybox is untested, and water surfaces are broken.
2014-01-28 16:22:04 +09:00
Bill Currie
b269338947 Start using the new shader system.
So far, alias model rendering is the only victim, but things are working,
even if only color map lookup and fog blending are broken out at this
stage.

I expect the effect naming scheme will go through some changes until I'm
happy with it.
2014-01-28 16:22:04 +09:00
Bill Currie
323fbe1927 Fix an allocation oopsie.
I must have been tired when I wrote that line.
2014-01-28 16:22:04 +09:00
Bill Currie
550f1ae788 Fix some bitrot.
Just updating for the changes to the ALLOC/FREE macros.
2014-01-28 16:22:03 +09:00
Bill Currie
96c40cb9a1 Add basic support for shader "effects".
Again, based on The OpenGL Shader Wrangler. The wrangling part is not used
yet, but the shader compiler has been modified to take the built up shader.
Just to keep things compiling, a wrapper has been temporarily created.
2014-01-28 16:22:03 +09:00
Bill Currie
3b56f0e3bf Advance src with next_line.
This fixes the double counting of the \n at the end of the chunk separator
line.
2014-01-28 16:22:03 +09:00
Bill Currie
d1848a93c8 Add tests for chunk line numbers.
Which happen to find errors :P
2014-01-28 16:22:03 +09:00
Bill Currie
d912970cd3 Add support for segmented text files.
The idea comes from The OpenGL Shader Wrangler
(http://prideout.net/blog/?p=11). Text files are broken up into chunks via
lines beginning with -- (^-- in regex). The chunks are optionally named
with tags of the form: [0-9A-Za-z._]+. Unnamed chunks cannot be found.
Searching for chunks looks for the longest tag that matches the beginning
of the search tag (eg, a chunk named "Vertex" will be found with a search
tag of "Vertex.foo"). Note that '.' forms the units for the searc
("Vertex.foo" will not find "Vertex.f").

Unlike glsw, this implementation does not have the concept of effects keys
as that will be separate. Also, this implementation takes strings rather
than file names (thus is more generally useful).
2014-01-28 16:22:03 +09:00
Bill Currie
4c6478c77f Strip trailing spaces from field names.
A certain mod (glare at rogue) has a space at the end of a field name in
the bsp entity data causing a crash. Thanks to ccr for the report.
2013-11-26 14:27:49 +09:00
Bill Currie
f5501fbf24 Fix a pile of automake deprecation warnings.
s/INCLUDES/AM_CPPFLAGS/g

I <3 sed :)
2013-11-24 13:11:50 +09:00
Bill Currie
6288684fa2 Fix more gcc 4.8 errors.
More actual bugs found, too.
2013-09-27 23:09:37 +09:00
Bill Currie
99a8e8f228 Fix the jump instruction.
The offset to compensate for st++ was missing.

Obviously, the code has never been tested.  Found while looking at the
jump code and thinking about using 32-bit addresses for the jump tables.
2013-06-26 09:59:19 +09:00
Bill Currie
88692f92d9 Fix the calls for Draw_Init in the gl renderers.
While namehack.h took care of the symbol mangling, I do prefer the calls to
be correct as it reduces confusion.
2013-05-09 17:58:33 +09:00
Bill Currie
0f75bdce17 Set the default joystick preamp to 0.01.
At the request of johnnyonflame. I probably should have done this when I
removed the builtin 1/100 scaling from the joystick code.
2013-04-19 13:54:30 +09:00
Bill Currie
247f3be0c0 Create reentrant versions of the set functions that need it.
Only the functions that allocate or delete sets or iterators.
2013-03-18 13:20:39 +09:00
Bill Currie
27bb337a60 Use set_bits_t for holding set elements.
set_bits_t is now 64 bits for x86_64 machines (in linux, anyway). This gave
qfvis a huge speed boost: from ~815s to ~720s.

Also, expose some of the set internals so custom set operators can be
created.
2013-03-16 21:26:49 +09:00
Bill Currie
7753583bfd Catch accuracy errors.
I'd forgotten to set the result flag. Unfortunately, the errors can get
very bad (1e-3) it seems :(
2013-03-13 17:16:34 +09:00
Bill Currie
6eec76dd49 Implement Fischer's SEB algorithm (for 3d).
Now we can get tight (<1e-6 * radius_squared error) bounding spheres. More
importantly (for qfvis, anyway) very quickly: 1.7Mspheres/second for a 5
point cloud on my 2.33GHz Core 2 :)
2013-03-13 17:10:55 +09:00
Bill Currie
9bbf1a9110 test the right cs function (oops) 2013-03-13 16:38:56 +09:00
Bill Currie
3193ffd9cc Better (-1..1) random numbers.
Now the distribution should be more even as the rng doesn't affect the
exponent.
2013-03-13 14:41:04 +09:00
Bill Currie
b6d4766201 Add a function to find the circumsphere of up to 4 points.
It seems to be a little sloppy (an error of a bit less than 1e-4). This
might be why I'm having trouble with my SEB code.
2013-03-13 14:35:30 +09:00
Bill Currie
0cd6d93030 Add a function to get the barycentric coords of a point.
It "works" for lines, triangles and tetrahedrons. For lines and triangles,
it gives the barycentric coordinates of the perpendicular projection of the
point onto to features. Only tetrahedrons are guaranteed to reproduce the
original point.
2013-03-12 14:16:42 +09:00
Bill Currie
ca0b03687f Change the naming of ALLOC's free-list.
Rather than prefixing free_ to the supplied name, suffix _freelist to the
supplied name. The biggest advantage of this is it allows the free-list to
be a structure member. It also cleans up the name-space a little.
2013-03-08 22:16:31 +09:00
Bill Currie
eb2828e11c Add a function to pre-allocate space for a large set.
When the maximum set size is large but constant, and members will be added
one at a time, growing the set dynamically is not very efficient.
2013-03-07 10:27:30 +09:00
Bill Currie
7c1d9d2b84 Make the angle and light hacks optional.
I'd forgotten that ED_ConvertToPlist mangled light into light_lev and
single component angle values into a vector. This fixes much of the
breakage in qflight (but not the light levels)
2013-03-07 09:11:23 +09:00
Bill Currie
675db274a6 Use Sys_Error instead of PR_Error in ED_ConvertToPlist.
ED_ConvertToPlist is now independent of the progs engine as its only use
for the progs_t * param was for PR_Error.
2013-03-07 09:11:22 +09:00
Bill Currie
7d2e938d37 Correct some error messages.
ED_ParseEntity has been ED_ConvertToPlist for a long time now.
2013-03-07 09:11:22 +09:00
Bill Currie
8e86ce9de9 Implement Sys_LongTime and wrap it with Sys_DoubleTime.
Sys_LongTime returns time in microseconds as a 64-bit int. Sys_DoubleTime
uses Sys_LongTime, converts to double and offsets 0 time by 4G (2**32).
This gives us consistent sub-microsecond precision for a very long time.

See http://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/
2013-02-27 14:29:28 +09:00
Bill Currie
32b76b3576 Do not try to create directories that already exist.
It seem that solaris will return EACCESS instead of EEXIST if the user
doesn't have write permission in the parent directory.
2013-02-20 14:03:03 +09:00
Bill Currie
a611ad57de Add Sys_isdir. 2013-02-20 13:59:31 +09:00
Bill Currie
6d7f747577 Add timerefresh to the glsl renderer.
Also, tweak the formatting of the output for the other renderers (%g
instead of %f) and make gl's timerefresh output unconditional.
2013-02-18 13:57:45 +09:00
Bill Currie
4e7e7c3ab0 Rename Sys_FileTime to Sys_FileExists.
The function never did anything but check the readability of the file.
2013-02-07 15:43:26 +09:00
Bill Currie
9047c3e4ad Fix the invalid keydest errors.
Once and for all: remove the default and move the Sys_Error outside the
switch (changing appropriate breaks to returns). Now gcc will let me know
when I forget to update the switch statements.
2013-02-02 15:22:09 +09:00
Bill Currie
bc12567572 Clean out a leftover from the 128 dlight change.
I'd missed a set of bit->lightnum conversions that resulting in lightnum
becoming much greater than 128 and thus trashing memory when the surface
was marked.
2013-01-31 22:39:23 +09:00
Bill Currie
37dfad8e04 Add a command to simulate typing.
It doesn't support backspace or enter yet, but it got the job done for now.
2013-01-29 14:44:33 +09:00
Bill Currie
c376ac1ebd Add some #define magic for SOL_IP on BSD-based stacks. 2013-01-29 12:13:59 +09:00
Bill Currie
8de4db0e2d Fix some sizeof snafus.
I'd failed to notice these earlier.
2013-01-28 21:52:18 +09:00
Bill Currie
bc2fa38468 Provide support for axis names.
x/y/z and pitch/yaw/roll (or p/y/r). Johnny's numbers still work, too, of
course.
2013-01-28 21:09:21 +09:00
Bill Currie
9a24c99cf6 Remove the force 1/100 scaling.
That's part of amp's (or preamp's) job.
2013-01-28 19:37:48 +09:00
Bill Currie
5c08e97b0b Ensure the axis button's state starts at 0.
realloc doesn't do that for us.
2013-01-28 19:37:12 +09:00
Bill Currie
1811d00568 Use the correct index for pressing an axis button.
Oops.
2013-01-28 19:36:25 +09:00
Bill Currie
8314edce4d Merge branch 'joystick'
This give much better control over individual joystick axes. They now have
per-axis pre and post amplification, the linear controller mappings are
more intuitive, and axes can now bet setup as buttons using thresholds.

Many thanks to Johnny on Flame for his work on the "user interface".
2013-01-28 18:14:16 +09:00
Bill Currie
4163a3a8f2 Reduce the default deadzone to 500.
12500 seems a tad high when the range is +/- 32767.
2013-01-28 18:10:49 +09:00
Bill Currie
0ff66268e7 Redo the button axis setup to use key names.
Johnny's number->J_AXISn mapping is preserved, but I had intended for any
key to be supported (J_AXISn was just to ensure free keys were available).
This gives both methods (and some range checking on the axis button
number).
2013-01-28 18:06:30 +09:00
Bill Currie
42c2666036 Clear out some old cruft.
With the new joystic axis system, those cvars are no longer needed.
2013-01-28 18:06:06 +09:00
Bill Currie
475d90e96f Expose Key_StringToKeynum. 2013-01-28 16:34:29 +09:00
Bill Currie
c6f9d8b64c Reduce CFLAGS abuse a little for mingw targets.
This fixes missing debug info (useful for fixing linker errors, if nothing
else).
2013-01-28 16:21:42 +09:00
Bill Currie
173af3a992 Tweak the deadzone code to work better with pre-amp.
Everthing was fine with pre-amp == 1, but if it was anything else, the
offset would become invalid.
2013-01-27 14:30:13 +09:00
Bill Currie
f5e1983e0f Produce prettier floats in the output. 2013-01-27 14:09:48 +09:00
Bill Currie
dfbb68d573 Terminate the option arrays.
Before they terminate QF.
2013-01-27 14:08:01 +09:00
Bill Currie
1a33d2f682 Do a whitespace run.
Just for long-term sanity's sake.
2013-01-27 14:05:24 +09:00
Johnny on Flame
e3e0d6aaa9 Add menu commands + fixes 2013-01-27 13:17:13 +09:00
Johnny on Flame
ee436d89f6 More in-game console command documentation for in_joy 2013-01-27 13:17:13 +09:00
Johnny on Flame
86e7392e7a A few fixes + boundary checks 2013-01-27 13:17:12 +09:00
Johnny on Flame
637d751aa7 Saves axes behaviours on the config file. 2013-01-27 13:17:12 +09:00
Johnny on Flame
4f92bceb4f Joystick configuration commands. 2013-01-27 13:17:12 +09:00
Bill Currie
b2e92c2864 Rewrite joy_axis and JOY_Move for axis buttons.
First, this completely smashes joystick input: it will not work (though it
doesn't crash). This is because there is, as of yet, no means to configure
the system.

Each joystick axis has:
    - per-axis amplification (both pre and post).
    - per-axis offset (offset applied after pre-amp but before post amp)
    - selectable destination:
        - linear delta: position and angles (as before)
        - axis button: if the value crosses the threshold, the given key is
          pressed or released as appropriate.

The axis amplification still uses joy_amp and joy_pre_amp (and
in_amp/in_pre_amp), but now also has the per-axis settings.

The per-axis offset is most useful for axis buttons. For example, the xbox
360 controller triggers are analong but go "all the way to negative on 0
state". Offsetting the input keeps axis button thresholds simple.

Amplification and offset is applied before anything is done with the axis
value. The formula is:

    joy_amp * in_amp * axis-amp *
        (offset + value * joy_pre_amp * in_pre_amp * axis-pre_amp)

Axis button thresholds are very simple: if the sign of the value is the
same as the sign of the threshold and abs(value) >= abs(threshold), the
button is pressed. While multiple thresholds and keys can be placed on an
axis, only one can be pressed at a time. The threshold furthest from 0
wins.
2013-01-23 13:15:02 +09:00
Bill Currie
35edfae2a0 Add keys for joystick axis buttons.
The idea is to allow a joystick axis to be mapped to button presses. These
allow the buttons to be bound without consuming other possibly valid keys.
2013-01-23 13:15:02 +09:00
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