Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CF: definitive skill_util.c patch (?!)
- To: crossfire (at) ifi.uio.no
- Subject: CF: definitive skill_util.c patch (?!)
- From: "Brian Thomas" <>
- Date: Thu, 2 May 96 06:01:51 EDT
- Sender:
Ok, I merged Steve Mead's and my patches together. I changed
the loop in lookup_skill_by_name so that w/o a match it will
return -1 value properly. I added a line in change_skill so
that the player will be informed when they make a request for
a non-existent skill.
-b.t.
*** skill_util.c.orig Thu May 2 04:32:43 1996
--- skill_util.c Thu May 2 05:58:40 1996
***************
*** 462,473 ****
*/
void read_skill_params () {
FILE *skill_params;
char fname[MAX_BUF];
! char skill_name[30];
! char skill_attrib[50];
int cat,bexp,time,stat1,stat2,stat3,skillindex;
float lexp;
sprintf(fname,"%s/%s",LibDir,"skill_params");
if(! (skill_params=fopen(fname,"r")))
--- 462,473 ----
*/
void read_skill_params () {
FILE *skill_params;
char fname[MAX_BUF];
! char skill_name[82];
! char skill_attrib[82];
int cat,bexp,time,stat1,stat2,stat3,skillindex;
float lexp;
sprintf(fname,"%s/%s",LibDir,"skill_params");
if(! (skill_params=fopen(fname,"r")))
***************
*** 476,492 ****
return;
}
while(!feof(skill_params))
{
! fgets(skill_name,49,skill_params);
skillindex=lookup_skill_by_name(skill_name);
if(skillindex == -1) {
LOG(llevError,"\nskill_params has unrecognized skill: %s",skill_name);
continue;
}
! fgets(skill_attrib,49,skill_params);
sscanf(skill_attrib,"%d %d %d %f %d %d %d",
&cat,&time,&bexp,&lexp,&stat1,&stat2,&stat3);
skills[skillindex].category=cat;
skills[skillindex].time=time;
skills[skillindex].bexp=bexp;
--- 476,493 ----
return;
}
while(!feof(skill_params))
{
! fgets(skill_name,82,skill_params);
! if(*skill_name=='#') continue;
skillindex=lookup_skill_by_name(skill_name);
if(skillindex == -1) {
LOG(llevError,"\nskill_params has unrecognized skill: %s",skill_name);
continue;
}
! fgets(skill_attrib,82,skill_params);
sscanf(skill_attrib,"%d %d %d %f %d %d %d",
&cat,&time,&bexp,&lexp,&stat1,&stat2,&stat3);
skills[skillindex].category=cat;
skills[skillindex].time=time;
skills[skillindex].bexp=bexp;
***************
*** 507,521 ****
/* truncate string at first blank space to find skill name. */
nmlen = strcspn(string," ");
strncpy(name,string,nmlen);
! while(strncmp(name,skills[skillnr].name,MIN(strlen(skills[skillnr].name),nmlen))
! && skillnr < (NROFSKILLS - 1)) {
! skillnr++;
! }
!
if(skillnr==NROFSKILLS) skillnr=-1;
return skillnr;
}
/* check_skill_to_fire() - */
--- 508,522 ----
/* truncate string at first blank space to find skill name. */
nmlen = strcspn(string," ");
strncpy(name,string,nmlen);
! while(skillnr < NROFSKILLS)
! if(!strncmp(name,skills[skillnr].name,MIN(strlen(skills[skillnr].name),nmlen)))
! break;
! else skillnr++;
!
if(skillnr==NROFSKILLS) skillnr=-1;
return skillnr;
}
/* check_skill_to_fire() - */
***************
*** 1071,1081 ****
if(!pl->chosen_skill->invisible) /* its a tool, need to unlink it */
unlink_skill(pl->chosen_skill);
pl->chosen_skill = NULL;
}
! if(sk_index<0) return 0; /* bye,bye. We didn't request a valid skill */
/* ok, look for the requested skill */
if((tmp=find_skill(pl,sk_index))) { /* yes, pl does have named skill */
pl->chosen_skill = tmp;
--- 1072,1085 ----
if(!pl->chosen_skill->invisible) /* its a tool, need to unlink it */
unlink_skill(pl->chosen_skill);
pl->chosen_skill = NULL;
}
! if(sk_index<0) { /* bye,bye. We didn't request a valid skill */
! new_draw_info(NDI_UNIQUE, 0,pl,"You can't use an non-existent skill!");
! return 0;
! }
/* ok, look for the requested skill */
if((tmp=find_skill(pl,sk_index))) { /* yes, pl does have named skill */
pl->chosen_skill = tmp;