diff --git a/.efrocachemap b/.efrocachemap index 828baec0..5d2a87ef 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3932,24 +3932,24 @@ "assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450", "assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e", "assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f", - "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b8/eb/280d15f31dcbf3830e6730f9c4be", - "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b9/b6/7a4d577d71bbce1d0a42d0fa8f0e", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/64/46/406adb6907d84ab1fbce0238b2f5", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e2/4a/c3ab9dfa2eb438e2270c867a0a32", - "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/75/7d/64dee3a33a9b9df3213789d031ca", - "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/24/4e/0de9a93c5abf5f91efa893c0f657", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ba/e3/7c54b7b121a73945a334acf2a778", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8b/80/59caf9ded1ac2d852f57489049c2", - "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/72/b8/b24e6069245d0c3e7c1f049e1386", - "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/79/62/ad715d74684b940ce846e7e58d8c", - "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/23/41/552a8ffeef5bc10bd0af04c10565", - "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/bf/aa/1dcfd60aeaec8d42f06adac2156b", - "build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a5/db/bcc616e930ef02de5f086cc819a1", - "build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7f/3b/af2f0efe5996de7cfc31a112c514", - "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8f/22/e3bb8333289707bba87db62cff1b", - "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/93/88/21434630ae75dfd78e8f1225beaf", - "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3c/2c/317eabff84c4b1819aeb78dc984a", - "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/12/b2/e0851ca040064fb5c4d953003a10", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/15/88/cfef2301d0ff44a26c411ed11c39", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b2/7a/5c80fa986d5da7908d7c3c31c61f" + "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e9/48/88db5152fcd7ff38363ce35e2b5c", + "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/83/9a/4d1f2cd9a7940d99e24d8f0719f4", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a3/58/4be1efd666668e078a7a9ca36928", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a5/5d/3ba7496fb214568d79aa36bc0fa2", + "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/85/4c/8ad6020c7b442306b5729ab7af5c", + "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/bd/a6/ecf53cf19d15644fe1b072dff936", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a0/f5/a2688f382c3dc2b3763f83a40b72", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c5/82/7313732699d4e1d86fa0c153c046", + "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/63/42/fc3ff5ea8c9e3b30788ae2adcb89", + "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/5a/b9/94c0e471b1cda37c5e8e8f92192b", + "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/d5/e8/df64479789b87fa7472162476d52", + "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/12/a1/06e3f98c545918e81520cd1154eb", + "build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2c/b1/c6394b207908dcf10702963d074b", + "build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/68/c6/61c27c594a5b67abb7cd0a2a0f51", + "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/96/61/51cb6fd93d32693f297f51bca1e5", + "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/96/32edc65468aa4546f245192238c3", + "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e2/88/4c3188f4bfa72c23902b3e4c1e56", + "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bb/5f/82a7d3e039af6ad89cf42231b8b7", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/09/38/1e6625b6e8710aba4c6d1cc18e94", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4d/ea/ebfd89fab46518a4c3bdf5e57638" } \ No newline at end of file diff --git a/docs/ba_module.md b/docs/ba_module.md index 1735a245..fb9cd596 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2020-10-13 for Ballistica version 1.5.26 build 20202

+

last updated on 2020-10-13 for Ballistica version 1.5.26 build 20205

This page documents the Python classes and functions in the 'ba' module, which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please let me know. Happy modding!


diff --git a/src/ballistica/app/app_config.cc b/src/ballistica/app/app_config.cc index c7063aa8..f5b60752 100644 --- a/src/ballistica/app/app_config.cc +++ b/src/ballistica/app/app_config.cc @@ -185,8 +185,10 @@ void AppConfig::SetupEntries() { bool_entries_[BoolID::kFullscreen] = BoolEntry("Fullscreen", false); bool_entries_[BoolID::kKickIdlePlayers] = BoolEntry("Kick Idle Players", false); + + // (default to internal keyboard on iircade; not elsewhere) bool_entries_[BoolID::kAlwaysUseInternalKeyboard] = - BoolEntry("Always Use Internal Keyboard", false); + BoolEntry("Always Use Internal Keyboard", g_buildconfig.iircade_build()); bool_entries_[BoolID::kShowFPS] = BoolEntry("Show FPS", false); bool_entries_[BoolID::kTVBorder] = BoolEntry("TV Border", g_platform->IsRunningOnTV()); diff --git a/src/ballistica/app/app_globals.h b/src/ballistica/app/app_globals.h index 67b91272..5a7e6ec5 100644 --- a/src/ballistica/app/app_globals.h +++ b/src/ballistica/app/app_globals.h @@ -35,7 +35,6 @@ class AppGlobals { std::map node_types_by_id; std::map node_message_types; std::vector node_message_formats; - std::string calced_blessing_hash; bool have_mods{}; bool replay_open{}; std::vector pausable_threads; diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index ae0fbb3d..5172b10b 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -29,7 +29,7 @@ namespace ballistica { // These are set automatically via script; don't change here. -const int kAppBuildNumber = 20203; +const int kAppBuildNumber = 20207; const char* kAppVersion = "1.5.26"; // Our standalone globals. diff --git a/src/ballistica/ballistica.h b/src/ballistica/ballistica.h index e283af2a..09c9ba8a 100644 --- a/src/ballistica/ballistica.h +++ b/src/ballistica/ballistica.h @@ -178,6 +178,9 @@ auto AppInternalPushPurchaseTransactionCall(const std::string& item, bool user_initiated) -> void; auto AppInternalGetPublicAccountID() -> std::string; auto AppInternalOnGameThreadPause() -> void; +auto AppInternalDirectSendLogs(const std::string& prefix, + const std::string& suffix, bool instant, + int* result = nullptr) -> void; /// Does it appear that we are a blessed build with no known user-modifications? auto IsUnmodifiedBlessedBuild() -> bool; diff --git a/src/ballistica/core/fatal_error.cc b/src/ballistica/core/fatal_error.cc index 30759cce..e59aad77 100644 --- a/src/ballistica/core/fatal_error.cc +++ b/src/ballistica/core/fatal_error.cc @@ -88,7 +88,7 @@ auto FatalError::ReportFatalError(const std::string& message, if (g_app_globals == nullptr) { suffix = logmsg; } - Logging::DirectSendLogs(prefix, suffix, true, &result); + AppInternalDirectSendLogs(prefix, suffix, true, &result); // If we're able to show a fatal-error dialog synchronously, do so. if (g_platform && g_platform->CanShowBlockingFatalErrorDialog()) { diff --git a/src/ballistica/core/logging.cc b/src/ballistica/core/logging.cc index 6831ecba..0484b9d0 100644 --- a/src/ballistica/core/logging.cc +++ b/src/ballistica/core/logging.cc @@ -104,111 +104,10 @@ void Logging::Log(const std::string& msg, bool to_stdout, bool to_server) { if (g_app_globals == nullptr) { logsuffix = msg; } - DirectSendLogs(logprefix, logsuffix, false); + AppInternalDirectSendLogs(logprefix, logsuffix, false); } } } } -auto Logging::DirectSendLogs(const std::string& prefix, - const std::string& suffix, bool instant, - int* result) -> void { - // Use a rough mechanism to restrict log uploads to 1 send per second. - static time_t last_non_instant_send_time{-1}; - if (!instant) { - auto curtime = Platform::GetCurrentSeconds(); - if (curtime == last_non_instant_send_time) { - return; - } - last_non_instant_send_time = curtime; - } - - std::thread t([prefix, suffix, instant, result]() { - // For non-instant sends, sleep for 2 seconds before sending logs; - // this should capture the just-added log as well as any more that - // got added in the subsequent second when we were not launching new - // send threads. - if (!instant) { - Platform::SleepMS(2000); - } - std::string log; - - // Send our blessing hash only after we've calculated it; don't use our - // internal one. This means that we'll get false-negatives on whether - // direct-sent logs are blessed, but I think that's better than false - // positives. - std::string calced_blessing_hash; - if (g_app_globals) { - std::lock_guard lock(g_app_globals->log_mutex); - log = g_app_globals->log; - calced_blessing_hash = g_app_globals->calced_blessing_hash; - } else { - log = "(g_app_globals not yet inited; no global log available)"; - } - if (!prefix.empty()) { - log = prefix + "\n" + log; - } - if (!suffix.empty()) { - log = log + "\n" + suffix; - } - - // Also send our blessing-calculation state; we may want to distinguish - // between blessing not being calced yet and being confirmed as un-blessed. - // FIXME: should probably do this in python layer log submits too. - std::string bless_calc_state; - if (!AppInternalHasBlessingHash()) { - bless_calc_state = "nointhash"; - } else if (g_app_globals == nullptr) { - bless_calc_state = "noglobs"; - } else if (g_app_globals->calced_blessing_hash.empty()) { - // Mention we're calculating, but also mention if it is likely that - // the user is mucking with stuff. - if (g_app_globals->user_ran_commands - || g_platform->using_custom_app_python_dir()) { - bless_calc_state = "calcing_likely_modded"; - } else { - bless_calc_state = "calcing_not_modded"; - } - } else { - bless_calc_state = "done"; - } - - std::string path{"/bsLog"}; - std::map params{ - {"log", log}, - {"time", "-1"}, - {"userAgentString", g_app_globals ? g_app_globals->user_agent_string - : "(no g_app_globals)"}, - {"newsShow", calced_blessing_hash.c_str()}, - {"bcs", bless_calc_state.c_str()}, - {"build", std::to_string(kAppBuildNumber)}}; - try { - Networking::MasterServerPost(path, params); - if (result) { - *result = 1; // SUCCESS! - } - } catch (const std::exception&) { - // Try our fallback master-server address if that didn't work. - try { - params["log"] = prefix + "(FALLBACK-ADDR):\n" + log; - Networking::MasterServerPost(path, params, true); - if (result) { - *result = 1; // SUCCESS! - } - } catch (const std::exception& exc) { - // Well, we tried; make a note to platform log if available - // that we failed. - if (g_platform != nullptr) { - g_platform->HandleLog(std::string("Early log-to-server failed: ") - + exc.what()); - } - if (result) { - *result = -1; // FAIL!! - } - } - } - }); - t.detach(); -} - } // namespace ballistica diff --git a/src/ballistica/core/logging.h b/src/ballistica/core/logging.h index bd2ab768..66d41ed9 100644 --- a/src/ballistica/core/logging.h +++ b/src/ballistica/core/logging.h @@ -22,12 +22,6 @@ class Logging { /// on the platform. static auto Log(const std::string& msg, bool to_stdout = true, bool to_server = true) -> void; - - /// Ship logs to the master-server in a bg thread. If result is passed, - /// it will be set to 1 on success and -1 on error. - static auto DirectSendLogs(const std::string& prefix, - const std::string& suffix, bool instant, - int* result = nullptr) -> void; }; } // namespace ballistica diff --git a/src/ballistica/dynamics/collision_cache.cc b/src/ballistica/dynamics/collision_cache.cc index 63ab02b3..c8ba4e78 100644 --- a/src/ballistica/dynamics/collision_cache.cc +++ b/src/ballistica/dynamics/collision_cache.cc @@ -12,19 +12,7 @@ namespace ballistica { -CollisionCache::CollisionCache() - : dirty_(true), - shadow_ray_(nullptr), - x_min_(-1), - x_max_(1), - y_min_(-1), - y_max_(1), - z_min_(-1), - z_max_(1) { - grid_width_ = 1; - grid_height_ = 1; - test_box_ = dCreateBox(nullptr, 1, 1, 1); -} +CollisionCache::CollisionCache() { test_box_ = dCreateBox(nullptr, 1, 1, 1); } CollisionCache::~CollisionCache() { if (shadow_ray_) { diff --git a/src/ballistica/dynamics/collision_cache.h b/src/ballistica/dynamics/collision_cache.h index dffb3c5c..55d6d1de 100644 --- a/src/ballistica/dynamics/collision_cache.h +++ b/src/ballistica/dynamics/collision_cache.h @@ -38,19 +38,19 @@ class CollisionCache { }; std::vector cells_; std::vector glow_; - bool dirty_; - dGeomID shadow_ray_; - dGeomID test_box_; - int grid_width_; - int grid_height_; + bool dirty_{true}; + dGeomID shadow_ray_{}; + dGeomID test_box_{}; + int grid_width_{1}; + int grid_height_{1}; float cell_width_{}; float cell_height_{}; - float x_min_; - float x_max_; - float y_min_; - float y_max_; - float z_min_; - float z_max_; + float x_min_{-1.0f}; + float x_max_{1.0f}; + float y_min_{-1.0f}; + float y_max_{1.0f}; + float z_min_{-1.0f}; + float z_max_{1.0f}; }; } // namespace ballistica diff --git a/src/ballistica/game/account.h b/src/ballistica/game/account.h index 79dc2f8b..103ded74 100644 --- a/src/ballistica/game/account.h +++ b/src/ballistica/game/account.h @@ -32,14 +32,15 @@ class Account { // An extra value included when passing our account info to the server // ..(can be used for platform-specific install-signature stuff, etc). - void SetAccountExtra(const std::string& extra); - void SetAccountExtra2(const std::string& extra); - void SetAccountToken(const std::string& account_id, const std::string& token); + auto SetAccountExtra(const std::string& extra) -> void; + auto SetAccountExtra2(const std::string& extra) -> void; + auto SetAccountToken(const std::string& account_id, const std::string& token) + -> void; - void SetAccount(AccountType account_type, AccountState account_state, - const std::string& name, const std::string& id); + auto SetAccount(AccountType account_type, AccountState account_state, + const std::string& name, const std::string& id) -> void; - void SetProductsPurchased(const std::vector& products); + auto SetProductsPurchased(const std::vector& products) -> void; auto GetProductPurchased(const std::string& product) -> bool; auto product_purchases_state() const -> int { return product_purchases_state_; diff --git a/src/ballistica/game/client_controller_interface.h b/src/ballistica/game/client_controller_interface.h index 19bc0d7d..0b686329 100644 --- a/src/ballistica/game/client_controller_interface.h +++ b/src/ballistica/game/client_controller_interface.h @@ -7,14 +7,14 @@ namespace ballistica { -// An interface for something that can control client-connections. -// (such as an output-stream or a replay-client-session) -// objects can register themselves as the current client-connection-controller -// and then they will get control of all existing (and forthcoming) clients +/// An interface for something that can control client-connections +/// (such as an output-stream or a replay-client-session). +/// Objects can register themselves as the current client-connection-controller +/// and then they will get control of all existing (and forthcoming) clients. class ClientControllerInterface { public: - virtual void OnClientConnected(ConnectionToClient* c) = 0; - virtual void OnClientDisconnected(ConnectionToClient* c) = 0; + virtual auto OnClientConnected(ConnectionToClient* c) -> void = 0; + virtual auto OnClientDisconnected(ConnectionToClient* c) -> void = 0; }; } // namespace ballistica diff --git a/src/ballistica/game/host_activity.h b/src/ballistica/game/host_activity.h index 36820f3c..8983dcf1 100644 --- a/src/ballistica/game/host_activity.h +++ b/src/ballistica/game/host_activity.h @@ -18,13 +18,13 @@ class HostActivity : public ContextTarget { explicit HostActivity(HostSession* host_session); ~HostActivity() override; auto GetHostSession() -> HostSession* override; - void SetGameSpeed(float speed); + auto SetGameSpeed(float speed) -> void; auto game_speed() const -> float { return game_speed_; } // ContextTarget time/timer support. auto NewTimer(TimeType timetype, TimerMedium length, bool repeat, const Object::Ref& runnable) -> int override; - void DeleteTimer(TimeType timetype, int timer_id) override; + auto DeleteTimer(TimeType timetype, int timer_id) -> void override; auto GetTime(TimeType timetype) -> millisecs_t override; /// Return a borrowed ref to the python activity; Py_None if nonexistent. @@ -45,43 +45,49 @@ class HostActivity : public ContextTarget { assert(scene_.exists()); return scene_.get(); } - void start(); + auto start() -> void; // A utility function; faster than dynamic_cast. auto GetAsHostActivity() -> HostActivity* override; auto GetMutableScene() -> Scene* override; - void Draw(FrameDef* frame_def); - void ScreenSizeChanged(); - void LanguageChanged(); - void DebugSpeedMultChanged(); - void GraphicsQualityChanged(GraphicsQuality q); + auto Draw(FrameDef* frame_def) -> void; + auto ScreenSizeChanged() -> void; + auto LanguageChanged() -> void; + auto DebugSpeedMultChanged() -> void; + auto GraphicsQualityChanged(GraphicsQuality q) -> void; // Used to register python calls created in this context so we can make sure // they got properly cleaned up. - void RegisterCall(PythonContextCall* call); + auto RegisterCall(PythonContextCall* call) -> void; auto shutting_down() const -> bool { return shutting_down_; } auto globals_node() const -> GlobalsNode*; - void SetPaused(bool val); + auto SetPaused(bool val) -> void; auto paused() const -> bool { return paused_; } - void set_allow_kick_idle_players(bool val) { allow_kick_idle_players_ = val; } + auto set_allow_kick_idle_players(bool val) -> void { + allow_kick_idle_players_ = val; + } auto getAllowKickIdlePlayers() const -> bool { return allow_kick_idle_players_; } auto GetGameStream() const -> GameStream*; - void DumpFullState(GameStream* out); + auto DumpFullState(GameStream* out) -> void; + auto SetGlobalsNode(GlobalsNode* node) -> void; + auto SetIsForeground(bool val) -> void; + auto RegisterPyActivity(PyObject* pyActivity) -> void; private: + auto HandleOutOfBoundsNodes() -> void; auto NewSimTimer(millisecs_t length, bool repeat, const Object::Ref& runnable) -> int; - void DeleteSimTimer(int timer_id); + auto DeleteSimTimer(int timer_id) -> void; auto NewBaseTimer(millisecs_t length, bool repeat, const Object::Ref& runnable) -> int; - void DeleteBaseTimer(int timer_id); - void UpdateStepTimerLength(); + auto DeleteBaseTimer(int timer_id) -> void; + auto UpdateStepTimerLength() -> void; + auto StepScene() -> void; + Object::WeakRef globals_node_; - void SetIsForeground(bool val); bool allow_kick_idle_players_ = false; - void StepScene(); Timer* step_scene_timer_ = nullptr; std::map > textures_; std::map > sounds_; @@ -98,21 +104,17 @@ class HostActivity : public ContextTarget { millisecs_t next_prune_time_ = 0; bool _started = false; int out_of_bounds_in_a_row_ = 0; - void HandleOutOfBoundsNodes(); bool paused_ = false; float game_speed_ = 0.0f; millisecs_t base_time_ = 0; Object::Ref scene_; Object::WeakRef host_session_; PythonRef py_activity_weak_ref_; - void RegisterPyActivity(PyObject* pyActivity); - // Want this at the bottom so it dies first since this may cause python stuff - // to access us. + // Want this at the bottom so it dies first since this may cause Python + // stuff to access us. TimerList sim_timers_; TimerList base_timers_; - friend class HostSession; - friend class GlobalsNode; }; } // namespace ballistica diff --git a/src/ballistica/game/player.h b/src/ballistica/game/player.h index 00b33c4c..c2594bfe 100644 --- a/src/ballistica/game/player.h +++ b/src/ballistica/game/player.h @@ -24,15 +24,15 @@ class Player : public Object { Player(int id, HostSession* host_session); ~Player() override; - void SetInputDevice(InputDevice* input_device); - void AssignInputCall(InputType type, PyObject* call_obj); - void InputCommand(InputType type, float value = 0.0f); + auto SetInputDevice(InputDevice* input_device) -> void; + auto AssignInputCall(InputType type, PyObject* call_obj) -> void; + auto InputCommand(InputType type, float value = 0.0f) -> void; - void SetName(const std::string& name, const std::string& full_name, - bool real); + auto SetName(const std::string& name, const std::string& full_name, bool real) + -> void; auto GetName(bool full = false, bool icon = true) const -> std::string; auto name_is_real() const -> bool { return name_is_real_; } - void ResetInput(); + auto ResetInput() -> void; auto GetHostSession() const -> HostSession*; auto id() const -> int { return id_; } @@ -41,7 +41,7 @@ class Player : public Object { auto BorrowPyRef() -> PyObject* { return GetPyRef(false); } // Set the player node for the current activity. - void set_node(Node* node) { + auto set_node(Node* node) -> void { assert(InGameThread()); node_ = node; } @@ -50,43 +50,43 @@ class Player : public Object { return node_.get(); } - void SetPyTeam(PyObject* team); + auto SetPyTeam(PyObject* team) -> void; auto GetPyTeam() -> PyObject*; // Returns a borrowed ref. - void SetPyCharacter(PyObject* team); + auto SetPyCharacter(PyObject* team) -> void; auto GetPyCharacter() -> PyObject*; // Returns a borrowed ref. - void SetPyColor(PyObject* team); + auto SetPyColor(PyObject* team) -> void; auto GetPyColor() -> PyObject*; // Returns a borrowed ref. - void SetPyHighlight(PyObject* team); + auto SetPyHighlight(PyObject* team) -> void; auto GetPyHighlight() -> PyObject*; // Returns a borrowed ref. - void SetPyActivityPlayer(PyObject* team); + auto SetPyActivityPlayer(PyObject* team) -> void; auto GetPyActivityPlayer() -> PyObject*; // Returns a borrowed ref. - void set_has_py_data(bool has) { has_py_data_ = has; } + auto set_has_py_data(bool has) -> void { has_py_data_ = has; } auto has_py_data() const -> bool { return has_py_data_; } auto GetInputDevice() const -> InputDevice* { return input_device_.get(); } auto GetAge() const -> millisecs_t { return GetRealTime() - creation_time_; } auto accepted() const -> bool { return accepted_; } - void SetPosition(const Vector3f& position); + auto SetPosition(const Vector3f& position) -> void; // If an public account-id can be determined with relative // certainty for this player, returns it. Otherwise returns // an empty string. auto GetPublicAccountID() const -> std::string; - void SetHostActivity(HostActivity* host_activity); + auto SetHostActivity(HostActivity* host_activity) -> void; auto GetHostActivity() const -> HostActivity*; auto has_py_ref() -> bool { return (py_ref_ != nullptr); } - void SetIcon(const std::string& tex_name, const std::string& tint_tex_name, + auto SetIcon(const std::string& tex_name, const std::string& tint_tex_name, const std::vector& tint_color, - const std::vector& tint2_color); + const std::vector& tint2_color) -> void; auto icon_tex_name() const -> const std::string& { BA_PRECONDITION(icon_set_); @@ -104,14 +104,14 @@ class Player : public Object { BA_PRECONDITION(icon_set_); return icon_tint2_color_; } - void set_accepted(bool value) { accepted_ = value; } + auto set_accepted(bool value) -> void { accepted_ = value; } auto time_out() const -> millisecs_t { return time_out_; } - void set_time_out(millisecs_t value) { time_out_ = value; } - void set_have_position(bool value) { have_position_ = value; } + auto set_time_out(millisecs_t value) -> void { time_out_ = value; } + auto set_have_position(bool value) -> void { have_position_ = value; } private: auto GetPyRef(bool new_ref) -> PyObject*; - void RunInput(InputType type, float value = 0.0f); + auto RunInput(InputType type, float value = 0.0f) -> void; bool icon_set_{}; std::string icon_tex_name_; std::string icon_tint_tex_name_; diff --git a/src/ballistica/game/player_spec.cc b/src/ballistica/game/player_spec.cc index 1df777d9..a894982e 100644 --- a/src/ballistica/game/player_spec.cc +++ b/src/ballistica/game/player_spec.cc @@ -12,7 +12,7 @@ namespace ballistica { -PlayerSpec::PlayerSpec() : account_type_(AccountType::kInvalid) {} +PlayerSpec::PlayerSpec() = default; PlayerSpec::PlayerSpec(const std::string& s) { cJSON* root_obj = cJSON_Parse(s.c_str()); diff --git a/src/ballistica/game/player_spec.h b/src/ballistica/game/player_spec.h index a6bf948f..4292cd09 100644 --- a/src/ballistica/game/player_spec.h +++ b/src/ballistica/game/player_spec.h @@ -14,41 +14,41 @@ namespace ballistica { // real account, and can be passed around easily in string form. class PlayerSpec { public: - // inits an invalid player-spec + /// Init an invalid player-spec PlayerSpec(); auto operator==(const PlayerSpec& spec) const -> bool; - // create a player-spec from a given spec-string. - // in the case of an error, defaults will be used - // (though the error will be reported) + /// Create a player-spec from a given spec-string. + /// In the case of an error, defaults will be used + /// (though the error will be reported). explicit PlayerSpec(const std::string& s); - // this returns a full display string for the spec, - // which may include the account icon + /// Return a full display string for the spec, + /// which may include the account icon. auto GetDisplayString() const -> std::string; - // returns a short version of the player's name - // ideal for displaying in-game; this includes - // no icon and may just be the first name + /// Returns a short version of the player's name. + /// Ideal for displaying in-game; this includes + /// no icon and may just be the first name. auto GetShortName() const -> std::string; - // return the full string form to be passed around + /// Return the full string form to be passed around. auto GetSpecString() const -> std::string; - // returns a PlayerSpec for the currently logged in account - // if there is no current logged in account, a dummy-spec is created - // using the device name (so this always returns something reasonable) + /// Return a PlayerSpec for the currently logged in account. + /// If there is no current logged in account, a dummy-spec is created + /// using the device name (so this always returns something reasonable). static auto GetAccountPlayerSpec() -> PlayerSpec; - // returns a 'dummy' PlayerSpec using the given name; can be - // used for non-account player profiles, names for non-logged-in - // party hosts, etc. + /// Return a 'dummy' PlayerSpec using the given name; can be + /// used for non-account player profiles, names for non-logged-in + /// party hosts, etc. static auto GetDummyPlayerSpec(const std::string& name) -> PlayerSpec; private: std::string name_; std::string short_name_; - AccountType account_type_; + AccountType account_type_{AccountType::kInvalid}; }; } // namespace ballistica diff --git a/src/ballistica/scene/node/globals_node.cc b/src/ballistica/scene/node/globals_node.cc index 391dac28..f9d2dc83 100644 --- a/src/ballistica/scene/node/globals_node.cc +++ b/src/ballistica/scene/node/globals_node.cc @@ -105,7 +105,7 @@ GlobalsNode::GlobalsNode(Scene* scene) : Node(scene, node_type) { Log("WARNING: more than one globals node created in HostActivity; this " "shouldn't happen"); } - ha->globals_node_ = this; + ha->SetGlobalsNode(this); // Set some values we always drive even when not the singleton 'current' // globals (stuff that only affects our activity/scene). diff --git a/src/ballistica/ui/widget/text_widget.cc b/src/ballistica/ui/widget/text_widget.cc index 96dd9a15..77a982f7 100644 --- a/src/ballistica/ui/widget/text_widget.cc +++ b/src/ballistica/ui/widget/text_widget.cc @@ -512,25 +512,24 @@ auto TextWidget::GetHeight() -> float { auto TextWidget::ShouldUseStringEditDialog() const -> bool { if (HeadlessMode()) { return false; - } else { - if (force_internal_editing_) { - return false; - } - if (always_use_internal_keyboard_) { - return true; - } + } + if (force_internal_editing_) { + return false; + } + if (always_use_internal_keyboard_) { + return true; + } - // On most platforms we always want to do this. - // on mac/pc, however, we use inline editing if the current UI input-device - // is the mouse or keyboard - if (g_buildconfig.ostype_macos() || g_buildconfig.ostype_windows() - || g_buildconfig.ostype_linux()) { - InputDevice* ui_input_device = g_ui->GetUIInputDevice(); - return !(ui_input_device == nullptr - || ui_input_device == g_input->keyboard_input()); - } else { - return true; - } + // On most platforms we always want to do this. + // on mac/pc, however, we use inline editing if the current UI input-device + // is the mouse or keyboard + if (g_buildconfig.ostype_macos() || g_buildconfig.ostype_windows() + || g_buildconfig.ostype_linux()) { + InputDevice* ui_input_device = g_ui->GetUIInputDevice(); + return !(ui_input_device == nullptr + || ui_input_device == g_input->keyboard_input()); + } else { + return true; } }