Skip MapN parsing if it is equal to EnterMap for instances (#2131)
Added a check to prevent instance from adding duplicate maps
This commit is contained in:
parent
ae540f133f
commit
6a75b17380
@ -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]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user