Hello,
I need some help converting a C function to PHP. I know what it can do, but I can't seem to think of how to write the function in PHP. Here is the function in C:
The function is supposed to convert a game's version number into a 32bit hex string. So a sample game version is 1.1.2965-797.0, and you have in it n1.n2.n3.n4. And this string correctly converted to its 32bit hex form should be 110b9500 (1.1.0b95.00).Code:u32 setver(u8 *gamever) { int v1 = 0, v2 = 0, v3 = 0, v4 = 0; sscanf(gamever, "%d.%d.%d.%d", &v1, &v2, &v3, &v4); return(((v1 & 0xf) << 28) | ((v2 & 0xf) << 24) | ((v3 & 0xffff) << 8) | (v4 & 0xff)); }
On n3, you have 0b95 which is 2965 in hex, so I think the function is written so the -797 is ignored for that specific game version, but I'm not quite sure.
Probably pretty simple for you guys . I thought I would try here first to see if anyone knows, and if not I can try a php forum too. Thanks!