Merge pull request #12405 from lioncash/shadow2

General: Resolve lingering -Wshadow warnings
This commit is contained in:
Tilka 2023-12-12 22:20:23 +00:00 committed by GitHub
commit 53a51a6f1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 49 deletions

View File

@ -215,8 +215,8 @@ namespace
class HLEPrintArgsVAList final : public HLEPrintArgs class HLEPrintArgsVAList final : public HLEPrintArgs
{ {
public: public:
HLEPrintArgsVAList(const Core::CPUThreadGuard& guard, HLE::SystemVABI::VAList* va_list) HLEPrintArgsVAList(const Core::CPUThreadGuard& guard, HLE::SystemVABI::VAList* list)
: m_guard(guard), m_va_list(va_list) : m_guard(guard), m_va_list(list)
{ {
} }
@ -305,15 +305,15 @@ std::string GetStringVA(HLEPrintArgs* args, std::string_view string)
if (string[i] == '*') if (string[i] == '*')
{ {
++i; ++i;
const s32 result = Common::BitCast<s32>(args->GetU32()); const s32 result_tmp = Common::BitCast<s32>(args->GetU32());
if (result >= 0) if (result_tmp >= 0)
return static_cast<u32>(result); return static_cast<u32>(result_tmp);
if (left_justified_flag_ptr) if (left_justified_flag_ptr)
{ {
// field width; this results in positive field width and left_justified flag set // field width; this results in positive field width and left_justified flag set
*left_justified_flag_ptr = true; *left_justified_flag_ptr = true;
return static_cast<u32>(-static_cast<s64>(result)); return static_cast<u32>(-static_cast<s64>(result_tmp));
} }
// precision; this is ignored // precision; this is ignored
@ -329,10 +329,10 @@ std::string GetStringVA(HLEPrintArgs* args, std::string_view string)
++start; ++start;
if (start == i) if (start == i)
return 0; return 0;
u32 result = 0; u32 result_tmp = 0;
const std::string tmp(string, start, i - start); const std::string tmp(string, start, i - start);
if (TryParse(tmp, &result, 10)) if (TryParse(tmp, &result_tmp, 10))
return result; return result_tmp;
} }
return std::nullopt; return std::nullopt;

View File

@ -116,8 +116,8 @@ void Reload()
std::optional<std::string> GetNetworkPatch(const std::string& source, IsKD is_kd) std::optional<std::string> GetNetworkPatch(const std::string& source, IsKD is_kd)
{ {
const auto patch = const auto patch =
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](NetworkPatch& patch) { std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](const NetworkPatch& p) {
return patch.source == source && patch.is_kd == is_kd && patch.enabled; return p.source == source && p.is_kd == is_kd && p.enabled;
}); });
if (patch == s_patches.end()) if (patch == s_patches.end())
return std::nullopt; return std::nullopt;

View File

@ -31,8 +31,8 @@ ConfigFloatSlider::ConfigFloatSlider(float minimum, float maximum,
setFont(bf); setFont(bf);
const QSignalBlocker blocker(this); const QSignalBlocker blocker(this);
const int current_value = std::round((Config::Get(m_setting) - m_minimum) / m_step); const int value = std::round((Config::Get(m_setting) - m_minimum) / m_step);
setValue(current_value); setValue(value);
}); });
} }

View File

@ -214,43 +214,44 @@ void GenerateCustomLightingHeaderDetails(ShaderCode* out, u32 enablelighting, u3
out->Write("\tint light_count;\n"); out->Write("\tint light_count;\n");
} }
static void GenerateLighting(ShaderCode* out, const LightingUidData& uid_data, int index,
int litchan_index, u32 channel_index, u32 custom_light_index,
bool alpha)
{
const auto attnfunc =
static_cast<AttenuationFunc>((uid_data.attnfunc >> (2 * litchan_index)) & 0x3);
const std::string_view light_type = alpha ? "alpha" : "color";
const std::string name = fmt::format("lights_chan{}_{}", channel_index, light_type);
out->Write("\t{{\n");
out->Write("\t\tcustom_data.{}[{}].direction = " LIGHT_DIR ".xyz;\n", name, custom_light_index,
LIGHT_DIR_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].position = " LIGHT_POS ".xyz;\n", name, custom_light_index,
LIGHT_POS_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].cosatt = " LIGHT_COSATT ";\n", name, custom_light_index,
LIGHT_COSATT_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].distatt = " LIGHT_DISTATT ";\n", name, custom_light_index,
LIGHT_DISTATT_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].attenuation_type = {};\n", name, custom_light_index,
static_cast<u32>(attnfunc));
if (alpha)
{
out->Write("\t\tcustom_data.{}[{}].color = float3(" LIGHT_COL
") / float3(255.0, 255.0, 255.0);\n",
name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb"));
}
else
{
out->Write("\t\tcustom_data.{}[{}].color = " LIGHT_COL " / float3(255.0, 255.0, 255.0);\n",
name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb"));
}
out->Write("\t}}\n");
}
void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData& uid_data, void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData& uid_data,
std::string_view in_color_name) std::string_view in_color_name)
{ {
auto generate_lighting = [](ShaderCode* out, const LightingUidData& uid_data, int index,
int litchan_index, u32 channel_index, u32 custom_light_index,
bool alpha) {
const auto attnfunc =
static_cast<AttenuationFunc>((uid_data.attnfunc >> (2 * litchan_index)) & 0x3);
const std::string_view light_type = alpha ? "alpha" : "color";
const std::string name = fmt::format("lights_chan{}_{}", channel_index, light_type);
out->Write("\t{{\n");
out->Write("\t\tcustom_data.{}[{}].direction = " LIGHT_DIR ".xyz;\n", name, custom_light_index,
LIGHT_DIR_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].position = " LIGHT_POS ".xyz;\n", name, custom_light_index,
LIGHT_POS_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].cosatt = " LIGHT_COSATT ";\n", name, custom_light_index,
LIGHT_COSATT_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].distatt = " LIGHT_DISTATT ";\n", name, custom_light_index,
LIGHT_DISTATT_PARAMS(index));
out->Write("\t\tcustom_data.{}[{}].attenuation_type = {};\n", name, custom_light_index,
static_cast<u32>(attnfunc));
if (alpha)
{
out->Write("\t\tcustom_data.{}[{}].color = float3(" LIGHT_COL
") / float3(255.0, 255.0, 255.0);\n",
name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb"));
}
else
{
out->Write("\t\tcustom_data.{}[{}].color = " LIGHT_COL " / float3(255.0, 255.0, 255.0);\n",
name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb"));
}
out->Write("\t}}\n");
};
for (u32 i = 0; i < 8; i++) for (u32 i = 0; i < 8; i++)
{ {
for (u32 channel_index = 0; channel_index < NUM_XF_COLOR_CHANNELS; channel_index++) for (u32 channel_index = 0; channel_index < NUM_XF_COLOR_CHANNELS; channel_index++)
@ -330,7 +331,7 @@ void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData
{ {
if ((uid_data.light_mask & (1 << (i + 8 * j))) != 0) if ((uid_data.light_mask & (1 << (i + 8 * j))) != 0)
{ {
generate_lighting(out, uid_data, i, j, j, light_count, false); GenerateLighting(out, uid_data, i, j, j, light_count, false);
light_count++; light_count++;
} }
} }
@ -344,7 +345,7 @@ void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData
{ {
if ((uid_data.light_mask & (1 << (i + 8 * (j + 2)))) != 0) if ((uid_data.light_mask & (1 << (i + 8 * (j + 2)))) != 0)
{ {
generate_lighting(out, uid_data, i, j + 2, j, light_count, true); GenerateLighting(out, uid_data, i, j + 2, j, light_count, true);
light_count++; light_count++;
} }
} }