Skip to content

Commit

Permalink
Remove SMOProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Nov 29, 2018
1 parent 64a9110 commit 6803d0a
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 975 deletions.
833 changes: 0 additions & 833 deletions src/NetworkSyncManager.cpp

Large diffs are not rendered by default.

61 changes: 0 additions & 61 deletions src/NetworkSyncManager.h
Expand Up @@ -227,66 +227,6 @@ class NetProtocol
virtual void OnEval(){};
virtual void OffEval(){};
};
class SMOProtocol : public NetProtocol
{ // Built on raw tcp
EzSockets* NetPlayerClient;
EzSockets* BroadcastReception;
PacketFunctions m_packet;
int m_iSalt;
bool TryConnect(unsigned short port, RString address);
void SendSMOnline();

public:
PacketFunctions SMOnlinePacket;
SMOProtocol();
~SMOProtocol();
bool Connect(NetworkSyncManager* n,
unsigned short port,
RString address) override; // Connect and say hello
void close() override;
void Update(NetworkSyncManager* n, float fDeltaTime) override;
void SelectUserSong(NetworkSyncManager* n, Song* song) override;
void CreateNewRoom(RString name, RString desc, RString password) override;
void EnterRoom(RString name, RString password) override;
void RequestRoomInfo(RString name) override;
void ReportPlayerOptions();
void SendChat(const RString& message, string tab, int type) override;
void ReportNSSOnOff(int i) override;
void ReportScore(NetworkSyncManager* n,
int playerID,
int step,
int score,
int combo,
float offset,
int numNotes) override;
void ReportScore(NetworkSyncManager* n,
int playerID,
int step,
int score,
int combo,
float offset) override;
void ReportSongOver(NetworkSyncManager* n) override;
void ReportStyle(NetworkSyncManager* n) override;
void StartRequest(NetworkSyncManager* n, short position) override;
void ProcessInput(NetworkSyncManager* n);
void Login(RString user, RString pass) override;
void OnMusicSelect() override;
void OffMusicSelect() override;
void OnRoomSelect() override;
void OffRoomSelect() override;
void OnOptions() override;
void OffOptions() override;
void OnEval() override;
void OffEval() override;

static void DealWithSMOnlinePack(PacketFunctions& SMOnlinePacket,
ScreenNetSelectMusic* s);
static void DealWithSMOnlinePack(PacketFunctions& SMOnlinePacket,
ScreenNetRoom* s);
static int DealWithSMOnlinePack(PacketFunctions& SMOnlinePacket,
ScreenSMOnlineLogin* s,
RString& response);
};

class ETTProtocol : public NetProtocol
{ // Websockets using uwebsockets sending json
Expand Down Expand Up @@ -355,7 +295,6 @@ class NetworkSyncManager
public:
NetworkSyncManager(LoadingWindow* ld = NULL);
~NetworkSyncManager();
SMOProtocol SMOP;
ETTProtocol ETTP;
NetProtocol* curProtocol{ nullptr };
// If "useSMserver" then send score to server
Expand Down
11 changes: 5 additions & 6 deletions src/ScreenGameplay.cpp
Expand Up @@ -301,7 +301,6 @@ ScreenGameplay::ScreenGameplay()
{
m_pSongBackground = NULL;
m_pSongForeground = NULL;
m_bForceNoNetwork = !GAMESTATE->m_bInNetGameplay;
m_delaying_ready_announce = false;
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = false;
#if !defined(WITHOUT_NETWORKING)
Expand Down Expand Up @@ -575,7 +574,7 @@ ScreenGameplay::Init()
// we need to wait, so that there is no Dead On Start issues.
// if you wait too long at the second checkpoint, you will
// appear dead when you begin your game.
if (!m_bForceNoNetwork)
if (GAMESTATE->m_bPlayingMulti)
NSMAN->StartRequest(0);

// Add individual life meter
Expand Down Expand Up @@ -618,7 +617,7 @@ ScreenGameplay::Init()

#if !defined(WITHOUT_NETWORKING)
// Only used in SMLAN/SMOnline:
if (!m_bForceNoNetwork && NSMAN->useSMserver &&
if (GAMESTATE->m_bPlayingMulti && NSMAN->useSMserver &&
GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StyleType !=
StyleType_OnePlayerTwoSides) {
m_bShowScoreboard = PREFSMAN->m_bEnableScoreboard.Get();
Expand Down Expand Up @@ -892,7 +891,7 @@ ScreenGameplay::~ScreenGameplay()

m_GameplayAssist.StopPlaying();

if (!m_bForceNoNetwork)
if (GAMESTATE->m_bPlayingMulti)
NSMAN->ReportSongOver();
#if !defined(WITHOUT_NETWORKING)
DLMAN->UpdateDLSpeed(false);
Expand Down Expand Up @@ -1338,7 +1337,7 @@ ScreenGameplay::BeginScreen()
SOUND->PlayOnceFromAnnouncer("gameplay intro"); // crowd cheer

// Get the transitions rolling
if (!m_bForceNoNetwork && NSMAN->useSMserver) {
if (GAMESTATE->m_bPlayingMulti && NSMAN->useSMserver) {
// If we're using networking, we must not have any delay. If we do,
// this can cause inconsistency on different computers and
// different themes.
Expand Down Expand Up @@ -1785,7 +1784,7 @@ ScreenGameplay::Update(float fDeltaTime)
PlayTicks();
SendCrossedMessages();

if (!m_bForceNoNetwork && NSMAN->useSMserver) {
if (GAMESTATE->m_bPlayingMulti && NSMAN->useSMserver) {
FOREACH_EnabledPlayerNumberInfo(m_vPlayerInfo, pi) if (pi->m_pLifeMeter)
NSMAN->m_playerLife = int(pi->m_pLifeMeter->GetLife() * 10000);

Expand Down
6 changes: 0 additions & 6 deletions src/ScreenGameplay.h
Expand Up @@ -325,12 +325,6 @@ class ScreenGameplay : public ScreenWithMenuElements
// announcer sound needs to be delayed. See HandleScreenMessage for more.
// -Kyz
bool m_delaying_ready_announce;

// HACK: We have no idea whether we're actually using SMOnline or not.
// No, seriously, NOWHERE is it stored what room we're in or whether we're
// in a room at all. Apparently we just hope the server is keeping track.
// All we can do is guess based on what subclass we are.
bool m_bForceNoNetwork;
};

vector<PlayerInfo>::iterator
Expand Down
4 changes: 0 additions & 4 deletions src/ScreenNetRoom.cpp
Expand Up @@ -11,7 +11,6 @@
#include "ThemeManager.h"
#include "WheelItemBase.h"

AutoScreenMessage(SM_SMOnlinePack);
AutoScreenMessage(SM_BackFromRoomName);
AutoScreenMessage(SM_BackFromRoomDesc);
AutoScreenMessage(SM_BackFromRoomPass);
Expand Down Expand Up @@ -90,9 +89,6 @@ ScreenNetRoom::HandleScreenMessage(const ScreenMessage SM)
if (!ScreenTextEntry::s_bCancelledLast) {
NSMAN->EnterRoom(m_sLastPickedRoom, ScreenTextEntry::s_sLastAnswer);
}
} else if (SM == SM_SMOnlinePack) {
SMOProtocol::DealWithSMOnlinePack(
static_cast<SMOProtocol*>(NSMAN->curProtocol)->SMOnlinePacket, this);
} else if (SM == ETTP_RoomsChange) {
UpdateRoomsList();
} else if (SM == SM_BackFromRoomName) {
Expand Down
1 change: 0 additions & 1 deletion src/ScreenNetSelectBase.cpp
Expand Up @@ -26,7 +26,6 @@
AutoScreenMessage(SM_AddToChat);
AutoScreenMessage(SM_UsersUpdate);
AutoScreenMessage(SM_FriendsUpdate);
AutoScreenMessage(SM_SMOnlinePack);

REGISTER_SCREEN_CLASS(ScreenNetSelectBase);

Expand Down
6 changes: 1 addition & 5 deletions src/ScreenNetSelectMusic.cpp
Expand Up @@ -35,7 +35,6 @@ AutoScreenMessage(SM_AddToChat);
AutoScreenMessage(SM_FriendsUpdate);
AutoScreenMessage(SM_NoSongs);
AutoScreenMessage(SM_ChangeSong);
AutoScreenMessage(SM_SMOnlinePack);
AutoScreenMessage(SM_SetWheelSong);
AutoScreenMessage(SM_RefreshWheelLocation);
AutoScreenMessage(SM_SongChanged);
Expand All @@ -55,7 +54,7 @@ void
ScreenNetSelectMusic::Init()
{
ScreenSelectMusic::Init();

GAMESTATE->m_bPlayingMulti = true;
SAMPLE_MUSIC_PREVIEW_MODE.Load(m_sName, "SampleMusicPreviewMode");
MUSIC_WHEEL_TYPE.Load(m_sName, "MusicWheelType");
PLAYER_OPTIONS_SCREEN.Load(m_sName, "PlayerOptionsScreen");
Expand Down Expand Up @@ -433,9 +432,6 @@ ScreenNetSelectMusic::HandleScreenMessage(const ScreenMessage SM)
m_MusicWheel.Move(1);
m_MusicWheel.Select();
}
} else if (SM == SM_SMOnlinePack) {
SMOProtocol::DealWithSMOnlinePack(
static_cast<SMOProtocol*>(NSMAN->curProtocol)->SMOnlinePacket, this);
} else if (SM == SM_ConfirmDeleteSong) {
if (ScreenPrompt::s_LastAnswer == ANSWER_YES) {
OnConfirmSongDeletion();
Expand Down
35 changes: 0 additions & 35 deletions src/ScreenSMOnlineLogin.cpp
Expand Up @@ -17,7 +17,6 @@

REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin);

AutoScreenMessage(SM_SMOnlinePack);
AutoScreenMessage(SM_PasswordDone);
AutoScreenMessage(SM_UsernameDone);
AutoScreenMessage(SM_NoProfilesDefined);
Expand Down Expand Up @@ -165,40 +164,6 @@ ScreenSMOnlineLogin::HandleScreenMessage(const ScreenMessage SM)
NULL);
}
}
} else if (SM == SM_SMOnlinePack) {
LOG->Trace("[ScreenSMOnlineLogin::HandleScreenMessage] SMOnlinePack");
if (!GAMESTATE->IsPlayerEnabled(static_cast<PlayerNumber>(m_iPlayer))) {
LuaHelpers::ReportScriptErrorFmt("Invalid player number: %i",
m_iPlayer);
return;
}
// This can cause problems in certain situations -aj
sLoginQuestion =
YOU_ARE_LOGGING_ON_AS.GetValue() + "\n" +
GAMESTATE->GetPlayerDisplayName((PlayerNumber)m_iPlayer) + "\n" +
ENTER_YOUR_PASSWORD.GetValue();
RString Response;
switch (SMOProtocol::DealWithSMOnlinePack(
static_cast<SMOProtocol*>(NSMAN->curProtocol)->SMOnlinePacket,
this,
Response)) {
case 0:
SCREENMAN->SetNewScreen(
THEME->GetMetric(m_sName, "NextScreen"));
m_iPlayer = 0;
break;
case 1:
ScreenTextEntry::Password(
SM_PasswordDone, sLoginQuestion, NULL);
break;
case 2:
m_iPlayer = 0;
break;
case 3:
ScreenTextEntry::Password(
SM_PasswordDone, Response + "\n\n" + sLoginQuestion, NULL);
break;
}
} else if (SM == SM_GoToNextScreen) {
LOG->Trace("[ScreenSMOnlineLogin::HandleScreenMessage] GoToNextScreen");
vector<PlayerNumber> v;
Expand Down
50 changes: 26 additions & 24 deletions src/ScreenSelectMusic.cpp
Expand Up @@ -80,6 +80,7 @@ REGISTER_SCREEN_CLASS(ScreenSelectMusic);
void
ScreenSelectMusic::Init()
{
GAMESTATE->m_bPlayingMulti = false;
g_ScreenStartedLoadingAt.Touch();
if (PREFSMAN->m_sTestInitialScreen.Get() == m_sName) {
GAMESTATE->m_PlayMode.Set(PLAY_MODE_REGULAR);
Expand Down Expand Up @@ -1711,7 +1712,7 @@ class LunaScreenSelectMusic : public Luna<ScreenSelectMusic>
auto* td = GAMESTATE->m_pCurSteps[PLAYER_1]->GetTimingData();
// vector<int> ihatemylife;
auto nd = GAMESTATE->m_pCurSteps[PLAYER_1]->GetNoteData();
auto nerv = nd.BuildAndGetNerv();
auto nerv = nd.BuildAndGetNerv();
/* functionally dead code, may be removed -poco
if (!hs->GetChordCohesion()) {
for (auto r : nerv)
Expand All @@ -1720,32 +1721,33 @@ class LunaScreenSelectMusic : public Luna<ScreenSelectMusic>
} else {
for (auto r : nerv)
ihatemylife.emplace_back(r);
}
}
*/
auto sdifs = td->BuildAndGetEtaner(nerv);
vector<int> noterows;
for (auto t : timestamps) {
auto timestamptobeat =
td->GetBeatFromElapsedTime(t * hs->GetMusicRate());
auto somenumberscaledbyoffsets =
sdifs[0] - (timestamps[0] * hs->GetMusicRate());
timestamptobeat += somenumberscaledbyoffsets;
auto noterowfrombeat = BeatToNoteRow(timestamptobeat);
noterows.emplace_back(noterowfrombeat);
}
int noterowoffsetter = nerv[0] - noterows[0];
for (auto& noterowwithoffset : noterows)
auto sdifs = td->BuildAndGetEtaner(nerv);
vector<int> noterows;
for (auto t : timestamps) {
auto timestamptobeat =
td->GetBeatFromElapsedTime(t * hs->GetMusicRate());
auto somenumberscaledbyoffsets =
sdifs[0] - (timestamps[0] * hs->GetMusicRate());
timestamptobeat += somenumberscaledbyoffsets;
auto noterowfrombeat = BeatToNoteRow(timestamptobeat);
noterows.emplace_back(noterowfrombeat);
}
int noterowoffsetter = nerv[0] - noterows[0];
for (auto& noterowwithoffset : noterows)
noterowwithoffset += noterowoffsetter;
GAMESTATE->SetProcessedTimingData(nullptr);
//hs->SetNoteRowVector(ihatemylife);
hs->SetNoteRowVector(noterows);

// Since we keep misses on EO as 180ms, we need to convert them back.
auto offsets = hs->GetCopyOfOffsetVector();
for (auto& offset : offsets) {
if (fabs(offset) >= .18f)
offset = -1.1f; // This is a miss to the replay reader.
}
// hs->SetNoteRowVector(ihatemylife);
hs->SetNoteRowVector(noterows);

// Since we keep misses on EO as 180ms, we need to convert them
// back.
auto offsets = hs->GetCopyOfOffsetVector();
for (auto& offset : offsets) {
if (fabs(offset) >= .18f)
offset = -1.1f; // This is a miss to the replay reader.
}
hs->SetOffsetVector(offsets);
}

Expand Down

0 comments on commit 6803d0a

Please sign in to comment.