Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

Commit

Permalink
Linux build fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flone-dnb committed Mar 25, 2020
1 parent c6a55da commit 49ccdb8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Model/ServerService/serverservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ void ServerService::sendMessageToAll(const std::string &sMessage)

unsigned short int iMessageSize = static_cast<unsigned short>(sMessage.size());

std::memcpy(vBuffer + 1, &iMessageSize, sizeof(unsigned short));
memcpy(vBuffer + 1, &iMessageSize, sizeof(unsigned short));

int iIndex = 1 + sizeof(unsigned short);

std::memcpy(vBuffer + iIndex, sMessage.c_str(), sMessage.size());
memcpy(vBuffer + iIndex, sMessage.c_str(), sMessage.size());
iIndex += sMessage.size();

int iSentSize = 0;
Expand Down Expand Up @@ -1657,7 +1657,7 @@ void ServerService::checkRoomSettings(UserStruct *userToListen)
vSendBuffer[0] = RC_PASSWORD_REQ;
vSendBuffer[1] = static_cast<char>(sRoomNameStr.size());

std::memcpy(vSendBuffer + 2, sRoomNameStr.c_str(), sRoomNameStr.size());
memcpy(vSendBuffer + 2, sRoomNameStr.c_str(), sRoomNameStr.size());

send(userToListen->userTCPSocket, vSendBuffer, 2 + static_cast<int>(sRoomNameStr.size()), 0);
}
Expand All @@ -1675,7 +1675,7 @@ void ServerService::userEntersRoom(UserStruct *userToListen, std::string sRoomNa
vSendBuffer[0] = RC_CAN_ENTER_ROOM;
vSendBuffer[1] = static_cast<char>(sRoomName.size());

std::memcpy(vSendBuffer + 2, sRoomName.c_str(), sRoomName.size());
memcpy(vSendBuffer + 2, sRoomName.c_str(), sRoomName.size());

send(userToListen->userTCPSocket, vSendBuffer, 2 + static_cast<int>(sRoomName.size()), 0);

Expand All @@ -1694,13 +1694,13 @@ void ServerService::userEntersRoom(UserStruct *userToListen, std::string sRoomNa

iIndex = 2;

std::memcpy(vResendBuffer + iIndex, userToListen->userName.c_str(), userToListen->userName.size());
memcpy(vResendBuffer + iIndex, userToListen->userName.c_str(), userToListen->userName.size());
iIndex += userToListen->userName.size();

vResendBuffer[iIndex] = static_cast<char>(sRoomName.size());
iIndex += 1;

std::memcpy(vResendBuffer + iIndex, sRoomName.c_str(), sRoomName.size());
memcpy(vResendBuffer + iIndex, sRoomName.c_str(), sRoomName.size());
iIndex += sRoomName.size();

for (size_t i = 0; i < users.size(); i++)
Expand Down Expand Up @@ -1734,7 +1734,7 @@ void ServerService::moveRoom(const std::string &sRoomName, bool bMoveUp)
vBuffer[0] = RC_SERVER_MOVED_ROOM;
vBuffer[1] = static_cast<char>(sRoomName.size());

std::memcpy(vBuffer + 2, sRoomName.c_str(), sRoomName.size());
memcpy(vBuffer + 2, sRoomName.c_str(), sRoomName.size());
vBuffer[2 + sRoomName.size()] = bMoveUp;

int iSizeToSend = 3 + static_cast<int>(sRoomName.size());
Expand Down Expand Up @@ -1776,7 +1776,7 @@ void ServerService::deleteRoom(const std::string &sRoomName)
vBuffer[0] = RC_SERVER_DELETES_ROOM;
vBuffer[1] = static_cast<char>(sRoomName.size());

std::memcpy(vBuffer + 2, sRoomName.c_str(), sRoomName.size());
memcpy(vBuffer + 2, sRoomName.c_str(), sRoomName.size());

int iSizeToSend = 2 + static_cast<int>(sRoomName.size());
int iSentSize = 0;
Expand Down Expand Up @@ -1833,13 +1833,13 @@ void ServerService::createRoom(const std::string &sName, size_t iMaxUsers)

vBuffer[1] = static_cast<char>(sName.size());

std::memcpy(vBuffer + 2, sName.c_str(), sName.size());
memcpy(vBuffer + 2, sName.c_str(), sName.size());

int iIndex = 2 + static_cast<int>(sName.size());

unsigned int iMax = static_cast<unsigned int>(iMaxUsers);

std::memcpy(vBuffer + iIndex, &iMax, sizeof(unsigned int));
memcpy(vBuffer + iIndex, &iMax, sizeof(unsigned int));
iIndex += static_cast<int>(sizeof(unsigned int));


Expand Down Expand Up @@ -1882,17 +1882,17 @@ void ServerService::changeRoomSettings(const std::string &sOldName, const std::s

int iIndex = 2;

std::memcpy(vBuffer + iIndex, sOldName.c_str(), sOldName.size());
memcpy(vBuffer + iIndex, sOldName.c_str(), sOldName.size());
iIndex += sOldName.size();

vBuffer[iIndex] = static_cast<char>(sNewName.size());
iIndex++;

std::memcpy(vBuffer + iIndex, sNewName.c_str(), sNewName.size());
memcpy(vBuffer + iIndex, sNewName.c_str(), sNewName.size());
iIndex += sNewName.size();

unsigned int iMax = static_cast<unsigned int>(iMaxUsers);
std::memcpy(vBuffer + iIndex, &iMax, sizeof(unsigned int));
memcpy(vBuffer + iIndex, &iMax, sizeof(unsigned int));
iIndex += sizeof(unsigned int);


Expand Down

0 comments on commit 49ccdb8

Please sign in to comment.