]> git.pond.sub.org Git - empserver/blob - doc/econfig
Rewrite top-level README for new build process. Merge information
[empserver] / doc / econfig
1 This is a short note on the empire configuration stuff. Some of this
2 is for deities to enable them to configure things, some of it is for
3 coders to see how this stuff works.
4
5 Julian Onions <j.onions@nexor.co.uk>  15/7/95
6
7 -- 
8 Also, the Empire config files are now self-documenting (to a point.)
9 Each option/variable now has a comment associated with it to hopefully
10 make life easier on deities wanting to change things.
11
12 -- Steve McClure, 10/21/1998
13 --
14
15 Deity Notes
16 -----------
17
18 To find out the current configuration, the simplest method is to
19 compile up util/pconfig and the run it. It can be run either with no
20 arguments, in which case it will print in config format the current
21 compiled in options. Otherwise with a file containing a configuration
22 it will first read in this file, and override any compiled in
23 variables and then print the merged options. 
24
25 So the first method shows you what's compiled in, the 2nd how a config
26 file would modify this.
27
28 Blank lines are ignored, as are lines starting with a # character.
29
30 Most of the options are straight forward, they take either a string
31 (quote using " to get spaces in it) or a number - integer or floating
32 point depending on the option. 
33
34 For instance
35   privname "The Deity"
36 sets the internal privname variable to that string, and 
37   port "7777" 
38 sets the empire port to 7777.
39   btu_build_rate 0.0004 
40 sets the internal floating point number for btu building rate,
41 and so on.
42
43 The only other type of variable currently defined are the
44 options. These may be specified as one or more lines starting
45 "option" and turned off with the keyword "nooption".
46
47 So, for instance
48
49     option FUEL ORBIT
50 and 
51     option FUEL
52     option ORBIT
53
54 are equivalent
55
56 To turn off an option that is compiled in, you can similarly have
57
58     nooption FUEL
59     nooption ORBIT
60 or
61     nooption FUEL ORBIT
62
63 The server can take a -e config file as a command line option so that
64 it will read a specific config file. If not, it will default to
65 looking for a file econfig in the built in data directory, but it
66 won't mind if one is absent. Similarly, util/files and util/fairland
67 et al all take a -e config file to run from a different config.
68 Thus, to start two games on the same host, you might have
69
70 Game1:
71 files -e econfig1
72 fairland -e econfig1
73 emp_server -e econfig1
74
75 Game2:
76 files -e econfig2
77 fairland -e econfig2
78 emp_server -e econfig2
79
80 econfig1 might have the lines
81
82 data "/empire/data1"
83 info "/empire/info.nr"
84 port "7777"
85
86 and econfig2 might have the lines
87
88 data "/empire/data2"
89 info "/empire/info.nr"
90 port "7778"
91
92 You only need the lines in that file that you require to override the
93 compiled in definitions, however having all the definitions may help
94 you to understand what is on and off. You could do this with
95
96 pconfig econfig1 > e1 && mv e1 econfig1
97 pconfig econfig2 > e2 && mv e2 econfig2
98
99 which will fill in all the missing options and values with their defaults.
100
101
102
103 Coder information
104 -----------------
105
106 The simplest way to describe this is to step through how a new option
107 would be added.
108
109 1. Think of the option name, say, "DUMB".
110 2. In src/lib/global/options.c define an integer and set it to 1 or 0
111 as appropriate. This is usually done as 
112
113 #ifdef DUMB
114 int opt_DUMB = 1;
115 #else
116 int opt_DUMB = 0;
117 #endif
118
119 3. At the end of that file, add an entry into the table so it is
120 configurable. This is done with a line like
121
122     { "DUMB", &opt_DUMB },
123
124 Make sure the table is still terminated by two NULL values!
125
126 4. In include/optlist.h add an external definition of this variable
127
128 extern int opt_DUMB;
129
130 5. Now the variable is defined, and configurable through the option
131 keyword in the config file. So you can go ahead and make changes
132 elsewhere in the code. This normally looks like
133
134           if (opt_DUMB) {
135              pr("You're being dumb\n");
136           } else {
137              pr ("You're being really dumb\n");
138           }
139
140 but it may call subroutines, return early from functions or whatever.