Closed Tianshee closed 1 year ago
Fixed with latest commit, thx
Hashes were not wrong, but signed instead of unsigned variant
I know what you mean about signed and unsigned variants.
-1934452204 is a valid hash for RapidGT and 2360515092 is a valid hash for RapidGT.
If can call CreateVechicle(-1934452204,...
or CreateVechicle(2360515092,...
I get RapidGT in both cases.
Two valid hashes for the same vehicle are possible because positive numbers greater than 0x7FFFFFFF turn into negative and vice versa. Hash for RapidGT is 0x8CB29A14 and can be interpreted as positive or negative number.
I can create many more "valid hashes" by adding math.random(1,0xFFFFFFFF)*0x100000000
to any valid hash. All that garbage will be cut before sending the number to the game. For example 71079991828(0x108CB29A14) is still a RapidGT.
It has absolutely nothing to do with hashes in VehicleList.ini
!
They are just wrong. Look at this line, for example.
GetHashKey( RHINO )= 782665360 ~= 976373367
Are you saying that those two numbers are basically the same?
782665360 != 976373367
0x2EA68690 != 0x3A324677
I can call IsModelValid(782665360)
or CreateVechicle(782665360,...
But I have no idea what 976373367(0x3A324677) is, it's just a seemingly random number.
Another example:
GetHashKey( bobcatXL )= 1069929536 ~= 1719944928
Both numbers are positive and completely different. 1069929536 works, 1719944928 is invalid and it's not possible to turn invalid into valid.
@Tianshee I have no idea what kind of stuff you are trying to explain overly complicated - did you check my commit? https://github.com/DurtyFree/gta-v-data-dumps/commit/1523cad0eee6863d4f7a1adebaa773c2091e3f91
I guess what you are trying to say is that SignedHash in my source file (vehicles.json) is sometimes correct and sometimes not? https://github.com/DurtyFree/gta-v-data-dumps/blob/master/vehicles.json
Yes, your SignedHash function contains a bug
Isn't it obvious that SignedHash for BARRACKS is just completely wrong?
"Name": "BARRACKS",
"DisplayName": "Barracks",
"Hash": 3471458123,
"SignedHash": 720993689,
"HexHash": "0xCEEA3F4B",
It should be -823509173
If you want to fix your SignedHash, you can simply replace it with something like this.
int64_t SignedHash(char* txt)
{
uint64_t h=Hash(txt);
if(h&0x80000000){ h|=(-1^0x7FFFFFFF); }
return (int64_t)h;
}
Much better than using two different hash functions supposed to be doing the same thing, isn't it?
Reopened until I have looked into it. Btw I am not using one hash function for each type of hash, which I have way too much in my data dumps - obviously, isn't it?
The hash issue is because, for some reason, the signed hashes are calculated with case-sensitivity when they shouldn't be. Take the Sugoi for example: Name = Sugoi (the S should be lowercase) Hash = 987469656 (unsigned, this is correct) (current) SignedHash = -545256593 (case sensitive, incorrect) (actual) SignedHash = 987469656 (not case-sensitive, how it should be)
I believe the issue stems from the fact that Rockstar sometimes capitalizes the model names in vehicles.meta. I think those really should be all lowercase while being formatted.
Fixed with latest commit, huge thx again to @Wildbrick142 for the detailed hint
Incorrect hashes from this file: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/VehicleList.ini
PR: https://github.com/DurtyFree/gta-v-data-dumps/pull/54/commits/d08f5412098335818d7a5dd2aaf233e29a5dc0cd
GetHashKey( Airbus )= 1283517198 ~= -362198621 GetHashKey( Airtug )= 1560980623 ~= -1899950134 GetHashKey( AMBULANCE )= 1171614426 ~= -1852559656 GetHashKey( Baller )= -808831384 ~= 219767970 GetHashKey( BARRACKS )= -823509173 ~= 720993689 GetHashKey( BARRACKS2 )= 1074326203 ~= 265402117 GetHashKey( BARRACKS3 )= 630371791 ~= 1636850305 GetHashKey( Benson )= 2053223216 ~= -1597654812 GetHashKey( BfInjection )= 1126868326 ~= -2120474319 GetHashKey( Biff )= 850991848 ~= -1456825247 GetHashKey( Bison2 )= 2072156101 ~= -1313918041 GetHashKey( Bison3 )= 1739845664 ~= -391700054 GetHashKey( BjXL )= 850565707 ~= 385871062 GetHashKey( BLIMP )= -150975354 ~= -646416997 GetHashKey( BLIMP2 )= -613725916 ~= -1117353854 GetHashKey( BMX )= 1131912276 ~= -512166165 GetHashKey( bobcatXL )= 1069929536 ~= 1719944928 GetHashKey( Bodhi2 )= -1435919434 ~= -921710368 GetHashKey( Burrito )= -1346687836 ~= -862561546 GetHashKey( Burrito4 )= 893081117 ~= 2113241707 GetHashKey( BUS )= -713569950 ~= 22097311 GetHashKey( Buzzard2 )= 745926877 ~= -1327052245 GetHashKey( Caddy2 )= -537896628 ~= -1616846874 GetHashKey( CAMPER )= 1876516712 ~= 1830090274 GetHashKey( Cargobob )= -50547061 ~= 638132286 GetHashKey( Cargobob3 )= 1394036463 ~= 1270502190 GetHashKey( Cargobob4 )= 2025593404 ~= -2046933067 GetHashKey( CRUSADER )= 321739290 ~= 343511227 GetHashKey( Dinghy )= 1033245328 ~= -1693834937 GetHashKey( Dominator )= 80636076 ~= 94407713 GetHashKey( Dynasty )= 310284501 ~= 1815884952 GetHashKey( Emperor2 )= -1883002148 ~= 477543359 GetHashKey( Euros )= 2038480341 ~= 1705128934 GetHashKey( FBI )= 1127131465 ~= -1712725762 GetHashKey( FBI2 )= -1647941228 ~= -192845181 GetHashKey( FLATBED )= 1353720154 ~= -935206825 GetHashKey( FORKLIFT )= 1491375716 ~= -1154774539 GetHashKey( Frogger )= 744705981 ~= 433399131 GetHashKey( Gauntlet )= -1800170043 ~= -36796051 GetHashKey( GRANGER )= -1775728740 ~= -452768186 GetHashKey( Hauler )= 1518533038 ~= 706351765 GetHashKey( Hauler2 )= 387748548 ~= 246890036 GetHashKey( Lazer )= -1281684762 ~= 1750364106 GetHashKey( MESA )= 914654722 ~= 2126640706 GetHashKey( MESA3 )= -2064372143 ~= 753689222 GetHashKey( Miljet )= 165154707 ~= -1817821896 GetHashKey( Mixer )= -784816453 ~= -1453946153 GetHashKey( Mixer2 )= 475220373 ~= -1183252781 GetHashKey( Mower )= 1783355638 ~= -2140626876 GetHashKey( Mule )= 904750859 ~= -203828971 GetHashKey( Mule2 )= -1050465301 ~= -2024823773 GetHashKey( Mule3 )= -2052737935 ~= -217613423 GetHashKey( Novak )= -1829436850 ~= 1327809603 GetHashKey( Packer )= 569305213 ~= -1475652208 GetHashKey( Phantom )= -2137348917 ~= 371926404 GetHashKey( Phoenix )= -2095439403 ~= 1197157430 GetHashKey( Pounder )= 2112052861 ~= -1038167849 GetHashKey( pRanger )= 741586030 ~= -2059595619 GetHashKey( Predator )= -488123221 ~= -393137354 GetHashKey( RancherXL )= 1645267888 ~= 787808497 GetHashKey( RapidGT )= -1934452204 ~= 135374764 GetHashKey( RapidGT2 )= 1737773231 ~= -405363230 GetHashKey( Rebel )= -1207771834 ~= -944049772 GetHashKey( Rentalbus )= -1098802077 ~= -543367575 GetHashKey( RHINO )= 782665360 ~= 976373367 GetHashKey( RIOT )= -1205689942 ~= 344751432 GetHashKey( Ripley )= -845979911 ~= 101258468 GetHashKey( Rubble )= -1705304628 ~= 655455525 GetHashKey( Sadler )= -599568815 ~= 1098789372 GetHashKey( Sanchez )= 788045382 ~= -1591467140 GetHashKey( Seminole )= 1221512915 ~= -204332342 GetHashKey( SEVEN70 )= -1757836725 ~= 2143692254 GetHashKey( Shamal )= -1214505995 ~= -1548725510 GetHashKey( SHERIFF )= -1683328900 ~= 1463124553 GetHashKey( SPECTER )= 1886268224 ~= 897439495 GetHashKey( SPECTER2 )= 1074745671 ~= 616267898 GetHashKey( Stryder )= 301304410 ~= 1418722363 GetHashKey( Stunt )= -2122757008 ~= 736232385 GetHashKey( Sugoi )= 987469656 ~= -545256593 GetHashKey( Suntrap )= -282946103 ~= -625701873 GetHashKey( Surano )= 384071873 ~= 899626052 GetHashKey( SURFER )= 699456151 ~= 1069713340 GetHashKey( Surfer2 )= -1311240698 ~= 1226788964 GetHashKey( Taco )= 1951180813 ~= -1933360995 GetHashKey( TipTruck )= 48339065 ~= 1374947884 GetHashKey( TipTruck2 )= -947761570 ~= -2094003487 GetHashKey( TOURBUS )= 1941029835 ~= -650426193 GetHashKey( TOWTRUCK )= -1323100960 ~= 2080391337 GetHashKey( Towtruck2 )= -442313018 ~= -656442358 GetHashKey( TRACTOR )= 1641462412 ~= 1142318173 GetHashKey( Trash )= 1917016601 ~= 2130409506 GetHashKey( Utillitruck3 )= 2132890591 ~= -780359528 GetHashKey( Vader )= -140902153 ~= 1159263570 GetHashKey( Ztype )= 758895617 ~= 2010598502
What's wrong with your hashes?