#include "mathlib.h"
#include "cmdlib.h"
Include dependency graph for scriplib.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | MAXTOKEN 1024 |
Functions | |
| qboolean | GetToken (qboolean crossline) |
| void | LoadScriptFile (const char *filename) |
| void | MatchToken (char *match) |
| void | Parse1DMatrix (int x, vec_t *m) |
| void | Parse2DMatrix (int y, int x, vec_t *m) |
| void | Parse3DMatrix (int z, int y, int x, vec_t *m) |
| void | ParseFromMemory (char *buffer, int size) |
| qboolean | TokenAvailable (void) |
| void | UnGetToken (void) |
| void | Write1DMatrix (FILE *f, int x, vec_t *m) |
| void | Write2DMatrix (FILE *f, int y, int x, vec_t *m) |
| void | Write3DMatrix (FILE *f, int z, int y, int x, vec_t *m) |
Variables | |
| qboolean | endofscript |
| int | grabbed |
| char * | script_p |
| char * | scriptbuffer |
| char * | scriptend_p |
| int | scriptline |
| char | token [MAXTOKEN] |
|
|
Definition at line 31 of file scriplib.h. |
|
|
Definition at line 160 of file scriplib.c. 00161 {
00162 char *token_p;
00163
00164 if (tokenready) // is a token allready waiting?
00165 {
00166 tokenready = qfalse;
00167 return qtrue;
00168 }
00169
00170 if (script->script_p >= script->end_p)
00171 return EndOfScript (crossline);
00172
00173 //
00174 // skip space
00175 //
00176 skipspace:
00177 while (*script->script_p <= 32)
00178 {
00179 if (script->script_p >= script->end_p)
00180 return EndOfScript (crossline);
00181 if (*script->script_p++ == '\n')
00182 {
00183 if (!crossline)
00184 Error ("Line %i is incomplete\n",scriptline);
00185 scriptline = script->line++;
00186 }
00187 }
00188
00189 if (script->script_p >= script->end_p)
00190 return EndOfScript (crossline);
00191
00192 // ; # // comments
00193 if (*script->script_p == ';' || *script->script_p == '#'
00194 || ( script->script_p[0] == '/' && script->script_p[1] == '/') )
00195 {
00196 if (!crossline)
00197 Error ("Line %i is incomplete\n",scriptline);
00198 while (*script->script_p++ != '\n')
00199 if (script->script_p >= script->end_p)
00200 return EndOfScript (crossline);
00201 scriptline = script->line++;
00202 goto skipspace;
00203 }
00204
00205 // /* */ comments
00206 if (script->script_p[0] == '/' && script->script_p[1] == '*')
00207 {
00208 if (!crossline)
00209 Error ("Line %i is incomplete\n",scriptline);
00210 script->script_p+=2;
00211 while (script->script_p[0] != '*' && script->script_p[1] != '/')
00212 {
00213 if ( *script->script_p == '\n' ) {
00214 scriptline = script->line++;
00215 }
00216 script->script_p++;
00217 if (script->script_p >= script->end_p)
00218 return EndOfScript (crossline);
00219 }
00220 script->script_p += 2;
00221 goto skipspace;
00222 }
00223
00224 //
00225 // copy token
00226 //
00227 token_p = token;
00228
00229 if (*script->script_p == '"')
00230 {
00231 // quoted token
00232 script->script_p++;
00233 while (*script->script_p != '"')
00234 {
00235 *token_p++ = *script->script_p++;
00236 if (script->script_p == script->end_p)
00237 break;
00238 if (token_p == &token[MAXTOKEN])
00239 Error ("Token too large on line %i\n",scriptline);
00240 }
00241 script->script_p++;
00242 }
00243 else // regular token
00244 while ( *script->script_p > 32 && *script->script_p != ';')
00245 {
00246 *token_p++ = *script->script_p++;
00247 if (script->script_p == script->end_p)
00248 break;
00249 if (token_p == &token[MAXTOKEN])
00250 Error ("Token too large on line %i\n",scriptline);
00251 }
00252
00253 *token_p = 0;
00254
00255 if (!strcmp (token, "$include"))
00256 {
00257 GetToken (qfalse);
00258 AddScriptToStack (token);
00259 return GetToken (crossline);
00260 }
00261
00262 return qtrue;
00263 }
|
|
|
Definition at line 1308 of file l_script.c. References AddScriptToStack(), basefolder, botimport, script_t::buffer, buffer, COM_Compress(), Com_Memset(), Com_sprintf(), script_t::end_p, endofscript, fclose(), fileHandle_t, FileLength(), script_t::filename, fopen(), fp, fread(), FreeMemory(), botlib_import_s::FS_FCloseFile, botlib_import_s::FS_FOpenFile, botlib_import_s::FS_Read, FS_READ, GetClearedMemory(), length(), script_t::line, NULL, script, script_t::script_p, script_t, SetScriptPunctuations(), strcpy(), strlen(), and tokenready. Referenced by LoadMapFile(), LoadShaderInfo(), LoadSourceFile(), ParseShaderFile(), PC_Directive_include(), and Q2_LoadMapFile(). 01309 {
01310 #ifdef BOTLIB
01311 fileHandle_t fp;
01312 char pathname[MAX_QPATH];
01313 #else
01314 FILE *fp;
01315 #endif
01316 int length;
01317 void *buffer;
01318 script_t *script;
01319
01320 #ifdef BOTLIB
01321 if (strlen(basefolder))
01322 Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename);
01323 else
01324 Com_sprintf(pathname, sizeof(pathname), "%s", filename);
01325 length = botimport.FS_FOpenFile( pathname, &fp, FS_READ );
01326 if (!fp) return NULL;
01327 #else
01328 fp = fopen(filename, "rb");
01329 if (!fp) return NULL;
01330
01331 length = FileLength(fp);
01332 #endif
01333
01334 buffer = GetClearedMemory(sizeof(script_t) + length + 1);
01335 script = (script_t *) buffer;
01336 Com_Memset(script, 0, sizeof(script_t));
01337 strcpy(script->filename, filename);
01338 script->buffer = (char *) buffer + sizeof(script_t);
01339 script->buffer[length] = 0;
01340 script->length = length;
01341 //pointer in script buffer
01342 script->script_p = script->buffer;
01343 //pointer in script buffer before reading token
01344 script->lastscript_p = script->buffer;
01345 //pointer to end of script buffer
01346 script->end_p = &script->buffer[length];
01347 //set if there's a token available in script->token
01348 script->tokenavailable = 0;
01349 //
01350 script->line = 1;
01351 script->lastline = 1;
01352 //
01353 SetScriptPunctuations(script, NULL);
01354 //
01355 #ifdef BOTLIB
01356 botimport.FS_Read(script->buffer, length, fp);
01357 botimport.FS_FCloseFile(fp);
01358 #else
01359 if (fread(script->buffer, length, 1, fp) != 1)
01360 {
01361 FreeMemory(buffer);
01362 script = NULL;
01363 } //end if
01364 fclose(fp);
01365 #endif
01366 //
01367 script->length = COM_Compress(script->buffer);
01368
01369 return script;
01370 } //end of the function LoadScriptFile
|
Here is the call graph for this function:

|
|
Definition at line 293 of file scriplib.c. References Error(), GetToken(), match(), qtrue, scriptline, strcmp(), and token. Referenced by Parse1DMatrix(), Parse2DMatrix(), Parse3DMatrix(), ParsePatch(), ParseRawBrush(), ParseShaderFile(), and ParseTerrain(). 00293 {
00294 GetToken( qtrue );
00295
00296 if ( strcmp( token, match ) ) {
00297 Error( "MatchToken( \"%s\" ) failed at line %i", match, scriptline );
00298 }
00299 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 302 of file scriplib.c. References atof(), GetToken(), i, m, MatchToken(), qfalse, and token. 00302 {
00303 int i;
00304
00305 MatchToken( "(" );
00306
00307 for (i = 0 ; i < x ; i++) {
00308 GetToken( qfalse );
00309 m[i] = atof(token);
00310 }
00311
00312 MatchToken( ")" );
00313 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 315 of file scriplib.c. References i, m, MatchToken(), Parse1DMatrix(), and x. 00315 {
00316 int i;
00317
00318 MatchToken( "(" );
00319
00320 for (i = 0 ; i < y ; i++) {
00321 Parse1DMatrix (x, m + i * x);
00322 }
00323
00324 MatchToken( ")" );
00325 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 327 of file scriplib.c. References i, m, MatchToken(), Parse2DMatrix(), x, and y. 00327 {
00328 int i;
00329
00330 MatchToken( "(" );
00331
00332 for (i = 0 ; i < z ; i++) {
00333 Parse2DMatrix (y, x, m + i * x*y);
00334 }
00335
00336 MatchToken( ")" );
00337 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 94 of file scriplib.c. References script_t::buffer, script_t::end_p, endofscript, Error(), script_t::filename, script_t::line, script, script_t::script_p, scriptstack, strcpy(), and tokenready. Referenced by ParseEntities(). 00095 {
00096 script = scriptstack;
00097 script++;
00098 if (script == &scriptstack[MAX_INCLUDES])
00099 Error ("script file exceeded MAX_INCLUDES");
00100 strcpy (script->filename, "memory buffer" );
00101
00102 script->buffer = buffer;
00103 script->line = 1;
00104 script->script_p = script->buffer;
00105 script->end_p = script->buffer + size;
00106
00107 endofscript = qfalse;
00108 tokenready = qfalse;
00109 }
|
Here is the call graph for this function:

|
|
Definition at line 273 of file scriplib.c. 00273 {
00274 int oldLine;
00275 qboolean r;
00276
00277 oldLine = script->line;
00278 r = GetToken( qtrue );
00279 if ( !r ) {
00280 return qfalse;
00281 }
00282 UnGetToken();
00283 if ( oldLine == script->line ) {
00284 return qtrue;
00285 }
00286 return qfalse;
00287 }
|
|
|
Definition at line 126 of file scriplib.c. References tokenready. Referenced by ParseMapEntity(), ParsePatch(), ParseRawBrush(), and TokenAvailable(). 00127 {
00128 tokenready = qtrue;
00129 }
|
|
||||||||||||||||
|
Definition at line 340 of file scriplib.c. References f, fprintf(), i, and m. Referenced by Write2DMatrix(). 00340 {
00341 int i;
00342
00343 fprintf (f, "( ");
00344 for (i = 0 ; i < x ; i++) {
00345 if (m[i] == (int)m[i] ) {
00346 fprintf (f, "%i ", (int)m[i]);
00347 } else {
00348 fprintf (f, "%f ", m[i]);
00349 }
00350 }
00351 fprintf (f, ")");
00352 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 354 of file scriplib.c. References f, fprintf(), i, m, Write1DMatrix(), and x. Referenced by Write3DMatrix(). 00354 {
00355 int i;
00356
00357 fprintf (f, "( ");
00358 for (i = 0 ; i < y ; i++) {
00359 Write1DMatrix (f, x, m + i*x);
00360 fprintf (f, " ");
00361 }
00362 fprintf (f, ")\n");
00363 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 366 of file scriplib.c. References f, fprintf(), i, m, Write2DMatrix(), x, and y. 00366 {
00367 int i;
00368
00369 fprintf (f, "(\n");
00370 for (i = 0 ; i < z ; i++) {
00371 Write2DMatrix (f, y, x, m + i*(x*y) );
00372 }
00373 fprintf (f, ")\n");
00374 }
|
Here is the call graph for this function:

|
|
Definition at line 48 of file scriplib.c. Referenced by EndOfScript(), LoadScriptFile(), and ParseFromMemory(). |
|
|
|
|
|
Definition at line 27 of file PARSE.CPP. Referenced by GetToken(), and StartTokenParsing(). |
|
|
|
|
|
|
|
|
Definition at line 45 of file scriplib.c. |
|
|
Definition at line 47 of file scriplib.c. |
1.3.9.1