Skip to content

Commit

Permalink
Exclude ps_srand() call from InitMathTables()
Browse files Browse the repository at this point in the history
Seems this is totally unrelated to fix library API. Moved ps_srand() to appropriate places right after InitMathTables();
  • Loading branch information
winterheart committed Apr 27, 2024
1 parent 55666b9 commit 0d8bd68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Descent3/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@
#include "stringtable.h"
#include "hlsoundlib.h"
#include "player.h"
#include "psrand.h"
#include "ambient.h"
#include "matcen.h"
#include "dedicated_server.h"
Expand Down Expand Up @@ -2204,6 +2205,10 @@ void InitD3Systems1(bool editor) {
// This function needs be called before ANY 3d stuff can get done. I mean it.
InitMathTables();

// Initialize a random seed.
ps_srand(time(nullptr));


// This function has to be done before any sound stuff is called
InitSounds();

Expand Down
5 changes: 0 additions & 5 deletions fix/fix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@
*/

#include <cmath>
#include <ctime>

#include "fix.h"
#include "psrand.h"

// Tables for trig functions
float sincos_table[321]; // 256 entries + 64 sin-only + 1 for interpolation
Expand Down Expand Up @@ -99,9 +97,6 @@ void InitMathTables() {

asin_table[256] = asin_table[255];
acos_table[256] = acos_table[255];

// Initialize a random seed.
ps_srand(time(nullptr));
}

// Returns the sine of the given angle. Linearly interpolates between two entries in a 256-entry table
Expand Down
4 changes: 4 additions & 0 deletions scripts/AIGame3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "AIGame3_External.h"

#include "module.h"
#include "psrand.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -1471,6 +1472,9 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {

InitMathTables();

// Initialize a random seed.
ps_srand(time(nullptr));

if (func_list->game_checksum != CHECKSUM) {
mprintf(0, "Game-Checksum FAIL!!! (%ul!=%ul)\n", func_list->game_checksum, CHECKSUM);
mprintf(0, "RECOMPILE YOUR SCRIPTS!!!\n");
Expand Down

0 comments on commit 0d8bd68

Please sign in to comment.