Galactic Bloodshed
Functions | Variables
files_shl.cc File Reference
#include "gb/files_shl.h"
#include <fcntl.h>
#include <sqlite3.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <memory>
#include <stdexcept>
#include "gb/files.h"
#include "gb/files_rw.h"
#include "gb/power.h"
#include "gb/races.h"
#include "gb/ships.h"
#include "gb/tweakables.h"
#include "gb/vars.h"
Include dependency graph for files_shl.cc:

Go to the source code of this file.

Functions

static void start_bulk_insert ()
 
static void end_bulk_insert ()
 
void close_file (int fd)
 
void initsqldata ()
 
void openstardata (int *fd)
 
void openshdata (int *fd)
 
void opencommoddata (int *fd)
 
void openracedata (int *fd)
 
void getsdata (struct stardata *S)
 
void getrace (Race **r, int rnum)
 
void getstar (startype **s, int star)
 
Planet getplanet (const starnum_t star, const planetnum_t pnum)
 
Sector getsector (const Planet &p, const int x, const int y)
 
SectorMap getsmap (const Planet &p)
 
std::optional< Shipgetship (const shipnum_t shipnum)
 
std::optional< Shipgetship (Ship **s, const shipnum_t shipnum)
 
int getcommod (commodtype **c, commodnum_t commodnum)
 
int getdeadship ()
 
int getdeadcommod ()
 
void putsdata (struct stardata *S)
 
void putrace (Race *r)
 
void putstar (startype *s, starnum_t snum)
 
void putplanet (const Planet &p, startype *star, const int pnum)
 
void putsector (const Sector &s, const Planet &p, const int x, const int y)
 
void putsmap (SectorMap &map, Planet &p)
 
static void putship_aimed (const Ship &s)
 
static void putship_mind (const Ship &s)
 
static void putship_pod (const Ship &s)
 
static void putship_timer (const Ship &s)
 
static void putship_impact (const Ship &s)
 
static void putship_trigger (const Ship &s)
 
static void putship_terraform (const Ship &s)
 
static void putship_transport (const Ship &s)
 
static void putship_waste (const Ship &s)
 
void putship (Ship *s)
 
void putcommod (commodtype *c, int commodnum)
 
int Numraces ()
 
shipnum_t Numships ()
 
int Numcommods ()
 
int Newslength (int type)
 
void clr_shipfree ()
 
void clr_commodfree ()
 
void makeshipdead (int shipnum)
 
void makecommoddead (int commodnum)
 
void Putpower (struct power p[MAXPLAYERS])
 
void Getpower (struct power p[MAXPLAYERS])
 
void Putblock (struct block b[MAXPLAYERS])
 
void Getblock (struct block b[MAXPLAYERS])
 

Variables

static int commoddata
 
static int racedata
 
static int shdata
 
static int stdata
 
sqlite3 * dbconn
 

Function Documentation

◆ close_file()

void close_file ( int  fd)

Definition at line 40 of file files_shl.cc.

Referenced by Getblock(), getdeadcommod(), getdeadship(), Getpower(), makecommoddead(), makeshipdead(), Putblock(), Putpower(), and Db::~Db().

Here is the caller graph for this function:

◆ clr_commodfree()

void clr_commodfree ( )

Definition at line 1572 of file files_shl.cc.

Referenced by do_turn().

Here is the caller graph for this function:

◆ clr_shipfree()

void clr_shipfree ( )

Definition at line 1570 of file files_shl.cc.

Referenced by do_turn().

Here is the caller graph for this function:

◆ end_bulk_insert()

static void end_bulk_insert ( )
static

Definition at line 929 of file files_shl.cc.

References dbconn.

Referenced by putplanet(), putship(), putsmap(), and putstar().

Here is the caller graph for this function:

◆ Getblock()

void Getblock ( struct block  b[MAXPLAYERS])

Definition at line 1661 of file files_shl.cc.

References close_file().

Here is the call graph for this function:

◆ getcommod()

int getcommod ( commodtype **  c,
commodnum_t  commodnum 
)

Definition at line 730 of file files_shl.cc.

References commoddata.

Referenced by bid(), and do_turn().

Here is the caller graph for this function:

◆ getdeadcommod()

int getdeadcommod ( )

Definition at line 777 of file files_shl.cc.

References close_file().

Referenced by sell().

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

◆ getdeadship()

int getdeadship ( )

Definition at line 751 of file files_shl.cc.

References close_file().

Referenced by create_ship_by_planet(), and create_ship_by_ship().

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

◆ getplanet()

Planet getplanet ( const starnum_t  star,
const planetnum_t  pnum 
)

◆ Getpower()

void Getpower ( struct power  p[MAXPLAYERS])

Definition at line 1637 of file files_shl.cc.

References close_file().

Here is the call graph for this function:

◆ getrace()

void getrace ( Race **  r,
int  rnum 
)

Definition at line 276 of file files_shl.cc.

References racedata.

◆ getsdata()

void getsdata ( struct stardata S)

Definition at line 272 of file files_shl.cc.

References stdata.

Referenced by allocateAPs(), colonies(), deductAPs(), dissolve(), do_turn(), dump(), enroll_valid_race(), exploration(), launch(), main(), production(), start_shiplist(), and tech_status().

Here is the caller graph for this function:

◆ getsector()

Sector getsector ( const Planet p,
const int  x,
const int  y 
)

Definition at line 480 of file files_shl.cc.

References dbconn.

Referenced by arm(), build(), capture(), defend(), do_merchant(), land(), load(), move_popn(), scrap(), and walk().

Here is the caller graph for this function:

◆ getship() [1/2]

std::optional<Ship> getship ( const shipnum_t  shipnum)

Definition at line 560 of file files_shl.cc.

◆ getship() [2/2]

std::optional<Ship> getship ( Ship **  s,
const shipnum_t  shipnum 
)

Definition at line 564 of file files_shl.cc.

References dbconn, and shdata.

◆ getsmap()

SectorMap getsmap ( const Planet p)

Definition at line 522 of file files_shl.cc.

References dbconn.

Referenced by bombard(), defend(), dissolve(), do_analysis(), do_meta_infect(), domissile(), doplanet(), enroll_valid_race(), land(), main(), Makestar(), repair(), revolt(), show_map(), and survey().

Here is the caller graph for this function:

◆ getstar()

void getstar ( startype **  s,
int  star 
)

Definition at line 281 of file files_shl.cc.

References dbconn, and stdata.

Referenced by allocateAPs(), bless(), anonymous_namespace{colonies.cc}::colonies_at_star(), deductAPs(), dissolve(), do_turn(), dump(), enroll_valid_race(), exploration(), main(), mk_expl_aimed_at(), name(), page(), anonymous_namespace{production.cc}::production_at_star(), send_message(), start_shiplist(), and tech_status().

Here is the caller graph for this function:

◆ initsqldata()

void initsqldata ( )

Definition at line 42 of file files_shl.cc.

References dbconn.

Referenced by main().

Here is the caller graph for this function:

◆ makecommoddead()

void makecommoddead ( int  commodnum)

Definition at line 1601 of file files_shl.cc.

References close_file().

Referenced by do_turn().

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

◆ makeshipdead()

void makeshipdead ( int  shipnum)

Definition at line 1577 of file files_shl.cc.

References close_file().

Referenced by do_turn().

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

◆ Newslength()

int Newslength ( int  type)

Definition at line 1540 of file files_shl.cc.

◆ Numcommods()

int Numcommods ( )

Definition at line 1533 of file files_shl.cc.

References commoddata.

Referenced by bid(), do_turn(), and sell().

Here is the caller graph for this function:

◆ Numraces()

int Numraces ( )

Definition at line 1509 of file files_shl.cc.

References racedata.

Referenced by enroll_valid_race(), and main().

Here is the caller graph for this function:

◆ Numships()

shipnum_t Numships ( )

Definition at line 1516 of file files_shl.cc.

References dbconn.

Referenced by create_ship_by_planet(), create_ship_by_ship(), dissolve(), do_trip(), do_turn(), enroll_valid_race(), main(), and rst().

Here is the caller graph for this function:

◆ opencommoddata()

void opencommoddata ( int *  fd)

Definition at line 256 of file files_shl.cc.

Referenced by Db::Db().

Here is the caller graph for this function:

◆ openracedata()

void openracedata ( int *  fd)

Definition at line 264 of file files_shl.cc.

Referenced by Db::Db().

Here is the caller graph for this function:

◆ openshdata()

void openshdata ( int *  fd)

Definition at line 248 of file files_shl.cc.

Referenced by Db::Db().

Here is the caller graph for this function:

◆ openstardata()

void openstardata ( int *  fd)

Definition at line 239 of file files_shl.cc.

Referenced by Db::Db().

Here is the caller graph for this function:

◆ Putblock()

void Putblock ( struct block  b[MAXPLAYERS])

Definition at line 1649 of file files_shl.cc.

References close_file().

Referenced by do_turn(), invite(), motto(), name(), and pledge().

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

◆ putcommod()

void putcommod ( commodtype c,
int  commodnum 
)

Definition at line 1504 of file files_shl.cc.

References commoddata.

Referenced by bid(), do_turn(), and sell().

Here is the caller graph for this function:

◆ putplanet()

void putplanet ( const Planet p,
startype star,
const int  pnum 
)

Definition at line 934 of file files_shl.cc.

References dbconn, end_bulk_insert(), and start_bulk_insert().

Referenced by arm(), bless(), bombard(), build(), capture(), defend(), dissolve(), do_turn(), dump(), enroll_valid_race(), fix(), give_orders(), land(), launch(), load(), main(), Makestar(), mk_expl_aimed_at(), mobilize(), move_popn(), repair(), route(), scrap(), sell(), tax(), technology(), toxicity(), transfer(), and walk().

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

◆ Putpower()

void Putpower ( struct power  p[MAXPLAYERS])

Definition at line 1625 of file files_shl.cc.

References close_file().

Referenced by do_turn().

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

◆ putrace()

void putrace ( Race r)

Definition at line 808 of file files_shl.cc.

References racedata.

Referenced by arm(), bless(), capital(), capture(), cs(), declare(), dissolve(), enroll_valid_race(), grant(), highlight(), insurgency(), main(), move_popn(), name(), news_read(), pay(), send_message(), toggle(), unload_onto_alien_sector(), vote(), and walk().

Here is the caller graph for this function:

◆ putsdata()

void putsdata ( struct stardata S)

Definition at line 804 of file files_shl.cc.

References stdata.

Referenced by allocateAPs(), build(), deductAPs(), do_turn(), launch(), and main().

Here is the caller graph for this function:

◆ putsector()

void putsector ( const Sector s,
const Planet p,
const int  x,
const int  y 
)

Definition at line 1076 of file files_shl.cc.

References dbconn.

Referenced by arm(), build(), capture(), enroll_valid_race(), land(), load(), main(), move_popn(), putsmap(), repair(), scrap(), and walk().

Here is the caller graph for this function:

◆ putship()

void putship ( Ship s)

Definition at line 1317 of file files_shl.cc.

References dbconn, end_bulk_insert(), putship_aimed(), putship_impact(), putship_mind(), putship_pod(), putship_terraform(), putship_timer(), putship_transport(), putship_trigger(), putship_waste(), shdata, and start_bulk_insert().

Referenced by bombard(), build(), capture(), defend(), do_transporter(), do_turn(), domine(), enroll_valid_race(), fire(), give_orders(), grant(), jettison(), land(), launch(), load(), main(), mech_defend(), mount(), scrap(), and walk().

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

◆ putship_aimed()

static void putship_aimed ( const Ship s)
static

Definition at line 1121 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_impact()

static void putship_impact ( const Ship s)
static

Definition at line 1214 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_mind()

static void putship_mind ( const Ship s)
static

Definition at line 1146 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_pod()

static void putship_pod ( const Ship s)
static

Definition at line 1173 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_terraform()

static void putship_terraform ( const Ship s)
static

Definition at line 1256 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_timer()

static void putship_timer ( const Ship s)
static

Definition at line 1194 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_transport()

static void putship_transport ( const Ship s)
static

Definition at line 1276 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_trigger()

static void putship_trigger ( const Ship s)
static

Definition at line 1236 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putship_waste()

static void putship_waste ( const Ship s)
static

Definition at line 1296 of file files_shl.cc.

References dbconn.

Referenced by putship().

Here is the caller graph for this function:

◆ putsmap()

void putsmap ( SectorMap map,
Planet p 
)

Definition at line 1108 of file files_shl.cc.

References end_bulk_insert(), putsector(), and start_bulk_insert().

Referenced by bombard(), defend(), dissolve(), do_meta_infect(), domissile(), doplanet(), land(), Makeplanet(), and revolt().

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

◆ putstar()

void putstar ( startype s,
starnum_t  snum 
)

Definition at line 813 of file files_shl.cc.

References dbconn, end_bulk_insert(), start_bulk_insert(), and stdata.

Referenced by allocateAPs(), bless(), build(), deductAPs(), dissolve(), do_turn(), dump(), enroll_valid_race(), grant(), main(), mk_expl_aimed_at(), and name().

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

◆ start_bulk_insert()

static void start_bulk_insert ( )
static

Definition at line 924 of file files_shl.cc.

References dbconn.

Referenced by putplanet(), putship(), putsmap(), and putstar().

Here is the caller graph for this function:

Variable Documentation

◆ commoddata

int commoddata
static

Definition at line 33 of file files_shl.cc.

Referenced by Db::Db(), getcommod(), Numcommods(), putcommod(), and Db::~Db().

◆ dbconn

sqlite3* dbconn

◆ racedata

int racedata
static

Definition at line 33 of file files_shl.cc.

Referenced by Db::Db(), getrace(), Numraces(), putrace(), and Db::~Db().

◆ shdata

int shdata
static

Definition at line 33 of file files_shl.cc.

Referenced by Db::Db(), getship(), putship(), and Db::~Db().

◆ stdata

int stdata
static

Definition at line 33 of file files_shl.cc.

Referenced by Db::Db(), getsdata(), getstar(), putsdata(), putstar(), and Db::~Db().