Code:
// Usage: survey
// Looks into all adjecent rooms from the player
// and shows all pcs/npcs in them
ACMD(do_survey)
{
// check if they even know the skill
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_SURVEY))
{
send_to_char(ch, "You have no idea how to do that.\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT)
{
send_to_char(ch, "You can't see a thing, you're blind!\r\n");
return;
}
- else if (IS_DARK(IN_ROOM(ch)) && !CAN_SEE_IN_DARK(ch))
+ if (IS_DARK(IN_ROOM(ch)) && !CAN_SEE_IN_DARK(ch)) // no need for "else" when you end the previous with a return.
{
send_to_char(ch, "It is pitch black...\r\n");
return;
}
// survey is like the "spy" skill, but it looks in all rooms around you
for (int i = 0; i < NUM_OF_DIRS; i++)
{
char cur_dir[MAX_INPUT_LENGTH];
// temp direction so it can be capitalized
sprintf(cur_dir, "%s", dirs[i]);
// this next bit is not needed. You already _know_ that the cur_dir is in dirs.
- // look for the direction they typed within the dirs array
- int look_type = search_block(cur_dir, dirs, FALSE);
-
- // check for invalid direction
- if (look_type == -1)
- {
- send_to_char(ch, "Look where???\r\n");
- return;
- }
// invalid direction or no room?
- if (look_type >= 0 && EXIT(ch, look_type) && !(EXIT(ch, look_type)->to_room == NOWHERE))
+ if (EXIT(ch, i) && !(EXIT(ch, i)->to_room == NOWHERE))
{
// this bit reinvents the CAP function in utils.c.
- char temp_string[MAX_INPUT_LENGTH];
-
- // direction with capital first letter
- strcpy(temp_string, dirs[look_type]);
- temp_string[0] -= 32;
- send_to_char(ch, "%s", CCNRM(ch, C_NRM)); // color for dir
- send_to_char(ch, "%s:\r\n", temp_string); // dir
+ send_to_char(ch, "%s%s:\r\n", CCNRM(ch, C_NRM), CAP(cur_dir)); // can send several at once
- if (IS_SET(EXIT(ch, look_type)->exit_info, EX_CLOSED) && EXIT(ch, look_type)->keyword) {
+ if (IS_SET(EXIT(ch, i)->exit_info, EX_CLOSED) && EXIT(ch, i)->keyword) {
- send_to_char(ch, "%s", CCYEL(ch, C_NRM));
- send_to_char(ch, "The %s is closed.\r\n", fname(EXIT(ch, look_type)->keyword));
+ send_to_char(ch, "%sThe %s is closed.\r\n", CCYEL(ch, C_NRM), fname(EXIT(ch, i)->keyword));
}
else {
// list of chars in room looking in, if none found tell player
// NOTE: list_char_to_char actually lists the characters
- if ((list_char_to_char(world[world[IN_ROOM(ch)].dir_option[look_type]->to_room].people, ch) == 0))
+ if ((list_char_to_char(world[world[IN_ROOM(ch)].dir_option[i]->to_room].people, ch) == 0))
{
- send_to_char(ch, "%s", CCYEL(ch, C_NRM));
- send_to_char(ch, "No one.\r\n");
+ send_to_char(ch, "%sNo one.\r\n", CCYEL(ch, C_NRM));
}
}
}
}
}
This might look like a scathing takedown, but a lot of it was ok. There was just a little extra, unneeded, work going on,