2001-06-01 21:57:59 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <QF/cmd.h>
|
|
|
|
#include <QF/cvar.h>
|
|
|
|
#include <QF/progs.h>
|
2001-07-14 23:52:56 +00:00
|
|
|
#include <QF/vfs.h>
|
2001-06-01 21:57:59 +00:00
|
|
|
#include <QF/sys.h>
|
|
|
|
#include <QF/zone.h>
|
|
|
|
|
2001-06-05 23:53:55 +00:00
|
|
|
#define MAX_EDICTS 1024
|
|
|
|
|
2001-06-01 21:57:59 +00:00
|
|
|
progs_t progs;
|
|
|
|
void *membase;
|
|
|
|
int memsize = 16*1024*1024;
|
|
|
|
|
2001-06-05 23:53:55 +00:00
|
|
|
edict_t *edicts;
|
|
|
|
int num_edicts;
|
|
|
|
int reserved_edicts;
|
|
|
|
|
2001-06-01 21:57:59 +00:00
|
|
|
void BI_Init (progs_t *progs);
|
|
|
|
|
2001-06-03 17:36:49 +00:00
|
|
|
extern char *type_name[];
|
2001-07-18 21:28:41 +00:00
|
|
|
extern cvar_t *developer;
|
2001-06-03 17:36:49 +00:00
|
|
|
|
2001-07-23 01:31:22 +00:00
|
|
|
extern int *read_result; //FIXME: eww
|
2001-06-06 20:05:08 +00:00
|
|
|
|
2001-06-01 21:57:59 +00:00
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
func_t main_func;
|
|
|
|
FILE *f;
|
|
|
|
int len;
|
2001-06-08 00:14:11 +00:00
|
|
|
int i;
|
2001-06-01 21:57:59 +00:00
|
|
|
|
|
|
|
Cvar_Init_Hash ();
|
|
|
|
Cmd_Init_Hash ();
|
|
|
|
membase = malloc (memsize);
|
|
|
|
Memory_Init (membase, memsize);
|
|
|
|
Cvar_Init ();
|
|
|
|
Cbuf_Init ();
|
|
|
|
Cmd_Init ();
|
|
|
|
|
2001-07-14 23:52:56 +00:00
|
|
|
Cvar_Get ("pr_debug", "1", 0, 0, 0);
|
|
|
|
Cvar_Get ("fs_basegame", ".", 0, 0, 0);
|
|
|
|
Cvar_Get ("fs_userpath", ".", 0, 0, 0);
|
|
|
|
Cvar_Get ("fs_sharepath", ".", 0, 0, 0);
|
2001-07-18 21:28:41 +00:00
|
|
|
developer = Cvar_Get ("developer", "1", 0, 0, 0);
|
2001-07-14 23:52:56 +00:00
|
|
|
|
2001-06-01 21:57:59 +00:00
|
|
|
PR_Init_Cvars ();
|
2001-07-14 23:52:56 +00:00
|
|
|
COM_Filesystem_Init_Cvars ();
|
|
|
|
COM_Filesystem_Init ();
|
2001-06-01 21:57:59 +00:00
|
|
|
PR_Init ();
|
|
|
|
BI_Init (&progs);
|
|
|
|
|
2001-06-05 23:53:55 +00:00
|
|
|
progs.edicts = &edicts;
|
|
|
|
progs.num_edicts = &num_edicts;
|
|
|
|
progs.reserved_edicts = &reserved_edicts;
|
2001-06-06 20:05:08 +00:00
|
|
|
progs.no_exec_limit = 1;
|
2001-06-05 23:53:55 +00:00
|
|
|
|
2001-06-01 21:59:46 +00:00
|
|
|
f = fopen ("qwaq.dat", "rb");
|
2001-06-01 21:57:59 +00:00
|
|
|
if (f) {
|
|
|
|
fseek (f, 0, SEEK_END);
|
|
|
|
len = ftell (f);
|
|
|
|
fseek (f, 0, SEEK_SET);
|
2001-06-01 21:59:46 +00:00
|
|
|
progs.progs = Hunk_AllocName (len, "qwaq.dat");
|
2001-06-01 21:57:59 +00:00
|
|
|
fread (progs.progs, 1, len, f);
|
|
|
|
fclose (f);
|
2001-07-18 21:28:41 +00:00
|
|
|
com_filesize = len;
|
2001-06-01 21:57:59 +00:00
|
|
|
if (progs.progs)
|
|
|
|
PR_LoadProgs (&progs, 0);
|
|
|
|
}
|
|
|
|
if (!progs.progs)
|
2001-06-01 21:59:46 +00:00
|
|
|
Sys_Error ("couldn't load %s\n", "qwaq.dat");
|
2001-06-05 23:53:55 +00:00
|
|
|
|
|
|
|
*progs.edicts = PR_InitEdicts (&progs, MAX_EDICTS);
|
2001-06-27 05:46:53 +00:00
|
|
|
for (i = 0; i < progs.progs->numstatements; i++) {
|
2001-06-03 17:36:49 +00:00
|
|
|
PR_PrintStatement (&progs, &progs.pr_statements[i]);
|
2001-06-27 05:46:53 +00:00
|
|
|
}
|
2001-06-03 17:36:49 +00:00
|
|
|
printf ("\n");
|
|
|
|
for (i = 0; i < progs.progs->numfunctions; i++) {
|
|
|
|
dfunction_t *func = &progs.pr_functions[i];
|
|
|
|
int j;
|
|
|
|
|
2001-06-29 00:05:34 +00:00
|
|
|
printf ("%d %d %d %d %d %s %s %d", func->first_statement, func->parm_start, func->numparms, func->locals, func->profile, PR_GetString (&progs, func->s_name), PR_GetString (&progs, func->s_file), func->numparms);
|
2001-06-03 17:36:49 +00:00
|
|
|
for (j = 0; j < func->numparms; j++)
|
|
|
|
printf (" %d", func->parm_size[j]);
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
printf ("\n");
|
|
|
|
for (i = 0; i < progs.progs->numglobaldefs; i++) {
|
|
|
|
ddef_t *def = &progs.pr_globaldefs[i];
|
|
|
|
|
|
|
|
printf ("%s %d %d %s\n", type_name[def->type & ~DEF_SAVEGLOBAL], (def->type & DEF_SAVEGLOBAL) != 0, def->ofs, PR_GetString (&progs, def->s_name));
|
|
|
|
}
|
|
|
|
printf ("\n");
|
2001-07-10 18:25:54 +00:00
|
|
|
#if 0
|
2001-06-03 17:36:49 +00:00
|
|
|
for (i = 0; i < progs.progs->numfielddefs; i++) {
|
|
|
|
ddef_t *def = &progs.pr_fielddefs[i];
|
|
|
|
|
|
|
|
printf ("%s %d %d %s\n", type_name[def->type & ~DEF_SAVEGLOBAL], (def->type & DEF_SAVEGLOBAL) != 0, def->ofs, PR_GetString (&progs, def->s_name));
|
|
|
|
}
|
|
|
|
printf ("\n");
|
2001-06-06 20:05:08 +00:00
|
|
|
#endif
|
2001-07-23 01:31:22 +00:00
|
|
|
read_result = (int*)PR_GetGlobalPointer (&progs, "read_result");
|
2001-06-01 21:57:59 +00:00
|
|
|
main_func = PR_GetFunctionIndex (&progs, "main");
|
|
|
|
PR_ExecuteProgram (&progs, main_func);
|
2001-06-06 21:30:58 +00:00
|
|
|
return G_FLOAT (&progs, OFS_RETURN);
|
2001-06-01 21:57:59 +00:00
|
|
|
}
|