mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
Whitespace.
This commit is contained in:
parent
a7b402031f
commit
dc947ce8f5
18 changed files with 354 additions and 400 deletions
|
@ -98,7 +98,6 @@ Con_ToggleConsole_f (void)
|
|||
Con_ClearNotify ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_ToggleChat_f (void)
|
||||
{
|
||||
|
@ -118,7 +117,6 @@ Con_ToggleChat_f (void)
|
|||
Con_ClearNotify ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_Clear_f (void)
|
||||
{
|
||||
|
@ -129,17 +127,15 @@ Con_Clear_f (void)
|
|||
con_main.display = con_main.current;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_ClearNotify (void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_CON_TIMES; i++)
|
||||
con_times[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_MessageMode_f (void)
|
||||
{
|
||||
|
@ -151,7 +147,6 @@ Con_MessageMode_f (void)
|
|||
key_dest = key_message;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_MessageMode2_f (void)
|
||||
{
|
||||
|
@ -163,12 +158,11 @@ Con_MessageMode2_f (void)
|
|||
key_dest = key_message;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_Resize (console_t *con)
|
||||
{
|
||||
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
|
||||
char tbuf[CON_TEXTSIZE];
|
||||
char tbuf[CON_TEXTSIZE];
|
||||
int width, oldwidth, oldtotallines, numlines, numchars, i, j;
|
||||
|
||||
width = (vid.width >> 3) - 2;
|
||||
|
||||
|
@ -213,7 +207,6 @@ Con_Resize (console_t *con)
|
|||
con->display = con->current;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_CheckResize
|
||||
|
||||
|
@ -226,7 +219,6 @@ Con_CheckResize (void)
|
|||
Con_Resize (&con_chat);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
|
@ -256,16 +248,14 @@ C_Shutdown (void)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_Init_Cvars (void)
|
||||
{
|
||||
con_notifytime =
|
||||
Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
|
||||
"How long in seconds messages are displayed on screen");
|
||||
con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
|
||||
"How long in seconds messages are displayed "
|
||||
"on screen");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_Linefeed (void)
|
||||
{
|
||||
|
@ -279,7 +269,6 @@ Con_Linefeed (void)
|
|||
' ', con_linewidth);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
C_Print
|
||||
|
||||
|
@ -290,14 +279,10 @@ Con_Linefeed (void)
|
|||
void
|
||||
C_Print (const char *fmt, va_list args)
|
||||
{
|
||||
static char *buffer;
|
||||
static int buffer_size;
|
||||
int size;
|
||||
int y;
|
||||
int c, l;
|
||||
static int cr;
|
||||
int mask;
|
||||
const char *txt;
|
||||
const char *txt;
|
||||
static char *buffer;
|
||||
int mask, size, c, l, y;
|
||||
static int buffer_size, cr;
|
||||
|
||||
size = vsnprintf (buffer, buffer_size, fmt, args);
|
||||
if (size + 1 > buffer_size) {
|
||||
|
@ -343,7 +328,6 @@ C_Print (const char *fmt, va_list args)
|
|||
cr = false;
|
||||
}
|
||||
|
||||
|
||||
if (!con->x) {
|
||||
Con_Linefeed ();
|
||||
// mark time for transparent overlay
|
||||
|
@ -375,10 +359,7 @@ C_Print (const char *fmt, va_list args)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
DRAWING
|
||||
*/
|
||||
/* DRAWING */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -389,10 +370,9 @@ C_Print (const char *fmt, va_list args)
|
|||
void
|
||||
Con_DrawInput (void)
|
||||
{
|
||||
int y;
|
||||
int i;
|
||||
char *text;
|
||||
char temp[MAXCMDLINE];
|
||||
int i, y;
|
||||
char temp[MAXCMDLINE];
|
||||
char *text;
|
||||
|
||||
/*XXX
|
||||
if (key_dest != key_console && cls.state == ca_active)
|
||||
|
@ -422,7 +402,6 @@ Con_DrawInput (void)
|
|||
Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_DrawNotify
|
||||
|
||||
|
@ -431,12 +410,9 @@ Con_DrawInput (void)
|
|||
void
|
||||
Con_DrawNotify (void)
|
||||
{
|
||||
int x, v;
|
||||
char *text;
|
||||
int i;
|
||||
float time;
|
||||
char *s;
|
||||
int skip;
|
||||
int skip, i, v, x;
|
||||
char *text, *s;
|
||||
float time;
|
||||
|
||||
v = 0;
|
||||
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
|
||||
|
@ -492,7 +468,6 @@ Con_DrawNotify (void)
|
|||
con_notifylines = v;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_DrawConsole
|
||||
|
||||
|
@ -501,10 +476,8 @@ Con_DrawNotify (void)
|
|||
void
|
||||
Con_DrawConsole (int lines)
|
||||
{
|
||||
int i, x, y;
|
||||
int rows;
|
||||
char *text;
|
||||
int row;
|
||||
char *text;
|
||||
int row, rows, i, x, y;
|
||||
|
||||
if (lines <= 0)
|
||||
return;
|
||||
|
@ -547,13 +520,12 @@ Con_DrawConsole (int lines)
|
|||
Con_DrawInput ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_DrawDownload (int lines)
|
||||
{
|
||||
int i, j, x, y, n = 0; //XXX n
|
||||
const char *text = 0;//XXX
|
||||
char dlbar[1024];
|
||||
char dlbar[1024];
|
||||
const char *text = 0; //XXX
|
||||
int i, j, x, y, n = 0; //XXX n
|
||||
|
||||
/*XXX
|
||||
if (!cls.download)
|
||||
|
@ -604,12 +576,12 @@ static general_funcs_t plugin_info_general_funcs = {
|
|||
C_Init,
|
||||
C_Shutdown,
|
||||
};
|
||||
static general_data_t plugin_info_general_data;
|
||||
|
||||
static general_data_t plugin_info_general_data;
|
||||
static console_data_t plugin_info_console_data;
|
||||
static console_funcs_t plugin_info_console_funcs = {
|
||||
C_Print,
|
||||
};
|
||||
static console_data_t plugin_info_console_data;
|
||||
|
||||
static plugin_funcs_t plugin_info_funcs = {
|
||||
&plugin_info_general_funcs,
|
||||
|
@ -632,8 +604,8 @@ static plugin_t plugin_info = {
|
|||
"0.1",
|
||||
"client console driver",
|
||||
"Copyright (C) 1996-1997 id Software, Inc.\n"
|
||||
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge"
|
||||
" project\n"
|
||||
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge "
|
||||
"project\n"
|
||||
"Please see the file \"AUTHORS\" for a list of contributors",
|
||||
&plugin_info_funcs,
|
||||
&plugin_info_data,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/cmd.h"
|
||||
|
@ -44,23 +45,21 @@
|
|||
//FIXME eww
|
||||
extern int con_linewidth;
|
||||
|
||||
|
||||
/*
|
||||
Con_BasicCompleteCommandLine
|
||||
|
||||
New function for tab-completion system
|
||||
Added by EvilTypeGuy
|
||||
Thanks to Fett erich@heintz.com
|
||||
Thanks to taniwha
|
||||
Con_BasicCompleteCommandLine
|
||||
|
||||
New function for tab-completion system
|
||||
Added by EvilTypeGuy
|
||||
Thanks to Fett erich@heintz.com
|
||||
Thanks to taniwha
|
||||
*/
|
||||
void
|
||||
Con_BasicCompleteCommandLine (inputline_t *il)
|
||||
{
|
||||
const char *cmd = "";
|
||||
char *s;
|
||||
int c, v, a, i;
|
||||
int cmd_len;
|
||||
const char **list[3] = {0, 0, 0};
|
||||
char *s;
|
||||
const char *cmd = "", **list[3] = {0, 0, 0};
|
||||
int cmd_len, a, c, i, v;
|
||||
|
||||
s = il->lines[il->edit_line] + 1;
|
||||
if (*s == '\\' || *s == '/')
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -41,6 +42,7 @@
|
|||
|
||||
static plugin_t *con_module;
|
||||
|
||||
|
||||
void
|
||||
Con_Init (const char *plugin_name)
|
||||
{
|
||||
|
@ -68,7 +70,8 @@ Con_Shutdown (void)
|
|||
void
|
||||
Con_Printf (const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
if (con_module)
|
||||
con_module->functions->console->pC_Print (fmt, args);
|
||||
|
|
|
@ -47,10 +47,9 @@
|
|||
struct inputline_s *
|
||||
Con_CreateInputLine (int lines, int width, char prompt)
|
||||
{
|
||||
int size;
|
||||
inputline_t *inputline;
|
||||
char **p;
|
||||
char *l;
|
||||
char *l, **p;
|
||||
int size;
|
||||
inputline_t *inputline;
|
||||
|
||||
size = sizeof (inputline_t); // space for the header
|
||||
size += sizeof (char *[lines]); // space for the line pointers
|
||||
|
@ -79,7 +78,7 @@ Con_DestroyInputLine (inputline_t *inputline)
|
|||
void
|
||||
Con_ProcessInput (inputline_t *il, int ch)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
switch (ch) {
|
||||
/*
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "QF/console.h"
|
||||
|
||||
|
||||
/*
|
||||
Con_DisplayList
|
||||
|
||||
|
@ -49,12 +50,9 @@
|
|||
void
|
||||
Con_DisplayList(const char **list, int con_linewidth)
|
||||
{
|
||||
int i = 0;
|
||||
int pos = 0;
|
||||
int len = 0;
|
||||
int maxlen = 0;
|
||||
int width = (con_linewidth - 4);
|
||||
const char **walk = list;
|
||||
const char **walk = list;
|
||||
int len = 0, maxlen = 0, pos =0, i = 0;
|
||||
int width = (con_linewidth - 4);
|
||||
|
||||
while (*walk) {
|
||||
len = strlen(*walk);
|
||||
|
|
|
@ -32,10 +32,6 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_CURSES_H
|
||||
# include <curses.h>
|
||||
#endif
|
||||
|
@ -45,6 +41,11 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/cmd.h"
|
||||
#include "QF/console.h"
|
||||
|
@ -90,6 +91,7 @@ static const byte attr_map[256] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
|
@ -150,11 +152,11 @@ C_Print (const char *fmt, va_list args)
|
|||
{
|
||||
#ifdef HAVE_CURSES_H
|
||||
if (use_curses) {
|
||||
static char *buffer;
|
||||
static int buffer_size;
|
||||
char *txt;
|
||||
chtype ch;
|
||||
int size;
|
||||
char *txt;
|
||||
static char *buffer;
|
||||
int size;
|
||||
static int buffer_size;
|
||||
chtype ch;
|
||||
|
||||
size = vsnprintf (buffer, buffer_size, fmt, args);
|
||||
if (size + 1 > buffer_size) {
|
||||
|
|
|
@ -29,15 +29,15 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -56,9 +56,7 @@
|
|||
#define RETURN_EDICT(p, e) ((p)->pr_globals[OFS_RETURN].integer_var = EDICT_TO_PROG(p, e))
|
||||
#define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s))
|
||||
|
||||
/*
|
||||
BUILT-IN FUNCTIONS
|
||||
*/
|
||||
/* BUILT-IN FUNCTIONS */
|
||||
|
||||
// FIXME: Hunk_TempAlloc, Con_Printf, Cvar_*, PR_SetString, PR_RunError, ED_PrintEdicts, PF_traceon, PF_traceoff, ED_PrintNum, PR_FindBuiltin isn't threadsafe/reentrant
|
||||
|
||||
|
@ -66,9 +64,8 @@
|
|||
const char *
|
||||
PF_VarString (progs_t *pr, int first)
|
||||
{
|
||||
int i;
|
||||
int len;
|
||||
char *out;
|
||||
char *out;
|
||||
int len, i;
|
||||
|
||||
for (len = 0, i = first; i < pr->pr_argc; i++)
|
||||
len += strlen (G_STRING (pr, (OFS_PARM0 + i * 3)));
|
||||
|
@ -86,9 +83,9 @@ PF_VarString (progs_t *pr, int first)
|
|||
void
|
||||
PF_normalize (progs_t *pr)
|
||||
{
|
||||
float *value1;
|
||||
vec3_t newvalue;
|
||||
float new;
|
||||
float new;
|
||||
float *value1;
|
||||
vec3_t newvalue;
|
||||
|
||||
value1 = G_VECTOR (pr, OFS_PARM0);
|
||||
|
||||
|
@ -116,8 +113,8 @@ PF_normalize (progs_t *pr)
|
|||
void
|
||||
PF_vlen (progs_t *pr)
|
||||
{
|
||||
float *value1;
|
||||
float new;
|
||||
float new;
|
||||
float *value1;
|
||||
|
||||
value1 = G_VECTOR (pr, OFS_PARM0);
|
||||
|
||||
|
@ -136,8 +133,8 @@ PF_vlen (progs_t *pr)
|
|||
void
|
||||
PF_vectoyaw (progs_t *pr)
|
||||
{
|
||||
float *value1;
|
||||
float yaw;
|
||||
float yaw;
|
||||
float *value1;
|
||||
|
||||
value1 = G_VECTOR (pr, OFS_PARM0);
|
||||
|
||||
|
@ -160,9 +157,8 @@ PF_vectoyaw (progs_t *pr)
|
|||
void
|
||||
PF_vectoangles (progs_t *pr)
|
||||
{
|
||||
float *value1;
|
||||
float forward;
|
||||
float yaw, pitch;
|
||||
float forward, pitch, yaw;
|
||||
float *value1;
|
||||
|
||||
value1 = G_VECTOR (pr, OFS_PARM0);
|
||||
|
||||
|
@ -198,7 +194,7 @@ PF_vectoangles (progs_t *pr)
|
|||
void
|
||||
PF_random (progs_t *pr)
|
||||
{
|
||||
float num;
|
||||
float num;
|
||||
|
||||
num = (rand () & 0x7fff) / ((float) 0x7fff);
|
||||
|
||||
|
@ -229,7 +225,7 @@ PF_break (progs_t *pr)
|
|||
void
|
||||
PF_localcmd (progs_t *pr)
|
||||
{
|
||||
const char *str;
|
||||
const char *str;
|
||||
|
||||
str = G_STRING (pr, OFS_PARM0);
|
||||
Cbuf_AddText (str);
|
||||
|
@ -244,7 +240,7 @@ PF_localcmd (progs_t *pr)
|
|||
void
|
||||
PF_cvar (progs_t *pr)
|
||||
{
|
||||
const char *str;
|
||||
const char *str;
|
||||
|
||||
str = G_STRING (pr, OFS_PARM0);
|
||||
|
||||
|
@ -259,8 +255,8 @@ PF_cvar (progs_t *pr)
|
|||
void
|
||||
PF_cvar_set (progs_t *pr)
|
||||
{
|
||||
const char *var_name, *val;
|
||||
cvar_t *var;
|
||||
const char *var_name, *val;
|
||||
cvar_t *var;
|
||||
|
||||
var_name = G_STRING (pr, OFS_PARM0);
|
||||
val = G_STRING (pr, OFS_PARM1);
|
||||
|
@ -285,9 +281,9 @@ PF_cvar_set (progs_t *pr)
|
|||
void
|
||||
PF_ftos (progs_t *pr)
|
||||
{
|
||||
float v;
|
||||
int i; // 1999-07-25 FTOS fix by Maddes
|
||||
char string[MAX_FLOAT_STRING];
|
||||
char string[MAX_FLOAT_STRING];
|
||||
float v;
|
||||
int i; // 1999-07-25 FTOS fix by Maddes
|
||||
|
||||
v = G_FLOAT (pr, OFS_PARM0);
|
||||
|
||||
|
@ -310,7 +306,7 @@ PF_ftos (progs_t *pr)
|
|||
void
|
||||
PF_fabs (progs_t *pr)
|
||||
{
|
||||
float v;
|
||||
float v;
|
||||
|
||||
v = G_FLOAT (pr, OFS_PARM0);
|
||||
G_FLOAT (pr, OFS_RETURN) = fabs (v);
|
||||
|
@ -331,14 +327,11 @@ PF_vtos (progs_t *pr)
|
|||
void
|
||||
PF_Find (progs_t *pr)
|
||||
{
|
||||
int e;
|
||||
int f;
|
||||
edict_t *ed;
|
||||
ddef_t *field_def;
|
||||
int type;
|
||||
|
||||
const char *s = 0, *t; // ev_string
|
||||
int i; // ev_vector
|
||||
int i; // ev_vector
|
||||
int type, e, f;
|
||||
ddef_t *field_def;
|
||||
edict_t *ed;
|
||||
|
||||
e = G_EDICTNUM (pr, OFS_PARM0);
|
||||
f = G_INT (pr, OFS_PARM1);
|
||||
|
@ -424,7 +417,7 @@ PF_dprint (progs_t *pr)
|
|||
void
|
||||
PF_rint (progs_t *pr)
|
||||
{
|
||||
float f;
|
||||
float f;
|
||||
|
||||
f = G_FLOAT (pr, OFS_PARM0);
|
||||
if (f > 0)
|
||||
|
@ -453,8 +446,8 @@ PF_ceil (progs_t *pr)
|
|||
void
|
||||
PF_nextent (progs_t *pr)
|
||||
{
|
||||
int i;
|
||||
edict_t *ent;
|
||||
int i;
|
||||
edict_t *ent;
|
||||
|
||||
i = G_EDICTNUM (pr, OFS_PARM0);
|
||||
while (1) {
|
||||
|
@ -479,14 +472,13 @@ PF_nextent (progs_t *pr)
|
|||
void
|
||||
PF_stof (progs_t *pr)
|
||||
{
|
||||
const char *s;
|
||||
const char *s;
|
||||
|
||||
s = G_STRING (pr, OFS_PARM0);
|
||||
|
||||
G_FLOAT (pr, OFS_RETURN) = atof (s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
PF_strlen
|
||||
|
||||
|
@ -495,7 +487,7 @@ PF_stof (progs_t *pr)
|
|||
void
|
||||
PF_strlen (progs_t *pr)
|
||||
{
|
||||
const char *s;
|
||||
const char *s;
|
||||
|
||||
s = G_STRING (pr, OFS_PARM0);
|
||||
G_FLOAT (pr, OFS_RETURN) = strlen(s);
|
||||
|
@ -509,9 +501,9 @@ PF_strlen (progs_t *pr)
|
|||
void
|
||||
PF_charcount (progs_t *pr)
|
||||
{
|
||||
char goal;
|
||||
const char *s;
|
||||
char goal;
|
||||
int count;
|
||||
int count;
|
||||
|
||||
goal = (G_STRING (pr, OFS_PARM0))[0];
|
||||
if (goal == '\0') {
|
||||
|
@ -538,8 +530,8 @@ PF_checkbuiltin (progs_t *pr)
|
|||
void
|
||||
PF_getbuiltin (progs_t *pr)
|
||||
{
|
||||
int i;
|
||||
const char *name;
|
||||
int i;
|
||||
|
||||
name = G_STRING (pr, OFS_PARM0);
|
||||
i = PR_FindBuiltin (pr, name);
|
||||
|
@ -559,25 +551,13 @@ PF_getbuiltin (progs_t *pr)
|
|||
void
|
||||
PF_sprintf (progs_t *pr)
|
||||
{
|
||||
char *out = 0;
|
||||
int out_size = 0;
|
||||
int out_max = 32;
|
||||
char *format;
|
||||
char *c; // current
|
||||
char new_format[INT_WIDTH * 2 + 9]; // "%0-+ #." and conversion
|
||||
int new_format_i;
|
||||
int looping;
|
||||
int ret;
|
||||
int curarg = 3;
|
||||
|
||||
int fmt_leadzero;
|
||||
int fmt_leftjust;
|
||||
int fmt_signed;
|
||||
int fmt_space;
|
||||
int fmt_alternate;
|
||||
|
||||
int fmt_minwidth;
|
||||
int fmt_precision;
|
||||
char *format;
|
||||
char *c; // current
|
||||
char *out = 0;
|
||||
int fmt_alternate, fmt_leadzero, fmt_leftjust, fmt_minwidth,
|
||||
fmt_precision, fmt_signed, fmt_space, looping, new_format_i, ret;
|
||||
int cur_arg = 3, out_max = 32, out_size = 0;
|
||||
char new_format[INT_WIDTH * 2 + 9]; // "%0-+ #." and conversion
|
||||
|
||||
format = G_STRING (pr, OFS_PARM0);
|
||||
c = format;
|
||||
|
@ -649,16 +629,15 @@ PF_sprintf (progs_t *pr)
|
|||
if (fmt_alternate) new_format[new_format_i++] = '#';
|
||||
if (fmt_minwidth)
|
||||
if ((new_format_i += snprintf (new_format + new_format_i,
|
||||
sizeof (new_format) - new_format_i,
|
||||
"%d",
|
||||
fmt_minwidth))
|
||||
sizeof (new_format) -
|
||||
new_format_i,
|
||||
"%d", fmt_minwidth))
|
||||
>= sizeof (new_format))
|
||||
PR_Error (pr, "PF_sprintf: new_format overflowed?!");
|
||||
new_format[new_format_i++] = '.';
|
||||
if ((new_format_i += snprintf (new_format + new_format_i,
|
||||
sizeof (new_format) - new_format_i,
|
||||
"%d",
|
||||
fmt_precision))
|
||||
"%d", fmt_precision))
|
||||
>= sizeof (new_format))
|
||||
PR_Error (pr, "PF_sprintf: new_format overflowed?!");
|
||||
switch (*c) {
|
||||
|
@ -670,8 +649,7 @@ PF_sprintf (progs_t *pr)
|
|||
new_format[new_format_i++] = '\0';
|
||||
switch (*c) {
|
||||
case 'i':
|
||||
while ((ret = snprintf (&out[out_size],
|
||||
out_max - out_size,
|
||||
while ((ret = snprintf (&out[out_size], out_max - out_size,
|
||||
new_format,
|
||||
G_INT (pr, OFS_PARM0 + curarg)))
|
||||
>= out_max - out_size) {
|
||||
|
@ -686,8 +664,7 @@ PF_sprintf (progs_t *pr)
|
|||
curarg += 3;
|
||||
break;
|
||||
case 'f':
|
||||
while ((ret = snprintf (&out[out_size],
|
||||
out_max - out_size,
|
||||
while ((ret = snprintf (&out[out_size], out_max - out_size,
|
||||
new_format,
|
||||
G_FLOAT (pr, OFS_PARM0 + curarg)))
|
||||
>= out_max - out_size) {
|
||||
|
@ -707,9 +684,9 @@ PF_sprintf (progs_t *pr)
|
|||
if (curarg > MAX_ARG)
|
||||
goto maxargs;
|
||||
while ((ret = snprintf (&out[out_size],
|
||||
out_max - out_size,
|
||||
new_format,
|
||||
G_FLOAT (pr, OFS_PARM0 + curarg)))
|
||||
out_max - out_size, new_format,
|
||||
G_FLOAT (pr, OFS_PARM0 +
|
||||
curarg)))
|
||||
>= out_max - out_size) {
|
||||
char *o;
|
||||
out_max *= 2;
|
||||
|
@ -731,7 +708,8 @@ PF_sprintf (progs_t *pr)
|
|||
if (curarg > MAX_ARG)
|
||||
goto maxargs;
|
||||
s = G_STRING (pr, OFS_PARM0 + curarg);
|
||||
while ((ret = snprintf (&out[out_size], out_max - out_size, "%s", s))
|
||||
while ((ret = snprintf (&out[out_size], out_max - out_size, "%s",
|
||||
s))
|
||||
>= out_max - out_size) {
|
||||
char *o;
|
||||
out_max *= 2;
|
||||
|
@ -775,7 +753,7 @@ PF_sprintf (progs_t *pr)
|
|||
|
||||
mallocerror:
|
||||
// if (errno == ENOMEM)
|
||||
// hopefully we can free up some mem so it can be used during shutdown
|
||||
// hopefully we can free up some mem so it can be used during shutdown
|
||||
// free (out);
|
||||
PR_Error (pr, "PF_sprintf: memory allocation error!\n");
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/cvar.h"
|
||||
|
@ -65,19 +66,20 @@ cvar_t *pr_debug;
|
|||
cvar_t *pr_source_path;
|
||||
static hashtab_t *file_hash;
|
||||
|
||||
|
||||
file_t *
|
||||
PR_Load_Source_File (progs_t *pr, const char *fname)
|
||||
{
|
||||
file_t *f = Hash_Find (file_hash, fname);
|
||||
char *l;
|
||||
char *path;
|
||||
char *path, *l;
|
||||
file_t *f = Hash_Find (file_hash, fname);
|
||||
|
||||
if (f)
|
||||
return f;
|
||||
f = malloc (sizeof (file_t));
|
||||
if (!f)
|
||||
return 0;
|
||||
path = Hunk_TempAlloc (strlen (pr_source_path->string) + strlen (fname) + 2);
|
||||
path = Hunk_TempAlloc (strlen (pr_source_path->string) + strlen (fname) +
|
||||
2);
|
||||
sprintf (path, "%s/%s", pr_source_path->string, fname);
|
||||
f->text = COM_LoadFile (path, 0);
|
||||
if (!f->text) {
|
||||
|
@ -115,13 +117,12 @@ PR_Load_Source_File (progs_t *pr, const char *fname)
|
|||
void
|
||||
PR_LoadDebug (progs_t *pr)
|
||||
{
|
||||
char *sym_path;
|
||||
const char *path_end, *sym_file;
|
||||
int i;
|
||||
int start = Hunk_LowMark ();
|
||||
ddef_t *def;
|
||||
pr_type_t *str = 0;
|
||||
int start = Hunk_LowMark ();
|
||||
int i;
|
||||
const char *path_end;
|
||||
const char *sym_file;
|
||||
char *sym_path;
|
||||
ddef_t *def;
|
||||
|
||||
pr->debug = 0;
|
||||
pr->auxfunctions = 0;
|
||||
|
@ -142,7 +143,8 @@ PR_LoadDebug (progs_t *pr)
|
|||
pr->debugfile = PR_GetString (pr, str->string_var);
|
||||
sym_file = COM_SkipPath (pr->debugfile);
|
||||
path_end = COM_SkipPath (pr->progs_name);
|
||||
sym_path = Hunk_TempAlloc (strlen (sym_file) + (path_end - pr->progs_name) + 1);
|
||||
sym_path = Hunk_TempAlloc (strlen (sym_file) + (path_end - pr->progs_name)
|
||||
+ 1);
|
||||
strncpy (sym_path, pr->progs_name, path_end - pr->progs_name);
|
||||
strcpy (sym_path + (path_end - pr->progs_name), sym_file);
|
||||
pr->debug = (pr_debug_header_t*)COM_LoadHunkFile (sym_path);
|
||||
|
@ -163,7 +165,8 @@ PR_LoadDebug (progs_t *pr)
|
|||
}
|
||||
pr->debug->crc = LittleShort (pr->debug->crc);
|
||||
if (pr->debug->crc != pr->crc) {
|
||||
Sys_Printf ("ignoring %s that doesn't match %s. (CRCs: sym:%d dat:%d)\n",
|
||||
Sys_Printf ("ignoring %s that doesn't match %s. (CRCs: "
|
||||
"sym:%d dat:%d)\n",
|
||||
sym_path,
|
||||
pr->progs_name,
|
||||
pr->debug->crc,
|
||||
|
@ -172,7 +175,8 @@ PR_LoadDebug (progs_t *pr)
|
|||
pr->debug = 0;
|
||||
return;
|
||||
}
|
||||
pr->debug->you_tell_me_and_we_will_both_know = LittleShort (pr->debug->you_tell_me_and_we_will_both_know);
|
||||
pr->debug->you_tell_me_and_we_will_both_know = LittleShort
|
||||
(pr->debug->you_tell_me_and_we_will_both_know);
|
||||
pr->debug->auxfunctions = LittleLong (pr->debug->auxfunctions);
|
||||
pr->debug->num_auxfunctions = LittleLong (pr->debug->num_auxfunctions);
|
||||
pr->debug->linenos = LittleLong (pr->debug->linenos);
|
||||
|
@ -180,21 +184,28 @@ PR_LoadDebug (progs_t *pr)
|
|||
pr->debug->locals = LittleLong (pr->debug->locals);
|
||||
pr->debug->num_locals = LittleLong (pr->debug->num_locals);
|
||||
|
||||
pr->auxfunctions = (pr_auxfunction_t*)((char*)pr->debug + pr->debug->auxfunctions);
|
||||
pr->auxfunctions = (pr_auxfunction_t*)((char*)pr->debug +
|
||||
pr->debug->auxfunctions);
|
||||
pr->linenos = (pr_lineno_t*)((char*)pr->debug + pr->debug->linenos);
|
||||
pr->local_defs = (ddef_t*)((char*)pr->debug + pr->debug->locals);
|
||||
|
||||
pr->auxfunction_map = Hunk_Alloc (pr->progs->numfunctions
|
||||
* sizeof (pr_auxfunction_t*));
|
||||
pr->auxfunction_map = Hunk_Alloc (pr->progs->numfunctions *
|
||||
sizeof (pr_auxfunction_t*));
|
||||
|
||||
for (i = 0; i < pr->debug->num_auxfunctions; i++) {
|
||||
pr->auxfunctions[i].function = LittleLong (pr->auxfunctions[i].function);
|
||||
pr->auxfunctions[i].source_line = LittleLong (pr->auxfunctions[i].source_line);
|
||||
pr->auxfunctions[i].line_info = LittleLong (pr->auxfunctions[i].line_info);
|
||||
pr->auxfunctions[i].local_defs = LittleLong (pr->auxfunctions[i].local_defs);
|
||||
pr->auxfunctions[i].num_locals = LittleLong (pr->auxfunctions[i].num_locals);
|
||||
pr->auxfunctions[i].function = LittleLong
|
||||
(pr->auxfunctions[i].function);
|
||||
pr->auxfunctions[i].source_line = LittleLong
|
||||
(pr->auxfunctions[i].source_line);
|
||||
pr->auxfunctions[i].line_info = LittleLong
|
||||
(pr->auxfunctions[i].line_info);
|
||||
pr->auxfunctions[i].local_defs = LittleLong
|
||||
(pr->auxfunctions[i].local_defs);
|
||||
pr->auxfunctions[i].num_locals = LittleLong
|
||||
(pr->auxfunctions[i].num_locals);
|
||||
|
||||
pr->auxfunction_map[pr->auxfunctions[i].function] = &pr->auxfunctions[i];
|
||||
pr->auxfunction_map[pr->auxfunctions[i].function] =
|
||||
&pr->auxfunctions[i];
|
||||
}
|
||||
for (i = 0; i < pr->debug->num_linenos; i++) {
|
||||
pr->linenos[i].fa.func = LittleLong (pr->linenos[i].fa.func);
|
||||
|
@ -242,8 +253,8 @@ PR_Get_Lineno_Line (progs_t *pr, pr_lineno_t *lineno)
|
|||
pr_lineno_t *
|
||||
PR_Find_Lineno (progs_t *pr, unsigned long addr)
|
||||
{
|
||||
pr_lineno_t *lineno = 0;
|
||||
int i;
|
||||
int i;
|
||||
pr_lineno_t *lineno = 0;
|
||||
|
||||
if (!pr->debug)
|
||||
return 0;
|
||||
|
@ -270,11 +281,11 @@ PR_Get_Source_File (progs_t *pr, pr_lineno_t *lineno)
|
|||
const char *
|
||||
PR_Get_Source_Line (progs_t *pr, unsigned long addr)
|
||||
{
|
||||
pr_auxfunction_t *func;
|
||||
const char *fname;
|
||||
unsigned long line;
|
||||
char *str;
|
||||
file_t *file;
|
||||
char *str;
|
||||
const char *fname;
|
||||
unsigned long line;
|
||||
file_t *file;
|
||||
pr_auxfunction_t *func;
|
||||
|
||||
pr_lineno_t *lineno = PR_Find_Lineno (pr, addr);
|
||||
if (!lineno || PR_Get_Lineno_Addr (pr, lineno) != addr)
|
||||
|
@ -303,9 +314,9 @@ PR_Get_Source_Line (progs_t *pr, unsigned long addr)
|
|||
ddef_t *
|
||||
PR_Get_Local_Def (progs_t *pr, int offs)
|
||||
{
|
||||
int i;
|
||||
dfunction_t *func = pr->pr_xfunction;
|
||||
pr_auxfunction_t *aux_func;
|
||||
int i;
|
||||
dfunction_t *func = pr->pr_xfunction;
|
||||
pr_auxfunction_t *aux_func;
|
||||
|
||||
if (!func)
|
||||
return 0;
|
||||
|
@ -348,7 +359,6 @@ PR_Debug_Init_Cvars (void)
|
|||
{
|
||||
pr_debug = Cvar_Get ("pr_debug", "0", CVAR_NONE, NULL,
|
||||
"enable progs debugging");
|
||||
pr_source_path = Cvar_Get ("pr_source_path", ".", CVAR_NONE, NULL,
|
||||
"where to look (within gamedir) for source "
|
||||
"files");
|
||||
pr_source_path = Cvar_Get ("pr_source_path", ".", CVAR_NONE, NULL, "where "
|
||||
"to look (within gamedir) for source files");
|
||||
}
|
||||
|
|
|
@ -46,17 +46,13 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
//=============================================================================
|
||||
|
||||
extern cvar_t *pr_deadbeef;
|
||||
|
||||
/*
|
||||
PR_PrintStatement
|
||||
*/
|
||||
|
||||
void
|
||||
PR_PrintStatement (progs_t * pr, dstatement_t *s)
|
||||
{
|
||||
int addr = s - pr->pr_statements;
|
||||
int addr = s - pr->pr_statements;
|
||||
opcode_t *op;
|
||||
|
||||
if (pr_debug->int_val && pr->debug) {
|
||||
|
@ -95,14 +91,11 @@ PR_PrintStatement (progs_t * pr, dstatement_t *s)
|
|||
Con_Printf ("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
PR_StackTrace
|
||||
*/
|
||||
void
|
||||
PR_StackTrace (progs_t * pr)
|
||||
{
|
||||
dfunction_t *f;
|
||||
int i;
|
||||
int i;
|
||||
dfunction_t *f;
|
||||
|
||||
if (pr->pr_depth == 0) {
|
||||
Con_Printf ("<NO STACK>\n");
|
||||
|
@ -121,17 +114,11 @@ PR_StackTrace (progs_t * pr)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
PR_Profile
|
||||
*/
|
||||
void
|
||||
PR_Profile (progs_t * pr)
|
||||
{
|
||||
dfunction_t *f, *best;
|
||||
int max;
|
||||
int num;
|
||||
int i;
|
||||
int max, num, i;
|
||||
dfunction_t *best, *f;
|
||||
|
||||
num = 0;
|
||||
do {
|
||||
|
@ -162,8 +149,8 @@ PR_Profile (progs_t * pr)
|
|||
void
|
||||
PR_RunError (progs_t * pr, const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
char string[1024];
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, error);
|
||||
vsnprintf (string, sizeof (string), error, argptr);
|
||||
|
@ -195,8 +182,7 @@ PR_RunError (progs_t * pr, const char *error, ...)
|
|||
int
|
||||
PR_EnterFunction (progs_t * pr, dfunction_t *f)
|
||||
{
|
||||
int i, j, c, o;
|
||||
// int k;
|
||||
int i, j, c, o;
|
||||
|
||||
//printf("%s:\n", PR_GetString(pr,f->s_name));
|
||||
pr->pr_stack[pr->pr_depth].s = pr->pr_xstatement;
|
||||
|
@ -219,7 +205,7 @@ PR_EnterFunction (progs_t * pr, dfunction_t *f)
|
|||
// for (k = f->parm_start; k < f->parm_start + c; k++)
|
||||
// pr->pr_globals[k].integer_var = 0xdeadbeef;
|
||||
|
||||
// copy parameters
|
||||
// copy parameters
|
||||
o = f->parm_start;
|
||||
for (i = 0; i < f->numparms; i++) {
|
||||
for (j = 0; j < f->parm_size[i]; j++) {
|
||||
|
@ -234,18 +220,15 @@ PR_EnterFunction (progs_t * pr, dfunction_t *f)
|
|||
return f->first_statement - 1; // offset the s++
|
||||
}
|
||||
|
||||
/*
|
||||
PR_LeaveFunction
|
||||
*/
|
||||
int
|
||||
PR_LeaveFunction (progs_t * pr)
|
||||
{
|
||||
int c;
|
||||
int c;
|
||||
|
||||
if (pr->pr_depth <= 0)
|
||||
PR_Error (pr, "prog stack underflow");
|
||||
|
||||
// restore locals from the stack
|
||||
// restore locals from the stack
|
||||
c = pr->pr_xfunction->locals;
|
||||
pr->localstack_used -= c;
|
||||
if (pr->localstack_used < 0)
|
||||
|
@ -255,33 +238,31 @@ PR_LeaveFunction (progs_t * pr)
|
|||
&pr->localstack[pr->localstack_used],
|
||||
sizeof (pr_type_t) * c);
|
||||
|
||||
// up stack
|
||||
// up stack
|
||||
pr->pr_depth--;
|
||||
pr->pr_xfunction = pr->pr_stack[pr->pr_depth].f;
|
||||
return pr->pr_stack[pr->pr_depth].s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
PR_ExecuteProgram
|
||||
|
||||
The interpretation main loop
|
||||
*/
|
||||
#define OPA (pr->pr_globals[st->a])
|
||||
#define OPB (pr->pr_globals[st->b])
|
||||
#define OPC (pr->pr_globals[st->c])
|
||||
|
||||
extern cvar_t *pr_boundscheck;
|
||||
|
||||
/*
|
||||
PR_ExecuteProgram
|
||||
|
||||
The interpretation main loop
|
||||
*/
|
||||
void
|
||||
PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
||||
{
|
||||
dstatement_t *st;
|
||||
dfunction_t *f, *newf;
|
||||
edict_t *ed;
|
||||
int exitdepth;
|
||||
pr_type_t *ptr;
|
||||
int profile, startprofile;
|
||||
int exitdepth, profile, startprofile;
|
||||
dfunction_t *f, *newf;
|
||||
dstatement_t *st;
|
||||
edict_t *ed;
|
||||
pr_type_t *ptr;
|
||||
|
||||
if (!fnum || fnum >= pr->progs->numfunctions) {
|
||||
if (*pr->globals.self)
|
||||
|
@ -294,7 +275,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
|
||||
pr->pr_trace = false;
|
||||
|
||||
// make a stack frame
|
||||
// make a stack frame
|
||||
exitdepth = pr->pr_depth;
|
||||
|
||||
st = &pr->pr_statements[PR_EnterFunction (pr, f)];
|
||||
|
@ -412,7 +393,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
&& !OPA.vector_var[2];
|
||||
break;
|
||||
case OP_NOT_S:
|
||||
OPC.integer_var = !OPA.string_var || !*PR_GetString (pr, OPA.string_var);
|
||||
OPC.integer_var = !OPA.string_var ||
|
||||
!*PR_GetString (pr, OPA.string_var);
|
||||
break;
|
||||
case OP_NOT_FNC:
|
||||
OPC.integer_var = !OPA.func_var;
|
||||
|
@ -489,19 +471,20 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_STOREP_S:
|
||||
case OP_STOREP_FNC: // pointers
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 4 > pr->pr_edictareasize)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 4 >
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to write to an out of bounds edict\n");
|
||||
PR_RunError (pr, "Progs attempted to write to an out of "
|
||||
"bounds edict\n");
|
||||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val && (OPB.integer_var % pr->pr_edict_size <
|
||||
if (pr_boundscheck->int_val && (OPB.integer_var %
|
||||
pr->pr_edict_size <
|
||||
((byte *) & (*pr->edicts)->v -
|
||||
(byte *) * pr->edicts))) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to write to an engine edict field\n");
|
||||
PR_RunError (pr, "Progs attempted to write to an engine "
|
||||
"edict field\n");
|
||||
return;
|
||||
}
|
||||
ptr = (pr_type_t*)((int)*pr->edicts + OPB.integer_var);
|
||||
|
@ -509,11 +492,11 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
break;
|
||||
case OP_STOREP_V:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 12 > pr->pr_edictareasize)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 12 >
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to write to an out of bounds edict\n");
|
||||
PR_RunError (pr, "Progs attempted to write to an out of "
|
||||
"bounds edict\n");
|
||||
return;
|
||||
}
|
||||
ptr = (pr_type_t*)((int)*pr->edicts + OPB.integer_var);
|
||||
|
@ -523,10 +506,11 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
break;
|
||||
case OP_ADDRESS:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >= pr->pr_edictareasize)) {
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >=
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to address an out of bounds edict\n");
|
||||
PR_RunError (pr, "Progs attempted to address an out of "
|
||||
"bounds edict\n");
|
||||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val
|
||||
|
@ -536,15 +520,16 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >= pr->progs->entityfields)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >=
|
||||
pr->progs->entityfields)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to address an invalid field in an edict\n");
|
||||
PR_RunError (pr, "Progs attempted to address an invalid "
|
||||
"field in an edict\n");
|
||||
return;
|
||||
}
|
||||
ed = PROG_TO_EDICT (pr, OPA.entity_var);
|
||||
OPC.integer_var = (int)&ed->v[OPB.integer_var] - (int)*pr->edicts;
|
||||
OPC.integer_var = (int) &ed->v[OPB.integer_var] -
|
||||
(int) *pr->edicts;
|
||||
break;
|
||||
case OP_LOAD_F:
|
||||
case OP_LOAD_FLD:
|
||||
|
@ -552,19 +537,19 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_LOAD_S:
|
||||
case OP_LOAD_FNC:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >= pr->pr_edictareasize)) {
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >=
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to read an out of bounds edict number\n");
|
||||
PR_RunError (pr, "Progs attempted to read an out of "
|
||||
"bounds edict number\n");
|
||||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >= pr->progs->entityfields)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >=
|
||||
pr->progs->entityfields)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to read an invalid field in an edict\n");
|
||||
PR_RunError (pr, "Progs attempted to read an invalid "
|
||||
"field in an edict\n");
|
||||
return;
|
||||
}
|
||||
ed = PROG_TO_EDICT (pr, OPA.entity_var);
|
||||
|
@ -572,20 +557,19 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
break;
|
||||
case OP_LOAD_V:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >= pr->pr_edictareasize)) {
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >=
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to read an out of bounds edict number\n");
|
||||
PR_RunError (pr, "Progs attempted to read an out of "
|
||||
"bounds edict number\n");
|
||||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0
|
||||
|| OPB.integer_var + 2 >= pr->progs->entityfields)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr,
|
||||
"Progs attempted to read an invalid field in an edict\n");
|
||||
PR_RunError (pr, "Progs attempted to read an invalid "
|
||||
"field in an edict\n");
|
||||
return;
|
||||
}
|
||||
ed = PROG_TO_EDICT (pr, OPA.entity_var);
|
||||
|
@ -647,7 +631,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
break;
|
||||
case OP_STATE:
|
||||
ed = PROG_TO_EDICT (pr, *pr->globals.self);
|
||||
ed->v[pr->fields.nextthink].float_var = *pr->globals.time + 0.1;
|
||||
ed->v[pr->fields.nextthink].float_var = *pr->globals.time +
|
||||
0.1;
|
||||
ed->v[pr->fields.frame].float_var = OPA.float_var;
|
||||
ed->v[pr->fields.think].func_var = OPB.func_var;
|
||||
break;
|
||||
|
@ -730,18 +715,21 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
break;
|
||||
case OP_STOREP_I:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 4 > pr->pr_edictareasize)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 4 >
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to write to an out of bounds edict\n");
|
||||
PR_RunError (pr, "Progs attempted to write to an out of "
|
||||
"bounds edict\n");
|
||||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var % pr->pr_edict_size <
|
||||
((byte *) & (*pr->edicts)->v - (byte *) *pr->edicts))) {
|
||||
((byte *) & (*pr->edicts)->v - (byte *) *pr->edicts)))
|
||||
{
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to write to an engine edict field\n");
|
||||
(pr, "Progs attempted to write to an engine edict "
|
||||
"field\n");
|
||||
return;
|
||||
}
|
||||
ptr = (pr_type_t*)((int)*pr->edicts + OPB.integer_var);
|
||||
|
@ -749,17 +737,20 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
break;
|
||||
case OP_LOAD_I:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >= pr->pr_edictareasize)) {
|
||||
&& (OPA.entity_var < 0 || OPA.entity_var >=
|
||||
pr->pr_edictareasize)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to read an out of bounds edict number\n");
|
||||
(pr, "Progs attempted to read an out of bounds edict "
|
||||
"number\n");
|
||||
return;
|
||||
}
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >= pr->progs->entityfields)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >=
|
||||
pr->progs->entityfields)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to read an invalid field in an entity_var\n");
|
||||
PR_RunError (pr, "Progs attempted to read an invalid "
|
||||
"field in an entity_var\n");
|
||||
return;
|
||||
}
|
||||
ed = PROG_TO_EDICT (pr, OPA.entity_var);
|
||||
|
@ -774,21 +765,22 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_GSTOREP_FLD: // integers
|
||||
case OP_GSTOREP_S:
|
||||
case OP_GSTOREP_FNC: // pointers
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var >= pr->pr_globaldefs)) {
|
||||
if (pr_boundscheck->int_val && (OPB.integer_var < 0 ||
|
||||
OPB.integer_var >= pr->pr_globaldefs)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to write to an invalid indexed global\n");
|
||||
PR_RunError (pr, "Progs attempted to write to an invalid "
|
||||
"indexed global\n");
|
||||
return;
|
||||
}
|
||||
pr->pr_globals[OPB.integer_var] = OPA.float_var;
|
||||
break;
|
||||
case OP_GSTOREP_V:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 2 >= pr->pr_globaldefs)) {
|
||||
&& (OPB.integer_var < 0 || OPB.integer_var + 2 >=
|
||||
pr->pr_globaldefs)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to write to an invalid indexed global\n");
|
||||
PR_RunError (pr, "Progs attempted to write to an invalid "
|
||||
"indexed global\n");
|
||||
return;
|
||||
}
|
||||
pr->pr_globals[OPB.integer_var] = OPA.vector_var[0];
|
||||
|
@ -801,8 +793,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
if (pr_boundscheck->int_val
|
||||
&& (i < 0 || i >= pr->pr_globaldefs)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to address an out of bounds global\n");
|
||||
PR_RunError (pr, "Progs attempted to address an out of "
|
||||
"bounds global\n");
|
||||
return;
|
||||
}
|
||||
OPC.float_var = pr->pr_globals[i];
|
||||
|
@ -815,10 +807,11 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_GLOAD_S:
|
||||
case OP_GLOAD_FNC:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPA.integer_var < 0 || OPA.integer_var >= pr->pr_globaldefs)) {
|
||||
&& (OPA.integer_var < 0 || OPA.integer_var >=
|
||||
pr->pr_globaldefs)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to read an invalid indexed global\n");
|
||||
PR_RunError (pr, "Progs attempted to read an invalid "
|
||||
"indexed global\n");
|
||||
return;
|
||||
}
|
||||
OPC.float_var = pr->pr_globals[OPA.integer_var];
|
||||
|
@ -826,10 +819,11 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
|
||||
case OP_GLOAD_V:
|
||||
if (pr_boundscheck->int_val
|
||||
&& (OPA.integer_var < 0 || OPA.integer_var + 2 >= pr->pr_globaldefs)) {
|
||||
&& (OPA.integer_var < 0 || OPA.integer_var + 2 >=
|
||||
pr->pr_globaldefs)) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs attempted to read an invalid indexed global\n");
|
||||
PR_RunError (pr, "Progs attempted to read an invalid "
|
||||
"indexed global\n");
|
||||
return;
|
||||
}
|
||||
OPC.vector_var[0] = pr->pr_globals[OPA.integer_var];
|
||||
|
@ -840,9 +834,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_BOUNDCHECK:
|
||||
if (OPA.integer_var < 0 || OPA.integer_var >= st->b) {
|
||||
pr->pr_xstatement = st - pr->pr_statements;
|
||||
PR_RunError
|
||||
(pr, "Progs boundcheck failed at line number %d, value is < 0 or >= %d\n",
|
||||
st->b, st->c);
|
||||
PR_RunError (pr, "Progs boundcheck failed at line number "
|
||||
"%d, value is < 0 or >= %d\n", st->b, st->c);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include "string.h"
|
||||
#endif
|
||||
|
@ -159,12 +158,13 @@ opcode_t pr_opcodes[] = {
|
|||
{0},
|
||||
};
|
||||
|
||||
|
||||
static const char *
|
||||
get_key (void *_op, void *unused)
|
||||
{
|
||||
opcode_t *op = (opcode_t *)_op;
|
||||
static char rep[4];
|
||||
char *r = rep;
|
||||
char *r = rep;
|
||||
static char rep[4];
|
||||
opcode_t *op = (opcode_t *)_op;
|
||||
|
||||
*r++ = (op->opcode & 0x7f) + 2;
|
||||
*r++ = ((op->opcode >> 7) & 0x7f) + 2;
|
||||
|
@ -176,8 +176,8 @@ get_key (void *_op, void *unused)
|
|||
opcode_t *
|
||||
PR_Opcode (short opcode)
|
||||
{
|
||||
opcode_t op;
|
||||
char rep[100];
|
||||
char rep[100];
|
||||
opcode_t op;
|
||||
|
||||
op.opcode = opcode;
|
||||
strcpy (rep, get_key (&op, 0));
|
||||
|
@ -187,7 +187,7 @@ PR_Opcode (short opcode)
|
|||
void
|
||||
PR_Opcode_Init (void)
|
||||
{
|
||||
opcode_t *op;
|
||||
opcode_t *op;
|
||||
|
||||
opcode_table = Hash_NewTable (1021, get_key, 0, 0);
|
||||
|
||||
|
|
|
@ -35,19 +35,21 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/hash.h"
|
||||
#include "QF/progs.h"
|
||||
|
||||
|
||||
static strref_t *
|
||||
new_string_ref (progs_t *pr)
|
||||
{
|
||||
strref_t *sr;
|
||||
if (!pr->free_string_refs) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
pr->dyn_str_size++;
|
||||
pr->dynamic_strings = realloc (pr->dynamic_strings, pr->dyn_str_size);
|
||||
if (!pr->dynamic_strings)
|
||||
|
@ -76,7 +78,7 @@ free_string_ref (progs_t *pr, strref_t *sr)
|
|||
static int
|
||||
string_index (progs_t *pr, strref_t *sr)
|
||||
{
|
||||
int i = sr - pr->static_strings;
|
||||
int i = sr - pr->static_strings;
|
||||
|
||||
if (i >= 0 && i < pr->num_strings)
|
||||
return sr->string - pr->pr_strings;
|
||||
|
@ -91,15 +93,16 @@ string_index (progs_t *pr, strref_t *sr)
|
|||
static const char *
|
||||
strref_get_key (void *_sr, void *notused)
|
||||
{
|
||||
strref_t *sr = (strref_t*)_sr;
|
||||
strref_t *sr = (strref_t*)_sr;
|
||||
|
||||
return sr->string;
|
||||
}
|
||||
|
||||
static void
|
||||
strref_free (void *_sr, void *_pr)
|
||||
{
|
||||
progs_t *pr = (progs_t*)_pr;
|
||||
strref_t *sr = (strref_t*)_sr;
|
||||
progs_t *pr = (progs_t*)_pr;
|
||||
strref_t *sr = (strref_t*)_sr;
|
||||
|
||||
// free the string and ref only if it's not a static string
|
||||
if (sr < pr->static_strings || sr >= pr->static_strings + pr->num_strings) {
|
||||
|
@ -111,9 +114,9 @@ strref_free (void *_sr, void *_pr)
|
|||
void
|
||||
PR_LoadStrings (progs_t *pr)
|
||||
{
|
||||
int count = 0;
|
||||
char *end = pr->pr_strings + pr->pr_stringsize;
|
||||
char *str = pr->pr_strings;
|
||||
char *end = pr->pr_strings + pr->pr_stringsize;
|
||||
char *str = pr->pr_strings;
|
||||
int count = 0;
|
||||
|
||||
while (str < end) {
|
||||
count++;
|
||||
|
@ -122,7 +125,8 @@ PR_LoadStrings (progs_t *pr)
|
|||
if (pr->strref_hash) {
|
||||
Hash_FlushTable (pr->strref_hash);
|
||||
} else {
|
||||
pr->strref_hash = Hash_NewTable (1021, strref_get_key, strref_free, pr);
|
||||
pr->strref_hash = Hash_NewTable (1021, strref_get_key, strref_free,
|
||||
pr);
|
||||
pr->dynamic_strings = 0;
|
||||
pr->free_string_refs = 0;
|
||||
pr->dyn_str_size = 0;
|
||||
|
@ -145,10 +149,10 @@ PR_LoadStrings (progs_t *pr)
|
|||
void
|
||||
PR_GarbageCollect (progs_t *pr)
|
||||
{
|
||||
char *str;
|
||||
int i, j;
|
||||
ddef_t *def;
|
||||
strref_t *sr;
|
||||
ddef_t *def;
|
||||
int i, j;
|
||||
char *str;
|
||||
|
||||
for (i = 0; i < pr->dyn_str_size; i++)
|
||||
for (j = 0; j < 1024; j++)
|
||||
|
@ -192,7 +196,8 @@ char *
|
|||
PR_GetString (progs_t *pr, int num)
|
||||
{
|
||||
if (num < 0) {
|
||||
int row = ~num / 1024;
|
||||
int row = ~num / 1024;
|
||||
|
||||
num = ~num % 1024;
|
||||
|
||||
if (row < 0 || row >= pr->dyn_str_size)
|
||||
|
|
|
@ -46,8 +46,6 @@
|
|||
#include "gib_parse.h"
|
||||
|
||||
|
||||
// Standard cvars
|
||||
|
||||
void
|
||||
GIB_Init (void)
|
||||
{
|
||||
|
@ -60,9 +58,9 @@ GIB_Init (void)
|
|||
void
|
||||
GIB_Gib_f (void)
|
||||
{
|
||||
gib_sub_t *sub;
|
||||
gib_module_t *mod;
|
||||
int i, ret;
|
||||
int i, ret;
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
|
||||
if (!(mod = GIB_Get_ModSub_Mod (Cmd_Argv (1)))) {
|
||||
Con_Printf ("Module not found!\n");
|
||||
|
@ -85,8 +83,8 @@ GIB_Gib_f (void)
|
|||
void
|
||||
GIB_Load_f (void)
|
||||
{
|
||||
char filename[256];
|
||||
VFile *f;
|
||||
char filename[256];
|
||||
VFile *f;
|
||||
|
||||
snprintf (filename, sizeof (filename), "%s/%s.gib", com_gamedir,
|
||||
Cmd_Argv (1));
|
||||
|
|
|
@ -38,8 +38,9 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/cmd.h"
|
||||
|
@ -55,6 +56,7 @@ static gib_inst_t *gibinstructions;
|
|||
|
||||
char *gib_subret;
|
||||
|
||||
|
||||
void
|
||||
GIB_AddInstruction (const char *name, gib_func_t func)
|
||||
{
|
||||
|
@ -91,7 +93,6 @@ GIB_Init_Instructions (void)
|
|||
GIB_AddInstruction ("listfetch", GIB_ListFetch_f);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
GIB_Echo_f (void)
|
||||
{
|
||||
|
@ -102,9 +103,9 @@ GIB_Echo_f (void)
|
|||
int
|
||||
GIB_Call_f (void)
|
||||
{
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
int i, ret;
|
||||
int ret, i;
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
|
||||
mod = GIB_Get_ModSub_Mod (GIB_Argv (1));
|
||||
if (!mod)
|
||||
|
@ -128,8 +129,8 @@ GIB_Call_f (void)
|
|||
int
|
||||
GIB_VarPrint_f (void)
|
||||
{
|
||||
int i;
|
||||
gib_var_t *var;
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= GIB_Argc (); i++) {
|
||||
var = GIB_Var_FindLocal (GIB_Argv (i));
|
||||
|
@ -157,9 +158,9 @@ GIB_Return_f (void)
|
|||
int
|
||||
GIB_ListFetch_f (void)
|
||||
{
|
||||
char *element;
|
||||
char *element;
|
||||
int i, m, n;
|
||||
gib_var_t *var;
|
||||
int i, n, m;
|
||||
|
||||
if (GIB_Argc () != 2)
|
||||
return GIB_E_NUMARGS;
|
||||
|
@ -196,9 +197,8 @@ GIB_Con_f (void)
|
|||
int
|
||||
GIB_ExpandVars (const char *source, char *buffer, int buffersize)
|
||||
{
|
||||
int i, n, m;
|
||||
|
||||
char varname[256];
|
||||
char varname[256];
|
||||
int i, m, n;
|
||||
gib_var_t *var;
|
||||
|
||||
for (i = 0, n = 0; i <= strlen (source); i++) {
|
||||
|
@ -228,9 +228,8 @@ GIB_ExpandVars (const char *source, char *buffer, int buffersize)
|
|||
int
|
||||
GIB_ExpandBackticks (const char *source, char *buffer, int buffersize)
|
||||
{
|
||||
int i, n, m, ret;
|
||||
|
||||
char tick[256];
|
||||
char tick[256];
|
||||
int ret, i, m, n;
|
||||
gib_var_t *var;
|
||||
|
||||
for (i = 0, n = 0; i <= strlen (source); i++) {
|
||||
|
|
|
@ -38,9 +38,10 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "QF/gib.h"
|
||||
|
||||
|
@ -55,6 +56,7 @@
|
|||
const char *gib_subargv[256];
|
||||
int gib_subargc;
|
||||
|
||||
|
||||
const char *
|
||||
GIB_Argv (int i)
|
||||
{
|
||||
|
@ -79,8 +81,8 @@ GIB_Strip_Arg (char *arg)
|
|||
int
|
||||
GIB_Execute_Block (const char *block, int retflag)
|
||||
{
|
||||
int len, i, ret;
|
||||
char *code;
|
||||
char *code;
|
||||
int len, ret, i;
|
||||
|
||||
i = 0;
|
||||
|
||||
|
@ -109,7 +111,7 @@ GIB_Execute_Block (const char *block, int retflag)
|
|||
int
|
||||
GIB_Execute_Inst (void)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ret = gib_instack[gib_insp - 1].instruction->func ();
|
||||
GIB_InStack_Pop ();
|
||||
|
@ -119,14 +121,11 @@ GIB_Execute_Inst (void)
|
|||
int
|
||||
GIB_Interpret_Inst (const char *inst)
|
||||
{
|
||||
char *buffer;
|
||||
char *buffer2;
|
||||
char *buffer3;
|
||||
int i, n, len, ret, gib_argc;
|
||||
char *gib_argv[256];
|
||||
char *buffer, *buffer2, *buffer3;
|
||||
char *gib_argv[256];
|
||||
int gib_argc, len, ret, i, n;
|
||||
gib_inst_t *ginst;
|
||||
|
||||
|
||||
buffer = malloc (strlen (inst) + 1);
|
||||
i = 0;
|
||||
|
||||
|
@ -141,7 +140,6 @@ GIB_Interpret_Inst (const char *inst)
|
|||
n++;
|
||||
}
|
||||
|
||||
|
||||
buffer2 = malloc (2048);
|
||||
buffer3 = malloc (2048);
|
||||
ret = GIB_ExpandVars (buffer, buffer2, 2048);
|
||||
|
@ -192,8 +190,8 @@ GIB_Interpret_Inst (const char *inst)
|
|||
int
|
||||
GIB_Run_Sub (gib_module_t * mod, gib_sub_t * sub)
|
||||
{
|
||||
int ret, i;
|
||||
char buf[256];
|
||||
char buf[256];
|
||||
int ret, i;
|
||||
|
||||
GIB_SubStack_Push (mod, sub, 0);
|
||||
|
||||
|
@ -223,7 +221,7 @@ GIB_Execute_Sub (void)
|
|||
int
|
||||
GIB_Run_Inst (const char *inst)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ret = GIB_Interpret_Inst (inst);
|
||||
if (ret) {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -52,14 +53,14 @@
|
|||
|
||||
static gib_module_t *gibmodules;
|
||||
|
||||
|
||||
void
|
||||
GIB_Module_Load (const char *name, VFile *f)
|
||||
{
|
||||
char line[1024];
|
||||
gib_module_t *newmod;
|
||||
gib_sub_t *newsub;
|
||||
int nameofs;
|
||||
int namelen;
|
||||
char line[1024];
|
||||
int namelen, nameofs;
|
||||
gib_module_t *newmod;
|
||||
gib_sub_t *newsub;
|
||||
|
||||
newmod = GIB_Create_Module (name);
|
||||
|
||||
|
@ -112,10 +113,9 @@ GIB_Create_Sub (gib_module_t * mod, const char *name)
|
|||
void
|
||||
GIB_Read_Sub (gib_sub_t * sub, VFile *f)
|
||||
{
|
||||
char line[1024];
|
||||
fpos_t begin;
|
||||
int sublen = 0;
|
||||
int insub = 0;
|
||||
char line[1024];
|
||||
int insub = 0, sublen = 0;
|
||||
fpos_t begin;
|
||||
|
||||
while (Qgets (f, line, 1024)) {
|
||||
if (strncmp ("}}", line, 2) == 0 && insub == 1) {
|
||||
|
@ -167,10 +167,9 @@ GIB_Find_Sub (gib_module_t * mod, const char *name)
|
|||
void
|
||||
GIB_Stats_f (void)
|
||||
{
|
||||
int modc, subc;
|
||||
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
int modc, subc;
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
|
||||
modc = 0;
|
||||
Con_Printf ("---=== GIB statistics ===---\n");
|
||||
|
|
|
@ -48,8 +48,8 @@
|
|||
int
|
||||
GIB_Get_Inst (const char *start)
|
||||
{
|
||||
int i;
|
||||
int len = 0;
|
||||
int i;
|
||||
int len = 0;
|
||||
|
||||
for (i = 0; start[i] != ';'; i++) {
|
||||
if (start[i] == '\'') {
|
||||
|
@ -78,8 +78,8 @@ GIB_Get_Inst (const char *start)
|
|||
int
|
||||
GIB_Get_Arg (const char *start)
|
||||
{
|
||||
int i;
|
||||
int ret = -2;
|
||||
int i;
|
||||
int ret = -2;
|
||||
|
||||
if (*start == '\'') {
|
||||
ret = GIB_End_Quote (start) + 1;
|
||||
|
@ -96,16 +96,17 @@ GIB_Get_Arg (const char *start)
|
|||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
for (i = 1;
|
||||
(start[i] != ' ' && start[i] != 0 && start[i] != '\''
|
||||
&& start[i] != '\"' && start[i] != '{') || start[i - 1] == '\\'; i++);
|
||||
for (i = 1; (start[i] != ' ' && start[i] != 0 && start[i] != '\'' &&
|
||||
start[i] != '\"' && start[i] != '{') || start[i - 1] == '\\';
|
||||
i++);
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
GIB_End_Quote (const char *start)
|
||||
{
|
||||
int i;
|
||||
int len = 0;
|
||||
int i;
|
||||
int len = 0;
|
||||
|
||||
for (i = 1; start[i] != '\''; i++) {
|
||||
if (start[i - 1] != '\\') {
|
||||
|
@ -115,7 +116,6 @@ GIB_End_Quote (const char *start)
|
|||
else
|
||||
i += len;
|
||||
}
|
||||
|
||||
if (start[i] == '{') {
|
||||
if ((len = GIB_End_Bracket (start + i)) < 0)
|
||||
return len;
|
||||
|
@ -128,10 +128,11 @@ GIB_End_Quote (const char *start)
|
|||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
GIB_End_DQuote (const char *start)
|
||||
{
|
||||
int i, ret;
|
||||
int ret, i;
|
||||
|
||||
for (i = 1; start[i] != '\"'; i++) {
|
||||
if (start[i - 1] != '\\') {
|
||||
|
@ -141,7 +142,6 @@ GIB_End_DQuote (const char *start)
|
|||
else
|
||||
i += ret;
|
||||
}
|
||||
|
||||
if (start[i] == '{') {
|
||||
if ((ret = GIB_End_Bracket (start + i)) < 0)
|
||||
return ret;
|
||||
|
@ -158,7 +158,7 @@ GIB_End_DQuote (const char *start)
|
|||
int
|
||||
GIB_End_Bracket (const char *start)
|
||||
{
|
||||
int i, ret;
|
||||
int ret, i;
|
||||
|
||||
for (i = 1; start[i] != '}'; i++) {
|
||||
if (start[i - 1] != '\\') {
|
||||
|
@ -168,21 +168,18 @@ GIB_End_Bracket (const char *start)
|
|||
else
|
||||
i += ret;
|
||||
}
|
||||
|
||||
if (start[i] == '\"') {
|
||||
if ((ret = GIB_End_DQuote (start + i)) < 0)
|
||||
return ret;
|
||||
else
|
||||
i += ret;
|
||||
}
|
||||
|
||||
if (start[i] == '{') {
|
||||
if ((ret = GIB_End_Bracket (start + i)) < 0)
|
||||
return ret;
|
||||
else
|
||||
i += ret;
|
||||
}
|
||||
|
||||
if (start[i] == 0)
|
||||
return -1;
|
||||
}
|
||||
|
@ -193,9 +190,9 @@ GIB_End_Bracket (const char *start)
|
|||
gib_sub_t *
|
||||
GIB_Get_ModSub_Sub (const char *modsub)
|
||||
{
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
char *divider;
|
||||
char *divider;
|
||||
gib_module_t *mod;
|
||||
gib_sub_t *sub;
|
||||
|
||||
if (!(divider = strstr (modsub, "::")))
|
||||
return 0;
|
||||
|
@ -207,11 +204,12 @@ GIB_Get_ModSub_Sub (const char *modsub)
|
|||
sub = GIB_Find_Sub (mod, divider + 2);
|
||||
return sub;
|
||||
}
|
||||
|
||||
gib_module_t *
|
||||
GIB_Get_ModSub_Mod (const char *modsub)
|
||||
{
|
||||
gib_module_t *mod;
|
||||
char *divider;
|
||||
char *divider;
|
||||
gib_module_t *mod;
|
||||
|
||||
if (!(divider = strstr (modsub, "::")))
|
||||
return 0;
|
||||
|
@ -224,7 +222,7 @@ GIB_Get_ModSub_Mod (const char *modsub)
|
|||
int
|
||||
GIB_ExpandEscapes (char *source)
|
||||
{
|
||||
int i, m;
|
||||
int i, m;
|
||||
|
||||
for (i = 0, m = 0; i <= strlen (source); i++) {
|
||||
if (source[i] == '\\') {
|
||||
|
|
|
@ -50,10 +50,11 @@ gib_substack_t *gib_substack = 0;
|
|||
int gib_insp = 0;
|
||||
int gib_subsp = 0;
|
||||
|
||||
|
||||
void
|
||||
GIB_InStack_Push (gib_inst_t * instruction, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
gib_instack =
|
||||
realloc (gib_instack, sizeof (gib_instack_t) * (gib_insp + 1));
|
||||
|
@ -72,7 +73,7 @@ GIB_InStack_Push (gib_inst_t * instruction, int argc, char **argv)
|
|||
void
|
||||
GIB_InStack_Pop (void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
gib_insp--;
|
||||
|
||||
|
@ -98,5 +99,6 @@ GIB_SubStack_Push (gib_module_t * mod, gib_sub_t * sub, gib_var_t * local)
|
|||
void
|
||||
GIB_SubStack_Pop (void)
|
||||
{
|
||||
gib_instack = realloc (gib_instack, sizeof (gib_instack_t) * (--gib_subsp));
|
||||
gib_instack = realloc (gib_instack, sizeof (gib_instack_t) *
|
||||
(--gib_subsp));
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
#include "gib_stack.h"
|
||||
|
||||
|
||||
gib_var_t *
|
||||
GIB_Var_FindLocal (char *key)
|
||||
{
|
||||
|
@ -56,6 +57,7 @@ GIB_Var_FindLocal (char *key)
|
|||
return 0;
|
||||
return var;
|
||||
}
|
||||
|
||||
gib_var_t *
|
||||
GIB_Var_FindGlobal (char *key)
|
||||
{
|
||||
|
@ -69,7 +71,6 @@ GIB_Var_FindGlobal (char *key)
|
|||
return var;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GIB_Var_Set (char *key, char *value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue