Skip to content

Commit

Permalink
don't use strtod as windows doesn't handle inf (fixes #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco149 committed Aug 20, 2017
1 parent ebe8395 commit 517d2bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 0 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#include <float.h>

#ifdef OPPAI_NOSTDINT
typedef unsigned long long int uint64_t;
#endif

#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)

Expand Down
16 changes: 13 additions & 3 deletions oppai.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@

#define OPPAI_VERSION_MAJOR 1
#define OPPAI_VERSION_MINOR 1
#define OPPAI_VERSION_PATCH 17
#define OPPAI_VERSION_PATCH 18

/* if your compiler doesn't have stdint, define this */
#ifdef OPPAI_NOSTDINT
typedef long long int int64_t;
typedef int int32_t;
typedef short int16_t;
typedef char int8_t;

typedef unsigned long long int uint64_t;
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
Expand Down Expand Up @@ -474,6 +476,14 @@ char const* errstr(int32_t err)
/* ------------------------------------------------------------- */
/* math */

internalfn
double get_inf()
{
const uint64_t raw = 0x7FF0000000000000LL;
double* p = (double*)&raw;
return *p;
}

/* dst = a - b */
internalfn
void v2f_sub(double* dst, double* a, double* b)
Expand Down Expand Up @@ -852,7 +862,7 @@ int32_t b_max_combo(struct beatmap* b)
int32_t res = b->nobjects;
int32_t i;

double infinity = strtod("inf", 0);
double infinity = get_inf();
double tnext = -infinity;
int32_t tindex = -1;

Expand Down Expand Up @@ -2300,7 +2310,7 @@ void swap_ptrs(void** a, void** b)
internalfn
int32_t d_taiko(struct diff_calc* d, uint32_t mods)
{
double infinity = strtod("inf", 0);
double infinity = get_inf();
struct beatmap* b = d->b;

int32_t i;
Expand Down

0 comments on commit 517d2bd

Please sign in to comment.