Added --Course command, and a command to send all songs to server
so the server can index them for gameplay for SMOnline. I am not sure if I did the Course setup properly. If I did not, feel free to fix it or... if you don't feel like it, I'm sure I'll figure it out after a while. I left a lot of notes in... I am not sure what style of code you want, at what point you want me to submit, if I am doing any of this wrong please just tell me, and I'll try to be more useful.
This commit is contained in:
@@ -19,8 +19,21 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "StepMania.h"
|
#include "StepMania.h"
|
||||||
#include "RageUtil.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()
|
NetworkSyncManager::NetworkSyncManager()
|
||||||
{
|
{
|
||||||
NetPlayerClient = new EzSockets;
|
NetPlayerClient = new EzSockets;
|
||||||
@@ -80,6 +93,7 @@ void NetworkSyncManager::StartUp()
|
|||||||
PlayerName.m_packID = 30;
|
PlayerName.m_packID = 30;
|
||||||
for( unsigned i=0; i < strlen(ProfileNames[0]); i++ )
|
for( unsigned i=0; i < strlen(ProfileNames[0]); i++ )
|
||||||
PlayerName.m_data[i] = ProfileNames[0][i];
|
PlayerName.m_data[i] = ProfileNames[0][i];
|
||||||
|
PlayerName.m_data[i] = 0;
|
||||||
NetPlayerClient->send((char*) &PlayerName,20);
|
NetPlayerClient->send((char*) &PlayerName,20);
|
||||||
}
|
}
|
||||||
if( ProfileNames.size() > 1 )
|
if( ProfileNames.size() > 1 )
|
||||||
@@ -87,6 +101,7 @@ void NetworkSyncManager::StartUp()
|
|||||||
PlayerName.m_packID = 31;
|
PlayerName.m_packID = 31;
|
||||||
for( unsigned i=0; i < strlen(ProfileNames[1]); i++ )
|
for( unsigned i=0; i < strlen(ProfileNames[1]); i++ )
|
||||||
PlayerName.m_data[i] = ProfileNames[1][i];
|
PlayerName.m_data[i] = ProfileNames[1][i];
|
||||||
|
PlayerName.m_data[i] = 0;
|
||||||
NetPlayerClient->send( (char*) &PlayerName,20 );
|
NetPlayerClient->send( (char*) &PlayerName,20 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,5 +230,99 @@ void NetworkSyncManager::StartRequest()
|
|||||||
LOG->Trace("Starting Game.");
|
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 <Song *> 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;i<LogSongs.size();i++)
|
||||||
|
{
|
||||||
|
Song * CSong = LogSongs[i];
|
||||||
|
SongInfo=char(1) + CSong->m_sGroupName;
|
||||||
|
SongInfo+=char(2) + CSong->GetTranslitMainTitle();
|
||||||
|
SongInfo+=char(3) + CSong->GetTranslitSubTitle();
|
||||||
|
SongInfo+=char(4) + CSong->GetTranslitArtist();
|
||||||
|
|
||||||
|
for (j=4;j<SongInfo.length()+4;j++)
|
||||||
|
toSend[j] = SongInfo.c_str()[j-4];
|
||||||
|
toSend[0]=char(35);
|
||||||
|
toSend[1]=char(0);
|
||||||
|
toSend[2]=char(0);
|
||||||
|
toSend[3]=char(0);
|
||||||
|
|
||||||
|
LOG->Info("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
|
//Global and accessable from anywhere
|
||||||
NetworkSyncManager *NSMAN;
|
NetworkSyncManager *NSMAN;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
|
|
||||||
|
void NSSendSongs();
|
||||||
|
void ArgStartCourse(CString CourseName);
|
||||||
|
|
||||||
class EzSockets;
|
class EzSockets;
|
||||||
|
|
||||||
class NetworkSyncManager
|
class NetworkSyncManager
|
||||||
@@ -28,6 +31,7 @@ public:
|
|||||||
void ReportSongOver(); //Report to server that song is over
|
void ReportSongOver(); //Report to server that song is over
|
||||||
void StartRequest(); //Request a start. Block until granted.
|
void StartRequest(); //Request a start. Block until granted.
|
||||||
bool Connect(const CString& addy, unsigned short port); // Connect to SM Server
|
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
|
int m_playerLife[NUM_PLAYERS]; //Life
|
||||||
|
|
||||||
|
|||||||
@@ -892,12 +892,29 @@ static void ProcessArgsFirst()
|
|||||||
CString Argument;
|
CString Argument;
|
||||||
if( GetCommandlineArgument( "test", &Argument ) )
|
if( GetCommandlineArgument( "test", &Argument ) )
|
||||||
LOG->Info ("Test: \"%s\"", Argument.c_str() );
|
LOG->Info ("Test: \"%s\"", Argument.c_str() );
|
||||||
|
|
||||||
|
//--LogSongs
|
||||||
|
if( GetCommandlineArgument( "sendsongs" ) )
|
||||||
|
NSMAN->SendSongs();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessArgsSecond()
|
static void ProcessArgsSecond()
|
||||||
{
|
{
|
||||||
|
CString Argument;
|
||||||
if( GetCommandlineArgument( "test2" ) )
|
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[])
|
int main(int argc, char* argv[])
|
||||||
|
|||||||
Reference in New Issue
Block a user