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

Comparing deliantra/server/common/loader.C (file contents):
Revision 1.146 by root, Wed Nov 11 04:45:22 2009 UTC vs.
Revision 1.148 by root, Wed Nov 11 23:27:56 2009 UTC

1287 *ptr++ = '\n'; 1287 *ptr++ = '\n';
1288 1288
1289 f.alloc (ptr - cur); 1289 f.alloc (ptr - cur);
1290 } 1290 }
1291 1291
1292#define CMP_OUT(v) if (expect_false (op->v != arch->v)) f.put (KW_ ## v, op->v) 1292#define CMP_OUT(v) if (expect_false (op->v != arch->v)) f.put (KW (v), op->v)
1293#define CMP_OUT2(k,v) if (expect_false (op->v != arch->v)) f.put (KW_ ## k, op->v) 1293#define CMP_OUT2(k,v) if (expect_false (op->v != arch->v)) f.put (KW (k), op->v)
1294 1294
1295 CMP_OUT (x); 1295 CMP_OUT (x);
1296 CMP_OUT (y); 1296 CMP_OUT (y);
1297 1297
1298 CMP_OUT (type); 1298 CMP_OUT (type);
1301 1301
1302 CMP_OUT (name); 1302 CMP_OUT (name);
1303 CMP_OUT (name_pl); 1303 CMP_OUT (name_pl);
1304 1304
1305 CMP_OUT (speed); 1305 CMP_OUT (speed);
1306 CMP_OUT (speed_left); 1306
1307 // speed_left is a major time-burner, and has good locality, so
1308 // we use a simple lookup-cache to avoid the very slow printf.
1309 if (op->speed_left != arch->speed_left)
1310 {
1311 static double last_speed_left = 0.;
1312 static char last_speed_left_str [256] = "speed_left 0\n";
1313 static int last_speed_left_len = sizeof ("speed_left 0\n") - 1;
1314
1315 if (last_speed_left != op->speed_left)
1316 {
1317 last_speed_left = op->speed_left;
1318 last_speed_left_len = sizeof ("speed_left ") - 1
1319 + sprintf (last_speed_left_str + sizeof ("speed_left ") - 1, "%.7g\n", last_speed_left);
1320 }
1321
1322 f.add (last_speed_left_str, last_speed_left_len);
1323 }
1307 1324
1308 CMP_OUT (title); 1325 CMP_OUT (title);
1309 CMP_OUT (race); 1326 CMP_OUT (race);
1310 CMP_OUT (slaying); 1327 CMP_OUT (slaying);
1311 CMP_OUT (skill); 1328 CMP_OUT (skill);
1312 1329
1313 CMP_OUT (tag); 1330 CMP_OUT (tag);
1314 CMP_OUT (custom_name); 1331 CMP_OUT (custom_name);
1315 1332
1316 if (object *owner = op->owner) 1333 if (object *owner = op->owner)
1317 f.put (KW_owner, static_cast<const char *>(owner->ref ())); 1334 f.put (KW(owner), static_cast<const char *>(owner->ref ()));
1318 1335
1319 // memory, attacked_by, chosen_skill, spellitem, spell, current_weapon, arch not saved 1336 // memory, attacked_by, chosen_skill, spellitem, spell, current_weapon, arch not saved
1320 1337
1321 CMP_OUT (other_arch); 1338 CMP_OUT (other_arch);
1322 1339
1323 if (op->msg != arch->msg ) f.put (KW_msg , KW_endmsg , op->msg ); 1340 if (op->msg != arch->msg ) f.put (KW(msg) , KW(endmsg) , op->msg );
1324 if (op->lore != arch->lore) f.put (KW_lore, KW_endlore, op->lore); 1341 if (op->lore != arch->lore) f.put (KW(lore), KW(endlore), op->lore);
1325 1342
1326 if (op->face != arch->face ) f.put (KW_face , op->face ? &faces [op->face ] : 0); 1343 if (op->face != arch->face ) f.put (KW(face) , op->face ? &faces [op->face ] : 0);
1327 if (op->sound != arch->sound ) f.put (KW_sound , op->sound ? &faces [op->sound ] : 0); 1344 if (op->sound != arch->sound ) f.put (KW(sound) , op->sound ? &faces [op->sound ] : 0);
1328 if (op->sound_destroy != arch->sound_destroy) f.put (KW_sound_destroy, op->sound_destroy ? &faces [op->sound_destroy] : 0); 1345 if (op->sound_destroy != arch->sound_destroy) f.put (KW(sound_destroy), op->sound_destroy ? &faces [op->sound_destroy] : 0);
1329 1346
1330 if (op->animation_id != arch->animation_id) 1347 if (op->animation_id != arch->animation_id)
1331 if (op->has_anim ()) 1348 if (op->has_anim ())
1332 f.put (KW_animation, op->anim ().name); 1349 f.put (KW(animation), op->anim ().name);
1333 else 1350 else
1334 { 1351 {
1335 f.put (KW_animation, (const char *)0); 1352 f.put (KW(animation));
1336 op->flag [FLAG_ANIMATE] = false; // TODO: why force to false here? 1353 op->flag [FLAG_ANIMATE] = false; // TODO: why force to false here?
1337 } 1354 }
1338 1355
1339 CMP_OUT2 (str, stats.Str); 1356 CMP_OUT2 (str, stats.Str);
1340 CMP_OUT2 (dex, stats.Dex); 1357 CMP_OUT2 (dex, stats.Dex);
1376 CMP_OUT (path_repelled); 1393 CMP_OUT (path_repelled);
1377 CMP_OUT (path_denied); 1394 CMP_OUT (path_denied);
1378 1395
1379 CMP_OUT2 (material, materials);//TODO: nuke 1396 CMP_OUT2 (material, materials);//TODO: nuke
1380 if (op->material != arch->material) 1397 if (op->material != arch->material)
1381 f.put (KW_materialname, op->material->name); 1398 f.put (KW(materialname), op->material->name);
1382 1399
1383 CMP_OUT (value); 1400 CMP_OUT (value);
1384 CMP_OUT (carrying); 1401 CMP_OUT (carrying);
1385 CMP_OUT (weight); 1402 CMP_OUT (weight);
1386 CMP_OUT (invisible); 1403 CMP_OUT (invisible);
1392 CMP_OUT (last_eat); 1409 CMP_OUT (last_eat);
1393 CMP_OUT (glow_radius); 1410 CMP_OUT (glow_radius);
1394 1411
1395 if (op->flag [FLAG_IS_LINKED]) 1412 if (op->flag [FLAG_IS_LINKED])
1396 if (auto (ol, op->find_link ())) 1413 if (auto (ol, op->find_link ()))
1397 f.put (KW_connected, ol->id); 1414 f.put (KW(connected), ol->id);
1398 1415
1399 CMP_OUT (randomitems); 1416 CMP_OUT (randomitems);
1400 CMP_OUT2 (container, weight_limit); 1417 CMP_OUT2 (container, weight_limit);
1401 1418
1402 CMP_OUT (run_away); 1419 CMP_OUT (run_away);
1422 CMP_OUT (move_slow_penalty); 1439 CMP_OUT (move_slow_penalty);
1423 1440
1424 object::flags_t diff = (op->flag ^ arch->flag) & flagmask; 1441 object::flags_t diff = (op->flag ^ arch->flag) & flagmask;
1425 1442
1426 if (diff [FLAG_OBJ_ORIGINAL]) 1443 if (diff [FLAG_OBJ_ORIGINAL])
1427 f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? "1" : "0"); 1444 f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0));
1428 1445
1429 diff.reset (FLAG_OBJ_ORIGINAL); 1446 diff.reset (FLAG_OBJ_ORIGINAL);
1430 1447
1431 // quickly test whether any other flags differ 1448 // quickly test whether any other flags differ
1432 if (expect_true (diff.any ())) 1449 if (expect_true (diff.any ()))
1433 for (int i = 0; i < NUM_FLAGS; i++) 1450 for (int i = 0; i < NUM_FLAGS; i++)
1434 if (expect_false (diff [i])) 1451 if (expect_false (diff [i]))
1435 f.put (flag_names [i], op->flag [i] ? "1" : "0"); 1452 f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0));
1436 1453
1437 // save body locations. gcc's memcmp does an abysmal job when used 1454 // save body locations. gcc's memcmp does an abysmal job when used
1438 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 1455 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
1439 if (expect_false (op->slot[i].info != arch->slot[i].info)) 1456 if (expect_false (op->slot[i].info != arch->slot[i].info))
1440 f.put (body_locations[i].save_name, op->slot[i].info); 1457 f.put (body_locations[i].save_name, op->slot[i].info);
1446 * the only place this is not set is when saving the player. 1463 * the only place this is not set is when saving the player.
1447 */ 1464 */
1448bool 1465bool
1449object::write (object_freezer &f) 1466object::write (object_freezer &f)
1450{ 1467{
1451 if (is_arch ()) 1468 if (expect_false (is_arch ()))
1452 { 1469 {
1453 f.put (KW_object, arch->archname); 1470 f.put (KW(object), arch->archname);
1454 write_diff (f, this, archetype::empty); 1471 write_diff (f, this, archetype::empty);
1455 } 1472 }
1456 else 1473 else
1457 { 1474 {
1458 f.put (KW_arch, arch->archname); 1475 f.put (KW(arch), arch->archname);
1459 write_diff (f, this, arch); 1476 write_diff (f, this, arch);
1460 } 1477 }
1461 1478
1462 for (object *tmp = inv; tmp; tmp = tmp->below) 1479 for (object *tmp = inv; tmp; tmp = tmp->below)
1463 tmp->write (f); 1480 tmp->write (f);
1464 1481
1465 f.put (this); 1482 f.put (this);
1466 f.put (KW_end); 1483 f.put (KW(end));
1467 1484
1468 return true; 1485 return true;
1469} 1486}
1470 1487
1471///////////////////////////////////////////////////////////////////////////// 1488/////////////////////////////////////////////////////////////////////////////

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines