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.103 by root, Tue Jan 2 20:40:34 2007 UTC vs.
Revision 1.107 by pippijn, Sat Jan 6 14:42:29 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2001 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
733void 734void
734object::activate_recursive () 735object::activate_recursive ()
735{ 736{
736 activate (); 737 activate ();
737 738
738 for (object *op = inv; op; op = op->above) 739 for (object *op = inv; op; op = op->below)
739 op->activate_recursive (); 740 op->activate_recursive ();
740} 741}
741 742
742/* This function removes object 'op' from the list of active 743/* This function removes object 'op' from the list of active
743 * objects. 744 * objects.
772} 773}
773 774
774void 775void
775object::deactivate_recursive () 776object::deactivate_recursive ()
776{ 777{
777 for (object *op = inv; op; op = op->above) 778 for (object *op = inv; op; op = op->below)
778 op->deactivate_recursive (); 779 op->deactivate_recursive ();
779 780
780 deactivate (); 781 deactivate ();
782}
783
784void
785object::set_flag_inv (int flag, int value)
786{
787 for (object *op = inv; op; op = op->below)
788 {
789 op->flag [flag] = value;
790 op->set_flag_inv (flag, value);
791 }
781} 792}
782 793
783/* 794/*
784 * Remove and free all objects in the inventory of the given object. 795 * Remove and free all objects in the inventory of the given object.
785 * object.c ? 796 * object.c ?
1204 { 1215 {
1205 /* The part may be on a different map. */ 1216 /* The part may be on a different map. */
1206 1217
1207 object *more = op->more; 1218 object *more = op->more;
1208 1219
1209 /* We really need the caller to normalize coordinates - if 1220 /* We really need the caller to normalise coordinates - if
1210 * we set the map, that doesn't work if the location is within 1221 * we set the map, that doesn't work if the location is within
1211 * a map and this is straddling an edge. So only if coordinate 1222 * a map and this is straddling an edge. So only if coordinate
1212 * is clear wrong do we normalize it. 1223 * is clear wrong do we normalise it.
1213 */ 1224 */
1214 if (OUT_OF_REAL_MAP (more->map, more->x, more->y)) 1225 if (OUT_OF_REAL_MAP (more->map, more->x, more->y))
1215 more->map = get_map_from_coord (m, &more->x, &more->y); 1226 more->map = get_map_from_coord (m, &more->x, &more->y);
1216 else if (!more->map) 1227 else if (!more->map)
1217 { 1228 {
1444{ 1455{
1445 object *tmp, *tmp1; 1456 object *tmp, *tmp1;
1446 1457
1447 /* first search for itself and remove any old instances */ 1458 /* first search for itself and remove any old instances */
1448 1459
1449 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1460 for (tmp = op->ms ().bot; tmp; tmp = tmp->above)
1450 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */ 1461 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */
1451 tmp->destroy (); 1462 tmp->destroy ();
1452 1463
1453 tmp1 = arch_to_object (archetype::find (arch_string)); 1464 tmp1 = arch_to_object (archetype::find (arch_string));
1454 1465
1777 1788
1778 /* The objects have to be checked from top to bottom. 1789 /* The objects have to be checked from top to bottom.
1779 * Hence, we first go to the top: 1790 * Hence, we first go to the top:
1780 */ 1791 */
1781 1792
1782 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp && tmp->above; tmp = tmp->above) 1793 for (tmp = op->ms ().bot; tmp && tmp->above; tmp = tmp->above)
1783 { 1794 {
1784 /* Trim the search when we find the first other spell effect 1795 /* Trim the search when we find the first other spell effect
1785 * this helps performance so that if a space has 50 spell objects, 1796 * this helps performance so that if a space has 50 spell objects,
1786 * we don't need to check all of them. 1797 * we don't need to check all of them.
1787 */ 1798 */
1845 * The first matching object is returned, or NULL if none. 1856 * The first matching object is returned, or NULL if none.
1846 */ 1857 */
1847object * 1858object *
1848present_arch (const archetype *at, maptile *m, int x, int y) 1859present_arch (const archetype *at, maptile *m, int x, int y)
1849{ 1860{
1850 if (m == NULL || out_of_map (m, x, y)) 1861 if (!m || out_of_map (m, x, y))
1851 { 1862 {
1852 LOG (llevError, "Present_arch called outside map.\n"); 1863 LOG (llevError, "Present_arch called outside map.\n");
1853 return NULL; 1864 return NULL;
1854 } 1865 }
1855 1866
1856 for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 1867 for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above)
1857 if (tmp->arch == at) 1868 if (tmp->arch == at)
1858 return tmp; 1869 return tmp;
1859 1870
1860 return NULL; 1871 return NULL;
1861} 1872}
1872 { 1883 {
1873 LOG (llevError, "Present called outside map.\n"); 1884 LOG (llevError, "Present called outside map.\n");
1874 return NULL; 1885 return NULL;
1875 } 1886 }
1876 1887
1877 for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 1888 for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above)
1878 if (tmp->type == type) 1889 if (tmp->type == type)
1879 return tmp; 1890 return tmp;
1880 1891
1881 return NULL; 1892 return NULL;
1882} 1893}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines