diff --git a/gfx/drivers_shader/glslang.cpp b/gfx/drivers_shader/glslang.cpp index 86659b4d19..b9fc0306ae 100644 --- a/gfx/drivers_shader/glslang.cpp +++ b/gfx/drivers_shader/glslang.cpp @@ -172,190 +172,205 @@ SlangProcess::SlangProcess() const char *value_str = strtok(0, delims); int value = (int)strtoul(value_str, nullptr, 0); - if (string_is_equal(token, "MaxLights")) - Resources.maxLights = value; - else if (string_is_equal(token, "MaxClipPlanes")) - Resources.maxClipPlanes = value; - else if (string_is_equal(token, "MaxTextureUnits")) - Resources.maxTextureUnits = value; - else if (string_is_equal(token, "MaxTextureCoords")) - Resources.maxTextureCoords = value; - else if (string_is_equal(token, "MaxVertexAttribs")) - Resources.maxVertexAttribs = value; - else if (string_is_equal(token, "MaxVertexUniformComponents")) - Resources.maxVertexUniformComponents = value; - else if (string_is_equal(token, "MaxVaryingFloats")) - Resources.maxVaryingFloats = value; - else if (string_is_equal(token, "MaxVertexTextureImageUnits")) - Resources.maxVertexTextureImageUnits = value; - else if (string_is_equal(token, "MaxCombinedTextureImageUnits")) - Resources.maxCombinedTextureImageUnits = value; - else if (string_is_equal(token, "MaxTextureImageUnits")) - Resources.maxTextureImageUnits = value; - else if (string_is_equal(token, "MaxFragmentUniformComponents")) - Resources.maxFragmentUniformComponents = value; - else if (string_is_equal(token, "MaxDrawBuffers")) - Resources.maxDrawBuffers = value; - else if (string_is_equal(token, "MaxVertexUniformVectors")) - Resources.maxVertexUniformVectors = value; - else if (string_is_equal(token, "MaxVaryingVectors")) - Resources.maxVaryingVectors = value; - else if (string_is_equal(token, "MaxFragmentUniformVectors")) - Resources.maxFragmentUniformVectors = value; - else if (string_is_equal(token, "MaxVertexOutputVectors")) - Resources.maxVertexOutputVectors = value; - else if (string_is_equal(token, "MaxFragmentInputVectors")) - Resources.maxFragmentInputVectors = value; - else if (string_is_equal(token, "MinProgramTexelOffset")) - Resources.minProgramTexelOffset = value; - else if (string_is_equal(token, "MaxProgramTexelOffset")) - Resources.maxProgramTexelOffset = value; - else if (string_is_equal(token, "MaxClipDistances")) - Resources.maxClipDistances = value; - else if (string_is_equal(token, "MaxComputeWorkGroupCountX")) - Resources.maxComputeWorkGroupCountX = value; - else if (string_is_equal(token, "MaxComputeWorkGroupCountY")) - Resources.maxComputeWorkGroupCountY = value; - else if (string_is_equal(token, "MaxComputeWorkGroupCountZ")) - Resources.maxComputeWorkGroupCountZ = value; - else if (string_is_equal(token, "MaxComputeWorkGroupSizeX")) - Resources.maxComputeWorkGroupSizeX = value; - else if (string_is_equal(token, "MaxComputeWorkGroupSizeY")) - Resources.maxComputeWorkGroupSizeY = value; - else if (string_is_equal(token, "MaxComputeWorkGroupSizeZ")) - Resources.maxComputeWorkGroupSizeZ = value; - else if (string_is_equal(token, "MaxComputeUniformComponents")) - Resources.maxComputeUniformComponents = value; - else if (string_is_equal(token, "MaxComputeTextureImageUnits")) - Resources.maxComputeTextureImageUnits = value; - else if (string_is_equal(token, "MaxComputeImageUniforms")) - Resources.maxComputeImageUniforms = value; - else if (string_is_equal(token, "MaxComputeAtomicCounters")) - Resources.maxComputeAtomicCounters = value; - else if (string_is_equal(token, "MaxComputeAtomicCounterBuffers")) - Resources.maxComputeAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxVaryingComponents")) - Resources.maxVaryingComponents = value; - else if (string_is_equal(token, "MaxVertexOutputComponents")) - Resources.maxVertexOutputComponents = value; - else if (string_is_equal(token, "MaxGeometryInputComponents")) - Resources.maxGeometryInputComponents = value; - else if (string_is_equal(token, "MaxGeometryOutputComponents")) - Resources.maxGeometryOutputComponents = value; - else if (string_is_equal(token, "MaxFragmentInputComponents")) - Resources.maxFragmentInputComponents = value; - else if (string_is_equal(token, "MaxImageUnits")) - Resources.maxImageUnits = value; - else if (string_is_equal(token, "MaxCombinedImageUnitsAndFragmentOutputs")) - Resources.maxCombinedImageUnitsAndFragmentOutputs = value; - else if (string_is_equal(token, "MaxCombinedShaderOutputResources")) - Resources.maxCombinedShaderOutputResources = value; - else if (string_is_equal(token, "MaxImageSamples")) - Resources.maxImageSamples = value; - else if (string_is_equal(token, "MaxVertexImageUniforms")) - Resources.maxVertexImageUniforms = value; - else if (string_is_equal(token, "MaxTessControlImageUniforms")) - Resources.maxTessControlImageUniforms = value; - else if (string_is_equal(token, "MaxTessEvaluationImageUniforms")) - Resources.maxTessEvaluationImageUniforms = value; - else if (string_is_equal(token, "MaxGeometryImageUniforms")) - Resources.maxGeometryImageUniforms = value; - else if (string_is_equal(token, "MaxFragmentImageUniforms")) - Resources.maxFragmentImageUniforms = value; - else if (string_is_equal(token, "MaxCombinedImageUniforms")) - Resources.maxCombinedImageUniforms = value; - else if (string_is_equal(token, "MaxGeometryTextureImageUnits")) - Resources.maxGeometryTextureImageUnits = value; - else if (string_is_equal(token, "MaxGeometryOutputVertices")) - Resources.maxGeometryOutputVertices = value; - else if (string_is_equal(token, "MaxGeometryTotalOutputComponents")) - Resources.maxGeometryTotalOutputComponents = value; - else if (string_is_equal(token, "MaxGeometryUniformComponents")) - Resources.maxGeometryUniformComponents = value; - else if (string_is_equal(token, "MaxGeometryVaryingComponents")) - Resources.maxGeometryVaryingComponents = value; - else if (string_is_equal(token, "MaxTessControlInputComponents")) - Resources.maxTessControlInputComponents = value; - else if (string_is_equal(token, "MaxTessControlOutputComponents")) - Resources.maxTessControlOutputComponents = value; - else if (string_is_equal(token, "MaxTessControlTextureImageUnits")) - Resources.maxTessControlTextureImageUnits = value; - else if (string_is_equal(token, "MaxTessControlUniformComponents")) - Resources.maxTessControlUniformComponents = value; - else if (string_is_equal(token, "MaxTessControlTotalOutputComponents")) - Resources.maxTessControlTotalOutputComponents = value; - else if (string_is_equal(token, "MaxTessEvaluationInputComponents")) - Resources.maxTessEvaluationInputComponents = value; - else if (string_is_equal(token, "MaxTessEvaluationOutputComponents")) - Resources.maxTessEvaluationOutputComponents = value; - else if (string_is_equal(token, "MaxTessEvaluationTextureImageUnits")) - Resources.maxTessEvaluationTextureImageUnits = value; - else if (string_is_equal(token, "MaxTessEvaluationUniformComponents")) - Resources.maxTessEvaluationUniformComponents = value; - else if (string_is_equal(token, "MaxTessPatchComponents")) - Resources.maxTessPatchComponents = value; - else if (string_is_equal(token, "MaxPatchVertices")) - Resources.maxPatchVertices = value; - else if (string_is_equal(token, "MaxTessGenLevel")) - Resources.maxTessGenLevel = value; - else if (string_is_equal(token, "MaxViewports")) - Resources.maxViewports = value; - else if (string_is_equal(token, "MaxVertexAtomicCounters")) - Resources.maxVertexAtomicCounters = value; - else if (string_is_equal(token, "MaxTessControlAtomicCounters")) - Resources.maxTessControlAtomicCounters = value; - else if (string_is_equal(token, "MaxTessEvaluationAtomicCounters")) - Resources.maxTessEvaluationAtomicCounters = value; - else if (string_is_equal(token, "MaxGeometryAtomicCounters")) - Resources.maxGeometryAtomicCounters = value; - else if (string_is_equal(token, "MaxFragmentAtomicCounters")) - Resources.maxFragmentAtomicCounters = value; - else if (string_is_equal(token, "MaxCombinedAtomicCounters")) - Resources.maxCombinedAtomicCounters = value; - else if (string_is_equal(token, "MaxAtomicCounterBindings")) - Resources.maxAtomicCounterBindings = value; - else if (string_is_equal(token, "MaxVertexAtomicCounterBuffers")) - Resources.maxVertexAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxTessControlAtomicCounterBuffers")) - Resources.maxTessControlAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxTessEvaluationAtomicCounterBuffers")) - Resources.maxTessEvaluationAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxGeometryAtomicCounterBuffers")) - Resources.maxGeometryAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxFragmentAtomicCounterBuffers")) - Resources.maxFragmentAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxCombinedAtomicCounterBuffers")) - Resources.maxCombinedAtomicCounterBuffers = value; - else if (string_is_equal(token, "MaxAtomicCounterBufferSize")) - Resources.maxAtomicCounterBufferSize = value; - else if (string_is_equal(token, "MaxTransformFeedbackBuffers")) - Resources.maxTransformFeedbackBuffers = value; - else if (string_is_equal(token, "MaxTransformFeedbackInterleavedComponents")) - Resources.maxTransformFeedbackInterleavedComponents = value; - else if (string_is_equal(token, "MaxCullDistances")) - Resources.maxCullDistances = value; - else if (string_is_equal(token, "MaxCombinedClipAndCullDistances")) - Resources.maxCombinedClipAndCullDistances = value; - else if (string_is_equal(token, "MaxSamples")) - Resources.maxSamples = value; + if (string_starts_with(token, "Max")) + { + if (string_starts_with(token, "MaxCompute")) + { + if (string_is_equal(token, "MaxComputeWorkGroupCountX")) + Resources.maxComputeWorkGroupCountX = value; + else if (string_is_equal(token, "MaxComputeWorkGroupCountY")) + Resources.maxComputeWorkGroupCountY = value; + else if (string_is_equal(token, "MaxComputeWorkGroupCountZ")) + Resources.maxComputeWorkGroupCountZ = value; + else if (string_is_equal(token, "MaxComputeWorkGroupSizeX")) + Resources.maxComputeWorkGroupSizeX = value; + else if (string_is_equal(token, "MaxComputeWorkGroupSizeY")) + Resources.maxComputeWorkGroupSizeY = value; + else if (string_is_equal(token, "MaxComputeWorkGroupSizeZ")) + Resources.maxComputeWorkGroupSizeZ = value; + else if (string_is_equal(token, "MaxComputeUniformComponents")) + Resources.maxComputeUniformComponents = value; + else if (string_is_equal(token, "MaxComputeTextureImageUnits")) + Resources.maxComputeTextureImageUnits = value; + else if (string_is_equal(token, "MaxComputeImageUniforms")) + Resources.maxComputeImageUniforms = value; + else if (string_is_equal(token, "MaxComputeAtomicCounters")) + Resources.maxComputeAtomicCounters = value; + else if (string_is_equal(token, "MaxComputeAtomicCounterBuffers")) + Resources.maxComputeAtomicCounterBuffers = value; + } + else if (string_starts_with(token, "MaxVertex")) + { + if (string_is_equal(token, "MaxVertexAttribs")) + Resources.maxVertexAttribs = value; + else if (string_is_equal(token, "MaxVertexUniformComponents")) + Resources.maxVertexUniformComponents = value; + else if (string_is_equal(token, "MaxVertexTextureImageUnits")) + Resources.maxVertexTextureImageUnits = value; + else if (string_is_equal(token, "MaxVertexUniformVectors")) + Resources.maxVertexUniformVectors = value; + else if (string_is_equal(token, "MaxVertexOutputVectors")) + Resources.maxVertexOutputVectors = value; + else if (string_is_equal(token, "MaxVertexOutputComponents")) + Resources.maxVertexOutputComponents = value; + else if (string_is_equal(token, "MaxVertexImageUniforms")) + Resources.maxVertexImageUniforms = value; + else if (string_is_equal(token, "MaxVertexAtomicCounters")) + Resources.maxVertexAtomicCounters = value; + else if (string_is_equal(token, "MaxVertexAtomicCounterBuffers")) + Resources.maxVertexAtomicCounterBuffers = value; + } + else if (string_starts_with(token, "MaxTess")) + { + if (string_is_equal(token, "MaxTessControlInputComponents")) + Resources.maxTessControlInputComponents = value; + else if (string_is_equal(token, "MaxTessControlOutputComponents")) + Resources.maxTessControlOutputComponents = value; + else if (string_is_equal(token, "MaxTessControlTextureImageUnits")) + Resources.maxTessControlTextureImageUnits = value; + else if (string_is_equal(token, "MaxTessControlUniformComponents")) + Resources.maxTessControlUniformComponents = value; + else if (string_is_equal(token, "MaxTessControlTotalOutputComponents")) + Resources.maxTessControlTotalOutputComponents = value; + else if (string_is_equal(token, "MaxTessEvaluationInputComponents")) + Resources.maxTessEvaluationInputComponents = value; + else if (string_is_equal(token, "MaxTessEvaluationOutputComponents")) + Resources.maxTessEvaluationOutputComponents = value; + else if (string_is_equal(token, "MaxTessEvaluationTextureImageUnits")) + Resources.maxTessEvaluationTextureImageUnits = value; + else if (string_is_equal(token, "MaxTessEvaluationUniformComponents")) + Resources.maxTessEvaluationUniformComponents = value; + else if (string_is_equal(token, "MaxTessPatchComponents")) + Resources.maxTessPatchComponents = value; + else if (string_is_equal(token, "MaxTessGenLevel")) + Resources.maxTessGenLevel = value; + else if (string_is_equal(token, "MaxTessControlAtomicCounters")) + Resources.maxTessControlAtomicCounters = value; + else if (string_is_equal(token, "MaxTessEvaluationAtomicCounters")) + Resources.maxTessEvaluationAtomicCounters = value; + else if (string_is_equal(token, "MaxTessControlAtomicCounterBuffers")) + Resources.maxTessControlAtomicCounterBuffers = value; + else if (string_is_equal(token, "MaxTessEvaluationAtomicCounterBuffers")) + Resources.maxTessEvaluationAtomicCounterBuffers = value; + else if (string_is_equal(token, "MaxTessControlImageUniforms")) + Resources.maxTessControlImageUniforms = value; + else if (string_is_equal(token, "MaxTessEvaluationImageUniforms")) + Resources.maxTessEvaluationImageUniforms = value; + } + else if (string_is_equal(token, "MaxLights")) + Resources.maxLights = value; + else if (string_is_equal(token, "MaxClipPlanes")) + Resources.maxClipPlanes = value; + else if (string_is_equal(token, "MaxTextureUnits")) + Resources.maxTextureUnits = value; + else if (string_is_equal(token, "MaxTextureCoords")) + Resources.maxTextureCoords = value; + else if (string_is_equal(token, "MaxVaryingFloats")) + Resources.maxVaryingFloats = value; + else if (string_is_equal(token, "MaxCombinedTextureImageUnits")) + Resources.maxCombinedTextureImageUnits = value; + else if (string_is_equal(token, "MaxTextureImageUnits")) + Resources.maxTextureImageUnits = value; + else if (string_is_equal(token, "MaxFragmentUniformComponents")) + Resources.maxFragmentUniformComponents = value; + else if (string_is_equal(token, "MaxDrawBuffers")) + Resources.maxDrawBuffers = value; + else if (string_is_equal(token, "MaxVaryingVectors")) + Resources.maxVaryingVectors = value; + else if (string_is_equal(token, "MaxFragmentUniformVectors")) + Resources.maxFragmentUniformVectors = value; + else if (string_is_equal(token, "MaxFragmentInputVectors")) + Resources.maxFragmentInputVectors = value; + else if (string_is_equal(token, "MinProgramTexelOffset")) + Resources.minProgramTexelOffset = value; + else if (string_is_equal(token, "MaxProgramTexelOffset")) + Resources.maxProgramTexelOffset = value; + else if (string_is_equal(token, "MaxClipDistances")) + Resources.maxClipDistances = value; + else if (string_is_equal(token, "MaxVaryingComponents")) + Resources.maxVaryingComponents = value; + else if (string_is_equal(token, "MaxGeometryInputComponents")) + Resources.maxGeometryInputComponents = value; + else if (string_is_equal(token, "MaxGeometryOutputComponents")) + Resources.maxGeometryOutputComponents = value; + else if (string_is_equal(token, "MaxFragmentInputComponents")) + Resources.maxFragmentInputComponents = value; + else if (string_is_equal(token, "MaxImageUnits")) + Resources.maxImageUnits = value; + else if (string_is_equal(token, "MaxCombinedImageUnitsAndFragmentOutputs")) + Resources.maxCombinedImageUnitsAndFragmentOutputs = value; + else if (string_is_equal(token, "MaxCombinedShaderOutputResources")) + Resources.maxCombinedShaderOutputResources = value; + else if (string_is_equal(token, "MaxImageSamples")) + Resources.maxImageSamples = value; + else if (string_is_equal(token, "MaxGeometryImageUniforms")) + Resources.maxGeometryImageUniforms = value; + else if (string_is_equal(token, "MaxFragmentImageUniforms")) + Resources.maxFragmentImageUniforms = value; + else if (string_is_equal(token, "MaxCombinedImageUniforms")) + Resources.maxCombinedImageUniforms = value; + else if (string_is_equal(token, "MaxGeometryTextureImageUnits")) + Resources.maxGeometryTextureImageUnits = value; + else if (string_is_equal(token, "MaxGeometryOutputVertices")) + Resources.maxGeometryOutputVertices = value; + else if (string_is_equal(token, "MaxGeometryTotalOutputComponents")) + Resources.maxGeometryTotalOutputComponents = value; + else if (string_is_equal(token, "MaxGeometryUniformComponents")) + Resources.maxGeometryUniformComponents = value; + else if (string_is_equal(token, "MaxGeometryVaryingComponents")) + Resources.maxGeometryVaryingComponents = value; + else if (string_is_equal(token, "MaxPatchVertices")) + Resources.maxPatchVertices = value; + else if (string_is_equal(token, "MaxViewports")) + Resources.maxViewports = value; + else if (string_is_equal(token, "MaxGeometryAtomicCounters")) + Resources.maxGeometryAtomicCounters = value; + else if (string_is_equal(token, "MaxFragmentAtomicCounters")) + Resources.maxFragmentAtomicCounters = value; + else if (string_is_equal(token, "MaxCombinedAtomicCounters")) + Resources.maxCombinedAtomicCounters = value; + else if (string_is_equal(token, "MaxAtomicCounterBindings")) + Resources.maxAtomicCounterBindings = value; + else if (string_is_equal(token, "MaxGeometryAtomicCounterBuffers")) + Resources.maxGeometryAtomicCounterBuffers = value; + else if (string_is_equal(token, "MaxFragmentAtomicCounterBuffers")) + Resources.maxFragmentAtomicCounterBuffers = value; + else if (string_is_equal(token, "MaxCombinedAtomicCounterBuffers")) + Resources.maxCombinedAtomicCounterBuffers = value; + else if (string_is_equal(token, "MaxAtomicCounterBufferSize")) + Resources.maxAtomicCounterBufferSize = value; + else if (string_is_equal(token, "MaxTransformFeedbackBuffers")) + Resources.maxTransformFeedbackBuffers = value; + else if (string_is_equal(token, "MaxTransformFeedbackInterleavedComponents")) + Resources.maxTransformFeedbackInterleavedComponents = value; + else if (string_is_equal(token, "MaxCullDistances")) + Resources.maxCullDistances = value; + else if (string_is_equal(token, "MaxCombinedClipAndCullDistances")) + Resources.maxCombinedClipAndCullDistances = value; + else if (string_is_equal(token, "MaxSamples")) + Resources.maxSamples = value; + } + else if (string_starts_with(token, "general")) + { + if (string_is_equal(token, "generalUniformIndexing")) + Resources.limits.generalUniformIndexing = (value != 0); + else if (string_is_equal(token, "generalAttributeMatrixVectorIndexing")) + Resources.limits.generalAttributeMatrixVectorIndexing = (value != 0); + else if (string_is_equal(token, "generalVaryingIndexing")) + Resources.limits.generalVaryingIndexing = (value != 0); + else if (string_is_equal(token, "generalSamplerIndexing")) + Resources.limits.generalSamplerIndexing = (value != 0); + else if (string_is_equal(token, "generalVariableIndexing")) + Resources.limits.generalVariableIndexing = (value != 0); + else if (string_is_equal(token, "generalConstantMatrixVectorIndexing")) + Resources.limits.generalConstantMatrixVectorIndexing = (value != 0); + } else if (string_is_equal(token, "nonInductiveForLoops")) Resources.limits.nonInductiveForLoops = (value != 0); else if (string_is_equal(token, "whileLoops")) Resources.limits.whileLoops = (value != 0); else if (string_is_equal(token, "doWhileLoops")) Resources.limits.doWhileLoops = (value != 0); - else if (string_is_equal(token, "generalUniformIndexing")) - Resources.limits.generalUniformIndexing = (value != 0); - else if (string_is_equal(token, "generalAttributeMatrixVectorIndexing")) - Resources.limits.generalAttributeMatrixVectorIndexing = (value != 0); - else if (string_is_equal(token, "generalVaryingIndexing")) - Resources.limits.generalVaryingIndexing = (value != 0); - else if (string_is_equal(token, "generalSamplerIndexing")) - Resources.limits.generalSamplerIndexing = (value != 0); - else if (string_is_equal(token, "generalVariableIndexing")) - Resources.limits.generalVariableIndexing = (value != 0); - else if (string_is_equal(token, "generalConstantMatrixVectorIndexing")) - Resources.limits.generalConstantMatrixVectorIndexing = (value != 0); token = strtok(0, delims); } diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 15438c9daa..e0646de9d3 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -436,26 +436,32 @@ static void cheat_manager_load_cb_second_pass(char *key, char *value) cheat_st->cheats[cheat_idx].handler = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "memory_search_size")) cheat_st->cheats[cheat_idx].memory_search_size = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "repeat_add_to_address")) - cheat_st->cheats[cheat_idx].repeat_add_to_address = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "repeat_add_to_value")) - cheat_st->cheats[cheat_idx].repeat_add_to_value = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "repeat_count")) - cheat_st->cheats[cheat_idx].repeat_count = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_port")) - cheat_st->cheats[cheat_idx].rumble_port = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_primary_duration")) - cheat_st->cheats[cheat_idx].rumble_primary_duration = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_primary_strength")) - cheat_st->cheats[cheat_idx].rumble_primary_strength = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_secondary_duration")) - cheat_st->cheats[cheat_idx].rumble_secondary_duration = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_secondary_strength")) - cheat_st->cheats[cheat_idx].rumble_secondary_strength = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_type")) - cheat_st->cheats[cheat_idx].rumble_type = (unsigned)strtoul(value, NULL, 0); - else if (string_is_equal(key, "rumble_value")) - cheat_st->cheats[cheat_idx].rumble_value = (unsigned)strtoul(value, NULL, 0); + else if (string_starts_with(key, "repeat_")) + { + if (string_is_equal(key, "repeat_add_to_address")) + cheat_st->cheats[cheat_idx].repeat_add_to_address = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "repeat_add_to_value")) + cheat_st->cheats[cheat_idx].repeat_add_to_value = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "repeat_count")) + cheat_st->cheats[cheat_idx].repeat_count = (unsigned)strtoul(value, NULL, 0); + } + else if (string_starts_with(key, "rumble")) + { + if (string_is_equal(key, "rumble_port")) + cheat_st->cheats[cheat_idx].rumble_port = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "rumble_primary_duration")) + cheat_st->cheats[cheat_idx].rumble_primary_duration = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "rumble_primary_strength")) + cheat_st->cheats[cheat_idx].rumble_primary_strength = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "rumble_secondary_duration")) + cheat_st->cheats[cheat_idx].rumble_secondary_duration = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "rumble_secondary_strength")) + cheat_st->cheats[cheat_idx].rumble_secondary_strength = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "rumble_type")) + cheat_st->cheats[cheat_idx].rumble_type = (unsigned)strtoul(value, NULL, 0); + else if (string_is_equal(key, "rumble_value")) + cheat_st->cheats[cheat_idx].rumble_value = (unsigned)strtoul(value, NULL, 0); + } else if (string_is_equal(key, "value")) cheat_st->cheats[cheat_idx].value = (unsigned)strtoul(value, NULL, 0); } diff --git a/playlist.c b/playlist.c index 2883bbe5c1..ea544eb5db 100644 --- a/playlist.c +++ b/playlist.c @@ -1832,9 +1832,7 @@ static JSON_Parser_HandlerResult JSONEndArrayHandler(JSON_Parser parser) else if (pCtx->object_depth == 2) { if (pCtx->in_subsystem_roms && string_is_equal(pCtx->current_items_string, "subsystem_roms") && pCtx->array_depth == 1) - { pCtx->in_subsystem_roms = false; - } } return JSON_Parser_Continue; @@ -1858,8 +1856,8 @@ static JSON_Parser_HandlerResult JSONStartObjectHandler(JSON_Parser parser) * Note: We can't just abort here, since there may * be more metadata to read at the end of the file... */ RARCH_WARN("JSON file contains more entries than current playlist capacity. Excess entries will be discarded.\n"); - pCtx->capacity_exceeded = true; - pCtx->current_entry = NULL; + pCtx->capacity_exceeded = true; + pCtx->current_entry = NULL; /* In addition, since we are discarding excess entries, * the playlist must be flagged as being modified * (i.e. the playlist is not the same as when it was @@ -1916,10 +1914,6 @@ static JSON_Parser_HandlerResult JSONStringHandler(JSON_Parser parser, char *pVa free(*pCtx->current_entry_val); *pCtx->current_entry_val = strdup(pValue); } - else - { - /* must be a value for an unknown member we aren't tracking, skip it */ - } } } else if (pCtx->object_depth == 1) @@ -1961,10 +1955,6 @@ static JSON_Parser_HandlerResult JSONNumberHandler(JSON_Parser parser, char *pVa *pCtx->current_entry_int_val = (int)strtoul(pValue, NULL, 10); else if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue)) *pCtx->current_entry_uint_val = (unsigned)strtoul(pValue, NULL, 10); - else - { - /* must be a value for an unknown member we aren't tracking, skip it */ - } } } else if (pCtx->object_depth == 1) @@ -1985,10 +1975,6 @@ static JSON_Parser_HandlerResult JSONNumberHandler(JSON_Parser parser, char *pVa *pCtx->current_meta_thumbnail_mode_val = (enum playlist_thumbnail_mode)strtoul(pValue, NULL, 10); else if (pCtx->current_meta_sort_mode_val) *pCtx->current_meta_sort_mode_val = (enum playlist_sort_mode)strtoul(pValue, NULL, 10); - else - { - /* must be a value for an unknown member we aren't tracking, skip it */ - } } } } @@ -2041,33 +2027,38 @@ static JSON_Parser_HandlerResult JSONObjectMemberHandler(JSON_Parser parser, cha pCtx->current_entry_val = &pCtx->current_entry->crc32; else if (string_is_equal(pValue, "db_name")) pCtx->current_entry_val = &pCtx->current_entry->db_name; - else if (string_is_equal(pValue, "subsystem_ident")) - pCtx->current_entry_val = &pCtx->current_entry->subsystem_ident; - else if (string_is_equal(pValue, "subsystem_name")) - pCtx->current_entry_val = &pCtx->current_entry->subsystem_name; - else if (string_is_equal(pValue, "subsystem_roms")) - pCtx->current_entry_string_list_val = &pCtx->current_entry->subsystem_roms; - else if (string_is_equal(pValue, "runtime_hours")) - pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_hours; - else if (string_is_equal(pValue, "runtime_minutes")) - pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_minutes; - else if (string_is_equal(pValue, "runtime_seconds")) - pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_seconds; - else if (string_is_equal(pValue, "last_played_year")) - pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_year; - else if (string_is_equal(pValue, "last_played_month")) - pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_month; - else if (string_is_equal(pValue, "last_played_day")) - pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_day; - else if (string_is_equal(pValue, "last_played_hour")) - pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_hour; - else if (string_is_equal(pValue, "last_played_minute")) - pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_minute; - else if (string_is_equal(pValue, "last_played_second")) - pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_second; - else + else if (string_starts_with(pValue, "subsystem_")) { - /* ignore unknown members */ + if (string_is_equal(pValue, "subsystem_ident")) + pCtx->current_entry_val = &pCtx->current_entry->subsystem_ident; + else if (string_is_equal(pValue, "subsystem_name")) + pCtx->current_entry_val = &pCtx->current_entry->subsystem_name; + else if (string_is_equal(pValue, "subsystem_roms")) + pCtx->current_entry_string_list_val = &pCtx->current_entry->subsystem_roms; + } + else if (string_starts_with(pValue, "runtime_")) + { + if (string_is_equal(pValue, "runtime_hours")) + pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_hours; + else if (string_is_equal(pValue, "runtime_minutes")) + pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_minutes; + else if (string_is_equal(pValue, "runtime_seconds")) + pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_seconds; + } + else if (string_starts_with(pValue, "last_played_")) + { + if (string_is_equal(pValue, "last_played_year")) + pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_year; + else if (string_is_equal(pValue, "last_played_month")) + pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_month; + else if (string_is_equal(pValue, "last_played_day")) + pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_day; + else if (string_is_equal(pValue, "last_played_hour")) + pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_hour; + else if (string_is_equal(pValue, "last_played_minute")) + pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_minute; + else if (string_is_equal(pValue, "last_played_second")) + pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_second; } } else @@ -2108,10 +2099,6 @@ static JSON_Parser_HandlerResult JSONObjectMemberHandler(JSON_Parser parser, cha pCtx->current_meta_thumbnail_mode_val = &pCtx->playlist->left_thumbnail_mode; else if (string_is_equal(pValue, "sort_mode")) pCtx->current_meta_sort_mode_val = &pCtx->playlist->sort_mode; - else - { - /* ignore unknown members */ - } } } } @@ -2122,21 +2109,19 @@ static JSON_Parser_HandlerResult JSONObjectMemberHandler(JSON_Parser parser, cha static void get_old_format_metadata_value( char *metadata_line, char *value, size_t len) { - char *start = NULL; char *end = NULL; - - start = strchr(metadata_line, '\"'); + char *start = strchr(metadata_line, '\"'); if (!start) return; start++; - end = strchr(start, '\"'); + end = strchr(start, '\"'); if (!end) return; - *end = '\0'; + *end = '\0'; strlcpy(value, start, len); } @@ -2145,16 +2130,14 @@ static bool playlist_read_file( { unsigned i; int test_char; - intfstream_t *file = NULL; - #if defined(HAVE_ZLIB) /* Always use RZIP interface when reading playlists * > this will automatically handle uncompressed * data */ - file = intfstream_open_rzip_file(path, + intfstream_t *file = intfstream_open_rzip_file(path, RETRO_VFS_FILE_ACCESS_READ); #else - file = intfstream_open_file(path, + intfstream_t *file = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); #endif @@ -2175,8 +2158,7 @@ static bool playlist_read_file( if (test_char == EOF) /* read error or end of file */ goto end; - } - while (!isgraph(test_char) || test_char > 0x7F); + }while (!isgraph(test_char) || test_char > 0x7F); if (test_char == '{') {