Opened 9 years ago

Last modified 5 years ago

#3578 closed defect

[PATCH] Seed random sounds — at Initial Version

Reported by: Thomas Owned by:
Priority: Should Have Milestone: Alpha 24
Component: Core engine Keywords:
Cc: Patch:

Description

Visual Actors now use the same seed for every sound.

Closes #1786.

Before using the random function it uses srand() with the actor id to seed the random function. I also made changes to rand.cpp. Apparently the first value returned by rand() is very dependent on the seed (see http://stackoverflow.com/questions/8599238/random-number-generation-in-c-first-number-not-very-random). Most actors were returning the same random value as they have similar seeds. Using modulo instead of dividing uses the least significant bits of the random value, yielding better results.

This is my first patch, so please tell me if I'm doing something wrong.

Change History (1)

by Thomas, 9 years ago

Attachment: patch.patch added

Patch

Note: See TracTickets for help on using tickets.