4449: Fix text selection cursor position (fixes #4444) r=heinrich5991 a=def-

after moving window to a screen with different dimensions than the
initial one

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4461: Support cl_video_show_direction 2 r=heinrich5991 a=def-

Currently to show your own key presses when recording you need
cl_video_showdirection 1 and cl_show_direction 2 which is kind of
unintuitive.

Also changed the name to be consistent with cl_show_direction

Thanks to hussainx3 for report.

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4466: Fix GLEW system lib linking on macOS (fixes #4439) r=heinrich5991 a=def-

Only GLEW::GLEW is provided, GLEW_LIBRARIES is empty by default

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4469: Consider initial chat delays as normal mutes, implement unmuteid (fixes # 4460) r=heinrich5991 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4470: Support GUI/Cmd key and use it as equivalent to ctrl in default shortcuts r=heinrich5991 a=def-

like ctrl-f / cmd-f

On macOS all these system shortcuts are done with cmd while on Windows
ctrl is used. Support both now

Added support for cmd key as modifier for binds

Fixed missing right variants of modifiers in some places

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4472: Make /rescue handle switch freeze too r=heinrich5991 a=def-

As reported by RonIn

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4473: Fix comment in CMakeLists.txt r=heinrich5991 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-12-19 16:58:46 +00:00 committed by GitHub
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 294 additions and 174 deletions

View file

@ -5,7 +5,7 @@ endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9 CACHE INTERNAL "")
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.9)
message(WARNING "Building for macOS <= 10.9 is not supported")
message(WARNING "Building for macOS < 10.9 is not supported")
endif()
file(STRINGS src/game/version.h VERSION_LINE

View file

@ -25,8 +25,8 @@ To clone the libraries if you have previously cloned DDNet without them:
git submodule update --init --recursive
Dependencies on Linux
---------------------
Dependencies on Linux / macOS
-----------------------------
You can install the required libraries on your system, `touch CMakeLists.txt` and CMake will use the system-wide libraries by default. You can install all required dependencies and CMake on Debian or Ubuntu like this:
@ -38,6 +38,10 @@ Or on Arch Linux like this:
There is an [AUR package for pnglite](https://aur.archlinux.org/packages/pnglite/). For instructions on installing it, see [AUR packages installation instructions on ArchWiki](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages).
On macOS you can use [homebrew](https://brew.sh/) to install build dependencies like this:
brew install cmake freetype opusfile SDL2 wavpack googletest glew
If you don't want to use the system libraries, you can pass the `-DPREFER_BUNDLED_LIBS=ON` parameter to cmake.
Building on Linux and macOS

View file

@ -5,6 +5,9 @@ if(NOT PREFER_BUNDLED_LIBS)
if(GLEW_FOUND)
set(GLEW_BUNDLED OFF)
set(GLEW_DEP)
if(NOT GLEW_LIBRARIES)
set(GLEW_LIBRARIES GLEW::GLEW)
endif()
endif()
endif()

View file

@ -1120,19 +1120,38 @@ void CGraphicsBackend_SDL_OpenGL::SetWindowParams(int FullscreenMode, bool IsBor
bool CGraphicsBackend_SDL_OpenGL::SetWindowScreen(int Index)
{
if(Index >= 0 && Index < m_NumScreens)
if(Index < 0 || Index >= m_NumScreens)
{
SDL_Rect ScreenPos;
if(SDL_GetDisplayBounds(Index, &ScreenPos) == 0)
{
SDL_SetWindowPosition(m_pWindow,
SDL_WINDOWPOS_CENTERED_DISPLAY(Index),
SDL_WINDOWPOS_CENTERED_DISPLAY(Index));
return true;
}
return false;
}
return false;
SDL_Rect ScreenPos;
if(SDL_GetDisplayBounds(Index, &ScreenPos) != 0)
{
return false;
}
SDL_SetWindowPosition(m_pWindow,
SDL_WINDOWPOS_CENTERED_DISPLAY(Index),
SDL_WINDOWPOS_CENTERED_DISPLAY(Index));
return UpdateDisplayMode(Index);
}
bool CGraphicsBackend_SDL_OpenGL::UpdateDisplayMode(int Index)
{
SDL_DisplayMode DisplayMode;
if(SDL_GetDesktopDisplayMode(Index, &DisplayMode) < 0)
{
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
return false;
}
g_Config.m_GfxDesktopWidth = DisplayMode.w;
g_Config.m_GfxDesktopHeight = DisplayMode.h;
g_Config.m_GfxRefreshRate = DisplayMode.refresh_rate;
return true;
}
int CGraphicsBackend_SDL_OpenGL::GetWindowScreen()

View file

@ -255,6 +255,7 @@ public:
virtual void Maximize();
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless);
virtual bool SetWindowScreen(int Index);
virtual bool UpdateDisplayMode(int Index);
virtual int GetWindowScreen();
virtual int WindowActive();
virtual int WindowOpen();

View file

@ -3466,7 +3466,7 @@ void CClient::Run()
bool CClient::CtrlShiftKey(int Key, bool &Last)
{
if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && !Last && Input()->KeyIsPressed(Key))
if(Input()->ModifierIsPressed() && (Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && !Last && Input()->KeyIsPressed(Key))
{
Last = true;
return true;

View file

@ -2320,7 +2320,28 @@ void CGraphics_Threaded::SetWindowParams(int FullscreenMode, bool IsBorderless)
bool CGraphics_Threaded::SetWindowScreen(int Index)
{
return m_pBackend->SetWindowScreen(Index);
if(!m_pBackend->SetWindowScreen(Index))
{
return false;
}
m_pBackend->GetViewportSize(m_ScreenWidth, m_ScreenHeight);
m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth;
return true;
}
void CGraphics_Threaded::Move(int x, int y)
{
#if defined(CONF_VIDEORECORDER)
if(IVideo::Current() && IVideo::Current()->IsRecording())
return;
#endif
// Only handling CurScreen != m_GfxScreen doesn't work reliably
const int CurScreen = m_pBackend->GetWindowScreen();
m_pBackend->UpdateDisplayMode(CurScreen);
m_pBackend->GetViewportSize(m_ScreenWidth, m_ScreenHeight);
m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth;
}
void CGraphics_Threaded::Resize(int w, int h, int RefreshRate, bool SetWindowSize, bool ForceResizeEvent)
@ -2352,6 +2373,7 @@ void CGraphics_Threaded::Resize(int w, int h, int RefreshRate, bool SetWindowSiz
g_Config.m_GfxScreenWidth = w;
g_Config.m_GfxScreenHeight = h;
g_Config.m_GfxScreenRefreshRate = m_ScreenRefreshRate;
m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth;
CCommandBuffer::SCommand_Update_Viewport Cmd;
Cmd.m_X = 0;

View file

@ -671,6 +671,7 @@ public:
virtual void Maximize() = 0;
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless) = 0;
virtual bool SetWindowScreen(int Index) = 0;
virtual bool UpdateDisplayMode(int Index) = 0;
virtual int GetWindowScreen() = 0;
virtual int WindowActive() = 0;
virtual int WindowOpen() = 0;
@ -1166,6 +1167,7 @@ public:
void Maximize() override;
void SetWindowParams(int FullscreenMode, bool IsBorderless) override;
bool SetWindowScreen(int Index) override;
void Move(int x, int y) override;
void Resize(int w, int h, int RefreshRate, bool SetWindowSize = false, bool ForceResizeEvent = false) override;
void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) override;
int GetWindowScreen() override;

View file

@ -149,6 +149,7 @@ public:
void Maximize() override{};
void SetWindowParams(int FullscreenMode, bool IsBorderless) override{};
bool SetWindowScreen(int Index) override { return false; };
void Move(int x, int y) override{};
void Resize(int w, int h, int RefreshRate, bool SetWindowSize = false, bool ForceResizeEvent = false) override{};
void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) override{};
int GetWindowScreen() override { return 0; };

View file

@ -359,6 +359,9 @@ int CInput::Update()
// shortcuts
switch(Event.window.event)
{
case SDL_WINDOWEVENT_MOVED:
Graphics()->Move(Event.window.data1, Event.window.data2);
break;
// listen to size changes, this includes our manual changes and the ones by the window manager
case SDL_WINDOWEVENT_SIZE_CHANGED:
Graphics()->Resize(Event.window.data1, Event.window.data2, -1);

View file

@ -5,6 +5,7 @@
#include <engine/graphics.h>
#include <engine/input.h>
#include <engine/keys.h>
#include <stddef.h>
@ -48,6 +49,7 @@ public:
virtual void Init();
bool ModifierIsPressed() const { return KeyState(KEY_LCTRL) || KeyState(KEY_RCTRL) || KeyState(KEY_LGUI) || KeyState(KEY_RGUI); }
bool KeyIsPressed(int Key) const { return KeyState(Key); }
bool KeyPress(int Key, bool CheckCounter) const { return CheckCounter ? (m_aInputCount[Key] == m_InputCounter) : m_aInputCount[Key]; }

View file

@ -213,6 +213,7 @@ public:
virtual bool SetWindowScreen(int Index) = 0;
virtual bool SetVSync(bool State) = 0;
virtual int GetWindowScreen() = 0;
virtual void Move(int x, int y) = 0;
virtual void Resize(int w, int h, int RefreshRate, bool SetWindowSize = false, bool ForceResizeEvent = false) = 0;
virtual void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) = 0;

View file

@ -62,6 +62,7 @@ public:
int *GetEventCountRaw() { return &m_NumEvents; }
// keys
virtual bool ModifierIsPressed() const = 0;
virtual bool KeyIsPressed(int Key) const = 0;
virtual bool KeyPress(int Key, bool CheckCounter = false) const = 0;
const char *KeyName(int Key) const { return (Key >= 0 && Key < g_MaxKeys) ? g_aaKeyStrings[Key] : g_aaKeyStrings[0]; }

View file

@ -379,7 +379,7 @@ MACRO_CONFIG_INT(ClChatTeamColors, cl_chat_teamcolors, 0, 0, 1, CFGFLAG_CLIENT |
MACRO_CONFIG_INT(ClChatReset, cl_chat_reset, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Reset chat when pressing escape")
MACRO_CONFIG_INT(ClChatOld, cl_chat_old, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Old chat style: No tee, no background");
MACRO_CONFIG_INT(ClShowDirection, cl_show_direction, 1, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Show tee direction")
MACRO_CONFIG_INT(ClShowDirection, cl_show_direction, 1, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Show key presses (1 = other players', 2 = also your own)")
MACRO_CONFIG_INT(ClHttpMapDownload, cl_http_map_download, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Try fast HTTP map download first")
MACRO_CONFIG_INT(ClOldGunPosition, cl_old_gun_position, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Tees hold gun a bit higher like in TW 0.6.1 and older")
MACRO_CONFIG_INT(ClConfirmDisconnectTime, cl_confirm_disconnect_time, 20, -1, 1440, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Confirmation popup before disconnecting after game time (in minutes, -1 to turn off, 0 to always turn on)")

View file

@ -92,6 +92,9 @@ int CBinds::GetModifierMask(IInput *i)
Mask |= i->KeyIsPressed(KEY_LCTRL) << CBinds::MODIFIER_CTRL;
Mask |= i->KeyIsPressed(KEY_RCTRL) << CBinds::MODIFIER_CTRL;
Mask |= i->KeyIsPressed(KEY_LALT) << CBinds::MODIFIER_ALT;
Mask |= i->KeyIsPressed(KEY_RALT) << CBinds::MODIFIER_ALT;
Mask |= i->KeyIsPressed(KEY_LGUI) << CBinds::MODIFIER_GUI;
Mask |= i->KeyIsPressed(KEY_RGUI) << CBinds::MODIFIER_GUI;
if(!Mask)
return 1 << CBinds::MODIFIER_NONE;
@ -109,7 +112,11 @@ int CBinds::GetModifierMaskOfKey(int Key)
case KEY_RCTRL:
return 1 << CBinds::MODIFIER_CTRL;
case KEY_LALT:
case KEY_RALT:
return 1 << CBinds::MODIFIER_ALT;
case KEY_LGUI:
case KEY_RGUI:
return 1 << CBinds::MODIFIER_GUI;
default:
return 0;
}
@ -124,7 +131,9 @@ bool CBinds::ModifierMatchesKey(int Modifier, int Key)
case MODIFIER_CTRL:
return Key == KEY_LCTRL || Key == KEY_RCTRL;
case MODIFIER_ALT:
return Key == KEY_LALT;
return Key == KEY_LALT || Key == KEY_RALT;
case MODIFIER_GUI:
return Key == KEY_LGUI || Key == KEY_RGUI;
case MODIFIER_NONE:
default:
return false;
@ -161,6 +170,8 @@ bool CBinds::OnInput(IInput::CEvent e)
// When ctrl+shift are pressed (ctrl+shift binds and also the hard-coded ctrl+shift+d, ctrl+shift+g, ctrl+shift+e), ignore other +xxx binds
if(e.m_Flags & IInput::FLAG_PRESS && Mask != ((1 << MODIFIER_CTRL) | (1 << MODIFIER_SHIFT)))
Console()->ExecuteLineStroked(1, m_aapKeyBindings[0][e.m_Key]);
if(e.m_Flags & IInput::FLAG_PRESS && Mask != ((1 << MODIFIER_GUI) | (1 << MODIFIER_SHIFT)))
Console()->ExecuteLineStroked(1, m_aapKeyBindings[0][e.m_Key]);
if(e.m_Flags & IInput::FLAG_RELEASE)
Console()->ExecuteLineStroked(0, m_aapKeyBindings[0][e.m_Key]);
ret = true;
@ -394,6 +405,8 @@ int CBinds::GetBindSlot(const char *pBindString, int *Mod)
*Mod |= (1 << MODIFIER_CTRL);
else if(!str_comp(aMod, "alt"))
*Mod |= (1 << MODIFIER_ALT);
else if(!str_comp(aMod, "gui"))
*Mod |= (1 << MODIFIER_GUI);
else
return 0;
@ -415,6 +428,8 @@ const char *CBinds::GetModifierName(int Modifier)
return "ctrl";
case MODIFIER_ALT:
return "alt";
case MODIFIER_GUI:
return "gui";
case MODIFIER_NONE:
default:
return "";

View file

@ -38,6 +38,7 @@ public:
MODIFIER_SHIFT,
MODIFIER_CTRL,
MODIFIER_ALT,
MODIFIER_GUI,
MODIFIER_COUNT,
MODIFIER_COMBINATION_COUNT = 1 << MODIFIER_COUNT
};

View file

@ -178,7 +178,7 @@ bool CChat::OnInput(IInput::CEvent Event)
if(m_Mode == MODE_NONE)
return false;
if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyPress(KEY_V))
if(Input()->ModifierIsPressed() && Input()->KeyPress(KEY_V))
{
const char *Text = Input()->GetClipboardText();
if(Text)
@ -205,12 +205,12 @@ bool CChat::OnInput(IInput::CEvent Event)
}
}
if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyPress(KEY_C))
if(Input()->ModifierIsPressed() && Input()->KeyPress(KEY_C))
{
Input()->SetClipboardText(m_Input.GetString());
}
if(Input()->KeyIsPressed(KEY_LCTRL)) // jump to spaces and special ASCII characters
if(Input()->ModifierIsPressed()) // jump to spaces and special ASCII characters
{
int SearchDirection = 0;
if(Input()->KeyPress(KEY_LEFT) || Input()->KeyPress(KEY_BACKSPACE))

View file

@ -115,7 +115,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
{
bool Handled = false;
if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL)) // jump to spaces and special ASCII characters
if(m_pGameConsole->Input()->ModifierIsPressed()) // jump to spaces and special ASCII characters
{
int SearchDirection = 0;
if(m_pGameConsole->Input()->KeyPress(KEY_LEFT) || m_pGameConsole->Input()->KeyPress(KEY_BACKSPACE))
@ -176,7 +176,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
m_Input.SetCursorOffset(FoundAt);
}
}
if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_V))
if(m_pGameConsole->Input()->ModifierIsPressed() && m_pGameConsole->Input()->KeyPress(KEY_V))
{
const char *Text = m_pGameConsole->Input()->GetClipboardText();
if(Text)
@ -203,23 +203,23 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
m_Input.Append(aLine);
}
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_C))
else if(m_pGameConsole->Input()->ModifierIsPressed() && m_pGameConsole->Input()->KeyPress(KEY_C))
{
m_pGameConsole->Input()->SetClipboardText(m_Input.GetString());
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_A))
else if(m_pGameConsole->Input()->ModifierIsPressed() && m_pGameConsole->Input()->KeyPress(KEY_A))
{
m_Input.SetCursorOffset(0);
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_E))
else if(m_pGameConsole->Input()->ModifierIsPressed() && m_pGameConsole->Input()->KeyPress(KEY_E))
{
m_Input.SetCursorOffset(m_Input.GetLength());
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_U))
else if(m_pGameConsole->Input()->ModifierIsPressed() && m_pGameConsole->Input()->KeyPress(KEY_U))
{
m_Input.SetRange("", 0, m_Input.GetCursorOffset());
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_K))
else if(m_pGameConsole->Input()->ModifierIsPressed() && m_pGameConsole->Input()->KeyPress(KEY_K))
{
m_Input.SetRange("", m_Input.GetCursorOffset(), m_Input.GetLength());
}
@ -681,7 +681,7 @@ void CGameConsole::OnRender()
float LineOffset = 1.0f;
bool WantsSelectionCopy = false;
if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyPress(KEY_C))
if(Input()->ModifierIsPressed() && Input()->KeyPress(KEY_C))
WantsSelectionCopy = true;
std::string SelectionString;

View file

@ -1650,7 +1650,7 @@ void CMapLayers::OnRender()
Render = true;
}
if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && Input()->KeyPress(KEY_KP_0))
if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->ModifierIsPressed() && (Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && Input()->KeyPress(KEY_KP_0))
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);

View file

@ -2613,7 +2613,7 @@ void CMenus::RenderBackground()
bool CMenus::CheckHotKey(int Key) const
{
return m_Popup == POPUP_NONE &&
!Input()->KeyIsPressed(KEY_LSHIFT) && !Input()->KeyIsPressed(KEY_RSHIFT) && !Input()->KeyIsPressed(KEY_LCTRL) && !Input()->KeyIsPressed(KEY_RCTRL) && !Input()->KeyIsPressed(KEY_LALT) && // no modifier
!Input()->KeyIsPressed(KEY_LSHIFT) && !Input()->KeyIsPressed(KEY_RSHIFT) && !Input()->ModifierIsPressed() && !Input()->KeyIsPressed(KEY_LALT) && // no modifier
Input()->KeyIsPressed(Key) && m_pClient->m_GameConsole.IsClosed();
}

View file

@ -528,7 +528,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
QuickSearch.VSplitLeft(SearchExcludeAddrStrMax, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
UI()->SetActiveItem(&g_Config.m_BrFilterString);
static int s_ClearButton = 0;
static float s_Offset = 0.0f;
@ -554,7 +554,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
static int s_ClearButton = 0;
static float s_Offset = 0.0f;
if(Input()->KeyPress(KEY_X) && (Input()->KeyPress(KEY_LSHIFT) || Input()->KeyPress(KEY_RSHIFT)) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->KeyPress(KEY_X) && (Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && Input()->ModifierIsPressed())
UI()->SetActiveItem(&g_Config.m_BrExcludeString);
if(UIEx()->DoClearableEditBox(&g_Config.m_BrExcludeString, &s_ClearButton, &QuickExclude, g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString), 12.0f, &s_Offset, false, CUI::CORNER_ALL))
Client()->ServerBrowserUpdate();
@ -611,7 +611,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
return m_aLocalStringHelper;
};
if(DoButtonMenu(m_RefreshButton, &s_RefreshButton, Func, 0, &ButtonRefresh, true, false, CUI::CORNER_ALL) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))))
if(DoButtonMenu(m_RefreshButton, &s_RefreshButton, Func, 0, &ButtonRefresh, true, false, CUI::CORNER_ALL) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed()))
{
if(g_Config.m_UiPage == PAGE_INTERNET)
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);

