Skip to content

Commit

Permalink
Change to inf, -inf and nan to match in-game
Browse files Browse the repository at this point in the history
  • Loading branch information
h3x4n1um committed Oct 19, 2019
1 parent 2528512 commit fdff5a0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 35 deletions.
18 changes: 2 additions & 16 deletions rton-json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,20 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
endif()
message(${CMAKE_CXX_COMPILER_ID})

file(GLOB SOURCES src/*.cpp include/*.hpp lib/*.hpp)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

# conan.io for non-window
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# conan.io for non-mingw
if (NOT MINGW)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
endif()

# require nlohmann_json
find_package(nlohmann_json 3.7.0 REQUIRED)

# semver
set(VERSION_MAJOR 2)
set(VERSION_MINOR 7)
set(VERSION_PATCH 5)

# configure a header file to pass some of the CMake settings
# to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/version.hpp.in"
"${PROJECT_BINARY_DIR}/version.hpp"
)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
include_directories("${PROJECT_BINARY_DIR}")

add_executable(rton-json ${SOURCES})

Expand Down
7 changes: 1 addition & 6 deletions rton-json/include/rton-json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ using json = nlohmann::basic_json<workaround_fifo_map>;
#endif
const string architecture = ARCHITECTURE;

#if __has_include("version.hpp")
# include "version.hpp"
const string ver = to_string(VERSION_MAJOR) + '.' + to_string(VERSION_MINOR) + '.' + to_string(VERSION_PATCH);
#else
const string ver = "Unknown";
#endif // VERSION_HPP
const string ver = "2.7.6";

extern ifstream input;
extern ofstream output, debug;
Expand Down
8 changes: 4 additions & 4 deletions rton-json/src/json2rton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ int write_RTON_block(json js){
output << second_string;
}
}
//NaN
else if (temp.find("NaN") != string::npos){
//nan
else if (temp.find("nan") != string::npos){
double dnan = numeric_limits<double>::signaling_NaN();
output.write(reinterpret_cast<const char*> (&float64), sizeof float64);
output.write(reinterpret_cast<const char*> (&dnan), sizeof dnan);
}
//Infinity
else if (temp.find("Infinity") != string::npos){
//inf
else if (temp.find("inf") != string::npos){
double dinf = numeric_limits<double>::infinity();
if (temp[0] == '-') dinf = -dinf;
output.write(reinterpret_cast<const char*> (&float64), sizeof float64);
Expand Down
8 changes: 4 additions & 4 deletions rton-json/src/rton2json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ json read_RTON_block(){
//float32
case 0x22:{
float tmp = read<float>();
if (isinf(tmp)) res.push_back(tmp > 0 ? "Infinity" : "-Infinity");
if (isinf(tmp)) res.push_back(tmp > 0 ? "inf" : "-inf");
else
if (isnan(tmp)) res.push_back("NaN");
if (isnan(tmp)) res.push_back("nan");
else res.push_back(tmp);
break;
}
Expand All @@ -88,9 +88,9 @@ json read_RTON_block(){
//float64
case 0x42:{
double tmp = read<double>();
if (isinf(tmp)) res.push_back(tmp > 0 ? "Infinity" : "-Infinity");
if (isinf(tmp)) res.push_back(tmp > 0 ? "inf" : "-inf");
else
if (isnan(tmp)) res.push_back("NaN");
if (isnan(tmp)) res.push_back("nan");
else res.push_back(tmp);
break;
}
Expand Down
5 changes: 0 additions & 5 deletions rton-json/version.hpp.in

This file was deleted.

0 comments on commit fdff5a0

Please sign in to comment.