Galactic Bloodshed
Functions
shlmisc.cc File Reference

Miscellaneous stuff included in the shell. More...

#include "gb/shlmisc.h"
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <sstream>
#include <string>
#include "gb/GB_server.h"
#include "gb/buffers.h"
#include "gb/files.h"
#include "gb/files_shl.h"
#include "gb/max.h"
#include "gb/races.h"
#include "gb/ships.h"
#include "gb/tweakables.h"
#include "gb/vars.h"
Include dependency graph for shlmisc.cc:

Go to the source code of this file.

Functions

std::optional< shipnum_tstring_to_shipnum (std::string_view s)
 Convert input string to a shipnum_t. More...
 
bool authorized (const governor_t Governor, const Ship &ship)
 
shipnum_t start_shiplist (GameObj &g, const std::string_view p)
 Get start of ship lists from either a ship number or ScopeLevel. More...
 
shipnum_t do_shiplist (Ship **s, shipnum_t *nextshipno)
 
bool in_list (const player_t playernum, const std::string_view list, const Ship &s, shipnum_t *nextshipno)
 Check is the ship is in the given input string. More...
 
void DontOwnErr (int Playernum, int Governor, shipnum_t shipno)
 
int enufAP (int Playernum, int Governor, unsigned short AP, int x)
 
std::tuple< player_t, governor_tgetracenum (const std::string &racepass, const std::string &govpass)
 Find the player/governor that matches passwords. More...
 
player_t get_player (const std::string &name)
 
void allocateAPs (const command_t &argv, GameObj &g)
 
void deductAPs (const player_t Playernum, const governor_t Governor, unsigned int n, starnum_t snum, int sdata)
 
double morale_factor (double x)
 

Detailed Description

Miscellaneous stuff included in the shell.

Definition in file shlmisc.cc.

Function Documentation

◆ allocateAPs()

void allocateAPs ( const command_t argv,
GameObj g 
)

Definition at line 175 of file shlmisc.cc.

References getsdata(), getstar(), putsdata(), and putstar().

Here is the call graph for this function:

◆ authorized()

bool authorized ( const governor_t  Governor,
const Ship ship 
)

Definition at line 46 of file shlmisc.cc.

◆ deductAPs()

void deductAPs ( const player_t  Playernum,
const governor_t  Governor,
unsigned int  n,
starnum_t  snum,
int  sdata 
)

Definition at line 214 of file shlmisc.cc.

References getsdata(), getstar(), putsdata(), and putstar().

Referenced by bombard(), capital(), capture(), declare(), defend(), dump(), examine(), fire(), insurgency(), land(), launch(), mobilize(), move_popn(), name(), page(), scrap(), sell(), send_message(), tax(), technology(), toxicity(), transfer(), and walk().

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

◆ do_shiplist()

shipnum_t do_shiplist ( Ship **  s,
shipnum_t nextshipno 
)

Definition at line 94 of file shlmisc.cc.

Referenced by bombard(), capture(), detonate(), fire(), grant(), jettison(), land(), launch(), load(), mount(), order(), and scrap().

Here is the caller graph for this function:

◆ DontOwnErr()

void DontOwnErr ( int  Playernum,
int  Governor,
shipnum_t  shipno 
)

Definition at line 126 of file shlmisc.cc.

Referenced by testship().

Here is the caller graph for this function:

◆ enufAP()

int enufAP ( int  Playernum,
int  Governor,
unsigned short  AP,
int  x 
)

Definition at line 131 of file shlmisc.cc.

Referenced by bombard(), capital(), capture(), declare(), defend(), dump(), fire(), insurgency(), jettison(), land(), launch(), load(), mobilize(), move_popn(), page(), scrap(), sell(), send_message(), tax(), technology(), toxicity(), transfer(), and walk().

Here is the caller graph for this function:

◆ get_player()

player_t get_player ( const std::string &  name)

Definition at line 163 of file shlmisc.cc.

◆ getracenum()

std::tuple<player_t, governor_t> getracenum ( const std::string &  racepass,
const std::string &  govpass 
)

Find the player/governor that matches passwords.

Parameters
racepassPassword for the race
govpassPassword for the governor
Returns
player and governor numbers, or 0 and 0 if not found

Definition at line 147 of file shlmisc.cc.

◆ in_list()

bool in_list ( const player_t  playernum,
const std::string_view  list,
const Ship s,
shipnum_t nextshipno 
)

Check is the ship is in the given input string.

See start_shiplist's comment for more details.

Definition at line 109 of file shlmisc.cc.

◆ morale_factor()

double morale_factor ( double  x)

Definition at line 239 of file shlmisc.cc.

Referenced by capture(), ground_attack(), insurgency(), mech_attack_people(), and people_attack_mech().

Here is the caller graph for this function:

◆ start_shiplist()

shipnum_t start_shiplist ( GameObj g,
const std::string_view  p 
)

Get start of ship lists from either a ship number or ScopeLevel.

start_shiplist and in_list work together so that a user can enter one of:

  • 1234 - a ship number
  • #1234 - a ship number prefixed by an octothorpe.
  • f - a letter representing the type of ship
  • frd - A sequence of letters representing the type of ship. Processing stops after first match.
  • * - An Asterisk as a wildcard for first match.

When a letter or asterisk is given, the shiplist is taken from the current scope.

Parameters
gGame object for scope
pString that might contain ship number
Returns
Ship number at the start of the ship list.

Definition at line 68 of file shlmisc.cc.

References getplanet(), getsdata(), and getstar().

Here is the call graph for this function:

◆ string_to_shipnum()

std::optional<shipnum_t> string_to_shipnum ( std::string_view  s)

Convert input string to a shipnum_t.

Parameters
sUser-provided input string
Returns
If the user provided a valid number, return it.

Definition at line 34 of file shlmisc.cc.