Skip to content

Commit f5b9a5e

Browse files
committed
refactor(network): use specific command classes in ConnectionManager
Update ConnectionManager to instantiate specific NetCommandMsg subclasses directly instead of creating generic NetCommandMsg and setting the type. Changes: - Use NetLoadCompleteCommandMsg in loadProgressComplete() - Use NetTimeOutGameStartCommandMsg in sendTimeOutGameStart() - Remove manual setNetCommandType() calls (type set in constructor) Applied to both Generals and Zero Hour
1 parent ad1d4a9 commit f5b9a5e

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

Core/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ set(GAMEENGINE_SRC
11281128
Source/GameNetwork/LANGameInfo.cpp
11291129
Source/GameNetwork/NAT.cpp
11301130
Source/GameNetwork/NetCommandList.cpp
1131-
# Source/GameNetwork/NetCommandMsg.cpp
1131+
Source/GameNetwork/NetCommandMsg.cpp
11321132
Source/GameNetwork/NetCommandRef.cpp
11331133
Source/GameNetwork/NetCommandWrapperList.cpp
11341134
Source/GameNetwork/NetMessageStream.cpp

Generals/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,12 +2236,11 @@ void ConnectionManager::updateLoadProgress( Int progress )
22362236

22372237
void ConnectionManager::loadProgressComplete()
22382238
{
2239-
NetCommandMsg *msg = newInstance(NetCommandMsg);
2239+
NetLoadCompleteCommandMsg *msg = newInstance(NetLoadCompleteCommandMsg);
22402240
msg->setPlayerID( m_localSlot );
22412241
if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) {
22422242
msg->setID(GenerateNextCommandID());
22432243
}
2244-
msg->setNetCommandType(NETCOMMANDTYPE_LOADCOMPLETE);
22452244
processLoadComplete(msg);
22462245
sendLocalCommand(msg, 0xff ^ (1 << m_localSlot));
22472246

@@ -2250,9 +2249,8 @@ void ConnectionManager::loadProgressComplete()
22502249

22512250
void ConnectionManager::sendTimeOutGameStart()
22522251
{
2253-
NetCommandMsg *msg = newInstance(NetCommandMsg);
2252+
NetTimeOutGameStartCommandMsg *msg = newInstance(NetTimeOutGameStartCommandMsg);
22542253
msg->setPlayerID( m_localSlot );
2255-
msg->setNetCommandType(NETCOMMANDTYPE_TIMEOUTSTART);
22562254
if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) {
22572255
msg->setID(GenerateNextCommandID());
22582256
}

GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,12 +2222,11 @@ void ConnectionManager::updateLoadProgress( Int progress )
22222222

22232223
void ConnectionManager::loadProgressComplete()
22242224
{
2225-
NetCommandMsg *msg = newInstance(NetCommandMsg);
2225+
NetLoadCompleteCommandMsg *msg = newInstance(NetLoadCompleteCommandMsg);
22262226
msg->setPlayerID( m_localSlot );
22272227
if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) {
22282228
msg->setID(GenerateNextCommandID());
22292229
}
2230-
msg->setNetCommandType(NETCOMMANDTYPE_LOADCOMPLETE);
22312230
processLoadComplete(msg);
22322231
sendLocalCommand(msg, 0xff ^ (1 << m_localSlot));
22332232

@@ -2236,9 +2235,8 @@ void ConnectionManager::loadProgressComplete()
22362235

22372236
void ConnectionManager::sendTimeOutGameStart()
22382237
{
2239-
NetCommandMsg *msg = newInstance(NetCommandMsg);
2238+
NetTimeOutGameStartCommandMsg *msg = newInstance(NetTimeOutGameStartCommandMsg);
22402239
msg->setPlayerID( m_localSlot );
2241-
msg->setNetCommandType(NETCOMMANDTYPE_TIMEOUTSTART);
22422240
if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) {
22432241
msg->setID(GenerateNextCommandID());
22442242
}

0 commit comments

Comments
 (0)