Skip to content

Commit

Permalink
Some type fixes for packets and removed problematic ranges code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mercere99 committed Dec 10, 2023
1 parent a614d15 commit 7281711
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/Interfaces/MainInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace i_2D {

void ChooseTexture();

bool SetLargeGrid(bool b){ mGridSizeLarge = b; }
void SetLargeGrid(bool b){ mGridSizeLarge = b; }

void Notify(const std::string & message,
const std::string & /*msg_type*/="none") override
Expand Down
2 changes: 1 addition & 1 deletion source/Interfaces/NetWorth/client/ClientInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace netWorth{
itemMap, agentMap);

// Send instruction to server
sendPkt << actionID;
sendPkt << static_cast<uint64_t>(actionID);
sendPacket(sendPkt, m_ip.value(), m_port);

m_manager->clearActionMap();
Expand Down
2 changes: 1 addition & 1 deletion source/Interfaces/NetWorth/client/ClientManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace netWorth{
* @param pkt received packet
*/
void packetToActionMap(sf::Packet pkt) {
size_t dataSize, agentID, actionID;
uint64_t dataSize, agentID, actionID;
pkt >> dataSize;
for (size_t i = 0; i < dataSize; i++) {
pkt >> agentID >> actionID;
Expand Down
2 changes: 1 addition & 1 deletion source/Interfaces/NetWorth/server/ServerInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace netWorth

// receive player input
sf::Packet recvPkt;
size_t actionID;
uint64_t actionID;
receivePacket(recvPkt, m_ip, m_port);
recvPkt >> actionID;

Expand Down
6 changes: 3 additions & 3 deletions source/Interfaces/NetWorth/server/ServerManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ namespace netWorth{
sf::Packet pkt;

// serialize action map
pkt << m_action_map.size();
for (auto pair: m_action_map) {
pkt << pair.first << pair.second;
pkt << static_cast<uint64_t>(m_action_map.size());
for (auto [agent_id, action_id]: m_action_map) {
pkt << static_cast<uint64_t>(agent_id) << static_cast<uint64_t>(action_id);
}

return pkt;
Expand Down
10 changes: 7 additions & 3 deletions source/Worlds/ProgramExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ namespace worldlang {
} while (!(has<Identifier>(values.back())
&& static_cast<std::string>(as<Identifier>(values.back())) == "__INTERNAL_ENDARGS"));
values.pop_back(); // don't keep that one
std::ranges::reverse(values);
std::reverse(values.begin(), values.end());
return values;
}

Expand Down Expand Up @@ -657,8 +657,12 @@ namespace worldlang {
}
// Convert to identifiers specifically
std::vector< Identifier > identifiers;
std::ranges::transform(identifier_values, std::back_inserter(identifiers), [this](const Value& v){ return as<Identifier>(v); });
//ex. a,b,c=1,2,3 becomes the follwoing units
std::transform(
identifier_values.begin(), identifier_values.end(),
std::back_inserter(identifiers),
[this](const Value& v){ return as<Identifier>(v); }
);
//ex. a,b,c=1,2,3 becomes the following units
// . a b c . 1 2 3 =
// v: 3 2 1
// i: c b a
Expand Down
2 changes: 1 addition & 1 deletion source/group_5_client_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void terminateClient() {
// Request connection to server
sf::Packet sendPkt;
std::optional<sf::IpAddress> ipAddr = sf::IpAddress::resolve(clientKillIP);
sendPkt << static_cast<size_t>(9999);
sendPkt << static_cast<uint64_t>(9999);
if (clientKillSocket->send(sendPkt, ipAddr.value(), clientKillPort) != sf::Socket::Status::Done) {
std::cerr << "Failed to send" << std::endl;
}
Expand Down

0 comments on commit 7281711

Please sign in to comment.