This is ridiculous. I've cleaned up over a thousand lines of this code and I'm tired of it. I'd enumerate our code guidelines again, but the last n times had no effect.
This commit is contained in:
@@ -179,7 +179,7 @@ void NetworkSyncManager::PostStartUp(const RString& ServerIP)
|
|||||||
m_packet.ClearPacket();
|
m_packet.ClearPacket();
|
||||||
if( NetPlayerClient->ReadPack((char *)&m_packet, NETMAXBUFFERSIZE)<1 )
|
if( NetPlayerClient->ReadPack((char *)&m_packet, NETMAXBUFFERSIZE)<1 )
|
||||||
dontExit=false; // Also allow exit if there is a problem on the socket
|
dontExit=false; // Also allow exit if there is a problem on the socket
|
||||||
if (m_packet.Read1() == (NSServerOffset + NSCHello))
|
if( m_packet.Read1() == NSServerOffset + NSCHello )
|
||||||
dontExit=false;
|
dontExit=false;
|
||||||
//Only allow passing on handshake.
|
//Only allow passing on handshake.
|
||||||
//Otherwise scoreboard updates and such will confuse us.
|
//Otherwise scoreboard updates and such will confuse us.
|
||||||
@@ -291,7 +291,7 @@ void NetworkSyncManager::ReportScore(int playerID, int step, int score, int comb
|
|||||||
//
|
//
|
||||||
//ASSUMED: No step will be more than 16 seconds off center
|
//ASSUMED: No step will be more than 16 seconds off center
|
||||||
//If assumption false: read 16 seconds either direction
|
//If assumption false: read 16 seconds either direction
|
||||||
int iOffset = int((offset+16.384)*2000.0);
|
int iOffset = int( (offset+16.384)*2000.0f );
|
||||||
|
|
||||||
if( iOffset>65535 )
|
if( iOffset>65535 )
|
||||||
iOffset=65535;
|
iOffset=65535;
|
||||||
@@ -299,7 +299,7 @@ void NetworkSyncManager::ReportScore(int playerID, int step, int score, int comb
|
|||||||
iOffset=1;
|
iOffset=1;
|
||||||
|
|
||||||
//Report 0 if hold, or miss (don't forget mines should report)
|
//Report 0 if hold, or miss (don't forget mines should report)
|
||||||
if ((step == TNS_Miss) || (step > TNS_W1))
|
if( step == TNS_Miss || step > TNS_W1 )
|
||||||
iOffset = 0;
|
iOffset = 0;
|
||||||
|
|
||||||
m_packet.Write2( (uint16_t)iOffset );
|
m_packet.Write2( (uint16_t)iOffset );
|
||||||
@@ -359,11 +359,11 @@ void NetworkSyncManager::StartRequest(short position)
|
|||||||
|
|
||||||
Steps * tSteps;
|
Steps * tSteps;
|
||||||
tSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
tSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||||
if ((tSteps!=NULL) && (GAMESTATE->IsPlayerEnabled(PLAYER_1)))
|
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_1) )
|
||||||
ctr = uint8_t(ctr+tSteps->GetMeter()*16);
|
ctr = uint8_t(ctr+tSteps->GetMeter()*16);
|
||||||
|
|
||||||
tSteps = GAMESTATE->m_pCurSteps[PLAYER_2];
|
tSteps = GAMESTATE->m_pCurSteps[PLAYER_2];
|
||||||
if ((tSteps!=NULL) && (GAMESTATE->IsPlayerEnabled(PLAYER_2)))
|
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_2) )
|
||||||
ctr = uint8_t( ctr+tSteps->GetMeter() );
|
ctr = uint8_t( ctr+tSteps->GetMeter() );
|
||||||
|
|
||||||
m_packet.Write1( ctr );
|
m_packet.Write1( ctr );
|
||||||
@@ -371,11 +371,11 @@ void NetworkSyncManager::StartRequest(short position)
|
|||||||
ctr=0;
|
ctr=0;
|
||||||
|
|
||||||
tSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
tSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||||
if ((tSteps!=NULL) && (GAMESTATE->IsPlayerEnabled(PLAYER_1)))
|
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_1) )
|
||||||
ctr = uint8_t( ctr + (int)tSteps->GetDifficulty()*16 );
|
ctr = uint8_t( ctr + (int)tSteps->GetDifficulty()*16 );
|
||||||
|
|
||||||
tSteps = GAMESTATE->m_pCurSteps[PLAYER_2];
|
tSteps = GAMESTATE->m_pCurSteps[PLAYER_2];
|
||||||
if ((tSteps!=NULL) && (GAMESTATE->IsPlayerEnabled(PLAYER_2)))
|
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_2) )
|
||||||
ctr = uint8_t( ctr + (int)tSteps->GetDifficulty() );
|
ctr = uint8_t( ctr + (int)tSteps->GetDifficulty() );
|
||||||
|
|
||||||
m_packet.Write1( ctr );
|
m_packet.Write1( ctr );
|
||||||
@@ -400,7 +400,7 @@ void NetworkSyncManager::StartRequest(short position)
|
|||||||
if( GAMESTATE->m_pCurCourse != NULL )
|
if( GAMESTATE->m_pCurCourse != NULL )
|
||||||
m_packet.WriteNT( GAMESTATE->m_pCurCourse->GetDisplayFullTitle() );
|
m_packet.WriteNT( GAMESTATE->m_pCurCourse->GetDisplayFullTitle() );
|
||||||
else
|
else
|
||||||
m_packet.WriteNT(RString(""));
|
m_packet.WriteNT( RString() );
|
||||||
|
|
||||||
//Send Player (and song) Options
|
//Send Player (and song) Options
|
||||||
m_packet.WriteNT( GAMESTATE->m_SongOptions.GetCurrent().GetString() );
|
m_packet.WriteNT( GAMESTATE->m_SongOptions.GetCurrent().GetString() );
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
{
|
{
|
||||||
int numRooms = NSMAN->m_SMOnlinePacket.Read1();
|
int numRooms = NSMAN->m_SMOnlinePacket.Read1();
|
||||||
m_Rooms.clear();
|
m_Rooms.clear();
|
||||||
for (int i=0;i<numRooms;i++)
|
for( int i=0; i<numRooms; ++i )
|
||||||
{
|
{
|
||||||
RoomData tmpRoomData;
|
RoomData tmpRoomData;
|
||||||
tmpRoomData.SetName( NSMAN->m_SMOnlinePacket.ReadNT() );
|
tmpRoomData.SetName( NSMAN->m_SMOnlinePacket.ReadNT() );
|
||||||
@@ -136,10 +136,10 @@ void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
m_Rooms.push_back( tmpRoomData );
|
m_Rooms.push_back( tmpRoomData );
|
||||||
}
|
}
|
||||||
//Abide by protocol and read room status
|
//Abide by protocol and read room status
|
||||||
for (int i=0;i<numRooms;i++)
|
for( int i=0; i<numRooms; ++i )
|
||||||
m_Rooms[i].SetState( NSMAN->m_SMOnlinePacket.Read1() );
|
m_Rooms[i].SetState( NSMAN->m_SMOnlinePacket.Read1() );
|
||||||
|
|
||||||
for (int i=0;i<numRooms;i++)
|
for( int i=0; i<numRooms; ++i )
|
||||||
m_Rooms[i].SetFlags( NSMAN->m_SMOnlinePacket.Read1() );
|
m_Rooms[i].SetFlags( NSMAN->m_SMOnlinePacket.Read1() );
|
||||||
|
|
||||||
if( m_iRoomPlace<0 )
|
if( m_iRoomPlace<0 )
|
||||||
@@ -158,7 +158,7 @@ void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
info.numPlayers = NSMAN->m_SMOnlinePacket.Read1();
|
info.numPlayers = NSMAN->m_SMOnlinePacket.Read1();
|
||||||
info.maxPlayers = NSMAN->m_SMOnlinePacket.Read1();
|
info.maxPlayers = NSMAN->m_SMOnlinePacket.Read1();
|
||||||
info.players.resize( info.numPlayers );
|
info.players.resize( info.numPlayers );
|
||||||
for (int i = 0; i < info.numPlayers; i++)
|
for( int i = 0; i < info.numPlayers; ++i )
|
||||||
info.players[i] = NSMAN->m_SMOnlinePacket.ReadNT();
|
info.players[i] = NSMAN->m_SMOnlinePacket.ReadNT();
|
||||||
|
|
||||||
m_roomInfo.SetRoomInfo( info );
|
m_roomInfo.SetRoomInfo( info );
|
||||||
@@ -215,7 +215,7 @@ void ScreenNetRoom::TweenOffScreen()
|
|||||||
void ScreenNetRoom::MenuStart( const InputEventPlus &input )
|
void ScreenNetRoom::MenuStart( const InputEventPlus &input )
|
||||||
{
|
{
|
||||||
m_RoomWheel.Select();
|
m_RoomWheel.Select();
|
||||||
RoomWheelData* rwd = (RoomWheelData*)m_RoomWheel.LastSelected();
|
RoomWheelData* rwd = dynamic_cast<RoomWheelData*>( m_RoomWheel.LastSelected() );
|
||||||
if( rwd )
|
if( rwd )
|
||||||
{
|
{
|
||||||
if ( rwd->m_iFlags % 2 )
|
if ( rwd->m_iFlags % 2 )
|
||||||
@@ -270,18 +270,18 @@ void ScreenNetRoom::UpdateRoomsList()
|
|||||||
if( !m_RoomWheel.IsEmpty() )
|
if( !m_RoomWheel.IsEmpty() )
|
||||||
{
|
{
|
||||||
if( difference > 0 )
|
if( difference > 0 )
|
||||||
for( int x = 0; x < difference; x++ )
|
for( int x = 0; x < difference; ++x )
|
||||||
m_RoomWheel.RemoveItem( m_RoomWheel.GetNumItems() - 1 );
|
m_RoomWheel.RemoveItem( m_RoomWheel.GetNumItems() - 1 );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
difference = abs( difference );
|
difference = abs( difference );
|
||||||
for( int x = 0; x < difference; x++ )
|
for( int x = 0; x < difference; ++x )
|
||||||
m_RoomWheel.AddItem( new RoomWheelData(TYPE_GENERIC, "", "", RageColor(1,1,1,1)) );
|
m_RoomWheel.AddItem( new RoomWheelData(TYPE_GENERIC, "", "", RageColor(1,1,1,1)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned int x = 0; x < m_Rooms.size(); x++)
|
for ( unsigned int x = 0; x < m_Rooms.size(); ++x)
|
||||||
m_RoomWheel.AddItem( new RoomWheelData(TYPE_GENERIC, "", "", RageColor(1,1,1,1)) );
|
m_RoomWheel.AddItem( new RoomWheelData(TYPE_GENERIC, "", "", RageColor(1,1,1,1)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +313,8 @@ void ScreenNetRoom::UpdateRoomsList()
|
|||||||
m_RoomWheel.RebuildWheelItems();
|
m_RoomWheel.RebuildWheelItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenNetRoom::CreateNewRoom( const RString& rName, const RString& rDesc, const RString & rPass ) {
|
void ScreenNetRoom::CreateNewRoom( const RString& rName, const RString& rDesc, const RString& rPass )
|
||||||
|
{
|
||||||
NSMAN->m_SMOnlinePacket.ClearPacket();
|
NSMAN->m_SMOnlinePacket.ClearPacket();
|
||||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)2 ); //Create room command
|
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)2 ); //Create room command
|
||||||
NSMAN->m_SMOnlinePacket.Write1( 1 ); //Type game room
|
NSMAN->m_SMOnlinePacket.Write1( 1 ); //Type game room
|
||||||
|
|||||||
Reference in New Issue
Block a user