Merge remote-tracking branch 'upstream/master'

This commit is contained in:
FinnHornhoover 2020-08-22 04:52:33 +03:00
commit 0401e8ef6c
3 changed files with 27 additions and 14 deletions

View File

@ -192,14 +192,15 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
int64_t UID = character->PCStyle.iPC_UID; int64_t UID = character->PCStyle.iPC_UID;
bool BecomeGM; // commented and disabled for now
//bool BecomeGM;
if (U16toU8(character->PCStyle.szFirstName) == settings::GMPASS) { //if (U16toU8(character->PCStyle.szFirstName) == settings::GMPASS) {
BecomeGM = true; // BecomeGM = true;
U8toU16("GM",character->PCStyle.szFirstName); // U8toU16("GM",character->PCStyle.szFirstName);
} else { //} else {
BecomeGM = false; // BecomeGM = false;
} //}
character->PCStyle.iNameCheck = 1; character->PCStyle.iNameCheck = 1;
response->sPC_Style = character->PCStyle; response->sPC_Style = character->PCStyle;
@ -225,7 +226,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
loginSessions[sock].characters[UID].Equip[2].iType = 2; loginSessions[sock].characters[UID].Equip[2].iType = 2;
loginSessions[sock].characters[UID].Equip[3].iID = character->sOn_Item.iEquipFootID; // foot! loginSessions[sock].characters[UID].Equip[3].iID = character->sOn_Item.iEquipFootID; // foot!
loginSessions[sock].characters[UID].Equip[3].iType = 3; loginSessions[sock].characters[UID].Equip[3].iType = 3;
loginSessions[sock].characters[UID].IsGM = BecomeGM; loginSessions[sock].characters[UID].IsGM = false;
sock->sendPacket(new CNPacketData((void*)response, P_LS2CL_REP_CHAR_CREATE_SUCC, sizeof(sP_LS2CL_REP_CHAR_CREATE_SUCC), sock->getEKey())); sock->sendPacket(new CNPacketData((void*)response, P_LS2CL_REP_CHAR_CREATE_SUCC, sizeof(sP_LS2CL_REP_CHAR_CREATE_SUCC), sock->getEKey()));
break; break;

View File

@ -76,8 +76,12 @@ bool CNSocket::sendData(uint8_t* data, int size) {
while (sentBytes < size) { while (sentBytes < size) {
int sent = send(sock, (buffer_t*)(data + sentBytes), size - sentBytes, 0); // no flags defined int sent = send(sock, (buffer_t*)(data + sentBytes), size - sentBytes, 0); // no flags defined
if (SOCKETERROR(sent)) if (SOCKETERROR(sent)) {
if (errno == 11)
continue; // try again
std::cout << "[FATAL] SOCKET ERROR: " << errno << std::endl;
return false; // error occured while sending bytes return false; // error occured while sending bytes
}
sentBytes += sent; sentBytes += sent;
} }
@ -116,6 +120,11 @@ void CNSocket::kill() {
} }
void CNSocket::sendPacket(CNPacketData* pak) { void CNSocket::sendPacket(CNPacketData* pak) {
if (!alive) {
delete pak;
return;
}
int tmpSize = pak->size + sizeof(uint32_t); int tmpSize = pak->size + sizeof(uint32_t);
uint8_t* tmpBuf = (uint8_t*)xmalloc(tmpSize); uint8_t* tmpBuf = (uint8_t*)xmalloc(tmpSize);
@ -127,10 +136,12 @@ void CNSocket::sendPacket(CNPacketData* pak) {
CNSocketEncryption::encryptData((uint8_t*)tmpBuf, (uint8_t*)(&pak->key), tmpSize); CNSocketEncryption::encryptData((uint8_t*)tmpBuf, (uint8_t*)(&pak->key), tmpSize);
// send packet size // send packet size
sendData((uint8_t*)&tmpSize, sizeof(uint32_t)); if (!sendData((uint8_t*)&tmpSize, sizeof(uint32_t)))
kill();
// send packet data! // send packet data!
sendData(tmpBuf, tmpSize); if (alive && !sendData(tmpBuf, tmpSize))
kill();
delete pak; delete pak;
free(tmpBuf); // free tmp buffer free(tmpBuf); // free tmp buffer

View File

@ -98,10 +98,11 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_PC_GIVE_ITEM* itemreq = (sP_CL2FE_REQ_PC_GIVE_ITEM*)data->buf; sP_CL2FE_REQ_PC_GIVE_ITEM* itemreq = (sP_CL2FE_REQ_PC_GIVE_ITEM*)data->buf;
PlayerView& plr = PlayerManager::players[sock]; PlayerView& plr = PlayerManager::players[sock];
if (!plr.plr.IsGM) { // Commented and disabled for future use
//if (!plr.plr.IsGM) {
// TODO: send fail packet // TODO: send fail packet
return; // return;
} //}
if (itemreq->eIL == 2) { if (itemreq->eIL == 2) {
// Quest item, not a real item, handle this later, stubbed for now // Quest item, not a real item, handle this later, stubbed for now