NetworkSyncManager.h
Go to the documentation of this file.00001
00002
00003
#ifndef NetworkSyncManager_H
00004
#define NetworkSyncManager_H
00005
00006
#include "PlayerNumber.h"
00007
#include "Difficulty.h"
00008
#include <queue>
00009
00010
class LoadingWindow;
00011
00012 const int NETPROTOCOLVERSION=1;
00013 const int NETMAXBUFFERSIZE=1020;
00014 const int NETNUMTAPSCORES=8;
00015
00016 enum NSCommand
00017 {
00018
NSCPing = 0,
00019
NSCPingR,
00020
NSCHello,
00021
NSCGSR,
00022
NSCGON,
00023
NSCGSU,
00024
NSCSU,
00025
NSCCM,
00026
NSCRSG,
00027
NSCUUL,
00028
NSCSMS,
00029
NSCUPOpts,
00030
NSCSMOnline,
00031
NUM_NS_COMMANDS
00032 };
00033
00034 const NSCommand NSServerOffset = (
NSCommand)128;
00035
00036 struct EndOfGame_PlayerData
00037 {
00038 int name;
00039 int score;
00040 int grade;
00041 Difficulty difficulty;
00042 int tapScores[
NETNUMTAPSCORES];
00043 CString playerOptions;
00044 };
00045
00046 enum NSScoreBoardColumn
00047 {
00048
NSSB_NAMES=0,
00049
NSSB_COMBO,
00050
NSSB_GRADE,
00051
NUM_NSSB_CATEGORIES
00052 };
00053 #define FOREACH_NSScoreBoardColumn( sc ) FOREACH_ENUM( NSScoreBoardColumn, NUM_NSSB_CATEGORIES, sc )
00054
00055
class EzSockets;
00056
class StepManiaLanServer;
00057
00058 class PacketFunctions
00059 {
00060
public:
00061 unsigned char Data[
NETMAXBUFFERSIZE];
00062 int Position;
00063 int size;
00064
00065
00066
00067 uint8_t
Read1();
00068 uint16_t
Read2();
00069 uint32_t
Read4();
00070
CString ReadNT();
00071
00072
void Write1(uint8_t Data);
00073
void Write2(uint16_t Data);
00074
void Write4(uint32_t Data);
00075
void WriteNT(
const CString& Data);
00076
00077
void ClearPacket();
00078 };
00079
00080 class NetworkSyncManager
00081 {
00082
public:
00083
NetworkSyncManager(
LoadingWindow *ld = NULL );
00084
~NetworkSyncManager();
00085
00086
00087
void ReportTiming(
float offset,
int PlayerNumber);
00088
void ReportScore(
int playerID,
int step,
int score,
int combo);
00089
void ReportSongOver();
00090
void ReportStyle();
00091
void ReportNSSOnOff(
int i);
00092
void StartRequest(
short position);
00093
CString GetServerName();
00094
00095
00096
void SendSMOnline( );
00097
00098
bool Connect(
const CString& addy,
unsigned short port);
00099
00100
void PostStartUp(
const CString& ServerIP);
00101
00102
void CloseConnection();
00103
00104
void DisplayStartupStatus();
00105
00106 int m_playerLife[
NUM_PLAYERS];
00107
00108
void Update(
float fDeltaTime);
00109
00110 bool useSMserver;
00111 bool isSMOnline;
00112 bool isSMOLoggedIn[
NUM_PLAYERS];
00113
00114 vector <int>
m_PlayerStatus;
00115 int m_ActivePlayers;
00116 vector <int>
m_ActivePlayer;
00117 vector <CString>
m_PlayerNames;
00118
00119
00120 vector<EndOfGame_PlayerData>
m_EvalPlayerData;
00121
00122
00123
bool ChangedScoreboard(
int Column);
00124 CString m_Scoreboard[
NUM_NSSB_CATEGORIES];
00125
00126
00127
void SendChat(
const CString& message);
00128 CString m_WaitingChat;
00129
00130
00131
void ReportPlayerOptions();
00132
00133
00134 CString m_sMainTitle;
00135 CString m_sArtist;
00136 CString m_sSubTitle;
00137 int m_iSelectMode;
00138
void SelectUserSong();
00139
00140 CString m_sChatText;
00141
00142 PacketFunctions m_SMOnlinePacket;
00143
00144 bool isLanServer;
00145 StepManiaLanServer *
LANserver;
00146
00147
private:
00148
#if !defined(WITHOUT_NETWORKING)
00149
00150
void ProcessInput();
00151
00152
void StartUp();
00153
00154 float m_lastOffset[2];
00155
00156
00157 int m_playerID;
00158 int m_step;
00159 int m_score;
00160 int m_combo;
00161
00162 int m_startupStatus;
00163
00164 bool m_scoreboardchange[
NUM_NSSB_CATEGORIES];
00165
00166 CString m_ServerName;
00167
00168 EzSockets *
NetPlayerClient;
00169
00170 int m_ServerVersion;
00171
00172
bool Listen(
unsigned short port);
00173
00174 PacketFunctions m_packet;
00175
#endif
00176
};
00177
00178 extern NetworkSyncManager *
NSMAN;
00179
00180
#endif
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
Generated on Thu Jan 27 20:57:25 2005 for StepMania by
1.3.7