Skip to content

Commit 49f1ca3

Browse files
committed
Merge branch 'development' into tracy-fixes
2 parents bafc6b1 + 9bc6044 commit 49f1ca3

15 files changed

+132
-60
lines changed

Entities/Arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ namespace RTE {
361361

362362
void Arm::UpdateArmFrame() {
363363
float halfMaxLength = m_MaxLength / 2.0F;
364-
int newFrame = static_cast<unsigned int>((m_HandCurrentOffset.GetMagnitude() - halfMaxLength) / halfMaxLength) * static_cast<float>(m_FrameCount);
365-
m_Frame = std::clamp<int>(newFrame, 0, m_FrameCount - 1);
364+
float newFrame = std::floor(((m_HandCurrentOffset.GetMagnitude() - halfMaxLength) / halfMaxLength) * static_cast<float>(m_FrameCount));
365+
m_Frame = static_cast<unsigned int>(std::clamp(newFrame, 0.0F, static_cast<float>(m_FrameCount - 1)));
366366
}
367367

368368
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Lua/LuaAdapterDefinitions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ namespace RTE {
360360
};
361361
#pragma endregion
362362

363+
#pragma region BuyMenuGUI Lua Adapters
364+
struct LuaAdaptersBuyMenuGUI {
365+
static std::list<const SceneObject *> * GetOrderList(const BuyMenuGUI *luaSelfObject);
366+
};
367+
#pragma endregion
368+
363369
#pragma region PieMenu Lua Adapters
364370
struct LuaAdaptersPieMenu {
365371
static bool AddPieSlice(PieMenu *luaSelfObject, PieSlice *pieSliceToAdd, const Entity *pieSliceOriginalSource);

Lua/LuaAdapters.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ namespace RTE {
422422
}
423423
}
424424

425+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
426+
427+
std::list<const SceneObject *> * LuaAdaptersBuyMenuGUI::GetOrderList(const BuyMenuGUI *luaSelfObject) {
428+
auto* orderList = new std::list<const SceneObject *>();
429+
luaSelfObject->GetOrderList(*orderList);
430+
return orderList;
431+
}
432+
425433
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
426434

427435
Attachable * LuaAdaptersAttachable::RemoveFromParent1(Attachable *luaSelfObject) {

Lua/LuaBindingsGUI.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ namespace RTE {
6767
.def("SetBannerImage", &BuyMenuGUI::SetBannerImage)
6868
.def("SetLogoImage", &BuyMenuGUI::SetLogoImage)
6969
.def("ClearCartList", &BuyMenuGUI::ClearCartList)
70-
.def("LoadDefaultLoadoutToCart", &BuyMenuGUI::LoadDefaultLoadoutToCart);
70+
.def("LoadDefaultLoadoutToCart", &BuyMenuGUI::LoadDefaultLoadoutToCart)
71+
.def("GetOrderList", &LuaAdaptersBuyMenuGUI::GetOrderList, luabind::adopt(luabind::return_value) + luabind::return_stl_iterator)
72+
.def("GetTotalCartCost", &BuyMenuGUI::GetTotalCartCost)
73+
.def("GetTotalOrderCost", &BuyMenuGUI::GetTotalOrderCost)
74+
.def("GetTotalOrderMass", &BuyMenuGUI::GetTotalOrderMass)
75+
.def("GetTotalOrderPassengers", &BuyMenuGUI::GetTotalOrderPassengers);
7176
}
7277

7378
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ namespace RTE {
130130
g_LuaMan.Destroy();
131131
ContentFile::FreeAllLoaded();
132132
g_ConsoleMan.Destroy();
133+
g_WindowMan.Destroy();
133134

134135
#ifdef DEBUG_BUILD
135136
Entity::ClassInfo::DumpPoolMemoryInfo(Writer("MemCleanupInfo.txt"));

Managers/ConsoleMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ namespace RTE {
255255
SetReadOnly();
256256
}
257257

258-
if (!g_UInputMan.FlagShiftState() && (!g_UInputMan.FlagCtrlState() && g_UInputMan.KeyPressed(SDL_SCANCODE_GRAVE))) {
258+
if (!g_UInputMan.FlagShiftState() && (!g_UInputMan.FlagCtrlState() && (g_UInputMan.KeyPressed(SDL_SCANCODE_GRAVE) || (IsEnabled() && g_UInputMan.KeyPressed(SDL_SCANCODE_ESCAPE))))) {
259259
if (IsEnabled()) {
260260
if (!m_ReadOnly) {
261261
m_InputTextBox->SetEnabled(false);

Managers/FrameMan.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ namespace RTE {
510510
}
511511

512512
// TODO: Remove this once GCC13 is released and switched to. std::format and std::chrono::time_zone are not part of latest libstdc++.
513-
#if _LINUX_OR_MACOSX_
513+
#if defined(__GNUC__) && __GNUC__ < 13
514514
std::chrono::time_point now = std::chrono::system_clock::now();
515515
time_t currentTime = std::chrono::system_clock::to_time_t(now);
516516
tm *localCurrentTime = std::localtime(&currentTime);
@@ -540,7 +540,7 @@ namespace RTE {
540540
SaveScreenToBitmap();
541541

542542
// Make a copy of the buffer because it may be overwritten mid thread and everything will be on fire.
543-
BITMAP *outputBitmap = create_bitmap_ex(bitmap_color_depth(m_ScreenDumpBuffer.get()), m_ScreenDumpBuffer->w * g_WindowMan.GetResMultiplier(), m_ScreenDumpBuffer->h * g_WindowMan.GetResMultiplier());
543+
BITMAP *outputBitmap = create_bitmap_ex(bitmap_color_depth(m_ScreenDumpBuffer.get()), m_ScreenDumpBuffer->w, m_ScreenDumpBuffer->h);
544544
stretch_blit(m_ScreenDumpBuffer.get(), outputBitmap, 0, 0, m_ScreenDumpBuffer->w, m_ScreenDumpBuffer->h, 0, 0, outputBitmap->w, outputBitmap->h);
545545

546546
auto saveScreenDump = [fullFileName](BITMAP *bitmapToSaveCopy) {
@@ -604,26 +604,10 @@ namespace RTE {
604604
if (!m_ScreenDumpBuffer) {
605605
return;
606606
}
607-
int drawSizeX, drawSizeY;
608-
SDL_GL_GetDrawableSize(g_WindowMan.GetWindow(), &drawSizeX, &drawSizeY);
609-
BITMAP* screenBitmap = create_bitmap_ex(32, drawSizeX, drawSizeY);
610-
GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
611-
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
612-
GL_CHECK(glReadBuffer(GL_FRONT));
613-
GL_CHECK(glPixelStorei(GL_PACK_ALIGNMENT, 1));
614-
GL_CHECK(glReadPixels(0, 0, screenBitmap->w, screenBitmap->h, GL_RGBA, GL_UNSIGNED_BYTE, screenBitmap->line[0]));
615-
GL_CHECK(glReadBuffer(GL_BACK));
616-
617-
BITMAP* depthBitmap = create_bitmap_ex(bitmap_color_depth(m_ScreenDumpBuffer.get()), screenBitmap->w, screenBitmap->h);
618-
blit(screenBitmap, depthBitmap, 0, 0, 0, 0, screenBitmap->w, screenBitmap->h);
619-
620-
BITMAP* flipBitmap = create_bitmap_ex(bitmap_color_depth(depthBitmap), depthBitmap->w, depthBitmap->h);
621-
draw_sprite_v_flip(flipBitmap, depthBitmap, 0, 0);
622-
623-
stretch_blit(flipBitmap, m_ScreenDumpBuffer.get(), 0, 0, screenBitmap->w, screenBitmap->h, 0, 0, m_ScreenDumpBuffer->w, m_ScreenDumpBuffer->h);
624-
destroy_bitmap(screenBitmap);
625-
destroy_bitmap(depthBitmap);
626-
destroy_bitmap(flipBitmap);
607+
608+
glBindTexture(GL_TEXTURE_2D, g_WindowMan.GetScreenBufferTexture());
609+
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, m_ScreenDumpBuffer->line[0]);
610+
627611
}
628612

629613
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Managers/PostProcessMan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,12 @@ namespace RTE {
534534
effectStrength = postEffect.m_Strength / 255.f;
535535
effectPosX = postEffect.m_Pos.m_X;
536536
effectPosY = postEffect.m_Pos.m_Y;
537-
m_PostProcessShader->SetVector4f(m_PostProcessShader->GetColorUniform(), glm::vec4(effectStrength));
537+
m_PostProcessShader->SetVector4f(m_PostProcessShader->GetColorUniform(), glm::vec4(effectStrength, effectStrength, effectStrength, 1.0f));
538538

539539
glm::mat4 transformMatrix(1);
540540
transformMatrix = glm::translate(transformMatrix, glm::vec3(effectPosX, effectPosY, 0));
541-
transformMatrix = glm::scale(transformMatrix, glm::vec3(effectBitmap->w * 0.5f, effectBitmap->h * 0.5f, 1.0));
542541
transformMatrix = glm::rotate(transformMatrix, -postEffect.m_Angle, glm::vec3(0, 0, 1));
542+
transformMatrix = glm::scale(transformMatrix, glm::vec3(effectBitmap->w * 0.5f, effectBitmap->h * 0.5f, 1.0));
543543

544544
glBindTexture(GL_TEXTURE_2D, reinterpret_cast<GLBitmapInfo*>(postEffect.m_Bitmap->extra)->m_Texture);
545545
m_PostProcessShader->SetMatrix4f(m_PostProcessShader->GetTransformUniform(), transformMatrix);

Managers/PresetMan.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,12 @@ bool PresetMan::IsModuleUserdata(const std::string &moduleName) const {
334334
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
335335

336336
std::string PresetMan::GetFullModulePath(const std::string &modulePath) const {
337-
const std::string modulePathGeneric = std::filesystem::path(modulePath).generic_string();
338-
const std::string pathTopDir = modulePathGeneric.substr(0, modulePathGeneric.find_first_of("/\\") + 1);
337+
// Note: Mods may use mixed path separators, which aren't supported on non Windows systems.
338+
// Since Windows supports both forward and backslash separators it's safe to replace all backslashes with forward slashes.
339+
std::string modulePathGeneric = std::filesystem::path(modulePath).generic_string();
340+
std::replace(modulePathGeneric.begin(), modulePathGeneric.end(), '\\', '/');
341+
342+
const std::string pathTopDir = modulePathGeneric.substr(0, modulePathGeneric.find_first_of("/") + 1);
339343
const std::string moduleName = GetModuleNameFromPath(modulePathGeneric);
340344

341345
std::string moduleTopDir = System::GetModDirectory();

Managers/UInputMan.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,6 @@ namespace RTE {
903903
}
904904
// Ctrl+R or Back button for controllers to reset activity.
905905
if (!g_MetaMan.GameInProgress() && !g_ActivityMan.ActivitySetToRestart()) {
906-
g_ActivityMan.SetRestartActivity(FlagCtrlState() && KeyPressed(SDLK_r) || AnyBackPress());
907906
g_ActivityMan.SetRestartActivity((FlagCtrlState() && KeyPressed(SDLK_r)) || AnyBackPress());
908907
}
909908
if (g_ActivityMan.ActivitySetToRestart()) {

0 commit comments

Comments
 (0)