shuffleArray(int *, int, CvRandom &)
- Defined in
- CvGameCoreUtils.cpp, line 895
- Hook name
CivHooks::shuffleArray
Hooks
static bool BeforeshuffleArray(int* piShuffle, int iNum, CvRandom& rand);static void AftershuffleArray(int* piShuffle, int iNum, CvRandom& rand);static void ReplaceshuffleArray(void (*original)(int*, int, CvRandom&), int* piShuffle, int iNum, CvRandom& rand);CivRegisterBefore<CivHooks::shuffleArray>(host, &BeforeshuffleArray);CivRegisterAfter<CivHooks::shuffleArray>(host, &AftershuffleArray);CivRegisterReplace<CivHooks::shuffleArray>(host, &ReplaceshuffleArray);
Code
895void shuffleArray(int* piShuffle, int iNum, CvRandom& rand)896{897 int iI, iJ;898899 for(iI = 0; iI < iNum; iI++)900 {901 piShuffle[iI] = iI;902 }903904 for(iI = 0; iI < iNum; iI++)905 {906 iJ = (rand.get(iNum - iI, NULL) + iI);907908 if(iI != iJ)909 {910 int iTemp = piShuffle[iI];911 piShuffle[iI] = piShuffle[iJ];912 piShuffle[iJ] = iTemp;913 }914 }915}