@@ -52,11 +52,15 @@ enum class ELobbyUpdateField
5252 MY_START_POS = 3 ,
5353 MY_TEAM = 4 ,
5454 LOBBY_STARTING_CASH = 5 ,
55- LOBBY_LIMIT_SUPERWEAPONS = 6
55+ LOBBY_LIMIT_SUPERWEAPONS = 6 ,
56+ HOST_ACTION_FORCE_START = 7
5657};
5758
5859void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_Map (AsciiString strMap, AsciiString strMapPath, int newMaxPlayers)
5960{
61+ // reset autostart if host changes anything (because ready flag will reset too)
62+ ClearAutoReadyCountdown ();
63+
6064 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
6165 std::map<std::string, std::string> mapHeaders;
6266
@@ -76,6 +80,9 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_Map(AsciiString strM
7680
7781void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_LimitSuperweapons (bool bLimitSuperweapons)
7882{
83+ // reset autostart if host changes anything (because ready flag will reset too)
84+ ClearAutoReadyCountdown ();
85+
7986 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
8087 std::map<std::string, std::string> mapHeaders;
8188
@@ -93,6 +100,9 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_LimitSuperweapons(bo
93100
94101void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_StartingCash (UnsignedInt startingCashValue)
95102{
103+ // reset autostart if host changes anything (because ready flag will reset too)
104+ ClearAutoReadyCountdown ();
105+
96106 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
97107 std::map<std::string, std::string> mapHeaders;
98108
@@ -110,6 +120,9 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_StartingCash(Unsigne
110120
111121void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MySide (int side, int updatedStartPos)
112122{
123+ // reset autostart if host changes anything (because ready flag will reset too). This occurs on client too, but nothing happens for them
124+ ClearAutoReadyCountdown ();
125+
113126 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
114127 std::map<std::string, std::string> mapHeaders;
115128
@@ -128,6 +141,9 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MySide(int side, int
128141
129142void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MyColor (int color)
130143{
144+ // reset autostart if host changes anything (because ready flag will reset too). This occurs on client too, but nothing happens for them
145+ ClearAutoReadyCountdown ();
146+
131147 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
132148 std::map<std::string, std::string> mapHeaders;
133149
@@ -145,6 +161,9 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MyColor(int color)
145161
146162void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MyStartPos (int startpos)
147163{
164+ // reset autostart if host changes anything (because ready flag will reset too). This occurs on client too, but nothing happens for them
165+ ClearAutoReadyCountdown ();
166+
148167 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
149168 std::map<std::string, std::string> mapHeaders;
150169
@@ -162,6 +181,9 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MyStartPos(int start
162181
163182void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MyTeam (int team)
164183{
184+ // reset autostart if host changes anything (because ready flag will reset too). This occurs on client too, but nothing happens for them
185+ ClearAutoReadyCountdown ();
186+
165187 std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
166188 std::map<std::string, std::string> mapHeaders;
167189
@@ -177,14 +199,31 @@ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_MyTeam(int team)
177199 });
178200}
179201
202+ void NGMP_OnlineServices_LobbyInterface::UpdateCurrentLobby_ForceReady ()
203+ {
204+ std::string strURI = std::format (" {}/{}" , NGMP_OnlineServicesManager::GetAPIEndpoint (" Lobby" , true ), m_CurrentLobby.lobbyID );
205+ std::map<std::string, std::string> mapHeaders;
206+
207+ nlohmann::json j;
208+ j[" field" ] = ELobbyUpdateField::HOST_ACTION_FORCE_START;
209+ std::string strPostData = j.dump ();
210+
211+ // convert
212+ NGMP_OnlineServicesManager::GetInstance ()->GetHTTPManager ()->SendPOSTRequest (strURI.c_str (), EIPProtocolVersion::DONT_CARE, mapHeaders, strPostData.c_str (), [=](bool bSuccess, int statusCode, std::string strBody)
213+ {
214+ UnicodeString msg = UnicodeString (L" All players have been forced to ready up." );
215+ SendAnnouncementMessageToCurrentLobby (msg, true );
216+ });
217+ }
218+
180219void NGMP_OnlineServices_LobbyInterface::SendChatMessageToCurrentLobby (UnicodeString& strChatMsgUnicode)
181220{
182221 // TODO_NGMP: Custom
183222 // TODO_NGMP: Support unicode again
184223 AsciiString strChatMsg;
185224 strChatMsg.translate (strChatMsgUnicode);
186225
187- NetRoom_ChatMessagePacket chatPacket (strChatMsg);
226+ NetRoom_ChatMessagePacket chatPacket (strChatMsg, false , false );
188227
189228 // TODO_NGMP: Move to uint64 for user id
190229 std::vector<int64_t > vecUsersToSend;
@@ -199,6 +238,21 @@ void NGMP_OnlineServices_LobbyInterface::SendChatMessageToCurrentLobby(UnicodeSt
199238 }
200239}
201240
241+ // TODO_NGMP: Just send a separate packet for each announce, more efficient and less hacky
242+ void NGMP_OnlineServices_LobbyInterface::SendAnnouncementMessageToCurrentLobby (UnicodeString& strAnnouncementMsgUnicode, bool bShowToHost)
243+ {
244+ AsciiString strChatMsg;
245+ strChatMsg.translate (strAnnouncementMsgUnicode);
246+
247+ NetRoom_ChatMessagePacket chatPacket (strChatMsg, true , bShowToHost);
248+
249+ std::vector<int64_t > vecUsersToSend;
250+ if (m_pLobbyMesh != nullptr )
251+ {
252+ m_pLobbyMesh->SendToMesh (chatPacket, vecUsersToSend);
253+ }
254+ }
255+
202256NGMP_OnlineServices_LobbyInterface::NGMP_OnlineServices_LobbyInterface ()
203257{
204258 /*
@@ -825,6 +879,8 @@ void NGMP_OnlineServices_LobbyInterface::JoinLobby(int index)
825879
826880void NGMP_OnlineServices_LobbyInterface::LeaveCurrentLobby ()
827881{
882+ m_timeStartAutoReadyCountdown = -1 ;
883+
828884 // kill mesh
829885 if (m_pLobbyMesh != nullptr )
830886 {
@@ -1180,6 +1236,9 @@ void NGMP_OnlineServices_LobbyInterface::CreateLobby(UnicodeString strLobbyName,
11801236
11811237void NGMP_OnlineServices_LobbyInterface::OnJoinedOrCreatedLobby (bool bAlreadyUpdatedDetails)
11821238{
1239+ // reset timer
1240+ m_timeStartAutoReadyCountdown = -1 ;
1241+
11831242 // TODO_NGMP: We need this on create, but this is a double call on join because we already got this info
11841243 // must be done in a callback, this is an async function
11851244 if (!bAlreadyUpdatedDetails)
0 commit comments