Skip to content

Commit 15593ff

Browse files
authored
Merge pull request #19 from x64-dev/main
main -> 60hz
2 parents fc96ace + 859174e commit 15593ff

5 files changed

Lines changed: 301 additions & 137 deletions

File tree

Lines changed: 187 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,188 @@
1-
#pragma once
2-
#include "../GameInfo.h"
3-
4-
class LobbyEntry;
5-
6-
class NGMPGameSlot : public GameSlot
7-
{
8-
public:
9-
NGMPGameSlot();
10-
Int getProfileID(void) const { return m_profileID; }
11-
void setProfileID(Int id) { m_profileID = id; }
12-
AsciiString getLoginName(void) const { return m_gameSpyLogin; }
13-
void setLoginName(AsciiString name) { m_gameSpyLogin = name; }
14-
AsciiString getLocale(void) const { return m_gameSpyLocale; }
15-
void setLocale(AsciiString name) { m_gameSpyLocale = name; }
16-
Int getWins(void) const { return m_wins; }
17-
Int getLosses(void) const { return m_losses; }
18-
void setWins(Int wins) { m_wins = wins; }
19-
void setLosses(Int losses) { m_losses = losses; }
20-
21-
Int getSlotRankPoints(void) const { return m_rankPoints; }
22-
Int getFavoriteSide(void) const { return m_favoriteSide; }
23-
void setSlotRankPoints(Int val) { m_rankPoints = val; }
24-
void setFavoriteSide(Int val) { m_favoriteSide = val; }
25-
26-
void setPingString(AsciiString pingStr) { m_pingStr = pingStr; }
27-
inline AsciiString getPingString(void) const { return m_pingStr; }
28-
inline Int getPingAsInt(void) const { return m_pingInt; }
29-
30-
int64_t m_userID = -1;
31-
32-
void UpdateLatencyFromConnection(AsciiString pingStr, int ping)
33-
{
34-
m_pingStr = pingStr;
35-
m_pingInt = ping;
36-
}
37-
38-
protected:
39-
Int m_profileID;
40-
AsciiString m_gameSpyLogin;
41-
AsciiString m_gameSpyLocale;
42-
43-
AsciiString m_pingStr;
44-
Int m_pingInt;
45-
Int m_wins, m_losses;
46-
Int m_rankPoints, m_favoriteSide;
47-
};
48-
49-
50-
class NGMPGame : public GameInfo
51-
{
52-
private:
53-
NGMPGameSlot m_Slots[MAX_SLOTS];
54-
UnicodeString m_gameName;
55-
Int m_id;
56-
//Transport* m_transport;
57-
AsciiString m_localName;
58-
Bool m_requiresPassword;
59-
Bool m_allowObservers;
60-
UnsignedInt m_version;
61-
UnsignedInt m_exeCRC;
62-
UnsignedInt m_iniCRC;
63-
Bool m_isQM;
64-
65-
AsciiString m_ladderIP;
66-
AsciiString m_pingStr;
67-
Int m_pingInt;
68-
UnsignedShort m_ladderPort;
69-
70-
Int m_reportedNumPlayers;
71-
Int m_reportedMaxPlayers;
72-
Int m_reportedNumObservers;
73-
74-
public:
75-
NGMPGame();
76-
virtual ~NGMPGame();
77-
virtual void reset(void);
78-
79-
void SyncWithLobby(LobbyEntry& lobby);
80-
void UpdateSlotsFromCurrentLobby();
81-
82-
void cleanUpSlotPointers(void);
83-
inline void setID(Int id) { m_id = id; }
84-
inline Int getID(void) const { return m_id; }
85-
86-
inline void setHasPassword(Bool val) { m_requiresPassword = val; }
87-
inline Bool getHasPassword(void) const { return m_requiresPassword; }
88-
inline void setAllowObservers(Bool val) { m_allowObservers = val; }
89-
inline Bool getAllowObservers(void) const { return m_allowObservers; }
90-
91-
inline void setVersion(UnsignedInt val) { m_version = val; }
92-
inline UnsignedInt getVersion(void) const { return m_version; }
93-
inline void setExeCRC(UnsignedInt val) { m_exeCRC = val; }
94-
inline UnsignedInt getExeCRC(void) const { return m_exeCRC; }
95-
inline void setIniCRC(UnsignedInt val) { m_iniCRC = val; }
96-
inline UnsignedInt getIniCRC(void) const { return m_iniCRC; }
97-
98-
inline void setReportedNumPlayers(Int val) { m_reportedNumPlayers = val; }
99-
inline Int getReportedNumPlayers(void) const { return m_reportedNumPlayers; }
100-
101-
inline void setReportedMaxPlayers(Int val) { m_reportedMaxPlayers = val; }
102-
inline Int getReportedMaxPlayers(void) const { return m_reportedMaxPlayers; }
103-
104-
inline void setReportedNumObservers(Int val) { m_reportedNumObservers = val; }
105-
inline Int getReportedNumObservers(void) const { return m_reportedNumObservers; }
106-
107-
inline void setLadderIP(AsciiString ladderIP) { m_ladderIP = ladderIP; }
108-
inline AsciiString getLadderIP(void) const { return m_ladderIP; }
109-
inline void setLadderPort(UnsignedShort ladderPort) { m_ladderPort = ladderPort; }
110-
inline UnsignedShort getLadderPort(void) const { return m_ladderPort; }
111-
void setPingString(AsciiString pingStr);
112-
inline AsciiString getPingString(void) const { return m_pingStr; }
113-
inline Int getPingAsInt(void) const { return m_pingInt; }
114-
115-
virtual Bool amIHost(void) const; ///< Convenience function - is the local player the game host?
116-
117-
NGMPGameSlot* getGameSpySlot(Int index);
118-
119-
AsciiString generateGameSpyGameResultsPacket(void);
120-
AsciiString generateLadderGameResultsPacket(void);
121-
void markGameAsQM(void) { m_isQM = TRUE; }
122-
Bool isQMGame(void) { return m_isQM; }
123-
124-
virtual void init(void);
125-
virtual void resetAccepted(void); ///< Reset the accepted flag on all players
126-
127-
virtual void startGame(Int gameID); ///< Mark our game as started and record the game ID.
128-
void launchGame(void); ///< NAT negotiation has finished - really start
129-
virtual Int getLocalSlotNum(void) const; ///< Get the local slot number, or -1 if we're not present
130-
131-
inline void setGameName(UnicodeString name) { m_gameName = name; }
132-
inline UnicodeString getGameName(void) const { return m_gameName; }
133-
134-
inline void setLocalName(AsciiString name) { m_localName = name; }
1+
#pragma once
2+
#include "../GameInfo.h"
3+
#include <chrono>
4+
5+
class LobbyEntry;
6+
7+
class NGMPGameSlot : public GameSlot
8+
{
9+
public:
10+
NGMPGameSlot();
11+
Int getProfileID(void) const { return m_profileID; }
12+
void setProfileID(Int id) { m_profileID = id; }
13+
AsciiString getLoginName(void) const { return m_gameSpyLogin; }
14+
void setLoginName(AsciiString name) { m_gameSpyLogin = name; }
15+
AsciiString getLocale(void) const { return m_gameSpyLocale; }
16+
void setLocale(AsciiString name) { m_gameSpyLocale = name; }
17+
Int getWins(void) const { return m_wins; }
18+
Int getLosses(void) const { return m_losses; }
19+
void setWins(Int wins) { m_wins = wins; }
20+
void setLosses(Int losses) { m_losses = losses; }
21+
22+
Int getSlotRankPoints(void) const { return m_rankPoints; }
23+
Int getFavoriteSide(void) const { return m_favoriteSide; }
24+
void setSlotRankPoints(Int val) { m_rankPoints = val; }
25+
void setFavoriteSide(Int val) { m_favoriteSide = val; }
26+
27+
void setPingString(AsciiString pingStr) { m_pingStr = pingStr; }
28+
inline AsciiString getPingString(void) const { return m_pingStr; }
29+
inline Int getPingAsInt(void) const { return m_pingInt; }
30+
31+
int64_t m_userID = -1;
32+
33+
void UpdateLatencyFromConnection(AsciiString pingStr, int ping)
34+
{
35+
m_pingStr = pingStr;
36+
m_pingInt = ping;
37+
}
38+
39+
protected:
40+
Int m_profileID;
41+
AsciiString m_gameSpyLogin;
42+
AsciiString m_gameSpyLocale;
43+
44+
AsciiString m_pingStr;
45+
Int m_pingInt;
46+
Int m_wins, m_losses;
47+
Int m_rankPoints, m_favoriteSide;
48+
};
49+
50+
51+
class NGMPGame : public GameInfo
52+
{
53+
private:
54+
NGMPGameSlot m_Slots[MAX_SLOTS];
55+
UnicodeString m_gameName;
56+
Int m_id;
57+
//Transport* m_transport;
58+
AsciiString m_localName;
59+
Bool m_requiresPassword;
60+
Bool m_allowObservers;
61+
UnsignedInt m_version;
62+
UnsignedInt m_exeCRC;
63+
UnsignedInt m_iniCRC;
64+
Bool m_isQM;
65+
66+
AsciiString m_ladderIP;
67+
AsciiString m_pingStr;
68+
Int m_pingInt;
69+
UnsignedShort m_ladderPort;
70+
71+
Int m_reportedNumPlayers;
72+
Int m_reportedMaxPlayers;
73+
Int m_reportedNumObservers;
74+
75+
std::chrono::system_clock::time_point matchStartTime;
76+
77+
#if defined(GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN)
78+
bool m_bCountdownStarted = false;
79+
int64_t m_countdownStartTime = -1;
80+
int64_t m_countdownLastCheckTime = -1;
81+
#endif
82+
83+
public:
84+
NGMPGame();
85+
virtual ~NGMPGame();
86+
virtual void reset(void);
87+
88+
#if defined(GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN)
89+
void StartCountdown()
90+
{
91+
m_bCountdownStarted = true;
92+
m_countdownStartTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::utc_clock::now().time_since_epoch()).count();
93+
m_countdownLastCheckTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::utc_clock::now().time_since_epoch()).count();
94+
}
95+
96+
void StopCountdown()
97+
{
98+
m_bCountdownStarted = false;
99+
m_countdownStartTime = -1;
100+
m_countdownLastCheckTime = -1;
101+
}
102+
103+
bool IsCountdownStarted()
104+
{
105+
return m_bCountdownStarted;
106+
}
107+
108+
int64_t GetCountdownStartTime()
109+
{
110+
return m_countdownStartTime;
111+
}
112+
113+
void UpdateCountdownLastCheckTime()
114+
{
115+
m_countdownLastCheckTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::utc_clock::now().time_since_epoch()).count();
116+
}
117+
118+
int GetTotalCountdownDuration()
119+
{
120+
return 10;
121+
}
122+
123+
int64_t GetCountdownLastCheckTime()
124+
{
125+
return m_countdownLastCheckTime;
126+
}
127+
#endif
128+
129+
void StartMatchTimer() { matchStartTime = std::chrono::system_clock::now(); }
130+
std::chrono::system_clock::time_point GetStartTime() { return matchStartTime; }
131+
132+
void SyncWithLobby(LobbyEntry& lobby);
133+
void UpdateSlotsFromCurrentLobby();
134+
135+
void cleanUpSlotPointers(void);
136+
inline void setID(Int id) { m_id = id; }
137+
inline Int getID(void) const { return m_id; }
138+
139+
inline void setHasPassword(Bool val) { m_requiresPassword = val; }
140+
inline Bool getHasPassword(void) const { return m_requiresPassword; }
141+
inline void setAllowObservers(Bool val) { m_allowObservers = val; }
142+
inline Bool getAllowObservers(void) const { return m_allowObservers; }
143+
144+
inline void setVersion(UnsignedInt val) { m_version = val; }
145+
inline UnsignedInt getVersion(void) const { return m_version; }
146+
inline void setExeCRC(UnsignedInt val) { m_exeCRC = val; }
147+
inline UnsignedInt getExeCRC(void) const { return m_exeCRC; }
148+
inline void setIniCRC(UnsignedInt val) { m_iniCRC = val; }
149+
inline UnsignedInt getIniCRC(void) const { return m_iniCRC; }
150+
151+
inline void setReportedNumPlayers(Int val) { m_reportedNumPlayers = val; }
152+
inline Int getReportedNumPlayers(void) const { return m_reportedNumPlayers; }
153+
154+
inline void setReportedMaxPlayers(Int val) { m_reportedMaxPlayers = val; }
155+
inline Int getReportedMaxPlayers(void) const { return m_reportedMaxPlayers; }
156+
157+
inline void setReportedNumObservers(Int val) { m_reportedNumObservers = val; }
158+
inline Int getReportedNumObservers(void) const { return m_reportedNumObservers; }
159+
160+
inline void setLadderIP(AsciiString ladderIP) { m_ladderIP = ladderIP; }
161+
inline AsciiString getLadderIP(void) const { return m_ladderIP; }
162+
inline void setLadderPort(UnsignedShort ladderPort) { m_ladderPort = ladderPort; }
163+
inline UnsignedShort getLadderPort(void) const { return m_ladderPort; }
164+
void setPingString(AsciiString pingStr);
165+
inline AsciiString getPingString(void) const { return m_pingStr; }
166+
inline Int getPingAsInt(void) const { return m_pingInt; }
167+
168+
virtual Bool amIHost(void) const; ///< Convenience function - is the local player the game host?
169+
170+
NGMPGameSlot* getGameSpySlot(Int index);
171+
172+
AsciiString generateGameSpyGameResultsPacket(void);
173+
AsciiString generateLadderGameResultsPacket(void);
174+
void markGameAsQM(void) { m_isQM = TRUE; }
175+
Bool isQMGame(void) { return m_isQM; }
176+
177+
virtual void init(void);
178+
virtual void resetAccepted(void); ///< Reset the accepted flag on all players
179+
180+
virtual void startGame(Int gameID); ///< Mark our game as started and record the game ID.
181+
void launchGame(void); ///< NAT negotiation has finished - really start
182+
virtual Int getLocalSlotNum(void) const; ///< Get the local slot number, or -1 if we're not present
183+
184+
inline void setGameName(UnicodeString name) { m_gameName = name; }
185+
inline UnicodeString getGameName(void) const { return m_gameName; }
186+
187+
inline void setLocalName(AsciiString name) { m_localName = name; }
135188
};

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/NextGenMP_defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#define ALLOW_NON_PROFILED_LOGIN 1
2424

25+
#define GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN
26+
2527
#define NATPMP_STATICLIB 1
2628
#define PLUM_STATIC 1
2729

0 commit comments

Comments
 (0)