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:
Charles Lohr
2004-04-17 22:26:37 +00:00
parent b5ec124e28
commit 3f63f6c60e
3 changed files with 132 additions and 2 deletions
+109
View File
@@ -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 <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
NetworkSyncManager *NSMAN;