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.90 by root, Fri Oct 16 00:30:19 2009 UTC vs.
Revision 1.92 by root, Thu Nov 5 15:43:21 2009 UTC

51// the vector of other_arch references to be resolved 51// the vector of other_arch references to be resolved
52static std::vector< std::pair<arch_ptr *, shstr> > postponed_arch_ref; 52static std::vector< std::pair<arch_ptr *, shstr> > postponed_arch_ref;
53// the vector of loaded but not yet committed archetypes 53// the vector of loaded but not yet committed archetypes
54static std::vector<archetype *> postponed_arch; 54static std::vector<archetype *> postponed_arch;
55 55
56//+GPL
57
56/** 58/**
57 * GROS - This function retrieves an archetype given the name that appears 59 * GROS - This function retrieves an archetype given the name that appears
58 * during the game (for example, "writing pen" instead of "stylus"). 60 * during the game (for example, "writing pen" instead of "stylus").
59 * It does not use the hashtable system, but browse the whole archlist each time. 61 * It does not use the hashtable system, but browse the whole archlist each time.
60 * I suggest not to use it unless you really need it because of performance issue. 62 * I suggest not to use it unless you really need it because of performance issue.
225 * is because of the 'else' handling - we don't want to match on 227 * is because of the 'else' handling - we don't want to match on
226 * something and set a low retval, even though it may match a higher retcal 228 * something and set a low retval, even though it may match a higher retcal
227 * later. So keep it in descending order here, so we try for the best 229 * later. So keep it in descending order here, so we try for the best
228 * match first, and work downward. 230 * match first, and work downward.
229 */ 231 */
232 const char *qbn0, *qbn1, *qsn; // query base name/short name caches
233
230 if (!strcasecmp (cp, query_name (op))) 234 if (!strcasecmp (cp, query_name (op)))
231 retval = 20; 235 retval = 20;
232 else if (!strcasecmp (cp, query_short_name (op))) 236 else if (!strcasecmp (cp, qsn = query_short_name (op)))
233 retval = 18; 237 retval = 18;
234 else if (!strcasecmp (cp, query_base_name (op, 0))) 238 else if (!strcasecmp (cp, qbn0 = query_base_name (op, 0)))
235 retval = 16; 239 retval = 16;
236 else if (!strcasecmp (cp, query_base_name (op, 1))) 240 else if (!strcasecmp (cp, qbn1 = query_base_name (op, 1)))
237 retval = 16; 241 retval = 16;
238 else if (op->custom_name && !strcasecmp (cp, op->custom_name)) 242 else if (op->custom_name && !strcasecmp (cp, op->custom_name))
239 retval = 15; 243 retval = 15;
240 else if (!strncasecmp (cp, query_base_name (op, 0), strlen (cp))) 244 else if (!strncasecmp (cp, qbn0, strlen (cp)))
241 retval = 14; 245 retval = 14;
242 else if (!strncasecmp (cp, query_base_name (op, 1), strlen (cp))) 246 else if (!strncasecmp (cp, qbn1, strlen (cp)))
243 retval = 14; 247 retval = 14;
244 /* Do substring checks, so things like 'Str+1' will match. 248 /* Do substring checks, so things like 'Str+1' will match.
245 * retval of these should perhaps be lower - they are lower 249 * retval of these should perhaps be lower - they are lower
246 * then the specific strcasecmp aboves, but still higher than 250 * then the specific strcasecmp aboves, but still higher than
247 * some other match criteria. 251 * some other match criteria.
248 */ 252 */
249 else if (strstr (query_base_name (op, 1), cp)) 253 else if (strstr (qbn1, cp))
250 retval = 12; 254 retval = 12;
251 else if (strstr (query_base_name (op, 0), cp)) 255 else if (strstr (qbn0, cp))
252 retval = 12; 256 retval = 12;
253 else if (strstr (query_short_name (op), cp)) 257 else if (strstr (qsn, cp))
254 retval = 12; 258 retval = 12;
255 /* Check against plural/non plural based on count. */ 259 /* Check against plural/non plural based on count. */
256 else if (count > 1 && !strcasecmp (cp, op->name_pl)) 260 else if (count > 1 && !strcasecmp (cp, op->name_pl))
257 retval = 6; 261 retval = 6;
258 else if (count == 1 && !strcasecmp (op->name, cp)) 262 else if (count == 1 && !strcasecmp (op->name, cp))
274 } 278 }
275 279
276 return 0; 280 return 0;
277} 281}
278 282
283//-GPL
284
279archetype::archetype (const char *name) 285archetype::archetype (const char *name)
280{ 286{
281 arch = this; 287 arch = this;
282 this->archname = this->name = this->name_pl = name; 288 this->archname = this->name = this->name_pl = name;
283} 289}
539 object *op = clone (); 545 object *op = clone ();
540 op->instantiate (); 546 op->instantiate ();
541 return op; 547 return op;
542} 548}
543 549
550//+GPL
551
544/* 552/*
545 * Creates an object. This function is called by get_archetype() 553 * Creates an object. This function is called by get_archetype()
546 * if it fails to find the appropriate archetype. 554 * if it fails to find the appropriate archetype.
547 * Thus get_archetype() will be guaranteed to always return 555 * Thus get_archetype() will be guaranteed to always return
548 * an object, and never NULL. 556 * an object, and never NULL.
641 } 649 }
642 650
643 return head; 651 return head;
644} 652}
645 653
654//-GPL
655

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines