Fixes #128 Also addresses telling the correct parameter that is missing from the ini
@@ -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];
@@ -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;
+ }
if (strcasecmp(key, "host") == 0) {
strcpy(host, val);
items[0] = true;