mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-04-30 10:55:04 +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 <stdlib.h>
|
||||
#include <unordered_map>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ServerRuntime
|
||||
{
|
||||
|
|
@ -95,11 +96,9 @@ static std::string IntToString(int value)
|
|||
return std::string(buffer);
|
||||
}
|
||||
|
||||
static std::string Int64ToString(__int64 value)
|
||||
static std::string Int64ToString(int64_t value)
|
||||
{
|
||||
char buffer[64] = {};
|
||||
_i64toa_s(value, buffer, sizeof(buffer), 10);
|
||||
return std::string(buffer);
|
||||
return std::to_string(value);
|
||||
}
|
||||
|
||||
static int ClampInt(int value, int minValue, int maxValue)
|
||||
|
|
@ -160,7 +159,7 @@ static bool TryParseInt(const std::string &value, int *outValue)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool TryParseInt64(const std::string &value, __int64 *outValue)
|
||||
static bool TryParseInt64(const std::string &value, int64_t *outValue)
|
||||
{
|
||||
if (outValue == NULL)
|
||||
{
|
||||
|
|
@ -174,13 +173,14 @@ static bool TryParseInt64(const std::string &value, __int64 *outValue)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*outValue = parsed;
|
||||
*outValue = static_cast<int64_t>(parsed);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ static std::string ReadNormalizedStringProperty(
|
|||
static bool ReadNormalizedOptionalInt64Property(
|
||||
std::unordered_map<std::string, std::string> *properties,
|
||||
const char *key,
|
||||
__int64 *outValue,
|
||||
int64_t *outValue,
|
||||
bool *shouldWrite)
|
||||
{
|
||||
std::string raw = TrimAscii((*properties)[key]);
|
||||
|
|
@ -515,7 +515,7 @@ static bool ReadNormalizedOptionalInt64Property(
|
|||
return false;
|
||||
}
|
||||
|
||||
__int64 parsed = 0;
|
||||
int64_t parsed = 0;
|
||||
if (!TryParseInt64(raw, &parsed))
|
||||
{
|
||||
(*properties)[key] = "";
|
||||
|
|
|
|||
Loading…
Reference in a new issue