Browse Source

db ini checks

Fixes #128

Also addresses telling the correct parameter that is missing from the ini
Image 1 year ago
parent
commit
3ec034e172
2 changed files with 12 additions and 1 deletions
  1. 1 1
      EQ2/source/common/database.cpp
  2. 11 0
      EQ2/source/common/dbcore.cpp

+ 1 - 1
EQ2/source/common/database.cpp

@@ -104,7 +104,7 @@ bool Database::Init(bool silentLoad) {
 		for (i = 0; i < 4; i++)
 		{
 			if ( !items[i] )
-				LogWrite(DATABASE__ERROR, 0, "DB", "Could not find parameter %s", exampleIni[i]);
+				LogWrite(DATABASE__ERROR, 0, "DB", "Could not find parameter %s", exampleIni[i+1]); // offset by 1 because the [Database] entry
 		}
 		LogWrite(DATABASE__ERROR, 0, "DB", "Example File:");
 		int length = sizeof exampleIni / sizeof exampleIni[0];

+ 11 - 0
EQ2/source/common/dbcore.cpp

@@ -100,12 +100,23 @@ bool DBcore::ReadDBINI(char* host, char* user, char* passwd, char* database, int
 
 		key = strtok(line, "=");
 
+		if (key == NULL)
+			continue;
+
 		//don't do anything until we find the [Database] section
 		if (!on_database_section && strncasecmp(key, "[Database]", 10) == 0)
 			on_database_section = true;
 		else {
 			val = strtok(NULL, "=");
 
+			if (val == NULL)
+			{
+				if (strcasecmp(key, "password") == 0) {
+					strcpy(passwd, "");
+					items[2] = true;
+				}
+				continue;
+			}
 			if (strcasecmp(key, "host") == 0) {
 				strcpy(host, val);
 				items[0] = true;