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

Comparing deliantra/server/server/skill_util.C (file contents):
Revision 1.7 by root, Sun Sep 3 00:18:42 2006 UTC vs.
Revision 1.8 by pippijn, Thu Sep 7 10:01:58 2006 UTC

1/* 1/*
2 * static char *rcsid_skill_util_c = 2 * static char *rcsid_skill_util_c =
3 * "$Id: skill_util.C,v 1.7 2006/09/03 00:18:42 root Exp $"; 3 * "$Id: skill_util.C,v 1.8 2006/09/07 10:01:58 pippijn Exp $";
4 */ 4 */
5/* 5/*
6 CrossFire, A Multiplayer game for X-windows 6 CrossFire, A Multiplayer game for X-windows
7 7
8 Copryight (C) 2002 Mark Wedel & Crossfire Development Team 8 Copryight (C) 2002 Mark Wedel & Crossfire Development Team
121 * use the skill, so thus if use of the skill requires a skill 121 * use the skill, so thus if use of the skill requires a skill
122 * tool, this code will equip it. 122 * tool, this code will equip it.
123 */ 123 */
124object *find_skill_by_name(object *who, const char *name) 124object *find_skill_by_name(object *who, const char *name)
125{ 125{
126 object *skill=NULL, *skill_tool=NULL, *tmp; 126 object *skill = NULL, *skill_tool = NULL, *tmp;
127 127
128 if (!name) return NULL; 128 if (!name) return NULL;
129 129
130 /* We make sure the length of the string in the object is greater 130 /* We make sure the length of the string in the object is greater
131 * in length than the passed string. Eg, if we have a skill called 131 * in length than the passed string. Eg, if we have a skill called
132 * 'hi', we don't want to match if the user passed 'high' 132 * 'hi', we don't want to match if the user passed 'high'
133 */ 133 */
134 for (tmp=who->inv; tmp!=NULL; tmp=tmp->below) { 134 for (tmp = who->inv; tmp != NULL; tmp = tmp->below) {
135 if (tmp->type == SKILL && !strncasecmp(name, tmp->skill, strlen(name)) && 135 if (tmp->type == SKILL && !strncasecmp(name, tmp->skill, strlen(name)) &&
136 strlen(tmp->skill) >= strlen(name)) skill = tmp; 136 (size_t) strlen(tmp->skill) >= strlen(name)) skill = tmp;
137 137
138 /* Try to find appropriate skilltool. If the player has one already 138 /* Try to find appropriate skilltool. If the player has one already
139 * applied, we try to keep using that one. 139 * applied, we try to keep using that one.
140 */ 140 */
141 else if (tmp->type == SKILL_TOOL && !strncasecmp(name, tmp->skill, strlen(name)) && 141 else if (tmp->type == SKILL_TOOL && !strncasecmp(name, tmp->skill, strlen(name)) &&
142 strlen(tmp->skill) >= strlen(name)) { 142 (size_t) strlen(tmp->skill) >= strlen(name)) {
143 if (QUERY_FLAG(tmp, FLAG_APPLIED)) skill_tool = tmp; 143 if (QUERY_FLAG(tmp, FLAG_APPLIED)) skill_tool = tmp;
144 else if (!skill_tool || !QUERY_FLAG(skill_tool, FLAG_APPLIED)) 144 else if (!skill_tool || !QUERY_FLAG(skill_tool, FLAG_APPLIED))
145 skill_tool = tmp; 145 skill_tool = tmp;
146 } 146 }
147 } 147 }
741 741
742 if (!string) return 0; 742 if (!string) return 0;
743 743
744 for (skop = op->inv; skop != NULL; skop=skop->below) { 744 for (skop = op->inv; skop != NULL; skop=skop->below) {
745 if (skop->type == SKILL && QUERY_FLAG(skop, FLAG_CAN_USE_SKILL) && 745 if (skop->type == SKILL && QUERY_FLAG(skop, FLAG_CAN_USE_SKILL) &&
746 !strncasecmp(string, skop->skill, MIN(strlen(string), strlen(skop->skill)))) 746 !strncasecmp(string, skop->skill, MIN(strlen(string), (size_t) strlen(skop->skill))))
747 break; 747 break;
748 else if (skop->type == SKILL_TOOL && 748 else if (skop->type == SKILL_TOOL &&
749 !strncasecmp(string, skop->skill, MIN(strlen(string), strlen(skop->skill)))) 749 !strncasecmp(string, skop->skill, MIN(strlen(string), (size_t) strlen(skop->skill))))
750 break; 750 break;
751 } 751 }
752 if (!skop) { 752 if (!skop) {
753 new_draw_info_format(NDI_UNIQUE, 0, op, 753 new_draw_info_format(NDI_UNIQUE, 0, op,
754 "Unable to find skill %s", string); 754 "Unable to find skill %s", string);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines