From cc753531a5c751cdb7bb84fc83d4e1d9ad094029 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 7 Jul 2005 00:48:23 +0000 Subject: [PATCH] 'autoext' program. Reads a list of extensions, works out what the engine supports, and generates a modder friendly qc file listing all the extensions that engine supports. Yay. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1136 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- quakec/autoext/src/autoext.qc | 106 ++++++++++++++++ quakec/autoext/src/builtins.qc | 21 ++++ quakec/autoext/src/defs.qc | 213 +++++++++++++++++++++++++++++++++ quakec/autoext/src/progs.src | 6 + 4 files changed, 346 insertions(+) create mode 100644 quakec/autoext/src/autoext.qc create mode 100644 quakec/autoext/src/builtins.qc create mode 100644 quakec/autoext/src/defs.qc create mode 100644 quakec/autoext/src/progs.src diff --git a/quakec/autoext/src/autoext.qc b/quakec/autoext/src/autoext.qc new file mode 100644 index 000000000..b146870c5 --- /dev/null +++ b/quakec/autoext/src/autoext.qc @@ -0,0 +1,106 @@ +float resultfile; +void(string s) putresultstring = +{ + fputs(resultfile, s); +}; + +void(string s) FoundExtension = +{ + float descfile; + string descfilename; + + putresultstring("//");putresultstring(s);putresultstring("\r\n"); + + descfilename = strcat("ext/", s, ".qc"); + descfile = fopen(descfilename, 0); + + if (descfile>=0) + { + for(;;) + { + s = fgets(descfile); + if (s) {} else break; + + putresultstring(s); + putresultstring("\r\n"); + } + fclose(descfile); + putresultstring("\r\n"); + } + else + { + putresultstring("//FIXME: AutoExt: No information\r\n"); + putresultstring("\r\n"); //and a blank line + } +}; + +void(string inname) decompose = +{ + float in; + float out; + float len; + string s; + string outname; + + in = fopen(inname, 0); + if (in < 0) + { + return; + } + + for(;;) + { + s = fgets(in); + if (s) {} else break; + + if (s == "") //skip extra whitespace + continue; + + len = strlen(s); + s = substring(s, 2, len-2); + outname = strcat("ext/", s, ".qc"); + out = fopen(outname, 2); + while((s = fgets(in)) != "") + { + fputs(out, s); + fputs(out, "\r\n"); + } + fclose(out); + } + + fclose(in); +}; + +void() worldspawn = +{ + float extlist; + string s; + + if (!cvar("pr_checkextension")) + error("Engine doesn't support any extensions\n"); + + if (!checkextension("FRIK_FILE")) + error("Unable to continue without FRIK_FILE\n"); + + +// decompose("lists/betwix.qc"); +// decompose("lists/dpextensions.qc"); + + extlist = fopen("lists/extlist.txt", 0); + resultfile = fopen("results.qc", 2); + + for(;;) + { + s = fgets(extlist); + if (s) {} else break; + + if (checkextension(s)) + FoundExtension(s); + } + + fclose(resultfile); + fclose(extlist); + +// dprint("\n\n\n\n\n\n\n\n"); + error("autoext compleate\n"); +}; \ No newline at end of file diff --git a/quakec/autoext/src/builtins.qc b/quakec/autoext/src/builtins.qc new file mode 100644 index 000000000..bcd7c1d7d --- /dev/null +++ b/quakec/autoext/src/builtins.qc @@ -0,0 +1,21 @@ +void(string e) error = #10; +float(string s) cvar = #45; +float(string s) checkextension = #99; + + +//FRIK_FILE +//IDEA: FrikaC +float (string s) stof = #81; // get numerical value from a string +float (string filename, float mode) fopen = #110; // opens a file inside quake/gamedir/ or quake/gamedir/data/ (mode is FILE_READ, FILE_APPEND, or FILE_WRITE), returns fhandle >= 0 if successful, or fhandle < 0 if unable to open file for any reason +void (float fhandle) fclose = #111; // closes a file +string (float fhandle) fgets = #112; // reads a line of text from the file and returns as a tempstring +void (float fhandle, string s) fputs = #113; // writes a line of text to the end of the file +float (string s) strlen = #114; // returns how many characters are in a string +string (string s1, string s2) strcat = #115; // concatenates two strings (for example "abc", "def" would return "abcdef") and returns as a tempstring +string (string s, float start, float length) substring = #116; // returns a section of a string as a tempstring +vector (string s) stov = #117; // returns vector value from a string +string (string s) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often) +void (string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!) +float FILE_READ = 0; +float FILE_APPEND = 1; +float FILE_WRITE = 2; \ No newline at end of file diff --git a/quakec/autoext/src/defs.qc b/quakec/autoext/src/defs.qc new file mode 100644 index 000000000..614135c98 --- /dev/null +++ b/quakec/autoext/src/defs.qc @@ -0,0 +1,213 @@ + +/* +============================================================================== + + SOURCE FOR GLOBALVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system globals +// +entity self; +entity other; +entity world; +float time; +float frametime; + +float force_retouch; // force all entities to touch triggers + // next frame. this is needed because + // non-moving things don't normally scan + // for triggers, and when a trigger is + // created (like a teleport trigger), it + // needs to catch everything. + // decremented each frame, so set to 2 + // to guarantee everything is touched +string mapname; + +float deathmatch; +float coop; +float teamplay; + +float serverflags; // propagated from level to level, used to + // keep track of completed episodes + +float total_secrets; +float total_monsters; + +float found_secrets; // number of secrets found +float killed_monsters; // number of monsters killed + + +// spawnparms are used to encode information about clients across server +// level changes +float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16; + +// +// global variables set by built in functions +// +vector v_forward, v_up, v_right; // set by makevectors() + +// set by traceline / tracebox +float trace_allsolid; +float trace_startsolid; +float trace_fraction; +vector trace_endpos; +vector trace_plane_normal; +float trace_plane_dist; +entity trace_ent; +float trace_inopen; +float trace_inwater; + +entity msg_entity; // destination of single entity writes + +// +// required prog functions +// +void() main; // only for testing + +void() StartFrame; + +void() PlayerPreThink; +void() PlayerPostThink; + +void() ClientKill; +void() ClientConnect; +void() PutClientInServer; // call after setting the parm1... parms +void() ClientDisconnect; + +void() SetNewParms; // called when a client first connects to + // a server. sets parms so they can be + // saved off for restarts + +void() SetChangeParms; // call to set parms for self so they can + // be saved for a level transition + + +//================================================ +void end_sys_globals; // flag for structure dumping +//================================================ + +/* +============================================================================== + + SOURCE FOR ENTVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system fields (*** = do not set in prog code, maintained by C code) +// +.float modelindex; // *** model index in the precached list +.vector absmin, absmax; // *** origin + mins / maxs + +.float ltime; // local time for entity +.float movetype; +.float solid; + +.vector origin; // *** +.vector oldorigin; // *** +.vector velocity; +.vector angles; +.vector avelocity; + +.vector punchangle; // temp angle adjust from damage or recoil + +.string classname; // spawn function +.string model; +.float frame; +.float skin; +.float effects; + +.vector mins, maxs; // bounding box extents reletive to origin +.vector size; // maxs - mins + +.void() touch; +.void() use; +.void() think; +.void() blocked; // for doors or plats, called when can't push other + +.float nextthink; +.entity groundentity; + +// stats +.float health; +.float frags; +.float weapon; // one of the IT_SHOTGUN, etc flags +.string weaponmodel; +.float weaponframe; +.float currentammo; +.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; + +.float items; // bit flags + +.float takedamage; +.entity chain; +.float deadflag; + +.vector view_ofs; // add to origin to get eye point + + +.float button0; // fire +.float button1; // use +.float button2; // jump + +.float impulse; // weapon changes + +.float fixangle; +.vector v_angle; // view / targeting angle for players +.float idealpitch; // calculated pitch angle for lookup up slopes + + +.string netname; + +.entity enemy; + +.float flags; + +.float colormap; +.float team; + +.float max_health; // players maximum health is stored here + +.float teleport_time; // don't back up + +.float armortype; // save this fraction of incoming damage +.float armorvalue; + +.float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes +.float watertype; // a contents value + +.float ideal_yaw; +.float yaw_speed; + +.entity aiment; + +.entity goalentity; // a movetarget or an enemy + +.float spawnflags; + +.string target; +.string targetname; + +// damage is accumulated through a frame. and sent as one single +// message, so the super shotgun doesn't generate huge messages +.float dmg_take; +.float dmg_save; +.entity dmg_inflictor; + +.entity owner; // who launched a missile +.vector movedir; // mostly for doors, but also used for waterjump + +.string message; // trigger messages + +.float sounds; // either a cd track number or sound number + +.string noise, noise1, noise2, noise3; // contains names of wavs to play + +//================================================ +void end_sys_fields; // flag for structure dumping +//================================================ + diff --git a/quakec/autoext/src/progs.src b/quakec/autoext/src/progs.src new file mode 100644 index 000000000..c77a378fe --- /dev/null +++ b/quakec/autoext/src/progs.src @@ -0,0 +1,6 @@ +../progs.dat + +defs.qc +builtins.qc + +autoext.qc \ No newline at end of file