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.64 by root, Tue Jun 5 13:05:02 2007 UTC vs.
Revision 1.67 by root, Sat Jun 9 21:16:12 2007 UTC

69find_archetype_by_object_name (const char *name) 69find_archetype_by_object_name (const char *name)
70{ 70{
71 shstr_cmp name_cmp (name); 71 shstr_cmp name_cmp (name);
72 72
73 for_all_archetypes (at) 73 for_all_archetypes (at)
74 if (at->archname == name_cmp) 74 if (at->name == name_cmp)
75 return at; 75 return at;
76 76
77 return 0; 77 return 0;
78} 78}
79 79
86find_archetype_by_object_type_name (int type, const char *name) 86find_archetype_by_object_type_name (int type, const char *name)
87{ 87{
88 shstr_cmp name_cmp (name); 88 shstr_cmp name_cmp (name);
89 89
90 for_all_archetypes (at) 90 for_all_archetypes (at)
91 if (at->archname == name_cmp && at->type == type) 91 if (at->name == name_cmp && at->type == type)
92 return at; 92 return at;
93 93
94 return 0; 94 return 0;
95} 95}
96 96
157 } 157 }
158 158
159 return create_singularity (name); 159 return create_singularity (name);
160} 160}
161 161
162 /* This is a subset of the parse_id command. Basically, name can be 162/* This is a subset of the parse_id command. Basically, name can be
163 * a string seperated lists of things to match, with certain keywords. 163 * a string seperated lists of things to match, with certain keywords.
164 * pl is the player (only needed to set count properly) 164 * pl is the player (only needed to set count properly)
165 * op is the item we are trying to match. Calling function takes care 165 * op is the item we are trying to match. Calling function takes care
166 * of what action might need to be done and if it is valid 166 * of what action might need to be done and if it is valid
167 * (pickup, drop, etc.) Return NONZERO if we have a match. A higher 167 * (pickup, drop, etc.) Return NONZERO if we have a match. A higher
168 * value means a better match. 0 means no match. 168 * value means a better match. 0 means no match.
169 * 169 *
170 * Brief outline of the procedure: 170 * Brief outline of the procedure:
171 * We take apart the name variable into the individual components. 171 * We take apart the name variable into the individual components.
172 * cases for 'all' and unpaid are pretty obvious. 172 * cases for 'all' and unpaid are pretty obvious.
173 * Next, we check for a count (either specified in name, or in the 173 * Next, we check for a count (either specified in name, or in the
174 * player object.) 174 * player object.)
175 * If count is 1, make a quick check on the name. 175 * If count is 1, make a quick check on the name.
176 * IF count is >1, we need to make plural name. Return if match. 176 * IF count is >1, we need to make plural name. Return if match.
177 * Last, make a check on the full name. 177 * Last, make a check on the full name.
178 */ 178 */
179int 179int
180item_matched_string (object *pl, object *op, const char *name) 180item_matched_string (object *pl, object *op, const char *name)
181{ 181{
182 char *cp, local_name[MAX_BUF]; 182 char *cp, local_name[MAX_BUF];
183 int count, retval = 0; 183 int count, retval = 0;
443 archetype *less = new_head; 443 archetype *less = new_head;
444 for (auto (p, parts.begin () + 1); p != parts.end (); ++p) 444 for (auto (p, parts.begin () + 1); p != parts.end (); ++p)
445 { 445 {
446 archetype *at = *p; 446 archetype *at = *p;
447 447
448 // some flags get inherited formt he head (probably a lot more)
449 // doing it here doesn't feel too cozy, but it allows code
450 // to ignore head checks for these flags, which saves time
451 at->flag [FLAG_ALIVE] = new_head->flag [FLAG_ALIVE];
452 at->flag [FLAG_NO_PICK] = new_head->flag [FLAG_NO_PICK];
453 at->flag [FLAG_MONSTER] = new_head->flag [FLAG_MONSTER];
454 at->flag [FLAG_IS_FLOOR] = new_head->flag [FLAG_IS_FLOOR];
455
448 if (at->x < new_head->min_x) new_head->min_x = at->x; 456 if (at->x < new_head->min_x) new_head->min_x = at->x;
449 if (at->y < new_head->min_y) new_head->min_y = at->y; 457 if (at->y < new_head->min_y) new_head->min_y = at->y;
450 if (at->x > new_head->max_x) new_head->max_x = at->x; 458 if (at->x > new_head->max_x) new_head->max_x = at->x;
451 if (at->y > new_head->max_y) new_head->max_y = at->y; 459 if (at->y > new_head->max_y) new_head->max_y = at->y;
452 460
514 * an object, and never NULL. 522 * an object, and never NULL.
515 */ 523 */
516object * 524object *
517create_singularity (const char *name) 525create_singularity (const char *name)
518{ 526{
519 object *op; 527 LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name);
528
529 if (!strcmp (name, "bug"))
530 abort ();
531
520 char buf[MAX_BUF]; 532 char buf[MAX_BUF];
533 sprintf (buf, "bug, please report (%s)", name);
521 534
522 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); 535 object *op = get_archetype ("bug");
523 op = object::create ();
524 op->name = op->name_pl = buf; 536 op->name = op->name_pl = buf;
525 SET_FLAG (op, FLAG_NO_PICK); 537
526 return op; 538 return op;
527} 539}
528 540
529/* 541/*
530 * Finds which archetype matches the given name, and returns a new 542 * Finds which archetype matches the given name, and returns a new

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines