summaryrefslogtreecommitdiff
path: root/procyon/source/bs
diff options
context:
space:
mode:
Diffstat (limited to 'procyon/source/bs')
-rw-r--r--procyon/source/bs/cont.c79
-rw-r--r--procyon/source/bs/sav.c35
-rw-r--r--procyon/source/bs/shipnm.c66
3 files changed, 33 insertions, 147 deletions
diff --git a/procyon/source/bs/cont.c b/procyon/source/bs/cont.c
deleted file mode 100644
index 61907fc..0000000
--- a/procyon/source/bs/cont.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <acm/bs.h>
-
-#include <flux.h>
-#include <inttypes.h>
-#include <zap/mem.h>
-
-static_assert(sizeof (acm_dflplnm) == acm_plnmlen);
-
-void acm_cont(acm_pldat * const _pldat) {
- acm_log("Continuing\n");
- acm_pldat pldat;
- uint_least64_t savver;
- flux_err fluxerr;
- flux_fil savfil;
- fluxerr = flux_op(&savfil,acm_dat.savloc,flux_md_rd,flux_keep);
- if (fluxerr) {
- acm_log("Unable to open save file, starting new game: %s\n",flux_errstr(fluxerr));
- goto new;
- }
- fluxerr = flux_rd(savfil,sizeof (savver),&savver,nullptr);
- if (!fluxerr) {
- fluxerr = flux_rd(savfil,sizeof (pldat),&pldat,nullptr);
- }
- flux_cl(savfil);
- if (fluxerr) {
- acm_log("Unable to read save file, starting new game: %s\n",flux_errstr(fluxerr));
- goto new;
- }
- if (savver != acm_savver) {
- printf("Old save version (%" PRIXLEAST64 "), starting new game: %s\n",savver,flux_errstr(fluxerr));
- goto new;
- }
- acm_log("Validating commander name\n");
- bool validnm = false;
- for (zap_sz n = 0x0u;n < acm_plnmlen + 0x1u;++n) {
- if (pldat.nm[n] == '\x0') {
- if (n == 0x0u) {
- break;
- }
- validnm = true;
- break;
- }
- }
- if (!validnm) {
- acm_log("Invalid commander name (corrupt save file), starting new game\n");
- acm_log(
- "Commander name:\n"
- " %hhX %hhX %hhX %hhX\n"
- " %hhX %hhX %hhX %hhX\n"
- " %hhX %hhX %hhX %hhX\n"
- " %hhX %hhX %hhX %hhX\n"
- " %hhX\n",
- pldat.nm[0x0u],pldat.nm[0x1u],pldat.nm[0x2u],pldat.nm[0x3u],
- pldat.nm[0x4u],pldat.nm[0x5u],pldat.nm[0x6u],pldat.nm[0x7u],
- pldat.nm[0x8u],pldat.nm[0x9u],pldat.nm[0xAu],pldat.nm[0xBu],
- pldat.nm[0xCu],pldat.nm[0xDu],pldat.nm[0xEu],pldat.nm[0xFu],
- pldat.nm[0x10u]
- );
- goto new;
- }
- printf("Loaded CMDR %s, %s @ %" PRIiLEAST64 "\n",pldat.nm,acm_shipnm(pldat.ship),pldat.tm);
- *_pldat = pldat;
- return;
-new:;
- pldat.heat = 0x120u; /* 288K */
- pldat.pos.px = 0x0u;
- pldat.pos.py = 0x0u;
- pldat.pos.pz = 0x0u;
- pldat.pos.rx = 0x0u;
- pldat.pos.ry = 0x0u;
- pldat.pos.rz = 0x0u;
- pldat.pos.vx = 0x0u;
- pldat.pos.vy = 0x0u;
- pldat.pos.vz = 0x0u;
- pldat.ship = acm_ship_side;
- pldat.tm = 0x9679C2B40u; /* 3250-01-01T12:00:00Z */
- zap_memcp(acm_dflplnm,acm_plnmlen + 0x1u,pldat.nm);
- *_pldat = pldat;
-}
diff --git a/procyon/source/bs/sav.c b/procyon/source/bs/sav.c
deleted file mode 100644
index 1e0b226..0000000
--- a/procyon/source/bs/sav.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <acm/bs.h>
-
-#include <flux.h>
-#include <stdio.h>
-
-void acm_sav(acm_pldat const * const _pldat) {
- acm_log("Saving\n");
- flux_err fluxerr;
- flux_fil savfil;
- fluxerr = flux_mkfil(&savfil,acm_dat.savloc,0644u);
- if (fluxerr) {
- if (fluxerr != flux_err_exist) {
- fprintf(stderr,"Unable to create save file (\"%s\"): %s\n",acm_dat.savloc,flux_errstr(fluxerr));
- acm_exit(acm_stat_err);
- }
- acm_log("Save file already exists, overwritting\n");
- fluxerr = flux_op(&savfil,acm_dat.savloc,flux_md_wr,flux_disc);
- if (fluxerr) {
- fprintf(stderr,"Unable to open save file: %s\n",flux_errstr(fluxerr));
- acm_exit(acm_stat_err);
- }
- }
- {
- uint_least64_t const savver = acm_savver;
- fluxerr = flux_wr(savfil,&savver,sizeof (savver));
- }
- if (!fluxerr) {
- fluxerr = flux_wr(savfil,_pldat,sizeof (*_pldat));
- }
- if (fluxerr) {
- fprintf(stderr,"Unable to write to save file: %s\n",flux_errstr(fluxerr));
- acm_exit(acm_stat_err);
- }
- flux_cl(savfil);
-}
diff --git a/procyon/source/bs/shipnm.c b/procyon/source/bs/shipnm.c
index dcbd6fb..f1d8f4e 100644
--- a/procyon/source/bs/shipnm.c
+++ b/procyon/source/bs/shipnm.c
@@ -1,70 +1,70 @@
#include <acm/bs.h>
-char const * acm_shipnm(acm_ship const _ship) {
+char const * acm_shipnm(acm_shipid const _ship) {
switch (_ship) {
- case acm_ship_add:
+ case acm_shipid_add:
return "Adder";
- case acm_ship_ana:
+ case acm_shipid_ana:
return "Anaconda";
- case acm_ship_asp:
+ case acm_shipid_asp:
return "Asp";
- case acm_ship_boa:
+ case acm_shipid_boa:
return "Boa";
- case acm_ship_cob:
+ case acm_shipid_cob:
return "Cobra";
- case acm_ship_con:
+ case acm_shipid_con:
return "Constrictor";
- case acm_ship_cou:
+ case acm_shipid_cou:
return "Courier";
- case acm_ship_cyg:
+ case acm_shipid_cyg:
return "Cygnus";
- case acm_ship_dov:
+ case acm_shipid_dov:
return "Dove";
- case acm_ship_eag:
+ case acm_shipid_eag:
return "Eagle";
- case acm_ship_falc:
+ case acm_shipid_falc:
return "Falcon";
- case acm_ship_fer:
+ case acm_shipid_fer:
return "Fer-de-lance";
- case acm_ship_frei:
+ case acm_shipid_frei:
return "Freighter";
- case acm_ship_geck:
+ case acm_shipid_geck:
return "Gecko";
- case acm_ship_haul:
+ case acm_shipid_haul:
return "Hauler";
- case acm_ship_hawk:
+ case acm_shipid_hawk:
return "Hawk";
- case acm_ship_keel:
+ case acm_shipid_keel:
return "Keelback";
- case acm_ship_kes:
+ case acm_shipid_kes:
return "Kestral";
- case acm_ship_krait:
+ case acm_shipid_krait:
return "Krait";
- case acm_ship_lift:
+ case acm_shipid_lift:
return "Lifter";
- case acm_ship_lion:
+ case acm_shipid_lion:
return "Lion";
- case acm_ship_mamba:
+ case acm_shipid_mamba:
return "Mamba";
- case acm_ship_moray:
+ case acm_shipid_moray:
return "Moray";
- case acm_ship_osp:
+ case acm_shipid_osp:
return "Osprey";
- case acm_ship_pan:
+ case acm_shipid_pan:
return "Panther";
- case acm_ship_puma:
+ case acm_shipid_puma:
return "Puma";
- case acm_ship_py:
+ case acm_shipid_py:
return "Python";
- case acm_ship_shut:
+ case acm_shipid_shut:
return "Shuttle";
- case acm_ship_side:
+ case acm_shipid_side:
return "Sidewinder";
- case acm_ship_tran:
+ case acm_shipid_tran:
return "Transporter";
- case acm_ship_vip:
+ case acm_shipid_vip:
return "Viper";
- case acm_ship_vult:
+ case acm_shipid_vult:
return "Vulture";
}
}