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

Comparing deliantra/server/common/arch.C (file contents):
Revision 1.80 by root, Sun May 4 18:46:01 2008 UTC vs.
Revision 1.89 by root, Mon Oct 12 14:00:57 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24#include <cassert> 25#include <cassert>
258 retval = 6; 259 retval = 6;
259 /* base name matched - not bad */ 260 /* base name matched - not bad */
260 else if (strcasecmp (cp, op->name) == 0 && !count) 261 else if (strcasecmp (cp, op->name) == 0 && !count)
261 retval = 4; 262 retval = 4;
262 /* Check for partial custom name, but give a real low priority */ 263 /* Check for partial custom name, but give a real low priority */
263 else if (op->custom_name && strstr (op->custom_name, cp)) 264 else if (op->custom_name.contains (cp))
264 retval = 3; 265 retval = 3;
265 266
266 if (retval) 267 if (retval)
267 { 268 {
268 if (pl->type == PLAYER) 269 if (pl->type == PLAYER)
440 return new_head; 441 return new_head;
441 } 442 }
442 443
443fail: 444fail:
444 for (auto (p, parts.begin ()); p != parts.end (); ++p) 445 for (auto (p, parts.begin ()); p != parts.end (); ++p)
445 (*p)->destroy (true); 446 (*p)->destroy ();
446 447
447 return 0; 448 return 0;
448} 449}
449 450
450void 451void
510 511
511 if (at->refcnt_cnt () > 1) // all arches have ONE refcount from their object 512 if (at->refcnt_cnt () > 1) // all arches have ONE refcount from their object
512 ++idx; 513 ++idx;
513 else 514 else
514 { 515 {
515 LOG (llevDebug, "garbage collect arch %s", at->debug_desc ()); 516 LOG (llevDebug, "garbage collect arch %s", &at->archname);
516 assert (at->arch == at); // verify that refcnt == 1 is truly valid 517 assert (at->arch == at); // verify that refcnt == 1 is truly valid
517 allarch.erase (idx); 518 allarch.erase (idx);
518 519
519 // break chain 520 // break chain
520 for (object *op = at->head_ (); op; ) 521 for (object *op = at->head_ (); op; )
530 } 531 }
531 } 532 }
532 while (--cnt); 533 while (--cnt);
533} 534}
534 535
535/*
536 * Creates and returns a new object which is a copy of the given archetype.
537 * This function returns NULL on failure.
538 */
539object *
540arch_to_object (archetype *at)
541{
542 if (!at)
543 {
544 LOG (llevError, "Couldn't find archetype.\n");
545 return 0;
546 }
547
548 return at->instance ();
549}
550
551object * 536object *
552archetype::instance () 537archetype::instance ()
553{ 538{
554 object *op = clone (); 539 object *op = clone ();
555 op->instantiate (); 540 op->instantiate ();
568 LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name); 553 LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name);
569 554
570 if (!strcmp (name, "bug")) 555 if (!strcmp (name, "bug"))
571 abort (); 556 abort ();
572 557
573 object *op = archetype::get ("bug"); 558 object *op = archetype::get (shstr_bug);
574 op->name = op->name_pl = format ("bug, please report (missing archetype %s)", name); 559 op->name = op->name_pl = format ("bug, please report (missing archetype %s)", name);
575 560
576 return op; 561 return op;
577} 562}
578 563

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines