Skip to content

Commit 5385f32

Browse files
committed
Clean up IpAddress implementation
1 parent fd8e6a0 commit 5385f32

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/CSFML/Network/IpAddress.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,13 @@ namespace
3737
// Helper function for converting a SFML address to a CSFML one
3838
[[nodiscard]] sfIpAddress fromSFMLAddress(std::optional<sf::IpAddress> address)
3939
{
40-
sfIpAddress result{};
41-
42-
if (address)
43-
{
44-
std::strncpy(result.address, address->toString().c_str(), 15);
45-
}
40+
if (!address)
41+
return sfIpAddress_None;
4642

43+
sfIpAddress result{};
44+
std::strncpy(result.address, address->toString().c_str(), 15);
4745
return result;
4846
}
49-
50-
// Helper function for converting a CSFML address to a SFML one
51-
[[nodiscard]] std::optional<sf::IpAddress> toSFMLAddress(sfIpAddress address)
52-
{
53-
return sf::IpAddress::resolve(address.address);
54-
}
5547
} // namespace
5648

5749

@@ -104,7 +96,7 @@ void sfIpAddress_toString(sfIpAddress address, char* string)
10496
////////////////////////////////////////////////////////////
10597
uint32_t sfIpAddress_toInteger(sfIpAddress address)
10698
{
107-
auto sfmlAddress = toSFMLAddress(address);
99+
const auto sfmlAddress = sf::IpAddress::resolve(address.address);
108100
return sfmlAddress ? sfmlAddress->toInteger() : 0;
109101
}
110102

0 commit comments

Comments
 (0)