Skip to content

Commit 2b90631

Browse files
committed
premake5, windows fixes, meta element removal fix
1 parent 4f71f11 commit 2b90631

File tree

5 files changed

+153
-10
lines changed

5 files changed

+153
-10
lines changed

kit/meta/meta.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,8 @@ class MetaBase:
10891089
// TODO: remove hooks too?
10901090
if(!m_Elements.at(id).key.empty())
10911091
remove(m_Elements[id].key);
1092-
m_Elements.erase(m_Elements.begin() + id);
1092+
else
1093+
m_Elements.erase(m_Elements.begin() + id);
10931094
}
10941095

10951096
void pop_back() {
@@ -1113,15 +1114,14 @@ class MetaBase:
11131114

11141115
auto l = this->lock();
11151116
unsigned idx = m_Keys.at(key);
1117+
assert(idx < m_Elements.size());
1118+
1119+
// TODO: not super efficient, might be better to flag out of date indices somehow
1120+
for (unsigned i = idx + 1; i<m_Elements.size(); ++i)
1121+
m_Keys[m_Elements[i].key] = i - 1;
1122+
11161123
m_Elements.erase(m_Elements.begin() + idx);
11171124
m_Keys.erase(key);
1118-
//kit::remove_if(m_Elements, [&](Element& e){
1119-
// // TODO: remove key from hooks
1120-
// bool b = e.key == key;
1121-
// if(b)
1122-
// m_Keys.erase(key);
1123-
// return b;
1124-
//});
11251125
}
11261126

11271127
// Copying internal MetaBase::Element into an existing element of type key

kit/net/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define WIN32_LEAN_AND_MEAN
1313
#endif
1414
#include <windows.h>
15-
#include <winsock.h>
15+
#include <winsock2.h>
1616
typedef int socklen_t;
1717
#else
1818
#include <sys/types.h>
@@ -69,7 +69,7 @@ class ISocket
6969
WinSockIniter() {
7070
WSADATA wsaData;
7171
if(WSAStartup(MAKEWORD(1,1), &wsaData) != 0) {
72-
cerr << "WinSock failed to intialize." << endl;
72+
std::cerr << "WinSock failed to intialize." << std::endl;
7373
exit(1);
7474
}
7575
}

kit/reactive/reactive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define REACTIVE_H_GQBDAQXV
33

44
#include <boost/optional.hpp>
5+
#include <boost/optional/optional_io.hpp>
56
#include <boost/signals2.hpp>
67
#include "../kit.h"
78
#include "signal.h"

premake5.lua

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
workspace("kit")
2+
targetdir("bin")
3+
4+
configurations {"Debug", "Release"}
5+
6+
defines { "GLM_FORCE_RADIANS", "DO_NOT_USE_WMAIN" }
7+
8+
-- Debug Config
9+
configuration "Debug"
10+
defines { "DEBUG" }
11+
symbols "On"
12+
linkoptions { }
13+
14+
configuration "linux"
15+
links {
16+
"z",
17+
"bfd",
18+
"iberty"
19+
}
20+
21+
-- Release Config
22+
configuration "Release"
23+
defines { "NDEBUG" }
24+
flags { "OptimizeSpeed" }
25+
optimize "speed"
26+
targetname("kit_dist")
27+
28+
-- gmake Config
29+
configuration "gmake"
30+
buildoptions { "-std=c++11" }
31+
-- buildoptions { "-std=c++11", "-pedantic", "-Wall", "-Wextra", '-v', '-fsyntax-only'}
32+
links {
33+
"pthread",
34+
"SDL2",
35+
"boost_system",
36+
"boost_filesystem",
37+
"boost_coroutine",
38+
"boost_python",
39+
"boost_regex",
40+
"jsoncpp",
41+
}
42+
includedirs {
43+
"/usr/local/include/",
44+
"/usr/include/bullet/",
45+
"/usr/include/raknet/DependentExtensions"
46+
}
47+
48+
libdirs {
49+
"/usr/local/lib"
50+
}
51+
52+
buildoptions {
53+
"`python2-config --includes`",
54+
"`pkg-config --cflags cairomm-1.0 pangomm-1.4`"
55+
}
56+
57+
linkoptions {
58+
"`python2-config --libs`",
59+
"`pkg-config --libs cairomm-1.0 pangomm-1.4`"
60+
}
61+
62+
configuration "macosx"
63+
links {
64+
"boost_thread-mt",
65+
}
66+
67+
--buildoptions { "-U__STRICT_ANSI__", "-stdlib=libc++" }
68+
--linkoptions { "-stdlib=libc++" }
69+
70+
configuration "linux"
71+
links {
72+
--"GL",
73+
"boost_thread",
74+
}
75+
76+
configuration "windows"
77+
toolset "v140"
78+
flags { "MultiProcessorCompile" }
79+
80+
links {
81+
"ws2_32",
82+
"SDL2",
83+
"boost_system-vc140-mt-1_61",
84+
"boost_thread-vc140-mt-1_61",
85+
"boost_python-vc140-mt-1_61",
86+
"boost_coroutine-vc140-mt-1_61",
87+
"boost_regex-vc140-mt-1_61",
88+
"lib_json",
89+
}
90+
91+
includedirs {
92+
"c:/local/boost_1_61_0",
93+
"c:/msvc/include",
94+
}
95+
configuration { "windows", "Debug" }
96+
libdirs {
97+
"c:/msvc/lib32/debug"
98+
}
99+
configuration { "windows" }
100+
libdirs {
101+
"c:/msvc/lib32",
102+
"c:/local/boost_1_61_0/lib32-msvc-14.0",
103+
}
104+
-- buildoptions {
105+
-- "/MP",
106+
-- "/Gm-",
107+
-- }
108+
109+
configuration { "windows", "Debug" }
110+
links {
111+
"libboost_filesystem-vc140-mt-gd-1_61",
112+
}
113+
configuration {}
114+
configuration { "windows", "Release" }
115+
links {
116+
"libboost_filesystem-vc140-mt-1_61",
117+
}
118+
119+
project "kit"
120+
kind "ConsoleApp"
121+
language "C++"
122+
123+
-- Project Files
124+
files {
125+
"tests/**",
126+
"kit/**"
127+
}
128+
129+
-- Exluding Files
130+
excludes {
131+
132+
}
133+
134+
includedirs {
135+
"/usr/local/include/",
136+
"/usr/include/bullet/",
137+
"/usr/include/raknet/DependentExtensions"
138+
}
139+

tests/meta.test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ TEST_CASE("Meta","[meta]") {
116116
REQUIRE_THROWS_AS(m->at<int>("two"), std::out_of_range);
117117
REQUIRE(m->at<int>(0) == 1);
118118
REQUIRE(m->at<int>(1) == 3);
119+
REQUIRE(m->id("one") == 0);
120+
REQUIRE(m->id("three") == 1);
119121
m->remove("one");
122+
REQUIRE(m->id("three") == 0);
120123
m->remove("three");
121124
REQUIRE_THROWS_AS(m->remove("two"), std::out_of_range);
122125
REQUIRE_THROWS_AS(m->remove("four"), std::out_of_range);

0 commit comments

Comments
 (0)