truelight@9360: /* $Id$ */ truelight@9360: rubidium@9430: /** @file ai_base.cpp handles the functions of the AIBase class */ truelight@9360: rubidium@9430: #include "ai_base.hpp" truelight@9360: truelight@9660: /* static */ uint32 AIBase::Rand() truelight@9360: { truelight@9360: /* We pick RandomRange if we are in SP (so when saved, we do the same over and over) truelight@9360: * but we pick InteractiveRandomRange if we are a network_server or network-client. */ truelight@9360: if (_networking) return InteractiveRandom(); truelight@9361: return ::Random(); truelight@9360: } truelight@9360: truelight@9660: /* static */ uint AIBase::RandRange(uint max) truelight@9360: { truelight@9360: /* We pick RandomRange if we are in SP (so when saved, we do the same over and over) truelight@9360: * but we pick InteractiveRandomRange if we are a network_server or network-client. */ truelight@9360: if (_networking) return InteractiveRandomRange(max); truelight@9361: return ::RandomRange(max); truelight@9360: } truelight@9360: truelight@9660: /* static */ bool AIBase::Chance(uint out, uint max) truelight@9360: { truelight@9660: return (uint16)AIBase::Rand() <= (uint16)((65536 * out) / max); truelight@9360: }