Commit Graph

228 Commits

Author SHA1 Message Date
Bill Currie e2d1a0f7d2 [ruamoko] Tag object memory with the class name
This makes it a lot easier to see what's leaking.
2020-03-31 16:43:10 +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 2d5df34234 [gamecode] Add VM enter/exit events
And rename prd_exit to prd_terminate (the idea is the host will
terminate the VM). This makes it possible for the debugger to pause the
VM before any code, even a builtin function, is executed. Breaks the
debugger source window, but only because it's not updating on file
change (I think).
2020-03-26 12:30:32 +09:00
Bill Currie 1bd8e2ee85 [gamecode] Add a param pointer to debug_handler
I decided I want events for VM enter/exit but enter needs to somehow
pass the function which will be executed (even if a builtin). A generic
void * param seemed the best idea, which meant the error string could be
passed via the param instead of a "global" string in the progs struct.
2020-03-26 11:44:02 +09:00
Bill Currie 52dcb0a6e2 [gamecode] Add G_PACKED macro
Not sure when I'll use it, but as it avoids the null pointer check, it
should make for faster access to structs when reading or writing
multiple fields.
2020-03-25 22:36:04 +09:00
Bill Currie 6f7ddf52ac [gamecode] Add an exit debug event type
The VM never sends it because it cannot know if its exit is program exit
or just sub-program exit, but it's available for host systems to send.
2020-03-25 18:28:28 +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 713150b41a [gamecode] Add debug hooks to the VM engine
While there was a breakpoint hook, it was for only breakpoints and more
was needed. Now there's a generic hook that is called for tracing,
breakpoints, watch points, runtime errors and VM errors, with the
"event" type passed as the first parameter and a data pointer in the
second.
2020-03-24 19:45:10 +09:00
Bill Currie 99f89840f9 [gamecode] Show containing def and relative offset
No more guessing when accessing structure field members. Next is ivars,
I guess.
2020-03-15 02:51:29 +09:00
Bill Currie 3d62a7f253 [gamecode] Use fuzzy bsearch to find defs by address
The idea is to find th def that contains the address. Had to write my
own bsearch (well... lifted from wikipedia) because libc's is exact. The
defs are assumed to be sorted (which qfcc now ensures when it writes
progs and sym files).
2020-03-15 02:48:13 +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 98756df9f7 [gamecode] Set final resource map free list pointer
The sub-tables were being properly linked together, but the very final
table was not properly terminated.
2020-03-09 18:03:25 +09:00
Bill Currie 3b959c3ed0 [gamecode] Add a macros for arbitrary param/return types
Of course, the type has to be small enough to fit or bad things may
happen, but it beats having to type the crazy casting every time.
2020-03-06 00:23:44 +09:00
Bill Currie 4e4b553cc3 [gamecode] Take care of missed type alias stuff 2020-03-01 16:20:23 +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 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 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 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 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 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 7406e0308e Fix some warnings picked up in an optimized build 2020-02-24 11:28:43 +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 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 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 98216c6eb0 Fixed some missed doxygen updates 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 9248e8cf01 Update for doxygen 1.8.16 2020-02-11 15:22:42 +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 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 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 0de0eb2fc7 Fix a bunch of bit-rot. 2018-06-08 13:21: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 1503626847 Remove a stray variable declaration.
Quite bogus. How that got in there is beyond me.
2013-01-13 15:10:39 +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 eb8dfd78d0 Fix a comment.
The information I most wanted wasn't there :P
2012-11-22 21:59:00 +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 ce16750b04 Cache the max_edicts value in the progs struct.
Makes checks a little easier.
2012-07-09 15:06:42 +09:00
Bill Currie 0aac004c98 Rearrange the edict related fields of progs_t. 2012-07-09 15:04:12 +09:00
Bill Currie e91b06a144 Better name for the edict count parameter to PR_LoadProgsFile. 2012-07-09 15:02:49 +09:00
Bill Currie 3626f34c9a Add entnum to edict_t for faster edict->num.
Swiped from fte :)
2012-06-28 14:43:29 +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
Jeff Teunissen a56f6b2e37 Docs: switch to SVG for the .fig files, add borders around imgs
Self-explanatory, really.
2011-08-23 01:39:40 -04:00
Bill Currie 1e3f321070 Do some doc work on progs. 2011-07-29 09:04:09 +09:00
Jeff Teunissen 6fad9bc777 Misc. doc sanitation
Slightly document some of the vector types, and fix some typos.
2011-07-25 17:22:44 -04:00
Jeff Teunissen 49b5940cd5 VM doc cleanups
Clarify that the "return value" macros all access the same location in
memory, and are just casting it (after a fashion) to the desired type.
2011-07-25 17:22:44 -04:00
Bill Currie c30e2956f2 Correct the pointer declarations in the docs. 2011-07-09 09:41:30 +09:00
Bill Currie ca6dd204b3 Use the right type for VM pointers.
Probably more of these hiding in the code.
2011-02-18 09:03:04 +09:00
Bill Currie f54ce02725 Macros for quaterion access in progs memory. 2011-02-12 22:57:37 +09:00
Bill Currie 8e557e81b6 Break out the guts of Ed_LoadFromFile into ED_Parse.
ED_Parse does not support progs privided parsing (at this stage, anyway),
but this will allow clients to easily get at the entities in a map.
2010-12-10 17:17:29 +09:00
Bill Currie 3ae2ef8d11 Remove non-progs data from edict_t.
All data that is irrelevant to the progs engine itself has been removed
from edict_t and moved into the sv_progs code.
2010-12-09 17:24:37 +09:00
Bill Currie 9deb178e21 Some documentation fixups. 2010-12-09 13:35:11 +09:00
Bill Currie 31cf4b0d78 Use a linked list for the leafs in which the entity is positioned.
This allows the pvs to be used on an antity no matter how many leafs the
entity is touching. Seems to work nicely, but it will leak memory every
time a map is loaded.
2010-12-08 08:44:52 +09:00
Bill Currie 0e737cae15 Fix some "a" -> "an". 2010-11-29 12:54:26 +09:00
Bill Currie 0a203c0ab5 qccx (etc) "integer" autodetection.
Check for usage of denormal floats and if found, either bail with a
descriptive error message or give a mild warning that things will probably
break. This avoids the possibility of things like RuneQuake getting "lucky"
and doing real harm, and certainly avoids the segfaults.
2010-01-13 06:36:54 +00:00
Bill Currie 00e590f5f5 Really nail down the args param in rua_obj_msg_sendv(). 2010-01-13 06:36:16 +00:00
Bill Currie dc3fc291f6 fix a bunch of comments 2010-01-13 06:30:36 +00:00
Bill Currie 6eae016d3e minor cleanups
fix some comments, cleanup some whitespace, and don't explicitly call
PR_RelocateBuiltins as it is called (indirectly) by PR_LoadProgs.
2010-01-13 06:28:28 +00:00
Bill Currie 36fe939ea5 don't hang when processing \{N} escape sequences and fix a comment 2010-01-13 06:21:29 +00:00
Bill Currie 9ac15436d9 More docs.
Enhance qfprogs qfo debugging.

Make sure functions marked as extern don't emit anything. Fixes the segfault
when building klik.
2008-08-01 13:54:24 +00:00
Bill Currie 23e3fc0cb8 document most of obj_file.h (and a few other doc tweaks) 2008-08-01 00:47:38 +00:00
Bill Currie 3e50aae01f "print" command for dumping values in the progs and add return type info to the debugging information 2007-09-15 07:47:31 +00:00
Bill Currie ca0bbd909c correctly save and restore the parameters when calling +initialize. fixes the segfault in the qwaq test. 2007-06-09 13:44:06 +00:00
Bill Currie 57bd43fc52 make the watchpoint (optionally) conditional 2007-05-08 02:25:01 +00:00
Bill Currie fe4a4a9e55 "hardware" (haha) watch points (one!) in progs. only catches changes done by progs, and the expression parser is as flaky as anything, but it's better than nothing :) 2007-05-08 02:04:47 +00:00
Bill Currie 59498cd5e7 make the edict macros consistent in return type 2007-04-09 08:55:05 +00:00
Bill Currie b5e6aa4519 for pr_debug 1, don't dump disassembly when tracing, just source lines. pr_debug >= 2 forces disassembly. detailed disassembly now on pr_debug >= 3 figure out the types of arguments in a function call 2007-04-09 06:16:03 +00:00
Bill Currie 124506fda2 Fix the access alignment bug on 64 bit archs. 2007-04-07 01:41:23 +00:00
Bill Currie 5b761bac83 make progs related code a little more consistent with its int type usage 2007-04-06 00:47:41 +00:00
Bill Currie 38254186da other than floats, progs should now be int size safe 2007-04-04 12:30:49 +00:00
Bill Currie c290e9a988 use plists for save-games. old save-games can still be read, but new ones will always be in the new format. might be a good idea to back up any old saves until more testing has been done. 2006-12-09 02:35:44 +00:00
Bill Currie 2a79f42eb5 progs now internally uses plists for entity/global initialization, with support for direct conversion from id's format. This means that the entity string in a map (or the external ent file) can be a plist. 2006-12-09 00:02:57 +00:00
Bill Currie 6fbddc3d43 so that's the right way to do groups and subgroups... 2006-12-05 11:40:00 +00:00
Bill Currie 42f1334b87 I've discovered \par :) 2006-12-04 13:08:52 +00:00
Bill Currie d28952dfcc fix a bunch of gcc-4.1 warnings (thanks for the heads up, jordi) 2006-11-30 22:52:36 +00:00
Bill Currie e3c9cfd3d2 some documentation work 2005-07-27 12:14:35 +00:00
Bill Currie 762aefc9b1 implement Raven's calling convention (rcall: first 2 params in opb and
opc). should give a general speedup to most progs.
2005-06-12 09:54:01 +00:00
Bill Currie b7def83d19 patch from raorn ("Alexey I. Froloff" <sir_raorn@immo.ru>) to fix
interaction between -hipnotic (etc) and -game
2005-02-14 09:08:32 +00:00
Bill Currie 23f71485d1 more tree recovering. This includes Despair's anisotropy support work. 2005-01-02 14:23:20 +00:00
Bill Currie 0e324d1851 use the script api for parsing ent data and savegames
This is an imperfect revision of history.
2004-11-12 02:39:00 +00:00
Bill Currie 64cc8c60d2 compile time protocol support seems to be complete now. fortunatly, protocols had never been written out so the corrections to the protocol related stuctures do not need a progs version bump. runtime protocol support hasn't been fully tested yet.
+load runtime support seems to be working.

This is an imperfect revision of history.
2004-11-11 00:34:00 +00:00
Bill Currie b35561504c do proper selector registration. unfortunatly, I discovered I'd created pr_method_t incorrectly and so had to bump the progs version again
This is an imperfect revision of history.
2004-11-10 05:37:00 +00:00
Bill Currie 78d98ea787 remove the time pointer (not really needed)
This is an imperfect revision of history.
2004-11-09 22:32:00 +00:00
Bill Currie 8770df39e5 start documenting things (progs building still borked)
This is an imperfect revision of history.
2004-11-08 23:27:00 +00:00
Bill Currie f5bc90a53a clean up some redundant progs functions (may be broken for a while)
This is an imperfect revision of history.
2004-11-05 11:49:00 +00:00
Bill Currie 33bc7858f7 avoid using the hunk in the progs engine (except for the override-able load and alloc functions) so tools (qfprogs and qwaq) don't need to create it.
register only the first instance of a progs provided string

This is an imperfect revision of history.
2004-11-02 04:59:00 +00:00
Bill Currie ff5b215c13 multi statement macro fixes as pointed out by Grievre 2004-03-16 04:15:07 +00:00
Bill Currie 24294c8778 make printing of global contents in PR_PrintStatement optional so
disassembly output is cleaner
2004-01-31 04:26:01 +00:00
Bill Currie 390ca99a92 first step to making qfdefs redundant. "standard" progs now get resolved
staticly rather than looking up the defs. "broken" progs should now work.
2004-01-21 08:09:47 +00:00
Bill Currie 249aee2e9f move the OO runtime support code from libQFgamecode to libQFruamoko where
it really belongs :)
2004-01-16 08:02:31 +00:00
Bill Currie c5c5c33e7d I had forgotten the free string refs list /had/ to be in the progs vm 2004-01-08 04:03:47 +00:00
Bill Currie e455b760ca use a cycled pool of "return strings". I'd love to come up with something
better, but this will do (similar to what qwe does, but qf style:)
2004-01-07 05:22:57 +00:00
Bill Currie 133879f8fa provide builtin mappings for id (none, really), qf and ktpro/qwe (qw only),
add qwe builtin extensions to qw-server. provide sv_progs_ext to control
the builtin mapping. valid values are "id", "qf" (our old static builtins),
"qwe"/"ktpro" (either works. for ktpro mod support) and "none" (no
mapping). any other value is equivalent to "none".
2004-01-06 07:00:39 +00:00