From 4b7c6521adf009c40cecf9e264d3033332086564 Mon Sep 17 00:00:00 2001 From: Charles Lohr Date: Wed, 14 Apr 2004 20:39:58 +0000 Subject: [PATCH] I changed the way StepMania connects to an IP or listens to something that makes way more sense. StepMania.exe -NETIP:[IP] and added support for reading profile names (for LAN). The LAN looks very stable at this point. --- stepmania/src/NetworkSyncManager.cpp | 88 ++++++++++++++++------------ stepmania/src/NetworkSyncManager.h | 6 ++ 2 files changed, 57 insertions(+), 37 deletions(-) diff --git a/stepmania/src/NetworkSyncManager.cpp b/stepmania/src/NetworkSyncManager.cpp index 5fefa8b09a..044ce2c1e5 100644 --- a/stepmania/src/NetworkSyncManager.cpp +++ b/stepmania/src/NetworkSyncManager.cpp @@ -11,70 +11,84 @@ ----------------------------------------------------------------------------- */ - - -/* ------------------------ -NOTE TO DEVS: - -This file is still under heavy editing. -Don't bother to edit it. I will be editing it as I go. - - - - IF YOU DO EDIT THIS FILE PLEASE LEAVE A NOTE! - I AM CONSTANTLY EDITING IT. ------------------------ -*/ - - - #include "global.h" #include #include "NetworkSyncManager.h" - -#include "BPMDisplay.h" -//for ssprintf +#include "ProfileManager.h" #include "ezsockets.h" #include "RageLog.h" +#include "RageUtil.h" + //String compare functions for command line args + NetworkSyncManager::NetworkSyncManager(int argc, char **argv) { NetPlayerClient = new EzSockets; m_ServerVersion = 0; - CString tempargv(argv[1]); + if (argc > 1) { + LOG->Trace("Multiple arguements were entered."); + int argCtr = 1; - if (argc > 2) { - LOG->Info("Multiple arguements were entered."); - - if (!tempargv.CompareNoCase("LISTEN")) - if (Listen(8765)) { - useSMserver = true; - } else - useSMserver = false; - else - if (Connect(argv[1],8765) == true) + while (argCtrTrace ("NetIP Found:%s",IPAddy.c_str()); + + if (!IPAddy.CompareNoCase("LISTEN")) + if (Listen(8765)) { + useSMserver = true; + } else + useSMserver = false; + else + if (Connect(IPAddy.c_str(),8765) == true) + { + useSMserver = true; + } else + useSMserver = false; + + break;//Once connected, break outta loop. + } + argCtr++; + } } else useSMserver = false; + + if (useSMserver) { int ClientCommand=3; NetPlayerClient->send((char*) &ClientCommand, 4); -// NetPlayerClient->send(0);//Send 0 for flash client NetPlayerClient->receive(m_ServerVersion); //If network play is desired //AND the connection works //Halt until we know what server //version we're dealing with - + vector ProfileNames; + PROFILEMAN->GetLocalProfileNames(ProfileNames); + + netName PlayerName; + int i; + + if (ProfileNames.size()>0) { + PlayerName.m_packID = 30; + for (i=0;isend((char*) &PlayerName,20); + } + if (ProfileNames.size()>1) { + PlayerName.m_packID = 31; + for (i=0;isend((char*) &PlayerName,20); + } LOG->Info("Server Version: %d",m_ServerVersion); } diff --git a/stepmania/src/NetworkSyncManager.h b/stepmania/src/NetworkSyncManager.h index d325e5dcfa..173dd65859 100644 --- a/stepmania/src/NetworkSyncManager.h +++ b/stepmania/src/NetworkSyncManager.h @@ -55,6 +55,12 @@ private: int m_life; //Player's Life }; + struct netName //Data structure used for 16-character strings. + { + int m_packID; + char m_data[16]; + }; + struct netHolderFlash { char data[73];