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

Comparing deliantra/server/common/object.C (file contents):
Revision 1.75 by root, Wed Dec 20 11:36:38 2006 UTC vs.
Revision 1.79 by root, Sat Dec 23 06:30:49 2006 UTC

467 } 467 }
468 468
469 op->key_values = 0; 469 op->key_values = 0;
470} 470}
471 471
472void object::clear ()
473{
474 attachable_base::clear ();
475
476 free_key_values (this);
477
478 owner = 0;
479 name = 0;
480 name_pl = 0;
481 title = 0;
482 race = 0;
483 slaying = 0;
484 skill = 0;
485 msg = 0;
486 lore = 0;
487 custom_name = 0;
488 materialname = 0;
489 contr = 0;
490 below = 0;
491 above = 0;
492 inv = 0;
493 container = 0;
494 env = 0;
495 more = 0;
496 head = 0;
497 map = 0;
498 active_next = 0;
499 active_prev = 0;
500
501 memset (static_cast<object_pod *>(this), 0, sizeof (object_pod));
502
503 SET_FLAG (this, FLAG_REMOVED);
504
505 /* What is not cleared is next, prev, and count */
506
507 expmul = 1.0;
508 face = blank_face;
509
510 if (settings.casting_time)
511 casting_time = -1;
512}
513
514/* 472/*
515 * copy_to first frees everything allocated by the dst object, 473 * copy_to first frees everything allocated by the dst object,
516 * and then copies the contents of itself into the second 474 * and then copies the contents of itself into the second
517 * object, allocating what needs to be allocated. Basically, any 475 * object, allocating what needs to be allocated. Basically, any
518 * data that is malloc'd needs to be re-malloc/copied. Otherwise, 476 * data that is malloc'd needs to be re-malloc/copied. Otherwise,
524{ 482{
525 bool is_freed = QUERY_FLAG (dst, FLAG_FREED); 483 bool is_freed = QUERY_FLAG (dst, FLAG_FREED);
526 bool is_removed = QUERY_FLAG (dst, FLAG_REMOVED); 484 bool is_removed = QUERY_FLAG (dst, FLAG_REMOVED);
527 485
528 *(object_copy *)dst = *this; 486 *(object_copy *)dst = *this;
529 *(object_pod *)dst = *this;
530 487
531 if (self || cb) 488 if (self || cb)
532 INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); 489 INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst));
533 490
534 if (is_freed) 491 if (is_freed)
746 abort (); 703 abort ();
747#endif 704#endif
748 return; 705 return;
749 } 706 }
750 707
751 mapspace &m = op->map->at (op->x, op->y); 708 mapspace &m = op->ms ();
752 709
753 if (m.flags_ & P_NEED_UPDATE) 710 if (m.flags_ & P_NEED_UPDATE)
754 /* nop */; 711 /* nop */;
755 else if (action == UP_OBJ_INSERT) 712 else if (action == UP_OBJ_INSERT)
756 { 713 {
1012 /* NO_FIX_PLAYER is set when a great many changes are being 969 /* NO_FIX_PLAYER is set when a great many changes are being
1013 * made to players inventory. If set, avoiding the call 970 * made to players inventory. If set, avoiding the call
1014 * to save cpu time. 971 * to save cpu time.
1015 */ 972 */
1016 if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 973 if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1017 fix_player (otmp); 974 otmp->update_stats ();
1018 975
1019 if (above != NULL) 976 if (above != NULL)
1020 above->below = below; 977 above->below = below;
1021 else 978 else
1022 env->inv = below; 979 env->inv = below;
1092 { 1049 {
1093 CLEAR_FLAG (this, FLAG_APPLIED); 1050 CLEAR_FLAG (this, FLAG_APPLIED);
1094 tmp->container = 0; 1051 tmp->container = 0;
1095 } 1052 }
1096 1053
1097 tmp->contr->socket->floorbox_update (); 1054 tmp->contr->ns->floorbox_update ();
1098 } 1055 }
1099 1056
1100 /* See if player moving off should effect something */ 1057 /* See if player moving off should effect something */
1101 if (check_walk_off 1058 if (check_walk_off
1102 && ((move_type & tmp->move_off) 1059 && ((move_type & tmp->move_off)
1316 op->below = originator->below; 1273 op->below = originator->below;
1317 1274
1318 if (op->below) 1275 if (op->below)
1319 op->below->above = op; 1276 op->below->above = op;
1320 else 1277 else
1321 op->map->at (op->x, op->y).bottom = op; 1278 op->ms ().bottom = op;
1322 1279
1323 /* since *below* originator, no need to update top */ 1280 /* since *below* originator, no need to update top */
1324 originator->below = op; 1281 originator->below = op;
1325 } 1282 }
1326 else 1283 else
1405 1362
1406 if (op->above) 1363 if (op->above)
1407 op->above->below = op; 1364 op->above->below = op;
1408 1365
1409 op->below = NULL; 1366 op->below = NULL;
1410 op->map->at (op->x, op->y).bottom = op; 1367 op->ms ().bottom = op;
1411 } 1368 }
1412 else 1369 else
1413 { /* get inserted into the stack above top */ 1370 { /* get inserted into the stack above top */
1414 op->above = top->above; 1371 op->above = top->above;
1415 1372
1419 op->below = top; 1376 op->below = top;
1420 top->above = op; 1377 top->above = op;
1421 } 1378 }
1422 1379
1423 if (op->above == NULL) 1380 if (op->above == NULL)
1424 op->map->at (op->x, op->y).top = op; 1381 op->ms ().top = op;
1425 } /* else not INS_BELOW_ORIGINATOR */ 1382 } /* else not INS_BELOW_ORIGINATOR */
1426 1383
1427 if (op->type == PLAYER) 1384 if (op->type == PLAYER)
1428 op->contr->do_los = 1; 1385 op->contr->do_los = 1;
1429 1386
1430 /* If we have a floor, we know the player, if any, will be above 1387 /* If we have a floor, we know the player, if any, will be above
1431 * it, so save a few ticks and start from there. 1388 * it, so save a few ticks and start from there.
1432 */ 1389 */
1433 if (!(flag & INS_MAP_LOAD)) 1390 if (!(flag & INS_MAP_LOAD))
1434 if (object *pl = op->map->at (op->x, op->y).player ()) 1391 if (object *pl = op->ms ().player ())
1435 pl->contr->socket->floorbox_update (); 1392 pl->contr->ns->floorbox_update ();
1436 1393
1437 /* If this object glows, it may affect lighting conditions that are 1394 /* If this object glows, it may affect lighting conditions that are
1438 * visible to others on this map. But update_all_los is really 1395 * visible to others on this map. But update_all_los is really
1439 * an inefficient way to do this, as it means los for all players 1396 * an inefficient way to do this, as it means los for all players
1440 * on the map will get recalculated. The players could very well 1397 * on the map will get recalculated. The players could very well
1724 add_weight (this, (op->weight + op->carrying)); 1681 add_weight (this, (op->weight + op->carrying));
1725 1682
1726 otmp = this->in_player (); 1683 otmp = this->in_player ();
1727 if (otmp && otmp->contr) 1684 if (otmp && otmp->contr)
1728 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1685 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1729 fix_player (otmp); 1686 otmp->update_stats ();
1730 1687
1731 op->map = 0; 1688 op->map = 0;
1732 op->env = this; 1689 op->env = this;
1733 op->above = 0; 1690 op->above = 0;
1734 op->below = 0; 1691 op->below = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines