Modified server to comply with revised protocol.
This commit is contained in:
@@ -18,6 +18,7 @@ LanPlayer::LanPlayer() {
|
|||||||
StepManiaLanServer::StepManiaLanServer() {
|
StepManiaLanServer::StepManiaLanServer() {
|
||||||
stop = true;
|
stop = true;
|
||||||
SecondSameSelect = false;
|
SecondSameSelect = false;
|
||||||
|
AssignPlayerIDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
StepManiaLanServer::~StepManiaLanServer() {
|
StepManiaLanServer::~StepManiaLanServer() {
|
||||||
@@ -118,6 +119,7 @@ void StepManiaLanServer::ParseData(PacketFunctions &Packet, int clientNum) {
|
|||||||
case 6:
|
case 6:
|
||||||
/* Style Update */
|
/* Style Update */
|
||||||
Client[clientNum].StyleUpdate(Packet);
|
Client[clientNum].StyleUpdate(Packet);
|
||||||
|
SendUserList();
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
// Chat message
|
// Chat message
|
||||||
@@ -217,6 +219,15 @@ void GameClient::GameOver(PacketFunctions &Packet) {
|
|||||||
InGame= false;
|
InGame= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StepManiaLanServer::AssignPlayerIDs() {
|
||||||
|
int counter = 0;
|
||||||
|
//Future: Figure out how to do dynamic numbering.
|
||||||
|
for (int x = 0; x < NUMBERCLIENTS; x++) {
|
||||||
|
Client[x].Player[0].PlayerID = counter++;
|
||||||
|
Client[x].Player[1].PlayerID = counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int StepManiaLanServer::SortStats(LanPlayer *playersPtr[]) {
|
int StepManiaLanServer::SortStats(LanPlayer *playersPtr[]) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
LanPlayer *tmp;
|
LanPlayer *tmp;
|
||||||
@@ -319,15 +330,9 @@ void StepManiaLanServer::SendNetPacket(int client, char *data, int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StepManiaLanServer::StatsNameColumn(PacketFunctions &data, LanPlayer *playersPtr[], int numPlayers) {
|
void StepManiaLanServer::StatsNameColumn(PacketFunctions &data, LanPlayer *playersPtr[], int numPlayers) {
|
||||||
char number[9];
|
|
||||||
CString numname;
|
CString numname;
|
||||||
for (int x = 0; x < numPlayers; x++) {
|
for (int x = 0; x < numPlayers; x++)
|
||||||
sprintf(number, "%d", x+1);
|
data.Write1(playersPtr[x]->PlayerID);
|
||||||
numname = number;
|
|
||||||
numname += ". ";
|
|
||||||
numname += playersPtr[x]->name;
|
|
||||||
data.WriteNT(numname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StepManiaLanServer::StatsComboColumn(PacketFunctions &data, LanPlayer *playersPtr[], int numPlayers)
|
void StepManiaLanServer::StatsComboColumn(PacketFunctions &data, LanPlayer *playersPtr[], int numPlayers)
|
||||||
@@ -534,7 +539,7 @@ void GameClient::CheckConnection() {
|
|||||||
/* If there is an error close the socket. */
|
/* If there is an error close the socket. */
|
||||||
if (clientSocket.IsError()) {
|
if (clientSocket.IsError()) {
|
||||||
clientSocket.close();
|
clientSocket.close();
|
||||||
Used = false;
|
Used = Ready = hasSong = InGame = false;
|
||||||
Player[0].name = Player[1].name = "";
|
Player[0].name = Player[1].name = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,6 +553,28 @@ void StepManiaLanServer::MoveClientToHost() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StepManiaLanServer::SendUserList() {
|
||||||
|
Reply.ClearPacket();
|
||||||
|
Reply.Write1(137);
|
||||||
|
Reply.Write1(NUMBERCLIENTS*2);
|
||||||
|
Reply.Write1(NUMBERCLIENTS*2);
|
||||||
|
for (int x = 0; x < NUMBERCLIENTS; x++) {
|
||||||
|
if (Client[x].Player[0].name.length() == 0) {
|
||||||
|
Reply.Write1(0);
|
||||||
|
} else {
|
||||||
|
Reply.Write1(1);
|
||||||
|
}
|
||||||
|
Reply.WriteNT(Client[x].Player[0].name);
|
||||||
|
if (Client[x].Player[1].name.length() == 0) {
|
||||||
|
Reply.Write1(0);
|
||||||
|
} else {
|
||||||
|
Reply.Write1(1);
|
||||||
|
}
|
||||||
|
Reply.WriteNT(Client[x].Player[1].name);
|
||||||
|
}
|
||||||
|
SendToAllClients(Reply);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Joshua Allen
|
* (c) 2003-2004 Joshua Allen
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class LanPlayer {
|
|||||||
int maxCombo;
|
int maxCombo;
|
||||||
int Grade;
|
int Grade;
|
||||||
int offset;
|
int offset;
|
||||||
|
int PlayerID;
|
||||||
LanPlayer();
|
LanPlayer();
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@@ -110,6 +111,8 @@ class StepManiaLanServer {
|
|||||||
void SendToAllClients(PacketFunctions &Packet);
|
void SendToAllClients(PacketFunctions &Packet);
|
||||||
bool CheckHasSongState();
|
bool CheckHasSongState();
|
||||||
void ClearHasSong();
|
void ClearHasSong();
|
||||||
|
void AssignPlayerIDs();
|
||||||
|
void SendUserList();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user