Skip to content

Commit

Permalink
Convert more function names to CamelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
fragglet committed Oct 24, 2024
1 parent 50fa8f6 commit e287d20
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 110 deletions.
10 changes: 5 additions & 5 deletions src/swauto.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ static int shoot(OBJECTS *obt)
return 0;
}

static bool within_home_range(OBJECTS *ob, int x, int y)
static bool WithinHomeRange(OBJECTS *ob, int x, int y)
{
const original_ob_t *orig_ob = ob->ob_original_ob;

return abs(x - orig_ob->x) < HOME
&& abs(y - ob->ob_orig_y) < HOME;
}

static bool is_target(OBJECTS *ob)
static bool IsTarget(OBJECTS *ob)
{
return ob->ob_type == TARGET || ob->ob_type == OX;
}
Expand All @@ -107,7 +107,7 @@ static bool tstcrash2(OBJECTS *ob, int x, int y, int alt, int dy)
// don't need to look three tics ahead. Otherwise at high speeds the
// autopilot can end up endlessly circling the runway, afraid any
// downward movement at all will lead to a crash.
if (ob->ob_home && within_home_range(ob, x, y)) {
if (ob->ob_home && WithinHomeRange(ob, x, y)) {
lookahead = 1;
}

Expand Down Expand Up @@ -144,7 +144,7 @@ static bool tstcrash2(OBJECTS *ob, int x, int y, int alt, int dy)


for (; obt->ob_xnext != NULL; obt = obt->ob_xnext) {
if (!is_target(obt) || obt->ob_x < xl) {
if (!IsTarget(obt) || obt->ob_x < xl) {
continue;
}
if (obt->ob_x > xr) {
Expand Down Expand Up @@ -327,7 +327,7 @@ int gohome(OBJECTS *ob)
}

courseadj = ((countmove & 0x001F) < 16) << 4;
if (within_home_range(ob, ob->ob_x, ob->ob_y)) {
if (WithinHomeRange(ob, ob->ob_x, ob->ob_y)) {
if (plyrplane) {
initplyr(ob);
initdisp(true);
Expand Down
15 changes: 6 additions & 9 deletions src/swcollsn.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "swsplat.h"

static void tstcrash(OBJECTS *obp);
static void blast_target(OBJECTS *ob, obtype_t type);
static void BlastTarget(OBJECTS *ob, obtype_t type);

static OBJECTS *killed[MAX_OBJS*2], *killer[MAX_OBJS*2];
static int killptr;
Expand Down Expand Up @@ -298,7 +298,7 @@ static void swkill(OBJECTS * ob1, OBJECTS * ob2)
ob->ob_onmap = false;
initexpl(ob, 0);

blast_target(ob, ttype);
BlastTarget(ob, ttype);
scoretarg(ob, ob->ob_orient == TARGET_OIL_TANK ? 200 : 100);

--numtarg[ob->ob_clr - 1];
Expand Down Expand Up @@ -527,10 +527,7 @@ static void tstcrash(OBJECTS *obp)
}
}


/* Determine valour factor */

static int compute_valour(OBJECTS *ob)
static int ComputeValour(OBJECTS *ob)
{
int reverse;
OBJECTS *so = get_score_obj(ob, &reverse);
Expand Down Expand Up @@ -572,7 +569,7 @@ static int compute_valour(OBJECTS *ob)
return valour;
}

static void blast_target(OBJECTS *ob, obtype_t type)
static void BlastTarget(OBJECTS *ob, obtype_t type)
{
int reverse;
OBJECTS *so = get_score_obj(ob, &reverse);
Expand All @@ -583,7 +580,7 @@ static void blast_target(OBJECTS *ob, obtype_t type)

if (type == BOMB || type == SHOT || type == MISSILE || type == PLANE) {
so->ob_flightscore.killscore += 4;
so->ob_flightscore.valour += 3 * compute_valour (ob);
so->ob_flightscore.valour += 3 * ComputeValour (ob);
}
}

Expand All @@ -602,7 +599,7 @@ void scorepln(OBJECTS * ob, obtype_t type)
scobj->ob_flightscore.planekills++;
}
scobj->ob_flightscore.valour +=
4 * (2 + compute_valour (ob));
4 * (2 + ComputeValour (ob));
}

scobj->ob_flightscore.killscore += 3;
Expand Down
38 changes: 19 additions & 19 deletions src/swgames.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ bool have_custom_level;

#define cl custom_level

static void free_custom_level(void)
static void FreeCustomLevel(void)
{
free(cl.gm_objects);
cl.gm_objects = NULL;
Expand All @@ -293,7 +293,7 @@ static void free_custom_level(void)
cl.gm_rseed = 12345;
}

static void add_object(original_ob_t *ob, struct yocton_object *yo)
static void AddObject(original_ob_t *ob, struct yocton_object *yo)
{
struct yocton_prop *p;

Expand All @@ -308,7 +308,7 @@ static void add_object(original_ob_t *ob, struct yocton_object *yo)
}
}

static void set_ground(struct yocton_object *yo)
static void SetGround(struct yocton_object *yo)
{
struct yocton_prop *p;

Expand All @@ -320,23 +320,23 @@ static void set_ground(struct yocton_object *yo)
}
}

static void process_level(struct yocton_object *obj)
static void ProcessLevel(struct yocton_object *obj)
{
struct yocton_prop *p;

while ((p = yocton_next_prop(obj)) != NULL) {
YOCTON_VAR_ARRAY(p, "object", cl.gm_objects, cl.gm_num_objects, {
add_object(&cl.gm_objects[cl.gm_num_objects],
yocton_prop_inner(p));
AddObject(&cl.gm_objects[cl.gm_num_objects],
yocton_prop_inner(p));
++cl.gm_num_objects;
});
YOCTON_IF_PROP(p, "ground", {
set_ground(yocton_prop_inner(p));
SetGround(yocton_prop_inner(p));
});
}
}

static void process_symbol(const char *name, struct yocton_object *obj)
static void ProcessSymbol(const char *name, struct yocton_object *obj)
{
symset_t *s;
struct yocton_prop *p;
Expand All @@ -351,19 +351,19 @@ static void process_symbol(const char *name, struct yocton_object *obj)
yocton_check(obj, "expecting frame number as property name",
*ptr == '\0' && errno != ERANGE && l < 256);

s = lookup_symset(name, l);
s = LookupSymset(name, l);
yocton_check(obj, "expecting valid symbol name and "
"frame number", s != NULL);
value = yocton_prop_value(p);
if (s != NULL && value != NULL) {
// TODO: Symbols must currently be the same size as
// the symbol they are replacing.
symset_from_text(s, value, s->sym[0].w, s->sym[0].h);
SymsetFromText(s, value, s->sym[0].w, s->sym[0].h);
}
}
}

static void process_sounds(struct yocton_object *obj)
static void ProcessSounds(struct yocton_object *obj)
{
struct yocton_prop *p;
char *title_tune = NULL;
Expand All @@ -377,17 +377,17 @@ static void process_sounds(struct yocton_object *obj)
}
}

static void process_symbols(struct yocton_object *obj)
static void ProcessSymbols(struct yocton_object *obj)
{
struct yocton_prop *p;

while ((p = yocton_next_prop(obj)) != NULL) {
process_symbol(yocton_prop_name(p),
yocton_prop_inner(p));
ProcessSymbol(yocton_prop_name(p),
yocton_prop_inner(p));
}
}

void load_custom_level(const char *filename)
void LoadCustomLevel(const char *filename)
{
FILE *fs;
struct yocton_object *obj;
Expand All @@ -396,7 +396,7 @@ void load_custom_level(const char *filename)
struct yocton_prop *p;
bool processed_level = false;

free_custom_level();
FreeCustomLevel();

fs = fopen(filename, "r");
if (fs == NULL) {
Expand All @@ -414,14 +414,14 @@ void load_custom_level(const char *filename)
if (!strcmp(name, "level")) {
yocton_check(obj, "only one level per file supported",
!processed_level);
process_level(yocton_prop_inner(p));
ProcessLevel(yocton_prop_inner(p));
processed_level = true;
}
if (!strcmp(name, "symbols")) {
process_symbols(yocton_prop_inner(p));
ProcessSymbols(yocton_prop_inner(p));
}
if (!strcmp(name, "sounds")) {
process_sounds(yocton_prop_inner(p));
ProcessSounds(yocton_prop_inner(p));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/swgames.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ extern const GAMES original_level;
extern GAMES custom_level;
extern bool have_custom_level;

void load_custom_level(const char *filename);
void LoadCustomLevel(const char *filename);

#endif
48 changes: 24 additions & 24 deletions src/swinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static void initflightscore(flight_score_t *score)
#define VALOUR_PRELIMIT 175
#define VALOUR_LIMIT 250

static bool have_medal(int *medals, int medals_nr, int medal_id)
static bool HaveMedal(int *medals, int medals_nr, int medal_id)
{
int i;

Expand All @@ -143,44 +143,44 @@ static bool have_medal(int *medals, int medals_nr, int medal_id)
return false;
}

static void give_medal(OBJECTS *ob, int medal_id)
static void GiveMedal(OBJECTS *ob, int medal_id)
{
score_t *sc = &ob->ob_score;
if (!have_medal(sc->medals, sc->medals_nr, medal_id)) {
if (!HaveMedal(sc->medals, sc->medals_nr, medal_id)) {
assert(sc->medals_nr < 3);
sc->medals[sc->medals_nr++] = medal_id;
}
}

static void give_ribbon(OBJECTS *ob, int ribbon_id)
static void GiveRibbon(OBJECTS *ob, int ribbon_id)
{
score_t *sc = &ob->ob_score;
if (!have_medal(sc->ribbons, sc->ribbons_nr, ribbon_id)) {
if (!HaveMedal(sc->ribbons, sc->ribbons_nr, ribbon_id)) {
assert(sc->ribbons_nr < 6);
sc->ribbons[sc->ribbons_nr++] = ribbon_id;
}
}

static void get_awards(OBJECTS *ob)
static void GetAwards(OBJECTS *ob)
{
flight_score_t *fsc = &ob->ob_flightscore;
score_t *sc = &ob->ob_score;

// We only award purple heart if wounded in combat (=hit by bullet),
// not from a bird strike or flying into an ox.
if (fsc->combatwound) {
give_medal(ob, MEDAL_PURPLEHEART);
GiveMedal(ob, MEDAL_PURPLEHEART);
}

// We count up the number of planes shot down, but they only count if
// the player returns to base successfully.
sc->planekills += fsc->planekills;
//printf("planes %d %d\n", sc->planekills, fsc->planekills);
if (sc->planekills >= 5) {
give_ribbon(ob, RIBBON_ACE);
GiveRibbon(ob, RIBBON_ACE);
}
if (sc->planekills >= 25) {
give_ribbon(ob, RIBBON_TOPACE);
GiveRibbon(ob, RIBBON_TOPACE);
}

// We count the number of landings during which we did a decent amount
Expand All @@ -190,16 +190,16 @@ static void get_awards(OBJECTS *ob)
}
//printf("kills %d landings %d\n", fsc->killscore, sc->landings);
if (sc->landings >= 3) {
give_ribbon(ob, RIBBON_SERVICE);
GiveRibbon(ob, RIBBON_SERVICE);
}

// If a huge number of damage is done, we give a medal (first time) or
// ribbon (second time)
if (fsc->killscore >= COMPETENCE_KILLSCORE) {
if (!have_medal(sc->medals, sc->medals_nr, MEDAL_COMPETENCE)) {
give_medal(ob, MEDAL_COMPETENCE);
if (!HaveMedal(sc->medals, sc->medals_nr, MEDAL_COMPETENCE)) {
GiveMedal(ob, MEDAL_COMPETENCE);
} else {
give_ribbon(ob, RIBBON_COMPETENCE2);
GiveRibbon(ob, RIBBON_COMPETENCE2);
}
}

Expand All @@ -208,19 +208,19 @@ static void get_awards(OBJECTS *ob)
sc->valour += fsc->valour;
//printf("valour %d %d\n", sc->valour, fsc->valour);
if (sc->valour >= VALOUR_PRELIMIT) {
give_ribbon(ob, RIBBON_PREVALOUR);
GiveRibbon(ob, RIBBON_PREVALOUR);
}
if (sc->valour >= VALOUR_LIMIT) {
give_medal(ob, MEDAL_VALOUR);
GiveMedal(ob, MEDAL_VALOUR);
}
}

static void get_endlevel(OBJECTS *ob)
static void GetEndLevel(OBJECTS *ob)
{
get_awards(ob);
GetAwards(ob);

if (ob->ob_crashcnt == 0) {
give_ribbon(ob, RIBBON_PERFECT);
GiveRibbon(ob, RIBBON_PERFECT);
}
}

Expand All @@ -243,7 +243,7 @@ OBJECTS *initpln(OBJECTS * obp)

if (obp && ob->ob_state != CRASHED && !ob->ob_athome) {
/* Just returned home */
get_awards(ob);
GetAwards(ob);
}

initflightscore(&ob->ob_flightscore);
Expand Down Expand Up @@ -655,7 +655,7 @@ static OBJECTS *inittarget(const original_ob_t *orig_ob)

// Number of explosion fragments is calculated based on the number of pixels
// in the "destroyed target" sprite:
static int target_explosion_size(int target_type)
static int TargetExplosionSize(int target_type)
{
symset_t *ss = &symbol_target_hit[target_type];
sopsym_t *s = &ss->sym[0];
Expand Down Expand Up @@ -722,7 +722,7 @@ void initexpl(OBJECTS *obo, int small)
// target sprite. For the original Sopwith destroyed-
// building sprite, this evaluates to 2, which is
// the original behavior.
ic = 110 / target_explosion_size(obo->ob_orient);
ic = 110 / TargetExplosionSize(obo->ob_orient);
} else {
ic = 2;
}
Expand Down Expand Up @@ -1028,7 +1028,7 @@ void swrestart(void)
ob = planes[player];
inc = 0;

get_endlevel(ob);
GetEndLevel(ob);

// Count down the remaining lives; the player gets awarded
// extra points for each life.
Expand Down Expand Up @@ -1082,7 +1082,7 @@ void swinit(int argc, char *argv[])

// We must generate symbols early, so that custom map files
// can replace symbols:
symbol_generate();
GenerateSymbols();

for (i=1; i<argc; ++i) {
if (!strcasecmp(argv[i], "-v")
Expand All @@ -1103,7 +1103,7 @@ void swinit(int argc, char *argv[])
} else if (!strcasecmp(argv[i], "-q")) {
soundflg = true;
} else if (!strcmp(argv[i], "-m") && (i + 1) < argc) {
load_custom_level(argv[i + 1]);
LoadCustomLevel(argv[i + 1]);
++i;
} else
#ifdef TCPIP
Expand Down
Loading

0 comments on commit e287d20

Please sign in to comment.