… | |
… | |
25 | #include <stdio.h> |
25 | #include <stdio.h> |
26 | #include <global.h> |
26 | #include <global.h> |
27 | |
27 | |
28 | sint64 levels[MAXNUMLEVELS]; |
28 | sint64 levels[MAXNUMLEVELS]; |
29 | |
29 | |
30 | static float exp_att_mult[NROFATTACKS + 2] = { |
30 | static const float exp_att_mult[NROFATTACKS + 2] = { |
31 | 0.0, /* AT_PHYSICAL */ |
31 | 0.0, /* AT_PHYSICAL */ |
32 | 0.0, /* AT_MAGIC */ |
32 | 0.0, /* AT_MAGIC */ |
33 | 0.0, /* AT_FIRE */ |
33 | 0.0, /* AT_FIRE */ |
34 | 0.0, /* AT_ELECTRICITY */ |
34 | 0.0, /* AT_ELECTRICITY */ |
35 | 0.0, /* AT_COLD */ |
35 | 0.0, /* AT_COLD */ |
… | |
… | |
48 | 0.0, /* AT_DEATH */ |
48 | 0.0, /* AT_DEATH */ |
49 | 0.0, /* AT_CHAOS */ |
49 | 0.0, /* AT_CHAOS */ |
50 | 0.0 /* AT_COUNTERSPELL */ |
50 | 0.0 /* AT_COUNTERSPELL */ |
51 | }; |
51 | }; |
52 | |
52 | |
53 | static float exp_prot_mult[NROFATTACKS + 2] = { |
53 | static const float exp_prot_mult[NROFATTACKS + 2] = { |
54 | 0.4, /* AT_PHYSICAL */ |
54 | 0.4, /* AT_PHYSICAL */ |
55 | 0.5, /* AT_MAGIC */ |
55 | 0.5, /* AT_MAGIC */ |
56 | 0.1, /* AT_FIRE */ |
56 | 0.1, /* AT_FIRE */ |
57 | 0.1, /* AT_ELECTRICITY */ |
57 | 0.1, /* AT_ELECTRICITY */ |
58 | 0.1, /* AT_COLD */ |
58 | 0.1, /* AT_COLD */ |
… | |
… | |
155 | else |
155 | else |
156 | return levels [min (level, settings.max_level)]; |
156 | return levels [min (level, settings.max_level)]; |
157 | } |
157 | } |
158 | |
158 | |
159 | /* This loads the experience table from the exp_table |
159 | /* This loads the experience table from the exp_table |
160 | * file. This tends to exit on any errors, since it |
160 | * file. |
161 | * populates the table as it goes along, so if there |
|
|
162 | * are errors, the table is likely in an inconsistent |
|
|
163 | * state. |
|
|
164 | */ |
161 | */ |
165 | void |
162 | void |
166 | init_experience () |
163 | init_experience () |
167 | { |
164 | { |
168 | char buf[MAX_BUF], *cp; |
|
|
169 | int lastlevel = 0, comp; |
165 | int lastlevel = 0; |
170 | sint64 lastexp = -1, tmpexp; |
166 | sint64 lastexp = -1; |
171 | |
167 | |
172 | sprintf (buf, "%s/exp_table", settings.confdir); |
168 | object_thawer thawer (settings.datadir, "exp_table"); |
173 | |
|
|
174 | object_thawer thawer (buf); |
|
|
175 | |
169 | |
176 | if (!thawer) |
170 | if (!thawer) |
177 | { |
171 | { |
178 | LOG (llevError, "unable to parse experience table file"); |
172 | LOG (llevError, "unable to parse experience table file"); |
179 | return; |
173 | return; |
180 | } |
174 | } |
181 | |
175 | |
182 | if (thawer.kw != KW_max_level) |
176 | if (thawer.kw != KW_max_level) |
183 | { |
177 | { |
184 | thawer.parse_error ("experience table file", "max_level"); |
178 | thawer.parse_error ("experience table file"); |
185 | return; |
179 | return; |
186 | } |
180 | } |
187 | |
181 | |
188 | thawer.get (settings.max_level); |
182 | thawer.get (settings.max_level); |
189 | |
183 | |
190 | sint64 newlevels [MAXNUMLEVELS]; |
184 | sint64 newlevels [MAXNUMLEVELS]; |
191 | |
185 | |
192 | while (thawer.next_line ()) |
186 | while (thawer.next_line ()) |
193 | { |
187 | { |
|
|
188 | sint64 tmpexp; |
194 | thawer.get (tmpexp); |
189 | thawer.get (tmpexp); |
195 | |
190 | |
196 | /* Do some sanity checking - if value is bogus, just exit because |
191 | /* Do some sanity checking - if value is bogus, just exit because |
197 | * the table otherwise is probably in an inconsistent state |
192 | * the table otherwise is probably in an inconsistent state |
198 | */ |
193 | */ |