1 | //Define rnd01, rnd0N, and randomN so that they
|
---|
2 | //work in your C++ environment.
|
---|
3 | //Some other functions/macros may also be needed if they
|
---|
4 | //are missing in your environment, like min, max, etc.
|
---|
5 |
|
---|
6 | #ifndef __NONSTD_H
|
---|
7 | #define __NONSTD_H
|
---|
8 |
|
---|
9 | #define APPLICATION_NAME "Framsticks"
|
---|
10 | #define MAIN_FRAMSTICKS
|
---|
11 | #define SAFEDELETE(p) {if (p) {delete p; p=NULL;}}
|
---|
12 | #define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}}
|
---|
13 |
|
---|
14 | //#ifndef _Windows included below?
|
---|
15 | //#include <stdlib.h>
|
---|
16 | //#endif
|
---|
17 |
|
---|
18 | #define DB(x) //output debug info. If needed, use #define DB(x) x
|
---|
19 | //#define DB(x) x
|
---|
20 |
|
---|
21 | // ms visual c++
|
---|
22 | #ifdef _MSC_VER
|
---|
23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
---|
24 | #include <windows.h>
|
---|
25 | #include <stdio.h>
|
---|
26 | #include <stdarg.h>
|
---|
27 | #define vsnprintf _vsnprintf
|
---|
28 | #define _USE_MATH_DEFINES
|
---|
29 |
|
---|
30 | #ifndef M_PI
|
---|
31 | #define M_PI 3.1415926535897932384626433832795
|
---|
32 | #endif
|
---|
33 | #ifndef M_PI_2
|
---|
34 | #define M_PI_2 (M_PI/2)
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | /////////////////////////////////////////////////////// 64-bit int type and other macros
|
---|
40 | #ifdef _Windows
|
---|
41 | typedef __int64 LONGLONG;
|
---|
42 | #define PATHSEPARATORCHAR '\\'
|
---|
43 | #define PATHSEPARATORSTRING "\\"
|
---|
44 | #define FPU_THROWS_EXCEPTIONS
|
---|
45 | #else
|
---|
46 | #define LONGLONG long long int
|
---|
47 | #define PATHSEPARATORCHAR '/'
|
---|
48 | #define PATHSEPARATORSTRING "/"
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | #ifdef __BORLANDC__
|
---|
52 | #define fileExists(f) (!access(f,0))
|
---|
53 | #include "stdlib.h" //random
|
---|
54 | #define FOPEN_READ "rt"
|
---|
55 | #define FOPEN_WRITE "wt"
|
---|
56 | #define FOPEN_APPEND "at"
|
---|
57 | #define rnd01 ((double)((double)_lrand()/(double)(LRAND_MAX+1)))
|
---|
58 | //#define rnd01 ((double)((double)rand()/(RAND_MAX+1)))
|
---|
59 | #define rnd0N(num) ((double)((num)*rnd01))
|
---|
60 | #define randomN(num) random(num) //uses _lrand
|
---|
61 | #else
|
---|
62 | #ifdef _MSC_VER
|
---|
63 | #define fileExists(f) (!access(f,0))
|
---|
64 | #else
|
---|
65 | #define fileExists(f) (!access(f,R_OK))
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | #define FOPEN_WRITE "wa"
|
---|
69 | #define FOPEN_APPEND "aa"
|
---|
70 | #define FOPEN_READ "ra"
|
---|
71 | //#define FLOATRAND
|
---|
72 | #ifdef FLOATRAND
|
---|
73 | #define randomN(x) ((int)((x)*drand48()))
|
---|
74 | #define rnd01 (drand48())
|
---|
75 | #define rnd0N(x) (drand48()*(x))
|
---|
76 | #else
|
---|
77 | #define rnd01 ((double)(rand()/(RAND_MAX+1.0)))
|
---|
78 | #define rnd0N(x) ((x)*rnd01)
|
---|
79 | #define randomN(x) ((int)rnd0N(x))
|
---|
80 | #endif
|
---|
81 | #endif
|
---|
82 |
|
---|
83 |
|
---|
84 | #ifdef __GNUC__
|
---|
85 | /*
|
---|
86 | #define min(a,b) (((a)>(b))?(b):(a))
|
---|
87 | #define max(a,b) (((a)>(b))?(a):(b))
|
---|
88 | #define abs(a) ((a)>=0?(a):-(a))
|
---|
89 | */
|
---|
90 | #include <algorithm>
|
---|
91 | using namespace std;
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | #ifdef DEFINE_STRICMP_AS_STRCASECMP
|
---|
95 | #define stricmp(a,b) strcasecmp(a,b)
|
---|
96 | #endif
|
---|
97 |
|
---|
98 | #endif
|
---|