mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 05:43:59 +02:00
- cast to unsigned int for all calls to srand
This commit is contained in:
@@ -346,7 +346,7 @@ void Ai::update() {
|
|||||||
//int allowJoinTeam = random.randRange(0, 100);
|
//int allowJoinTeam = random.randRange(0, 100);
|
||||||
//srand(time(NULL) + aiInterface->getMyFaction()->getIndex());
|
//srand(time(NULL) + aiInterface->getMyFaction()->getIndex());
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks() + aiInterface->getMyFaction()->getIndex());
|
srand((unsigned int)seed.getCurTicks() + aiInterface->getMyFaction()->getIndex());
|
||||||
|
|
||||||
int allowJoinTeam = rand() % 100;
|
int allowJoinTeam = rand() % 100;
|
||||||
|
|
||||||
|
@@ -236,20 +236,20 @@ Intro::Intro(Program *program):
|
|||||||
|
|
||||||
//unsigned int seed = time(NULL);
|
//unsigned int seed = time(NULL);
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks());
|
srand((unsigned int)seed.getCurTicks());
|
||||||
int failedLookups=0;
|
int failedLookups=0;
|
||||||
std::map<int,bool> usedIndex;
|
std::map<int,bool> usedIndex;
|
||||||
for(;modelList.size() < models.size();) {
|
for(;modelList.size() < models.size();) {
|
||||||
int index = rand() % models.size();
|
int index = rand() % models.size();
|
||||||
if(usedIndex.find(index) != usedIndex.end()) {
|
if(usedIndex.find(index) != usedIndex.end()) {
|
||||||
failedLookups++;
|
failedLookups++;
|
||||||
srand(seed.getCurTicks() / failedLookups);
|
srand((unsigned int)seed.getCurTicks() / failedLookups);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//printf("picIndex = %d list count = %d\n",picIndex,coreData.getMiscTextureList().size());
|
//printf("picIndex = %d list count = %d\n",picIndex,coreData.getMiscTextureList().size());
|
||||||
modelList.push_back(models[index]);
|
modelList.push_back(models[index]);
|
||||||
usedIndex[index]=true;
|
usedIndex[index]=true;
|
||||||
srand(seed.getCurTicks() / modelList.size());
|
srand((unsigned int)seed.getCurTicks() / modelList.size());
|
||||||
}
|
}
|
||||||
models = modelList;
|
models = modelList;
|
||||||
}
|
}
|
||||||
@@ -426,14 +426,14 @@ Intro::Intro(Program *program):
|
|||||||
if(showIntroPicsRandom == true) {
|
if(showIntroPicsRandom == true) {
|
||||||
//unsigned int seed = time(NULL);
|
//unsigned int seed = time(NULL);
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks());
|
srand((unsigned int)seed.getCurTicks());
|
||||||
int failedLookups=0;
|
int failedLookups=0;
|
||||||
std::map<int,bool> usedIndex;
|
std::map<int,bool> usedIndex;
|
||||||
for(;intoTexList.size() < showIntroPics;) {
|
for(;intoTexList.size() < showIntroPics;) {
|
||||||
int picIndex = rand() % coreData.getMiscTextureList().size();
|
int picIndex = rand() % coreData.getMiscTextureList().size();
|
||||||
if(usedIndex.find(picIndex) != usedIndex.end()) {
|
if(usedIndex.find(picIndex) != usedIndex.end()) {
|
||||||
failedLookups++;
|
failedLookups++;
|
||||||
srand(seed.getCurTicks() / failedLookups);
|
srand((unsigned int)seed.getCurTicks() / failedLookups);
|
||||||
|
|
||||||
if(failedLookups > 10000) {
|
if(failedLookups > 10000) {
|
||||||
for(unsigned int i = 0;
|
for(unsigned int i = 0;
|
||||||
@@ -451,7 +451,7 @@ Intro::Intro(Program *program):
|
|||||||
//printf("picIndex = %d list count = %d\n",picIndex,coreData.getMiscTextureList().size());
|
//printf("picIndex = %d list count = %d\n",picIndex,coreData.getMiscTextureList().size());
|
||||||
intoTexList.push_back(coreData.getMiscTextureList()[picIndex]);
|
intoTexList.push_back(coreData.getMiscTextureList()[picIndex]);
|
||||||
usedIndex[picIndex]=true;
|
usedIndex[picIndex]=true;
|
||||||
srand(seed.getCurTicks() / intoTexList.size());
|
srand((unsigned int)seed.getCurTicks() / intoTexList.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -253,9 +253,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||||||
listBoxTileset.init(xoffset+460, mapPos, 150);
|
listBoxTileset.init(xoffset+460, mapPos, 150);
|
||||||
//listBoxTileset.setItems(results);
|
//listBoxTileset.setItems(results);
|
||||||
setupTilesetList("");
|
setupTilesetList("");
|
||||||
//srand((unsigned int)time(NULL));
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks());
|
srand((unsigned int)seed.getCurTicks());
|
||||||
|
|
||||||
listBoxTileset.setSelectedItemIndex(rand() % listBoxTileset.getItemCount());
|
listBoxTileset.setSelectedItemIndex(rand() % listBoxTileset.getItemCount());
|
||||||
|
|
||||||
@@ -1568,9 +1567,8 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
|
|||||||
|
|
||||||
// Max 1000 tries to get a random, unused faction
|
// Max 1000 tries to get a random, unused faction
|
||||||
for(int findRandomFaction = 1; findRandomFaction < 1000; ++findRandomFaction) {
|
for(int findRandomFaction = 1; findRandomFaction < 1000; ++findRandomFaction) {
|
||||||
//srand((unsigned int)time(NULL) + findRandomFaction);
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks() + findRandomFaction);
|
srand((unsigned int)seed.getCurTicks() + findRandomFaction);
|
||||||
|
|
||||||
int selectedFactionIndex = rand() % listBoxFactions[i].getItemCount();
|
int selectedFactionIndex = rand() % listBoxFactions[i].getItemCount();
|
||||||
string selectedFactionName = listBoxFactions[i].getItem(selectedFactionIndex);
|
string selectedFactionName = listBoxFactions[i].getItem(selectedFactionIndex);
|
||||||
|
@@ -250,9 +250,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
GraphicComponent::applyAllCustomProperties(containerName);
|
GraphicComponent::applyAllCustomProperties(containerName);
|
||||||
|
|
||||||
char szIRCNick[80]="";
|
char szIRCNick[80]="";
|
||||||
//srand(time(NULL));
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks());
|
srand((unsigned int)seed.getCurTicks());
|
||||||
|
|
||||||
int randomNickId = rand() % 999;
|
int randomNickId = rand() % 999;
|
||||||
string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
||||||
|
@@ -453,9 +453,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||||||
if(this->isConnected() == true) {
|
if(this->isConnected() == true) {
|
||||||
//RandomGen random;
|
//RandomGen random;
|
||||||
//sessionKey = random.randRange(-100000, 100000);
|
//sessionKey = random.randRange(-100000, 100000);
|
||||||
//srand((unsigned int)time(NULL) / (this->playerIndex + 1));
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks() / (this->playerIndex + 1));
|
srand((unsigned int)seed.getCurTicks() / (this->playerIndex + 1));
|
||||||
|
|
||||||
sessionKey = rand() % 1000000;
|
sessionKey = rand() % 1000000;
|
||||||
|
|
||||||
|
@@ -536,9 +536,8 @@ Model *SkillType::getAnimation(float animProgress, const Unit *unit,
|
|||||||
|
|
||||||
if(foundSpecificAnimation == false) {
|
if(foundSpecificAnimation == false) {
|
||||||
//int modelIndex = random.randRange(0,animations.size()-1);
|
//int modelIndex = random.randRange(0,animations.size()-1);
|
||||||
//srand(time(NULL) + unit->getId());
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks() + unit->getId());
|
srand((unsigned int)seed.getCurTicks() + unit->getId());
|
||||||
|
|
||||||
modelIndex = rand() % animations.size();
|
modelIndex = rand() % animations.size();
|
||||||
|
|
||||||
@@ -546,9 +545,8 @@ Model *SkillType::getAnimation(float animProgress, const Unit *unit,
|
|||||||
//printf("SELECTING RANDOM Model index = %d [%s] model attributes [%d to %d] for unit [%s - %d] with HP = %d\n",modelIndex,animations[modelIndex]->getFileName().c_str(),attributes.fromHp,attributes.toHp,unit->getType()->getName().c_str(),unit->getId(),unit->getHp());
|
//printf("SELECTING RANDOM Model index = %d [%s] model attributes [%d to %d] for unit [%s - %d] with HP = %d\n",modelIndex,animations[modelIndex]->getFileName().c_str(),attributes.fromHp,attributes.toHp,unit->getType()->getName().c_str(),unit->getId(),unit->getHp());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//srand(time(NULL) + unit->getId());
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand(seed.getCurTicks() + unit->getId());
|
srand((unsigned int)seed.getCurTicks() + unit->getId());
|
||||||
|
|
||||||
int filteredModelIndex = rand() % filteredAnimations.size();
|
int filteredModelIndex = rand() % filteredAnimations.size();
|
||||||
modelIndex = filteredAnimations[filteredModelIndex];
|
modelIndex = filteredAnimations[filteredModelIndex];
|
||||||
|
@@ -734,7 +734,7 @@ void writeCachedFileCRCValue(string crcCacheFile, uint32 &crcValue) {
|
|||||||
if(fp != NULL) {
|
if(fp != NULL) {
|
||||||
//RandomGen random;
|
//RandomGen random;
|
||||||
//int offset = random.randRange(5, 15);
|
//int offset = random.randRange(5, 15);
|
||||||
srand((unsigned long)time(NULL) + (unsigned long)crcCacheFile.length());
|
srand((unsigned int)time(NULL) + (unsigned long)crcCacheFile.length());
|
||||||
int offset = rand() % 15;
|
int offset = rand() % 15;
|
||||||
if(offset == 0) {
|
if(offset == 0) {
|
||||||
offset = 3;
|
offset = 3;
|
||||||
|
@@ -440,7 +440,6 @@ const string Properties::getRandomKey(const bool realrandom) const{
|
|||||||
int max=getPropertyCount();
|
int max=getPropertyCount();
|
||||||
int randomIndex=-1;
|
int randomIndex=-1;
|
||||||
if(realrandom == true){
|
if(realrandom == true){
|
||||||
//srand((unsigned int)time(NULL));
|
|
||||||
Chrono seed(true);
|
Chrono seed(true);
|
||||||
srand((unsigned int)seed.getCurTicks());
|
srand((unsigned int)seed.getCurTicks());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user