Files
oboe/src/mathutil.hpp
Celtic Minstrel 82abdab695 Major code reorganization
This commit only updates the XCode project for the changes.
A later commit each will update it for scons and MSVC.

A few actual changes are mixed in:
- Add a prefix header for a handful of common definitions
- Moved current_cursor into the Cursor class as a static member
- Removed the make_cursor_sword and make_cursor_watch functions
- Include tests in the All target
- Remove redundant -l flags for Common and Common-Party (since they're included in the Link phases anyway)
2017-04-14 00:24:29 -04:00

46 lines
1.0 KiB
C++

/*
* mathutil.h
* BoE
*
* Created by Celtic Minstrel on 16/04/09.
*
*/
#include <cmath>
#include <SFML/System/Time.hpp>
using std::abs;
short get_ran(short times, short min, short max);
short max(short a,short b);
short min(short a,short b);
short minmax(short min,short max,short k);
short gcd(short a, short b);
sf::Time time_in_ticks(int ticks);
template<typename T>
inline void move_to_zero(T& val){
if(val < 0)
val++;
if(val > 0)
val--;
}
// Not quite mathutil... perhaps I need a more general util file.
// This is from <http://stackoverflow.com/a/16597048>.
template<typename ContainerT, typename PredicateT >
void erase_if(ContainerT& items, const PredicateT& predicate) {
for(auto it = items.begin(); it != items.end();) {
if(predicate(*it)) it = items.erase(it);
else ++it;
}
};
// Case-insensitive string comparison seems to be semi-standard, but with different names.
#if defined(__APPLE__)
#define strnicmp strncasecmp
#elif defined(_MSC_VER)
#define strnicmp _strnicmp
#else
#error Missing strnicmp / strncasecmp
#endif