Skip to content

Commit 1053488

Browse files
committed
Cleanup for 1.2.
Cleaned up whitespace, comments, brace style, etc. Updated tdata reference.
1 parent d713faf commit 1053488

24 files changed

+234
-286
lines changed

src/BuddyManager.cpp

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void BuddyManager::init() {
2222
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BUDDY_WARP, reqBuddyWarp);
2323
}
2424

25-
//Buddy request
25+
// Buddy request
2626
void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
2727
if (data->size != sizeof(sP_CL2FE_REQ_REQUEST_MAKE_BUDDY))
2828
return; // malformed packet
@@ -51,12 +51,12 @@ void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
5151
resp.iBuddyID = plr.plr->iID;
5252
resp.iBuddyPCUID = plr.plr->PCStyle.iPC_UID;
5353

54-
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC)); //informs the player that the request was sent
55-
requestedBuddy(otherSock, plrReq, plr); //The other player will see the request
54+
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC)); // informs the player that the request was sent
55+
requestedBuddy(otherSock, plrReq, plr); // The other player will see the request
5656

5757
}
5858

59-
//Sending buddy request by player name
59+
// Sending buddy request by player name
6060
void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
6161
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY)) {
6262
return; // malformed packet
@@ -72,13 +72,13 @@ void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
7272

7373
CNSocket* otherSock = sock;
7474

75-
int sizeOfRes = sizeof(pkt->szFirstName) / 9; //Maximum size of a player's first name
76-
int sizeOfLNRes = sizeof(pkt->szLastName) / 17; //Maximum size of a player's last name
75+
int sizeOfRes = sizeof(pkt->szFirstName) / 9; // Maximum size of a player's first name
76+
int sizeOfLNRes = sizeof(pkt->szLastName) / 17; // Maximum size of a player's last name
7777

7878
for (auto pair : PlayerManager::players) {
7979
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
8080
int sizeOfLNReq = sizeof(pair.second.plr->PCStyle.szLastName) / 17;
81-
if (BuddyManager::firstNameCheck(pair.second.plr->PCStyle.szFirstName, pkt->szFirstName, sizeOfReq, sizeOfRes) == true && BuddyManager::lastNameCheck(pair.second.plr->PCStyle.szLastName, pkt->szLastName, sizeOfLNReq, sizeOfLNRes) == true) { //This long line of gorgeous parameters is to check if the player's name matches :eyes:
81+
if (BuddyManager::firstNameCheck(pair.second.plr->PCStyle.szFirstName, pkt->szFirstName, sizeOfReq, sizeOfRes) == true && BuddyManager::lastNameCheck(pair.second.plr->PCStyle.szLastName, pkt->szLastName, sizeOfLNReq, sizeOfLNRes) == true) { // This long line of gorgeous parameters is to check if the player's name matches :eyes:
8282
otherSock = pair.first;
8383
break;
8484
}
@@ -93,7 +93,7 @@ void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
9393

9494
}
9595

96-
//Accepting buddy request
96+
// Accepting buddy request
9797
void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
9898
if (data->size != sizeof(sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY))
9999
return; // malformed packet
@@ -118,7 +118,7 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
118118
PlayerView& plr = PlayerManager::players[otherSock];
119119

120120
if (pkt->iAcceptFlag == 1) {
121-
//resp.iBuddySlot = 0; //hard-coding this for now
121+
//resp.iBuddySlot = 0; // hard-coding this for now
122122
resp.BuddyInfo.iID = pkt->iBuddyID;
123123
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
124124
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
@@ -131,7 +131,7 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
131131
memcpy(resp.BuddyInfo.szLastName, plr.plr->PCStyle.szLastName, sizeof(plr.plr->PCStyle.szLastName));
132132

133133
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
134-
buddyList(sock, resp.BuddyInfo); //saves buddy data to player's buddylist
134+
buddyList(sock, resp.BuddyInfo); // saves buddy data to player's buddylist
135135
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
136136
resp.BuddyInfo.iID = plrReq->iID;
137137
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
@@ -143,21 +143,20 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
143143
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
144144
memcpy(resp.BuddyInfo.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
145145
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
146-
buddyList(otherSock, resp.BuddyInfo); //saves requester's data to this player's buddylist
146+
buddyList(otherSock, resp.BuddyInfo); // saves requester's data to this player's buddylist
147147
}
148-
}
149-
else {
148+
} else {
150149
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
151150

152-
declineResp.iErrorCode = 6; //Buddy declined notification
151+
declineResp.iErrorCode = 6; // Buddy declined notification
153152
declineResp.iBuddyID = pkt->iBuddyID;
154153
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
155154

156-
otherSock->sendPacket((void*)&declineResp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL)); //tells the requester that the player declined
155+
otherSock->sendPacket((void*)&declineResp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL)); // tells the requester that the player declined
157156
}
158157
}
159158

160-
//Accepting buddy request from the find name request
159+
// Accepting buddy request from the find name request
161160
void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
162161
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY)) {
163162
return; // malformed packet
@@ -188,7 +187,7 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
188187
PlayerView& plr = PlayerManager::players[otherSock];
189188

190189
if (pkt->iAcceptFlag == 1) {
191-
//resp.iBuddySlot = 0; //hard-coding this for now
190+
//resp.iBuddySlot = 0; // hard-coding this for now
192191
//resp.BuddyInfo.iID = plrReq->iID;
193192
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
194193
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
@@ -218,11 +217,10 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
218217
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
219218
buddyList(otherSock, resp.BuddyInfo);
220219
}
221-
}
222-
else {
220+
} else {
223221
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
224222

225-
declineResp.iErrorCode = 6; //Buddy declined notification
223+
declineResp.iErrorCode = 6; // Buddy declined notification
226224
declineResp.iBuddyID = plr.plr->iID;
227225
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
228226

@@ -231,7 +229,7 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
231229

232230
}
233231

234-
//Buddy freechatting
232+
// Buddy freechatting
235233
void BuddyManager::reqBuddyFreechat(CNSocket* sock, CNPacketData* data) {
236234
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE))
237235
return; // malformed packet
@@ -250,19 +248,19 @@ void BuddyManager::reqBuddyFreechat(CNSocket* sock, CNPacketData* data) {
250248
resp.iToPCUID = pkt->iBuddyPCUID;
251249
resp.iEmoteCode = pkt->iEmoteCode;
252250
memcpy(resp.szFreeChat, pkt->szFreeChat, sizeof(pkt->szFreeChat));
253-
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); //shows the player that they sent the message to their buddy
251+
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); // shows the player that they sent the message to their buddy
254252

255253
for (auto pair : PlayerManager::players) {
256254
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
257255
otherSock = pair.first;
258-
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); //sends the message to the buddy.
256+
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); // sends the message to the buddy.
259257
}
260258
}
261259

262260

263261
}
264262

265-
//Buddy menuchat
263+
// Buddy menuchat
266264
void BuddyManager::reqBuddyMenuchat(CNSocket* sock, CNPacketData* data) {
267265
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE))
268266
return; // malformed packet
@@ -281,29 +279,29 @@ void BuddyManager::reqBuddyMenuchat(CNSocket* sock, CNPacketData* data) {
281279
resp.iToPCUID = pkt->iBuddyPCUID;
282280
resp.iEmoteCode = pkt->iEmoteCode;
283281
memcpy(resp.szFreeChat, pkt->szFreeChat, sizeof(pkt->szFreeChat));
284-
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); //shows the player that they sent the message to their buddy
282+
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); // shows the player that they sent the message to their buddy
285283

286284
for (auto pair : PlayerManager::players) {
287285
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
288286
otherSock = pair.first;
289-
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); //sends the message to the buddy.
287+
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); // sends the message to the buddy.
290288
}
291289
}
292290
}
293291

294-
//Getting buddy state
292+
// Getting buddy state
295293
void BuddyManager::reqPktGetBuddyState(CNSocket* sock, CNPacketData* data) {
296294
INITSTRUCT(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC, resp);
297295
INITSTRUCT(sBuddyBaseInfo, buddyInfo);
298296

299297
for (int BuddySlot = 0; BuddySlot < 50; BuddySlot++) {
300-
resp.aBuddyState[BuddySlot] = 1; //this sets every buddy to online. Will get the pcstate right directly from the DB.
298+
resp.aBuddyState[BuddySlot] = 1; // this sets every buddy to online. Will get the pcstate right directly from the DB.
301299
resp.aBuddyID[BuddySlot] = buddyInfo.iID;
302300
sock->sendPacket((void*)&resp, P_FE2CL_REP_GET_BUDDY_STATE_SUCC, sizeof(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC));
303301
}
304302
}
305303

306-
//Blocking the buddy
304+
// Blocking the buddy
307305
void BuddyManager::reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
308306
if (data->size != sizeof(sP_CL2FE_REQ_SET_BUDDY_BLOCK))
309307
return; // malformed packet
@@ -319,10 +317,10 @@ void BuddyManager::reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
319317

320318
}
321319

322-
//Deleting the buddy
320+
// Deleting the buddy
323321
void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
324322
if (data->size != sizeof(sP_CL2FE_REQ_REMOVE_BUDDY))
325-
return; //malformed packet
323+
return; // malformed packet
326324

327325
sP_CL2FE_REQ_REMOVE_BUDDY* pkt = (sP_CL2FE_REQ_REMOVE_BUDDY*)data->buf;
328326

@@ -334,8 +332,8 @@ void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
334332
sock->sendPacket((void*)&resp, P_FE2CL_REP_REMOVE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REMOVE_BUDDY_SUCC));
335333
}
336334

337-
//Warping to buddy
338-
void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {} //stub
335+
// Warping to buddy
336+
void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {} // stub
339337

340338
#pragma region Helper methods
341339

@@ -348,11 +346,11 @@ void BuddyManager::requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& pl
348346
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
349347
memcpy(resp.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
350348

351-
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER)); //player get the buddy request.
349+
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER)); // player get the buddy request.
352350

353351
}
354352

355-
//Buddy list load
353+
// Buddy list load
356354
void BuddyManager::buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo) {
357355

358356
size_t resplen = sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC) + sizeof(sBuddyBaseInfo);
@@ -378,14 +376,14 @@ void BuddyManager::buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo) {
378376
memcpy(respdata->szLastName, BuddyInfo.szLastName, sizeof(BuddyInfo.szLastName));
379377
}
380378

381-
sock->sendPacket((void*)respbuf, P_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC, resplen); //updates/loads player's buddy list
379+
sock->sendPacket((void*)respbuf, P_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC, resplen); // updates/loads player's buddy list
382380

383381
}
384382

385-
//If the requested player accepts the buddy request, the requester's buddylist will get loaded up.
383+
// If the requested player accepts the buddy request, the requester's buddylist will get loaded up.
386384
void BuddyManager::otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr) {
387385

388-
//resp.iBuddySlot = 0; //hard-coding this for now
386+
// resp.iBuddySlot = 0; //hard-coding this for now
389387
resp.BuddyInfo.iID = BuddyID;
390388
resp.BuddyInfo.iPCUID = BuddyPCUID;
391389
resp.BuddyInfo.iNameCheckFlag = plr->PCStyle.iNameCheck;
@@ -401,7 +399,7 @@ void BuddyManager::otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t Bud
401399
buddyList(sock, resp.BuddyInfo);
402400
}
403401

404-
//Check if the requested name matches the requested player's name
402+
// Check if the requested name matches the requested player's name
405403
bool BuddyManager::firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes) {
406404
// If lengths of array are not equal means
407405
// array are not equal

src/BuddyManager.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
#pragma once
2-
3-
#include "Player.hpp"
4-
#include "CNProtocol.hpp"
5-
#include "CNStructs.hpp"
6-
#include "CNShardServer.hpp"
7-
8-
#include <map>
9-
#include <list>
10-
11-
namespace BuddyManager {
12-
void init();
13-
14-
//Buddy requests
15-
void requestBuddy(CNSocket* sock, CNPacketData* data);
1+
#pragma once
2+
3+
#include "Player.hpp"
4+
#include "CNProtocol.hpp"
5+
#include "CNStructs.hpp"
6+
#include "CNShardServer.hpp"
7+
8+
#include <map>
9+
#include <list>
10+
11+
namespace BuddyManager {
12+
void init();
13+
14+
// Buddy requests
15+
void requestBuddy(CNSocket* sock, CNPacketData* data);
1616
void reqBuddyByName(CNSocket* sock, CNPacketData* data);
1717

18-
//Buddy accepting
18+
// Buddy accepting
1919
void reqAcceptBuddy(CNSocket* sock, CNPacketData* data);
2020
void reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data);
2121

22-
//Buddy Messaging
22+
// Buddy Messaging
2323
void reqBuddyFreechat(CNSocket* sock, CNPacketData* data);
2424
void reqBuddyMenuchat(CNSocket* sock, CNPacketData* data);
2525

26-
//Getting buddy state
26+
// Getting buddy state
2727
void reqPktGetBuddyState(CNSocket* sock, CNPacketData* data);
2828

29-
//Blocking/removing buddies
29+
// Blocking/removing buddies
3030
void reqBuddyBlock(CNSocket* sock, CNPacketData* data);
3131
void reqBuddyDelete(CNSocket* sock, CNPacketData* data);
3232

33-
//Buddy warping
33+
// Buddy warping
3434
void reqBuddyWarp(CNSocket* sock, CNPacketData* data);
35-
36-
//helper methods
35+
36+
// helper methods
3737
void requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr);
38-
void buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo); //updates the buddylist
39-
void otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr); //tells the other player that they are now buddies with the requester.
38+
void buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo); // updates the buddylist
39+
void otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr); // tells the other player that they are now buddies with the requester.
4040

41-
//Name checks
42-
bool firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes); //checks if the request and requested player's first names match
43-
bool lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes); //checks if the request and requested player's last names match
41+
// Name checks
42+
bool firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes); // checks if the request and requested player's first names match
43+
bool lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes); // checks if the request and requested player's last names match
4444
}

src/CNLoginServer.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,23 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
5757
loginSessions[sock].slot = 1;
5858
loginSessions[sock].lastHeartbeat = getTime();
5959
success = true;
60-
}
60+
6161
// if user exists, check if password is correct
62-
else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword)) {
62+
} else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword)) {
6363
/*calling this here to timestamp login attempt,
6464
* in order to make duplicate exit sanity check work*/
6565
Database::updateSelected(findUser->AccountID, findUser->Selected);
6666
// check if account isn't currently in use
6767
if (CNLoginServer::isAccountInUse(findUser->AccountID)) {
6868
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
69-
}
70-
// if not, login success
71-
else
72-
{
69+
} else { // if not, login success
7370
loginSessions[sock] = CNLoginData();
7471
loginSessions[sock].userID = findUser->AccountID;
7572
loginSessions[sock].slot = findUser->Selected;
7673
loginSessions[sock].lastHeartbeat = getTime();
7774
success = true;
7875
}
79-
}
80-
else {
76+
} else {
8177
errorCode = (int)LoginError::ID_AND_PASSWORD_DO_NOT_MATCH;
8278
}
8379
}
@@ -369,11 +365,12 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
369365
if (settings::VERBOSITY)
370366
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
371367
break;
372-
/* Unimplemented CL2LS packets:
373-
P_CL2LS_CHECK_NAME_LIST - unused by the client
374-
P_CL2LS_REQ_SERVER_SELECT
375-
P_CL2LS_REQ_SHARD_LIST_INFO - dev commands, useless as we only run 1 server
376-
*/
368+
/*
369+
* Unimplemented CL2LS packets:
370+
* P_CL2LS_CHECK_NAME_LIST - unused by the client
371+
* P_CL2LS_REQ_SERVER_SELECT
372+
* P_CL2LS_REQ_SHARD_LIST_INFO - dev commands, useless as we only run 1 server
373+
*/
377374
}
378375
}
379376

src/CNProtocol.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ int CNSocketEncryption::Encrypt_byte_change_A(int ERSize, uint8_t* data, int siz
99
int num2 = 0;
1010
int num3 = 0;
1111

12-
while (num + ERSize <= size)
13-
{
12+
while (num + ERSize <= size) {
1413
int num4 = num + num3;
1514
int num5 = num + (ERSize - 1 - num3);
1615

@@ -19,8 +18,7 @@ int CNSocketEncryption::Encrypt_byte_change_A(int ERSize, uint8_t* data, int siz
1918
data[num5] = b;
2019
num += ERSize;
2120
num3++;
22-
if (num3 > ERSize / 2)
23-
{
21+
if (num3 > ERSize / 2) {
2422
num3 = 0;
2523
}
2624
}

0 commit comments

Comments
 (0)