Skip to content

Commit 1a39ebe

Browse files
committed
port to 2.208, fix memleaks, reduce copies
1 parent 853b249 commit 1a39ebe

27 files changed

Lines changed: 219 additions & 189 deletions

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "ext/cereal"]
2-
path = ext/cereal
3-
url = https://github.com/USCiLab/cereal

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif()
2828

2929
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
3030
add_compile_definitions(WIN32_LEAN_AND_MEAN=1)
31-
target_link_libraries(${PROJECT_NAME} Crypt32)
31+
target_link_libraries(${PROJECT_NAME} crypt32)
3232
endif()
3333

3434
set(USE_ZLIB OFF)
@@ -45,12 +45,12 @@ set(MBEDTLS_AS_SUBPROJECT OFF)
4545
set(DISABLE_PACKAGE_CONFIG_AND_INSTALL OFF)
4646
set(MBEDTLS_FATAL_WARNINGS OFF)
4747

48-
CPMAddPackage("gh:TechStudent10/mbedtls#fc79213")
49-
48+
CPMAddPackage("gh:TechStudent10/mbedtls#4d80dd5")
5049
set(MBEDTLS_INCLUDE_DIRS "${mbedtls_SOURCE_DIR}/include")
5150
set(MBEDTLS_LIBRARY "mbedtls")
5251
set(MBEDX509_LIBRARY "mbedx509")
5352
set(MBEDCRYPTO_LIBRARY "mbedcrypto")
53+
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
5454

5555
CPMAddPackage("gh:machinezone/IXWebSocket#dc8807e")
5656
install(TARGETS mbedtls mbedx509 mbedcrypto EXPORT mbedtls-targets)
@@ -65,7 +65,15 @@ endif()
6565
target_compile_definitions(${PROJECT_NAME} PRIVATE CR_EXPORTING)
6666

6767
target_include_directories(${PROJECT_NAME} PRIVATE ${ixwebsocket_SOURCE_DIR})
68-
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/ext/cereal/include")
68+
69+
CPMAddPackage(
70+
NAME cereal
71+
GITHUB_REPOSITORY USCiLab/cereal
72+
GIT_TAG 22a1b36
73+
DOWNLOAD_ONLY ON
74+
)
75+
76+
target_include_directories(${PROJECT_NAME} PRIVATE "${cereal_SOURCE_DIR}/include")
6977

7078
target_link_libraries(${PROJECT_NAME} ixwebsocket)
7179

ext/cereal

Lines changed: 0 additions & 1 deletion
This file was deleted.

mod.json

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"geode": "4.1.2",
2+
"geode": "5.3.0",
33
"gd": {
4-
"win": "2.2074",
5-
"android": "2.2074",
6-
"mac": "2.2074",
7-
"ios": "2.2074"
4+
"win": "2.2081",
5+
"android": "2.2081",
6+
"mac": "2.2081",
7+
"ios": "2.2081"
88
},
99
"id": "techstudent10.creation_rotation",
1010
"name": "Creation Rotation",
@@ -19,18 +19,10 @@
1919
"resources/certs/*.pem"
2020
]
2121
},
22-
"dependencies": [
23-
{
24-
"id": "cvolton.level-id-api",
25-
"version": ">=v1.1.0",
26-
"importance": "required"
27-
},
28-
{
29-
"id": "geode.node-ids",
30-
"version": ">=v1.17.0",
31-
"importance": "required"
32-
}
33-
],
22+
"dependencies": {
23+
"cvolton.level-id-api": ">=v2.0.0",
24+
"geode.node-ids": ">=v1.23.0"
25+
},
3426
"settings": {
3527
"server-url": {
3628
"name": "Server URL",

src/admin/layers/AdminPanel.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55

66
AdminPanel* AdminPanel::create() {
77
auto ret = new AdminPanel;
8-
if (ret->initAnchored(220.f, 265.f)) {
8+
if (ret->init()) {
99
ret->autorelease();
1010
return ret;
1111
}
1212
delete ret;
1313
return nullptr;
1414
}
1515

16-
bool AdminPanel::setup() {
16+
bool AdminPanel::init() {
17+
if (!Popup::init(220.f, 265.f)) {
18+
return false;
19+
}
20+
1721
this->setTitle("Administrator Panel");
1822

1923
auto usernameInput = TextInput::create(100.f, "Username");

src/admin/layers/AdminPanel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
using namespace geode::prelude;
55

6-
class AdminPanel : public geode::Popup<> {
6+
class AdminPanel : public geode::Popup {
77
protected:
8-
bool setup() override;
8+
bool init() override;
99
public:
1010
static AdminPanel* create();
1111
};

src/admin/layers/AuthPopup.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99

1010
AuthPopup* AuthPopup::create() {
1111
auto ret = new AuthPopup;
12-
if (ret->initAnchored(140.f, 140.f)) {
12+
if (ret->init()) {
1313
ret->autorelease();
1414
return ret;
1515
}
1616
delete ret;
1717
return nullptr;
1818
}
1919

20-
bool AuthPopup::setup() {
20+
bool AuthPopup::init() {
21+
if (!Popup::init(140.f, 140.f)) {
22+
return false;
23+
}
24+
2125
m_noElasticity = true;
2226
this->setTitle("Admin Authorization");
2327

@@ -41,7 +45,7 @@ bool AuthPopup::setup() {
4145
}
4246
);
4347

44-
nm.on<AuthorizedUserPacket>([this](AuthorizedUserPacket*) {
48+
nm.on<AuthorizedUserPacket>([this](AuthorizedUserPacket) {
4549
AdminPanel::create()->show();
4650
});
4751

src/admin/layers/AuthPopup.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
using namespace geode::prelude;
55

6-
class AuthPopup : public geode::Popup<> {
6+
class AuthPopup : public geode::Popup {
77
protected:
8-
bool setup() override;
8+
bool init() override;
99
public:
1010
static AuthPopup* create();
1111
};

src/layers/ChatPanel.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
ChatPanel* ChatPanel::create() {
66
auto ret = new ChatPanel;
7-
if (ret->initAnchored(350.f, 280.f)) {
7+
if (ret->init()) {
88
ret->autorelease();
99
return ret;
1010
}
@@ -14,18 +14,22 @@ ChatPanel* ChatPanel::create() {
1414

1515
void ChatPanel::initialize() {
1616
// initialize the listeners n' stuff if they havent already
17-
if (!ChatPanel::hasInitialized) {
17+
if (!hasInitialized) {
1818
auto& nm = NetworkManager::get();
19-
nm.on<MessageSentPacket>([](MessageSentPacket* packet) {
20-
ChatPanel::messages.push_back(packet->message);
21-
ChatPanel::messagesQueue.push_back(packet->message);
19+
nm.on<MessageSentPacket>([](MessageSentPacket packet) {
20+
messages.push_back(packet.message);
21+
messagesQueue.push_back(std::move(packet.message));
2222
});
2323

24-
ChatPanel::hasInitialized = true;
24+
hasInitialized = true;
2525
}
2626
}
2727

28-
bool ChatPanel::setup() {
28+
bool ChatPanel::init() {
29+
if (!Popup::init(350.f, 280.f)) {
30+
return false;
31+
}
32+
2933
this->setTitle("Chat");
3034

3135
ChatPanel::initialize();
@@ -93,7 +97,7 @@ bool ChatPanel::setup() {
9397
return true;
9498
}
9599

96-
void ChatPanel::renderMessage(Message message) {
100+
void ChatPanel::renderMessage(Message const& message) {
97101
auto msgNode = CCNode::create();
98102
auto msgText = TextArea::create(
99103
fmt::format("<cy>{}</c>: {}", message.author.name, message.message),
@@ -117,18 +121,18 @@ void ChatPanel::renderMessage(Message message) {
117121
}
118122

119123
void ChatPanel::updateMessages(float dt) {
120-
for (auto message : ChatPanel::messagesQueue) {
124+
for (auto const& message : messagesQueue) {
121125
renderMessage(message);
122126
}
123-
ChatPanel::messagesQueue.clear();
127+
messagesQueue.clear();
124128
}
125129

126130
void ChatPanel::clearMessages() {
127-
ChatPanel::messages.clear();
131+
messages.clear();
128132

129133
auto& nm = NetworkManager::get();
130134
nm.unbind<MessageSentPacket>();
131-
ChatPanel::hasInitialized = false;
135+
hasInitialized = false;
132136
}
133137

134138
void ChatPanel::sendMessage() {
@@ -142,11 +146,11 @@ void ChatPanel::sendMessage() {
142146
messageInput->setString("");
143147
}
144148

145-
void ChatPanel::keyDown(cocos2d::enumKeyCodes keycode) {
149+
void ChatPanel::keyDown(cocos2d::enumKeyCodes keycode, double timestamp) {
146150
if (keycode == cocos2d::KEY_Enter && CCIMEDispatcher::sharedDispatcher()->hasDelegate()) {
147151
log::debug("sending via keybind");
148152
sendMessage();
149153
} else {
150-
geode::Popup<>::keyDown(keycode);
154+
Popup::keyDown(keycode, timestamp);
151155
}
152156
}

src/layers/ChatPanel.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using namespace geode::prelude;
66

7-
class ChatPanel : public geode::Popup<> {
7+
class ChatPanel : public geode::Popup {
88
protected:
99
float m_width;
1010
float m_height;
@@ -13,16 +13,16 @@ class ChatPanel : public geode::Popup<> {
1313
inline static std::vector<Message> messages = {};
1414
inline static std::vector<Message> messagesQueue = {};
1515

16-
ScrollLayer* scrollLayer;
17-
TextInput* messageInput;
16+
ScrollLayer* scrollLayer = nullptr;
17+
TextInput* messageInput = nullptr;
1818

19-
bool setup() override;
19+
bool init() override;
2020

2121
void sendMessage();
22-
void renderMessage(Message message);
22+
void renderMessage(Message const& message);
2323
void updateMessages(float dt);
2424

25-
void keyDown(cocos2d::enumKeyCodes) override;
25+
void keyDown(cocos2d::enumKeyCodes, double) override;
2626
public:
2727
static ChatPanel* create();
2828

0 commit comments

Comments
 (0)