2001-09-28 07:09:38 +00:00
|
|
|
/*
|
|
|
|
#FILENAME#
|
|
|
|
|
|
|
|
#DESCRIPTION#
|
|
|
|
|
|
|
|
Copyright (C) 2001 #AUTHOR#
|
|
|
|
|
|
|
|
Author: #AUTHOR#
|
|
|
|
Date: #DATE#
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
|
|
|
|
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-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;
|
2002-01-30 17:41:16 +00:00
|
|
|
VFile *f;
|
2001-06-01 21:57:59 +00:00
|
|
|
int len;
|
|
|
|
|
|
|
|
Cvar_Init_Hash ();
|
|
|
|
Cmd_Init_Hash ();
|
|
|
|
membase = malloc (memsize);
|
2002-05-14 06:37:28 +00:00
|
|
|
SYS_CHECKMEM (membase);
|
2001-06-01 21:57:59 +00:00
|
|
|
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);
|
2001-12-12 08:39:47 +00:00
|
|
|
Cvar_Get ("pr_boundscheck", "0", 0, 0, 0);
|
2001-07-14 23:52:56 +00:00
|
|
|
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 ();
|
2002-05-31 06:02:26 +00:00
|
|
|
PR_Obj_Progs_Init (&progs);
|
2001-06-01 21:57:59 +00:00
|
|
|
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-12-14 08:15:04 +00:00
|
|
|
progs.progs_name = "qwaq.dat";
|
2001-06-05 23:53:55 +00:00
|
|
|
|
2002-01-30 17:41:16 +00:00
|
|
|
f = Qopen (progs.progs_name, "rb");
|
2001-06-01 21:57:59 +00:00
|
|
|
if (f) {
|
2002-01-30 17:41:16 +00:00
|
|
|
Qseek (f, 0, SEEK_END);
|
|
|
|
len = Qtell (f);
|
|
|
|
Qseek (f, 0, SEEK_SET);
|
2001-07-18 21:28:41 +00:00
|
|
|
com_filesize = len;
|
2002-01-30 17:41:16 +00:00
|
|
|
PR_LoadProgsFile (&progs, f, len, 0, 1024 * 1024);
|
|
|
|
Qclose (f);
|
2001-06-01 21:57:59 +00:00
|
|
|
}
|
|
|
|
if (!progs.progs)
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("couldn't load %s", "qwaq.dat");
|
2002-01-30 17:41:16 +00:00
|
|
|
|
|
|
|
if (!PR_ResolveGlobals (&progs))
|
|
|
|
PR_Error (&progs, "unable to load %s", progs.progs_name);
|
|
|
|
PR_LoadStrings (&progs);
|
|
|
|
PR_LoadDebug (&progs);
|
|
|
|
PR_Check_Opcodes (&progs);
|
2001-12-14 08:15:04 +00:00
|
|
|
PR_RelocateBuiltins (&progs);
|
2002-05-31 06:02:26 +00:00
|
|
|
PR_InitRuntime (&progs);
|
2001-06-05 23:53:55 +00:00
|
|
|
|
|
|
|
*progs.edicts = PR_InitEdicts (&progs, MAX_EDICTS);
|
2001-06-03 17:36:49 +00:00
|
|
|
|
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
|
|
|
}
|