Bill Currie
ec7d974dc1
[gamecode] Move % handling to the flags state
...
% is effectively a format flag that cancels the format and outputs a
% single %. Fixes % not getting output for %%.
2021-01-05 00:07:58 +09:00
Bill Currie
1b8b7c04cb
[gamecode] Disconnect held strings from return slot
...
Fixes an internal string error when a return string has been freed.
2021-01-04 23:42:10 +09:00
Bill Currie
98795bf604
[gamecode] Add a comment about returning temp strings
2020-07-05 16:53:35 +09:00
Bill Currie
2bec2527b4
[gamecode] Re-expose PR_LoadStrings
...
It's required for qfprogs now that PR_LoadDebug reads strings early.
2020-04-04 14:33:49 +09:00
Bill Currie
59f48e5e32
[gamecode] Add function to test if string exists
...
As it returns the string id, it is useful for getting an string id
without risking creating a new one.
2020-04-04 12:32:12 +09:00
Bill Currie
41184bd97d
[gamecode] Document the format state machine
2020-04-01 20:50:42 +09:00
Bill Currie
a36f72f7b4
[gamecode] Support variable field width and precision
2020-04-01 19:45:33 +09:00
Bill Currie
7f4d2215e2
[gamecode] Accept EOS at end of conversion specifier
2020-04-01 18:32:30 +09:00
Bill Currie
7f86fb5529
[gamecode] Rework PR_Sprintf to use a state machine
...
This makes it much easier to extend. There are even stubs for variable
field width and precision (not set yet).
2020-04-01 13:32:07 +09:00
Bill Currie
a7956c7311
[gamecode] Move format state into a state struct
...
This is the first step in reworking PR_Sprintf to use a state machine.
The goal is to make it more robust against errors and easier to extend
(eg, * width and precision).
2020-04-01 11:19:56 +09:00
Bill Currie
58acc483fd
[gamecode] Save new string ref in return slot
...
This plugs the memory leak that caused qwaq to crash after resizing the
locals window a "few" times (several seconds of playing with the size).
2020-03-31 20:38:41 +09:00
Bill Currie
1586df4dfc
[gamecode] Make it possible to check string mutability
2020-03-26 16:38:09 +09:00
Bill Currie
ec82d6b027
[gamecode] Add support for holding ephemeral strings
...
PR_HoldString converts ephemeral (temp and return) strings to dynamic
strings. This makes dealing with strings in progs a little easier.
2020-03-26 16:36:29 +09:00
Bill Currie
b4874f7d9b
[gamecode] Make PR_FreeString a little more forgiving
...
It treats only strings that are actually invalid as invalid. That is,
now it is safe to "free" a static string: it's just a no-op.
2020-03-26 15:48:04 +09:00
Bill Currie
22e2695f80
[gamecode] Add VISIBLE to some missed functions
2020-03-26 15:36:46 +09:00
Bill Currie
4cef9792f4
[util] Make hash-tables semi-thread-safe
...
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie
f290b115a5
[gamecode] Add function PR_PushTempString
...
This "pushes" a temp string onto the callee's stack frame after removing
it from the caller's stack frame. This is so builtins can pass
auto-freed memory to called progs code. No checking is done, but mayhem
is likely to ensue if a string is pushed that was allocated in an
earlier frame.
2020-03-09 23:36:09 +09:00
Bill Currie
7d43bd5c66
[gamecode] Add function PR_AllocTempBlock()
...
PR_AllocTempBlock() works the same way as PR_SetTempString(), except
that it takes a size parameter and always allocates (never tries to
merge). This is, in a way, abusing the string system, but I needed a way
to allocate a block of progs memory that would be automatically freed
when the current frame ended. The biggest abuse is the need to cast away
the const of PR_GetString()'s return value.
2020-03-09 22:16:19 +09:00
Bill Currie
5f299cbac7
[gamecode] Ensure static string refs are initialized
...
That was a fun one to track down :P
2020-03-08 21:29:31 +09:00
Bill Currie
c726d77e7d
[gamecode] Respect the @float_promoted@ magic string
...
Rather than relying on progs code version, use the string to determine
whether PR_Sprintf should behave as if floats have been promoted through
... I imagine I'll get to the rest of the server code at some stage.
With these two changes, nq-x11 works again (teleporters were the
symptom).
2020-03-08 19:19:15 +09:00
Bill Currie
789f263855
Use get_strref() correctly
...
I had forgotten that it works only for dynamic strings.
2020-02-27 02:07:53 +09:00
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
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
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
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
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
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
59e85b7d5e
Fix a pile of dead assignments.
...
Some were actual bugs!
2018-09-08 22:23:57 +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
Bill Currie
cc35209f86
Yet more char index issues :P
2012-08-18 12:20:08 +09:00
Bill Currie
23a38738fc
Massive whitespace cleanup.
...
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie
bc1b483525
Nuke the rcsid stuff.
...
It's pretty useless in git.
2012-04-22 10:56:32 +09:00
Bill Currie
b5019c8e33
Nuke the engine dicrectory from gamecode.
...
Not the contents, of course :) Anyway, finally, that totally useless
directory is gone.
2012-02-06 23:44:52 +09:00
Adam Olsen
9ea52e8239
Move the gamecode engine into a subdir.
2001-08-21 21:05:26 +00:00
Bill Currie
8059265181
pr_strings.c:
...
fix some off-by-one bugs
gl_mesh.c:
make the messing... message developer mode
2001-08-15 06:01:38 +00:00
Bill Currie
31a560cc3f
d'oh
2001-08-13 20:23:41 +00:00
Bill Currie
da7e8568a4
fix a couple of issues with garbage collection
2001-08-13 20:22:36 +00:00
Bill Currie
2a6830d2d8
revised dynamic string handling. allows for `bounds checking'
2001-08-13 20:01:37 +00:00
Bill Currie
1c9e1b176f
fear the mighty const correct patch
2001-07-15 07:04:17 +00:00
Bill Currie
340e104778
/D'OH/!!! How many /years/ have I been working with linked lists and free?
2001-06-11 22:42:05 +00:00
Bill Currie
2bc94ea66f
progs.h:
...
add no_exec_limit field. Set to 1 to disable the runaway loop check
for unlimited runs (eg, in qwaq)
pr_exec.c:
don't bother checking the profile counter if pr->no_exec_limit is set
pr_strings.c:
free unreferenced dynamic strings rather than referenced.
2001-06-06 18:10:47 +00:00
Bill Currie
e339e82c01
hash.h is now const correct as is a lot of qfcc
2001-06-04 04:52:14 +00:00
Bill Currie
f78b973978
move the api headers into include/QF and clean up (most of) the resulting mess.
...
target specific files that I don't build won't compile yet. just put QF/
infront of the offending headers.
Also move ver_check into libqfutils
2001-03-27 20:33:07 +00:00
Bill Currie
97bf8d2c51
garbage collector implemented but untested. Also unsused because the issue is
...
WHEN to call it. I don't imagine it will be cheap :/
2001-03-06 05:29:46 +00:00
Bill Currie
4489319298
first step towards garbage collected dynamic strings in qc. All strings
...
external to the progs file are now malloced and then freed at progs reload.
All that needs to be implementd for gc to work is the scanner and deallocator.
2001-03-06 04:22:33 +00:00