VgaGames4 - random man-pages

[.. upper level ..]

vg4->random->get()

Return a network-suitable random number.

SYNTAX
unsigned int vg4->random->get(const char *scope, unsigned int nstart, unsigned int nend)

FUNCTION PARAMETERS
scope Scope of random numbers
nstart Starting number
nend Ending number (inclusively)

RETURN VALUE
Returns a random number between nstart and nend

DESCRIPTION
Return a network-suitable random number. Each network-client must call this function in the same order to get the same numbers. The scope is an arbitrary string, which encloses a sequence of random numbers for a specific usage. It minimizes the possibility for a disorder in calling this function on each network-client. E.g. there may be a scope for the player, a scope for the enemy spaceship, and so on. This function may be used also in single-user games.

EXAMPLE
unsigned int rno;

/* get a random number between 10 and 100 inclusively in the scope Myship */
rno = vg4->random->get("Myship", 10, 100);

/* this block returns for each call the same numbers as ... */
rno = vg4->random->get("Myship", 10, 20);       /* e.g. 13 */
rno = vg4->random->get("Myship", 20, 30);       /* e.g. 28 */
rno = vg4->random->get("Enemyship", 100, 200);  /* e.g. 100 */
rno = vg4->random->get("Enemyship", 200, 300);  /* e.g. 300 */

/* ... this block because of two independent scopes */
rno = vg4->random->get("Myship", 10, 20);       /* e.g. 13 */
rno = vg4->random->get("Enemyship", 100, 200);  /* e.g. 100 */
rno = vg4->random->get("Myship", 20, 30);       /* e.g. 28 */
rno = vg4->random->get("Enemyship", 200, 300);  /* e.g. 300 */