1 // Emacs style mode select -*- C++ -*- 2 //---------------------------------------------------------------------------- 3 // 4 // $Id: t_vari.h 1368 2017-11-01 01:17:48Z wesleyjohnson $ 5 // 6 // Copyright(C) 2000 Simon Howard 7 // Copyright (C) 2001-2011 by DooM Legacy Team. 8 // 9 // This program is free software; you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation; either version 2 of the License, or 12 // (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with this program; if not, write to the Free Software 21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 // 23 // $Log: t_vari.h,v $ 24 // Revision 1.3 2004/07/27 08:19:37 exl 25 // New fmod, fs functions, bugfix or 2, patrol nodes 26 // 27 // Revision 1.2 2003/05/30 22:44:07 hurdler 28 // add checkcvar function to FS 29 // 30 // Revision 1.1 2000/11/02 17:57:28 stroggonmeth 31 // FraggleScript files... 32 // 33 // 34 //-------------------------------------------------------------------------- 35 36 37 #ifndef T_VARIABLE_H 38 #define T_VARIABLE_H 39 40 #include "t_parse.h" 41 // m_fixed.h, p_mobj.h 42 43 // hash the variables for speed: this is the hashkey 44 45 #define variable_hash(n) \ 46 ( ( (n)[0] + (n)[1] + \ 47 ((n)[1] ? (n)[2] + \ 48 ((n)[2] ? (n)[3] : 0) : 0) ) % VARIABLESLOTS ) 49 50 // fs_variable_t 51 struct fs_variable_s 52 { 53 char *name; 54 int type; // vt_string or vt_int: same as in fs_value_t 55 union 56 { 57 int32_t i; 58 fixed_t fixed; 59 char *s; 60 mobj_t *mobj; 61 fs_array_t *a; // arrays 62 63 char **pS; // pointer to game string 64 int *pI; // pointer to game int 65 fixed_t *pFixed; 66 mobj_t **pMobj; // pointer to game obj 67 double *pf; 68 fs_array_t **pA; // arrays 69 70 void (*handler)(); // for functions 71 char *labelptr; // for labels 72 } value; 73 fs_variable_t *next; // for hashing 74 }; 75 76 // variable types 77 78 enum 79 { 80 FSVT_string, 81 FSVT_int, 82 FSVT_fixed, 83 FSVT_mobj, // a map object 84 FSVT_function, // functions are stored as variables 85 FSVT_label, // labels for goto calls are variables 86 FSVT_const, // const 87 FSVT_array, // array 88 FSVT_pInt, // pointer to game int 89 FSVT_pFixed, 90 FSVT_pString, // pointer to game string 91 FSVT_pMobj, // pointer to game mobj 92 FSVT_pArray, // haleyjd: 05/27: pointer to game array 93 }; 94 95 // variables 96 97 void T_Clear_HubScript(); 98 99 void T_Init_variables(); 100 fs_variable_t * new_variable(script_t *script, const char *name, int vtype); 101 fs_variable_t * find_variable(const char *name); 102 fs_variable_t * variable_for_name(script_t *script, const char *name); 103 fs_value_t getvariablevalue(fs_variable_t *v); 104 void setvariablevalue(fs_variable_t *v, fs_value_t newvalue); 105 void clear_variables(script_t *script); 106 107 fs_variable_t * add_game_int(const char *name, int *var); 108 fs_variable_t * add_game_string(const char *name, char **var); 109 fs_variable_t * add_game_mobj(const char *name, mobj_t **mo); 110 111 // functions 112 113 fs_value_t evaluate_function(int start, int stop); // actually run a function 114 fs_variable_t * new_function(const char *name, void (*handler)() ); 115 116 // arguments to handler functions 117 118 #define MAXARGS 128 119 extern int t_argc; 120 extern fs_value_t * t_argv; 121 extern fs_value_t t_return; 122 123 #endif 124