From 2842f4d4f1b8255ae040188d35b28f350c43ac51 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Wed, 28 Apr 2004 00:42:38 +0000 Subject: [PATCH] Ruamoko builtin declaration/implementation cleanup/simplification. Incomplete, but working. --- ruamoko/include/debug.h | 95 ++++++++++++++++------------ ruamoko/include/entities.h | 125 ++++++++++++++++++++++++++----------- ruamoko/lib/debug.r | 10 +-- ruamoko/lib/entities.r | 12 +--- 4 files changed, 145 insertions(+), 97 deletions(-) diff --git a/ruamoko/include/debug.h b/ruamoko/include/debug.h index e21e27827..55c356fd2 100644 --- a/ruamoko/include/debug.h +++ b/ruamoko/include/debug.h @@ -31,61 +31,74 @@ #ifndef __ruamoko_debug_h #define __ruamoko_debug_h -/* - abort (in QuakeC, this was break) +#ifdef __RUA_INTERNAL_IMPLEMENT +# define BUILTIN(name, number, rettype, ...) \ + rettype (__VA_ARGS__) name = number +#else +# define BUILTIN(name, number, rettype, ...) \ + rettype (__VA_ARGS__) name +@extern { +#endif // __RUA_INTERNAL_IMPLEMENT - Tell the engine to abort (stop) code processing. -*/ -@extern void () abort; + /* + abort (in QuakeC, this was break) -/* - error + Tell the engine to abort (stop) code processing. + */ + BUILTIN (abort, #6, void, void); - Abort (crash) the server. "e" is the message the server crashes with. -*/ -@extern void (string e) error; + /* + coredump -/* - objerror + Tell the engine to print all edicts (entities) + */ + BUILTIN (coredump, #28, void, void); - Prints info on the "self" ENTITY (not object), and error message "e". - The entity is freed. -*/ -@extern void (string e) objerror; + /* + traceon -/* - dprint + Enable instruction trace in the interpreter + */ + BUILTIN (traceon, #29, void, void); - Print string "e" if the developer Cvar is set to a nonzero value -*/ -@extern void (string s) dprint; + /* + traceoff -/* - coredump + Disable instruction trace in the interpreter + */ + BUILTIN (traceoff, #30, void, void); - Tell the engine to print all edicts (entities) -*/ -@extern void () coredump; + /* + eprint -/* - traceon + Print all information on an entity to the console + */ + BUILTIN (eprint, #31, void, entity e); - Enable instruction trace in the interpreter -*/ -@extern void () traceon; + /* + dprint -/* - traceoff + Print a string to the console if the "developer" Cvar is nonzero. + */ + BUILTIN (dprint, #25, void, string str); - Disable instruction trace in the interpreter -*/ -@extern void () traceoff; + /* + error -/* - eprint + Abort (crash) the server. "str" is the message the server crashes with. + */ + BUILTIN (error, #10, void, string str); - Print all information on an entity to the server console -*/ -@extern void (entity e) eprint; + /* + objerror + + Prints info on the "self" ENTITY (not object), and error message "e". + The entity is freed. + */ + BUILTIN (objerror, #10, void, string e); + +#ifndef __RUA_INTERNAL_IMPLEMENT +}; +#endif // __RUA_INTERNAL_IMPLEMENT #endif //__ruamoko_debug_h diff --git a/ruamoko/include/entities.h b/ruamoko/include/entities.h index 4e20cae0c..1c064a555 100644 --- a/ruamoko/include/entities.h +++ b/ruamoko/include/entities.h @@ -31,54 +31,107 @@ #ifndef __ruamoko_entities_h #define __ruamoko_entities_h -/* - setmodel +#ifdef __RUA_INTERNAL_IMPLEMENT +# define BUILTIN(name, number, rettype, ...) \ + rettype (__VA_ARGS__) name = number +#else +# define BUILTIN(name, number, rettype, ...) \ + rettype (__VA_ARGS__) name +@extern { +#endif // __RUA_INTERNAL_IMPLEMENT - Sets the model name for entity e to string m. - Set the entity's move type and solid type before calling this. -*/ -@extern void (entity e, string m) setmodel; + /* + setmodel -/* - setorigin + Sets the model name for entity e to string m. + Set the entity's move type and solid type before calling. + SERVER ONLY + */ + BUILTIN (setmodel, #3, void, entity e, string m); - Sets origin for entity e to vector o. -*/ -@extern void (entity e, vector o) setorigin; + /* + setorigin -/* - setsize + Sets origin for entity e to vector o. + SERVER ONLY + */ + BUILTIN (setorigin, #2, void, entity e, vector o); - Set the size of entity e to a cube with the bounds ( x1 y1 z1 ) ( x2 y2 z2 ) -*/ -@extern void (entity e, vector min, vector max) setsize; + /* + setsize -/* - spawn + Set the size of entity e to a cube with the bounds ( x1 y1 z1 ) ( x2 y2 z2 ) + SERVER ONLY + */ + BUILTIN (setsize, #4, void, entity e, vector min, vector max); - Creates a new entity and returns it. -*/ -@extern entity () spawn; + /* + spawn -/* - remove + Creates a new entity and returns it. + SERVER ONLY + */ + BUILTIN (spawn, #14, entity, void); - Remove entity e. -*/ -@extern void (entity e) remove; + /* + remove -@extern entity (entity start, .string fld, string match) find; -@extern entity (vector org, float rad) findradius; -@extern entity (entity e) nextent; + Remove entity e. + SERVER ONLY + */ + BUILTIN (remove, #15, void, entity e); -/* - makestatic + /* + find - Make entity e static (part of the world). - Static entities do not interact with the game. -*/ -@extern void (entity e) makestatic; + Search all entities for a field with contents matching a value and + return the first matching entity. -@extern void (entity e) setspawnparms; + start: the edict from which to start. + field: The field to search. + match: The contents to search for. + + This function must be called multiple times to get multiple results. + Stupid, but functional. + */ +#ifdef __VERSION6__ + BUILTIN (find, #18, entity, entity start, .string field, string match); +#else + BUILTIN (find, #18, entity, entity start, ...); +#endif + + /* + findradius + + Search for entities within radius of origin. + + If none found, world is returned. + If >1 found, the next will be linked using the "chain" field. + SERVER ONLY + */ + BUILTIN (findradius, #22, entity, vector origin, float radius); + + /* + nextent + + Return next entity after e. Use for traversing all entities. + Entity zero (the world) is returned if no more exist. + */ + BUILTIN (nextent, #47, entity, entity e); + + /* + makestatic + + Make entity e static (part of the world). + Static entities do not interact with the game. + SERVER ONLY + */ + BUILTIN (makestatic, #69, void, entity e); + + BUILTIN (setspawnparms, #78, void, entity e); + +#ifndef __RUA_INTERNAL_IMPLEMENT +}; +#endif // __RUA_INTERNAL_IMPLEMENT #endif //__ruamoko_entities_h diff --git a/ruamoko/lib/debug.r b/ruamoko/lib/debug.r index ecf5bffcb..26a69b68e 100644 --- a/ruamoko/lib/debug.r +++ b/ruamoko/lib/debug.r @@ -1,10 +1,2 @@ +#define __RUA_INTERNAL_IMPLEMENT #include "debug.h" - -//FIXME void () break = #6; -void (string e) error = #10; -void (string e) objerror = #11; -void (string s) dprint = #25; -void () coredump = #28; -void () traceon = #29; -void () traceoff = #30; -void (entity e) eprint = #31; diff --git a/ruamoko/lib/entities.r b/ruamoko/lib/entities.r index 57fd85ce4..45fa3c5c3 100644 --- a/ruamoko/lib/entities.r +++ b/ruamoko/lib/entities.r @@ -1,12 +1,2 @@ +#define __RUA_INTERNAL_IMPLEMENT #include "entities.h" - -void (entity e, vector o) setorigin = #2; -void (entity e, string m) setmodel = #3; -void (entity e, vector min, vector max) setsize = #4; -entity () spawn = #14; -void (entity e) remove = #15; -entity (entity start, .string fld, string match) find = #18; -entity (vector org, float rad) findradius = #22; -entity (entity e) nextent = #47; -void (entity e) makestatic = #69; -void (entity e) setspawnparms = #78;