From 8ad1c7219dfbce08ff890e9213719c26dbe94782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Nie=C3=9Fner?= Date: Sun, 2 Jun 2019 13:37:53 +0200 Subject: [PATCH] Remove junk --- oldsrc/Constants.h | 9 --- oldsrc/Protocoll.h | 22 ------ oldsrc/Server.cpp | 164 --------------------------------------------- oldsrc/Server.h | 36 ---------- protocol.md | 12 ---- 5 files changed, 243 deletions(-) delete mode 100644 oldsrc/Constants.h delete mode 100644 oldsrc/Protocoll.h delete mode 100644 oldsrc/Server.cpp delete mode 100644 oldsrc/Server.h delete mode 100644 protocol.md diff --git a/oldsrc/Constants.h b/oldsrc/Constants.h deleted file mode 100644 index f2df971..0000000 --- a/oldsrc/Constants.h +++ /dev/null @@ -1,9 +0,0 @@ -// #pragma once - -// namespace constants { - -// const int CLIENT_PORT = 9999; -// const int MAX_CLIENTS = 128; - -// } - diff --git a/oldsrc/Protocoll.h b/oldsrc/Protocoll.h deleted file mode 100644 index 2455fd6..0000000 --- a/oldsrc/Protocoll.h +++ /dev/null @@ -1,22 +0,0 @@ -// #pragma once - -// #define CONNECTION_REQUEST 0x01 -// #define CONNECTION_ACCEPTED 0x02 -// #define CONNECTION_DENIED 0x03 - -// struct ConnectionRequest { -// ConnectionRequest() : type(CONNECTION_REQUEST) {} -// char type = CONNECTION_REQUEST; -// }; - -// struct ConnectionAccepted { -// ConnectionAccepted() : type(CONNECTION_ACCEPTED) {} -// char type; -// int index; -// }; - -// struct ConnectionDenied { -// ConnectionDenied() : type(CONNECTION_DENIED) {} -// char type; -// }; - diff --git a/oldsrc/Server.cpp b/oldsrc/Server.cpp deleted file mode 100644 index fbed280..0000000 --- a/oldsrc/Server.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// #include "Server.h" -// #include "Protocoll.h" - -// #include -// #include -// #include - -// Server::Server(int port) : m_maxClients(constants::MAX_CLIENTS), m_clientConnected{0} -// { -// udpSocket = SDLNet_UDP_Open(port); - -// if (udpSocket == nullptr) -// { -// std::cout << "\tSDLNet_UDP_Open failed : " << SDLNet_GetError() << std::endl; -// } -// std::cout << "Server was started and is listening on port: " << port << std::endl; - -// //Creating ConnectionAccepted packet! -// // Allocate udp packet with 512 byte size -// connectionAccepted = SDLNet_AllocPacket(512); - -// if (connectionAccepted == nullptr) -// { -// std::cout << "\tSDLNet_AllocPacket failed : " << SDLNet_GetError() << std::endl; -// } -// ConnectionAccepted conAcc = ConnectionAccepted(); -// memcpy(connectionAccepted->data, &conAcc, sizeof(ConnectionAccepted)); -// connectionAccepted->len = sizeof(ConnectionAccepted); - -// connectionDenied = SDLNet_AllocPacket(512); - -// if (connectionDenied == nullptr) -// { -// std::cout << "\tSDLNet_AllocPacket failed : " << SDLNet_GetError() << std::endl; -// } -// ConnectionDenied conDen = ConnectionDenied(); -// memcpy(connectionDenied->data, &conDen, sizeof(ConnectionDenied)); -// connectionDenied->len = sizeof(ConnectionDenied); - -// //Creating receiver packet! -// receivedPacket = SDLNet_AllocPacket(512); - -// if (receivedPacket == nullptr) -// { -// std::cout << "\tSDLNet_AllocPacket failed : " << SDLNet_GetError() << std::endl; -// } -// } - -// int Server::FindFreeClientIndex() const -// { -// for (int i = 0; i < m_maxClients; ++i) -// { -// if (!m_clientConnected[i]) -// return i; -// } -// return -1; -// } - -// int Server::FindExistingClientIndex(const IPaddress &ip) const -// { -// for (int i = 0; i < m_maxClients; ++i) -// { -// if (m_clientConnected[i] && m_clients[i].host == ip.host && m_clients[i].port == ip.port) -// return i; -// } -// return -1; -// } - -// bool Server::IsClientConnected(int clientIndex) const -// { -// return m_clientConnected[clientIndex]; -// } - -// const IPaddress &Server::GetClientAddress(int clientIndex) const -// { -// return m_clients[clientIndex]; -// } - -// void Server::update(unsigned int delta) -// { -// //Receive packages -// if (SDLNet_UDP_Recv(udpSocket, receivedPacket)) -// { -// switch (*(receivedPacket->data)) -// { -// case CONNECTION_REQUEST: -// std::cout << "Connection request package received\n"; -// int freeIndex; -// if ((freeIndex = this->FindFreeClientIndex()) == -1) -// { -// std::cout << "Connection denied because server full" << std::endl; -// //Send Connection denied -// this->sendConnectionDenied(receivedPacket->address); -// break; -// } -// std::cout << "Free index found: " << freeIndex << std::endl; -// int indexOfExistingClient; -// if ((indexOfExistingClient = FindExistingClientIndex(receivedPacket->address)) == -1) -// { -// std::cout << "Client doesent exist create new" << std::endl; -// m_clients[freeIndex] = receivedPacket->address; -// m_clientConnected[freeIndex] = true; -// //Send connection accepted with index -// this->sendConnectionAccepted(receivedPacket->address, freeIndex); -// m_numConnectedClients++; -// break; -// } -// else -// { -// std::cout << "Client exist sending accepted" << std::endl; -// //Send connection accepted with index -// this->sendConnectionAccepted(receivedPacket->address, indexOfExistingClient); -// } -// break; -// default: -// break; -// } -// } - -// //Wait 10 sec -// using namespace std::chrono_literals; -// std::this_thread::sleep_for(1s); - -// //Send data -// /*for(auto &value: clients) { -// value.send(this->udpSocket,*helloWorldPacket); -// } -// std::cout << "Data was send!!" << std::endl;*/ -// } - -// bool Server::sendPacket(UDPpacket &packet) -// { -// // Send -// // SDLNet_UDP_Send returns number of packets sent. 0 means error -// if (SDLNet_UDP_Send(this->udpSocket, -1, &packet) == 0) -// { -// std::cout << "\tSDLNet_UDP_Send failed : " << SDLNet_GetError() << "\n" -// << "==========================================================================================================\n"; -// return false; -// } -// return true; -// } - -// bool Server::sendConnectionDenied(IPaddress dest) -// { -// this->connectionDenied->address.host = dest.host; -// this->connectionDenied->address.port = dest.port; -// return this->sendPacket(*connectionDenied); -// } - -// bool Server::sendConnectionAccepted(IPaddress dest, int index) -// { -// this->connectionAccepted->address.host = dest.host; -// this->connectionAccepted->address.port = dest.port; -// ((ConnectionAccepted *) connectionAccepted->data)->index = index; -// return this->sendPacket(*connectionAccepted); -// } - -// Server::~Server() -// { -// SDLNet_FreePacket(receivedPacket); -// SDLNet_FreePacket(connectionAccepted); -// SDLNet_UDP_Close(udpSocket); -// } \ No newline at end of file diff --git a/oldsrc/Server.h b/oldsrc/Server.h deleted file mode 100644 index 9f84adf..0000000 --- a/oldsrc/Server.h +++ /dev/null @@ -1,36 +0,0 @@ -// #pragma once - -// #include -// #include "Constants.h" - -// class Server { -// public: -// Server(int port); -// ~Server(); - -// int FindFreeClientIndex() const; -// int FindExistingClientIndex( const IPaddress &ip ) const; -// bool IsClientConnected( int clientIndex ) const; -// const IPaddress & GetClientAddress( int clientIndex ) const; - -// void update(unsigned int delta); - -// void gameTick(); - -// private: -// UDPsocket udpSocket; - -// UDPpacket *connectionDenied; -// UDPpacket *connectionAccepted; -// UDPpacket *receivedPacket; - -// int m_maxClients; -// int m_numConnectedClients; -// bool m_clientConnected[constants::MAX_CLIENTS]; -// IPaddress m_clients[constants::MAX_CLIENTS]; - -// bool sendPacket(UDPpacket &packet); - -// bool sendConnectionDenied(IPaddress dest); -// bool sendConnectionAccepted(IPaddress dest, int index); -// }; \ No newline at end of file diff --git a/protocol.md b/protocol.md deleted file mode 100644 index e79d670..0000000 --- a/protocol.md +++ /dev/null @@ -1,12 +0,0 @@ -## Loading Screen - -- [Client] -Client sends unique UserID. - -- [Server] -assign slot to Client - -- [Client] -Send User Name - -- [Server_START_UPDATE_ROUTINE]