]> icculus.org git repositories - btb/d2x.git/blob - main/editor/func.c
even ifndef NETWORK do last level hack only on last level of built-in mission
[btb/d2x.git] / main / editor / func.c
1 /* $Id: func.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * .
18  *
19  */
20
21 #ifdef RCS
22 static char rcsid[] = "$Id: func.c,v 1.3 2004-12-19 15:21:11 btb Exp $";
23 #endif
24
25 #ifdef HAVE_CONFIG_H
26 #include "conf.h"
27 #endif
28
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include "func.h"
33
34 #define MAX_PARAMS 10
35
36 static FUNCTION * func_table = NULL;
37 static int func_size = 0;
38 static int initialized = 0;
39 static int func_params[MAX_PARAMS];
40
41 int func_howmany()
42 {
43         return func_size;
44 }
45
46 void func_init( FUNCTION * funtable, int size )
47 {
48         if (!initialized)
49         {
50                 initialized = 1;
51                 func_table = funtable;
52                 func_size = size;
53                 atexit( func_close );
54         }
55 }
56
57
58 void func_close()
59 {
60         if (initialized)
61         {
62                 initialized = 0;
63                 func_table = NULL;
64                 func_size = 0;
65         }
66 }
67
68 int (*func_get( char * name, int * numparams ))(void)
69 {
70         int i;
71
72         for (i=0; i<func_size; i++ )
73                 if (!stricmp( name, func_table[i].name ))
74                 {
75                         *numparams = func_table[i].nparams;
76                         return func_table[i].cfunction;
77                 }
78
79         return NULL;
80 }
81
82 int func_get_index( char * name )
83 {
84         int i;
85
86         for (i=0; i<func_size; i++ )
87                 if (!stricmp( name, func_table[i].name ))
88                 {
89                         return i;
90                 }
91
92         return -1;
93 }
94
95
96 int (*func_nget( int func_number, int * numparams, char **name ))(void)
97 {
98         if (func_number < func_size )
99         {
100                 *name = func_table[func_number].name;
101                 *numparams = func_table[func_number].nparams;
102                 return func_table[func_number].cfunction;
103         }
104
105         return NULL;
106 }
107
108 void func_set_param( int n, int value )
109 {
110         func_params[n] = value;
111 }
112
113 int func_get_param( int n )
114 {
115         return func_params[n];
116 }
117
118