source: abuse/trunk/src/imlib/jrand.cpp @ 481

Last change on this file since 481 was 481, checked in by Sam Hocevar, 12 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

File size: 781 bytes
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include <time.h>
13#include <stdio.h>
14
15#include "jrand.h"
16
17unsigned short rtable[RAND_TABLE_SIZE];
18unsigned short rand_on=0;
19
20void jrand_init()
21{
22  // make sure random table is always the same.
23  unsigned long rseed=('F'<<24)|('U'<<16)|('C'<<8)|'K';
24  int i;
25  unsigned short *tp=rtable;
26  for (i=0;i<RAND_TABLE_SIZE;i++,tp++)
27  {
28    rseed=rseed*0x41c64e6d+12345;
29    *tp=(rseed>>16)&0xffff;
30  }
31
32  time_t t=time(NULL);         // get an original random seed now.
33  rand_on=t%RAND_TABLE_SIZE;
34}
35
Note: See TracBrowser for help on using the repository browser.