Skip to content

Commit

Permalink
Fix remaining MSVC warnings in network code
Browse files Browse the repository at this point in the history
  • Loading branch information
obligaron committed Dec 16, 2023
1 parent 2421de4 commit 0b8c59f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Source/dvlnet/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ bool base::SNetGetOwnerTurnsWaiting(uint32_t *turns)
plr_t owner = GetOwner();
PlayerState &playerState = playerStateTable_[owner];
std::deque<turn_t> &turnQueue = playerState.turnQueue;
*turns = turnQueue.size();
*turns = static_cast<uint32_t>(turnQueue.size());

return true;
}
Expand All @@ -521,7 +521,7 @@ bool base::SNetGetTurnsInTransit(uint32_t *turns)
{
PlayerState &playerState = playerStateTable_[plr_self];
std::deque<turn_t> &turnQueue = playerState.turnQueue;
*turns = turnQueue.size();
*turns = static_cast<uint32_t>(turnQueue.size());
return true;
}

Expand Down
11 changes: 6 additions & 5 deletions Source/dvlnet/frame_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ tl::expected<buffer_t, PacketError> frame_queue::Read(framesize_t s)
return tl::make_unexpected(FrameQueueError());
buffer_t ret;
while (s > 0 && s >= buffer_deque.front().size()) {
s -= buffer_deque.front().size();
current_size -= buffer_deque.front().size();
framesize_t bufferSize = static_cast<framesize_t>(buffer_deque.front().size());
s -= bufferSize;
current_size -= bufferSize;
ret.insert(ret.end(),
buffer_deque.front().begin(),
buffer_deque.front().end());
Expand All @@ -49,7 +50,7 @@ tl::expected<buffer_t, PacketError> frame_queue::Read(framesize_t s)

void frame_queue::Write(buffer_t buf)
{
current_size += buf.size();
current_size += static_cast<framesize_t>(buf.size());
buffer_deque.push_back(std::move(buf));
}

Expand Down Expand Up @@ -80,9 +81,9 @@ tl::expected<buffer_t, PacketError> frame_queue::ReadPacket()
tl::expected<buffer_t, PacketError> frame_queue::MakeFrame(buffer_t packetbuf)
{
buffer_t ret;
if (packetbuf.size() > max_frame_size)
framesize_t size = static_cast<framesize_t>(packetbuf.size());
if (size > max_frame_size)
return tl::make_unexpected("Buffer exceeds maximum frame size");
framesize_t size = packetbuf.size();
ret.insert(ret.end(), packet_out::begin(size), packet_out::end(size));
ret.insert(ret.end(), packetbuf.begin(), packetbuf.end());
return ret;
Expand Down
4 changes: 2 additions & 2 deletions Source/dvlnet/protocol_zt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ std::string protocol_zt::make_default_gamename()
std::string ret;
std::string allowedChars = "abcdefghkopqrstuvwxyz";
std::random_device rd;
std::uniform_int_distribution<int> dist(0, allowedChars.size() - 1);
for (int i = 0; i < 5; ++i) {
std::uniform_int_distribution<size_t> dist(0, allowedChars.size() - 1);
for (size_t i = 0; i < 5; ++i) {
ret += allowedChars.at(dist(rd));
}
return ret;
Expand Down
2 changes: 1 addition & 1 deletion Source/storm/storm_net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct _SNETEVENT {
uint32_t eventid;
uint32_t playerid;
void *data;
uint32_t databytes;
size_t databytes;
};

#define PS_CONNECTED 0x10000
Expand Down

0 comments on commit 0b8c59f

Please sign in to comment.