5131: Remove base/tl/base.h r=heinrich5991 a=Robyt3



## 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: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2022-05-15 20:11:13 +00:00 committed by GitHub
commit 61cca6ca16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 34 deletions

View file

@ -1649,7 +1649,6 @@ set_src(BASE GLOB_RECURSE src/base
tl/algorithm.h tl/algorithm.h
tl/allocator.h tl/allocator.h
tl/array.h tl/array.h
tl/base.h
tl/range.h tl/range.h
tl/sorted_array.h tl/sorted_array.h
tl/threading.h tl/threading.h

View file

@ -1,17 +0,0 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef BASE_TL_BASE_H
#define BASE_TL_BASE_H
#include <algorithm>
#include <base/system.h>
#include <utility>
using std::swap;
inline void tl_assert(bool statement)
{
dbg_assert(statement, "assert!");
}
#endif

View file

@ -3,7 +3,7 @@
#ifndef BASE_TL_RANGE_H #ifndef BASE_TL_RANGE_H
#define BASE_TL_RANGE_H #define BASE_TL_RANGE_H
#include "base/tl/base.h" #include <base/system.h>
/* /*
Group: Range concepts Group: Range concepts
@ -186,27 +186,27 @@ public:
bool empty() const { return begin >= end; } bool empty() const { return begin >= end; }
void pop_front() void pop_front()
{ {
tl_assert(!empty()); dbg_assert(!empty(), "empty");
begin++; begin++;
} }
void pop_back() void pop_back()
{ {
tl_assert(!empty()); dbg_assert(!empty(), "empty");
end--; end--;
} }
T &front() T &front()
{ {
tl_assert(!empty()); dbg_assert(!empty(), "empty");
return *begin; return *begin;
} }
T &back() T &back()
{ {
tl_assert(!empty()); dbg_assert(!empty(), "empty");
return *(end - 1); return *(end - 1);
} }
T &index(unsigned i) T &index(unsigned i)
{ {
tl_assert(i < (unsigned)(end - begin)); dbg_assert(i < (unsigned)(end - begin), "out of range");
return begin[i]; return begin[i];
} }
unsigned size() const { return (unsigned)(end - begin); } unsigned size() const { return (unsigned)(end - begin); }

View file

@ -2,7 +2,6 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <base/math.h> #include <base/math.h>
#include <base/system.h> #include <base/system.h>
#include <base/tl/base.h>
#include "lineinput.h" #include "lineinput.h"
#include <engine/keys.h> #include <engine/keys.h>
@ -27,7 +26,7 @@ void CLineInput::Set(const char *pString)
void CLineInput::SetRange(const char *pString, int Begin, int End) void CLineInput::SetRange(const char *pString, int Begin, int End)
{ {
if(Begin > End) if(Begin > End)
swap(Begin, End); std::swap(Begin, End);
Begin = clamp(Begin, 0, m_Len); Begin = clamp(Begin, 0, m_Len);
End = clamp(End, 0, m_Len); End = clamp(End, 0, m_Len);

View file

@ -231,7 +231,7 @@ int CLayerGroup::SwapLayers(int Index0, int Index1)
if(Index0 == Index1) if(Index0 == Index1)
return Index0; return Index0;
m_pMap->m_Modified = true; m_pMap->m_Modified = true;
swap(m_lLayers[Index0], m_lLayers[Index1]); std::swap(m_lLayers[Index0], m_lLayers[Index1]);
return Index1; return Index1;
} }
@ -1946,11 +1946,11 @@ void CEditor::DoQuadKnife(int QuadIndex)
IsInTriangle(m_aQuadKnifePoints[1], m_aQuadKnifePoints[0], m_aQuadKnifePoints[2], m_aQuadKnifePoints[3])) IsInTriangle(m_aQuadKnifePoints[1], m_aQuadKnifePoints[0], m_aQuadKnifePoints[2], m_aQuadKnifePoints[3]))
{ {
// Fix concave order // Fix concave order
swap(m_aQuadKnifePoints[0], m_aQuadKnifePoints[3]); std::swap(m_aQuadKnifePoints[0], m_aQuadKnifePoints[3]);
swap(m_aQuadKnifePoints[1], m_aQuadKnifePoints[2]); std::swap(m_aQuadKnifePoints[1], m_aQuadKnifePoints[2]);
} }
swap(m_aQuadKnifePoints[2], m_aQuadKnifePoints[3]); std::swap(m_aQuadKnifePoints[2], m_aQuadKnifePoints[3]);
CQuad *pResult = pLayer->NewQuad(64, 64, 64, 64); CQuad *pResult = pLayer->NewQuad(64, 64, 64, 64);
pQuad = &pLayer->m_lQuads[QuadIndex]; pQuad = &pLayer->m_lQuads[QuadIndex];

View file

@ -416,7 +416,7 @@ public:
if(Index0 == Index1) if(Index0 == Index1)
return Index0; return Index0;
m_Modified = true; m_Modified = true;
swap(m_lGroups[Index0], m_lGroups[Index1]); std::swap(m_lGroups[Index0], m_lGroups[Index1]);
return Index1; return Index1;
} }

View file

@ -902,9 +902,9 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
PrimarySavedTee.Load(pTargetPlayer->GetCharacter(), Team, true); PrimarySavedTee.Load(pTargetPlayer->GetCharacter(), Team, true);
SecondarySavedTee.Load(pPlayer->GetCharacter(), Team, true); SecondarySavedTee.Load(pPlayer->GetCharacter(), Team, true);
swap(m_TeeStarted[pPlayer->GetCID()], m_TeeStarted[pTargetPlayer->GetCID()]); std::swap(m_TeeStarted[pPlayer->GetCID()], m_TeeStarted[pTargetPlayer->GetCID()]);
swap(m_TeeFinished[pPlayer->GetCID()], m_TeeFinished[pTargetPlayer->GetCID()]); std::swap(m_TeeFinished[pPlayer->GetCID()], m_TeeFinished[pTargetPlayer->GetCID()]);
swap(pPlayer->GetCharacter()->GetRescueTeeRef(), pTargetPlayer->GetCharacter()->GetRescueTeeRef()); std::swap(pPlayer->GetCharacter()->GetRescueTeeRef(), pTargetPlayer->GetCharacter()->GetRescueTeeRef());
GameServer()->m_World.SwapClients(pPlayer->GetCID(), pTargetPlayer->GetCID()); GameServer()->m_World.SwapClients(pPlayer->GetCID(), pTargetPlayer->GetCID());