lfnetwork.com mark read register faq members calendar

Thread: JA Linux server BUG (Raven's) and fix (Mine :))
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 01-19-2004, 09:59 PM   #1
[ONE]Mushroom
Rookie
 
[ONE]Mushroom's Avatar
 
Join Date: Nov 2003
Posts: 51
JA Linux server BUG (Raven's) and fix (Mine :))

From w_saber.c

The following function...

Code:
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:

Code:
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:

Code:
//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.

Last edited by [ONE]Mushroom; 01-19-2004 at 10:21 PM.
[ONE]Mushroom is offline   you may: quote & reply,
Old 01-20-2004, 07:05 PM   #2
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,172
Are you sure that it isn't an issue with the divoid patch? I think that function dates back to Q3/Q2.


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Old 01-21-2004, 08:26 AM   #3
[ONE]Mushroom
Rookie
 
[ONE]Mushroom's Avatar
 
Join Date: Nov 2003
Posts: 51
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 is offline   you may: quote & reply,
Old 01-21-2004, 08:34 AM   #4
[ONE]Mushroom
Rookie
 
[ONE]Mushroom's Avatar
 
Join Date: Nov 2003
Posts: 51
Re: JA Linux server BUG (Raven's) and fix (Mine :))

Slightly more elegant:

Code:
//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 is offline   you may: quote & reply,
Old 01-28-2004, 03:18 PM   #5
[ONE]Mushroom
Rookie
 
[ONE]Mushroom's Avatar
 
Join Date: Nov 2003
Posts: 51
I've got bored of waiting for Raven/Lucasarts/Activision, and released a bug fixed mini mod myself here
[ONE]Mushroom is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > JA Linux server BUG (Raven's) and fix (Mine :))

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:23 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.