And this is the first C++ generator!

Hello, gas bags!  Somehow, it seems fitting that they're the first...
they did, after all, mess up the code/settings on the probes
to wreak havoc!

Hopefully I haven't!  :-)

I think I can simplify things a lot from here...
This commit is contained in:
2024-04-25 02:03:02 -04:00
parent 822e1c3004
commit 97148db2d4
3 changed files with 17 additions and 5 deletions
+2 -1
View File
@@ -21,6 +21,7 @@
#include "planets/planets.h"
#include "planets/elemdata.h"
extern struct GeneratorBase slyDef;
// This array has to be sorted in Y coordinate order then X coordinate order.
// Items out of order can cause crashes (better, actually) or "ghost"
@@ -538,7 +539,7 @@ STAR_DESC starmap_array[] =
{{1937, 9979}, MAKE_STAR (DWARF_STAR, RED_BODY, -1), 0, 1, 103},
#endif
{{1004, 1083}, MAKE_STAR (DWARF_STAR, GREEN_BODY, -1), SLYLANDRO_DEFINED, 2, 27},
{{1004, 1083}, MAKE_STAR (DWARF_STAR, GREEN_BODY, -1), CXX_DEFINED, 2, 27, &slyDef},
{{1776, 1395}, MAKE_STAR (DWARF_STAR, YELLOW_BODY, -1), START_COLONY_DEFINED, 0, 98},
{{1777, 1405}, MAKE_STAR (DWARF_STAR, YELLOW_BODY, -1), 0, 0, 99},
+6 -1
View File
@@ -25,6 +25,10 @@ struct GenerateFunctions;
typedef struct GenerateFunctions GenerateFunctions;
struct GeneratorBase {};
typedef struct GeneratorBase GeneratorBase;
#if defined(__cplusplus)
}
#endif
@@ -126,6 +130,7 @@ namespace Planets ::detail:: Generate_m
}
class exports::Generator
: public GeneratorBase
{
public:
virtual ~Generator()= 0;
@@ -159,7 +164,7 @@ namespace Planets ::detail:: Generate_m
};
class exports::DefaultGenerator
: virtual public Generator
: public Generator
{
public:
~DefaultGenerator() override;
@@ -21,17 +21,21 @@
#include "../planets.h"
#include "../../comm.h"
#include <iostream>
namespace
{
using namespace Planets::exports;
class GenerateSlylandro
: public virtual DefaultGenerator
: public DefaultGenerator
{
bool
generatePlanets( SolarSystem *const solarSys ) override
{
std::cerr << "The C++ generator for slylandro planets was called!" << std::endl;
DefaultGenerator::generatePlanets( solarSys );
solarSys->PlanetDesc[ 3 ].data_index = RED_GAS_GIANT;
@@ -43,6 +47,8 @@ namespace
bool
generateOrbital( SolarSystem *const solarSys, PLANET_DESC *const world )
{
std::cerr << "The C++ generator for slylandro orbital was called!" << std::endl;
if( matchWorld( solarSys, world, 3, MATCH_PLANET ) )
{
InitCommunication( SLYLANDRO_HOME_CONVERSATION );
@@ -54,7 +60,7 @@ namespace
};
}
extern "C" void *getSlyDef()
extern "C"
{
return static_cast< Generator * >( new GenerateSlylandro{} );
GenerateSlylandro slyDef;
}