Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

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

Page: 1 of 1
 [ONE]Mushroom
01-19-2004, 9:59 PM
#1
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.
 razorace
01-20-2004, 7:05 PM
#2
Are you sure that it isn't an issue with the divoid patch? I think that function dates back to Q3/Q2.
 [ONE]Mushroom
01-21-2004, 8:26 AM
#3
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 :)
 [ONE]Mushroom
01-21-2004, 8:34 AM
#4
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.
 [ONE]Mushroom
01-28-2004, 3:18 PM
#5
I've got bored of waiting for Raven/Lucasarts/Activision, and released a bug fixed mini mod myself here (http://www.pcgamemods.com/4101/)
Page: 1 of 1