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.5 by root, Mon May 29 15:28:24 2006 UTC vs.
Revision 1.7 by root, Fri Jun 23 18:30:22 2006 UTC

1/* 1/*
2 * static char *rcsid_object_c = 2 * static char *rcsid_object_c =
3 * "$Id: object.c,v 1.5 2006/05/29 15:28:24 root Exp $"; 3 * "$Id: object.c,v 1.7 2006/06/23 18:30:22 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
1544 CLEAR_FLAG(op,FLAG_REMOVED); 1544 CLEAR_FLAG(op,FLAG_REMOVED);
1545 1545
1546 /* Debugging information so you can see the last coordinates this object had */ 1546 /* Debugging information so you can see the last coordinates this object had */
1547 op->ox=op->x; 1547 op->ox=op->x;
1548 op->oy=op->y; 1548 op->oy=op->y;
1549
1550 /* Ideally, the caller figures this out. However, it complicates a lot
1551 * of areas of callers (eg, anything that uses find_free_spot would now
1552 * need extra work
1553 */
1554 op->map=get_map_from_coord(m, &op->x, &op->y);
1549 x = op->x; 1555 x = op->x;
1550 y = op->y; 1556 y = op->y;
1551 op->map=get_map_from_coord(m, &x, &y);
1552 1557
1553 /* this has to be done after we translate the coordinates. 1558 /* this has to be done after we translate the coordinates.
1554 */ 1559 */
1555 if(op->nrof && !(flag & INS_NO_MERGE)) { 1560 if(op->nrof && !(flag & INS_NO_MERGE)) {
1556 for(tmp=GET_MAP_OB(op->map,x,y);tmp!=NULL;tmp=tmp->above) 1561 for(tmp=GET_MAP_OB(op->map,x,y);tmp!=NULL;tmp=tmp->above)
1557 if (CAN_MERGE(op,tmp)) { 1562 if (CAN_MERGE(op,tmp)) {
1558 op->nrof+=tmp->nrof; 1563 op->nrof+=tmp->nrof;
1559 remove_ob(tmp); 1564 remove_ob(tmp);
1560 free_object(tmp); 1565 free_object(tmp);
1561 } 1566 }
1562 }
1563
1564 /* Ideally, the caller figures this out. However, it complicates a lot
1565 * of areas of callers (eg, anything that uses find_free_spot would now
1566 * need extra work
1567 */
1568 if (op->map != m) {
1569 /* coordinates should not change unless map also changes */
1570 op->x = x;
1571 op->y = y;
1572 } 1567 }
1573 1568
1574 CLEAR_FLAG(op,FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ 1569 CLEAR_FLAG(op,FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
1575 CLEAR_FLAG(op, FLAG_INV_LOCKED); 1570 CLEAR_FLAG(op, FLAG_INV_LOCKED);
1576 if (!QUERY_FLAG(op, FLAG_ALIVE)) 1571 if (!QUERY_FLAG(op, FLAG_ALIVE))
1634 if (!(flag & INS_ON_TOP) && 1629 if (!(flag & INS_ON_TOP) &&
1635 (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && 1630 (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) &&
1636 (op->face && !op->face->visibility)) { 1631 (op->face && !op->face->visibility)) {
1637 for (last=top; last != floor; last=last->below) 1632 for (last=top; last != floor; last=last->below)
1638 if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; 1633 if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break;
1639 /* Check to see i we found the object that blocks view, 1634 /* Check to see if we found the object that blocks view,
1640 * and make sure we have a below pointer for it so that 1635 * and make sure we have a below pointer for it so that
1641 * we can get inserted below this one, which requires we 1636 * we can get inserted below this one, which requires we
1642 * set top to the object below us. 1637 * set top to the object below us.
1643 */ 1638 */
1644 if (last && last->below && last != floor) top=last->below; 1639 if (last && last->below && last != floor) top=last->below;
2397 * object, needs to travel toward it. 2392 * object, needs to travel toward it.
2398 */ 2393 */
2399 2394
2400int find_dir_2(int x, int y) { 2395int find_dir_2(int x, int y) {
2401 int q; 2396 int q;
2397
2402 if(!y) 2398 if(y)
2399 q=x*100/y;
2400 else if (x)
2403 q= -300*x; 2401 q= -300*x;
2404 else 2402 else
2405 q=x*100/y; 2403 return 0;
2404
2406 if(y>0) { 2405 if(y>0) {
2407 if(q < -242) 2406 if(q < -242)
2408 return 3 ; 2407 return 3 ;
2409 if (q < -41) 2408 if (q < -41)
2410 return 2 ; 2409 return 2 ;
2412 return 1 ; 2411 return 1 ;
2413 if (q < 242) 2412 if (q < 242)
2414 return 8 ; 2413 return 8 ;
2415 return 7 ; 2414 return 7 ;
2416 } 2415 }
2416
2417 if (q < -242) 2417 if (q < -242)
2418 return 7 ; 2418 return 7 ;
2419 if (q < -41) 2419 if (q < -41)
2420 return 6 ; 2420 return 6 ;
2421 if (q < 41) 2421 if (q < 41)
2422 return 5 ; 2422 return 5 ;
2423 if (q < 242) 2423 if (q < 242)
2424 return 4 ; 2424 return 4 ;
2425
2425 return 3 ; 2426 return 3 ;
2426} 2427}
2427 2428
2428/* 2429/*
2429 * absdir(int): Returns a number between 1 and 8, which represent 2430 * absdir(int): Returns a number between 1 and 8, which represent

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines