ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/exp.C
(Generate patch)

Comparing deliantra/server/common/exp.C (file contents):
Revision 1.38 by root, Sat Dec 31 06:18:01 2011 UTC vs.
Revision 1.45 by root, Mon Jun 10 17:06:31 2024 UTC

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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * 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 10 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25#include <stdio.h> 26#include <stdio.h>
26#include <global.h> 27#include <global.h>
155 156
156/* This loads the experience table from the exp_table 157/* This loads the experience table from the exp_table
157 * file. 158 * file.
158 */ 159 */
159void 160void
160reload_exp_table () 161_reload_exp_table ()
161{ 162{
162 int lastlevel = 0; 163 int lastlevel = 0;
163 sint64 lastexp = -1; 164 sint64 lastexp = -1;
164 165
165 object_thawer thawer (settings.datadir, "exp_table"); 166 object_thawer thawer (settings.datadir, "exp_table");
177 } 178 }
178 179
179 thawer.get (settings.max_level); 180 thawer.get (settings.max_level);
180 181
181 sint64 newlevels [MAXNUMLEVELS]; 182 sint64 newlevels [MAXNUMLEVELS];
183 newlevels [0] = 0;
182 184
183 while (thawer.next_line ()) 185 while (thawer.next_line ())
184 { 186 {
185 sint64 tmpexp; 187 sint64 tmpexp;
186 thawer.get (tmpexp); 188 thawer.get (tmpexp);
194 return; 196 return;
195 } 197 }
196 198
197 lastlevel++; 199 lastlevel++;
198 200
199 if (lastlevel > settings.max_level) 201 if (lastlevel > settings.max_level || lastlevel >= MAXNUMLEVELS - 1)
200 { 202 {
201 LOG (llevError, "Too many levels specified in table (%d > %d)\n", lastlevel, settings.max_level); 203 LOG (llevError, "Too many levels specified in table (%d > %d (settings.max_level) or >= %d (MAXNUMLEVELS - 1))\n", lastlevel, settings.max_level, MAXNUMLEVELS - 1);
202 exit (1); 204 exit (1);
203 } 205 }
204 206
205 newlevels [lastlevel] = tmpexp; 207 newlevels [lastlevel] = tmpexp;
206 lastexp = tmpexp; 208 lastexp = tmpexp;
210 { 212 {
211 LOG (llevError, "Warning: exp_table does not have %d entries (%d)\n", settings.max_level, lastlevel); 213 LOG (llevError, "Warning: exp_table does not have %d entries (%d)\n", settings.max_level, lastlevel);
212 return; 214 return;
213 } 215 }
214 216
217 // copy the last exp value one level higher, so we can take the difference to the "next" level
218 // eve4n for players at max. level
219 newlevels [lastlevel + 1] = newlevels [lastlevel];
220
215 memcpy (levels, newlevels, sizeof (levels)); 221 memcpy (levels, newlevels, sizeof (levels));
216} 222}
217 223

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines