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.229 by root, Sat May 3 12:29:09 2008 UTC vs.
Revision 1.232 by root, Tue May 6 18:09:42 2008 UTC

1290 * of areas of callers (eg, anything that uses find_free_spot would now 1290 * of areas of callers (eg, anything that uses find_free_spot would now
1291 * need extra work 1291 * need extra work
1292 */ 1292 */
1293 if (!xy_normalise (m, op->x, op->y)) 1293 if (!xy_normalise (m, op->x, op->y))
1294 { 1294 {
1295 op->destroy (1); 1295 op->head_ ()->destroy (1);// remove head_ once all tail object destroyers found
1296 return 0; 1296 return 0;
1297 } 1297 }
1298 1298
1299 if (object *more = op->more) 1299 if (object *more = op->more)
1300 if (!insert_ob_in_map (more, m, originator, flag)) 1300 if (!insert_ob_in_map (more, m, originator, flag))
1587 } 1587 }
1588 else 1588 else
1589 { 1589 {
1590 decrease (nr); 1590 decrease (nr);
1591 1591
1592 object *op = object_create_clone (this); 1592 object *op = deep_clone ();
1593 op->nrof = nr; 1593 op->nrof = nr;
1594 return op; 1594 return op;
1595 } 1595 }
1596} 1596}
1597 1597
1818 LOG (llevError, "Present_arch called outside map.\n"); 1818 LOG (llevError, "Present_arch called outside map.\n");
1819 return NULL; 1819 return NULL;
1820 } 1820 }
1821 1821
1822 for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above) 1822 for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above)
1823 if (tmp->arch == at) 1823 if (tmp->arch->archname == at->archname)
1824 return tmp; 1824 return tmp;
1825 1825
1826 return NULL; 1826 return NULL;
1827} 1827}
1828 1828
1892 * The first matching object is returned, or NULL if none. 1892 * The first matching object is returned, or NULL if none.
1893 */ 1893 */
1894object * 1894object *
1895present_arch_in_ob (const archetype *at, const object *op) 1895present_arch_in_ob (const archetype *at, const object *op)
1896{ 1896{
1897 for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) 1897 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1898 if (tmp->arch == at) 1898 if (tmp->arch->archname == at->archname)
1899 return tmp; 1899 return tmp;
1900 1900
1901 return NULL; 1901 return NULL;
1902} 1902}
1903 1903
2312 2312
2313/* 2313/*
2314 * create clone from object to another 2314 * create clone from object to another
2315 */ 2315 */
2316object * 2316object *
2317object_create_clone (object *asrc) 2317object::deep_clone ()
2318{ 2318{
2319 assert (("deep_clone called on non-head object", is_head ()));
2320
2319 object *dst = 0; 2321 object *dst = clone ();
2320 2322
2321 if (!asrc)
2322 return 0;
2323
2324 object *src = asrc->head_ ();
2325
2326 object *prev = 0; 2323 object *prev = dst;
2327 for (object *part = src; part; part = part->more) 2324 for (object *part = this->more; part; part = part->more)
2328 { 2325 {
2329 object *tmp = part->clone (); 2326 object *tmp = part->clone ();
2330
2331 tmp->x -= src->x;
2332 tmp->y -= src->y;
2333
2334 if (!part->head)
2335 {
2336 dst = tmp;
2337 tmp->head = 0;
2338 }
2339 else
2340 tmp->head = dst; 2327 tmp->head = dst;
2341
2342 tmp->more = 0;
2343
2344 if (prev)
2345 prev->more = tmp; 2328 prev->more = tmp;
2346
2347 prev = tmp; 2329 prev = tmp;
2348 } 2330 }
2349 2331
2350 for (object *item = src->inv; item; item = item->below) 2332 for (object *item = inv; item; item = item->below)
2351 insert_ob_in_ob (object_create_clone (item), dst); 2333 insert_ob_in_ob (item->deep_clone (), dst);
2352 2334
2353 return dst; 2335 return dst;
2354} 2336}
2355 2337
2356/* This returns the first object in who's inventory that 2338/* This returns the first object in who's inventory that

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines