Server now requires the host to select the exact same song twice in a row before allowing
a start.
This commit is contained in:
@@ -17,6 +17,7 @@ LanPlayer::LanPlayer() {
|
|||||||
|
|
||||||
StepManiaLanServer::StepManiaLanServer() {
|
StepManiaLanServer::StepManiaLanServer() {
|
||||||
stop = true;
|
stop = true;
|
||||||
|
SecondSameSelect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
StepManiaLanServer::~StepManiaLanServer() {
|
StepManiaLanServer::~StepManiaLanServer() {
|
||||||
@@ -405,20 +406,41 @@ void StepManiaLanServer::SelectSong(PacketFunctions &Packet, int clientNum) {
|
|||||||
|
|
||||||
if (use == 2) {
|
if (use == 2) {
|
||||||
if (clientNum == 0) {
|
if (clientNum == 0) {
|
||||||
gameInfo.title = Packet.ReadNT();
|
SecondSameSelect = false;
|
||||||
gameInfo.artist = Packet.ReadNT();
|
|
||||||
gameInfo.subtitle = Packet.ReadNT();
|
CurrentSongInfo.title = Packet.ReadNT();
|
||||||
|
CurrentSongInfo.artist = Packet.ReadNT();
|
||||||
|
CurrentSongInfo.subtitle = Packet.ReadNT();
|
||||||
|
|
||||||
Reply.ClearPacket();
|
Reply.ClearPacket();
|
||||||
Reply.Write1(136);
|
Reply.Write1(136);
|
||||||
Reply.Write1(1);
|
Reply.Write1(1);
|
||||||
Reply.WriteNT(gameInfo.title);
|
Reply.WriteNT(CurrentSongInfo.title);
|
||||||
Reply.WriteNT(gameInfo.artist);
|
Reply.WriteNT(CurrentSongInfo.artist);
|
||||||
Reply.WriteNT(gameInfo.subtitle);
|
Reply.WriteNT(CurrentSongInfo.subtitle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ClearHasSong();
|
ClearHasSong();
|
||||||
|
|
||||||
SendToAllClients(Reply);
|
SendToAllClients(Reply);
|
||||||
|
|
||||||
|
//The following code forces the host to select the same song twice in order to play it.
|
||||||
|
if (strcmp(CurrentSongInfo.title, LastSongInfo.title) == 0)
|
||||||
|
if (strcmp(CurrentSongInfo.artist, LastSongInfo.artist) == 0)
|
||||||
|
if (strcmp(CurrentSongInfo.artist, LastSongInfo.artist) == 0)
|
||||||
|
SecondSameSelect = true;
|
||||||
|
if (SecondSameSelect == false) {
|
||||||
|
LastSongInfo.title = CurrentSongInfo.title;
|
||||||
|
LastSongInfo.artist = CurrentSongInfo.artist;
|
||||||
|
LastSongInfo.subtitle = CurrentSongInfo.subtitle;
|
||||||
|
message = servername;
|
||||||
|
message += ":Play \"";
|
||||||
|
message += CurrentSongInfo.title;
|
||||||
|
message += "\"?";
|
||||||
|
ServerChat(message);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
message = servername;
|
message = servername;
|
||||||
message += ": You do not have permission to pick a song.";
|
message += ": You do not have permission to pick a song.";
|
||||||
@@ -442,7 +464,7 @@ void StepManiaLanServer::SelectSong(PacketFunctions &Packet, int clientNum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message += " lacks song \"";
|
message += " lacks song \"";
|
||||||
message += gameInfo.title;
|
message += CurrentSongInfo.title;
|
||||||
message += "\"";
|
message += "\"";
|
||||||
ServerChat(message);
|
ServerChat(message);
|
||||||
}
|
}
|
||||||
@@ -451,13 +473,19 @@ void StepManiaLanServer::SelectSong(PacketFunctions &Packet, int clientNum) {
|
|||||||
if (use == 0)
|
if (use == 0)
|
||||||
Client[clientNum].hasSong = true;
|
Client[clientNum].hasSong = true;
|
||||||
|
|
||||||
if (CheckHasSongState()) {
|
//Only play if everyone has the same song and the host has select the same song twice.
|
||||||
|
if (CheckHasSongState()&&SecondSameSelect) {
|
||||||
Reply.ClearPacket();
|
Reply.ClearPacket();
|
||||||
Reply.Write1(136);
|
Reply.Write1(136);
|
||||||
Reply.Write1(2);
|
Reply.Write1(2);
|
||||||
Reply.WriteNT(gameInfo.title);
|
Reply.WriteNT(CurrentSongInfo.title);
|
||||||
Reply.WriteNT(gameInfo.artist);
|
Reply.WriteNT(CurrentSongInfo.artist);
|
||||||
Reply.WriteNT(gameInfo.subtitle);
|
Reply.WriteNT(CurrentSongInfo.subtitle);
|
||||||
|
//Reset last song in case host picks same song again
|
||||||
|
LastSongInfo.title = "";
|
||||||
|
LastSongInfo.artist = "";
|
||||||
|
LastSongInfo.subtitle = "";
|
||||||
|
|
||||||
SendToAllClients(Reply);
|
SendToAllClients(Reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,10 @@ class StepManiaLanServer {
|
|||||||
int ClientHost;
|
int ClientHost;
|
||||||
LanPlayer *playersPtr[NUMBERCLIENTS*2];
|
LanPlayer *playersPtr[NUMBERCLIENTS*2];
|
||||||
time_t statsTime;
|
time_t statsTime;
|
||||||
GameInfo gameInfo;
|
GameInfo CurrentSongInfo;
|
||||||
|
GameInfo LastSongInfo;
|
||||||
bool StatsNameChange;
|
bool StatsNameChange;
|
||||||
|
bool SecondSameSelect;
|
||||||
|
|
||||||
void Hello(PacketFunctions&Packet, int clientNum);
|
void Hello(PacketFunctions&Packet, int clientNum);
|
||||||
void UpdateClients();
|
void UpdateClients();
|
||||||
|
|||||||
Reference in New Issue
Block a user