Selaa lähdekoodia

Skip MapN parsing if it is equal to EnterMap for instances (#2131)

Added a check to prevent instance from adding duplicate maps
Jittapan Pluemsumran 8 vuotta sitten
vanhempi
commit
6a75b17380
1 muutettua tiedostoa jossa 25 lisäystä ja 1 poistoa
  1. 25 1
      src/map/instance.c

+ 25 - 1
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]);