From 6a75b173801bbc19982522126d9e217a4eb5cd80 Mon Sep 17 00:00:00 2001 From: Jittapan Pluemsumran Date: Sun, 21 May 2017 00:50:01 +0700 Subject: [PATCH] Skip MapN parsing if it is equal to EnterMap for instances (#2131) Added a check to prevent instance from adding duplicate maps --- src/map/instance.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/map/instance.c b/src/map/instance.c index 79a9ba8a8b..3607612c13 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -839,7 +839,7 @@ static bool instance_db_free_sub(struct instance_db *db); *------------------------------------------*/ static bool instance_readdb_sub(char* str[], int columns, int current) { - uint8 i; + uint8 i,j; char *ptr; int id = strtol(str[0], &ptr, 10); struct instance_db *db; @@ -911,6 +911,30 @@ static bool instance_readdb_sub(char* str[], int columns, int current) ShowWarning("instance_readdb_sub: Invalid map '%s' in maplist, skipping...\n", str[i]); continue; } + + if (strcmpi(str[4], str[i]) == 0) { + ShowWarning("instance_readdb_sub: '%s'(Map%d) must not be equal to EnterMap for instance id '%d', skipping...\n", str[i], i - 5, id); + continue; + } + + // Check if the map is in the list already + for (j = 7; j < i; j++) { + // Skip empty columns + if (!strlen(str[j])) { + continue; + } + + if (strcmpi(str[j], str[i]) == 0) { + break; + } + } + + // If it was already in the list + if (j < i) { + ShowWarning("instance_readdb_sub: '%s'(Map%d) was already added for instance id '%d', skipping...\n", str[i], i - 5, id); + continue; // Skip it + } + RECREATE(db->maplist, StringBuf *, db->maplist_count+1); db->maplist[db->maplist_count] = StringBuf_Malloc(); StringBuf_AppendStr(db->maplist[db->maplist_count], str[i]);