Moved GIB into libs/gib and made util no longer depend on it. Cleaned up

some cruft from a previous incarnation of GIB.
This commit is contained in:
Brian Koropoff 2002-11-09 07:13:52 +00:00
parent 1dfbf4ba7e
commit b40400d59c
24 changed files with 155 additions and 89 deletions

View file

@ -1970,6 +1970,7 @@ AC_OUTPUT(
libs/audio/cd/Makefile
libs/audio/targets/Makefile
libs/audio/renderer/Makefile
libs/gib/Makefile
libs/console/Makefile
libs/gamecode/Makefile
libs/gamecode/engine/Makefile

View file

@ -62,8 +62,6 @@ int Cmd_ExecuteString (const char *text, cmd_source_t src);
struct cbuf_s;
void Cmd_StuffCmds (struct cbuf_s *cbuf);
void Cmd_Exec_File (struct cbuf_s *cbuf, const char *path, int qfs);
void Cmd_Return (const char *value);
void Cmd_Error (const char *message);
extern struct cbuf_args_s *cmd_args;
extern struct cvar_s *cmd_warncmd;

32
include/QF/gib_init.h Normal file
View file

@ -0,0 +1,32 @@
/*
#FILENAME#
#DESCRIPTION#
Copyright (C) 2002 #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$
*/
void GIB_Init (void);

View file

@ -1,3 +1,3 @@
AUTOMAKE_OPTIONS= foreign
SUBDIRS= audio console gamecode models video util
SUBDIRS= audio console gamecode models video util gib

View file

@ -142,11 +142,11 @@ bi_Cmd_Args (progs_t *pr)
RETURN_STRING (pr, Cmd_Args (P_INT (pr, 0)));
}
static void
bi_Cmd_Return (progs_t *pr)
{
Cmd_Return (P_STRING (pr, 0));
}
//static void
//bi_Cmd_Return (progs_t *pr)
//{
// Cmd_Return (P_STRING (pr, 0));
//}
//Cmd_TokenizeString
//Cmd_ExecuteString
@ -166,5 +166,5 @@ Cmd_Progs_Init (progs_t *pr)
PR_AddBuiltin (pr, "Cmd_Argc", bi_Cmd_Argc, -1);
PR_AddBuiltin (pr, "Cmd_Argv", bi_Cmd_Argv, -1);
PR_AddBuiltin (pr, "Cmd_Args", bi_Cmd_Args, -1);
PR_AddBuiltin (pr, "Cmd_Return", bi_Cmd_Return, -1);
// PR_AddBuiltin (pr, "Cmd_Return", bi_Cmd_Return, -1);
}

10
libs/gib/Makefile.am Normal file
View file

@ -0,0 +1,10 @@
AUTOMAKE_OPTIONS= foreign
AM_CFLAGS= @PREFER_PIC@
INCLUDES= -I$(top_srcdir)/include
lib_LTLIBRARIES= libQFgib.la
libQFgib_la_LDFLAGS= -version-info 1:0:0
libQFgib_la_SOURCES= \
gib_buffer.c gib_builtin.c gib_function.c gib_parse.c gib_process.c \
gib_thread.c gib_vars.c gib_init.c ops.c exp.c

88
libs/gib/gib_init.c Normal file
View file

@ -0,0 +1,88 @@
/*
#FILENAME#
#DESCRIPTION#
Copyright (C) 2002 #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$";
#include <string.h>
#include "QF/qtypes.h"
#include "QF/cbuf.h"
#include "QF/quakefs.h"
#include "QF/gib_parse.h"
#include "QF/gib_builtin.h"
#include "QF/cmd.h"
#include "QF/sys.h"
#include "QF/zone.h"
#include "QF/cvar.h"
void
GIB_Exec_Override_f (void) {
char *f;
int mark;
if (Cmd_Argc () != 2) {
Sys_Printf ("exec <filename> : execute a script file\n");
return;
}
mark = Hunk_LowMark ();
f = (char *) COM_LoadHunkFile (Cmd_Argv (1));
if (!f) {
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
return;
}
if (!Cvar_Command() && (cmd_warncmd->int_val || (developer && developer->int_val)))
Sys_Printf ("execing %s\n", Cmd_Argv (1));
if (!strcmp (Cmd_Argv (1) + strlen (Cmd_Argv(1)) - 4, ".gib")) {
// GIB script, put it in a new buffer on the stack
cbuf_t *sub = Cbuf_New (&gib_interp);
if (cbuf_active->down)
Cbuf_DeleteStack (cbuf_active->down);
cbuf_active->down = sub;
sub->up = cbuf_active;
cbuf_active->state = CBUF_STATE_STACK;
Cbuf_AddText (sub, f);
GIB_Parse_Strip_Comments (sub);
} else
Cbuf_InsertText (cbuf_active, f);
Hunk_FreeToLowMark (mark);
}
void
GIB_Init (void)
{
// Override the exec command with a GIB-aware one
if (Cmd_Exists("exec")) {
Cmd_RemoveCommand ("exec");
Cmd_AddCommand ("exec", GIB_Exec_Override_f, "Execute a script file.");
}
// Initialize builtins
GIB_Builtin_Init ();
}

View file

@ -27,11 +27,9 @@ libQFutil_la_LIBADD= libasm.la $(Z_LIBS) $(DL_LIBS)
libQFutil_la_DEPENDENCIES= libasm.la
libQFutil_la_SOURCES= \
bspfile.c buildnum.c cbuf.c checksum.c cmd.c crc.c cvar.c dstring.c \
exp.c fendian.c getopt.c getopt1.c gib_buffer.c gib_builtin.c \
gib_function.c gib_parse.c gib_process.c gib_thread.c gib_vars.c hash.c \
idparse.c info.c link.c mathlib.c mdfour.c msg.c ops.c pakfile.c pcx.c \
plugin.c qargs.c qendian.c qfplist.c quakefs.c quakeio.c sizebuf.c string.c \
sys.c tga.c va.c ver_check.c wad.c zone.c \
$(fnmatch)
fendian.c getopt.c getopt1.c hash.c idparse.c info.c link.c mathlib.c \
mdfour.c msg.c pakfile.c pcx.c plugin.c qargs.c qendian.c qfplist.c \
quakefs.c quakeio.c sizebuf.c string.c sys.c tga.c va.c ver_check.c \
wad.c zone.c $(fnmatch)
EXTRA_DIST= $(asm_src) $(fnmatch_src)

View file

@ -47,8 +47,6 @@ static const char rcsid[] =
#include "QF/cmd.h"
#include "QF/cvar.h"
#include "QF/dstring.h"
#include "QF/gib_builtin.h"
#include "QF/gib_parse.h"
#include "QF/hash.h"
#include "QF/qargs.h"
#include "QF/quakefs.h"
@ -59,8 +57,6 @@ typedef struct cmdalias_s {
struct cmdalias_s *next;
const char *name;
const char *value;
qboolean restricted; // Created from restricted buffer
qboolean legacy; // Created from a legacy buffer
} cmdalias_t;
static cmdalias_t *cmd_alias;
@ -482,19 +478,7 @@ Cmd_Exec_f (void)
if (!Cvar_Command ()
&& (cmd_warncmd->int_val || (developer && developer->int_val)))
Sys_Printf ("execing %s\n", Cmd_Argv (1));
if (!strcmp (Cmd_Argv (1) + strlen (Cmd_Argv(1)) - 4, ".gib")) {
// GIB script, put it in a new buffer on the stack
cbuf_t *sub = Cbuf_New (&gib_interp);
if (cbuf_active->down)
Cbuf_DeleteStack (cbuf_active->down);
cbuf_active->down = sub;
sub->up = cbuf_active;
cbuf_active->state = CBUF_STATE_STACK;
Cbuf_AddText (sub, f);
GIB_Parse_Strip_Comments (sub);
} else
Cbuf_InsertText (cbuf_active, f);
Cbuf_InsertText (cbuf_active, f);
Hunk_FreeToLowMark (mark);
}
@ -609,10 +593,6 @@ Cmd_Init (void)
cmd_warncmd = Cvar_Get ("cmd_warncmd", "0", CVAR_NONE, NULL, "Toggles the "
"display of error messages for unknown commands");
cmd_cbuf = Cbuf_New (&id_interp);
// FIXME: GIB should really be initialized elsewhere
GIB_Builtin_Init ();
}
int
@ -644,7 +624,6 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
if (f) {
f[len] = 0;
Qread (file, f, len);
// Always insert into console
Cbuf_InsertText (cbuf, f);
free (f);
}
@ -652,14 +631,3 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
}
}
void
Cmd_Return (const char *value)
{
//FIXME implement
}
void
Cmd_Error (const char *message)
{
Sys_Printf ("%s", message);
}

View file

@ -86,7 +86,8 @@ common_LIBFILES= \
$(top_builddir)/libs/console/libQFconsole.la \
$(top_builddir)/libs/gamecode/builtins/libQFgamecode_builtins.la \
$(top_builddir)/libs/gamecode/engine/libQFgamecode.la \
$(top_builddir)/libs/util/libQFutil.la
$(top_builddir)/libs/util/libQFutil.la \
$(top_builddir)/libs/gib/libQFgib.la
client_LIBS= $(client_LIBFILES) $(common_LIBFILES)

View file

@ -51,6 +51,7 @@ static const char rcsid[] =
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/gib_thread.h"
#include "QF/gib_init.h"
#include "buildnum.h"
#include "chase.h"
@ -866,6 +867,7 @@ Host_Init (void)
Sys_Init ();
Cmd_Init ();
GIB_Init ();
// execute +set as early as possible
Cmd_StuffCmds (host_cbuf);

View file

@ -90,7 +90,8 @@ qf_server_LIBS= \
$(top_builddir)/libs/gamecode/builtins/libQFgamecode_builtins.la \
$(top_builddir)/libs/gamecode/engine/libQFgamecode.la \
$(top_builddir)/libs/console/libQFconsole.la \
$(top_builddir)/libs/util/libQFutil.la
$(top_builddir)/libs/util/libQFutil.la \
$(top_builddir)/libs/gib/libQFgib.la
qw_server_SOURCES= sv_model.c
qw_server_LDADD= libserver.a libcommon.a libnet.a libasm.a $(qf_server_LIBS) $(NET_LIBS) $(DL_LIBS) $(CURSES_LIBS)
@ -112,7 +113,8 @@ qf_client_LIBS= \
$(top_builddir)/libs/gamecode/engine/libQFgamecode.la \
$(top_builddir)/libs/audio/libQFcd.la \
$(top_builddir)/libs/audio/libQFsound.la \
$(top_builddir)/libs/util/libQFutil.la
$(top_builddir)/libs/util/libQFutil.la \
$(top_builddir)/libs/gib/libQFgib.la
client_LIBS= libnet.a libasm.a $(qf_client_LIBS)
client_libs= libclient.a libcommon.a

View file

@ -366,12 +366,6 @@ IN_Impulse (void)
Team_BestWeaponImpulse (); // HACK HACK HACK
}
void
IN_Getimpulse_f (void)
{
Cmd_Return(va("%i", in_impulse));
}
/*
CL_KeyState
@ -817,8 +811,6 @@ CL_Input_Init (void)
"jumping");
Cmd_AddCommand ("impulse", IN_Impulse, "Call a game function or QuakeC "
"function.");
Cmd_AddCommand ("getimpulse", IN_Getimpulse_f, "Returns the impulse that "
"will be sent to the server this frame");
Cmd_AddCommand ("+klook", IN_KLookDown, "When active, +forward and +back "
"perform +lookup and +lookdown");
Cmd_AddCommand ("-klook", IN_KLookUp, "When active, +forward and +back "

View file

@ -83,6 +83,7 @@ static const char rcsid[] =
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/gib_thread.h"
#include "QF/gib_init.h"
#include "bothdefs.h"
#include "buildnum.h"
@ -627,16 +628,6 @@ CL_FullServerinfo_f (void)
}
}
void
CL_Getserverinfo_f (void)
{
if (Cmd_Argc () != 2) {
Cmd_Error ("getserverinfo: invalid number of arguments.\n");
return;
}
Cmd_Return (Info_ValueForKey (cl.serverinfo, Cmd_Argv(1)));
}
void
CL_AddQFInfoKeys (void)
{
@ -737,22 +728,6 @@ CL_SetInfo_f (void)
CL_Cmd_ForwardToServer ();
}
void
CL_GetInfo_f (void)
{
const char *str;
if (Cmd_Argc () != 2) {
Cmd_Error ("getinfo: invalid number of arguments\n");
return;
}
str = Info_ValueForKey(cls.userinfo, Cmd_Argv(1));
if (str)
Cmd_Return (str);
else
Cmd_Return ("");
}
/*
CL_Packet_f
@ -1232,14 +1207,10 @@ CL_Init (void)
"that Quake should switch to upon a backpack pickup.\n "
"w_switch - Determines the highest weapon that Quake "
"should switch to upon a weapon pickup.");
Cmd_AddCommand ("getinfo", CL_GetInfo_f, "Returns the value of client "
"info key $1");
Cmd_AddCommand ("fullinfo", CL_FullInfo_f, "Used by GameSpy and Qlist to "
"set setinfo variables");
Cmd_AddCommand ("fullserverinfo", CL_FullServerinfo_f, "Used by GameSpy "
"and Qlist to obtain server variables");
Cmd_AddCommand ("getserverinfo", CL_Getserverinfo_f, "Returns the value "
"corresponding to key $1 in the server info.");
Cmd_AddCommand ("download", CL_Download_f, "Manually download a quake "
"file from the server");
Cmd_AddCommand ("nextul", CL_NextUpload, "Tells the client to send the "
@ -1700,6 +1671,7 @@ Host_Init (void)
Sys_Init ();
Cmd_Init ();
GIB_Init ();
// execute +set as early as possible
Cmd_StuffCmds (cl_cbuf);

View file

@ -67,6 +67,7 @@ static const char rcsid[] =
#include "QF/gib_parse.h"
#include "QF/gib_buffer.h"
#include "QF/gib_thread.h"
#include "QF/gib_init.h"
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"
@ -2469,6 +2470,7 @@ SV_Init (void)
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
Cmd_Init ();
GIB_Init ();
// execute +set as early as possible
Cmd_StuffCmds (sv_cbuf);