From 654975dab8c0e47f3523745bfee4abecf8ab0b30 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 27 Feb 2016 05:24:02 +0100 Subject: Replaced various '-1' with the correct constant INFINITE_DURATION, INVALID_TIMER, SC_NONE, INDEX_NOT_FOUND, depending on context. Signed-off-by: Haru --- src/map/mercenary.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/map/mercenary.c') diff --git a/src/map/mercenary.c b/src/map/mercenary.c index ec0b2291f..fa337e13b 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -66,19 +66,23 @@ int merc_search_index(int class_) { int i; ARR_FIND(0, MAX_MERCENARY_CLASS, i, mercenary->db[i].class_ == class_); - return (i == MAX_MERCENARY_CLASS)?-1:i; + if (i == MAX_MERCENARY_CLASS) + return INDEX_NOT_FOUND; + return i; } bool merc_class(int class_) { - return (bool)(mercenary->search_index(class_) > -1); + if (mercenary->search_index(class_) != INDEX_NOT_FOUND) + return true; + return false; } struct view_data * merc_get_viewdata(int class_) { int i = mercenary->search_index(class_); - if( i < 0 ) - return 0; + if (i == INDEX_NOT_FOUND) + return NULL; return &mercenary->db[i].vd; } @@ -90,7 +94,7 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime) int i; nullpo_retr(0,sd); - if( (i = mercenary->search_index(class_)) < 0 ) + if ((i = mercenary->search_index(class_)) == INDEX_NOT_FOUND) return 0; db = &mercenary->db[i]; @@ -310,8 +314,8 @@ int merc_data_received(const struct s_mercenary *merc, bool flag) if( (sd = map->charid2sd(merc->char_id)) == NULL ) return 0; - if( !flag || i < 0 ) - { // Not created - loaded - DB info + if (!flag || i == INDEX_NOT_FOUND) { + // Not created - loaded - DB info sd->status.mer_id = 0; return 0; } -- cgit v1.2.3-70-g09d2