Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Fix RoleRate Settings crash (#293)
Browse files Browse the repository at this point in the history
There is a crash happening if the host never has changed the RoleRate Settings before.
So skip modifying these settings if we don't find them.
  • Loading branch information
DarkPenguin24 authored Feb 5, 2022
1 parent 6611044 commit 25998b6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions gui/tabs/host_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ namespace HostTab {

if (!IsInGame())
{
auto vectors = (*Game::pGameOptionsData)->fields.RoleOptions->fields.roleRates->fields.entries[0].vector;
for (auto iVector = 0; iVector < 32; iVector++)
auto roleRates = (*Game::pGameOptionsData)->fields.RoleOptions->fields.roleRates;
if(roleRates->fields.count != 0)
{
if (vectors[iVector].key == RoleTypes__Enum::Engineer && State.engineers_amount > vectors[iVector].value.MaxCount)
vectors[iVector].value.MaxCount = State.engineers_amount;
else if (vectors[iVector].key == RoleTypes__Enum::Scientist && State.scientists_amount > vectors[iVector].value.MaxCount)
vectors[iVector].value.MaxCount = State.scientists_amount;
else if (vectors[iVector].key == RoleTypes__Enum::Shapeshifter && State.shapeshifters_amount > vectors[iVector].value.MaxCount)
vectors[iVector].value.MaxCount = State.shapeshifters_amount;
auto vectors = roleRates->fields.entries[0].vector;
for (auto iVector = 0; iVector < 32; iVector++)
{
if (vectors[iVector].key == RoleTypes__Enum::Engineer && State.engineers_amount > vectors[iVector].value.MaxCount)
vectors[iVector].value.MaxCount = State.engineers_amount;
else if (vectors[iVector].key == RoleTypes__Enum::Scientist && State.scientists_amount > vectors[iVector].value.MaxCount)
vectors[iVector].value.MaxCount = State.scientists_amount;
else if (vectors[iVector].key == RoleTypes__Enum::Shapeshifter && State.shapeshifters_amount > vectors[iVector].value.MaxCount)
vectors[iVector].value.MaxCount = State.shapeshifters_amount;
}
}

if((*Game::pGameOptionsData)->fields.NumImpostors <= State.impostors_amount + State.shapeshifters_amount)
(*Game::pGameOptionsData)->fields.NumImpostors = State.impostors_amount + State.shapeshifters_amount;
}
Expand Down

0 comments on commit 25998b6

Please sign in to comment.