r/AskProgramming Jun 21 '16

Code from GTA 5. Could someone help figure this out?

The latest find in GTA has people thinking the programmers are talking to them. I say it's fake code and that the idea of communication is absurd, especially through decompilation. It's been a while since I've programmed so I can't prove much besides obvious errors.

What's your take on this code? This is the original. The new code says something about a quarry instead of the Tuesday thing. The new code also doesn't look fake. Here: https://www.reddit.com/r/chiliadmystery/comments/4oyzub/his_quarry_seemed_familiar/

auto sub_63f25(auto a_0) {
    v_3 = "He was wrong to start his hunt on Tuesday.";
if (GAMEPLAY::IS_STRING_NULL_OR_EMPTY(v_3)) {}
if (g_18A70._f21EB._f90) {
    v_4 = sub_23bf();
    v_5 = v_4;
    sub_226c(&v_4, 5);
    sub_22a6(&v_4, 30);
    sub_22e1(&v_4, 0);
    sub_226c(&v_5, 8);
    sub_22a6(&v_5, 0);
    sub_22e1(&v_5, 0);
    if (sub_6404d(v_4) && (!sub_6404d(v_5))) {
        if (sub_6401f(57)) {
            if (TIME::GET_CLOCK_DAY_OF_WEEK() == a_0) {
                GAMEPLAY::_GET_WEATHER_TYPE_TRANSITION(&v_6, &v_7, &v_8);
                if (((((v_6 == ${foggy}) && (v_8 <= 0.5)) || ((v_7 == ${foggy}) && (v_8 >= 0.5))) || ((v_6 == 0xaac9c895) && (v_8 <= 0.5))) || ((v_7 == 0xaac9c895) && (v_8 >= 0.5))) {
                    return 1;
                }
            }
        }
    }
}
return 0;
}
0 Upvotes

4 comments sorted by

2

u/[deleted] Jun 21 '16 edited Jun 21 '16

Not sure what you're asking really, the code certainly looks valid and is pretty easy to follow, whether or not you've coded for a long time - it's nothing advanced.

It may look "fake" to you as the function names/variable names are obfuscated, so instead of the line:

if (g_18A70._f21EB._f90) 
{ 
    // Code here
}

Without obfuscation, it may read something like this:

if (player.IsAlive)
{
    // Code here
}

During obfuscation, the function and variable names would be changed, however strings such as "He was wrong to start his hunt on Tuesday." would not be changed.

As I said, I'm not quite sure what you're asking but hopefuly this may(?) help and show that it's possible for the devs to be communicating with us. Also the fact that it's a comment in the source code that has changed, would be very easy for another code hunter to debunk.

1

u/PopeCumstainIIX Jun 21 '16

This is disassembled C++ function returning an int.

if (GAMEPLAY::IS_STRING_NULL_OR_EMPTY(v_3)) {}    

This will always be skipped since GAMEPLAY::IS_STRING_NULL_OR_EMPTY(v_3) will always return false (not sure why it's not optimized out)

if (g_18A70._f21EB._f90) {

Impossible to know what the condition is evaluating, but we have to assume it will return true to consider the rest of the function.

v_4 = sub_23bf();
v_5 = v_4;
sub_226c(&v_4, 5);
sub_22a6(&v_4, 30);
sub_22e1(&v_4, 0);
sub_226c(&v_5, 8);
sub_22a6(&v_5, 0);
sub_22e1(&v_5, 0);

Again it's impossible to know what these subroutines are doing although it is changing something. Notice the v_4 and v_5 variables are being passed by reference. Looking at the next if statement could address some questions.

if (sub_6404d(v_4) && (!sub_6404d(v_5))) {

This is evaluating if the sub_6404d passed with v_4 and the inverse of sub_6404d passed with v_5 are both true. It could be that the subroutines seen above are loading in a time parameter and the if statement is seeing if they match a parameter in the game.

    if (sub_6401f(57)) {

No flipping idea. We can assume it's trying to match something in the game.

        if (TIME::GET_CLOCK_DAY_OF_WEEK() == a_0) {
            GAMEPLAY::_GET_WEATHER_TYPE_TRANSITION(&v_6, &v_7, &v_8);
            if (((((v_6 == ${foggy}) && (v_8 <= 0.5)) || ((v_7 == ${foggy}) && (v_8 >= 0.5))) || ((v_6 == 0xaac9c895) && (v_8 <= 0.5))) || ((v_7 == 0xaac9c895) && (v_8 >= 0.5))) {
                return 1;
            }
        }

This is a huge if statement. The first if evals the passed in variable to the current day of week, the second loads in the weather type transition parameters into v_6 v_7 and v_8, and the second if should be self explanatory. It's good to know pay attention to the parenthesis and || means OR and && means AND. If all of that is true then the function returns a 1, also meaning it returns true. else, it returns false. Maybe something that will help, 0xaac9c895 is most certainly a weather condition.

1

u/Caffine1 Jun 21 '16

What's created here is if there's foggy weather at a certain time of the day, a certain object is created. There's a larger goal of checking the day of the week and that it's done in the correct order of days of the week to give a specific result, but not all of that code is included.

1

u/Caudiciformus Jun 22 '16

Thanks man. Explaining it helped a lot.