Skip to content

Commit 9ce3d10

Browse files
committed
New lint
Signed-off-by: Evangelos Lamprou <vagos@lamprou.xyz>
1 parent 153986b commit 9ce3d10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2327
-2329
lines changed

.clang-format

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
BasedOnStyle: LLVM
22
Language: Cpp
33
IndentWidth: 4
4-
TabWidth: 4
5-
UseTab: Always
4+
UseTab: Never
65
BreakBeforeBraces: Allman
76
AllowShortIfStatementsOnASingleLine: false
87
AllowShortBlocksOnASingleLine: false
98
AllowShortFunctionsOnASingleLine: Inline
109
ColumnLimit: 100
11-
PointerAlignment: Left
10+
PointerAlignment: Left
11+
SortIncludes: true
12+
IncludeBlocks: Regroup

include/Exceptions.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
#ifndef EXCEPTIONS_HPP
22
#define EXCEPTIONS_HPP
33

4+
#include <cassert>
45
#include <exception>
56
#include <string>
67

7-
#include <cassert>
8-
98
struct TargetNotFound : public std::exception
109
{
1110

12-
TargetNotFound()
13-
{
14-
// assert(false);
15-
}
11+
TargetNotFound()
12+
{
13+
// assert(false);
14+
}
1615

17-
virtual const char* what() const throw() { return "Nothing with that name was found!\n"; }
16+
virtual const char* what() const throw() { return "Nothing with that name was found!\n"; }
1817
};
1918

2019
struct InvalidCommand : public std::exception
2120
{
22-
virtual const char* what() const throw() { return "There is no such command!\n"; }
21+
virtual const char* what() const throw() { return "There is no such command!\n"; }
2322
};
2423

2524
struct MissingComponent : public std::exception
2625
{
27-
const char* what() const throw() { return "You can't do that!\n"; }
26+
const char* what() const throw() { return "You can't do that!\n"; }
2827
};
2928

3029
struct PlayerDisconnect : public std::exception
3130
{
32-
const char* what() const throw() { return "Player disconnected!\n"; }
31+
const char* what() const throw() { return "Player disconnected!\n"; }
3332
};
3433

3534
#endif // EXCEPTIONS_HPP

include/Helpers.hpp

Lines changed: 95 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
constexpr int SIZE = 65;
55

66
#include <algorithm>
7+
#include <boost/algorithm/string.hpp>
78
#include <exception>
89
#include <list>
910
#include <memory>
@@ -12,8 +13,6 @@ constexpr int SIZE = 65;
1213
#include <unordered_map>
1314
#include <vector>
1415

15-
#include <boost/algorithm/string.hpp>
16-
1716
class Thing;
1817

1918
bool IsNumber(const std::string& s);
@@ -22,58 +21,58 @@ std::vector<std::string> TokenizeString(const std::string& s);
2221

2322
enum class Color
2423
{
25-
None,
26-
White,
27-
Red,
28-
Green,
29-
Blue,
30-
Yellow,
31-
Cyan,
32-
Magenta,
24+
None,
25+
White,
26+
Red,
27+
Green,
28+
Blue,
29+
Yellow,
30+
Cyan,
31+
Magenta,
3332
};
3433

3534
struct Event
3635
{
37-
enum class Type
38-
{
39-
Invalid,
40-
Say,
41-
Move,
42-
Use,
43-
Do,
44-
Whisper,
45-
Chat,
46-
Message,
47-
Buy,
48-
Info,
49-
Ask,
50-
Help,
51-
Inspect,
52-
Greet,
53-
Attack,
54-
Kill,
55-
Death,
56-
Enter,
57-
Leave,
58-
Gain,
59-
Look,
60-
Gain_Quest,
61-
Register,
62-
};
63-
64-
std::string verb;
65-
std::string target;
66-
std::string object;
67-
std::string extra;
68-
std::string payload;
69-
70-
Type type;
36+
enum class Type
37+
{
38+
Invalid,
39+
Say,
40+
Move,
41+
Use,
42+
Do,
43+
Whisper,
44+
Chat,
45+
Message,
46+
Buy,
47+
Info,
48+
Ask,
49+
Help,
50+
Inspect,
51+
Greet,
52+
Attack,
53+
Kill,
54+
Death,
55+
Enter,
56+
Leave,
57+
Gain,
58+
Look,
59+
Gain_Quest,
60+
Register,
61+
};
62+
63+
std::string verb;
64+
std::string target;
65+
std::string object;
66+
std::string extra;
67+
std::string payload;
68+
69+
Type type;
7170
};
7271

7372
const std::string GetColor(Color color_code);
7473

7574
const std::string HeaderString(const std::string& s, const std::string& title, const char h = ' ',
76-
int size = SIZE);
75+
int size = SIZE);
7776

7877
const std::string ColorString(const std::string& s, Color color_code);
7978

@@ -82,101 +81,101 @@ const std::string CenteredString(const std::string& s, int size = SIZE);
8281
template <typename T> const std::shared_ptr<Thing> GetSmartPtr(const T& container, Thing* t_ptr);
8382

8483
const std::shared_ptr<Thing> FindByName(std::vector<std::shared_ptr<Thing>>& container,
85-
const std::string& s);
84+
const std::string& s);
8685

8786
template <typename T, typename F>
8887
const std::string BlockListStringSimple(const T& c, const char b, F f, int step = 3,
89-
int size = SIZE)
88+
int size = SIZE)
9089
{
91-
int i = 0;
90+
int i = 0;
9291

93-
std::stringstream ss;
92+
std::stringstream ss;
9493

95-
for (auto& t : c)
96-
{
97-
ss << b << (b ? ' ' : '\0') << f(t);
94+
for (auto& t : c)
95+
{
96+
ss << b << (b ? ' ' : '\0') << f(t);
9897

99-
ss << '\t';
98+
ss << '\t';
10099

101-
i++;
100+
i++;
102101

103-
if (i % step == 0)
104-
ss << '\n';
105-
}
102+
if (i % step == 0)
103+
ss << '\n';
104+
}
106105

107-
return ss.str();
106+
return ss.str();
108107
}
109108

110109
template <typename T, typename F>
111110
const std::string BlockListString(const T& c, const char b, F f, int step = 3, int size = SIZE)
112111
{
113-
// Group identical Things
112+
// Group identical Things
114113

115-
std::unordered_map<std::string, int> m;
114+
std::unordered_map<std::string, int> m;
116115

117-
for (auto& t : c)
118-
{
119-
m[f(t)] += 1;
120-
}
116+
for (auto& t : c)
117+
{
118+
m[f(t)] += 1;
119+
}
121120

122-
std::stringstream ss;
121+
std::stringstream ss;
123122

124-
int i = 0;
123+
int i = 0;
125124

126-
for (auto [name, n] : m)
127-
{
125+
for (auto [name, n] : m)
126+
{
128127

129-
ss << b << ' ' << name;
128+
ss << b << ' ' << name;
130129

131-
if (n > 1)
132-
ss << " (" << n << ')';
130+
if (n > 1)
131+
ss << " (" << n << ')';
133132

134-
ss << '\t';
133+
ss << '\t';
135134

136-
i++;
135+
i++;
137136

138-
if (i % step == 0)
139-
ss << '\n';
140-
}
137+
if (i % step == 0)
138+
ss << '\n';
139+
}
141140

142-
return ss.str();
141+
return ss.str();
143142
}
144143

145144
const std::string BarString(float filled, int max_size = SIZE, const char f = ':',
146-
const char lb = '[', const char rb = ']');
145+
const char lb = '[', const char rb = ']');
147146

148147
template <typename T, typename F>
149148
const std::string VerticalListString(const T& c, const char b, F f, const char sep = 0,
150-
int size = SIZE)
149+
int size = SIZE)
151150
{
152-
std::stringstream ss;
151+
std::stringstream ss;
153152

154-
for (auto it = c.begin(); it != c.end(); ++it)
155-
{
156-
ss << b << ' ' << f(*it) << '\n';
153+
for (auto it = c.begin(); it != c.end(); ++it)
154+
{
155+
ss << b << ' ' << f(*it) << '\n';
157156

158-
if (size && sep && it != c.end() - 1)
159-
ss << std::string(size, sep) << '\n';
160-
}
157+
if (size && sep && it != c.end() - 1)
158+
ss << std::string(size, sep) << '\n';
159+
}
161160

162-
return ss.str();
161+
return ss.str();
163162
}
164163

165164
template <typename T>
166165
const std::string VerticalListString(const T& c, const char b, const char sep = ' ',
167-
int size = SIZE)
166+
int size = SIZE)
168167
{
169-
std::stringstream ss;
168+
std::stringstream ss;
170169

171-
for (auto it = c.begin(); it != c.end(); ++it)
172-
{
173-
ss << b << ' ' << **it << '\n';
170+
for (auto it = c.begin(); it != c.end(); ++it)
171+
{
172+
ss << b << ' ' << **it << '\n';
174173

175-
if (size && it != c.end() - 1)
176-
ss << std::string(size, sep) << '\n';
177-
}
174+
if (size && it != c.end() - 1)
175+
ss << std::string(size, sep) << '\n';
176+
}
178177

179-
return ss.str();
178+
return ss.str();
180179
}
181180

182181
void HandleException(const std::shared_ptr<Thing>& t, std::exception& e);

include/Quest.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#ifndef QUEST_HPP
22
#define QUEST_HPP
33

4+
#include "script/ScriptedThing.hpp"
5+
46
#include <memory>
57
#include <string>
68

7-
#include "script/ScriptedThing.hpp"
8-
99
class ScriptedQuest : public ScriptedThing
1010
{
1111
public:
12-
ScriptedQuest(const std::string& name);
12+
ScriptedQuest(const std::string& name);
1313
};
1414

1515
#endif // QUEST_HPP

0 commit comments

Comments
 (0)