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.74 by root, Wed Dec 20 09:14:21 2006 UTC vs.
Revision 1.80 by root, Sat Dec 23 06:41:39 2006 UTC

221 SET_FLAG (ob1, FLAG_BEEN_APPLIED); 221 SET_FLAG (ob1, FLAG_BEEN_APPLIED);
222 222
223 if (QUERY_FLAG (ob2, FLAG_IDENTIFIED)) 223 if (QUERY_FLAG (ob2, FLAG_IDENTIFIED))
224 SET_FLAG (ob2, FLAG_BEEN_APPLIED); 224 SET_FLAG (ob2, FLAG_BEEN_APPLIED);
225 225
226 if ((ob1->flags ^ ob2->flags).reset (FLAG_INV_LOCKED).reset (FLAG_CLIENT_SENT).any () 226 if ((ob1->flag ^ ob2->flag).reset (FLAG_INV_LOCKED).reset (FLAG_CLIENT_SENT).any ()
227 || ob1->arch != ob2->arch 227 || ob1->arch != ob2->arch
228 || ob1->name != ob2->name 228 || ob1->name != ob2->name
229 || ob1->title != ob2->title 229 || ob1->title != ob2->title
230 || ob1->msg != ob2->msg 230 || ob1->msg != ob2->msg
231 || ob1->weight != ob2->weight 231 || ob1->weight != ob2->weight
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)
694 op->active_next = NULL; 651 op->active_next = NULL;
695 op->active_prev = NULL; 652 op->active_prev = NULL;
696} 653}
697 654
698/* 655/*
699 * update_object() updates the array which represents the map. 656 * update_object() updates the the map.
700 * It takes into account invisible objects (and represent squares covered 657 * It takes into account invisible objects (and represent squares covered
701 * by invisible objects by whatever is below them (unless it's another 658 * by invisible objects by whatever is below them (unless it's another
702 * invisible object, etc...) 659 * invisible object, etc...)
703 * If the object being updated is beneath a player, the look-window 660 * If the object being updated is beneath a player, the look-window
704 * of that player is updated (this might be a suboptimal way of 661 * of that player is updated (this might be a suboptimal way of
705 * updating that window, though, since update_object() is called _often_) 662 * updating that window, though, since update_object() is called _often_)
706 * 663 *
707 * action is a hint of what the caller believes need to be done. 664 * action is a hint of what the caller believes need to be done.
708 * For example, if the only thing that has changed is the face (due to
709 * an animation), we don't need to call update_position until that actually
710 * comes into view of a player. OTOH, many other things, like addition/removal
711 * of walls or living creatures may need us to update the flags now.
712 * current action are: 665 * current action are:
713 * UP_OBJ_INSERT: op was inserted 666 * UP_OBJ_INSERT: op was inserted
714 * UP_OBJ_REMOVE: op was removed 667 * UP_OBJ_REMOVE: op was removed
715 * UP_OBJ_CHANGE: object has somehow changed. In this case, we always update 668 * UP_OBJ_CHANGE: object has somehow changed. In this case, we always update
716 * as that is easier than trying to look at what may have changed. 669 * as that is easier than trying to look at what may have changed.
717 * UP_OBJ_FACE: only the objects face has changed. 670 * UP_OBJ_FACE: only the objects face has changed.
718 */ 671 */
719
720void 672void
721update_object (object *op, int action) 673update_object (object *op, int action)
722{ 674{
723 int update_now = 0, flags;
724 MoveType move_on, move_off, move_block, move_slow; 675 MoveType move_on, move_off, move_block, move_slow;
725 676
726 if (op == NULL) 677 if (op == NULL)
727 { 678 {
728 /* this should never happen */ 679 /* this should never happen */
729 LOG (llevDebug, "update_object() called for NULL object.\n"); 680 LOG (llevDebug, "update_object() called for NULL object.\n");
730 return; 681 return;
731 } 682 }
732 683
733 if (op->env != NULL) 684 if (op->env)
734 { 685 {
735 /* Animation is currently handled by client, so nothing 686 /* Animation is currently handled by client, so nothing
736 * to do in this case. 687 * to do in this case.
737 */ 688 */
738 return; 689 return;
752 abort (); 703 abort ();
753#endif 704#endif
754 return; 705 return;
755 } 706 }
756 707
757 flags = GET_MAP_FLAGS (op->map, op->x, op->y); 708 mapspace &m = op->ms ();
758 SET_MAP_FLAGS (op->map, op->x, op->y, flags | P_NEED_UPDATE);
759 move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y);
760 move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y);
761 move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y);
762 move_off = GET_MAP_MOVE_OFF (op->map, op->x, op->y);
763 709
710 if (m.flags_ & P_NEED_UPDATE)
711 /* nop */;
764 if (action == UP_OBJ_INSERT) 712 else if (action == UP_OBJ_INSERT)
765 { 713 {
714 // this is likely overkill, TODO: revisit (schmorp)
766 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(flags & P_BLOCKSVIEW)) 715 if ((QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(m.flags_ & P_BLOCKSVIEW))
767 update_now = 1;
768
769 if (QUERY_FLAG (op, FLAG_NO_MAGIC) && !(flags & P_NO_MAGIC)) 716 || (QUERY_FLAG (op, FLAG_NO_MAGIC) && !(m.flags_ & P_NO_MAGIC))
770 update_now = 1; 717 || (op->type == PLAYER && !(m.flags_ & P_PLAYER))
771 718 || (op->type == SAFE_GROUND && !(m.flags_ & P_SAFE))
719 || (QUERY_FLAG (op, FLAG_ALIVE) && !(m.flags_ & P_IS_ALIVE))
772 if (QUERY_FLAG (op, FLAG_DAMNED) && !(flags & P_NO_CLERIC)) 720 || (QUERY_FLAG (op, FLAG_DAMNED) && !(m.flags_ & P_NO_CLERIC))
773 update_now = 1;
774
775 if (QUERY_FLAG (op, FLAG_ALIVE) && !(flags & P_IS_ALIVE))
776 update_now = 1;
777
778 if (op->type == SAFE_GROUND && !(flags & P_SAFE))
779 update_now = 1;
780
781 if ((move_on | op->move_on) != move_on) 721 || (m.move_on | op->move_on ) != m.move_on
782 update_now = 1;
783
784 if ((move_off | op->move_off) != move_off) 722 || (m.move_off | op->move_off ) != m.move_off
785 update_now = 1; 723 || (m.move_slow | op->move_slow) != m.move_slow
786
787 /* This isn't perfect, but I don't expect a lot of objects to 724 /* This isn't perfect, but I don't expect a lot of objects to
788 * to have move_allow right now. 725 * to have move_allow right now.
789 */ 726 */
790 if (((move_block | op->move_block) & ~op->move_allow) != move_block) 727 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block
791 update_now = 1; 728 || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp)
792 729 m.flags_ = P_NEED_UPDATE;
793 if ((move_slow | op->move_slow) != move_slow)
794 update_now = 1;
795 } 730 }
796
797 /* if the object is being removed, we can't make intelligent 731 /* if the object is being removed, we can't make intelligent
798 * decisions, because remove_ob can't really pass the object 732 * decisions, because remove_ob can't really pass the object
799 * that is being removed. 733 * that is being removed.
800 */ 734 */
801 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) 735 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE)
802 update_now = 1; 736 m.flags_ = P_NEED_UPDATE;
803 else if (action == UP_OBJ_FACE) 737 else if (action == UP_OBJ_FACE)
804 /* Nothing to do for that case */ ; 738 /* Nothing to do for that case */ ;
805 else 739 else
806 LOG (llevError, "update_object called with invalid action: %d\n", action); 740 LOG (llevError, "update_object called with invalid action: %d\n", action);
807 741
808 if (update_now)
809 {
810 SET_MAP_FLAGS (op->map, op->x, op->y, flags | P_NO_ERROR | P_NEED_UPDATE);
811 update_position (op->map, op->x, op->y);
812 }
813
814 if (op->more != NULL) 742 if (op->more)
815 update_object (op->more, action); 743 update_object (op->more, action);
816} 744}
817 745
818object::vector object::mortals; 746object::vector object::mortals;
819object::vector object::objects; // not yet used 747object::vector object::objects; // not yet used
1041 /* 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
1042 * made to players inventory. If set, avoiding the call 970 * made to players inventory. If set, avoiding the call
1043 * to save cpu time. 971 * to save cpu time.
1044 */ 972 */
1045 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))
1046 fix_player (otmp); 974 otmp->update_stats ();
1047 975
1048 if (above != NULL) 976 if (above != NULL)
1049 above->below = below; 977 above->below = below;
1050 else 978 else
1051 env->inv = below; 979 env->inv = below;
1070 998
1071 /* link the object above us */ 999 /* link the object above us */
1072 if (above) 1000 if (above)
1073 above->below = below; 1001 above->below = below;
1074 else 1002 else
1075 SET_MAP_TOP (map, x, y, below); /* we were top, set new top */ 1003 map->at (x, y).top = below; /* we were top, set new top */
1076 1004
1077 /* Relink the object below us, if there is one */ 1005 /* Relink the object below us, if there is one */
1078 if (below) 1006 if (below)
1079 below->above = above; 1007 below->above = above;
1080 else 1008 else
1092 dump = dump_object (GET_MAP_OB (map, x, y)); 1020 dump = dump_object (GET_MAP_OB (map, x, y));
1093 LOG (llevError, "%s\n", dump); 1021 LOG (llevError, "%s\n", dump);
1094 free (dump); 1022 free (dump);
1095 } 1023 }
1096 1024
1097 SET_MAP_OB (map, x, y, above); /* goes on above it. */ 1025 map->at (x, y).bottom = above; /* goes on above it. */
1098 } 1026 }
1099 1027
1100 above = 0; 1028 above = 0;
1101 below = 0; 1029 below = 0;
1102 1030
1121 { 1049 {
1122 CLEAR_FLAG (this, FLAG_APPLIED); 1050 CLEAR_FLAG (this, FLAG_APPLIED);
1123 tmp->container = 0; 1051 tmp->container = 0;
1124 } 1052 }
1125 1053
1126 tmp->contr->socket->floorbox_update (); 1054 tmp->contr->ns->floorbox_update ();
1127 } 1055 }
1128 1056
1129 /* See if player moving off should effect something */ 1057 /* See if player moving off should effect something */
1130 if (check_walk_off 1058 if (check_walk_off
1131 && ((move_type & tmp->move_off) 1059 && ((move_type & tmp->move_off)
1145 last = tmp; 1073 last = tmp;
1146 } 1074 }
1147 1075
1148 /* last == NULL of there are no objects on this space */ 1076 /* last == NULL of there are no objects on this space */
1149 if (!last) 1077 if (!last)
1150 { 1078 map->at (x, y).flags_ = P_NEED_UPDATE;
1151 /* set P_NEED_UPDATE, otherwise update_position will complain. In theory,
1152 * we could preserve the flags (GET_MAP_FLAGS), but update_position figures
1153 * those out anyways, and if there are any flags set right now, they won't
1154 * be correct anyways.
1155 */
1156 SET_MAP_FLAGS (map, x, y, P_NEED_UPDATE);
1157 update_position (map, x, y);
1158 }
1159 else 1079 else
1160 update_object (last, UP_OBJ_REMOVE); 1080 update_object (last, UP_OBJ_REMOVE);
1161 1081
1162 if (QUERY_FLAG (this, FLAG_BLOCKSVIEW) || glow_radius) 1082 if (QUERY_FLAG (this, FLAG_BLOCKSVIEW) || glow_radius)
1163 update_all_los (map, x, y); 1083 update_all_los (map, x, y);
1353 op->below = originator->below; 1273 op->below = originator->below;
1354 1274
1355 if (op->below) 1275 if (op->below)
1356 op->below->above = op; 1276 op->below->above = op;
1357 else 1277 else
1358 SET_MAP_OB (op->map, op->x, op->y, op); 1278 op->ms ().bottom = op;
1359 1279
1360 /* since *below* originator, no need to update top */ 1280 /* since *below* originator, no need to update top */
1361 originator->below = op; 1281 originator->below = op;
1362 } 1282 }
1363 else 1283 else
1409 * If INS_ON_TOP is used, don't do this processing 1329 * If INS_ON_TOP is used, don't do this processing
1410 * Need to find the object that in fact blocks view, otherwise 1330 * Need to find the object that in fact blocks view, otherwise
1411 * stacking is a bit odd. 1331 * stacking is a bit odd.
1412 */ 1332 */
1413 if (!(flag & INS_ON_TOP) && 1333 if (!(flag & INS_ON_TOP) &&
1414 (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && (op->face && !op->face->visibility)) 1334 (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_BLOCKSVIEW) && (op->face && !op->face->visibility))
1415 { 1335 {
1416 for (last = top; last != floor; last = last->below) 1336 for (last = top; last != floor; last = last->below)
1417 if (QUERY_FLAG (last, FLAG_BLOCKSVIEW) && (last->type != EXIT)) 1337 if (QUERY_FLAG (last, FLAG_BLOCKSVIEW) && (last->type != EXIT))
1418 break; 1338 break;
1419 /* Check to see if we found the object that blocks view, 1339 /* Check to see if we found the object that blocks view,
1442 1362
1443 if (op->above) 1363 if (op->above)
1444 op->above->below = op; 1364 op->above->below = op;
1445 1365
1446 op->below = NULL; 1366 op->below = NULL;
1447 SET_MAP_OB (op->map, op->x, op->y, op); 1367 op->ms ().bottom = op;
1448 } 1368 }
1449 else 1369 else
1450 { /* get inserted into the stack above top */ 1370 { /* get inserted into the stack above top */
1451 op->above = top->above; 1371 op->above = top->above;
1452 1372
1456 op->below = top; 1376 op->below = top;
1457 top->above = op; 1377 top->above = op;
1458 } 1378 }
1459 1379
1460 if (op->above == NULL) 1380 if (op->above == NULL)
1461 SET_MAP_TOP (op->map, op->x, op->y, op); 1381 op->ms ().top = op;
1462 } /* else not INS_BELOW_ORIGINATOR */ 1382 } /* else not INS_BELOW_ORIGINATOR */
1463 1383
1464 if (op->type == PLAYER) 1384 if (op->type == PLAYER)
1465 op->contr->do_los = 1; 1385 op->contr->do_los = 1;
1466 1386
1467 /* 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
1468 * it, so save a few ticks and start from there. 1388 * it, so save a few ticks and start from there.
1469 */ 1389 */
1470 if (!(flag & INS_MAP_LOAD)) 1390 if (!(flag & INS_MAP_LOAD))
1471 for (tmp = floor ? floor : GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1391 if (object *pl = op->ms ().player ())
1472 if (tmp->type == PLAYER)
1473 tmp->contr->socket->floorbox_update (); 1392 pl->contr->ns->floorbox_update ();
1474 1393
1475 /* If this object glows, it may affect lighting conditions that are 1394 /* If this object glows, it may affect lighting conditions that are
1476 * 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
1477 * 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
1478 * on the map will get recalculated. The players could very well 1397 * on the map will get recalculated. The players could very well
1512 1431
1513 return op; 1432 return op;
1514} 1433}
1515 1434
1516/* this function inserts an object in the map, but if it 1435/* this function inserts an object in the map, but if it
1517 * finds an object of its own type, it'll remove that one first. 1436 * finds an object of its own type, it'll remove that one first.
1518 * op is the object to insert it under: supplies x and the map. 1437 * op is the object to insert it under: supplies x and the map.
1519 */ 1438 */
1520void 1439void
1521replace_insert_ob_in_map (const char *arch_string, object *op) 1440replace_insert_ob_in_map (const char *arch_string, object *op)
1522{ 1441{
1523 object * 1442 object *tmp, *tmp1;
1524 tmp;
1525 object *
1526 tmp1;
1527 1443
1528 /* first search for itself and remove any old instances */ 1444 /* first search for itself and remove any old instances */
1529 1445
1530 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1446 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1531 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */ 1447 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */
1765 add_weight (this, (op->weight + op->carrying)); 1681 add_weight (this, (op->weight + op->carrying));
1766 1682
1767 otmp = this->in_player (); 1683 otmp = this->in_player ();
1768 if (otmp && otmp->contr) 1684 if (otmp && otmp->contr)
1769 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1685 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1770 fix_player (otmp); 1686 otmp->update_stats ();
1771 1687
1772 op->map = 0; 1688 op->map = 0;
1773 op->env = this; 1689 op->env = this;
1774 op->above = 0; 1690 op->above = 0;
1775 op->below = 0; 1691 op->below = 0;
2241 mp = m; 2157 mp = m;
2242 nx = x + freearr_x[i]; 2158 nx = x + freearr_x[i];
2243 ny = y + freearr_y[i]; 2159 ny = y + freearr_y[i];
2244 2160
2245 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); 2161 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny);
2162
2246 if (mflags & P_OUT_OF_MAP) 2163 if (mflags & P_OUT_OF_MAP)
2247 {
2248 max = maxfree[i]; 2164 max = maxfree[i];
2249 }
2250 else 2165 else
2251 { 2166 {
2252 blocked = GET_MAP_MOVE_BLOCK (mp, nx, ny); 2167 blocked = GET_MAP_MOVE_BLOCK (mp, nx, ny);
2253 2168
2254 if ((move_type & blocked) == move_type) 2169 if ((move_type & blocked) == move_type)
2255 {
2256 max = maxfree[i]; 2170 max = maxfree[i];
2257 }
2258 else if (mflags & P_IS_ALIVE) 2171 else if (mflags & P_IS_ALIVE)
2259 { 2172 {
2260 for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = tmp->above) 2173 for (tmp = GET_MAP_OB (mp, nx, ny); tmp; tmp = tmp->above)
2261 {
2262 if ((QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER) && (tmp != exclude || (tmp->head && tmp->head != exclude))) 2174 if ((QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER) && (tmp != exclude || (tmp->head && tmp->head != exclude)))
2263 {
2264 break; 2175 break;
2265 } 2176
2266 }
2267 if (tmp) 2177 if (tmp)
2268 {
2269 return freedir[i]; 2178 return freedir[i];
2270 }
2271 } 2179 }
2272 } 2180 }
2273 } 2181 }
2182
2274 return 0; 2183 return 0;
2275} 2184}
2276 2185
2277/* 2186/*
2278 * distance(object 1, object 2) will return the square of the 2187 * distance(object 1, object 2) will return the square of the
2280 */ 2189 */
2281 2190
2282int 2191int
2283distance (const object *ob1, const object *ob2) 2192distance (const object *ob1, const object *ob2)
2284{ 2193{
2285 int 2194 int i;
2286 i;
2287 2195
2288 i = (ob1->x - ob2->x) * (ob1->x - ob2->x) + (ob1->y - ob2->y) * (ob1->y - ob2->y); 2196 i = (ob1->x - ob2->x) * (ob1->x - ob2->x) + (ob1->y - ob2->y) * (ob1->y - ob2->y);
2289 return i; 2197 return i;
2290} 2198}
2291 2199
2296 */ 2204 */
2297 2205
2298int 2206int
2299find_dir_2 (int x, int y) 2207find_dir_2 (int x, int y)
2300{ 2208{
2301 int 2209 int q;
2302 q;
2303 2210
2304 if (y) 2211 if (y)
2305 q = x * 100 / y; 2212 q = x * 100 / y;
2306 else if (x) 2213 else if (x)
2307 q = -300 * x; 2214 q = -300 * x;
2433 * find a path to that monster that we found. If not, 2340 * find a path to that monster that we found. If not,
2434 * we don't bother going toward it. Returns 1 if we 2341 * we don't bother going toward it. Returns 1 if we
2435 * can see a direct way to get it 2342 * can see a direct way to get it
2436 * Modified to be map tile aware -.MSW 2343 * Modified to be map tile aware -.MSW
2437 */ 2344 */
2438
2439
2440int 2345int
2441can_see_monsterP (maptile *m, int x, int y, int dir) 2346can_see_monsterP (maptile *m, int x, int y, int dir)
2442{ 2347{
2443 sint16 dx, dy; 2348 sint16 dx, dy;
2444 int
2445 mflags; 2349 int mflags;
2446 2350
2447 if (dir < 0) 2351 if (dir < 0)
2448 return 0; /* exit condition: invalid direction */ 2352 return 0; /* exit condition: invalid direction */
2449 2353
2450 dx = x + freearr_x[dir]; 2354 dx = x + freearr_x[dir];
2463 return 0; 2367 return 0;
2464 2368
2465 /* yes, can see. */ 2369 /* yes, can see. */
2466 if (dir < 9) 2370 if (dir < 9)
2467 return 1; 2371 return 1;
2372
2468 return can_see_monsterP (m, x, y, reduction_dir[dir][0]) | 2373 return can_see_monsterP (m, x, y, reduction_dir[dir][0])
2469 can_see_monsterP (m, x, y, reduction_dir[dir][1]) | can_see_monsterP (m, x, y, reduction_dir[dir][2]); 2374 | can_see_monsterP (m, x, y, reduction_dir[dir][1])
2375 | can_see_monsterP (m, x, y, reduction_dir[dir][2]);
2470} 2376}
2471
2472
2473 2377
2474/* 2378/*
2475 * can_pick(picker, item): finds out if an object is possible to be 2379 * can_pick(picker, item): finds out if an object is possible to be
2476 * picked up by the picker. Returnes 1 if it can be 2380 * picked up by the picker. Returnes 1 if it can be
2477 * picked up, otherwise 0. 2381 * picked up, otherwise 0.
2488 return /*QUERY_FLAG(who,FLAG_WIZ)|| */ 2392 return /*QUERY_FLAG(who,FLAG_WIZ)|| */
2489 (item->weight > 0 && !QUERY_FLAG (item, FLAG_NO_PICK) && 2393 (item->weight > 0 && !QUERY_FLAG (item, FLAG_NO_PICK) &&
2490 !QUERY_FLAG (item, FLAG_ALIVE) && !item->invisible && (who->type == PLAYER || item->weight < who->weight / 3)); 2394 !QUERY_FLAG (item, FLAG_ALIVE) && !item->invisible && (who->type == PLAYER || item->weight < who->weight / 3));
2491} 2395}
2492 2396
2493
2494/* 2397/*
2495 * create clone from object to another 2398 * create clone from object to another
2496 */ 2399 */
2497object * 2400object *
2498object_create_clone (object *asrc) 2401object_create_clone (object *asrc)
2517 { 2420 {
2518 dst = tmp; 2421 dst = tmp;
2519 tmp->head = 0; 2422 tmp->head = 0;
2520 } 2423 }
2521 else 2424 else
2522 {
2523 tmp->head = dst; 2425 tmp->head = dst;
2524 }
2525 2426
2526 tmp->more = 0; 2427 tmp->more = 0;
2527 2428
2528 if (prev) 2429 if (prev)
2529 prev->more = tmp; 2430 prev->more = tmp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines