diff options
29 files changed, 261 insertions, 246 deletions
@@ -3,7 +3,6 @@ /build /datdir /glad -/rust *.tar *.zip *.zst diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 93f4594..b8086cc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -12,6 +12,14 @@ * Update some typings; * Rename intro to start sequence; +* Enforce new naming convention; +* Use fixed-width floating-point types; +* Update shader validation script; +* Rename bs module to bas; +* Register SIGTERM handler; +* Make cmpshd static; +* Rename crd to prcrd; + # 0.B.2 * Fix data directory not being set correctly by CMake; diff --git a/bowshock/CMakeLists.txt b/bowshock/CMakeLists.txt index f5e93fb..ed404e7 100644 --- a/bowshock/CMakeLists.txt +++ b/bowshock/CMakeLists.txt @@ -15,9 +15,7 @@ add_executable( "source/bs/rnd.cxx" "source/ini/bow/chkpar.cxx" - "source/ini/bow/cmpshd.cxx" "source/ini/bow/cmpshdprg.cxx" - "source/ini/bow/crd.cxx" "source/ini/bow/exi.cxx" "source/ini/bow/getquo.cxx" "source/ini/bow/getsavpth.cxx" @@ -28,6 +26,7 @@ add_executable( "source/ini/bow/inisig.cxx" "source/ini/bow/lop.cxx" "source/ini/bow/polevt.cxx" + "source/ini/bow/pricrd.cxx" "source/ini/bow/priquo.cxx" "source/ini/bow/srtseq.cxx" diff --git a/bowshock/include/bow/bs.hxx b/bowshock/include/bow/bas.hxx index 0b3d487..40771fd 100644 --- a/bowshock/include/bow/bs.hxx +++ b/bowshock/include/bow/bas.hxx @@ -71,7 +71,7 @@ namespace bow { tau, // taurus urs, // ursa vip, // vipera - // Remember maxshpid in sav + // Remember maxshpid in sav! }; enum struct tar : ::zp::i8 { @@ -99,9 +99,9 @@ namespace bow { }; struct xyz { - double x; - double y; - double z; + ::zp::f04 x; + ::zp::f04 y; + ::zp::f04 z; }; struct obj { @@ -116,7 +116,7 @@ namespace bow { ::bow::xyz rot; // radians ::bow::xyz posVel; // astronomical units per second ::bow::xyz rotVel; // radians per second - double mas; // kilograms + ::zp::f04 mas; // kilograms ::bow::obj * nxt; }; @@ -124,7 +124,7 @@ namespace bow { ::bow::obj * objs; }; - struct pldat { + struct plydat { char nam[::bow::cmdnamlen+0x1u]; ::zp::i04 tim; ::zp::i04 sysidt; diff --git a/bowshock/include/bow/ini.hxx b/bowshock/include/bow/ini.hxx index f86eb80..486d406 100644 --- a/bowshock/include/bow/ini.hxx +++ b/bowshock/include/bow/ini.hxx @@ -13,14 +13,14 @@ namespace bow { struct gfxdat { ::GLFWwindow * win; - ::GLuint shdprog; + ::GLuint shdprg; }; struct trmopt { - char const * savPth; + char const * savpth; bool hassavpth:0x1u; bool newsav:0x1u; - bool skip:0x1u; + bool skp:0x1u; }; class bow { @@ -28,21 +28,20 @@ namespace bow { [[noreturn]] auto ini(int argc,char const * const * argv) noexcept -> void; private: - ::bow::pldat pldat; + ::bow::plydat plydat; ::bow::gfxdat gfxdat; - auto getsavpth() noexcept -> char const *; + auto getsavpth() noexcept -> char const *; auto getquo( char const * * quo,char const * * src,::zp::i8 id) noexcept -> void; auto priquo() noexcept -> void; - [[noreturn]] auto crd() noexcept -> void; - [[noreturn]] auto hlp(char const * progNm) noexcept -> void; + [[noreturn]] auto pricrd() noexcept -> void; + [[noreturn]] auto hlp(char const * prognm) noexcept -> void; auto chkpar(trmopt & opt,int argc,char const * const * argv) noexcept -> void; - auto cmpshd( ::GLuint & shd, char const * nam,GLenum typ) -> void; - auto compshdprog(::GLuint & shdprog,char const * nam) noexcept -> void; + auto compshdprg(::GLuint & shdprg,char const * nam) noexcept -> void; auto inigfx() noexcept -> void; auto inirnd() noexcept -> void; @@ -51,7 +50,7 @@ namespace bow { auto polevt() noexcept -> bool; auto srtseq() noexcept -> bool; - auto lop() noexcept -> void; + auto lop() noexcept -> void; [[noreturn]] auto exi(::bow::cnd stat) noexcept -> void; }; diff --git a/bowshock/include/bow/lgc.hxx b/bowshock/include/bow/lgc.hxx index b3ff4e3..57d4171 100644 --- a/bowshock/include/bow/lgc.hxx +++ b/bowshock/include/bow/lgc.hxx @@ -2,18 +2,18 @@ #pragma once -#include <bow/bs.hxx> +#include <bow/bas.hxx> namespace bow { - constexpr double dstmod = 0x1.16A5D2D360000000p037; // distance modifier (1 astronomical unit) - constexpr double masmod = 0x1.91930A5E75F0C192p100; // mass modifier (1 solar mas) - constexpr double timmod = 0x1.0000000000000000p012; // time modifier (1 second) + constexpr ::zp::f04 dstmod = 0x1.16A5D2D360000000p037; // distance modifier (1 astronomical unit) + constexpr ::zp::f04 masmod = 0x1.91930A5E75F0C192p100; // mass modifier (1 solar mas) + constexpr ::zp::f04 timmod = 0x1.0000000000000000p012; // time modifier (1 second) - constexpr double grvfac = (::bow::masmod*(::bow::timmod*::bow::timmod))/((::bow::dstmod*::bow::dstmod*::bow::dstmod)); // inverse + constexpr ::zp::f04 grvfac = (::bow::masmod*(::bow::timmod*::bow::timmod))/((::bow::dstmod*::bow::dstmod*::bow::dstmod)); // inverse - constexpr double grvval = 0x1.258688101B4BB16Dp-34*::bow::grvfac; // gravitational constant (s^2*m*t^2) + constexpr ::zp::f04 grvval = 0x1.258688101B4BB16Dp-34*::bow::grvfac; // gravitational constant (s^2*m*t^2) - [[nodiscard]] auto shpmas(::bow::shp id) noexcept -> double; + [[nodiscard]] auto shpmas(::bow::shp id) noexcept -> ::zp::f04; auto grv(::bow::objroot & sys) noexcept -> void; auto grv(::bow::objroot & objs,::bow::objroot const & sys) noexcept -> void; diff --git a/bowshock/include/bow/run.hxx b/bowshock/include/bow/run.hxx index ecfe31d..5c7be43 100644 --- a/bowshock/include/bow/run.hxx +++ b/bowshock/include/bow/run.hxx @@ -2,7 +2,7 @@ #pragma once -#include <bow/bs.hxx> +#include <bow/bas.hxx> #include <source_location> diff --git a/bowshock/include/bow/sav.hxx b/bowshock/include/bow/sav.hxx index c2d8912..f1eca58 100644 --- a/bowshock/include/bow/sav.hxx +++ b/bowshock/include/bow/sav.hxx @@ -2,7 +2,7 @@ #pragma once -#include <bow/bs.hxx> +#include <bow/bas.hxx> namespace bow { constexpr ::zp::i04 savver = 0x6u; @@ -58,10 +58,10 @@ namespace bow { auto decsav(::bow::savdat & buf,::zp::i8 const * dat) noexcept -> void; auto encsav(::zp::i8 * buf,::bow::savdat const & dat) noexcept -> void; - auto newsav(::bow::pldat & dat) noexcept -> void; + auto newsav(::bow::plydat & dat) noexcept -> void; - auto cnt( ::bow::pldat & dat,char const * fil) noexcept -> void; - auto gendat(::bow::pldat & dat) noexcept -> void; + auto cnt( ::bow::plydat & dat,char const * fil) noexcept -> void; + auto gendat(::bow::plydat & dat) noexcept -> void; - auto sav(char const * fil,::bow::pldat const & dat) noexcept -> void; + auto sav(char const * fil,::bow::plydat const & dat) noexcept -> void; } diff --git a/bowshock/source/bs/rnd.cxx b/bowshock/source/bs/rnd.cxx index c345037..98f9523 100644 --- a/bowshock/source/bs/rnd.cxx +++ b/bowshock/source/bs/rnd.cxx @@ -1,6 +1,6 @@ // Copyright 2022-2023 Gabriel Jensen. -#include <bow/bs.hxx> +#include <bow/bas.hxx> #include <cstdlib> diff --git a/bowshock/source/ini/bow/chkpar.cxx b/bowshock/source/ini/bow/chkpar.cxx index 6d50e81..cf68d45 100644 --- a/bowshock/source/ini/bow/chkpar.cxx +++ b/bowshock/source/ini/bow/chkpar.cxx @@ -6,12 +6,12 @@ #include <zp/str> auto ::bow::bow::chkpar(::bow::trmopt & opt,int const argc,char const * const * argv) noexcept -> void { - char const * const progNm = *argv; + char const * const prognm = *argv; opt = ::bow::trmopt { .hassavpth = false, - .newsav = false, - .skip = false, + .newsav = false, + .skp = false, }; if (argc >= 0x2) [[unlikely]] { @@ -23,17 +23,17 @@ auto ::bow::bow::chkpar(::bow::trmopt & opt,int const argc,char const * const * if (par[0x0u] == '-' && par[0x1u] == '-') { par += 0x2u; - if (::zp::strequ(par,"credits")) crd(); - else if (::zp::strequ(par,"help")) hlp(progNm); - else if (::zp::strequ(par,"new")) opt.newsav = true; - else if (::zp::strequ(par,"skip")) opt.skip = true; - else bow_logerr("invalid pareter \"%s\"",par); + if (::zp::strequ(par,"credits")) {pricrd();} + else if (::zp::strequ(par,"help")) {hlp(prognm);} + else if (::zp::strequ(par,"new")) {opt.newsav = true;} + else if (::zp::strequ(par,"skip")) {opt.skp = true;} + else {bow_logerr("invalid pareter \"%s\"",par);} continue; } // Else: Interpret it as a save path. - opt.savPth = par; + opt.savpth = par; opt.hassavpth = true; } } diff --git a/bowshock/source/ini/bow/cmpshd.cxx b/bowshock/source/ini/bow/cmpshd.cxx deleted file mode 100644 index 572ae4c..0000000 --- a/bowshock/source/ini/bow/cmpshd.cxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2022-2023 Gabriel Jensen. - -#include <bow/ini.hxx> - -#include <cstdlib> -#include <ly/io> -#include <ly/fs> -#include <glad/glad.h> -#include <stdexcept> -#include <zp/mem> -#include <zp/str> - -auto ::bow::bow::cmpshd(::GLuint & shd,char const * const nam,GLenum const typ) -> void { - char const * typStr; - - char const * typExt; - ::zp::siz typExtLen; - - switch (typ) { - default: - bow_logerr("bad shader type %lX",static_cast<unsigned long>(typ)); - ::bow::abr(); - case GL_FRAGMENT_SHADER: - bow_setstrlen(typExt,typExtLen,"frag"); - typStr = "fragment"; - break; - case GL_VERTEX_SHADER: - bow_setstrlen(typExt,typExtLen,"vert"); - typStr = "vertex"; - break; - } - - char const * dir; - ::zp::siz dirLen; - bow_setstrlen(dir,dirLen,bow_datdir "/shaders"); - - ::zp::siz const nmLen = ::zp::strlen(nam); - ::zp::siz const pthlen = dirLen + 0x1u + nmLen + 0x1u + typExtLen + 0x1u + sizeof (::bow::shdfilext); - - char * pth = new char[pthlen + 0x1u]; - - pth = ::zp::cpy(pth,dir,dirLen).dst; - *pth++ = '/'; - pth = ::zp::cpy(pth,nam,nmLen).dst; - *pth++ = '.'; - pth = ::zp::cpy(pth,typExt,typExtLen).dst; - *pth++ = '.'; - pth = ::zp::cpy(pth,::bow::shdfilext,sizeof (::bow::shdfilext)).dst; - *pth = '\x00'; - pth -= pthlen; - - bow_logdbg("compiling %s shader at \"%s\"",typStr,pth); - - ::ly::fil fil; - ::ly::err err = fil.opn(pth,::ly::mod::red,::ly::kep); - - if (err != ::ly::err::ok) [[unlikely]] {throw ::std::runtime_error {"unable to open shader source"};} - - ::zp::siz const filsiz = [&pth]() { - ::ly::pthinf pthinf; - ::ly::sttpth(pthinf,pth); - - return pthinf.siz; - }(); - - delete[] pth; - - static_assert(sizeof (GLchar) == sizeof (char)); - GLchar * const src = new GLchar[filsiz + 0x1u]; - - err = fil.red(src,filsiz); - if (err != ::ly::err::ok) {throw ::std::runtime_error {"unable to read shader source"};} - fil.cls(); - - src[filsiz] = '\x00'; - - shd = glCreateShader(typ); - glShaderSource(shd,0x1,(GLchar const * const *)&src,nullptr); - - delete[] src; - - glCompileShader(shd); - - GLint compStat; - glGetShaderiv(shd,GL_COMPILE_STATUS,&compStat); - if (compStat == GL_FALSE) [[unlikely]] {throw ::std::runtime_error {"unable to compile shader"};} -} diff --git a/bowshock/source/ini/bow/cmpshdprg.cxx b/bowshock/source/ini/bow/cmpshdprg.cxx index 9869c35..87b8446 100644 --- a/bowshock/source/ini/bow/cmpshdprg.cxx +++ b/bowshock/source/ini/bow/cmpshdprg.cxx @@ -2,15 +2,102 @@ #include <bow/ini.hxx> +#include <cstdlib> +#include <ly/io> +#include <ly/fs> #include <glad/glad.h> #include <stdexcept> +#include <zp/mem> +#include <zp/str> -auto ::bow::bow::compshdprog(::GLuint & shdprog,char const * const nam) noexcept -> void { +namespace bow { + static auto cmpshd(::GLuint & shd,char const * nam,::GLenum typ) -> void; +} + +static auto ::bow::cmpshd(::GLuint & shd,char const * const nam,::GLenum const typ) -> void { + char const * typstr; + + char const * typExt; + ::zp::siz typExtLen; + + switch (typ) { + default: + bow_logerr("bad shader type %X",static_cast<unsigned int>(typ)); + ::bow::abr(); + case GL_FRAGMENT_SHADER: + bow_setstrlen(typExt,typExtLen,"frag"); + typstr = "fragment"; + break; + case GL_VERTEX_SHADER: + bow_setstrlen(typExt,typExtLen,"vert"); + typstr = "vertex"; + break; + } + + char const * dir; + ::zp::siz dirLen; + bow_setstrlen(dir,dirLen,bow_datdir "/shaders"); + + ::zp::siz const nmLen = ::zp::strlen(nam); + ::zp::siz const pthlen = dirLen + 0x1u + nmLen + 0x1u + typExtLen + 0x1u + sizeof (::bow::shdfilext); + + char * pth = new char[pthlen + 0x1u]; + + pth = ::zp::cpy(pth,dir,dirLen).dst; + *pth++ = '/'; + pth = ::zp::cpy(pth,nam,nmLen).dst; + *pth++ = '.'; + pth = ::zp::cpy(pth,typExt,typExtLen).dst; + *pth++ = '.'; + pth = ::zp::cpy(pth,::bow::shdfilext,sizeof (::bow::shdfilext)).dst; + *pth = '\x00'; + pth -= pthlen; + + bow_logdbg("compiling %s shader at \"%s\"",typstr,pth); + + ::ly::fil fil; + ::ly::err err = fil.opn(pth,::ly::mod::red,::ly::kep); + + if (err != ::ly::err::ok) [[unlikely]] {throw ::std::runtime_error {"unable to open shader source"};} + + ::zp::siz const filsiz = [&pth]() { + ::ly::pthinf pthinf; + ::ly::sttpth(pthinf,pth); + + return pthinf.siz; + }(); + + delete[] pth; + + static_assert(sizeof (GLchar) == sizeof (char)); + GLchar * const src = new GLchar[filsiz + 0x1u]; + + err = fil.red(src,filsiz); + if (err != ::ly::err::ok) {throw ::std::runtime_error {"unable to read shader source"};} + fil.cls(); + + src[filsiz] = '\x00'; + + shd = glCreateShader(typ); + glShaderSource(shd,0x1,(GLchar const * const *)&src,nullptr); + + delete[] src; + + glCompileShader(shd); + + GLint compStat; + glGetShaderiv(shd,GL_COMPILE_STATUS,&compStat); + if (compStat == GL_FALSE) [[unlikely]] {throw ::std::runtime_error {"unable to compile shader"};} +} + +auto ::bow::bow::compshdprg(::GLuint & shdprg,char const * const nam) noexcept -> void { bow_log("compiling shader program \"%s\"",nam); ::GLuint vtxshd; ::GLuint frgshd; + using ::bow::cmpshd; + try { cmpshd(vtxshd,nam,GL_VERTEX_SHADER); cmpshd(frgshd,nam,GL_FRAGMENT_SHADER); @@ -24,10 +111,10 @@ auto ::bow::bow::compshdprog(::GLuint & shdprog,char const * const nam) noexcept ::bow::abr(); } - shdprog = glCreateProgram(); - glAttachShader(shdprog,vtxshd); - glAttachShader(shdprog,frgshd); - glLinkProgram(shdprog); + shdprg = glCreateProgram(); + glAttachShader(shdprg,vtxshd); + glAttachShader(shdprg,frgshd); + glLinkProgram(shdprg); glDeleteShader(vtxshd); glDeleteShader(frgshd); diff --git a/bowshock/source/ini/bow/exi.cxx b/bowshock/source/ini/bow/exi.cxx index 76477b0..a597d70 100644 --- a/bowshock/source/ini/bow/exi.cxx +++ b/bowshock/source/ini/bow/exi.cxx @@ -8,7 +8,7 @@ auto ::bow::bow::exi(::bow::cnd const cnd) noexcept -> void { bow_log("quitting"); - glDeleteProgram(gfxdat.shdprog); + glDeleteProgram(gfxdat.shdprg); ::glfwDestroyWindow(gfxdat.win); ::glfwTerminate(); diff --git a/bowshock/source/ini/bow/hlp.cxx b/bowshock/source/ini/bow/hlp.cxx index ec75280..1e5f58c 100644 --- a/bowshock/source/ini/bow/hlp.cxx +++ b/bowshock/source/ini/bow/hlp.cxx @@ -5,7 +5,7 @@ #include <cinttypes> #include <cstdlib> -auto ::bow::bow::hlp(char const * const progNm) noexcept -> void { +auto ::bow::bow::hlp(char const * const prognm) noexcept -> void { bow_lograw( "\n" "\x1B[1mBowshock\x1B[0m %" PRIX64 ".%" PRIX64 ".%" PRIX64 "\n" @@ -17,9 +17,9 @@ auto ::bow::bow::hlp(char const * const progNm) noexcept -> void { " --credits Print the game \x1B[1mcredits\x1B[0m\n" " --help Print \x1B[1mhelp\x1B[0m screen\n" " --new srt a \x1B[1mnew\x1B[0m save file\n" - " --skip \x1B[1mSkip\x1B[0m the intro\n" + " --skp \x1B[1mskp\x1B[0m the intro\n" "\n", - ::bow::vermaj,::bow::vermin,::bow::verpat,progNm); + ::bow::vermaj,::bow::vermin,::bow::verpat,prognm); ::std::exit(EXIT_SUCCESS); } diff --git a/bowshock/source/ini/bow/ini.cxx b/bowshock/source/ini/bow/ini.cxx index a13fd1f..6c8dcec 100644 --- a/bowshock/source/ini/bow/ini.cxx +++ b/bowshock/source/ini/bow/ini.cxx @@ -29,17 +29,17 @@ auto ::bow::bow::ini(int const argc,char const * const * const argv) noexcept -> inisig(); inigfx(); - if (opt.skip || !srtseq()) [[likely]] { - if (!opt.hassavpth) {opt.savPth = getsavpth();} + if (opt.skp || !srtseq()) [[likely]] { + if (!opt.hassavpth) {opt.savpth = getsavpth();} - if (opt.newsav) ::bow::newsav(pldat); - else ::bow::cnt(pldat,opt.savPth); + if (opt.newsav) {::bow::newsav(plydat);} + else {::bow::cnt(plydat,opt.savpth);} lop(); - ::bow::sav(opt.savPth,pldat); + ::bow::sav(opt.savpth,plydat); - if (!opt.hassavpth) delete[] const_cast<char *>(opt.savPth); + if (!opt.hassavpth) {delete[] const_cast<char *>(opt.savpth);} } exi(::bow::cnd::oky); diff --git a/bowshock/source/ini/bow/inigfx.cxx b/bowshock/source/ini/bow/inigfx.cxx index ba33ce5..8a02971 100644 --- a/bowshock/source/ini/bow/inigfx.cxx +++ b/bowshock/source/ini/bow/inigfx.cxx @@ -38,5 +38,5 @@ auto ::bow::bow::inigfx() noexcept -> void { ::glfwSwapBuffers(gfxdat.win); ::glfwSwapInterval(0x1); - compshdprog(gfxdat.shdprog,"main"); + compshdprg(gfxdat.shdprg,"main"); } diff --git a/bowshock/source/ini/bow/inisig.cxx b/bowshock/source/ini/bow/inisig.cxx index dec7fb2..1c01db0 100644 --- a/bowshock/source/ini/bow/inisig.cxx +++ b/bowshock/source/ini/bow/inisig.cxx @@ -7,19 +7,26 @@ ::std::sig_atomic_t volatile ::bow::gotint; namespace bow { - static auto intHnd(int const sig) -> void { - ::std::signal(sig,::bow::intHnd); // Ignore the return value: We can't do anything (meaningful) about it anyways. - ::bow::gotint = 0x1; - } + static auto inthnd(int const sig) -> void; } +static auto ::bow::inthnd(int const sig) -> void { + ::std::signal(sig,::bow::inthnd); // Ignore the return value: We can't do anything (meaningful) about it anyways. + ::bow::gotint = 0x1; +}; + auto ::bow::bow::inisig() noexcept -> void { bow_log("initialising signal handlers"); ::bow::gotint = 0x0; - - if (::std::signal(SIGINT,::bow::intHnd) == SIG_ERR) [[unlikely]] { - bow_log("unable to set signal handler"); - ::bow::abr(); - } + + auto const sethnd = []<typename hndtyp>(int const sig,hndtyp const & hnd) -> void { + if (::std::signal(sig,static_cast<auto (*)(int) -> void>(hnd)) == SIG_ERR) [[unlikely]] { + bow_log("unable to set signal handler for %i",sig); + ::bow::abr(); + } + }; + + sethnd(SIGINT, ::bow::inthnd); + sethnd(SIGTERM,::bow::inthnd); } diff --git a/bowshock/source/ini/bow/lop.cxx b/bowshock/source/ini/bow/lop.cxx index 3e607f2..7c9c120 100644 --- a/bowshock/source/ini/bow/lop.cxx +++ b/bowshock/source/ini/bow/lop.cxx @@ -35,7 +35,7 @@ auto ::bow::bow::lop() noexcept -> void { .objs = nullptr, }; - try {::bow::gensys(sysRoot,pldat.sysidt,pldat.tim);} + try {::bow::gensys(sysRoot,plydat.sysidt,plydat.tim);} catch (::std::bad_alloc const & e) { bow_logerr("unable to allocate memory for object"); ::bow::abr(); @@ -67,15 +67,15 @@ auto ::bow::bow::lop() noexcept -> void { }; ::bow::addobj(objroot,objTmp); - auto const scrlHand = [](::GLFWwindow * const win,[[maybe_unused]] double const xoff,double const yoff) -> void { - ::bow::pldat * dat = static_cast<::bow::pldat *>(::glfwGetWindowUserPointer(win)); + auto const scrlHand = [](::GLFWwindow * const win,[[maybe_unused]] ::zp::f04 const xoff,::zp::f04 const yoff) -> void { + ::bow::plydat * dat = static_cast<::bow::plydat *>(::glfwGetWindowUserPointer(win)); dat->zom *= ::std::pow(0x1.04p0f,0x0p0f-static_cast<float>(yoff)); }; - ::glfwSetWindowUserPointer(gfxdat.win,&pldat); + ::glfwSetWindowUserPointer(gfxdat.win,&plydat); ::glfwSetScrollCallback(gfxdat.win,scrlHand); - for (;;++pldat.tim) { + for (;;++plydat.tim) { if (polevt()) [[unlikely]] break; ::bow::grv(sysRoot); @@ -84,7 +84,7 @@ auto ::bow::bow::lop() noexcept -> void { ::bow::mov(sysRoot); ::bow::mov(objroot); - ::GLfloat const frm = 0x1p0*pldat.zom; + ::GLfloat const frm = 0x1p0*plydat.zom; vtx[0x0u] = (::GLfloat)sysRoot.objs->nxt->pos.x/frm; vtx[0x1u] = (::GLfloat)sysRoot.objs->nxt->pos.y/frm; @@ -99,7 +99,7 @@ auto ::bow::bow::lop() noexcept -> void { glBindBuffer(GL_ARRAY_BUFFER,vbo); glBufferSubData(GL_ARRAY_BUFFER,0x0,sizeof (vtx),vtx); - glUseProgram(gfxdat.shdprog); + glUseProgram(gfxdat.shdprg); glBindVertexArray(vao); glDrawArrays(GL_TRIANGLES,0x0,0x3 * 0x1); diff --git a/bowshock/source/ini/bow/crd.cxx b/bowshock/source/ini/bow/pricrd.cxx index f76b4e7..cc63cdc 100644 --- a/bowshock/source/ini/bow/crd.cxx +++ b/bowshock/source/ini/bow/pricrd.cxx @@ -7,7 +7,7 @@ #include <cstdlib> #include <stdexcept> -auto ::bow::bow::crd() noexcept -> void { +auto ::bow::bow::pricrd() noexcept -> void { char const * const pth = bow_datdir "/CREDITS.txt"; ::zp::siz const filsiz = [&pth]() { @@ -26,29 +26,29 @@ auto ::bow::bow::crd() noexcept -> void { ::std::exit(EXIT_FAILURE); } - char * crd; + char * pricrd; - try {crd = new char[filsiz + 0x3u];} + try {pricrd = new char[filsiz + 0x3u];} catch (::std::bad_alloc const & e) { bow_logerr("unable to allocate memory"); ::std::exit(EXIT_FAILURE); } - char * const credsrt = crd; + char * const credsrt = pricrd; - *crd++ = '\n'; + *pricrd++ = '\n'; - fil.red(crd,filsiz); + fil.red(pricrd,filsiz); fil.cls(); - crd += filsiz; + pricrd += filsiz; - *crd++ = '\n'; - *crd++ = '\x00'; + *pricrd++ = '\n'; + *pricrd++ = '\x00'; - crd = credsrt; + pricrd = credsrt; - ::ly::dflout.wrt(crd,filsiz + 0x3u); + ::ly::dflout.wrt(pricrd,filsiz + 0x3u); if (err != ::ly::err::ok) { bow_logerr("unable to write to defout"); @@ -56,7 +56,7 @@ auto ::bow::bow::crd() noexcept -> void { ::std::exit(EXIT_FAILURE); } - delete[] crd; + delete[] pricrd; ::std::exit(EXIT_SUCCESS); } diff --git a/bowshock/source/ini/bow/srtseq.cxx b/bowshock/source/ini/bow/srtseq.cxx index 6377fb2..e0ed099 100644 --- a/bowshock/source/ini/bow/srtseq.cxx +++ b/bowshock/source/ini/bow/srtseq.cxx @@ -14,7 +14,7 @@ auto ::bow::bow::srtseq() noexcept -> bool { constexpr ::GLfloat bowb = 0x1.9999999Ap-3; ::glfwSetTime(0x0p0); - for (double dur = 0x0p0;dur <= 0x3p0;dur = ::glfwGetTime()) { + for (::zp::f04 dur = 0x0p0;dur <= 0x3p0;dur = ::glfwGetTime()) { if (polevt()) [[unlikely]] break; glClearColor(bowr,bowg,bowb,0x1p0); @@ -22,9 +22,9 @@ auto ::bow::bow::srtseq() noexcept -> bool { ::glfwSwapBuffers(gfxdat.win); } - double const fadedur = 0x1p0; + ::zp::f04 const fadedur = 0x1p0; ::glfwSetTime(0x0p0); - for (double fac = 0x0p0;fac <= fadedur;fac = ::glfwGetTime()) { + for (::zp::f04 fac = 0x0p0;fac <= fadedur;fac = ::glfwGetTime()) { if (polevt()) [[unlikely]] {break;} ::GLfloat const r = bowr*(0x1p0f-fac/fadedur); diff --git a/bowshock/source/lgc/grv.cxx b/bowshock/source/lgc/grv.cxx index 1eceae5..c12e434 100644 --- a/bowshock/source/lgc/grv.cxx +++ b/bowshock/source/lgc/grv.cxx @@ -6,19 +6,19 @@ namespace bow { static auto grav1(::bow::obj & obj,::bow::obj const & par) noexcept -> void { - double const distx = par.pos.x-obj.pos.x; - double const disty = par.pos.y-obj.pos.y; - double const distz = par.pos.z-obj.pos.z; - double const dist = ::std::sqrt(distx*distx+disty*disty+distz*distz); + ::zp::f04 const distx = par.pos.x-obj.pos.x; + ::zp::f04 const disty = par.pos.y-obj.pos.y; + ::zp::f04 const distz = par.pos.z-obj.pos.z; + ::zp::f04 const dist = ::std::sqrt(distx*distx+disty*disty+distz*distz); - double const angy = ::std::atan2(disty,distx); - double const angz = ::std::atan2(distz,distx); + ::zp::f04 const angy = ::std::atan2(disty,distx); + ::zp::f04 const angz = ::std::atan2(distz,distx); - double acc = par.mas/(dist*dist)*::bow::grvval; + ::zp::f04 acc = par.mas/(dist*dist)*::bow::grvval; - double const vx = ::std::cos(angy)*acc; - double const vy = ::std::sin(angy)*acc; - double const vz = ::std::sin(angz)*acc; + ::zp::f04 const vx = ::std::cos(angy)*acc; + ::zp::f04 const vy = ::std::sin(angy)*acc; + ::zp::f04 const vz = ::std::sin(angz)*acc; obj.posVel.x += vx; obj.posVel.y += vy; @@ -26,24 +26,24 @@ namespace bow { } static void grav2(::bow::obj & obj0,::bow::obj & obj1) noexcept { - double const distx = obj1.pos.x-obj0.pos.x; - double const disty = obj1.pos.y-obj0.pos.y; - double const distz = obj1.pos.z-obj0.pos.z; - double const dist = ::std::sqrt(distx*distx+disty*disty+distz*distz); + ::zp::f04 const distx = obj1.pos.x-obj0.pos.x; + ::zp::f04 const disty = obj1.pos.y-obj0.pos.y; + ::zp::f04 const distz = obj1.pos.z-obj0.pos.z; + ::zp::f04 const dist = ::std::sqrt(distx*distx+disty*disty+distz*distz); - double const angy = ::std::atan2(disty,distx); - double const angz = ::std::atan2(distz,distx); + ::zp::f04 const angy = ::std::atan2(disty,distx); + ::zp::f04 const angz = ::std::atan2(distz,distx); - double acc0 = ::bow::grvval/(dist*dist); - double const acc1 = acc0*obj0.mas; // This is negative. + ::zp::f04 acc0 = ::bow::grvval/(dist*dist); + ::zp::f04 const acc1 = acc0*obj0.mas; // This is negative. acc0 *= obj1.mas; - double vx0 = ::std::cos(angy); - double vy0 = ::std::sin(angy); - double vz0 = ::std::sin(angz); - double const vx1 = vx0*acc1; - double const vy1 = vy0*acc1; - double const vz1 = vz0*acc1; + ::zp::f04 vx0 = ::std::cos(angy); + ::zp::f04 vy0 = ::std::sin(angy); + ::zp::f04 vz0 = ::std::sin(angz); + ::zp::f04 const vx1 = vx0*acc1; + ::zp::f04 const vy1 = vy0*acc1; + ::zp::f04 const vz1 = vz0*acc1; vx0 *= acc0; vy0 *= acc0; vz0 *= acc0; diff --git a/bowshock/source/lgc/shpmas.cxx b/bowshock/source/lgc/shpmas.cxx index 675a1b0..1003eb4 100644 --- a/bowshock/source/lgc/shpmas.cxx +++ b/bowshock/source/lgc/shpmas.cxx @@ -2,8 +2,8 @@ #include <bow/lgc.hxx> -auto ::bow::shpmas([[maybe_unused]] ::bow::shp const id) noexcept -> double { - double mas = 0x100p0; +auto ::bow::shpmas([[maybe_unused]] ::bow::shp const id) noexcept -> ::zp::f04 { + ::zp::f04 mas = 0x100p0; mas /= ::bow::masmod; return mas; diff --git a/bowshock/source/run/abr.cxx b/bowshock/source/run/abr.cxx index 76225be..5a28569 100644 --- a/bowshock/source/run/abr.cxx +++ b/bowshock/source/run/abr.cxx @@ -7,7 +7,10 @@ #include <source_location> auto ::bow::abr(::std::source_location const srcloc) noexcept -> void { - bow_log("\x1B[38;5;197maborting\x1B[0m from \"%s\":%" PRIXLEAST32 " @ %s\n",srcloc.file_name(),srcloc.line(),srcloc.function_name()); + bow_log( + "\x1B[38;5;197maborting\x1B[0m from \"%s\":%" PRIXLEAST32 " @ %s\n", + srcloc.file_name(),srcloc.line(),srcloc.function_name() + ); ::std::abort(); } diff --git a/bowshock/source/sav/cnt.cxx b/bowshock/source/sav/cnt.cxx index d6effdb..65c99dd 100644 --- a/bowshock/source/sav/cnt.cxx +++ b/bowshock/source/sav/cnt.cxx @@ -6,7 +6,7 @@ #include <ly/io> #include <zp/mem> -auto ::bow::cnt(::bow::pldat & pldat,char const * const pth) noexcept -> void { +auto ::bow::cnt(::bow::plydat & plydat,char const * const pth) noexcept -> void { bow_log("loading save file at \"%s\"",pth); ::ly::fil fil; @@ -16,7 +16,7 @@ auto ::bow::cnt(::bow::pldat & pldat,char const * const pth) noexcept -> void { if (err != ::ly::err::ok) [[unlikely]] { bow_logerr("unable to open save file \"%s\"",pth); - return ::bow::newsav(pldat); + return ::bow::newsav(plydat); } ::zp::i8 rawDat[::bow::savlen]; @@ -28,7 +28,7 @@ auto ::bow::cnt(::bow::pldat & pldat,char const * const pth) noexcept -> void { if (err == ::ly::err::eof) bow_logerr("corrupt save file at \"%s\"",pth); else bow_logerr("unable to read file at \"%s\"",pth); - return ::bow::newsav(pldat); + return ::bow::newsav(plydat); } fil.cls(); @@ -40,15 +40,15 @@ auto ::bow::cnt(::bow::pldat & pldat,char const * const pth) noexcept -> void { if (dat.fmtVer != ::bow::savver) [[unlikely]] { bow_logerr("invalid format (%" PRIX64 ") of save file at \"%s\"",dat.fmtVer,pth); - return ::bow::newsav(pldat); + return ::bow::newsav(plydat); } if (dat.shptyp > ::bow::maxshpid) [[unlikely]] { bow_logerr("invalid shp type (%" PRIX8 ")",dat.shptyp); - return ::bow::newsav(pldat); + return ::bow::newsav(plydat); } - pldat = ::bow::pldat { + plydat = ::bow::plydat { .tim = dat.tim, .sysidt = dat.sysidt, .shp = { @@ -75,10 +75,10 @@ auto ::bow::cnt(::bow::pldat & pldat,char const * const pth) noexcept -> void { }, }, }; - ::zp::cpy(pldat.nam,dat.cmdnam,::bow::cmdnamlen); - pldat.nam[::bow::cmdnamlen] = '\x00'; + ::zp::cpy(plydat.nam,dat.cmdnam,::bow::cmdnamlen); + plydat.nam[::bow::cmdnamlen] = '\x00'; - ::bow::gendat(pldat); + ::bow::gendat(plydat); - bow_log("welcome back, commander %s",pldat.nam); + bow_log("welcome back, commander %s",plydat.nam); } diff --git a/bowshock/source/sav/decsav.cxx b/bowshock/source/sav/decsav.cxx index 61d0f16..6adc78a 100644 --- a/bowshock/source/sav/decsav.cxx +++ b/bowshock/source/sav/decsav.cxx @@ -9,10 +9,10 @@ auto ::bow::decsav(::bow::savdat & buf,::zp::i8 const * dat) noexcept -> void { dat = ::zp::memcpy(&buf,dat,sizeof (buf)).src; }; - decVal(buf.fmtVer); // fmtver - decVal(buf.cmdnam); // cmdnam - decVal(buf.tim); // tim - decVal(buf.sysidt); // sysidt + decVal(buf.fmtVer); // fmtver + decVal(buf.cmdnam); // cmdnam + decVal(buf.tim); // tim + decVal(buf.sysidt); // sysidt decVal(buf.shptyp); // shptyp decVal(buf.shpposx); // shpposx decVal(buf.shpposy); // shpposy diff --git a/bowshock/source/sav/gendat.cxx b/bowshock/source/sav/gendat.cxx index f362b27..2a88d84 100644 --- a/bowshock/source/sav/gendat.cxx +++ b/bowshock/source/sav/gendat.cxx @@ -3,7 +3,7 @@ #include <bow/lgc.hxx> #include <bow/sav.hxx> -auto ::bow::gendat(::bow::pldat & dat) noexcept -> void { +auto ::bow::gendat(::bow::plydat & dat) noexcept -> void { bow_log("generating player data"); dat.shp.typ = ::bow::objtyp::shp; diff --git a/bowshock/source/sav/newsav.cxx b/bowshock/source/sav/newsav.cxx index d00bf61..1c525c2 100644 --- a/bowshock/source/sav/newsav.cxx +++ b/bowshock/source/sav/newsav.cxx @@ -2,10 +2,10 @@ #include <bow/sav.hxx> -auto ::bow::newsav(::bow::pldat & dat) noexcept -> void { +auto ::bow::newsav(::bow::plydat & dat) noexcept -> void { bow_log("generating new save file"); - dat = ::bow::pldat { + dat = ::bow::plydat { .nam = "Caelum\x00\x00\x00\x00\x00\x00\x00\x00", .tim = 0x0u, // 256 julian years after the Unix Epoch. .sysidt = 0x45u, diff --git a/bowshock/source/sav/sav.cxx b/bowshock/source/sav/sav.cxx index f221292..9e8a896 100644 --- a/bowshock/source/sav/sav.cxx +++ b/bowshock/source/sav/sav.cxx @@ -6,8 +6,8 @@ #include <ly/io> #include <zp/mem> -auto ::bow::sav(char const * const pth,::bow::pldat const & pldat) noexcept -> void { - bow_log("saving commander %s at \"%s\"",pldat.nam,pth); +auto ::bow::sav(char const * const pth,::bow::plydat const & plydat) noexcept -> void { + bow_log("saving commander %s at \"%s\"",plydat.nam,pth); ::ly::fil fil; ::ly::err err = fil.crt(pth,0644u); @@ -20,24 +20,24 @@ auto ::bow::sav(char const * const pth,::bow::pldat const & pldat) noexcept -> v ::zp::i8 dat[::bow::savlen]; ::bow::savdat savdat = { - .fmtVer = ::bow::savver, - .tim = pldat.tim, - .sysidt = pldat.sysidt, - .shptyp = static_cast<::zp::i8>(pldat.shp.shptyp), - .shpposx = pldat.shp.pos.x, - .shpposy = pldat.shp.pos.y, - .shpposz = pldat.shp.pos.z, - .shprotx = pldat.shp.rot.x, - .shproty = pldat.shp.rot.y, - .shprotz = pldat.shp.rot.z, - .shpposvelx = pldat.shp.posVel.x, - .shpposvely = pldat.shp.posVel.y, - .shpposvelz = pldat.shp.posVel.z, - .shprotvelx = pldat.shp.rotVel.x, - .shprotvely = pldat.shp.rotVel.y, - .shprotvelz = pldat.shp.rotVel.z, + .fmtVer = ::bow::savver, + .tim = plydat.tim, + .sysidt = plydat.sysidt, + .shptyp = static_cast<::zp::i8>(plydat.shp.shptyp), + .shpposx = plydat.shp.pos.x, + .shpposy = plydat.shp.pos.y, + .shpposz = plydat.shp.pos.z, + .shprotx = plydat.shp.rot.x, + .shproty = plydat.shp.rot.y, + .shprotz = plydat.shp.rot.z, + .shpposvelx = plydat.shp.posVel.x, + .shpposvely = plydat.shp.posVel.y, + .shpposvelz = plydat.shp.posVel.z, + .shprotvelx = plydat.shp.rotVel.x, + .shprotvely = plydat.shp.rotVel.y, + .shprotvelz = plydat.shp.rotVel.z, }; - ::zp::cpy(savdat.cmdnam,pldat.nam,sizeof (savdat.cmdnam)); + ::zp::cpy(savdat.cmdnam,plydat.nam,sizeof (savdat.cmdnam)); ::bow::encsav(dat,savdat); diff --git a/validateShaders.py b/validateShaders.py index d0b9c51..11ec783 100755 --- a/validateShaders.py +++ b/validateShaders.py @@ -2,19 +2,19 @@ from subprocess import PIPE,run -def validate(pth:str): - print("validating \"",pth,"\"... ",end='',sep='') +def validate(path:str): + print("validating \"",path,"\"... ",end='',sep='') - pth = "bowshock/shader/" + pth + ".glsl" + path = "bowshock/shader/" + path + ".glsl" prog = "glslangValidator" - stat = run([prog,pth],stdout=PIPE) + status = run([prog,path],stdout=PIPE) - ret = stat.returncode - if ret != 0x0: + result = status.returncode + if result != 0x0: print("\x1B[38;5;161merror\x1B[0m") print() - print(stat.stdout.decode("utf-8")) + print(status.stdout.decode("utf-8")) quit(0x1) print("\x1B[38;5;77mokay\x1B[0m") |