[ONE]Mushroom Posted January 20, 2004 Share Posted January 20, 2004 From w_saber.c The following function... float RandFloat(float min, float max) { return ((rand() * (max - min)) / 32768.0F + min; } int rand() returns an integer between 0 and RAND_MAX (32767 - not 32768 - on MS). On Linux, this value is very different (2147483647). The result of this is that RandFloat (min, max) is always very large. This function is called in g_missile.c, for example in G_ReflectMissile. Pushed rockets do not go back towards their previous 'owner'. To fix this, change the function to: float RandFloat(float min, float max) { return ((rand() * (max - min)) / (float)RAND_MAX) + min; //JMMod er... RAND_MAX? } RAND_MAX is #defined in stdlib.h, but for some reason isn't recognised with Divoid's Makefile, so (being lazy) I just added: //JMMod #ifdef __linux__ #define RAND_MAX 2147483647 #endif to the top of w_saber.c I've tested this, it works Because this only effects .so files on Linux servers, it can be fixed with no changes to the client's files. I'll also email Raven. Link to comment Share on other sites More sharing options...
razorace Posted January 21, 2004 Share Posted January 21, 2004 Are you sure that it isn't an issue with the divoid patch? I think that function dates back to Q3/Q2. Link to comment Share on other sites More sharing options...
[ONE]Mushroom Posted January 21, 2004 Author Share Posted January 21, 2004 Pushed missiles always go in (approx) the same direction on vanilla JA linux servers, which is what this bug causes. It's a particular problem in JMMod though, as the JM needs to be able to counter explosive projectiles. I didn't run Divoid's patch, I went through the changes by hand (as I didn't trust it to find the correct code after I'd been editing it). There's nothing in there that could cause this IIRC. The code may well be old, but as you know previous Quake engine games compiled to QVM bytecodes. In the QVM, I assume that RAND_MAX is 32767, so it isn't a problem. Damn Raven for moving to .dlls and .sos I've got an email back from some guy called Kenn Hoekstra at Raven (!), who says he'll forward my email onto the lead programmer. Hopefully they'll fix it and give me credit in the next release of the Linux server .so Link to comment Share on other sites More sharing options...
[ONE]Mushroom Posted January 21, 2004 Author Share Posted January 21, 2004 Slightly more elegant: //JMMod #ifndef RAND_MAX #ifdef __linux__ #define RAND_MAX 2147483647 #else #define RAND_MAX 32767 #endif #endif I've no idea what RAND_MAX should be under MacOS, sorry. Link to comment Share on other sites More sharing options...
[ONE]Mushroom Posted January 28, 2004 Author Share Posted January 28, 2004 I've got bored of waiting for Raven/Lucasarts/Activision, and released a bug fixed mini mod myself here Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.