Fixed SortStats

This commit is contained in:
Josh Allen
2004-09-17 22:22:39 +00:00
parent 0e03b5cfed
commit d12fc08abc
2 changed files with 18 additions and 34 deletions
+8 -23
View File
@@ -159,7 +159,7 @@ void StepManiaLanServer::ParseData(PacketFunctions& Packet, const unsigned int c
case NSCGSU: case NSCGSU:
// StatsUpdate // StatsUpdate
Client[clientNum]->UpdateStats(Packet); Client[clientNum]->UpdateStats(Packet);
if (Client[clientNum]->lowerJudge) if (!Client[clientNum]->lowerJudge)
CheckLowerJudge(clientNum); CheckLowerJudge(clientNum);
break; break;
case NSCSU: case NSCSU:
@@ -390,32 +390,23 @@ void StepManiaLanServer::PopulatePlayersPtr(vector<LanPlayer*> &playersPtr) {
int StepManiaLanServer::SortStats(vector<LanPlayer*> &playersPtr) int StepManiaLanServer::SortStats(vector<LanPlayer*> &playersPtr)
{ {
LanPlayer *tmp; LanPlayer *tmp;
StatsNameChange = false; //Set it to no name so stats will not send if there is not a change bool isChanged;
bool allZero = true;
PopulatePlayersPtr(playersPtr); PopulatePlayersPtr(playersPtr);
for (unsigned int x = 0; x < playersPtr.size(); ++x)
{
//See if all the players have zero. Used to send names if everyone is 0
if ((playersPtr[x]->score > 0) && allZero)
allZero = false;
if ((x+1) < playersPtr.size()) do
{
isChanged = false;
for (int x = 0; x < int(playersPtr.size())-1; ++x)
if ((playersPtr[x]->score) < (playersPtr[x+1]->score)) if ((playersPtr[x]->score) < (playersPtr[x+1]->score))
{ {
tmp = playersPtr[x]; tmp = playersPtr[x];
playersPtr[x] = playersPtr[x+1]; playersPtr[x] = playersPtr[x+1];
playersPtr[x+1] = tmp; playersPtr[x+1] = tmp;
x = 0; isChanged = true;
StatsNameChange = true;
} }
} while (isChanged);
}
//If there are players all at 0, the name lsit won't be updated
//this make sure it is sent to the server eventually
if (!StatsNameChange && allZero)
StatsNameChange = true;
return playersPtr.size(); return playersPtr.size();
} }
@@ -426,11 +417,6 @@ void StepManiaLanServer::SendStatsToClients()
SortStats(playersPtr); //Return number of players SortStats(playersPtr); //Return number of players
//If there was a change in the name data, send it to the clients.
//Used to save bandwidth and some processing time.
//Disabled this. FUTURE: Figure out why it dosn't work correctly and fix.
// if (StatsNameChange)
// {
/* Write and Send name packet */ /* Write and Send name packet */
Reply.ClearPacket(); Reply.ClearPacket();
Reply.Write1(NSCGSU + NSServerOffset); Reply.Write1(NSCGSU + NSServerOffset);
@@ -443,7 +429,6 @@ void StepManiaLanServer::SendStatsToClients()
if (Client[x]->InGame) if (Client[x]->InGame)
SendNetPacket(x, Reply); SendNetPacket(x, Reply);
// }
/* Write and send Combo packet */ /* Write and send Combo packet */
Reply.ClearPacket(); Reply.ClearPacket();
-1
View File
@@ -90,7 +90,6 @@ private:
time_t statsTime; time_t statsTime;
GameInfo CurrentSongInfo; GameInfo CurrentSongInfo;
GameInfo LastSongInfo; GameInfo LastSongInfo;
bool StatsNameChange;
bool SecondSameSelect; bool SecondSameSelect;
vector<CString> bannedIPs; vector<CString> bannedIPs;