bool Protocol79::CharlistLogin(const char *username, const char *password) { NetworkMessage nm; ONThreadSafe(threadsafe); connectiontype = CHARLIST; nm.AddU8(0x01); // protocol id nm.AddU16(0x02); // client OS nm.AddU16(protocolversion); nm.AddU32(fingerprints[FINGERPRINT_TIBIADAT]); // tibia.dat nm.AddU32(fingerprints[FINGERPRINT_TIBIASPR]); // tibia.spr nm.AddU32(fingerprints[FINGERPRINT_TIBIAPIC]); // tibia.pic nm.RSABegin(); // encryption keys for (int i = 0 ; i < 4 ; i++) { nm.AddU32(key[i]); } // account number and password nm.AddU32(atol((this->username = username).c_str())); nm.AddString(this->password = password); nm.RSAEncrypt(); if (!nm.Dump(s)) { this->errormsg = "Could not write to socket.\nPossible it's a premature disconnect.\n\nCheck you typed in the correct protocol!"; ONThreadUnsafe(threadsafe); return false; } nm.Clean(); if (!nm.FillFromSocket(s)) { this->errormsg = "Could not read from socket.\nPossibly it's a premature disconnect.\n\nCheck you typed in the correct protocol!"; ONThreadUnsafe(threadsafe); return false; } printf("Okies, lets decrypt\n"); // this->Close(); nm.XTEADecrypt(key); printf("Ok, decoded\n"); logonsuccessful = true; while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm)); if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); ONThreadUnsafe(threadsafe); return logonsuccessful; }
bool Protocol77::GameworldLogin () { // this is valid for 7.7! // 7.72 has a bit different order of stuff! check out old outcast's sources NetworkMessage nm; connectiontype = GAMEWORLD; nm.AddU8(0x0A); // protocol id nm.RSABegin(); // encryption keys for (int i = 0 ; i < 4 ; i++) { nm.AddU32(key[i]); } // in 7.72 onwards move this BEFORE the keys and BEFORE the encryption nm.AddU16(0x02); // client OS nm.AddU16(protocolversion); // are we a gamemaster nm.AddChar(0); // account number and password nm.AddU32(atol(this->username.c_str())); // this does NOT exist before 7.4 nm.AddString(this->charlist[this->charlistselected]->charactername); nm.AddString(this->password); nm.RSAEncrypt(); // FIXME inside dump, we should check whether or not socket is still open // or after dump, at least nm.Dump(s); nm.Clean(); nm.FillFromSocket(s ); nm.XTEADecrypt(key); logonsuccessful = true; while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm)); if ((signed int)(nm.GetSize())!=0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); if (logonsuccessful) active = true; return logonsuccessful; }
bool Protocol77::CharlistLogin(const char *username, const char *password) { NetworkMessage nm; connectiontype = CHARLIST; nm.AddU8(0x01); // protocol id nm.AddU16(0x02); // client OS nm.AddU16(protocolversion); nm.AddU32(fingerprints[FINGERPRINT_TIBIADAT]); // tibia.dat nm.AddU32(fingerprints[FINGERPRINT_TIBIASPR]); // tibia.spr nm.AddU32(fingerprints[FINGERPRINT_TIBIAPIC]); // tibia.pic nm.RSABegin(); // encryption keys for (int i = 0 ; i < 4 ; i++) { nm.AddU32(key[i]); } // account number and password nm.AddU32(atol((this->username = username).c_str())); nm.AddString(this->password = password); nm.RSAEncrypt(); // FIXME inside dump, we should check whether or not socket is still open // or after dump, at least nm.Dump(s); nm.Clean(); nm.FillFromSocket(s); nm.XTEADecrypt(key); logonsuccessful = true; while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm)); if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); Close(); return logonsuccessful; }
void LiveServer::UpdateOperation(int percent) { for(PeerList::iterator citer = connected_clients.begin(); citer != connected_clients.end(); ++citer) { NetworkMessage* msg = AllocMessage(); msg->AddByte(PACKET_UPDATE_OPERATION); msg->AddU32(percent); (*citer)->Send(msg); } }
void LiveServer::OnReceiveHello(LivePeer* connection, NetworkMessage* nmsg) { uint32_t rvid = nmsg->ReadU32(); if(rvid != __RME_VERSION_ID__) { NetworkMessage* omsg = AllocMessage(); omsg->AddByte(PACKET_KICK); // FAREWELL omsg->AddString("Wrong editor version."); connection->Send(omsg); connection->Close(); return; } uint32_t net_ver = nmsg->ReadU32(); if(net_ver != __LIVE_NET_VERSION__) { NetworkMessage* omsg = AllocMessage(); omsg->AddByte(PACKET_KICK); // FAREWELL omsg->AddString("Wrong protocol version."); connection->Send(omsg); connection->Close(); return; } uint32_t client_version = nmsg->ReadU32(); std::string rnick = nmsg->ReadString(); std::string pass = nmsg->ReadString(); wxString upass = wxString(pass.c_str(), wxConvUTF8); if(password != upass) { log->Message(wxT("Client tried to connect, but used the wrong password, connection refused.")); connection->Close(); return; } connection->SetNick(wxString(rnick.c_str(), wxConvUTF8)); log->Message(connection->GetNick() << wxT(" (") << connection->GetHost() << wxT(") connected.")); if((ClientVersionID)client_version != gui.GetCurrentVersionID()) { NetworkMessage* omsg = AllocMessage(); omsg->AddByte(PACKET_CHANGE_CLIENT_VERSION); // CHANGE CLIENT VER omsg->AddU32(gui.GetCurrentVersionID()); connection->Send(omsg); } else { // Reply that we have accepted the remote connection NetworkMessage* omsg = AllocMessage(); omsg->AddByte(PACKET_ACCEPTED_CLIENT); // CONNECTION ACCEPTED WITHOUT ISSUE connection->Send(omsg); } }
bool RMENet::Connect() { wxIPV4address ipaddr; ipaddr.Hostname("127.0.0.1");//90.230.54.138")); ipaddr.Service(31312); socket = newd wxSocketClient(wxSOCKET_NOWAIT); connection = newd NetworkConnection(this, socket); socket->SetClientData(connection); socket->SetEventHandler(*this, wxID_ANY); socket->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG | wxSOCKET_LOST_FLAG); socket->Notify(true); wxEvtHandler::Connect(wxID_ANY, wxEVT_SOCKET, wxSocketEventHandler(RMENet::HandleEvent)); socket->Connect(ipaddr, false); if(!socket || !socket->WaitOnConnect(5, 0) || !socket || !socket->IsConnected()) { if(socket) socket->Destroy(); socket = nullptr; delete connection; connection = nullptr; return false; } NetworkMessage* nmsg = AllocMessage(); nmsg->AddByte(0x00); // Hello! nmsg->AddU32(__LIVE_NET_VERSION__); nmsg->AddString(g_settings.getString(Config::LIVE_USERNAME)); nmsg->AddString(g_settings.getString(Config::LIVE_PASSWORD)); connection->Send(nmsg); return true; }
bool ProtocolME0::GameworldLogin () { NetworkMessage nm; ONThreadSafe(threadsafe); connectiontype = GAMEWORLD; //nm.AddU8(0x14); //nm.AddString(this->charlist[this->charlistselected]->charactername); //spcount ++; if (!strcmp(this->charlist[this->charlistselected]->charactername, "Character Manager")) { nm.AddU8(0x0C); // charmgr... nm.AddU8(0x01); // ...enter FILE *f = fopen((std::string("save/") + this->username + ".ous").c_str(), "r"); ASSERTFRIENDLY(f, "It appears that savefile has mysteriously disappeared. Exiting"); fclose(f); } else { nm.AddU8(0x0A); // player's creature id shall be 1 nm.AddU32(1); nm.AddU8(0x32); // report bugs? nm.AddU8(0); nm.AddU8(0); nm.AddU8(0x64); // player teleport nm.AddU16(30); nm.AddU16(30); nm.AddU8(7); int tilesremaining = 18*14*7; for (int i = 0; i < 18; i ++) for (int j = 0; j < 14; j++) { printf("%d\n", tilesremaining); nm.AddU16(102); if (i == 8 && j == 6) { nm.AddU16(0x0061); nm.AddU32(0); // remove with this id nm.AddU32(1); // creatureid -- player is 1 nm.AddString("Newbie"); nm.AddU8(25); // health nm.AddU8(0); //dir nm.AddU16(128); // lookid nm.AddU8(50); nm.AddU8(60); nm.AddU8(70); nm.AddU8(80); nm.AddU8(0); // addons nm.AddU8(0); // lightlevel nm.AddU8(0); // lightcolor nm.AddU16(500); // speed nm.AddU8(0); // skull nm.AddU8(0); // shield } tilesremaining--; nm.AddU16(0xFF00); } while(tilesremaining) { nm.AddU8(tilesremaining > 255 ? 255 : tilesremaining); tilesremaining -= tilesremaining > 255 ? 255 : tilesremaining; printf("%d\n", tilesremaining); nm.AddU8(0xFF); } } ((GM_MainMenu*)game)->DestroyCharlist(); // by default logon is a success logonsuccessful = true; packetparsing: while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm)); if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); ONThreadUnsafe(threadsafe); return logonsuccessful; }
bool ProtocolME0::CharlistLogin(const char *username, const char *password) { NetworkMessage nm; ONThreadSafe(threadsafe); connectiontype = CHARLIST; this->username = username; this->password = password; FILE *f = fopen((std::string("save/") + username + ".ous").c_str(),"r"); if (!f) { FILE *fo = fopen((std::string("save/") + username + ".ous").c_str(),"w"); if (!fo) { nm.AddU8(0x0A); nm.AddString("You need write permissions on save/ subfolder of \nThe Outcast to start a local game."); goto packetparsing; } else { fprintf(fo, "%s\n", password); fclose(fo); f = fopen((std::string("save/") + username + ".ous").c_str(),"r"); } } { char filepwd[255]; fscanf(f, "%s", filepwd); if (strcmp(filepwd, password)) { nm.AddU8(0x0A); nm.AddString("You entered incorrect password."); } else { char charname[255]; nm.AddU8(0x14); nm.AddString("7435\nWelcome to Clavicula, a singleplayer mode for The Outcast!\n\nClavicula is an attempt to create a singleplayer game \nsimilar to Tibia. To create a character, choose Character\nManager option from the character list."); nm.AddU8(0x64); int pos = ftell(f); int spcount = 0; while (fscanf(f, "%s", charname)==1) spcount ++; fseek(f, pos, SEEK_SET); nm.AddU8(1 + spcount); // one character is CREATE CHARACTER, others are temp count to make dynamic list nm.AddString("Character Manager"); nm.AddString("Clavicula"); nm.AddU32(0); // ip address nm.AddU16(0); // port while (fscanf(f, "%s", charname)==1) { nm.AddString(charname); nm.AddString("Clavicula"); nm.AddU32(0); // ip address nm.AddU16(0); // port } nm.AddU16(0); // free account } } // by default logon is a success logonsuccessful = true; packetparsing: while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm)); if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); ONThreadUnsafe(threadsafe); return logonsuccessful; }
bool Protocol79::GameworldLogin () { // this is valid for 7.9! // 7.7 has a bit different order of stuff! check out old outcast's sources NetworkMessage nm; SetProtocolStatus("Preparing to transfer logon data..."); connectiontype = GAMEWORLD; nm.AddU8(0x0A); // protocol id // in 7.72 onwards move this BEFORE the keys and BEFORE the encryption nm.AddU16(0x02); // client OS nm.AddU16(protocolversion); SetProtocolStatus("RSA encryption..."); nm.RSABegin(); //key[3] = 92; // encryption keys for (int i = 0 ; i < 4 ; i++) { nm.AddU32(key[i]); //printf("KEY %d - %d\n", i, key[i]); } // are we a gamemaster nm.AddChar(0); // account number and password nm.AddU32(atol(this->username.c_str())); // this does NOT exist before 7.4 nm.AddString(this->charlist[this->charlistselected]->charactername); nm.AddString(this->password); nm.RSAEncrypt(); SetProtocolStatus("Transmitting logon data..."); if (!nm.Dump(s)) { this->errormsg = "Could not write to socket.\nPossible it's a premature disconnect.\n\nCheck you typed in the correct protocol!"; return false; } // SetStance(DEFENSIVE, STAND); SetProtocolStatus("Waiting for response..."); //nm.Clean(); NetworkMessage nm2; //nm.FillFromSocket(s); if (!nm2.FillFromSocket(s )) { this->errormsg = "Could not read from socket.\nPossibly it's a premature disconnect.\n\nCheck you typed in the correct protocol!"; return false; } nm2.XTEADecrypt(key); logonsuccessful = true; while ((signed int)(nm2.GetSize())>0 && ParsePacket(&nm2)); if ((signed int)(nm2.GetSize())!=0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); if (logonsuccessful) active = true; return logonsuccessful; }