Galactic Bloodshed
Macros | Functions | Variables
racegen.cc File Reference
#include "gb/racegen.h"
#include <unistd.h>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "gb/enroll.h"
#include "gb/game_info.h"
Include dependency graph for racegen.cc:

Go to the source code of this file.

Macros

#define ROUND(f)   ((int)(0.5 + (f)))
 
#define FPRINTF   if (f != nullptr) fprintf
 
#define FSCANF(file, format, variable)   if (EOF == fscanf((file), (format), (variable))) goto premature_end_of_file
 
#define FPRINTF   if (verbose) fprintf
 
#define INPUTSIZE   512
 
#define BUFSIZE   512
 

Functions

static int do_racegen ()
 
static int critique_modification ()
 
static void execute (int argc, char **argv)
 
static void fix_up_iq ()
 
static void initialize ()
 
static void help (int, char *[])
 
static void load (int, char *[])
 
static void metamorph ()
 
static int modify (int argc, char *argv[])
 
static void normal ()
 
static void print (int argc, char *argv[])
 
static void save (int argc, char *argv[])
 
static void send2 (int argc, char *argv[])
 
static void quit (int argc, char **argv)
 
int main ()
 
int cost_of_race ()
 
int critique_to_file (FILE *f, int rigorous_checking, int is_player_race)
 
int load_from_file (FILE *g)
 
static int load_from_filename (const char *filename)
 
void print_to_file (FILE *f, int verbose)
 
static int print_to_filename (const char *filename, int verbose)
 
static void send2 (int, char **)
 
int Dialogue (const char *prompt,...)
 
void modify_print_loop (int)
 

Variables

static int fd
 
static int isserver = 0
 
static attribute attr [N_ATTRIBUTES]
 
const char * planet_print_name [N_HOME_PLANET_TYPES]
 
const int planet_cost [N_HOME_PLANET_TYPES] = {75, 50, 50, 50, -25, -25, 600}
 
const char * race_print_name [N_RACE_TYPES] = {"Normal", "Metamorph"}
 
const int race_cost [N_RACE_TYPES] = {0, 0}
 
const char * priv_print_name [N_PRIV_TYPES] = {"God", "Guest", "Normal"}
 
const char * sector_print_name [N_SECTOR_TYPES]
 
const int blah [N_SECTOR_TYPES] = {-1, 0, 50, 100, 200, 300, 400, 500}
 
const double compat_cov [N_SECTOR_TYPES][N_SECTOR_TYPES]
 
const double planet_compat_cov [N_HOME_PLANET_TYPES][N_SECTOR_TYPES]
 
struct x race_info cost_info last
 
int npoints = STARTING_POINTS
 
int last_npoints = STARTING_POINTS
 
int altered = 0
 
int changed = 1
 
int please_quit = 0
 

Macro Definition Documentation

◆ BUFSIZE

#define BUFSIZE   512

◆ FPRINTF [1/2]

#define FPRINTF   if (f != nullptr) fprintf

◆ FPRINTF [2/2]

#define FPRINTF   if (verbose) fprintf

◆ FSCANF

#define FSCANF (   file,
  format,
  variable 
)    if (EOF == fscanf((file), (format), (variable))) goto premature_end_of_file

◆ INPUTSIZE

#define INPUTSIZE   512

◆ ROUND

#define ROUND (   f)    ((int)(0.5 + (f)))

Function Documentation

◆ cost_of_race()

int cost_of_race ( )

Definition at line 332 of file racegen.cc.

References attr, x::attr, blah, x::compat, compat_cov, attribute::cov, attribute::e_factor, attribute::e_fudge, attribute::e_hinge, x::home_planet_type, attribute::l_factor, attribute::l_fudge, x::n_sector_types, planet_compat_cov, planet_cost, race_cost, and x::race_type.

Referenced by initialize(), modify_print_loop(), and process().

Here is the caller graph for this function:

◆ critique_modification()

static int critique_modification ( )
static

Definition at line 614 of file racegen.cc.

References altered, changed, critique_to_file(), x::rejection, and x::status.

Referenced by modify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ critique_to_file()

int critique_to_file ( FILE *  f,
int  rigorous_checking,
int  is_player_race 
)

Definition at line 440 of file racegen.cc.

References x::address, attr, x::attr, x::compat, x::home_planet_type, attribute::is_integral, attribute::maximum, attribute::minimum, x::n_sector_types, npoints, x::password, planet_compat_cov, attribute::print_name, priv_print_name, x::priv_type, x::race_type, x::rejection, and x::status.

Referenced by critique_modification(), enroll(), enroll_player_race(), and send2().

Here is the caller graph for this function:

◆ Dialogue()

int Dialogue ( const char *  prompt,
  ... 
)

Definition at line 1213 of file racegen.cc.

Referenced by do_racegen(), enroll_player_race(), load(), and quit().

Here is the caller graph for this function:

◆ do_racegen()

static int do_racegen ( )
static

Definition at line 1371 of file racegen.cc.

References Dialogue(), initialize(), and modify_print_loop().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute()

static void execute ( int  argc,
char **  argv 
)
static

Definition at line 1282 of file racegen.cc.

References help(), load(), modify(), print(), quit(), save(), and send2().

Referenced by modify_print_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fix_up_iq()

static void fix_up_iq ( )
static

Definition at line 425 of file racegen.cc.

References attr, x::attr, and attribute::print_name.

Referenced by load_from_file(), and modify().

Here is the caller graph for this function:

◆ help()

static void help ( int  argc,
char *  argv[] 
)
static

Definition at line 661 of file racegen.cc.

References attr, x::filename, planet_print_name, attribute::print_name, race_print_name, and sector_print_name.

Referenced by execute(), and modify().

Here is the caller graph for this function:

◆ initialize()

static void initialize ( )
static

Definition at line 631 of file racegen.cc.

References x::address, attr, x::attr, x::compat, cost_of_race(), x::home_planet_type, attribute::init, attribute::l_fudge, x::n_sector_types, x::name, normal(), x::password, x::priv_type, and x::race_type.

Referenced by do_racegen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

static void load ( int  argc,
char *  argv[] 
)
static

Definition at line 900 of file racegen.cc.

References altered, changed, Dialogue(), x::filename, and load_from_filename().

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_file()

int load_from_file ( FILE *  g)

Definition at line 843 of file racegen.cc.

References x::address, x::attr, x::compat, fix_up_iq(), x::home_planet_type, metamorph(), x::name, normal(), x::password, x::priv_type, x::race_type, and x::status.

Referenced by load_from_filename(), and process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_filename()

static int load_from_filename ( const char *  filename)
static

Definition at line 887 of file racegen.cc.

References load_from_file().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 45 of file racegen.cc.

References do_racegen().

Here is the call graph for this function:

◆ metamorph()

static void metamorph ( )
static

Morphs are not born, they hatch. THus the mass limitation is smaller:

Morphs are naturally adept at fertilization.

Due to general squishiness, this effect is not as strong for mesos.

IQ represents max IQ, thus, no go.

Definition at line 374 of file racegen.cc.

References attr, attribute::cov, and attribute::print_name.

Referenced by load_from_file(), and modify().

Here is the caller graph for this function:

◆ modify()

static int modify ( int  argc,
char *  argv[] 
)
static

Definition at line 924 of file racegen.cc.

References x::address, attr, x::attr, x::compat, critique_modification(), fix_up_iq(), help(), x::home_planet_type, attribute::is_integral, metamorph(), x::name, normal(), x::password, and x::race_type.

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modify_print_loop()

void modify_print_loop ( int  )

Definition at line 1329 of file racegen.cc.

References changed, cost_of_race(), execute(), last_npoints, npoints, please_quit, and print_to_file().

Referenced by do_racegen(), and enroll_player_race().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normal()

static void normal ( )
static

Definition at line 401 of file racegen.cc.

References attr, attribute::cov, and attribute::print_name.

Referenced by initialize(), load_from_file(), and modify().

Here is the caller graph for this function:

◆ print()

static void print ( int  argc,
char *  argv[] 
)
static

Definition at line 1153 of file racegen.cc.

References print_to_file(), and print_to_filename().

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_to_file()

void print_to_file ( FILE *  f,
int  verbose 
)

Definition at line 1061 of file racegen.cc.

References x::address, attr, x::attr, x::compat, x::home_planet_type, attribute::is_integral, last_npoints, x::n_sector_types, x::name, npoints, x::password, planet_compat_cov, planet_print_name, attribute::print_name, x::priv_type, race_print_name, x::race_type, and sector_print_name.

Referenced by enroll_player_race(), modify_print_loop(), print(), print_to_filename(), and send2().

Here is the caller graph for this function:

◆ print_to_filename()

static int print_to_filename ( const char *  filename,
int  verbose 
)
static

Definition at line 1141 of file racegen.cc.

References print_to_file().

Referenced by print(), and save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quit()

static void quit ( int  argc,
char **  argv 
)
static

Definition at line 1256 of file racegen.cc.

References altered, Dialogue(), fd, isserver, please_quit, and save().

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

static void save ( int  argc,
char *  argv[] 
)
static

Definition at line 1160 of file racegen.cc.

References altered, x::filename, and print_to_filename().

Referenced by execute(), and quit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send2() [1/2]

static void send2 ( int  argc,
char *  argv[] 
)
static

◆ send2() [2/2]

static void send2 ( int  ,
char **   
)
static

Definition at line 1171 of file racegen.cc.

References x::address, critique_to_file(), x::password, and print_to_file().

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ altered

int altered = 0

Definition at line 323 of file racegen.cc.

Referenced by critique_modification(), load(), quit(), and save().

◆ attr

attribute attr[N_ATTRIBUTES]
static

◆ blah

const int blah[N_SECTOR_TYPES] = {-1, 0, 50, 100, 200, 300, 400, 500}

Definition at line 262 of file racegen.cc.

Referenced by cost_of_race().

◆ changed

int changed = 1

Definition at line 324 of file racegen.cc.

Referenced by critique_modification(), load(), and modify_print_loop().

◆ compat_cov

const double compat_cov[N_SECTOR_TYPES][N_SECTOR_TYPES]

Definition at line 264 of file racegen.cc.

Referenced by cost_of_race().

◆ fd

int fd
static

Definition at line 28 of file racegen.cc.

Referenced by quit().

◆ isserver

int isserver = 0
static

Definition at line 29 of file racegen.cc.

Referenced by quit().

◆ last

struct x race_info cost_info last

Definition at line 319 of file racegen.cc.

◆ last_npoints

int last_npoints = STARTING_POINTS

Definition at line 322 of file racegen.cc.

Referenced by modify_print_loop(), print_to_file(), and process().

◆ npoints

int npoints = STARTING_POINTS

Definition at line 321 of file racegen.cc.

Referenced by critique_to_file(), modify_print_loop(), print_to_file(), and process().

◆ planet_compat_cov

const double planet_compat_cov[N_HOME_PLANET_TYPES][N_SECTOR_TYPES]
Initial value:
= {
{1.00, 1.00, 2.00, 99.00, 1.01, 1.50, 3.00, 1.01},
{1.01, 1.50, 2.00, 99.00, 1.01, 1.00, 3.00, 1.01},
{3.00, 1.01, 1.01, 99.00, 1.50, 3.00, 1.00, 1.01},
{1.00, 1.50, 3.00, 99.00, 1.01, 1.01, 3.00, 1.01},
{1.01, 1.00, 1.00, 99.00, 1.01, 1.01, 1.00, 1.01},
{3.00, 1.01, 1.00, 99.00, 1.00, 1.50, 2.00, 1.01},
{99.00, 99.00, 99.00, 1.00, 99.00, 99.00, 99.00, 99.00}}

Definition at line 299 of file racegen.cc.

Referenced by cost_of_race(), critique_to_file(), and print_to_file().

◆ planet_cost

const int planet_cost[N_HOME_PLANET_TYPES] = {75, 50, 50, 50, -25, -25, 600}

Definition at line 252 of file racegen.cc.

Referenced by cost_of_race().

◆ planet_print_name

const char* planet_print_name[N_HOME_PLANET_TYPES]
Initial value:
= {
"Earth", "Forest", "Desert", "Water", "Airless", "Iceball", "Jovian"}

Definition at line 250 of file racegen.cc.

Referenced by help(), and print_to_file().

◆ please_quit

int please_quit = 0

Definition at line 325 of file racegen.cc.

Referenced by enroll_player_race(), modify_print_loop(), and quit().

◆ priv_print_name

const char* priv_print_name[N_PRIV_TYPES] = {"God", "Guest", "Normal"}

Definition at line 257 of file racegen.cc.

Referenced by critique_to_file().

◆ race_cost

const int race_cost[N_RACE_TYPES] = {0, 0}

Definition at line 255 of file racegen.cc.

Referenced by cost_of_race().

◆ race_print_name

const char* race_print_name[N_RACE_TYPES] = {"Normal", "Metamorph"}

Definition at line 254 of file racegen.cc.

Referenced by help(), and print_to_file().

◆ sector_print_name

const char* sector_print_name[N_SECTOR_TYPES]
Initial value:
= {
"Water", "Land", "Mountain", "Gas", "Ice", "Forest", "Desert", "Plated"}

Definition at line 259 of file racegen.cc.

Referenced by help(), and print_to_file().