diff --git a/ballisticacore-cmake/.idea/scopes/External.xml b/ballisticacore-cmake/.idea/scopes/External.xml
new file mode 100644
index 00000000..a140a57c
--- /dev/null
+++ b/ballisticacore-cmake/.idea/scopes/External.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/ballisticacore-cmake/CMakeLists.txt b/ballisticacore-cmake/CMakeLists.txt
index c0cb8ad4..c9f3f640 100644
--- a/ballisticacore-cmake/CMakeLists.txt
+++ b/ballisticacore-cmake/CMakeLists.txt
@@ -81,7 +81,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
"${CMAKE_CXX_FLAGS} -Wno-psabi")
endif()
-set(BA_SRC_ROOT src)
+set(BA_SRC_ROOT ../src)
include_directories(${BA_SRC_ROOT})
add_compile_options(-include ballistica/config/config_cmake.h)
@@ -642,7 +642,7 @@ target_include_directories(ballisticacore PRIVATE
target_link_libraries(ballisticacore PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/prefablib/libballisticacore_internal.a ode pthread ${Python_LIBRARIES}
- ${SDL2_LIBRARIES} ${EXTRA_LIBRARIES} dl)
+ ${SDL2_LIBRARIES} ${EXTRA_LIBRARIES} dl z)
# Hack for building on rpi (might be due to my manually built Python 3.8)
# Hopefully can remove later...
diff --git a/ballisticacore-cmake/src b/ballisticacore-cmake/src
deleted file mode 120000
index 5cd551cf..00000000
--- a/ballisticacore-cmake/src
+++ /dev/null
@@ -1 +0,0 @@
-../src
\ No newline at end of file
diff --git a/config/config.json b/config/config.json
index 0ccbddfd..f5c5b98b 100644
--- a/config/config.json
+++ b/config/config.json
@@ -21,6 +21,7 @@
"name": "BallisticaCore",
"public": true,
"pylint_ignored_untracked_deps": [
+ "__main__",
"astroid.modutils",
"astroid",
"pylint.lint",
diff --git a/config/toolconfigsrc/mypy.ini b/config/toolconfigsrc/mypy.ini
index 7d776146..86b64008 100644
--- a/config/toolconfigsrc/mypy.ini
+++ b/config/toolconfigsrc/mypy.ini
@@ -30,7 +30,10 @@ ignore_missing_imports = True
[mypy-xml.*]
ignore_missing_imports = True
-[mypy-vis_cleanup]
+# We delete a bunch of stuff from _ba in here
+# which our public stub module doesn't list,
+# so we get complaints that they don't exist.
+[mypy-ba_embedded_vis_cleanup]
ignore_errors = True
[mypy-bastd.mapdata.*]
diff --git a/docs/ba_module.md b/docs/ba_module.md
index ffb633f8..e95c0401 100644
--- a/docs/ba_module.md
+++ b/docs/ba_module.md
@@ -1,5 +1,5 @@
-last updated on 2021-04-13 for Ballistica version 1.6.0 build 20332
+last updated on 2021-04-14 for Ballistica version 1.6.0 build 20335
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.cc b/src/ballistica/app/app.cc
index 451a8d7a..6bd078a5 100644
--- a/src/ballistica/app/app.cc
+++ b/src/ballistica/app/app.cc
@@ -137,13 +137,13 @@ void App::RunEvents() {
void App::UpdatePauseResume() {
if (actually_paused_) {
// Unpause if no one wants pause.
- if (!sys_paused_app_ && !user_paused_app_) {
+ if (!sys_paused_app_) {
OnResume();
actually_paused_ = false;
}
} else {
// Pause if anyone wants.
- if (sys_paused_app_ || user_paused_app_) {
+ if (sys_paused_app_) {
OnPause();
actually_paused_ = true;
}
@@ -264,7 +264,7 @@ void App::PrimeEventPump() {
void App::PushShowOnlineScoreUICall(const std::string& show,
const std::string& game,
const std::string& game_version) {
- PushCall([this, show, game, game_version] {
+ PushCall([show, game, game_version] {
assert(InMainThread());
g_platform->ShowOnlineScoreUI(show, game, game_version);
});
@@ -272,7 +272,7 @@ void App::PushShowOnlineScoreUICall(const std::string& show,
void App::PushNetworkSetupCall(int port, int telnet_port, bool enable_telnet,
const std::string& telnet_password) {
- PushCall([this, port, telnet_port, enable_telnet, telnet_password] {
+ PushCall([port, telnet_port, enable_telnet, telnet_password] {
assert(InMainThread());
// Kick these off if they don't exist.
// (do we want to support changing ports on existing ones?)
@@ -293,59 +293,58 @@ void App::PushNetworkSetupCall(int port, int telnet_port, bool enable_telnet,
void App::PushPurchaseAckCall(const std::string& purchase,
const std::string& order_id) {
- PushCall([this, purchase, order_id] {
- g_platform->PurchaseAck(purchase, order_id);
- });
+ PushCall(
+ [purchase, order_id] { g_platform->PurchaseAck(purchase, order_id); });
}
void App::PushGetScoresToBeatCall(const std::string& level,
const std::string& config,
void* py_callback) {
- PushCall([this, level, config, py_callback] {
+ PushCall([level, config, py_callback] {
assert(InMainThread());
g_platform->GetScoresToBeat(level, config, py_callback);
});
}
void App::PushPurchaseCall(const std::string& item) {
- PushCall([this, item] {
+ PushCall([item] {
assert(InMainThread());
g_platform->Purchase(item);
});
}
void App::PushRestorePurchasesCall() {
- PushCall([this] {
+ PushCall([] {
assert(InMainThread());
g_platform->RestorePurchases();
});
}
void App::PushOpenURLCall(const std::string& url) {
- PushCall([this, url] { g_platform->OpenURL(url); });
+ PushCall([url] { g_platform->OpenURL(url); });
}
void App::PushGetFriendScoresCall(const std::string& game,
const std::string& game_version, void* data) {
- PushCall([this, game, game_version, data] {
+ PushCall([game, game_version, data] {
g_platform->GetFriendScores(game, game_version, data);
});
}
void App::PushSubmitScoreCall(const std::string& game,
const std::string& game_version, int64_t score) {
- PushCall([this, game, game_version, score] {
+ PushCall([game, game_version, score] {
g_platform->SubmitScore(game, game_version, score);
});
}
void App::PushAchievementReportCall(const std::string& achievement) {
- PushCall([this, achievement] { g_platform->ReportAchievement(achievement); });
+ PushCall([achievement] { g_platform->ReportAchievement(achievement); });
}
void App::PushStringEditCall(const std::string& name, const std::string& value,
int max_chars) {
- PushCall([this, name, value, max_chars] {
+ PushCall([name, value, max_chars] {
static millisecs_t last_edit_time = 0;
millisecs_t t = GetRealTime();
@@ -367,7 +366,7 @@ void App::PushSetStressTestingCall(bool enable, int player_count) {
}
void App::PushResetAchievementsCall() {
- PushCall([this] { g_platform->ResetAchievements(); });
+ PushCall([] { g_platform->ResetAchievements(); });
}
void App::OnBootstrapComplete() {
@@ -390,7 +389,7 @@ void App::OnBootstrapComplete() {
}
void App::PushCursorUpdate(bool vis) {
- PushCall([this, vis] {
+ PushCall([vis] {
assert(InMainThread());
g_platform->SetHardwareCursorVisible(vis);
});
diff --git a/src/ballistica/app/app.h b/src/ballistica/app/app.h
index bb9946da..30576afc 100644
--- a/src/ballistica/app/app.h
+++ b/src/ballistica/app/app.h
@@ -133,7 +133,6 @@ class App : public Module {
bool done_{};
bool server_wrapper_managed_{};
bool sys_paused_app_{};
- bool user_paused_app_{};
bool actually_paused_{};
std::unique_ptr stress_test_;
millisecs_t last_resize_draw_event_time_{};
diff --git a/src/ballistica/audio/audio.cc b/src/ballistica/audio/audio.cc
index 4fcb6e2e..3315ff80 100644
--- a/src/ballistica/audio/audio.cc
+++ b/src/ballistica/audio/audio.cc
@@ -87,7 +87,7 @@ auto Audio::IsSoundPlaying(uint32_t play_id) -> bool {
return result;
}
-auto Audio::SourceBeginExisting(uint32_t play_id, uint32_t debug_id)
+auto Audio::SourceBeginExisting(uint32_t play_id, int debug_id)
-> AudioSource* {
BA_DEBUG_FUNCTION_TIMER_BEGIN();
uint32_t source_id = AudioServer::source_id_from_play_id(play_id);
diff --git a/src/ballistica/audio/audio.h b/src/ballistica/audio/audio.h
index 20ec7060..48488256 100644
--- a/src/ballistica/audio/audio.h
+++ b/src/ballistica/audio/audio.h
@@ -34,7 +34,7 @@ class Audio {
// If a sound play id is playing, locks and returns its sound source.
// on success, you must unlock the source once done with it.
- auto SourceBeginExisting(uint32_t play_id, uint32_t debug_id) -> AudioSource*;
+ auto SourceBeginExisting(uint32_t play_id, int debug_id) -> AudioSource*;
// Return true if the sound id is currently valid. This is not guaranteed
// to be super accurate, but can be used to determine if a sound is still
diff --git a/src/ballistica/audio/audio_server.cc b/src/ballistica/audio/audio_server.cc
index 974e0a18..b396f203 100644
--- a/src/ballistica/audio/audio_server.cc
+++ b/src/ballistica/audio/audio_server.cc
@@ -37,8 +37,8 @@ const bool kShowInUseSounds = false;
int AudioServer::al_source_count_ = 0;
struct AudioServer::Impl {
- Impl() {}
- ~Impl() {}
+ Impl() = default;
+ ~Impl() = default;
#if BA_ENABLE_AUDIO
ALCcontext* alc_context_{};
@@ -417,7 +417,6 @@ AudioServer::AudioServer(Thread* thread)
}
AudioServer::~AudioServer() {
- delete impl_;
#if BA_ENABLE_AUDIO
sound_source_refs_.clear();
@@ -434,6 +433,7 @@ AudioServer::~AudioServer() {
assert(al_source_count_ == 0);
#endif // BA_ENABLE_AUDIO
+ delete impl_;
}
void AudioServer::UpdateAvailableSources() {
diff --git a/src/ballistica/audio/audio_streamer.cc b/src/ballistica/audio/audio_streamer.cc
index 4711e171..d44a9982 100644
--- a/src/ballistica/audio/audio_streamer.cc
+++ b/src/ballistica/audio/audio_streamer.cc
@@ -49,6 +49,11 @@ auto AudioStreamer::Play() -> bool {
alSourcePlay(source_);
CHECK_AL_ERROR;
+ // Suppress 'always returns true' lint.
+ if (explicit_bool(false)) {
+ return false;
+ }
+
return true;
}
@@ -132,11 +137,17 @@ auto AudioStreamer::Stream(ALuint buffer) -> bool {
CHECK_AL_ERROR;
DoStream(pcm, &size, &rate);
if (size > 0) {
- alBufferData(buffer, al_format(), pcm, size, rate);
+ alBufferData(buffer, al_format(), pcm, size, static_cast(rate));
CHECK_AL_ERROR;
} else {
eof_ = true;
}
+
+ // Suppress 'always returns true' lint.
+ if (explicit_bool(false)) {
+ return false;
+ }
+
return true;
}
diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc
index 02eabe15..b789e123 100644
--- a/src/ballistica/ballistica.cc
+++ b/src/ballistica/ballistica.cc
@@ -21,7 +21,7 @@
namespace ballistica {
// These are set automatically via script; don't change here.
-const int kAppBuildNumber = 20333;
+const int kAppBuildNumber = 20336;
const char* kAppVersion = "1.6.0";
// Our standalone globals.
diff --git a/src/ballistica/core/fatal_error.cc b/src/ballistica/core/fatal_error.cc
index e59aad77..1e231b59 100644
--- a/src/ballistica/core/fatal_error.cc
+++ b/src/ballistica/core/fatal_error.cc
@@ -21,9 +21,9 @@ auto FatalError::ReportFatalError(const std::string& message,
// blessed build. If we are, our main goal is to communicate as much info
// about the error to the master server, and communicating to the user is
// a stretch goal.
- // If we are unblessed or modified, the main goals are communicating the error
- // to the user and exiting the app cleanly (so we don't pollute our crash
- // records with results of user tinkering).
+ // If we are unblessed or modified, the main goals are communicating the
+ // error to the user and exiting the app cleanly (so we don't pollute our
+ // crash records with results of user tinkering).
// Try to avoid crash reports if we're not a clean blessed build.
// bool exit_cleanly = !IsUnmodifiedBlessedBuild();
diff --git a/src/ballistica/core/thread.cc b/src/ballistica/core/thread.cc
index eb687692..453dcc0b 100644
--- a/src/ballistica/core/thread.cc
+++ b/src/ballistica/core/thread.cc
@@ -287,16 +287,6 @@ void Thread::GetThreadMessages(std::list* messages) {
}
}
-void Thread::WriteToOwner(const void* data, uint32_t size) {
- assert(std::this_thread::get_id() == thread_id());
- {
- std::unique_lock lock(data_to_client_mutex_);
- data_to_client_.emplace_back(size);
- memcpy(&(data_to_client_.back()[0]), data, size);
- }
- data_to_client_cv_.notify_all();
-}
-
Thread::Thread(ThreadIdentifier identifier_in, ThreadType type_in)
: type_(type_in), identifier_(identifier_in) {
switch (type_) {
@@ -419,6 +409,11 @@ auto Thread::ThreadMain() -> int {
throw;
}
}
+
+ // Silence some lint complaints about always returning 0.
+ if (explicit_bool(false)) {
+ return 1;
+ }
return 0;
}
}
@@ -438,6 +433,9 @@ void Thread::Quit() {
Thread::~Thread() = default;
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
void Thread::LogThreadMessageTally() {
// Prevent recursion.
if (!writing_tally_) {
@@ -498,6 +496,7 @@ void Thread::LogThreadMessageTally() {
writing_tally_ = false;
}
}
+#pragma clang diagnostic pop
void Thread::PushThreadMessage(const ThreadMessage& t) {
{
@@ -555,6 +554,19 @@ void Thread::PushThreadMessage(const ThreadMessage& t) {
thread_message_cv_.notify_all();
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantParameter"
+
+void Thread::WriteToOwner(const void* data, uint32_t size) {
+ assert(std::this_thread::get_id() == thread_id());
+ {
+ std::unique_lock lock(data_to_client_mutex_);
+ data_to_client_.emplace_back(size);
+ memcpy(&(data_to_client_.back()[0]), data, size);
+ }
+ data_to_client_cv_.notify_all();
+}
+
void Thread::ReadFromThread(std::unique_lock* lock, void* buffer,
uint32_t size) {
// Threads cant read from themselves.. could load to lock-deadlock.
@@ -572,6 +584,8 @@ void Thread::ReadFromThread(std::unique_lock* lock, void* buffer,
data_to_client_.pop_front();
}
+#pragma clang diagnostic pop
+
void Thread::SetThreadsPaused(bool paused) {
threads_paused_ = paused;
for (auto&& i : g_app_globals->pausable_threads) {
diff --git a/src/ballistica/dynamics/bg/bg_dynamics.cc b/src/ballistica/dynamics/bg/bg_dynamics.cc
index 2e296ea1..d84739f6 100644
--- a/src/ballistica/dynamics/bg/bg_dynamics.cc
+++ b/src/ballistica/dynamics/bg/bg_dynamics.cc
@@ -362,8 +362,6 @@ void BGDynamics::DrawChunks(FrameDef* frame_def,
c.SetColor(0.9f, 0.6f, 0.3f, 1.0f);
break;
}
- default:
- throw Exception();
}
c.DrawModelInstanced(model, *draw_snapshot, kModelDrawFlagNoReflection);
c.Submit();
diff --git a/src/ballistica/dynamics/bg/bg_dynamics_server.cc b/src/ballistica/dynamics/bg/bg_dynamics_server.cc
index 60e9c891..28dcadea 100644
--- a/src/ballistica/dynamics/bg/bg_dynamics_server.cc
+++ b/src/ballistica/dynamics/bg/bg_dynamics_server.cc
@@ -1689,7 +1689,8 @@ auto BGDynamicsServer::CreateDrawSnapshot() -> BGDynamicsDrawSnapshot* {
float flicker = i->flicker_;
float shadow_dist = i->shadow_dist_;
float life = std::min(
- 1.0f, (static_cast(time_) - i->birth_time_) / i->lifespan_);
+ 1.0f, (static_cast(time_) - static_cast(i->birth_time_))
+ / i->lifespan_);
// Shrink our matrix down over time.
switch (type) {
@@ -2218,7 +2219,8 @@ void BGDynamicsServer::PushTooSlowCall() {
if (chunk_count_ > 0 || tendril_count_thick_ > 0
|| tendril_count_thin_ > 0) {
// Ok lets kill a small percentage of our oldest chunks.
- int killcount = static_cast(0.1f * chunks_.size());
+ int killcount =
+ static_cast(0.1f * static_cast(chunks_.size()));
int killed = 0;
auto i = chunks_.begin();
while (i != chunks_.end()) {
@@ -2236,7 +2238,7 @@ void BGDynamicsServer::PushTooSlowCall() {
i = i_next;
}
// ...and tendrils.
- killcount = static_cast(0.2f * tendrils_.size());
+ killcount = static_cast(0.2f * static_cast(tendrils_.size()));
for (int j = 0; j < killcount; j++) {
Tendril* t = *tendrils_.begin();
if (t->type_ == BGDynamicsTendrilType::kThinSmoke) {
diff --git a/src/ballistica/dynamics/material/material_condition_node.cc b/src/ballistica/dynamics/material/material_condition_node.cc
index 22300cdc..895c9f07 100644
--- a/src/ballistica/dynamics/material/material_condition_node.cc
+++ b/src/ballistica/dynamics/material/material_condition_node.cc
@@ -75,8 +75,13 @@ void MaterialConditionNode::Restore(const char** buffer, ClientSession* cs) {
val1 = Utils::ExtractInt32NBO(buffer);
val2 = Utils::ExtractInt32NBO(buffer);
break;
+
+// Currently not reachable, but guarding in case GetValueCount changes.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
default:
throw Exception();
+#pragma clang diagnostic pop
}
} else {
// not a leaf node - make ourself some children
diff --git a/src/ballistica/dynamics/rigid_body.cc b/src/ballistica/dynamics/rigid_body.cc
index 57b719d0..62ed4fc0 100644
--- a/src/ballistica/dynamics/rigid_body.cc
+++ b/src/ballistica/dynamics/rigid_body.cc
@@ -425,8 +425,6 @@ auto RigidBody::SetDimensions(float d1, float d2, float d3, float m1, float m2,
case Shape::kTrimesh: // NOLINT(bugprone-branch-clone)
// Trimesh bodies not supported yet.
throw Exception();
- default:
- throw Exception();
}
// Need to handle groups here.
diff --git a/src/ballistica/game/game.cc b/src/ballistica/game/game.cc
index 0cf37157..38cd76d4 100644
--- a/src/ballistica/game/game.cc
+++ b/src/ballistica/game/game.cc
@@ -904,7 +904,7 @@ void Game::PushInGameConsoleScriptCommand(const std::string& command) {
g_app_globals->user_ran_commands = true;
}
if (cmd.CanEval()) {
- PyObject* obj = cmd.RunReturnObj(true);
+ PyObject* obj = cmd.RunReturnObj(true, nullptr);
if (obj && obj != Py_None) {
PyObject* s = PyObject_Repr(obj);
if (s) {
@@ -935,7 +935,7 @@ void Game::PushStdinScriptCommand(const std::string& command) {
// Eval this if possible (so we can possibly print return value).
if (cmd.CanEval()) {
- if (PyObject* obj = cmd.RunReturnObj(true)) {
+ if (PyObject* obj = cmd.RunReturnObj(true, nullptr)) {
// Print the value if we're running directly from a terminal
// (or being run under the server-manager)
if ((IsStdinATerminal() || g_app->server_wrapper_managed())
diff --git a/src/ballistica/game/game_stream.h b/src/ballistica/game/game_stream.h
index 9da9e19d..0cb56b24 100644
--- a/src/ballistica/game/game_stream.h
+++ b/src/ballistica/game/game_stream.h
@@ -15,7 +15,7 @@ namespace ballistica {
// stream of messages that can be saved to file or sent over the network.
class GameStream : public Object, public ClientControllerInterface {
public:
- GameStream(HostSession* host_session, bool saveReplay);
+ GameStream(HostSession* host_session, bool save_replay);
~GameStream() override;
auto SetTime(millisecs_t t) -> void;
auto AddScene(Scene* s) -> void;
diff --git a/src/ballistica/generic/base64.cc b/src/ballistica/generic/base64.cc
index 959d14d0..c775c522 100644
--- a/src/ballistica/generic/base64.cc
+++ b/src/ballistica/generic/base64.cc
@@ -120,8 +120,8 @@ auto base64_decode(const std::string& encoded_string, bool urlsafe)
in_++;
if (i == 4) {
for (i = 0; i < 4; i++) {
- char_array_4[i] =
- static_cast(base64_chars.find(char_array_4[i]));
+ char_array_4[i] = static_cast(
+ base64_chars.find(static_cast(char_array_4[i])));
}
char_array_3[0] = static_cast(
@@ -131,7 +131,7 @@ auto base64_decode(const std::string& encoded_string, bool urlsafe)
char_array_3[2] = static_cast(
((char_array_4[2] & 0x3u) << 6u) + char_array_4[3]);
- for (i = 0; (i < 3); i++) ret += char_array_3[i];
+ for (i = 0; (i < 3); i++) ret += static_cast(char_array_3[i]);
i = 0;
}
}
@@ -140,8 +140,8 @@ auto base64_decode(const std::string& encoded_string, bool urlsafe)
char_array_4[j] = 0;
}
for (int j = 0; j < 4; j++) { // NOLINT(modernize-loop-convert)
- char_array_4[j] =
- static_cast(base64_chars.find(char_array_4[j]));
+ char_array_4[j] = static_cast(
+ base64_chars.find(static_cast(char_array_4[j])));
}
char_array_3[0] = static_cast(
(char_array_4[0] << 2u) + ((char_array_4[1] & 0x30u) >> 4u));
@@ -150,7 +150,7 @@ auto base64_decode(const std::string& encoded_string, bool urlsafe)
char_array_3[2] = static_cast(
((char_array_4[2] & 0x3u) << 6u) + char_array_4[3]);
for (int j = 0; (j < i - 1); j++) {
- ret += char_array_3[j];
+ ret += static_cast(char_array_3[j]);
}
}
return ret;
diff --git a/src/ballistica/generic/json.cc b/src/ballistica/generic/json.cc
index 315556f7..21429698 100644
--- a/src/ballistica/generic/json.cc
+++ b/src/ballistica/generic/json.cc
@@ -865,6 +865,9 @@ auto cJSON_DetachItemFromArray(cJSON* array, int which) -> cJSON* {
void cJSON_DeleteItemFromArray(cJSON* array, int which) {
cJSON_Delete(cJSON_DetachItemFromArray(array, which));
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantFunctionResult"
+
auto cJSON_DetachItemFromObject(cJSON* object, const char* string) -> cJSON* {
int i = 0;
cJSON* c = object->child;
@@ -875,6 +878,9 @@ auto cJSON_DetachItemFromObject(cJSON* object, const char* string) -> cJSON* {
if (c) return cJSON_DetachItemFromArray(object, i);
return nullptr;
}
+
+#pragma clang diagnostic pop
+
void cJSON_DeleteItemFromObject(cJSON* object, const char* string) {
cJSON_Delete(cJSON_DetachItemFromObject(object, string));
}
diff --git a/src/ballistica/generic/utils.cc b/src/ballistica/generic/utils.cc
index 4ce06c07..d5a7af2a 100644
--- a/src/ballistica/generic/utils.cc
+++ b/src/ballistica/generic/utils.cc
@@ -243,7 +243,7 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
for (i = 0; i < f_size; i++) {
c = (unsigned char)(str)[i];
if (c < 127) { // normal ASCII
- to.append(1, c);
+ to.append(1, static_cast(c));
}
}
@@ -268,19 +268,19 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
c = (unsigned char)(str)[i];
if (c < 32) { // control char
if (c == 9 || c == 10 || c == 13) { // allow only \t \n \r
- to.append(1, c);
+ to.append(1, static_cast(c));
}
continue;
} else if (c < 127) { // normal ASCII
- to.append(1, c);
+ to.append(1, static_cast(c));
continue;
} else if (c < 160) {
// control char (nothing should be defined here either
// ASCI, ISO_8859-1 or UTF8, so skipping)
if (c2 == 128) { // fix microsoft mess, add euro
- to.append(1, (unsigned char)(226));
- to.append(1, (unsigned char)(130));
- to.append(1, (unsigned char)(172));
+ to.append(1, static_cast((unsigned char)(226)));
+ to.append(1, static_cast((unsigned char)(130)));
+ to.append(1, static_cast((unsigned char)(172)));
}
if (c2 == 133) { // fix IBM mess, add NEL = \n\r
to.append(1, 10);
@@ -288,11 +288,11 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
}
continue;
} else if (c < 192) { // invalid for UTF8, converting ASCII
- to.append(1, (unsigned char)194);
- to.append(1, c);
+ to.append(1, static_cast((unsigned char)194));
+ to.append(1, static_cast(c));
continue;
} else if (c < 194) { // invalid for UTF8, converting ASCII
- to.append(1, (unsigned char)195);
+ to.append(1, static_cast((unsigned char)195));
to.append(1, c - 64);
continue;
} else if (c < 224 && i + 1 < f_size) { // possibly 2byte UTF8
@@ -300,8 +300,8 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
if (c2 > 127 && c2 < 192) { // valid 2byte UTF8
if (c == 194 && c2 < 160) { // control char, skipping
} else {
- to.append(1, c);
- to.append(1, c2);
+ to.append(1, static_cast(c));
+ to.append(1, static_cast(c2));
}
i++;
continue;
@@ -310,9 +310,9 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
c2 = (unsigned char)(str)[i + 1];
c3 = (unsigned char)(str)[i + 2];
if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192) { // valid 3byte UTF8
- to.append(1, c);
- to.append(1, c2);
- to.append(1, c3);
+ to.append(1, static_cast(c));
+ to.append(1, static_cast(c2));
+ to.append(1, static_cast(c3));
i += 2;
continue;
}
@@ -323,17 +323,17 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192 && c4 > 127
&& c4 < 192) {
// valid 4byte UTF8
- to.append(1, c);
- to.append(1, c2);
- to.append(1, c3);
- to.append(1, c4);
+ to.append(1, static_cast(c));
+ to.append(1, static_cast(c2));
+ to.append(1, static_cast(c3));
+ to.append(1, static_cast(c4));
i += 3;
continue;
}
}
// invalid UTF8, converting ASCII
// (c>245 || string too short for multi-byte))
- to.append(1, (unsigned char)195);
+ to.append(1, static_cast((unsigned char)195));
to.append(1, c - 64);
}
}
@@ -424,11 +424,16 @@ static std::list* g_random_names_list = nullptr;
auto Utils::GetRandomNameList() -> const std::list& {
assert(InGameThread());
- if (!g_random_names_list) {
- // this will init the list with our default english names
+ if (g_random_names_list == nullptr) {
+ // This will init the list with our default english names.
SetRandomNameList(std::list(1, "DEFAULT_NAMES"));
}
+
+ // Clion incorrectly thinks this might be null.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "NullDereferences"
return *g_random_names_list;
+#pragma clang diagnostic pop
}
void Utils::SetRandomNameList(const std::list& custom_names) {
diff --git a/src/ballistica/graphics/camera.cc b/src/ballistica/graphics/camera.cc
index ee71892c..b5361835 100644
--- a/src/ballistica/graphics/camera.cc
+++ b/src/ballistica/graphics/camera.cc
@@ -606,6 +606,7 @@ void Camera::Update(millisecs_t elapsed) {
// Prevent camera "explosions" if we've been unable to update for a while.
elapsed = std::min(millisecs_t{100}, elapsed);
+ auto elapsedf{static_cast(elapsed)};
// In normal mode we orbit; in vr mode we don't.
if (IsVRMode()) {
@@ -626,36 +627,36 @@ void Camera::Update(millisecs_t elapsed) {
}
target_radius_smoothed_ +=
- elapsed * (target_radius_ - target_radius_smoothed_) * zoom_speed;
+ elapsedf * (target_radius_ - target_radius_smoothed_) * zoom_speed;
float diff = field_of_view_x_ - field_of_view_x_smoothed_;
field_of_view_x_smoothed_ +=
- elapsed * diff * (diff > 0.0f ? fov_speed_out : fov_speed_in);
+ elapsedf * diff * (diff > 0.0f ? fov_speed_out : fov_speed_in);
diff = field_of_view_y_ - field_of_view_y_smoothed_;
field_of_view_y_smoothed_ +=
- elapsed * diff * (diff > 0.0f ? fov_speed_out : fov_speed_in);
+ elapsedf * diff * (diff > 0.0f ? fov_speed_out : fov_speed_in);
if (x_constrained_) {
xy_constrain_blend_ +=
- elapsed * (1.0f - xy_constrain_blend_) * xy_blend_speed;
+ elapsedf * (1.0f - xy_constrain_blend_) * xy_blend_speed;
xy_constrain_blend_ = std::min(1.0f, xy_constrain_blend_);
} else {
xy_constrain_blend_ +=
- elapsed * (0.0f - xy_constrain_blend_) * xy_blend_speed * elapsed;
+ elapsedf * (0.0f - xy_constrain_blend_) * xy_blend_speed * elapsedf;
xy_constrain_blend_ = std::max(0.0f, xy_constrain_blend_);
}
if (!IsVRMode()) {
- smooth_speed_.x += elapsed * rand_component
+ smooth_speed_.x += elapsedf * rand_component
* (-0.5f
+ Utils::precalc_rand_1((real_time / rand_incr_1)
% kPrecalcRandsCount));
- smooth_speed_.y += elapsed * rand_component
+ smooth_speed_.y += elapsedf * rand_component
* (-0.5f
+ Utils::precalc_rand_2((real_time / rand_incr_2)
% kPrecalcRandsCount));
- smooth_speed_.z += elapsed * rand_component
+ smooth_speed_.z += elapsedf * rand_component
* (-0.5f
+ Utils::precalc_rand_3((real_time / rand_incr_3)
% kPrecalcRandsCount));
@@ -663,11 +664,11 @@ void Camera::Update(millisecs_t elapsed) {
if (RandomFloat() < 0.1f && !IsVRMode()) {
smooth_speed_2_.x +=
- elapsed * rand_component * 4.0f * (-0.5f + RandomFloat());
+ elapsedf * rand_component * 4.0f * (-0.5f + RandomFloat());
smooth_speed_2_.y +=
- elapsed * rand_component * 4.0f * (-0.5f + RandomFloat());
+ elapsedf * rand_component * 4.0f * (-0.5f + RandomFloat());
smooth_speed_2_.z +=
- elapsed * rand_component * 4.0f * (-0.5f + RandomFloat());
+ elapsedf * rand_component * 4.0f * (-0.5f + RandomFloat());
}
// If we have no important areas of interest, keep our camera from moving too
diff --git a/src/ballistica/graphics/graphics_server.cc b/src/ballistica/graphics/graphics_server.cc
index d3450199..25c0cf22 100644
--- a/src/ballistica/graphics/graphics_server.cc
+++ b/src/ballistica/graphics/graphics_server.cc
@@ -351,6 +351,10 @@ void GraphicsServer::SetScreen(bool fullscreen, int width, int height,
}
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+#pragma ide diagnostic ignored "ConstantParameter"
+
void GraphicsServer::HandleFullContextScreenRebuild(
bool need_full_context_rebuild, bool fullscreen, int width, int height,
GraphicsQuality graphics_quality_requested,
@@ -457,6 +461,8 @@ void GraphicsServer::HandleFullContextScreenRebuild(
});
}
+#pragma clang diagnostic pop
+
// Given physical res, calculate virtual res.
void GraphicsServer::CalcVirtualRes(float* x, float* y) {
float x_in = (*x);
@@ -523,6 +529,10 @@ void GraphicsServer::HandlePushAndroidRes(const std::string& android_res) {
}
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+#pragma ide diagnostic ignored "ConstantParameter"
+
void GraphicsServer::HandleFullscreenToggling(bool do_set_existing_fs,
bool do_toggle_fs,
bool fullscreen) {
@@ -560,6 +570,7 @@ void GraphicsServer::HandleFullscreenToggling(bool do_set_existing_fs,
#endif // macos && xcode_build
}
}
+#pragma clang diagnostic pop
void GraphicsServer::SetTextureCompressionTypes(
const std::list& types) {
@@ -645,6 +656,9 @@ void GraphicsServer::SetCamera(const Vector3f& eye, const Vector3f& target,
cam_orient_matrix_dirty_ = true;
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
void GraphicsServer::UpdateCamOrientMatrix() {
assert(InGraphicsThread());
if (cam_orient_matrix_dirty_) {
@@ -672,6 +686,8 @@ void GraphicsServer::UpdateCamOrientMatrix() {
}
}
+#pragma clang diagnostic pop
+
#pragma mark PushCalls
void GraphicsServer::PushSetScreenCall(bool fullscreen, int width, int height,
diff --git a/src/ballistica/graphics/texture/ktx.cc b/src/ballistica/graphics/texture/ktx.cc
index 76cd4369..5b5c0be4 100644
--- a/src/ballistica/graphics/texture/ktx.cc
+++ b/src/ballistica/graphics/texture/ktx.cc
@@ -2205,6 +2205,10 @@ void KTXUnpackETC(const GLubyte* srcETC, const GLenum srcFormat,
if (alphaFormat != AF_NONE) setupAlphaTable();
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+#pragma ide diagnostic ignored "UnreachableCode"
+
// NOTE: none of the decompress functions actually use the parameter
if (alphaFormat == AF_11BIT) {
throw Exception();
@@ -2249,6 +2253,8 @@ void KTXUnpackETC(const GLubyte* srcETC, const GLenum srcFormat,
}
}
+#pragma clang diagnostic pop
+
/* Ok, now write out the active pixels to the destination image.
* (But only if the active pixels differ from the total pixels)
*/
diff --git a/src/ballistica/input/device/keyboard_input.cc b/src/ballistica/input/device/keyboard_input.cc
index 988e0db8..148a3ad7 100644
--- a/src/ballistica/input/device/keyboard_input.cc
+++ b/src/ballistica/input/device/keyboard_input.cc
@@ -10,9 +10,9 @@
namespace ballistica {
-KeyboardInput::KeyboardInput(KeyboardInput* parentKeyboardInputIn) {
- if (parentKeyboardInputIn) {
- parent_keyboard_input_ = parentKeyboardInputIn;
+KeyboardInput::KeyboardInput(KeyboardInput* parent_keyboard_input_in) {
+ if (parent_keyboard_input_in) {
+ parent_keyboard_input_ = parent_keyboard_input_in;
assert(parent_keyboard_input_->child_keyboard_input_ == nullptr);
// Currently we assume only 2 keyboard inputs.
@@ -115,6 +115,9 @@ auto KeyboardInput::HandleKey(const SDL_Keysym* keysym, bool repeat, bool down)
pass = true;
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
// if we're keyboard 1 we always send at least a key press event
// along..
if (!parent_keyboard_input_ && !pass) {
@@ -122,6 +125,8 @@ auto KeyboardInput::HandleKey(const SDL_Keysym* keysym, bool repeat, bool down)
pass = true;
}
break;
+
+#pragma clang diagnostic pop
}
}
if (pass) {
@@ -138,6 +143,11 @@ auto KeyboardInput::HandleKey(const SDL_Keysym* keysym, bool repeat, bool down)
return true;
}
+// Clion seems to think child_keyboard_input_ will never be set here (it will).
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
// At this point, if we have a child input, let it try to handle things.
if (child_keyboard_input_ && enable_child_) {
if (child_keyboard_input_->HandleKey(keysym, repeat, down)) {
@@ -145,6 +155,8 @@ auto KeyboardInput::HandleKey(const SDL_Keysym* keysym, bool repeat, bool down)
}
}
+#pragma clang diagnostic pop
+
if (!attached_to_player()) {
if (down
&& ((keysym->sym == jump_key_) || (keysym->sym == punch_key_)
diff --git a/src/ballistica/input/device/touch_input.cc b/src/ballistica/input/device/touch_input.cc
index 5cfef0f4..addb2928 100644
--- a/src/ballistica/input/device/touch_input.cc
+++ b/src/ballistica/input/device/touch_input.cc
@@ -431,13 +431,13 @@ void TouchInput::Draw(FrameDef* frame_def) {
if (movement_control_type_ == MovementControlType::kSwipe) {
c.SetTexture(g_media->GetTexture(SystemTextureID::kTouchArrows));
if (editing_) {
- float val = 1.5f + sinf(real_time * 0.02f);
+ float val = 1.5f + sinf(static_cast(real_time) * 0.02f);
c.SetColor(val, val, 1.0f, 1.0f);
}
} else {
float val;
if (editing_) {
- val = 0.35f + 0.15f * sinf(real_time * 0.02f);
+ val = 0.35f + 0.15f * sinf(static_cast(real_time) * 0.02f);
} else {
val = 0.35f;
}
@@ -459,7 +459,7 @@ void TouchInput::Draw(FrameDef* frame_def) {
if (movement_control_type_ == MovementControlType::kJoystick) {
float val;
if (editing_) {
- val = 0.35f + 0.15f * sinf(real_time * 0.02f);
+ val = 0.35f + 0.15f * sinf(static_cast(real_time) * 0.02f);
} else {
val = 0.35f;
}
@@ -474,11 +474,10 @@ void TouchInput::Draw(FrameDef* frame_def) {
if (!buttons_touch_ && action_control_type_ == ActionControlType::kSwipe
&& !swipe_controls_hidden_) {
- float sc2 = sc_actions;
- if (action_control_type_ == ActionControlType::kSwipe) sc2 *= 0.6f;
+ float sc2{sc_actions * 0.6f};
c.SetTexture(g_media->GetTexture(SystemTextureID::kTouchArrowsActions));
if (editing_) {
- float val = 1.5f + sinf(real_time * 0.02f);
+ float val = 1.5f + sinf(static_cast(real_time) * 0.02f);
c.SetColor(val, val, 1.0f, 1.0f);
} else {
c.SetColor(1.0f, 1.0f, 1.0f, 1.0f);
@@ -496,10 +495,10 @@ void TouchInput::Draw(FrameDef* frame_def) {
c.Submit();
}
- bool have_player_position = false;
+ bool have_player_position{false};
std::vector player_position(3);
if (attached_to_player()) {
- PlayerNode* player_node = nullptr;
+ PlayerNode* player_node{};
// Try to come up with whichever scene is in the foreground, and try
// to pull a node for the player we're attached to.
@@ -523,7 +522,7 @@ void TouchInput::Draw(FrameDef* frame_def) {
SimpleComponent c(frame_def->GetOverlayFlatPass());
c.SetTransparent(true);
- uint32_t residual_time = 130;
+ uint32_t residual_time{130};
// Draw buttons.
bool do_draw;
@@ -561,7 +560,7 @@ void TouchInput::Draw(FrameDef* frame_def) {
}
}
- float s = 0.5f;
+ float s{0.5f};
// In buttons mode we draw based on our UI size. Otherwise we draw in the
// world at a constant scale.
@@ -576,10 +575,10 @@ void TouchInput::Draw(FrameDef* frame_def) {
}
}
- float b_width = 50.0f * s;
- float half_b_width = 0.0f;
+ float b_width{50.0f * s};
+ float half_b_width{0.0f};
- float button_spread_s = 0.0f * s;
+ float button_spread_s{0.0f * s};
if (action_control_type_ == ActionControlType::kSwipe) {
button_spread_s *= 2.0f;
@@ -587,7 +586,7 @@ void TouchInput::Draw(FrameDef* frame_def) {
bool was_held;
float pop;
- float pop_time = 100.0f;
+ float pop_time{100.0f};
c.PushTransform();
@@ -604,11 +603,12 @@ void TouchInput::Draw(FrameDef* frame_def) {
}
}
- float squash = 1.3f;
- float stretch = 1.3f;
+ float squash{1.3f};
+ float stretch{1.3f};
- float s_extra = 1.0f;
- if (editing_) s_extra = 0.7f + 0.3f * sinf(real_time * 0.02f);
+ float s_extra{1.0f};
+ if (editing_)
+ s_extra = 0.7f + 0.3f * sinf(static_cast(real_time) * 0.02f);
// Bomb.
was_held =
diff --git a/src/ballistica/input/remote_app.cc b/src/ballistica/input/remote_app.cc
index ad8fcaa9..74c6b066 100644
--- a/src/ballistica/input/remote_app.cc
+++ b/src/ballistica/input/remote_app.cc
@@ -241,11 +241,13 @@ void RemoteAppServer::HandleData(int socket, uint8_t* buffer, size_t amt,
uint32_t h_raw_last = (last_state >> 8u) & 0xFFu;
uint32_t v_raw_last = (last_state >> 16u) & 0xFFu;
float dpad_h, dpad_v;
- dpad_h = -1.0f + 2.0f * (h_raw / 255.0f);
- dpad_v = -1.0f + 2.0f * (v_raw / 255.0f);
+ dpad_h = -1.0f + 2.0f * (static_cast(h_raw) / 255.0f);
+ dpad_v = -1.0f + 2.0f * (static_cast(v_raw) / 255.0f);
float last_dpad_h, last_dpad_v;
- last_dpad_h = -1.0f + 2.0f * (h_raw_last / 255.0f);
- last_dpad_v = -1.0f + 2.0f * (v_raw_last / 255.0f);
+ last_dpad_h =
+ -1.0f + 2.0f * (static_cast(h_raw_last) / 255.0f);
+ last_dpad_v =
+ -1.0f + 2.0f * (static_cast(v_raw_last) / 255.0f);
// Process this first since it can affect how other events are
// handled.
@@ -434,11 +436,12 @@ auto RemoteAppServer::GetClient(int request_id, struct sockaddr* addr,
void RemoteAppServer::HandleRemoteEvent(RemoteAppClient* client,
RemoteEventType b) {
+ bool send{true};
+
// Ok we got some data from the remote.
// All we have to do is translate it into an SDL event and feed it to our
// manual joystick we made.
SDL_Event e{};
- bool send = true;
switch (b) {
case RemoteEventType::kBombPress:
e.type = SDL_JOYBUTTONDOWN;
@@ -501,6 +504,9 @@ void RemoteAppServer::HandleRemoteEvent(RemoteAppClient* client,
e.jbutton.button = 64;
break;
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
default:
send = false;
break;
@@ -509,6 +515,7 @@ void RemoteAppServer::HandleRemoteEvent(RemoteAppClient* client,
assert(g_game);
g_input->PushJoystickEvent(e, client->joystick_);
}
+#pragma clang diagnostic pop
}
void RemoteAppServer::HandleRemoteFloatEvent(RemoteAppClient* client,
@@ -526,6 +533,10 @@ void RemoteAppServer::HandleRemoteFloatEvent(RemoteAppClient* client,
e.jaxis.axis = 1;
e.jaxis.value = static_cast(32767 * val);
break;
+
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
default:
send = false;
break;
@@ -534,6 +545,7 @@ void RemoteAppServer::HandleRemoteFloatEvent(RemoteAppClient* client,
assert(g_game);
g_input->PushJoystickEvent(e, client->joystick_);
}
+#pragma clang diagnostic pop
}
} // namespace ballistica
diff --git a/src/ballistica/media/media.cc b/src/ballistica/media/media.cc
index 36d13ca7..4819a4e8 100644
--- a/src/ballistica/media/media.cc
+++ b/src/ballistica/media/media.cc
@@ -617,6 +617,10 @@ void Media::MarkComponentForLoad(MediaComponentData* c) {
g_media_server->PushRunnable(Object::NewDeferred(media_ptr));
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantFunctionResult"
+
auto Media::GetModelPendingLoadCount() -> int {
if (!have_pending_loads_[static_cast(MediaType::kModel)]) {
return 0;
@@ -686,6 +690,8 @@ auto Media::GetCollideModelPendingLoadCount() -> int {
return total;
}
+#pragma clang diagnostic pop
+
auto Media::GetGraphicalPendingLoadCount() -> int {
// Each of these calls lock the media-lists so we don't.
return GetModelPendingLoadCount() + GetTexturePendingLoadCount();
diff --git a/src/ballistica/networking/telnet_server.cc b/src/ballistica/networking/telnet_server.cc
index c55ddaa0..0d7ea842 100644
--- a/src/ballistica/networking/telnet_server.cc
+++ b/src/ballistica/networking/telnet_server.cc
@@ -53,6 +53,9 @@ void TelnetServer::Resume() {
paused_cv_.notify_all();
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantFunctionResult"
+
auto TelnetServer::RunThread() -> int {
// Do this whole thing in a loop.
// If we get put to sleep we just start over.
@@ -66,14 +69,16 @@ auto TelnetServer::RunThread() -> int {
sd_ = socket(AF_INET, SOCK_STREAM, 0);
if (sd_ < 0) {
Log("Error: Unable to open host socket; errno " + std::to_string(errno));
- return 0;
+ return 1;
}
// Make it reusable.
int on = 1;
int status =
setsockopt(sd_, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on));
- if (-1 == status) Log("Error setting SO_REUSEADDR on telnet server");
+ if (-1 == status) {
+ Log("Error setting SO_REUSEADDR on telnet server");
+ }
// Bind to local server port.
struct sockaddr_in serv_addr {};
@@ -83,7 +88,7 @@ auto TelnetServer::RunThread() -> int {
serv_addr.sin_port = htons(port_); // NOLINT
result = ::bind(sd_, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
if (result != 0) {
- return 0;
+ return 1;
}
char buffer[10000];
const char* prompt = "ballisticacore> ";
@@ -176,6 +181,8 @@ auto TelnetServer::RunThread() -> int {
}
}
+#pragma clang diagnostic pop
+
void TelnetServer::PushTelnetScriptCommand(const std::string& command) {
assert(g_game);
if (g_game == nullptr) {
@@ -189,7 +196,7 @@ void TelnetServer::PushTelnetScriptCommand(const std::string& command) {
}
PythonCommand cmd(command, "");
if (cmd.CanEval()) {
- PyObject* obj = cmd.RunReturnObj(true);
+ PyObject* obj = cmd.RunReturnObj(true, nullptr);
if (obj && obj != Py_None) {
PyObject* s = PyObject_Repr(obj);
if (s) {
diff --git a/src/ballistica/python/class/python_class_collide_model.cc b/src/ballistica/python/class/python_class_collide_model.cc
index 8ad2b8e0..ece54383 100644
--- a/src/ballistica/python/class/python_class_collide_model.cc
+++ b/src/ballistica/python/class/python_class_collide_model.cc
@@ -66,6 +66,11 @@ auto PythonClassCollideModel::tp_new(PyTypeObject* type, PyObject* args,
+ " objects must only be created in the game thread (current is ("
+ GetCurrentThreadName() + ").");
}
+
+// Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (!s_create_empty_) {
throw Exception(
"Can't instantiate CollideModels directly; use "
@@ -73,6 +78,7 @@ auto PythonClassCollideModel::tp_new(PyTypeObject* type, PyObject* args,
}
self->collide_model_ = new Object::Ref();
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
@@ -81,7 +87,7 @@ void PythonClassCollideModel::Delete(Object::Ref* ref) {
assert(InGameThread());
// if we're the py-object for a collide_model, clear them out
// (FIXME - we should pass the old pointer in here to sanity-test that we
- // were their ref)
+ // were their ref)
if (ref->exists()) {
(*ref)->ClearPyObject();
}
diff --git a/src/ballistica/python/class/python_class_data.cc b/src/ballistica/python/class/python_class_data.cc
index f2f42d8b..ef11bc49 100644
--- a/src/ballistica/python/class/python_class_data.cc
+++ b/src/ballistica/python/class/python_class_data.cc
@@ -64,6 +64,11 @@ auto PythonClassData::tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+ " objects must only be created in the game thread (current is ("
+ GetCurrentThreadName() + ").");
}
+
+ // Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (!s_create_empty_) {
throw Exception(
"Can't instantiate Datas directly; use ba.getdata() to get "
@@ -71,6 +76,7 @@ auto PythonClassData::tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
}
self->data_ = new Object::Ref();
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
diff --git a/src/ballistica/python/class/python_class_input_device.cc b/src/ballistica/python/class/python_class_input_device.cc
index ec38cefc..de70685d 100644
--- a/src/ballistica/python/class/python_class_input_device.cc
+++ b/src/ballistica/python/class/python_class_input_device.cc
@@ -244,6 +244,10 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self,
BA_PYTHON_CATCH;
}
+// Yes Clion, we always return -1 here.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantFunctionResult"
+
auto PythonClassInputDevice::tp_setattro(PythonClassInputDevice* self,
PyObject* attr, PyObject* val) -> int {
BA_PYTHON_TRY;
@@ -255,6 +259,8 @@ auto PythonClassInputDevice::tp_setattro(PythonClassInputDevice* self,
BA_PYTHON_INT_CATCH;
}
+#pragma clang diagnostic pop
+
auto PythonClassInputDevice::RemoveRemotePlayerFromGame(
PythonClassInputDevice* self) -> PyObject* {
BA_PYTHON_TRY;
diff --git a/src/ballistica/python/class/python_class_material.cc b/src/ballistica/python/class/python_class_material.cc
index 78e8f4a8..16ac06a9 100644
--- a/src/ballistica/python/class/python_class_material.cc
+++ b/src/ballistica/python/class/python_class_material.cc
@@ -97,6 +97,11 @@ auto PythonClassMaterial::tp_new(PyTypeObject* type, PyObject* args,
PyObject* name_obj = Py_None;
std::string name;
Object::Ref m;
+
+ // Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
if (!s_create_empty_) {
static const char* kwlist[] = {"label", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|O",
@@ -119,6 +124,7 @@ auto PythonClassMaterial::tp_new(PyTypeObject* type, PyObject* args,
}
self->material_ = new Object::Ref(m);
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
@@ -181,6 +187,10 @@ auto PythonClassMaterial::tp_getattro(PythonClassMaterial* self, PyObject* attr)
BA_PYTHON_CATCH;
}
+// Yes Clion, we always return -1 here.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantFunctionResult"
+
auto PythonClassMaterial::tp_setattro(PythonClassMaterial* self, PyObject* attr,
PyObject* val) -> int {
BA_PYTHON_TRY;
@@ -195,6 +205,8 @@ auto PythonClassMaterial::tp_setattro(PythonClassMaterial* self, PyObject* attr,
BA_PYTHON_INT_CATCH;
}
+#pragma clang diagnostic pop
+
auto PythonClassMaterial::Dir(PythonClassMaterial* self) -> PyObject* {
BA_PYTHON_TRY;
diff --git a/src/ballistica/python/class/python_class_model.cc b/src/ballistica/python/class/python_class_model.cc
index 9a2a0fc8..fc2c7406 100644
--- a/src/ballistica/python/class/python_class_model.cc
+++ b/src/ballistica/python/class/python_class_model.cc
@@ -64,6 +64,10 @@ auto PythonClassModel::tp_new(PyTypeObject* type, PyObject* args,
+ " objects must only be created in the game thread (current is ("
+ GetCurrentThreadName() + ").");
}
+ // Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (!s_create_empty_) {
throw Exception(
"Can't instantiate Models directly; use ba.getmodel() to get "
@@ -71,6 +75,7 @@ auto PythonClassModel::tp_new(PyTypeObject* type, PyObject* args,
}
self->model_ = new Object::Ref();
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
diff --git a/src/ballistica/python/class/python_class_node.cc b/src/ballistica/python/class/python_class_node.cc
index f40fac28..bc813ea6 100644
--- a/src/ballistica/python/class/python_class_node.cc
+++ b/src/ballistica/python/class/python_class_node.cc
@@ -89,6 +89,9 @@ auto PythonClassNode::tp_new(PyTypeObject* type, PyObject* args,
+ " objects must only be created in the game thread (current is ("
+ GetCurrentThreadName() + ").");
}
+ // Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (!s_create_empty_) {
if (!PyTuple_Check(args) || (PyTuple_GET_SIZE(args) != 1)
|| (keywds != nullptr) || (PyTuple_GET_ITEM(args, 0) != Py_None)) {
@@ -99,6 +102,7 @@ auto PythonClassNode::tp_new(PyTypeObject* type, PyObject* args,
}
self->node_ = new Object::WeakRef();
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
diff --git a/src/ballistica/python/class/python_class_session_player.cc b/src/ballistica/python/class/python_class_session_player.cc
index 6fea19b6..cefc59f9 100644
--- a/src/ballistica/python/class/python_class_session_player.cc
+++ b/src/ballistica/python/class/python_class_session_player.cc
@@ -163,6 +163,10 @@ auto PythonClassSessionPlayer::tp_new(PyTypeObject* type, PyObject* args,
// If the user is creating one, make sure they passed None to get an
// invalid ref.
+ // Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
if (!s_create_empty_) {
if (!PyTuple_Check(args) || (PyTuple_GET_SIZE(args) != 1)
|| (keywds != nullptr) || (PyTuple_GET_ITEM(args, 0) != Py_None))
@@ -172,6 +176,7 @@ auto PythonClassSessionPlayer::tp_new(PyTypeObject* type, PyObject* args,
}
self->player_ = new Object::WeakRef();
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
diff --git a/src/ballistica/python/class/python_class_sound.cc b/src/ballistica/python/class/python_class_sound.cc
index c349cacc..74e4e098 100644
--- a/src/ballistica/python/class/python_class_sound.cc
+++ b/src/ballistica/python/class/python_class_sound.cc
@@ -63,6 +63,10 @@ auto PythonClassSound::tp_new(PyTypeObject* type, PyObject* args,
+ " objects must only be created in the game thread (current is ("
+ GetCurrentThreadName() + ").");
}
+ // Clion incorrectly things s_create_empty will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (!s_create_empty_) {
throw Exception(
"Can't instantiate Sounds directly; use ba.getsound() to get "
@@ -70,6 +74,7 @@ auto PythonClassSound::tp_new(PyTypeObject* type, PyObject* args,
}
self->sound_ = new Object::Ref();
BA_PYTHON_NEW_CATCH;
+#pragma clang diagnostic pop
}
return reinterpret_cast(self);
}
diff --git a/src/ballistica/python/methods/python_methods_app.cc b/src/ballistica/python/methods/python_methods_app.cc
index 02c58d89..dcbca8f6 100644
--- a/src/ballistica/python/methods/python_methods_app.cc
+++ b/src/ballistica/python/methods/python_methods_app.cc
@@ -605,6 +605,9 @@ auto PyQuit(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
// A few types get handled specially on android.
if (g_buildconfig.ostype_android()) {
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantConditionsOC"
+
if (!handled && back) {
// Back-quit simply synthesizes a back press.
// Note to self: I remember this behaved slightly differently than
@@ -612,6 +615,9 @@ auto PyQuit(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
g_platform->AndroidSynthesizeBackPress();
handled = true;
}
+
+#pragma clang diagnostic pop
+
if (!handled && soft) {
// Soft-quit just kills our activity but doesn't run app shutdown.
// Thus we'll be able to spin back up (reset to the main menu)
@@ -735,8 +741,6 @@ auto PyEnv(PyObject* self) -> PyObject* {
is_test_build_obj = Py_False;
#endif
bool demo_mode{g_buildconfig.demo_build()};
- bool arcade_mode{g_buildconfig.arcade_build()};
- bool iircade_mode{g_buildconfig.arcade_build()};
const char* ui_scale;
switch (GetUIScale()) {
diff --git a/src/ballistica/python/methods/python_methods_system.cc b/src/ballistica/python/methods/python_methods_system.cc
index 2977e36e..ed2d65cd 100644
--- a/src/ballistica/python/methods/python_methods_system.cc
+++ b/src/ballistica/python/methods/python_methods_system.cc
@@ -709,6 +709,9 @@ auto PyAndroidMediaScanFile(PyObject* self, PyObject* args, PyObject* keywds)
BA_PYTHON_CATCH;
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantFunctionResult"
+
auto PyAndroidGetExternalStoragePath(PyObject* self, PyObject* args,
PyObject* keywds) -> PyObject* {
BA_PYTHON_TRY;
@@ -732,6 +735,7 @@ auto PyAndroidGetExternalStoragePath(PyObject* self, PyObject* args,
Py_RETURN_NONE;
BA_PYTHON_CATCH;
}
+#pragma clang diagnostic pop
auto PyAndroidShowWifiSettings(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* {
diff --git a/src/ballistica/python/methods/python_methods_ui.cc b/src/ballistica/python/methods/python_methods_ui.cc
index 9308c4ca..5aa77f39 100644
--- a/src/ballistica/python/methods/python_methods_ui.cc
+++ b/src/ballistica/python/methods/python_methods_ui.cc
@@ -316,7 +316,8 @@ auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds)
#if BA_TEST_BUILD
g_python->TimeFormatCheck(TimeFormat::kSeconds, transition_delay_obj);
#endif
- b->set_transition_delay(1000.0f * Python::GetPyFloat(transition_delay_obj));
+ b->set_transition_delay(static_cast(
+ 1000.0f * Python::GetPyFloat(transition_delay_obj)));
}
if (text_res_scale_obj != Py_None) {
b->SetTextResScale(Python::GetPyFloat(text_res_scale_obj));
diff --git a/src/ballistica/python/python.cc b/src/ballistica/python/python.cc
index 30477afe..84e9500d 100644
--- a/src/ballistica/python/python.cc
+++ b/src/ballistica/python/python.cc
@@ -964,10 +964,10 @@ void Python::Reset(bool do_init) {
throw std::logic_error(
"Error in ba Python bootstrapping. See log for details.");
}
- PyObject* appstate =
- PythonCommand("_app_state", "").RunReturnObj();
+ PyObject* appstate = PythonCommand("app_state", "")
+ .RunReturnObj(false, nullptr);
if (appstate == nullptr) {
- throw Exception("Unable to get value: '" + std::string("_app_state")
+ throw Exception("Unable to get value: '" + std::string("app_state")
+ "'.");
}
SetObj(ObjID::kApp, appstate);
@@ -2375,16 +2375,18 @@ void Python::SetObjCallable(ObjID id, PyObject* pyobj, bool incref) {
BA_PRECONDITION(obj(id).CallableCheck());
}
-void Python::SetObj(ObjID id, const char* expr) {
- PyObject* obj = PythonCommand(expr, "").RunReturnObj();
+void Python::SetObj(ObjID id, const char* expr, PyObject* context) {
+ PyObject* obj =
+ PythonCommand(expr, "").RunReturnObj(false, context);
if (obj == nullptr) {
throw Exception("Unable to get value: '" + std::string(expr) + "'.");
}
SetObj(id, obj);
}
-void Python::SetObjCallable(ObjID id, const char* expr) {
- PyObject* obj = PythonCommand(expr, "").RunReturnObj();
+void Python::SetObjCallable(ObjID id, const char* expr, PyObject* context) {
+ PyObject* obj =
+ PythonCommand(expr, "").RunReturnObj(false, context);
if (obj == nullptr) {
throw Exception("Unable to get value: '" + std::string(expr) + "'.");
}
diff --git a/src/ballistica/python/python.h b/src/ballistica/python/python.h
index c74f7424..39ef32ea 100644
--- a/src/ballistica/python/python.h
+++ b/src/ballistica/python/python.h
@@ -402,11 +402,12 @@ class Python {
void SetObjCallable(ObjID id, PyObject* pyobj, bool incref = false);
/// Set the value for a named object to the result of a Python expression.
- void SetObj(ObjID id, const char* expression);
+ void SetObj(ObjID id, const char* expression, PyObject* context = nullptr);
/// Set the value for a named object to the result of a Python expression
/// and verify that it is callable.
- void SetObjCallable(ObjID id, const char* expression);
+ void SetObjCallable(ObjID id, const char* expression,
+ PyObject* context = nullptr);
std::set do_once_locations_;
PythonRef objs_[static_cast(ObjID::kLast)];
diff --git a/src/ballistica/python/python_command.cc b/src/ballistica/python/python_command.cc
index a84f8536..bf13f7f7 100644
--- a/src/ballistica/python/python_command.cc
+++ b/src/ballistica/python/python_command.cc
@@ -136,10 +136,16 @@ auto PythonCommand::CanEval() -> bool {
return true;
}
-auto PythonCommand::RunReturnObj(bool print_errors) -> PyObject* {
+auto PythonCommand::RunReturnObj(bool print_errors, PyObject* context)
+ -> PyObject* {
assert(Python::HaveGIL());
assert(g_python);
assert(!dead_);
+ if (context == nullptr) {
+ context = g_python->main_dict();
+ }
+ assert(PyDict_Check(context));
+
if (!eval_code_obj_.get()) {
CompileForEval(print_errors);
assert(!dead_);
@@ -164,8 +170,7 @@ auto PythonCommand::RunReturnObj(bool print_errors) -> PyObject* {
return nullptr;
}
PUSH_PYCOMMAND(this);
- PyObject* v = PyEval_EvalCode(eval_code_obj_.get(), g_python->main_dict(),
- g_python->main_dict());
+ PyObject* v = PyEval_EvalCode(eval_code_obj_.get(), context, context);
POP_PYCOMMAND();
assert(!dead_);
if (v == nullptr) {
diff --git a/src/ballistica/python/python_command.h b/src/ballistica/python/python_command.h
index e6029ee0..f91e729f 100644
--- a/src/ballistica/python/python_command.h
+++ b/src/ballistica/python/python_command.h
@@ -49,7 +49,7 @@ class PythonCommand {
/// Run thecommand and return the result as a new Python reference.
/// Only works for eval-able commands.
/// Returns nullptr on errors, but Python error state will be cleared.
- auto RunReturnObj(bool print_errors = false) -> PyObject*;
+ auto RunReturnObj(bool print_errors, PyObject* context) -> PyObject*;
void LogContext();
diff --git a/src/ballistica/scene/node/anim_curve_node.cc b/src/ballistica/scene/node/anim_curve_node.cc
index 7531eb53..2ae3471a 100644
--- a/src/ballistica/scene/node/anim_curve_node.cc
+++ b/src/ballistica/scene/node/anim_curve_node.cc
@@ -51,10 +51,10 @@ auto AnimCurveNode::GetOut() -> float {
}
for (size_t i = 0; i < num; i++) {
if (i == 0) {
- input_start_ = times_[i];
+ input_start_ = static_cast(times_[i]);
}
if (i == (num - 1)) {
- input_end_ = times_[i];
+ input_end_ = static_cast(times_[i]);
}
keyframes_.emplace_back(times_[i], values_[i]);
}
@@ -73,7 +73,9 @@ auto AnimCurveNode::GetOut() -> float {
bool got;
if (loop_) {
in_val = fmodf(in_val, (input_end_ - input_start_));
- if (in_val < 0) in_val += (input_end_ - input_start_);
+ if (in_val < 0) {
+ in_val += (input_end_ - input_start_);
+ }
got = false;
} else {
if (in_val >= input_end_) {
@@ -97,7 +99,7 @@ auto AnimCurveNode::GetOut() -> float {
if (i == keyframes_.end()) {
break;
}
- if (i->time < in_val) {
+ if (static_cast(i->time) < in_val) {
i++;
i1 = i2;
i2 = i;
@@ -109,7 +111,7 @@ auto AnimCurveNode::GetOut() -> float {
out_ = i1->value;
} else {
out_ = i1->value
- + ((in_val - i1->time)
+ + ((in_val - static_cast(i1->time))
/ static_cast(i2->time - i1->time))
* (i2->value - i1->value);
}
diff --git a/src/ballistica/scene/node/bomb_node.cc b/src/ballistica/scene/node/bomb_node.cc
index c39bfa3b..9ebdddd3 100644
--- a/src/ballistica/scene/node/bomb_node.cc
+++ b/src/ballistica/scene/node/bomb_node.cc
@@ -53,10 +53,9 @@ void BombNode::Step() {
dVector3 fuse_tip_pos;
dGeomGetRelPointPos(body_->geom(), 0, (fuse_length_ + kFuseOffset), 0,
fuse_tip_pos);
- light_translate_ = fuse_tip_pos;
- light_translate_.x += body_->blend_offset().x;
- light_translate_.y += body_->blend_offset().y;
- light_translate_.z += body_->blend_offset().z;
+ light_translate_.x = fuse_tip_pos[0] + body_->blend_offset().x;
+ light_translate_.y = fuse_tip_pos[1] + body_->blend_offset().y;
+ light_translate_.z = fuse_tip_pos[2] + body_->blend_offset().z;
#if !BA_HEADLESS_BUILD
fuse_.SetTransform(Matrix44fTranslate(0, kFuseOffset * model_scale_, 0)
* body_->GetTransform());
diff --git a/src/ballistica/scene/node/globals_node.cc b/src/ballistica/scene/node/globals_node.cc
index 80a35b9f..28b1f215 100644
--- a/src/ballistica/scene/node/globals_node.cc
+++ b/src/ballistica/scene/node/globals_node.cc
@@ -351,10 +351,6 @@ auto GlobalsNode::GetCameraMode() const -> std::string {
return "rotate";
case CameraMode::kFollow:
return "follow";
- default:
- Log("ERROR: Globals: Unrecognized camera_mode_: "
- + std::to_string(static_cast(camera_mode_)));
- return "unknown";
}
}
diff --git a/src/ballistica/scene/node/image_node.cc b/src/ballistica/scene/node/image_node.cc
index e4667da0..309d3be1 100644
--- a/src/ballistica/scene/node/image_node.cc
+++ b/src/ballistica/scene/node/image_node.cc
@@ -93,9 +93,6 @@ auto ImageNode::GetAttach() const -> std::string {
return "bottomLeft";
case Attach::CENTER_LEFT:
return "centerLeft";
- default:
- throw Exception("Invalid attach val in ImageNode "
- + std::to_string(static_cast(attach_)));
}
}
diff --git a/src/ballistica/scene/node/locator_node.cc b/src/ballistica/scene/node/locator_node.cc
index c3b5bbd9..48c4a04f 100644
--- a/src/ballistica/scene/node/locator_node.cc
+++ b/src/ballistica/scene/node/locator_node.cc
@@ -53,9 +53,6 @@ auto LocatorNode::getShape() const -> std::string {
return "circleOutline";
case Shape::kLocator:
return "locator";
- default:
- throw Exception("Invalid shape val: "
- + std::to_string(static_cast(shape_)));
}
}
@@ -125,13 +122,16 @@ void LocatorNode::Draw(FrameDef* frame_def) {
}
bool transparent = false;
- if (shape_ == Shape::kCircle || shape_ == Shape::kCircleOutline)
+ if (shape_ == Shape::kCircle || shape_ == Shape::kCircleOutline) {
transparent = true;
+ }
// beauty
if (draw_beauty_) {
SimpleComponent c(frame_def->beauty_pass());
- if (transparent) c.SetTransparent(true);
+ if (transparent) {
+ c.SetTransparent(true);
+ }
c.SetColor(color_[0], color_[1], color_[2], opacity_);
c.SetTexture(g_media->GetTexture(texture));
c.PushTransform();
@@ -146,11 +146,10 @@ void LocatorNode::Draw(FrameDef* frame_def) {
// colored shadow for circle
if (shape_ == Shape::kCircle || shape_ == Shape::kCircleOutline) {
SimpleComponent c(frame_def->light_shadow_pass());
- if (transparent) {
- c.SetTransparent(true);
- if (additive_) {
- c.SetPremultiplied(true);
- }
+ assert(transparent);
+ c.SetTransparent(true);
+ if (additive_) {
+ c.SetPremultiplied(true);
}
if (additive_) {
c.SetColor(color_[0] * opacity_, color_[1] * opacity_,
diff --git a/src/ballistica/scene/node/math_node.cc b/src/ballistica/scene/node/math_node.cc
index 40dbccd0..1054bfca 100644
--- a/src/ballistica/scene/node/math_node.cc
+++ b/src/ballistica/scene/node/math_node.cc
@@ -46,9 +46,6 @@ auto MathNode::GetOperation() const -> std::string {
return "divide";
case Operation::kSin:
return "sin";
- default:
- throw Exception("invalid operation: "
- + std::to_string(static_cast(operation_)));
}
}
@@ -102,10 +99,6 @@ auto MathNode::GetOutput() -> std::vector {
}
break;
}
- default:
- BA_LOG_ONCE("Error: invalid math op in getOutput(): "
- + std::to_string(static_cast(operation_)));
- break;
}
return outputs;
}
diff --git a/src/ballistica/scene/node/node_attribute.cc b/src/ballistica/scene/node/node_attribute.cc
index 6175313d..d940857f 100644
--- a/src/ballistica/scene/node/node_attribute.cc
+++ b/src/ballistica/scene/node/node_attribute.cc
@@ -87,7 +87,8 @@ void NodeAttributeUnbound::DisconnectIncoming(Node* node) {
Object::WeakRef test_ref(a);
#endif
- assert(a && a->src_node.exists());
+ assert(a != nullptr);
+ assert(a->src_node.exists());
// Remove from src node's outgoing list.
a->src_node->attribute_connections_.erase(a->src_iterator);
diff --git a/src/ballistica/scene/node/text_node.cc b/src/ballistica/scene/node/text_node.cc
index 2fa616d4..8a73f839 100644
--- a/src/ballistica/scene/node/text_node.cc
+++ b/src/ballistica/scene/node/text_node.cc
@@ -135,16 +135,13 @@ void TextNode::SetBig(bool val) {
}
auto TextNode::GetHAlign() const -> std::string {
- if (h_align_ == HAlign::kLeft) {
- return "left";
- } else if (h_align_ == HAlign::kRight) {
- return "right";
- } else if (h_align_ == HAlign::kCenter) {
- return "center";
- } else {
- BA_LOG_ONCE("Error: Invalid h_align value in text-node: "
- + std::to_string(static_cast(h_align_)));
- return "";
+ switch (h_align_) {
+ case HAlign::kLeft:
+ return "left";
+ case HAlign::kRight:
+ return "right";
+ case HAlign::kCenter:
+ return "center";
}
}
@@ -162,18 +159,15 @@ void TextNode::SetHAlign(const std::string& val) {
}
auto TextNode::GetVAlign() const -> std::string {
- if (v_align_ == VAlign::kTop) {
- return "top";
- } else if (v_align_ == VAlign::kBottom) {
- return "bottom";
- } else if (v_align_ == VAlign::kCenter) {
- return "center";
- } else if (v_align_ == VAlign::kNone) {
- return "none";
- } else {
- BA_LOG_ONCE("Error: Invalid v_align value in text-node: "
- + std::to_string(static_cast(v_align_)));
- return "";
+ switch (v_align_) {
+ case VAlign::kTop:
+ return "top";
+ case VAlign::kBottom:
+ return "bottom";
+ case VAlign::kCenter:
+ return "center";
+ case VAlign::kNone:
+ return "none";
}
}
@@ -193,16 +187,13 @@ void TextNode::SetVAlign(const std::string& val) {
}
auto TextNode::GetHAttach() const -> std::string {
- if (h_attach_ == HAttach::kLeft) {
- return "left";
- } else if (h_attach_ == HAttach::kRight) {
- return "right";
- } else if (h_attach_ == HAttach::kCenter) {
- return "center";
- } else {
- BA_LOG_ONCE("Error: Invalid h_attach value in text-node: "
- + std::to_string(static_cast(h_attach_)));
- return "";
+ switch (h_attach_) {
+ case HAttach::kLeft:
+ return "left";
+ case HAttach::kRight:
+ return "right";
+ case HAttach::kCenter:
+ return "center";
}
}
@@ -220,16 +211,13 @@ void TextNode::SetHAttach(const std::string& val) {
}
auto TextNode::GetVAttach() const -> std::string {
- if (v_attach_ == VAttach::kTop) {
- return "top";
- } else if (v_attach_ == VAttach::kBottom) {
- return "bottom";
- } else if (v_attach_ == VAttach::kCenter) {
- return "center";
- } else {
- BA_LOG_ONCE("Error: Invalid v_attach value in text-node: "
- + std::to_string(static_cast(v_attach_)));
- return "";
+ switch (v_attach_) {
+ case VAttach::kTop:
+ return "top";
+ case VAttach::kBottom:
+ return "bottom";
+ case VAttach::kCenter:
+ return "center";
}
}
@@ -288,23 +276,27 @@ void TextNode::Update() {
offset_v = 0.0f;
} else {
// Screen space; apply alignment and stuff.
- if (h_attach_ == HAttach::kLeft) {
- offset_h = 0;
- } else if (h_attach_ == HAttach::kRight) {
- offset_h = g_graphics->screen_virtual_width();
- } else if (h_attach_ == HAttach::kCenter) {
- offset_h = g_graphics->screen_virtual_width() / 2;
- } else {
- throw Exception("invalid h_attach");
+ switch (h_attach_) {
+ case HAttach::kLeft:
+ offset_h = 0;
+ break;
+ case HAttach::kRight:
+ offset_h = g_graphics->screen_virtual_width();
+ break;
+ case HAttach::kCenter:
+ offset_h = g_graphics->screen_virtual_width() / 2;
+ break;
}
- if (v_attach_ == VAttach::kTop) {
- offset_v = g_graphics->screen_virtual_height();
- } else if (v_attach_ == VAttach::kBottom) {
- offset_v = 0;
- } else if (v_attach_ == VAttach::kCenter) {
- offset_v = g_graphics->screen_virtual_height() / 2;
- } else {
- throw Exception("invalid v_attach");
+ switch (v_attach_) {
+ case VAttach::kTop:
+ offset_v = g_graphics->screen_virtual_height();
+ break;
+ case VAttach::kBottom:
+ offset_v = 0;
+ break;
+ case VAttach::kCenter:
+ offset_v = g_graphics->screen_virtual_height() / 2;
+ break;
}
}
position_final_ = position_;
@@ -377,8 +369,6 @@ void TextNode::Draw(FrameDef* frame_def) {
case HAlign::kCenter:
h_align = TextMesh::HAlign::kCenter;
break;
- default:
- throw Exception();
}
TextMesh::VAlign v_align;
@@ -395,8 +385,6 @@ void TextNode::Draw(FrameDef* frame_def) {
case VAlign::kBottom:
v_align = TextMesh::VAlign::kBottom;
break;
- default:
- throw Exception();
}
// update if need be
@@ -552,8 +540,6 @@ void TextNode::Draw(FrameDef* frame_def) {
case HAlign::kCenter:
h_align = TextMesh::HAlign::kCenter;
break;
- default:
- throw Exception();
}
TextMesh::VAlign v_align;
@@ -570,8 +556,6 @@ void TextNode::Draw(FrameDef* frame_def) {
case VAlign::kBottom:
v_align = TextMesh::VAlign::kBottom;
break;
- default:
- throw Exception();
}
// Update if need be.
diff --git a/src/ballistica/scene/scene.cc b/src/ballistica/scene/scene.cc
index 15476a03..90eecc0a 100644
--- a/src/ballistica/scene/scene.cc
+++ b/src/ballistica/scene/scene.cc
@@ -261,12 +261,17 @@ void Scene::Step() {
void Scene::DeleteNode(Node* node) {
assert(node);
+ // Clion incorrectly things in_step_ will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (in_step_) {
throw Exception(
"Cannot delete nodes within a sim step."
" Consider a deferred call or timer. Node="
+ node->GetObjectDescription());
}
+#pragma clang diagnostic pop
// Copy refs to its death-actions and dependent-nodes; we'll deal with these
// after the node is dead so we're sure they don't muck with the node.
@@ -341,11 +346,16 @@ auto Scene::NewNode(const std::string& type_string, const std::string& name,
PyObject* delegate) -> Node* {
assert(InGameThread());
+ // Clion incorrectly things in_step_ will always be false.
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
+#pragma ide diagnostic ignored "ConstantConditionsOC"
if (in_step_) {
throw Exception(
"Cannot create nodes within a sim step."
" Consider a deferred call or timer.");
}
+#pragma clang diagnostic pop
// Should never change the scene while we're stepping it.
assert(!in_step_);
diff --git a/src/ballistica/ui/widget/button_widget.cc b/src/ballistica/ui/widget/button_widget.cc
index 5ed3e2a7..5822d6b2 100644
--- a/src/ballistica/ui/widget/button_widget.cc
+++ b/src/ballistica/ui/widget/button_widget.cc
@@ -169,7 +169,7 @@ void ButtonWidget::Draw(RenderPass* pass, bool draw_transparent) {
// Simple transition.
millisecs_t transition = (birth_time_ + transition_delay_) - current_time;
if (transition > 0) {
- extra_offs_x -= transition * 4.0f;
+ extra_offs_x -= static_cast(transition) * 4.0f;
}
if (text_width_dirty_) {
diff --git a/src/ballistica/ui/widget/root_widget.cc b/src/ballistica/ui/widget/root_widget.cc
index 2797967a..789356ef 100644
--- a/src/ballistica/ui/widget/root_widget.cc
+++ b/src/ballistica/ui/widget/root_widget.cc
@@ -72,7 +72,7 @@ struct RootWidget::Button {
float height{30.0f};
float scale{1.0f};
bool selectable{true};
- int visibility_mask{};
+ uint32_t visibility_mask{};
};
// for adding text label decorations to buttons
@@ -134,7 +134,7 @@ auto RootWidget::AddCover(float h_align, VAlign v_align, float x, float y,
bd.call = Python::ObjID::kEmptyCall;
bd.visibility_mask =
- static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
+ static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
// when the user specifies no backing it means they intend to cover the screen
// with a flat-ish window texture.. however this only applies to phone-size;
// for other sizes we always draw a backing.
@@ -147,6 +147,9 @@ auto RootWidget::AddCover(float h_align, VAlign v_align, float x, float y,
return b;
}
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "ConstantParameter"
+
void RootWidget::AddMeter(float h_align, float x, int type, float r, float g,
float b, bool plus, const std::string& s) {
float yoffs = (GetUIScale() == UIScale::kSmall) ? 0.0f : -7.0f;
@@ -231,8 +234,12 @@ void RootWidget::AddMeter(float h_align, float x, int type, float r, float g,
bd.img = "tickets";
bd.call = Python::ObjID::kTicketIconPressCall;
break;
+
+#pragma clang diagnostic push
+#pragma ide diagnostic ignored "UnreachableCode"
default:
break;
+#pragma clang diagnostic pop
}
bd.visibility_mask =
(static_cast(Widget::ToolbarVisibility::kMenuFull)
@@ -306,8 +313,12 @@ void RootWidget::AddMeter(float h_align, float x, int type, float r, float g,
}
}
+#pragma clang diagnostic pop
+
void RootWidget::Setup() {
-#if BA_TOOLBAR_TEST
+ if (!explicit_bool(BA_TOOLBAR_TEST)) {
+ return;
+ }
// back button
{
@@ -324,8 +335,8 @@ void RootWidget::Setup() {
bd.img = "nub";
bd.call = Python::ObjID::kBackButtonPressCall;
bd.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuMinimal)
- | static_cast(Widget::ToolbarVisibility::kMenuFull));
+ (static_cast(Widget::ToolbarVisibility::kMenuMinimal)
+ | static_cast(Widget::ToolbarVisibility::kMenuFull));
Button* b = back_button_ = AddButton(bd);
// clan
@@ -353,11 +364,11 @@ void RootWidget::Setup() {
// }
// if (c) {
// c->visibility_mask |=
- // static_cast(Widget::ToolbarVisibility::kMenuCurrency);
+ // static_cast(Widget::ToolbarVisibility::kMenuCurrency);
// }
// top bar backing (currency only)
- if (false) {
+ if (explicit_bool(false)) {
ButtonDef bd;
bd.h_align = 0.5f;
bd.v_align = VAlign::kTop;
@@ -392,16 +403,16 @@ void RootWidget::Setup() {
bd.call = Python::ObjID::kEmptyCall;
// bd.visibility_mask =
- // static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
+ // static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
// bd.visibility_mask |=
- // static_cast(Widget::ToolbarVisibility::kMenuFull);
+ // static_cast(Widget::ToolbarVisibility::kMenuFull);
bd.visibility_mask |=
- static_cast(Widget::ToolbarVisibility::kMenuCurrency);
+ static_cast(Widget::ToolbarVisibility::kMenuCurrency);
AddButton(bd);
}
// top bar backing
- if (false) {
+ if (explicit_bool(false)) {
ButtonDef bd;
bd.h_align = 0.5f;
bd.v_align = VAlign::kTop;
@@ -413,11 +424,7 @@ void RootWidget::Setup() {
bd.x = 0.0f;
bd.y = -20.0f;
bd.img = "uiAtlas2";
- if (GetUIScale() != UIScale::kSmall) {
- bd.model_transparent = "toolbarBackingTop2";
- } else {
- bd.model_transparent = "toolbarBackingTop2";
- }
+ bd.model_transparent = "toolbarBackingTop2";
bd.selectable = false;
bd.color_r = 0.44f;
bd.color_g = 0.41f;
@@ -435,11 +442,11 @@ void RootWidget::Setup() {
// bd.call = "";
bd.call = Python::ObjID::kEmptyCall;
bd.visibility_mask =
- static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
+ static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
bd.visibility_mask |=
- static_cast(Widget::ToolbarVisibility::kMenuFull);
+ static_cast(Widget::ToolbarVisibility::kMenuFull);
// bd.visibility_mask |=
- // static_cast(Widget::ToolbarVisibility::kMenuCurrency);
+ // static_cast(Widget::ToolbarVisibility::kMenuCurrency);
AddButton(bd);
}
@@ -466,8 +473,8 @@ void RootWidget::Setup() {
// bd.call = "";
bd.call = Python::ObjID::kEmptyCall;
bd.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
// on desktop, stick this in the top left corner
// if (GetUIScale() == UIScale::kLarge) {
@@ -527,12 +534,12 @@ void RootWidget::Setup() {
b.img = "usersButton";
b.call = Python::ObjID::kFriendsButtonPressCall;
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kInGame)
- | static_cast(Widget::ToolbarVisibility::kMenuMinimal)
- | static_cast(Widget::ToolbarVisibility::kMenuMinimalNoBack)
- | static_cast(Widget::ToolbarVisibility::kMenuCurrency)
- | static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kInGame)
+ | static_cast(Widget::ToolbarVisibility::kMenuMinimal)
+ | static_cast(Widget::ToolbarVisibility::kMenuMinimalNoBack)
+ | static_cast(Widget::ToolbarVisibility::kMenuCurrency)
+ | static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
party_button_ = AddButton(b);
}
@@ -551,12 +558,12 @@ void RootWidget::Setup() {
b.color_g = 0.5f;
b.color_b = 0.2f;
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kInGame)
- | static_cast(Widget::ToolbarVisibility::kMenuMinimal)
- | static_cast(Widget::ToolbarVisibility::kMenuMinimalNoBack)
- | static_cast(Widget::ToolbarVisibility::kMenuCurrency)
- | static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kInGame)
+ | static_cast(Widget::ToolbarVisibility::kMenuMinimal)
+ | static_cast(Widget::ToolbarVisibility::kMenuMinimalNoBack)
+ | static_cast(Widget::ToolbarVisibility::kMenuCurrency)
+ | static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
menu_button_ = AddButton(b);
}
@@ -578,8 +585,8 @@ void RootWidget::Setup() {
b.color_b = BOT_LEFT_COLOR_B;
b.img = "logIcon";
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
AddButton(b);
}
@@ -598,8 +605,8 @@ void RootWidget::Setup() {
b.color_b = BOT_LEFT_COLOR_B;
b.img = "achievementsIcon";
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
AddButton(b);
}
@@ -618,8 +625,8 @@ void RootWidget::Setup() {
b.color_b = BOT_LEFT_COLOR_B;
b.img = "leaderboardsIcon";
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
AddButton(b);
}
@@ -638,8 +645,8 @@ void RootWidget::Setup() {
b.color_b = BOT_LEFT_COLOR_B;
b.img = "settingsIcon";
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
settings_button_ = AddButton(b);
}
@@ -682,11 +689,7 @@ void RootWidget::Setup() {
bd.x = 0.0f;
bd.y = 41.0f;
bd.img = "uiAtlas2";
- if (GetUIScale() != UIScale::kSmall) {
- bd.model_transparent = "toolbarBackingBottom2";
- } else {
- bd.model_transparent = "toolbarBackingBottom2";
- }
+ bd.model_transparent = "toolbarBackingBottom2";
bd.selectable = false;
bd.color_r = backingR;
bd.color_g = backingG;
@@ -697,9 +700,9 @@ void RootWidget::Setup() {
// bd.call = "";
bd.call = Python::ObjID::kEmptyCall;
bd.visibility_mask =
- static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
+ static_cast(Widget::ToolbarVisibility::kMenuFullRoot);
bd.visibility_mask |=
- static_cast(Widget::ToolbarVisibility::kMenuFull);
+ static_cast(Widget::ToolbarVisibility::kMenuFull);
AddButton(bd);
}
@@ -713,8 +716,8 @@ void RootWidget::Setup() {
b.img = "chestIcon";
b.depth_min = 0.3f;
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
float spacing = 110.0f;
b.x = -2.0f * spacing;
AddButton(b);
@@ -756,7 +759,7 @@ void RootWidget::Setup() {
// b.y = b.height * 0.5f + 10;
// b.img = "settingsIcon";
// b.visibility_mask =
- // (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ // (static_cast(Widget::ToolbarVisibility::kMenuFull)
// |
// static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
// AddButton(b);
@@ -772,8 +775,8 @@ void RootWidget::Setup() {
b.y = b.height * 0.5f;
b.img = "storeIcon";
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
AddButton(b);
}
@@ -787,13 +790,11 @@ void RootWidget::Setup() {
b.y = b.height * 0.45f;
b.img = "inventoryIcon";
b.visibility_mask =
- (static_cast(Widget::ToolbarVisibility::kMenuFull)
- | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
+ (static_cast(Widget::ToolbarVisibility::kMenuFull)
+ | static_cast(Widget::ToolbarVisibility::kMenuFullRoot));
AddButton(b);
}
-#endif // BA_TOOLBAR_TEST
-
UpdateForFocusedWindow(nullptr);
}
@@ -802,8 +803,9 @@ void RootWidget::Draw(RenderPass* pass, bool transparent) {
// motion.
if (!transparent) {
millisecs_t current_time = pass->frame_def()->base_time();
- float time_diff = std::min(millisecs_t{100}, current_time - update_time_);
- StepPositions(time_diff);
+ millisecs_t time_diff =
+ std::min(millisecs_t{100}, current_time - update_time_);
+ StepPositions(static_cast(time_diff));
update_time_ = current_time;
}
ContainerWidget::Draw(pass, transparent);
@@ -1099,9 +1101,9 @@ void RootWidget::SetScreenWidget(StackWidget* w) {
void RootWidget::SetOverlayWidget(StackWidget* w) {
// this needs to happen after our buttons and things get added..
-#if BA_TOOLBAR_TEST
- assert(!buttons_.empty());
-#endif // BA_TOOLBAR_TEST
+ if (explicit_bool(BA_TOOLBAR_TEST)) {
+ assert(!buttons_.empty());
+ }
AddWidget(w);
overlay_stack_widget_ = w;
}
diff --git a/src/generated_src/ballistica/bootstrap.py b/src/generated_src/ballistica/bootstrap.py
index babfd660..50cc1def 100644
--- a/src/generated_src/ballistica/bootstrap.py
+++ b/src/generated_src/ballistica/bootstrap.py
@@ -141,7 +141,7 @@ def _ballistica_bootstrap() -> object:
return app
-_app_state = _ballistica_bootstrap()
+app_state = _ballistica_bootstrap()
# This code runs in the main namespace, so clean up after ourself.
del _ballistica_bootstrap, TYPE_CHECKING
diff --git a/tools/batools/codegen.py b/tools/batools/codegen.py
index 503394fd..d10b1214 100644
--- a/tools/batools/codegen.py
+++ b/tools/batools/codegen.py
@@ -80,7 +80,7 @@ def gen_binding_code(projroot: str, in_path: str, out_path: str) -> None:
# Then it grabs the function that was defined and runs it.
ccode += ('PyObject* bindvals = PythonCommand("get_binding_values()",'
' "")'
- '.RunReturnObj(true);\n'
+ '.RunReturnObj(true, nullptr);\n'
'if (bindvals == nullptr) {\n'
' // Use a standard error to avoid a useless stack trace.\n'
' throw std::logic_error("Error binding required Python'
diff --git a/tools/efrotools/code.py b/tools/efrotools/code.py
index c0271414..59531160 100644
--- a/tools/efrotools/code.py
+++ b/tools/efrotools/code.py
@@ -811,7 +811,7 @@ def check_clioncode(projroot: Path, full: bool, verbose: bool) -> None:
cachepath = Path('.cache/check_clioncode')
filenames = get_code_filenames(projroot)
clionroot = Path('/Applications/CLion.app')
- clionbin = Path(clionroot, 'Contents/MacOS/clion')
+ # clionbin = Path(clionroot, 'Contents/MacOS/clion')
inspect = Path(clionroot, 'Contents/bin/inspect.sh')
# At the moment offline clion inspections seem a bit flaky.
@@ -821,43 +821,59 @@ def check_clioncode(projroot: Path, full: bool, verbose: bool) -> None:
# So for now let's try blowing away caches, launching the gui
# temporarily, and then kicking off inspections after that. Sigh.
print('Clearing CLion caches...', flush=True)
- subprocess.run('rm -rf ~/Library/Caches/CLion*', shell=True, check=True)
+ caches_root = os.environ['HOME'] + '/Library/Caches/JetBrains'
+ if not os.path.exists(caches_root):
+ raise RuntimeError(f'CLion caches root not found: {caches_root}')
+ subprocess.run('rm -rf ~/Library/Caches/JetBrains/CLion*',
+ shell=True,
+ check=True)
# UPDATE: seems this is unnecessary now; should double check.
# Note: I'm assuming this project needs to be open when the GUI
# comes up. Currently just have one project so can rely on auto-open
# but may need to get fancier later if that changes.
- if bool(False):
+ if bool(True):
print('Launching GUI CLion to rebuild caches...', flush=True)
- process = subprocess.Popen(str(clionbin))
+ # process = subprocess.Popen(str(clionbin))
+ subprocess.run(
+ ['open', '-a', clionroot,
+ Path(projroot, 'ballisticacore-cmake')],
+ check=True)
# Wait a moment and ask it nicely to die.
- waittime = 120
+ waittime = 60
while waittime > 0:
- print(f'Waiting for {waittime} more seconds.')
+ print(f'Waiting for {waittime} more seconds.', flush=True)
time.sleep(10)
waittime -= 10
- # Seems killing it via applescript is more likely to leave it
- # in a working state for offline inspections than TERM signal..
- subprocess.run("osascript -e 'tell application \"CLion\" to quit'",
- shell=True,
- check=False)
+ # For some reason this is giving a return-code 1 although
+ # it appears to be working.
+ print('Waiting for GUI CLion to quit...', flush=True)
+ subprocess.run(
+ [
+ 'osascript', '-e', 'tell application "CLion" to quit\n'
+ 'repeat until application "CLion" is not running\n'
+ ' delay 1\n'
+ 'end repeat'
+ ],
+ check=False,
+ )
+ time.sleep(5)
# process.terminate()
- print('Waiting for GUI CLion to quit...', flush=True)
- process.wait(timeout=60)
+ # process.wait(timeout=60)
print('Launching Offline CLion to run inspections...', flush=True)
- _run_idea_inspections_cached(
- cachepath=cachepath,
- filenames=filenames,
- full=full,
- projroot=Path(projroot, 'ballisticacore-cmake'),
- inspectdir=Path(projroot, 'ballisticacore-cmake/src/ballistica'),
- displayname='CLion',
- inspect=inspect,
- verbose=verbose)
+ _run_idea_inspections_cached(cachepath=cachepath,
+ filenames=filenames,
+ full=full,
+ projroot=Path(projroot,
+ 'ballisticacore-cmake'),
+ inspectdir=Path(projroot, 'src/ballistica'),
+ displayname='CLion',
+ inspect=inspect,
+ verbose=verbose)
def check_android_studio(projroot: Path, full: bool, verbose: bool) -> None: