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

Fix return-type and value of Pathing::GetApproximateLength #127

Merged
merged 1 commit into from Sep 6, 2014
Merged

Fix return-type and value of Pathing::GetApproximateLength #127

merged 1 commit into from Sep 6, 2014

Conversation

rlcevg
Copy link
Contributor

@rlcevg rlcevg commented Sep 1, 2014

Changes generation of this not very useful code (ORIGINAL):

EXPORT(float) bridged_Pathing_getApproximateLength(int skirmishAIId, float* start_posF3, float* end_posF3, int pathType, float goalRadius) {

    struct SGetApproximateLengthPathCommand commandData;
    int internal_ret;
    commandData.start_posF3 = start_posF3;
    commandData.end_posF3 = end_posF3;
    commandData.pathType = pathType;
    commandData.goalRadius = goalRadius;

    internal_ret = id_clb[skirmishAIId]->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_PATH_GET_APPROXIMATE_LENGTH, &commandData);

    internal_ret = commandData.ret_approximatePathLength;
    if (internal_ret == 0) {
        internal_ret = commandData.ret_approximatePathLength;
    } else {
        internal_ret = 0;
    }
    return internal_ret;
}

to more meaningful code (FIXED):

EXPORT(float) bridged_Pathing_getApproximateLength(int skirmishAIId, float* start_posF3, float* end_posF3, int pathType, float goalRadius) {

    struct SGetApproximateLengthPathCommand commandData;
    int internal_ret;
    commandData.start_posF3 = start_posF3;
    commandData.end_posF3 = end_posF3;
    commandData.pathType = pathType;
    commandData.goalRadius = goalRadius;

    internal_ret = id_clb[skirmishAIId]->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_PATH_GET_APPROXIMATE_LENGTH, &commandData);

    if (internal_ret == 0) {
        return commandData.ret_approximatePathLength;
    } else {
        return (float)0;
    }
}

That way function will return proper value instead of always 0.

PS: Strange behavior noticed. If start point = end point then length is always 10. Not a big problem and its anyway ApproximateLength.

jk3064 added a commit that referenced this pull request Sep 6, 2014
Fix return-type and value of Pathing::GetApproximateLength
@jk3064 jk3064 merged commit e21be6c into spring:develop Sep 6, 2014
@rlcevg rlcevg deleted the fix_awk_GetApproximateLength branch December 16, 2019 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants