6082: Fix incorrect cursor position after exiting pause/spec r=def- a=Robyt3
The cursor position was not correctly restored when exiting pause or spec, when the mouse was on the left side of the tee (x being negative).
This is caused by a calculation introduced in #1637 and #1830 that tries to ensure that the mouse can still be moved if it ends up inside the minimum mouse distance (`cl_mouse_min_distance` and `cl_dyncam_min_distance`). However, this did not consider that the x position can become negative, so the x position was also incorrectly changed when exiting pause.
This is fixed by reverting the changes, as this code has become obsolete and has been superseded by #2009 and #3884. The `CControls::ClampMousePos` function, which is called directly after restoring the position, already ensures that mouse is not stuck within the minimum mouse distance.
Closes#2591.
## 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 (especially base/) or added coverage to integration test
- [ ] 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)
Co-authored-by: Robert Müller <robytemueller@gmail.com>
The cursor position was not correctly restored when exiting pause or spec, when the mouse was on the left side of the tee (x being negative).
This is caused by a calculation introduced in #1637 and #1830 that tries to ensure that the mouse can still be moved if it ends up inside the minimum mouse distance (`cl_mouse_min_distance` and `cl_dyncam_min_distance`).
However, this did not consider that the x position can become negative, so the x position was also incorrectly changed when exiting pause.
This is fixed by reverting the changes, as this code has become obsolete and has been superseded by #2009 and #3884. The `CControls::ClampMousePos` function, which is called directly after restoring the position, already ensures that mouse is not stuck within the minimum mouse distance.
Closes#2591.
6081: Add generic confirm popup to menu, adapt generic message popup, use the generic popups when possible r=def- a=Robyt3
## 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 (especially base/) or added coverage to integration test
- [ ] 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: Robert Müller <robytemueller@gmail.com>
Add "Cancel" button to country/region picker popup. It's already possible to cancel with the Escape key, so there should also be a button, which keeps the current selection.
Delegate the listbox activation (enter / double click on item) to the popup to confirm it. Enter was previously working but then broken by the logic that ensures that every hotkey is only consumed once. Now both enter and double click confirm the popup.
From teeworlds/teeworlds#2961.
Add a generic popup to confirm an operation to the menu and revise the generic message popup similar to this.
Both popups have a title and a message. The message popup has one button and the confirmation popup has two buttons.
For each button a label, the next popup after clicking the button, and a custom button handler can be set.
From teeworlds/teeworlds#2598.
Add a new menu "Tools" next to the "File" menu, with a button to "Remove unused envelopes".
Clicking the button opens a confirmation popup to confirm the operation.
Closes#2576.
Add `CEditor::ShowPopupConfirm` to show a generic confirmation popup.
This popups shows a message and buttons to confirm or cancel an operation. The result will be available to the caller in the given `SConfirmPopupContext`.
6080: Try using default MariaDB server version (fixes#6079) r=Robyt3 a=def-
<!-- What is the motivation for the changes of this pull request? -->
<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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 (especially base/) or added coverage to integration test
- [ ] 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: Dennis Felsing <dennis@felsin9.de>
6075: Fix key reader text flashing for one frame, refactoring r=def- a=Robyt3
The key reader was displaying the old key for a frame. It now shows the new key immediately without flashing the old one after changing a bind.
Refactoring:
- The if-branches are restructured to be the same as on upstream.
- The function `GetKeyBindModifiersName` can be called without an additional check, because it returns an empty string when no modifier is pressed.
- The unused parameter `Checked` of the `DoButton_KeySelect` function is removed.
From teeworlds/teeworlds#2877.
## 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 (especially base/) or added coverage to integration test
- [ ] 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)
6076: Fix stored commands using original callback instead of the chain, fix client crash when launching with `screenshot` command r=def- a=Robyt3
## 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 (especially base/) or added coverage to integration test
- [ ] 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: Robert Müller <robytemueller@gmail.com>
6074: Reset teams when restarting round r=def- a=Robyt3
The state of teams was not reset when restarting a round with `restart`, which led to various issues (#5144):
- Switchers kept their previous state instead of being reset to the initial state after restarting.
- Teams that started racing sometimes could not be joined after restarting.
- Sometimes teams cannot finish a race after restarting. I cannot reproduce this issue, so I don't know if it's fixed by these changes.
## 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 (especially base/) or added coverage to integration test
- [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)
Co-authored-by: Robert Müller <robytemueller@gmail.com>
According to cppcheck's `constVariable` error:
```
src\engine\client\backend\opengl\opengl_sl.cpp:74:43: style: Variable 'Define' can be declared as reference to const [constVariable]
for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:2149:12: style: Variable 'GraphicThreadCommandBuffer' can be declared as reference to const [constVariable]
auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3192:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3200:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3810:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
for(auto &Mode : vPresentModeList)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3818:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
for(auto &Mode : vPresentModeList)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6511:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6555:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6660:9: style: Variable 'MemBlock' can be declared as reference to const [constVariable]
auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6799:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6808:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6902:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6907:9: style: Variable 'TextTextureDescr' can be declared as reference to const [constVariable]
auto &TextTextureDescr = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6961:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6970:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\game\client\components\hud.cpp:178:8: style: Variable 'aFlagCarrier' can be declared as const array [constVariable]
int aFlagCarrier[2] = {
^
src\game\client\components\hud.cpp:519:16: style: Variable 's_aTextWidth' can be declared as const array [constVariable]
static float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
^
src\game\client\components\killmessages.cpp:305:30: style: Variable 'Client' can be declared as reference to const [constVariable]
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
^
src\game\client\components\killmessages.cpp:314:30: style: Variable 'Client' can be declared as reference to const [constVariable]
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
^
src\game\client\components\menus_ingame.cpp:243:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
^
src\game\client\components\menus_ingame.cpp:530:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
^
src\game\client\components\players.cpp:767:44: style: Variable 'CharacterInfo' can be declared as reference to const [constVariable]
CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
^
src\game\client\components\spectator.cpp:122:27: style: Variable 'Snap' can be declared as reference to const [constVariable]
CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
^
src\game\client\components\spectator.cpp:221:12: style: Variable 'pInfo' can be declared as reference to const [constVariable]
for(auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
^
src\game\client\gameclient.cpp:2220:15: style: Variable 'OwnClientData' can be declared as reference to const [constVariable]
CClientData &OwnClientData = m_aClients[ownID];
^
src\game\client\gameclient.cpp:2227:16: style: Variable 'cData' can be declared as reference to const [constVariable]
CClientData &cData = m_aClients[i];
^
src\game\client\prediction\entities\character.cpp:397:11: style: Variable 'aSpreading' can be declared as const array [constVariable]
float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
^
src\game\client\prediction\entities\laser.cpp:53:9: style: Variable 'HitPos' can be declared as reference to const [constVariable]
vec2 &HitPos = pHit->Core()->m_Pos;
^
src\game\editor\auto_map.cpp:507:18: style: Variable 'Index' can be declared as reference to const [constVariable]
for(auto &Index : pRule->m_vIndexList)
^
src\game\editor\auto_map.cpp:518:18: style: Variable 'Index' can be declared as reference to const [constVariable]
for(auto &Index : pRule->m_vIndexList)
^
src\game\editor\editor.cpp:118:12: style: Variable 'Item' can be declared as reference to const [constVariable]
for(auto &Item : vList)
^
src\game\editor\editor.cpp:2983:11: style: Variable 'aAspects' can be declared as const array [constVariable]
float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
^
src\game\editor\editor.cpp:3141:15: style: Variable 's_aShift' can be declared as const array [constVariable]
static int s_aShift[] = {24, 16, 8, 0};
^
src\engine\server\server.cpp:2807:14: style: Variable 'Client' can be declared as reference to const [constVariable]
for(auto &Client : m_aClients)
^
src\engine\server\sql_string_helpers.cpp:51:6: style: Variable 'aTimes' can be declared as const array [constVariable]
int aTimes[7] =
^
src\test\secure_random.cpp:24:6: style: Variable 'BOUNDS' can be declared as const array [constVariable]
int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
^
```
According to cppchecker's `arrayIndexThenCheck` error:
```
src\game\client\race.cpp:24:30: style: Array index 'i' is used before limits check. [arrayIndexThenCheck]
for(int i = 0; isdigit(pStr[i]) && i < 3; i++)
^
```
According to cppchecker's `constParameter` error:
```
src\engine\gfx\image_manipulation.cpp:7:58: style: Parameter 'pSrc' can be declared as pointer to const [constParameter]
static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest, unsigned char AlphaThreshold = TW_DILATE_ALPHA_THRESHOLD)
^
src\engine\gfx\image_manipulation.cpp:58:67: style: Parameter 'pSrc' can be declared as pointer to const [constParameter]
static void CopyColorValues(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest)
^
src\engine\shared\network_conn.cpp:241:42: style: Parameter 'Addr' can be declared as reference to const [constParameter]
void CNetConnection::DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken, SECURITY_TOKEN Token, bool Sixup)
^
src\base\system.cpp:4060:71: style: Parameter 'random' can be declared as pointer to const [constParameter]
void generate_password(char *buffer, unsigned length, unsigned short *random, unsigned random_length)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:263:38: style: Parameter 'AllocatedMemory' can be declared as reference to const [constParameter]
void Free(SMemoryHeapQueueElement &AllocatedMemory)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:1708:47: style: Parameter 'ImgExtent' can be declared as reference to const [constParameter]
static size_t ImageMipLevelCount(VkExtent3D &ImgExtent)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:2801:29: style: Parameter 'Image' can be declared as reference to const [constParameter]
void ImageBarrier(VkImage &Image, size_t MipMapBase, size_t MipMapCount, size_t LayerBase, size_t LayerCount, VkFormat Format, VkImageLayout OldLayout, VkImageLayout NewLayout)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6495:46: style: Parameter 'ExecBuffer' can be declared as reference to const [constParameter]
void Cmd_Clear(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand_Clear *pCommand)
^
src\game\client\components\skins.cpp:83:72: style: Parameter 'pImg' can be declared as pointer to const [constParameter]
static void CheckMetrics(CSkin::SSkinMetricVariable &Metrics, uint8_t *pImg, int ImgWidth, int ImgX, int ImgY, int CheckWidth, int CheckHeight)
^
src\game\client\prediction\entities\character.h:106:37: style: Parameter 'pNewInput' can be declared as pointer to const [constParameter]
void SetInput(CNetObj_PlayerInput *pNewInput)
^
src\game\client\prediction\gameworld.cpp:245:106: style: Parameter 'pNotThis' can be declared as pointer to const [constParameter]
CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis, int CollideWith, class CCharacter *pThisOnly)
^
src\game\client\prediction\gameworld.cpp:245:151: style: Parameter 'pThisOnly' can be declared as pointer to const [constParameter]
CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis, int CollideWith, class CCharacter *pThisOnly)
^
src\game\client\prediction\gameworld.cpp:283:116: style: Parameter 'pNotThis' can be declared as pointer to const [constParameter]
std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis)
^
src\game\client\ui.cpp:522:180: style: Parameter 'pReadCursor' can be declared as pointer to const [constParameter]
void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen, CTextCursor *pReadCursor)
^
src\game\client\ui_scrollregion.cpp:23:86: style: Parameter 'pParams' can be declared as pointer to const [constParameter]
void CScrollRegion::Begin(CUIRect *pClipRect, vec2 *pOutOffset, CScrollRegionParams *pParams)
^
src\game\server\scoreworker.h:239:29: style: Parameter 'aTimeCp' can be declared as const array [constParameter]
void Set(float Time, float aTimeCp[NUM_CHECKPOINTS])
^
src\game\server\score.cpp:135:80: style: Parameter 'aTimeCp' can be declared as const array [constParameter]
void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float aTimeCp[NUM_CHECKPOINTS], bool NotEligible)
^
src\game\server\teeinfo.cpp:40:57: style: Parameter 'pUseCustomColors' can be declared as pointer to const [constParameter]
CTeeInfo::CTeeInfo(const char *apSkinPartNames[6], int *pUseCustomColors, int *pSkinPartColors)
^
src\game\server\teeinfo.cpp:40:80: style: Parameter 'pSkinPartColors' can be declared as pointer to const [constParameter]
CTeeInfo::CTeeInfo(const char *apSkinPartNames[6], int *pUseCustomColors, int *pSkinPartColors)
^
```
According to cppchecker's `arrayIndexOutOfBoundsCond` error:
```
src\engine\server\server.cpp:117:19: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
dbg_assert(m_aIDs[ID].m_State == ID_ALLOCATED, "id is not allocated");
^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
if(ID < 0)
^
src\engine\server\server.cpp:117:19: note: Array index out of bounds
dbg_assert(m_aIDs[ID].m_State == ID_ALLOCATED, "id is not allocated");
^
src\engine\server\server.cpp:120:8: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
m_aIDs[ID].m_State = ID_TIMED;
^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
if(ID < 0)
^
src\engine\server\server.cpp:120:8: note: Array index out of bounds
m_aIDs[ID].m_State = ID_TIMED;
^
src\engine\server\server.cpp:121:8: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
m_aIDs[ID].m_Timeout = time_get() + time_freq() * 5;
^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
if(ID < 0)
^
src\engine\server\server.cpp:121:8: note: Array index out of bounds
m_aIDs[ID].m_Timeout = time_get() + time_freq() * 5;
^
src\engine\server\server.cpp:122:8: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
m_aIDs[ID].m_Next = -1;
^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
if(ID < 0)
^
src\engine\server\server.cpp:122:8: note: Array index out of bounds
m_aIDs[ID].m_Next = -1;
^
```
According to cppchecker's `nullPointerRedundantCheck` error:
```
src\engine\server\server_logger.cpp:29:3: warning: Either the condition 'm_pServer' is redundant or there is possible null pointer dereference: m_pServer. [nullPointerRedundantCheck]
m_pServer->SendLogLine(pMessage);
^
src\engine\server\server_logger.cpp:19:7: note: Assuming that condition 'm_pServer' is not redundant
if(m_pServer)
^
src\engine\server\server_logger.cpp:29:3: note: Null pointer dereference
m_pServer->SendLogLine(pMessage);
^
```
According to cppcheck's `redundantInitialization` and `redundantAssignment` errors:
```
src\game\client\ui.cpp:456:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization]
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
^
src\game\client\ui.cpp:454:11: note: tw is initialized
float tw = std::numeric_limits<float>::max();
^
src\game\client\ui.cpp:456:5: note: tw is overwritten
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
^
src\game\client\ui.cpp:529:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization]
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
^
src\game\client\ui.cpp:527:11: note: tw is initialized
float tw = std::numeric_limits<float>::max();
^
src\game\client\ui.cpp:529:5: note: tw is overwritten
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
^
src\game\editor\editor.cpp:6051:19: style: Variable 'm_Map.m_Modified' is reassigned a value before the old one has been used. [redundantAssignment]
m_Map.m_Modified = false;
^
src\game\editor\editor.cpp:6046:19: note: m_Map.m_Modified is assigned
m_Map.m_Modified = false;
^
src\game\editor\editor.cpp:6051:19: note: m_Map.m_Modified is overwritten
m_Map.m_Modified = false;
^
src\game\client\prediction\entities\character.cpp:1148:36: style: Variable 'm_LatestInput' is reassigned a value before the old one has been used. [redundantAssignment]
m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
^
src\game\client\prediction\entities\character.cpp:1134:16: note: m_LatestInput is assigned
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
^
src\game\client\prediction\entities\character.cpp:1148:36: note: m_LatestInput is overwritten
m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
^
src\game\client\prediction\entities\character.cpp:1148:20: style: Variable 'm_LatestPrevInput' is reassigned a value before the old one has been used. [redundantAssignment]
m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
^
src\game\client\prediction\entities\character.cpp:1134:36: note: m_LatestPrevInput is assigned
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
^
src\game\client\prediction\entities\character.cpp:1148:20: note: m_LatestPrevInput is overwritten
m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
^
src\game\client\prediction\entities\character.cpp:1148:50: style: Variable 'm_PrevInput' is reassigned a value before the old one has been used. [redundantAssignment]
m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
^
src\game\client\prediction\entities\character.cpp:1134:50: note: m_PrevInput is assigned
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
^
src\game\client\prediction\entities\character.cpp:1148:50: note: m_PrevInput is overwritten
m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
^
```
According to cppcheck's `badBitmaskCheck` error:
```
src\engine\client\client.cpp:422:26: style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]
Packer.AddInt((0 << 1) | (pMsg->m_System ? 1 : 0)); // NETMSG_EX, NETMSGTYPE_EX
^
src\engine\shared\snapshot.cpp:40:45: style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]
int TypeItemIndex = GetItemIndex((0 << 16) | InternalType); // NETOBJTYPE_EX
^
src\engine\server\server.cpp:777:26: style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]
Packer.AddInt((0 << 1) | (pMsg->m_System ? 1 : 0)); // NETMSG_EX, NETMSGTYPE_EX
^
```
According to cppcheck's `selfAssignment` error:
```
src\engine\client\backend\vulkan\backend_vulkan.cpp:5784:23: warning: Redundant assignment of 'DescrSetTextOutline' to itself. [selfAssignment]
DescrSetTextOutline = DescrSetText;
^
```
According to cppcheck's `unsignedLessThanZero` error:
```
src\engine\shared\datafile.cpp:129:13: style: Checking if unsigned expression 'Bytes' is less than zero. [unsignedLessThanZero]
if(Bytes <= 0)
^
```
According to cppcheck's `nullPointerRedundantCheck` check:
```
src\game\client\components\menus_settings.cpp:729:8: warning: Either the condition 'pSkinToBeSelected==0' is redundant or there is possible null pointer dereference: pSkinToBeSelected. [nullPointerRedundantCheck]
if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
^
src\game\client\components\menus_settings.cpp:732:25: note: Assuming that condition 'pSkinToBeSelected==0' is not redundant
if(pSkinToBeSelected == 0)
^
src\game\client\components\menus_settings.cpp:729:8: note: Null pointer dereference
if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
^
src\game\editor\editor.cpp:5034:19: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
float EndTime = pEnvelope->EndTime();
^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
if(pEnvelope)
^
src\game\editor\editor.cpp:5034:19: note: Null pointer dereference
float EndTime = pEnvelope->EndTime();
^
src\game\editor\editor.cpp:5038:3: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
pEnvelope->FindTopBottom(s_ActiveChannels);
^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
if(pEnvelope)
^
src\game\editor\editor.cpp:5038:3: note: Null pointer dereference
pEnvelope->FindTopBottom(s_ActiveChannels);
^
src\game\editor\editor.cpp:5039:15: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
float Top = pEnvelope->m_Top;
^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
if(pEnvelope)
^
src\game\editor\editor.cpp:5039:15: note: Null pointer dereference
float Top = pEnvelope->m_Top;
^
src\game\editor\editor.cpp:5040:18: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
float Bottom = pEnvelope->m_Bottom;
^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
if(pEnvelope)
^
src\game\editor\editor.cpp:5040:18: note: Null pointer dereference
float Bottom = pEnvelope->m_Bottom;
^
src\game\editor\editor.cpp:5081:23: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
for(int c = 0; c < pEnvelope->m_Channels; c++)
^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
if(pEnvelope)
^
src\game\editor\editor.cpp:5081:23: note: Null pointer dereference
for(int c = 0; c < pEnvelope->m_Channels; c++)
^
```
The assigned values are never used, so the assignments can be removed or variable scopes can be reduced.
According to cppcheck's `unreadVariable` error.
The client crashes when launching with `screenshot` in the command line, as the graphics are not available when the command is executed.
This is fixed by storing the command, so it's executed when everything is ready.
When stored commands (`CFGFLAG_STORE`) were executed with `CConsole::StoreCommands(false)`, the associated chained commands were not properly executed, if they were chained after the command has been stored (e.g. in `CMenus::OnInit`).
Storing the command saves the current callback and userdata, which were overridden by the chain callback and userdata, but the stored callback and userdata were not updated.
This is fixed by storing a pointer to the command itself, which will be updated when it is chained.
From teeworlds/teeworlds#2572.
The key reader was displaying the old key for a frame. It now shows the new key immediately without flashing the old one after changing a bind.
Refactoring:
- The if-branches are restructured to be the same as on upstream.
- The function `GetKeyBindModifiersName` can be called without an additional check, because it returns an empty string when no modifier is pressed.
- The unused parameter `Checked` of the `DoButton_KeySelect` function is removed.
From teeworlds/teeworlds#2877.
The state of teams was not reset when restarting a round with `restart`, which led to various issues (#5144):
- Switchers kept their previous state instead of being reset to the initial state after restarting.
- Teams that started racing sometimes could not be joined after restarting.
- Sometimes teams cannot finish a race after restarting. I cannot reproduce this issue, so I don't know if it's fixed by these changes.
6073: Remove // in ddnet:// url handler r=Jupeyy a=def-
<!-- What is the motivation for the changes of this pull request? -->
<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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 (especially base/) or added coverage to integration test
- [ ] 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: Dennis Felsing <dennis@felsin9.de>