directions[]]= { "north",
"east",
"south",
"west",
"up",
"down" };
I just want to be able to open n and all i need is for the is_abbrev function to return 1 if the value n is passed to agument. same for n e w s u d. But the is_abbrev function +
+ plusseses I think before its first comparison. but c progrmmaing mus be understood to modify that function.
Code:
int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname)
{
int door;
char *directions[] = {"north", "east", "south" , "west" , "up", "down"};
if (*dir) { /* a direction was specified */
if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */
send_to_char(ch, "That's not a direction.\r\n");
return (-1);
}
if (EXIT(ch, door)) { /* Braces added according to indent. -gg */
if (EXIT(ch, door)->keyword) {
if (isname(type, EXIT(ch, door)->keyword))
return (door);
else {
send_to_char(ch, "I see no %s there.\r\n", type);
return (-1);
}
} else
return (door);
} else {
send_to_char(ch, "I really don't see how you can %s anything there.\r\n", cmdname);
return (-1);
}
} else { /* try to locate the keyword */
if (!*type) {
send_to_char(ch, "What is it you want to %s?\r\n", cmdname);
return (-1);
}
for (door = 0; door < NUM_OF_DIRS; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->keyword)
if (isname(type, EXIT(ch, door)->keyword) || is_abbrev(type, directions[door]))
return (door);
send_to_char(ch, "There doesn't seem to be %s %s here.\r\n", AN(type), type);
return (-1);
}
}
int is_abbrev(const char *arg1, const char *arg2)
{
if (!*arg1)
return (0);
for (; *arg1 && *arg2; arg1++, arg2++)
if (LOWER(*arg1) != LOWER(*arg2))
return (0);
if (!*arg1)
return (1);
else
return (0);
}
I just need a function simular to is_abbrev that will return one if n e s w u or d is passed to it.