Refactoring the universe generation code.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3334 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2009-11-21 21:04:45 +00:00
parent 7d3e5b3511
commit 76d4261313
77 changed files with 6520 additions and 5236 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.7:
- Refactored universe generation - SvdB
- Comm animation processing rewrite, bugs fixed - Alex
- Added graphics context debugging function - SvdB
- Thread down-throttling and game sleep when inactive (currently disabled),
+27
View File
@@ -1,3 +1,30 @@
Note: this file (still) describes the way in which various things were
generated in the original source. It is still useful, but there are some
changes:
- all of this functionality used to be handled through a single function,
either the function returned by GenerateIP(), or GenerateRandomIP().
Now, there is a structure GenerateFunctions, which contains a function
for each of the type of generation. See generate.h.
- most functions don't use the global variables pSolarSysState, pOrbitalDesc,
and pPlanetDesc anymore. Instead, where these are needed, they are passed
along through a parameter.
Files related to this system:
- planets/generate.h
Defines GenerateFunctions.
- planets/generate/gendefault.c
Default generation functions for when no specific one is specified.
- planets/generate/gen*.c
Specific generation functions.
- gendef.c
Glue code.
This file should eventually be updated to reflect the new system.
See the file 'orggenerate' for a description on how the system originally
worked.
============================================================================
The various universe related game data is generated through a call
to a solar system dependant generation function.
This function is of type PLAN_GEN_FUNC, which is a typedef to
+133
View File
@@ -0,0 +1,133 @@
Note: this file describes the way in which various things were generated
in the original source. See the file 'generate' for the current system.
============================================================================
The various universe related game data is generated through a call
to a solar system dependant generation function.
This function is of type PLAN_GEN_FUNC, which is a typedef to
void (*PLAN_GEN_FUNC) (BYTE control)
, where the 'control' argument specifies what type of data needs to be
generated (one of GENERATE_PLANETS, GENERATE_MOONS, GENERATE_ORBITAL,
INIT_NPCS, REINIT_NPCS, UNINIT_NPCS, GENERATE_MINERAL, GENERATE_ENERGY,
GENERATE_LIFE, or GENERATE_NAME).
The generation function for a solar system is kept in the 'GenFunc'
field of the SOLARSYS_STATE structure.
The SOLARSYS_STATE structure contains the data for a solar system.
Currently, only one SOLARSYS_STATE structure is used at once, and
the global variable pSolarSysState points to the current one.
The GenFunc field is initialised in ExploreSolarSys(), to the value
returned by GenerateIP() in sc2code/gendef.c. Usually, this will be
'GenerateRandomIP', but for some specific solar systems a (pointer to a)
custom generation function is returned. This depends on the value of
CurStarDescPtr->Index, which contains values such as SOL_DEFINED,
MELNORME0_DEFINED, AQUA_HELIX_DEFINED, etc (see sc2code/encount.h
for the complete list).
The starmap_array in sc2code/plandata.c specifies Index for all
the solar systems in the game.
Following are the possible values of the 'control' argument to the
generation function, with the description of how the generation function
acts on this. As the custom generation functions often only need to
change one specific aspect of this game data generation, they will
often call GenerateRandomIP() for the rest.
StarBases are handled as if they were moons.
GENERATE_PLANETS
Pre: the global variable pSolarSysState points to the relevant solar system.
Pre: the RNG is initialised with a seed to be used for the generation.
In practice, this seed is generated from the HyperSpace coordinates
of the solar system (which are hardcoded in sc2code/plandata.c),
followed by exactly one call to TFB_Random().
Post: the RNG is in an undefined state.
This function determines how many planets the system has, and fills in
pSolarSysState->PlanetDesc[] for all planets, including the NumPlanets
field, which determines how many moons the planet will have.
It also sets the random seed that is used for data generated for this planet
(including the number of moons), based on its coordinates (which are in the
general case randomly determined themselves).
GENERATE_MOONS
Pre: the global variable pSolarSysState points to the relevant solar system,
which is initialised by a GENERATE_PLANETS call.
Pre: the RNG is initialised with a seed to be used for the generation.
In practice, this seed is the seed stored by GENERATE_PLANETS
in the rand_seed field for the planet around which the moon(s) orbit.
Pre: pSolarSysState->pBaseDesc points to the the relevant planet
of pSolarSysState->PlanetDesc[].
Post: The RNG is in an undefined state.
This function fills in pSolarSysState->MoonDesc[] for all moons around
the planet pointed to by pSolarSysState->pBaseDesc.
It also sets the random seed that is used for data generated for the moon
based on its coordinates (which are in the general case randomly determined
themselves).
GENERATE_ORBITAL
Pre: the global variable pSolarSysState points to the relevant solar system,
which is initialised by a GENERATE_PLANETS call.
Pre: pSolarSysState->pOrbitalDesc points to the relevant planet or moon from
pSolarSysState->PlanetDesc[] or pSolarSysState->moonDesc[]
Pre: the planet or moon that pSolarSysState->pOrbitalDesc points to
is initialised by a GENERATE_PLANETS or GENERATE_MOONS call.
This function fills in pSolarSysState->SysInfo with the characteristics
of the planet or moon, as seen from orbit.
It also initialises the random seeds used for the generation of bio,
minerals, and energy nodes on the surface.
It also sets the discovery report string (if appropriate), initialises
the surface graphics, and start the planet music.
For specific planets, it may initiate race communication and possibly combat,
and will only return once these are over.
NB. The GENERATE_ORBITAL code should be split up into separate calculation
and activation (graphics and music) parts.
GENERATE_MINERAL, GENERATE_ENERGY, GENERATE_LIFE
Pre: the global variable pSolarSysState points to the relevant solar system,
which is initialised by a GENERATE_PLANETS call.
Pre: pSolarSysState->pOrbitalDesc points to the relevant planet or moon from
pSolarSysState->PlanetDesc[] or pSolarSysState->moonDesc[]
Pre: the planet or moon that pSolarSysState->pOrbitalDesc points to
is initialised by a GENERATE_PLANETS or GENERATE_MOONS call.
Pre: pSolarSysState->SysInfo is filled in by a GENERATE_ORBITAL call
This function determines the properties of one mineral deposit, energy node,
or life form on a planet or moon. On entry the caller sets
pSolarSysState->CurNode to the index of the requested item. This function
will then fill in pSolarSysState->SysInfo.PlanetInfo.CurPt,
pSolarSysState->SysInfo.PlanetInfo.CurType, and in the case of minerals also
pSolarSysState->SysInfo.PlanetInfo.CurDensity.
In case pSolarSysState->CurNode is set to a value larger than or equal to
the number of items of the requested kind ((COUNT) ~0 in practice), it is
set to the real number of nodes. In this case the CurXXX fields of
pSolarSysState->SysInfo.PlanetInfo are set to the values corresponding to
the largest valid CurNode index, but should probably be considered to be
undefined.
These functions may also change the game state, cause the lander
to take off (by setting InTransit to true in the active PLANETSIDE_DESC
structure), or mark an energy node as not retrieved, usually in response
to an item having been picked up since the last call. The game makes
a GENERATE_MINERAL, GENERATE_ENERGY or GENERATE_LIFE call (whatever
is relevant) for each item right after it is picked up.
GENERATE_NAME
Pre: pSolarSysState is set to the relevant solar system.
Pre: The planet is initialised by GENERATE_PLANETS.
Pre: pSolarSysState->pBaseDesc points to the relevant planet, which should
be in the system.
This function fills GLOBAL_SIS (PlanetName) with the name of the planet
pointed to by pSolarSysState->pBaseDesc.
It also sets the GAME_STATE flag BATTLE_PLANET to the type of this planet,
so that it will be shown appropriately in melee if combat follows.
There is no generate function for the names of moons. The few moons that
are named (those in the Sol system), are handled as a special case of
the routines that prints these names (PrintCoarseScan3DO and
PrintCoraseScanPC).
INIT_NPCS
REINIT_NPCS
UNINIT_NPCS
[TODO]
Initial version of this document created by Serge van den Boom, on 2005-07-11.
+7 -4
View File
@@ -19,6 +19,9 @@
#ifndef _ENCOUNT_H
#define _ENCOUNT_H
typedef struct brief_ship_info BRIEF_SHIP_INFO;
typedef struct encounter ENCOUNTER;
// XXX: temporary, for CONVERSATION
#include "commglue.h"
#include "displist.h"
@@ -33,7 +36,7 @@ typedef HLINK HENCOUNTER;
#define ONE_SHOT_ENCOUNTER (1 << 7)
#define ENCOUNTER_REFORMING (1 << 6)
typedef struct
struct brief_ship_info
{
// The only field actually used right now is crew_level
BYTE race_id;
@@ -41,9 +44,9 @@ typedef struct
COUNT max_crew;
BYTE max_energy;
} BRIEF_SHIP_INFO;
};
typedef struct
struct encounter
{
// LINK elements; must be first
HENCOUNTER pred, succ;
@@ -58,7 +61,7 @@ typedef struct
BRIEF_SHIP_INFO ShipList[MAX_HYPER_SHIPS];
SDWORD log_x, log_y;
} ENCOUNTER;
};
#define AllocEncounter() AllocLink (&GLOBAL (encounter_q))
#define PutEncounter(h) PutQueue (&GLOBAL (encounter_q), h)
+65 -59
View File
@@ -17,26 +17,54 @@
*/
#include "encount.h"
#include "planets/generate.h"
PLAN_GEN_FUNC
GenerateIP (BYTE Index)
extern GenerateFunctions generateDefaultFunctions;
extern GenerateFunctions generateAndrosynthFunctions;
extern GenerateFunctions generateBurvixeseFunctions;
extern GenerateFunctions generateChmmrFunctions;
extern GenerateFunctions generateColonyFunctions;
extern GenerateFunctions generateDruugeFunctions;
extern GenerateFunctions generateIlwrathFunctions;
extern GenerateFunctions generateMelnormeFunctions;
extern GenerateFunctions generateMyconFunctions;
extern GenerateFunctions generateOrzFunctions;
extern GenerateFunctions generatePkunkFunctions;
extern GenerateFunctions generateRainbowWorldFunctions;
extern GenerateFunctions generateSaMatraFunctions;
extern GenerateFunctions generateShofixtiFunctions;
extern GenerateFunctions generateSlylandroFunctions;
extern GenerateFunctions generateSolFunctions;
extern GenerateFunctions generateSpathiFunctions;
extern GenerateFunctions generateSupoxFunctions;
extern GenerateFunctions generateSyreenFunctions;
extern GenerateFunctions generateTalkingPetFunctions;
extern GenerateFunctions generateThraddashFunctions;
extern GenerateFunctions generateTrapFunctions;
extern GenerateFunctions generateUtwigFunctions;
extern GenerateFunctions generateVaultFunctions;
extern GenerateFunctions generateVuxFunctions;
extern GenerateFunctions generateWreckFunctions;
extern GenerateFunctions generateYehatFunctions;
extern GenerateFunctions generateZoqFotPikFunctions;
extern GenerateFunctions generateZoqFotPikScoutFunctions;
const GenerateFunctions *
getGenerateFunctions (BYTE Index)
{
PLAN_GEN_FUNC GenFunc;
switch (Index)
{
case SOL_DEFINED:
GenFunc = GenerateSOL;
break;
return &generateSolFunctions;
case SHOFIXTI_DEFINED:
GenFunc = GenerateShofixti;
break;
return &generateShofixtiFunctions;
case START_COLONY_DEFINED:
GenFunc = GenerateColony;
break;
return &generateColonyFunctions;
case SPATHI_DEFINED:
GenFunc = GenerateSpathi;
break;
return &generateSpathiFunctions;
case MELNORME0_DEFINED:
case MELNORME1_DEFINED:
case MELNORME2_DEFINED:
@@ -46,86 +74,64 @@ GenerateIP (BYTE Index)
case MELNORME6_DEFINED:
case MELNORME7_DEFINED:
case MELNORME8_DEFINED:
GenFunc = GenerateMelnorme;
break;
return &generateMelnormeFunctions;
case TALKING_PET_DEFINED:
GenFunc = GenerateTalkingPet;
break;
return &generateTalkingPetFunctions;
case CHMMR_DEFINED:
GenFunc = GenerateChmmr;
break;
return &generateChmmrFunctions;
case SYREEN_DEFINED:
return &generateSyreenFunctions;
case MYCON_TRAP_DEFINED:
GenFunc = GenerateSyreen;
break;
return &generateTrapFunctions;
case BURVIXESE_DEFINED:
GenFunc = GenerateBurvixes;
break;
return &generateBurvixeseFunctions;
case SLYLANDRO_DEFINED:
GenFunc = GenerateSlylandro;
break;
return &generateSlylandroFunctions;
case DRUUGE_DEFINED:
GenFunc = GenerateDruuge;
break;
return &generateDruugeFunctions;
case BOMB_DEFINED:
case UTWIG_DEFINED:
GenFunc = GenerateUtwig;
break;
return &generateUtwigFunctions;
case AQUA_HELIX_DEFINED:
case THRADD_DEFINED:
GenFunc = GenerateThradd;
break;
return &generateThraddashFunctions;
case SUN_DEVICE_DEFINED:
case MYCON_DEFINED:
case EGG_CASE0_DEFINED:
case EGG_CASE1_DEFINED:
case EGG_CASE2_DEFINED:
GenFunc = GenerateMycon;
break;
return &generateMyconFunctions;
case ANDROSYNTH_DEFINED:
return &generateAndrosynthFunctions;
case TAALO_PROTECTOR_DEFINED:
case ORZ_DEFINED:
GenFunc = GenerateOrz;
break;
return &generateOrzFunctions;
case SHIP_VAULT_DEFINED:
GenFunc = GenerateShipVault;
break;
return &generateVaultFunctions;
case URQUAN_WRECK_DEFINED:
GenFunc = GenerateUrquanWreck;
break;
return &generateWreckFunctions;
case MAIDENS_DEFINED:
case VUX_BEAST_DEFINED:
case VUX_DEFINED:
GenFunc = GenerateVUX;
break;
return &generateVuxFunctions;
case SAMATRA_DEFINED:
GenFunc = GenerateSamatra;
break;
return &generateSaMatraFunctions;
case ZOQFOT_DEFINED:
return &generateZoqFotPikFunctions;
case ZOQ_SCOUT_DEFINED:
GenFunc = GenerateZoqFotPik;
break;
return &generateZoqFotPikScoutFunctions;
case YEHAT_DEFINED:
GenFunc = GenerateYehat;
break;
return &generateYehatFunctions;
case PKUNK_DEFINED:
GenFunc = GeneratePkunk;
break;
return &generatePkunkFunctions;
case SUPOX_DEFINED:
GenFunc = GenerateSupox;
break;
return &generateSupoxFunctions;
case RAINBOW_DEFINED:
GenFunc = GenerateRainbow;
break;
return &generateRainbowWorldFunctions;
case ILWRATH_DEFINED:
GenFunc = GenerateIlwrath;
break;
return &generateIlwrathFunctions;
default:
GenFunc = GenerateRandomIP;
break;
return &generateDefaultFunctions;
}
return (GenFunc);
}
+10
View File
@@ -0,0 +1,10 @@
#ifndef GENDEF_H
#define GENDEF_H
#include "planets/generate.h"
#include "libs/compiler.h"
const GenerateFunctions *getGenerateFunctions (BYTE Index);
#endif /* GENDEF_H */
+2 -1
View File
@@ -568,7 +568,8 @@ LoadGame (COUNT which_game, SUMMARY_DESC *SummPtr)
LoadRaceQueue (fh, &GLOBAL (avail_race_q));
// START_INTERPLANETARY is only set when saving from Homeworld
// encounter screen. When the game is loaded, GENERATE_ORBITAL will
// encounter screen. When the game is loaded, the
// GenerateOrbitalFunction for the current star system will
// create the encounter anew and populate the npc queue.
if (!(NextActivity & START_INTERPLANETARY))
{
+2
View File
@@ -852,6 +852,8 @@ InitMelee (MELEE_STATE *pMS)
r.corner.x = r.corner.y = 0;
RedrawMeleeFrame ();
(void) pMS;
}
static void
+3 -6
View File
@@ -1,7 +1,4 @@
uqm_CFILES="calc.c cargo.c devices.c genburv.c genchmmr.c gencol.c
gendru.c genilw.c genmel.c genmyc.c genorz.c genpet.c genpku.c
genrain.c gensam.c genshof.c gensly.c gensol.c genspa.c gensup.c
gensyr.c genthrad.c gentopo.c genutw.c genvault.c genvux.c
genwreck.c genyeh.c genzoq.c lander.c orbits.c oval.c pl_stuff.c
planets.c plangen.c pstarmap.c report.c
uqm_SUBDIRS="generate"
uqm_CFILES="calc.c cargo.c devices.c gentopo.c lander.c orbits.c
oval.c pl_stuff.c planets.c plangen.c pstarmap.c report.c
roster.c scan.c solarsys.c surface.c"
-183
View File
@@ -1,183 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "libs/mathlib.h"
void
GenerateBurvixes (BYTE control)
{
COUNT i;
DWORD rand_val;
switch (control)
{
case GENERATE_ENERGY:
{
DWORD rand_val, old_rand;
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT which_node;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]
&& !GET_GAME_STATE (BURVIXESE_BROADCASTERS))
{
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1);
SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
}
case GENERATE_MOONS:
GenerateRandomIP (GENERATE_MOONS);
if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT angle;
pSolarSysState->MoonDesc[0].data_index = SELENIC_WORLD;
pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS
+ (MAX_MOONS - 1) * MOON_DELTA;
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
pSolarSysState->MoonDesc[0].location.x =
COSINE (angle, pSolarSysState->MoonDesc[0].radius);
pSolarSysState->MoonDesc[0].location.y =
SINE (angle, pSolarSysState->MoonDesc[0].radius);
}
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = REDUX_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 39L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
{
rand_val = DoPlanetaryAnalysis (
&pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc
);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateLifeForms (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
GenerateMineralDeposits (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (BURV_RUINS_STRTAB));
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
}
else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]
&& !GET_GAME_STATE (BURVIXESE_BROADCASTERS))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (BURV_BCS_MASK_PMAP_ANIM));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (BURV_BCS_STRTAB));
}
LoadPlanet (NULL);
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-142
View File
@@ -1,142 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "../build.h"
#include "../encount.h"
#include "../setup.h"
#include "../state.h"
#include "../sounds.h"
#include "libs/mathlib.h"
void
GenerateChmmr (BYTE control)
{
switch (control)
{
case GENERATE_MOONS:
GenerateRandomIP (GENERATE_MOONS);
if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[1])
{
COUNT angle;
DWORD rand_val;
pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE;
pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS;
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
pSolarSysState->MoonDesc[0].location.x =
COSINE (angle, pSolarSysState->MoonDesc[0].radius);
pSolarSysState->MoonDesc[0].location.y =
SINE (angle, pSolarSysState->MoonDesc[0].radius);
}
break;
case GENERATE_PLANETS:
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[1].data_index = SAPPHIRE_WORLD;
if (!GET_GAME_STATE (CHMMR_UNLEASHED))
pSolarSysState->PlanetDesc[1].data_index |= PLANET_SHIELDED;
pSolarSysState->PlanetDesc[1].NumPlanets = 1;
break;
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1])
{
if (GET_GAME_STATE (CHMMR_UNLEASHED))
{
pSolarSysState->MenuState.Initialized += 2;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (CHMMR_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
{
GLOBAL (CurrentActivity) |= END_INTERPLANETARY;
}
break;
}
else if (GET_GAME_STATE (SUN_DEVICE_ON_SHIP)
&& !GET_GAME_STATE (ILWRATH_DECEIVED)
&& ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING))
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (ILWRATH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (ILWRATH_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
}
/* Starbase */
else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[1]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
RECT r;
LockMutex (GraphicsLock);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (CHMMR_BASE_STRTAB));
ScanContext = CreateContext ("genchmmr.ScanContext");
SetContext (ScanContext);
SetContextFGFrame (Screen);
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
r.extent.width = MAP_WIDTH;
r.extent.height = MAP_HEIGHT;
SetContextClipRect (&r);
DoDiscoveryReport (MenuSounds);
SetContext (SpaceContext);
DestroyContext (ScanContext);
ScanContext = 0;
DestroyStringTable (ReleaseStringTable (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;
FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
UnlockMutex (GraphicsLock);
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-101
View File
@@ -1,101 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../state.h"
#include "../grpinfo.h"
void
GenerateColony (BYTE control)
{
switch (control)
{
case INIT_NPCS:
{
HIPGROUP hGroup;
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (COLONY_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (COLONY_GRPOFFS0, GLOBAL (BattleGroupRef));
}
GenerateRandomIP (INIT_NPCS);
if (GLOBAL (BattleGroupRef)
&& (hGroup = GetHeadLink (&GLOBAL (ip_group_q))))
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
GroupPtr->task = IN_ORBIT;
GroupPtr->sys_loc = 0 + 1; /* orbitting colony */
GroupPtr->dest_loc = 0 + 1; /* orbitting colony */
GroupPtr->loc.x = 0;
GroupPtr->loc.y = 0;
GroupPtr->group_counter = 0;
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
break;
}
case GENERATE_PLANETS:
{
COUNT angle;
PLANET_DESC *pMinPlanet;
pMinPlanet = &pSolarSysState->PlanetDesc[0];
FillOrbits (pSolarSysState, (BYTE)~0, pMinPlanet, FALSE);
pMinPlanet->radius = EARTH_RADIUS * 115L / 100;
angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y);
pMinPlanet->location.x =
COSINE (angle, pMinPlanet->radius);
pMinPlanet->location.y =
SINE (angle, pMinPlanet->radius);
pMinPlanet->data_index = WATER_WORLD | PLANET_SHIELDED;
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
DoPlanetaryAnalysis (
&pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc
);
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE * 98 / 100;
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 28;
LoadPlanet (NULL);
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-159
View File
@@ -1,159 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateDruuge (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (!GET_GAME_STATE (ROSY_SPHERE))
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
else
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!GET_GAME_STATE (ROSY_SPHERE))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (ROSY_SPHERE, 1);
SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1);
}
}
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
memmove (&pSolarSysState->PlanetDesc[1],
&pSolarSysState->PlanetDesc[0],
sizeof (pSolarSysState->PlanetDesc[0])
* pSolarSysState->SunDesc[0].NumPlanets);
++pSolarSysState->SunDesc[0].NumPlanets;
pSolarSysState->PlanetDesc[0].data_index = DUST_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 50L / 100;
pSolarSysState->PlanetDesc[0].NumPlanets = 0;
angle = HALF_CIRCLE - OCTANT;
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].rand_seed = MAKE_DWORD (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING))
{
NotifyOthers (DRUUGE_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (DRUUGE_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (DRUUGE_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (DRUUGE_RUINS_STRTAB)
);
if (GET_GAME_STATE (ROSY_SPHERE))
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
+89
View File
@@ -0,0 +1,89 @@
/*
* 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 GENERATE_H
#define GENERATE_H
typedef struct GenerateFunctions GenerateFunctions;
#include "types.h"
#include "planets.h"
#include "libs/compiler.h"
/*
* To do (for further cleanups):
* - split off pickupMineral, pickupEnergy, pickupLife from Generate*
* - split off generateOrbital in a calculation and an activation
* (graphics and music) part.
* - for GenerateNameFunction, set the name in an argument, instead
* of in GLOBAL_SYS(PlanetName)
* - make generateName work for moons
* - add parameters to initNcs, reinitNpcs, and uninitNpcs, so that
* globals don't have to be used.
* - Add a reference from each world to the solar system, so that most
* of these functions can do with one less argument.
* - (maybe) don't directly call the generate functions via
* solarSys->genFuncs->..., but use a function for this, which first
* checks for solar system dependent handlers, and if this does not exist,
* or returns false, calls the default function.
*/
// Any of these functions returning true means that the action has been
// handled, and that the default function should not be called.
typedef bool (*InitNpcsFunction)(void);
typedef bool (*ReinitNpcsFunction)(void);
typedef bool (*UninitNpcsFunction)(void);
typedef bool (*GeneratePlanetsFunction)(SOLARSYS_STATE *solarSys);
typedef bool (*GenerateMoonsFunction)(SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
typedef bool (*GenerateOrbitalFunction)(SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
typedef bool (*GenerateNameFunction)(SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
typedef bool (*GenerateMineralsFunction)(SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
typedef bool (*GenerateEnergyFunction)(SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
typedef bool (*GenerateLifeFunction)(SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
struct GenerateFunctions {
InitNpcsFunction initNpcs;
// Ships in the solar system, the first time it is accessed.
ReinitNpcsFunction reinitNpcs;
// Ships in the solar system, every next time it is accessed.
UninitNpcsFunction uninitNpcs;
// When leaving the solar system.
GeneratePlanetsFunction generatePlanets;
// Layout of planets within a solar system.
GenerateMoonsFunction generateMoons;
// Layout of moons around a planet.
GenerateNameFunction generateName;
// Name of a planet.
GenerateOrbitalFunction generateOrbital;
// Characteristics of words (planets and moons).
GenerateMineralsFunction generateMinerals;
// Minerals on the planet surface.
GenerateEnergyFunction generateEnergy;
// Energy sources on the planet surface.
GenerateLifeFunction generateLife;
// Bio on the planet surface.
};
#endif /* GENERATE_H */
+5
View File
@@ -0,0 +1,5 @@
uqm_CFILES="gendefault.c genand.c genburv.c genchmmr.c gencol.c gendru.c
genilw.c genmel.c genmyc.c genorz.c genpet.c genpku.c genrain.c
gensam.c genshof.c gensly.c gensol.c genspa.c gensup.c gensyr.c
genthrad.c gentrap.c genutw.c genvault.c genvux.c genwreck.c
genyeh.c genzfpscout.c genzoq.c"
@@ -17,11 +17,10 @@
#ifndef _GENALL_H
#define _GENALL_H
#include "planets.h"
#include "gendefault.h"
#include "types.h"
#include "../generate.h"
#include "libs/compiler.h"
#include "../globdata.h"
#include "../nameref.h"
#include "../resinst.h"
#endif /* _GENALL_H */
+185
View File
@@ -0,0 +1,185 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../globdata.h"
#include "../../nameref.h"
#include "../../resinst.h"
#include "../../sounds.h"
#include "libs/mathlib.h"
static bool GenerateAndrosynth_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateAndrosynthFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateAndrosynth_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateAndrosynth_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateAndrosynth_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateAndrosynth_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[1].data_index = TELLURIC_WORLD;
solarSys->PlanetDesc[1].radius = EARTH_RADIUS * 204L / 100;
angle = ARCTAN (solarSys->PlanetDesc[1].location.x,
solarSys->PlanetDesc[1].location.y);
solarSys->PlanetDesc[1].location.x =
COSINE (angle, solarSys->PlanetDesc[1].radius);
solarSys->PlanetDesc[1].location.y =
SINE (angle, solarSys->PlanetDesc[1].radius);
return true;
}
static bool
GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 1, MATCH_PLANET))
{
UWORD retval;
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (ANDROSYNTH_RUINS_STRTAB));
retval = HIWORD (
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]);
while (retval)
{
if (retval & 1)
{
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetRelStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
if (GetStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString) == 0)
{
DestroyStringTable (ReleaseStringTable (
solarSys->SysInfo.PlanetInfo.DiscoveryString));
solarSys->SysInfo.PlanetInfo.DiscoveryString = 0;
}
}
retval >>= 1;
}
}
GenerateDefault_generateOrbital (solarSys, world);
if (matchWorld (solarSys, world, 1, MATCH_PLANET))
{
solarSys->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE * 144 / 100;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 28;
solarSys->SysInfo.PlanetInfo.Weather = 1;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
}
return true;
}
static bool
GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
DWORD rand_val;
DWORD old_rand;
if (matchWorld (solarSys, world, 1, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 0;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << (i + 16))))
{
SET_GAME_STATE (PLANETARY_CHANGE, 1);
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
|= (1L << (i + 16));
if (solarSys->SysInfo.PlanetInfo.DiscoveryString)
{
UnbatchGraphics ();
DoDiscoveryReport (MenuSounds);
BatchGraphics ();
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetRelStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString,
1);
}
}
}
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+210
View File
@@ -0,0 +1,210 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../globdata.h"
#include "../../nameref.h"
#include "../../resinst.h"
#include "libs/mathlib.h"
static bool GenerateBurvixese_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateBurvixese_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
static bool GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateBurvixeseFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateBurvixese_generatePlanets,
/* .generateMoons = */ GenerateBurvixese_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateBurvixese_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateBurvixese_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateBurvixese_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = REDUX_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 39L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateBurvixese_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
GenerateDefault_generateMoons (solarSys, planet);
if (matchWorld (solarSys, planet, 0, MATCH_PLANET))
{
COUNT angle;
DWORD rand_val;
solarSys->MoonDesc[0].data_index = SELENIC_WORLD;
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS
+ (MAX_MOONS - 1) * MOON_DELTA;
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
solarSys->MoonDesc[0].location.x =
COSINE (angle, solarSys->MoonDesc[0].radius);
solarSys->MoonDesc[0].location.y =
SINE (angle, solarSys->MoonDesc[0].radius);
}
return true;
}
static bool
GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
COUNT i;
DWORD rand_val;
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateLifeForms (&solarSys->SysInfo, &i);
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
GenerateMineralDeposits (&solarSys->SysInfo, &i);
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (BURV_RUINS_STRTAB));
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
}
else if (matchWorld (solarSys, world, 0, 0)
&& !GET_GAME_STATE (BURVIXESE_BROADCASTERS))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] = CaptureDrawable (
LoadGraphic (BURV_BCS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (BURV_BCS_STRTAB));
}
LoadPlanet (NULL);
return true;
}
static bool
GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
DWORD rand_val;
DWORD old_rand;
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT nodeI;
COUNT i;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
if (matchWorld (solarSys, world, 0, 0)
&& !GET_GAME_STATE (BURVIXESE_BROADCASTERS))
{
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1);
SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+174
View File
@@ -0,0 +1,174 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../sounds.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateChmmr_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateChmmr_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
static bool GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
const GenerateFunctions generateChmmrFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateChmmr_generatePlanets,
/* .generateMoons = */ GenerateChmmr_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateChmmr_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateChmmr_generatePlanets (SOLARSYS_STATE *solarSys)
{
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[1].data_index = SAPPHIRE_WORLD;
if (!GET_GAME_STATE (CHMMR_UNLEASHED))
solarSys->PlanetDesc[1].data_index |= PLANET_SHIELDED;
solarSys->PlanetDesc[1].NumPlanets = 1;
return true;
}
static bool
GenerateChmmr_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
GenerateDefault_generateMoons (solarSys, planet);
if (matchWorld (solarSys, planet, 1, MATCH_PLANET))
{
COUNT angle;
DWORD rand_val;
solarSys->MoonDesc[0].data_index = HIERARCHY_STARBASE;
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS;
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
solarSys->MoonDesc[0].location.x =
COSINE (angle, solarSys->MoonDesc[0].radius);
solarSys->MoonDesc[0].location.y =
SINE (angle, solarSys->MoonDesc[0].radius);
}
return true;
}
static bool
GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 1, MATCH_PLANET))
{
if (GET_GAME_STATE (CHMMR_UNLEASHED))
{
solarSys->MenuState.Initialized += 2;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (CHMMR_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
{
GLOBAL (CurrentActivity) |= END_INTERPLANETARY;
}
return true;
}
else if (GET_GAME_STATE (SUN_DEVICE_ON_SHIP)
&& !GET_GAME_STATE (ILWRATH_DECEIVED)
&& ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING))
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (ILWRATH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (ILWRATH_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
}
else if (matchWorld (solarSys, world, 1, 0))
{
/* Starbase */
RECT r;
LockMutex (GraphicsLock);
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (CHMMR_BASE_STRTAB));
ScanContext = CreateContext ("genchmmr.ScanContext");
SetContext (ScanContext);
SetContextFGFrame (Screen);
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
r.extent.width = MAP_WIDTH;
r.extent.height = MAP_HEIGHT;
SetContextClipRect (&r);
DoDiscoveryReport (MenuSounds);
SetContext (SpaceContext);
DestroyContext (ScanContext);
ScanContext = 0;
DestroyStringTable (ReleaseStringTable (
solarSys->SysInfo.PlanetInfo.DiscoveryString));
solarSys->SysInfo.PlanetInfo.DiscoveryString = 0;
FreeLanderFont (&solarSys->SysInfo.PlanetInfo);
UnlockMutex (GraphicsLock);
return true;
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
+123
View File
@@ -0,0 +1,123 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../globdata.h"
#include "../../grpinfo.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateColony_initNpcs (void);
static bool GenerateColony_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateColony_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
const GenerateFunctions generateColonyFunctions = {
/* .initNpcs = */ GenerateColony_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateColony_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateColony_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateColony_initNpcs (void)
{
HIPGROUP hGroup;
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (COLONY_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (COLONY_GRPOFFS0, GLOBAL (BattleGroupRef));
}
GenerateDefault_initNpcs ();
if (GLOBAL (BattleGroupRef)
&& (hGroup = GetHeadLink (&GLOBAL (ip_group_q))))
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
GroupPtr->task = IN_ORBIT;
GroupPtr->sys_loc = 0 + 1; /* orbitting colony */
GroupPtr->dest_loc = 0 + 1; /* orbitting colony */
GroupPtr->loc.x = 0;
GroupPtr->loc.y = 0;
GroupPtr->group_counter = 0;
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
return true;
}
static bool
GenerateColony_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
PLANET_DESC *pMinPlanet;
pMinPlanet = &solarSys->PlanetDesc[0];
FillOrbits (solarSys, (BYTE)~0, pMinPlanet, FALSE);
pMinPlanet->radius = EARTH_RADIUS * 115L / 100;
angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y);
pMinPlanet->location.x = COSINE (angle, pMinPlanet->radius);
pMinPlanet->location.y = SINE (angle, pMinPlanet->radius);
pMinPlanet->data_index = WATER_WORLD | PLANET_SHIELDED;
return true;
}
static bool
GenerateColony_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
DoPlanetaryAnalysis (&solarSys->SysInfo, world);
solarSys->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE * 98 / 100;
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 28;
LoadPlanet (NULL);
return true;
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
+276
View File
@@ -0,0 +1,276 @@
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../encount.h"
#include "../../gamestr.h"
#include "../../globdata.h"
#include "../../grpinfo.h"
#include "../../races.h"
#include "../../state.h"
#include "libs/mathlib.h"
bool GenerateDefault_initNpcs (void);
bool GenerateDefault_reinitNpcs (void);
bool GenerateDefault_uninitNpcs (void);
bool GenerateDefault_generatePlanets (SOLARSYS_STATE *solarSys);
bool GenerateDefault_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
bool GenerateDefault_generateName (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
bool GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
bool GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
bool GenerateDefault_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
bool GenerateDefault_generateLife (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static void GeneratePlanets (SOLARSYS_STATE *system);
static void check_yehat_rebellion (void);
const GenerateFunctions generateDefaultFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateDefault_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateDefault_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
bool
GenerateDefault_initNpcs (void)
{
if (!GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP))
{
GLOBAL (BattleGroupRef) = 0;
BuildGroups ();
}
return true;
}
bool
GenerateDefault_reinitNpcs (void)
{
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
// This is not a great place to do the Yehat rebellion check, but
// since you can start the rebellion in any star system (not just
// the Homeworld), I could not find a better place for it.
// At least it is better than where it was originally.
check_yehat_rebellion ();
return true;
}
bool
GenerateDefault_uninitNpcs (void)
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (npc_built_ship_q));
ReinitQueue (&GLOBAL (ip_group_q));
return true;
}
bool
GenerateDefault_generatePlanets (SOLARSYS_STATE *solarSys)
{
FillOrbits (solarSys, (BYTE)~0, solarSys->PlanetDesc, FALSE);
GeneratePlanets (solarSys);
return true;
}
bool
GenerateDefault_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
FillOrbits (solarSys, planet->NumPlanets, solarSys->MoonDesc, FALSE);
return true;
}
bool
GenerateDefault_generateName (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
COUNT i = planetIndex (solarSys, world);
utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + (9 + 7) + i));
SET_GAME_STATE (BATTLE_PLANET, world->data_index);
return true;
}
bool
GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
COUNT i;
DWORD rand_val;
SYSTEM_INFO *sysInfo;
#ifdef DEBUG_SOLARSYS
if (worldIsPlanet (solarSys, world))
{
log_add (log_Debug, "Planet index = %d",
planetIndex (solarSys, world));
}
else
{
log_add (log_Debug, "Planet index = %d, Moon index = %d",
planetIndex (solarSys, world),
moonIndex (solarSys, world));
}
#endif /* DEBUG_SOLARSYS */
sysInfo = &solarSys->SysInfo;
rand_val = DoPlanetaryAnalysis (sysInfo, world);
sysInfo->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateLifeForms (sysInfo, &i);
sysInfo->PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
GenerateMineralDeposits (sysInfo, &i);
sysInfo->PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
LoadPlanet (NULL);
return true;
}
bool
GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode)
{
GenerateMineralDeposits (&solarSys->SysInfo, whichNode);
(void) world;
return true;
}
bool
GenerateDefault_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
*whichNode = 0;
(void) solarSys;
(void) world;
return true;
}
bool
GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
GenerateLifeForms (&solarSys->SysInfo, whichNode);
(void) world;
return true;
}
// NB. This function modifies the RNG state.
static void
GeneratePlanets (SOLARSYS_STATE *solarSys)
{
COUNT i;
PLANET_DESC *planet;
for (i = solarSys->SunDesc[0].NumPlanets,
planet = &solarSys->PlanetDesc[0]; i; --i, ++planet)
{
DWORD rand_val;
BYTE byte_val;
BYTE num_moons;
BYTE type;
rand_val = TFB_Random ();
byte_val = LOBYTE (rand_val);
num_moons = 0;
type = PlanData[planet->data_index & ~PLANET_SHIELDED].Type;
switch (PLANSIZE (type))
{
case LARGE_ROCKY_WORLD:
if (byte_val < 0x00FF * 25 / 100)
{
if (byte_val < 0x00FF * 5 / 100)
++num_moons;
++num_moons;
}
break;
case GAS_GIANT:
if (byte_val < 0x00FF * 90 / 100)
{
if (byte_val < 0x00FF * 75 / 100)
{
if (byte_val < 0x00FF * 50 / 100)
{
if (byte_val < 0x00FF * 25 / 100)
++num_moons;
++num_moons;
}
++num_moons;
}
++num_moons;
}
break;
}
planet->NumPlanets = num_moons;
}
}
static void
check_yehat_rebellion (void)
{
HIPGROUP hGroup, hNextGroup;
// XXX: Is there a better way to do this? I could not find one.
// When you talk to a Yehat ship (YEHAT_SHIP) and start the rebellion,
// there is no battle following the comm. There is *never* a battle in
// an encounter with Rebels, but the group race_id (YEHAT_REBEL_SHIP)
// is different from Royalists (YEHAT_SHIP). There is *always* a battle
// in an encounter with Royalists.
// TRANSLATION: "If the civil war has not started yet, or the player
// battled a ship -- bail."
if (!GET_GAME_STATE (YEHAT_CIVIL_WAR) || EncounterRace >= 0)
return; // not this time
// Send Yehat groups to flee the system, but only if the player
// has actually talked to a ship.
for (hGroup = GetHeadLink (&GLOBAL (ip_group_q)); hGroup;
hGroup = hNextGroup)
{
IP_GROUP *GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
// IGNORE_FLAGSHIP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == YEHAT_SHIP
&& (GroupPtr->task & IGNORE_FLAGSHIP))
{
GroupPtr->task &= REFORM_GROUP;
GroupPtr->task |= FLEE | IGNORE_FLAGSHIP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
}
+44
View File
@@ -0,0 +1,44 @@
/*
* 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 GENDEFAULT_H
#define GENDEFAULT_H
#include "types.h"
#include "../planets.h"
#include "libs/compiler.h"
bool GenerateDefault_initNpcs (void);
bool GenerateDefault_reinitNpcs (void);
bool GenerateDefault_uninitNpcs (void);
bool GenerateDefault_generatePlanets (SOLARSYS_STATE *solarSys);
bool GenerateDefault_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
bool GenerateDefault_generateName (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
bool GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
bool GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
bool GenerateDefault_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
bool GenerateDefault_generateLife (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
extern const GenerateFunctions generateDefaultFunctions;
#endif /* GENDEFAULT_H */
+188
View File
@@ -0,0 +1,188 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
#include <string.h>
static bool GenerateDruuge_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateDruuge_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateDruugeFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateDruuge_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateDruuge_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDruuge_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateDruuge_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
memmove (&solarSys->PlanetDesc[1], &solarSys->PlanetDesc[0],
sizeof (solarSys->PlanetDesc[0])
* solarSys->SunDesc[0].NumPlanets);
++solarSys->SunDesc[0].NumPlanets;
solarSys->PlanetDesc[0].data_index = DUST_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 50L / 100;
solarSys->PlanetDesc[0].NumPlanets = 0;
angle = HALF_CIRCLE - OCTANT;
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].rand_seed = MAKE_DWORD (
solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
return true;
}
static bool
GenerateDruuge_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING))
{
NotifyOthers (DRUUGE_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (DRUUGE_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (DRUUGE_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (DRUUGE_RUINS_STRTAB));
if (GET_GAME_STATE (ROSY_SPHERE))
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (!GET_GAME_STATE (ROSY_SPHERE))
solarSys->SysInfo.PlanetInfo.CurType = 0;
else
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!GET_GAME_STATE (ROSY_SPHERE))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (ROSY_SPHERE, 1);
SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1);
}
}
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+163
View File
@@ -0,0 +1,163 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateIlwrath_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateIlwrath_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateIlwrath_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateIlwrathFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateIlwrath_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateIlwrath_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateIlwrath_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateIlwrath_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = PRIMORDIAL_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 204L / 100;
angle = ARCTAN (
solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateIlwrath_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING))
{
NotifyOthers (ILWRATH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (ILWRATH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (ILWRATH_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
}
GenerateDefault_generateOrbital (solarSys, world);
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
solarSys->SysInfo.PlanetInfo.Weather = 2;
solarSys->SysInfo.PlanetInfo.Tectonics = 3;
}
return true;
}
static bool
GenerateIlwrath_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+110
View File
@@ -0,0 +1,110 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../../build.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../state.h"
#include "libs/log.h"
static bool GenerateMelnorme_initNpcs (void);
static int SelectMelnormeRefVar (void);
static DWORD GetMelnormeRef (void);
static void SetMelnormeRef (DWORD Ref);
const GenerateFunctions generateMelnormeFunctions = {
/* .initNpcs = */ GenerateMelnorme_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateDefault_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateDefault_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateMelnorme_initNpcs (void)
{
GLOBAL (BattleGroupRef) = GetMelnormeRef ();
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (MELNORME_SHIP, &GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SetMelnormeRef (GLOBAL (BattleGroupRef));
}
GenerateDefault_initNpcs ();
return true;
}
static int
SelectMelnormeRefVar (void)
{
switch (CurStarDescPtr->Index)
{
case MELNORME0_DEFINED: return MELNORME0_GRPOFFS0;
case MELNORME1_DEFINED: return MELNORME1_GRPOFFS0;
case MELNORME2_DEFINED: return MELNORME2_GRPOFFS0;
case MELNORME3_DEFINED: return MELNORME3_GRPOFFS0;
case MELNORME4_DEFINED: return MELNORME4_GRPOFFS0;
case MELNORME5_DEFINED: return MELNORME5_GRPOFFS0;
case MELNORME6_DEFINED: return MELNORME6_GRPOFFS0;
case MELNORME7_DEFINED: return MELNORME7_GRPOFFS0;
case MELNORME8_DEFINED: return MELNORME8_GRPOFFS0;
default:
return -1;
}
}
static DWORD
GetMelnormeRef (void)
{
int RefVar = SelectMelnormeRefVar ();
if (RefVar < 0)
{
log_add (log_Warning, "GetMelnormeRef(): reference unknown");
return 0;
}
return GET_GAME_STATE_32 (RefVar);
}
static void
SetMelnormeRef (DWORD Ref)
{
int RefVar = SelectMelnormeRefVar ();
if (RefVar < 0)
{
log_add (log_Warning, "SetMelnormeRef(): reference unknown");
return;
}
SET_GAME_STATE_32 (RefVar, Ref);
}
+269
View File
@@ -0,0 +1,269 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateMycon_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateMycon_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static bool GenerateMycon_generateLife (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateMyconFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateMycon_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateMycon_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateMycon_generateEnergy,
/* .generateLife = */ GenerateMycon_generateLife,
};
static bool
GenerateMycon_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = SHATTERED_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 80L / 100;
if (solarSys->PlanetDesc[0].NumPlanets > 2)
solarSys->PlanetDesc[0].NumPlanets = 2;
angle = ARCTAN (
solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateMycon_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if ((CurStarDescPtr->Index == MYCON_DEFINED
|| CurStarDescPtr->Index == SUN_DEVICE_DEFINED)
&& ActivateStarShip (MYCON_SHIP, SPHERE_TRACKING))
{
if (CurStarDescPtr->Index == MYCON_DEFINED
|| !GET_GAME_STATE (SUN_DEVICE_UNGUARDED))
{
NotifyOthers (MYCON_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (CurStarDescPtr->Index == MYCON_DEFINED
|| !GET_GAME_STATE (MYCON_FELL_FOR_AMBUSH))
{
CloneShipFragment (MYCON_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
}
else
{
COUNT i;
for (i = 0; i < 5; ++i)
CloneShipFragment (MYCON_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
if (CurStarDescPtr->Index == MYCON_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
InitCommunication (MYCON_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
return true;
{
BOOLEAN MyconSurvivors;
MyconSurvivors =
GetHeadLink (&GLOBAL (npc_built_ship_q)) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (MyconSurvivors)
return true;
SET_GAME_STATE (SUN_DEVICE_UNGUARDED, 1);
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
}
switch (CurStarDescPtr->Index)
{
case SUN_DEVICE_DEFINED:
if (!GET_GAME_STATE (SUN_DEVICE))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (SUN_DEVICE_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (SUN_DEVICE_STRTAB));
}
break;
case EGG_CASE0_DEFINED:
case EGG_CASE1_DEFINED:
case EGG_CASE2_DEFINED:
if (GET_GAME_STATE (KNOW_ABOUT_SHATTERED) == 0)
SET_GAME_STATE (KNOW_ABOUT_SHATTERED, 1);
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0)))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (EGG_CASE_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (EGG_CASE_STRTAB));
}
break;
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (CurStarDescPtr->Index != MYCON_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
{
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (CurStarDescPtr->Index == SUN_DEVICE_DEFINED)
{
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (SUN_DEVICE, 1);
SET_GAME_STATE (SUN_DEVICE_ON_SHIP, 1);
SET_GAME_STATE (MYCON_VISITS, 0);
}
}
}
else
{
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if ((solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& solarSys->SysInfo.PlanetInfo.DiscoveryString)
{
switch (CurStarDescPtr->Index)
{
case EGG_CASE0_DEFINED:
SET_GAME_STATE (EGG_CASE0_ON_SHIP, 1);
break;
case EGG_CASE1_DEFINED:
SET_GAME_STATE (EGG_CASE1_ON_SHIP, 1);
break;
case EGG_CASE2_DEFINED:
SET_GAME_STATE (EGG_CASE2_ON_SHIP, 1);
break;
}
}
}
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
static bool
GenerateMycon_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
*whichNode = 0;
(void) solarSys;
(void) world;
return true;
}
+241
View File
@@ -0,0 +1,241 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateOrz_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateOrz_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateOrzFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateOrz_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateOrz_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateOrz_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateOrz_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
if (CurStarDescPtr->Index == ORZ_DEFINED)
{
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 156L / 100;
solarSys->PlanetDesc[0].NumPlanets = 0;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
}
return true;
}
static bool
GenerateOrz_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if ((CurStarDescPtr->Index == ORZ_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
|| (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED
&& matchWorld (solarSys, world, 1, 2)
&& !GET_GAME_STATE (TAALO_PROTECTOR)))
{
COUNT i;
if ((CurStarDescPtr->Index == ORZ_DEFINED
|| !GET_GAME_STATE (TAALO_UNPROTECTED))
&& ActivateStarShip (ORZ_SHIP, SPHERE_TRACKING))
{
NotifyOthers (ORZ_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (CurStarDescPtr->Index == ORZ_DEFINED)
{
CloneShipFragment (ORZ_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
for (i = 0; i < 14; ++i)
{
CloneShipFragment (ORZ_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (ORZ_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
return true;
{
BOOLEAN OrzSurvivors;
OrzSurvivors = GetHeadLink (&GLOBAL (npc_built_ship_q))
&& (CurStarDescPtr->Index == ORZ_DEFINED
|| !GET_GAME_STATE (TAALO_UNPROTECTED));
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (OrzSurvivors)
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
SET_GAME_STATE (TAALO_UNPROTECTED, 1);
if (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED)
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (TAALO_DEVICE_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (TAALO_DEVICE_STRTAB));
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
DWORD rand_val;
DWORD old_rand;
if (CurStarDescPtr->Index != ORZ_DEFINED
&& matchWorld (solarSys, world, 1, 2)
&& !GET_GAME_STATE (TAALO_PROTECTOR))
{
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (TAALO_PROTECTOR, 1);
SET_GAME_STATE (TAALO_PROTECTOR_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
return true;
}
if (CurStarDescPtr->Index == ORZ_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode &&
!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+272
View File
@@ -0,0 +1,272 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateTalkingPet_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateTalkingPet_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateTalkingPet_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static void ZapToUrquanEncounter (void);
const GenerateFunctions generateTalkingPetFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateTalkingPet_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateTalkingPet_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateTalkingPet_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateTalkingPet_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = TELLURIC_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 204L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateTalkingPet_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET)
&& (GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES)
|| !GET_GAME_STATE (TALKING_PET)
|| ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING)))
{
NotifyOthers (UMGAH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING))
{
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
if (!GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES))
{
CloneShipFragment (UMGAH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
InitCommunication (UMGAH_CONVERSATION);
}
else
{
COUNT i;
for (i = 0; i < 10; ++i)
{
CloneShipFragment (UMGAH_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
InitCommunication (TALKING_PET_CONVERSATION);
}
solarSys->MenuState.Initialized -= 2;
}
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
BOOLEAN UmgahSurvivors;
UmgahSurvivors = GetHeadLink (
&GLOBAL (npc_built_ship_q)) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
if (GET_GAME_STATE (PLAYER_HYPNOTIZED))
ZapToUrquanEncounter ();
else if (GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES)
&& !UmgahSurvivors)
{
// Defeated the zombie fleet.
InitCommunication (TALKING_PET_CONVERSATION);
}
else if (!(ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING)))
{
// The Kohr-Ah have destroyed the Umgah, but the
// talking pet survived.
InitCommunication (TALKING_PET_CONVERSATION);
}
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
GenerateDefault_generateOrbital (solarSys, world);
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
solarSys->SysInfo.PlanetInfo.Weather = 0;
return true;
}
static bool
GenerateTalkingPet_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
COUNT old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
static void
ZapToUrquanEncounter (void)
{
HENCOUNTER hEncounter;
if ((hEncounter = AllocEncounter ()) || (hEncounter = GetHeadEncounter ()))
{
SIZE dx, dy;
ENCOUNTER *EncounterPtr;
HFLEETINFO hStarShip;
FLEET_INFO *TemplatePtr;
BRIEF_SHIP_INFO *BSIPtr;
LockEncounter (hEncounter, &EncounterPtr);
if (hEncounter == GetHeadEncounter ())
RemoveEncounter (hEncounter);
memset (EncounterPtr, 0, sizeof (*EncounterPtr));
InsertEncounter (hEncounter, GetHeadEncounter ());
hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), URQUAN_SHIP);
TemplatePtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
EncounterPtr->origin = TemplatePtr->loc;
EncounterPtr->radius = TemplatePtr->actual_strength;
EncounterPtr->SD.Type = URQUAN_SHIP;
EncounterPtr->SD.Index = MAKE_BYTE (1, 0) | ONE_SHOT_ENCOUNTER;
BSIPtr = &EncounterPtr->ShipList[0];
BSIPtr->race_id = URQUAN_SHIP;
BSIPtr->crew_level = TemplatePtr->crew_level;
BSIPtr->max_crew = TemplatePtr->max_crew;
BSIPtr->max_energy = TemplatePtr->max_energy;
EncounterPtr->SD.star_pt.x = 5288;
EncounterPtr->SD.star_pt.y = 4892;
EncounterPtr->log_x = UNIVERSE_TO_LOGX (EncounterPtr->SD.star_pt.x);
EncounterPtr->log_y = UNIVERSE_TO_LOGY (EncounterPtr->SD.star_pt.y);
GLOBAL_SIS (log_x) = EncounterPtr->log_x;
GLOBAL_SIS (log_y) = EncounterPtr->log_y;
UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
{
#define LOST_DAYS 15
BYTE black_buf[] = {FadeAllToBlack};
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND * 2));
LockMutex (GraphicsLock);
MoveGameClockDays (LOST_DAYS);
UnlockMutex (GraphicsLock);
}
GLOBAL (CurrentActivity) = MAKE_WORD (IN_HYPERSPACE, 0) | START_ENCOUNTER;
dx = CurStarDescPtr->star_pt.x - EncounterPtr->SD.star_pt.x;
dy = CurStarDescPtr->star_pt.y - EncounterPtr->SD.star_pt.y;
dx = (SIZE)square_root ((long)dx * dx + (long)dy * dy)
+ (FUEL_TANK_SCALE >> 1);
LockMutex (GraphicsLock);
DeltaSISGauges (0, -dx, 0);
if (GLOBAL_SIS (FuelOnBoard) < 5 * FUEL_TANK_SCALE)
{
dx = ((5 + ((COUNT)TFB_Random () % 5)) * FUEL_TANK_SCALE)
- (SIZE)GLOBAL_SIS (FuelOnBoard);
DeltaSISGauges (0, dx, 0);
}
DrawSISMessage (NULL);
DrawHyperCoords (EncounterPtr->SD.star_pt);
UnlockMutex (GraphicsLock);
UnlockEncounter (hEncounter);
}
}
+176
View File
@@ -0,0 +1,176 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GeneratePkunk_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GeneratePkunk_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generatePkunkFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GeneratePkunk_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GeneratePkunk_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GeneratePkunk_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GeneratePkunk_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 104L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GeneratePkunk_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (PKUNK_SHIP, SPHERE_TRACKING))
{
NotifyOthers (PKUNK_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (PKUNK_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (PKUNK_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (PKUNK_RUINS_STRTAB));
if (GET_GAME_STATE (CLEAR_SPINDLE))
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (!GET_GAME_STATE (CLEAR_SPINDLE))
solarSys->SysInfo.PlanetInfo.CurType = 0;
else
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!GET_GAME_STATE (CLEAR_SPINDLE))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (CLEAR_SPINDLE, 1);
SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1);
}
}
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+98
View File
@@ -0,0 +1,98 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "libs/mathlib.h"
static bool GenerateRainbowWorld_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateRainbowWorld_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
const GenerateFunctions generateRainbowWorldFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateRainbowWorld_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateRainbowWorld_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateRainbowWorld_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = RAINBOW_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 0;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 50L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
if (angle <= QUADRANT)
angle += QUADRANT;
else if (angle >= FULL_CIRCLE - QUADRANT)
angle -= QUADRANT;
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateRainbowWorld_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
BYTE which_rainbow;
UWORD rainbow_mask;
STAR_DESC *SDPtr;
rainbow_mask = MAKE_WORD (
GET_GAME_STATE (RAINBOW_WORLD0),
GET_GAME_STATE (RAINBOW_WORLD1));
which_rainbow = 0;
SDPtr = &star_array[0];
while (SDPtr != CurStarDescPtr)
{
if (SDPtr->Index == RAINBOW_DEFINED)
++which_rainbow;
++SDPtr;
}
rainbow_mask |= 1 << which_rainbow;
SET_GAME_STATE (RAINBOW_WORLD0, LOBYTE (rainbow_mask));
SET_GAME_STATE (RAINBOW_WORLD1, HIBYTE (rainbow_mask));
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
+320
View File
@@ -0,0 +1,320 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../grpinfo.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateSaMatra_initNpcs (void);
static bool GenerateSaMatra_reinitNpcs (void);
static bool GenerateSaMatra_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateSaMatra_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
static bool GenerateSaMatra_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static void BuildUrquanGuard (void);
const GenerateFunctions generateSaMatraFunctions = {
/* .initNpcs = */ GenerateSaMatra_initNpcs,
/* .reinitNpcs = */ GenerateSaMatra_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateSaMatra_generatePlanets,
/* .generateMoons = */ GenerateSaMatra_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateSaMatra_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateSaMatra_initNpcs (void)
{
if (!GET_GAME_STATE (URQUAN_MESSED_UP))
{
BuildUrquanGuard ();
}
else
{ // Exorcise Ur-Quan ghosts upon system reentry
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
// wipe out the group
}
return true;
}
static bool
GenerateSaMatra_reinitNpcs (void)
{
BOOLEAN GuardEngaged;
HIPGROUP hGroup;
HIPGROUP hNextGroup;
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
EncounterGroup = 0;
EncounterRace = -1;
// Do not want guards to chase the player
GuardEngaged = FALSE;
for (hGroup = GetHeadLink (&GLOBAL (ip_group_q));
hGroup; hGroup = hNextGroup)
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
if (GET_GAME_STATE (URQUAN_MESSED_UP))
{
GroupPtr->task &= REFORM_GROUP;
GroupPtr->task |= FLEE | IGNORE_FLAGSHIP;
GroupPtr->dest_loc = 0;
}
else if (GroupPtr->task & REFORM_GROUP)
{
// REFORM_GROUP was set in ipdisp.c:ip_group_collision
// during a collision with the flagship.
GroupPtr->task &= ~REFORM_GROUP;
GroupPtr->group_counter = 0;
GuardEngaged = TRUE;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
if (GuardEngaged)
{
COUNT angle;
POINT org;
XFormIPLoc (&pSolarSysState->PlanetDesc[4].image.origin, &org, FALSE);
angle = ARCTAN (GLOBAL (ip_location.x) - org.x,
GLOBAL (ip_location.y) - org.y);
GLOBAL (ip_location.x) = org.x + COSINE (angle, 3000);
GLOBAL (ip_location.y) = org.y + SINE (angle, 3000);
XFormIPLoc (&GLOBAL (ip_location),
&GLOBAL (ShipStamp.origin), TRUE);
}
return true;
}
static bool
GenerateSaMatra_generatePlanets (SOLARSYS_STATE *solarSys)
{
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[4].NumPlanets = 1;
return true;
}
static bool
GenerateSaMatra_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
GenerateDefault_generateMoons (solarSys, planet);
if (matchWorld (solarSys, planet, 4, MATCH_PLANET))
{
COUNT angle;
DWORD rand_val;
solarSys->MoonDesc[0].data_index = SA_MATRA;
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + (2 * MOON_DELTA);
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
solarSys->MoonDesc[0].location.x =
COSINE (angle, solarSys->MoonDesc[0].radius);
solarSys->MoonDesc[0].location.y =
SINE (angle, solarSys->MoonDesc[0].radius);
}
return true;
}
static bool
GenerateSaMatra_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
/* Samatra */
if (matchWorld (solarSys, world, 4, 0))
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (!GET_GAME_STATE (URQUAN_MESSED_UP))
{
CloneShipFragment (!GET_GAME_STATE (KOHR_AH_FRENZY) ?
URQUAN_SHIP : BLACK_URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
}
else
{
#define URQUAN_REMNANTS 3
BYTE i;
for (i = 0; i < URQUAN_REMNANTS; ++i)
{
CloneShipFragment (URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
CloneShipFragment (BLACK_URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
}
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
SET_GAME_STATE (URQUAN_PROTECTING_SAMATRA, 1);
InitCommunication (URQUAN_CONVERSATION);
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
BOOLEAN UrquanSurvivors;
UrquanSurvivors = GetHeadLink (&GLOBAL (npc_built_ship_q)) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (UrquanSurvivors)
{
SET_GAME_STATE (URQUAN_PROTECTING_SAMATRA, 0);
}
else
{
EncounterGroup = 0;
EncounterRace = -1;
GLOBAL (CurrentActivity) = IN_LAST_BATTLE | START_ENCOUNTER;
if (GET_GAME_STATE (YEHAT_CIVIL_WAR)
&& ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING)
&& ActivateStarShip (YEHAT_REBEL_SHIP,
FEASIBILITY_STUDY))
InitCommunication (YEHAT_REBEL_CONVERSATION);
}
}
solarSys->MenuState.Initialized -= 2;
return true;
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static void
BuildUrquanGuard (void)
{
BYTE ship1, ship2;
BYTE b0, b1;
POINT org;
HIPGROUP hGroup, hNextGroup;
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (SAMATRA_GRPOFFS0);
if (!GET_GAME_STATE (KOHR_AH_FRENZY))
{
ship1 = URQUAN_SHIP;
ship2 = BLACK_URQUAN_SHIP;
}
else
{
ship1 = BLACK_URQUAN_SHIP;
ship2 = URQUAN_SHIP;
}
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
for (b0 = 0; b0 < MAX_SHIPS_PER_SIDE; ++b0)
CloneShipFragment (ship1, &GLOBAL (npc_built_ship_q), 0);
if (GLOBAL (BattleGroupRef) == 0)
{
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
SET_GAME_STATE_32 (SAMATRA_GRPOFFS0, GLOBAL (BattleGroupRef));
}
#define NUM_URQUAN_GUARDS0 12
for (b0 = 1; b0 <= NUM_URQUAN_GUARDS0; ++b0)
PutGroupInfo (GLOBAL (BattleGroupRef), b0);
ReinitQueue (&GLOBAL (npc_built_ship_q));
for (b0 = 0; b0 < MAX_SHIPS_PER_SIDE; ++b0)
CloneShipFragment (ship2, &GLOBAL (npc_built_ship_q), 0);
#define NUM_URQUAN_GUARDS1 4
for (b0 = 1; b0 <= NUM_URQUAN_GUARDS1; ++b0)
PutGroupInfo (GLOBAL (BattleGroupRef),
(BYTE)(NUM_URQUAN_GUARDS0 + b0));
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP);
XFormIPLoc (&pSolarSysState->PlanetDesc[4].image.origin, &org, FALSE);
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
for (b0 = 0, b1 = 0;
b0 < NUM_URQUAN_GUARDS0;
++b0, b1 += FULL_CIRCLE / (NUM_URQUAN_GUARDS0 + NUM_URQUAN_GUARDS1))
{
IP_GROUP *GroupPtr;
if (b1 % (FULL_CIRCLE / NUM_URQUAN_GUARDS1) == 0)
b1 += FULL_CIRCLE / (NUM_URQUAN_GUARDS0 + NUM_URQUAN_GUARDS1);
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
GroupPtr->task = ON_STATION | IGNORE_FLAGSHIP;
GroupPtr->sys_loc = 0;
GroupPtr->dest_loc = 4 + 1;
GroupPtr->orbit_pos = NORMALIZE_FACING (ANGLE_TO_FACING (b1));
GroupPtr->group_counter = 0;
GroupPtr->loc.x = org.x + COSINE (b1, STATION_RADIUS);
GroupPtr->loc.y = org.y + SINE (b1, STATION_RADIUS);
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
hGroup = hNextGroup;
}
for (b0 = 0, b1 = 0;
b0 < NUM_URQUAN_GUARDS1;
++b0, b1 += FULL_CIRCLE / NUM_URQUAN_GUARDS1)
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
GroupPtr->task = ON_STATION | IGNORE_FLAGSHIP;
GroupPtr->sys_loc = 0;
GroupPtr->dest_loc = 4 + 1;
GroupPtr->orbit_pos = NORMALIZE_FACING (ANGLE_TO_FACING (b1));
GroupPtr->group_counter = 0;
GroupPtr->loc.x = org.x + COSINE (b1, STATION_RADIUS);
GroupPtr->loc.y = org.y + SINE (b1, STATION_RADIUS);
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
hGroup = hNextGroup;
}
}
+173
View File
@@ -0,0 +1,173 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../../build.h"
#include "../../globdata.h"
#include "../../grpinfo.h"
#include "../../state.h"
#include "../planets.h"
static bool GenerateShofixti_initNpcs (void);
static bool GenerateShofixti_reinitNpcs (void);
static bool GenerateShofixti_uninitNpcs (void);
static bool GenerateShofixti_generatePlanets (SOLARSYS_STATE *solarSys);
static void check_old_shofixti (void);
const GenerateFunctions generateShofixtiFunctions = {
/* .initNpcs = */ GenerateShofixti_initNpcs,
/* .reinitNpcs = */ GenerateShofixti_reinitNpcs,
/* .uninitNpcs = */ GenerateShofixti_uninitNpcs,
/* .generatePlanets = */ GenerateShofixti_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateDefault_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateShofixti_initNpcs (void)
{
if (!GET_GAME_STATE (SHOFIXTI_RECRUITED)
&& (!GET_GAME_STATE (SHOFIXTI_KIA)
|| (!GET_GAME_STATE (SHOFIXTI_BRO_KIA)
&& GET_GAME_STATE (MAIDENS_ON_SHIP))))
{
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (SHOFIXTI_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0
|| !GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP))
{
HSHIPFRAG hStarShip;
if (GLOBAL (BattleGroupRef) == 0)
GLOBAL (BattleGroupRef) = ~0L;
hStarShip = CloneShipFragment (SHOFIXTI_SHIP,
&GLOBAL (npc_built_ship_q), 1);
if (hStarShip)
{ /* Set old Shofixti name; his brother if Tanaka died */
SHIP_FRAGMENT *FragPtr = LockShipFrag (
&GLOBAL (npc_built_ship_q), hStarShip);
/* Name Tanaka or Katana (+1) */
FragPtr->captains_name_index =
NAME_OFFSET + NUM_CAPTAINS_NAMES +
(GET_GAME_STATE (SHOFIXTI_KIA) & 1);
UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip);
}
GLOBAL (BattleGroupRef) = PutGroupInfo (
GLOBAL (BattleGroupRef), 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (SHOFIXTI_GRPOFFS0, GLOBAL (BattleGroupRef));
}
}
// This was originally a fallthrough to REINIT_NPCS.
// XXX: is the call to check_old_shofixti() needed?
GenerateDefault_initNpcs ();
check_old_shofixti ();
return true;
}
static bool
GenerateShofixti_reinitNpcs (void)
{
GenerateDefault_reinitNpcs ();
check_old_shofixti ();
return true;
}
static bool
GenerateShofixti_uninitNpcs (void)
{
if (GLOBAL (BattleGroupRef)
&& !GET_GAME_STATE (SHOFIXTI_RECRUITED)
&& GetHeadLink (&GLOBAL (ip_group_q)) == 0)
{
if (!GET_GAME_STATE (SHOFIXTI_KIA))
{
SET_GAME_STATE (SHOFIXTI_KIA, 1);
SET_GAME_STATE (SHOFIXTI_VISITS, 0);
}
else if (GET_GAME_STATE (MAIDENS_ON_SHIP))
{
SET_GAME_STATE (SHOFIXTI_BRO_KIA, 1);
}
}
GenerateDefault_uninitNpcs ();
return true;
}
static bool
GenerateShofixti_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT i;
#define NUM_PLANETS 6
solarSys->SunDesc[0].NumPlanets = NUM_PLANETS;
for (i = 0; i < NUM_PLANETS; ++i)
{
PLANET_DESC *pCurDesc = &solarSys->PlanetDesc[i];
pCurDesc->NumPlanets = 0;
if (i < (NUM_PLANETS >> 1))
pCurDesc->data_index = SELENIC_WORLD;
else
pCurDesc->data_index = METAL_WORLD;
}
FillOrbits (solarSys, NUM_PLANETS, solarSys->PlanetDesc, TRUE);
return true;
}
static void
check_old_shofixti (void)
{
HIPGROUP hGroup;
IP_GROUP *GroupPtr;
if (!GLOBAL (BattleGroupRef))
return; // nothing to check
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
if (!hGroup)
return; // still nothing to check
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
// REFORM_GROUP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == SHOFIXTI_SHIP
&& (GroupPtr->task & REFORM_GROUP)
&& GET_GAME_STATE (SHOFIXTI_RECRUITED))
{
GroupPtr->task = FLEE | IGNORE_FLAGSHIP | REFORM_GROUP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
+69
View File
@@ -0,0 +1,69 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../comm.h"
static bool GenerateSlylandro_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateSlylandro_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
const GenerateFunctions generateSlylandroFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateSlylandro_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateSlylandro_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateSlylandro_generatePlanets (SOLARSYS_STATE *solarSys)
{
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[3].data_index = RED_GAS_GIANT;
solarSys->PlanetDesc[3].NumPlanets = 1;
return true;
}
static bool
GenerateSlylandro_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 3, MATCH_PLANET))
{
solarSys->MenuState.Initialized += 2;
InitCommunication (SLYLANDRO_HOME_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
return true;
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
+663
View File
@@ -0,0 +1,663 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../lifeform.h"
#include "../planets.h"
#include "../../build.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../gamestr.h"
#include "../../grpinfo.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateSol_initNpcs (void);
static bool GenerateSol_reinitNpcs (void);
static bool GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateSol_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
static bool GenerateSol_generateName (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static bool GenerateSol_generateLife (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static int init_probe (void);
static void check_probe (void);
const GenerateFunctions generateSolFunctions = {
/* .initNpcs = */ GenerateSol_initNpcs,
/* .reinitNpcs = */ GenerateSol_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateSol_generatePlanets,
/* .generateMoons = */ GenerateSol_generateMoons,
/* .generateName = */ GenerateSol_generateName,
/* .generateOrbital = */ GenerateSol_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateSol_generateEnergy,
/* .generateLife = */ GenerateSol_generateLife,
};
static bool
GenerateSol_initNpcs (void)
{
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (URQUAN_PROBE_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (URQUAN_DRONE_SHIP, &GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (URQUAN_PROBE_GRPOFFS0, GLOBAL (BattleGroupRef));
}
if (!init_probe ())
GenerateDefault_initNpcs ();
return true;
}
static bool
GenerateSol_reinitNpcs (void)
{
if (GET_GAME_STATE (CHMMR_BOMB_STATE) != 3)
{
GenerateDefault_reinitNpcs ();
check_probe ();
}
else
{
GLOBAL (BattleGroupRef) = 0;
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
}
return true;
}
static bool
GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT planetI;
#define SOL_SEED 334241042L
TFB_SeedRandom (SOL_SEED);
solarSys->SunDesc[0].NumPlanets = 9;
for (planetI = 0; planetI < 9; ++planetI)
{
COUNT angle;
DWORD rand_val;
UWORD word_val;
PLANET_DESC *pCurDesc = &solarSys->PlanetDesc[planetI];
pCurDesc->rand_seed = rand_val = TFB_Random ();
word_val = LOWORD (rand_val);
angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val));
switch (planetI)
{
case 0: /* MERCURY */
pCurDesc->data_index = METAL_WORLD;
pCurDesc->radius = EARTH_RADIUS * 39L / 100;
pCurDesc->NumPlanets = 0;
break;
case 1: /* VENUS */
pCurDesc->data_index = PRIMORDIAL_WORLD;
pCurDesc->radius = EARTH_RADIUS * 72L / 100;
pCurDesc->NumPlanets = 0;
angle = NORMALIZE_ANGLE (FULL_CIRCLE - angle);
break;
case 2: /* EARTH */
pCurDesc->data_index = WATER_WORLD | PLANET_SHIELDED;
pCurDesc->radius = EARTH_RADIUS;
pCurDesc->NumPlanets = 2;
break;
case 3: /* MARS */
pCurDesc->data_index = DUST_WORLD;
pCurDesc->radius = EARTH_RADIUS * 152L / 100;
pCurDesc->NumPlanets = 0;
break;
case 4: /* JUPITER */
pCurDesc->data_index = RED_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 500L /* 520L */ / 100;
pCurDesc->NumPlanets = 4;
break;
case 5: /* SATURN */
pCurDesc->data_index = ORA_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 750L /* 952L */ / 100;
pCurDesc->NumPlanets = 1;
break;
case 6: /* URANUS */
pCurDesc->data_index = GRN_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 1000L /* 1916L */ / 100;
pCurDesc->NumPlanets = 0;
break;
case 7: /* NEPTUNE */
pCurDesc->data_index = BLU_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 1250L /* 2999L */ / 100;
pCurDesc->NumPlanets = 1;
break;
case 8: /* PLUTO */
pCurDesc->data_index = PELLUCID_WORLD;
pCurDesc->radius = EARTH_RADIUS * 1550L /* 3937L */ / 100;
pCurDesc->NumPlanets = 0;
angle = FULL_CIRCLE - OCTANT;
break;
}
pCurDesc->location.x = COSINE (angle, pCurDesc->radius);
pCurDesc->location.y = SINE (angle, pCurDesc->radius);
}
return true;
}
static bool
GenerateSol_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
COUNT planetNr;
DWORD rand_val;
GenerateDefault_generateMoons (solarSys, planet);
planetNr = planetIndex (solarSys, planet);
switch (planetNr)
{
case 2: /* moons of EARTH */
{
COUNT angle;
/* Starbase: */
solarSys->MoonDesc[0].data_index = HIERARCHY_STARBASE;
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS;
angle = HALF_CIRCLE + QUADRANT;
solarSys->MoonDesc[0].location.x =
COSINE (angle, solarSys->MoonDesc[0].radius);
solarSys->MoonDesc[0].location.y =
SINE (angle, solarSys->MoonDesc[0].radius);
/* Luna: */
solarSys->MoonDesc[1].data_index = SELENIC_WORLD;
solarSys->MoonDesc[1].radius = MIN_MOON_RADIUS
+ (MAX_MOONS - 1) * MOON_DELTA;
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
solarSys->MoonDesc[1].location.x =
COSINE (angle, solarSys->MoonDesc[1].radius);
solarSys->MoonDesc[1].location.y =
SINE (angle, solarSys->MoonDesc[1].radius);
break;
}
case 4: /* moons of JUPITER */
solarSys->MoonDesc[0].data_index = RADIOACTIVE_WORLD;
/* Io */
solarSys->MoonDesc[1].data_index = HALIDE_WORLD;
/* Europa */
solarSys->MoonDesc[2].data_index = CYANIC_WORLD;
/* Ganymede */
solarSys->MoonDesc[3].data_index = PELLUCID_WORLD;
/* Callisto */
break;
case 5: /* moons of SATURN */
solarSys->MoonDesc[0].data_index = ALKALI_WORLD;
/* Titan */
break;
case 7: /* moons of NEPTUNE */
solarSys->MoonDesc[0].data_index = VINYLOGOUS_WORLD;
/* Triton */
break;
}
return true;
}
static bool
GenerateSol_generateName (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
COUNT planetNr = planetIndex (solarSys, world);
utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + planetNr));
SET_GAME_STATE (BATTLE_PLANET, solarSys->PlanetDesc[planetNr].data_index);
return true;
}
static bool
GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
DWORD rand_val;
COUNT planetNr;
if (matchWorld (solarSys, world, 2, 0))
{
/* Starbase */
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
EncounterGroup = 0;
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
return true;
}
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
if (rand_val)
{
COUNT i;
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateMineralDeposits (&solarSys->SysInfo, &i);
}
planetNr = planetIndex (solarSys, world);
if (worldIsPlanet (solarSys, world))
{
switch (planetNr)
{
case 0: /* MERCURY */
solarSys->SysInfo.PlanetInfo.AtmoDensity = 0;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 98;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 38;
solarSys->SysInfo.PlanetInfo.AxialTilt = 3;
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 2;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 59 * 240;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 165;
break;
case 1: /* VENUS */
solarSys->SysInfo.PlanetInfo.AtmoDensity = 90 *
EARTH_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 95;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 95;
solarSys->SysInfo.PlanetInfo.AxialTilt = 177;
solarSys->SysInfo.PlanetInfo.Weather = 7;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 243 * 240;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 457;
break;
case 2: /* EARTH */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 100;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 100;
solarSys->SysInfo.PlanetInfo.AxialTilt = 23;
solarSys->SysInfo.PlanetInfo.Weather = 1;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 240;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 22;
break;
case 3: /* MARS */
// XXX: Mars atmo should actually be 1/2 in current units
solarSys->SysInfo.PlanetInfo.AtmoDensity = 1;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 72;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 53;
solarSys->SysInfo.PlanetInfo.AxialTilt = 24;
solarSys->SysInfo.PlanetInfo.Weather = 1;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 246;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -53;
break;
case 4: /* JUPITER */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 24;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 1120;
solarSys->SysInfo.PlanetInfo.AxialTilt = 3;
solarSys->SysInfo.PlanetInfo.Weather = 7;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 98;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -143;
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 520L / 100;
break;
case 5: /* SATURN */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 13;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 945;
solarSys->SysInfo.PlanetInfo.AxialTilt = 27;
solarSys->SysInfo.PlanetInfo.Weather = 7;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 102;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -197;
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 952L / 100;
break;
case 6: /* URANUS */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 21;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 411;
solarSys->SysInfo.PlanetInfo.AxialTilt = 98;
solarSys->SysInfo.PlanetInfo.Weather = 7;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 172;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -217;
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 1916L / 100;
break;
case 7: /* NEPTUNE */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 28;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 396;
solarSys->SysInfo.PlanetInfo.AxialTilt = 30;
solarSys->SysInfo.PlanetInfo.Weather = 7;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 182;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -229;
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 2999L / 100;
break;
case 8: /* PLUTO */
if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (SPAPLUTO_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (SPAPLUTO_STRTAB));
}
solarSys->SysInfo.PlanetInfo.AtmoDensity = 0;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 33;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 18;
solarSys->SysInfo.PlanetInfo.AxialTilt = 119;
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 1533;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -235;
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 3937L / 100;
break;
}
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity,
solarSys->SysInfo.PlanetInfo.PlanetRadius);
LoadPlanet (planetNr == 2 ?
CaptureDrawable (LoadGraphic (EARTH_MASK_ANIM)) : NULL);
}
else
{
// World is a moon.
COUNT moonNr = moonIndex (solarSys, world);
solarSys->SysInfo.PlanetInfo.AxialTilt = 0;
solarSys->SysInfo.PlanetInfo.AtmoDensity = 0;
solarSys->SysInfo.PlanetInfo.Weather = 0;
switch (planetNr)
{
case 2: /* moons of EARTH */
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] =
rand_val;
if (!GET_GAME_STATE (MOONBASE_DESTROYED))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (MOONBASE_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (MOONBASE_STRTAB));
}
solarSys->SysInfo.PlanetInfo.PlanetDensity = 60;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 25;
solarSys->SysInfo.PlanetInfo.AxialTilt = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 240 * 29;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -18;
break;
case 4: /* moons of JUPITER */
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 520L / 100;
switch (moonNr)
{
case 0: /* Io */
solarSys->SysInfo.PlanetInfo.PlanetDensity = 69;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 25;
solarSys->SysInfo.PlanetInfo.Tectonics = 3;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 390;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -163;
break;
case 1: /* Europa */
solarSys->SysInfo.PlanetInfo.PlanetDensity = 54;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 25;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 840;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -161;
break;
case 2: /* Ganymede */
solarSys->SysInfo.PlanetInfo.PlanetDensity = 35;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 41;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 1728;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -164;
break;
case 3: /* Callisto */
solarSys->SysInfo.PlanetInfo.PlanetDensity = 35;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 38;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 4008;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -167;
break;
}
break;
case 5: /* moon of SATURN: Titan */
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 952L / 100;
solarSys->SysInfo.PlanetInfo.AtmoDensity = 160;
solarSys->SysInfo.PlanetInfo.Weather = 2;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 34;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 40;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 3816;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -178;
break;
case 7: /* moon of NEPTUNE: Triton */
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 2999L / 100;
solarSys->SysInfo.PlanetInfo.AtmoDensity = 10;
solarSys->SysInfo.PlanetInfo.Weather = 1;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 95;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 27;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod = 4300;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -216;
break;
}
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity,
solarSys->SysInfo.PlanetInfo.PlanetRadius);
LoadPlanet (NULL);
}
return true;
}
static bool
GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 8, MATCH_PLANET))
{
/* Pluto */
if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
{
solarSys->SysInfo.PlanetInfo.CurPt.x = 20;
solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT - 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 2;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (FOUND_PLUTO_SPATHI, 1);
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
pLanderInputState->planetSideDesc->InTransit = TRUE;
}
else if (*whichNode == (COUNT)~0)
*whichNode = 1;
return true;
}
}
else if (matchWorld (solarSys, world, 2, 1)
&& !GET_GAME_STATE (MOONBASE_DESTROYED))
{
/* Earth Moon */
solarSys->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH * 3 / 4;
solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 1 / 4;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
{
*whichNode = 1;
}
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (MOONBASE_DESTROYED, 1);
SET_GAME_STATE (MOONBASE_ON_SHIP, 1);
}
}
return true;
}
*whichNode = 0;
return true;
}
static bool
GenerateSol_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (!matchWorld (solarSys, world, 2, 1))
{
*whichNode = 0;
}
else /* Earth Moon */
{
COUNT i;
COUNT nodeI;
DWORD old_rand;
DWORD rand_val;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES + 1;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 10);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
}
return true;
}
static int
init_probe (void)
{
HIPGROUP hGroup;
if (!GET_GAME_STATE (PROBE_MESSAGE_DELIVERED)
&& GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP)
&& (hGroup = GetHeadLink (&GLOBAL (ip_group_q))))
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
GroupPtr->task = IN_ORBIT;
GroupPtr->sys_loc = 2 + 1; /* orbitting earth */
GroupPtr->dest_loc = 2 + 1; /* orbitting earth */
GroupPtr->loc.x = 0;
GroupPtr->loc.y = 0;
GroupPtr->group_counter = 0;
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
return 1;
}
else
return 0;
}
static void
check_probe (void)
{
HIPGROUP hGroup;
IP_GROUP *GroupPtr;
if (!GLOBAL (BattleGroupRef))
return; // nothing to check
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
if (!hGroup)
return; // still nothing to check
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
// REFORM_GROUP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == URQUAN_DRONE_SHIP
&& (GroupPtr->task & REFORM_GROUP))
{
// We just want the probe to take off as fast as possible,
// so clear out REFORM_GROUP
GroupPtr->task = FLEE | IGNORE_FLAGSHIP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
+284
View File
@@ -0,0 +1,284 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lifeform.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateSpathi_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateSpathi_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
static bool GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateSpathi_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static bool GenerateSpathi_generateLife (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateSpathiFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateSpathi_generatePlanets,
/* .generateMoons = */ GenerateSpathi_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateSpathi_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateSpathi_generateEnergy,
/* .generateLife = */ GenerateSpathi_generateLife,
};
static bool
GenerateSpathi_generatePlanets (SOLARSYS_STATE *solarSys)
{
PLANET_DESC *pMinPlanet;
COUNT angle;
pMinPlanet = &solarSys->PlanetDesc[0];
solarSys->SunDesc[0].NumPlanets = 1;
FillOrbits (solarSys,
solarSys->SunDesc[0].NumPlanets, pMinPlanet, FALSE);
pMinPlanet->radius = EARTH_RADIUS * 1150L / 100;
angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y);
pMinPlanet->location.x = COSINE (angle, pMinPlanet->radius);
pMinPlanet->location.y = SINE (angle, pMinPlanet->radius);
pMinPlanet->data_index = WATER_WORLD;
if (GET_GAME_STATE (SPATHI_SHIELDED_SELVES))
pMinPlanet->data_index |= PLANET_SHIELDED;
pMinPlanet->NumPlanets = 1;
return true;
}
static bool
GenerateSpathi_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
COUNT angle;
GenerateDefault_generateMoons (solarSys, planet);
if (matchWorld (solarSys, planet, 0, MATCH_PLANET))
{
#ifdef NOTYET
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
"Spathiwa");
#endif /* NOTYET */
solarSys->MoonDesc[0].data_index = PELLUCID_WORLD;
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA;
angle = NORMALIZE_ANGLE (LOWORD (TFB_Random ()));
solarSys->MoonDesc[0].location.x =
COSINE (angle, solarSys->MoonDesc[0].radius);
solarSys->MoonDesc[0].location.y =
SINE (angle, solarSys->MoonDesc[0].radius);
}
return true;
}
static bool
GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
DWORD rand_val;
COUNT i;
if (matchWorld (solarSys, world, 0, 0))
{
/* Spathiwa's moon */
if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES)
&& ActivateStarShip (SPATHI_SHIP, SPHERE_TRACKING))
{
NotifyOthers (SPATHI_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (SPATHI_SHIP, &GLOBAL (npc_built_ship_q),
INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (SPATHI_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateLifeForms (&solarSys->SysInfo, &i);
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
GenerateMineralDeposits (&solarSys->SysInfo, &i);
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 28;
if (!GET_GAME_STATE (UMGAH_BROADCASTERS))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (UMGAH_BCS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (UMGAH_BCS_STRTAB));
}
LoadPlanet (NULL);
return true;
}
else if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
/* visiting Spathiwa */
rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world);
solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateMineralDeposits (&solarSys->SysInfo, &i);
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
solarSys->SysInfo.PlanetInfo.PlanetRadius = 120;
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity,
solarSys->SysInfo.PlanetInfo.PlanetRadius);
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 31;
LoadPlanet (NULL);
return true;
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateSpathi_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, 0)
&& !GET_GAME_STATE (UMGAH_BROADCASTERS))
{
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (UMGAH_BROADCASTERS, 1);
SET_GAME_STATE (UMGAH_BROADCASTERS_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
static bool
GenerateSpathi_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET)
&& !GET_GAME_STATE (SPATHI_SHIELDED_SELVES))
{
COUNT i;
COUNT nodeI;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
nodeI = 0;
i = 0;
do
{
DWORD rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 32);
*whichNode = nodeI;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN])
{
SET_GAME_STATE (SPATHI_CREATURES_EXAMINED, 1);
if (solarSys->SysInfo.
PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN] == 0xFFFFFFFF)
SET_GAME_STATE (SPATHI_CREATURES_ELIMINATED, 1);
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+178
View File
@@ -0,0 +1,178 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateSupox_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateSupox_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateSupoxFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateSupox_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateSupox_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateSupox_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateSupox_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 2;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 152L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateSupox_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (SUPOX_SHIP, SPHERE_TRACKING))
{
NotifyOthers (SUPOX_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (SUPOX_SHIP, &GLOBAL (npc_built_ship_q),
INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (SUPOX_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
if (!GET_GAME_STATE (ULTRON_CONDITION))
{
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
}
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (!GET_GAME_STATE (ULTRON_CONDITION))
solarSys->SysInfo.PlanetInfo.CurType = 0;
else
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!GET_GAME_STATE (ULTRON_CONDITION))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (ULTRON_CONDITION, 1);
}
}
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+101
View File
@@ -0,0 +1,101 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../comm.h"
static bool GenerateSyreen_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateSyreen_generateMoons (SOLARSYS_STATE *solarSys,
PLANET_DESC *planet);
static bool GenerateSyreen_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
const GenerateFunctions generateSyreenFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateSyreen_generatePlanets,
/* .generateMoons = */ GenerateSyreen_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateSyreen_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateSyreen_generatePlanets (SOLARSYS_STATE *solarSys)
{
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = WATER_WORLD | PLANET_SHIELDED;
solarSys->PlanetDesc[0].NumPlanets = 1;
return true;
}
static bool
GenerateSyreen_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
{
GenerateDefault_generateMoons (solarSys, planet);
if (matchWorld (solarSys, planet, 0, MATCH_PLANET))
{
solarSys->MoonDesc[0].data_index = HIERARCHY_STARBASE;
solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS;
solarSys->MoonDesc[0].location.x =
COSINE (QUADRANT, solarSys->MoonDesc[0].radius);
solarSys->MoonDesc[0].location.y =
SINE (QUADRANT, solarSys->MoonDesc[0].radius);
}
return true;
}
static bool
GenerateSyreen_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
/* Syreen home planet */
GenerateDefault_generateOrbital (solarSys, world);
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 19;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
solarSys->SysInfo.PlanetInfo.Weather = 0;
solarSys->SysInfo.PlanetInfo.AtmoDensity = EARTH_ATMOSPHERE * 9 / 10;
return true;
}
if (matchWorld (solarSys, world, 0, 0))
{
/* Starbase */
solarSys->MenuState.Initialized += 2;
InitCommunication (SYREEN_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
return true;
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
+234
View File
@@ -0,0 +1,234 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateThraddash_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateThraddash_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateThraddash_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateThraddashFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateThraddash_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateThraddash_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateThraddash_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateThraddash_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED)
{
solarSys->PlanetDesc[0].data_index = PRIMORDIAL_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 65L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
}
else /* CurStarDescPtr->Index == THRADD_DEFINED */
{
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 0;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 98L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
}
return true;
}
static bool
GenerateThraddash_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (THRADDASH_SHIP, SPHERE_TRACKING)
&& (CurStarDescPtr->Index == THRADD_DEFINED
|| (!GET_GAME_STATE (HELIX_UNPROTECTED)
&& (BYTE)(GET_GAME_STATE (THRADD_MISSION) - 1) >= 3)))
{
NotifyOthers (THRADDASH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (THRADDASH_SHIP, &GLOBAL (npc_built_ship_q),
INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
if (CurStarDescPtr->Index == THRADD_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
InitCommunication (THRADD_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
return true;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (CurStarDescPtr->Index == THRADD_DEFINED
|| (!GET_GAME_STATE (HELIX_UNPROTECTED)
&& (BYTE)(GET_GAME_STATE (THRADD_MISSION) - 1) >= 3))
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED
&& !GET_GAME_STATE (AQUA_HELIX))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (AQUA_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (AQUA_STRTAB));
}
else if (CurStarDescPtr->Index == THRADD_DEFINED)
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateThraddash_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
DWORD rand_val;
DWORD old_rand;
if (CurStarDescPtr->Index != AQUA_HELIX_DEFINED)
{
COUNT i;
COUNT nodeI;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
if (!GET_GAME_STATE (AQUA_HELIX))
{
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0)) && *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (HELIX_VISITS, 0);
SET_GAME_STATE (AQUA_HELIX, 1);
SET_GAME_STATE (AQUA_HELIX_ON_SHIP, 1);
SET_GAME_STATE (HELIX_UNPROTECTED, 1);
}
}
TFB_SeedRandom (old_rand);
return true;
}
}
*whichNode = 0;
return true;
}
+77
View File
@@ -0,0 +1,77 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
static bool GenerateTrap_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateTrap_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
const GenerateFunctions generateTrapFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateTrap_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateTrap_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateTrap_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = TELLURIC_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 203L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateTrap_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
GenerateDefault_generateOrbital (solarSys, world);
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
solarSys->SysInfo.PlanetInfo.AtmoDensity = EARTH_ATMOSPHERE * 2;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 35;
solarSys->SysInfo.PlanetInfo.Weather = 3;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
}
return true;
}
+289
View File
@@ -0,0 +1,289 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateUtwig_initNpcs (void);
static bool GenerateUtwig_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateUtwig_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateUtwigFunctions = {
/* .initNpcs = */ GenerateUtwig_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateUtwig_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateUtwig_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateUtwig_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateUtwig_initNpcs (void)
{
if (CurStarDescPtr->Index == BOMB_DEFINED
&& !GET_GAME_STATE (UTWIG_BOMB))
{
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
}
else
{
GenerateDefault_initNpcs ();
}
return true;
}
static bool
GenerateUtwig_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
if (CurStarDescPtr->Index == UTWIG_DEFINED)
{
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 174L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
}
return true;
}
static bool
GenerateUtwig_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if ((CurStarDescPtr->Index == UTWIG_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
|| (CurStarDescPtr->Index == BOMB_DEFINED
&& matchWorld (solarSys, world, 5, 1)
&& !GET_GAME_STATE (UTWIG_BOMB)))
{
if ((CurStarDescPtr->Index == UTWIG_DEFINED
|| !GET_GAME_STATE (UTWIG_HAVE_ULTRON))
&& ActivateStarShip (UTWIG_SHIP, SPHERE_TRACKING))
{
NotifyOthers (UTWIG_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (UTWIG_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
if (CurStarDescPtr->Index == UTWIG_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
InitCommunication (UTWIG_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
if (CurStarDescPtr->Index == BOMB_DEFINED
&& !GET_GAME_STATE (BOMB_UNPROTECTED)
&& ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING))
{
COUNT i;
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
for (i = 0; i < 5; ++i)
{
CloneShipFragment (DRUUGE_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
InitCommunication (DRUUGE_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
return true;
{
BOOLEAN DruugeSurvivors;
DruugeSurvivors =
GetHeadLink (&GLOBAL (npc_built_ship_q)) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (DruugeSurvivors)
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
SET_GAME_STATE (BOMB_UNPROTECTED, 1);
}
}
if (CurStarDescPtr->Index == BOMB_DEFINED)
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (BOMB_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (BOMB_STRTAB));
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
}
GenerateDefault_generateOrbital (solarSys, world);
if (CurStarDescPtr->Index == UTWIG_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
{
solarSys->SysInfo.PlanetInfo.Weather = 1;
solarSys->SysInfo.PlanetInfo.Tectonics = 1;
}
return true;
}
static bool
GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
DWORD rand_val;
DWORD old_rand;
if (CurStarDescPtr->Index == UTWIG_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
if (CurStarDescPtr->Index == BOMB_DEFINED
&& matchWorld (solarSys, world, 5, 1)
&& !GET_GAME_STATE (UTWIG_BOMB))
{
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (UTWIG_BOMB, 1);
SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 1);
SET_GAME_STATE (DRUUGE_MANNER, 1);
SET_GAME_STATE (DRUUGE_VISITS, 0);
SET_GAME_STATE (DRUUGE_HOME_VISITS, 0);
}
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+127
View File
@@ -0,0 +1,127 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../globdata.h"
#include "../../nameref.h"
#include "../../resinst.h"
#include "libs/mathlib.h"
static bool GenerateVault_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateVault_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateVaultFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateDefault_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateVault_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateVault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateVault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, 0))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (VAULT_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (VAULT_STRTAB));
if (GET_GAME_STATE (SHIP_VAULT_UNLOCKED))
{
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 2);
}
else if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP))
{
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateVault_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, 0))
{
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (!GET_GAME_STATE (SHIP_VAULT_UNLOCKED))
solarSys->SysInfo.PlanetInfo.CurType = 0;
else
solarSys->SysInfo.PlanetInfo.CurType = 1;
*whichNode = 1;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (SHIP_VAULT_UNLOCKED, 1);
SET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP, 0);
SET_GAME_STATE (SYREEN_HOME_VISITS, 0);
}
else if (!GET_GAME_STATE (KNOW_SYREEN_VAULT))
{
SET_GAME_STATE (KNOW_SYREEN_VAULT, 1);
SET_GAME_STATE (SYREEN_HOME_VISITS, 0);
}
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+366
View File
@@ -0,0 +1,366 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../lifeform.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../encount.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../setup.h"
#include "../../sounds.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateVux_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateVux_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateVux_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
static bool GenerateVux_generateLife (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateVuxFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateVux_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateVux_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateVux_generateEnergy,
/* .generateLife = */ GenerateVux_generateLife,
};
static bool
GenerateVux_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
if (CurStarDescPtr->Index == MAIDENS_DEFINED)
{
GenerateDefault_generatePlanets (solarSys);
// XXX: this is the second time that this function is
// called. Is it safe to remove one, or does this change
// the RNG so that the outcome is different?
solarSys->PlanetDesc[0].data_index = REDUX_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 212L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
}
else
{
if (CurStarDescPtr->Index == VUX_DEFINED)
{
solarSys->PlanetDesc[0].data_index = REDUX_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 42L / 100;
angle = HALF_CIRCLE + OCTANT;
}
else /* if (CurStarDescPtr->Index == VUX_BEAST_DEFINED) */
{
memmove (&solarSys->PlanetDesc[1], &solarSys->PlanetDesc[0],
sizeof (solarSys->PlanetDesc[0])
* solarSys->SunDesc[0].NumPlanets);
++solarSys->SunDesc[0].NumPlanets;
angle = HALF_CIRCLE - OCTANT;
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 110L / 100;
solarSys->PlanetDesc[0].NumPlanets = 0;
}
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].rand_seed = MAKE_DWORD (
solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
}
return true;
}
static bool
GenerateVux_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if ((matchWorld (solarSys, world, 0, MATCH_PLANET)
&& (CurStarDescPtr->Index == VUX_DEFINED
|| (CurStarDescPtr->Index == MAIDENS_DEFINED
&& !GET_GAME_STATE (ZEX_IS_DEAD))))
&& ActivateStarShip (VUX_SHIP, SPHERE_TRACKING))
{
NotifyOthers (VUX_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (VUX_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
if (CurStarDescPtr->Index == VUX_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (VUX_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
return true;
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (CurStarDescPtr->Index == VUX_DEFINED
|| !GET_GAME_STATE (ZEX_IS_DEAD))
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (CurStarDescPtr->Index == MAIDENS_DEFINED)
{
if (!GET_GAME_STATE (SHOFIXTI_MAIDENS))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] = CaptureDrawable (
LoadGraphic (MAIDENS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (MAIDENS_STRTAB));
}
}
else if (CurStarDescPtr->Index == VUX_BEAST_DEFINED)
{
if (!GET_GAME_STATE (VUX_BEAST))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] = 0;
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (BEAST_STRTAB));
}
}
else
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
}
GenerateDefault_generateOrbital (solarSys, world);
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
solarSys->SysInfo.PlanetInfo.Weather = 2;
solarSys->SysInfo.PlanetInfo.Tectonics = 0;
}
return true;
}
static bool
GenerateVux_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET)
&& CurStarDescPtr->Index != VUX_BEAST_DEFINED)
{
if (CurStarDescPtr->Index == MAIDENS_DEFINED
&& !GET_GAME_STATE (SHOFIXTI_MAIDENS))
{
solarSys->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH / 3;
solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 5 / 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
solarSys->SysInfo.PlanetInfo.CurType = 0;
if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& *whichNode == (COUNT)~0)
*whichNode = 1;
else
{
*whichNode = 0;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (SHOFIXTI_MAIDENS, 1);
SET_GAME_STATE (MAIDENS_ON_SHIP, 1);
}
}
return true;
}
if (CurStarDescPtr->Index == VUX_DEFINED)
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
}
*whichNode = 0;
return true;
}
static bool
GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (CurStarDescPtr->Index == MAIDENS_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
i = 0;
do
{
DWORD rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (i < 4)
solarSys->SysInfo.PlanetInfo.CurType = 9;
else if (i < 8)
solarSys->SysInfo.PlanetInfo.CurType = 14;
else /* if (i < 12) */
solarSys->SysInfo.PlanetInfo.CurType = 18;
if (i >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
} while (++i < 12);
*whichNode = i;
TFB_SeedRandom (old_rand);
return true;
}
if (CurStarDescPtr->Index == VUX_BEAST_DEFINED
&& matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
i = 0;
do
{
DWORD rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (i == 0)
solarSys->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES + 2;
else if (i <= 5)
/* {SPEED_MOTIONLESS | DANGER_NORMAL, MAKE_BYTE (5, 3)}, */
solarSys->SysInfo.PlanetInfo.CurType = 3;
else /* if (i <= 10) */
/* {BEHAVIOR_UNPREDICTABLE | SPEED_SLOW | DANGER_NORMAL, MAKE_BYTE (3, 8)}, */
solarSys->SysInfo.PlanetInfo.CurType = 8;
if (i >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
else if (i == 0
&& (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i))
&& !GET_GAME_STATE (VUX_BEAST))
{
UnbatchGraphics ();
DoDiscoveryReport (MenuSounds);
BatchGraphics ();
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (VUX_BEAST, 1);
SET_GAME_STATE (VUX_BEAST_ON_SHIP, 1);
}
} while (++i < 11);
*whichNode = i;
TFB_SeedRandom (old_rand);
return true;
}
GenerateDefault_generateLife (solarSys, world, whichNode);
return true;
}
+115
View File
@@ -0,0 +1,115 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../lander.h"
#include "../planets.h"
#include "../../globdata.h"
#include "../../nameref.h"
#include "../../resinst.h"
#include "libs/mathlib.h"
static bool GenerateWreck_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateWreck_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateWreckFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateDefault_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateWreck_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateWreck_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateWreck_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 6, MATCH_PLANET))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (WRECK_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (WRECK_STRTAB));
if (GET_GAME_STATE (PORTAL_KEY))
{
solarSys->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
}
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateWreck_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 6, MATCH_PLANET))
{
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (!GET_GAME_STATE (PORTAL_KEY))
solarSys->SysInfo.PlanetInfo.CurType = 0;
else
solarSys->SysInfo.PlanetInfo.CurType = 1;
*whichNode = 1;
if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
if (!GET_GAME_STATE (PORTAL_KEY))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (PORTAL_KEY, 1);
SET_GAME_STATE (PORTAL_KEY_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
+152
View File
@@ -0,0 +1,152 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../ipdisp.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateYehat_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateYehat_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateYehat_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateYehatFunctions = {
/* .initNpcs = */ GenerateDefault_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateYehat_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateYehat_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateYehat_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateYehat_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = WATER_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 106L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateYehat_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING))
{
NotifyOthers (YEHAT_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (YEHAT_SHIP, &GLOBAL (npc_built_ship_q),
INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (YEHAT_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateYehat_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
@@ -0,0 +1,93 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../../build.h"
#include "../../globdata.h"
#include "../../grpinfo.h"
#include "../../state.h"
static bool GenerateZoqFotPikScout_initNpcs (void);
static bool GenerateZoqFotPikScout_reinitNpcs (void);
const GenerateFunctions generateZoqFotPikScoutFunctions = {
/* .initNpcs = */ GenerateZoqFotPikScout_initNpcs,
/* .reinitNpcs = */ GenerateZoqFotPikScout_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateDefault_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateDefault_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateDefault_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateZoqFotPikScout_initNpcs (void)
{
if (!GET_GAME_STATE (MET_ZOQFOT))
{
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (ZOQFOT_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (ZOQFOTPIK_SHIP,
&GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (ZOQFOT_GRPOFFS0, GLOBAL (BattleGroupRef));
}
}
GenerateDefault_initNpcs ();
return true;
}
static bool
GenerateZoqFotPikScout_reinitNpcs (void)
{
HIPGROUP hGroup;
IP_GROUP *GroupPtr;
GenerateDefault_reinitNpcs ();
if (!GLOBAL (BattleGroupRef))
return true; // nothing to check
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
if (!hGroup)
return true; // still nothing to check
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
// REFORM_GROUP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == ZOQFOTPIK_SHIP
&& (GroupPtr->task & REFORM_GROUP))
{
GroupPtr->task = FLEE | IGNORE_FLAGSHIP | REFORM_GROUP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
return true;
}
+184
View File
@@ -0,0 +1,184 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../planets.h"
#include "../../build.h"
#include "../../comm.h"
#include "../../globdata.h"
#include "../../nameref.h"
#include "../../state.h"
#include "libs/mathlib.h"
static bool GenerateZoqFotPik_initNpcs (void);
static bool GenerateZoqFotPik_generatePlanets (SOLARSYS_STATE *solarSys);
static bool GenerateZoqFotPik_generateOrbital (SOLARSYS_STATE *solarSys,
PLANET_DESC *world);
static bool GenerateZoqFotPik_generateEnergy (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *whichNode);
const GenerateFunctions generateZoqFotPikFunctions = {
/* .initNpcs = */ GenerateZoqFotPik_initNpcs,
/* .reinitNpcs = */ GenerateDefault_reinitNpcs,
/* .uninitNpcs = */ GenerateDefault_uninitNpcs,
/* .generatePlanets = */ GenerateZoqFotPik_generatePlanets,
/* .generateMoons = */ GenerateDefault_generateMoons,
/* .generateName = */ GenerateDefault_generateName,
/* .generateOrbital = */ GenerateZoqFotPik_generateOrbital,
/* .generateMinerals = */ GenerateDefault_generateMinerals,
/* .generateEnergy = */ GenerateZoqFotPik_generateEnergy,
/* .generateLife = */ GenerateDefault_generateLife,
};
static bool
GenerateZoqFotPik_initNpcs (void)
{
if (GET_GAME_STATE (ZOQFOT_DISTRESS) != 1)
GenerateDefault_initNpcs ();
return true;
}
static bool
GenerateZoqFotPik_generatePlanets (SOLARSYS_STATE *solarSys)
{
COUNT angle;
GenerateDefault_generatePlanets (solarSys);
solarSys->PlanetDesc[0].data_index = REDUX_WORLD;
solarSys->PlanetDesc[0].NumPlanets = 1;
solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 138L / 100;
angle = ARCTAN (solarSys->PlanetDesc[0].location.x,
solarSys->PlanetDesc[0].location.y);
solarSys->PlanetDesc[0].location.x =
COSINE (angle, solarSys->PlanetDesc[0].radius);
solarSys->PlanetDesc[0].location.y =
SINE (angle, solarSys->PlanetDesc[0].radius);
return true;
}
static bool
GenerateZoqFotPik_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
if (ActivateStarShip (ZOQFOTPIK_SHIP, SPHERE_TRACKING))
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (GET_GAME_STATE (ZOQFOT_DISTRESS))
{
CloneShipFragment (BLACK_URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (BLACKURQ_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
return true;
if (GetHeadLink (&GLOBAL (npc_built_ship_q)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
return true;
}
}
CloneShipFragment (ZOQFOTPIK_SHIP, &GLOBAL (npc_built_ship_q),
INFINITE_FLEET);
solarSys->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (ZOQFOTPIK_CONVERSATION);
solarSys->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
return true;
}
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->PlanetSideFrame[1] =
CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM));
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (RUINS_STRTAB));
}
GenerateDefault_generateOrbital (solarSys, world);
return true;
}
static bool
GenerateZoqFotPik_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *whichNode)
{
if (matchWorld (solarSys, world, 0, MATCH_PLANET))
{
COUNT i;
COUNT nodeI;
DWORD rand_val;
DWORD old_rand;
old_rand = TFB_SeedRandom (
solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]);
nodeI = 0;
i = 0;
do
{
rand_val = TFB_Random ();
solarSys->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
solarSys->SysInfo.PlanetInfo.CurType = 1;
solarSys->SysInfo.PlanetInfo.CurDensity = 0;
if (nodeI >= *whichNode
&& !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++nodeI;
} while (++i < 16);
*whichNode = nodeI;
TFB_SeedRandom (old_rand);
return true;
}
*whichNode = 0;
return true;
}
-134
View File
@@ -1,134 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateIlwrath (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = PRIMORDIAL_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 204L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING))
{
NotifyOthers (ILWRATH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (ILWRATH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (ILWRATH_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
GenerateRandomIP (GENERATE_ORBITAL);
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.Weather = 2;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 3;
}
break;
default:
GenerateRandomIP (control);
break;
}
}
-115
View File
@@ -1,115 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../state.h"
#include "libs/log.h"
static int
SelectMelnormeRefVar (void)
{
int RefVar;
switch (CurStarDescPtr->Index)
{
case MELNORME0_DEFINED:
RefVar = MELNORME0_GRPOFFS0;
break;
case MELNORME1_DEFINED:
RefVar = MELNORME1_GRPOFFS0;
break;
case MELNORME2_DEFINED:
RefVar = MELNORME2_GRPOFFS0;
break;
case MELNORME3_DEFINED:
RefVar = MELNORME3_GRPOFFS0;
break;
case MELNORME4_DEFINED:
RefVar = MELNORME4_GRPOFFS0;
break;
case MELNORME5_DEFINED:
RefVar = MELNORME5_GRPOFFS0;
break;
case MELNORME6_DEFINED:
RefVar = MELNORME6_GRPOFFS0;
break;
case MELNORME7_DEFINED:
RefVar = MELNORME7_GRPOFFS0;
break;
case MELNORME8_DEFINED:
RefVar = MELNORME8_GRPOFFS0;
break;
default:
RefVar = -1;
}
return RefVar;
}
static DWORD
GetMelnormeRef (void)
{
int RefVar = SelectMelnormeRefVar ();
if (RefVar < 0)
{
log_add (log_Warning, "GetMelnormeRef(): reference unknown");
return 0;
}
return GET_GAME_STATE_32 (RefVar);
}
static void
SetMelnormeRef (DWORD Ref)
{
int RefVar = SelectMelnormeRefVar ();
if (RefVar < 0)
{
log_add (log_Warning, "SetMelnormeRef(): reference unknown");
return;
}
SET_GAME_STATE_32 (RefVar, Ref);
}
void
GenerateMelnorme (BYTE control)
{
switch (control)
{
case INIT_NPCS:
GLOBAL (BattleGroupRef) = GetMelnormeRef ();
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (MELNORME_SHIP,
&GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SetMelnormeRef (GLOBAL (BattleGroupRef));
}
GenerateRandomIP (INIT_NPCS);
break;
default:
GenerateRandomIP (control);
break;
}
}
-235
View File
@@ -1,235 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../setup.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateMycon (BYTE control)
{
switch (control)
{
case GENERATE_LIFE:
pSolarSysState->CurNode = 0;
break;
case GENERATE_ENERGY:
if (CurStarDescPtr->Index != MYCON_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (CurStarDescPtr->Index == SUN_DEVICE_DEFINED)
{
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (SUN_DEVICE, 1);
SET_GAME_STATE (SUN_DEVICE_ON_SHIP, 1);
SET_GAME_STATE (MYCON_VISITS, 0);
}
}
}
else
{
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if ((pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->SysInfo.PlanetInfo.DiscoveryString)
{
switch (CurStarDescPtr->Index)
{
case EGG_CASE0_DEFINED:
SET_GAME_STATE (EGG_CASE0_ON_SHIP, 1);
break;
case EGG_CASE1_DEFINED:
SET_GAME_STATE (EGG_CASE1_ON_SHIP, 1);
break;
case EGG_CASE2_DEFINED:
SET_GAME_STATE (EGG_CASE2_ON_SHIP, 1);
break;
}
}
}
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = SHATTERED_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 80L / 100;
if (pSolarSysState->PlanetDesc[0].NumPlanets > 2)
pSolarSysState->PlanetDesc[0].NumPlanets = 2;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if ((CurStarDescPtr->Index == MYCON_DEFINED
|| CurStarDescPtr->Index == SUN_DEVICE_DEFINED)
&& ActivateStarShip (MYCON_SHIP, SPHERE_TRACKING))
{
if (CurStarDescPtr->Index == MYCON_DEFINED
|| !GET_GAME_STATE (SUN_DEVICE_UNGUARDED))
{
NotifyOthers (MYCON_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (CurStarDescPtr->Index == MYCON_DEFINED
|| !GET_GAME_STATE (MYCON_FELL_FOR_AMBUSH))
CloneShipFragment (MYCON_SHIP,
&GLOBAL (npc_built_ship_q),
INFINITE_FLEET);
else
{
COUNT i;
for (i = 0; i < 5; ++i)
CloneShipFragment (MYCON_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
if (CurStarDescPtr->Index == MYCON_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
InitCommunication (MYCON_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
break;
{
BOOLEAN MyconSurvivors;
MyconSurvivors = GetHeadLink (
&GLOBAL (npc_built_ship_q)
) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (MyconSurvivors)
break;
SET_GAME_STATE (SUN_DEVICE_UNGUARDED, 1);
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
}
switch (CurStarDescPtr->Index)
{
case SUN_DEVICE_DEFINED:
if (!GET_GAME_STATE (SUN_DEVICE))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (SUN_DEVICE_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (SUN_DEVICE_STRTAB)
);
}
break;
case EGG_CASE0_DEFINED:
case EGG_CASE1_DEFINED:
case EGG_CASE2_DEFINED:
if (GET_GAME_STATE (KNOW_ABOUT_SHATTERED) == 0)
{
SET_GAME_STATE (KNOW_ABOUT_SHATTERED, 1);
}
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0)))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (EGG_CASE_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (EGG_CASE_STRTAB)
);
}
break;
}
}
default:
GenerateRandomIP (control);
break;
}
}
-366
View File
@@ -1,366 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../setup.h"
#include "../state.h"
#include "../sounds.h"
#include "libs/mathlib.h"
static void
GenerateAndrosynth (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
{
DWORD rand_val, old_rand;
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1])
{
COUNT i, which_node;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << (i + 16))))
{
SET_GAME_STATE (PLANETARY_CHANGE, 1);
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
|= (1L << (i + 16));
if (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString)
{
UnbatchGraphics ();
DoDiscoveryReport (MenuSounds);
BatchGraphics ();
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetRelStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
}
}
}
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
}
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[1].data_index = TELLURIC_WORLD;
pSolarSysState->PlanetDesc[1].radius = EARTH_RADIUS * 204L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[1].location.x,
pSolarSysState->PlanetDesc[1].location.y
);
pSolarSysState->PlanetDesc[1].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[1].radius);
pSolarSysState->PlanetDesc[1].location.y =
SINE (angle, pSolarSysState->PlanetDesc[1].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1])
{
UWORD retval;
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (ANDROSYNTH_RUINS_STRTAB)
);
retval = HIWORD (
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
);
while (retval)
{
if (retval & 1)
{
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetRelStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
if (GetStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
) == 0)
{
DestroyStringTable (ReleaseStringTable (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;
}
}
retval >>= 1;
}
}
GenerateRandomIP (GENERATE_ORBITAL);
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1])
{
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE * 144 / 100;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 28;
pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
}
break;
default:
GenerateRandomIP (control);
break;
}
}
void
GenerateOrz (BYTE control)
{
if (CurStarDescPtr && CurStarDescPtr->Index == ANDROSYNTH_DEFINED)
{
GenerateAndrosynth (control);
return;
}
switch (control)
{
case GENERATE_ENERGY:
{
DWORD rand_val, old_rand;
if (CurStarDescPtr->Index != ORZ_DEFINED
&& pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[1]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[2]
&& !GET_GAME_STATE (TAALO_PROTECTOR))
{
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (TAALO_PROTECTOR, 1);
SET_GAME_STATE (TAALO_PROTECTOR_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
break;
}
else if (CurStarDescPtr->Index == ORZ_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
}
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
if (CurStarDescPtr->Index == ORZ_DEFINED)
{
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 156L / 100;
pSolarSysState->PlanetDesc[0].NumPlanets = 0;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
}
break;
}
case GENERATE_ORBITAL:
if ((CurStarDescPtr->Index == ORZ_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
|| (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED
&& pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[1]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[2]
&& !GET_GAME_STATE (TAALO_PROTECTOR)))
{
COUNT i;
if ((CurStarDescPtr->Index == ORZ_DEFINED
|| !GET_GAME_STATE (TAALO_UNPROTECTED))
&& ActivateStarShip (ORZ_SHIP, SPHERE_TRACKING))
{
NotifyOthers (ORZ_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (CurStarDescPtr->Index == ORZ_DEFINED)
{
CloneShipFragment (ORZ_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
for (i = 0; i < 14; ++i)
CloneShipFragment (ORZ_SHIP,
&GLOBAL (npc_built_ship_q), 0);
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (ORZ_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
break;
else
{
BOOLEAN OrzSurvivors;
OrzSurvivors = GetHeadLink (&GLOBAL (npc_built_ship_q))
&& (CurStarDescPtr->Index == ORZ_DEFINED
|| !GET_GAME_STATE (TAALO_UNPROTECTED));
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (OrzSurvivors)
break;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
SET_GAME_STATE (TAALO_UNPROTECTED, 1);
if (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED)
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (TAALO_DEVICE_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (TAALO_DEVICE_STRTAB)
);
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
-242
View File
@@ -1,242 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../setup.h"
#include "../state.h"
#include "libs/mathlib.h"
static void
ZapToUrquanEncounter (void)
{
HENCOUNTER hEncounter;
if ((hEncounter = AllocEncounter ()) || (hEncounter = GetHeadEncounter ()))
{
SIZE dx, dy;
ENCOUNTER *EncounterPtr;
HFLEETINFO hStarShip;
FLEET_INFO *TemplatePtr;
BRIEF_SHIP_INFO *BSIPtr;
LockEncounter (hEncounter, &EncounterPtr);
if (hEncounter == GetHeadEncounter ())
RemoveEncounter (hEncounter);
memset (EncounterPtr, 0, sizeof (*EncounterPtr));
InsertEncounter (hEncounter, GetHeadEncounter ());
hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), URQUAN_SHIP);
TemplatePtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
EncounterPtr->origin = TemplatePtr->loc;
EncounterPtr->radius = TemplatePtr->actual_strength;
EncounterPtr->SD.Type = URQUAN_SHIP;
EncounterPtr->SD.Index = MAKE_BYTE (1, 0) | ONE_SHOT_ENCOUNTER;
BSIPtr = &EncounterPtr->ShipList[0];
BSIPtr->race_id = URQUAN_SHIP;
BSIPtr->crew_level = TemplatePtr->crew_level;
BSIPtr->max_crew = TemplatePtr->max_crew;
BSIPtr->max_energy = TemplatePtr->max_energy;
EncounterPtr->SD.star_pt.x = 5288;
EncounterPtr->SD.star_pt.y = 4892;
EncounterPtr->log_x = UNIVERSE_TO_LOGX (EncounterPtr->SD.star_pt.x);
EncounterPtr->log_y = UNIVERSE_TO_LOGY (EncounterPtr->SD.star_pt.y);
GLOBAL_SIS (log_x) = EncounterPtr->log_x;
GLOBAL_SIS (log_y) = EncounterPtr->log_y;
UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
{
#define LOST_DAYS 15
BYTE black_buf[] = {FadeAllToBlack};
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND * 2));
LockMutex (GraphicsLock);
MoveGameClockDays (LOST_DAYS);
UnlockMutex (GraphicsLock);
}
GLOBAL (CurrentActivity) = MAKE_WORD (IN_HYPERSPACE, 0) | START_ENCOUNTER;
dx = CurStarDescPtr->star_pt.x - EncounterPtr->SD.star_pt.x;
dy = CurStarDescPtr->star_pt.y - EncounterPtr->SD.star_pt.y;
dx = (SIZE)square_root ((long)dx * dx + (long)dy * dy)
+ (FUEL_TANK_SCALE >> 1);
LockMutex (GraphicsLock);
DeltaSISGauges (0, -dx, 0);
if (GLOBAL_SIS (FuelOnBoard) < 5 * FUEL_TANK_SCALE)
{
dx = ((5 + ((COUNT)TFB_Random () % 5)) * FUEL_TANK_SCALE)
- (SIZE)GLOBAL_SIS (FuelOnBoard);
DeltaSISGauges (0, dx, 0);
}
DrawSISMessage (NULL);
DrawHyperCoords (EncounterPtr->SD.star_pt);
UnlockMutex (GraphicsLock);
UnlockEncounter (hEncounter);
}
}
void
GenerateTalkingPet (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = TELLURIC_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 204L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]
&& (GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES)
|| !GET_GAME_STATE (TALKING_PET)
|| ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING)))
{
NotifyOthers (UMGAH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING))
{
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
if (!GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES))
{
CloneShipFragment (UMGAH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
InitCommunication (UMGAH_CONVERSATION);
}
else
{
COUNT i;
for (i = 0; i < 10; ++i)
CloneShipFragment (UMGAH_SHIP,
&GLOBAL (npc_built_ship_q), 0);
InitCommunication (TALKING_PET_CONVERSATION);
}
pSolarSysState->MenuState.Initialized -= 2;
}
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
BOOLEAN UmgahSurvivors;
UmgahSurvivors = GetHeadLink (
&GLOBAL (npc_built_ship_q)
) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
if (GET_GAME_STATE (PLAYER_HYPNOTIZED))
ZapToUrquanEncounter ();
else if (GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES)
&& !UmgahSurvivors)
{
// Defeated the zombie fleet.
InitCommunication (TALKING_PET_CONVERSATION);
}
else if (!(ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING)))
{
// The Kohr-Ah have destroyed the Umgah, but the
// talking pet survived.
InitCommunication (TALKING_PET_CONVERSATION);
}
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
GenerateRandomIP (GENERATE_ORBITAL);
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
break;
default:
GenerateRandomIP (control);
break;
}
}
-152
View File
@@ -1,152 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GeneratePkunk (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (!GET_GAME_STATE (CLEAR_SPINDLE))
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
else
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!GET_GAME_STATE (CLEAR_SPINDLE))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (CLEAR_SPINDLE, 1);
SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1);
}
}
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 104L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (PKUNK_SHIP, SPHERE_TRACKING))
{
NotifyOthers (PKUNK_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (PKUNK_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (PKUNK_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (PKUNK_RUINS_STRTAB)
);
if (GET_GAME_STATE (CLEAR_SPINDLE))
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
-79
View File
@@ -1,79 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../encount.h"
void
GenerateRainbow (BYTE control)
{
switch (control)
{
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = RAINBOW_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 0;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 50L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
if (angle <= QUADRANT)
angle += QUADRANT;
else if (angle >= FULL_CIRCLE - QUADRANT)
angle -= QUADRANT;
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
BYTE which_rainbow;
UWORD rainbow_mask;
STAR_DESC *SDPtr;
rainbow_mask = MAKE_WORD (
GET_GAME_STATE (RAINBOW_WORLD0),
GET_GAME_STATE (RAINBOW_WORLD1)
);
which_rainbow = 0;
SDPtr = &star_array[0];
while (SDPtr != CurStarDescPtr)
{
if (SDPtr->Index == RAINBOW_DEFINED)
++which_rainbow;
++SDPtr;
}
rainbow_mask |= 1 << which_rainbow;
SET_GAME_STATE (RAINBOW_WORLD0, LOBYTE (rainbow_mask));
SET_GAME_STATE (RAINBOW_WORLD1, HIBYTE (rainbow_mask));
}
default:
GenerateRandomIP (control);
break;
}
}
-271
View File
@@ -1,271 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../races.h"
#include "../state.h"
#include "../grpinfo.h"
#include "libs/mathlib.h"
static void
BuildUrquanGuard (void)
{
BYTE ship1, ship2;
BYTE b0, b1;
POINT org;
HIPGROUP hGroup, hNextGroup;
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (SAMATRA_GRPOFFS0);
if (!GET_GAME_STATE (KOHR_AH_FRENZY))
ship1 = URQUAN_SHIP, ship2 = BLACK_URQUAN_SHIP;
else
ship1 = BLACK_URQUAN_SHIP, ship2 = URQUAN_SHIP;
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
for (b0 = 0; b0 < MAX_SHIPS_PER_SIDE; ++b0)
CloneShipFragment (ship1,
&GLOBAL (npc_built_ship_q), 0);
if (GLOBAL (BattleGroupRef) == 0)
{
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
SET_GAME_STATE_32 (SAMATRA_GRPOFFS0, GLOBAL (BattleGroupRef));
}
#define NUM_URQUAN_GUARDS0 12
for (b0 = 1; b0 <= NUM_URQUAN_GUARDS0; ++b0)
PutGroupInfo (GLOBAL (BattleGroupRef), b0);
ReinitQueue (&GLOBAL (npc_built_ship_q));
for (b0 = 0; b0 < MAX_SHIPS_PER_SIDE; ++b0)
CloneShipFragment (ship2,
&GLOBAL (npc_built_ship_q), 0);
#define NUM_URQUAN_GUARDS1 4
for (b0 = 1; b0 <= NUM_URQUAN_GUARDS1; ++b0)
PutGroupInfo (GLOBAL (BattleGroupRef), (BYTE)(NUM_URQUAN_GUARDS0 + b0));
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP);
XFormIPLoc (&pSolarSysState->PlanetDesc[4].image.origin,
&org, FALSE);
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
for (b0 = 0, b1 = 0;
b0 < NUM_URQUAN_GUARDS0;
++b0, b1 += FULL_CIRCLE / (NUM_URQUAN_GUARDS0 + NUM_URQUAN_GUARDS1))
{
IP_GROUP *GroupPtr;
if (b1 % (FULL_CIRCLE / NUM_URQUAN_GUARDS1) == 0)
b1 += FULL_CIRCLE / (NUM_URQUAN_GUARDS0 + NUM_URQUAN_GUARDS1);
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
GroupPtr->task = ON_STATION | IGNORE_FLAGSHIP;
GroupPtr->sys_loc = 0;
GroupPtr->dest_loc = 4 + 1;
GroupPtr->orbit_pos = NORMALIZE_FACING (ANGLE_TO_FACING (b1));
GroupPtr->group_counter = 0;
GroupPtr->loc.x = org.x + COSINE (b1, STATION_RADIUS);
GroupPtr->loc.y = org.y + SINE (b1, STATION_RADIUS);
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
hGroup = hNextGroup;
}
for (b0 = 0, b1 = 0;
b0 < NUM_URQUAN_GUARDS1;
++b0, b1 += FULL_CIRCLE / NUM_URQUAN_GUARDS1)
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
GroupPtr->task = ON_STATION | IGNORE_FLAGSHIP;
GroupPtr->sys_loc = 0;
GroupPtr->dest_loc = 4 + 1;
GroupPtr->orbit_pos = NORMALIZE_FACING (ANGLE_TO_FACING (b1));
GroupPtr->group_counter = 0;
GroupPtr->loc.x = org.x + COSINE (b1, STATION_RADIUS);
GroupPtr->loc.y = org.y + SINE (b1, STATION_RADIUS);
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
hGroup = hNextGroup;
}
}
void
GenerateSamatra (BYTE control)
{
switch (control)
{
case INIT_NPCS:
if (!GET_GAME_STATE (URQUAN_MESSED_UP))
BuildUrquanGuard ();
else
{ // Exorcise Ur-Quan ghosts upon system reentry
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); // wipe out the group
}
break;
case REINIT_NPCS:
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
EncounterGroup = 0;
EncounterRace = -1; // Do not want guards to chase the player
{
BOOLEAN GuardEngaged;
HIPGROUP hGroup, hNextGroup;
GuardEngaged = FALSE;
for (hGroup = GetHeadLink (&GLOBAL (ip_group_q));
hGroup; hGroup = hNextGroup)
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
if (GET_GAME_STATE (URQUAN_MESSED_UP))
{
GroupPtr->task &= REFORM_GROUP;
GroupPtr->task |= FLEE | IGNORE_FLAGSHIP;
GroupPtr->dest_loc = 0;
}
else if (GroupPtr->task & REFORM_GROUP)
{
// REFORM_GROUP was set in ipdisp.c:ip_group_collision
// during a collision with the flagship.
GroupPtr->task &= ~REFORM_GROUP;
GroupPtr->group_counter = 0;
GuardEngaged = TRUE;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
if (GuardEngaged)
{
COUNT angle;
POINT org;
XFormIPLoc (
&pSolarSysState->PlanetDesc[4].image.origin,
&org, FALSE);
angle = ARCTAN (GLOBAL (ip_location.x) - org.x,
GLOBAL (ip_location.y) - org.y);
GLOBAL (ip_location.x) = org.x + COSINE (angle, 3000);
GLOBAL (ip_location.y) = org.y + SINE (angle, 3000);
XFormIPLoc (&GLOBAL (ip_location),
&GLOBAL (ShipStamp.origin), TRUE);
}
}
break;
case GENERATE_MOONS:
GenerateRandomIP (GENERATE_MOONS);
if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[4])
{
COUNT angle;
DWORD rand_val;
pSolarSysState->MoonDesc[0].data_index = SA_MATRA;
pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS
+ (2 * MOON_DELTA);
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
pSolarSysState->MoonDesc[0].location.x =
COSINE (angle, pSolarSysState->MoonDesc[0].radius);
pSolarSysState->MoonDesc[0].location.y =
SINE (angle, pSolarSysState->MoonDesc[0].radius);
}
break;
case GENERATE_PLANETS:
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[4].NumPlanets = 1;
break;
case GENERATE_ORBITAL:
/* Samatra */
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[4]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (!GET_GAME_STATE (URQUAN_MESSED_UP))
CloneShipFragment (!GET_GAME_STATE (KOHR_AH_FRENZY) ?
URQUAN_SHIP : BLACK_URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
else
{
#define URQUAN_REMNANTS 3
BYTE i;
for (i = 0; i < URQUAN_REMNANTS; ++i)
{
CloneShipFragment (URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
CloneShipFragment (BLACK_URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
}
}
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
SET_GAME_STATE (URQUAN_PROTECTING_SAMATRA, 1);
InitCommunication (URQUAN_CONVERSATION);
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
BOOLEAN UrquanSurvivors;
UrquanSurvivors = GetHeadLink (
&GLOBAL (npc_built_ship_q)
) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (UrquanSurvivors)
{
SET_GAME_STATE (URQUAN_PROTECTING_SAMATRA, 0);
}
else
{
EncounterGroup = 0;
EncounterRace = -1;
GLOBAL (CurrentActivity) = IN_LAST_BATTLE | START_ENCOUNTER;
if (GET_GAME_STATE (YEHAT_CIVIL_WAR)
&& ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING)
&& ActivateStarShip (YEHAT_REBEL_SHIP, FEASIBILITY_STUDY))
InitCommunication (YEHAT_REBEL_CONVERSATION);
}
}
pSolarSysState->MenuState.Initialized -= 2;
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-139
View File
@@ -1,139 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../state.h"
#include "../grpinfo.h"
static void
check_old_shofixti (void)
{
HIPGROUP hGroup;
IP_GROUP *GroupPtr;
if (!GLOBAL (BattleGroupRef))
return; // nothing to check
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
if (!hGroup)
return; // still nothing to check
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
// REFORM_GROUP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == SHOFIXTI_SHIP
&& (GroupPtr->task & REFORM_GROUP)
&& GET_GAME_STATE (SHOFIXTI_RECRUITED))
{
GroupPtr->task = FLEE | IGNORE_FLAGSHIP | REFORM_GROUP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
void
GenerateShofixti (BYTE control)
{
switch (control)
{
case INIT_NPCS:
if (!GET_GAME_STATE (SHOFIXTI_RECRUITED)
&& (!GET_GAME_STATE (SHOFIXTI_KIA)
|| (!GET_GAME_STATE (SHOFIXTI_BRO_KIA)
&& GET_GAME_STATE (MAIDENS_ON_SHIP))))
{
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (SHOFIXTI_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0
|| !GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP))
{
HSHIPFRAG hStarShip;
if (GLOBAL (BattleGroupRef) == 0)
GLOBAL (BattleGroupRef) = ~0L;
hStarShip = CloneShipFragment (SHOFIXTI_SHIP,
&GLOBAL (npc_built_ship_q), 1);
if (hStarShip)
{ /* Set old Shofixti name; his brother if Tanaka died */
SHIP_FRAGMENT *FragPtr = LockShipFrag (
&GLOBAL (npc_built_ship_q), hStarShip);
/* Name Tanaka or Katana (+1) */
FragPtr->captains_name_index = NAME_OFFSET +
NUM_CAPTAINS_NAMES +
(GET_GAME_STATE (SHOFIXTI_KIA) & 1);
UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip);
}
GLOBAL (BattleGroupRef) = PutGroupInfo (
GLOBAL (BattleGroupRef), 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (SHOFIXTI_GRPOFFS0,
GLOBAL (BattleGroupRef));
}
}
case REINIT_NPCS:
GenerateRandomIP (control);
check_old_shofixti ();
break;
case UNINIT_NPCS:
if (GLOBAL (BattleGroupRef)
&& !GET_GAME_STATE (SHOFIXTI_RECRUITED)
&& GetHeadLink (&GLOBAL (ip_group_q)) == 0)
{
if (!GET_GAME_STATE (SHOFIXTI_KIA))
{
SET_GAME_STATE (SHOFIXTI_KIA, 1);
SET_GAME_STATE (SHOFIXTI_VISITS, 0);
}
else if (GET_GAME_STATE (MAIDENS_ON_SHIP))
{
SET_GAME_STATE (SHOFIXTI_BRO_KIA, 1);
}
}
GenerateRandomIP (UNINIT_NPCS);
break;
case GENERATE_PLANETS:
{
COUNT i;
PLANET_DESC *pCurDesc;
#define NUM_PLANETS 6
pSolarSysState->SunDesc[0].NumPlanets = NUM_PLANETS;
for (i = 0, pCurDesc = pSolarSysState->PlanetDesc;
i < NUM_PLANETS; ++i, ++pCurDesc)
{
pCurDesc->NumPlanets = 0;
if (i < (NUM_PLANETS >> 1))
pCurDesc->data_index = SELENIC_WORLD;
else
pCurDesc->data_index = METAL_WORLD;
}
FillOrbits (pSolarSysState,
NUM_PLANETS, &pSolarSysState->PlanetDesc[0], TRUE);
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-46
View File
@@ -1,46 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../encount.h"
void
GenerateSlylandro (BYTE control)
{
switch (control)
{
case GENERATE_PLANETS:
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[3].data_index = RED_GAS_GIANT;
pSolarSysState->PlanetDesc[3].NumPlanets = 1;
break;
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[3])
{
pSolarSysState->MenuState.Initialized += 2;
InitCommunication (SLYLANDRO_HOME_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-612
View File
@@ -1,612 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "lifeform.h"
#include "../build.h"
#include "../gamestr.h"
#include "../races.h"
#include "../state.h"
#include "../grpinfo.h"
#include "../encount.h"
#include "libs/mathlib.h"
static int
init_probe (void)
{
HIPGROUP hGroup;
if (!GET_GAME_STATE (PROBE_MESSAGE_DELIVERED)
&& GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP)
&& (hGroup = GetHeadLink (&GLOBAL (ip_group_q))))
{
IP_GROUP *GroupPtr;
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
GroupPtr->task = IN_ORBIT;
GroupPtr->sys_loc = 2 + 1; /* orbitting earth */
GroupPtr->dest_loc = 2 + 1; /* orbitting earth */
GroupPtr->loc.x = 0;
GroupPtr->loc.y = 0;
GroupPtr->group_counter = 0;
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
return 1;
}
else
return 0;
}
static void
check_probe (void)
{
HIPGROUP hGroup;
IP_GROUP *GroupPtr;
if (!GLOBAL (BattleGroupRef))
return; // nothing to check
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
if (!hGroup)
return; // still nothing to check
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
// REFORM_GROUP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == URQUAN_DRONE_SHIP
&& (GroupPtr->task & REFORM_GROUP))
{
// We just want the probe to take off as fast as possible,
// so clear out REFORM_GROUP
GroupPtr->task = FLEE | IGNORE_FLAGSHIP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
static void
generate_energy_nodes (void)
{
/* Pluto */
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[8])
{
if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
{
pSolarSysState->SysInfo.PlanetInfo.CurPt.x = 20;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT - 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 2;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (FOUND_PLUTO_SPATHI, 1);
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
pLanderInputState->planetSideDesc->InTransit = TRUE;
}
else if (pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
return;
}
}
/* Earth Moon */
else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[2]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[1]
&& !GET_GAME_STATE (MOONBASE_DESTROYED))
{
pSolarSysState->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH * 3 / 4;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 1 / 4;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (MOONBASE_DESTROYED, 1);
SET_GAME_STATE (MOONBASE_ON_SHIP, 1);
}
}
return;
}
pSolarSysState->CurNode = 0;
}
static void
generate_tractors (void)
{
if (pSolarSysState->pOrbitalDesc->pPrevDesc != &pSolarSysState->PlanetDesc[2]
|| pSolarSysState->pOrbitalDesc != &pSolarSysState->MoonDesc[1])
pSolarSysState->CurNode = 0;
else /* Earth Moon */
{
COUNT i, which_node;
DWORD old_rand, rand_val;
old_rand = TFB_SeedRandom (pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES + 1;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 10);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
}
}
static void
generate_orbital (void)
{
COUNT i;
DWORD rand_val;
/* Starbase */
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[2]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
EncounterGroup = 0;
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
return;
}
rand_val = DoPlanetaryAnalysis (&pSolarSysState->SysInfo,
pSolarSysState->pOrbitalDesc);
if (rand_val)
{
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] =
rand_val;
i = (COUNT)~0;
rand_val = GenerateMineralDeposits (&pSolarSysState->SysInfo, &i);
}
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0])
{
i = pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc;
switch (i)
{
case 0: /* MERCURY */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 98;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 38;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 3;
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 2;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 59 * 240;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 165;
break;
case 1: /* VENUS */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 90 *
EARTH_ATMOSPHERE;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 95;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 95;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 177;
pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 243 * 240;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 457;
break;
case 2: /* EARTH */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 100;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 100;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 23;
pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 240;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 22;
break;
case 3: /* MARS */
// XXX: Mars atmo should actually be 1/2 in current units
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 1;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 72;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 53;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 24;
pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 246;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -53;
break;
case 4: /* JUPITER */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 24;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 1120;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 3;
pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 98;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -143;
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 520L / 100;
break;
case 5: /* SATURN */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 13;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 945;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 27;
pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 102;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -197;
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 952L / 100;
break;
case 6: /* URANUS */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 21;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 411;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 98;
pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 172;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -217;
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 1916L / 100;
break;
case 7: /* NEPTUNE */
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 28;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 396;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 30;
pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 182;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -229;
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 2999L / 100;
break;
case 8: /* PLUTO */
if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (SPAPLUTO_MASK_PMAP_ANIM));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (SPAPLUTO_STRTAB));
}
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 33;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 18;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 119;
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 1533;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -235;
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 3937L / 100;
break;
}
pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity =
CalcGravity (pSolarSysState->SysInfo.PlanetInfo.PlanetDensity,
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius);
LoadPlanet (i == 2 ? CaptureDrawable (LoadGraphic (EARTH_MASK_ANIM))
: NULL);
}
else
{
i = pSolarSysState->pOrbitalDesc->pPrevDesc
- pSolarSysState->PlanetDesc;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 0;
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
switch (i)
{
case 2: /* moons of EARTH */
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] =
rand_val;
if (!GET_GAME_STATE (MOONBASE_DESTROYED))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (MOONBASE_MASK_PMAP_ANIM));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (MOONBASE_STRTAB));
}
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 60;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 25;
pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 240 * 29;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -18;
break;
case 4: /* moons of JUPITER */
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 520L / 100;
switch (pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc)
{
case 0: /* Io */
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 69;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 25;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 3;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 390;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -163;
break;
case 1: /* Europa */
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 54;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 25;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 840;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -161;
break;
case 2: /* Ganymede */
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 35;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 41;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 1728;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -164;
break;
case 3: /* Callisto */
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 35;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 38;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 4008;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -167;
break;
}
break;
case 5: /* moon of SATURN: Titan */
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 952L / 100;
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 160;
pSolarSysState->SysInfo.PlanetInfo.Weather = 2;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 34;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 40;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 3816;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -178;
break;
case 7: /* moon of NEPTUNE: Triton */
pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 2999L / 100;
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 10;
pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 95;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 27;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 4300;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -216;
break;
}
pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity =
CalcGravity (pSolarSysState->SysInfo.PlanetInfo.PlanetDensity,
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius);
LoadPlanet (NULL);
}
}
void
GenerateSOL (BYTE control)
{
COUNT i;
DWORD rand_val;
PLANET_DESC *pCurDesc;
switch (control)
{
case INIT_NPCS:
GLOBAL (BattleGroupRef) =
GET_GAME_STATE_32 (URQUAN_PROBE_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (URQUAN_DRONE_SHIP,
&GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (URQUAN_PROBE_GRPOFFS0,
GLOBAL (BattleGroupRef));
}
if (!init_probe ())
GenerateRandomIP (INIT_NPCS);
break;
case REINIT_NPCS:
if (GET_GAME_STATE (CHMMR_BOMB_STATE) != 3)
{
GenerateRandomIP (REINIT_NPCS);
check_probe ();
}
else
{
GLOBAL (BattleGroupRef) = 0;
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
}
break;
case GENERATE_ENERGY:
generate_energy_nodes ();
break;
case GENERATE_LIFE:
generate_tractors ();
break;
case GENERATE_ORBITAL:
generate_orbital ();
break;
case GENERATE_NAME:
i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc;
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + i));
SET_GAME_STATE (BATTLE_PLANET,
pSolarSysState->PlanetDesc[i].data_index);
break;
case GENERATE_MOONS:
{
GenerateRandomIP (GENERATE_MOONS);
i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc;
switch (i)
{
case 2: /* moons of EARTH */
{
COUNT angle;
/* Starbase: */
pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE;
pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS;
angle = HALF_CIRCLE + QUADRANT;
pSolarSysState->MoonDesc[0].location.x =
COSINE (angle, pSolarSysState->MoonDesc[0].radius);
pSolarSysState->MoonDesc[0].location.y =
SINE (angle, pSolarSysState->MoonDesc[0].radius);
/* Luna: */
pSolarSysState->MoonDesc[1].data_index = SELENIC_WORLD;
pSolarSysState->MoonDesc[1].radius = MIN_MOON_RADIUS
+ (MAX_MOONS - 1) * MOON_DELTA;
rand_val = TFB_Random ();
angle = NORMALIZE_ANGLE (LOWORD (rand_val));
pSolarSysState->MoonDesc[1].location.x =
COSINE (angle, pSolarSysState->MoonDesc[1].radius);
pSolarSysState->MoonDesc[1].location.y =
SINE (angle, pSolarSysState->MoonDesc[1].radius);
break;
}
case 4: /* moons of JUPITER */
pSolarSysState->MoonDesc[0].data_index = RADIOACTIVE_WORLD;
/* Io */
pSolarSysState->MoonDesc[1].data_index = HALIDE_WORLD;
/* Europa */
pSolarSysState->MoonDesc[2].data_index = CYANIC_WORLD;
/* Ganymede */
pSolarSysState->MoonDesc[3].data_index = PELLUCID_WORLD;
/* Callisto */
break;
case 5: /* moons of SATURN */
pSolarSysState->MoonDesc[0].data_index = ALKALI_WORLD;
/* Titan */
break;
case 7: /* moons of NEPTUNE */
pSolarSysState->MoonDesc[0].data_index = VINYLOGOUS_WORLD;
/* Triton */
break;
}
break;
}
case GENERATE_PLANETS:
{
#define SOL_SEED 334241042L
TFB_SeedRandom (SOL_SEED);
pSolarSysState->SunDesc[0].NumPlanets = 9;
for (i = 0, pCurDesc = pSolarSysState->PlanetDesc; i < 9; ++i, ++pCurDesc)
{
COUNT angle;
UWORD word_val;
pCurDesc->rand_seed = rand_val = TFB_Random ();
word_val = LOWORD (rand_val);
angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val));
switch (i)
{
case 0: /* MERCURY */
pCurDesc->data_index = METAL_WORLD;
pCurDesc->radius = EARTH_RADIUS * 39L / 100;
pCurDesc->NumPlanets = 0;
break;
case 1: /* VENUS */
pCurDesc->data_index = PRIMORDIAL_WORLD;
pCurDesc->radius = EARTH_RADIUS * 72L / 100;
pCurDesc->NumPlanets = 0;
angle = NORMALIZE_ANGLE (FULL_CIRCLE - angle);
break;
case 2: /* EARTH */
pCurDesc->data_index = WATER_WORLD | PLANET_SHIELDED;
pCurDesc->radius = EARTH_RADIUS;
pCurDesc->NumPlanets = 2;
break;
case 3: /* MARS */
pCurDesc->data_index = DUST_WORLD;
pCurDesc->radius = EARTH_RADIUS * 152L / 100;
pCurDesc->NumPlanets = 0;
break;
case 4: /* JUPITER */
pCurDesc->data_index = RED_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 500L /* 520L */ / 100;
pCurDesc->NumPlanets = 4;
break;
case 5: /* SATURN */
pCurDesc->data_index = ORA_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 750L /* 952L */ / 100;
pCurDesc->NumPlanets = 1;
break;
case 6: /* URANUS */
pCurDesc->data_index = GRN_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 1000L /* 1916L */ / 100;
pCurDesc->NumPlanets = 0;
break;
case 7: /* NEPTUNE */
pCurDesc->data_index = BLU_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 1250L /* 2999L */ / 100;
pCurDesc->NumPlanets = 1;
break;
case 8: /* PLUTO */
pCurDesc->data_index = PELLUCID_WORLD;
pCurDesc->radius = EARTH_RADIUS * 1550L /* 3937L */ / 100;
pCurDesc->NumPlanets = 0;
angle = FULL_CIRCLE - OCTANT;
break;
}
pCurDesc->location.x =
COSINE (angle, pCurDesc->radius);
pCurDesc->location.y =
SINE (angle, pCurDesc->radius);
}
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-243
View File
@@ -1,243 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lifeform.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateSpathi (BYTE control)
{
COUNT i, angle;
DWORD rand_val;
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]
&& !GET_GAME_STATE (UMGAH_BROADCASTERS))
{
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (UMGAH_BROADCASTERS, 1);
SET_GAME_STATE (UMGAH_BROADCASTERS_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_MOONS:
GenerateRandomIP (GENERATE_MOONS);
if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0])
{
#ifdef NOTYET
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
"Spathiwa");
#endif /* NOTYET */
pSolarSysState->MoonDesc[0].data_index = PELLUCID_WORLD;
pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA;
angle = NORMALIZE_ANGLE (LOWORD (TFB_Random ()));
pSolarSysState->MoonDesc[0].location.x =
COSINE (angle, pSolarSysState->MoonDesc[0].radius);
pSolarSysState->MoonDesc[0].location.y =
SINE (angle, pSolarSysState->MoonDesc[0].radius);
}
break;
case GENERATE_PLANETS:
{
PLANET_DESC *pMinPlanet;
pMinPlanet = &pSolarSysState->PlanetDesc[0];
pSolarSysState->SunDesc[0].NumPlanets = 1;
FillOrbits (pSolarSysState,
pSolarSysState->SunDesc[0].NumPlanets, pMinPlanet, FALSE);
pMinPlanet->radius = EARTH_RADIUS * 1150L / 100;
angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y);
pMinPlanet->location.x =
COSINE (angle, pMinPlanet->radius);
pMinPlanet->location.y =
SINE (angle, pMinPlanet->radius);
pMinPlanet->data_index = WATER_WORLD;
if (GET_GAME_STATE (SPATHI_SHIELDED_SELVES))
pMinPlanet->data_index |= PLANET_SHIELDED;
pMinPlanet->NumPlanets = 1;
break;
}
case GENERATE_LIFE:
/* visiting Spathiwa */
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]
&& !GET_GAME_STATE (SPATHI_SHIELDED_SELVES))
{
COUNT which_node;
DWORD old_rand;
old_rand = TFB_SeedRandom (pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 32);
pSolarSysState->CurNode = which_node;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN])
{
SET_GAME_STATE (SPATHI_CREATURES_EXAMINED, 1);
if (pSolarSysState->SysInfo.
PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN] == 0xFFFFFFFF)
SET_GAME_STATE (SPATHI_CREATURES_ELIMINATED, 1);
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES)
&& ActivateStarShip (SPATHI_SHIP, SPHERE_TRACKING))
{
NotifyOthers (SPATHI_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (SPATHI_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (SPATHI_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
rand_val = DoPlanetaryAnalysis (
&pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc
);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateLifeForms (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
GenerateMineralDeposits (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 28;
if (!GET_GAME_STATE (UMGAH_BROADCASTERS))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (UMGAH_BCS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (UMGAH_BCS_STRTAB)
);
}
LoadPlanet (NULL);
break;
}
else if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
/* visiting Spathiwa */
rand_val = DoPlanetaryAnalysis (
&pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc
);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateMineralDeposits (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 120;
pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity =
CalcGravity (pSolarSysState->SysInfo.PlanetInfo.PlanetDensity,
pSolarSysState->SysInfo.PlanetInfo.PlanetRadius);
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 31;
LoadPlanet (NULL);
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-150
View File
@@ -1,150 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateSupox (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (!GET_GAME_STATE (ULTRON_CONDITION))
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
else
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i))
{
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << i);
if (!GET_GAME_STATE (ULTRON_CONDITION))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (ULTRON_CONDITION, 1);
}
}
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 2;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 152L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (SUPOX_SHIP, SPHERE_TRACKING))
{
NotifyOthers (SUPOX_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (SUPOX_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (SUPOX_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
if (!GET_GAME_STATE (ULTRON_CONDITION))
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
-118
View File
@@ -1,118 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../encount.h"
static void
GenerateTrap (BYTE control)
{
switch (control)
{
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = TELLURIC_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 203L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
GenerateRandomIP (GENERATE_ORBITAL);
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = EARTH_ATMOSPHERE * 2;
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 35;
pSolarSysState->SysInfo.PlanetInfo.Weather = 3;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
}
break;
default:
GenerateRandomIP (control);
break;
}
}
void
GenerateSyreen (BYTE control)
{
if (CurStarDescPtr && CurStarDescPtr->Index == MYCON_TRAP_DEFINED)
{
GenerateTrap (control);
return;
}
switch (control)
{
case GENERATE_MOONS:
GenerateRandomIP (GENERATE_MOONS);
if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE;
pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS;
pSolarSysState->MoonDesc[0].location.x =
COSINE (QUADRANT, pSolarSysState->MoonDesc[0].radius);
pSolarSysState->MoonDesc[0].location.y =
SINE (QUADRANT, pSolarSysState->MoonDesc[0].radius);
}
break;
case GENERATE_PLANETS:
{
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index =
WATER_WORLD | PLANET_SHIELDED;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
GenerateRandomIP (GENERATE_ORBITAL);
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 19;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
pSolarSysState->SysInfo.PlanetInfo.AtmoDensity =
EARTH_ATMOSPHERE * 9 / 10;
break;
}
/* Starbase */
else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
pSolarSysState->MenuState.Initialized += 2;
InitCommunication (SYREEN_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-213
View File
@@ -1,213 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../setup.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateThradd (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
DWORD rand_val, old_rand;
if (CurStarDescPtr->Index != AQUA_HELIX_DEFINED)
{
COUNT i, which_node;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
else if (!GET_GAME_STATE (AQUA_HELIX))
{
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (HELIX_VISITS, 0);
SET_GAME_STATE (AQUA_HELIX, 1);
SET_GAME_STATE (AQUA_HELIX_ON_SHIP, 1);
SET_GAME_STATE (HELIX_UNPROTECTED, 1);
}
}
TFB_SeedRandom (old_rand);
break;
}
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED)
{
pSolarSysState->PlanetDesc[0].data_index = PRIMORDIAL_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 65L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
}
else
{
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 0;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 98L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
}
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (THRADDASH_SHIP, SPHERE_TRACKING)
&& (CurStarDescPtr->Index == THRADD_DEFINED
|| (!GET_GAME_STATE (HELIX_UNPROTECTED)
&& (BYTE)(GET_GAME_STATE (THRADD_MISSION) - 1) >= 3)))
{
NotifyOthers (THRADDASH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (THRADDASH_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
if (CurStarDescPtr->Index == THRADD_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
InitCommunication (THRADD_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
break;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (CurStarDescPtr->Index == THRADD_DEFINED
|| (!GET_GAME_STATE (HELIX_UNPROTECTED)
&& (BYTE)(GET_GAME_STATE (THRADD_MISSION) - 1) >= 3))
break;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED
&& !GET_GAME_STATE (AQUA_HELIX))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (AQUA_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (AQUA_STRTAB)
);
}
else if (CurStarDescPtr->Index == THRADD_DEFINED)
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
-260
View File
@@ -1,260 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../setup.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateUtwig (BYTE control)
{
switch (control)
{
case INIT_NPCS:
if (CurStarDescPtr->Index == BOMB_DEFINED
&& !GET_GAME_STATE (UTWIG_BOMB))
{
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
}
else
GenerateRandomIP (INIT_NPCS);
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
if (CurStarDescPtr->Index == UTWIG_DEFINED)
{
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 174L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
}
break;
}
case GENERATE_ENERGY:
{
DWORD rand_val, old_rand;
if (CurStarDescPtr->Index == UTWIG_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
else if (CurStarDescPtr->Index == BOMB_DEFINED
&& pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[5]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[1]
&& !GET_GAME_STATE (UTWIG_BOMB))
{
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (UTWIG_BOMB, 1);
SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 1);
SET_GAME_STATE (DRUUGE_MANNER, 1);
SET_GAME_STATE (DRUUGE_VISITS, 0);
SET_GAME_STATE (DRUUGE_HOME_VISITS, 0);
}
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
}
case GENERATE_ORBITAL:
if ((CurStarDescPtr->Index == UTWIG_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
|| (CurStarDescPtr->Index == BOMB_DEFINED
&& pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[5]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[1]
&& !GET_GAME_STATE (UTWIG_BOMB)))
{
if ((CurStarDescPtr->Index == UTWIG_DEFINED
|| !GET_GAME_STATE (UTWIG_HAVE_ULTRON))
&& ActivateStarShip (UTWIG_SHIP, SPHERE_TRACKING))
{
NotifyOthers (UTWIG_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (UTWIG_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
if (CurStarDescPtr->Index == UTWIG_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
InitCommunication (UTWIG_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else if (CurStarDescPtr->Index == BOMB_DEFINED
&& !GET_GAME_STATE (BOMB_UNPROTECTED)
&& ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING))
{
COUNT i;
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
for (i = 0; i < 5; ++i)
CloneShipFragment (DRUUGE_SHIP,
&GLOBAL (npc_built_ship_q), 0);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
InitCommunication (DRUUGE_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
break;
else
{
BOOLEAN DruugeSurvivors;
DruugeSurvivors = GetHeadLink (
&GLOBAL (npc_built_ship_q)
) != 0;
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (DruugeSurvivors)
break;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
SET_GAME_STATE (BOMB_UNPROTECTED, 1);
}
}
if (CurStarDescPtr->Index == BOMB_DEFINED)
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (BOMB_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (BOMB_STRTAB)
);
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
GenerateRandomIP (GENERATE_ORBITAL);
if (CurStarDescPtr->Index == UTWIG_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
}
break;
default:
GenerateRandomIP (control);
break;
}
}
-109
View File
@@ -1,109 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "../encount.h"
#include "../setup.h"
#include "libs/mathlib.h"
void
GenerateShipVault (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (!GET_GAME_STATE (SHIP_VAULT_UNLOCKED))
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
else
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->CurNode = 1;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (SHIP_VAULT_UNLOCKED, 1);
SET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP, 0);
SET_GAME_STATE (SYREEN_HOME_VISITS, 0);
}
else if (!GET_GAME_STATE (KNOW_SYREEN_VAULT))
{
SET_GAME_STATE (KNOW_SYREEN_VAULT, 1);
SET_GAME_STATE (SYREEN_HOME_VISITS, 0);
}
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (VAULT_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (VAULT_STRTAB)
);
if (GET_GAME_STATE (SHIP_VAULT_UNLOCKED))
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
2
);
else if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP))
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
}
default:
GenerateRandomIP (control);
break;
}
}
-333
View File
@@ -1,333 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "lifeform.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../setup.h"
#include "../state.h"
#include "../sounds.h"
#include "libs/mathlib.h"
void
GenerateVUX (BYTE control)
{
DWORD rand_val;
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]
&& CurStarDescPtr->Index != VUX_BEAST_DEFINED)
{
if (CurStarDescPtr->Index == MAIDENS_DEFINED
&& !GET_GAME_STATE (SHOFIXTI_MAIDENS))
{
pSolarSysState->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH / 3;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 5 / 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
&& pSolarSysState->CurNode == (COUNT)~0)
pSolarSysState->CurNode = 1;
else
{
pSolarSysState->CurNode = 0;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
SET_GAME_STATE (SHOFIXTI_MAIDENS, 1);
SET_GAME_STATE (MAIDENS_ON_SHIP, 1);
}
}
break;
}
else if (CurStarDescPtr->Index == VUX_DEFINED)
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
if (CurStarDescPtr->Index == MAIDENS_DEFINED)
{
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = REDUX_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 212L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
}
else
{
if (CurStarDescPtr->Index == VUX_DEFINED)
{
pSolarSysState->PlanetDesc[0].data_index = REDUX_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 42L / 100;
angle = HALF_CIRCLE + OCTANT;
}
else /* if (CurStarDescPtr->Index == VUX_BEAST_DEFINED) */
{
memmove (&pSolarSysState->PlanetDesc[1],
&pSolarSysState->PlanetDesc[0],
sizeof (pSolarSysState->PlanetDesc[0])
* pSolarSysState->SunDesc[0].NumPlanets);
++pSolarSysState->SunDesc[0].NumPlanets;
angle = HALF_CIRCLE - OCTANT;
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 110L / 100;
pSolarSysState->PlanetDesc[0].NumPlanets = 0;
}
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].rand_seed = MAKE_DWORD (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
}
break;
}
case GENERATE_ORBITAL:
{
if ((pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]
&& (CurStarDescPtr->Index == VUX_DEFINED
|| (CurStarDescPtr->Index == MAIDENS_DEFINED
&& !GET_GAME_STATE (ZEX_IS_DEAD))))
&& ActivateStarShip (VUX_SHIP, SPHERE_TRACKING))
{
NotifyOthers (VUX_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (VUX_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
if (CurStarDescPtr->Index == VUX_DEFINED)
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
}
else
{
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6);
}
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication (VUX_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
break;
else
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
if (CurStarDescPtr->Index == VUX_DEFINED
|| !GET_GAME_STATE (ZEX_IS_DEAD))
break;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (CurStarDescPtr->Index == MAIDENS_DEFINED)
{
if (!GET_GAME_STATE (SHOFIXTI_MAIDENS))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (MAIDENS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (MAIDENS_STRTAB)
);
}
}
else if (CurStarDescPtr->Index == VUX_BEAST_DEFINED)
{
if (!GET_GAME_STATE (VUX_BEAST))
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] = 0;
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (BEAST_STRTAB)
);
}
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
GenerateRandomIP (GENERATE_ORBITAL);
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.Weather = 2;
pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
}
break;
}
case GENERATE_LIFE:
if (CurStarDescPtr->Index == MAIDENS_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i;
DWORD old_rand;
old_rand = TFB_SeedRandom (pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (i < 4)
pSolarSysState->SysInfo.PlanetInfo.CurType = 9;
else if (i < 8)
pSolarSysState->SysInfo.PlanetInfo.CurType = 14;
else /* if (i < 12) */
pSolarSysState->SysInfo.PlanetInfo.CurType = 18;
if (i >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
} while (++i < 12);
pSolarSysState->CurNode = i;
TFB_SeedRandom (old_rand);
break;
}
else if (CurStarDescPtr->Index == VUX_BEAST_DEFINED
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i;
DWORD old_rand;
old_rand = TFB_SeedRandom (pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]);
i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
if (i == 0)
pSolarSysState->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES + 2;
else if (i <= 5)
/* {SPEED_MOTIONLESS | DANGER_NORMAL, MAKE_BYTE (5, 3)}, */
pSolarSysState->SysInfo.PlanetInfo.CurType = 3;
else /* if (i <= 10) */
/* {BEHAVIOR_UNPREDICTABLE | SPEED_SLOW | DANGER_NORMAL, MAKE_BYTE (3, 8)}, */
pSolarSysState->SysInfo.PlanetInfo.CurType = 8;
if (i >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i)))
break;
else if (i == 0
&& (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN]
& (1L << i))
&& !GET_GAME_STATE (VUX_BEAST))
{
UnbatchGraphics ();
DoDiscoveryReport (MenuSounds);
BatchGraphics ();
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (VUX_BEAST, 1);
SET_GAME_STATE (VUX_BEAST_ON_SHIP, 1);
}
} while (++i < 11);
pSolarSysState->CurNode = i;
TFB_SeedRandom (old_rand);
break;
}
default:
GenerateRandomIP (control);
break;
}
}
-94
View File
@@ -1,94 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "lander.h"
#include "libs/mathlib.h"
void
GenerateUrquanWreck (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[6])
{
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (!GET_GAME_STATE (PORTAL_KEY))
pSolarSysState->SysInfo.PlanetInfo.CurType = 0;
else
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->CurNode = 1;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0))
{
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
if (!GET_GAME_STATE (PORTAL_KEY))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SET_GAME_STATE (PORTAL_KEY, 1);
SET_GAME_STATE (PORTAL_KEY_ON_SHIP, 1);
}
}
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[6])
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (WRECK_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (WRECK_STRTAB)
);
if (GET_GAME_STATE (PORTAL_KEY))
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
SetAbsStringTableIndex (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString,
1
);
}
default:
GenerateRandomIP (control);
break;
}
}
-128
View File
@@ -1,128 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../ipdisp.h"
#include "../state.h"
#include "libs/mathlib.h"
void
GenerateYehat (BYTE control)
{
switch (control)
{
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 106L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING))
{
NotifyOthers (YEHAT_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (YEHAT_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (YEHAT_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
-215
View File
@@ -1,215 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "genall.h"
#include "../build.h"
#include "../encount.h"
#include "../state.h"
#include "../grpinfo.h"
#include "libs/mathlib.h"
static void
check_scout (void)
{
HIPGROUP hGroup;
IP_GROUP *GroupPtr;
if (!GLOBAL (BattleGroupRef))
return; // nothing to check
hGroup = GetHeadLink (&GLOBAL (ip_group_q));
if (!hGroup)
return; // still nothing to check
GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
// REFORM_GROUP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == ZOQFOTPIK_SHIP
&& (GroupPtr->task & REFORM_GROUP))
{
GroupPtr->task = FLEE | IGNORE_FLAGSHIP | REFORM_GROUP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
static void
GenerateScout (BYTE control)
{
switch (control)
{
case INIT_NPCS:
if (!GET_GAME_STATE (MET_ZOQFOT))
{
GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (ZOQFOT_GRPOFFS0);
if (GLOBAL (BattleGroupRef) == 0)
{
CloneShipFragment (ZOQFOTPIK_SHIP,
&GLOBAL (npc_built_ship_q), 0);
GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1);
ReinitQueue (&GLOBAL (npc_built_ship_q));
SET_GAME_STATE_32 (ZOQFOT_GRPOFFS0,
GLOBAL (BattleGroupRef));
}
}
GenerateRandomIP (INIT_NPCS);
break;
case REINIT_NPCS:
GenerateRandomIP (REINIT_NPCS);
check_scout ();
break;
default:
GenerateRandomIP (control);
break;
}
}
void
GenerateZoqFotPik (BYTE control)
{
if (CurStarDescPtr && CurStarDescPtr->Index == ZOQ_SCOUT_DEFINED)
{
GenerateScout (control);
return;
}
switch (control)
{
case INIT_NPCS:
if (GET_GAME_STATE (ZOQFOT_DISTRESS) != 1)
GenerateRandomIP (INIT_NPCS);
break;
case GENERATE_ENERGY:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
COUNT i, which_node;
DWORD rand_val, old_rand;
old_rand = TFB_SeedRandom (
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]
);
which_node = i = 0;
do
{
rand_val = TFB_Random ();
pSolarSysState->SysInfo.PlanetInfo.CurPt.x =
(LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurPt.y =
(HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8;
pSolarSysState->SysInfo.PlanetInfo.CurType = 1;
pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0;
if (which_node >= pSolarSysState->CurNode
&& !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << i)))
break;
++which_node;
} while (++i < 16);
pSolarSysState->CurNode = which_node;
TFB_SeedRandom (old_rand);
break;
}
pSolarSysState->CurNode = 0;
break;
case GENERATE_PLANETS:
{
COUNT angle;
GenerateRandomIP (GENERATE_PLANETS);
pSolarSysState->PlanetDesc[0].data_index = REDUX_WORLD;
pSolarSysState->PlanetDesc[0].NumPlanets = 1;
pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 138L / 100;
angle = ARCTAN (
pSolarSysState->PlanetDesc[0].location.x,
pSolarSysState->PlanetDesc[0].location.y
);
pSolarSysState->PlanetDesc[0].location.x =
COSINE (angle, pSolarSysState->PlanetDesc[0].radius);
pSolarSysState->PlanetDesc[0].location.y =
SINE (angle, pSolarSysState->PlanetDesc[0].radius);
break;
}
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
if (ActivateStarShip (ZOQFOTPIK_SHIP, SPHERE_TRACKING))
{
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (GET_GAME_STATE (ZOQFOT_DISTRESS))
{
CloneShipFragment (BLACK_URQUAN_SHIP,
&GLOBAL (npc_built_ship_q), 0);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (BLACKURQ_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
break;
if (GetHeadLink (&GLOBAL (npc_built_ship_q)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
break;
}
}
CloneShipFragment (ZOQFOTPIK_SHIP,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
pSolarSysState->MenuState.Initialized += 2;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
InitCommunication (ZOQFOTPIK_CONVERSATION);
pSolarSysState->MenuState.Initialized -= 2;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
break;
}
else
{
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (RUINS_STRTAB)
);
}
}
default:
GenerateRandomIP (control);
break;
}
}
+3 -1
View File
@@ -832,7 +832,9 @@ CheckObjectCollision (COUNT index)
pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] |=
(1L << which_node);
pSolarSysState->CurNode = (COUNT)~0;
(*pSolarSysState->GenFunc) ((BYTE)(scan + GENERATE_MINERAL));
callGenerateForScanType (pSolarSysState,
pSolarSysState->pOrbitalDesc,
&pSolarSysState->CurNode, scan);
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] &
(1L << which_node)))
+3 -3
View File
@@ -119,7 +119,7 @@ DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode)
}
// Initialise the surface graphics, and start the planet music.
// Called from the GENERATE_ORBITAL case of an IP generation function
// Called from the GenerateFunctions.generateOribital() function
// (when orbit is entered; either from IP, or from loading a saved game)
// and when "starmap" is selected from orbit and then cancelled;
// also after in-orbit comm and after defeating planet guards in combat.
@@ -148,8 +148,8 @@ LoadPlanet (FRAME SurfDefFrame)
if (pSolarSysState->MenuState.flash_task == 0)
{
// The "rotate planets" task is not initialised yet.
// This means the call to LoadPlanet is made from a
// GENERATE_ORBITAL case of an IP generation function.
// This means the call to LoadPlanet is made from some
// GenerateFunctions.generateOribital() function.
PLANET_DESC *pPlanetDesc;
StopMusic ();
+52 -61
View File
@@ -19,9 +19,6 @@
#ifndef _PLANETS_H
#define _PLANETS_H
#include "../menustat.h"
#include "../units.h"
#define END_INTERPLANETARY START_INTERPLANETARY
enum
@@ -50,33 +47,6 @@ enum
#define MAP_WIDTH SIS_SCREEN_WIDTH
#define MAP_HEIGHT (75 - SAFE_Y)
enum
{
GENERATE_PLANETS = 0,
// Layout of planets within a solar system.
GENERATE_MOONS,
// Layout of moons around a planet.
GENERATE_ORBITAL,
// Characteristics of words (planets and moons).
INIT_NPCS,
// Ships in the solar system, the first time it is accessed.
REINIT_NPCS,
// Ships in the solar system, every next time it is accessed.
UNINIT_NPCS,
// When leaving the solar system.
GENERATE_MINERAL,
// Minerals on the planet surface.
GENERATE_ENERGY,
// Energy sources on the planet surface.
GENERATE_LIFE,
// Bio on the planet surface.
GENERATE_NAME
// Name of a planet.
};
enum
{
BIOLOGICAL_DISASTER = 0,
@@ -95,6 +65,7 @@ enum
LANDER_RETURNS,
LANDER_DESTROYED
};
#define MAX_SCROUNGED 50 /* max lander can hold */
#define SCALE_RADIUS(r) ((r) << 6)
@@ -113,7 +84,27 @@ enum
#define MIN_MOON_RADIUS 35
#define MOON_DELTA 20
typedef struct planet_desc
#define MAX_SUNS 1
#define MAX_PLANETS 16
#define MAX_MOONS 4
typedef struct planet_desc PLANET_DESC;
typedef struct star_desc STAR_DESC;
typedef struct planet_orbit PLANET_ORBIT;
typedef struct solarsys_state SOLARSYS_STATE;
#include "generate.h"
#include "../menustat.h"
#include "../units.h"
#include "elemdata.h"
#include "plandata.h"
#include "sundata.h"
struct planet_desc
{
DWORD rand_seed;
@@ -126,27 +117,22 @@ typedef struct planet_desc
COUNT NextIndex;
STAMP image;
struct planet_desc *pPrevDesc;
} PLANET_DESC;
PLANET_DESC *pPrevDesc;
// The Sun or planet that this world is orbiting around.
};
typedef struct
struct star_desc
{
POINT star_pt;
BYTE Type, Index;
BYTE Prefix, Postfix;
} STAR_DESC;
#define MAX_SUNS 1
#define MAX_PLANETS 16
#define MAX_MOONS 4
#include "elemdata.h"
#include "plandata.h"
#include "sundata.h"
BYTE Type;
BYTE Index;
BYTE Prefix;
BYTE Postfix;
};
typedef void (*PLAN_GEN_FUNC) (BYTE control);
typedef struct planet_orbit
struct planet_orbit
{
FRAME TopoZoomFrame;
// 4x scaled topo image for planet-side
@@ -167,11 +153,11 @@ typedef struct planet_orbit
// temp RGBA data for whatever transforms (nuked often)
FRAME WorkFrame;
// any extra frame workspace (for dynamic objects)
} PLANET_ORBIT;
};
// See doc/devel/generate for information on how this structure is
// filled.
typedef struct solarsys_state
struct solarsys_state
{
MENU_STATE MenuState;
@@ -179,12 +165,12 @@ typedef struct solarsys_state
PLANET_DESC SunDesc[MAX_SUNS];
PLANET_DESC PlanetDesc[MAX_PLANETS];
// Description of the planets in the system.
// Only defined after a call to GenFunc with GENERATE_PLANETS
// as its argument, and overwritten by subsequent calls.
// Only defined after a call to (*genFuncs)->generatePlanets()
// and overwritten by subsequent calls.
PLANET_DESC MoonDesc[MAX_MOONS];
// Description of the moons orbiting the planet pointed to
// by pBaseDesc.
// Only defined after a call to GenFunc with GENERATE_MOONS
// Only defined after a call to (*genFuncs)->generateMoons()
// as its argument, and overwritten by subsequent calls.
PLANET_DESC *pBaseDesc;
PLANET_DESC *pOrbitalDesc;
@@ -196,8 +182,10 @@ typedef struct solarsys_state
// PlanetDesc[PlanetDesc[i].NextIndex] is the next planet
// after PlanetDesc[i] in the ordering.
BYTE turn_counter, turn_wait;
BYTE thrust_counter, max_ship_speed;
BYTE turn_counter;
BYTE turn_wait;
BYTE thrust_counter;
BYTE max_ship_speed;
STRING XlatRef;
STRINGPTR XlatPtr;
@@ -206,23 +194,27 @@ typedef struct solarsys_state
SYSTEM_INFO SysInfo;
COUNT CurNode;
PLAN_GEN_FUNC GenFunc;
// Function to call to fill in various parts of this structure.
// See doc/devel/generate.
const GenerateFunctions *genFuncs;
// Functions to call to fill in various parts of this structure.
// See generate.h, doc/devel/generate
FRAME PlanetSideFrame[6];
UWORD Tint_rgb;
UBYTE PauseRotate;
FRAME TopoFrame;
PLANET_ORBIT Orbit;
} SOLARSYS_STATE;
};
extern SOLARSYS_STATE *pSolarSysState;
extern MUSIC_REF SpaceMusic;
bool currentWorldIsPlanet (void);
bool currentPlanetIndex (void);
bool currentMoonIndex (void);
bool worldIsPlanet (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
bool worldIsMoon (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
COUNT planetIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
COUNT moonIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *moon);
#define MATCH_PLANET ((BYTE) -1)
bool matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world,
BYTE planetI, BYTE moonI);
extern void LoadPlanet (FRAME SurfDefFrame);
extern void DrawPlanet (int x, int y, int dy, unsigned int rgb);
@@ -233,7 +225,6 @@ extern void FreeLanderFont (PLANET_INFO *info);
extern void ExploreSolarSys (void);
extern void DrawStarBackGround (BOOLEAN ForPlanet);
extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay);
extern void GenerateRandomIP (BYTE control);
extern PLAN_GEN_FUNC GenerateIP (BYTE Index);
extern void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem);
extern void DrawOval (RECT *pRect, BYTE num_off_pixels);
+2 -3
View File
@@ -43,6 +43,8 @@
#include "libs/mathlib.h"
#include "libs/memlib.h"
#include <stdlib.h>
static POINT cursorLoc;
static POINT mapOrigin;
@@ -1026,7 +1028,6 @@ static void
DrawMatchedStarName (TEXTENTRY_STATE *pTES)
{
STAR_SEARCH_STATE *pSS = (STAR_SEARCH_STATE *) pTES->CbParam;
MENU_STATE *pMS = pSS->pMS;
UNICODE buf[STAR_SEARCH_BUFSIZE] = "";
SIZE ExPos = 0;
SIZE CurPos = -1;
@@ -1109,7 +1110,6 @@ static BOOLEAN
OnStarNameChange (TEXTENTRY_STATE *pTES)
{
STAR_SEARCH_STATE *pSS = (STAR_SEARCH_STATE *) pTES->CbParam;
MENU_STATE *pMS = pSS->pMS;
COUNT flags;
BOOLEAN ret = TRUE;
@@ -1154,7 +1154,6 @@ static BOOLEAN
OnStarNameFrame (TEXTENTRY_STATE *pTES)
{
STAR_SEARCH_STATE *pSS = (STAR_SEARCH_STATE *) pTES->CbParam;
MENU_STATE *pMS = pSS->pMS;
if (PulsedInputState.menu[KEY_MENU_NEXT])
{ // search for next match
+29 -3
View File
@@ -904,6 +904,27 @@ DrawScannedStuff (COUNT y, BYTE CurState)
SetContextForeGroundColor (OldColor);
}
bool
callGenerateForScanType (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT *node, BYTE scanType)
{
switch (scanType)
{
case MINERAL_SCAN:
return (*solarSys->genFuncs->generateMinerals) (
solarSys, world, node);
case ENERGY_SCAN:
return (*solarSys->genFuncs->generateEnergy) (
solarSys, world, node);
case BIOLOGICAL_SCAN:
return (*solarSys->genFuncs->generateLife) (
solarSys, world, node);
}
assert (false);
return false;
}
static BOOLEAN
DoScan (MENU_STATE *pMS)
{
@@ -1020,7 +1041,9 @@ DoScan (MENU_STATE *pMS)
t.CharCount = (COUNT)~0;
pSolarSysState->CurNode = (COUNT)~0;
(*pSolarSysState->GenFunc) ((BYTE)(min_scan + GENERATE_MINERAL));
callGenerateForScanType (pSolarSysState,
pSolarSysState->pOrbitalDesc, &pSolarSysState->CurNode,
min_scan);
pMS->delta_item = (SIZE)pSolarSysState->CurNode;
t.pStr = GAME_STRING (SCAN_STRING_BASE + min_scan);
@@ -1243,7 +1266,8 @@ GeneratePlanetSide (void)
NUM_SCANDOT_TRANSITIONS * (scan - ENERGY_SCAN));
pSolarSysState->CurNode = (COUNT)~0;
(*pSolarSysState->GenFunc) ((BYTE)(scan + GENERATE_MINERAL));
callGenerateForScanType (pSolarSysState,
pSolarSysState->pOrbitalDesc, &pSolarSysState->CurNode, scan);
num_nodes = pSolarSysState->CurNode;
while (num_nodes--)
@@ -1262,7 +1286,9 @@ GeneratePlanetSide (void)
LockElement (hNodeElement, &NodeElementPtr);
pSolarSysState->CurNode = num_nodes;
(*pSolarSysState->GenFunc) ((BYTE)(scan + GENERATE_MINERAL));
callGenerateForScanType (pSolarSysState,
pSolarSysState->pOrbitalDesc, &pSolarSysState->CurNode,
scan);
NodeElementPtr->scan_node = MAKE_WORD (scan, num_nodes + 1);
NodeElementPtr->playerNr = PS_NON_PLAYER;
+10 -4
View File
@@ -19,28 +19,34 @@
#ifndef _SCAN_H
#define _SCAN_H
typedef struct scan_desc SCAN_DESC;
typedef struct scan_block SCAN_BLOCK;
#include "libs/compiler.h"
#include "libs/gfxlib.h"
#include "planets.h"
typedef struct
struct scan_desc
{
POINT start;
COUNT start_dot;
COUNT num_dots;
COUNT dots_per_semi;
} SCAN_DESC;
};
typedef struct
struct scan_block
{
POINT *line_base;
COUNT num_scans;
COUNT num_same_scans;
SCAN_DESC *scan_base;
} SCAN_BLOCK;
};
extern void RepairBackRect (RECT *pRect);
extern void GeneratePlanetSide (void);
extern bool callGenerateForScanType (SOLARSYS_STATE *solarSys,
PLANET_DESC *world, COUNT *node, BYTE scanType);
extern void RedrawSurfaceScan (const POINT *newLoc);
+71 -209
View File
@@ -24,6 +24,7 @@
#include "../encount.h"
#include "../races.h"
#include "../gamestr.h"
#include "../gendef.h"
#include "../globdata.h"
#include "../sis.h"
#include "../init.h"
@@ -47,7 +48,10 @@
SOLARSYS_STATE *pSolarSysState;
FRAME SISIPFrame, SunFrame, OrbitalFrame, SpaceJunkFrame;
FRAME SISIPFrame;
FRAME SunFrame;
FRAME OrbitalFrame;
FRAME SpaceJunkFrame;
COLORMAP OrbitalCMap;
COLORMAP SunCMap;
MUSIC_REF SpaceMusic;
@@ -71,73 +75,61 @@ BYTE draw_sys_flags = DRAW_STARS | DRAW_PLANETS | DRAW_ORBITS
bool
currentWorldIsPlanet (void) {
return pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc;
}
bool
currentPlanetIndex (void) {
return (currentWorldIsPlanet ()) ?
(pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc) :
pSolarSysState->pOrbitalDesc->pPrevDesc -
pSolarSysState->PlanetDesc;
}
bool
currentMoonIndex (void) {
assert (!currentWorldIsPlanet ());
return (pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc);
}
// NB. This function modifies the RNG state.
static void
GeneratePlanets (SOLARSYS_STATE *system)
worldIsPlanet (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world)
{
COUNT i;
PLANET_DESC *planet;
return world->pPrevDesc == solarSys->SunDesc;
}
for (i = system->SunDesc[0].NumPlanets,
planet = &system->PlanetDesc[0]; i; --i, ++planet)
bool
worldIsMoon (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world)
{
return world->pPrevDesc != solarSys->SunDesc;
}
// Returns the planet index of the world. If the world is a moon, then
// this is the index of the planet it is orbiting.
COUNT
planetIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world)
{
const PLANET_DESC *planet = worldIsPlanet (solarSys, world) ?
world : world->pPrevDesc;
return planet - solarSys->PlanetDesc;
}
COUNT
moonIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *moon)
{
assert (!worldIsPlanet (solarSys, moon));
return moon - solarSys->MoonDesc;
}
// Test whether 'world' is the planetI-th planet, and if moonI is not
// set to MATCH_PLANET, also whether 'world' is the moonI-th moon.
bool
matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world,
BYTE planetI, BYTE moonI)
{
// Check whether we have the right planet.
if (planetIndex (solarSys, world) != planetI)
return false;
if (moonI == MATCH_PLANET)
{
DWORD rand_val;
BYTE byte_val;
BYTE num_moons;
BYTE type;
rand_val = TFB_Random ();
byte_val = LOBYTE (rand_val);
num_moons = 0;
type = PlanData[planet->data_index & ~PLANET_SHIELDED].Type;
switch (PLANSIZE (type))
{
case LARGE_ROCKY_WORLD:
if (byte_val < 0x00FF * 25 / 100)
{
if (byte_val < 0x00FF * 5 / 100)
++num_moons;
++num_moons;
}
break;
case GAS_GIANT:
if (byte_val < 0x00FF * 90 / 100)
{
if (byte_val < 0x00FF * 75 / 100)
{
if (byte_val < 0x00FF * 50 / 100)
{
if (byte_val < 0x00FF * 25 / 100)
++num_moons;
++num_moons;
}
++num_moons;
}
++num_moons;
}
break;
}
planet->NumPlanets = num_moons;
// Only test whether we are at the planet.
if (!worldIsPlanet (solarSys, world))
return false;
}
else
{
// Test whether the moon matches too
if (!worldIsMoon (solarSys, world))
return false;
if (moonIndex (solarSys, world) != moonI)
return false;
}
return true;
}
static void
@@ -159,8 +151,8 @@ GenerateMoons (void)
pCurDesc = pSolarSysState->pBaseDesc;
old_seed = TFB_SeedRandom (pCurDesc->rand_seed);
(*pSolarSysState->GenFunc) (GENERATE_NAME);
(*pSolarSysState->GenFunc) (GENERATE_MOONS);
(*pSolarSysState->genFuncs->generateName) (pSolarSysState, pCurDesc);
(*pSolarSysState->genFuncs->generateMoons) (pSolarSysState, pCurDesc);
facing = NORMALIZE_FACING (ANGLE_TO_FACING (
ARCTAN (pCurDesc->location.x, pCurDesc->location.y)));
@@ -286,7 +278,8 @@ sortPlanetPositions (void)
static void
initSolarSysSISCharacteristics (void)
{
BYTE i, num_thrusters;
BYTE i;
BYTE num_thrusters;
num_thrusters = 0;
for (i = 0; i < NUM_DRIVE_SLOTS; ++i)
@@ -348,7 +341,7 @@ LoadSolarSys (void)
pCurDesc->image.origin = pCurDesc->location;
pCurDesc->image.frame = SunFrame;
(*pSolarSysState->GenFunc) (GENERATE_PLANETS);
(*pSolarSysState->genFuncs->generatePlanets) (pSolarSysState);
if (GET_GAME_STATE (PLANETARY_CHANGE))
{
PutPlanetInfo ();
@@ -1426,7 +1419,8 @@ StartGroups:
}
GetPlanetInfo ();
(*pSolarSysState->GenFunc) (GENERATE_ORBITAL);
(*pSolarSysState->genFuncs->generateOrbital) (pSolarSysState,
pSolarSysState->pOrbitalDesc);
LastActivity &= ~(CHECK_LOAD | CHECK_RESTART);
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD |
START_ENCOUNTER)) || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
@@ -1435,8 +1429,8 @@ StartGroups:
if (pSolarSysState->MenuState.flash_task == 0)
{
/* Note! This implies that our GenFunc was a
conversation; that is, that this is a homeworld */
/* Note! This implies that our generateOrbital function started
a conversation; that is, that this is a homeworld */
SetTransitionSource (NULL);
LoadSolarSys ();
ValidateOrbits ();
@@ -1490,7 +1484,7 @@ InitSolarSys (void)
if (Reentry)
{
(*pSolarSysState->GenFunc) (REINIT_NPCS);
(*pSolarSysState->genFuncs->reinitNpcs) ();
}
else
{
@@ -1499,7 +1493,7 @@ InitSolarSys (void)
GLOBAL (BattleGroupRef) = 0;
ReinitQueue (&GLOBAL (ip_group_q));
ReinitQueue (&GLOBAL (npc_built_ship_q));
(*pSolarSysState->GenFunc) (INIT_NPCS);
(*pSolarSysState->genFuncs->initNpcs) ();
}
if (pSolarSysState->MenuState.Initialized == 0)
@@ -1569,7 +1563,7 @@ endInterPlanetary (void)
{
// These are game state changing ops and so cannot be
// called once another game has been loaded!
(*pSolarSysState->GenFunc) (UNINIT_NPCS);
(*pSolarSysState->genFuncs->uninitNpcs) ();
SET_GAME_STATE (USED_BROADCASTER, 0);
}
}
@@ -1629,140 +1623,8 @@ UninitSolarSys (void)
pSolarSysState->pBaseDesc =
closestPlanetInterPlanetary (&GLOBAL (ShipStamp.origin));
(*pSolarSysState->GenFunc) (GENERATE_NAME);
}
}
}
static void
GenerateOrbital (void) {
COUNT i;
DWORD rand_val;
#ifdef DEBUG_SOLARSYS
if (currentWorldIsPlanet ())
{
log_add (log_Debug, "Planet index = %d", currentPlanetIndex ());
}
else
{
log_add (log_Debug, "Planet index = %d, Moon index = %d",
currentPlanetIndex (), currentMoonIndex ());
}
#endif /* DEBUG_SOLARSYS */
rand_val = DoPlanetaryAnalysis (&pSolarSysState->SysInfo,
pSolarSysState->pOrbitalDesc);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
i = (COUNT)~0;
rand_val = GenerateLifeForms (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
i = (COUNT)~0;
GenerateMineralDeposits (&pSolarSysState->SysInfo, &i);
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
LoadPlanet (NULL);
}
static void
check_yehat_rebellion (void)
{
HIPGROUP hGroup, hNextGroup;
// XXX: Is there a better way to do this? I could not find one.
// When you talk to a Yehat ship (YEHAT_SHIP) and start the rebellion,
// there is no battle following the comm. There is *never* a battle in
// an encounter with Rebels, but the group race_id (YEHAT_REBEL_SHIP)
// is different from Royalists (YEHAT_SHIP). There is *always* a battle
// in an encounter with Royalists.
// TRANSLATION: "If the civil war has not started yet, or the player
// battled a ship -- bail."
if (!GET_GAME_STATE (YEHAT_CIVIL_WAR) || EncounterRace >= 0)
return; // not this time
// Send Yehat groups to flee the system, but only if the player
// has actually talked to a ship.
for (hGroup = GetHeadLink (&GLOBAL (ip_group_q)); hGroup;
hGroup = hNextGroup)
{
IP_GROUP *GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup);
hNextGroup = _GetSuccLink (GroupPtr);
// IGNORE_FLAGSHIP was set in ipdisp.c:ip_group_collision()
// during a collision with the flagship.
if (GroupPtr->race_id == YEHAT_SHIP
&& (GroupPtr->task & IGNORE_FLAGSHIP))
{
GroupPtr->task &= REFORM_GROUP;
GroupPtr->task |= FLEE | IGNORE_FLAGSHIP;
GroupPtr->dest_loc = 0;
}
UnlockIpGroup (&GLOBAL (ip_group_q), hGroup);
}
}
void
GenerateRandomIP (BYTE control)
{
switch (control)
{
case INIT_NPCS:
if (!GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP))
{
GLOBAL (BattleGroupRef) = 0;
BuildGroups ();
}
break;
case REINIT_NPCS:
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
// This is not a great place to do the Yehat rebellion check, but
// since you can start the rebellion in any star system (not just
// the Homeworld), I could not find a better place for it.
// At least it is better than where it was originally.
check_yehat_rebellion ();
break;
case UNINIT_NPCS:
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (npc_built_ship_q));
ReinitQueue (&GLOBAL (ip_group_q));
break;
case GENERATE_MINERAL:
GenerateMineralDeposits (&pSolarSysState->SysInfo,
&pSolarSysState->CurNode);
break;
case GENERATE_ENERGY:
pSolarSysState->CurNode = 0;
break;
case GENERATE_LIFE:
GenerateLifeForms (&pSolarSysState->SysInfo,
&pSolarSysState->CurNode);
break;
case GENERATE_ORBITAL:
{
GenerateOrbital ();
break;
}
case GENERATE_NAME:
{
COUNT i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc;
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + (9 + 7) + i));
SET_GAME_STATE (BATTLE_PLANET,
pSolarSysState->PlanetDesc[i].data_index);
break;
}
case GENERATE_MOONS:
FillOrbits (pSolarSysState,
pSolarSysState->pBaseDesc->NumPlanets,
&pSolarSysState->MoonDesc[0], FALSE);
break;
case GENERATE_PLANETS:
{
FillOrbits (pSolarSysState,
(BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE);
GeneratePlanets (pSolarSysState);
break;
(*pSolarSysState->genFuncs->generateName) (
pSolarSysState, pSolarSysState->pBaseDesc);
}
}
}
@@ -2031,7 +1893,7 @@ ExploreSolarSys (void)
memset (pSolarSysState, 0, sizeof (*pSolarSysState));
SolarSysState.GenFunc = GenerateIP (CurStarDescPtr->Index);
SolarSysState.genFuncs = getGenerateFunctions (CurStarDescPtr->Index);
InitSolarSys ();
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
+2 -1
View File
@@ -688,7 +688,8 @@ RetrySave:
SaveRaceQueue (fh, &GLOBAL (avail_race_q));
// START_INTERPLANETARY is only set when saving from Homeworld
// encounter screen. When the game is loaded, GENERATE_ORBITAL will
// encounter screen. When the game is loaded, the
// GenerateOrbitalFunction for the current star system
// create the encounter anew and populate the npc queue.
if (!(GLOBAL (CurrentActivity) & START_INTERPLANETARY))
{
+45 -36
View File
@@ -28,6 +28,7 @@
#include "status.h"
#include "gamestr.h"
#include "gameev.h"
#include "gendef.h"
#include "globdata.h"
#include "planets/lifeform.h"
#include "races.h"
@@ -635,10 +636,10 @@ starRecurse (STAR_DESC *star, void *arg)
SolarSysState.SunDesc[0].location.x = 0;
SolarSysState.SunDesc[0].location.y = 0;
//SolarSysState.SunDesc[0].radius = MIN_ZOOM_RADIUS;
SolarSysState.GenFunc = GenerateIP (star->Index);
SolarSysState.genFuncs = getGenerateFunctions (star->Index);
pSolarSysState = &SolarSysState;
(*pSolarSysState->GenFunc) (GENERATE_PLANETS);
(*SolarSysState.genFuncs->generatePlanets) (&SolarSysState);
if (universeRecurseArg->systemFuncPre != NULL)
{
@@ -666,8 +667,8 @@ starRecurse (STAR_DESC *star, void *arg)
}
static void
planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
PLANET_DESC *planet, void *arg)
planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
void *arg)
{
UniverseRecurseArg *universeRecurseArg = (UniverseRecurseArg *) arg;
@@ -681,10 +682,10 @@ planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
{
system->pOrbitalDesc = planet;
DoPlanetaryAnalysis (&system->SysInfo, planet);
// When GenerateRandomIP is used as GenFunc,
// GENERATE_ORBITAL will also call DoPlanetaryAnalysis,
// but with other GenFuncs this is not guaranteed.
(*system->GenFunc) (GENERATE_ORBITAL);
// When GenerateDefaultFunctions is used as genFuncs,
// generateOrbital will also call DoPlanetaryAnalysis,
// but with other GenerateFunctions this is not guaranteed.
(*system->genFuncs->generateOrbital) (system, planet);
(*universeRecurseArg->planetFuncPre) (
planet, universeRecurseArg->arg);
}
@@ -693,7 +694,7 @@ planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
{
DWORD oldSeed = TFB_SeedRandom (planet->rand_seed);
(*system->GenFunc) (GENERATE_MOONS);
(*system->genFuncs->generateMoons) (system, planet);
forAllMoons (star, system, planet, moonRecurse,
(void *) universeRecurseArg);
@@ -705,10 +706,10 @@ planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
{
system->pOrbitalDesc = planet;
DoPlanetaryAnalysis (&system->SysInfo, planet);
// When GenerateRandomIP is used as GenFunc,
// GENERATE_ORBITAL will also call DoPlanetaryAnalysis,
// but with other GenFuncs this is not guaranteed.
(*system->GenFunc) (GENERATE_ORBITAL);
// When GenerateDefaultFunctions is used as genFuncs,
// generateOrbital will also call DoPlanetaryAnalysis,
// but with other GenerateFunctions this is not guaranteed.
(*system->genFuncs->generateOrbital) (system, planet);
(*universeRecurseArg->planetFuncPost) (
planet, universeRecurseArg->arg);
}
@@ -730,10 +731,10 @@ moonRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
{
system->pOrbitalDesc = moon;
DoPlanetaryAnalysis (&system->SysInfo, moon);
// When GenerateRandomIP is used as GenFunc,
// GENERATE_ORBITAL will also call DoPlanetaryAnalysis,
// but with other GenFuncs this is not guaranteed.
(*system->GenFunc) (GENERATE_ORBITAL);
// When GenerateDefaultFunctions is used as genFuncs,
// generateOrbital will also call DoPlanetaryAnalysis,
// but with other GenerateFunctions this is not guaranteed.
(*system->genFuncs->generateOrbital) (system, moon);
(*universeRecurseArg->moonFunc) (
moon, universeRecurseArg->arg);
}
@@ -974,7 +975,8 @@ dumpPlanetCallback (const PLANET_DESC *planet, void *arg)
void
dumpPlanet (FILE *out, const PLANET_DESC *planet)
{
(*pSolarSysState->GenFunc) (GENERATE_NAME);
(*pSolarSysState->genFuncs->generateName) (
pSolarSysState, (PLANET_DESC *) planet);
fprintf (out, "- %-37s %s\n", GLOBAL_SIS (PlanetName),
planetTypeString (planet->data_index & ~PLANET_SHIELDED));
dumpWorld (out, planet);
@@ -1053,17 +1055,19 @@ calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world)
COUNT numBio;
COUNT i;
assert(system->pOrbitalDesc == world);
assert (system->pOrbitalDesc == world);
((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0;
(*system->GenFunc) (GENERATE_LIFE);
(*system->genFuncs->generateLife) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
numBio = system->CurNode;
result = 0;
for (i = 0; i < numBio; i++)
{
((SOLARSYS_STATE *) system)->CurNode = i;
(*system->GenFunc) (GENERATE_LIFE);
(*system->genFuncs->generateLife) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
result += BIO_CREDIT_VALUE * LONIBBLE (CreatureData[
system->SysInfo.PlanetInfo.CurType].ValueAndHitPoints);
}
@@ -1071,16 +1075,17 @@ calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world)
}
void
generateBioIndex(const SOLARSYS_STATE *system,
const PLANET_DESC *world, COUNT bio[])
generateBioIndex(const SOLARSYS_STATE *system, const PLANET_DESC *world,
COUNT bio[])
{
COUNT numBio;
COUNT i;
assert(system->pOrbitalDesc == world);
assert (system->pOrbitalDesc == world);
((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0;
(*system->GenFunc) (GENERATE_LIFE);
(*system->genFuncs->generateLife) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
numBio = system->CurNode;
for (i = 0; i < NUM_CREATURE_TYPES + NUM_SPECIAL_CREATURE_TYPES; i++)
@@ -1089,30 +1094,32 @@ generateBioIndex(const SOLARSYS_STATE *system,
for (i = 0; i < numBio; i++)
{
((SOLARSYS_STATE *) system)->CurNode = i;
(*system->GenFunc) (GENERATE_LIFE);
(*system->genFuncs->generateLife) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
bio[system->SysInfo.PlanetInfo.CurType]++;
}
}
COUNT
calculateMineralValue (const SOLARSYS_STATE *system,
const PLANET_DESC *world)
calculateMineralValue (const SOLARSYS_STATE *system, const PLANET_DESC *world)
{
COUNT result;
COUNT numDeposits;
COUNT i;
assert(system->pOrbitalDesc == world);
assert (system->pOrbitalDesc == world);
((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0;
(*system->GenFunc) (GENERATE_MINERAL);
(*system->genFuncs->generateMinerals) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
numDeposits = system->CurNode;
result = 0;
for (i = 0; i < numDeposits; i++)
{
((SOLARSYS_STATE *) system)->CurNode = i;
(*system->GenFunc) (GENERATE_MINERAL);
(*system->genFuncs->generateMinerals) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
result += HIBYTE (system->SysInfo.PlanetInfo.CurDensity) *
GLOBAL (ElementWorth[ElementCategory (
system->SysInfo.PlanetInfo.CurType)]);
@@ -1121,16 +1128,17 @@ calculateMineralValue (const SOLARSYS_STATE *system,
}
void
generateMineralIndex(const SOLARSYS_STATE *system,
const PLANET_DESC *world, COUNT minerals[])
generateMineralIndex(const SOLARSYS_STATE *system, const PLANET_DESC *world,
COUNT minerals[])
{
COUNT numDeposits;
COUNT i;
assert(system->pOrbitalDesc == world);
assert (system->pOrbitalDesc == world);
((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0;
(*system->GenFunc) (GENERATE_MINERAL);
(*system->genFuncs->generateMinerals) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
numDeposits = system->CurNode;
for (i = 0; i < NUM_ELEMENT_CATEGORIES; i++)
@@ -1139,7 +1147,8 @@ generateMineralIndex(const SOLARSYS_STATE *system,
for (i = 0; i < numDeposits; i++)
{
((SOLARSYS_STATE *) system)->CurNode = i;
(*system->GenFunc) (GENERATE_MINERAL);
(*system->genFuncs->generateMinerals) ((SOLARSYS_STATE *) system,
(PLANET_DESC *) world, &((SOLARSYS_STATE *) system)->CurNode);
minerals[ElementCategory(system->SysInfo.PlanetInfo.CurType)] +=
HIBYTE (system->SysInfo.PlanetInfo.CurDensity);
}
+2 -2
View File
@@ -21,8 +21,8 @@
#define UQM_MAJOR_VERSION_S "0"
#define UQM_MINOR_VERSION 6
#define UQM_MINOR_VERSION_S "6"
#define UQM_PATCH_VERSION 7
#define UQM_PATCH_VERSION_S "7"
#define UQM_PATCH_VERSION 8
#define UQM_PATCH_VERSION_S "8"
#define UQM_EXTRA_VERSION ""
/* The final version is interpreted as:
* printf ("%d.%d.%d%s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,