Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Generals/Code/GameEngine/Include/Common/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ typedef enum
} LanguageID;

#define GameStrcpy wcscpy
#define GameStrncpy wcsncpy
#define GameStrlen wcslen
#define GameStrcat wcscat
#define GameStrcmp wcscmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ WindowMsgHandledType ScoreScreenSystem( GameWindow *window, UnsignedInt msg,
req.arg.addbuddy.id = playerID;
UnicodeString buddyAddstr;
buddyAddstr = TheGameText->fetch("GUI:BuddyAddReq");
wcsncpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
req.arg.addbuddy.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
TheGameSpyBuddyMessageQueue->addRequest(req);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ WindowMsgHandledType BuddyControlSystem( GameWindow *window, UnsignedInt msg,
// Send the message
BuddyRequest req;
req.buddyRequestType = BuddyRequest::BUDDYREQUEST_MESSAGE;
wcsncpy(req.arg.message.text, txtInput.str(), MAX_BUDDY_CHAT_LEN);
req.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(req.arg.message.text, txtInput.str(), MAX_BUDDY_CHAT_LEN);
req.arg.message.recipient = selectedProfile;
TheGameSpyBuddyMessageQueue->addRequest(req);

Expand Down Expand Up @@ -1184,8 +1183,7 @@ void RequestBuddyAdd(Int profileID, AsciiString nick)
req.arg.addbuddy.id = profileID;
UnicodeString buddyAddstr;
buddyAddstr = TheGameText->fetch("GUI:BuddyAddReq");
wcsncpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
req.arg.addbuddy.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
TheGameSpyBuddyMessageQueue->addRequest(req);

UnicodeString s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,7 @@ void BuddyThreadClass::messageCallback( GPConnection *con, GPRecvBuddyMessageArg
gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getNickForMessage, &messageResponse);

std::wstring s = MultiByteToWideCharSingleLine( arg->message );
wcsncpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN);
messageResponse.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN);
messageResponse.arg.message.date = arg->date;
DEBUG_LOG(("Got a buddy message from %d [%ls]", arg->profile, s.c_str()));
TheGameSpyBuddyMessageQueue->addResponse( messageResponse );
Expand Down Expand Up @@ -629,8 +628,7 @@ void BuddyThreadClass::requestCallback( GPConnection *con, GPRecvBuddyRequestArg
gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getInfoResponseForRequest, &response);

std::wstring s = MultiByteToWideCharSingleLine( arg->reason );
wcsncpy(response.arg.request.text, s.c_str(), GP_REASON_LEN);
response.arg.request.text[GP_REASON_LEN-1] = 0;
wcslcpy(response.arg.request.text, s.c_str(), GP_REASON_LEN);

TheGameSpyBuddyMessageQueue->addResponse( response );
}
Expand Down
42 changes: 14 additions & 28 deletions Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ void LANAPI::update( void )
LANMessage msg;
fillInLANMessage( &msg );
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
wcsncpy(msg.name, m_currentGame->getPlayerName(0).str(), g_lanPlayerNameLength);
msg.name[g_lanPlayerNameLength] = 0;
wcslcpy(msg.name, m_currentGame->getPlayerName(0).str(), ARRAY_SIZE(msg.name));
handleRequestGameLeave(&msg, m_currentGame->getIP(0));
UnicodeString text;
text = TheGameText->fetch("LAN:HostNotResponding");
Expand All @@ -538,8 +537,7 @@ void LANAPI::update( void )
UnicodeString theStr;
theStr.format(TheGameText->fetch("LAN:PlayerDropped"), m_currentGame->getPlayerName(p).str());
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
wcsncpy(msg.name, m_currentGame->getPlayerName(p).str(), g_lanPlayerNameLength);
msg.name[g_lanPlayerNameLength] = 0;
wcslcpy(msg.name, m_currentGame->getPlayerName(p).str(), ARRAY_SIZE(msg.name));
handleRequestGameLeave(&msg, m_currentGame->getIP(p));
OnChat(UnicodeString::TheEmptyString, m_localIP, theStr, LANCHAT_SYSTEM);
}
Expand Down Expand Up @@ -670,8 +668,7 @@ void LANAPI::RequestGameJoinDirectConnect(UnsignedInt ipaddress)
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_INFO;
fillInLANMessage(&msg);
msg.PlayerInfo.ip = GetLocalIP();
wcsncpy(msg.PlayerInfo.playerName, m_name.str(), m_name.getLength());
msg.PlayerInfo.playerName[m_name.getLength()] = 0;
wcslcpy(msg.PlayerInfo.playerName, m_name.str(), ARRAY_SIZE(msg.PlayerInfo.playerName));

sendMessage(&msg, ipaddress);

Expand All @@ -684,8 +681,7 @@ void LANAPI::RequestGameLeave( void )
LANMessage msg;
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
fillInLANMessage( &msg );
wcsncpy(msg.GameToLeave.gameName, (m_currentGame)?m_currentGame->getName().str():L"", g_lanGameNameLength);
msg.GameToLeave.gameName[g_lanGameNameLength] = 0;
wcslcpy(msg.PlayerInfo.playerName, m_name.str(), ARRAY_SIZE(msg.PlayerInfo.playerName));
sendMessage(&msg);
m_transport->update(); // Send immediately, before OnPlayerLeave below resets everything.

Expand Down Expand Up @@ -717,8 +713,7 @@ void LANAPI::RequestGameAnnounce( void )

AsciiString gameOpts = GameInfoToAsciiString(m_currentGame);
strlcpy(reply.GameInfo.options,gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options));
wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
reply.GameInfo.gameName[g_lanGameNameLength] = 0;
wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName));
reply.GameInfo.inProgress = m_currentGame->isGameInProgress();
reply.GameInfo.isDirectConnect = m_currentGame->getIsDirectConnect();

Expand All @@ -736,8 +731,7 @@ void LANAPI::RequestAccept( void )
fillInLANMessage( &msg );
msg.LANMessageType = LANMessage::MSG_SET_ACCEPT;
msg.Accept.isAccepted = true;
wcsncpy(msg.Accept.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
msg.Accept.gameName[g_lanGameNameLength] = 0;
wcslcpy(msg.Accept.gameName, m_currentGame->getName().str(), ARRAY_SIZE(msg.Accept.gameName));
sendMessage(&msg);
}

Expand All @@ -750,8 +744,7 @@ void LANAPI::RequestHasMap( void )
fillInLANMessage( &msg );
msg.LANMessageType = LANMessage::MSG_MAP_AVAILABILITY;
msg.MapStatus.hasMap = m_currentGame->getSlot(m_currentGame->getLocalSlotNum())->hasMap();
wcsncpy(msg.MapStatus.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
msg.MapStatus.gameName[g_lanGameNameLength] = 0;
wcslcpy(msg.MapStatus.gameName, m_currentGame->getName().str(), ARRAY_SIZE(msg.MapStatus.gameName));
CRC mapNameCRC;
//mapNameCRC.computeCRC(m_currentGame->getMap().str(), m_currentGame->getMap().getLength());
AsciiString portableMapName = TheGameState->realMapPathToPortableMapPath(m_currentGame->getMap());
Expand Down Expand Up @@ -788,12 +781,10 @@ void LANAPI::RequestChat( UnicodeString message, ChatType format )
{
LANMessage msg;
fillInLANMessage( &msg );
wcsncpy(msg.Chat.gameName, (m_currentGame)?m_currentGame->getName().str():L"", g_lanGameNameLength);
msg.Chat.gameName[g_lanGameNameLength] = 0;
wcslcpy(msg.Chat.gameName, (m_currentGame) ? m_currentGame->getName().str() : L"", ARRAY_SIZE(msg.Chat.gameName));
msg.LANMessageType = LANMessage::MSG_CHAT;
msg.Chat.chatType = format;
wcsncpy(msg.Chat.message, message.str(), g_lanMaxChatLength);
msg.Chat.message[g_lanMaxChatLength] = 0;
wcslcpy(msg.Chat.message, message.str(), ARRAY_SIZE(msg.Chat.message));
sendMessage(&msg);

OnChat(m_name, m_localIP, message, format);
Expand Down Expand Up @@ -943,8 +934,7 @@ void LANAPI::RequestGameCreate( UnicodeString gameName, Bool isDirectConnect )
//RequestSlotList();
/*
LANMessage msg;
wcsncpy(msg.name, m_name.str(), g_lanPlayerNameLength);
msg.name[g_lanPlayerNameLength] = 0;
wcslcpy(msg.name, m_name.str(), ARRAY_SIZE(msg.name));
wcscpy(msg.GameInfo.gameName, myGame->getName().str());
for (player=0; player<MAX_SLOTS; ++player)
{
Expand Down Expand Up @@ -1015,18 +1005,15 @@ void LANAPI::RequestSlotList( void )

LANMessage reply;
reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
wcsncpy(reply.name, m_name.str(), g_lanPlayerNameLength);
reply.name[g_lanPlayerNameLength] = 0;
wcslcpy(reply.name, m_name.str(), ARRAY_SIZE(reply.name));
int player;
for (player = 0; player < MAX_SLOTS; ++player)
{
wcsncpy(reply.GameInfo.name[player], m_currentGame->getPlayerName(player).str(), g_lanPlayerNameLength);
reply.GameInfo.name[player][g_lanPlayerNameLength] = 0;
wcslcpy(reply.GameInfo.name[player], m_currentGame->getPlayerName(player).str(), ARRAY_SIZE(reply.GameInfo.name[player]));
reply.GameInfo.ip[player] = m_currentGame->getIP(player);
reply.GameInfo.playerAccepted[player] = m_currentGame->getSlot(player)->isAccepted();
}
wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
reply.GameInfo.gameName[g_lanGameNameLength] = 0;
wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName));
reply.GameInfo.inProgress = m_currentGame->isGameInProgress();

sendMessage(&reply);
Expand Down Expand Up @@ -1082,8 +1069,7 @@ void LANAPI::fillInLANMessage( LANMessage *msg )
if (!msg)
return;

wcsncpy(msg->name, m_name.str(), g_lanPlayerNameLength);
msg->name[g_lanPlayerNameLength] = 0;
wcslcpy(msg->name, m_name.str(), ARRAY_SIZE(msg->name));
strlcpy(msg->userName, m_userName.str(), ARRAY_SIZE(msg->userName));
strlcpy(msg->hostName, m_hostName.str(), ARRAY_SIZE(msg->hostName));
}
Expand Down
12 changes: 4 additions & 8 deletions Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void LANAPI::handleRequestLocations( LANMessage *msg, UnsignedInt senderIP )
reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
AsciiString gameOpts = GenerateGameOptionsString();
strlcpy(reply.GameInfo.options, gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options));
wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
reply.GameInfo.gameName[g_lanGameNameLength] = 0;
wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName));
reply.GameInfo.inProgress = m_currentGame->isGameInProgress();

sendMessage(&reply);
Expand Down Expand Up @@ -194,8 +193,7 @@ void LANAPI::handleRequestGameInfo( LANMessage *msg, UnsignedInt senderIP )

AsciiString gameOpts = GameInfoToAsciiString(m_currentGame);
strlcpy(reply.GameInfo.options,gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options));
wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
reply.GameInfo.gameName[g_lanGameNameLength] = 0;
wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName));
reply.GameInfo.inProgress = m_currentGame->isGameInProgress();
reply.GameInfo.isDirectConnect = m_currentGame->getIsDirectConnect();

Expand Down Expand Up @@ -314,8 +312,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
{
// OK, add him in.
reply.LANMessageType = LANMessage::MSG_JOIN_ACCEPT;
wcsncpy(reply.GameJoined.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
reply.GameJoined.gameName[g_lanGameNameLength] = 0;
wcslcpy(reply.GameJoined.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameJoined.gameName));
reply.GameJoined.slotPosition = player;
reply.GameJoined.gameIP = m_localIP;
reply.GameJoined.playerIP = senderIP;
Expand All @@ -339,8 +336,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
if (canJoin && player == MAX_SLOTS)
{
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
wcsncpy(reply.GameNotJoined.gameName, m_currentGame->getName().str(), g_lanGameNameLength);
reply.GameNotJoined.gameName[g_lanGameNameLength] = 0;
wcslcpy(reply.GameNotJoined.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameNotJoined.gameName));
reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_FULL;
reply.GameNotJoined.gameIP = m_localIP;
reply.GameNotJoined.playerIP = senderIP;
Expand Down
1 change: 0 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/Common/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ typedef enum
} LanguageID;

#define GameStrcpy wcscpy
#define GameStrncpy wcsncpy
#define GameStrlen wcslen
#define GameStrcat wcscat
#define GameStrcmp wcscmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,7 @@ WindowMsgHandledType ScoreScreenSystem( GameWindow *window, UnsignedInt msg,
req.arg.addbuddy.id = playerID;
UnicodeString buddyAddstr;
buddyAddstr = TheGameText->fetch("GUI:BuddyAddReq");
wcsncpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
req.arg.addbuddy.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
TheGameSpyBuddyMessageQueue->addRequest(req);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ WindowMsgHandledType BuddyControlSystem( GameWindow *window, UnsignedInt msg,
// Send the message
BuddyRequest req;
req.buddyRequestType = BuddyRequest::BUDDYREQUEST_MESSAGE;
wcsncpy(req.arg.message.text, txtInput.str(), MAX_BUDDY_CHAT_LEN);
req.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(req.arg.message.text, txtInput.str(), MAX_BUDDY_CHAT_LEN);
req.arg.message.recipient = selectedProfile;
TheGameSpyBuddyMessageQueue->addRequest(req);

Expand Down Expand Up @@ -1185,8 +1184,7 @@ void RequestBuddyAdd(Int profileID, AsciiString nick)
req.arg.addbuddy.id = profileID;
UnicodeString buddyAddstr;
buddyAddstr = TheGameText->fetch("GUI:BuddyAddReq");
wcsncpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
req.arg.addbuddy.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN);
TheGameSpyBuddyMessageQueue->addRequest(req);

UnicodeString s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,7 @@ void BuddyThreadClass::messageCallback( GPConnection *con, GPRecvBuddyMessageArg
gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getNickForMessage, &messageResponse);

std::wstring s = MultiByteToWideCharSingleLine( arg->message );
wcsncpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN);
messageResponse.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0;
wcslcpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN);
messageResponse.arg.message.date = arg->date;
DEBUG_LOG(("Got a buddy message from %d [%ls]", arg->profile, s.c_str()));
TheGameSpyBuddyMessageQueue->addResponse( messageResponse );
Expand Down Expand Up @@ -629,8 +628,7 @@ void BuddyThreadClass::requestCallback( GPConnection *con, GPRecvBuddyRequestArg
gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getInfoResponseForRequest, &response);

std::wstring s = MultiByteToWideCharSingleLine( arg->reason );
wcsncpy(response.arg.request.text, s.c_str(), GP_REASON_LEN);
response.arg.request.text[GP_REASON_LEN-1] = 0;
wcslcpy(response.arg.request.text, s.c_str(), GP_REASON_LEN);

TheGameSpyBuddyMessageQueue->addResponse( response );
}
Expand Down
Loading
Loading