src/ai/api/ai_base.cpp
author rubidium
Fri, 16 Mar 2007 10:14:14 +0000
branchnoai
changeset 9440 0986434f3af8
parent 9430 9e0a193b2bec
child 9660 d0a430e8310b
permissions -rw-r--r--
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
/* $Id$ */

/** @file ai_base.cpp handles the functions of the AIBase class */

#include "ai_base.hpp"

uint32 AIBase::Rand()
{
	/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
	 *   but we pick InteractiveRandomRange if we are a network_server or network-client. */
	if (_networking) return InteractiveRandom();
	return ::Random();
}

uint AIBase::RandRange(uint max)
{
	/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
	 *   but we pick InteractiveRandomRange if we are a network_server or network-client. */
	if (_networking) return InteractiveRandomRange(max);
	return ::RandomRange(max);
}

bool AIBase::Chance(uint out, uint max)
{
	return (uint16)this->Rand() <= (uint16)((65536 * out) / max);
}