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.1.1.1 by root, Fri Feb 3 07:11:30 2006 UTC vs.
Revision 1.1.1.2 by elmex, Wed Feb 22 18:01:17 2006 UTC

1/* 1/*
2 * static char *rcsid_arch_c = 2 * static char *rcsid_arch_c =
3 * "$Id: arch.c,v 1.1.1.1 2006/02/03 07:11:30 root Exp $"; 3 * "$Id: arch.c,v 1.1.1.2 2006/02/22 18:01:17 elmex Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
31#include <funcpoint.h> 31#include <funcpoint.h>
32#include <loader.h> 32#include <loader.h>
33 33
34/* IF set, does a little timing on the archetype load. */ 34/* IF set, does a little timing on the archetype load. */
35#define TIME_ARCH_LOAD 0 35#define TIME_ARCH_LOAD 0
36
37static void add_arch(archetype *at);
36 38
37static archetype *arch_table[ARCHTABLE]; 39static archetype *arch_table[ARCHTABLE];
38int arch_cmp=0; /* How many strcmp's */ 40int arch_cmp=0; /* How many strcmp's */
39int arch_search=0; /* How many searches */ 41int arch_search=0; /* How many searches */
40int arch_init; /* True if doing arch initialization */ 42int arch_init; /* True if doing arch initialization */
66 68
67 for(at = first_archetype;at!=NULL;at=at->next) { 69 for(at = first_archetype;at!=NULL;at=at->next) {
68 if (!strcmp(at->clone.name, name)) 70 if (!strcmp(at->clone.name, name))
69 return at; 71 return at;
70 } 72 }
73 return NULL;
74}
75
76/**
77 * This function retrieves an archetype by type and name that appears during
78 * the game. It is basically the same as find_archetype_by_object_name()
79 * except that it considers only items of the given type.
80 */
81archetype *find_archetype_by_object_type_name(int type, const char *name) {
82 archetype *at;
83
84 if (name == NULL)
85 return NULL;
86
87 for (at = first_archetype; at != NULL; at = at->next) {
88 if (at->clone.type == type && strcmp(at->clone.name, name) == 0)
89 return at;
90 }
91
71 return NULL; 92 return NULL;
72} 93}
73 94
74/* This is a lot like the above function. Instead, we are trying to match 95/* This is a lot like the above function. Instead, we are trying to match
75 * the arch->skill values. type is the type of object to match 96 * the arch->skill values. type is the type of object to match
658 679
659/* 680/*
660 * Adds an archetype to the hashtable. 681 * Adds an archetype to the hashtable.
661 */ 682 */
662 683
663void add_arch(archetype *at) { 684static void add_arch(archetype *at) {
664 int index=hasharch(at->name, ARCHTABLE),org_index=index; 685 int index=hasharch(at->name, ARCHTABLE),org_index=index;
665 for(;;) { 686 for(;;) {
666 if(arch_table[index]==NULL) { 687 if(arch_table[index]==NULL) {
667 arch_table[index]=at; 688 arch_table[index]=at;
668 return; 689 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines