Atrinik Server  4.0
Data Structures | Macros | Typedefs | Functions | Variables
object.c File Reference
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <global.h>
#include <loader.h>
#include <arch.h>
#include <artifact.h>
#include <toolkit/string.h>
#include <object.h>
#include <object_methods.h>
#include <sound_ambient.h>
#include <unistd.h>

Go to the source code of this file.

Data Structures

struct  yy_buffer_state
 
struct  yy_trans_info
 

Macros

#define YY_INT_ALIGNED   long int
 
#define yy_create_buffer   yy_object_create_buffer
 
#define yy_delete_buffer   yy_object_delete_buffer
 
#define yy_flex_debug   yy_object_flex_debug
 
#define yy_init_buffer   yy_object_init_buffer
 
#define yy_flush_buffer   yy_object_flush_buffer
 
#define yy_load_buffer_state   yy_object_load_buffer_state
 
#define yy_switch_to_buffer   yy_object_switch_to_buffer
 
#define yyin   yy_objectin
 
#define yyleng   yy_objectleng
 
#define yylex   yy_objectlex
 
#define yylineno   yy_objectlineno
 
#define yyout   yy_objectout
 
#define yyrestart   yy_objectrestart
 
#define yytext   yy_objecttext
 
#define yywrap   yy_objectwrap
 
#define yyalloc   yy_objectalloc
 
#define yyrealloc   yy_objectrealloc
 
#define yyfree   yy_objectfree
 
#define FLEX_SCANNER
 
#define YY_FLEX_MAJOR_VERSION   2
 
#define YY_FLEX_MINOR_VERSION   5
 
#define YY_FLEX_SUBMINOR_VERSION   35
 
#define FLEX_BETA
 
#define FLEXINT_H
 
#define INT8_MIN   (-128)
 
#define INT16_MIN   (-32767-1)
 
#define INT32_MIN   (-2147483647-1)
 
#define INT8_MAX   (127)
 
#define INT16_MAX   (32767)
 
#define INT32_MAX   (2147483647)
 
#define UINT8_MAX   (255U)
 
#define UINT16_MAX   (65535U)
 
#define UINT32_MAX   (4294967295U)
 
#define yyconst
 
#define YY_NULL   0
 
#define YY_SC_TO_UI(c)   ((unsigned int) (unsigned char) c)
 
#define BEGIN   (yy_start) = 1 + 2 *
 
#define YY_START   (((yy_start) - 1) / 2)
 
#define YYSTATE   YY_START
 
#define YY_STATE_EOF(state)   (YY_END_OF_BUFFER + state + 1)
 
#define YY_NEW_FILE   yy_objectrestart(yy_objectin )
 
#define YY_END_OF_BUFFER_CHAR   0
 
#define YY_BUF_SIZE   16384
 
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
 
#define YY_TYPEDEF_YY_BUFFER_STATE
 
#define EOB_ACT_CONTINUE_SCAN   0
 
#define EOB_ACT_END_OF_FILE   1
 
#define EOB_ACT_LAST_MATCH   2
 
#define YY_LESS_LINENO(n)
 
#define yyless(n)
 
#define unput(c)   yyunput( c, (yytext_ptr) )
 
#define YY_TYPEDEF_YY_SIZE_T
 
#define YY_STRUCT_YY_BUFFER_STATE
 
#define YY_BUFFER_NEW   0
 
#define YY_BUFFER_NORMAL   1
 
#define YY_BUFFER_EOF_PENDING   2
 
#define YY_CURRENT_BUFFER
 
#define YY_CURRENT_BUFFER_LVALUE   (yy_buffer_stack)[(yy_buffer_stack_top)]
 
#define YY_FLUSH_BUFFER   yy_object_flush_buffer(YY_CURRENT_BUFFER )
 
#define yy_new_buffer   yy_object_create_buffer
 
#define yy_set_interactive(is_interactive)
 
#define yy_set_bol(at_bol)
 
#define YY_AT_BOL()   (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
 
#define yy_objectwrap(n)   1
 
#define YY_SKIP_YYWRAP
 
#define yytext_ptr   yy_objecttext
 
#define YY_DO_BEFORE_ACTION
 
#define YY_NUM_RULES   290
 
#define YY_END_OF_BUFFER   291
 
#define REJECT   reject_used_but_not_detected
 
#define yymore()   yymore_used_but_not_detected
 
#define YY_MORE_ADJ   0
 
#define YY_RESTORE_YY_MORE_OFFSET
 
#define YY_DECL
 
#define MAXDEPTH   10
 
#define SET_ATTACK(op, type, val)   op->attack[type] = val;
 
#define SET_PROTECTION(op, type, val)   op->protection[type] = val;
 
#define IVAL   atoi(yval())
 
#define FVAL   atof(yval())
 
#define YY_NO_INPUT
 
#define INITIAL   0
 
#define MESSAGE   1
 
#define YY_EXTRA_TYPE   void *
 
#define YY_READ_BUF_SIZE   8192
 
#define ECHO   do { if (fwrite( yy_objecttext, yy_objectleng, 1, yy_objectout )) {} } while (0)
 
#define YY_INPUT(buf, result, max_size)
 
#define yyterminate()   return YY_NULL
 
#define YY_START_STACK_INCR   25
 
#define YY_FATAL_ERROR(msg)   yy_fatal_error( msg )
 
#define YY_USER_ACTION
 
#define YY_BREAK   break;
 
#define YY_RULE_SETUP
 
#define YY_EXIT_FAILURE   2
 
#define yyless(n)
 
#define YYTABLES_NAME   "yytables"
 
#define SAVE_VALUE(_sb, _name, _value, _fmt)
 
#define SAVE_STRING(_sb, _name, _value)   SAVE_VALUE(_sb, _name, _value, "%s")
 
#define SAVE_DOUBLE(_sb, _name, _value)   SAVE_VALUE(_sb, _name, _value, "%f")
 
#define SAVE_INT(_sb, _name, _value)   SAVE_VALUE(_sb, _name, _value, "%d")
 
#define SAVE_UINT(_sb, _name, _value)   SAVE_VALUE(_sb, _name, _value, "%u")
 
#define SAVE_INT64(_sb, _name, _value)   SAVE_VALUE(_sb, _name, _value, "%" PRId64)
 
#define SAVE_UINT64(_sb, _name, _value)   SAVE_VALUE(_sb, _name, _value, "%" PRIu64)
 

Typedefs

typedef signed char flex_int8_t
 
typedef short int flex_int16_t
 
typedef int flex_int32_t
 
typedef unsigned char flex_uint8_t
 
typedef unsigned short int flex_uint16_t
 
typedef unsigned int flex_uint32_t
 
typedef struct yy_buffer_stateYY_BUFFER_STATE
 
typedef size_t yy_size_t
 
typedef char YY_CHAR
 
typedef int yy_state_type
 

Functions

void yy_objectrestart (FILE *input_file)
 
void yy_object_switch_to_buffer (YY_BUFFER_STATE new_buffer)
 
YY_BUFFER_STATE yy_object_create_buffer (FILE *file, int size)
 
void yy_object_delete_buffer (YY_BUFFER_STATE b)
 
void yy_object_flush_buffer (YY_BUFFER_STATE b)
 
void yy_objectpush_buffer_state (YY_BUFFER_STATE new_buffer)
 
void yy_objectpop_buffer_state (void)
 
static void yy_objectensure_buffer_stack (void)
 
static void yy_object_load_buffer_state (void)
 
static void yy_object_init_buffer (YY_BUFFER_STATE b, FILE *file)
 
YY_BUFFER_STATE yy_object_scan_buffer (char *base, yy_size_t size)
 
YY_BUFFER_STATE yy_object_scan_string (yyconst char *yy_str)
 
YY_BUFFER_STATE yy_object_scan_bytes (yyconst char *bytes, int len)
 
void * yy_objectalloc (yy_size_t)
 
void * yy_objectrealloc (void *, yy_size_t)
 
void yy_objectfree (void *)
 
static yy_state_type yy_get_previous_state (void)
 
static yy_state_type yy_try_NUL_trans (yy_state_type current_state)
 
static int yy_get_next_buffer (void)
 
static void yy_fatal_error (yyconst char msg[])
 
static const char * yval (void)
 
static void add_key_value (object *op)
 
static int yy_init_globals (void)
 
int yy_objectlex_destroy (void)
 
int yy_objectget_debug (void)
 
void yy_objectset_debug (int debug_flag)
 
YY_EXTRA_TYPE yy_objectget_extra (void)
 
void yy_objectset_extra (YY_EXTRA_TYPE user_defined)
 
FILE * yy_objectget_in (void)
 
void yy_objectset_in (FILE *in_str)
 
FILE * yy_objectget_out (void)
 
void yy_objectset_out (FILE *out_str)
 
int yy_objectget_leng (void)
 
char * yy_objectget_text (void)
 
int yy_objectget_lineno (void)
 
void yy_objectset_lineno (int line_number)
 
static void yy_push_state (int new_state)
 
static void yy_pop_state (void)
 
 if (!(yy_init))
 
 while (1)
 
int isatty (int)
 
static void yy_fatal_error (yyconst char *msg)
 
void free_object_loader (void)
 
void delete_loader_buffer (void *buffer)
 
void * create_loader_buffer (FILE *fp)
 
static void load_object_begin (object *op, object **items)
 
static void load_object_finish (object *op, int map_flags)
 
int load_object (const char *str, object *op, int map_flags)
 
int load_object_fp (FILE *fp, object *op, int map_flags)
 
int load_object_buffer (void *buffer, object *op, int map_flags)
 
int set_variable (object *op, const char *buf)
 
void get_ob_diff (StringBuffer *sb, const object *op, const object *op2)
 

Variables

int yy_objectleng
 
FILE * yy_objectin = (FILE *) 0
 
FILE * yy_objectout = (FILE *) 0
 
static size_t yy_buffer_stack_top = 0
 
static size_t yy_buffer_stack_max = 0
 
static YY_BUFFER_STATEyy_buffer_stack = 0
 
static char yy_hold_char
 
static int yy_n_chars
 
static char * yy_c_buf_p = (char *) 0
 
static int yy_init = 0
 
static int yy_start = 0
 
static int yy_did_buffer_switch_on_eof
 
int yy_objectlineno = 1
 
char * yy_objecttext
 
static yyconst flex_int32_t yy_nxt [][128]
 
static yyconst flex_int32_t yy_accept [2558]
 
static yy_state_type yy_last_accepting_state
 
static char * yy_last_accepting_cpos
 
static yyconst yy_state_type yy_NUL_trans [2558]
 
int yy_object_flex_debug = 0
 
static void * cur_buffer
 
static int lex_error = 0
 
static char msgbuf [HUGE_BUF *4]
 
static size_t msgbuf_len
 
static artifact_tart_amask
 
static int yy_start_stack_ptr = 0
 
static int yy_start_stack_depth = 0
 
static int * yy_start_stack = NULL
 
 YY_DECL
 
register char * yy_cp
 
register char * yy_bp
 
register int yy_act
 
int ismore = 0
 
objectop = items[*depth]
 

Detailed Description

C file generated by GNU Flex from loader.l, it handles object loading related code.

Definition in file object.c.

Macro Definition Documentation

#define FVAL   atof(yval())

Next value as float.

Definition at line 45308 of file object.c.

#define IVAL   atoi(yval())

Next value as integer.

Definition at line 45306 of file object.c.

#define SAVE_DOUBLE (   _sb,
  _name,
  _value 
)    SAVE_VALUE(_sb, _name, _value, "%f")

Save a double to the specified StringBuffer instance.

Definition at line 48698 of file object.c.

#define SAVE_INT (   _sb,
  _name,
  _value 
)    SAVE_VALUE(_sb, _name, _value, "%d")

Save an int to the specified StringBuffer instance.

Definition at line 48702 of file object.c.

#define SAVE_INT64 (   _sb,
  _name,
  _value 
)    SAVE_VALUE(_sb, _name, _value, "%" PRId64)

Save a 64-bit int to the specified StringBuffer instance.

Definition at line 48710 of file object.c.

#define SAVE_STRING (   _sb,
  _name,
  _value 
)    SAVE_VALUE(_sb, _name, _value, "%s")

Save a string to the specified StringBuffer instance.

Definition at line 48694 of file object.c.

#define SAVE_UINT (   _sb,
  _name,
  _value 
)    SAVE_VALUE(_sb, _name, _value, "%u")

Save an unsigned int to the specified StringBuffer instance.

Definition at line 48706 of file object.c.

#define SAVE_UINT64 (   _sb,
  _name,
  _value 
)    SAVE_VALUE(_sb, _name, _value, "%" PRIu64)

Save an unsigned 64-bit int to the specified StringBuffer instance.

Definition at line 48715 of file object.c.

#define SAVE_VALUE (   _sb,
  _name,
  _value,
  _fmt 
)
Value:
do { \
stringbuffer_append_printf((_sb), "%s " _fmt "\n", (_name), (_value)); \
} while (0)

Generic value saver.

Definition at line 48687 of file object.c.

#define YY_CURRENT_BUFFER
Value:
: NULL)
static YY_BUFFER_STATE * yy_buffer_stack
Definition: object.c:283
static size_t yy_buffer_stack_top
Definition: object.c:281

Definition at line 291 of file object.c.

#define YY_DECL
Value:
static int \
lex_load (int *depth, \
object **items, \
int maxdepth, \
int map_flags, \
int linemode)

Definition at line 45284 of file object.c.

#define YY_DO_BEFORE_ACTION
Value:
(yytext_ptr) = yy_bp; \
yy_objectleng = (size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;

Definition at line 44643 of file object.c.

#define YY_INPUT (   buf,
  result,
  max_size 
)
Value:
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yy_objectin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
if ( c == EOF && ferror( yy_objectin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
while ( (result = fread(buf, 1, max_size, yy_objectin))==0 && ferror(yy_objectin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yy_objectin); \
} \
}\
\

Definition at line 45496 of file object.c.

#define YY_RULE_SETUP
Value:
if ( yy_objectleng > 0 ) \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
(yy_objecttext[yy_objectleng - 1] == '\n'); \
YY_USER_ACTION

Definition at line 45571 of file object.c.

#define yy_set_bol (   at_bol)
Value:
{ \
if ( ! YY_CURRENT_BUFFER ){\
yy_objectensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_object_create_buffer(yy_objectin,YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
YY_BUFFER_STATE yy_object_create_buffer(FILE *file, int size)
Definition: object.c:47851

Definition at line 349 of file object.c.

#define yy_set_interactive (   is_interactive)
Value:
{ \
if ( ! YY_CURRENT_BUFFER ){ \
yy_objectensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_object_create_buffer(yy_objectin,YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
YY_BUFFER_STATE yy_object_create_buffer(FILE *file, int size)
Definition: object.c:47851

Definition at line 339 of file object.c.

#define yyless (   n)
Value:
do \
{ \
/* Undo effects of setting up yy_objecttext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yy_objecttext again */ \
} \
while ( 0 )

Definition at line 48182 of file object.c.

#define yyless (   n)
Value:
do \
{ \
/* Undo effects of setting up yy_objecttext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yy_objecttext[yy_objectleng] = (yy_hold_char); \
(yy_c_buf_p) = yy_objecttext + yyless_macro_arg; \
(yy_hold_char) = *(yy_c_buf_p); \
*(yy_c_buf_p) = '\0'; \
yy_objectleng = yyless_macro_arg; \
} \
while ( 0 )

Definition at line 48182 of file object.c.

Function Documentation

static void add_key_value ( object op)
static

This extracts the key/value from the yy_objecttext field - calls object_set_value() to actually set the value.

Function basically has to find spaces, strip out extra, etc. strchr() doesn't work as good because could also be tabs.

Parameters
opObject in which to insert the value.

Definition at line 45321 of file object.c.

void free_object_loader ( void  )

Frees all memory allocated by the object loader.

Definition at line 48436 of file object.c.

void get_ob_diff ( StringBuffer *  sb,
const object op,
const object op2 
)

Get difference between two objects, and save it in a StringBuffer instance.

This function is typically used to dump objects (op2 = empty object), or to save objects (op2 is the objects original archetype).

Parameters
sbString buffer to modify.
opWhat object the different values will be taken from.
op2Object's original archetype.

Definition at line 48732 of file object.c.

int load_object ( const char *  str,
object op,
int  map_flags 
)

Loads an object from the given string.

Variables will be read, parsed and patched into the object until the string "end" is reached, or the end of the string.

Parameters
strString to load from.
opObject to load into.
map_flagsLoad flags.
Returns
One of Lexical loader return codes.

Definition at line 48527 of file object.c.

static void load_object_begin ( object op,
object **  items 
)
static

Begin loading an object; sets up the necessary state variables.

Parameters
opObject that is to be loaded.
itemsObjects array.

Definition at line 48475 of file object.c.

int load_object_buffer ( void *  buffer,
object op,
int  map_flags 
)

Loads an object from the given flex buffer.

Variables will be read, parsed and patched into the object until the string "end" is reached, or the end of the file.

Parameters
bufferBuffer to load from.
opObject to load into.
map_flagsLoad flags.
Returns
One of Lexical loader return codes.

Definition at line 48633 of file object.c.

static void load_object_finish ( object op,
int  map_flags 
)
static

Finish loading an object.

Parameters
opObject that is to be loaded.
map_flagsLoad flags.

Definition at line 48492 of file object.c.

int load_object_fp ( FILE *  fp,
object op,
int  map_flags 
)

Loads an object from the given file pointer.

Variables will be read, parsed and patched into the object until the string "end" is reached, or the end of the file.

Parameters
fpFile to load from.
opObject to load into.
map_flagsLoad flags.
Returns
One of Lexical loader return codes.

Definition at line 48576 of file object.c.

int set_variable ( object op,
const char *  buf 
)

This takes a buffer, scans it for variables, and sets those variables as appropriate in op.

Parameters
opObject to alter.
bufModifications to apply.

Definition at line 48663 of file object.c.

static const char * yval ( void  )
static

Returns the next token for lex.

Our save file syntax is very simple, so we can use a very simple processing mechanism here instead using something like bison.

This skips over the space and returns the value, or "" if no value is found.

Definition at line 48398 of file object.c.

YY_BUFFER_STATE yy_object_create_buffer ( FILE *  file,
int  size 
)

Allocate and initialize an input buffer state.

Parameters
fileA readable stream.
sizeThe character buffer size in bytes. When in doubt, use YY_BUF_SIZE.
Returns
the allocated buffer state.

Definition at line 47851 of file object.c.

void yy_object_delete_buffer ( YY_BUFFER_STATE  b)

Destroy the buffer.

Parameters
ba buffer created with yy_object_create_buffer()

Definition at line 47879 of file object.c.

void yy_object_flush_buffer ( YY_BUFFER_STATE  b)

Discard all buffered characters. On the next scan, YY_INPUT will be called.

Parameters
bthe buffer state to be flushed, usually YY_CURRENT_BUFFER.

Definition at line 47930 of file object.c.

YY_BUFFER_STATE yy_object_scan_buffer ( char *  base,
yy_size_t  size 
)

Setup the input buffer state to scan directly from a user-specified character buffer.

Parameters
basethe character buffer
sizethe size in bytes of the character buffer
Returns
the newly allocated buffer state object.

Definition at line 48057 of file object.c.

YY_BUFFER_STATE yy_object_scan_bytes ( yyconst char *  yybytes,
int  _yybytes_len 
)

Setup the input buffer state to scan the given bytes. The next call to yy_objectlex() will scan from a copy of bytes.

Parameters
yybytesthe byte buffer to scan
_yybytes_lenthe number of bytes in the buffer pointed to by bytes.
Returns
the newly allocated buffer state object.

Definition at line 48107 of file object.c.

YY_BUFFER_STATE yy_object_scan_string ( yyconst char *  yystr)

Setup the input buffer state to scan a string. The next call to yy_objectlex() will scan from a copy of str.

Parameters
yystra NUL-terminated string to scan
Returns
the newly allocated buffer state object.
Note
If you want to scan bytes that may contain NUL values, then use yy_object_scan_bytes() instead.

Definition at line 48094 of file object.c.

void yy_object_switch_to_buffer ( YY_BUFFER_STATE  new_buffer)

Switch to a different input buffer.

Parameters
new_bufferThe new input buffer.

Definition at line 47806 of file object.c.

FILE * yy_objectget_in ( void  )

Get the input stream.

Definition at line 48210 of file object.c.

int yy_objectget_leng ( void  )

Get the length of the current token.

Definition at line 48226 of file object.c.

int yy_objectget_lineno ( void  )

Get the current line number.

Definition at line 48201 of file object.c.

FILE * yy_objectget_out ( void  )

Get the output stream.

Definition at line 48218 of file object.c.

char * yy_objectget_text ( void  )

Get the current token.

Definition at line 48235 of file object.c.

void yy_objectpop_buffer_state ( void  )

Removes and deletes the top of the stack, if present. The next element becomes the new top.

Definition at line 47989 of file object.c.

void yy_objectpush_buffer_state ( YY_BUFFER_STATE  new_buffer)

Pushes the new state onto the stack. The new state becomes the current state. This function will allocate the stack if necessary.

Parameters
new_bufferThe new state.

Definition at line 47959 of file object.c.

void yy_objectrestart ( FILE *  input_file)

Immediately switch to a different input stream.

Parameters
input_fileA readable stream.
Note
This function does not reset the start condition to INITIAL .

Definition at line 47789 of file object.c.

void yy_objectset_in ( FILE *  in_str)

Set the input stream. This does not discard the current input buffer.

Parameters
in_strA readable stream.
See Also
yy_object_switch_to_buffer

Definition at line 48256 of file object.c.

void yy_objectset_lineno ( int  line_number)

Set the current line number.

Parameters
line_number

Definition at line 48244 of file object.c.

Variable Documentation

YY_BUFFER_STATE* yy_buffer_stack = 0
static

Stack as an array.

Definition at line 283 of file object.c.

size_t yy_buffer_stack_max = 0
static

capacity of stack.

Definition at line 282 of file object.c.

size_t yy_buffer_stack_top = 0
static

index of top of stack.

Definition at line 281 of file object.c.

YY_DECL
Initial value:
{
register yy_state_type yy_current_state

The main scanner function which does all the work.

Definition at line 45580 of file object.c.