diff --git a/stepmania/src/NetworkSyncManager.cpp b/stepmania/src/NetworkSyncManager.cpp index 67051b822c..b94734a26e 100644 --- a/stepmania/src/NetworkSyncManager.cpp +++ b/stepmania/src/NetworkSyncManager.cpp @@ -19,8 +19,21 @@ #include "RageLog.h" #include "StepMania.h" #include "RageUtil.h" +#include "ThemeManager.h" +#include "ScreenSelectMusic.h" +#include "PlayerNumber.h" +#include "GameConstantsAndTypes.h" +#include "SongOptions.h" +#include "ScreenManager.h" +#include "Course.h" +#include "Song.h" +#include "SongManager.h" +#include "GameState.h" +#define NEXT_SCREEN( play_mode ) THEME->GetMetric ("ScreenSelectMusic","NextScreen"+Capitalize(PlayModeToString(play_mode))) + //Used for advancing to gameplay screen + NetworkSyncManager::NetworkSyncManager() { NetPlayerClient = new EzSockets; @@ -80,6 +93,7 @@ void NetworkSyncManager::StartUp() PlayerName.m_packID = 30; for( unsigned i=0; i < strlen(ProfileNames[0]); i++ ) PlayerName.m_data[i] = ProfileNames[0][i]; + PlayerName.m_data[i] = 0; NetPlayerClient->send((char*) &PlayerName,20); } if( ProfileNames.size() > 1 ) @@ -87,6 +101,7 @@ void NetworkSyncManager::StartUp() PlayerName.m_packID = 31; for( unsigned i=0; i < strlen(ProfileNames[1]); i++ ) PlayerName.m_data[i] = ProfileNames[1][i]; + PlayerName.m_data[i] = 0; NetPlayerClient->send( (char*) &PlayerName,20 ); } @@ -215,5 +230,99 @@ void NetworkSyncManager::StartRequest() LOG->Trace("Starting Game."); } +//This must be executed after NSMAN was started. + +//this is for use with SMOnline. +//In order to gaurentee song title and group names +//line up, SM will be started and load, and then +//send all info to the local client. +//This information will be then relayed to the +//SMOnline server. +void NetworkSyncManager::SendSongs() +{ + vector LogSongs; + LogSongs = SONGMAN->GetAllSongs(); + int i,j; + CString SongInfo; + char toSend[1020]; //Standard buffer is 1024 and + //we have to include 4 size bytes + for (i=0;im_sGroupName; + SongInfo+=char(2) + CSong->GetTranslitMainTitle(); + SongInfo+=char(3) + CSong->GetTranslitSubTitle(); + SongInfo+=char(4) + CSong->GetTranslitArtist(); + + for (j=4;jInfo("SLen: %d",SongInfo.length()); + NetPlayerClient->send (toSend,SongInfo.length()+4); + } + toSend[0]=char(36); + NetPlayerClient->send (toSend,4); + + //Exit because this is ONLY for use with SMOnline + //If admins feel strongly, this can be exported + //to another command line, like "--exitfirst" + exit (0); + + //NOTE TO ADMINS: I do not actually know the + //safe way to exit stepmania, if you can, either tell me + //or do it, please? +} + + +//I am adding this for Network support +//Feel free to change the way --course is used +//I am not building any part of SMOnline specific to this yet. + +void ArgStartCourse(CString CourseName) +{ + Course * desCourse = SONGMAN->GetCourseFromName(CourseName); + LOG->Info ("Course Desied: %s/%d",CourseName.c_str(), desCourse); + if (desCourse == 0) + { + LOG->Info ("Desired Course not found!"); + return ; + } + + LOG->Info("desCourse->GetPlayMode(); = %d",desCourse->GetPlayMode()); + + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; + //Need to add more functionality eventually + + GAMESTATE->m_pCurCourse = desCourse; + GAMESTATE->m_CurStyle = STYLE_DANCE_SINGLE; + + GAMESTATE->m_PlayMode = desCourse->GetPlayMode(); + if (desCourse->IsOni()) + GAMESTATE->m_SongOptions.m_LifeType = SongOptions::LIFE_BATTERY; + else + GAMESTATE->m_SongOptions.m_LifeType = SongOptions::LIFE_BAR; + + GAMESTATE->m_SongOptions.m_iBatteryLives = desCourse->m_iLives; + + GAMESTATE->PlayersFinalized(); + + //Go to Gameplay Screen + SCREENMAN->SetNewScreen( NEXT_SCREEN(GAMESTATE->m_PlayMode) ); + + //Not sure if this is correct, it may make more sense + //to have a metric to allow/disallow user options at this point. + + GAMESTATE->BeginGame(); + GAMESTATE->BeginStage(); +} + + + + //Global and accessable from anywhere NetworkSyncManager *NSMAN; + diff --git a/stepmania/src/NetworkSyncManager.h b/stepmania/src/NetworkSyncManager.h index 24d9b93522..72f0b4abb1 100644 --- a/stepmania/src/NetworkSyncManager.h +++ b/stepmania/src/NetworkSyncManager.h @@ -14,7 +14,10 @@ */ #include "PlayerNumber.h" - + +void NSSendSongs(); +void ArgStartCourse(CString CourseName); + class EzSockets; class NetworkSyncManager @@ -28,6 +31,7 @@ public: void ReportSongOver(); //Report to server that song is over void StartRequest(); //Request a start. Block until granted. bool Connect(const CString& addy, unsigned short port); // Connect to SM Server + void SendSongs(); //Send song list to server (And exit) int m_playerLife[NUM_PLAYERS]; //Life diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 9d2ba4067f..20eb392d16 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -892,12 +892,29 @@ static void ProcessArgsFirst() CString Argument; if( GetCommandlineArgument( "test", &Argument ) ) LOG->Info ("Test: \"%s\"", Argument.c_str() ); + + //--LogSongs + if( GetCommandlineArgument( "sendsongs" ) ) + NSMAN->SendSongs(); } static void ProcessArgsSecond() { + CString Argument; if( GetCommandlineArgument( "test2" ) ) - LOG->Info ("Test2" ); + LOG->Info ("Test2"); + + + //--Course=[coursename] + + //Will start the given course when StepMania + //starts, disallows player options. + + //"ArgStartCourse", is in the NSManager + //bacause Networked StepMania will + //use it a lot. + if( GetCommandlineArgument( "course", & Argument ) ) + ArgStartCourse(Argument); } int main(int argc, char* argv[])