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.49 by root, Mon Apr 16 12:37:08 2007 UTC vs.
Revision 1.50 by root, Mon Apr 16 13:02:28 2007 UTC

377 overwrite (head, parts.front ().second); 377 overwrite (head, parts.front ().second);
378 head->tail_x = 0; 378 head->tail_x = 0;
379 head->tail_y = 0; 379 head->tail_y = 0;
380 380
381 // link into list of heads, if not already there 381 // link into list of heads, if not already there
382 if (!head->next) 382 if (!head->linked)
383 { 383 {
384 head->linked = true;
384 head->next = first_archetype; 385 head->next = first_archetype;
385 first_archetype = head; 386 first_archetype = head;
386 } 387 }
387 388
388 // reassemble new chain 389 // reassemble new chain
530 531
531 return arch_to_object (at); 532 return arch_to_object (at);
532} 533}
533 534
534/* 535/*
535 * Hash-function used by the arch-hashtable.
536 */
537
538unsigned long
539hasharch (const char *str, int tablesize)
540{
541 unsigned long hash = 0;
542 unsigned int i = 0;
543 const char *p;
544
545 /* use the one-at-a-time hash function, which supposedly is
546 * better than the djb2-like one used by perl5.005, but
547 * certainly is better then the bug used here before.
548 * see http://burtleburtle.net/bob/hash/doobs.html
549 */
550 for (p = str; i < MAXSTRING && *p; p++, i++)
551 {
552 hash += *p;
553 hash += hash << 10;
554 hash ^= hash >> 6;
555 }
556
557 hash += hash << 3;
558 hash ^= hash >> 11;
559 hash += hash << 15;
560
561 return hash % tablesize;
562}
563
564/*
565 * Finds, using the hashtable, which archetype matches the given name. 536 * Finds, using the hashtable, which archetype matches the given name.
566 * returns a pointer to the found archetype, otherwise NULL. 537 * returns a pointer to the found archetype, otherwise NULL.
567 */ 538 */
568archetype * 539archetype *
569archetype::find (const char *name) 540archetype::find (const char *name)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines