Merge pull request #2495 from birarda/random-number

remove loadRandomIdentifier and random number generator seed no longer required
This commit is contained in:
Stephen Birarda 2014-03-25 14:46:02 -07:00
commit 46f8e2493b
4 changed files with 2 additions and 20 deletions

View file

@ -235,12 +235,6 @@ void ScriptEngine::init() {
// let the VoxelPacketSender know how frequently we plan to call it
_voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS);
_particlesScriptingInterface.getParticlePacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS);
// call srand to seed the random number generator
srand(QDateTime::currentMSecsSinceEpoch()
+ QCoreApplication::applicationPid()
+ NodeList::getInstance()->getNodeSocket().localPort());
}
void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) {

View file

@ -413,9 +413,8 @@ void NodeList::sendSTUNRequest() {
// transaction ID (random 12-byte unsigned integer)
const uint NUM_TRANSACTION_ID_BYTES = 12;
unsigned char transactionID[NUM_TRANSACTION_ID_BYTES];
loadRandomIdentifier(transactionID, NUM_TRANSACTION_ID_BYTES);
memcpy(stunRequestPacket + packetIndex, &transactionID, sizeof(transactionID));
QUuid randomUUID = QUuid::createUuid();
memcpy(stunRequestPacket + packetIndex, randomUUID.toRfc4122().data(), NUM_TRANSACTION_ID_BYTES);
// lookup the IP for the STUN server
static HifiSockAddr stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT);

View file

@ -206,15 +206,6 @@ bool isInEnvironment(const char* environment) {
}
}
void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes) {
// seed the the random number generator
srand(time(NULL));
for (int i = 0; i < numBytes; i++) {
identifierBuffer[i] = rand() % 256;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// Function: getCmdOption()
// Description: Handy little function to tell you if a command line flag and option was

View file

@ -96,8 +96,6 @@ int getNthBit(unsigned char byte, int ordinal); /// determines the bit placement
bool isInEnvironment(const char* environment);
void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes);
const char* getCmdOption(int argc, const char * argv[],const char* option);
bool cmdOptionExists(int argc, const char * argv[],const char* option);