Added more robustness to config lookup

This commit is contained in:
Paul Dino Jones 2024-09-06 14:50:00 -04:00
parent 9e09a2792a
commit d1629dfcbd
1 changed files with 13 additions and 4 deletions

View File

@ -214,14 +214,23 @@ int getconfigtouse(const char* config_file_str, char* car, int sim)
} }
slogt("checking if car is matched %i", j); slogt("checking if car is matched %i", j);
temp = NULL;
found = config_setting_lookup_string(config_config, "car", &temp); found = config_setting_lookup_string(config_config, "car", &temp);
if(strcicmp(temp, car) == 0) if(temp != NULL && found > 0)
{ {
confignum = j; if(strcicmp(temp, car) == 0)
{
confignum = j;
}
if(strcicmp("default", temp) == 0)
{
slogt("matched default car");
confignum = j;
}
} }
if(strcicmp("default", temp) == 0) else
{ {
slogt("matched default car"); slogt("assuming default car");
confignum = j; confignum = j;
} }
if(confignum<configs-1) if(confignum<configs-1)