2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/zone.h"
|
|
|
|
#include "QF/quakefs.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "gib.h"
|
|
|
|
#include "gib_instructions.h"
|
|
|
|
#include "gib_interpret.h"
|
|
|
|
#include "gib_modules.h"
|
|
|
|
#include "gib_parse.h"
|
|
|
|
#include "gib_vars.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];
|
|
|
|
QFile *f;
|
|
|
|
|
|
|
|
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
|
|
|
}
|