Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion rts/Game/UI/KeyBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,13 @@ bool CKeyBindings::UnBindAction(const std::string& command)
RECOIL_DETAILED_TRACY_ZONE;
if (debugEnabled)
LOG("[CKeyBindings::%s] command=%s", __func__, command.c_str());
return RemoveActionFromKeyMap(command, codeBindings) || RemoveActionFromKeyMap(command, scanBindings);

// clear both maps; || would short-circuit and leave the scancode binding when
// the action is also bound to a keycode
const bool removedFromCode = RemoveActionFromKeyMap(command, codeBindings);
const bool removedFromScan = RemoveActionFromKeyMap(command, scanBindings);

return removedFromCode || removedFromScan;
}


Expand Down
6 changes: 2 additions & 4 deletions rts/Lua/LuaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,13 @@ void LuaParser::AddString(int key, const std::string& value)

int LuaParser::TimeCheck(lua_State* L)
{
#if (!defined(UNITSYNC) && !defined(DEDICATED))
if (!lua_isstring(L, 1) || !lua_isfunction(L, 2))
luaL_error(L, "Invalid arguments to TimeCheck('string', func, ...)");

{
#if (!defined(UNITSYNC) && !defined(DEDICATED))
ScopedOnceTimer timer(lua_tostring(L, 1));
#endif

lua_remove(L, 1);

Expand All @@ -519,9 +520,6 @@ int LuaParser::TimeCheck(lua_State* L)
}

return lua_gettop(L);
#else
return 0;
#endif
}


Expand Down
3 changes: 1 addition & 2 deletions rts/Lua/LuaUnsyncedCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2150,8 +2150,7 @@ int LuaUnsyncedCtrl::SetSkyBoxTexture(lua_State* L)
if (CLuaHandle::GetHandleSynced(L))
return 0;

if (const auto& sky = ISky::GetSky(); sky != nullptr)
sky->SetLuaTexture(ParseLuaTextureData(L, false));
ISky::SetSkyLuaTexture(ParseLuaTextureData(L, false));

return 0;
}
Expand Down
24 changes: 24 additions & 0 deletions rts/Rendering/Env/ISky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ void ISky::SetSky()
}
}

void ISky::SetSkyLuaTexture(const MapTextureData& td)
{
if (sky == nullptr)
return;

/* TODO: consider if perhaps there should be some way to set the
* sky to one of the other classes (CModernSky, etc) via Lua. */

if (td.id != 0u && dynamic_cast<CSkyBox*>(sky.get()) == nullptr) {
auto luaSky = std::make_unique<CSkyBox>(td.id, td.size.x, td.size.y);

if (luaSky->IsValid()) {
sky = std::move(luaSky);
return;
}

LOG_L(L_WARNING, "[ISky::%s] failed to create SkyBox from Lua texture (%u), keeping current sky", __func__, td.id);
return;
}

/* FIXME: td.id == 0 reaches here. Untested in recent times */
sky->SetLuaTexture(td);
}

void ISky::SetSkyAxisAngle(const float4& skyAxisAngleRaw)
{
auto axis = float3{ skyAxisAngleRaw.x, skyAxisAngleRaw.y, skyAxisAngleRaw.z };
Expand Down
1 change: 1 addition & 0 deletions rts/Rendering/Env/ISky.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ISky
void SetUpdated() { updated = true; }
public:
static void SetSky();
static void SetSkyLuaTexture(const MapTextureData& td);
static auto& GetSky() { return sky; }
static void KillSky() { sky = nullptr; }
public:
Expand Down
2 changes: 1 addition & 1 deletion tools/pr-downloader
Loading