Planet/system generation code cleanup: isolate generation code with an own RandomContext; generation funcs do not return the random seed anymore; move and cleanup some calculation funcs; clarify deliberate Random() truncation; other random cleanups
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3694 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -3482,6 +3482,10 @@ SOURCE=..\..\src\uqm\starmap.c
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\src\uqm\starmap.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\src\uqm\state.c
|
SOURCE=..\..\src\uqm\state.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -29,13 +29,6 @@
|
|||||||
#ifndef _RANDOM_H
|
#ifndef _RANDOM_H
|
||||||
#define _RANDOM_H
|
#define _RANDOM_H
|
||||||
|
|
||||||
/* ----------------------------DEFINES------------------------------------ */
|
|
||||||
|
|
||||||
#define RAND(n) ( (int) ( (unsigned int)TFB_Random() % (n) ) )
|
|
||||||
#define SRAND(n) ( (int)TFB_Random() % (n) )
|
|
||||||
#define AND_RAND(n) ( (int)TFB_Random() & (n) )
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------GLOBALS/EXTERNS---------------------------- */
|
/* ----------------------------GLOBALS/EXTERNS---------------------------- */
|
||||||
|
|
||||||
DWORD TFB_SeedRandom (DWORD seed);
|
DWORD TFB_SeedRandom (DWORD seed);
|
||||||
@@ -55,6 +48,7 @@ void RandomContext_Delete (RandomContext *context);
|
|||||||
RandomContext *RandomContext_Copy (const RandomContext *source);
|
RandomContext *RandomContext_Copy (const RandomContext *source);
|
||||||
DWORD RandomContext_Random (RandomContext *context);
|
DWORD RandomContext_Random (RandomContext *context);
|
||||||
DWORD RandomContext_SeedRandom (RandomContext *context, DWORD new_seed);
|
DWORD RandomContext_SeedRandom (RandomContext *context, DWORD new_seed);
|
||||||
|
DWORD RandomContext_GetSeed (RandomContext *context);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _RANDOM_H */
|
#endif /* _RANDOM_H */
|
||||||
|
|||||||
@@ -82,4 +82,8 @@ RandomContext_SeedRandom (RandomContext *context, DWORD new_seed)
|
|||||||
return old_seed;
|
return old_seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
RandomContext_GetSeed (RandomContext *context)
|
||||||
|
{
|
||||||
|
return context->seed;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,5 +18,6 @@ uqm_HFILES="battlecontrols.h battle.h build.h clock.h cnctdlg.h coderes.h
|
|||||||
nameref.h oscill.h pickship.h process.h races.h resinst.h respkg.h
|
nameref.h oscill.h pickship.h process.h races.h resinst.h respkg.h
|
||||||
restart.h save.h settings.h setup.h setupmenu.h shipcont.h ship.h
|
restart.h save.h settings.h setup.h setupmenu.h shipcont.h ship.h
|
||||||
sis.h sounds.h starbase.h starcon.h state.h status.h tactrans.h
|
sis.h sounds.h starbase.h starcon.h state.h status.h tactrans.h
|
||||||
|
starmap.h
|
||||||
units.h uqmdebug.h util.h velocity.h weapon.h"
|
units.h uqmdebug.h util.h velocity.h weapon.h"
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "sis.h"
|
#include "sis.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
|
#include "starmap.h"
|
||||||
#include "endian_uqm.h"
|
#include "endian_uqm.h"
|
||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "battlecontrols.h"
|
#include "battlecontrols.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
#include "starmap.h"
|
||||||
#include "cons_res.h"
|
#include "cons_res.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "menustat.h"
|
#include "menustat.h"
|
||||||
|
|||||||
@@ -93,78 +93,12 @@ struct encounter
|
|||||||
#define GetPredEncounter(l) _GetPredLink (l)
|
#define GetPredEncounter(l) _GetPredLink (l)
|
||||||
#define GetSuccEncounter(l) _GetSuccLink (l)
|
#define GetSuccEncounter(l) _GetSuccLink (l)
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
SOL_DEFINED = 1,
|
|
||||||
SHOFIXTI_DEFINED,
|
|
||||||
MAIDENS_DEFINED,
|
|
||||||
START_COLONY_DEFINED,
|
|
||||||
SPATHI_DEFINED,
|
|
||||||
ZOQFOT_DEFINED,
|
|
||||||
|
|
||||||
MELNORME0_DEFINED,
|
|
||||||
MELNORME1_DEFINED,
|
|
||||||
MELNORME2_DEFINED,
|
|
||||||
MELNORME3_DEFINED,
|
|
||||||
MELNORME4_DEFINED,
|
|
||||||
MELNORME5_DEFINED,
|
|
||||||
MELNORME6_DEFINED,
|
|
||||||
MELNORME7_DEFINED,
|
|
||||||
MELNORME8_DEFINED,
|
|
||||||
|
|
||||||
TALKING_PET_DEFINED,
|
|
||||||
CHMMR_DEFINED,
|
|
||||||
SYREEN_DEFINED,
|
|
||||||
BURVIXESE_DEFINED,
|
|
||||||
SLYLANDRO_DEFINED,
|
|
||||||
DRUUGE_DEFINED,
|
|
||||||
BOMB_DEFINED,
|
|
||||||
AQUA_HELIX_DEFINED,
|
|
||||||
SUN_DEVICE_DEFINED,
|
|
||||||
TAALO_PROTECTOR_DEFINED,
|
|
||||||
SHIP_VAULT_DEFINED,
|
|
||||||
URQUAN_WRECK_DEFINED,
|
|
||||||
VUX_BEAST_DEFINED,
|
|
||||||
SAMATRA_DEFINED,
|
|
||||||
ZOQ_SCOUT_DEFINED,
|
|
||||||
MYCON_DEFINED,
|
|
||||||
EGG_CASE0_DEFINED,
|
|
||||||
EGG_CASE1_DEFINED,
|
|
||||||
EGG_CASE2_DEFINED,
|
|
||||||
PKUNK_DEFINED,
|
|
||||||
UTWIG_DEFINED,
|
|
||||||
SUPOX_DEFINED,
|
|
||||||
YEHAT_DEFINED,
|
|
||||||
VUX_DEFINED,
|
|
||||||
ORZ_DEFINED,
|
|
||||||
THRADD_DEFINED,
|
|
||||||
RAINBOW_DEFINED,
|
|
||||||
ILWRATH_DEFINED,
|
|
||||||
ANDROSYNTH_DEFINED,
|
|
||||||
MYCON_TRAP_DEFINED
|
|
||||||
};
|
|
||||||
|
|
||||||
#define UMGAH_DEFINED TALKING_PET_DEFINED
|
|
||||||
|
|
||||||
// XXX: The stuff till EOC does not belong here
|
|
||||||
extern STAR_DESC *CurStarDescPtr;
|
|
||||||
extern STAR_DESC *star_array;
|
|
||||||
|
|
||||||
#define NUM_SOLAR_SYSTEMS 502
|
|
||||||
|
|
||||||
extern STAR_DESC* FindStar (STAR_DESC *pLastStar, POINT *puniverse,
|
|
||||||
SIZE xbounds, SIZE ybounds);
|
|
||||||
|
|
||||||
extern void GetClusterName (const STAR_DESC *pSD, UNICODE buf[]);
|
|
||||||
// <<< EOC
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HAIL = 0,
|
HAIL = 0,
|
||||||
ATTACK
|
ATTACK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern void EncounterBattle (void);
|
extern void EncounterBattle (void);
|
||||||
extern void BuildBattle (COUNT which_player);
|
extern void BuildBattle (COUNT which_player);
|
||||||
extern COUNT InitEncounter (void);
|
extern COUNT InitEncounter (void);
|
||||||
@@ -172,35 +106,6 @@ extern COUNT UninitEncounter (void);
|
|||||||
extern BOOLEAN FleetIsInfinite (COUNT playerNr);
|
extern BOOLEAN FleetIsInfinite (COUNT playerNr);
|
||||||
extern void UpdateShipFragCrew (STARSHIP *);
|
extern void UpdateShipFragCrew (STARSHIP *);
|
||||||
|
|
||||||
// XXX: in comm.h, temporary, until solsys generation code is redone
|
|
||||||
extern COUNT InitCommunication (CONVERSATION which_comm);
|
|
||||||
|
|
||||||
extern void GenerateSOL (BYTE control);
|
|
||||||
extern void GenerateShofixti (BYTE control);
|
|
||||||
extern void GenerateColony (BYTE control);
|
|
||||||
extern void GenerateSpathi (BYTE control);
|
|
||||||
extern void GenerateZoqFotPik (BYTE control);
|
|
||||||
extern void GenerateMelnorme (BYTE control);
|
|
||||||
extern void GenerateTalkingPet (BYTE control);
|
|
||||||
extern void GenerateChmmr (BYTE control);
|
|
||||||
extern void GenerateSyreen (BYTE control);
|
|
||||||
extern void GenerateBurvixes (BYTE control);
|
|
||||||
extern void GenerateSlylandro (BYTE control);
|
|
||||||
extern void GenerateDruuge (BYTE control);
|
|
||||||
extern void GenerateUtwig (BYTE control);
|
|
||||||
extern void GenerateThradd (BYTE control);
|
|
||||||
extern void GenerateMycon (BYTE control);
|
|
||||||
extern void GenerateOrz (BYTE control);
|
|
||||||
extern void GenerateShipVault (BYTE control);
|
|
||||||
extern void GenerateUrquanWreck (BYTE control);
|
|
||||||
extern void GenerateVUX (BYTE control);
|
|
||||||
extern void GenerateSamatra (BYTE control);
|
|
||||||
extern void GenerateYehat (BYTE control);
|
|
||||||
extern void GeneratePkunk (BYTE control);
|
|
||||||
extern void GenerateSupox (BYTE control);
|
|
||||||
extern void GenerateRainbow (BYTE control);
|
|
||||||
extern void GenerateIlwrath (BYTE control);
|
|
||||||
|
|
||||||
// Last race the player battled with, or -1 if no battle took place.
|
// Last race the player battled with, or -1 if no battle took place.
|
||||||
// Set to -1 by some funcs to inhibit IP groups from intercepting
|
// Set to -1 by some funcs to inhibit IP groups from intercepting
|
||||||
// the flagship.
|
// the flagship.
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
// XXX: for CurStarDescPtr and XXX_DEFINED constants
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
#include "gendef.h"
|
||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "hyper.h"
|
#include "hyper.h"
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
// XXX: for FindStart(), GetClusterName()
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
|
||||||
#include "menustat.h"
|
#include "menustat.h"
|
||||||
#include "sis.h"
|
#include "sis.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gendef.h"
|
#include "gendef.h"
|
||||||
#include "encount.h"
|
|
||||||
#include "planets/generate.h"
|
#include "planets/generate.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,59 @@ extern "C" {
|
|||||||
|
|
||||||
const GenerateFunctions *getGenerateFunctions (BYTE Index);
|
const GenerateFunctions *getGenerateFunctions (BYTE Index);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SOL_DEFINED = 1,
|
||||||
|
SHOFIXTI_DEFINED,
|
||||||
|
MAIDENS_DEFINED,
|
||||||
|
START_COLONY_DEFINED,
|
||||||
|
SPATHI_DEFINED,
|
||||||
|
ZOQFOT_DEFINED,
|
||||||
|
|
||||||
|
MELNORME0_DEFINED,
|
||||||
|
MELNORME1_DEFINED,
|
||||||
|
MELNORME2_DEFINED,
|
||||||
|
MELNORME3_DEFINED,
|
||||||
|
MELNORME4_DEFINED,
|
||||||
|
MELNORME5_DEFINED,
|
||||||
|
MELNORME6_DEFINED,
|
||||||
|
MELNORME7_DEFINED,
|
||||||
|
MELNORME8_DEFINED,
|
||||||
|
|
||||||
|
TALKING_PET_DEFINED,
|
||||||
|
CHMMR_DEFINED,
|
||||||
|
SYREEN_DEFINED,
|
||||||
|
BURVIXESE_DEFINED,
|
||||||
|
SLYLANDRO_DEFINED,
|
||||||
|
DRUUGE_DEFINED,
|
||||||
|
BOMB_DEFINED,
|
||||||
|
AQUA_HELIX_DEFINED,
|
||||||
|
SUN_DEVICE_DEFINED,
|
||||||
|
TAALO_PROTECTOR_DEFINED,
|
||||||
|
SHIP_VAULT_DEFINED,
|
||||||
|
URQUAN_WRECK_DEFINED,
|
||||||
|
VUX_BEAST_DEFINED,
|
||||||
|
SAMATRA_DEFINED,
|
||||||
|
ZOQ_SCOUT_DEFINED,
|
||||||
|
MYCON_DEFINED,
|
||||||
|
EGG_CASE0_DEFINED,
|
||||||
|
EGG_CASE1_DEFINED,
|
||||||
|
EGG_CASE2_DEFINED,
|
||||||
|
PKUNK_DEFINED,
|
||||||
|
UTWIG_DEFINED,
|
||||||
|
SUPOX_DEFINED,
|
||||||
|
YEHAT_DEFINED,
|
||||||
|
VUX_DEFINED,
|
||||||
|
ORZ_DEFINED,
|
||||||
|
THRADD_DEFINED,
|
||||||
|
RAINBOW_DEFINED,
|
||||||
|
ILWRATH_DEFINED,
|
||||||
|
ANDROSYNTH_DEFINED,
|
||||||
|
MYCON_TRAP_DEFINED
|
||||||
|
};
|
||||||
|
|
||||||
|
#define UMGAH_DEFINED TALKING_PET_DEFINED
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "coderes.h"
|
#include "coderes.h"
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
|
#include "starmap.h"
|
||||||
#include "master.h"
|
#include "master.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
// XXX: for CurStarDescPtr and XXX_DEFINED constants
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
#include "gendef.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "intel.h"
|
#include "intel.h"
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "menustat.h"
|
#include "menustat.h"
|
||||||
// for DrawMenuStateStrings()
|
// for DrawMenuStateStrings()
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
|
#include "starmap.h"
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
#include "shipcont.h"
|
#include "shipcont.h"
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "libs/declib.h"
|
#include "libs/declib.h"
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
|
#include "starmap.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "load.h"
|
#include "load.h"
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// XXX: for XXX_DEFINED constants
|
#include "gendef.h"
|
||||||
#include "encount.h"
|
|
||||||
#include "resinst.h"
|
#include "resinst.h"
|
||||||
#include "planets/planets.h"
|
#include "planets/planets.h"
|
||||||
#include "planets/elemdata.h"
|
#include "planets/elemdata.h"
|
||||||
|
|||||||
+149
-35
@@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* ----------------------------- INCLUDES ---------------------------- */
|
/* ----------------------------- INCLUDES ---------------------------- */
|
||||||
#include "../encount.h"
|
#include "planets.h"
|
||||||
|
#include "uqm/starmap.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
/* -------------------------------- DATA -------------------------------- */
|
/* -------------------------------- DATA -------------------------------- */
|
||||||
@@ -26,9 +27,6 @@
|
|||||||
|
|
||||||
//#define DEBUG_PLANET_CALC
|
//#define DEBUG_PLANET_CALC
|
||||||
|
|
||||||
#define CalcMass(b) CalcFromBase (b, b)
|
|
||||||
#define CalcRadius(b) CalcFromBase (b, ((b) >> 1) + 1)
|
|
||||||
|
|
||||||
#define LOW_TEMP 0
|
#define LOW_TEMP 0
|
||||||
#define MED_TEMP 500
|
#define MED_TEMP 500
|
||||||
#define HIGH_TEMP 1500
|
#define HIGH_TEMP 1500
|
||||||
@@ -36,15 +34,6 @@
|
|||||||
#define MED_TEMP_BONUS 25
|
#define MED_TEMP_BONUS 25
|
||||||
#define HIGH_TEMP_BONUS 50
|
#define HIGH_TEMP_BONUS 50
|
||||||
#define MAX_TECTONICS 255
|
#define MAX_TECTONICS 255
|
||||||
#ifdef OLD
|
|
||||||
#define CalcTectonics(b,t) (CalcFromBase(b, 3 << 5) \
|
|
||||||
+ (UWORD)((t) < LOW_TEMP ? 0 : \
|
|
||||||
((t) < MED_TEMP ? LOW_TEMP_BONUS : \
|
|
||||||
((t) < HIGH_TEMP ? MED_TEMP_BONUS : \
|
|
||||||
HIGH_TEMP_BONUS))))
|
|
||||||
#else /* OLD */
|
|
||||||
#define CalcTectonics(b,t) CalcFromBase(b, 3 << 5)
|
|
||||||
#endif /* OLD */
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -56,6 +45,18 @@ enum
|
|||||||
WHITE_SUN_INTENSITY
|
WHITE_SUN_INTENSITY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static UWORD
|
||||||
|
CalcFromBase (UWORD base, UWORD variance)
|
||||||
|
{
|
||||||
|
return base + LOWORD (RandomContext_Random (SysGenRNG)) % variance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline UWORD
|
||||||
|
CalcHalfBaseVariance (UWORD base)
|
||||||
|
{
|
||||||
|
return CalcFromBase (base, (base >> 1) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CalcSysInfo (SYSTEM_INFO *SysInfoPtr)
|
CalcSysInfo (SYSTEM_INFO *SysInfoPtr)
|
||||||
{
|
{
|
||||||
@@ -149,7 +150,7 @@ GeneratePlanetComposition (PLANET_INFO *PlanetInfoPtr, SIZE SurfaceTemp,
|
|||||||
PlanetInfoPtr->Weather += 1 << 5;
|
PlanetInfoPtr->Weather += 1 << 5;
|
||||||
else if (radius > 10)
|
else if (radius > 10)
|
||||||
PlanetInfoPtr->Weather -= 1 << 5;
|
PlanetInfoPtr->Weather -= 1 << 5;
|
||||||
atmo = CalcFromBase (atmo, (atmo >> 1) + 1);
|
atmo = CalcHalfBaseVariance (atmo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ CalcTemp (SYSTEM_INFO *SysInfoPtr, SIZE radius)
|
|||||||
bonus = COLD_BONUS;
|
bonus = COLD_BONUS;
|
||||||
|
|
||||||
bonus <<= HINIBBLE (SysInfoPtr->PlanetInfo.PlanDataPtr->AtmoAndDensity);
|
bonus <<= HINIBBLE (SysInfoPtr->PlanetInfo.PlanDataPtr->AtmoAndDensity);
|
||||||
bonus = CalcFromBase (bonus, (bonus >> 1) + 1);
|
bonus = CalcHalfBaseVariance (bonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (centigrade + bonus);
|
return (centigrade + bonus);
|
||||||
@@ -204,11 +205,11 @@ static COUNT
|
|||||||
CalcRotation (PLANET_INFO *PlanetInfoPtr)
|
CalcRotation (PLANET_INFO *PlanetInfoPtr)
|
||||||
{
|
{
|
||||||
if (PLANSIZE (PlanetInfoPtr->PlanDataPtr->Type) == GAS_GIANT)
|
if (PLANSIZE (PlanetInfoPtr->PlanDataPtr->Type) == GAS_GIANT)
|
||||||
return ((COUNT)CalcFromBase (80, 80));
|
return CalcFromBase (80, 80);
|
||||||
else if (((BYTE)TFB_Random () % 10) == 0)
|
else if (LOBYTE (RandomContext_Random (SysGenRNG)) % 10 == 0)
|
||||||
return ((COUNT)CalcFromBase ((UWORD)50 * 240, (UWORD)200 * 240));
|
return CalcFromBase (50 * 240, 200 * 240);
|
||||||
else
|
else
|
||||||
return ((COUNT)CalcFromBase (150, 150));
|
return CalcFromBase (150, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SIZE
|
static SIZE
|
||||||
@@ -223,22 +224,137 @@ CalcTilt (void)
|
|||||||
i = NUM_TOSSES;
|
i = NUM_TOSSES;
|
||||||
do /* Using added Randomom values to give bell curve */
|
do /* Using added Randomom values to give bell curve */
|
||||||
{
|
{
|
||||||
tilt += (UWORD)TFB_Random () % ((TILT_RANGE / NUM_TOSSES) + 1);
|
tilt += LOWORD (RandomContext_Random (SysGenRNG))
|
||||||
|
% ((TILT_RANGE / NUM_TOSSES) + 1);
|
||||||
} while (--i);
|
} while (--i);
|
||||||
|
|
||||||
return (tilt);
|
return (tilt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB. Returns the RNG to the state it found it in.
|
UWORD
|
||||||
DWORD
|
CalcGravity (const PLANET_INFO *PlanetInfoPtr)
|
||||||
|
{
|
||||||
|
return (DWORD)PlanetInfoPtr->PlanetDensity * PlanetInfoPtr->PlanetRadius
|
||||||
|
/ 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
static UWORD
|
||||||
|
CalcTectonics (UWORD base, UWORD temp)
|
||||||
|
{
|
||||||
|
UWORD tect = CalcFromBase (base, 3 << 5);
|
||||||
|
#ifdef OLD
|
||||||
|
if (temp >= HIGH_TEMP)
|
||||||
|
tect += HIGH_TEMP_BONUS;
|
||||||
|
else if (temp >= MED_TEMP)
|
||||||
|
tect += MED_TEMP_BONUS;
|
||||||
|
else if (temp >= LOW_TEMP)
|
||||||
|
tect += LOW_TEMP_BONUS;
|
||||||
|
#else /* !OLD */
|
||||||
|
(void) temp; /* silence compiler whining */
|
||||||
|
#endif /* OLD */
|
||||||
|
return tect;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This code moved from planets/surface.c:CalcLifeForms()
|
||||||
|
static int
|
||||||
|
CalcLifeChance (const PLANET_INFO *PlanetInfoPtr)
|
||||||
|
{
|
||||||
|
SIZE life_var = 0;
|
||||||
|
|
||||||
|
if (PLANSIZE (PlanetInfoPtr->PlanDataPtr->Type) == GAS_GIANT)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (PlanetInfoPtr->SurfaceTemperature < -151)
|
||||||
|
life_var -= 300;
|
||||||
|
else if (PlanetInfoPtr->SurfaceTemperature < -51)
|
||||||
|
life_var -= 100;
|
||||||
|
else if (PlanetInfoPtr->SurfaceTemperature < 0)
|
||||||
|
life_var += 100;
|
||||||
|
else if (PlanetInfoPtr->SurfaceTemperature < 50)
|
||||||
|
life_var += 300;
|
||||||
|
else if (PlanetInfoPtr->SurfaceTemperature < 150)
|
||||||
|
life_var += 50;
|
||||||
|
else if (PlanetInfoPtr->SurfaceTemperature < 250)
|
||||||
|
life_var -= 100;
|
||||||
|
else if (PlanetInfoPtr->SurfaceTemperature < 500)
|
||||||
|
life_var -= 400;
|
||||||
|
else
|
||||||
|
life_var -= 800;
|
||||||
|
|
||||||
|
if (PlanetInfoPtr->AtmoDensity == 0)
|
||||||
|
life_var -= 1000;
|
||||||
|
else if (PlanetInfoPtr->AtmoDensity < 15)
|
||||||
|
life_var += 100;
|
||||||
|
else if (PlanetInfoPtr->AtmoDensity < 30)
|
||||||
|
life_var += 200;
|
||||||
|
else if (PlanetInfoPtr->AtmoDensity < 100)
|
||||||
|
life_var += 300;
|
||||||
|
else if (PlanetInfoPtr->AtmoDensity < 1000)
|
||||||
|
life_var += 150;
|
||||||
|
else if (PlanetInfoPtr->AtmoDensity < 2500)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
life_var -= 100;
|
||||||
|
|
||||||
|
#ifndef NOTYET
|
||||||
|
life_var += 200 + 80 + 80;
|
||||||
|
#else /* NOTYET */
|
||||||
|
if (PlanetInfoPtr->SurfaceGravity < 10)
|
||||||
|
;
|
||||||
|
else if (PlanetInfoPtr->SurfaceGravity < 35)
|
||||||
|
life_var += 50;
|
||||||
|
else if (PlanetInfoPtr->SurfaceGravity < 75)
|
||||||
|
life_var += 100;
|
||||||
|
else if (PlanetInfoPtr->SurfaceGravity < 150)
|
||||||
|
life_var += 200;
|
||||||
|
else if (PlanetInfoPtr->SurfaceGravity < 400)
|
||||||
|
life_var += 50;
|
||||||
|
else if (PlanetInfoPtr->SurfaceGravity < 800)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
life_var -= 100;
|
||||||
|
|
||||||
|
if (PlanetInfoPtr->Tectonics < 1)
|
||||||
|
life_var += 80;
|
||||||
|
else if (PlanetInfoPtr->Tectonics < 2)
|
||||||
|
life_var += 70;
|
||||||
|
else if (PlanetInfoPtr->Tectonics < 3)
|
||||||
|
life_var += 60;
|
||||||
|
else if (PlanetInfoPtr->Tectonics < 4)
|
||||||
|
life_var += 50;
|
||||||
|
else if (PlanetInfoPtr->Tectonics < 5)
|
||||||
|
life_var += 25;
|
||||||
|
else if (PlanetInfoPtr->Tectonics < 6)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
life_var -= 100;
|
||||||
|
|
||||||
|
if (PlanetInfoPtr->Weather < 1)
|
||||||
|
life_var += 80;
|
||||||
|
else if (PlanetInfoPtr->Weather < 2)
|
||||||
|
life_var += 70;
|
||||||
|
else if (PlanetInfoPtr->Weather < 3)
|
||||||
|
life_var += 60;
|
||||||
|
else if (PlanetInfoPtr->Weather < 4)
|
||||||
|
life_var += 50;
|
||||||
|
else if (PlanetInfoPtr->Weather < 5)
|
||||||
|
life_var += 25;
|
||||||
|
else if (PlanetInfoPtr->Weather < 6)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
life_var -= 100;
|
||||||
|
#endif /* NOTYET */
|
||||||
|
|
||||||
|
return life_var;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the SysGenRNG to the required state first.
|
||||||
|
void
|
||||||
DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc)
|
DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc)
|
||||||
{
|
{
|
||||||
DWORD old_seed;
|
assert (pPlanetDesc->data_index != HIERARCHY_STARBASE);
|
||||||
|
|
||||||
if (pPlanetDesc->data_index == HIERARCHY_STARBASE)
|
RandomContext_SeedRandom (SysGenRNG, pPlanetDesc->rand_seed);
|
||||||
return (0);
|
|
||||||
|
|
||||||
old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed);
|
|
||||||
|
|
||||||
CalcSysInfo (SysInfoPtr);
|
CalcSysInfo (SysInfoPtr);
|
||||||
|
|
||||||
@@ -303,18 +419,18 @@ DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc)
|
|||||||
}
|
}
|
||||||
SysInfoPtr->PlanetInfo.PlanetDensity +=
|
SysInfoPtr->PlanetInfo.PlanetDensity +=
|
||||||
(SysInfoPtr->PlanetInfo.PlanetDensity / 20)
|
(SysInfoPtr->PlanetInfo.PlanetDensity / 20)
|
||||||
- ((COUNT)TFB_Random ()
|
- (LOWORD (RandomContext_Random (SysGenRNG))
|
||||||
% (SysInfoPtr->PlanetInfo.PlanetDensity / 10));
|
% (SysInfoPtr->PlanetInfo.PlanetDensity / 10));
|
||||||
|
|
||||||
switch (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type))
|
switch (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type))
|
||||||
{
|
{
|
||||||
case SMALL_ROCKY_WORLD:
|
case SMALL_ROCKY_WORLD:
|
||||||
#define SMALL_RADIUS 25
|
#define SMALL_RADIUS 25
|
||||||
SysInfoPtr->PlanetInfo.PlanetRadius = CalcRadius (SMALL_RADIUS);
|
SysInfoPtr->PlanetInfo.PlanetRadius = CalcHalfBaseVariance (SMALL_RADIUS);
|
||||||
break;
|
break;
|
||||||
case LARGE_ROCKY_WORLD:
|
case LARGE_ROCKY_WORLD:
|
||||||
#define LARGE_RADIUS 75
|
#define LARGE_RADIUS 75
|
||||||
SysInfoPtr->PlanetInfo.PlanetRadius = CalcRadius (LARGE_RADIUS);
|
SysInfoPtr->PlanetInfo.PlanetRadius = CalcHalfBaseVariance (LARGE_RADIUS);
|
||||||
break;
|
break;
|
||||||
case GAS_GIANT:
|
case GAS_GIANT:
|
||||||
#define MIN_GAS_RADIUS 300
|
#define MIN_GAS_RADIUS 300
|
||||||
@@ -325,9 +441,7 @@ DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SysInfoPtr->PlanetInfo.RotationPeriod = CalcRotation (&SysInfoPtr->PlanetInfo);
|
SysInfoPtr->PlanetInfo.RotationPeriod = CalcRotation (&SysInfoPtr->PlanetInfo);
|
||||||
SysInfoPtr->PlanetInfo.SurfaceGravity =
|
SysInfoPtr->PlanetInfo.SurfaceGravity = CalcGravity (&SysInfoPtr->PlanetInfo);
|
||||||
CalcGravity (SysInfoPtr->PlanetInfo.PlanetDensity,
|
|
||||||
SysInfoPtr->PlanetInfo.PlanetRadius);
|
|
||||||
SysInfoPtr->PlanetInfo.AxialTilt = CalcTilt ();
|
SysInfoPtr->PlanetInfo.AxialTilt = CalcTilt ();
|
||||||
if ((SysInfoPtr->PlanetInfo.Tectonics =
|
if ((SysInfoPtr->PlanetInfo.Tectonics =
|
||||||
CalcTectonics (SysInfoPtr->PlanetInfo.PlanDataPtr->BaseTectonics,
|
CalcTectonics (SysInfoPtr->PlanetInfo.PlanDataPtr->BaseTectonics,
|
||||||
@@ -341,6 +455,8 @@ DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc)
|
|||||||
SysInfoPtr->PlanetInfo.Tectonics >>= 5;
|
SysInfoPtr->PlanetInfo.Tectonics >>= 5;
|
||||||
SysInfoPtr->PlanetInfo.Weather >>= 5;
|
SysInfoPtr->PlanetInfo.Weather >>= 5;
|
||||||
|
|
||||||
|
SysInfoPtr->PlanetInfo.LifeChance = CalcLifeChance (&SysInfoPtr->PlanetInfo);
|
||||||
|
|
||||||
#ifdef DEBUG_PLANET_CALC
|
#ifdef DEBUG_PLANET_CALC
|
||||||
radius = (SIZE)((DWORD)UNSCALE_RADIUS (radius) * 100 / UNSCALE_RADIUS (EARTH_RADIUS));
|
radius = (SIZE)((DWORD)UNSCALE_RADIUS (radius) * 100 / UNSCALE_RADIUS (EARTH_RADIUS));
|
||||||
log_add (log_Debug, "\tOrbital Distance : %d.%02d AU", radius / 100, radius % 100);
|
log_add (log_Debug, "\tOrbital Distance : %d.%02d AU", radius / 100, radius % 100);
|
||||||
@@ -404,7 +520,5 @@ DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc)
|
|||||||
}
|
}
|
||||||
#endif /* DEBUG_PLANET_CALC */
|
#endif /* DEBUG_PLANET_CALC */
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TFB_SeedRandom (old_seed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "../build.h"
|
#include "../build.h"
|
||||||
#include "../colors.h"
|
#include "../colors.h"
|
||||||
|
#include "../gendef.h"
|
||||||
|
#include "../starmap.h"
|
||||||
#include "../encount.h"
|
#include "../encount.h"
|
||||||
#include "../gamestr.h"
|
#include "../gamestr.h"
|
||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ GenerateBurvixese_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
|
|||||||
solarSys->MoonDesc[0].data_index = SELENIC_WORLD;
|
solarSys->MoonDesc[0].data_index = SELENIC_WORLD;
|
||||||
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS
|
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS
|
||||||
+ (MAX_MOONS - 1) * MOON_DELTA;
|
+ (MAX_MOONS - 1) * MOON_DELTA;
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
||||||
solarSys->MoonDesc[0].location.x =
|
solarSys->MoonDesc[0].location.x =
|
||||||
COSINE (angle, solarSys->MoonDesc[0].radius);
|
COSINE (angle, solarSys->MoonDesc[0].radius);
|
||||||
@@ -98,18 +98,17 @@ GenerateBurvixese_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
|
|||||||
static bool
|
static bool
|
||||||
GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
||||||
{
|
{
|
||||||
COUNT i;
|
|
||||||
DWORD rand_val;
|
DWORD rand_val;
|
||||||
|
|
||||||
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
||||||
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL);
|
||||||
rand_val = GenerateLifeForms (&solarSys->SysInfo, &i);
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL);
|
||||||
GenerateMineralDeposits (&solarSys->SysInfo, &i);
|
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ GenerateChmmr_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
|
|||||||
|
|
||||||
solarSys->MoonDesc[0].data_index = HIERARCHY_STARBASE;
|
solarSys->MoonDesc[0].data_index = HIERARCHY_STARBASE;
|
||||||
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS;
|
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS;
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
||||||
solarSys->MoonDesc[0].location.x =
|
solarSys->MoonDesc[0].location.x =
|
||||||
COSINE (angle, solarSys->MoonDesc[0].radius);
|
COSINE (angle, solarSys->MoonDesc[0].radius);
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ GenerateDefault_generateName (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
bool
|
bool
|
||||||
GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
||||||
{
|
{
|
||||||
COUNT i;
|
|
||||||
DWORD rand_val;
|
DWORD rand_val;
|
||||||
SYSTEM_INFO *sysInfo;
|
SYSTEM_INFO *sysInfo;
|
||||||
|
|
||||||
@@ -146,15 +145,15 @@ GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
|
|
||||||
sysInfo = &solarSys->SysInfo;
|
sysInfo = &solarSys->SysInfo;
|
||||||
|
|
||||||
rand_val = DoPlanetaryAnalysis (sysInfo, world);
|
DoPlanetaryAnalysis (sysInfo, world);
|
||||||
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
sysInfo->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
sysInfo->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateLifeForms (sysInfo, GENERATE_ALL);
|
||||||
rand_val = GenerateLifeForms (sysInfo, &i);
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
sysInfo->PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
sysInfo->PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateMineralDeposits (sysInfo, GENERATE_ALL);
|
||||||
GenerateMineralDeposits (sysInfo, &i);
|
|
||||||
|
|
||||||
sysInfo->PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
|
sysInfo->PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
|
||||||
LoadPlanet (NULL);
|
LoadPlanet (NULL);
|
||||||
@@ -166,9 +165,8 @@ COUNT
|
|||||||
GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys,
|
GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys,
|
||||||
PLANET_DESC *world, COUNT whichNode)
|
PLANET_DESC *world, COUNT whichNode)
|
||||||
{
|
{
|
||||||
GenerateMineralDeposits (&solarSys->SysInfo, &whichNode);
|
return GenerateMineralDeposits (&solarSys->SysInfo, whichNode);
|
||||||
(void) world;
|
(void) world;
|
||||||
return whichNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -209,9 +207,8 @@ COUNT
|
|||||||
GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
||||||
COUNT whichNode)
|
COUNT whichNode)
|
||||||
{
|
{
|
||||||
GenerateLifeForms (&solarSys->SysInfo, &whichNode);
|
return GenerateLifeForms (&solarSys->SysInfo, whichNode);
|
||||||
(void) world;
|
(void) world;
|
||||||
return whichNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -229,17 +226,15 @@ COUNT
|
|||||||
GenerateDefault_generateArtifact (SOLARSYS_STATE *solarSys, COUNT whichNode)
|
GenerateDefault_generateArtifact (SOLARSYS_STATE *solarSys, COUNT whichNode)
|
||||||
{
|
{
|
||||||
// Generate an energy node at a random location
|
// Generate an energy node at a random location
|
||||||
GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, &whichNode);
|
return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, whichNode);
|
||||||
return whichNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
COUNT
|
COUNT
|
||||||
GenerateDefault_generateRuins (SOLARSYS_STATE *solarSys, COUNT whichNode)
|
GenerateDefault_generateRuins (SOLARSYS_STATE *solarSys, COUNT whichNode)
|
||||||
{
|
{
|
||||||
// Generate a standard spread of city ruins of a destroyed civilization
|
// Generate a standard spread of city ruins of a destroyed civilization
|
||||||
GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, NUM_RACE_RUINS,
|
return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, NUM_RACE_RUINS,
|
||||||
0, &whichNode);
|
0, whichNode);
|
||||||
return whichNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -309,7 +304,7 @@ GeneratePlanets (SOLARSYS_STATE *solarSys)
|
|||||||
BYTE num_moons;
|
BYTE num_moons;
|
||||||
BYTE type;
|
BYTE type;
|
||||||
|
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
byte_val = LOBYTE (rand_val);
|
byte_val = LOBYTE (rand_val);
|
||||||
|
|
||||||
num_moons = 0;
|
num_moons = 0;
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
#include "genall.h"
|
#include "genall.h"
|
||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../state.h"
|
#include "../../state.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
#include "../scan.h"
|
#include "../scan.h"
|
||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../comm.h"
|
#include "../../comm.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../ipdisp.h"
|
#include "../../ipdisp.h"
|
||||||
#include "../../nameref.h"
|
#include "../../nameref.h"
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
#include "../planets.h"
|
#include "../planets.h"
|
||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../comm.h"
|
#include "../../comm.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../ipdisp.h"
|
#include "../../ipdisp.h"
|
||||||
#include "../../nameref.h"
|
#include "../../nameref.h"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../comm.h"
|
#include "../../comm.h"
|
||||||
#include "../../encount.h"
|
#include "../../encount.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../ipdisp.h"
|
#include "../../ipdisp.h"
|
||||||
#include "../../nameref.h"
|
#include "../../nameref.h"
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
#include "genall.h"
|
#include "genall.h"
|
||||||
#include "../planets.h"
|
#include "../planets.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ GenerateSaMatra_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
|
|||||||
|
|
||||||
solarSys->MoonDesc[0].data_index = SA_MATRA;
|
solarSys->MoonDesc[0].data_index = SA_MATRA;
|
||||||
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + (2 * MOON_DELTA);
|
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + (2 * MOON_DELTA);
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
||||||
solarSys->MoonDesc[0].location.x =
|
solarSys->MoonDesc[0].location.x =
|
||||||
COSINE (angle, solarSys->MoonDesc[0].radius);
|
COSINE (angle, solarSys->MoonDesc[0].radius);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys)
|
|||||||
COUNT planetI;
|
COUNT planetI;
|
||||||
|
|
||||||
#define SOL_SEED 334241042L
|
#define SOL_SEED 334241042L
|
||||||
TFB_SeedRandom (SOL_SEED);
|
RandomContext_SeedRandom (SysGenRNG, SOL_SEED);
|
||||||
|
|
||||||
solarSys->SunDesc[0].NumPlanets = 9;
|
solarSys->SunDesc[0].NumPlanets = 9;
|
||||||
for (planetI = 0; planetI < 9; ++planetI)
|
for (planetI = 0; planetI < 9; ++planetI)
|
||||||
@@ -118,7 +118,8 @@ GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys)
|
|||||||
UWORD word_val;
|
UWORD word_val;
|
||||||
PLANET_DESC *pCurDesc = &solarSys->PlanetDesc[planetI];
|
PLANET_DESC *pCurDesc = &solarSys->PlanetDesc[planetI];
|
||||||
|
|
||||||
pCurDesc->rand_seed = rand_val = TFB_Random ();
|
pCurDesc->rand_seed = RandomContext_Random (SysGenRNG);
|
||||||
|
rand_val = pCurDesc->rand_seed;
|
||||||
word_val = LOWORD (rand_val);
|
word_val = LOWORD (rand_val);
|
||||||
angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val));
|
angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val));
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ GenerateSol_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
|
|||||||
solarSys->MoonDesc[1].data_index = SELENIC_WORLD;
|
solarSys->MoonDesc[1].data_index = SELENIC_WORLD;
|
||||||
solarSys->MoonDesc[1].radius = MIN_MOON_RADIUS
|
solarSys->MoonDesc[1].radius = MIN_MOON_RADIUS
|
||||||
+ (MAX_MOONS - 1) * MOON_DELTA;
|
+ (MAX_MOONS - 1) * MOON_DELTA;
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
||||||
solarSys->MoonDesc[1].location.x =
|
solarSys->MoonDesc[1].location.x =
|
||||||
COSINE (angle, solarSys->MoonDesc[1].radius);
|
COSINE (angle, solarSys->MoonDesc[1].radius);
|
||||||
@@ -269,15 +270,12 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
||||||
if (rand_val)
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
{
|
|
||||||
COUNT i;
|
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL);
|
||||||
rand_val = GenerateMineralDeposits (&solarSys->SysInfo, &i);
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
}
|
|
||||||
|
|
||||||
planetNr = planetIndex (solarSys, world);
|
planetNr = planetIndex (solarSys, world);
|
||||||
if (worldIsPlanet (solarSys, world))
|
if (worldIsPlanet (solarSys, world))
|
||||||
@@ -405,8 +403,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
}
|
}
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
|
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
|
||||||
CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity,
|
CalcGravity (&solarSys->SysInfo.PlanetInfo);
|
||||||
solarSys->SysInfo.PlanetInfo.PlanetRadius);
|
|
||||||
LoadPlanet (planetNr == 2 ?
|
LoadPlanet (planetNr == 2 ?
|
||||||
CaptureDrawable (LoadGraphic (EARTH_MASK_ANIM)) : NULL);
|
CaptureDrawable (LoadGraphic (EARTH_MASK_ANIM)) : NULL);
|
||||||
}
|
}
|
||||||
@@ -421,6 +418,10 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
switch (planetNr)
|
switch (planetNr)
|
||||||
{
|
{
|
||||||
case 2: /* moons of EARTH */
|
case 2: /* moons of EARTH */
|
||||||
|
// NOTE: Even though we save the seed here, it is irrelevant.
|
||||||
|
// The seed will be used to randomly place the tractors, but
|
||||||
|
// since they are mobile, they will be moved to different
|
||||||
|
// locations not governed by this seed.
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] =
|
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] =
|
||||||
rand_val;
|
rand_val;
|
||||||
|
|
||||||
@@ -505,8 +506,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
}
|
}
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
|
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
|
||||||
CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity,
|
CalcGravity (&solarSys->SysInfo.PlanetInfo);
|
||||||
solarSys->SysInfo.PlanetInfo.PlanetRadius);
|
|
||||||
LoadPlanet (NULL);
|
LoadPlanet (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,9 +601,8 @@ GenerateSol_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
|||||||
if (matchWorld (solarSys, world, 2, 1))
|
if (matchWorld (solarSys, world, 2, 1))
|
||||||
{
|
{
|
||||||
/* Earth Moon */
|
/* Earth Moon */
|
||||||
GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, 10,
|
return GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, 10,
|
||||||
NUM_CREATURE_TYPES + 1, &whichNode);
|
NUM_CREATURE_TYPES + 1, whichNode);
|
||||||
return whichNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ GenerateSpathi_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
|
|||||||
|
|
||||||
solarSys->MoonDesc[0].data_index = PELLUCID_WORLD;
|
solarSys->MoonDesc[0].data_index = PELLUCID_WORLD;
|
||||||
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA;
|
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA;
|
||||||
angle = NORMALIZE_ANGLE (LOWORD (TFB_Random ()));
|
angle = NORMALIZE_ANGLE (LOWORD (RandomContext_Random (SysGenRNG)));
|
||||||
solarSys->MoonDesc[0].location.x =
|
solarSys->MoonDesc[0].location.x =
|
||||||
COSINE (angle, solarSys->MoonDesc[0].radius);
|
COSINE (angle, solarSys->MoonDesc[0].radius);
|
||||||
solarSys->MoonDesc[0].location.y =
|
solarSys->MoonDesc[0].location.y =
|
||||||
@@ -116,7 +116,6 @@ static bool
|
|||||||
GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
||||||
{
|
{
|
||||||
DWORD rand_val;
|
DWORD rand_val;
|
||||||
COUNT i;
|
|
||||||
|
|
||||||
if (matchWorld (solarSys, world, 0, 0))
|
if (matchWorld (solarSys, world, 0, 0))
|
||||||
{
|
{
|
||||||
@@ -144,15 +143,16 @@ GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
|
||||||
|
DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
||||||
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL);
|
||||||
rand_val = GenerateLifeForms (&solarSys->SysInfo, &i);
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL);
|
||||||
GenerateMineralDeposits (&solarSys->SysInfo, &i);
|
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
|
||||||
|
|
||||||
@@ -181,18 +181,18 @@ GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
else if (matchWorld (solarSys, world, 0, MATCH_PLANET))
|
else if (matchWorld (solarSys, world, 0, MATCH_PLANET))
|
||||||
{
|
{
|
||||||
/* visiting Spathiwa */
|
/* visiting Spathiwa */
|
||||||
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
DoPlanetaryAnalysis (&solarSys->SysInfo, world);
|
||||||
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
|
||||||
i = (COUNT)~0;
|
GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL);
|
||||||
rand_val = GenerateMineralDeposits (&solarSys->SysInfo, &i);
|
rand_val = RandomContext_GetSeed (SysGenRNG);
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
|
||||||
|
|
||||||
solarSys->SysInfo.PlanetInfo.PlanetRadius = 120;
|
solarSys->SysInfo.PlanetInfo.PlanetRadius = 120;
|
||||||
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
|
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
|
||||||
CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity,
|
CalcGravity (&solarSys->SysInfo.PlanetInfo);
|
||||||
solarSys->SysInfo.PlanetInfo.PlanetRadius);
|
|
||||||
solarSys->SysInfo.PlanetInfo.Weather = 0;
|
solarSys->SysInfo.PlanetInfo.Weather = 0;
|
||||||
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
|
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
|
||||||
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 31;
|
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 31;
|
||||||
@@ -253,9 +253,8 @@ GenerateSpathi_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
|||||||
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
|
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
|
||||||
{
|
{
|
||||||
#define NUM_EVIL_ONES 32
|
#define NUM_EVIL_ONES 32
|
||||||
GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, NUM_EVIL_ONES,
|
return GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, NUM_EVIL_ONES,
|
||||||
NUM_CREATURE_TYPES, &whichNode);
|
NUM_CREATURE_TYPES, whichNode);
|
||||||
return whichNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
#include "../planets.h"
|
#include "../planets.h"
|
||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../comm.h"
|
#include "../../comm.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../ipdisp.h"
|
#include "../../ipdisp.h"
|
||||||
#include "../../nameref.h"
|
#include "../../nameref.h"
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
#include "../planets.h"
|
#include "../planets.h"
|
||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../comm.h"
|
#include "../../comm.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../ipdisp.h"
|
#include "../../ipdisp.h"
|
||||||
#include "../../nameref.h"
|
#include "../../nameref.h"
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
#include "../planets.h"
|
#include "../planets.h"
|
||||||
#include "../../build.h"
|
#include "../../build.h"
|
||||||
#include "../../comm.h"
|
#include "../../comm.h"
|
||||||
#include "../../encount.h"
|
#include "../../gendef.h"
|
||||||
|
#include "../../starmap.h"
|
||||||
#include "../../globdata.h"
|
#include "../../globdata.h"
|
||||||
#include "../../ipdisp.h"
|
#include "../../ipdisp.h"
|
||||||
#include "../../nameref.h"
|
#include "../../nameref.h"
|
||||||
@@ -276,9 +277,8 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
|||||||
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
|
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
|
||||||
{
|
{
|
||||||
COUNT i;
|
COUNT i;
|
||||||
DWORD old_rand;
|
|
||||||
|
|
||||||
old_rand = TFB_SeedRandom (
|
RandomContext_SeedRandom (SysGenRNG,
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
|
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
|
||||||
|
|
||||||
for (i = 0; i <= whichNode && i < 12; ++i)
|
for (i = 0; i <= whichNode && i < 12; ++i)
|
||||||
@@ -292,8 +292,6 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
|||||||
solarSys->SysInfo.PlanetInfo.CurType = 18;
|
solarSys->SysInfo.PlanetInfo.CurType = 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFB_SeedRandom (old_rand);
|
|
||||||
|
|
||||||
return 12; // only matters when count is requested
|
return 12; // only matters when count is requested
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,9 +299,8 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
|||||||
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
|
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
|
||||||
{
|
{
|
||||||
COUNT i;
|
COUNT i;
|
||||||
DWORD old_rand;
|
|
||||||
|
|
||||||
old_rand = TFB_SeedRandom (
|
RandomContext_SeedRandom (SysGenRNG,
|
||||||
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
|
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
|
||||||
|
|
||||||
for (i = 0; i <= whichNode && i < 11; ++i)
|
for (i = 0; i <= whichNode && i < 11; ++i)
|
||||||
@@ -319,8 +316,6 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
|
|||||||
solarSys->SysInfo.PlanetInfo.CurType = 8;
|
solarSys->SysInfo.PlanetInfo.CurType = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFB_SeedRandom (old_rand);
|
|
||||||
|
|
||||||
return 11; // only matters when count is requested
|
return 11; // only matters when count is requested
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ DeltaTopography (COUNT num_iterations, SBYTE *DepthArray, RECT *pRect,
|
|||||||
DWORD rand_val;
|
DWORD rand_val;
|
||||||
SBYTE *lpDst;
|
SBYTE *lpDst;
|
||||||
|
|
||||||
depth_delta = ((((SIZE)TFB_Random () & 1) << 1) - 1) * depth_delta;
|
if ((RandomContext_Random (SysGenRNG) & 1) == 0)
|
||||||
|
depth_delta = -depth_delta;
|
||||||
|
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
w1 = LOWORD (rand_val);
|
w1 = LOWORD (rand_val);
|
||||||
w2 = HIWORD (rand_val);
|
w2 = HIWORD (rand_val);
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
#include "../cons_res.h"
|
#include "../cons_res.h"
|
||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
#include "../colors.h"
|
#include "../colors.h"
|
||||||
// XXX: for CurStarDescPtr and XXX_DEFINED
|
|
||||||
#include "../encount.h"
|
|
||||||
#include "../process.h"
|
#include "../process.h"
|
||||||
#include "../units.h"
|
#include "../units.h"
|
||||||
#include "../gamestr.h"
|
#include "../gamestr.h"
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "planets.h"
|
#include "planets.h"
|
||||||
// XXX: for CurStarDescPtr
|
#include "../starmap.h"
|
||||||
#include "../encount.h"
|
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
@@ -499,10 +498,15 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
|
|||||||
|
|
||||||
if (NumPlanets == (BYTE)~0)
|
if (NumPlanets == (BYTE)~0)
|
||||||
{
|
{
|
||||||
#define MAX_GENERATED_PLANETS 10
|
#define MAX_GENERATED_PLANETS 9
|
||||||
while ((NumPlanets = (BYTE)(LOWORD (TFB_Random())
|
// XXX: This is pretty funny. Instead of calling RNG once, like so:
|
||||||
% MAX_GENERATED_PLANETS)) == 0)
|
// 1 + Random % MAX_GENERATED_PLANETS
|
||||||
;
|
// we spin in a loop until the result > 0.
|
||||||
|
// Note that this behavior must be kept to preserve the universe.
|
||||||
|
do
|
||||||
|
NumPlanets = LOWORD (RandomContext_Random (SysGenRNG))
|
||||||
|
% (MAX_GENERATED_PLANETS + 1);
|
||||||
|
while (NumPlanets == 0);
|
||||||
system->SunDesc[0].NumPlanets = NumPlanets;
|
system->SunDesc[0].NumPlanets = NumPlanets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +532,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
if (TypesDefined)
|
if (TypesDefined)
|
||||||
rand_val = 0;
|
rand_val = 0;
|
||||||
else
|
else
|
||||||
@@ -564,7 +568,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
|
|||||||
else
|
else
|
||||||
min_radius = Suns[StarSize].MinGasGDist;
|
min_radius = Suns[StarSize].MinGasGDist;
|
||||||
RelocatePlanet:
|
RelocatePlanet:
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
if (GeneratingMoons)
|
if (GeneratingMoons)
|
||||||
{
|
{
|
||||||
pPD->radius = MIN_MOON_RADIUS
|
pPD->radius = MIN_MOON_RADIUS
|
||||||
@@ -592,7 +596,7 @@ RelocatePlanet:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
|
||||||
pPD->location.x = COSINE (angle, pPD->radius);
|
pPD->location.x = COSINE (angle, pPD->radius);
|
||||||
pPD->location.y = SINE (angle, pPD->radius);
|
pPD->location.y = SINE (angle, pPD->radius);
|
||||||
|
|||||||
@@ -313,8 +313,7 @@ enum
|
|||||||
SUPER_DENSITY
|
SUPER_DENSITY
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CalcGravity(d,r) (UWORD)((DWORD)(d) * (r) / 100)
|
extern UWORD CalcGravity (const PLANET_INFO*);
|
||||||
#define CalcFromBase(b,v) ((UWORD)(b) + ((UWORD)TFB_Random () % (v)))
|
|
||||||
|
|
||||||
#define EARTH_ATMOSPHERE 50
|
#define EARTH_ATMOSPHERE 50
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#ifndef _PLANETS_H
|
#ifndef _PLANETS_H
|
||||||
#define _PLANETS_H
|
#define _PLANETS_H
|
||||||
|
|
||||||
|
#include "libs/mathlib.h"
|
||||||
|
|
||||||
#define END_INTERPLANETARY START_INTERPLANETARY
|
#define END_INTERPLANETARY START_INTERPLANETARY
|
||||||
|
|
||||||
enum PlanetScanTypes
|
enum PlanetScanTypes
|
||||||
@@ -233,6 +235,9 @@ extern SOLARSYS_STATE *pSolarSysState;
|
|||||||
extern MUSIC_REF SpaceMusic;
|
extern MUSIC_REF SpaceMusic;
|
||||||
extern CONTEXT PlanetContext;
|
extern CONTEXT PlanetContext;
|
||||||
|
|
||||||
|
// Random context used for all solar system, planets and surfaces generation
|
||||||
|
extern RandomContext *SysGenRNG;
|
||||||
|
|
||||||
bool playerInSolarSystem (void);
|
bool playerInSolarSystem (void);
|
||||||
bool playerInPlanetOrbit (void);
|
bool playerInPlanetOrbit (void);
|
||||||
bool playerInInnerSystem (void);
|
bool playerInInnerSystem (void);
|
||||||
@@ -244,6 +249,8 @@ COUNT moonIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *moon);
|
|||||||
bool matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world,
|
bool matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world,
|
||||||
BYTE planetI, BYTE moonI);
|
BYTE planetI, BYTE moonI);
|
||||||
|
|
||||||
|
DWORD GetRandomSeedForStar (const STAR_DESC *star);
|
||||||
|
|
||||||
POINT locationToDisplay (POINT pt, SIZE scaleRadius);
|
POINT locationToDisplay (POINT pt, SIZE scaleRadius);
|
||||||
POINT displayToLocation (POINT pt, SIZE scaleRadius);
|
POINT displayToLocation (POINT pt, SIZE scaleRadius);
|
||||||
POINT planetOuterLocation (COUNT planetI);
|
POINT planetOuterLocation (COUNT planetI);
|
||||||
|
|||||||
@@ -842,7 +842,7 @@ DitherMap (SBYTE *DepthArray)
|
|||||||
{
|
{
|
||||||
// Use up the random value byte by byte
|
// Use up the random value byte by byte
|
||||||
if ((i & 3) == 0)
|
if ((i & 3) == 0)
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
else
|
else
|
||||||
rand_val >>= 8;
|
rand_val >>= 8;
|
||||||
|
|
||||||
@@ -1066,7 +1066,7 @@ MakeStorms (COUNT storm_count, SBYTE *DepthArray)
|
|||||||
|
|
||||||
intersect = FALSE;
|
intersect = FALSE;
|
||||||
|
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
loword = LOWORD (rand_val);
|
loword = LOWORD (rand_val);
|
||||||
hiword = HIWORD (rand_val);
|
hiword = HIWORD (rand_val);
|
||||||
switch (HIBYTE (hiword) & 31)
|
switch (HIBYTE (hiword) & 31)
|
||||||
@@ -1094,7 +1094,7 @@ MakeStorms (COUNT storm_count, SBYTE *DepthArray)
|
|||||||
if (pstorm_r->extent.height <= 4)
|
if (pstorm_r->extent.height <= 4)
|
||||||
pstorm_r->extent.height += 4;
|
pstorm_r->extent.height += 4;
|
||||||
|
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
loword = LOWORD (rand_val);
|
loword = LOWORD (rand_val);
|
||||||
hiword = HIWORD (rand_val);
|
hiword = HIWORD (rand_val);
|
||||||
|
|
||||||
@@ -1183,7 +1183,7 @@ MakeGasGiant (COUNT num_bands, SBYTE *DepthArray, RECT *pRect, SIZE
|
|||||||
band_error = num_bands >> 1;
|
band_error = num_bands >> 1;
|
||||||
lpDst = DepthArray;
|
lpDst = DepthArray;
|
||||||
|
|
||||||
band_delta = ((LOWORD (TFB_Random ())
|
band_delta = ((LOWORD (RandomContext_Random (SysGenRNG))
|
||||||
& (NUM_BAND_COLORS - 1)) << RANGE_SHIFT)
|
& (NUM_BAND_COLORS - 1)) << RANGE_SHIFT)
|
||||||
+ (1 << (RANGE_SHIFT - 1));
|
+ (1 << (RANGE_SHIFT - 1));
|
||||||
last_y = next_y = 0;
|
last_y = next_y = 0;
|
||||||
@@ -1191,7 +1191,7 @@ MakeGasGiant (COUNT num_bands, SBYTE *DepthArray, RECT *pRect, SIZE
|
|||||||
{
|
{
|
||||||
COORD cur_y;
|
COORD cur_y;
|
||||||
|
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
loword = LOWORD (rand_val);
|
loword = LOWORD (rand_val);
|
||||||
hiword = HIWORD (rand_val);
|
hiword = HIWORD (rand_val);
|
||||||
|
|
||||||
@@ -1232,7 +1232,7 @@ MakeGasGiant (COUNT num_bands, SBYTE *DepthArray, RECT *pRect, SIZE
|
|||||||
& (((1 << RANGE_SHIFT) * NUM_BAND_COLORS) - 1);
|
& (((1 << RANGE_SHIFT) * NUM_BAND_COLORS) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeStorms (4 + (TFB_Random () & 3) + 1, DepthArray);
|
MakeStorms (4 + (RandomContext_Random (SysGenRNG) & 3) + 1, DepthArray);
|
||||||
|
|
||||||
DitherMap (DepthArray);
|
DitherMap (DepthArray);
|
||||||
}
|
}
|
||||||
@@ -1718,11 +1718,11 @@ GenerateLightMap (SBYTE *pTopo, int w, int h)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the SysGenRNG to the required state first.
|
||||||
void
|
void
|
||||||
GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
|
GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
DWORD old_seed;
|
|
||||||
const PlanetFrame *PlanDataPtr;
|
const PlanetFrame *PlanDataPtr;
|
||||||
PLANET_INFO *PlanetInfo = &pSolarSysState->SysInfo.PlanetInfo;
|
PLANET_INFO *PlanetInfo = &pSolarSysState->SysInfo.PlanetInfo;
|
||||||
COUNT i, y;
|
COUNT i, y;
|
||||||
@@ -1732,7 +1732,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
|
|||||||
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
|
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
|
||||||
BOOLEAN shielded = (pPlanetDesc->data_index & PLANET_SHIELDED) != 0;
|
BOOLEAN shielded = (pPlanetDesc->data_index & PLANET_SHIELDED) != 0;
|
||||||
|
|
||||||
old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed);
|
RandomContext_SeedRandom (SysGenRNG, pPlanetDesc->rand_seed);
|
||||||
|
|
||||||
TopoContext = CreateContext ("Plangen.TopoContext");
|
TopoContext = CreateContext ("Plangen.TopoContext");
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
@@ -1818,7 +1818,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
|
|||||||
RECT crater_r;
|
RECT crater_r;
|
||||||
UWORD loword;
|
UWORD loword;
|
||||||
|
|
||||||
loword = LOWORD (TFB_Random ());
|
loword = LOWORD (RandomContext_Random (SysGenRNG));
|
||||||
switch (HIBYTE (loword) & 31)
|
switch (HIBYTE (loword) & 31)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@@ -1841,7 +1841,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
loword = LOWORD (TFB_Random ());
|
loword = LOWORD (RandomContext_Random (SysGenRNG));
|
||||||
crater_r.extent.height = crater_r.extent.width;
|
crater_r.extent.height = crater_r.extent.width;
|
||||||
crater_r.corner.x = HIBYTE (loword)
|
crater_r.corner.x = HIBYTE (loword)
|
||||||
% (MAP_WIDTH - crater_r.extent.width);
|
% (MAP_WIDTH - crater_r.extent.width);
|
||||||
@@ -1952,7 +1952,5 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
|
|||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
DestroyContext (TopoContext);
|
DestroyContext (TopoContext);
|
||||||
|
|
||||||
TFB_SeedRandom (old_seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
#include "../colors.h"
|
#include "../colors.h"
|
||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
#include "../menustat.h"
|
#include "../menustat.h"
|
||||||
// XXX: for stuff that does not belong there
|
#include "../starmap.h"
|
||||||
#include "../encount.h"
|
|
||||||
#include "../races.h"
|
#include "../races.h"
|
||||||
#include "../gameopt.h"
|
#include "../gameopt.h"
|
||||||
#include "../gamestr.h"
|
#include "../gamestr.h"
|
||||||
|
|||||||
@@ -1300,6 +1300,8 @@ generateBioNode (SOLARSYS_STATE *system, ELEMENT *NodeElementPtr,
|
|||||||
|
|
||||||
creatureType = system->SysInfo.PlanetInfo.CurType;
|
creatureType = system->SysInfo.PlanetInfo.CurType;
|
||||||
|
|
||||||
|
// NOTE: TFB_Random() calls here are NOT part of the deterministic planet
|
||||||
|
// generation PRNG flow.
|
||||||
if (CreatureData[creatureType].Attributes & SPEED_MASK)
|
if (CreatureData[creatureType].Attributes & SPEED_MASK)
|
||||||
{
|
{
|
||||||
// Place moving creatures at a random location.
|
// Place moving creatures at a random location.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
#include "../menustat.h"
|
#include "../menustat.h"
|
||||||
// for DrawMenuStateStrings()
|
// for DrawMenuStateStrings()
|
||||||
#include "../encount.h"
|
#include "../starmap.h"
|
||||||
#include "../races.h"
|
#include "../races.h"
|
||||||
#include "../gamestr.h"
|
#include "../gamestr.h"
|
||||||
#include "../gendef.h"
|
#include "../gendef.h"
|
||||||
@@ -95,6 +95,7 @@ static FRAME SolarSysFrame;
|
|||||||
static RECT scaleRect;
|
static RECT scaleRect;
|
||||||
// system zooms in when the flagship enters this rect
|
// system zooms in when the flagship enters this rect
|
||||||
|
|
||||||
|
RandomContext *SysGenRNG;
|
||||||
|
|
||||||
#define DISPLAY_TO_LOC (DISPLAY_FACTOR >> 1)
|
#define DISPLAY_TO_LOC (DISPLAY_FACTOR >> 1)
|
||||||
|
|
||||||
@@ -211,15 +212,15 @@ playerInInnerSystem (void)
|
|||||||
return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc;
|
return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the SysGenRNG to the required state first.
|
||||||
static void
|
static void
|
||||||
GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet)
|
GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet)
|
||||||
{
|
{
|
||||||
COUNT i;
|
COUNT i;
|
||||||
COUNT facing;
|
COUNT facing;
|
||||||
PLANET_DESC *pMoonDesc;
|
PLANET_DESC *pMoonDesc;
|
||||||
DWORD old_seed;
|
|
||||||
|
|
||||||
old_seed = TFB_SeedRandom (planet->rand_seed);
|
RandomContext_SeedRandom (SysGenRNG, planet->rand_seed);
|
||||||
|
|
||||||
(*system->genFuncs->generateName) (system, planet);
|
(*system->genFuncs->generateName) (system, planet);
|
||||||
(*system->genFuncs->generateMoons) (system, planet);
|
(*system->genFuncs->generateMoons) (system, planet);
|
||||||
@@ -235,8 +236,6 @@ GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet)
|
|||||||
|
|
||||||
pMoonDesc->temp_color = planet->temp_color;
|
pMoonDesc->temp_color = planet->temp_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFB_SeedRandom (old_seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -256,6 +255,9 @@ FreeIPData (void)
|
|||||||
SpaceJunkFrame = 0;
|
SpaceJunkFrame = 0;
|
||||||
DestroyMusic (SpaceMusic);
|
DestroyMusic (SpaceMusic);
|
||||||
SpaceMusic = 0;
|
SpaceMusic = 0;
|
||||||
|
|
||||||
|
RandomContext_Delete (SysGenRNG);
|
||||||
|
SysGenRNG = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -275,6 +277,11 @@ LoadIPData (void)
|
|||||||
|
|
||||||
SpaceMusic = LoadMusic (IP_MUSIC);
|
SpaceMusic = LoadMusic (IP_MUSIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!SysGenRNG)
|
||||||
|
{
|
||||||
|
SysGenRNG = RandomContext_New ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -350,11 +357,10 @@ initSolarSysSISCharacteristics (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD
|
DWORD
|
||||||
seedRandomForSolarSys (void)
|
GetRandomSeedForStar (const STAR_DESC *star)
|
||||||
{
|
{
|
||||||
return TFB_SeedRandom (MAKE_DWORD (CurStarDescPtr->star_pt.x,
|
return MAKE_DWORD (star->star_pt.x, star->star_pt.y);
|
||||||
CurStarDescPtr->star_pt.y));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an orbital PLANET_DESC when player is in orbit
|
// Returns an orbital PLANET_DESC when player is in orbit
|
||||||
@@ -364,7 +370,6 @@ LoadSolarSys (void)
|
|||||||
COUNT i;
|
COUNT i;
|
||||||
PLANET_DESC *orbital = NULL;
|
PLANET_DESC *orbital = NULL;
|
||||||
PLANET_DESC *pCurDesc;
|
PLANET_DESC *pCurDesc;
|
||||||
DWORD old_seed;
|
|
||||||
#define NUM_TEMP_RANGES 5
|
#define NUM_TEMP_RANGES 5
|
||||||
static const Color temp_color_array[NUM_TEMP_RANGES] =
|
static const Color temp_color_array[NUM_TEMP_RANGES] =
|
||||||
{
|
{
|
||||||
@@ -375,13 +380,13 @@ LoadSolarSys (void)
|
|||||||
BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x08, 0x00), 0x75),
|
BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x08, 0x00), 0x75),
|
||||||
};
|
};
|
||||||
|
|
||||||
old_seed = seedRandomForSolarSys ();
|
RandomContext_SeedRandom (SysGenRNG, GetRandomSeedForStar (CurStarDescPtr));
|
||||||
|
|
||||||
SunFrame = SetAbsFrameIndex (SunFrame, STAR_TYPE (CurStarDescPtr->Type));
|
SunFrame = SetAbsFrameIndex (SunFrame, STAR_TYPE (CurStarDescPtr->Type));
|
||||||
|
|
||||||
pCurDesc = &pSolarSysState->SunDesc[0];
|
pCurDesc = &pSolarSysState->SunDesc[0];
|
||||||
pCurDesc->pPrevDesc = 0;
|
pCurDesc->pPrevDesc = 0;
|
||||||
pCurDesc->rand_seed = TFB_Random ();
|
pCurDesc->rand_seed = RandomContext_Random (SysGenRNG);
|
||||||
|
|
||||||
pCurDesc->data_index = STAR_TYPE (CurStarDescPtr->Type);
|
pCurDesc->data_index = STAR_TYPE (CurStarDescPtr->Type);
|
||||||
pCurDesc->location.x = 0;
|
pCurDesc->location.x = 0;
|
||||||
@@ -467,9 +472,6 @@ LoadSolarSys (void)
|
|||||||
GLOBAL (ShipStamp.frame) = SetAbsFrameIndex (SISIPFrame, i - 1);
|
GLOBAL (ShipStamp.frame) = SetAbsFrameIndex (SISIPFrame, i - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore RNG state:
|
|
||||||
TFB_SeedRandom (old_seed);
|
|
||||||
|
|
||||||
return orbital;
|
return orbital;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1656,7 +1658,6 @@ CreateStarBackGround (void)
|
|||||||
COUNT i, j;
|
COUNT i, j;
|
||||||
DWORD rand_val;
|
DWORD rand_val;
|
||||||
STAMP s;
|
STAMP s;
|
||||||
DWORD old_seed;
|
|
||||||
CONTEXT oldContext;
|
CONTEXT oldContext;
|
||||||
RECT clipRect;
|
RECT clipRect;
|
||||||
FRAME frame;
|
FRAME frame;
|
||||||
@@ -1675,7 +1676,7 @@ CreateStarBackGround (void)
|
|||||||
|
|
||||||
ClearDrawable ();
|
ClearDrawable ();
|
||||||
|
|
||||||
old_seed = seedRandomForSolarSys ();
|
RandomContext_SeedRandom (SysGenRNG, GetRandomSeedForStar (CurStarDescPtr));
|
||||||
|
|
||||||
#define NUM_DIM_PIECES 8
|
#define NUM_DIM_PIECES 8
|
||||||
s.frame = SpaceJunkFrame;
|
s.frame = SpaceJunkFrame;
|
||||||
@@ -1684,7 +1685,7 @@ CreateStarBackGround (void)
|
|||||||
#define NUM_DIM_DRAWN 5
|
#define NUM_DIM_DRAWN 5
|
||||||
for (j = 0; j < NUM_DIM_DRAWN; ++j)
|
for (j = 0; j < NUM_DIM_DRAWN; ++j)
|
||||||
{
|
{
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH;
|
s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH;
|
||||||
s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT;
|
s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT;
|
||||||
|
|
||||||
@@ -1698,7 +1699,7 @@ CreateStarBackGround (void)
|
|||||||
#define NUM_BRT_DRAWN 30
|
#define NUM_BRT_DRAWN 30
|
||||||
for (j = 0; j < NUM_BRT_DRAWN; ++j)
|
for (j = 0; j < NUM_BRT_DRAWN; ++j)
|
||||||
{
|
{
|
||||||
rand_val = TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH;
|
s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH;
|
||||||
s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT;
|
s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT;
|
||||||
|
|
||||||
@@ -1707,8 +1708,6 @@ CreateStarBackGround (void)
|
|||||||
s.frame = IncFrameIndex (s.frame);
|
s.frame = IncFrameIndex (s.frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
TFB_SeedRandom (old_seed);
|
|
||||||
|
|
||||||
SetContext (oldContext);
|
SetContext (oldContext);
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
|
|||||||
@@ -43,12 +43,14 @@ typedef struct
|
|||||||
PLANET_INFO PlanetInfo;
|
PLANET_INFO PlanetInfo;
|
||||||
} SYSTEM_INFO;
|
} SYSTEM_INFO;
|
||||||
|
|
||||||
extern DWORD GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr,
|
#define GENERATE_ALL ((COUNT)~0)
|
||||||
COUNT *pwhich_deposit);
|
|
||||||
extern DWORD GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_life);
|
extern COUNT GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr,
|
||||||
|
COUNT whichDeposit);
|
||||||
|
extern COUNT GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT whichLife);
|
||||||
extern void GenerateRandomLocation (SYSTEM_INFO *);
|
extern void GenerateRandomLocation (SYSTEM_INFO *);
|
||||||
extern DWORD GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes,
|
extern COUNT GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes,
|
||||||
COUNT type, COUNT *whichNode);
|
COUNT type, COUNT whichNode);
|
||||||
|
|
||||||
#define DWARF_ELEMENT_DENSITY 1
|
#define DWARF_ELEMENT_DENSITY 1
|
||||||
#define GIANT_ELEMENT_DENSITY 3
|
#define GIANT_ELEMENT_DENSITY 3
|
||||||
@@ -56,11 +58,9 @@ extern DWORD GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes,
|
|||||||
|
|
||||||
#define MAX_ELEMENT_DENSITY ((MAX_ELEMENT_UNITS * SUPERGIANT_ELEMENT_DENSITY) << 1)
|
#define MAX_ELEMENT_DENSITY ((MAX_ELEMENT_UNITS * SUPERGIANT_ELEMENT_DENSITY) << 1)
|
||||||
|
|
||||||
extern DWORD DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr,
|
extern void DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr,
|
||||||
PLANET_DESC *pPlanetDesc);
|
PLANET_DESC *pPlanetDesc);
|
||||||
|
|
||||||
extern SYSTEM_INFO CurSysInfo;
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+38
-120
@@ -41,16 +41,16 @@ CalcMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT which_deposit)
|
|||||||
{
|
{
|
||||||
BYTE num_possible;
|
BYTE num_possible;
|
||||||
|
|
||||||
num_possible = (BYTE)((BYTE)TFB_Random ()
|
num_possible = LOBYTE (RandomContext_Random (SysGenRNG))
|
||||||
% (DEPOSIT_QUANTITY (eptr->Density) + 1));
|
% (DEPOSIT_QUANTITY (eptr->Density) + 1);
|
||||||
while (num_possible--)
|
while (num_possible--)
|
||||||
{
|
{
|
||||||
#define MEDIUM_DEPOSIT_THRESHOLD 150
|
#define MEDIUM_DEPOSIT_THRESHOLD 150
|
||||||
#define LARGE_DEPOSIT_THRESHOLD 225
|
#define LARGE_DEPOSIT_THRESHOLD 225
|
||||||
COUNT deposit_quality_fine,
|
COUNT deposit_quality_fine;
|
||||||
deposit_quality_gross;
|
COUNT deposit_quality_gross;
|
||||||
|
|
||||||
deposit_quality_fine = ((COUNT)TFB_Random () % 100)
|
deposit_quality_fine = (LOWORD (RandomContext_Random (SysGenRNG)) % 100)
|
||||||
+ (
|
+ (
|
||||||
DEPOSIT_QUALITY (eptr->Density)
|
DEPOSIT_QUALITY (eptr->Density)
|
||||||
+ SysInfoPtr->StarSize
|
+ SysInfoPtr->StarSize
|
||||||
@@ -85,14 +85,16 @@ ExitCalcMinerals:
|
|||||||
return (num_deposits);
|
return (num_deposits);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD
|
// Returns:
|
||||||
GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_deposit)
|
// for whichLife==~0 : the number of nodes generated
|
||||||
|
// for whichLife<32 : the index of the last node (no known usage exists)
|
||||||
|
// Sets the SysGenRNG to the required state first.
|
||||||
|
COUNT
|
||||||
|
GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT whichDeposit)
|
||||||
{
|
{
|
||||||
DWORD old_rand;
|
RandomContext_SeedRandom (SysGenRNG,
|
||||||
|
SysInfoPtr->PlanetInfo.ScanSeed[MINERAL_SCAN]);
|
||||||
old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[MINERAL_SCAN]);
|
return CalcMineralDeposits (SysInfoPtr, whichDeposit);
|
||||||
*pwhich_deposit = CalcMineralDeposits (SysInfoPtr, *pwhich_deposit);
|
|
||||||
return (TFB_SeedRandom (old_rand));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static COUNT
|
static COUNT
|
||||||
@@ -101,114 +103,28 @@ CalcLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT which_life)
|
|||||||
COUNT num_life_forms;
|
COUNT num_life_forms;
|
||||||
|
|
||||||
num_life_forms = 0;
|
num_life_forms = 0;
|
||||||
if (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type) == GAS_GIANT)
|
if (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type) != GAS_GIANT)
|
||||||
SysInfoPtr->PlanetInfo.LifeChance = -1;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
#define MIN_LIFE_CHANCE 10
|
#define MIN_LIFE_CHANCE 10
|
||||||
SIZE life_var;
|
SIZE life_var;
|
||||||
|
|
||||||
life_var = 0;
|
life_var = RandomContext_Random (SysGenRNG) & 1023;
|
||||||
|
|
||||||
if (SysInfoPtr->PlanetInfo.SurfaceTemperature < -151)
|
|
||||||
life_var -= 300;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < -51)
|
|
||||||
life_var -= 100;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 0)
|
|
||||||
life_var += 100;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 50)
|
|
||||||
life_var += 300;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 150)
|
|
||||||
life_var += 50;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 250)
|
|
||||||
life_var -= 100;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 500)
|
|
||||||
life_var -= 400;
|
|
||||||
else
|
|
||||||
life_var -= 800;
|
|
||||||
|
|
||||||
if (SysInfoPtr->PlanetInfo.AtmoDensity == 0)
|
|
||||||
life_var -= 1000;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < 15)
|
|
||||||
life_var += 100;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < 30)
|
|
||||||
life_var += 200;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < 100)
|
|
||||||
life_var += 300;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < 1000)
|
|
||||||
life_var += 150;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < 2500)
|
|
||||||
;
|
|
||||||
else
|
|
||||||
life_var -= 100;
|
|
||||||
|
|
||||||
#ifndef NOTYET
|
|
||||||
life_var += 200 + 80 + 80;
|
|
||||||
#else /* NOTYET */
|
|
||||||
if (SysInfoPtr->PlanetInfo.SurfaceGravity < 10)
|
|
||||||
;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 35)
|
|
||||||
life_var += 50;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 75)
|
|
||||||
life_var += 100;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 150)
|
|
||||||
life_var += 200;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 400)
|
|
||||||
life_var += 50;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 800)
|
|
||||||
;
|
|
||||||
else
|
|
||||||
life_var -= 100;
|
|
||||||
|
|
||||||
if (SysInfoPtr->PlanetInfo.Tectonics < 1)
|
|
||||||
life_var += 80;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Tectonics < 2)
|
|
||||||
life_var += 70;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Tectonics < 3)
|
|
||||||
life_var += 60;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Tectonics < 4)
|
|
||||||
life_var += 50;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Tectonics < 5)
|
|
||||||
life_var += 25;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Tectonics < 6)
|
|
||||||
;
|
|
||||||
else
|
|
||||||
life_var -= 100;
|
|
||||||
|
|
||||||
if (SysInfoPtr->PlanetInfo.Weather < 1)
|
|
||||||
life_var += 80;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Weather < 2)
|
|
||||||
life_var += 70;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Weather < 3)
|
|
||||||
life_var += 60;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Weather < 4)
|
|
||||||
life_var += 50;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Weather < 5)
|
|
||||||
life_var += 25;
|
|
||||||
else if (SysInfoPtr->PlanetInfo.Weather < 6)
|
|
||||||
;
|
|
||||||
else
|
|
||||||
life_var -= 100;
|
|
||||||
#endif /* NOTYET */
|
|
||||||
|
|
||||||
SysInfoPtr->PlanetInfo.LifeChance = life_var;
|
|
||||||
|
|
||||||
life_var = (COUNT)TFB_Random () & 1023;
|
|
||||||
if (life_var < SysInfoPtr->PlanetInfo.LifeChance
|
if (life_var < SysInfoPtr->PlanetInfo.LifeChance
|
||||||
|| (SysInfoPtr->PlanetInfo.LifeChance < MIN_LIFE_CHANCE
|
|| (SysInfoPtr->PlanetInfo.LifeChance < MIN_LIFE_CHANCE
|
||||||
&& life_var < MIN_LIFE_CHANCE))
|
&& life_var < MIN_LIFE_CHANCE))
|
||||||
{
|
{
|
||||||
BYTE num_types;
|
BYTE num_types;
|
||||||
|
|
||||||
num_types = (BYTE)(((BYTE)TFB_Random () % MAX_LIFE_VARIATION) + 1);
|
num_types = 1 + LOBYTE (RandomContext_Random (SysGenRNG))
|
||||||
|
% MAX_LIFE_VARIATION;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
BYTE index, num_creatures;
|
BYTE index, num_creatures;
|
||||||
UWORD rand_val;
|
UWORD rand_val;
|
||||||
|
|
||||||
rand_val = (UWORD)TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
index = LOBYTE (rand_val) % NUM_CREATURE_TYPES;
|
index = LOBYTE (rand_val) % NUM_CREATURE_TYPES;
|
||||||
num_creatures = (BYTE)((HIBYTE (rand_val) % 10) + 1);
|
num_creatures = 1 + HIBYTE (rand_val) % 10;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GenerateRandomLocation (SysInfoPtr);
|
GenerateRandomLocation (SysInfoPtr);
|
||||||
@@ -233,15 +149,16 @@ CalcLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT which_life)
|
|||||||
return (num_life_forms);
|
return (num_life_forms);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD
|
// Returns:
|
||||||
GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_life)
|
// for whichLife==~0 : the number of lifeforms generated
|
||||||
|
// for whichLife<32 : the index of the last lifeform (no known usage exists)
|
||||||
|
// Sets the SysGenRNG to the required state first.
|
||||||
|
COUNT
|
||||||
|
GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT whichLife)
|
||||||
{
|
{
|
||||||
DWORD old_rand;
|
RandomContext_SeedRandom (SysGenRNG,
|
||||||
|
|
||||||
old_rand = TFB_SeedRandom (
|
|
||||||
SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
|
SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
|
||||||
*pwhich_life = CalcLifeForms (SysInfoPtr, *pwhich_life);
|
return CalcLifeForms (SysInfoPtr, whichLife);
|
||||||
return (TFB_SeedRandom (old_rand));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -249,21 +166,24 @@ GenerateRandomLocation (SYSTEM_INFO *SysInfoPtr)
|
|||||||
{
|
{
|
||||||
UWORD rand_val;
|
UWORD rand_val;
|
||||||
|
|
||||||
rand_val = (UWORD)TFB_Random ();
|
rand_val = RandomContext_Random (SysGenRNG);
|
||||||
SysInfoPtr->PlanetInfo.CurPt.x =
|
SysInfoPtr->PlanetInfo.CurPt.x =
|
||||||
(LOBYTE (rand_val) % (MAP_WIDTH - (8 << 1))) + 8;
|
(LOBYTE (rand_val) % (MAP_WIDTH - (8 << 1))) + 8;
|
||||||
SysInfoPtr->PlanetInfo.CurPt.y =
|
SysInfoPtr->PlanetInfo.CurPt.y =
|
||||||
(HIBYTE (rand_val) % (MAP_HEIGHT - (8 << 1))) + 8;
|
(HIBYTE (rand_val) % (MAP_HEIGHT - (8 << 1))) + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD
|
// Returns:
|
||||||
|
// for whichNode==~0 : the number of nodes generated
|
||||||
|
// for whichNode<32 : the index of the last node (no known usage exists)
|
||||||
|
// Sets the SysGenRNG to the required state first.
|
||||||
|
COUNT
|
||||||
GenerateRandomNodes (SYSTEM_INFO *SysInfoPtr, COUNT scan, COUNT numNodes,
|
GenerateRandomNodes (SYSTEM_INFO *SysInfoPtr, COUNT scan, COUNT numNodes,
|
||||||
COUNT type, COUNT *whichNode)
|
COUNT type, COUNT whichNode)
|
||||||
{
|
{
|
||||||
DWORD old_rand;
|
|
||||||
COUNT i;
|
COUNT i;
|
||||||
|
|
||||||
old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[scan]);
|
RandomContext_SeedRandom (SysGenRNG, SysInfoPtr->PlanetInfo.ScanSeed[scan]);
|
||||||
|
|
||||||
for (i = 0; i < numNodes; ++i)
|
for (i = 0; i < numNodes; ++i)
|
||||||
{
|
{
|
||||||
@@ -273,11 +193,9 @@ GenerateRandomNodes (SYSTEM_INFO *SysInfoPtr, COUNT scan, COUNT numNodes,
|
|||||||
// CurDensity is irrelevant for energy and bio nodes
|
// CurDensity is irrelevant for energy and bio nodes
|
||||||
SysInfoPtr->PlanetInfo.CurDensity = 0;
|
SysInfoPtr->PlanetInfo.CurDensity = 0;
|
||||||
|
|
||||||
if (i >= *whichNode)
|
if (i >= whichNode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*whichNode = i; // only matters when count is requested
|
return i;
|
||||||
|
|
||||||
return (TFB_SeedRandom (old_rand));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "credits.h"
|
#include "credits.h"
|
||||||
// XXX: for star_array[]
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
|
||||||
#include "fmv.h"
|
#include "fmv.h"
|
||||||
#include "menustat.h"
|
#include "menustat.h"
|
||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
|
|||||||
+1
-2
@@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "races.h"
|
#include "races.h"
|
||||||
// XXX: including encount.h for stuff that does not belong there
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "menustat.h"
|
#include "menustat.h"
|
||||||
// for DrawMenuStateStrings()
|
// for DrawMenuStateStrings()
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
// XXX: for CurStarDescPtr
|
#include "starmap.h"
|
||||||
#include "encount.h"
|
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
#include "load.h"
|
#include "load.h"
|
||||||
|
|||||||
@@ -16,10 +16,9 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "encount.h"
|
#include "starmap.h"
|
||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "libs/compiler.h"
|
|
||||||
#include "libs/gfxlib.h"
|
#include "libs/gfxlib.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STARMAP_H_INCL_
|
||||||
|
#define STARMAP_H_INCL_
|
||||||
|
|
||||||
|
#include "libs/compiler.h"
|
||||||
|
#include "planets/planets.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern STAR_DESC *CurStarDescPtr;
|
||||||
|
extern STAR_DESC *star_array;
|
||||||
|
|
||||||
|
#define NUM_SOLAR_SYSTEMS 502
|
||||||
|
|
||||||
|
extern STAR_DESC* FindStar (STAR_DESC *pLastStar, POINT *puniverse,
|
||||||
|
SIZE xbounds, SIZE ybounds);
|
||||||
|
|
||||||
|
extern void GetClusterName (const STAR_DESC *pSD, UNICODE buf[]);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STARMAP_H_INCL_ */
|
||||||
|
|
||||||
+2
-1
@@ -18,12 +18,13 @@
|
|||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
#include "encount.h"
|
#include "starmap.h"
|
||||||
#include "libs/memlib.h"
|
#include "libs/memlib.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
// in-memory file i/o
|
// in-memory file i/o
|
||||||
struct GAME_STATE_FILE
|
struct GAME_STATE_FILE
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "encount.h"
|
#include "starmap.h"
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "sis.h"
|
#include "sis.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
@@ -627,15 +627,14 @@ starRecurse (STAR_DESC *star, void *arg)
|
|||||||
|
|
||||||
SOLARSYS_STATE SolarSysState;
|
SOLARSYS_STATE SolarSysState;
|
||||||
SOLARSYS_STATE *oldPSolarSysState = pSolarSysState;
|
SOLARSYS_STATE *oldPSolarSysState = pSolarSysState;
|
||||||
DWORD oldSeed =
|
|
||||||
TFB_SeedRandom (MAKE_DWORD (star->star_pt.x, star->star_pt.y));
|
|
||||||
|
|
||||||
STAR_DESC *oldStarDescPtr = CurStarDescPtr;
|
STAR_DESC *oldStarDescPtr = CurStarDescPtr;
|
||||||
CurStarDescPtr = star;
|
CurStarDescPtr = star;
|
||||||
|
|
||||||
|
RandomContext_SeedRandom (SysGenRNG, GetRandomSeedForStar (star));
|
||||||
|
|
||||||
memset (&SolarSysState, 0, sizeof (SolarSysState));
|
memset (&SolarSysState, 0, sizeof (SolarSysState));
|
||||||
SolarSysState.SunDesc[0].pPrevDesc = 0;
|
SolarSysState.SunDesc[0].pPrevDesc = 0;
|
||||||
SolarSysState.SunDesc[0].rand_seed = TFB_Random ();
|
SolarSysState.SunDesc[0].rand_seed = RandomContext_Random (SysGenRNG);
|
||||||
SolarSysState.SunDesc[0].data_index = STAR_TYPE (star->Type);
|
SolarSysState.SunDesc[0].data_index = STAR_TYPE (star->Type);
|
||||||
SolarSysState.SunDesc[0].location.x = 0;
|
SolarSysState.SunDesc[0].location.x = 0;
|
||||||
SolarSysState.SunDesc[0].location.y = 0;
|
SolarSysState.SunDesc[0].location.y = 0;
|
||||||
@@ -667,7 +666,6 @@ starRecurse (STAR_DESC *star, void *arg)
|
|||||||
|
|
||||||
pSolarSysState = oldPSolarSysState;
|
pSolarSysState = oldPSolarSysState;
|
||||||
CurStarDescPtr = oldStarDescPtr;
|
CurStarDescPtr = oldStarDescPtr;
|
||||||
TFB_SeedRandom (oldSeed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -695,14 +693,12 @@ planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
|
|||||||
|
|
||||||
if (universeRecurseArg->moonFunc != NULL)
|
if (universeRecurseArg->moonFunc != NULL)
|
||||||
{
|
{
|
||||||
DWORD oldSeed = TFB_SeedRandom (planet->rand_seed);
|
RandomContext_SeedRandom (SysGenRNG, planet->rand_seed);
|
||||||
|
|
||||||
(*system->genFuncs->generateMoons) (system, planet);
|
(*system->genFuncs->generateMoons) (system, planet);
|
||||||
|
|
||||||
forAllMoons (star, system, planet, moonRecurse,
|
forAllMoons (star, system, planet, moonRecurse,
|
||||||
(void *) universeRecurseArg);
|
(void *) universeRecurseArg);
|
||||||
|
|
||||||
TFB_SeedRandom (oldSeed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (universeRecurseArg->planetFuncPost != NULL)
|
if (universeRecurseArg->planetFuncPost != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user