rem: if (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) printf ("Planet index = %d\n", pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc); else printf ("Planet index = %d, Moon index = %d\n", pSolarSysState->pOrbitalDesc->pPrevDesc - pSolarSysState->PlanetDesc, pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc);
add: if (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) fprintf (stderr, "Planet index = %d\n", pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc); else fprintf (stderr, "Planet index = %d, Moon index = %d\n", pSolarSysState->pOrbitalDesc->pPrevDesc - pSolarSysState->PlanetDesc, pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc);
context: GenerateRandomIP (BYTE control){	COUNT i;	DWORD rand_val;	PPLANET_DESC pCurDesc;	switch (control)	{		case INIT_NPCS:			if (!GetGroupInfo (GLOBAL (BattleGroupRef), (BYTE)~0))			{				GLOBAL (BattleGroupRef) = 0;				BuildGroups ();			}			break;		case REINIT_NPCS:			GetGroupInfo (0L, 0);			break;		case UNINIT_NPCS:			PutGroupInfo (0L, (BYTE)~0);			ReinitQueue (&GLOBAL (npc_built_ship_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:		{#ifdef DEBUGif (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc)	printf ("Planet index = %d\n", pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc);else	printf ("Planet index = %d, Moon index = %d\n",			pSolarSysState->pOrbitalDesc->pPrevDesc - pSolarSysState->PlanetDesc,			pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc);#endif /* DEBUG */			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 (FALSE);			break;		}		case GENERATE_NAME:		{			i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc;			wsprintf (GLOBAL_SIS (PlanetName), "%s", GAME_STRING (PLANET_NUMBER_BASE + (9 + 7) + i));			SET_GAME_STATE (BATTLE_PLANET, pSolarSysState->PlanetDesc[i].data_index);			break;		}		case GENERATE_MOONS:			FillOrbits (					pSolarSysState->pBaseDesc->NumPlanets,					&pSolarSysState->MoonDesc[0], FALSE					);			break;		case GENERATE_PLANETS:		{			FillOrbits ((BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE);			for (i = pSolarSysState->SunDesc[0].NumPlanets,					pCurDesc = &pSolarSysState->PlanetDesc[0]; i; --i, ++pCurDesc)			{				BYTE byte_val;				BYTE num_moons;				rand_val = Random ();				byte_val = LOBYTE (rand_val);				num_moons = 0;				switch (PLANSIZE (PlanData[						pCurDesc->data_index & ~PLANET_SHIELDED						].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;				}				pCurDesc->NumPlanets = num_moons;			}			break;		}	}}