View file

@ -1202,7 +1202,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
}
static int s_RefreshButton = 0;
if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))))
if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed()))
{
DemolistPopulate();
DemolistOnUpdate(false);

View file

@ -684,7 +684,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
static int s_ClearButton = 0;
static float s_Offset = 0.0f;
if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))))
if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()))
{
UI()->SetActiveItem(&m_aFilterString);
m_ControlPageOpening = false;
@ -734,7 +734,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1, -1.0f);
Reason.VSplitLeft(w + 10.0f, 0, &Reason);
static float s_Offset = 0.0f;
if(Input()->KeyPress(KEY_R) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())
UI()->SetActiveItem(&m_aCallvoteReason);
UIEx()->DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL);

View file

@ -708,7 +708,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
static int s_ClearButton = 0;
static float s_Offset = 0.0f;
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
UI()->SetActiveItem(&g_Config.m_ClSkinFilterString);
if(UIEx()->DoClearableEditBox(&g_Config.m_ClSkinFilterString, &s_ClearButton, &QuickSearch, g_Config.m_ClSkinFilterString, sizeof(g_Config.m_ClSkinFilterString), 14.0f, &s_Offset, false, CUI::CORNER_ALL, Localize("Search")))
s_InitSkinlist = true;

View file

@ -521,7 +521,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
static int s_ClearButton = 0;
static float s_Offset = 0.0f;
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
UI()->SetActiveItem(&s_aFilterString[s_CurCustomTab]);
if(UIEx()->DoClearableEditBox(&s_aFilterString[s_CurCustomTab], &s_ClearButton, &QuickSearch, s_aFilterString[s_CurCustomTab], sizeof(s_aFilterString[0]), 14.0f, &s_Offset, false, CUI::CORNER_ALL, Localize("Search")))
s_InitCustomList[s_CurCustomTab] = true;

View file

