diff options
author | Haru <haru@dotalux.com> | 2015-05-17 02:35:40 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-05-17 02:35:53 +0200 |
commit | b9a8ad743a78d5053482cb4d47d2795252ec9095 (patch) | |
tree | 40d10510054cd3dd254c366ccbe550817cb3e4ec /src/map/npc.c | |
parent | b2b597c523f19fbacaf052117d47f254483c6e0e (diff) | |
download | hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.tar.gz hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.tar.bz2 hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.tar.xz hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.zip |
Fixed some issues detected by coverity scan
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/npc.c')
-rw-r--r-- | src/map/npc.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 996cd4fda..1721e3db3 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -62,24 +62,27 @@ static struct view_data npc_viewdb2[MAX_NPC_CLASS2_END-MAX_NPC_CLASS2_START]; /* for speedup */ unsigned int npc_market_qty[MAX_INVENTORY]; -static struct script_event_s -{ +static struct script_event_s { //Holds pointers to the commonly executed scripts for speedup. [Skotlex] struct event_data *event[UCHAR_MAX]; const char *event_name[UCHAR_MAX]; uint8 event_count; } script_event[NPCE_MAX]; +/** + * Returns the viewdata for normal npc classes. + * @param class_ The NPC class ID. + * @return The viewdata, or NULL if the ID is invalid. + */ struct view_data* npc_get_viewdata(int class_) { - //Returns the viewdata for normal npc classes. - if( class_ == INVISIBLE_CLASS ) + if (class_ == INVISIBLE_CLASS) return &npc_viewdb[0]; - if (npc->db_checkid(class_) || class_ == WARP_CLASS){ - if( class_ > MAX_NPC_CLASS2_START ){ - return &npc_viewdb2[class_-MAX_NPC_CLASS2_START]; - }else{ + if (npc->db_checkid(class_) || class_ == WARP_CLASS) { + if (class_ < MAX_NPC_CLASS2_START) { return &npc_viewdb[class_]; + } else { + return &npc_viewdb2[class_-MAX_NPC_CLASS2_START]; } } return NULL; |