Skip to content

Commit

Permalink
Fixed crash when demo folder does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex109 committed Mar 29, 2024
1 parent e3f4b5f commit 27a649f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cod4qol/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,20 @@ void commands::LoadDemos()
*game::modCount = 0;
*game::modIndex = 0;

for (const auto& entry : std::filesystem::directory_iterator(relative_dir))
if (std::filesystem::exists(relative_dir))
{
if (entry.path().extension() != ".dm_1")
continue;
for (const auto& entry : std::filesystem::directory_iterator(relative_dir))
{
if (entry.path().extension() != ".dm_1")
continue;

const char* string = game::String_Alloc(entry.path().stem().string().c_str());
const char* string = game::String_Alloc(entry.path().stem().string().c_str());

game::modName[2 * (*game::modCount)] = string;
game::modDesc[2 * (*game::modCount)] = string;
game::modName[2 * (*game::modCount)] = string;
game::modDesc[2 * (*game::modCount)] = string;

(*game::modCount)++;
(*game::modCount)++;
}
}

if((*game::modCount) < 1)
Expand Down

0 comments on commit 27a649f

Please sign in to comment.