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

Comparing deliantra/server/common/player.C (file contents):
Revision 1.17 by root, Tue Jan 9 01:28:32 2007 UTC vs.
Revision 1.18 by root, Tue Jan 9 21:32:41 2007 UTC

47int 47int
48is_dragon_pl (const object *op) 48is_dragon_pl (const object *op)
49{ 49{
50 if (op != NULL && op->type == PLAYER && op->arch != NULL && op->arch->clone.race != NULL && strcmp (op->arch->clone.race, "dragon") == 0) 50 if (op != NULL && op->type == PLAYER && op->arch != NULL && op->arch->clone.race != NULL && strcmp (op->arch->clone.race, "dragon") == 0)
51 return 1; 51 return 1;
52
52 return 0; 53 return 0;
53} 54}
54 55
55/* 56/*
56 * If final is set, it a clean/final save, not a backup, ie dont remove objects from inventory 57 * If final is set, it a clean/final save, not a backup, ie dont remove objects from inventory
82 PL_OUT (digestion); 83 PL_OUT (digestion);
83 PL_OUT2 (pickup, mode); 84 PL_OUT2 (pickup, mode);
84 PL_OUT (outputs_sync); 85 PL_OUT (outputs_sync);
85 PL_OUT (outputs_count); 86 PL_OUT (outputs_count);
86 87
87 freezer.put (KW_usekeys, usekeys == key_inventory ? "key_inventory" : (usekeys == keyrings ? "keyrings" : "containers")); 88 freezer.put (KW_usekeys, usekeys == key_inventory ? "key_inventory" : (usekeys == keyrings ? "keyrings" : "containers"));
88 freezer.put (KW_unapply, unapply == unapply_nochoice ? "unapply_nochoice" : (unapply == unapply_never ? "unapply_never" : "unapply_always")); 89 freezer.put (KW_unapply, unapply == unapply_nochoice ? "unapply_nochoice" : (unapply == unapply_never ? "unapply_never" : "unapply_always"));
89 90
90 PL_OUT2 (map, maplevel); 91 PL_OUT2 (map, maplevel);
91 PL_OUT (savebed_map); 92 PL_OUT (savebed_map);
92 PL_OUT (bed_x); 93 PL_OUT (bed_x);
140} 141}
141 142
142player * 143player *
143player::load_pl (object_thawer &thawer) 144player::load_pl (object_thawer &thawer)
144{ 145{
146 int maxerrs = 10;
147
145 player *pl = new player; 148 player *pl = new player;
146 149
147 pl->savebed_map = first_map_path; 150 pl->savebed_map = first_map_path;
148 151
149 /* this loads the standard objects values. */ 152 /* this loads the standard objects values. */
156 159
157 switch (kw) 160 switch (kw)
158 { 161 {
159 case KW_EOF: 162 case KW_EOF:
160 LOG (llevError, "%s: unexpected EOF while reading player header\n", thawer.name); 163 LOG (llevError, "%s: unexpected EOF while reading player header\n", thawer.name);
161 pl->ob->destroy (); 164 goto failure;
162 pl->destroy (); 165
166 default:
167 LOG (llevError, "%s: skipping unknown key in player header: %s\n", thawer.name, keyword_str [kw]);
168 if (!--maxerrs) goto failure;
163 return 0; 169 break;
164 170
165 case KW_ERROR: 171 case KW_ERROR:
166 LOG (llevError, "%s: error while reading player header, skipping (%s,%s)\n", thawer.name, thawer.last_keyword, thawer.last_value); 172 LOG (llevError, "%s: parse error while reading player header, skipping (%s,%s).\n", thawer.name, thawer.last_keyword, thawer.last_value);
173 if (!--maxerrs) goto failure;
167 break; 174 break;
168 175
169 case KW_endplst: 176 case KW_endplst:
170 goto done; 177 goto done;
171 178
231 fgets (line, 32, thawer); pl->levsp [i] = atoi (line); 238 fgets (line, 32, thawer); pl->levsp [i] = atoi (line);
232 fgets (line, 32, thawer); pl->levgrace[i] = atoi (line); 239 fgets (line, 32, thawer); pl->levgrace[i] = atoi (line);
233 } 240 }
234 } 241 }
235 break; 242 break;
236
237 default:
238 LOG (llevError, "%s: skipping unknown key in player header: %s\n", thawer.name, keyword_str [kw]);
239 break;
240 } 243 }
241 } 244 }
242 245
243done: 246done:
244 if (!load_object (thawer, pl->ob, 0)) 247 if (!load_object (thawer, pl->ob, 0))
249 } 252 }
250 253
251 INVOKE_PLAYER (LOAD, pl); 254 INVOKE_PLAYER (LOAD, pl);
252 255
253 return pl; 256 return pl;
257
258failure:
259 LOG (llevError, "%s: too many or too grave errors, aborting player load.\n", thawer.name);
260
261 pl->ob->destroy ();
262 pl->destroy ();
263
264 return 0;
254} 265}
255 266
256player * 267player *
257player::load_pl (const char *path) 268player::load_pl (const char *path)
258{ 269{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines