~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to common/random.cpp

  • Committer: Package Import Robot
  • Author(s): Moritz Muehlenhoff
  • Date: 2011-11-05 10:29:43 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20111105102943-zfm3dhlvy5b01u7v
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * You should have received a copy of the GNU General Public License
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 
 *
21
 
 * $URL$
22
 
 * $Id$
23
20
 */
24
21
 
25
22
#include "common/random.h"
26
23
#include "common/system.h"
 
24
#include "common/EventRecorder.h"
27
25
 
28
26
 
29
27
namespace Common {
30
28
 
31
 
RandomSource::RandomSource() {
 
29
RandomSource::RandomSource(const String &name) {
32
30
        // Use system time as RNG seed. Normally not a good idea, if you are using
33
31
        // a RNG for security purposes, but good enough for our purposes.
34
32
        assert(g_system);
35
33
        uint32 seed = g_system->getMillis();
36
34
        setSeed(seed);
 
35
 
 
36
        // Register this random source with the event recorder. This may end
 
37
        // up querying or resetting the current seed, so we must call it
 
38
        // *after* the initial seed has been set.
 
39
        g_eventRec.registerRandomSource(*this, name);
37
40
}
38
41
 
39
42
void RandomSource::setSeed(uint32 seed) {