From 3388587b7a2ded9333ab48ce4d02372d750a60fe Mon Sep 17 00:00:00 2001 From: jackpoz Date: Tue, 22 Jul 2014 21:43:19 +0200 Subject: Core/Misc: Replace rand() calls with SFMT --- src/server/scripts/World/go_scripts.cpp | 4 ++-- src/server/scripts/World/mob_generic_creature.cpp | 4 ++-- src/server/scripts/World/npcs_special.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/server/scripts/World') diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 4bb88a560bb..3c3f0c2c26b 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -245,7 +245,7 @@ public: bool OnGossipHello(Player* player, GameObject* go) override { go->UseDoorOrButton(); - int Random = rand() % (sizeof(NpcPrisonEntry) / sizeof(uint32)); + int Random = rand32() % (sizeof(NpcPrisonEntry) / sizeof(uint32)); if (Creature* creature = player->SummonCreature(NpcPrisonEntry[Random], go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), go->GetAngle(player), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) @@ -295,7 +295,7 @@ public: bool OnGossipHello(Player* player, GameObject* go) override { go->UseDoorOrButton(); - int Random = rand() % (sizeof(NpcStasisEntry) / sizeof(uint32)); + int Random = rand32() % (sizeof(NpcStasisEntry) / sizeof(uint32)); player->SummonCreature(NpcStasisEntry[Random], go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), go->GetAngle(player), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); diff --git a/src/server/scripts/World/mob_generic_creature.cpp b/src/server/scripts/World/mob_generic_creature.cpp index 2eb91b7b8fe..a27a78a5338 100644 --- a/src/server/scripts/World/mob_generic_creature.cpp +++ b/src/server/scripts/World/mob_generic_creature.cpp @@ -107,7 +107,7 @@ public: else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); //50% chance if elite or higher, 20% chance if not, to replace our white hit with a spell - if (info && (rand() % (me->GetCreatureTemplate()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown) + if (info && (rand32() % (me->GetCreatureTemplate()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown) { //Cast the spell if (Healing)DoCastSpell(me, info); @@ -130,7 +130,7 @@ public: SpellInfo const* info = NULL; //Select a healing spell if less than 30% hp ONLY 33% of the time - if (HealthBelowPct(30) && rand() % 3 == 0) + if (HealthBelowPct(30) && rand32() % 3 == 0) info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index e67823a2939..f4a8d72d8c8 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -365,7 +365,7 @@ public: switch (emote) { case TEXT_EMOTE_CHICKEN: - if (player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE && rand() % 30 == 1) + if (player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE && rand32() % 30 == 1) { me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); me->setFaction(FACTION_FRIENDLY); @@ -841,16 +841,16 @@ void npc_doctor::npc_doctorAI::UpdateAI(uint32 diff) if (Coordinates.empty()) return; - std::vector::iterator itr = Coordinates.begin() + rand() % Coordinates.size(); + std::vector::iterator itr = Coordinates.begin() + rand32() % Coordinates.size(); uint32 patientEntry = 0; switch (me->GetEntry()) { case DOCTOR_ALLIANCE: - patientEntry = AllianceSoldierId[rand() % 3]; + patientEntry = AllianceSoldierId[rand32() % 3]; break; case DOCTOR_HORDE: - patientEntry = HordeSoldierId[rand() % 3]; + patientEntry = HordeSoldierId[rand32() % 3]; break; default: TC_LOG_ERROR("scripts", "Invalid entry for Triage doctor. Please check your database"); -- cgit v1.2.3