ThirteenAG / WidescreenFixesPack

Plugins to make or improve widescreen resolutions support in games, add more features and fix bugs.
https://thirteenag.github.io/wfp
MIT License
2.33k stars 221 forks source link

[THUG1] Not compatible with the No-CD Crack #135

Closed Catarax closed 7 years ago

Catarax commented 8 years ago

The only no-cd crack of Tony Hawk's Underground 1 can be downloaded here: http://thps-mods.com/cracks.php

And it's not compatible with the current widescreen hack.

ThirteenAG commented 8 years ago

I'll remake Tony Hawk's fixes in the future, they won't be exe dependent.

ThirteenAG commented 7 years ago

https://github.com/ThirteenAG/WidescreenFixesPack/issues/163#issuecomment-294505103

Catarax commented 7 years ago

Perfect, thank you!

Also there is a game-bug on each THPS3+ games, they have always the SAME random soundtrack songorder (exclusive bug on the lazy PC port), I've tried to fix it with qb scripts but it was partial because there is a fixed value to randomize the song list when starting the exe, so this can only be done through dll hack.

I can give you much more information if you want, only THUG PRO has been fixed by the developpers of the project. The THUG1 Xbox source code exists to understand how it's managed also...

I'm not into dll hacks but this is really weird they didn't fixed it from THPS3 to American Wasteland. It looks like a missing value never randomized at all and probably all games need the same fix.

If you could have a look, it would be really great, this is really boring to have the same soundtrack on games like that.

ThirteenAG commented 7 years ago

Well, provide as many information as you can, maybe I'll take a look. Also do note that I never played any of those games, so an easy way to access/reproduce the issue would be good to know.

Catarax commented 7 years ago

Okay, here's the informations :

Reproducing the bug :

Difference with console ports :

Origin of the bug : "THUG.exe

When the game is first run it uses a fixed seed value (107482099), which makes all "random" actions at startup very predictable.

From scripts you can call "Randomize" to randomize the seed and then "SetRandomMode" to re-shuffle the soundtrack. But its still going to be rather predictable.

To fix this you need to change the function that generates the "random seed", in the executable."

Fixing the bug: "exe functions aren't in qb format. Unless you create a proxy dll, as Mortens answer implied, you won't be able to override the existing function. You can take my suggestion and prevent the current cfunc from being called from within qb scripts and instead call on your own functions but directly overriding the function is out of the question through scripting alone. The THUG1 source was released and is on git hub somewhere. Have a look into cfuncs.cpp and music.cpp. "

Tony Hawk's Underground Xbox source code : https://github.com/thug1src/thug https://github.com/thug1src/thug/blob/master/Code/Sk/Scripting/cfuncs.cpp https://github.com/thug1src/thug/blob/master/Code/Gel/Music/music.cpp

Other games affected:

If you prefer a new ticket bug, let me know. Thanks!

ThirteenAG commented 7 years ago

I'll let you know.

ThirteenAG commented 7 years ago

When exactly this randomizing action happens? Only on startup? Or there's a possibility to randomize songs order in game?

ThirteenAG commented 7 years ago

I suppose I can replace this code: https://github.com/thug1src/thug/blob/master/Code/Gel/Music/music.cpp#L348 with some other implementation, if that's what you after. Not sure if modifying random function directly won't break other things, so perhaps it's better to deal with songs randomization directly.

Catarax commented 7 years ago

Yes, it could fix it by that way.

There is 2 options in Tony Hawk's games soundtrack :

But when you skip a track in Random order mode, it's always the same one from a static random playlist etablished by the exe. (by the value 107482099 stored in it). Just changing that value defined at startup would bring another playlist.

Maybe you can call randomly a number of "Randomize()" then SetRandomMode(1): at each time the exe is launched, would be enough else. In QB Scripts, I can't use theses functions, probably due to the initial startup taking over.

ThirteenAG commented 7 years ago

New build is available, check it out and let me know if that would suffice.

Catarax commented 7 years ago

Thanks a lot for fixing this, this is very good! Took the time to donate for your work.

But yes, even more randomness could definitively eliminate some predictable song if you have time to look on it.

ThirteenAG commented 7 years ago

Thank you. What do you mean by more randomness?

Catarax commented 7 years ago

It's ok. But for example, after relaunching, the third track played was the same. In the script, you create a new playlist at each startup in an array? If you randomize the whole lot why not, else don't bother on it, this is already good enough.

ThirteenAG commented 7 years ago

But I checked the resulting arrays, it was pretty random(launched the game 3 times in a row):

[0]     36          [0]     23          [0]     31  
[1]     34          [1]     15          [1]     0   
[2]     32          [2]     17          [2]     16  
[3]     16          [3]     47          [3]     36  
[4]     1           [4]     26          [4]     34  
[5]     39          [5]     24          [5]     18  
[6]     23          [6]     8           [6]     32  
[7]     8           [7]     13          [7]     35  
[8]     43          [8]     30          [8]     44  
[9]     17          [9]     2           [9]     37  
[10]    44          [10]    32          [10]    15  
[11]    15          [11]    43          [11]    3   
[12]    49          [12]    3           [12]    50  
[13]    41          [13]    11          [13]    40  
[14]    28          [14]    19          [14]    4   
[15]    33          [15]    22          [15]    33  
[16]    18          [16]    40          [16]    43  
[17]    4           [17]    46          [17]    9   
[18]    24          [18]    52          [18]    20  
[19]    31          [19]    20          [19]    49  
[20]    6           [20]    51          [20]    1   
[21]    46          [21]    42          [21]    52  
[22]    42          [22]    48          [22]    17  
[23]    45          [23]    14          [23]    22  
[24]    50          [24]    1           [24]    28  
[25]    19          [25]    16          [25]    24  
[26]    38          [26]    12          [26]    47  
[27]    30          [27]    33          [27]    23  
[28]    13          [28]    49          [28]    5   
[29]    10          [29]    0           [29]    10  
[30]    7           [30]    50          [30]    8   
[31]    47          [31]    7           [31]    39  
[32]    9           [32]    36          [32]    45  
[33]    11          [33]    34          [33]    13  
[34]    35          [34]    45          [34]    46  
[35]    21          [35]    4           [35]    21  
[36]    40          [36]    39          [36]    26  
[37]    2           [37]    41          [37]    7   
[38]    0           [38]    37          [38]    41  
[39]    27          [39]    25          [39]    42  
[40]    52          [40]    29          [40]    51  
[41]    48          [41]    21          [41]    2   
[42]    12          [42]    27          [42]    27  
[43]    22          [43]    6           [43]    6   
[44]    26          [44]    28          [44]    30  
[45]    29          [45]    10          [45]    11  
[46]    3           [46]    18          [46]    14  
[47]    14          [47]    44          [47]    29  
[48]    20          [48]    5           [48]    48  
[49]    51          [49]    35          [49]    12  
[50]    25          [50]    38          [50]    38  
[51]    5           [51]    9           [51]    19  
[52]    37          [52]    31          [52]    25  

Maybe it was just a coincidence in your case?

Catarax commented 7 years ago

Thanks for the details! I think i've understood the problem, the THUG1 soundtrack is about 78 tracks (including 2/3 hidden) and it's locked to 52/53 here. That's probably why I don't feel it totally.

Will tell you the correct number when I come back home if you want.

ThirteenAG commented 7 years ago

Hm, I assumed that num_songs variable from this code is the actual number of songs. So, I disregarded the fact they randomize from n=0 to n<2000. The original array didn't have more than 53 songs either. Maybe it's savegame related?

Catarax commented 7 years ago

Well, the source code of the Xbox version is probably a developpement version at the time or near finished, That's why it's not completely accurate.

So there is 76 tracks with a 100% savegame with 3 KISS tracks to unlock. But you can force them to play, I doubt it'll crash the game.

Thanks!

ThirteenAG commented 7 years ago

Can you upload that save game for me? I'll compare that variable's value.

Catarax commented 7 years ago

http://www.thps-mods.com/cas/thug.rar

ThirteenAG commented 7 years ago

I think it's all good, num_songs is 76 with this save:

        [0] 65  int
        [1] 18  int
        [2] 31  int
        [3] 43  int
        [4] 54  int
        [5] 74  int
        [6] 69  int
        [7] 28  int
        [8] 12  int
        [9] 21  int
        [10]    5   int
        [11]    22  int
        [12]    26  int
        [13]    72  int
        [14]    73  int
        [15]    41  int
        [16]    20  int
        [17]    51  int
        [18]    55  int
        [19]    53  int
        [20]    1   int
        [21]    0   int
        [22]    58  int
        [23]    19  int
        [24]    35  int
        [25]    4   int
        [26]    71  int
        [27]    6   int
        [28]    23  int
        [29]    59  int
        [30]    44  int
        [31]    30  int
        [32]    25  int
        [33]    62  int
        [34]    7   int
        [35]    24  int
        [36]    47  int
        [37]    3   int
        [38]    13  int
        [39]    8   int
        [40]    75  int
        [41]    33  int
        [42]    66  int
        [43]    37  int
        [44]    2   int
        [45]    57  int
        [46]    56  int
        [47]    39  int
        [48]    64  int
        [49]    61  int
        [50]    50  int
        [51]    15  int
        [52]    63  int
        [53]    38  int
        [54]    49  int
        [55]    52  int
        [56]    27  int
        [57]    14  int
        [58]    10  int
        [59]    29  int
        [60]    16  int
        [61]    68  int
        [62]    45  int
        [63]    34  int
        [64]    11  int
        [65]    36  int
        [66]    32  int
        [67]    60  int
        [68]    40  int
        [69]    67  int
        [70]    9   int
        [71]    17  int
        [72]    48  int
        [73]    70  int
        [74]    46  int
        [75]    42  int