1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
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 | reload_exp_table () |
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 load 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 | { |
… | |
… | |
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 | */ |