mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-15 22:05:07 -05:00
Random misc. warning fixes and cleanups
- Fix unused c_sand member warning in Valleys Mapgen - Fix some code style - Make some std::string params const ref
This commit is contained in:
parent
33b874fea3
commit
27aff22a9b
@ -125,7 +125,6 @@ private:
|
|||||||
Noise *noise_valley_profile;
|
Noise *noise_valley_profile;
|
||||||
|
|
||||||
content_t c_lava_source;
|
content_t c_lava_source;
|
||||||
content_t c_sand;
|
|
||||||
|
|
||||||
float terrainLevelAtPoint(s16 x, s16 z);
|
float terrainLevelAtPoint(s16 x, s16 z);
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ std::string wide_to_narrow(const std::wstring &wcs)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string urlencode(std::string str)
|
std::string urlencode(const std::string &str)
|
||||||
{
|
{
|
||||||
// Encodes non-unreserved URI characters by a percent sign
|
// Encodes non-unreserved URI characters by a percent sign
|
||||||
// followed by two hex digits. See RFC 3986, section 2.3.
|
// followed by two hex digits. See RFC 3986, section 2.3.
|
||||||
@ -322,17 +322,18 @@ std::string urlencode(std::string str)
|
|||||||
std::ostringstream oss(std::ios::binary);
|
std::ostringstream oss(std::ios::binary);
|
||||||
for (u32 i = 0; i < str.size(); i++) {
|
for (u32 i = 0; i < str.size(); i++) {
|
||||||
unsigned char c = str[i];
|
unsigned char c = str[i];
|
||||||
if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~')
|
if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~') {
|
||||||
oss << c;
|
oss << c;
|
||||||
else
|
} else {
|
||||||
oss << "%"
|
oss << "%"
|
||||||
<< url_hex_chars[(c & 0xf0) >> 4]
|
<< url_hex_chars[(c & 0xf0) >> 4]
|
||||||
<< url_hex_chars[c & 0x0f];
|
<< url_hex_chars[c & 0x0f];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string urldecode(std::string str)
|
std::string urldecode(const std::string &str)
|
||||||
{
|
{
|
||||||
// Inverse of urlencode
|
// Inverse of urlencode
|
||||||
std::ostringstream oss(std::ios::binary);
|
std::ostringstream oss(std::ios::binary);
|
||||||
@ -343,18 +344,20 @@ std::string urldecode(std::string str)
|
|||||||
hex_digit_decode(str[i+2], lowvalue)) {
|
hex_digit_decode(str[i+2], lowvalue)) {
|
||||||
oss << (char) ((highvalue << 4) | lowvalue);
|
oss << (char) ((highvalue << 4) | lowvalue);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
oss << str[i];
|
oss << str[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 readFlagString(std::string str, const FlagDesc *flagdesc, u32 *flagmask)
|
u32 readFlagString(std::string str, const FlagDesc *flagdesc, u32 *flagmask)
|
||||||
{
|
{
|
||||||
u32 result = 0, mask = 0;
|
u32 result = 0;
|
||||||
|
u32 mask = 0;
|
||||||
char *s = &str[0];
|
char *s = &str[0];
|
||||||
char *flagstr, *strpos = NULL;
|
char *flagstr;
|
||||||
|
char *strpos = NULL;
|
||||||
|
|
||||||
while ((flagstr = strtok_r(s, ",", &strpos))) {
|
while ((flagstr = strtok_r(s, ",", &strpos))) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
@ -77,8 +77,8 @@ wchar_t *narrow_to_wide_c(const char *str);
|
|||||||
std::wstring narrow_to_wide(const std::string &mbs);
|
std::wstring narrow_to_wide(const std::string &mbs);
|
||||||
std::string wide_to_narrow(const std::wstring &wcs);
|
std::string wide_to_narrow(const std::wstring &wcs);
|
||||||
|
|
||||||
std::string urlencode(std::string str);
|
std::string urlencode(const std::string &str);
|
||||||
std::string urldecode(std::string str);
|
std::string urldecode(const std::string &str);
|
||||||
u32 readFlagString(std::string str, const FlagDesc *flagdesc, u32 *flagmask);
|
u32 readFlagString(std::string str, const FlagDesc *flagdesc, u32 *flagmask);
|
||||||
std::string writeFlagString(u32 flags, const FlagDesc *flagdesc, u32 flagmask);
|
std::string writeFlagString(u32 flags, const FlagDesc *flagdesc, u32 flagmask);
|
||||||
size_t mystrlcpy(char *dst, const char *src, size_t size);
|
size_t mystrlcpy(char *dst, const char *src, size_t size);
|
||||||
|
Loading…
Reference in New Issue
Block a user