Visual studio compatibility

This removes some inlines when using visual studio to compile, uisng TPT_NO_INLINE. It also fixes many other problems visual studio has with the code
This commit is contained in:
jacob1 2012-09-03 20:09:53 -04:00 committed by Simon Robertshaw
parent 58fa3dd539
commit f8f70a3f77
40 changed files with 219 additions and 193 deletions

View File

@ -181,18 +181,20 @@ extern unsigned char ZSIZE;
#ifdef WIN #ifdef WIN
#define strcasecmp stricmp #define strcasecmp stricmp
#endif #endif //_MSC_VER
#if defined(WIN) && !defined(__GNUC__) #if defined(_MSC_VER)
#define fmin min #define fmin(a,b) (((a) < (b)) ? (a) : (b))
#define fminf min #define fminf(a,b) (((a) < (b)) ? (a) : (b))
#define fmax max #define fmax(a,b) (((a) > (b)) ? (a) : (b))
#define fmaxf max #define fmaxf(a,b) (((a) > (b)) ? (a) : (b))
#endif #endif
#if defined(WIN) && !defined(__GNUC__) #if defined(_MSC_VER)
#define TPT_INLINE _inline #define TPT_INLINE _inline
#define TPT_NO_INLINE //Remove inlines in visual studio, but only the ones that don't work
#else #else
#define TPT_INLINE inline #define TPT_INLINE inline
#define TPT_NO_INLINE inline
#endif #endif
#define SDEUT #define SDEUT

View File

@ -4,7 +4,7 @@
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <zlib.h> #include "zlib.h"
#include <stdio.h> #include <stdio.h>
#include "Format.h" #include "Format.h"
#include "graphics/Graphics.h" #include "graphics/Graphics.h"

View File

@ -111,7 +111,7 @@ int isign(float i) //TODO: INline or macro
return 0; return 0;
} }
TPT_INLINE unsigned clamp_flt(float f, float min, float max) //TODO: Also inline/macro TPT_NO_INLINE unsigned clamp_flt(float f, float min, float max) //TODO: Also inline/macro
{ {
if (f<min) if (f<min)
return 0; return 0;
@ -120,7 +120,7 @@ TPT_INLINE unsigned clamp_flt(float f, float min, float max) //TODO: Also inline
return (int)(255.0f*(f-min)/(max-min)); return (int)(255.0f*(f-min)/(max-min));
} }
TPT_INLINE float restrict_flt(float f, float min, float max) //TODO Inline or macro or something TPT_NO_INLINE float restrict_flt(float f, float min, float max) //TODO Inline or macro or something
{ {
if (f<min) if (f<min)
return min; return min;
@ -623,7 +623,7 @@ void HSV_to_RGB(int h,int s,int v,int *r,int *g,int *b)//convert 0-255(0-360 for
ss = s/255.0f; ss = s/255.0f;
vv = v/255.0f; vv = v/255.0f;
c = vv * ss; c = vv * ss;
x = c * ( 1 - fabs(fmod(hh,2.0) -1) ); x = c * ( 1 - fabs(fmod(hh,2.0f) -1) );
if(hh<1){ if(hh<1){
*r = (int)(c*255.0); *r = (int)(c*255.0);
*g = (int)(x*255.0); *g = (int)(x*255.0);

View File

@ -3,9 +3,9 @@
#include <map> #include <map>
#include <string> #include <string>
#include <time.h> #include <time.h>
#include "SDL.h" #include "SDL/SDL.h"
#ifdef WIN #ifdef WIN
#include "SDL_syswm.h" #include "SDL/SDL_syswm.h"
#include <direct.h> #include <direct.h>
#endif #endif
#include <iostream> #include <iostream>

View File

@ -44,7 +44,7 @@ namespace json
{ {
inline Exception::Exception(const std::string& sMessage) : TPT_NO_INLINE Exception::Exception(const std::string& sMessage) :
std::runtime_error(sMessage) {} std::runtime_error(sMessage) {}
@ -129,32 +129,32 @@ public:
inline UnknownElement::UnknownElement() : m_pImp( new Imp_T<Null>( Null() ) ) {} TPT_NO_INLINE UnknownElement::UnknownElement() : m_pImp( new Imp_T<Null>( Null() ) ) {}
inline UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp( unknown.m_pImp->Clone()) {} TPT_NO_INLINE UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp( unknown.m_pImp->Clone()) {}
inline UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T<Object>(object) ) {} TPT_NO_INLINE UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T<Object>(object) ) {}
inline UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T<Array>(array) ) {} TPT_NO_INLINE UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T<Array>(array) ) {}
inline UnknownElement::UnknownElement(const Number& number) : m_pImp( new Imp_T<Number>(number) ) {} TPT_NO_INLINE UnknownElement::UnknownElement(const Number& number) : m_pImp( new Imp_T<Number>(number) ) {}
inline UnknownElement::UnknownElement(const Boolean& boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {} TPT_NO_INLINE UnknownElement::UnknownElement(const Boolean& boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {}
inline UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T<String>(string) ) {} TPT_NO_INLINE UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T<String>(string) ) {}
inline UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T<Null>(null) ) {} TPT_NO_INLINE UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T<Null>(null) ) {}
inline UnknownElement::~UnknownElement() { delete m_pImp; } TPT_NO_INLINE UnknownElement::~UnknownElement() { delete m_pImp; }
inline UnknownElement::operator const Object& () const { return CastTo<Object>(); } TPT_NO_INLINE UnknownElement::operator const Object& () const { return CastTo<Object>(); }
inline UnknownElement::operator const Array& () const { return CastTo<Array>(); } TPT_NO_INLINE UnknownElement::operator const Array& () const { return CastTo<Array>(); }
inline UnknownElement::operator const Number& () const { return CastTo<Number>(); } TPT_NO_INLINE UnknownElement::operator const Number& () const { return CastTo<Number>(); }
inline UnknownElement::operator const Boolean& () const { return CastTo<Boolean>(); } TPT_NO_INLINE UnknownElement::operator const Boolean& () const { return CastTo<Boolean>(); }
inline UnknownElement::operator const String& () const { return CastTo<String>(); } TPT_NO_INLINE UnknownElement::operator const String& () const { return CastTo<String>(); }
inline UnknownElement::operator const Null& () const { return CastTo<Null>(); } TPT_NO_INLINE UnknownElement::operator const Null& () const { return CastTo<Null>(); }
inline UnknownElement::operator Object& () { return ConvertTo<Object>(); } TPT_NO_INLINE UnknownElement::operator Object& () { return ConvertTo<Object>(); }
inline UnknownElement::operator Array& () { return ConvertTo<Array>(); } TPT_NO_INLINE UnknownElement::operator Array& () { return ConvertTo<Array>(); }
inline UnknownElement::operator Number& () { return ConvertTo<Number>(); } TPT_NO_INLINE UnknownElement::operator Number& () { return ConvertTo<Number>(); }
inline UnknownElement::operator Boolean& () { return ConvertTo<Boolean>(); } TPT_NO_INLINE UnknownElement::operator Boolean& () { return ConvertTo<Boolean>(); }
inline UnknownElement::operator String& () { return ConvertTo<String>(); } TPT_NO_INLINE UnknownElement::operator String& () { return ConvertTo<String>(); }
inline UnknownElement::operator Null& () { return ConvertTo<Null>(); } TPT_NO_INLINE UnknownElement::operator Null& () { return ConvertTo<Null>(); }
inline UnknownElement& UnknownElement::operator = (const UnknownElement& unknown) TPT_NO_INLINE UnknownElement& UnknownElement::operator = (const UnknownElement& unknown)
{ {
// always check for this // always check for this
if (&unknown != this) if (&unknown != this)
@ -170,28 +170,28 @@ inline UnknownElement& UnknownElement::operator = (const UnknownElement& unknown
return *this; return *this;
} }
inline UnknownElement& UnknownElement::operator[] (const std::string& key) TPT_NO_INLINE UnknownElement& UnknownElement::operator[] (const std::string& key)
{ {
// the people want an object. make us one if we aren't already // the people want an object. make us one if we aren't already
Object& object = ConvertTo<Object>(); Object& object = ConvertTo<Object>();
return object[key]; return object[key];
} }
inline const UnknownElement& UnknownElement::operator[] (const std::string& key) const TPT_NO_INLINE const UnknownElement& UnknownElement::operator[] (const std::string& key) const
{ {
// throws if we aren't an object // throws if we aren't an object
const Object& object = CastTo<Object>(); const Object& object = CastTo<Object>();
return object[key]; return object[key];
} }
inline UnknownElement& UnknownElement::operator[] (size_t index) TPT_NO_INLINE UnknownElement& UnknownElement::operator[] (size_t index)
{ {
// the people want an array. make us one if we aren't already // the people want an array. make us one if we aren't already
Array& array = ConvertTo<Array>(); Array& array = ConvertTo<Array>();
return array[index]; return array[index];
} }
inline const UnknownElement& UnknownElement::operator[] (size_t index) const TPT_NO_INLINE const UnknownElement& UnknownElement::operator[] (size_t index) const
{ {
// throws if we aren't an array // throws if we aren't an array
const Array& array = CastTo<Array>(); const Array& array = CastTo<Array>();
@ -227,11 +227,11 @@ ElementTypeT& UnknownElement::ConvertTo()
} }
inline void UnknownElement::Accept(ConstVisitor& visitor) const { m_pImp->Accept(visitor); } TPT_NO_INLINE void UnknownElement::Accept(ConstVisitor& visitor) const { m_pImp->Accept(visitor); }
inline void UnknownElement::Accept(Visitor& visitor) { m_pImp->Accept(visitor); } TPT_NO_INLINE void UnknownElement::Accept(Visitor& visitor) { m_pImp->Accept(visitor); }
inline bool UnknownElement::operator == (const UnknownElement& element) const TPT_NO_INLINE bool UnknownElement::operator == (const UnknownElement& element) const
{ {
return m_pImp->Compare(*element.m_pImp); return m_pImp->Compare(*element.m_pImp);
} }
@ -242,10 +242,10 @@ inline bool UnknownElement::operator == (const UnknownElement& element) const
// Object members // Object members
inline Object::Member::Member(const std::string& nameIn, const UnknownElement& elementIn) : TPT_NO_INLINE Object::Member::Member(const std::string& nameIn, const UnknownElement& elementIn) :
name(nameIn), element(elementIn) {} name(nameIn), element(elementIn) {}
inline bool Object::Member::operator == (const Member& member) const TPT_NO_INLINE bool Object::Member::operator == (const Member& member) const
{ {
return name == member.name && return name == member.name &&
element == member.element; element == member.element;
@ -265,30 +265,30 @@ private:
inline Object::iterator Object::Begin() { return m_Members.begin(); } TPT_NO_INLINE Object::iterator Object::Begin() { return m_Members.begin(); }
inline Object::iterator Object::End() { return m_Members.end(); } TPT_NO_INLINE Object::iterator Object::End() { return m_Members.end(); }
inline Object::const_iterator Object::Begin() const { return m_Members.begin(); } TPT_NO_INLINE Object::const_iterator Object::Begin() const { return m_Members.begin(); }
inline Object::const_iterator Object::End() const { return m_Members.end(); } TPT_NO_INLINE Object::const_iterator Object::End() const { return m_Members.end(); }
inline size_t Object::Size() const { return m_Members.size(); } TPT_NO_INLINE size_t Object::Size() const { return m_Members.size(); }
inline bool Object::Empty() const { return m_Members.empty(); } TPT_NO_INLINE bool Object::Empty() const { return m_Members.empty(); }
inline Object::iterator Object::Find(const std::string& name) TPT_NO_INLINE Object::iterator Object::Find(const std::string& name)
{ {
return std::find_if(m_Members.begin(), m_Members.end(), Finder(name)); return std::find_if(m_Members.begin(), m_Members.end(), Finder(name));
} }
inline Object::const_iterator Object::Find(const std::string& name) const TPT_NO_INLINE Object::const_iterator Object::Find(const std::string& name) const
{ {
return std::find_if(m_Members.begin(), m_Members.end(), Finder(name)); return std::find_if(m_Members.begin(), m_Members.end(), Finder(name));
} }
inline Object::iterator Object::Insert(const Member& member) TPT_NO_INLINE Object::iterator Object::Insert(const Member& member)
{ {
return Insert(member, End()); return Insert(member, End());
} }
inline Object::iterator Object::Insert(const Member& member, iterator itWhere) TPT_NO_INLINE Object::iterator Object::Insert(const Member& member, iterator itWhere)
{ {
iterator it = Find(member.name); iterator it = Find(member.name);
if (it != m_Members.end()) if (it != m_Members.end())
@ -298,12 +298,12 @@ inline Object::iterator Object::Insert(const Member& member, iterator itWhere)
return it; return it;
} }
inline Object::iterator Object::Erase(iterator itWhere) TPT_NO_INLINE Object::iterator Object::Erase(iterator itWhere)
{ {
return m_Members.erase(itWhere); return m_Members.erase(itWhere);
} }
inline UnknownElement& Object::operator [](const std::string& name) TPT_NO_INLINE UnknownElement& Object::operator [](const std::string& name)
{ {
iterator it = Find(name); iterator it = Find(name);
@ -315,7 +315,7 @@ inline UnknownElement& Object::operator [](const std::string& name)
return it->element; return it->element;
} }
inline const UnknownElement& Object::operator [](const std::string& name) const TPT_NO_INLINE const UnknownElement& Object::operator [](const std::string& name) const
{ {
const_iterator it = Find(name); const_iterator it = Find(name);
if (it == End()) if (it == End())
@ -323,12 +323,12 @@ inline const UnknownElement& Object::operator [](const std::string& name) const
return it->element; return it->element;
} }
inline void Object::Clear() TPT_NO_INLINE void Object::Clear()
{ {
m_Members.clear(); m_Members.clear();
} }
inline bool Object::operator == (const Object& object) const TPT_NO_INLINE bool Object::operator == (const Object& object) const
{ {
return m_Members == object.m_Members; return m_Members == object.m_Members;
} }
@ -337,35 +337,35 @@ inline bool Object::operator == (const Object& object) const
///////////////// /////////////////
// Array members // Array members
inline Array::iterator Array::Begin() { return m_Elements.begin(); } TPT_NO_INLINE Array::iterator Array::Begin() { return m_Elements.begin(); }
inline Array::iterator Array::End() { return m_Elements.end(); } TPT_NO_INLINE Array::iterator Array::End() { return m_Elements.end(); }
inline Array::const_iterator Array::Begin() const { return m_Elements.begin(); } TPT_NO_INLINE Array::const_iterator Array::Begin() const { return m_Elements.begin(); }
inline Array::const_iterator Array::End() const { return m_Elements.end(); } TPT_NO_INLINE Array::const_iterator Array::End() const { return m_Elements.end(); }
inline Array::iterator Array::Insert(const UnknownElement& element, iterator itWhere) TPT_NO_INLINE Array::iterator Array::Insert(const UnknownElement& element, iterator itWhere)
{ {
return m_Elements.insert(itWhere, element); return m_Elements.insert(itWhere, element);
} }
inline Array::iterator Array::Insert(const UnknownElement& element) TPT_NO_INLINE Array::iterator Array::Insert(const UnknownElement& element)
{ {
return Insert(element, End()); return Insert(element, End());
} }
inline Array::iterator Array::Erase(iterator itWhere) TPT_NO_INLINE Array::iterator Array::Erase(iterator itWhere)
{ {
return m_Elements.erase(itWhere); return m_Elements.erase(itWhere);
} }
inline void Array::Resize(size_t newSize) TPT_NO_INLINE void Array::Resize(size_t newSize)
{ {
m_Elements.resize(newSize); m_Elements.resize(newSize);
} }
inline size_t Array::Size() const { return m_Elements.size(); } TPT_NO_INLINE size_t Array::Size() const { return m_Elements.size(); }
inline bool Array::Empty() const { return m_Elements.empty(); } TPT_NO_INLINE bool Array::Empty() const { return m_Elements.empty(); }
inline UnknownElement& Array::operator[] (size_t index) TPT_NO_INLINE UnknownElement& Array::operator[] (size_t index)
{ {
size_t nMinSize = index + 1; // zero indexed size_t nMinSize = index + 1; // zero indexed
if (m_Elements.size() < nMinSize) if (m_Elements.size() < nMinSize)
@ -373,18 +373,18 @@ inline UnknownElement& Array::operator[] (size_t index)
return m_Elements[index]; return m_Elements[index];
} }
inline const UnknownElement& Array::operator[] (size_t index) const TPT_NO_INLINE const UnknownElement& Array::operator[] (size_t index) const
{ {
if (index >= m_Elements.size()) if (index >= m_Elements.size())
throw Exception("Array out of bounds"); throw Exception("Array out of bounds");
return m_Elements[index]; return m_Elements[index];
} }
inline void Array::Clear() { TPT_NO_INLINE void Array::Clear() {
m_Elements.clear(); m_Elements.clear();
} }
inline bool Array::operator == (const Array& array) const TPT_NO_INLINE bool Array::operator == (const Array& array) const
{ {
return m_Elements == array.m_Elements; return m_Elements == array.m_Elements;
} }
@ -393,7 +393,7 @@ inline bool Array::operator == (const Array& array) const
////////////////// //////////////////
// Null members // Null members
inline bool Null::operator == (const Null& trivial) const TPT_NO_INLINE bool Null::operator == (const Null& trivial) const
{ {
return true; return true;
} }

View File

@ -35,6 +35,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#if defined(_MSC_VER)
#define TPT_NO_INLINE //Remove inlines in visual studio, but only the ones that don't work
#else
#define TPT_NO_INLINE inline
#endif
/* /*
TODO: TODO:

View File

@ -43,12 +43,12 @@ TODO:
namespace json namespace json
{ {
inline std::istream& operator >> (std::istream& istr, UnknownElement& elementRoot) { TPT_NO_INLINE std::istream& operator >> (std::istream& istr, UnknownElement& elementRoot) {
Reader::Read(elementRoot, istr); Reader::Read(elementRoot, istr);
return istr; return istr;
} }
inline Reader::Location::Location() : TPT_NO_INLINE Reader::Location::Location() :
m_nLine(0), m_nLine(0),
m_nLineOffset(0), m_nLineOffset(0),
m_nDocOffset(0) m_nDocOffset(0)
@ -84,7 +84,7 @@ private:
}; };
inline char Reader::InputStream::Get() TPT_NO_INLINE char Reader::InputStream::Get()
{ {
assert(m_iStr.eof() == false); // enforce reading of only valid stream data assert(m_iStr.eof() == false); // enforce reading of only valid stream data
char c = m_iStr.get(); char c = m_iStr.get();
@ -122,12 +122,12 @@ private:
}; };
inline Reader::TokenStream::TokenStream(const Tokens& tokens) : TPT_NO_INLINE Reader::TokenStream::TokenStream(const Tokens& tokens) :
m_Tokens(tokens), m_Tokens(tokens),
m_itCurrent(tokens.begin()) m_itCurrent(tokens.begin())
{} {}
inline const Reader::Token& Reader::TokenStream::Peek() { TPT_NO_INLINE const Reader::Token& Reader::TokenStream::Peek() {
if (EOS()) if (EOS())
{ {
const Token& lastToken = *m_Tokens.rbegin(); const Token& lastToken = *m_Tokens.rbegin();
@ -137,13 +137,13 @@ inline const Reader::Token& Reader::TokenStream::Peek() {
return *(m_itCurrent); return *(m_itCurrent);
} }
inline const Reader::Token& Reader::TokenStream::Get() { TPT_NO_INLINE const Reader::Token& Reader::TokenStream::Get() {
const Token& token = Peek(); const Token& token = Peek();
++m_itCurrent; ++m_itCurrent;
return token; return token;
} }
inline bool Reader::TokenStream::EOS() const { TPT_NO_INLINE bool Reader::TokenStream::EOS() const {
return m_itCurrent == m_Tokens.end(); return m_itCurrent == m_Tokens.end();
} }
@ -151,13 +151,13 @@ inline bool Reader::TokenStream::EOS() const {
// Reader (finally) // Reader (finally)
inline void Reader::Read(Object& object, std::istream& istr) { Read_i(object, istr); } TPT_NO_INLINE void Reader::Read(Object& object, std::istream& istr) { Read_i(object, istr); }
inline void Reader::Read(Array& array, std::istream& istr) { Read_i(array, istr); } TPT_NO_INLINE void Reader::Read(Array& array, std::istream& istr) { Read_i(array, istr); }
inline void Reader::Read(String& string, std::istream& istr) { Read_i(string, istr); } TPT_NO_INLINE void Reader::Read(String& string, std::istream& istr) { Read_i(string, istr); }
inline void Reader::Read(Number& number, std::istream& istr) { Read_i(number, istr); } TPT_NO_INLINE void Reader::Read(Number& number, std::istream& istr) { Read_i(number, istr); }
inline void Reader::Read(Boolean& boolean, std::istream& istr) { Read_i(boolean, istr); } TPT_NO_INLINE void Reader::Read(Boolean& boolean, std::istream& istr) { Read_i(boolean, istr); }
inline void Reader::Read(Null& null, std::istream& istr) { Read_i(null, istr); } TPT_NO_INLINE void Reader::Read(Null& null, std::istream& istr) { Read_i(null, istr); }
inline void Reader::Read(UnknownElement& unknown, std::istream& istr) { Read_i(unknown, istr); } TPT_NO_INLINE void Reader::Read(UnknownElement& unknown, std::istream& istr) { Read_i(unknown, istr); }
template <typename ElementTypeT> template <typename ElementTypeT>
@ -181,7 +181,7 @@ void Reader::Read_i(ElementTypeT& element, std::istream& istr)
} }
inline void Reader::Scan(Tokens& tokens, InputStream& inputStream) TPT_NO_INLINE void Reader::Scan(Tokens& tokens, InputStream& inputStream)
{ {
while (EatWhiteSpace(inputStream), // ignore any leading white space... while (EatWhiteSpace(inputStream), // ignore any leading white space...
inputStream.EOS() == false) // ...before checking for EOS inputStream.EOS() == false) // ...before checking for EOS
@ -272,14 +272,14 @@ inline void Reader::Scan(Tokens& tokens, InputStream& inputStream)
} }
inline void Reader::EatWhiteSpace(InputStream& inputStream) TPT_NO_INLINE void Reader::EatWhiteSpace(InputStream& inputStream)
{ {
while (inputStream.EOS() == false && while (inputStream.EOS() == false &&
::isspace(inputStream.Peek())) ::isspace(inputStream.Peek()))
inputStream.Get(); inputStream.Get();
} }
inline std::string Reader::MatchExpectedString(InputStream& inputStream, const std::string& sExpected) TPT_NO_INLINE std::string Reader::MatchExpectedString(InputStream& inputStream, const std::string& sExpected)
{ {
std::string::const_iterator it(sExpected.begin()), std::string::const_iterator it(sExpected.begin()),
itEnd(sExpected.end()); itEnd(sExpected.end());
@ -297,7 +297,7 @@ inline std::string Reader::MatchExpectedString(InputStream& inputStream, const s
} }
inline std::string Reader::MatchString(InputStream& inputStream) TPT_NO_INLINE std::string Reader::MatchString(InputStream& inputStream)
{ {
MatchExpectedString(inputStream, "\""); MatchExpectedString(inputStream, "\"");
@ -341,7 +341,7 @@ inline std::string Reader::MatchString(InputStream& inputStream)
} }
inline std::string Reader::MatchNumber(InputStream& inputStream) TPT_NO_INLINE std::string Reader::MatchNumber(InputStream& inputStream)
{ {
const char sNumericChars[] = "0123456789.eE-+"; const char sNumericChars[] = "0123456789.eE-+";
std::set<char> numericChars; std::set<char> numericChars;
@ -358,7 +358,7 @@ inline std::string Reader::MatchNumber(InputStream& inputStream)
} }
inline void Reader::Parse(UnknownElement& element, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(UnknownElement& element, Reader::TokenStream& tokenStream)
{ {
const Token& token = tokenStream.Peek(); const Token& token = tokenStream.Peek();
switch (token.nType) { switch (token.nType) {
@ -414,7 +414,7 @@ inline void Reader::Parse(UnknownElement& element, Reader::TokenStream& tokenStr
} }
inline void Reader::Parse(Object& object, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(Object& object, Reader::TokenStream& tokenStream)
{ {
MatchExpectedToken(Token::TOKEN_OBJECT_BEGIN, tokenStream); MatchExpectedToken(Token::TOKEN_OBJECT_BEGIN, tokenStream);
@ -456,7 +456,7 @@ inline void Reader::Parse(Object& object, Reader::TokenStream& tokenStream)
} }
inline void Reader::Parse(Array& array, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(Array& array, Reader::TokenStream& tokenStream)
{ {
MatchExpectedToken(Token::TOKEN_ARRAY_BEGIN, tokenStream); MatchExpectedToken(Token::TOKEN_ARRAY_BEGIN, tokenStream);
@ -479,13 +479,13 @@ inline void Reader::Parse(Array& array, Reader::TokenStream& tokenStream)
} }
inline void Reader::Parse(String& string, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(String& string, Reader::TokenStream& tokenStream)
{ {
string = MatchExpectedToken(Token::TOKEN_STRING, tokenStream); string = MatchExpectedToken(Token::TOKEN_STRING, tokenStream);
} }
inline void Reader::Parse(Number& number, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(Number& number, Reader::TokenStream& tokenStream)
{ {
const Token& currentToken = tokenStream.Peek(); // might need this later for throwing exception const Token& currentToken = tokenStream.Peek(); // might need this later for throwing exception
const std::string& sValue = MatchExpectedToken(Token::TOKEN_NUMBER, tokenStream); const std::string& sValue = MatchExpectedToken(Token::TOKEN_NUMBER, tokenStream);
@ -506,20 +506,20 @@ inline void Reader::Parse(Number& number, Reader::TokenStream& tokenStream)
} }
inline void Reader::Parse(Boolean& boolean, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(Boolean& boolean, Reader::TokenStream& tokenStream)
{ {
const std::string& sValue = MatchExpectedToken(Token::TOKEN_BOOLEAN, tokenStream); const std::string& sValue = MatchExpectedToken(Token::TOKEN_BOOLEAN, tokenStream);
boolean = (sValue == "true" ? true : false); boolean = (sValue == "true" ? true : false);
} }
inline void Reader::Parse(Null&, Reader::TokenStream& tokenStream) TPT_NO_INLINE void Reader::Parse(Null&, Reader::TokenStream& tokenStream)
{ {
MatchExpectedToken(Token::TOKEN_NULL, tokenStream); MatchExpectedToken(Token::TOKEN_NULL, tokenStream);
} }
inline const std::string& Reader::MatchExpectedToken(Token::Type nExpected, Reader::TokenStream& tokenStream) TPT_NO_INLINE const std::string& Reader::MatchExpectedToken(Token::Type nExpected, Reader::TokenStream& tokenStream)
{ {
const Token& token = tokenStream.Get(); const Token& token = tokenStream.Get();
if (token.nType != nExpected) if (token.nType != nExpected)

View File

@ -43,16 +43,16 @@ namespace json
{ {
inline void Writer::Write(const UnknownElement& elementRoot, std::ostream& ostr) { Write_i(elementRoot, ostr); } TPT_NO_INLINE void Writer::Write(const UnknownElement& elementRoot, std::ostream& ostr) { Write_i(elementRoot, ostr); }
inline void Writer::Write(const Object& object, std::ostream& ostr) { Write_i(object, ostr); } TPT_NO_INLINE void Writer::Write(const Object& object, std::ostream& ostr) { Write_i(object, ostr); }
inline void Writer::Write(const Array& array, std::ostream& ostr) { Write_i(array, ostr); } TPT_NO_INLINE void Writer::Write(const Array& array, std::ostream& ostr) { Write_i(array, ostr); }
inline void Writer::Write(const Number& number, std::ostream& ostr) { Write_i(number, ostr); } TPT_NO_INLINE void Writer::Write(const Number& number, std::ostream& ostr) { Write_i(number, ostr); }
inline void Writer::Write(const String& string, std::ostream& ostr) { Write_i(string, ostr); } TPT_NO_INLINE void Writer::Write(const String& string, std::ostream& ostr) { Write_i(string, ostr); }
inline void Writer::Write(const Boolean& boolean, std::ostream& ostr) { Write_i(boolean, ostr); } TPT_NO_INLINE void Writer::Write(const Boolean& boolean, std::ostream& ostr) { Write_i(boolean, ostr); }
inline void Writer::Write(const Null& null, std::ostream& ostr) { Write_i(null, ostr); } TPT_NO_INLINE void Writer::Write(const Null& null, std::ostream& ostr) { Write_i(null, ostr); }
inline Writer::Writer(std::ostream& ostr) : TPT_NO_INLINE Writer::Writer(std::ostream& ostr) :
m_ostr(ostr), m_ostr(ostr),
m_nTabDepth(0) m_nTabDepth(0)
{} {}
@ -65,7 +65,7 @@ void Writer::Write_i(const ElementTypeT& element, std::ostream& ostr)
ostr.flush(); // all done ostr.flush(); // all done
} }
inline void Writer::Write_i(const Array& array) TPT_NO_INLINE void Writer::Write_i(const Array& array)
{ {
if (array.Empty()) if (array.Empty())
m_ostr << "[]"; m_ostr << "[]";
@ -91,7 +91,7 @@ inline void Writer::Write_i(const Array& array)
} }
} }
inline void Writer::Write_i(const Object& object) TPT_NO_INLINE void Writer::Write_i(const Object& object)
{ {
if (object.Empty()) if (object.Empty())
m_ostr << "{}"; m_ostr << "{}";
@ -120,17 +120,17 @@ inline void Writer::Write_i(const Object& object)
} }
} }
inline void Writer::Write_i(const Number& numberElement) TPT_NO_INLINE void Writer::Write_i(const Number& numberElement)
{ {
m_ostr << std::setprecision(20) << numberElement.Value(); m_ostr << std::setprecision(20) << numberElement.Value();
} }
inline void Writer::Write_i(const Boolean& booleanElement) TPT_NO_INLINE void Writer::Write_i(const Boolean& booleanElement)
{ {
m_ostr << (booleanElement.Value() ? "true" : "false"); m_ostr << (booleanElement.Value() ? "true" : "false");
} }
inline void Writer::Write_i(const String& stringElement) TPT_NO_INLINE void Writer::Write_i(const String& stringElement)
{ {
m_ostr << '"'; m_ostr << '"';
@ -156,22 +156,22 @@ inline void Writer::Write_i(const String& stringElement)
m_ostr << '"'; m_ostr << '"';
} }
inline void Writer::Write_i(const Null& ) TPT_NO_INLINE void Writer::Write_i(const Null& )
{ {
m_ostr << "null"; m_ostr << "null";
} }
inline void Writer::Write_i(const UnknownElement& unknown) TPT_NO_INLINE void Writer::Write_i(const UnknownElement& unknown)
{ {
unknown.Accept(*this); unknown.Accept(*this);
} }
inline void Writer::Visit(const Array& array) { Write_i(array); } TPT_NO_INLINE void Writer::Visit(const Array& array) { Write_i(array); }
inline void Writer::Visit(const Object& object) { Write_i(object); } TPT_NO_INLINE void Writer::Visit(const Object& object) { Write_i(object); }
inline void Writer::Visit(const Number& number) { Write_i(number); } TPT_NO_INLINE void Writer::Visit(const Number& number) { Write_i(number); }
inline void Writer::Visit(const String& string) { Write_i(string); } TPT_NO_INLINE void Writer::Visit(const String& string) { Write_i(string); }
inline void Writer::Visit(const Boolean& boolean) { Write_i(boolean); } TPT_NO_INLINE void Writer::Visit(const Boolean& boolean) { Write_i(boolean); }
inline void Writer::Visit(const Null& null) { Write_i(null); } TPT_NO_INLINE void Writer::Visit(const Null& null) { Write_i(null); }

View File

@ -8,7 +8,9 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <string.h> #include <string.h>
#if !defined(WIN) || defined(__GNUC__)
#include <strings.h> #include <strings.h>
#endif
#include "CommandInterface.h" #include "CommandInterface.h"
#include "game/GameModel.h" #include "game/GameModel.h"
#include "game/GameController.h" #include "game/GameController.h"

View File

@ -30,9 +30,9 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -1,8 +1,8 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include <iostream> #include <iostream>
@ -77,6 +77,7 @@ int LuaButton::action(lua_State * l)
{ {
actionFunction = 0; actionFunction = 0;
} }
return 0;
} }
int LuaButton::text(lua_State * l) int LuaButton::text(lua_State * l)

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
extern "C" { extern "C" {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include "LuaLuna.h" #include "LuaLuna.h"

View File

@ -1,8 +1,8 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include <iostream> #include <iostream>

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
extern "C" { extern "C" {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include "LuaLuna.h" #include "LuaLuna.h"

View File

@ -1,8 +1,8 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include <iostream> #include <iostream>

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
extern "C" { extern "C" {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include "LuaLuna.h" #include "LuaLuna.h"

View File

@ -2,8 +2,8 @@
//http://lua-users.org/wiki/SimplerCppBinding //http://lua-users.org/wiki/SimplerCppBinding
extern "C" { extern "C" {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
} }
template <typename T> class Luna template <typename T> class Luna

View File

@ -10,9 +10,9 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include "CommandInterface.h" #include "CommandInterface.h"

View File

@ -1,8 +1,8 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include <iostream> #include <iostream>
@ -79,6 +79,7 @@ int LuaTextbox::onTextChanged(lua_State * l)
{ {
onTextChangedFunction = 0; onTextChangedFunction = 0;
} }
return 0;
} }
void LuaTextbox::triggerOnTextChanged() void LuaTextbox::triggerOnTextChanged()

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
extern "C" { extern "C" {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include "LuaLuna.h" #include "LuaLuna.h"

View File

@ -1,8 +1,8 @@
extern "C" extern "C"
{ {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include <iostream> #include <iostream>
@ -353,6 +353,7 @@ int LuaWindow::onInitialized(lua_State * l)
{ {
onInitializedFunction = 0; onInitializedFunction = 0;
} }
return 0;
} }
int LuaWindow::onExit(lua_State * l) int LuaWindow::onExit(lua_State * l)
@ -367,6 +368,7 @@ int LuaWindow::onExit(lua_State * l)
{ {
onExitFunction = 0; onExitFunction = 0;
} }
return 0;
} }
int LuaWindow::onTick(lua_State * l) int LuaWindow::onTick(lua_State * l)
@ -381,6 +383,7 @@ int LuaWindow::onTick(lua_State * l)
{ {
onTickFunction = 0; onTickFunction = 0;
} }
return 0;
} }
int LuaWindow::onDraw(lua_State * l) int LuaWindow::onDraw(lua_State * l)
@ -395,6 +398,7 @@ int LuaWindow::onDraw(lua_State * l)
{ {
onDrawFunction = 0; onDrawFunction = 0;
} }
return 0;
} }
int LuaWindow::onFocus(lua_State * l) int LuaWindow::onFocus(lua_State * l)
@ -409,6 +413,7 @@ int LuaWindow::onFocus(lua_State * l)
{ {
onFocusFunction = 0; onFocusFunction = 0;
} }
return 0;
} }
int LuaWindow::onBlur(lua_State * l) int LuaWindow::onBlur(lua_State * l)
@ -423,6 +428,7 @@ int LuaWindow::onBlur(lua_State * l)
{ {
onBlurFunction = 0; onBlurFunction = 0;
} }
return 0;
} }
int LuaWindow::onTryExit(lua_State * l) int LuaWindow::onTryExit(lua_State * l)
@ -437,6 +443,7 @@ int LuaWindow::onTryExit(lua_State * l)
{ {
onTryExitFunction = 0; onTryExitFunction = 0;
} }
return 0;
} }
int LuaWindow::onTryOkay(lua_State * l) int LuaWindow::onTryOkay(lua_State * l)
@ -451,6 +458,7 @@ int LuaWindow::onTryOkay(lua_State * l)
{ {
onTryOkayFunction = 0; onTryOkayFunction = 0;
} }
return 0;
} }
int LuaWindow::onMouseMove(lua_State * l) int LuaWindow::onMouseMove(lua_State * l)
@ -465,6 +473,7 @@ int LuaWindow::onMouseMove(lua_State * l)
{ {
onMouseMoveFunction = 0; onMouseMoveFunction = 0;
} }
return 0;
} }
int LuaWindow::onMouseDown(lua_State * l) int LuaWindow::onMouseDown(lua_State * l)
@ -479,6 +488,7 @@ int LuaWindow::onMouseDown(lua_State * l)
{ {
onMouseDownFunction = 0; onMouseDownFunction = 0;
} }
return 0;
} }
int LuaWindow::onMouseUp(lua_State * l) int LuaWindow::onMouseUp(lua_State * l)
@ -493,6 +503,7 @@ int LuaWindow::onMouseUp(lua_State * l)
{ {
onMouseUpFunction = 0; onMouseUpFunction = 0;
} }
return 0;
} }
int LuaWindow::onMouseWheel(lua_State * l) int LuaWindow::onMouseWheel(lua_State * l)
@ -507,6 +518,7 @@ int LuaWindow::onMouseWheel(lua_State * l)
{ {
onMouseWheelFunction = 0; onMouseWheelFunction = 0;
} }
return 0;
} }
int LuaWindow::onKeyPress(lua_State * l) int LuaWindow::onKeyPress(lua_State * l)
@ -521,6 +533,7 @@ int LuaWindow::onKeyPress(lua_State * l)
{ {
onKeyPressFunction = 0; onKeyPressFunction = 0;
} }
return 0;
} }
int LuaWindow::onKeyRelease(lua_State * l) int LuaWindow::onKeyRelease(lua_State * l)
@ -535,6 +548,7 @@ int LuaWindow::onKeyRelease(lua_State * l)
{ {
onKeyReleaseFunction = 0; onKeyReleaseFunction = 0;
} }
return 0;
} }

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
extern "C" { extern "C" {
#include "lua.h" #include "lua5.1/lua.h"
#include "lauxlib.h" #include "lua5.1/lauxlib.h"
#include "lualib.h" #include "lua5.1/lualib.h"
} }
#include "LuaLuna.h" #include "LuaLuna.h"

View File

@ -2069,7 +2069,7 @@ void GameView::OnDraw()
ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2) ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)
{ {
ui::Point newPoint(0, 0); ui::Point newPoint(0, 0);
float snapAngle = floor(atan2(point2.Y-point1.Y, point2.X-point1.X)/(M_PI*0.25)+0.5)*M_PI*0.25; float snapAngle = floor(atan2((float)point2.Y-point1.Y, point2.X-point1.X)/(M_PI*0.25)+0.5)*M_PI*0.25;
float lineMag = sqrtf(pow((float)(point2.X-point1.X),2)+pow((float)(point2.Y-point1.Y),2)); float lineMag = sqrtf(pow((float)(point2.X-point1.X),2)+pow((float)(point2.Y-point1.Y),2));
newPoint.X = (int)(lineMag*cos(snapAngle)+point1.X+0.5f); newPoint.X = (int)(lineMag*cos(snapAngle)+point1.X+0.5f);
newPoint.Y = (int)(lineMag*sin(snapAngle)+point1.Y+0.5f); newPoint.Y = (int)(lineMag*sin(snapAngle)+point1.Y+0.5f);
@ -2079,7 +2079,7 @@ ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)
ui::Point GameView::rectSnapCoords(ui::Point point1, ui::Point point2) ui::Point GameView::rectSnapCoords(ui::Point point1, ui::Point point2)
{ {
ui::Point newPoint(0, 0); ui::Point newPoint(0, 0);
float snapAngle = floor((atan2(point2.Y-point1.Y, point2.X-point1.X)+M_PI*0.25)/(M_PI*0.5)+0.5)*M_PI*0.5 - M_PI*0.25; float snapAngle = floor((atan2((float)point2.Y-point1.Y, point2.X-point1.X)+M_PI*0.25)/(M_PI*0.5)+0.5)*M_PI*0.5 - M_PI*0.25;
float lineMag = sqrtf(pow((float)(point2.X-point1.X),2)+pow((float)(point2.Y-point1.Y),2)); float lineMag = sqrtf(pow((float)(point2.X-point1.X),2)+pow((float)(point2.Y-point1.Y),2));
newPoint.X = (int)(lineMag*cos(snapAngle)+point1.X+0.5f); newPoint.X = (int)(lineMag*cos(snapAngle)+point1.X+0.5f);
newPoint.Y = (int)(lineMag*sin(snapAngle)+point1.Y+0.5f); newPoint.Y = (int)(lineMag*sin(snapAngle)+point1.Y+0.5f);

View File

@ -53,9 +53,9 @@ public:
Type GetType() { return type; } Type GetType() { return type; }
virtual bool GetToggle() {} virtual bool GetToggle() { return true;}
virtual int GetMutli() {} virtual int GetMutli() { return 0;}
virtual int GetMultiCount() {} virtual int GetMultiCount() { return 0;}
std::string GetIcon() { return icon; } std::string GetIcon() { return icon; }
void SetIcon(std::string icon) { this->icon = icon; } void SetIcon(std::string icon) { this->icon = icon; }

View File

@ -96,7 +96,7 @@ TPT_INLINE void VideoBuffer::AddPixel(int x, int y, int r, int g, int b, int a)
Buffer[y*(Width)+x] = PIXRGB(r,g,b); Buffer[y*(Width)+x] = PIXRGB(r,g,b);
} }
TPT_INLINE int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a) TPT_NO_INLINE int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a)
{ {
int i, j, w, bn = 0, ba = 0; int i, j, w, bn = 0, ba = 0;
char *rp = font_data + font_ptrs[c]; char *rp = font_data + font_ptrs[c];
@ -116,7 +116,7 @@ TPT_INLINE int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int
return x + w; return x + w;
} }
TPT_INLINE int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, int b, int a) TPT_NO_INLINE int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, int b, int a)
{ {
int i, j, w, bn = 0, ba = 0; int i, j, w, bn = 0, ba = 0;
char *rp = font_data + font_ptrs[c]; char *rp = font_data + font_ptrs[c];
@ -136,7 +136,7 @@ TPT_INLINE int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, in
return x + w; return x + w;
} }
TPT_INLINE int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a) TPT_NO_INLINE int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a)
{ {
int i, j, w, bn = 0, ba = 0; int i, j, w, bn = 0, ba = 0;
char *rp = font_data + font_ptrs[c]; char *rp = font_data + font_ptrs[c];

View File

@ -150,7 +150,7 @@ TPT_INLINE int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, i
return x + w; return x + w;
} }
TPT_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a) TPT_NO_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
{ {
int i, j, w, bn = 0, ba = 0; int i, j, w, bn = 0, ba = 0;
char *rp = font_data + font_ptrs[c]; char *rp = font_data + font_ptrs[c];

View File

@ -116,7 +116,7 @@ TPT_INLINE int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, i
return x + w; return x + w;
} }
TPT_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a) TPT_NO_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
{ {
int i, j, w, bn = 0, ba = 0; int i, j, w, bn = 0, ba = 0;
char *rp = font_data + font_ptrs[c]; char *rp = font_data + font_ptrs[c];

View File

@ -1221,7 +1221,7 @@ void Renderer::render_parts()
{ {
gradv = 0.4f; gradv = 0.4f;
if (!(sim->parts[i].life<5)) if (!(sim->parts[i].life<5))
q = sqrt(sim->parts[i].life); q = sqrt((float)sim->parts[i].life);
else else
q = sim->parts[i].life; q = sim->parts[i].life;
colr = colg = colb = sin(gradv*q) * 100 + 128; colr = colg = colb = sin(gradv*q) * 100 + 128;

View File

@ -66,12 +66,12 @@ bool Button::GetTogglable()
return isTogglable; return isTogglable;
} }
inline bool Button::GetToggleState() TPT_NO_INLINE bool Button::GetToggleState()
{ {
return toggle; return toggle;
} }
inline void Button::SetToggleState(bool state) TPT_NO_INLINE void Button::SetToggleState(bool state)
{ {
toggle = state; toggle = state;
} }

View File

@ -47,8 +47,8 @@ public:
virtual void DoAction(); //action of button what ever it may be virtual void DoAction(); //action of button what ever it may be
void SetTogglable(bool isTogglable); void SetTogglable(bool isTogglable);
bool GetTogglable(); bool GetTogglable();
inline bool GetToggleState(); TPT_NO_INLINE bool GetToggleState();
inline void SetToggleState(bool state); TPT_NO_INLINE void SetToggleState(bool state);
void SetActionCallback(ButtonAction * action); void SetActionCallback(ButtonAction * action);
ButtonAction * GetActionCallback() { return actionCallback; } ButtonAction * GetActionCallback() { return actionCallback; }
void SetText(std::string buttonText); void SetText(std::string buttonText);

View File

@ -1,6 +1,6 @@
#if defined(USE_SDL) #if defined(USE_SDL)
#include "SDL.h" #include "SDL/SDL.h"
#define KEY_UP SDLK_UP #define KEY_UP SDLK_UP
#define KEY_DOWN SDLK_DOWN #define KEY_DOWN SDLK_DOWN
#define KEY_RIGHT SDLK_RIGHT #define KEY_RIGHT SDLK_RIGHT

View File

@ -79,13 +79,13 @@ int Slider::GetValue()
void Slider::SetColour(Colour col1, Colour col2) void Slider::SetColour(Colour col1, Colour col2)
{ {
pixel pix[2] = {PIXRGB(col1.Red, col1.Green, col1.Blue), PIXRGB(col2.Red, col2.Green, col2.Blue)};
float fl[2] = {0.0f, 1.0f};
if(bgGradient) if(bgGradient)
free(bgGradient); free(bgGradient);
this->col1 = col1; this->col1 = col1;
this->col2 = col2; this->col2 = col2;
bgGradient = (unsigned char*)Graphics::GenerateGradient( bgGradient = (unsigned char*)Graphics::GenerateGradient(pix, fl, 2, Size.X-7);
(pixel[2]){PIXRGB(col1.Red, col1.Green, col1.Blue), PIXRGB(col2.Red, col2.Green, col2.Blue)},
(float[2]){0.0f, 1.0f}, 2, Size.X-7);
} }
void Slider::SetValue(int value) void Slider::SetValue(int value)

View File

@ -159,7 +159,7 @@ int PreviewModel::GetCommentsPageNum()
int PreviewModel::GetCommentsPageCount() int PreviewModel::GetCommentsPageCount()
{ {
return max(1, (int)(ceil(commentsTotal/20))); return max(1, (int)(ceil(commentsTotal/20.0f)));
} }
bool PreviewModel::GetCommentsLoaded() bool PreviewModel::GetCommentsLoaded()

View File

@ -1,6 +1,9 @@
//#include <cstdlib> //#include <cstdlib>
#include <cmath> #include <cmath>
#include <math.h>
#if !defined(WIN) || defined(__GNUC__)
#include <strings.h> #include <strings.h>
#endif
#include "Config.h" #include "Config.h"
#include "Simulation.h" #include "Simulation.h"
#include "Elements.h" #include "Elements.h"
@ -1093,6 +1096,7 @@ int Simulation::ToolBrush(int positionX, int positionY, int tool, Brush * cBrush
if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES)) if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES))
Tool(positionX+(x-radiusX), positionY+(y-radiusY), tool, strength); Tool(positionX+(x-radiusX), positionY+(y-radiusY), tool, strength);
} }
return 0;
} }
void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength) void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength)
@ -1660,7 +1664,7 @@ void *Simulation::transform_save(void *odata, int *size, matrix2d transform, vec
return ndata; return ndata;
} }
inline void Simulation::orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]) TPT_NO_INLINE void Simulation::orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[])
{ {
resblock1[0] = (block1&0x000000FF); resblock1[0] = (block1&0x000000FF);
resblock1[1] = (block1&0x0000FF00)>>8; resblock1[1] = (block1&0x0000FF00)>>8;
@ -1673,7 +1677,7 @@ inline void Simulation::orbitalparts_get(int block1, int block2, int resblock1[]
resblock2[3] = (block2&0xFF000000)>>24; resblock2[3] = (block2&0xFF000000)>>24;
} }
inline void Simulation::orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]) TPT_NO_INLINE void Simulation::orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[])
{ {
int block1tmp = 0; int block1tmp = 0;
int block2tmp = 0; int block2tmp = 0;
@ -3952,11 +3956,7 @@ killed:
if (!parts[i].vx&&!parts[i].vy)//if its not moving, skip to next particle, movement code it next if (!parts[i].vx&&!parts[i].vy)//if its not moving, skip to next particle, movement code it next
continue; continue;
#if defined(WIN) && !defined(__GNUC__)
mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy));
#else
mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy)); mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy));
#endif
if (mv < ISTP) if (mv < ISTP)
{ {
clear_x = x; clear_x = x;

View File

@ -156,7 +156,7 @@ public:
inline int is_wire(int x, int y); inline int is_wire(int x, int y);
inline int is_wire_off(int x, int y); inline int is_wire_off(int x, int y);
inline void set_emap(int x, int y); inline void set_emap(int x, int y);
inline int parts_avg(int ci, int ni, int t); TPT_NO_INLINE int parts_avg(int ci, int ni, int t);
void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags); void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags);
int nearest_part(int ci, int t, int max_d); int nearest_part(int ci, int t, int max_d);
void update_particles_i(int start, int inc); void update_particles_i(int start, int inc);
@ -196,8 +196,8 @@ public:
int GetParticleType(std::string type); int GetParticleType(std::string type);
void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate); void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate);
inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); TPT_NO_INLINE void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]);
inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); TPT_NO_INLINE void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]);
inline int get_wavelength_bin(int *wm); inline int get_wavelength_bin(int *wm);
inline int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny); inline int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny);
inline int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, float *ny); inline int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, float *ny);

View File

@ -115,7 +115,7 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
dy = parts[i].y - parts[r>>8].y; dy = parts[i].y - parts[r>>8].y;
//Stickness //Stickness
if ((dx*dx + dy*dy)>1.5 && (gel || !sim->elements[r&0xFF].Falldown || (fabs(rx)<2 && fabs(ry)<2))) if ((dx*dx + dy*dy)>1.5 && (gel || !sim->elements[r&0xFF].Falldown || (fabs((float)rx)<2 && fabs((float)ry)<2)))
{ {
float per, nd; float per, nd;
nd = dx*dx + dy*dy - 0.5; nd = dx*dx + dy*dy - 0.5;

View File

@ -121,7 +121,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
parts[i].life=60; parts[i].life=60;
parts[p].temp=parts[p].life*parts[i].tmp/2.5; parts[p].temp=parts[p].life*parts[i].tmp/2.5;
parts[p].tmp2=1; parts[p].tmp2=1;
parts[p].tmp=atan2(-ry, rx)/M_PI*360; parts[p].tmp=atan2(-ry, (float)rx)/M_PI*360;
parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling
if (fabs(sim->pv[y/CELL][x/CELL])!=0.0f) if (fabs(sim->pv[y/CELL][x/CELL])!=0.0f)
{ {

View File

@ -17,7 +17,7 @@ public:
SimTool(); SimTool();
virtual ~SimTool() {} virtual ~SimTool() {}
virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) {} virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) { return 0; }
}; };
#endif #endif