mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-14 00:02:31 +00:00
replaced msvc __int64 to int64_t, updated Int64ToString and TryParseInt64 to use int64_t instead
This commit is contained in:
parent
78d4bc80cf
commit
7bcfedf84a
|
|
@ -12,6 +12,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace ServerRuntime
|
namespace ServerRuntime
|
||||||
{
|
{
|
||||||
|
|
@ -95,11 +96,9 @@ static std::string IntToString(int value)
|
||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string Int64ToString(__int64 value)
|
static std::string Int64ToString(int64_t value)
|
||||||
{
|
{
|
||||||
char buffer[64] = {};
|
return std::to_string(value);
|
||||||
_i64toa_s(value, buffer, sizeof(buffer), 10);
|
|
||||||
return std::string(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ClampInt(int value, int minValue, int maxValue)
|
static int ClampInt(int value, int minValue, int maxValue)
|
||||||
|
|
@ -160,7 +159,7 @@ static bool TryParseInt(const std::string &value, int *outValue)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TryParseInt64(const std::string &value, __int64 *outValue)
|
static bool TryParseInt64(const std::string &value, int64_t *outValue)
|
||||||
{
|
{
|
||||||
if (outValue == NULL)
|
if (outValue == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -174,13 +173,14 @@ static bool TryParseInt64(const std::string &value, __int64 *outValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
__int64 parsed = _strtoi64(trimmed.c_str(), &end, 10);
|
long long parsed = strtoll(trimmed.c_str(), &end, 10);
|
||||||
|
|
||||||
if (end == trimmed.c_str() || *end != 0)
|
if (end == trimmed.c_str() || *end != 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*outValue = parsed;
|
*outValue = static_cast<int64_t>(parsed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -498,7 +498,7 @@ static std::string ReadNormalizedStringProperty(
|
||||||
static bool ReadNormalizedOptionalInt64Property(
|
static bool ReadNormalizedOptionalInt64Property(
|
||||||
std::unordered_map<std::string, std::string> *properties,
|
std::unordered_map<std::string, std::string> *properties,
|
||||||
const char *key,
|
const char *key,
|
||||||
__int64 *outValue,
|
int64_t *outValue,
|
||||||
bool *shouldWrite)
|
bool *shouldWrite)
|
||||||
{
|
{
|
||||||
std::string raw = TrimAscii((*properties)[key]);
|
std::string raw = TrimAscii((*properties)[key]);
|
||||||
|
|
@ -515,7 +515,7 @@ static bool ReadNormalizedOptionalInt64Property(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 parsed = 0;
|
int64_t parsed = 0;
|
||||||
if (!TryParseInt64(raw, &parsed))
|
if (!TryParseInt64(raw, &parsed))
|
||||||
{
|
{
|
||||||
(*properties)[key] = "";
|
(*properties)[key] = "";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue