From 5cb57268f2f4b3d2f59df47710b52e7f530c18b3 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Sun, 22 Dec 2002 02:37:40 +0000 Subject: [PATCH] Renamed 'Random' to 'TFB_Random' to avoid conflict with Carbon framework on MacOS X. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@462 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/battle.c | 4 +-- sc2/src/sc2code/build.h | 2 +- sc2/src/sc2code/comm.c | 24 +++++++-------- sc2/src/sc2code/comm/melnorm/melnorm.c | 2 +- sc2/src/sc2code/comm/mycon/myconc.c | 2 +- sc2/src/sc2code/comm/starbas/starbas.c | 6 ++-- sc2/src/sc2code/comm/yehat/yehatc.c | 2 +- sc2/src/sc2code/cyborg.c | 4 +-- sc2/src/sc2code/encount.c | 2 +- sc2/src/sc2code/galaxy.c | 8 ++--- sc2/src/sc2code/grpinfo.c | 14 ++++----- sc2/src/sc2code/hyper.c | 10 +++---- sc2/src/sc2code/ipdisp.c | 12 ++++---- sc2/src/sc2code/libs/math/fastrand.c | 4 +-- sc2/src/sc2code/libs/math/random.c | 6 ++-- sc2/src/sc2code/libs/math/random.h | 6 ++-- sc2/src/sc2code/libs/mathlib.h | 2 +- sc2/src/sc2code/melee.c | 2 +- sc2/src/sc2code/misc.c | 24 +++++++-------- sc2/src/sc2code/pickmele.c | 2 +- sc2/src/sc2code/planets/calc.c | 6 ++-- sc2/src/sc2code/planets/genburv.c | 6 ++-- sc2/src/sc2code/planets/genchmmr.c | 2 +- sc2/src/sc2code/planets/gendru.c | 2 +- sc2/src/sc2code/planets/genilw.c | 2 +- sc2/src/sc2code/planets/genmyc.c | 2 +- sc2/src/sc2code/planets/genorz.c | 6 ++-- sc2/src/sc2code/planets/genpet.c | 4 +-- sc2/src/sc2code/planets/genpku.c | 2 +- sc2/src/sc2code/planets/gensam.c | 2 +- sc2/src/sc2code/planets/gensol.c | 6 ++-- sc2/src/sc2code/planets/genspa.c | 6 ++-- sc2/src/sc2code/planets/gensup.c | 2 +- sc2/src/sc2code/planets/genthrad.c | 4 +-- sc2/src/sc2code/planets/gentopo.c | 4 +-- sc2/src/sc2code/planets/genutw.c | 4 +-- sc2/src/sc2code/planets/genvault.c | 2 +- sc2/src/sc2code/planets/genvux.c | 6 ++-- sc2/src/sc2code/planets/genwreck.c | 2 +- sc2/src/sc2code/planets/genyeh.c | 2 +- sc2/src/sc2code/planets/genzoq.c | 2 +- sc2/src/sc2code/planets/lander.c | 36 +++++++++++------------ sc2/src/sc2code/planets/orbits.c | 8 ++--- sc2/src/sc2code/planets/pl_stuff.c | 2 +- sc2/src/sc2code/planets/plandata.h | 2 +- sc2/src/sc2code/planets/plangen.c | 16 +++++----- sc2/src/sc2code/planets/scan.c | 4 +-- sc2/src/sc2code/planets/solarsys.c | 8 ++--- sc2/src/sc2code/planets/surface.c | 14 ++++----- sc2/src/sc2code/ship.c | 6 ++-- sc2/src/sc2code/ships/androsyn/androsyn.c | 8 ++--- sc2/src/sc2code/ships/arilou/arilou.c | 6 ++-- sc2/src/sc2code/ships/chenjesu/chenjesu.c | 2 +- sc2/src/sc2code/ships/chmmr/chmmr.c | 6 ++-- sc2/src/sc2code/ships/lastbat/lastbat.c | 6 ++-- sc2/src/sc2code/ships/melnorme/melnorme.c | 2 +- sc2/src/sc2code/ships/orz/orz.c | 12 ++++---- sc2/src/sc2code/ships/pkunk/pkunk.c | 12 ++++---- sc2/src/sc2code/ships/shofixti/shofixti.c | 2 +- sc2/src/sc2code/ships/slylandr/slylandr.c | 2 +- sc2/src/sc2code/ships/supox/supox.c | 2 +- sc2/src/sc2code/ships/umgah/umgah.c | 2 +- sc2/src/sc2code/ships/utwig/utwig.c | 2 +- sc2/src/sc2code/ships/vux/vux.c | 6 ++-- sc2/src/sc2code/ships/yehat/yehat.c | 2 +- sc2/src/sc2code/ships/zoqfot/zoqfot.c | 2 +- sc2/src/sc2code/tactrans.c | 4 +-- sc2/src/sc2code/weapon.c | 6 ++-- 68 files changed, 196 insertions(+), 196 deletions(-) diff --git a/sc2/src/sc2code/battle.c b/sc2/src/sc2code/battle.c index f02606c6c..49319bd8c 100644 --- a/sc2/src/sc2code/battle.c +++ b/sc2/src/sc2code/battle.c @@ -177,9 +177,9 @@ Battle (void) SeedRandom (GetTimeCounter ()); #else /* DEMO_MODE */ if (BattleSeed == 0) - BattleSeed = Random (); + BattleSeed = TFB_Random (); SeedRandom (BattleSeed); - BattleSeed = Random (); /* get next battle seed */ + BattleSeed = TFB_Random (); /* get next battle seed */ #endif /* DEMO_MODE */ BattleSong (FALSE); diff --git a/sc2/src/sc2code/build.h b/sc2/src/sc2code/build.h index cfcc665f5..cfa3c5a62 100644 --- a/sc2/src/sc2code/build.h +++ b/sc2/src/sc2code/build.h @@ -35,7 +35,7 @@ (BYTE)HIWORD ((S)->RaceDescPtr) #define StarShipPlayer(S) \ (COUNT)LOWORD ((S)->RaceDescPtr) -#define PickCaptainName() (((COUNT)Random () \ +#define PickCaptainName() (((COUNT)TFB_Random () \ & (NUM_CAPTAINS_NAMES - 1)) \ + NAME_OFFSET) diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index abc4f540e..54d44314e 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -672,11 +672,11 @@ SetUpSequence (PSEQUENCE pSeq) if (pSeq->AnimType == COLOR_ANIM) pSeq->AnimObj.CurCMap = SetRelColorMapIndex (pSeq->AnimObj.CurCMap, - (COUNT)Random () % pSeq->FramesLeft); + (COUNT)TFB_Random () % pSeq->FramesLeft); else pSeq->AnimObj.CurFrame = SetRelFrameIndex (pSeq->AnimObj.CurFrame, - (COUNT)Random () % pSeq->FramesLeft); + (COUNT)TFB_Random () % pSeq->FramesLeft); } else if (ADPtr->AnimFlags & YOYO_ANIM) { @@ -691,7 +691,7 @@ SetUpSequence (PSEQUENCE pSeq) pSeq->Alarm = ADPtr->BaseRestartRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomRestartRate + 1)) + 1; } @@ -803,7 +803,7 @@ int ambient_anim_task(void* data) ActiveMask |= 1L << i; pSeq->Alarm = ADPtr->BaseFrameRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomFrameRate + 1)) + 1; } @@ -812,7 +812,7 @@ int ambient_anim_task(void* data) ActiveMask &= ~(1L << i); pSeq->Alarm = ADPtr->BaseRestartRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomRestartRate + 1)) + 1; if (ActiveMask & ADPtr->BlockMask) @@ -866,13 +866,13 @@ pBatch->Object.Stamp.origin.x = -SAFE_X; pSeq->AnimObj.CurCMap = SetAbsColorMapIndex (pSeq->AnimObj.CurCMap, ADPtr->StartIndex - + ((COUNT)Random () + + ((COUNT)TFB_Random () % ADPtr->NumFrames)); else pSeq->AnimObj.CurFrame = SetAbsFrameIndex (pSeq->AnimObj.CurFrame, ADPtr->StartIndex - + ((COUNT)Random () + + ((COUNT)TFB_Random () % ADPtr->NumFrames)); } else if (pSeq->AnimType == COLOR_ANIM) @@ -937,7 +937,7 @@ pBatch->Object.Stamp.origin.x = -SAFE_X; { FrameRate = ADPtr->BaseFrameRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomFrameRate + 1)); if (TalkAlarm < 0 || GetFrameIndex (TalkFrame) == @@ -945,11 +945,11 @@ pBatch->Object.Stamp.origin.x = -SAFE_X; { TalkFrame = SetAbsFrameIndex (CommFrame, ADPtr->StartIndex + 1 - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->NumFrames - 1))); FrameRate += ADPtr->BaseRestartRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomRestartRate + 1)); } else @@ -984,7 +984,7 @@ pBatch->Object.Stamp.origin.x = -SAFE_X; { FrameRate = ADPtr->BaseFrameRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomFrameRate + 1)); if (TalkAlarm < 0) TalkFrame = SetAbsFrameIndex (CommFrame, @@ -1001,7 +1001,7 @@ pBatch->Object.Stamp.origin.x = -SAFE_X; { FrameRate = ADPtr->BaseFrameRate - + ((COUNT)Random () + + ((COUNT)TFB_Random () % (ADPtr->RandomFrameRate + 1)); if (TalkAlarm < 0) TalkFrame = SetAbsFrameIndex (CommFrame, diff --git a/sc2/src/sc2code/comm/melnorm/melnorm.c b/sc2/src/sc2code/comm/melnorm/melnorm.c index 1d23447d4..30c7b3ded 100644 --- a/sc2/src/sc2code/comm/melnorm/melnorm.c +++ b/sc2/src/sc2code/comm/melnorm/melnorm.c @@ -238,7 +238,7 @@ StripShip (COUNT fuel_required) { DWORD rand_val; - rand_val = Random (); + rand_val = TFB_Random (); switch (which_module = LOBYTE (LOWORD (rand_val)) % (CREW_POD + 1)) { case PLANET_LANDER: diff --git a/sc2/src/sc2code/comm/mycon/myconc.c b/sc2/src/sc2code/comm/mycon/myconc.c index c974dd2eb..5f026cbd1 100644 --- a/sc2/src/sc2code/comm/mycon/myconc.c +++ b/sc2/src/sc2code/comm/mycon/myconc.c @@ -356,7 +356,7 @@ NormalMycon (RESPONSE_REF R) DISABLE_PHRASE (RESPONSE_TO_REF (R)); } - if ((BYTE)Random () < 256 * 30 / 100) + if ((BYTE)TFB_Random () < 256 * 30 / 100) RespFunc = (RESPONSE_FUNC)CombatIsInevitable; else RespFunc = (RESPONSE_FUNC)NormalMycon; diff --git a/sc2/src/sc2code/comm/starbas/starbas.c b/sc2/src/sc2code/comm/starbas/starbas.c index 0b35750e2..4dcd56674 100644 --- a/sc2/src/sc2code/comm/starbas/starbas.c +++ b/sc2/src/sc2code/comm/starbas/starbas.c @@ -163,7 +163,7 @@ RESPONSE_REF R; { RESPONSE_REF pStr0, pStr1; - switch ((BYTE)Random () & 7) + switch ((BYTE)TFB_Random () & 7) { case 0: pStr0 = NORMAL_GOODBYE_A0; @@ -1572,7 +1572,7 @@ CheckBulletins (BOOLEAN Repeat) pIntro = BEFORE_WE_GO_ON_1; else { - switch ((BYTE)Random () % 7) + switch ((BYTE)TFB_Random () % 7) { case 0: pIntro = BEFORE_WE_GO_ON_1; @@ -1656,7 +1656,7 @@ NormalStarbase (RESPONSE_REF R) { RESPONSE_REF pStr0, pStr1; - switch ((BYTE)Random () & 7) + switch ((BYTE)TFB_Random () & 7) { case 0: pStr0 = NORMAL_HELLO_A0; diff --git a/sc2/src/sc2code/comm/yehat/yehatc.c b/sc2/src/sc2code/comm/yehat/yehatc.c index 7a69a299e..7efb75a6c 100644 --- a/sc2/src/sc2code/comm/yehat/yehatc.c +++ b/sc2/src/sc2code/comm/yehat/yehatc.c @@ -189,7 +189,7 @@ ExitConversation (RESPONSE_REF R) } else if (PLAYER_SAID (R, bye_space)) { - if ((BYTE)Random () & 1) + if ((BYTE)TFB_Random () & 1) NPCPhrase (GOODBYE_AND_DIE_SPACE); else { diff --git a/sc2/src/sc2code/cyborg.c b/sc2/src/sc2code/cyborg.c index 45ac837e2..d93377714 100644 --- a/sc2/src/sc2code/cyborg.c +++ b/sc2/src/sc2code/cyborg.c @@ -494,7 +494,7 @@ TurnShip (ELEMENTPTR ShipPtr, COUNT angle) if (ship_delta_facing == ANGLE_TO_FACING (HALF_CIRCLE)) ship_delta_facing = NORMALIZE_FACING (ship_delta_facing + - (Random () & 1 ? + (TFB_Random () & 1 ? ANGLE_TO_FACING (OCTANT >> 1) : -ANGLE_TO_FACING (OCTANT >> 1))); @@ -766,7 +766,7 @@ Entice (ELEMENTPTR ShipPtr, EVALUATE_DESCPTR EvalDescPtr) - EvalDescPtr->facing ); if ((desired_turn_angle & (HALF_CIRCLE - 1)) == 0) - desired_thrust_angle = Random () & 1 ? RIGHT : LEFT; + desired_thrust_angle = TFB_Random () & 1 ? RIGHT : LEFT; else desired_thrust_angle = desired_turn_angle < HALF_CIRCLE ? RIGHT : LEFT; } diff --git a/sc2/src/sc2code/encount.c b/sc2/src/sc2code/encount.c index 02961bd2d..d2ae0fd06 100644 --- a/sc2/src/sc2code/encount.c +++ b/sc2/src/sc2code/encount.c @@ -106,7 +106,7 @@ BuildBattle (COUNT which_player) load_gravity_well (NUMBER_OF_PLANET_TYPES); break; case IN_HYPERSPACE: - load_gravity_well ((BYTE)((COUNT)Random () + load_gravity_well ((BYTE)((COUNT)TFB_Random () % NUMBER_OF_PLANET_TYPES)); break; default: diff --git a/sc2/src/sc2code/galaxy.c b/sc2/src/sc2code/galaxy.c index f8c363a9a..de79b707c 100644 --- a/sc2/src/sc2code/galaxy.c +++ b/sc2/src/sc2code/galaxy.c @@ -241,8 +241,8 @@ InitGalaxy (void) if (i == BIG_STAR_COUNT || i == BIG_STAR_COUNT + MED_STAR_COUNT) ++factor; - ppt->x = (COORD)((UWORD)Random () % SPACE_WIDTH) << factor; - ppt->y = (COORD)((UWORD)Random () % SPACE_HEIGHT) << factor; + ppt->x = (COORD)((UWORD)TFB_Random () % SPACE_WIDTH) << factor; + ppt->y = (COORD)((UWORD)TFB_Random () % SPACE_HEIGHT) << factor; if (i < BIG_STAR_COUNT + MED_STAR_COUNT) { @@ -307,7 +307,7 @@ MoveGalaxy (VIEW_STATE view_state, register SIZE dx, register SIZE dy) { pprim->Object.Stamp.frame = SetAbsFrameIndex (stars_in_space, - ((COUNT)Random () & 31) + (32 + 26)); + ((COUNT)TFB_Random () & 31) + (32 + 26)); ++pprim; } while (--i); @@ -316,7 +316,7 @@ MoveGalaxy (VIEW_STATE view_state, register SIZE dx, register SIZE dy) { pprim->Object.Stamp.frame = SetAbsFrameIndex (stars_in_space, - ((COUNT)Random () & 31) + 26); + ((COUNT)TFB_Random () & 31) + 26); ++pprim; } while (--i); } diff --git a/sc2/src/sc2code/grpinfo.c b/sc2/src/sc2code/grpinfo.c index 6d6ca5c0c..2841812ca 100644 --- a/sc2/src/sc2code/grpinfo.c +++ b/sc2/src/sc2code/grpinfo.c @@ -162,7 +162,7 @@ BuildGroups (void) * 60L / encounter_radius); } - rand_val = Random (); + rand_val = TFB_Random (); if ((int)(LOWORD (rand_val) % 100) < (int)i && (BestPercent == 0 || (HIWORD (rand_val) % (i + BestPercent)) < i)) @@ -192,7 +192,7 @@ FoundHome: }; which_group = 0; - num_groups = ((COUNT)Random () % (BestPercent >> 1)) + 1; + num_groups = ((COUNT)TFB_Random () % (BestPercent >> 1)) + 1; if (num_groups > (MAX_BATTLE_GROUPS >> 1)) num_groups = (MAX_BATTLE_GROUPS >> 1); else if (num_groups < 5 @@ -204,7 +204,7 @@ FoundHome: for (Index = HINIBBLE (EncounterMakeup[BestIndex]); Index; --Index) { if (Index <= LONIBBLE (EncounterMakeup[BestIndex]) - || (COUNT)Random () % 100 < 50) + || (COUNT)TFB_Random () % 100 < 50) CloneShipFragment ( BestIndex, &GLOBAL (npc_built_ship_q), 0 ); @@ -417,7 +417,7 @@ GetGroupInfo (DWORD offset, BYTE which_group) OwnStarShip (FragPtr, BAD_GUY, 0); SET_GROUP_ID (FragPtr, which_group); - rand_val = Random (); + rand_val = TFB_Random (); task = (BYTE)(LOBYTE (LOWORD (rand_val)) % ON_STATION); if (task == FLEE) task = ON_STATION; @@ -432,14 +432,14 @@ GetGroupInfo (DWORD offset, BYTE which_group) HIBYTE (LOWORD (rand_val)) % group_loc ) + 1); SET_GROUP_DEST (FragPtr, group_loc); - rand_val = Random (); + rand_val = TFB_Random (); FragPtr->ShipInfo.loc.x = (LOWORD (rand_val) % 10000) - 5000; FragPtr->ShipInfo.loc.y = (HIWORD (rand_val) % 10000) - 5000; if (task == EXPLORE) FragPtr->ShipInfo.group_counter = - ((COUNT)Random () + ((COUNT)TFB_Random () % MAX_REVOLUTIONS) << FACING_SHIFT; else @@ -491,7 +491,7 @@ GetGroupInfo (DWORD offset, BYTE which_group) if (offset) InitGroupInfo (FALSE); - /* Random battle group */ + /* TFB_Random battle group */ else if (ValidateEvent (ABSOLUTE_EVENT, /* still fresh */ &month_index, &day_index, &year_index)) { diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index bd5944bff..638d2a630 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -227,7 +227,7 @@ percent = 0; && (COUNT)dy < encounter_radius && (DWORD)dx * dx + (DWORD)dy * dy < (DWORD)encounter_radius * encounter_radius - && ((COUNT)Random () % 100) < percent) + && ((COUNT)TFB_Random () % 100) < percent) { #ifndef DEBUG char buf[20]; @@ -794,7 +794,7 @@ AddAmbientElement (void) SetPrimType (&DisplayArray[HyperSpaceElementPtr->PrimIndex], STAMP_PRIM); HyperSpaceElementPtr->preprocess_func = animation_preprocess; - rand_val = Random (); + rand_val = TFB_Random (); dy = LOWORD (rand_val); dx = (SIZE)(LOBYTE (dy) % SPACE_WIDTH) - (SPACE_WIDTH >> 1); dy = (SIZE)(HIBYTE (dy) % SPACE_HEIGHT) - (SPACE_HEIGHT >> 1); @@ -941,7 +941,7 @@ AddEncounterElement (ENCOUNTERPTR EncounterPtr, NumShips = LONIBBLE (EncounterMakeup[Type]); for (i = HINIBBLE (EncounterMakeup[Type]) - NumShips; i; --i) { - if ((COUNT)Random () % 100 < 50) + if ((COUNT)TFB_Random () % 100 < 50) ++NumShips; } @@ -975,7 +975,7 @@ AddEncounterElement (ENCOUNTERPTR EncounterPtr, { DWORD rand_val; - rand_val = Random (); + rand_val = TFB_Random (); SD.star_pt.x = puniverse->x + (LOWORD (rand_val) % (XOFFS << 1)) - XOFFS; @@ -1527,7 +1527,7 @@ SeedUniverse (void) SetContext (StatusContext); - if (!(LOWORD (Random ()) & 7)) + if (!(LOWORD (TFB_Random ()) & 7)) AddAmbientElement (); if (universe.x != GLOBAL (ShipStamp.origin.x) diff --git a/sc2/src/sc2code/ipdisp.c b/sc2/src/sc2code/ipdisp.c index fc4dd9a4e..06d0979f7 100644 --- a/sc2/src/sc2code/ipdisp.c +++ b/sc2/src/sc2code/ipdisp.c @@ -48,10 +48,10 @@ NotifyOthers (COUNT which_race, BYTE target_loc) else if ((target_loc = GET_GROUP_DEST (StarShipPtr)) == 0) { target_loc = GET_ORBIT_LOC (StarShipPtr); - SET_ORBIT_LOC (StarShipPtr, NORMALIZE_FACING (Random ())); + SET_ORBIT_LOC (StarShipPtr, NORMALIZE_FACING (TFB_Random ())); #ifdef OLD target_loc = (BYTE)(( - (COUNT)Random () + (COUNT)TFB_Random () % pSolarSysState->SunDesc[0].NumPlanets ) + 1); #endif /* OLD */ @@ -61,7 +61,7 @@ NotifyOthers (COUNT which_race, BYTE target_loc) StarShipPtr->ShipInfo.group_counter = 0; else StarShipPtr->ShipInfo.group_counter = - ((COUNT)Random () + ((COUNT)TFB_Random () % MAX_REVOLUTIONS) << FACING_SHIFT; } @@ -139,7 +139,7 @@ ip_group_preprocess (PELEMENT ElementPtr) StarShipPtr->ShipInfo.group_counter = 0; else StarShipPtr->ShipInfo.group_counter = - ((COUNT)Random () + ((COUNT)TFB_Random () % MAX_REVOLUTIONS) << FACING_SHIFT; } @@ -263,7 +263,7 @@ ip_group_preprocess (PELEMENT ElementPtr) if (StarShipPtr->ShipInfo.group_counter) --StarShipPtr->ShipInfo.group_counter; else if (task == EXPLORE - && (next_loc = (BYTE)(((COUNT)Random () + && (next_loc = (BYTE)(((COUNT)TFB_Random () % pSolarSysState->SunDesc[0].NumPlanets) + 1)) != target_loc) { @@ -420,7 +420,7 @@ CheckGetAway: ANGLE_TO_FACING (angle + HALF_CIRCLE) )); StarShipPtr->ShipInfo.group_counter = - ((COUNT)Random () % MAX_REVOLUTIONS) + ((COUNT)TFB_Random () % MAX_REVOLUTIONS) << FACING_SHIFT; } diff --git a/sc2/src/sc2code/libs/math/fastrand.c b/sc2/src/sc2code/libs/math/fastrand.c index 7a8552ac0..76d6e76df 100644 --- a/sc2/src/sc2code/libs/math/fastrand.c +++ b/sc2/src/sc2code/libs/math/fastrand.c @@ -51,7 +51,7 @@ seed_fast_random(DWORD seed) retval = SeedRandom(seed); for( index = 0; index < TABLE_SIZE; index++ ) - random_table[index] = Random(); + random_table[index] = TFB_Random(); fast_index = 0; /* must be set to the start of the table for repeatability... */ @@ -95,7 +95,7 @@ fast_random() void reseed_fast_random() { - fast_index = (COUNT)(Random() % TABLE_SIZE); + fast_index = (COUNT)(TFB_Random() % TABLE_SIZE); } diff --git a/sc2/src/sc2code/libs/math/random.c b/sc2/src/sc2code/libs/math/random.c index e9fd9a632..a2dbe99d2 100644 --- a/sc2/src/sc2code/libs/math/random.c +++ b/sc2/src/sc2code/libs/math/random.c @@ -21,7 +21,7 @@ * DESC: a library of random number generators for general purpose use. * * References: -* "Random Number Generators: Good ones are hard to find" S.K.Park & K.W.Miller +* "TFB_Random Number Generators: Good ones are hard to find" S.K.Park & K.W.Miller * Communications of the ACM, Vol31 Number 10, October 1988, Pp 1192-1201 * * HISTORY: Created 1/23/1989 @@ -48,7 +48,7 @@ static DWORD seed = 12345L; /* random number seed */ /* ----------------------------CODE--------------------------------------- */ /***************************************************************************** -* FUNC: DWORD Random() +* FUNC: DWORD TFB_Random() * * DESC: random number generator * @@ -59,7 +59,7 @@ static DWORD seed = 12345L; /* random number seed */ *****************************************************************************/ DWORD -Random (void) +TFB_Random (void) { if ((seed = A * (seed % Q) - R * (seed / Q)) > M) return (seed -= M); diff --git a/sc2/src/sc2code/libs/math/random.h b/sc2/src/sc2code/libs/math/random.h index 1a98eb808..b54a392c4 100644 --- a/sc2/src/sc2code/libs/math/random.h +++ b/sc2/src/sc2code/libs/math/random.h @@ -41,9 +41,9 @@ #define SFASTRAND(n) ( (int)_FAST_ % (n) ) #define AND_FASTRAND(n) ( (int)_FAST_ & (n) ) -#define RAND(n) ( (int) ( (unsigned int)Random() % (n) ) ) -#define SRAND(n) ( (int)Random() % (n) ) -#define AND_RAND(n) ( (int)Random() & (n) ) +#define RAND(n) ( (int) ( (unsigned int)TFB_Random() % (n) ) ) +#define SRAND(n) ( (int)TFB_Random() % (n) ) +#define AND_RAND(n) ( (int)TFB_Random() & (n) ) #define INDEXED_RANDOM(x) (random_table[x]) diff --git a/sc2/src/sc2code/libs/mathlib.h b/sc2/src/sc2code/libs/mathlib.h index 3dd82af14..f9af4d5fe 100644 --- a/sc2/src/sc2code/libs/mathlib.h +++ b/sc2/src/sc2code/libs/mathlib.h @@ -22,7 +22,7 @@ #include "compiler.h" extern DWORD SeedRandom (DWORD seed); -extern DWORD Random (void); +extern DWORD TFB_Random (void); extern COUNT square_root (DWORD value); #endif /* _MATHLIB_H */ diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 588cbb6f7..a3015db02 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -1611,7 +1611,7 @@ DoMelee (INPUT_STATE InputState, PMELEE_STATE pMS) ; SeedRandomNumbers (); - load_gravity_well ((BYTE)((COUNT)Random () % NUMBER_OF_PLANET_TYPES)); + load_gravity_well ((BYTE)((COUNT)TFB_Random () % NUMBER_OF_PLANET_TYPES)); Battle (); free_gravity_well (); diff --git a/sc2/src/sc2code/misc.c b/sc2/src/sc2code/misc.c index ba8f4bcf5..64eea16fb 100644 --- a/sc2/src/sc2code/misc.c +++ b/sc2/src/sc2code/misc.c @@ -45,9 +45,9 @@ spawn_planet (void) do { PlanetElementPtr->current.location.x = - WRAP_X (DISPLAY_ALIGN_X (Random ())); + WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); PlanetElementPtr->current.location.y = - WRAP_Y (DISPLAY_ALIGN_Y (Random ())); + WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); } while (CalculateGravity (PlanetElementPtr) || TimeSpaceMatterConflict (PlanetElementPtr)); loc = PlanetElementPtr->current.location; @@ -152,19 +152,19 @@ spawn_asteroid (PELEMENT ElementPtr) AsteroidElementPtr->state_flags = APPEARING; AsteroidElementPtr->life_span = NORMAL_LIFE; SetPrimType (&DisplayArray[AsteroidElementPtr->PrimIndex], STAMP_PRIM); - if ((val = (COUNT)Random ()) & (1 << 0)) + if ((val = (COUNT)TFB_Random ()) & (1 << 0)) { if (!(val & (1 << 1))) AsteroidElementPtr->current.location.x = 0; else AsteroidElementPtr->current.location.x = LOG_SPACE_WIDTH; AsteroidElementPtr->current.location.y = - WRAP_Y (DISPLAY_ALIGN_Y (Random ())); + WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); } else { AsteroidElementPtr->current.location.x = - WRAP_X (DISPLAY_ALIGN_X (Random ())); + WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); if (!(val & (1 << 1))) AsteroidElementPtr->current.location.y = 0; else @@ -172,16 +172,16 @@ spawn_asteroid (PELEMENT ElementPtr) } SetVelocityVector (&AsteroidElementPtr->velocity, - DISPLAY_TO_WORLD (((SIZE)Random () & 7) + 4), - (COUNT)Random ()); + DISPLAY_TO_WORLD (((SIZE)TFB_Random () & 7) + 4), + (COUNT)TFB_Random ()); AsteroidElementPtr->current.image.farray = asteroid; AsteroidElementPtr->current.image.frame = SetAbsFrameIndex (asteroid[0], - NORMALIZE_FACING (Random ())); + NORMALIZE_FACING (TFB_Random ())); AsteroidElementPtr->turn_wait = AsteroidElementPtr->thrust_wait = - (BYTE)Random () & (BYTE)((1 << 2) - 1); - AsteroidElementPtr->thrust_wait |= (BYTE)Random () & (BYTE)(1 << 7); + (BYTE)TFB_Random () & (BYTE)((1 << 2) - 1); + AsteroidElementPtr->thrust_wait |= (BYTE)TFB_Random () & (BYTE)(1 << 7); AsteroidElementPtr->preprocess_func = asteroid_preprocess; AsteroidElementPtr->death_func = spawn_rubble; AsteroidElementPtr->collision_func = collision; @@ -354,8 +354,8 @@ AbandonShip (ELEMENTPTR ShipPtr, ELEMENTPTR TargetPtr, ShipIntersect.IntersectStamp.origin = ShipPtr->IntersectControl.EndPoint; - w = (SIZE)((COUNT)Random () % r.extent.width); - h = (SIZE)((COUNT)Random () % r.extent.height); + w = (SIZE)((COUNT)TFB_Random () % r.extent.width); + h = (SIZE)((COUNT)TFB_Random () % r.extent.height); CrewIntersect.EndPoint = ShipIntersect.EndPoint; CrewIntersect.IntersectStamp.frame = DecFrameIndex (stars_in_space); if (dx == 0 && dy == 0) diff --git a/sc2/src/sc2code/pickmele.c b/sc2/src/sc2code/pickmele.c index 82549cd4e..9de62b179 100644 --- a/sc2/src/sc2code/pickmele.c +++ b/sc2/src/sc2code/pickmele.c @@ -300,7 +300,7 @@ ChangeSelection: hBattleShip = 0; else { - ship_index = (COUNT)Random () % ships_left; + ship_index = (COUNT)TFB_Random () % ships_left; for (hBattleShip = GetHeadLink (&race_q[which_player]); hBattleShip != 0; hBattleShip = hNextShip) { diff --git a/sc2/src/sc2code/planets/calc.c b/sc2/src/sc2code/planets/calc.c index b56a6242e..d6d0ee691 100644 --- a/sc2/src/sc2code/planets/calc.c +++ b/sc2/src/sc2code/planets/calc.c @@ -193,7 +193,7 @@ CalcRotation (PLANET_INFOPTR PlanetInfoPtr) { if (PLANSIZE (PlanetInfoPtr->PlanDataPtr->Type) == GAS_GIANT) return ((COUNT)CalcFromBase (80, 80)); - else if (((BYTE)Random () % 10) == 0) + else if (((BYTE)TFB_Random () % 10) == 0) return ((COUNT)CalcFromBase ((UWORD)50 * 240, (UWORD)200 * 240)); else return ((COUNT)CalcFromBase (150, 150)); @@ -211,7 +211,7 @@ CalcTilt (void) i = NUM_TOSSES; do /* Using added Randomom values to give bell curve */ { - tilt += (UWORD)Random () % ((TILT_RANGE / NUM_TOSSES) + 1); + tilt += (UWORD)TFB_Random () % ((TILT_RANGE / NUM_TOSSES) + 1); } while (--i); return (tilt); @@ -292,7 +292,7 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC } SysInfoPtr->PlanetInfo.PlanetDensity += (SysInfoPtr->PlanetInfo.PlanetDensity / 20) - - ((COUNT)Random () + - ((COUNT)TFB_Random () % (SysInfoPtr->PlanetInfo.PlanetDensity / 10)); switch (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type)) diff --git a/sc2/src/sc2code/planets/genburv.c b/sc2/src/sc2code/planets/genburv.c index c4ba23ac5..fee20c488 100644 --- a/sc2/src/sc2code/planets/genburv.c +++ b/sc2/src/sc2code/planets/genburv.c @@ -41,7 +41,7 @@ GenerateBurvixes (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -67,7 +67,7 @@ GenerateBurvixes (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -104,7 +104,7 @@ GenerateBurvixes (BYTE control) pSolarSysState->MoonDesc[0].data_index = SELENIC_WORLD; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS + (MAX_MOONS - 1) * MOON_DELTA; - rand_val = Random (); + rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pSolarSysState->MoonDesc[0].location.x = COSINE (angle, pSolarSysState->MoonDesc[0].radius); diff --git a/sc2/src/sc2code/planets/genchmmr.c b/sc2/src/sc2code/planets/genchmmr.c index a2b2f2fbb..33e90d4ad 100644 --- a/sc2/src/sc2code/planets/genchmmr.c +++ b/sc2/src/sc2code/planets/genchmmr.c @@ -33,7 +33,7 @@ GenerateChmmr (BYTE control) pSolarSysState->MoonDesc[0].data_index = (BYTE)~0; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS; - rand_val = Random (); + rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pSolarSysState->MoonDesc[0].location.x = COSINE (angle, pSolarSysState->MoonDesc[0].radius); diff --git a/sc2/src/sc2code/planets/gendru.c b/sc2/src/sc2code/planets/gendru.c index 0ef84f7df..088a40036 100644 --- a/sc2/src/sc2code/planets/gendru.c +++ b/sc2/src/sc2code/planets/gendru.c @@ -37,7 +37,7 @@ GenerateDruuge (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genilw.c b/sc2/src/sc2code/planets/genilw.c index df4b9ee91..b89ec5165 100644 --- a/sc2/src/sc2code/planets/genilw.c +++ b/sc2/src/sc2code/planets/genilw.c @@ -36,7 +36,7 @@ GenerateIlwrath (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genmyc.c b/sc2/src/sc2code/planets/genmyc.c index 59df407ed..2ba02a57f 100644 --- a/sc2/src/sc2code/planets/genmyc.c +++ b/sc2/src/sc2code/planets/genmyc.c @@ -36,7 +36,7 @@ GenerateMycon (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genorz.c b/sc2/src/sc2code/planets/genorz.c index daaecf5f6..5f30d6d13 100644 --- a/sc2/src/sc2code/planets/genorz.c +++ b/sc2/src/sc2code/planets/genorz.c @@ -39,7 +39,7 @@ GenerateAndrosynth (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -201,7 +201,7 @@ GenerateOrz (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -238,7 +238,7 @@ GenerateOrz (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genpet.c b/sc2/src/sc2code/planets/genpet.c index 5bc1a6f86..68752341e 100644 --- a/sc2/src/sc2code/planets/genpet.c +++ b/sc2/src/sc2code/planets/genpet.c @@ -89,7 +89,7 @@ ZapToUrquanEncounter (void) DeltaSISGauges (0, -dx, 0); if (GLOBAL_SIS (FuelOnBoard) < 5 * FUEL_TANK_SCALE) { - dx = ((5 + ((COUNT)Random () % 5)) * FUEL_TANK_SCALE) + dx = ((5 + ((COUNT)TFB_Random () % 5)) * FUEL_TANK_SCALE) - (SIZE)GLOBAL_SIS (FuelOnBoard); DeltaSISGauges (0, dx, 0); } @@ -119,7 +119,7 @@ GenerateTalkingPet (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genpku.c b/sc2/src/sc2code/planets/genpku.c index 94994af54..36c9b0f88 100644 --- a/sc2/src/sc2code/planets/genpku.c +++ b/sc2/src/sc2code/planets/genpku.c @@ -37,7 +37,7 @@ GeneratePkunk (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/gensam.c b/sc2/src/sc2code/planets/gensam.c index 91bdcbfbf..9a580cd24 100644 --- a/sc2/src/sc2code/planets/gensam.c +++ b/sc2/src/sc2code/planets/gensam.c @@ -217,7 +217,7 @@ GenerateSamatra (BYTE control) pSolarSysState->MoonDesc[0].data_index = (BYTE)(~0 - 1); pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS + (2 * MOON_DELTA); - rand_val = Random (); + rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pSolarSysState->MoonDesc[0].location.x = COSINE (angle, pSolarSysState->MoonDesc[0].radius); diff --git a/sc2/src/sc2code/planets/gensol.c b/sc2/src/sc2code/planets/gensol.c index b316c4f7b..cea248123 100644 --- a/sc2/src/sc2code/planets/gensol.c +++ b/sc2/src/sc2code/planets/gensol.c @@ -140,7 +140,7 @@ generate_tractors (void) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -465,7 +465,7 @@ GenerateSOL (BYTE control) pSolarSysState->MoonDesc[1].data_index = SELENIC_WORLD; pSolarSysState->MoonDesc[1].radius = MIN_MOON_RADIUS + (MAX_MOONS - 1) * MOON_DELTA; - rand_val = Random (); + rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pSolarSysState->MoonDesc[1].location.x = COSINE (angle, pSolarSysState->MoonDesc[1].radius); @@ -499,7 +499,7 @@ GenerateSOL (BYTE control) COUNT angle; UWORD word_val; - pCurDesc->rand_seed = rand_val = Random (); + pCurDesc->rand_seed = rand_val = TFB_Random (); word_val = LOWORD (rand_val); angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val)); diff --git a/sc2/src/sc2code/planets/genspa.c b/sc2/src/sc2code/planets/genspa.c index 397e386e2..5b7b9c8df 100644 --- a/sc2/src/sc2code/planets/genspa.c +++ b/sc2/src/sc2code/planets/genspa.c @@ -37,7 +37,7 @@ GenerateSpathi (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -74,7 +74,7 @@ GenerateSpathi (BYTE control) pSolarSysState->MoonDesc[0].data_index = PELLUCID_WORLD; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA; - angle = NORMALIZE_ANGLE (LOWORD (Random ())); + angle = NORMALIZE_ANGLE (LOWORD (TFB_Random ())); pSolarSysState->MoonDesc[0].location.x = COSINE (angle, pSolarSysState->MoonDesc[0].radius); pSolarSysState->MoonDesc[0].location.y = @@ -113,7 +113,7 @@ GenerateSpathi (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/gensup.c b/sc2/src/sc2code/planets/gensup.c index 376a8a4d9..28ece1cea 100644 --- a/sc2/src/sc2code/planets/gensup.c +++ b/sc2/src/sc2code/planets/gensup.c @@ -37,7 +37,7 @@ GenerateSupox (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genthrad.c b/sc2/src/sc2code/planets/genthrad.c index 224e439f9..82f2e64fc 100644 --- a/sc2/src/sc2code/planets/genthrad.c +++ b/sc2/src/sc2code/planets/genthrad.c @@ -39,7 +39,7 @@ GenerateThradd (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -63,7 +63,7 @@ GenerateThradd (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/gentopo.c b/sc2/src/sc2code/planets/gentopo.c index 8915e2a8f..c14c1fdc5 100644 --- a/sc2/src/sc2code/planets/gentopo.c +++ b/sc2/src/sc2code/planets/gentopo.c @@ -40,9 +40,9 @@ DeltaTopography (COUNT num_iterations, PSBYTE DepthArray, PRECT pRect, DWORD rand_val; register PSBYTE lpDst; - depth_delta = ((((SIZE)Random () & 1) << 1) - 1) * depth_delta; + depth_delta = ((((SIZE)TFB_Random () & 1) << 1) - 1) * depth_delta; - rand_val = Random (); + rand_val = TFB_Random (); w1 = LOWORD (rand_val); w2 = HIWORD (rand_val); diff --git a/sc2/src/sc2code/planets/genutw.c b/sc2/src/sc2code/planets/genutw.c index 3d943b915..95980463f 100644 --- a/sc2/src/sc2code/planets/genutw.c +++ b/sc2/src/sc2code/planets/genutw.c @@ -67,7 +67,7 @@ GenerateUtwig (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -94,7 +94,7 @@ GenerateUtwig (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genvault.c b/sc2/src/sc2code/planets/genvault.c index c0c37da1b..f308ada75 100644 --- a/sc2/src/sc2code/planets/genvault.c +++ b/sc2/src/sc2code/planets/genvault.c @@ -34,7 +34,7 @@ GenerateShipVault (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genvux.c b/sc2/src/sc2code/planets/genvux.c index b7dfd9ff7..d2b399c8a 100644 --- a/sc2/src/sc2code/planets/genvux.c +++ b/sc2/src/sc2code/planets/genvux.c @@ -66,7 +66,7 @@ GenerateVUX (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -257,7 +257,7 @@ GenerateVUX (BYTE control) i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = @@ -289,7 +289,7 @@ GenerateVUX (BYTE control) i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genwreck.c b/sc2/src/sc2code/planets/genwreck.c index 4ca8642b8..3e3e76cc1 100644 --- a/sc2/src/sc2code/planets/genwreck.c +++ b/sc2/src/sc2code/planets/genwreck.c @@ -33,7 +33,7 @@ GenerateUrquanWreck (BYTE control) pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genyeh.c b/sc2/src/sc2code/planets/genyeh.c index 8f0b14b28..ed18f548e 100644 --- a/sc2/src/sc2code/planets/genyeh.c +++ b/sc2/src/sc2code/planets/genyeh.c @@ -36,7 +36,7 @@ GenerateYehat (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/genzoq.c b/sc2/src/sc2code/planets/genzoq.c index df73cc44f..f69922e27 100644 --- a/sc2/src/sc2code/planets/genzoq.c +++ b/sc2/src/sc2code/planets/genzoq.c @@ -122,7 +122,7 @@ GenerateZoqFotPik (BYTE control) which_node = i = 0; do { - rand_val = Random (); + rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index a2c0d9f76..608c3e505 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -247,7 +247,7 @@ object_animation (PELEMENT ElementPtr) if (ElementPtr->mass_points == LAVASPOT_DISASTER && frame_index == 5 - && (BYTE)Random () < 256 * 90 / 100) + && (BYTE)TFB_Random () < 256 * 90 / 100) { HELEMENT hLavaElement; @@ -270,7 +270,7 @@ object_animation (PELEMENT ElementPtr) else LavaElementPtr->next.location.x %= MAP_WIDTH << MAG_SHIFT; LavaElementPtr->hit_points = NORMALIZE_FACING ( - ElementPtr->hit_points + ((COUNT)Random () % 3) - 1 + ElementPtr->hit_points + ((COUNT)TFB_Random () % 3) - 1 ); UnlockElement (hLavaElement); } @@ -312,7 +312,7 @@ object_animation (PELEMENT ElementPtr) DetectPercent = (((BYTE)(CreatureData[index].Attributes & AWARENESS_MASK) >> AWARENESS_SHIFT) + 1) * (30 / 6); - if (((BYTE)Random () % 100) < DetectPercent) + if (((BYTE)TFB_Random () % 100) < DetectPercent) { ElementPtr->thrust_wait = 0; ElementPtr->mass_points |= CREATURE_AWARE; @@ -336,7 +336,7 @@ object_animation (PELEMENT ElementPtr) { COUNT rand_val; - rand_val = (COUNT)Random (); + rand_val = (COUNT)TFB_Random (); angle = NORMALIZE_ANGLE (LOBYTE (rand_val)); ElementPtr->thrust_wait = (HIBYTE (rand_val) >> 2) + 10; @@ -354,7 +354,7 @@ object_animation (PELEMENT ElementPtr) || old_angle == (FULL_CIRCLE - QUADRANT)) angle = old_angle; else - angle = (((COUNT)Random () & 1) + angle = (((COUNT)TFB_Random () & 1) * HALF_CIRCLE) - QUADRANT; ElementPtr->thrust_wait = 5; } @@ -412,7 +412,7 @@ DeltaLanderCrew (SIZE crew_delta, COUNT which_disaster) ShieldFlags = GET_GAME_STATE (LANDER_SHIELDS); ShieldFlags &= 1 << which_disaster; crew_delta = HIBYTE (pMenuState->delta_item); - if (ShieldFlags && (BYTE)Random () < 256 * 95 / 100) + if (ShieldFlags && (BYTE)TFB_Random () < 256 * 95 / 100) pMenuState->delta_item = SHIELD_BIT; else { @@ -570,7 +570,7 @@ CheckObjectCollision (COUNT index) { case EARTHQUAKE_DISASTER: case LAVASPOT_DISASTER: - if ((BYTE)Random () < (256 >> 2)) + if ((BYTE)TFB_Random () < (256 >> 2)) DeltaLanderCrew (-1, scan); break; } @@ -621,7 +621,7 @@ CheckObjectCollision (COUNT index) 0, 6, 13, 26 }; - if (((COUNT)Random () & 127) < danger_vals[ + if (((COUNT)TFB_Random () & 127) < danger_vals[ (CreatureData[ ElementPtr->mass_points & ~CREATURE_AWARE @@ -845,7 +845,7 @@ lightning_process (PELEMENT ElementPtr) if (ElementPtr->mass_points == LIGHTNING_DISASTER) { if (HIBYTE (pMenuState->delta_item) - && (BYTE)Random () < (256 / 10) + && (BYTE)TFB_Random () < (256 / 10) && !( (PPLANETSIDE_DESC)pMenuState->ModuleFrame )->InTransit) @@ -857,7 +857,7 @@ lightning_process (PELEMENT ElementPtr) pPrim->Object.Stamp.frame = SetAbsFrameIndex (pPrim->Object.Stamp.frame, - (COUNT)Random () % num_frames); + (COUNT)TFB_Random () % num_frames); } ElementPtr->turn_wait += HINIBBLE (ElementPtr->turn_wait); @@ -882,12 +882,12 @@ AddLightning (void) LightningElementPtr->state_flags = FINITE_LIFE | BAD_GUY; LightningElementPtr->preprocess_func = lightning_process; - if ((BYTE)Random () >= (256 >> 2)) + if ((BYTE)TFB_Random () >= (256 >> 2)) LightningElementPtr->mass_points = 0; else LightningElementPtr->mass_points = LIGHTNING_DISASTER; - rand_val = Random (); + rand_val = TFB_Random (); LightningElementPtr->life_span = 10 + (HIWORD (rand_val) % 10) + 1; LightningElementPtr->next.location.x = ( pSolarSysState->MenuState.first_item.x @@ -935,7 +935,7 @@ AddGroundDisaster (COUNT which_disaster) GroundDisasterElementPtr->state_flags = FINITE_LIFE | BAD_GUY; GroundDisasterElementPtr->preprocess_func = object_animation; - rand_val = Random (); + rand_val = TFB_Random (); GroundDisasterElementPtr->next.location.x = ( pSolarSysState->MenuState.first_item.x + ((MAP_WIDTH << MAG_SHIFT) - (SURFACE_WIDTH * 3 / 8)) @@ -958,7 +958,7 @@ AddGroundDisaster (COUNT which_disaster) { SetPrimType (pPrim, STAMP_PRIM); GroundDisasterElementPtr->hit_points = - NORMALIZE_FACING (Random ()); + NORMALIZE_FACING (TFB_Random ()); pPrim->Object.Stamp.frame = LanderFrame[3]; GroundDisasterElementPtr->turn_wait = MAKE_BYTE (0, 0); } @@ -987,7 +987,7 @@ BuildObjectList (void) lander_flags &= ~KILL_CREW; pPSD = (PPLANETSIDE_DESC)pMenuState->ModuleFrame; - rand_val = Random (); + rand_val = TFB_Random (); if (LOBYTE (HIWORD (rand_val)) < pPSD->FireChance) { AddGroundDisaster (LAVASPOT_DISASTER); @@ -1470,14 +1470,14 @@ InitPlanetSide (void) pt = pSolarSysState->MenuState.first_item; // Jitter the X landing point. - pt.x -= RANDOM_MISS - (SIZE)(LOWORD (Random ()) % (RANDOM_MISS << 1)); + pt.x -= RANDOM_MISS - (SIZE)(LOWORD (TFB_Random ()) % (RANDOM_MISS << 1)); if (pt.x < 0) pt.x += (MAP_WIDTH << MAG_SHIFT); else if (pt.x >= (MAP_WIDTH << MAG_SHIFT)) pt.x -= (MAP_WIDTH << MAG_SHIFT); // Jitter the Y landing point. - pt.y -= RANDOM_MISS - (SIZE)(LOWORD (Random ()) % (RANDOM_MISS << 1)); + pt.y -= RANDOM_MISS - (SIZE)(LOWORD (TFB_Random ()) % (RANDOM_MISS << 1)); if (pt.y < 0) pt.y = 0; else if (pt.y >= (MAP_HEIGHT << MAG_SHIFT)) @@ -1931,7 +1931,7 @@ PlanetSide (PMENU_STATE pMS) PSD.ColorCycle[(NUM_TEXT_FRAMES >> 1) - 1] = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x3, 0x00), 0x7F); pMS->ModuleFrame = (FRAME)&PSD; - index = NORMALIZE_FACING ((COUNT)Random ()); + index = NORMALIZE_FACING ((COUNT)TFB_Random ()); LanderFrame[0] = SetAbsFrameIndex ( LanderFrame[0], index ); diff --git a/sc2/src/sc2code/planets/orbits.c b/sc2/src/sc2code/planets/orbits.c index 0db400631..dde3c521f 100644 --- a/sc2/src/sc2code/planets/orbits.c +++ b/sc2/src/sc2code/planets/orbits.c @@ -492,7 +492,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; if (NumPlanets == (BYTE)~0) { #define MAX_GENERATED_PLANETS 10 - while ((NumPlanets = (BYTE)(LOWORD (Random()) + while ((NumPlanets = (BYTE)(LOWORD (TFB_Random()) % MAX_GENERATED_PLANETS)) == 0) ; pSolarSysState->SunDesc[0].NumPlanets = NumPlanets; @@ -520,7 +520,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; do { - rand_val = Random (); + rand_val = TFB_Random (); if (TypesDefined) rand_val = 0; else @@ -558,7 +558,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; else min_radius = Suns[StarSize].MinGasGDist; RelocatePlanet: - rand_val = Random (); + rand_val = TFB_Random (); if (GeneratingMoons) { pPD->radius = MIN_MOON_RADIUS @@ -586,7 +586,7 @@ RelocatePlanet: } } - rand_val = Random (); + rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pPD->location.x = COSINE (angle, pPD->radius); diff --git a/sc2/src/sc2code/planets/pl_stuff.c b/sc2/src/sc2code/planets/pl_stuff.c index 28781a4a0..696dc60ff 100644 --- a/sc2/src/sc2code/planets/pl_stuff.c +++ b/sc2/src/sc2code/planets/pl_stuff.c @@ -79,7 +79,7 @@ RotatePlanet (int x, int da, int dx, int dy, int zoom) r.extent.height = SIS_SCREEN_HEIGHT - MAP_HEIGHT; rp = &r; if (scale_amt == PLANET_INIT_ZOOM_SIZE) - zoom_from |= Random () & 0x03; + zoom_from |= TFB_Random () & 0x03; // we're zooming in, take care of scaling the frames for (i=0; i < num_frames; i++) { diff --git a/sc2/src/sc2code/planets/plandata.h b/sc2/src/sc2code/planets/plandata.h index 74143b44c..3f581254a 100644 --- a/sc2/src/sc2code/planets/plandata.h +++ b/sc2/src/sc2code/planets/plandata.h @@ -263,7 +263,7 @@ enum }; #define CalcGravity(d,r) (UWORD)((DWORD)(d) * (r) / 100) -#define CalcFromBase(b,v) ((UWORD)(b) + ((UWORD)Random () % (v))) +#define CalcFromBase(b,v) ((UWORD)(b) + ((UWORD)TFB_Random () % (v))) #define PLANET_INFOPTR PPLANET_INFO diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 9408b7c38..e3907e263 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -709,7 +709,7 @@ DitherMap (PSBYTE DepthArray) { DWORD rand_val; - rand_val = Random (); + rand_val = TFB_Random (); *lpDst++ += (SBYTE) ((1 << (RANGE_SHIFT - 4)) - (LOBYTE (LOWORD (rand_val)) & ((1 << (RANGE_SHIFT - 3)) - 1))); *lpDst++ += (SBYTE) ((1 << (RANGE_SHIFT - 4)) @@ -936,7 +936,7 @@ MakeStorms (COUNT storm_count, PSBYTE DepthArray) intersect = FALSE; - rand_val = Random (); + rand_val = TFB_Random (); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); switch (HIBYTE (hiword) & 31) @@ -964,7 +964,7 @@ MakeStorms (COUNT storm_count, PSBYTE DepthArray) if (pstorm_r->extent.height <= 4) pstorm_r->extent.height += 4; - rand_val = Random (); + rand_val = TFB_Random (); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); @@ -1053,7 +1053,7 @@ MakeGasGiant (COUNT num_bands, PSBYTE DepthArray, PRECT pRect, SIZE band_error = num_bands >> 1; lpDst = DepthArray; - band_delta = ((LOWORD (Random ()) + band_delta = ((LOWORD (TFB_Random ()) & (NUM_BAND_COLORS - 1)) << RANGE_SHIFT) + (1 << (RANGE_SHIFT - 1)); last_y = next_y = 0; @@ -1061,7 +1061,7 @@ MakeGasGiant (COUNT num_bands, PSBYTE DepthArray, PRECT pRect, SIZE { COORD cur_y; - rand_val = Random (); + rand_val = TFB_Random (); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); @@ -1102,7 +1102,7 @@ MakeGasGiant (COUNT num_bands, PSBYTE DepthArray, PRECT pRect, SIZE & (((1 << RANGE_SHIFT) * NUM_BAND_COLORS) - 1); } - MakeStorms ((COUNT)(4 + ((COUNT)Random () & 3) + 1), DepthArray); + MakeStorms ((COUNT)(4 + ((COUNT)TFB_Random () & 3) + 1), DepthArray); DitherMap (DepthArray); } @@ -1224,7 +1224,7 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth) RECT crater_r; UWORD loword; - loword = LOWORD (Random ()); + loword = LOWORD (TFB_Random ()); switch (HIBYTE (loword) & 31) { case 0: @@ -1247,7 +1247,7 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth) break; } - loword = LOWORD (Random ()); + loword = LOWORD (TFB_Random ()); crater_r.extent.height = crater_r.extent.width; crater_r.corner.x = HIBYTE (loword) % (MAP_WIDTH - crater_r.extent.width); diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 0bece42f8..8f567fd0d 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -1120,7 +1120,7 @@ GeneratePlanetSide (void) if (CreatureData[which_node].Attributes & SPEED_MASK) { - i = (COUNT)Random (); + i = (COUNT)TFB_Random (); NodeElementPtr->current.location.x = (LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8; NodeElementPtr->current.location.y = @@ -1159,7 +1159,7 @@ GeneratePlanetSide (void) DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame = SetAbsFrameIndex ( pSolarSysState->PlanetSideFrame[i + 3], - (COUNT)Random () + (COUNT)TFB_Random () ); } } diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index 74c8472ac..10370b63f 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -191,7 +191,7 @@ LoadSolarSys (void) pCurDesc = &pSolarSysState->SunDesc[0]; pCurDesc->pPrevDesc = 0; - pCurDesc->rand_seed = Random (); + pCurDesc->rand_seed = TFB_Random (); pCurDesc->data_index = STAR_TYPE (CurStarDescPtr->Type); pCurDesc->location.x = pCurDesc->location.y = 0; @@ -1595,7 +1595,7 @@ GenerateRandomIP (BYTE control) BYTE byte_val; BYTE num_moons; - rand_val = Random (); + rand_val = TFB_Random (); byte_val = LOBYTE (rand_val); num_moons = 0; @@ -1780,7 +1780,7 @@ DrawStarBackGround (BOOLEAN ForPlanet) #define NUM_DIM_DRAWN 5 for (j = 0; j < NUM_DIM_DRAWN; ++j) { - rand_val = Random (); + rand_val = TFB_Random (); s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH; s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT; @@ -1794,7 +1794,7 @@ DrawStarBackGround (BOOLEAN ForPlanet) #define NUM_BRT_DRAWN 30 for (j = 0; j < NUM_BRT_DRAWN; ++j) { - rand_val = Random (); + rand_val = TFB_Random (); s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH; s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT; diff --git a/sc2/src/sc2code/planets/surface.c b/sc2/src/sc2code/planets/surface.c index 523646a61..c255126d2 100644 --- a/sc2/src/sc2code/planets/surface.c +++ b/sc2/src/sc2code/planets/surface.c @@ -36,7 +36,7 @@ CalcMineralDeposits (SYSTEM_INFOPTR SysInfoPtr, COUNT which_deposit) { BYTE num_possible; - num_possible = (BYTE)((BYTE)Random () + num_possible = (BYTE)((BYTE)TFB_Random () % (DEPOSIT_QUANTITY (eptr->Density) + 1)); while (num_possible--) { @@ -47,7 +47,7 @@ CalcMineralDeposits (SYSTEM_INFOPTR SysInfoPtr, COUNT which_deposit) COUNT deposit_quality_fine, deposit_quality_gross; - deposit_quality_fine = ((COUNT)Random () % 100) + deposit_quality_fine = ((COUNT)TFB_Random () % 100) + ( DEPOSIT_QUALITY (eptr->Density) + SysInfoPtr->StarSize @@ -59,7 +59,7 @@ CalcMineralDeposits (SYSTEM_INFOPTR SysInfoPtr, COUNT which_deposit) else deposit_quality_gross = 2; - rand_val = Random (); + rand_val = TFB_Random (); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); SysInfoPtr->PlanetInfo.CurPt.x = @@ -199,25 +199,25 @@ CalcLifeForms (SYSTEM_INFOPTR SysInfoPtr, COUNT which_life) SysInfoPtr->PlanetInfo.LifeChance = life_var; - life_var = (COUNT)Random () & 1023; + life_var = (COUNT)TFB_Random () & 1023; if (life_var < SysInfoPtr->PlanetInfo.LifeChance || (SysInfoPtr->PlanetInfo.LifeChance < MIN_LIFE_CHANCE && life_var < MIN_LIFE_CHANCE)) { BYTE num_types; - num_types = (BYTE)(((BYTE)Random () % MAX_LIFE_VARIATION) + 1); + num_types = (BYTE)(((BYTE)TFB_Random () % MAX_LIFE_VARIATION) + 1); do { BYTE index, num_creatures; UWORD rand_val; - rand_val = (UWORD)Random (); + rand_val = (UWORD)TFB_Random (); index = LOBYTE (rand_val) % NUM_CREATURE_TYPES; num_creatures = (BYTE)((HIBYTE (rand_val) % 10) + 1); do { - rand_val = (UWORD)Random (); + rand_val = (UWORD)TFB_Random (); SysInfoPtr->PlanetInfo.CurPt.x = (LOBYTE (rand_val) % (MAP_WIDTH - (8 << 1))) + 8; SysInfoPtr->PlanetInfo.CurPt.y = diff --git a/sc2/src/sc2code/ship.c b/sc2/src/sc2code/ship.c index 1b8f09c88..39e90f0e6 100644 --- a/sc2/src/sc2code/ship.c +++ b/sc2/src/sc2code/ship.c @@ -426,7 +426,7 @@ spawn_ship (STARSHIPPTR } else { - StarShipPtr->ShipFacing = NORMALIZE_FACING (Random ()); + StarShipPtr->ShipFacing = NORMALIZE_FACING (TFB_Random ()); if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) { COUNT facing; @@ -445,9 +445,9 @@ spawn_ship (STARSHIPPTR do { ShipElementPtr->current.location.x = - WRAP_X (DISPLAY_ALIGN_X (Random ())); + WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); ShipElementPtr->current.location.y = - WRAP_Y (DISPLAY_ALIGN_Y (Random ())); + WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); } while (CalculateGravity (ShipElementPtr) || TimeSpaceMatterConflict (ShipElementPtr)); } diff --git a/sc2/src/sc2code/ships/androsyn/androsyn.c b/sc2/src/sc2code/ships/androsyn/androsyn.c index 614475643..8b22a75a4 100644 --- a/sc2/src/sc2code/ships/androsyn/androsyn.c +++ b/sc2/src/sc2code/ships/androsyn/androsyn.c @@ -143,7 +143,7 @@ bubble_preprocess (PELEMENT ElementPtr) IncFrameIndex (ElementPtr->current.image.frame); ElementPtr->state_flags |= CHANGING; - thrust_wait = (BYTE)((COUNT)Random () & 3); + thrust_wait = (BYTE)((COUNT)TFB_Random () & 3); } if (turn_wait > 0) @@ -157,11 +157,11 @@ bubble_preprocess (PELEMENT ElementPtr) GetVelocityTravelAngle (&ElementPtr->velocity) )); if ((delta_facing = TrackShip (ElementPtr, &facing)) == -1) - facing = (COUNT)Random (); + facing = (COUNT)TFB_Random (); else if (delta_facing <= ANGLE_TO_FACING (HALF_CIRCLE)) - facing += (COUNT)Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1); + facing += (COUNT)TFB_Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1); else - facing -= (COUNT)Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1); + facing -= (COUNT)TFB_Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1); SetVelocityVector (&ElementPtr->velocity, MISSILE_SPEED, facing); diff --git a/sc2/src/sc2code/ships/arilou/arilou.c b/sc2/src/sc2code/ships/arilou/arilou.c index 578bc6f08..8dd2663fd 100644 --- a/sc2/src/sc2code/ships/arilou/arilou.c +++ b/sc2/src/sc2code/ships/arilou/arilou.c @@ -170,7 +170,7 @@ arilou_intelligence (PELEMENT ShipPtr, PEVALUATE_DESC ObjectsOfConcern, || (IsTrackingWeapon && (lpEvalDesc->which_turn == 1 || (lpEvalDesc->ObjectPtr->state_flags & CREW_OBJECT))) /* FIGHTERS!!! */ || PlotIntercept (lpEvalDesc->ObjectPtr, ShipPtr, 3, 0)) - && !(Random () & 3)) + && !(TFB_Random () & 3)) { StarShipPtr->ship_input_state &= ~(LEFT | RIGHT | THRUST | WEAPON); StarShipPtr->ship_input_state |= SPECIAL; @@ -262,9 +262,9 @@ arilou_preprocess (PELEMENT ElementPtr) else { ElementPtr->next.location.x = - WRAP_X (DISPLAY_ALIGN_X (Random ())); + WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); ElementPtr->next.location.y = - WRAP_Y (DISPLAY_ALIGN_Y (Random ())); + WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); } } diff --git a/sc2/src/sc2code/ships/chenjesu/chenjesu.c b/sc2/src/sc2code/ships/chenjesu/chenjesu.c index 3ba76ec5f..d8cd9dafe 100644 --- a/sc2/src/sc2code/ships/chenjesu/chenjesu.c +++ b/sc2/src/sc2code/ships/chenjesu/chenjesu.c @@ -243,7 +243,7 @@ doggy_preprocess (PELEMENT ElementPtr) GetVelocityTravelAngle (&ElementPtr->velocity) )); if ((delta_facing = TrackShip (ElementPtr, &facing)) < 0) - facing = NORMALIZE_FACING (Random ()); + facing = NORMALIZE_FACING (TFB_Random ()); else { ELEMENTPTR ShipPtr; diff --git a/sc2/src/sc2code/ships/chmmr/chmmr.c b/sc2/src/sc2code/ships/chmmr/chmmr.c index 5d44524c1..e41711728 100644 --- a/sc2/src/sc2code/ships/chmmr/chmmr.c +++ b/sc2/src/sc2code/ships/chmmr/chmmr.c @@ -138,7 +138,7 @@ laser_death (ELEMENTPTR ElementPtr) - ShipPtr->current.location.x; dy = ElementPtr->current.location.y - ShipPtr->current.location.y; - if (((BYTE)Random () & 0x07) + if (((BYTE)TFB_Random () & 0x07) && (dist = (long)dx * dx + (long)dy * dy) >= (long)DISPLAY_TO_WORLD (CHMMR_OFFSET + 10) * DISPLAY_TO_WORLD (CHMMR_OFFSET + 10) @@ -155,7 +155,7 @@ laser_death (ELEMENTPTR ElementPtr) IonSpotsPtr->life_span = 9; angle = ARCTAN (dx, dy); - magnitude = ((COUNT)Random () + magnitude = ((COUNT)TFB_Random () % ((square_root (dist) + 1) - DISPLAY_TO_WORLD (CHMMR_OFFSET + 10))) + DISPLAY_TO_WORLD (CHMMR_OFFSET + 10); @@ -684,7 +684,7 @@ spawn_satellites (PELEMENT ElementPtr) StarShipPtr->RaceDescPtr->ship_data.special; SattPtr->current.image.frame = SetAbsFrameIndex ( StarShipPtr->RaceDescPtr->ship_data.special[0], - (COUNT)Random () & 0x07 + (COUNT)TFB_Random () & 0x07 ); SattPtr->preprocess_func = satellite_preprocess; diff --git a/sc2/src/sc2code/ships/lastbat/lastbat.c b/sc2/src/sc2code/ships/lastbat/lastbat.c index 5ce4bdf44..d400b93e1 100644 --- a/sc2/src/sc2code/ships/lastbat/lastbat.c +++ b/sc2/src/sc2code/ships/lastbat/lastbat.c @@ -225,7 +225,7 @@ spawn_comet (PELEMENT ElementPtr) if (ElementPtr->state_flags & PLAYER_SHIP) { CometPtr->turn_wait = 0; - facing = (COUNT)Random (); + facing = (COUNT)TFB_Random (); SetVelocityVector (&CometPtr->velocity, COMET_SPEED, facing); } @@ -464,7 +464,7 @@ sentinel_preprocess (PELEMENT ElementPtr) else { ElementPtr->state_flags &= ~NONSOLID; - facing = (COUNT)Random (); + facing = (COUNT)TFB_Random (); SetVelocityVector (&ElementPtr->velocity, MISSILE_SPEED, facing); } @@ -794,7 +794,7 @@ samatra_preprocess (PELEMENT ElementPtr) GeneratorPtr->current.image.frame = SetAbsFrameIndex ( StarShipPtr->RaceDescPtr->ship_data.special[0], - (BYTE)Random () % 10 + (BYTE)TFB_Random () % 10 ); GeneratorPtr->preprocess_func = generator_preprocess; diff --git a/sc2/src/sc2code/ships/melnorme/melnorme.c b/sc2/src/sc2code/ships/melnorme/melnorme.c index aabcbeaf3..d3bb33191 100644 --- a/sc2/src/sc2code/ships/melnorme/melnorme.c +++ b/sc2/src/sc2code/ships/melnorme/melnorme.c @@ -456,7 +456,7 @@ confusion_collision (PELEMENT ElementPtr0, PPOINT pPt0, PELEMENT ElementPtr1, PP ConfusionPtr->life_span = 400; ConfusionPtr->turn_wait = - (BYTE)(1 << ((BYTE)Random () & 1)); /* LEFT or RIGHT */ + (BYTE)(1 << ((BYTE)TFB_Random () & 1)); /* LEFT or RIGHT */ UnlockElement (hConfusionElement); } diff --git a/sc2/src/sc2code/ships/orz/orz.c b/sc2/src/sc2code/ships/orz/orz.c index ab70ba350..9ddc34599 100644 --- a/sc2/src/sc2code/ships/orz/orz.c +++ b/sc2/src/sc2code/ships/orz/orz.c @@ -271,7 +271,7 @@ COUNT ConcernCounter; { StarShipPtr->ship_input_state |= SPECIAL; if (delta_facing == ANGLE_TO_FACING (HALF_CIRCLE)) - delta_facing += (((BYTE)Random () & 1) << 1) - 1; + delta_facing += (((BYTE)TFB_Random () & 1) << 1) - 1; if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) StarShipPtr->ship_input_state |= RIGHT; @@ -413,7 +413,7 @@ LeftShip: ElementPtr->thrust_wait = MARINE_WAIT; - randval = (BYTE)Random (); + randval = (BYTE)TFB_Random (); if (randval < (0x0100 / 16)) { ElementPtr->life_span = 0; @@ -461,7 +461,7 @@ LeftShip: ); ElementPtr->thrust_wait = 0; ElementPtr->turn_wait = - MAKE_BYTE (0, NORMALIZE_FACING ((BYTE)Random ())); + MAKE_BYTE (0, NORMALIZE_FACING ((BYTE)TFB_Random ())); ElementPtr->preprocess_func = marine_preprocess; } } @@ -569,7 +569,7 @@ PELEMENT ElementPtr; else { if (delta_facing == ANGLE_TO_FACING (OCTANT)) - facing += (((SIZE)Random () & 1) << 1) - 1; + facing += (((SIZE)TFB_Random () & 1) << 1) - 1; else if (delta_facing < ANGLE_TO_FACING (OCTANT)) ++facing; else @@ -615,7 +615,7 @@ PELEMENT ElementPtr; if (delta_facing > 0) { if (delta_facing == ANGLE_TO_FACING (HALF_CIRCLE)) - facing += (((BYTE)Random () & 1) << 1) - 1; + facing += (((BYTE)TFB_Random () & 1) << 1) - 1; else if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) ++facing; else @@ -750,7 +750,7 @@ marine_collision (PELEMENT ElementPtr0, PPOINT pPt0, PELEMENT ElementPtr1, PPOIN else if ((ElementPtr0->state_flags & IGNORE_SIMILAR) && ElementPtr1->crew_level #ifdef NEVER - && (BYTE)Random () <= (0x0100 / 3) + && (BYTE)TFB_Random () <= (0x0100 / 3) #endif /* NEVER */ ) { diff --git a/sc2/src/sc2code/ships/pkunk/pkunk.c b/sc2/src/sc2code/ships/pkunk/pkunk.c index 739004b2c..83dc4f8de 100644 --- a/sc2/src/sc2code/ships/pkunk/pkunk.c +++ b/sc2/src/sc2code/ships/pkunk/pkunk.c @@ -192,7 +192,7 @@ COUNT ConcernCounter; if (StarShipPtr->RaceDescPtr->ship_info.energy_level < StarShipPtr->RaceDescPtr->ship_info.max_energy && (StarShipPtr->special_counter == 0 - || (BYTE)Random () < 20)) + || (BYTE)TFB_Random () < 20)) StarShipPtr->ship_input_state |= SPECIAL; else StarShipPtr->ship_input_state &= ~SPECIAL; @@ -249,7 +249,7 @@ new_pkunk (PELEMENT ElementPtr) ElementPtr->turn_wait = ElementPtr->thrust_wait = 0; ElementPtr->life_span = NORMAL_LIFE; - StarShipPtr->ShipFacing = NORMALIZE_FACING (Random ()); + StarShipPtr->ShipFacing = NORMALIZE_FACING (TFB_Random ()); ElementPtr->current.image.farray = StarShipPtr->RaceDescPtr->ship_data.ship; ElementPtr->current.image.frame = SetAbsFrameIndex (StarShipPtr->RaceDescPtr->ship_data.ship[0], @@ -261,9 +261,9 @@ new_pkunk (PELEMENT ElementPtr) do { ElementPtr->current.location.x = - WRAP_X (DISPLAY_ALIGN_X (Random ())); + WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); ElementPtr->current.location.y = - WRAP_Y (DISPLAY_ALIGN_Y (Random ())); + WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); } while (CalculateGravity (ElementPtr) || TimeSpaceMatterConflict (ElementPtr)); @@ -440,7 +440,7 @@ PELEMENT ElementPtr; { ELEMENTPTR PhoenixPtr; - if (((BYTE)Random () & 1) + if (((BYTE)TFB_Random () & 1) && (hPhoenix = AllocElement ())) { @@ -530,7 +530,7 @@ PELEMENT ElementPtr; do { CurSound = - 2 + ((COUNT)Random () + 2 + ((COUNT)TFB_Random () % (GetSoundCount (StarShipPtr->RaceDescPtr->ship_data.ship_sounds) - 2)); } while (CurSound == LastSound); ProcessSound (SetAbsSoundIndex ( diff --git a/sc2/src/sc2code/ships/shofixti/shofixti.c b/sc2/src/sc2code/ships/shofixti/shofixti.c index 255057593..bceb3f54b 100644 --- a/sc2/src/sc2code/ships/shofixti/shofixti.c +++ b/sc2/src/sc2code/ships/shofixti/shofixti.c @@ -332,7 +332,7 @@ COUNT ConcernCounter; && ShipPtr->crew_level == 1) || (PlotIntercept (lpWeaponEvalDesc->ObjectPtr, ShipPtr, 2, 0) && lpWeaponEvalDesc->ObjectPtr->mass_points >= ShipPtr->crew_level - && (Random () & 1)))))) + && (TFB_Random () & 1)))))) StarShipPtr->ship_input_state |= SPECIAL; } } diff --git a/sc2/src/sc2code/ships/slylandr/slylandr.c b/sc2/src/sc2code/ships/slylandr/slylandr.c index 5fae1e472..7e2dcea42 100644 --- a/sc2/src/sc2code/ships/slylandr/slylandr.c +++ b/sc2/src/sc2code/ships/slylandr/slylandr.c @@ -164,7 +164,7 @@ initialize_lightning (PELEMENT ElementPtr, HELEMENT LaserArray[]) LaserPtr->postprocess_func = lightning_postprocess; LaserPtr->collision_func = lightning_collision; - rand_val = Random (); + rand_val = TFB_Random (); if (!(ElementPtr->state_flags & PLAYER_SHIP)) { diff --git a/sc2/src/sc2code/ships/supox/supox.c b/sc2/src/sc2code/ships/supox/supox.c index cbe4963f5..da57f9aa8 100644 --- a/sc2/src/sc2code/ships/supox/supox.c +++ b/sc2/src/sc2code/ships/supox/supox.c @@ -162,7 +162,7 @@ COUNT ConcernCounter; StarShipPtr->ship_input_state &= ~THRUST; StarShipPtr->ship_input_state |= SPECIAL; if (!(StarShipPtr->cur_status_flags & (LEFT | RIGHT))) - StarShipPtr->ship_input_state |= 1 << ((BYTE)Random () & 1); + StarShipPtr->ship_input_state |= 1 << ((BYTE)TFB_Random () & 1); else StarShipPtr->ship_input_state |= StarShipPtr->cur_status_flags & (LEFT | RIGHT); diff --git a/sc2/src/sc2code/ships/umgah/umgah.c b/sc2/src/sc2code/ships/umgah/umgah.c index c205695ab..1b0c29849 100644 --- a/sc2/src/sc2code/ships/umgah/umgah.c +++ b/sc2/src/sc2code/ships/umgah/umgah.c @@ -227,7 +227,7 @@ COUNT ConcernCounter; /* don't want him backing straight into ship */ if (this_turn <= 8 && LinedUp) { - if (Random () & 1) + if (TFB_Random () & 1) StarShipPtr->ship_input_state |= LEFT; else StarShipPtr->ship_input_state |= RIGHT; diff --git a/sc2/src/sc2code/ships/utwig/utwig.c b/sc2/src/sc2code/ships/utwig/utwig.c index e01d4b53c..88f291cd6 100644 --- a/sc2/src/sc2code/ships/utwig/utwig.c +++ b/sc2/src/sc2code/ships/utwig/utwig.c @@ -225,7 +225,7 @@ COUNT ConcernCounter; & PLAYER_SHIP) /* means IMMEDIATE WEAPON */ || PlotIntercept (lpEvalDesc->ObjectPtr, ShipPtr, 2, 0)) - && (Random () & 3)) + && (TFB_Random () & 3)) { StarShipPtr->ship_input_state |= SPECIAL; StarShipPtr->ship_input_state &= ~WEAPON; diff --git a/sc2/src/sc2code/ships/vux/vux.c b/sc2/src/sc2code/ships/vux/vux.c index 06c3f0142..94a36bb17 100644 --- a/sc2/src/sc2code/ships/vux/vux.c +++ b/sc2/src/sc2code/ships/vux/vux.c @@ -165,7 +165,7 @@ limpet_collision (PELEMENT ElementPtr0, PPOINT pPt0, PELEMENT /* LIMPET_AFFIXES */ StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 2)); s.frame = SetAbsFrameIndex ( - StarShipPtr->RaceDescPtr->ship_data.weapon[0], (COUNT)Random () + StarShipPtr->RaceDescPtr->ship_data.weapon[0], (COUNT)TFB_Random () ); ModifySilhouette (ElementPtr1, &s, MODIFY_IMAGE); } @@ -322,11 +322,11 @@ vux_preprocess (PELEMENT ElementPtr) ElementPtr->current.location.x = (OtherShipPtr->current.location.x - (MAXX_ENTRY_DIST >> 1)) + - ((COUNT)Random () % MAXX_ENTRY_DIST); + ((COUNT)TFB_Random () % MAXX_ENTRY_DIST); ElementPtr->current.location.y = (OtherShipPtr->current.location.y - (MAXY_ENTRY_DIST >> 1)) + - ((COUNT)Random () % MAXY_ENTRY_DIST); + ((COUNT)TFB_Random () % MAXY_ENTRY_DIST); dx = OtherShipPtr->current.location.x - ElementPtr->current.location.x; dy = OtherShipPtr->current.location.y - diff --git a/sc2/src/sc2code/ships/yehat/yehat.c b/sc2/src/sc2code/ships/yehat/yehat.c index d222bdb18..c83817f24 100644 --- a/sc2/src/sc2code/ships/yehat/yehat.c +++ b/sc2/src/sc2code/ships/yehat/yehat.c @@ -191,7 +191,7 @@ COUNT ConcernCounter; & PLAYER_SHIP) /* means IMMEDIATE WEAPON */ || PlotIntercept (lpEvalDesc->ObjectPtr, ShipPtr, 2, 0)) - && (Random () & 3)) + && (TFB_Random () & 3)) StarShipPtr->ship_input_state |= SPECIAL; if (lpEvalDesc->ObjectPtr diff --git a/sc2/src/sc2code/ships/zoqfot/zoqfot.c b/sc2/src/sc2code/ships/zoqfot/zoqfot.c index 8c9ade23b..171b464a7 100644 --- a/sc2/src/sc2code/ships/zoqfot/zoqfot.c +++ b/sc2/src/sc2code/ships/zoqfot/zoqfot.c @@ -119,7 +119,7 @@ spit_preprocess (PELEMENT ElementPtr) IncFrameIndex (ElementPtr->next.image.frame); angle = GetVelocityTravelAngle (&ElementPtr->velocity); if ((index = GetFrameIndex (ElementPtr->next.image.frame)) == 1) - angle = angle + (((COUNT)Random () % 3) - 1); + angle = angle + (((COUNT)TFB_Random () % 3) - 1); speed = WORLD_TO_VELOCITY (DISPLAY_TO_WORLD ( GetFrameCount (ElementPtr->next.image.frame) - index) << 1); diff --git a/sc2/src/sc2code/tactrans.c b/sc2/src/sc2code/tactrans.c index 6c0fd80ca..104f60b48 100644 --- a/sc2/src/sc2code/tactrans.c +++ b/sc2/src/sc2code/tactrans.c @@ -206,7 +206,7 @@ explosion_preprocess (PELEMENT ShipPtr) SetPrimType (&DisplayArray[ElementPtr->PrimIndex], STAMP_PRIM); ElementPtr->current.image.farray = explosion; ElementPtr->current.image.frame = explosion[0]; - rand_val = Random (); + rand_val = TFB_Random (); angle = LOBYTE (HIWORD (rand_val)); dist = DISPLAY_TO_WORLD (LOBYTE (LOWORD (rand_val)) % 8); if (HIBYTE (LOWORD (rand_val)) < 256 * 1 / 3) @@ -218,7 +218,7 @@ explosion_preprocess (PELEMENT ShipPtr) ShipPtr->current.location.y + SINE (angle, dist); ElementPtr->preprocess_func = animation_preprocess; - rand_val = Random (); + rand_val = TFB_Random (); angle = LOBYTE (LOWORD (rand_val)); dist = WORLD_TO_VELOCITY ( DISPLAY_TO_WORLD (HIBYTE (LOWORD (rand_val)) % 5) diff --git a/sc2/src/sc2code/weapon.c b/sc2/src/sc2code/weapon.c index 5749f3e34..9f62db2f5 100644 --- a/sc2/src/sc2code/weapon.c +++ b/sc2/src/sc2code/weapon.c @@ -265,10 +265,10 @@ ModifySilhouette (ELEMENTPTR ShipIntersect.EndPoint = ShipIntersect.IntersectStamp.origin; do { - ObjectIntersect.IntersectStamp.origin.x = ((COUNT)Random () + ObjectIntersect.IntersectStamp.origin.x = ((COUNT)TFB_Random () % (r.extent.width - or.extent.width)) + ((or.extent.width - r.extent.width) >> 1); - ObjectIntersect.IntersectStamp.origin.y = ((COUNT)Random () + ObjectIntersect.IntersectStamp.origin.y = ((COUNT)TFB_Random () % (r.extent.height - or.extent.height)) + ((or.extent.height - r.extent.height) >> 1); ObjectIntersect.EndPoint = @@ -384,7 +384,7 @@ CheckTracking: facing = *pfacing; if (best_delta_facing == ANGLE_TO_FACING (HALF_CIRCLE)) - facing += (((BYTE)Random () & 1) << 1) - 1; + facing += (((BYTE)TFB_Random () & 1) << 1) - 1; else if (best_delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) ++facing; else