@ -542,34 +542,32 @@ void CPlayers::RenderPlayer(
Graphics()->SetColor(1.0f, 1.0f, 1.0f, Alpha);
Graphics()->QuadsSetRotation(0);
int ShowDirection = g_Config.m_ClShowDirection;
#if defined(CONF_VIDEORECORDER)
if((((!IVideo::Current() && (g_Config.m_ClShowDirection >= 1)) || (IVideo::Current() && g_Config.m_ClVideoShowDirection)) && ClientID >= 0) || DemoPlayer()->IsPlaying())
#else
if((g_Config.m_ClShowDirection >= 1 && ClientID >= 0) || DemoPlayer()->IsPlaying())
if(IVideo::Current())
ShowDirection = g_Config.m_ClVideoShowDirection;
#endif
if((Local && ShowDirection == 2) || (!Local && ShowDirection >= 1))
{
if((Local && g_Config.m_ClShowDirection == 2) || (!Local && g_Config.m_ClShowDirection >= 1))
if(Player.m_Direction == -1)
{
if(Player.m_Direction == -1)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROW].m_Id);
Graphics()->QuadsSetRotation(pi);
Graphics()->RenderQuadContainerAsSprite(m_DirectionQuadContainerIndex, 0, Position.x - 30.f, Position.y - 70.f);
}
else if(Player.m_Direction == 1)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROW].m_Id);
Graphics()->RenderQuadContainerAsSprite(m_DirectionQuadContainerIndex, 0, Position.x + 30.f, Position.y - 70.f);
}
if(Player.m_Jumped & 1)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROW].m_Id);
Graphics()->QuadsSetRotation(pi * 3 / 2);
Graphics()->RenderQuadContainerAsSprite(m_DirectionQuadContainerIndex, 0, Position.x, Position.y - 70.f);
}
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
Graphics()->QuadsSetRotation(0);
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROW].m_Id);
Graphics()->QuadsSetRotation(pi);
Graphics()->RenderQuadContainerAsSprite(m_DirectionQuadContainerIndex, 0, Position.x - 30.f, Position.y - 70.f);
}
else if(Player.m_Direction == 1)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROW].m_Id);
Graphics()->RenderQuadContainerAsSprite(m_DirectionQuadContainerIndex, 0, Position.x + 30.f, Position.y - 70.f);
}
if(Player.m_Jumped & 1)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROW].m_Id);
Graphics()->QuadsSetRotation(pi * 3 / 2);
Graphics()->RenderQuadContainerAsSprite(m_DirectionQuadContainerIndex, 0, Position.x, Position.y - 70.f);
}
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
Graphics()->QuadsSetRotation(0);
}
if(OtherTeam || ClientID < 0)

View file

@ -154,7 +154,7 @@ int32_t CLineInput::Manipulate(IInput::CEvent Event, char *pStr, int StrMaxSize,
}
else if(Key == KEY_LEFT)
{
if(ModifierKey == KEY_LCTRL)
if(ModifierKey == KEY_LCTRL || ModifierKey == KEY_RCTRL || ModifierKey == KEY_LGUI || ModifierKey == KEY_RGUI)
{
bool MovedCursor = false;
int OldCursorPos = CursorPos;
@ -181,7 +181,7 @@ int32_t CLineInput::Manipulate(IInput::CEvent Event, char *pStr, int StrMaxSize,
}
else if(Key == KEY_RIGHT)
{
if(ModifierKey == KEY_LCTRL)
if(ModifierKey == KEY_LCTRL || ModifierKey == KEY_RCTRL || ModifierKey == KEY_LGUI || ModifierKey == KEY_RGUI)
{
bool WasNonWordChar = IsNotAWordChar(pStr[CursorPos]);
while((!WasNonWordChar && !IsNotAWordChar(pStr[CursorPos])) || (WasNonWordChar && IsNotAWordChar(pStr[CursorPos])))

View file

@ -704,62 +704,62 @@ void CCharacter::HandleTiles(int Index)
}
// handle switch tiles
if(Collision()->IsSwitch(MapIndex) == TILE_FREEZE && Team() != TEAM_SUPER)
if(Collision()->GetSwitchType(MapIndex) == TILE_FREEZE && Team() != TEAM_SUPER)
{
if(Collision()->GetSwitchNumber(MapIndex) == 0 || Collision()->m_pSwitchers[Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
Freeze(Collision()->GetSwitchDelay(MapIndex));
}
else if(Collision()->IsSwitch(MapIndex) == TILE_DFREEZE && Team() != TEAM_SUPER)
else if(Collision()->GetSwitchType(MapIndex) == TILE_DFREEZE && Team() != TEAM_SUPER)
{
if(Collision()->GetSwitchNumber(MapIndex) == 0 || Collision()->m_pSwitchers[Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
m_DeepFreeze = true;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_DUNFREEZE && Team() != TEAM_SUPER)
else if(Collision()->GetSwitchType(MapIndex) == TILE_DUNFREEZE && Team() != TEAM_SUPER)
{
if(Collision()->GetSwitchNumber(MapIndex) == 0 || Collision()->m_pSwitchers[Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
m_DeepFreeze = false;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_HAMMER && Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_HAMMER && Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
{
m_Hit &= ~DISABLE_HIT_HAMMER;
m_Core.m_NoHammerHit = false;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_HAMMER) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_HAMMER) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
{
m_Hit |= DISABLE_HIT_HAMMER;
m_Core.m_NoHammerHit = true;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_SHOTGUN && Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_SHOTGUN && Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
{
m_Hit &= ~DISABLE_HIT_SHOTGUN;
m_Core.m_NoShotgunHit = false;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_SHOTGUN) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_SHOTGUN) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
{
m_Hit |= DISABLE_HIT_SHOTGUN;
m_Core.m_NoShotgunHit = true;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_GRENADE && Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_GRENADE && Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
{
m_Hit &= ~DISABLE_HIT_GRENADE;
m_Core.m_NoGrenadeHit = false;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_GRENADE) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_GRENADE) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
{
m_Hit |= DISABLE_HIT_GRENADE;
m_Core.m_NoGrenadeHit = true;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_LASER && Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_LASER && Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
{
m_Hit &= ~DISABLE_HIT_LASER;
m_Core.m_NoLaserHit = false;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_LASER) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
else if(Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_LASER) && Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
{
m_Hit |= DISABLE_HIT_LASER;
m_Core.m_NoLaserHit = true;
}
else if(Collision()->IsSwitch(MapIndex) == TILE_JUMP)
else if(Collision()->GetSwitchType(MapIndex) == TILE_JUMP)
{
int newJumps = Collision()->GetSwitchDelay(MapIndex);
if(newJumps != m_Core.m_Jumps)

View file

@ -235,9 +235,9 @@ bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigne
m_CurCursor = minimum(str_length(pStr), m_CurCursor);
bool IsShiftPressed = Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT);
bool IsCtrlPressed = Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL);
bool IsModPressed = Input()->ModifierIsPressed();
if(!IsShiftPressed && IsCtrlPressed && Input()->KeyPress(KEY_V))
if(!IsShiftPressed && IsModPressed && Input()->KeyPress(KEY_V))
{
const char *pText = Input()->GetClipboardText();
if(pText)
@ -294,7 +294,7 @@ bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigne
}
}
if(!IsShiftPressed && IsCtrlPressed && (Input()->KeyPress(KEY_C) || Input()->KeyPress(KEY_X)))
if(!IsShiftPressed && IsModPressed && (Input()->KeyPress(KEY_C) || Input()->KeyPress(KEY_X)))
{
if(m_HasSelection)
{
@ -322,7 +322,7 @@ bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigne
Input()->SetClipboardText(pStr);
}
if(!IsShiftPressed && IsCtrlPressed && Input()->KeyPress(KEY_A))
if(!IsShiftPressed && IsModPressed && Input()->KeyPress(KEY_A))
{
m_CurSelStart = 0;
int StrLen = str_length(pStr);
@ -331,7 +331,7 @@ bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigne
m_CurCursor = StrLen;
}
if(!IsShiftPressed && IsCtrlPressed && Input()->KeyPress(KEY_U))
if(!IsShiftPressed && IsModPressed && Input()->KeyPress(KEY_U))
{
pStr[0] = '\0';
m_CurCursor = 0;
@ -343,7 +343,7 @@ bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigne
int LastCursor = m_CurCursor;
int Len, NumChars;
str_utf8_stats(pStr, StrSize, StrSize, &Len, &NumChars);
int32_t ManipulateChanges = CLineInput::Manipulate(m_pInputEventsArray[i], pStr, StrSize, StrSize, &Len, &m_CurCursor, &NumChars, m_HasSelection ? CLineInput::LINE_INPUT_MODIFY_DONT_DELETE : 0, IsCtrlPressed ? KEY_LCTRL : 0);
int32_t ManipulateChanges = CLineInput::Manipulate(m_pInputEventsArray[i], pStr, StrSize, StrSize, &Len, &m_CurCursor, &NumChars, m_HasSelection ? CLineInput::LINE_INPUT_MODIFY_DONT_DELETE : 0, IsModPressed ? KEY_LCTRL : 0);
ReturnValue |= (ManipulateChanges & (CLineInput::LINE_INPUT_CHANGE_STRING | CLineInput::LINE_INPUT_CHANGE_CHARACTERS_DELETE)) != 0;
// if cursor changed, reset selection

View file

@ -754,7 +754,7 @@ void CCollision::GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed) con
*MaxSpeed = m_pSpeedup[Index].m_MaxSpeed;
}
int CCollision::IsSwitch(int Index) const
int CCollision::GetSwitchType(int Index) const
{
if(Index < 0 || !m_pSwitch)
return 0;

View file

@ -92,7 +92,7 @@ public:
int IsSpeedup(int Index) const;
int IsTune(int Index) const;
void GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed) const;
int IsSwitch(int Index) const;
int GetSwitchType(int Index) const;
int GetSwitchNumber(int Index) const;
int GetSwitchDelay(int Index) const;

View file

@ -48,9 +48,10 @@ CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, th
CONSOLE_COMMAND("vote_unmute", "v[id]", CFGFLAG_SERVER, ConVoteUnmute, this, "Give back v's right to vote.")
CONSOLE_COMMAND("vote_mutes", "", CFGFLAG_SERVER, ConVoteMutes, this, "List the current active vote mutes.")
CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "")
CONSOLE_COMMAND("muteid", "v[id] i[seconds] ?r[reason]", CFGFLAG_SERVER, ConMuteID, this, "")
CONSOLE_COMMAND("muteip", "s[ip] i[seconds] ?r[reason]", CFGFLAG_SERVER, ConMuteIP, this, "")
CONSOLE_COMMAND("unmute", "v[id]", CFGFLAG_SERVER, ConUnmute, this, "")
CONSOLE_COMMAND("muteid", "v[id] i[seconds] ?r[reason]", CFGFLAG_SERVER, ConMuteID, this, "Mute player with id")
CONSOLE_COMMAND("muteip", "s[ip] i[seconds] ?r[reason]", CFGFLAG_SERVER, ConMuteIP, this, "Mute player with IP address")
CONSOLE_COMMAND("unmute", "i[muteid]", CFGFLAG_SERVER, ConUnmute, this, "Unmute mute with number from \"mutes\"")
CONSOLE_COMMAND("unmuteid", "v[id]", CFGFLAG_SERVER, ConUnmuteID, this, "Unmute player with id")
CONSOLE_COMMAND("mutes", "", CFGFLAG_SERVER, ConMutes, this, "")
CONSOLE_COMMAND("moderate", "", CFGFLAG_SERVER, ConModerate, this, "Enables/disables active moderator mode for the player")
CONSOLE_COMMAND("vote_no", "", CFGFLAG_SERVER, ConVoteNo, this, "Same as \"vote no\"")

View file

@ -828,7 +828,7 @@ static int EntitiesListdirCallback(const char *pName, int IsDir, int StorageType
void CEditor::DoToolbar(CUIRect ToolBar)
{
bool CtrlPressed = Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL);
bool ModPressed = Input()->ModifierIsPressed();
bool ShiftPressed = Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT);
CUIRect TB_Top, TB_Bottom;
@ -845,7 +845,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(40.0f, &Button, &TB_Top);
static int s_HqButton = 0;
if(DoButton_Editor(&s_HqButton, "HD", m_ShowDetail, &Button, 0, "[ctrl+h] Toggle High Detail") ||
(Input()->KeyPress(KEY_H) && CtrlPressed))
(Input()->KeyPress(KEY_H) && ModPressed))
{
m_ShowDetail = !m_ShowDetail;
}
@ -856,7 +856,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(40.0f, &Button, &TB_Top);
static int s_AnimateButton = 0;
if(DoButton_Editor(&s_AnimateButton, "Anim", m_Animate, &Button, 0, "[ctrl+m] Toggle animation") ||
(Input()->KeyPress(KEY_M) && CtrlPressed))
(Input()->KeyPress(KEY_M) && ModPressed))
{
m_AnimateStart = time_get();
m_Animate = !m_Animate;
@ -868,7 +868,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(40.0f, &Button, &TB_Top);
static int s_ProofButton = 0;
if(DoButton_Editor(&s_ProofButton, "Proof", m_ProofBorders, &Button, 0, "[ctrl+p] Toggles proof borders. These borders represent what a player maximum can see.") ||
(Input()->KeyPress(KEY_P) && CtrlPressed))
(Input()->KeyPress(KEY_P) && ModPressed))
{
m_ProofBorders = !m_ProofBorders;
}
@ -879,7 +879,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(40.0f, &Button, &TB_Top);
static int s_GridButton = 0;
if(DoButton_Editor(&s_GridButton, "Grid", m_GridActive, &Button, 0, "[ctrl+g] Toggle Grid") ||
(Input()->KeyPress(KEY_G) && CtrlPressed))
(Input()->KeyPress(KEY_G) && ModPressed))
{
m_GridActive = !m_GridActive;
}
@ -890,7 +890,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(40.0f, &Button, &TB_Top);
static int s_TileInfoButton = 0;
if(DoButton_Editor(&s_TileInfoButton, "Info", m_ShowTileInfo, &Button, 0, "[ctrl+i] Show tile information") ||
(Input()->KeyPress(KEY_I) && CtrlPressed))
(Input()->KeyPress(KEY_I) && ModPressed))
{
m_ShowTileInfo = !m_ShowTileInfo;
m_ShowEnvelopePreview = 0;
@ -902,7 +902,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(40.0f, &Button, &TB_Top);
static int s_AllowPlaceUnusedTilesButton = 0;
if(DoButton_Editor(&s_AllowPlaceUnusedTilesButton, "Unused", m_AllowPlaceUnusedTiles, &Button, 0, "[ctrl+u] Allow placing unused tiles") ||
(Input()->KeyPress(KEY_U) && CtrlPressed))
(Input()->KeyPress(KEY_U) && ModPressed))
{
m_AllowPlaceUnusedTiles = !m_AllowPlaceUnusedTiles;
}
@ -1135,7 +1135,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
static int s_ModifierButton = 0;
if(DoButton_Ex(&s_ModifierButton, aButtonName, 0, &Button, 0, aBuf, CUI::CORNER_ALL) || (CtrlPressed && Input()->KeyPress(KEY_A)))
if(DoButton_Ex(&s_ModifierButton, aButtonName, 0, &Button, 0, aBuf, CUI::CORNER_ALL) || (ModPressed && Input()->KeyPress(KEY_A)))
{
static int s_ModifierPopupID = 0;
if(!UiPopupExists(&s_ModifierPopupID))
@ -1161,12 +1161,12 @@ void CEditor::DoToolbar(CUIRect ToolBar)
if(pLayer->m_Type == LAYERTYPE_QUADS)
{
Invoked = DoButton_Editor(&s_AddItemButton, "Add Quad", 0, &Button, 0, "[ctrl+q] Add a new quad") ||
(Input()->KeyPress(KEY_Q) && CtrlPressed);
(Input()->KeyPress(KEY_Q) && ModPressed);
}
else if(pLayer->m_Type == LAYERTYPE_SOUNDS)
{
Invoked = DoButton_Editor(&s_AddItemButton, "Add Sound", 0, &Button, 0, "[ctrl+q] Add a new sound source") ||
(Input()->KeyPress(KEY_Q) && CtrlPressed);
(Input()->KeyPress(KEY_Q) && ModPressed);
}
if(Invoked)
@ -1177,7 +1177,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
pGroup->Mapping(Mapping);
int x = Mapping[0] + (Mapping[2] - Mapping[0]) / 2;
int y = Mapping[1] + (Mapping[3] - Mapping[1]) / 2;
if(Input()->KeyPress(KEY_Q) && CtrlPressed)
if(Input()->KeyPress(KEY_Q) && ModPressed)
{
x += UI()->MouseWorldX() - (m_WorldOffsetX * pGroup->m_ParallaxX / 100) - pGroup->m_OffsetX;
y += UI()->MouseWorldY() - (m_WorldOffsetY * pGroup->m_ParallaxY / 100) - pGroup->m_OffsetY;
@ -1211,7 +1211,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Bottom.VSplitLeft(65.0f, &Button, &TB_Bottom);
static int s_BrushDrawModeButton = 0;
if(DoButton_Editor(&s_BrushDrawModeButton, "Destructive", m_BrushDrawDestructive, &Button, 0, "[ctrl+d] Toggle brush draw mode") ||
(Input()->KeyPress(KEY_D) && CtrlPressed && !ShiftPressed))
(Input()->KeyPress(KEY_D) && ModPressed && !ShiftPressed))
m_BrushDrawDestructive = !m_BrushDrawDestructive;
TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom);
}
@ -1556,7 +1556,7 @@ void CEditor::DoQuad(CQuad *q, int Index)
SelectQuad(Index);
}
else if(Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))
else if(Input()->ModifierIsPressed())
{
m_LockMouse = true;
s_Operation = OP_ROTATE;
@ -2037,7 +2037,7 @@ void CEditor::DoQuadEnvPoint(const CQuad *pQuad, int QIndex, int PIndex)
if(UI()->MouseButton(0))
{
if(Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))
if(Input()->ModifierIsPressed())
{
m_LockMouse = true;
s_Operation = OP_ROTATE;
@ -2279,7 +2279,7 @@ void CEditor::DoMapEditor(CUIRect View)
s_StartWx = wx;
s_StartWy = wy;
if(Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL) || UI()->MouseButton(2))
if(Input()->ModifierIsPressed() || UI()->MouseButton(2))
{
if(Input()->KeyIsPressed(KEY_LSHIFT))
s_Operation = OP_PAN_EDITOR;
@ -2589,7 +2589,7 @@ void CEditor::DoMapEditor(CUIRect View)
}
}
if(!Input()->KeyIsPressed(KEY_LSHIFT) && !Input()->KeyIsPressed(KEY_RSHIFT) &&
!Input()->KeyIsPressed(KEY_LCTRL) && !Input()->KeyIsPressed(KEY_RCTRL) &&
!Input()->ModifierIsPressed() &&
m_Dialog == DIALOG_NONE && m_EditBoxActive == 0)
{
float PanSpeed = 64.0f;
@ -5082,7 +5082,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
{
if(i != 0)
{
if((Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->ModifierIsPressed())
pEnvelope->m_lPoints[i].m_Time += (int)((m_MouseDeltaX));
else
pEnvelope->m_lPoints[i].m_Time += (int)((m_MouseDeltaX * TimeScale) * 1000.0f);
@ -5094,7 +5094,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
}
else
{
if((Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
if(Input()->ModifierIsPressed())
pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY * 0.001f);
else
pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY * ValueScale);
@ -5621,7 +5621,7 @@ void CEditor::Render()
if(Input()->KeyPress(i))
{
int Slot = i - KEY_1;
if((Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)) && !m_Brush.IsEmpty())
if(Input()->ModifierIsPressed() && !m_Brush.IsEmpty())
{
dbg_msg("editor", "saving current brush to %d", Slot);
if(m_apSavedBrushes[Slot])
@ -5700,11 +5700,11 @@ void CEditor::Render()
if(m_Dialog == DIALOG_NONE)
{
bool CtrlPressed = Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL);
bool ModPressed = Input()->ModifierIsPressed();
bool ShiftPressed = Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT);
bool AltPressed = Input()->KeyIsPressed(KEY_LALT) || Input()->KeyIsPressed(KEY_RALT);
// ctrl+n to create new map
if(Input()->KeyPress(KEY_N) && CtrlPressed)
if(Input()->KeyPress(KEY_N) && ModPressed)
{
if(HasUnsavedData())
{
@ -5721,12 +5721,12 @@ void CEditor::Render()
}
}
// ctrl+a to append map
if(Input()->KeyPress(KEY_A) && CtrlPressed)
if(Input()->KeyPress(KEY_A) && ModPressed)
{
InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_MAP, "Append map", "Append", "maps", "", CallbackAppendMap, this);
}
// ctrl+o or ctrl+l to open
if((Input()->KeyPress(KEY_O) || Input()->KeyPress(KEY_L)) && CtrlPressed)
if((Input()->KeyPress(KEY_O) || Input()->KeyPress(KEY_L)) && ModPressed)
{
if(ShiftPressed)
{
@ -5761,13 +5761,13 @@ void CEditor::Render()
}
// ctrl+shift+alt+s to save as
if(Input()->KeyPress(KEY_S) && CtrlPressed && ShiftPressed && AltPressed)
if(Input()->KeyPress(KEY_S) && ModPressed && ShiftPressed && AltPressed)
InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveCopyMap, this);
// ctrl+shift+s to save as
else if(Input()->KeyPress(KEY_S) && CtrlPressed && ShiftPressed)
else if(Input()->KeyPress(KEY_S) && ModPressed && ShiftPressed)
InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveMap, this);
// ctrl+s to save
else if(Input()->KeyPress(KEY_S) && CtrlPressed)
else if(Input()->KeyPress(KEY_S) && ModPressed)
{
if(m_aFileName[0] && m_ValidSaveFilename)
{

View file

@ -434,15 +434,20 @@ bool CGameContext::VoteUnmute(const NETADDR *pAddr, const char *pDisplayName, in
return false;
}
bool CGameContext::TryMute(const NETADDR *pAddr, int Secs, const char *pReason)
bool CGameContext::TryMute(const NETADDR *pAddr, int Secs, const char *pReason, bool InitialChatDelay)
{
// find a matching mute for this ip, update expiration time if found
for(int i = 0; i < m_NumMutes; i++)
{
if(net_addr_comp_noport(&m_aMutes[i].m_Addr, pAddr) == 0)
{
m_aMutes[i].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
str_copy(m_aMutes[i].m_aReason, pReason, sizeof(m_aMutes[i].m_aReason));
const int NewExpire = Server()->Tick() + Secs * Server()->TickSpeed();
if(NewExpire > m_aMutes[i].m_Expire)
{
m_aMutes[i].m_Expire = NewExpire;
str_copy(m_aMutes[i].m_aReason, pReason, sizeof(m_aMutes[i].m_aReason));
m_aMutes[i].m_InitialChatDelay = InitialChatDelay;
}
return true;
}
}
@ -453,6 +458,7 @@ bool CGameContext::TryMute(const NETADDR *pAddr, int Secs, const char *pReason)
m_aMutes[m_NumMutes].m_Addr = *pAddr;
m_aMutes[m_NumMutes].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
str_copy(m_aMutes[m_NumMutes].m_aReason, pReason, sizeof(m_aMutes[m_NumMutes].m_aReason));
m_aMutes[m_NumMutes].m_InitialChatDelay = InitialChatDelay;
m_NumMutes++;
return true;
}
@ -461,11 +467,12 @@ bool CGameContext::TryMute(const NETADDR *pAddr, int Secs, const char *pReason)
return false;
}
void CGameContext::Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason)
void CGameContext::Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason, bool InitialChatDelay)
{
if(!TryMute(pAddr, Secs, pReason))
if(!TryMute(pAddr, Secs, pReason, InitialChatDelay))
return;
if(InitialChatDelay)
return;
if(!pDisplayName)
return;
@ -601,19 +608,47 @@ void CGameContext::ConMuteIP(IConsole::IResult *pResult, void *pUserData)
void CGameContext::ConUnmute(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
char aIpBuf[64];
char aBuf[64];
int Victim = pResult->GetVictim();
int Index = pResult->GetInteger(0);
if(Victim < 0 || Victim >= pSelf->m_NumMutes)
if(Index < 0 || Index >= pSelf->m_NumMutes)
return;
net_addr_str(&pSelf->m_aMutes[Victim].m_Addr, aIpBuf, sizeof(aIpBuf), false);
char aIpBuf[64];
char aBuf[64];
net_addr_str(&pSelf->m_aMutes[Index].m_Addr, aIpBuf, sizeof(aIpBuf), false);
str_format(aBuf, sizeof(aBuf), "Unmuted %s", aIpBuf);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
pSelf->m_NumMutes--;
pSelf->m_aMutes[Victim] = pSelf->m_aMutes[pSelf->m_NumMutes];
pSelf->m_aMutes[Index] = pSelf->m_aMutes[pSelf->m_NumMutes];
}
// unmute by player id
void CGameContext::ConUnmuteID(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
int Victim = pResult->GetVictim();
if(Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim])
return;
NETADDR Addr;
pSelf->Server()->GetClientAddr(Victim, &Addr);
for(int i = 0; i < pSelf->m_NumMutes; i++)
{
if(net_addr_comp_noport(&pSelf->m_aMutes[i].m_Addr, &Addr) == 0)
{
char aIpBuf[64];
char aBuf[64];
net_addr_str(&pSelf->m_aMutes[i].m_Addr, aIpBuf, sizeof(aIpBuf), false);
str_format(aBuf, sizeof(aBuf), "Unmuted %s", aIpBuf);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
pSelf->m_NumMutes--;
pSelf->m_aMutes[i] = pSelf->m_aMutes[pSelf->m_NumMutes];
return;
}
}
}
// list mutes

View file

@ -1716,46 +1716,46 @@ void CCharacter::HandleTiles(int Index)
m_Core.m_Vel = ClampVel(m_MoveRestrictions, m_Core.m_Vel);
// handle switch tiles
if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_SWITCHOPEN && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_SWITCHOPEN && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
{
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()] = true;
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_EndTick[Team()] = 0;
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Type[Team()] = TILE_SWITCHOPEN;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_SWITCHTIMEDOPEN && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_SWITCHTIMEDOPEN && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
{
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()] = true;
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_EndTick[Team()] = Server()->Tick() + 1 + GameServer()->Collision()->GetSwitchDelay(MapIndex) * Server()->TickSpeed();
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Type[Team()] = TILE_SWITCHTIMEDOPEN;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_SWITCHTIMEDCLOSE && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_SWITCHTIMEDCLOSE && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
{
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()] = false;
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_EndTick[Team()] = Server()->Tick() + 1 + GameServer()->Collision()->GetSwitchDelay(MapIndex) * Server()->TickSpeed();
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Type[Team()] = TILE_SWITCHTIMEDCLOSE;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_SWITCHCLOSE && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_SWITCHCLOSE && Team() != TEAM_SUPER && GameServer()->Collision()->GetSwitchNumber(MapIndex) > 0)
{
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()] = false;
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_EndTick[Team()] = 0;
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Type[Team()] = TILE_SWITCHCLOSE;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_FREEZE && Team() != TEAM_SUPER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_FREEZE && Team() != TEAM_SUPER)
{
if(GameServer()->Collision()->GetSwitchNumber(MapIndex) == 0 || GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
Freeze(GameServer()->Collision()->GetSwitchDelay(MapIndex));
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_DFREEZE && Team() != TEAM_SUPER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_DFREEZE && Team() != TEAM_SUPER)
{
if(GameServer()->Collision()->GetSwitchNumber(MapIndex) == 0 || GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
m_DeepFreeze = true;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_DUNFREEZE && Team() != TEAM_SUPER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_DUNFREEZE && Team() != TEAM_SUPER)
{
if(GameServer()->Collision()->GetSwitchNumber(MapIndex) == 0 || GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
m_DeepFreeze = false;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_HAMMER && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_HAMMER && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can hammer hit others");
m_Hit &= ~DISABLE_HIT_HAMMER;
@ -1763,7 +1763,7 @@ void CCharacter::HandleTiles(int Index)
m_Core.m_NoHammerHit = false;
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_HAMMER) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_HAMMER) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_HAMMER)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't hammer hit others");
m_Hit |= DISABLE_HIT_HAMMER;
@ -1771,43 +1771,43 @@ void CCharacter::HandleTiles(int Index)
m_Core.m_NoHammerHit = true;
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_SHOTGUN && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_SHOTGUN && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can shoot others with shotgun");
m_Hit &= ~DISABLE_HIT_SHOTGUN;
m_Core.m_NoShotgunHit = false;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_SHOTGUN) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_SHOTGUN) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_SHOTGUN)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't shoot others with shotgun");
m_Hit |= DISABLE_HIT_SHOTGUN;
m_Core.m_NoShotgunHit = true;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_GRENADE && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_GRENADE && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can shoot others with grenade");
m_Hit &= ~DISABLE_HIT_GRENADE;
m_Core.m_NoGrenadeHit = false;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_GRENADE) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_GRENADE) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_GRENADE)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't shoot others with grenade");
m_Hit |= DISABLE_HIT_GRENADE;
m_Core.m_NoGrenadeHit = true;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_LASER && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_ENABLE && m_Hit & DISABLE_HIT_LASER && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can shoot others with laser");
m_Hit &= ~DISABLE_HIT_LASER;
m_Core.m_NoLaserHit = false;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_LASER) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_HIT_DISABLE && !(m_Hit & DISABLE_HIT_LASER) && GameServer()->Collision()->GetSwitchDelay(MapIndex) == WEAPON_LASER)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't shoot others with laser");
m_Hit |= DISABLE_HIT_LASER;
m_Core.m_NoLaserHit = true;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_JUMP)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_JUMP)
{
int newJumps = GameServer()->Collision()->GetSwitchDelay(MapIndex);
@ -1834,7 +1834,7 @@ void CCharacter::HandleTiles(int Index)
m_Core.m_Jumps = newJumps;
}
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ADD_TIME && !m_LastPenalty)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_ADD_TIME && !m_LastPenalty)
{
int min = GameServer()->Collision()->GetSwitchDelay(MapIndex);
int sec = GameServer()->Collision()->GetSwitchNumber(MapIndex);
@ -1858,7 +1858,7 @@ void CCharacter::HandleTiles(int Index)
m_LastPenalty = true;
}
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_SUBTRACT_TIME && !m_LastBonus)
else if(GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_SUBTRACT_TIME && !m_LastBonus)
{
int min = GameServer()->Collision()->GetSwitchDelay(MapIndex);
int sec = GameServer()->Collision()->GetSwitchNumber(MapIndex);
@ -1885,12 +1885,12 @@ void CCharacter::HandleTiles(int Index)
m_LastBonus = true;
}
if(GameServer()->Collision()->IsSwitch(MapIndex) != TILE_ADD_TIME)
if(GameServer()->Collision()->GetSwitchType(MapIndex) != TILE_ADD_TIME)
{
m_LastPenalty = false;
}
if(GameServer()->Collision()->IsSwitch(MapIndex) != TILE_SUBTRACT_TIME)
if(GameServer()->Collision()->GetSwitchType(MapIndex) != TILE_SUBTRACT_TIME)
{
m_LastBonus = false;
}
@ -2104,12 +2104,26 @@ void CCharacter::DDRaceTick()
// look for save position for rescue feature
if(g_Config.m_SvRescue || ((g_Config.m_SvTeam == 3 || Team() > TEAM_FLOCK) && Team() >= TEAM_FLOCK && Team() < TEAM_SUPER))
{
int index = GameServer()->Collision()->GetPureMapIndex(m_Pos);
int tile = GameServer()->Collision()->GetTileIndex(index);
int ftile = GameServer()->Collision()->GetFTileIndex(index);
if(IsGrounded() && tile != TILE_FREEZE && tile != TILE_DFREEZE && ftile != TILE_FREEZE && ftile != TILE_DFREEZE && !m_DeepFreeze)
int Index = GameServer()->Collision()->GetPureMapIndex(m_Pos);
const int aTiles[] = {
GameServer()->Collision()->GetTileIndex(Index),
GameServer()->Collision()->GetFTileIndex(Index),
GameServer()->Collision()->GetSwitchType(Index)};
if(IsGrounded() && !m_DeepFreeze)
{
SetRescue();
bool IsInFreeze = false;
for(const int Tile : aTiles)
{
if(Tile == TILE_FREEZE || Tile == TILE_DFREEZE)
{
IsInFreeze = true;
break;
}
}
if(!IsInFreeze)
{
SetRescue();
}
}
}

View file

@ -193,8 +193,8 @@ void CLaser::DoBounce()
{
int MapIndex = GameServer()->Collision()->GetPureMapIndex(Coltile);
int TileFIndex = GameServer()->Collision()->GetFTileIndex(MapIndex);
bool IsSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_TELE_GUN;
bool IsBlueSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_BLUE_TELE_GUN;
bool IsSwitchTeleGun = GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_ALLOW_TELE_GUN;
bool IsBlueSwitchTeleGun = GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_ALLOW_BLUE_TELE_GUN;
int IsTeleInWeapon = GameServer()->Collision()->IsTeleportWeapon(MapIndex);
if(!IsTeleInWeapon)

View file

@ -179,8 +179,8 @@ void CProjectile::Tick()
{
int MapIndex = GameServer()->Collision()->GetPureMapIndex(pTargetChr ? pTargetChr->m_Pos : ColPos);
int TileFIndex = GameServer()->Collision()->GetFTileIndex(MapIndex);
bool IsSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_TELE_GUN;
bool IsBlueSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_BLUE_TELE_GUN;
bool IsSwitchTeleGun = GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_ALLOW_TELE_GUN;
bool IsBlueSwitchTeleGun = GameServer()->Collision()->GetSwitchType(MapIndex) == TILE_ALLOW_BLUE_TELE_GUN;
if(IsSwitchTeleGun || IsBlueSwitchTeleGun)
{

View file

@ -1359,6 +1359,14 @@ void CGameContext::OnClientEnter(int ClientID)
NewClientInfoMsg.m_Local = 1;
Server()->SendPackMsg(&NewClientInfoMsg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientID);
}
// initial chat delay
if(g_Config.m_SvChatInitialDelay != 0 && m_apPlayers[ClientID]->m_JoinTick > m_NonEmptySince + 10 * Server()->TickSpeed())
{
NETADDR Addr;
Server()->GetClientAddr(ClientID, &Addr);
Mute(&Addr, g_Config.m_SvSpamMuteDuration, Server()->ClientName(ClientID), "Initial chat delay", true);
}
}
bool CGameContext::OnClientDataPersist(int ClientID, void *pData)
@ -1400,18 +1408,9 @@ void CGameContext::OnClientConnected(int ClientID, void *pData)
// Check which team the player should be on
const int StartTeam = (Spec || g_Config.m_SvTournamentMode) ? TEAM_SPECTATORS : m_pController->GetAutoTeam(ClientID);
if(!m_apPlayers[ClientID])
m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
else
{
if(m_apPlayers[ClientID])
delete m_apPlayers[ClientID];
m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
// //m_apPlayers[ClientID]->Reset();
// //((CServer*)Server())->m_aClients[ClientID].Reset();
// ((CServer*)Server())->m_aClients[ClientID].m_State = 4;
}
//players[client_id].init(client_id);
//players[client_id].client_id = client_id;
m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
#ifdef CONF_DEBUG
if(g_Config.m_DbgDummies)
@ -3789,13 +3788,11 @@ int CGameContext::ProcessSpamProtection(int ClientID, bool RespectChatInitialDel
Server()->GetClientAddr(ClientID, &Addr);
int Muted = 0;
if(m_apPlayers[ClientID]->m_JoinTick > m_NonEmptySince + 10 * Server()->TickSpeed() && RespectChatInitialDelay)
Muted = (m_apPlayers[ClientID]->m_JoinTick + Server()->TickSpeed() * g_Config.m_SvChatInitialDelay - Server()->Tick()) / Server()->TickSpeed();
if(Muted <= 0)
for(int i = 0; i < m_NumMutes && Muted <= 0; i++)
{
for(int i = 0; i < m_NumMutes && Muted <= 0; i++)
if(!net_addr_comp_noport(&Addr, &m_aMutes[i].m_Addr))
{
if(!net_addr_comp_noport(&Addr, &m_aMutes[i].m_Addr))
if(RespectChatInitialDelay || m_aMutes[i].m_InitialChatDelay)
Muted = (m_aMutes[i].m_Expire - Server()->Tick()) / Server()->TickSpeed();
}
}

View file

@ -299,8 +299,6 @@ private:
//DDRace Console Commands
//static void ConMute(IConsole::IResult *pResult, void *pUserData);
//static void ConUnmute(IConsole::IResult *pResult, void *pUserData);
static void ConKillPlayer(IConsole::IResult *pResult, void *pUserData);
static void ConNinja(IConsole::IResult *pResult, void *pUserData);
@ -393,6 +391,7 @@ private:
static void ConMuteID(IConsole::IResult *pResult, void *pUserData);
static void ConMuteIP(IConsole::IResult *pResult, void *pUserData);
static void ConUnmute(IConsole::IResult *pResult, void *pUserData);
static void ConUnmuteID(IConsole::IResult *pResult, void *pUserData);
static void ConMutes(IConsole::IResult *pResult, void *pUserData);
static void ConModerate(IConsole::IResult *pResult, void *pUserData);
@ -412,14 +411,15 @@ private:
NETADDR m_Addr;
int m_Expire;
char m_aReason[128];
bool m_InitialChatDelay;
};
CMute m_aMutes[MAX_MUTES];
int m_NumMutes;
CMute m_aVoteMutes[MAX_VOTE_MUTES];
int m_NumVoteMutes;
bool TryMute(const NETADDR *pAddr, int Secs, const char *pReason);
void Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason = "");
bool TryMute(const NETADDR *pAddr, int Secs, const char *pReason, bool InitialChatDelay);
void Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason = "", bool InitialChatDelay = false);
bool TryVoteMute(const NETADDR *pAddr, int Secs);
bool VoteMute(const NETADDR *pAddr, int Secs, const char *pDisplayName, int AuthedID);
bool VoteUnmute(const NETADDR *pAddr, const char *pDisplayName, int AuthedID);

View file

@ -188,7 +188,7 @@ MACRO_CONFIG_INT(ClVideoShowhud, cl_video_showhud, 0, 0, 1, CFGFLAG_CLIENT | CFG
MACRO_CONFIG_INT(ClVideoShowChat, cl_video_showchat, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show chat when rendering video")
MACRO_CONFIG_INT(ClVideoSndEnable, cl_video_sound_enable, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Use sound when rendering video")
MACRO_CONFIG_INT(ClVideoShowHookCollOther, cl_video_show_hook_coll_other, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show other players' hook collision lines when rendering video")
MACRO_CONFIG_INT(ClVideoShowDirection, cl_video_showdirection, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show other players' key presses when rendering video")
MACRO_CONFIG_INT(ClVideoShowDirection, cl_video_show_direction, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show players' key presses when rendering video (1 = other players', 2 = also your own)")
MACRO_CONFIG_INT(ClVideoX264Crf, cl_video_crf, 18, 0, 51, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Set crf when encode video with libx264 (0 for highest quality, 51 for lowest)")
MACRO_CONFIG_INT(ClVideoX264Preset, cl_video_preset, 5, 0, 9, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Set preset when encode video with libx264, default is 5 (medium), 0 is ultrafast, 9 is placebo (the slowest, not recommend)")