2000-08-28 00:45:40 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "cvar.h"
|
|
|
|
#include "console.h"
|
|
|
|
#include "qargs.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
#include "zone.h"
|
|
|
|
#include "quakefs.h"
|
|
|
|
#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
|
|
|
|
|
|
|
|
void GIB_Init (void)
|
|
|
|
{
|
|
|
|
Cmd_AddCommand("gibload", GIB_Load_f);
|
|
|
|
Cmd_AddCommand("gibstats", GIB_Stats_f);
|
|
|
|
Cmd_AddCommand("gib", GIB_Gib_f);
|
|
|
|
GIB_Init_Instructions ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GIB_Gib_f (void)
|
|
|
|
{
|
|
|
|
gib_sub_t *sub;
|
|
|
|
gib_module_t *mod;
|
|
|
|
int i, ret;
|
|
|
|
if (!(mod = GIB_Get_ModSub_Mod(Cmd_Argv(1))))
|
|
|
|
{
|
|
|
|
Con_Printf("Module not found!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(sub = GIB_Get_ModSub_Sub(Cmd_Argv(1))))
|
|
|
|
Con_Printf("Subroutine not found!\n");
|
|
|
|
else
|
|
|
|
{
|
2000-08-30 06:07:02 +00:00
|
|
|
gib_subargc = Cmd_Argc() - 1;
|
|
|
|
gib_subargv[0] = sub->name;
|
|
|
|
for (i = 1; i <= gib_subargc; i++)
|
|
|
|
gib_subargv[i] = Cmd_Argv(i + 1);
|
2000-08-28 00:45:40 +00:00
|
|
|
ret = GIB_Run_Sub(mod, sub);
|
|
|
|
if (ret != 0)
|
2000-08-30 06:07:02 +00:00
|
|
|
Con_Printf("Error in execution of %s!\nError code: %i\n", Cmd_Argv(1), ret);
|
2000-08-28 00:45:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GIB_Load_f (void)
|
|
|
|
{
|
|
|
|
char filename[256];
|
2000-09-19 22:32:45 +00:00
|
|
|
QFile *f;
|
2000-08-28 00:45:40 +00:00
|
|
|
|
2000-09-21 16:23:51 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s/%s.gib", com_gamedir, Cmd_Argv(1));
|
2000-09-19 22:32:45 +00:00
|
|
|
f = Qopen(filename, "r");
|
2000-08-28 00:45:40 +00:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
GIB_Module_Load(Cmd_Argv(1), f);
|
2000-09-19 22:32:45 +00:00
|
|
|
Qclose(f);
|
2000-08-28 00:45:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Con_Printf("gibload: File not found.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|