summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorskyleo <skyleo@skyleo.de>2019-09-08 02:53:24 +0200
committerHaru <haru@dotalux.com>2020-03-08 20:56:27 +0100
commitd13b24a62ac933364839c7ece1f70eba001e7c2d (patch)
treec10d9f953cf017579a22c9d58b9fc74fefc2956e /src/map/atcommand.c
parentfeb1f9d96a9cfc12602c96235106397b67f2aeb4 (diff)
downloadhercules-d13b24a62ac933364839c7ece1f70eba001e7c2d.tar.gz
hercules-d13b24a62ac933364839c7ece1f70eba001e7c2d.tar.bz2
hercules-d13b24a62ac933364839c7ece1f70eba001e7c2d.tar.xz
hercules-d13b24a62ac933364839c7ece1f70eba001e7c2d.zip
Refactor code using directions to use enum unit_dir
This removes a lot of duplicated code, especially related to people not using the arrays dirx and diry. Assertions for whenever these arrays are used have been added as well, to ensure valid index range. Some trailing white space has been removed as well.
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 707522423..410cd7af7 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -4123,16 +4123,36 @@ ACMD(mapinfo)
for (i = 0; i < map->list[m_id].npc_num;) {
struct npc_data *nd = map->list[m_id].npc[i];
switch(nd->dir) {
- case 0: strcpy(direction, msg_fd(fd,1101)); break; // North
- case 1: strcpy(direction, msg_fd(fd,1102)); break; // North West
- case 2: strcpy(direction, msg_fd(fd,1103)); break; // West
- case 3: strcpy(direction, msg_fd(fd,1104)); break; // South West
- case 4: strcpy(direction, msg_fd(fd,1105)); break; // South
- case 5: strcpy(direction, msg_fd(fd,1106)); break; // South East
- case 6: strcpy(direction, msg_fd(fd,1107)); break; // East
- case 7: strcpy(direction, msg_fd(fd,1108)); break; // North East
- case 9: strcpy(direction, msg_fd(fd,1109)); break; // North
- default: strcpy(direction, msg_fd(fd,1110)); break; // Unknown
+ case UNIT_DIR_NORTH:
+ strcpy(direction, msg_fd(fd, 1101)); // North
+ break;
+ case UNIT_DIR_NORTHWEST:
+ strcpy(direction, msg_fd(fd, 1102)); // North West
+ break;
+ case UNIT_DIR_WEST:
+ strcpy(direction, msg_fd(fd, 1103)); // West
+ break;
+ case UNIT_DIR_SOUTHWEST:
+ strcpy(direction, msg_fd(fd, 1104)); // South West
+ break;
+ case UNIT_DIR_SOUTH:
+ strcpy(direction, msg_fd(fd, 1105)); // South
+ break;
+ case UNIT_DIR_SOUTHEAST:
+ strcpy(direction, msg_fd(fd, 1106)); // South East
+ break;
+ case UNIT_DIR_EAST:
+ strcpy(direction, msg_fd(fd, 1107)); // East
+ break;
+ case UNIT_DIR_NORTHEAST:
+ strcpy(direction, msg_fd(fd, 1108)); // North East
+ break;
+ case 9: // is this actually used? [skyleo]
+ strcpy(direction, msg_fd(fd, 1109)); // North
+ break;
+ default:
+ strcpy(direction, msg_fd(fd, 1110)); // Unknown
+ break;
}
if(strcmp(nd->name,nd->exname) == 0)
safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
@@ -6899,7 +6919,7 @@ ACMD(identify)
}
}
}
-
+
if (num == 0)
clif->message(fd,msg_fd(fd,1238)); // There are no items to appraise.
else if (!identifyall)