Jump to content

Home

JA Linux server BUG (Raven's) and fix (Mine :))


[ONE]Mushroom

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...