Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#ifndef CLIENT_CLIENTCONNECTION_H #define CLIENT_CLIENTCONNECTION_H //############################################################################### class ClientConnection { public: ClientConnection(char * serverIP, char * portString); ~ClientConnection(); void Reconnect(char * serverIP, char * portString); void AddLineLocal(s32 x1, s32 y1, s32 x2, s32 y2); void SendLineToServer(s32 x1, s32 y1, s32 x2, s32 y2); list<line2d<s32> > * GetLineList(); void DrawLines(IVideoDriver * irrVideo); void DeleteLines(void); void ListenForPackets(); bool ServerOnline(void); void HandlePacket(Packet * p); void Admin_DeleteLines(void); void SetStandardRes(void); void SetServerRes(int x, int y); unsigned long GetAvrgPing(void); // Public Variablen int iXSize; int iYSize; private: RakClientInterface * client; list<line2d<s32> > lineList; }; #endif |
Phili
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
class ClientConnection { public: ClientConnection(char * serverIP, char * portString) : client(NULL) { client = RakNetworkFactory::GetRakClientInterface(); client->Connect(serverIP, atoi(portString), 0, 0, 1); ListenForPackets(); Sleep(2000); } ~ClientConnection() { client->Disconnect(300); RakNetworkFactory::DestroyRakClientInterface(client); } void Reconnect(char * serverIP, char * portString) { RakNetworkFactory::DestroyRakClientInterface(client); client = RakNetworkFactory::GetRakClientInterface(); client->Connect(serverIP, atoi(portString), 0, 0, 0); } void AddLineLocal(s32 x1, s32 y1, s32 x2, s32 y2) { line2d<s32> myLine(x1, y1, x2, y2); lineList.push_back(myLine); } void SendLineToServer(s32 x1, s32 y1, s32 x2, s32 y2) { RakNet::BitStream dataStream; dataStream.Write(PACKET_ID_LINE); dataStream.Write(x1); dataStream.Write(y1); dataStream.Write(x2); dataStream.Write(y2); client->Send(&dataStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } list<line2d<s32> > * GetLineList() { return &lineList; } void DrawLines(IVideoDriver * irrVideo) { list<line2d<s32> >::Iterator it = lineList.begin(); for(; it != lineList.end(); ++it) { line2d<s32> currentLine = (*it); position2d<s32> start = position2d<s32>(currentLine.start.X, currentLine.start.Y); position2d<s32> end = position2d<s32>(currentLine.end.X, currentLine.end.Y); irrVideo->draw2DLine(start, end); } } void DeleteLines(void) { lineList.clear(); } void ListenForPackets() { Packet * p = client->Receive(); if(p != NULL) { HandlePacket(p); client->DeallocatePacket(p); } } void HandlePacket(Packet * p) { RakNet::BitStream dataStream((char*)p->data, p->length, false); unsigned char packetID; dataStream.Read(packetID); switch(packetID) { case PACKET_ID_LINE: int x1, y1, x2, y2; dataStream.Read(x1); dataStream.Read(y1); dataStream.Read(x2); dataStream.Read(y2); AddLineLocal(x1, y1, x2, y2); break; // New Client case PACKET_ID_NEW_CLIENT: ::PlaySoundW (L"c:/windows/media/chimes.wav", NULL, SND_ASYNC); break; case PACKET_ID_DELETE_LINES: // Prompt Window zeichnen DelPrompt->setVisible(true); if(CheckSound->isChecked() == false) { ::PlaySoundW (L"c:/windows/media/Windows XP-Fehler.wav", NULL, SND_ASYNC); } break; case PACKET_ID_CLIENT_CONFIG: int x,y; ::PlaySoundW (L"c:/windows/media/Windows XP-Informationsleiste.wav", NULL, SND_ASYNC); dataStream.Read(x); dataStream.Read(y); SetServerRes(x,y); } } bool ServerOnline(void) { if(client->IsConnected() == true) { return (true); } else { return (false); } } void Admin_DeleteLines(void) { RakNet::BitStream dataStream; dataStream.Write(PACKET_ID_DELETE_LINES); dataStream.Write1(); client->Send(&dataStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } void SetStandardRes(void) { iXSize = 800; iYSize = 600; } void SetServerRes(int x, int y) { iXSize = x; iYSize = y; } unsigned long GetAvrgPing(void) { client->PingServer(); unsigned int iPingTime = client->GetLastPing(); return (iPingTime); } // Public Variablen int iXSize; int iYSize; private: RakClientInterface * client; list<line2d<s32> > lineList; }; |
C-/C++-Quelltext |
|
1 2 |
.\client_clientconnection.cpp(8) : error C2143: syntax error : missing ';' before '{' .\client_clientconnection.cpp(8) : error C2447: '{' : missing function header (old-style formal list?) |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
// HIER DIE ÄNDERUNG ClientConnection(char * serverIP, char * portString) { public: ClientConnection(char * serverIP, char * portString) : client(NULL) { client = RakNetworkFactory::GetRakClientInterface(); client->Connect(serverIP, atoi(portString), 0, 0, 1); ListenForPackets(); Sleep(2000); } ~ClientConnection() { client->Disconnect(300); RakNetworkFactory::DestroyRakClientInterface(client); } void Reconnect(char * serverIP, char * portString) { RakNetworkFactory::DestroyRakClientInterface(client); client = RakNetworkFactory::GetRakClientInterface(); client->Connect(serverIP, atoi(portString), 0, 0, 0); } void AddLineLocal(s32 x1, s32 y1, s32 x2, s32 y2) { line2d<s32> myLine(x1, y1, x2, y2); lineList.push_back(myLine); } void SendLineToServer(s32 x1, s32 y1, s32 x2, s32 y2) { RakNet::BitStream dataStream; dataStream.Write(PACKET_ID_LINE); dataStream.Write(x1); dataStream.Write(y1); dataStream.Write(x2); dataStream.Write(y2); client->Send(&dataStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } list<line2d<s32> > * GetLineList() { return &lineList; } void DrawLines(IVideoDriver * irrVideo) { list<line2d<s32> >::Iterator it = lineList.begin(); for(; it != lineList.end(); ++it) { line2d<s32> currentLine = (*it); position2d<s32> start = position2d<s32>(currentLine.start.X, currentLine.start.Y); position2d<s32> end = position2d<s32>(currentLine.end.X, currentLine.end.Y); irrVideo->draw2DLine(start, end); } } void DeleteLines(void) { lineList.clear(); } void ListenForPackets() { Packet * p = client->Receive(); if(p != NULL) { HandlePacket(p); client->DeallocatePacket(p); } } void HandlePacket(Packet * p) { RakNet::BitStream dataStream((char*)p->data, p->length, false); unsigned char packetID; dataStream.Read(packetID); switch(packetID) { case PACKET_ID_LINE: int x1, y1, x2, y2; dataStream.Read(x1); dataStream.Read(y1); dataStream.Read(x2); dataStream.Read(y2); AddLineLocal(x1, y1, x2, y2); break; // New Client case PACKET_ID_NEW_CLIENT: ::PlaySoundW (L"c:/windows/media/chimes.wav", NULL, SND_ASYNC); break; case PACKET_ID_DELETE_LINES: // Prompt Window zeichnen DelPrompt->setVisible(true); if(CheckSound->isChecked() == false) { ::PlaySoundW (L"c:/windows/media/Windows XP-Fehler.wav", NULL, SND_ASYNC); } break; case PACKET_ID_CLIENT_CONFIG: int x,y; ::PlaySoundW (L"c:/windows/media/Windows XP-Informationsleiste.wav", NULL, SND_ASYNC); dataStream.Read(x); dataStream.Read(y); SetServerRes(x,y); } } bool ServerOnline(void) { if(client->IsConnected() == true) { return (true); } else { return (false); } } void Admin_DeleteLines(void) { RakNet::BitStream dataStream; dataStream.Write(PACKET_ID_DELETE_LINES); dataStream.Write1(); client->Send(&dataStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } void SetStandardRes(void) { iXSize = 800; iYSize = 600; } void SetServerRes(int x, int y) { iXSize = x; iYSize = y; } unsigned long GetAvrgPing(void) { client->PingServer(); unsigned int iPingTime = client->GetLastPing(); return (iPingTime); } // Public Variablen int iXSize; int iYSize; private: RakClientInterface * client; list<line2d<s32> > lineList; }; |
C-/C++-Quelltext |
|
1 2 3 |
.\client_clientconnection.cpp(7) : error C2062: type 'char' unexpected .\client_clientconnection.cpp(8) : error C2143: syntax error : missing ';' before '{' .\client_clientconnection.cpp(8) : error C2447: '{' : missing function header (old-style formal list?) |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
ClientConnection::ClientConnection(char * serverIP, char * portString) : client(NULL) { client = RakNetworkFactory::GetRakClientInterface(); client->Connect(serverIP, atoi(portString), 0, 0, 1); ListenForPackets(); Sleep(2000); } ClientConnection::~ClientConnection() { client->Disconnect(300); RakNetworkFactory::DestroyRakClientInterface(client); } void ClientConnection::Reconnect(char * serverIP, char * portString) { RakNetworkFactory::DestroyRakClientInterface(client); client = RakNetworkFactory::GetRakClientInterface(); client->Connect(serverIP, atoi(portString), 0, 0, 0); } void ClientConnection::AddLineLocal(s32 x1, s32 y1, s32 x2, s32 y2) { line2d<s32> myLine(x1, y1, x2, y2); lineList.push_back(myLine); } void ClientConnection::SendLineToServer(s32 x1, s32 y1, s32 x2, s32 y2) { RakNet::BitStream dataStream; dataStream.Write(PACKET_ID_LINE); dataStream.Write(x1); dataStream.Write(y1); dataStream.Write(x2); dataStream.Write(y2); client->Send(&dataStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } list<line2d<s32> > * ClientConnection::GetLineList() { return &lineList; } void ClientConnection::DrawLines(IVideoDriver * irrVideo) { list<line2d<s32> >::Iterator it = lineList.begin(); for(; it != lineList.end(); ++it) { line2d<s32> currentLine = (*it); position2d<s32> start = position2d<s32>(currentLine.start.X, currentLine.start.Y); position2d<s32> end = position2d<s32>(currentLine.end.X, currentLine.end.Y); irrVideo->draw2DLine(start, end); } } void ClientConnection::DeleteLines(void) { lineList.clear(); } void ClientConnection::ListenForPackets() { Packet * p = client->Receive(); if(p != NULL) { HandlePacket(p); client->DeallocatePacket(p); } } void ClientConnection::HandlePacket(Packet * p) { RakNet::BitStream dataStream((char*)p->data, p->length, false); unsigned char packetID; dataStream.Read(packetID); switch(packetID) { case PACKET_ID_LINE: int x1, y1, x2, y2; dataStream.Read(x1); dataStream.Read(y1); dataStream.Read(x2); dataStream.Read(y2); AddLineLocal(x1, y1, x2, y2); break; // New Client case PACKET_ID_NEW_CLIENT: ::PlaySoundW (L"c:/windows/media/chimes.wav", NULL, SND_ASYNC); break; case PACKET_ID_DELETE_LINES: // Prompt Window zeichnen DelPrompt->setVisible(true); if(CheckSound->isChecked() == false) { ::PlaySoundW (L"c:/windows/media/Windows XP-Fehler.wav", NULL, SND_ASYNC); } break; case PACKET_ID_CLIENT_CONFIG: int x,y; ::PlaySoundW (L"c:/windows/media/Windows XP-Informationsleiste.wav", NULL, SND_ASYNC); dataStream.Read(x); dataStream.Read(y); SetServerRes(x,y); } } bool ClientConnection::ServerOnline(void) { if(client->IsConnected() == true) { return (true); } else { return (false); } } void ClientConnection::Admin_DeleteLines(void) { RakNet::BitStream dataStream; dataStream.Write(PACKET_ID_DELETE_LINES); dataStream.Write1(); client->Send(&dataStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } void ClientConnection::SetStandardRes(void) { iXSize = 800; iYSize = 600; } void ClientConnection::SetServerRes(int x, int y) { iXSize = x; iYSize = y; } unsigned long ClientConnection::GetAvrgPing(void) { client->PingServer(); unsigned int iPingTime = client->GetLastPing(); return (iPingTime); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
.\client_clientconnection.cpp(9) : error C2059: syntax error : '{' .\client_clientconnection.cpp(9) : error C2630: ';' found in what should be a comma-separated list .\client_clientconnection.cpp(10) : error C2143: syntax error : missing ';' before 'public' .\client_clientconnection.cpp(13) : error C2143: syntax error : missing ';' before '{' .\client_clientconnection.cpp(24) : error C2512: 'ClientConnection::ClientConnection' : no appropriate default constructor available .\client_clientconnection.cpp(25) : error C2143: syntax error : missing ';' before '{' .\client_clientconnection.cpp(30) : error C2601: 'Reconnect' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(38) : error C2601: 'AddLineLocal' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(45) : error C2601: 'SendLineToServer' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(58) : error C2601: 'GetLineList' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(63) : error C2601: 'DrawLines' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(76) : error C2601: 'DeleteLines' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(81) : error C2601: 'ListenForPackets' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(92) : error C2601: 'HandlePacket' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(138) : error C2601: 'ServerOnline' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(150) : error C2601: 'Admin_DeleteLines' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(160) : error C2601: 'SetStandardRes' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(166) : error C2601: 'SetServerRes' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(172) : error C2601: 'GetAvrgPing' : local function definitions are illegal .\client_clientconnection.cpp(9): this line contains a '{' which has not yet been matched .\client_clientconnection.cpp(186) : error C2143: syntax error : missing ';' before 'private' .\client_clientconnection.cpp(31) : error C2065: 'client' : undeclared identifier .\client_clientconnection.cpp(34) : error C2227: left of '->Connect' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(41) : error C2065: 'lineList' : undeclared identifier .\client_clientconnection.cpp(41) : error C2228: left of '.push_back' must have class/struct/union type is ''unknown-type'' .\client_clientconnection.cpp(54) : error C2227: left of '->Send' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(64) : error C2228: left of '.begin' must have class/struct/union type is ''unknown-type'' .\client_clientconnection.cpp(66) : error C2228: left of '.end' must have class/struct/union type is ''unknown-type'' .\client_clientconnection.cpp(77) : error C2228: left of '.clear' must have class/struct/union type is ''unknown-type'' .\client_clientconnection.cpp(82) : error C2227: left of '->Receive' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(85) : error C3861: 'HandlePacket': identifier not found .\client_clientconnection.cpp(87) : error C2227: left of '->DeallocatePacket' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(108) : error C3861: 'AddLineLocal': identifier not found .\client_clientconnection.cpp(133) : error C3861: 'SetServerRes': identifier not found .\client_clientconnection.cpp(139) : error C2227: left of '->IsConnected' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(156) : error C2227: left of '->Send' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(161) : error C2065: 'iXSize' : undeclared identifier .\client_clientconnection.cpp(162) : error C2065: 'iYSize' : undeclared identifier .\client_clientconnection.cpp(173) : error C2227: left of '->PingServer' must point to class/struct/union/generic type type is ''unknown-type'' .\client_clientconnection.cpp(176) : error C2227: left of '->GetLastPing' must point to class/struct/union/generic type type is ''unknown-type'' |
Werbeanzeige