diff --git a/lib/bin/gmeng.h b/lib/bin/gmeng.h index 5317464..be30bcd 100755 --- a/lib/bin/gmeng.h +++ b/lib/bin/gmeng.h @@ -129,24 +129,24 @@ static void _functree_vl(char* file, int line, const char* func) { Gmeng::func_last.push_back(dat); }; -#define __functree_call__(file, line, func) _functree_vl(file, line, vl_get_name(func)) +#define __functree_call__(func) _functree_vl(__FILE__, __LINE__, vl_get_name(func)) #define v_str std::to_string template static uintptr_t _uget_addr(const T& obj) { - //__functree_call__(__FILE__, __LINE__, _uget_addr); + //__functree_call__(_uget_addr); return (reinterpret_cast(&obj)); }; static bool file_exists(std::string f) { - __functree_call__(__FILE__, __LINE__, file_exists); + __functree_call__(file_exists); return std::filesystem::is_directory(f) || std::filesystem::exists(f); } static std::string repeatString(const std::string& str, int times) { - //__functree_call__(__FILE__, __LINE__, repeatString); + //__functree_call__(repeatString); std::string result = ""; for (int i = 0; i < times; i++) { result += str; @@ -175,14 +175,14 @@ static std::vector> splitThing(std::vector obj, std::f }; static std::string _uconv_1ihx(int value) { - //__functree_call__(__FILE__, __LINE__, _conv_1ihx); + //__functree_call__(_conv_1ihx); std::stringstream stream; stream << "0x" << std::hex << value; return stream.str(); } static int g_mkid() { - //__functree_call__(__FILE__, __LINE__, g_mkid); + //__functree_call__(g_mkid); std::random_device rd; // random device to seed the generator std::mt19937 gen(rd()); // mersenne twister 19937 generator std::uniform_int_distribution distribution(1000000, 9999999); // 7-digit range @@ -215,14 +215,14 @@ static bool startsWith(const std::string& str, const char* prefix) }; static void g_setTimeout(std::function callback, int delay) { - __functree_call__(__FILE__, __LINE__, g_setTimeout); + __functree_call__(g_setTimeout); std::this_thread::sleep_for(std::chrono::milliseconds(delay)); callback(); } static std::string g_readFile(const string &fileName) { - __functree_call__(__FILE__, __LINE__, g_readFile); + __functree_call__(g_readFile); ifstream ifs(fileName.c_str(), ios::in | ios::binary | ios::ate); ifstream::pos_type fileSize = ifs.tellg(); @@ -235,7 +235,7 @@ static std::string g_readFile(const string &fileName) }; static void g_rmChar( string &str, char* charsToRemove ) { - __functree_call__(__FILE__, __LINE__, g_rmChar); + __functree_call__(g_rmChar); for ( unsigned int i = 0; i < strlen(charsToRemove); ++i ) { str.erase( remove(str.begin(), str.end(), charsToRemove[i]), str.end() ); } @@ -306,7 +306,7 @@ namespace Gmeng { // __etp = event type // __est = event script inline void cast_ev(int __etp, std::string __est) { - __functree_call__(__FILE__, __LINE__, Gmeng::EventHandler::cast_ev); + __functree_call__(Gmeng::EventHandler::cast_ev); if (__etp < 8500 || __etp > 8599) throw std::invalid_argument("Gmeng::EventHandler->cast_ev(int __etp <- right here | " + std::to_string(__etp) + " is not a valid event type"); if (__etp == Gmeng::CONSTANTS::C_InputEvent) std::cerr << __est; if (__etp == Gmeng::CONSTANTS::C_PlugEvent) std::cerr << __est; @@ -314,7 +314,7 @@ namespace Gmeng { return; }; inline std::string gen_estr(Gmeng::event __e) { - //__functree_call__(__FILE__, __LINE__, Gmeng::EventHandler::gen_estr); + //__functree_call__(Gmeng::EventHandler::gen_estr); if (__e.id == Gmeng::CONSTANTS::IE_Type0) return std::string ("[gm0:core/__MOUSECLICK__]"); return std::string ("[gm0:core/__EVCAST] " + std::to_string(__e.id) + @@ -378,7 +378,7 @@ namespace Gmeng { std::size_t width = _width; std::size_t height = _height; int totalObjects; Gmeng::DisplayMap<_width, _height> display; Gmeng::RendererOptions options; inline void setUnits(Unit unitmap[_width * _height]) { - __functree_call__(__FILE__, __LINE__, Gmeng::G_Renderer::setUnits); + __functree_call__(Gmeng::G_Renderer::setUnits); for (int i = 0; i < _width * _height; i++) { this->display.unitmap[i] = unitmap[i]; }; @@ -401,24 +401,24 @@ namespace Gmeng { }; inline void controller_set(int index, std::string value) { - __functree_call__(__FILE__, __LINE__, controller_set); + __functree_call__(controller_set); Gmeng::global.indexes.push_back(index); Gmeng::global.containers.push_back(value); }; inline void switch_dev_console() { - __functree_call__(__FILE__, __LINE__, switch_dev_console); + __functree_call__(switch_dev_console); Gmeng::global.dev_console = !Gmeng::global.dev_console; }; inline std::string _uget_thread() { - /// __functree_call__(__FILE__, __LINE__, _uget_thread); + /// __functree_call__(_uget_thread); static std::atomic counter(0); thread_local int threadId = counter.fetch_add(1); return std::to_string(threadId); }; inline std::string _uthread_id(const std::thread& thread) { - /// __functree_call__(__FILE__, __LINE__, _uthread_id); + /// __functree_call__(_uthread_id); std::thread::id threadId = thread.get_id(); size_t hashValue = std::hash{}(threadId); return std::to_string(hashValue); @@ -434,7 +434,7 @@ inline std::string _uthread_id(const std::thread& thread) { #define v_rcol Gmeng::resetcolor static void gm_err(v_intl type, v_title err_title) { - __functree_call__(__FILE__, __LINE__, gm_err); + __functree_call__(gm_err); switch (type) { case 0: // v_gm_err case 0: continue running program std::cerr << Gmeng::colors[4] << "gm:0 *error >> " << err_title << v_endl << v_rcol; @@ -452,13 +452,13 @@ inline Gmeng::Unit g_spike(int color = 0, int bgcolor = 0, bool big = false) { return Gmeng::Unit{.color=color,.collidable=false,.special=true,.special_clr=bgcolor,.special_c_unit=(big ? "X" : "x")}; }; inline int g_find_modifier(const std::vector& modifiers, const std::string& targetName) { - __functree_call__(__FILE__, __LINE__, g_find_modifier); + __functree_call__(g_find_modifier); for (size_t i = 0; i < modifiers.size(); ++i) { if (modifiers[i].name == targetName) { return static_cast(i); }; }; return -1; } inline std::vector _ulogc_gen1dvfc(int ln = 7400) { - __functree_call__(__FILE__, __LINE__, _ulogc_gen1dvfc); + __functree_call__(_ulogc_gen1dvfc); std::vector vector; for (int i = 0; i < ln; i++) { vector.push_back("\x0b"); @@ -512,7 +512,7 @@ static void gm_nlog(std::string msg) { }) static std::string str_replace(const std::string& str, const std::string& from, const std::string& to) { - // __functree_call__(__FILE__, __LINE__, str_replace); + // __functree_call__(str_replace); std::string result = str; std::size_t start_pos = 0; while ((start_pos = result.find(from, start_pos)) != std::string::npos) { result.replace(start_pos, from.length(), to); @@ -598,21 +598,21 @@ static void gm_slog(Gmeng::color_t color, std::string title, std::string text) { namespace Gmeng { static std::vector v_threads; static std::thread _ucreate_thread(std::function func) { - __functree_call__(__FILE__, __LINE__, Gmeng::_ucreate_thread); + __functree_call__(Gmeng::_ucreate_thread); return (Gmeng::v_threads.emplace_back(func)).detach(), std::move(Gmeng::v_threads.back()); }; static void _uclear_threads() { - __functree_call__(__FILE__, __LINE__, Gmeng::_uclear_threads); + __functree_call__(Gmeng::_uclear_threads); v_threads.erase(std::remove_if(v_threads.begin(), v_threads.end(), [](const std::thread& t) { return !t.joinable(); }), v_threads.end()); }; static void _ujoin_threads () { - __functree_call__(__FILE__, __LINE__, Gmeng::_ujoin_threads); + __functree_call__(Gmeng::_ujoin_threads); for (auto& thread : Gmeng::v_threads) { gm_log("Gmeng::_ujoin_threads -> gm:v_thread, _ucreate_thread() -> T_MEMADDR: " + _uconv_1ihx(_uget_addr(&thread)) + " - MAIN THREAD ID: " + _uget_thread() + " - T_THREAD_ID: " + _uthread_id(thread)); try { if (thread.joinable()) thread.join(); _uclear_threads(); } catch (std::exception& e) { std::cerr << (Gmeng::colors[4] + "_ujoin_threads() -> *error :: could not join thread, skipping..."); gm_log(" :::: error cause -> " + std::string(e.what())); }; }; }; } static void _gupdate_logc_intvl(int ms = 250) { - __functree_call__(__FILE__, __LINE__, _gupdate_logc_intvl); + __functree_call__(_gupdate_logc_intvl); #if __GMENG_ALLOW_LOG__ == false return; #endif @@ -620,7 +620,7 @@ static void _gupdate_logc_intvl(int ms = 250) { __gmeng_write_log__("gmeng.log", "Gmeng: Go-To Console Game Engine.\nSPAWN(1) = v_success\ncontroller_t of termui/_udisplay_of(GMENG, window) handed over to: controller_t(gmeng::threads::get(0))\n"); __gmeng_write_log__("gmeng.log", "Executable Name: " + Gmeng::global.executable + "\n", true); if (!Gmeng::global.shush) Gmeng::_ucreate_thread([&]() { - __functree_call__(__FILE__, __LINE__, _glog_thread_create); + __functree_call__(_glog_thread_create); for ( ;; ) { if (!Gmeng::global.dev_console) continue; if (Gmeng::logstream.str().length() > Gmeng::logc.v_drawpoints.size()) { @@ -639,7 +639,7 @@ static void _gupdate_logc_intvl(int ms = 250) { static void _gthread_catchup() { __annotation__(_gthread_catchup, "Gmeng::_uthread catchup function, attaches to all threads and clears them."); - __functree_call__(__FILE__, __LINE__, _gthread_catchup); + __functree_call__(_gthread_catchup); gm_log("_gthread_catchup() -> waiting for " + v_str(Gmeng::v_threads.size()) + " threads to catch-up to thread:" + (_uget_thread())); Gmeng::_ujoin_threads(); }; @@ -721,7 +721,7 @@ static std::string ws2s(const std::wstring& wstr) { ///// OS Check for windows static void __explain_why_i_cannot_run_to_dumbass_using_windows() { __annot__(__explain_why_i_cannot_run_to_dumbass_using_windows, "explains to a user using windows why windows cannot run gmeng."); - __functree_call__(__FILE__, __LINE__, __explain_why_i_cannot_run_to_dumbass_using_windows); + __functree_call__(__explain_why_i_cannot_run_to_dumbass_using_windows); std::cout << Gmeng::colors[4] << "libgmeng-abi: __excuse__" << std::endl; std::cout << "INTERNAL: __gmeng_platform__, __gmeng_threading__, __stdlib__, __libc++-abi__, __std_com_apple_main_pthread__" << std::endl; std::cout << "Gmeng is not available in a core-platform other than darwin ( apple_kernel )." << std::endl; @@ -732,7 +732,7 @@ static void __explain_why_i_cannot_run_to_dumbass_using_windows() { static void patch_argv_global(int argc, char* argv[]) { __annot__(patch_argv_global, "patches the Gmeng::global variable with the command-line arguments."); - __functree_call__(__FILE__, __LINE__, patch_argv_global); + __functree_call__(patch_argv_global); #if _WIN32 __explain_why_i_cannot_run_to_dumbass_using_windows(); return; @@ -743,7 +743,7 @@ static void patch_argv_global(int argc, char* argv[]) { char *v_arg = argv[i]; std::string argument (v_arg); if ( argument == "-help" || argument == "/help" || argument == "--help" || argument == "/?" || argument == "-?" ) { - __functree_call__(__FILE__, __LINE__, __gmeng__help__menu__); + __functree_call__(__gmeng__help__menu__); struct winsize size; ioctl(STDOUT_FILENO, TIOCGWINSZ, &size); int times = size.ws_col-11; diff --git a/lib/bin/src/gmeng.cpp b/lib/bin/src/gmeng.cpp index e525145..ef4f439 100755 --- a/lib/bin/src/gmeng.cpp +++ b/lib/bin/src/gmeng.cpp @@ -9,7 +9,7 @@ std::vector g_trace_trajectory(int x1, int y1, int x2, int y2) { - __functree_call__(__FILE__, __LINE__, g_trace_trajectory); + __functree_call__(g_trace_trajectory); std::vector coordinates; int dx = abs(x2 - x1); int dy = abs(y2 - y1); int sx = (x1 < x2) ? 1 : -1; int sy = (y1 < y2) ? 1 : -1; @@ -55,18 +55,18 @@ namespace Gmeng { bool player_init = false; int entitytotal = 0; inline void SetResolution(std::size_t w, std::size_t h) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::SetResolution); + __functree_call__(Gmeng::Camera::SetResolution); display_map.__h = h; display_map.__w = w; this->w = w; this->h = h; }; inline void constructor(Gmeng::Unit unitmap[_w*_h]) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::constructor); + __functree_call__(Gmeng::Camera::constructor); for (int i = 0; i < (w*h); i++) { this->display_map.unitmap[i] = unitmap[i]; }; }; inline void update() { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::update); + __functree_call__(Gmeng::Camera::update); for (int i = 0; i < this->h; i++) { for (int j = 0; j < this->w; j++) { if (i*j == this->h*this->w) break; @@ -78,14 +78,14 @@ namespace Gmeng { }; }; inline void temp_displacement(int __pX, int __pY, Gmeng::Unit u) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::temp_displacement); + __functree_call__(Gmeng::Camera::temp_displacement); this->set_curXY(__pX, __pY); int pos_in_map = (__pY * this->w) + __pX; this->raw_unit_map[pos_in_map] = this->draw_unit(u); this->rewrite_mapping({ pos_in_map }); }; inline std::string draw() { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::draw); + __functree_call__(Gmeng::Camera::draw); if (Gmeng::global.dont_hold_back && !Gmeng::global.shush) { gm_log("Gmeng::Camera job_render *draw -> total drawpoints available at this->cam::vp_mem0: " + v_str(sizeof(this->raw_unit_map)) + " , v_addr " + _uconv_1ihx(0) + " -> " + _uconv_1ihx(sizeof(this->raw_unit_map))); gm_log("Gmeng::Camera job_render *draw -> total drawpoints allocated for job_render at this->cam::vp_mem0: " + v_str(this->w*this->h) + " | " + _uconv_1ihx(this->w*this->h)); @@ -113,17 +113,17 @@ namespace Gmeng { }; inline bool has_modifier(std::string name) { for (const Gmeng::modifier& modifier : modifiers.values) if (modifier.name == name && modifier.value == 1) return true; return false; }; inline void update_modifier(Gmeng::modifier& modifier, int value) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::update_modifier); + __functree_call__(Gmeng::Camera::update_modifier); modifier.value = value; }; inline void set_modifier(std::string name, int value) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::set_modifier); + __functree_call__(Gmeng::Camera::set_modifier); int vi = g_find_modifier(this->modifiers.values, name); if (vi != -1) this->update_modifier(this->modifiers.values[vi], value); else this->modifiers.values.emplace_back(Gmeng::modifier { .name=name, .value=value }); }; inline void SetPlayer(int entityId, Objects::G_Player player, int x= 0, int y = -1, bool force = false) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::SetPlayer); + __functree_call__(Gmeng::Camera::SetPlayer); for (int i = 0; i < this->entitytotal; i++) { Objects::G_Entity entity = this->entitymap[i]; if (entity.entityId == entityId) throw std::invalid_argument("entity already exists: cannot create player"); @@ -145,15 +145,15 @@ namespace Gmeng { this->player_init = true; }; inline void AddEntity(int entityId, Objects::G_Entity entity) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::__no_impl__::AddEntity); + __functree_call__(Gmeng::Camera::__no_impl__::AddEntity); //working on }; inline void RemoveEntity(int entityId) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::__no_impl__::RemoveEntity); + __functree_call__(Gmeng::Camera::__no_impl__::RemoveEntity); //working on }; inline Objects::coord GetPos(int entityId) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::GetPos); + __functree_call__(Gmeng::Camera::GetPos); bool exists; Objects::G_Entity entity; for (int i = 0; i < this->entitytotal; i++) { @@ -165,21 +165,21 @@ namespace Gmeng { return entity.coords; }; inline void set_curXY(int x, int y) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::set_curXY); + __functree_call__(Gmeng::Camera::set_curXY); std::cout << "\033[" << x+2 << ";" << y+2 << "H"; return; // extra numbers account for the border around the map. }; inline void reset_cur() { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::reset_cur); + __functree_call__(Gmeng::Camera::reset_cur); this->set_curXY(-3, this->h); }; inline Objects::coord get_xy(int __p1) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::get_xy); + __functree_call__(Gmeng::Camera::get_xy); int __p1_x = __p1 / this->w; int __p1_y = __p1 % this->w; return { .x=__p1_x,.y=__p1_y }; }; inline void draw_info() { - /// __functree_call__(__FILE__, __LINE__, Gmeng::Camera::draw_info); + /// __functree_call__(Gmeng::Camera::draw_info); this->set_curXY(0,0); std::cout << "[ pos: " << std::to_string(this->player.coords.x) << "," << std::to_string(this->player.coords.y) << " ] "; this->set_curXY(1,0); @@ -224,7 +224,7 @@ namespace Gmeng { return final; }; inline void rewrite_mapping(const std::vector& positions) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::rewrite_mapping); + __functree_call__(Gmeng::Camera::rewrite_mapping); for (std::size_t i=0;iget_xy(curid); @@ -235,26 +235,26 @@ namespace Gmeng { this->reset_cur(); }; inline void clear_screen() { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::clear_screen); + __functree_call__(Gmeng::Camera::clear_screen); std::cout << "\033[2J\033[1;1H"; }; inline void set_entTag(std::string __nt) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::set_entTag); + __functree_call__(Gmeng::Camera::set_entTag); this->player.c_ent_tag = __nt; }; inline std::string get_entTag() { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::get_entTag); + __functree_call__(Gmeng::Camera::get_entTag); return this->player.c_ent_tag; }; inline void rewrite_full() { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::rewrite_full); + __functree_call__(Gmeng::Camera::rewrite_full); this->clear_screen(); this->update(); std::cout << repeatString("\n", 20) << endl; std::cout << this->draw() << std::endl; }; inline void MovePlayer(int entityId, int width, int height) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::MovePlayer); + __functree_call__(Gmeng::Camera::MovePlayer); int move_to_in_map = (height*this->w)+width; bool exists = false; Objects::G_Player entity; @@ -291,7 +291,7 @@ namespace Gmeng { this->rewrite_mapping({move_to_in_map, current_pos_in_map}); }; inline void MoveEntity(int entityId, int width, int height) { - __functree_call__(__FILE__, __LINE__, Gmeng::Camera::MoveEntity); + __functree_call__(Gmeng::Camera::MoveEntity); int move_to_in_map = (height*this->w)+width; bool exists = false; Objects::G_Entity entity; @@ -310,7 +310,7 @@ namespace Gmeng { }; template inline Camera<_w, _h> UseRenderer(Gmeng::G_Renderer<_w, _h> __r) { - __functree_call__(__FILE__, __LINE__, Gmeng::UseRenderer); + __functree_call__(Gmeng::UseRenderer); Gmeng::Camera<_w, _h> wrldmp; wrldmp.w = __r.width; wrldmp.h = __r.height; wrldmp.constructor(__r.display.unitmap); @@ -336,7 +336,7 @@ namespace Gmeng::RemoteServer { }; static void _gremote_server_apl(bool state, std::string aplpass) { - __functree_call__(__FILE__, __LINE__, _gremote_server_apl); + __functree_call__(_gremote_server_apl); Gmeng::RemoteServer::state = state; Gmeng::RemoteServer::aplpass = aplpass; auto thread_t = Gmeng::_ucreate_thread([&]() { diff --git a/lib/bin/src/objects.cpp b/lib/bin/src/objects.cpp index 794790f..4c6fd7a 100755 --- a/lib/bin/src/objects.cpp +++ b/lib/bin/src/objects.cpp @@ -1,5 +1,6 @@ #pragma once -#include +#include + #define __GMENG_OBJECTINIT__ true namespace Objects { diff --git a/lib/bin/src/renderer.cpp b/lib/bin/src/renderer.cpp index e74fda8..f9a19ca 100755 --- a/lib/bin/src/renderer.cpp +++ b/lib/bin/src/renderer.cpp @@ -27,7 +27,7 @@ namespace Gmeng { struct drawpoint { int x; int y; }; struct viewpoint { drawpoint start; drawpoint end; }; inline Gmeng::texture generate_empty_texture(int width, int height) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::generate_empty_texture); + __functree_call__(Gmeng::Renderer::generate_empty_texture); Gmeng::texture __t; __t.width = width; __t.height = height; __t.collidable = false; int color_value = 0; for (int i = 0; i < height; i++) { @@ -43,7 +43,7 @@ namespace Gmeng { class Model { private: inline Objects::coord get_pointXY(int pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Model::get_pointXY); + __functree_call__(Gmeng::Renderer::Model::get_pointXY); int __p1_x = (pos % this->width); int __p1_y = (pos / this->width); return Objects::coord { @@ -55,20 +55,20 @@ namespace Gmeng { std::size_t width; std::size_t height; std::size_t size; drawpoint position; std::string name; Gmeng::texture texture; int id; inline void reset_texture() { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Model::reset_texture); + __functree_call__(Gmeng::Renderer::Model::reset_texture); this->texture = generate_empty_texture(this->width, this->height); }; inline void attach_texture(Gmeng::texture __t) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Model::attach_texture); + __functree_call__(Gmeng::Renderer::Model::attach_texture); this->texture = __t; this->width = __t.width; this->height = __t.height; }; inline void load_texture(std::string __tf) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Model::load_texture); + __functree_call__(Gmeng::Renderer::Model::load_texture); this->texture = Gmeng::LoadTexture(__tf); }; //! FIXME: width,height values remain unchanged }; inline Model generate_empty_model(int width, int height) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::generate_empty_model); + __functree_call__(Gmeng::Renderer::generate_empty_model); int id = g_mkid(); return Model { .width=static_cast(width), .height=static_cast(height), .size=static_cast(width*height), @@ -85,7 +85,7 @@ namespace Gmeng { }; /// parses a string.gmdl file to a gmdl gnmdl parse_gmdl(std::string _indx) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::parse_gmdl); + __functree_call__(Gmeng::Renderer::parse_gmdl); /// syntax: /// mdl_0x px=0 py=0 w=10 h=10 tx=tx_0x /// name posX posY width height texture @@ -104,7 +104,7 @@ namespace Gmeng { }; // compiles Renderer::Model objects into a Gmeng::Unit vector std::vector draw_model(Gmeng::Renderer::Model __m) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::draw_model); + __functree_call__(Gmeng::Renderer::draw_model); std::vector unitmap; if (Gmeng::global.dont_hold_back) gm_log("job_render *draw_model -> MODEL * size: " + v_str(__m.width * __m.height) + " units | TEXTURE * size: " + v_str(__m.texture.units.size()) + " units"); for ( int i = 0; i < __m.height; i++ ) { @@ -127,7 +127,7 @@ namespace Gmeng { /// this means that this drawpoint does not represent the coordinate 5,5; /// however an object with the size of 5,5. std::size_t getsize(drawpoint c) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::getsize); + __functree_call__(Gmeng::Renderer::getsize); return ( c.x < 1 ? ( c.y ) : @@ -136,12 +136,12 @@ namespace Gmeng { }; /// returns drawpoint object as log string std::string conv_dp(drawpoint p) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::conv_dp); + __functree_call__(Gmeng::Renderer::conv_dp); return "x=" + v_str(p.x) + ",y=" + v_str(p.y); }; // returns placement coordinates for each coordinate of object at __p with size of __s in mapsize of __ws std::vector get_placement(drawpoint __p, drawpoint __s, drawpoint __ws, bool _vlinear_render = false) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::get_placement); + __functree_call__(Gmeng::Renderer::get_placement); gm_log("gm::v_renderer -> get_placement : pvalues = 1: " + conv_dp(__p) + " 2: " + conv_dp(__s) + " 3: " + conv_dp(__ws)); if (getsize(__p) > getsize(__ws) || getsize(__s) > getsize(__ws)) throw std::invalid_argument("placement parameters invalid"); std::vector vec; @@ -168,7 +168,7 @@ namespace Gmeng { }; /// returns placement coordinates for a viewpoint within a map sizeof drawpointxy std::vector get_displacement(viewpoint& view, const drawpoint& map) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::get_displacement); + __functree_call__(Gmeng::Renderer::get_displacement); std::vector result; // Ensure the viewpoint is within the map boundaries @@ -190,17 +190,17 @@ namespace Gmeng { Gmeng::Camera<0, 0> camera; Gmeng::Renderer::viewpoint viewpoint; std::size_t width; std::size_t height; std::vector rendered_units; inline void set_resolution(std::size_t width, std::size_t height) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Display::set_resolution); + __functree_call__(Gmeng::Renderer::Display::set_resolution); this->width = width; this->height = height; this->camera.SetResolution(this->width, this->height); }; inline void refresh() { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Display::refresh); + __functree_call__(Gmeng::Renderer::Display::refresh); // refresh resolution this->camera.SetResolution(this->width, this->height); }; inline void plunit(Objects::G_Player pl, Objects::coord plcoords) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Display::plunit); + __functree_call__(Gmeng::Renderer::Display::plunit); auto v_playerunit = this->rendered_units[(plcoords.x*this->camera.w)+plcoords.y]; std::cout << this->camera.draw_unit(v_playerunit) << " " << Gmeng::colors[pl.colorId] << pl.colorId << endl; this->rendered_units[(plcoords.x*this->camera.w)+plcoords.y] = Gmeng::Unit { @@ -213,11 +213,11 @@ namespace Gmeng { }; }; inline void nplunit(Objects::coord coords) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Display::nplunit); + __functree_call__(Gmeng::Renderer::Display::nplunit); this->rendered_units[coords.y*this->camera.w + coords.x].is_player = false; }; inline void draw(Objects::G_Player pl, Objects::coord plcoords) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Display::draw); + __functree_call__(Gmeng::Renderer::Display::draw); this->refresh(); if (!this->camera.player_init) this->camera.SetPlayer(0, pl, plcoords.y, plcoords.x, true); else this->camera.MovePlayer(0, plcoords.y, plcoords.x); @@ -234,7 +234,7 @@ namespace Gmeng { std::cout << this->camera.draw() << endl; }; inline void move_to(Gmeng::Renderer::viewpoint __vp) { - __functree_call__(__FILE__, __LINE__, Gmeng::Renderer::Display::move_to); + __functree_call__(Gmeng::Renderer::Display::move_to); this->viewpoint = __vp; }; }; @@ -272,7 +272,7 @@ namespace Gmeng { /// being bigger than the size of current_chunk in r_chunk->chunks(0) - it is limited. /// std::vector as &new_delegate since a single character may have color defining escape codes in it inline std::string _ujoin_unit_linear(std::string& current, std::vector& new_delegate, LinearRenderBufferPositionController pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::_ujoin_unit_linear); + __functree_call__(Gmeng::_ujoin_unit_linear); int _vpos = 0; std::vector c_lines = g_splitStr(current, "\n"); switch (pos) { @@ -295,7 +295,7 @@ namespace Gmeng { }; }; inline std::string _ujoin_unit_horizontal(std::string& current, std::vector& new_delegate, HorizontalRenderBufferPositionController pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::_ujoin_unit_horizontal); + __functree_call__(Gmeng::_ujoin_unit_horizontal); switch (pos) { case SIDE_TOP: return g_joinStr(new_delegate, "") + "\n" + current; @@ -307,20 +307,20 @@ namespace Gmeng { }; inline Objects::coord trace_1dp(int xy, int wmp_x) { - __functree_call__(__FILE__, __LINE__, Gmeng::trace_1dp); + __functree_call__(Gmeng::trace_1dp); int width = xy % wmp_x; int height = xy / wmp_x; return Objects::coord { .x = width, .y = height }; }; /// logs information about units within vp_units as vector, po_size vp_units wsizeX inline void log_vpu(std::vector& vp_units, int wsizeX) { - __functree_call__(__FILE__, __LINE__, Gmeng::log_vpu); + __functree_call__(Gmeng::log_vpu); int jndx = 0; for (const auto& _v_unit : vp_units) { Objects::coord gp = Gmeng::trace_1dp(jndx, wsizeX); gm_nlog("vp_gtx.units @ pos "+ v_str(jndx) + " ("+v_str(gp.y)+","+v_str(gp.x)+"):\n\tv_color -> " + v_str(_v_unit.color) + "\n\tv_collision -> " + (_v_unit.collidable ? "true" : "false") + "\n\tv_special -> " + (_v_unit.special ? "true" : "false") + "\n\tv_spcolor -> " + v_str(_v_unit.special_clr) + "\n"); jndx++; }; gm_nlog("\n"); }; /// logs information about a viewpoint chunk inline void log_vpc(Gmeng::r_chunk vp_chunk) { - __functree_call__(__FILE__, __LINE__, Gmeng::log_vpc); + __functree_call__(Gmeng::log_vpc); gm_nlog("vp_chunk->vpc_info : r_chunk & Gmeng::r_chunk & Gmeng::Renderer::Model & Gmeng::Texture & gm_vpcontrol\n"); gm_nlog("metadata:\n"); gm_nlog("\tv_viewpoint -> start = " + Gmeng::Renderer::conv_dp(vp_chunk.vp.start) + " - end = " + Gmeng::Renderer::conv_dp(vp_chunk.vp.end) + "\n"); @@ -372,14 +372,14 @@ namespace Gmeng { }; inline Gmeng::Renderer::Model vd_find_model(v_dictl dict, v_title name) { - __functree_call__(__FILE__, __LINE__, Gmeng::vd_find_model); + __functree_call__(Gmeng::vd_find_model); for (const auto& val : dict.v_getrelative()) { if (val.data.name == name) return val.data; }; return Gmeng::nomdl; }; inline Gmeng::texture vd_find_texture(v_dictl dict, v_title name) { - __functree_call__(__FILE__, __LINE__, Gmeng::vd_find_texture); + __functree_call__(Gmeng::vd_find_texture); int ccount = 0; for (const auto& val : dict.v_getrelative()) { if (Gmeng::global.dont_hold_back) gm_log("gm::vd_find_texture() -> v_searchAddr: v_dictl vgm_defaults asumed | addr: " + _uconv_1ihx(ccount) + " -> relative_value = " + val.data.name + " , search_value = " + name + " , match = " + std::string(val.data.name == name ? "yes" : "no")); @@ -394,7 +394,7 @@ namespace Gmeng { }; /// reads a folder's .gmdl and .gtx files into Gmeng::vgm_defaults::vg_rdmodels & vg_textures; inline void _uread_into_vgm(const v_title& folder) { - __functree_call__(__FILE__, __LINE__, Gmeng::_uread_into_vgm); + __functree_call__(Gmeng::_uread_into_vgm); // we wait until all textures are in vgm_defaults before we load any models // afterwards we loop through the vector and load them into Gmeng::vgm_defaults::vg_rdmodels std::vector q_modelindx; @@ -421,13 +421,13 @@ namespace Gmeng { /// writes values in Gmeng::vgm_defaults::vg_rdmodels & vg_textures into vectors v_mdls and v_txtrs inline void _uwritevgm_to_maps(std::map& v_mdls, std::map& v_txtrs) { - __functree_call__(__FILE__, __LINE__, Gmeng::_uwritevgm_to_maps); + __functree_call__(Gmeng::_uwritevgm_to_maps); for (const auto& mdl : vgm_defaults::vg_rdmodels.v_getrelative()) { v_mdls[mdl.data.name] = mdl.data; }; for (const auto& txtr : vgm_defaults::vg_textures.v_getrelative()) { v_txtrs[txtr.data.name] = txtr.data; }; }; inline LevelInfo parse_glvl(std::string __fn) { - __functree_call__(__FILE__, __LINE__, Gmeng::parse_glvl); + __functree_call__(Gmeng::parse_glvl); /// syntax: /// ln 1-4 are headers /// ln 0 | name=level_name @@ -546,7 +546,7 @@ namespace Gmeng { private: // compiles a chunk into a std::vector unitmap for a Camera instance to render inline std::vector render_chunk(Gmeng::r_chunk chunk) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::__private__::render_chunk); + __functree_call__(Gmeng::Level::__private__::render_chunk); // write base_template skybox image to chunk (level 0 of canvas) // base_template's viewpoint relative to the chunks viewpoint will be drawn as a base 'skybox' like image Gmeng::texture* base_map = &this->base.lvl_template; std::vector units; @@ -625,15 +625,15 @@ namespace Gmeng { return units; }; inline Gmeng::r_chunk get_chunk(int id) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::__private__::get_chunk); + __functree_call__(Gmeng::Level::__private__::get_chunk); return this->chunks[id]; }; inline void set_chunk(int id, Gmeng::r_chunk chunk) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::__private__::set_chunk); + __functree_call__(Gmeng::Level::__private__::set_chunk); this->chunks[id] = chunk; }; inline Renderer::viewpoint calculate_camera_viewpoint() { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::__private__::calculate_camera_viewpoint); + __functree_call__(Gmeng::Level::__private__::calculate_camera_viewpoint); Renderer::drawpoint start; Renderer::drawpoint end; start.x = this->plcoords.x - ((this->display.width -1)/2); start.y = this->plcoords.y - ((this->display.height-1)/2); @@ -649,12 +649,12 @@ namespace Gmeng { Gmeng::Renderer::LevelBase base; Gmeng::Renderer::Display display; Objects::G_Player player = Gmeng::v_base_player; Objects::coord plcoords = { .x=0, .y=0 }; std::vector chunks; std::string desc; std::string name; inline int load_chunk(Gmeng::r_chunk chunk) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::load_chunk); + __functree_call__(Gmeng::Level::load_chunk); this->chunks.push_back(chunk); return (this->chunks.size()-1); }; inline void load_level(Gmeng::LevelInfo __glvl) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::load_level); + __functree_call__(Gmeng::Level::load_level); int i,j = 0; gm_log("vp_loadlevel: __glvl chunks v_size: " + v_str(__glvl.chunks.size())); for (const auto& chunk : __glvl.chunks) { @@ -688,14 +688,14 @@ namespace Gmeng { }; /// sets the current frame to the param &vector inline void set_image(std::vector units) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::set_image); + __functree_call__(Gmeng::Level::set_image); std::copy(units.begin(), units.end(), this->display.camera.display_map.unitmap); this->display.draw(this->player, this->plcoords); }; // draws chunk in Gmeng::Level::(std::vector)chunks on position: chunk_id // to the Display::Camera controller inline void draw_camera(int chunk_id) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::draw_camera); + __functree_call__(Gmeng::Level::draw_camera); if (chunk_id < 0 || chunk_id > chunks.size()) throw std::invalid_argument("chunk_id is invalid"); Gmeng::r_chunk chunk = this->chunks[chunk_id]; gm_log("render_chunk start" ); @@ -713,11 +713,11 @@ namespace Gmeng { this->display.draw(this->player, this->plcoords); }; inline std::vector get_rendered_chunk(int id) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::get_rendered_chunk); + __functree_call__(Gmeng::Level::get_rendered_chunk); return this->render_chunk(this->chunks[id]); }; inline std::vector v_render_chunk(Gmeng::r_chunk chunk) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::v_render_chunk); + __functree_call__(Gmeng::Level::v_render_chunk); return this->render_chunk(chunk); }; /// refreshes the current chunk display @@ -726,14 +726,14 @@ namespace Gmeng { this->display.draw(this->player, this->plcoords); }; inline void set_player(Objects::G_Player p, int x, int y) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::set_player); + __functree_call__(Gmeng::Level::set_player); if (this->display.camera.player_init) this->display.nplunit(this->plcoords); this->player = p; this->plcoords = { .x=x, .y=y }; gm_log("r_level::set_player *inline,static -> v_success ; r_level::player (Objects::G_Player).coords = @pos(" + v_str(this->player.coords.x)+","+v_str(this->player.coords.y)+")"); this->move_player(x, y); }; inline void move_player(int x, int y) { - __functree_call__(__FILE__, __LINE__, Gmeng::Level::move_player); + __functree_call__(Gmeng::Level::move_player); this->plcoords.x=x; this->plcoords.y=y; this->display.viewpoint = this->calculate_camera_viewpoint(); }; @@ -741,7 +741,7 @@ namespace Gmeng { /// checks if a viewpoint contains a sub-viewpoint /// this code is horrifying to edit, we should just hope that it will never cause issues inline std::vector viewpoint_includes(const Renderer::viewpoint &v_control, const Renderer::viewpoint &v_check) { - __functree_call__(__FILE__, __LINE__, Gmeng::viewpoint_includes); + __functree_call__(Gmeng::viewpoint_includes); std::vector __shared__; // Check if v_checks start point is within control if (v_check.start.x >= v_control.start.x && v_check.start.y >= v_control.start.y && @@ -773,14 +773,14 @@ namespace Gmeng { return __shared__; }; inline bool viewpoint_includes_dp(Renderer::viewpoint vp, Renderer::drawpoint dp) { - //__functree_call__(__FILE__, __LINE__, Gmeng::viewpoint_includes_dp); + //__functree_call__(Gmeng::viewpoint_includes_dp); if (dp.x >= vp.start.x && dp.x <= vp.end.x && dp.y >= vp.start.y && dp.y <= vp.end.y) return true; return false; }; /// @deprecated not used internally | DOES NOT RETURN CORRECT VALUES inline std::vector trace_render_partial(Gmeng::Level level_t, int id, std::vector drawpoints) { - __functree_call__(__FILE__, __LINE__, Gmeng::__deprecated_do_not_use__::trace_render_partial); + __functree_call__(Gmeng::__deprecated_do_not_use__::trace_render_partial); std::vector raw_chunk = level_t.get_rendered_chunk(id); std::vector __partial__; for (const auto& dp : drawpoints) { @@ -798,7 +798,7 @@ namespace Gmeng { }; /// traces a chunk's display position in a vector inline std::vector trace_chunk_vector(Gmeng::Level& level_t) { - __functree_call__(__FILE__, __LINE__, Gmeng::__deprecated_do_not_use__::trace_chunk_vector); + __functree_call__(Gmeng::__deprecated_do_not_use__::trace_chunk_vector); std::vector displays; Gmeng::Camera<0, 0> *pCamera = &(level_t.display.camera); Gmeng::Renderer::Display *pDisplay = &(level_t.display); int __iterator_count__ = 0; @@ -813,7 +813,7 @@ namespace Gmeng { }; /// combines render buffers into a list inline std::vector splice_render_buffers(std::vector chunks, Gmeng::Level &level_t) { - __functree_call__(__FILE__, __LINE__, Gmeng::__deprecated_do_not_use__::splice_render_buffers); + __functree_call__(Gmeng::__deprecated_do_not_use__::splice_render_buffers); std::vector units; for (const auto& chunk : chunks) { std::vector shared_delegates = viewpoint_includes(level_t.display.viewpoint, chunk.vp); @@ -824,7 +824,7 @@ namespace Gmeng { return units; }; inline std::vector chromatize_viewpoint(Renderer::viewpoint vp) { - __functree_call__(__FILE__, __LINE__, Gmeng::chromatize_viewpoint); + __functree_call__(Gmeng::chromatize_viewpoint); std::vector _vpos; /// x, y < |MATH_DELTA( VP_END, VP_START )| (viewpoint_width) /// transcend_drawpoint_to_viewpoint(); __viewpoint_controller__(); @@ -839,7 +839,7 @@ namespace Gmeng { return _vpos; }; inline Renderer::drawpoint trace_drawpoint_in_viewpoint(Renderer::viewpoint vp, Renderer::drawpoint dp) { - __functree_call__(__FILE__, __LINE__, Gmeng::trace_drawpoint_in_viewpoint); + __functree_call__(Gmeng::trace_drawpoint_in_viewpoint); std::vector vp_pos = chromatize_viewpoint(vp); return { .x = vp_pos[dp.y * (vp.end.x - vp.start.x) + dp.x].x, @@ -849,12 +849,12 @@ namespace Gmeng { /// @deprecated not used internally | NOT IMPLEMENTED /// trace_chunk_vector implements optimization itself. inline void _voptimize_chunk_vector(Gmeng::Level& level_t) { - __functree_call__(__FILE__, __LINE__, Gmeng::__no_impl__::_voptimize_chunk_vector); + __functree_call__(Gmeng::__no_impl__::_voptimize_chunk_vector); }; /// sorts a chunk vector according to its levels' viewpoints ( correct_formed_list ) /// @deprecated not used internally, but returns values as expected inline std::vector _vsort_chunk_vector(Gmeng::Level& level_t) { - __functree_call__(__FILE__, __LINE__, Gmeng::__deprecated_do_not_use__::_vsort_chunk_vector); + __functree_call__(Gmeng::__deprecated_do_not_use__::_vsort_chunk_vector); std::vector chunks; int __base_width__ = level_t.base.width; int __iterator_value__ = 0; @@ -870,7 +870,7 @@ namespace Gmeng { /// compiles a level's display viewpoint into a vector of units /// (splicing different parts of r_chunk renderbuffers into one Camera instance) inline std::vector _vgen_camv_fv2cv(Gmeng::Level &level_t) { - __functree_call__(__FILE__, __LINE__, Gmeng::__deprecated_do_not_use__::_vgen_camv_fv2cv); + __functree_call__(Gmeng::__deprecated_do_not_use__::_vgen_camv_fv2cv); Gmeng::Renderer::Display *pDisplay = &level_t.display; Gmeng::Camera<0,0> *pCamera = &level_t.display.camera; std::vector chunks = Gmeng::trace_chunk_vector(level_t); std::vector units = Gmeng::splice_render_buffers(chunks, level_t); @@ -912,7 +912,7 @@ namespace Gmeng { /// vector[4] = 4 template inline number_type _vcreate_vu2d_delta_xy(int x, int y, int width) { - __functree_call__(__FILE__, __LINE__, _vcreate_vu2d_delta_xy); + __functree_call__(_vcreate_vu2d_delta_xy); return v_static_cast( ( y * width ) + x ); }; /// @deprecated USE get_lvl_view(&level) INSTEAD @@ -924,7 +924,7 @@ namespace Gmeng { /// -> splice_render_buffers( chunks ) => vector< UNIT(0) > units /// -> _vcreate_vp2d_deltay, _vcreate_vp2d_deltax, _vcreate_vu2d_delta_xy inline std::string _vcamv_gen_frame(Gmeng::Level level_t) { - __functree_call__(__FILE__, __LINE__, Gmeng::__deprecated_do_not_use__::_vcamv_gen_frame); + __functree_call__(Gmeng::__deprecated_do_not_use__::_vcamv_gen_frame); gm_log("_vcamv_gen_frame() -> registering job_render to process queue [ __gmeng_invoke_expr__, __gmeng_vcamv_gen_frame__, __gmeng_renderer__ ]"); std::string __final__ = ""; gm_log("_vcamv_gen_frame() job_render -> process has been recognized by the thread"); @@ -971,13 +971,13 @@ namespace Gmeng { }; inline int _cc1d_scalar_size(Renderer::viewpoint vp) { - __functree_call__(__FILE__, __LINE__, Gmeng::_cc1d_scalar_size); + __functree_call__(Gmeng::_cc1d_scalar_size); return ( _vcreate_vp2d_deltax(vp) * 0x1 ); }; /// mirror: reverses a vector template inline void mirror(std::vector<__vtype__>& __v, int cc = 0) { - __functree_call__(__FILE__, __LINE__, Gmeng::mirror); + __functree_call__(Gmeng::mirror); cc % 2 == 0 ? std::reverse(__v.begin(), __v.end()) : std::reverse(__v.end(), __v.begin()) ; @@ -990,7 +990,7 @@ namespace Gmeng { /// "xxxxxxx", /// "xxxoxxx", } -> VECTOR(VECTOR, 3); inline std::vector _vconcatenate_lvl_chunks(Gmeng::Level& lvl, bool cubic_render = true) { - __functree_call__(__FILE__, __LINE__, Gmeng::_vconcatenate_lvl_chunks); + __functree_call__(Gmeng::_vconcatenate_lvl_chunks); gm_log("Gmeng::_vconcatenate_lvl_chunks *debugger, *0.0, p0,gm:0 :: breakpoint 1"); std::vector<__CHROMATIZED_CHUNK_CONTROLLER_VIEWPOINT__> v_chunks; const int __level_base_width__ = v_static_cast(lvl.base.lvl_template.width); @@ -1056,7 +1056,7 @@ namespace Gmeng { /// returns all drawpoints that are included in a viewpoint as a vector. inline std::vector _vexpand_viewpoint(Gmeng::Renderer::viewpoint &vp) { - __functree_call__(__FILE__, __LINE__, Gmeng::_vexpand_viewpoint); + __functree_call__(Gmeng::_vexpand_viewpoint); std::vector v_drawpoints; for (int unchromatized_y = 0; unchromatized_y < _vcreate_vp2d_deltay(vp); unchromatized_y++) { for (int unchromatized_x = 0; unchromatized_x < _vcreate_vp2d_deltax(vp); unchromatized_x++) { @@ -1076,7 +1076,7 @@ namespace Gmeng { /// Only use this when a chunk's models, textures are updated. Player and entity movement are handled /// automatically, so there is no need to put this method in any loops. inline std::vector _vget_renderscale2dpartial_scalar(Gmeng::Level& level_t, bool cubic_render = true) { - __functree_call__(__FILE__, __LINE__, Gmeng::_vget_renderscale2dpartial_scalar); + __functree_call__(Gmeng::_vget_renderscale2dpartial_scalar); std::vector v_concat_chunks = _vconcatenate_lvl_chunks(level_t, cubic_render); return v_concat_chunks; }; @@ -1093,7 +1093,7 @@ namespace Gmeng { }; /// returns the camera of the current level, with drawpoints included in level_t->display.viewpoint inline std::string get_lvl_view(Gmeng::Level& level_t, std::vector concat_chunks, bool cubic_render = true) { - __functree_call__(__FILE__, __LINE__, Gmeng::get_lvl_view); + __functree_call__(Gmeng::get_lvl_view); gm_log("get_lvl_view -> tracing viewpoint from level->display.vp"); /// splits each unit including its colorcode ascii characters, using the formatter \x0F defined /// in _vget_renderscale2dpartial_scalar() ~ _vconcatenate_lvl_chunks(). @@ -1205,7 +1205,7 @@ namespace Gmeng { /// This method requires a Gmeng::Level& and a viable rendered_viewpoint as parameters. /// to create a rendered_viewpoint use Gmeng::_vget_renderscale2dpartial_scalar(level) and put its return value to get_lvl_view(level, value) inline void emplace_lvl_camera(Gmeng::Level& level_t, std::string cam_data) { - __functree_call__(__FILE__, __LINE__, Gmeng::emplace_lvl_camera); + __functree_call__(Gmeng::emplace_lvl_camera); ASSERT("pref.log", Assertions::vd_assert::OFF); std::string cam_data_raw = cam_data; gm_log("emplace_lvl_camera -> retrieved viable camera data from rendered_viewpoint"); diff --git a/lib/bin/src/textures.cpp b/lib/bin/src/textures.cpp index 9d1977e..baa2e5a 100755 --- a/lib/bin/src/textures.cpp +++ b/lib/bin/src/textures.cpp @@ -16,7 +16,7 @@ namespace Gmeng { inline void set_texturemap(Gmeng::texture &g_tx, Gmeng::texture &g_tx2) { - __functree_call__(__FILE__, __LINE__, Gmeng::set_texturemap); + __functree_call__(Gmeng::set_texturemap); int indx = 0; for ( const auto& unit : g_tx2.units ) { g_tx.units[indx] = unit; @@ -24,7 +24,7 @@ namespace Gmeng { }; }; inline Gmeng::texture LoadTexture(std::string __fname) { - __functree_call__(__FILE__, __LINE__, Gmeng::LoadTexture); + __functree_call__(Gmeng::LoadTexture); std::ifstream file(__fname); Gmeng::texture texture; if (!file.is_open()) { std::cerr << Gmeng::colors[4] << "[gm0:core] Gmeng::LoadTexture(): could not load texturemap file " << __fname << ": e_file_unavailable"; }; std::vector lines; std::string line; diff --git a/lib/bin/types/interface.h b/lib/bin/types/interface.h index 5074f3c..7244be8 100755 --- a/lib/bin/types/interface.h +++ b/lib/bin/types/interface.h @@ -23,7 +23,7 @@ namespace Gmeng { }; static Gmeng::uicolor_t conv_bgcolor(Gmeng::uicolor_t color) { - __functree_call__(__FILE__, __LINE__, Gmeng::conv_bgcolor); + __functree_call__(Gmeng::conv_bgcolor); if ((int) color < 9) return color; return (Gmeng::uicolor_t)( (short)color-8 ); }; diff --git a/lib/bin/utils/interface.cpp b/lib/bin/utils/interface.cpp index fc7fe55..b585f41 100755 --- a/lib/bin/utils/interface.cpp +++ b/lib/bin/utils/interface.cpp @@ -34,7 +34,7 @@ #endif /// quick little fix for the 5.7 ncurses version. USE G++ PARAMETER: `pkg-config --libs --cflags ncurses`!!!!!! std::string _gutil_get_terminal() { - __functree_call__(__FILE__, __LINE__, _gutil_get_terminal); + __functree_call__(_gutil_get_terminal); char* term_program = getenv("TERM_PROGRAM"); if (term_program != nullptr) { return std::string(term_program); @@ -51,7 +51,7 @@ std::string _gutil_get_terminal() { using namespace Gmeng; Renderer::drawpoint get_char_sizes() { - __functree_call__(__FILE__, __LINE__, get_char_sizes); + __functree_call__(get_char_sizes); struct winsize size; ioctl(STDOUT_FILENO, TIOCGWINSZ, &size); @@ -197,7 +197,7 @@ struct transportable_image { }; std::vector harvest_units(const std::vector& units, int original_width, const Renderer::viewpoint& view) { - //__functree_call__(__FILE__, __LINE__, harvest_units); + //__functree_call__(harvest_units); std::vector harvested_units; if (original_width == _vcreate_vp2d_deltax(view)+1) return units; int start_x = view.start.x; int start_y = view.start.y; @@ -216,7 +216,7 @@ std::vector harvest_units(const std::vector& units, int original_wid // dark magic fuckery std::vector scale_image(const std::vector& units, int original_width, int new_width, int new_height) { - //__functree_call__(__FILE__, __LINE__, scale_image); + //__functree_call__(scale_image); // If original width and new width are the same, return original units if (original_width == new_width) return units; int original_height = static_cast(units.size()) / original_width; @@ -273,7 +273,7 @@ namespace Gmeng { bool __any_modifier__ = false; int id = g_mkid(); static Renderer::viewpoint get_viewpoint(UI::Element& elem) { - //__functree_call__(__FILE__, __LINE__, Gmeng::UI::Element::__static__::get_viewpoint); + //__functree_call__(Gmeng::UI::Element::__static__::get_viewpoint); return { elem.position, { elem.position.x + (int)elem.width, elem.position.y + (int)elem.height } @@ -318,12 +318,12 @@ namespace Gmeng { std::size_t Screen::height = 0; bool Screen::initialized = false; void Screen::handle_resize(int sig) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::handle_resize); + __functree_call__(Gmeng::UI::Screen::handle_resize); Gmeng::UI::Screen::refresh_width_height(); } void Screen::refresh_width_height() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::refresh_width_height); + __functree_call__(Gmeng::UI::Screen::refresh_width_height); auto sizes = get_char_sizes(); wcharsizex = sizes.x; wcharsizey = sizes.y; @@ -337,7 +337,7 @@ namespace Gmeng { void Screen::initialize() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::initialize); + __functree_call__(Gmeng::UI::Screen::initialize); if (Gmeng::UI::Screen::initialized) { if (global.debugger) gm_slog(YELLOW, "DEBUGGER", "Screen cannot be initialized, a previous one already exists."); return; @@ -394,12 +394,12 @@ namespace Gmeng { } void Screen::destroy() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::destroy); + __functree_call__(Gmeng::UI::Screen::destroy); endwin(); Gmeng::UI::Screen::initialized = false; } void Screen::recv_mouse() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::recv_mouse); + __functree_call__(Gmeng::UI::Screen::recv_mouse); MEVENT event; bool mpos_show = false; while (true) { @@ -454,7 +454,7 @@ namespace Gmeng { }; Renderer::drawpoint Screen::get_current_pos() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::get_current_pos); + __functree_call__(Gmeng::UI::Screen::get_current_pos); int x, y; getyx(stdscr, y, x); std::cout << x << y; @@ -463,7 +463,7 @@ namespace Gmeng { } void Screen::report_mouse_pos(bool state) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::report_mouse_pos); + __functree_call__(Gmeng::UI::Screen::report_mouse_pos); this->should_report_mouse = state; std::thread t_mousepos = Gmeng::_ucreate_thread([&]() { while (this->should_report_mouse) { @@ -477,12 +477,12 @@ namespace Gmeng { } Renderer::drawpoint Screen::get_mouse_pointer_pos() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::get_mouse_pointer_pos); + __functree_call__(Gmeng::UI::Screen::get_mouse_pointer_pos); return this->mouse_pos; }; void Screen::set_cursor(Renderer::drawpoint dp) { - //__functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::set_cursor); + //__functree_call__(Gmeng::UI::Screen::set_cursor); move(dp.y, dp.x); this->current_cursor_pos = dp; }; @@ -539,7 +539,7 @@ namespace Gmeng { template bool Screen::add_element(std::unique_ptr __a) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::add_element); + __functree_call__(Gmeng::UI::Screen::add_element); // Implementation for creating a menu (subclass) // Background color, position, and buttons will be used here if (!this->_uhas_space(__a->position, { static_cast(__a->width), static_cast(__a->height) })) { @@ -563,10 +563,10 @@ namespace Gmeng { refresh(); }; - void Screen::__refresh() { __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::__refresh); refresh(); }; + void Screen::__refresh() { __functree_call__(Gmeng::UI::Screen::__refresh); refresh(); }; void Screen::check_hover_states(Renderer::drawpoint mpos) { - //__functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::check_hover_states); + //__functree_call__(Gmeng::UI::Screen::check_hover_states); for (auto& elem : this->elements) { if ( viewpoint_includes_dp(UI::Element::get_viewpoint(*elem), mpos) ) { @@ -577,7 +577,7 @@ namespace Gmeng { }; void Screen::handle_left_click(Renderer::drawpoint pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::__private__::handle_left_click); + __functree_call__(Gmeng::UI::Screen::__private__::handle_left_click); if (!this->handles_input && this->input_handler != NULL) { if (!viewpoint_includes_dp(UI::Element::get_viewpoint(*this->input_handler), pos)) { this->handles_input = true; @@ -600,7 +600,7 @@ namespace Gmeng { } void Screen::handle_right_click(Renderer::drawpoint pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::__private__::handle_right_click); + __functree_call__(Gmeng::UI::Screen::__private__::handle_right_click); for (auto& elem : this->elements) { bool v = viewpoint_includes_dp(Element::get_viewpoint(*elem), pos); if (v) { elem->context_menu(this); }; @@ -608,7 +608,7 @@ namespace Gmeng { }; void Screen::handle_scroll_up(Renderer::drawpoint pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::__private__::handle_scroll_up); + __functree_call__(Gmeng::UI::Screen::__private__::handle_scroll_up); for (auto& elem : this->elements) { bool v = viewpoint_includes_dp(Element::get_viewpoint(*elem), pos); if (v) { elem->mouse_scroll(this, MouseScroll::UP); break; }; @@ -616,7 +616,7 @@ namespace Gmeng { }; void Screen::handle_scroll_down(Renderer::drawpoint pos) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Screen::__private__::handle_scroll_down); + __functree_call__(Gmeng::UI::Screen::__private__::handle_scroll_down); for (auto& elem : this->elements) { bool v = viewpoint_includes_dp(Element::get_viewpoint(*elem), pos); if (v) { elem->mouse_scroll(this, MouseScroll::DOWN); break; }; @@ -632,7 +632,7 @@ namespace Gmeng { public: std::string data = ""; InfoBox(dp pos, func _func, std::size_t width, std::size_t height) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::InfoBox); + __functree_call__(Gmeng::UI::InfoBox); this->position = pos; this->width = width; this->height = height; @@ -682,7 +682,7 @@ namespace Gmeng { public: using UI::Element::Element; bool compact = false; Button(Renderer::drawpoint pos, std::string title, bool compact, short fg_color, short bg_color, std::function fn) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Button); + __functree_call__(Gmeng::UI::Button); this->position = pos; this->title = title; this->foreground_color = fg_color; this->background_color = bg_color; this->foreground_color_highlight = *(&this->foreground_color); @@ -697,7 +697,7 @@ namespace Gmeng { }; inline void text_recv(UI::Screen* instance, char ch) override {}; inline void click(UI::Screen* instance, UI::Interactions::MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Button::click); + __functree_call__(Gmeng::UI::Button::click); this->clicked = button == LEFT ? true : false; switch (button) { case LEFT: @@ -717,7 +717,7 @@ namespace Gmeng { }; inline void hover(UI::Screen* instance, bool state) override { - if (state && !this->hovered) __functree_call__(__FILE__, __LINE__, Gmeng::UI::Button::hover); + if (state && !this->hovered) __functree_call__(Gmeng::UI::Button::hover); this->hovered = state; if (this->clicked) return; // if clicked, ignore hover color. if (state) this->refresh(instance, HOVERED); @@ -765,7 +765,7 @@ namespace Gmeng { public: std::size_t width = 2; std::size_t height = 2; Gmeng::texture contents = Renderer::generate_empty_texture(this->width, this->height); - small_render_t(Gmeng::texture txtr) : width(txtr.width), height(txtr.height), contents(txtr) { __functree_call__(__FILE__, __LINE__, Gmeng::UI::small_render_t); }; + small_render_t(Gmeng::texture txtr) : width(txtr.width), height(txtr.height), contents(txtr) { __functree_call__(Gmeng::UI::small_render_t); }; small_render_t() = default; enum partial_type { END_OF_HLINE = 0, // end of line, skip to next line @@ -780,7 +780,7 @@ namespace Gmeng { struct Renderer::drawpoint image_size; }; std::vector get() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::small_render_t::get); + __functree_call__(Gmeng::UI::small_render_t::get); std::vector v_partials; for (int i = 0; i < this->contents.height; i++) { for (int j = 0; j < this->contents.width; j++) { @@ -795,7 +795,7 @@ namespace Gmeng { return v_partials; }; std::vector with_frame() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::small_render_t::with_frame); + __functree_call__(Gmeng::UI::small_render_t::with_frame); std::vector v_partials; repeat(this->width+2, [&]() { v_partials.push_back({ UCORNER }); }); v_partials.push_back({ END_OF_HLINE }); @@ -823,7 +823,7 @@ namespace Gmeng { std::size_t MAX_WIDTH; std::size_t MAX_HEIGHT; } max_values; static std::vector> do_render(std::vector image, max_values max = {0, 0}) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::small_render_t::__static__::do_render); + __functree_call__(Gmeng::UI::small_render_t::__static__::do_render); std::vector> render; std::vector p; int c; @@ -864,7 +864,7 @@ namespace Gmeng { operator int() const { return (int)this->enabled; }; operator std::string() const { return this->enabled ? "YES" : "NO"; }; Switch(dp pos, std::string name, uicolor_t textcolor = UI_WHITE, uicolor_t textcolor_highlight = UI_CYAN, bool enabled = false) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Switch); + __functree_call__(Gmeng::UI::Switch); this->position = pos; this->title = name + " "; this->hidden = false; @@ -877,11 +877,11 @@ namespace Gmeng { this->foreground_color = this->foreground_color_highlight = this->foreground_color_click = UI_BLACK; }; inline void hover(UI::Screen* instance, bool state) override { - if (state && !this->hovered) __functree_call__(__FILE__, __LINE__, Gmeng::UI::Switch::hover); + if (state && !this->hovered) __functree_call__(Gmeng::UI::Switch::hover); this->hovered = state; this->refresh(instance, this->hovered ? HOVERED : NONE); }; inline void click(UI::Screen* instance, MouseButton) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Switch::click); + __functree_call__(Gmeng::UI::Switch::click); this->enabled = !this->enabled; this->refresh(instance, HOVERED); this->change_func(this); @@ -912,7 +912,7 @@ namespace Gmeng { using UI::Element::Element; small_render_t render; Hoverable(dp pos,std::string title, small_render_t render, uicolor_t color_base, uicolor_t color_hovered) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Hoverable); + __functree_call__(Gmeng::UI::Hoverable); this->render = render; this->position = pos; this->hidden = false; @@ -928,7 +928,7 @@ namespace Gmeng { }; Hoverable() = default; inline void click(UI::Screen* instance, Interactions::MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Hoverable::click); + __functree_call__(Gmeng::UI::Hoverable::click); /// NO FUNCTIONALITY; }; inline void text_recv(UI::Screen* instance, char ch) override {}; @@ -937,7 +937,7 @@ namespace Gmeng { this->hovered = state; this->refresh(instance, NONE); } else { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Hoverable::hover); + __functree_call__(Gmeng::UI::Hoverable::hover); this->hovered = state; this->refresh(instance, HOVERED); }; @@ -1042,7 +1042,7 @@ namespace Gmeng { public: std::string* ptr; bool locked = false; TextController(dp pos, std::string* _string, std::size_t max_width = -1, uicolor_t color = UI_WHITE, uicolor_t highlight_color = UI_BLUE) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::TextController); + __functree_call__(Gmeng::UI::TextController); this->hidden = false; this->width = max_width == -1 ? _string->length() : max_width; this->clicked = false; @@ -1052,7 +1052,7 @@ namespace Gmeng { }; inline void hover(UI::Screen*, bool) override {}; inline void click(UI::Screen* instance, MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::TextController::click); + __functree_call__(Gmeng::UI::TextController::click); if (this->clicked || this->locked) return; if (instance->input_handler != NULL) { instance->input_handler->clicked = false; @@ -1122,7 +1122,7 @@ namespace Gmeng { public: int* ptr = nullptr; type_t type; bool locked = false; NumButton(dp pos, int* ptr, type_t type, uicolor_t color = UI_CYAN, uicolor_t color_highlight= UI_WHITE) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::NumButton); + __functree_call__(Gmeng::UI::NumButton); this->hidden = false; this->width = this->height = 1; this->ptr = ptr; @@ -1142,7 +1142,7 @@ namespace Gmeng { public: direction_t direction = LEFT; func click_func; NavButton(dp pos, direction_t direction, uicolor_t color, uicolor_t color_highlight, uicolor_t color_click, func click_func) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::NavButton); + __functree_call__(Gmeng::UI::NavButton); this->position = pos; this->width = 1; this->height = 1; @@ -1155,12 +1155,12 @@ namespace Gmeng { }; inline void text_recv(UI::Screen*, char) override {}; inline void hover(UI::Screen* instance, bool state) override { - if (state && !this->hovered) __functree_call__(__FILE__, __LINE__, Gmeng::UI::NavButton::hover); + if (state && !this->hovered) __functree_call__(Gmeng::UI::NavButton::hover); this->hovered = state; this->refresh(instance, HOVERED); }; inline void click(UI::Screen* instance, MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::NavButton::click); + __functree_call__(Gmeng::UI::NavButton::click); instance->modify_scr(v_str(g_mkid()) + "YO VAR", UI_WHITE, UI_GREEN, false, {0,LINES-5}); this->click_func(this); }; @@ -1179,18 +1179,18 @@ namespace Gmeng { UI::NavButton nav_l; UI::NavButton nav_r; public: void hndl_l(NavButton*) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::SettingsMenu::page_left); + __functree_call__(Gmeng::UI::SettingsMenu::page_left); if (this->mpage-1 < 0) { this->mpage = this->self_elements.size()-1; return; }; this->mpage--; }; void hndl_r(NavButton*) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::SettingsMenu::page_right); + __functree_call__(Gmeng::UI::SettingsMenu::page_right); if (this->mpage+1 >= this->self_elements.size()) { this->mpage = 0; return; }; this->mpage++; }; int mpage = 0; int vid = g_mkid(); SettingsMenu(dp pos, std::string title, std::size_t width, std::size_t height) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::SettingsMenu); + __functree_call__(Gmeng::UI::SettingsMenu); this->position = pos; this->title = title; this->width = width; @@ -1202,17 +1202,17 @@ namespace Gmeng { nav_l = navbutton_l; nav_r = navbutton_r; }; inline void add_element(int page, std::unique_ptr element) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::SettingsMenu::add_element); + __functree_call__(Gmeng::UI::SettingsMenu::add_element); if (page >= this->self_elements.size()) this->self_elements.push_back({}); this->self_elements[page].push_back(std::move(element)); }; inline void hover(UI::Screen* instance, bool state) override { - if (state && !this->hovered) __functree_call__(__FILE__, __LINE__, Gmeng::UI::SettingsMenu::hover); + if (state && !this->hovered) __functree_call__(Gmeng::UI::SettingsMenu::hover); this->hovered = state; this->refresh(instance, HOVERED); }; inline void click(UI::Screen* instance, MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::SettingsMenu::click); + __functree_call__(Gmeng::UI::SettingsMenu::click); this->refresh(instance, CLICKED); }; inline void refresh(UI::Screen* instance, ButtonInteraction type) override { @@ -1286,7 +1286,7 @@ namespace Gmeng { bool dragging; bool with_frame = false; vp viewspace = { {0,0}, {0,0} }; bool show_info = true; draginfo_t drag_info; small_render_t image; dp camera = { 0,0 }; bool allow_zoom = true; bool follow_cursor = false; Image(dp pos, small_render_t _image, bool with_frame = false, uicolor_t frame_color = UI_CYAN, uicolor_t frame_color_click = UI_BLUE) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Image); + __functree_call__(Gmeng::UI::Image); this->position = pos; this->hidden = this->clicked = false; this->image = _image; @@ -1331,7 +1331,7 @@ namespace Gmeng { this->refresh(instance, CONTEXT_MENU); }; inline void hover(UI::Screen* instance, bool state) override { - if (state && !this->hovered) __functree_call__(__FILE__, __LINE__, Gmeng::UI::Image::hover); + if (state && !this->hovered) __functree_call__(Gmeng::UI::Image::hover); this->hovered = state; if (!state) { this->clicked = false; this->hovered = false; return; }; if (state && this->clicked) { // clicked AND hovering @@ -1351,7 +1351,7 @@ namespace Gmeng { }; }; inline void click(UI::Screen* instance, MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Image::click); + __functree_call__(Gmeng::UI::Image::click); if (this->jabelahe) return this->clicked = true, this->refresh(instance, CONTEXT_MENU); this->clicked = !this->clicked; /// switch the status, only needed here because other elements handle click() differently if (!this->clicked) { //previously clicked @@ -1432,7 +1432,7 @@ namespace Gmeng { }; }; inline void mouse_scroll(UI::Screen* instance, MouseScroll type) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Image::mouse_scroll); + __functree_call__(Gmeng::UI::Image::mouse_scroll); if (!this->allow_zoom) return; this->clicked = true; /// for increasing and decreasing viewpoint @@ -1451,7 +1451,7 @@ namespace Gmeng { }; inline void text_recv(UI::Screen* instance, char ch) override {}; inline void context_menu(UI::Screen* instance) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::Image::context_menu); + __functree_call__(Gmeng::UI::Image::context_menu); this->clicked = true; if (this->active_context) { this->jabelahe = true; @@ -1504,7 +1504,7 @@ namespace Gmeng { public: const std::string* input = &_text; bool compact = false; LineTextBox(dp pos, std::size_t max_size, uicolor_t color, uicolor_t highlighted_color, bool compact, tfunc enter_func) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::LineTextBox); + __functree_call__(Gmeng::UI::LineTextBox); this->position = pos; this->hidden = false; this->width = max_size; @@ -1520,7 +1520,7 @@ namespace Gmeng { /// NO FUNCTIONALITY; }; inline void click(UI::Screen* instance, Interactions::MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::LineTextBox::click); + __functree_call__(Gmeng::UI::LineTextBox::click); if (this->clicked) return; if (instance->input_handler != NULL) { instance->input_handler->clicked = false; @@ -1589,7 +1589,7 @@ namespace Gmeng { using UI::Element::Element; bool extended = false; // show contents, or title of the menu only. ActionMenu(Renderer::drawpoint pos, std::string title, std::size_t width, std::size_t height, uicolor_t color, uicolor_t highlight_color) : Element() { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::ActionMenu); + __functree_call__(Gmeng::UI::ActionMenu); this->position = pos; this->hidden = false; this->title = title; @@ -1602,7 +1602,7 @@ namespace Gmeng { }; inline void text_recv(UI::Screen* instance, char ch) override {}; inline void click(UI::Screen* instance, UI::Interactions::MouseButton button) override { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::ActionMenu::click); + __functree_call__(Gmeng::UI::ActionMenu::click); this->clicked = button == LEFT ? true : false; this->refresh(instance, CLICKED); instance->__refresh(); @@ -1612,7 +1612,7 @@ namespace Gmeng { }; inline void hover(UI::Screen* instance, bool state) override { - if (state && !this->hovered) __functree_call__(__FILE__, __LINE__, Gmeng::UI::ActionMenu::hover); + if (state && !this->hovered) __functree_call__(Gmeng::UI::ActionMenu::hover); this->hovered = state; //if (this->clicked) return; // click does not affect ActionMenu elements. if (state) this->refresh(instance, HOVERED); @@ -1621,7 +1621,7 @@ namespace Gmeng { template inline void add_member(std::unique_ptr elem) { - __functree_call__(__FILE__, __LINE__, Gmeng::UI::ActionMenu::add_member); + __functree_call__(Gmeng::UI::ActionMenu::add_member); this->members.push_back(std::move(elem)); }; diff --git a/lib/bin/utils/network.cpp b/lib/bin/utils/network.cpp index 80c7d28..ca5e245 100755 --- a/lib/bin/utils/network.cpp +++ b/lib/bin/utils/network.cpp @@ -1,6 +1,5 @@ #pragma once -#include #include #if _WIN32 == false #include @@ -49,7 +48,7 @@ size_t write_callback(char* ptr, size_t size, size_t nmemb, std::string* data) { // Function to send an HTTP GET request using libcurl response_t send_request(const std::string& url, const std::string& authorization = "NONE") { #if _WIN32 == false - __functree_call__(__FILE__, __LINE__, send_request); + __functree_call__(send_request); CURL* curl; CURLcode res; struct response_t response; @@ -104,7 +103,7 @@ response_t send_request(const std::string& url, const std::string& authorization /// OVERLOAD for post requests response_t send_request(const std::string& url, const std::string& authorization = "NONE", const std::string& method = "GET", const std::string& body = "") { #if _WIN32 == false - __functree_call__(__FILE__, __LINE__, Gmeng::send_request::overload::POST_BODY); + __functree_call__(Gmeng::send_request::overload::POST_BODY); CURL* curl; CURLcode res; struct response_t response; @@ -189,12 +188,12 @@ struct response { class gmserver_t { public: gmserver_t(int port) : port(port), server_fd(-1), running(false) { - __functree_call__(__FILE__, __LINE__, gmserver_t::gmserver_t); + __functree_call__(gmserver_t::gmserver_t); }; void run() { #if _WIN32 == false - __functree_call__(__FILE__, __LINE__, gmserver_t::run); + __functree_call__(gmserver_t::run); // Create socket int server_fd = socket(AF_INET, SOCK_STREAM, 0); if (server_fd == -1) { @@ -245,7 +244,7 @@ class gmserver_t { } void create_path(path_type_t type, std::string path, std::function func) { - __functree_call__(__FILE__, __LINE__, gmserver_t::create_path); + __functree_call__(gmserver_t::create_path); if (type == path_type_t::GET) { get_paths[path] = func; } else if (type == path_type_t::POST) { @@ -254,7 +253,7 @@ class gmserver_t { } void stop() { - __functree_call__(__FILE__, __LINE__, gmserver_t::stop); + __functree_call__(gmserver_t::stop); running = false; if (server_fd != -1) { close(server_fd); @@ -265,7 +264,7 @@ class gmserver_t { private: void handle_request(int client_fd) { #if _WIN32 == false - __functree_call__(__FILE__, __LINE__, gmserver_t::__private__::handle_request); + __functree_call__(gmserver_t::__private__::handle_request); const int max_length = 1024; char buffer[max_length] = {0}; int valread = read(client_fd, buffer, max_length - 1); @@ -297,7 +296,7 @@ class gmserver_t { } request parse_request(const char* buffer) { - __functree_call__(__FILE__, __LINE__, gmserver_t::__private__::parse_request); + __functree_call__(gmserver_t::__private__::parse_request); #if _WIN32 == false request req; @@ -330,7 +329,7 @@ class gmserver_t { void send_response(int client_fd, response& res) { #if _WIN32 == false - __functree_call__(__FILE__, __LINE__, gmserver_t::__private__::send_response); + __functree_call__(gmserver_t::__private__::send_response); std::string response_str = "HTTP/1.1 " + std::to_string(res.status_code) + " OK\r\n"; response_str += "Content-Length: " + std::to_string(res.body.size()) + "\r\n"; response_str += "\r\n"; // End of headers @@ -353,7 +352,7 @@ struct GM_SVHOLD { }; std::map _vget_sv_data(const std::string& input) { - __functree_call__(__FILE__, __LINE__, _vget_sv_data); + __functree_call__(_vget_sv_data); std::map result; std::istringstream iss(input); @@ -441,12 +440,12 @@ std::map _vget_sv_data(const std::string& input) { namespace Gmeng::Networking { namespace conversion { Renderer::drawpoint c_drawpoint(std::string val) { - //__functree_call__(__FILE__, __LINE__, Gmeng::Networking::conversion::c_drawpoint); + //__functree_call__(Gmeng::Networking::conversion::c_drawpoint); auto v = g_splitStr(val, ","); return { std::stoi(v[0]), std::stoi(v[1]) }; }; Renderer::viewpoint c_viewpoint(std::string val) { - //__functree_call__(__FILE__, __LINE__, Gmeng::Networking::conversion::c_viewpoint); + //__functree_call__(Gmeng::Networking::conversion::c_viewpoint); auto v = g_splitStr(val, "|"); return { c_drawpoint(v[0]), c_drawpoint(v[1]) }; }; diff --git a/lib/bin/utils/script.cpp b/lib/bin/utils/script.cpp index 69072b5..84ae699 100644 --- a/lib/bin/utils/script.cpp +++ b/lib/bin/utils/script.cpp @@ -19,6 +19,45 @@ namespace Gmeng::script_parser_util { script_file gmng_scrinternal = { .filename = "gmeng:internals", .current_line=0 }; script_file gmng_scrrepl = { .filename = "script:REPL", .current_line=0 }; + + namespace builtin { + const object_class number { + .name = "number", + .hash = v_str(g_mkid()), + .methods = map { + { "to_string", hashed_function { + .parameters = { }, + .hashed_id = "to_string", + .parent = nullptr, + .name = "to_string" + } }, + } + }; + const object_class string = { + .name = "string", + .hash = v_str(g_mkid()), + .methods = map { + { "empty", hashed_function { + .parameters = { function_parameter { .name="slice_until" } }, + .hashed_id = v_str(g_mkid()) + "_empty", + .parent = nullptr, + .name = "empty", + } }, + }, + .variables = map { + { "content", base_class { + .name = "$!_BASE_STRING_DONT_USE", + .hashed_id = builtin::string.hash + "_content", + } } + } + }; + + void make_string_type(object_class* obj) { + obj->name = string.name; + + }; + }; + class Scope { public: map classes; @@ -49,7 +88,10 @@ namespace Gmeng::script_parser_util { string v_data = trim(data); if (v_data.starts_with("\"")) { if (!v_data.ends_with("\"")) throw script_syntax_exception("string not closed, missing '\"' character at the end of string"); - // make it a string + obj = builtin::string; + } else if (v_data.starts_with("{")) { + if (!v_data.ends_with("}")) throw script_syntax_exception("variable call must follow {var_name} syntax"); + }; return obj; };