mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-25 04:35:17 +00:00
Merge pull request #23 from Link4565/dev
This commit is contained in:
commit
5f1a91161f
3 changed files with 26 additions and 18 deletions
|
@ -254,9 +254,12 @@ bool Client::startConnection() {
|
|||
|
||||
Logger::log("Sucessful Connection. Waiting to recieve init packet.\n");
|
||||
|
||||
bool waitingForInitPacket = true;
|
||||
// wait for client init packet
|
||||
while (true) {
|
||||
while (waitingForInitPacket) {
|
||||
if (mSocket->RECV()) {
|
||||
if(!mSocket->mPacketQueue.isEmpty()){
|
||||
|
||||
Packet* curPacket = mSocket->mPacketQueue.popFront();
|
||||
|
||||
if (curPacket->mType == PacketType::CLIENTINIT) {
|
||||
|
@ -271,13 +274,14 @@ bool Client::startConnection() {
|
|||
}
|
||||
|
||||
free(curPacket);
|
||||
waitingForInitPacket = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
Logger::log("Recieve failed! Stopping Connection.\n");
|
||||
mIsConnectionActive = false;
|
||||
waitingForInitPacket = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ SocketBase::SocketBase(const char *name)
|
|||
{
|
||||
strcpy(this->sockName, name);
|
||||
|
||||
this->sock_flags = 0;
|
||||
this->sock_flags = 0x80;
|
||||
}
|
||||
|
||||
const char *SocketBase::getStateChar() {
|
||||
|
|
|
@ -84,7 +84,7 @@ bool SocketClient::SEND(Packet *packet) {
|
|||
if (packet->mType != PLAYERINF && packet->mType != HACKCAPINF)
|
||||
Logger::log("Sending packet: %s\n", packetNames[packet->mType]);
|
||||
|
||||
if ((valread = nn::socket::Send(this->socket_log_socket, buffer, packet->mPacketSize + sizeof(Packet), this->sock_flags) > 0)) {
|
||||
if ((valread = nn::socket::Send(this->socket_log_socket, buffer, packet->mPacketSize + sizeof(Packet), 0) > 0)) {
|
||||
return true;
|
||||
} else {
|
||||
Logger::log("Failed to Fully Send Packet! Result: %d Type: %s Packet Size: %d\n", valread, packetNames[packet->mType], packet->mPacketSize);
|
||||
|
@ -116,12 +116,16 @@ bool SocketClient::RECV() {
|
|||
|
||||
if(result > 0) {
|
||||
valread += result;
|
||||
} else {
|
||||
if(this->socket_errno==11){
|
||||
return true;
|
||||
} else {
|
||||
Logger::log("Header Read Failed! Value: %d Total Read: %d\n", result, valread);
|
||||
this->closeSocket();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(valread > 0) {
|
||||
Packet* header = reinterpret_cast<Packet*>(headerBuf);
|
||||
|
|
Loading…
Reference in a new issue