2001-05-25 20:31:47 +00:00
|
|
|
/*
|
|
|
|
gib.c
|
|
|
|
|
|
|
|
#DESCRIPTION#
|
|
|
|
|
|
|
|
Copyright (C) 2000 #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
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-05-25 16:09:14 +00:00
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-05-25 16:09:14 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-09 20:50:38 +00:00
|
|
|
#include "QF/gib.h"
|
2001-05-30 04:34:06 +00:00
|
|
|
#include "QF/vfs.h"
|
2001-05-25 16:09:14 +00:00
|
|
|
|
2001-06-01 00:39:31 +00:00
|
|
|
#include "compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "gib_instructions.h"
|
|
|
|
#include "gib_interpret.h"
|
|
|
|
#include "gib_modules.h"
|
|
|
|
#include "gib_parse.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Standard cvars
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_Init (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
Cmd_AddCommand ("gibload", GIB_Load_f, "No Description");
|
|
|
|
Cmd_AddCommand ("gibstats", GIB_Stats_f, "No Description");
|
|
|
|
Cmd_AddCommand ("gib", GIB_Gib_f, "No Description");
|
2001-02-19 21:15:25 +00:00
|
|
|
GIB_Init_Instructions ();
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_Gib_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
gib_sub_t *sub;
|
2001-02-19 21:15:25 +00:00
|
|
|
gib_module_t *mod;
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
if (!(mod = GIB_Get_ModSub_Mod (Cmd_Argv (1)))) {
|
|
|
|
Con_Printf ("Module not found!\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!(sub = GIB_Get_ModSub_Sub (Cmd_Argv (1))))
|
|
|
|
Con_Printf ("Subroutine not found!\n");
|
|
|
|
else {
|
|
|
|
gib_subargc = Cmd_Argc () - 1;
|
|
|
|
gib_subargv[0] = sub->name;
|
|
|
|
for (i = 1; i <= gib_subargc; i++)
|
|
|
|
gib_subargv[i] = Cmd_Argv (i + 1);
|
|
|
|
ret = GIB_Run_Sub (mod, sub);
|
|
|
|
if (ret != 0)
|
|
|
|
Con_Printf ("Error in execution of %s!\nError code: %i\n",
|
|
|
|
Cmd_Argv (1), ret);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_Load_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
char filename[256];
|
2001-05-30 03:21:19 +00:00
|
|
|
VFile *f;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
snprintf (filename, sizeof (filename), "%s/%s.gib", com_gamedir,
|
|
|
|
Cmd_Argv (1));
|
|
|
|
f = Qopen (filename, "r");
|
|
|
|
if (f) {
|
|
|
|
GIB_Module_Load (Cmd_Argv (1), f);
|
|
|
|
Qclose (f);
|
|
|
|
} else
|
|
|
|
Con_Printf ("gibload: File not found.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|