Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy behavior for INI read int/float when value does not contain number #283

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

MiranDMC
Copy link
Collaborator

@MiranDMC MiranDMC commented Feb 5, 2025

Commands read_int_from_ini_file and read_float_from_ini_file called from scripts in legacy mode now returns success and value 0 in case of invalid data inside ini file.
Fixes #281

Test script.

{$CLEO .cs}

//set_current_directory 1

write_int_to_ini_file {value} 42 {path} "test.ini" {section} "t" {key} "iVal"
write_float_to_ini_file {value} 42.0 {path} "test.ini" {section} "t" {key} "fVal"
//write_string_to_ini_file {value} "forty two" {path} "test.ini" {section} "t" {key} "sVal" // CLEO4 crash

while true
    wait 100
    
    int iVal = 123
    int iResult = false
    if
        iVal = read_int_from_ini_file {path} "test.ini" {section} "t" {key} "iVal"
    then
        iResult = true
    end
    
    float fVal = 123
    int fResult = false
    if
        fVal = read_float_from_ini_file {path} "test.ini" {section} "t" {key} "fVal"
    then
        fResult = true
    end
    
    longString sVal = "default"
    int sResult = false
    if
        sVal = read_string_from_ini_file {path} "test.ini" {section} "t" {key} "sVal"
    then
        sResult = true
    end
    
    print_formatted_now {format} "INT - ok: %d, value: %d~n~FLOAT - ok: %d, value: %f~n~TXT - ok: %d, value: %s" {time} 1000 {args} iResult iVal fResult fVal sResult sVal
end

@MiranDMC MiranDMC requested a review from x87 February 5, 2025 07:34
@MiranDMC MiranDMC merged commit bd49199 into master Feb 5, 2025
2 checks passed
@MiranDMC MiranDMC deleted the INI_read_int/float_CLEO4_mode_fixes_ branch February 5, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tuning mod v 3.01 by junior_Djjr not working
2 participants