Merge pull request #180 from mniip/warnings

Warnings
This commit is contained in:
jacob1 2013-10-29 19:24:20 -07:00
commit 45bf0dfcdb
38 changed files with 276 additions and 280 deletions

View File

@ -253,7 +253,7 @@ if GetOption("toolprefix"):
# make sure the compiler can find the source data and generated files. enable warnings, set C++ flavor, and keep inline functions # make sure the compiler can find the source data and generated files. enable warnings, set C++ flavor, and keep inline functions
env.Append(CPPPATH=['src/', 'data/', 'generated/']) env.Append(CPPPATH=['src/', 'data/', 'generated/'])
env.Append(CCFLAGS=['-w', '-std=c++98', '-fkeep-inline-functions']) env.Append(CXXFLAGS=['-std=c++98'])
env.Append(LIBS=['pthread', 'm']) env.Append(LIBS=['pthread', 'm'])
env.Append(CPPDEFINES=["_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"]) env.Append(CPPDEFINES=["_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"])

View File

@ -53,4 +53,4 @@ static const char *introTextData =
#ifdef REALISTIC #ifdef REALISTIC
"REALISTIC" "REALISTIC"
#endif #endif
; ;

File diff suppressed because one or more lines are too long

View File

@ -181,13 +181,10 @@ extern unsigned char ZSIZE;
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define TPT_INLINE _inline #define TPT_INLINE _inline
#define TPT_NO_INLINE
#elif defined(__llvm__) #elif defined(__llvm__)
#define TPT_INLINE #define TPT_INLINE
#define TPT_NO_INLINE
#else #else
#define TPT_INLINE inline #define TPT_INLINE inline
#define TPT_NO_INLINE inline
#endif #endif
#define SDEUT #define SDEUT

View File

@ -73,7 +73,7 @@ std::string format::UnixtimeToDateMini(time_t unixtime)
std::string format::CleanString(std::string dirtyString, int maxStringLength) std::string format::CleanString(std::string dirtyString, int maxStringLength)
{ {
return CleanString(dirtyString, std::string::npos, maxStringLength); return CleanString(dirtyString, (int)std::string::npos, maxStringLength);
} }
std::string format::CleanString(std::string dirtyString, int maxVisualSize, int maxStringLength) std::string format::CleanString(std::string dirtyString, int maxVisualSize, int maxStringLength)
@ -97,7 +97,7 @@ std::string format::CleanString(std::string dirtyString, int maxVisualSize, int
std::string format::CleanString(char * dirtyData, int maxStringLength) std::string format::CleanString(char * dirtyData, int maxStringLength)
{ {
return CleanString(dirtyData, std::string::npos, maxStringLength); return CleanString(dirtyData, (int)std::string::npos, maxStringLength);
} }
std::string format::CleanString(char * dirtyData, int maxVisualSize, int maxStringLength) std::string format::CleanString(char * dirtyData, int maxVisualSize, int maxStringLength)

View File

@ -101,7 +101,7 @@ int isign(float i) //TODO: INline or macro
return 0; return 0;
} }
TPT_NO_INLINE unsigned clamp_flt(float f, float min, float max) //TODO: Also inline/macro unsigned clamp_flt(float f, float min, float max) //TODO: Also inline/macro
{ {
if (f<min) if (f<min)
return 0; return 0;
@ -110,7 +110,7 @@ TPT_NO_INLINE unsigned clamp_flt(float f, float min, float max) //TODO: Also inl
return (int)(255.0f*(f-min)/(max-min)); return (int)(255.0f*(f-min)/(max-min));
} }
TPT_NO_INLINE float restrict_flt(float f, float min, float max) //TODO Inline or macro or something 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;
@ -119,7 +119,7 @@ TPT_NO_INLINE float restrict_flt(float f, float min, float max) //TODO Inline or
return f; return f;
} }
char *mystrdup(char *s) char *mystrdup(const char *s)
{ {
char *x; char *x;
if (s) if (s)
@ -128,7 +128,7 @@ char *mystrdup(char *s)
strcpy(x, s); strcpy(x, s);
return x; return x;
} }
return s; return NULL;
} }
void strlist_add(struct strlist **list, char *str) void strlist_add(struct strlist **list, char *str)
@ -221,7 +221,7 @@ void strcaturl(char *dst, char *src)
*d = 0; *d = 0;
} }
void strappend(char *dst, char *src) void strappend(char *dst, const char *src)
{ {
char *d; char *d;
unsigned char *s; unsigned char *s;
@ -465,7 +465,7 @@ int register_extension()
#elif defined(LIN) #elif defined(LIN)
char *currentfilename = exe_name(); char *currentfilename = exe_name();
FILE *f; FILE *f;
char *mimedata = const char *mimedata =
"<?xml version=\"1.0\"?>\n" "<?xml version=\"1.0\"?>\n"
" <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n" " <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
" <mime-type type=\"application/vnd.powdertoy.save\">\n" " <mime-type type=\"application/vnd.powdertoy.save\">\n"
@ -480,7 +480,7 @@ int register_extension()
fwrite(mimedata, 1, strlen(mimedata), f); fwrite(mimedata, 1, strlen(mimedata), f);
fclose(f); fclose(f);
char *desktopfiledata_tmp = const char *desktopfiledata_tmp =
"[Desktop Entry]\n" "[Desktop Entry]\n"
"Type=Application\n" "Type=Application\n"
"Name=Powder Toy\n" "Name=Powder Toy\n"

View File

@ -40,7 +40,7 @@ unsigned clamp_flt(float f, float min, float max);
float restrict_flt(float f, float min, float max); float restrict_flt(float f, float min, float max);
char *mystrdup(char *s); char *mystrdup(const char *s);
struct strlist struct strlist
{ {
@ -64,11 +64,11 @@ void save_string(FILE *f, char *str);
int load_string(FILE *f, char *str, int max); int load_string(FILE *f, char *str, int max);
void strcaturl(char *dst, char *src); void strcaturl(char *dst, const char *src);
std::string URLEscape(std::string source); std::string URLEscape(std::string source);
void strappend(char *dst, char *src); void strappend(char *dst, const char *src);
void *file_load(char *fn, int *size); void *file_load(char *fn, int *size);

View File

@ -687,7 +687,7 @@ bool SaveWindowPosition()
#endif #endif
void BlueScreen(char * detailMessage){ void BlueScreen(const char * detailMessage){
ui::Engine * engine = &ui::Engine::Ref(); ui::Engine * engine = &ui::Engine::Ref();
engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210); engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210);

View File

@ -48,7 +48,7 @@ static int ( *oid_inc_func )( void ) = NULL;
------------------------------ */ ------------------------------ */
bson *bson_empty( bson *obj ) { bson *bson_empty( bson *obj ) {
static char *data = "\005\0\0\0\0"; static char data[] = "\005\0\0\0\0";
bson_init_data( obj, data ); bson_init_data( obj, data );
obj->finished = 1; obj->finished = 1;
obj->err = 0; obj->err = 0;

View File

@ -44,7 +44,7 @@ namespace json
{ {
TPT_NO_INLINE Exception::Exception(const std::string& sMessage) : Exception::Exception(const std::string& sMessage) :
std::runtime_error(sMessage) {} std::runtime_error(sMessage) {}
@ -129,32 +129,32 @@ public:
TPT_NO_INLINE UnknownElement::UnknownElement() : m_pImp( new Imp_T<Null>( Null() ) ) {} UnknownElement::UnknownElement() : m_pImp( new Imp_T<Null>( Null() ) ) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp( unknown.m_pImp->Clone()) {} UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp( unknown.m_pImp->Clone()) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T<Object>(object) ) {} UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T<Object>(object) ) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T<Array>(array) ) {} UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T<Array>(array) ) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const Number& number) : m_pImp( new Imp_T<Number>(number) ) {} UnknownElement::UnknownElement(const Number& number) : m_pImp( new Imp_T<Number>(number) ) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const Boolean& boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {} UnknownElement::UnknownElement(const Boolean& boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T<String>(string) ) {} UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T<String>(string) ) {}
TPT_NO_INLINE UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T<Null>(null) ) {} UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T<Null>(null) ) {}
TPT_NO_INLINE UnknownElement::~UnknownElement() { delete m_pImp; } UnknownElement::~UnknownElement() { delete m_pImp; }
TPT_NO_INLINE UnknownElement::operator const Object& () const { return CastTo<Object>(); } UnknownElement::operator const Object& () const { return CastTo<Object>(); }
TPT_NO_INLINE UnknownElement::operator const Array& () const { return CastTo<Array>(); } UnknownElement::operator const Array& () const { return CastTo<Array>(); }
TPT_NO_INLINE UnknownElement::operator const Number& () const { return CastTo<Number>(); } UnknownElement::operator const Number& () const { return CastTo<Number>(); }
TPT_NO_INLINE UnknownElement::operator const Boolean& () const { return CastTo<Boolean>(); } UnknownElement::operator const Boolean& () const { return CastTo<Boolean>(); }
TPT_NO_INLINE UnknownElement::operator const String& () const { return CastTo<String>(); } UnknownElement::operator const String& () const { return CastTo<String>(); }
TPT_NO_INLINE UnknownElement::operator const Null& () const { return CastTo<Null>(); } UnknownElement::operator const Null& () const { return CastTo<Null>(); }
TPT_NO_INLINE UnknownElement::operator Object& () { return ConvertTo<Object>(); } UnknownElement::operator Object& () { return ConvertTo<Object>(); }
TPT_NO_INLINE UnknownElement::operator Array& () { return ConvertTo<Array>(); } UnknownElement::operator Array& () { return ConvertTo<Array>(); }
TPT_NO_INLINE UnknownElement::operator Number& () { return ConvertTo<Number>(); } UnknownElement::operator Number& () { return ConvertTo<Number>(); }
TPT_NO_INLINE UnknownElement::operator Boolean& () { return ConvertTo<Boolean>(); } UnknownElement::operator Boolean& () { return ConvertTo<Boolean>(); }
TPT_NO_INLINE UnknownElement::operator String& () { return ConvertTo<String>(); } UnknownElement::operator String& () { return ConvertTo<String>(); }
TPT_NO_INLINE UnknownElement::operator Null& () { return ConvertTo<Null>(); } UnknownElement::operator Null& () { return ConvertTo<Null>(); }
TPT_NO_INLINE UnknownElement& UnknownElement::operator = (const UnknownElement& unknown) UnknownElement& UnknownElement::operator = (const UnknownElement& unknown)
{ {
// always check for this // always check for this
if (&unknown != this) if (&unknown != this)
@ -170,28 +170,28 @@ TPT_NO_INLINE UnknownElement& UnknownElement::operator = (const UnknownElement&
return *this; return *this;
} }
TPT_NO_INLINE UnknownElement& UnknownElement::operator[] (const std::string& key) 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];
} }
TPT_NO_INLINE const UnknownElement& UnknownElement::operator[] (const std::string& key) const 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];
} }
TPT_NO_INLINE UnknownElement& UnknownElement::operator[] (size_t index) 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];
} }
TPT_NO_INLINE const UnknownElement& UnknownElement::operator[] (size_t index) const 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()
} }
TPT_NO_INLINE void UnknownElement::Accept(ConstVisitor& visitor) const { m_pImp->Accept(visitor); } void UnknownElement::Accept(ConstVisitor& visitor) const { m_pImp->Accept(visitor); }
TPT_NO_INLINE void UnknownElement::Accept(Visitor& visitor) { m_pImp->Accept(visitor); } void UnknownElement::Accept(Visitor& visitor) { m_pImp->Accept(visitor); }
TPT_NO_INLINE bool UnknownElement::operator == (const UnknownElement& element) const 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 @@ TPT_NO_INLINE bool UnknownElement::operator == (const UnknownElement& element) c
// Object members // Object members
TPT_NO_INLINE Object::Member::Member(const std::string& nameIn, const UnknownElement& elementIn) : Object::Member::Member(const std::string& nameIn, const UnknownElement& elementIn) :
name(nameIn), element(elementIn) {} name(nameIn), element(elementIn) {}
TPT_NO_INLINE bool Object::Member::operator == (const Member& member) const 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:
TPT_NO_INLINE Object::iterator Object::Begin() { return m_Members.begin(); } Object::iterator Object::Begin() { return m_Members.begin(); }
TPT_NO_INLINE Object::iterator Object::End() { return m_Members.end(); } Object::iterator Object::End() { return m_Members.end(); }
TPT_NO_INLINE Object::const_iterator Object::Begin() const { return m_Members.begin(); } Object::const_iterator Object::Begin() const { return m_Members.begin(); }
TPT_NO_INLINE Object::const_iterator Object::End() const { return m_Members.end(); } Object::const_iterator Object::End() const { return m_Members.end(); }
TPT_NO_INLINE size_t Object::Size() const { return m_Members.size(); } size_t Object::Size() const { return m_Members.size(); }
TPT_NO_INLINE bool Object::Empty() const { return m_Members.empty(); } bool Object::Empty() const { return m_Members.empty(); }
TPT_NO_INLINE Object::iterator Object::Find(const std::string& name) 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));
} }
TPT_NO_INLINE Object::const_iterator Object::Find(const std::string& name) const 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));
} }
TPT_NO_INLINE Object::iterator Object::Insert(const Member& member) Object::iterator Object::Insert(const Member& member)
{ {
return Insert(member, End()); return Insert(member, End());
} }
TPT_NO_INLINE Object::iterator Object::Insert(const Member& member, iterator itWhere) 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 @@ TPT_NO_INLINE Object::iterator Object::Insert(const Member& member, iterator itW
return it; return it;
} }
TPT_NO_INLINE Object::iterator Object::Erase(iterator itWhere) Object::iterator Object::Erase(iterator itWhere)
{ {
return m_Members.erase(itWhere); return m_Members.erase(itWhere);
} }
TPT_NO_INLINE UnknownElement& Object::operator [](const std::string& name) UnknownElement& Object::operator [](const std::string& name)
{ {
iterator it = Find(name); iterator it = Find(name);
@ -315,7 +315,7 @@ TPT_NO_INLINE UnknownElement& Object::operator [](const std::string& name)
return it->element; return it->element;
} }
TPT_NO_INLINE const UnknownElement& Object::operator [](const std::string& name) const 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 @@ TPT_NO_INLINE const UnknownElement& Object::operator [](const std::string& name)
return it->element; return it->element;
} }
TPT_NO_INLINE void Object::Clear() void Object::Clear()
{ {
m_Members.clear(); m_Members.clear();
} }
TPT_NO_INLINE bool Object::operator == (const Object& object) const bool Object::operator == (const Object& object) const
{ {
return m_Members == object.m_Members; return m_Members == object.m_Members;
} }
@ -337,35 +337,35 @@ TPT_NO_INLINE bool Object::operator == (const Object& object) const
///////////////// /////////////////
// Array members // Array members
TPT_NO_INLINE Array::iterator Array::Begin() { return m_Elements.begin(); } Array::iterator Array::Begin() { return m_Elements.begin(); }
TPT_NO_INLINE Array::iterator Array::End() { return m_Elements.end(); } Array::iterator Array::End() { return m_Elements.end(); }
TPT_NO_INLINE Array::const_iterator Array::Begin() const { return m_Elements.begin(); } Array::const_iterator Array::Begin() const { return m_Elements.begin(); }
TPT_NO_INLINE Array::const_iterator Array::End() const { return m_Elements.end(); } Array::const_iterator Array::End() const { return m_Elements.end(); }
TPT_NO_INLINE Array::iterator Array::Insert(const UnknownElement& element, iterator itWhere) Array::iterator Array::Insert(const UnknownElement& element, iterator itWhere)
{ {
return m_Elements.insert(itWhere, element); return m_Elements.insert(itWhere, element);
} }
TPT_NO_INLINE Array::iterator Array::Insert(const UnknownElement& element) Array::iterator Array::Insert(const UnknownElement& element)
{ {
return Insert(element, End()); return Insert(element, End());
} }
TPT_NO_INLINE Array::iterator Array::Erase(iterator itWhere) Array::iterator Array::Erase(iterator itWhere)
{ {
return m_Elements.erase(itWhere); return m_Elements.erase(itWhere);
} }
TPT_NO_INLINE void Array::Resize(size_t newSize) void Array::Resize(size_t newSize)
{ {
m_Elements.resize(newSize); m_Elements.resize(newSize);
} }
TPT_NO_INLINE size_t Array::Size() const { return m_Elements.size(); } size_t Array::Size() const { return m_Elements.size(); }
TPT_NO_INLINE bool Array::Empty() const { return m_Elements.empty(); } bool Array::Empty() const { return m_Elements.empty(); }
TPT_NO_INLINE UnknownElement& Array::operator[] (size_t index) 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 @@ TPT_NO_INLINE UnknownElement& Array::operator[] (size_t index)
return m_Elements[index]; return m_Elements[index];
} }
TPT_NO_INLINE const UnknownElement& Array::operator[] (size_t index) const 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];
} }
TPT_NO_INLINE void Array::Clear() { void Array::Clear() {
m_Elements.clear(); m_Elements.clear();
} }
TPT_NO_INLINE bool Array::operator == (const Array& array) const bool Array::operator == (const Array& array) const
{ {
return m_Elements == array.m_Elements; return m_Elements == array.m_Elements;
} }
@ -393,7 +393,7 @@ TPT_NO_INLINE bool Array::operator == (const Array& array) const
////////////////// //////////////////
// Null members // Null members
TPT_NO_INLINE bool Null::operator == (const Null& trivial) const bool Null::operator == (const Null& trivial) const
{ {
return true; return true;
} }

View File

@ -43,12 +43,12 @@ TODO:
namespace json namespace json
{ {
TPT_NO_INLINE std::istream& operator >> (std::istream& istr, UnknownElement& elementRoot) { std::istream& operator >> (std::istream& istr, UnknownElement& elementRoot) {
Reader::Read(elementRoot, istr); Reader::Read(elementRoot, istr);
return istr; return istr;
} }
TPT_NO_INLINE Reader::Location::Location() : 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:
}; };
TPT_NO_INLINE char Reader::InputStream::Get() 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:
}; };
TPT_NO_INLINE Reader::TokenStream::TokenStream(const Tokens& tokens) : Reader::TokenStream::TokenStream(const Tokens& tokens) :
m_Tokens(tokens), m_Tokens(tokens),
m_itCurrent(tokens.begin()) m_itCurrent(tokens.begin())
{} {}
TPT_NO_INLINE const Reader::Token& Reader::TokenStream::Peek() { 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 @@ TPT_NO_INLINE const Reader::Token& Reader::TokenStream::Peek() {
return *(m_itCurrent); return *(m_itCurrent);
} }
TPT_NO_INLINE const Reader::Token& Reader::TokenStream::Get() { const Reader::Token& Reader::TokenStream::Get() {
const Token& token = Peek(); const Token& token = Peek();
++m_itCurrent; ++m_itCurrent;
return token; return token;
} }
TPT_NO_INLINE bool Reader::TokenStream::EOS() const { bool Reader::TokenStream::EOS() const {
return m_itCurrent == m_Tokens.end(); return m_itCurrent == m_Tokens.end();
} }
@ -151,13 +151,13 @@ TPT_NO_INLINE bool Reader::TokenStream::EOS() const {
// Reader (finally) // Reader (finally)
TPT_NO_INLINE void Reader::Read(Object& object, std::istream& istr) { Read_i(object, istr); } void Reader::Read(Object& object, std::istream& istr) { Read_i(object, istr); }
TPT_NO_INLINE void Reader::Read(Array& array, std::istream& istr) { Read_i(array, istr); } void Reader::Read(Array& array, std::istream& istr) { Read_i(array, istr); }
TPT_NO_INLINE void Reader::Read(String& string, std::istream& istr) { Read_i(string, istr); } void Reader::Read(String& string, std::istream& istr) { Read_i(string, istr); }
TPT_NO_INLINE void Reader::Read(Number& number, std::istream& istr) { Read_i(number, istr); } void Reader::Read(Number& number, std::istream& istr) { Read_i(number, istr); }
TPT_NO_INLINE void Reader::Read(Boolean& boolean, std::istream& istr) { Read_i(boolean, istr); } void Reader::Read(Boolean& boolean, std::istream& istr) { Read_i(boolean, istr); }
TPT_NO_INLINE void Reader::Read(Null& null, std::istream& istr) { Read_i(null, istr); } void Reader::Read(Null& null, std::istream& istr) { Read_i(null, istr); }
TPT_NO_INLINE void Reader::Read(UnknownElement& unknown, std::istream& istr) { Read_i(unknown, istr); } 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)
} }
TPT_NO_INLINE void Reader::Scan(Tokens& tokens, InputStream& inputStream) 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 @@ TPT_NO_INLINE void Reader::Scan(Tokens& tokens, InputStream& inputStream)
} }
TPT_NO_INLINE void Reader::EatWhiteSpace(InputStream& inputStream) void Reader::EatWhiteSpace(InputStream& inputStream)
{ {
while (inputStream.EOS() == false && while (inputStream.EOS() == false &&
::isspace(inputStream.Peek())) ::isspace(inputStream.Peek()))
inputStream.Get(); inputStream.Get();
} }
TPT_NO_INLINE std::string Reader::MatchExpectedString(InputStream& inputStream, const std::string& sExpected) 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 @@ TPT_NO_INLINE std::string Reader::MatchExpectedString(InputStream& inputStream,
} }
TPT_NO_INLINE std::string Reader::MatchString(InputStream& inputStream) std::string Reader::MatchString(InputStream& inputStream)
{ {
MatchExpectedString(inputStream, "\""); MatchExpectedString(inputStream, "\"");
@ -341,7 +341,7 @@ TPT_NO_INLINE std::string Reader::MatchString(InputStream& inputStream)
} }
TPT_NO_INLINE std::string Reader::MatchNumber(InputStream& inputStream) 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 @@ TPT_NO_INLINE std::string Reader::MatchNumber(InputStream& inputStream)
} }
TPT_NO_INLINE void Reader::Parse(UnknownElement& element, Reader::TokenStream& tokenStream) 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 @@ TPT_NO_INLINE void Reader::Parse(UnknownElement& element, Reader::TokenStream& t
} }
TPT_NO_INLINE void Reader::Parse(Object& object, Reader::TokenStream& tokenStream) void Reader::Parse(Object& object, Reader::TokenStream& tokenStream)
{ {
MatchExpectedToken(Token::TOKEN_OBJECT_BEGIN, tokenStream); MatchExpectedToken(Token::TOKEN_OBJECT_BEGIN, tokenStream);
@ -456,7 +456,7 @@ TPT_NO_INLINE void Reader::Parse(Object& object, Reader::TokenStream& tokenStrea
} }
TPT_NO_INLINE void Reader::Parse(Array& array, Reader::TokenStream& tokenStream) void Reader::Parse(Array& array, Reader::TokenStream& tokenStream)
{ {
MatchExpectedToken(Token::TOKEN_ARRAY_BEGIN, tokenStream); MatchExpectedToken(Token::TOKEN_ARRAY_BEGIN, tokenStream);
@ -479,13 +479,13 @@ TPT_NO_INLINE void Reader::Parse(Array& array, Reader::TokenStream& tokenStream)
} }
TPT_NO_INLINE void Reader::Parse(String& string, Reader::TokenStream& tokenStream) void Reader::Parse(String& string, Reader::TokenStream& tokenStream)
{ {
string = MatchExpectedToken(Token::TOKEN_STRING, tokenStream); string = MatchExpectedToken(Token::TOKEN_STRING, tokenStream);
} }
TPT_NO_INLINE void Reader::Parse(Number& number, Reader::TokenStream& tokenStream) 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 @@ TPT_NO_INLINE void Reader::Parse(Number& number, Reader::TokenStream& tokenStrea
} }
TPT_NO_INLINE void Reader::Parse(Boolean& boolean, Reader::TokenStream& tokenStream) 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);
} }
TPT_NO_INLINE void Reader::Parse(Null&, Reader::TokenStream& tokenStream) void Reader::Parse(Null&, Reader::TokenStream& tokenStream)
{ {
MatchExpectedToken(Token::TOKEN_NULL, tokenStream); MatchExpectedToken(Token::TOKEN_NULL, tokenStream);
} }
TPT_NO_INLINE const std::string& Reader::MatchExpectedToken(Token::Type nExpected, Reader::TokenStream& tokenStream) 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
{ {
TPT_NO_INLINE void Writer::Write(const UnknownElement& elementRoot, std::ostream& ostr) { Write_i(elementRoot, ostr); } void Writer::Write(const UnknownElement& elementRoot, std::ostream& ostr) { Write_i(elementRoot, ostr); }
TPT_NO_INLINE void Writer::Write(const Object& object, std::ostream& ostr) { Write_i(object, ostr); } void Writer::Write(const Object& object, std::ostream& ostr) { Write_i(object, ostr); }
TPT_NO_INLINE void Writer::Write(const Array& array, std::ostream& ostr) { Write_i(array, ostr); } void Writer::Write(const Array& array, std::ostream& ostr) { Write_i(array, ostr); }
TPT_NO_INLINE void Writer::Write(const Number& number, std::ostream& ostr) { Write_i(number, ostr); } void Writer::Write(const Number& number, std::ostream& ostr) { Write_i(number, ostr); }
TPT_NO_INLINE void Writer::Write(const String& string, std::ostream& ostr) { Write_i(string, ostr); } void Writer::Write(const String& string, std::ostream& ostr) { Write_i(string, ostr); }
TPT_NO_INLINE void Writer::Write(const Boolean& boolean, std::ostream& ostr) { Write_i(boolean, ostr); } void Writer::Write(const Boolean& boolean, std::ostream& ostr) { Write_i(boolean, ostr); }
TPT_NO_INLINE void Writer::Write(const Null& null, std::ostream& ostr) { Write_i(null, ostr); } void Writer::Write(const Null& null, std::ostream& ostr) { Write_i(null, ostr); }
TPT_NO_INLINE Writer::Writer(std::ostream& ostr) : 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
} }
TPT_NO_INLINE void Writer::Write_i(const Array& array) void Writer::Write_i(const Array& array)
{ {
if (array.Empty()) if (array.Empty())
m_ostr << "[]"; m_ostr << "[]";
@ -91,7 +91,7 @@ TPT_NO_INLINE void Writer::Write_i(const Array& array)
} }
} }
TPT_NO_INLINE void Writer::Write_i(const Object& object) void Writer::Write_i(const Object& object)
{ {
if (object.Empty()) if (object.Empty())
m_ostr << "{}"; m_ostr << "{}";
@ -120,17 +120,17 @@ TPT_NO_INLINE void Writer::Write_i(const Object& object)
} }
} }
TPT_NO_INLINE void Writer::Write_i(const Number& numberElement) void Writer::Write_i(const Number& numberElement)
{ {
m_ostr << std::setprecision(20) << numberElement.Value(); m_ostr << std::setprecision(20) << numberElement.Value();
} }
TPT_NO_INLINE void Writer::Write_i(const Boolean& booleanElement) void Writer::Write_i(const Boolean& booleanElement)
{ {
m_ostr << (booleanElement.Value() ? "true" : "false"); m_ostr << (booleanElement.Value() ? "true" : "false");
} }
TPT_NO_INLINE void Writer::Write_i(const String& stringElement) void Writer::Write_i(const String& stringElement)
{ {
m_ostr << '"'; m_ostr << '"';
@ -156,22 +156,22 @@ TPT_NO_INLINE void Writer::Write_i(const String& stringElement)
m_ostr << '"'; m_ostr << '"';
} }
TPT_NO_INLINE void Writer::Write_i(const Null& ) void Writer::Write_i(const Null& )
{ {
m_ostr << "null"; m_ostr << "null";
} }
TPT_NO_INLINE void Writer::Write_i(const UnknownElement& unknown) void Writer::Write_i(const UnknownElement& unknown)
{ {
unknown.Accept(*this); unknown.Accept(*this);
} }
TPT_NO_INLINE void Writer::Visit(const Array& array) { Write_i(array); } void Writer::Visit(const Array& array) { Write_i(array); }
TPT_NO_INLINE void Writer::Visit(const Object& object) { Write_i(object); } void Writer::Visit(const Object& object) { Write_i(object); }
TPT_NO_INLINE void Writer::Visit(const Number& number) { Write_i(number); } void Writer::Visit(const Number& number) { Write_i(number); }
TPT_NO_INLINE void Writer::Visit(const String& string) { Write_i(string); } void Writer::Visit(const String& string) { Write_i(string); }
TPT_NO_INLINE void Writer::Visit(const Boolean& boolean) { Write_i(boolean); } void Writer::Visit(const Boolean& boolean) { Write_i(boolean); }
TPT_NO_INLINE void Writer::Visit(const Null& null) { Write_i(null); } void Writer::Visit(const Null& null) { Write_i(null); }

View File

@ -650,7 +650,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s
} }
int luacon_eval(char *command){ int luacon_eval(const char *command){
ui::Engine::Ref().LastTick(clock()); ui::Engine::Ref().LastTick(clock());
return luaL_dostring (luacon_ci->l, command); return luaL_dostring (luacon_ci->l, command);
} }
@ -1917,7 +1917,8 @@ int luatpt_setfpscap(lua_State* l)
} }
int luatpt_getscript(lua_State* l) int luatpt_getscript(lua_State* l)
{ {
char *filedata = NULL, *fileuri = NULL, *filename = NULL, *lastError = NULL, *luacommand = NULL; char *filedata = NULL, *fileuri = NULL, *filename = NULL, *luacommand = NULL;
const char *lastError = NULL;
std::string fileauthor = "", fileid = ""; std::string fileauthor = "", fileid = "";
int len, ret,run_script; int len, ret,run_script;
FILE * outputfile; FILE * outputfile;
@ -1998,7 +1999,10 @@ fin:
if(luacommand) delete[] luacommand; if(luacommand) delete[] luacommand;
luacommand = NULL; luacommand = NULL;
if(lastError) return luaL_error(l, lastError); if(lastError)
{
return luaL_error(l, lastError);
}
return 0; return 0;
} }

View File

@ -24,7 +24,7 @@ void luacon_hook(lua_State *L, lua_Debug *ar);
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, int bsx, int bsy); int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, int bsx, int bsy);
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel); int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
int luacon_keyevent(int key, int modifier, int event); int luacon_keyevent(int key, int modifier, int event);
int luacon_eval(char *command); int luacon_eval(const char *command);
char *luacon_geterror(); char *luacon_geterror();
void luacon_close(); void luacon_close();
int luacon_partsread(lua_State* l); int luacon_partsread(lua_State* l);

View File

@ -3,7 +3,7 @@
#include <stdint.h> #include <stdint.h>
#include "TPTSTypes.h" #include "TPTSTypes.h"
AnyType::AnyType(ValueType type_, void * value_): AnyType::AnyType(ValueType type_, ValueValue value_):
type(type_), type(type_),
value(value_) value(value_)
{ {
@ -19,13 +19,9 @@ AnyType::AnyType(const AnyType & v):
value(v.value) value(v.value)
{ {
if(type == TypeString) if(type == TypeString)
{ value.str = new std::string(*(value.str));
value = new std::string(*((std::string*)value));
}
else if(type == TypePoint) else if(type == TypePoint)
{ value.pt = new ui::Point(*(value.pt));
value = new ui::Point(*((ui::Point*)value));
}
} }
AnyType::operator NumberType() AnyType::operator NumberType()
@ -33,7 +29,7 @@ AnyType::operator NumberType()
if(type != TypeNumber) if(type != TypeNumber)
throw InvalidConversionException(type, TypeNumber); throw InvalidConversionException(type, TypeNumber);
else else
return NumberType((intptr_t)value); return NumberType(value.num);
} }
AnyType::operator StringType() AnyType::operator StringType()
@ -41,16 +37,16 @@ AnyType::operator StringType()
if(type == TypeNumber) if(type == TypeNumber)
{ {
std::stringstream numberStream; std::stringstream numberStream;
numberStream << ((NumberType*)this)->Value(); numberStream << ((NumberType *)this)->Value();
return StringType(numberStream.str()); return StringType(numberStream.str());
} }
else if(type == TypeString && value) else if(type == TypeString && value.str)
{ {
return StringType(*((std::string*)value)); return StringType(*(value.str));
} }
else if (type == TypePoint && value) else if (type == TypePoint && value.pt)
{ {
ui::Point thisPoint = *((ui::Point*)value); ui::Point thisPoint = *(value.pt);
std::stringstream pointStream; std::stringstream pointStream;
pointStream << thisPoint.X << "," << thisPoint.Y; pointStream << thisPoint.X << "," << thisPoint.Y;
return StringType(pointStream.str()); return StringType(pointStream.str());
@ -64,11 +60,11 @@ AnyType::operator PointType()
{ {
if(type == TypePoint) if(type == TypePoint)
{ {
return PointType(*((ui::Point*)value)); return PointType(*(value.pt));
} }
else if(type == TypeString) else if(type == TypeString)
{ {
std::stringstream pointStream(*((std::string*)value)); std::stringstream pointStream(*(value.str));
int x, y; int x, y;
char comma; char comma;
pointStream >> x >> comma >> y; pointStream >> x >> comma >> y;
@ -82,35 +78,49 @@ AnyType::operator PointType()
AnyType::~AnyType() AnyType::~AnyType()
{ {
if(type == TypeString || type == TypePoint) if(type == TypeString)
delete value; delete value.str;
else if(type == TypePoint)
delete value.pt;
} }
//Number Type //Number Type
NumberType::NumberType(int number): AnyType(TypeNumber, (void*)number) { } NumberType::NumberType(int number): AnyType(TypeNumber, ValueValue())
{
value.num = number;
}
int NumberType::Value() int NumberType::Value()
{ {
return (intptr_t)value; return value.num;
} }
//String type //String type
StringType::StringType(std::string string): AnyType(TypeString, new std::string(string)) { } StringType::StringType(std::string string): AnyType(TypeString, ValueValue())
{
value.str = new std::string(string);
}
std::string StringType::Value() std::string StringType::Value()
{ {
return std::string(*((std::string*)value)); return *value.str;
} }
//Point type //Point type
PointType::PointType(ui::Point point): AnyType(TypePoint, new ui::Point(point)) { } PointType::PointType(ui::Point point): AnyType(TypePoint, ValueValue())
{
value.pt = new ui::Point(point);
}
PointType::PointType(int pointX, int pointY): AnyType(TypePoint, new ui::Point(pointX, pointY)) { } PointType::PointType(int pointX, int pointY): AnyType(TypePoint, ValueValue())
{
value.pt = new ui::Point(pointX, pointY);
}
ui::Point PointType::Value() ui::Point PointType::Value()
{ {
return ui::Point(*((ui::Point*)value)); return *value.pt;
} }

View File

@ -6,6 +6,7 @@
#include "gui/interface/Point.h" #include "gui/interface/Point.h"
enum ValueType { TypeNumber, TypePoint, TypeString, TypeNull, TypeFunction }; enum ValueType { TypeNumber, TypePoint, TypeString, TypeNull, TypeFunction };
typedef union { int num; std::string* str; ui::Point* pt; } ValueValue;
class GeneralException class GeneralException
{ {
@ -29,9 +30,9 @@ class AnyType
{ {
protected: protected:
ValueType type; ValueType type;
void * value; ValueValue value;
public: public:
AnyType(ValueType type_, void * value_); AnyType(ValueType type_, ValueValue value_);
AnyType(const AnyType & v); AnyType(const AnyType & v);
operator NumberType(); operator NumberType();
operator StringType(); operator StringType();

View File

@ -154,7 +154,7 @@ int TPTScriptInterface::parseNumber(char * stringData)
AnyType TPTScriptInterface::eval(std::deque<std::string> * words) AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
{ {
if(words->size() < 1) if(words->size() < 1)
return AnyType(TypeNull, NULL); return AnyType(TypeNull, ValueValue());
std::string word = words->front(); words->pop_front(); std::string word = words->front(); words->pop_front();
char * rawWord = (char *)word.c_str(); char * rawWord = (char *)word.c_str();
ValueType wordType = testType(word); ValueType wordType = testType(word);

View File

@ -333,7 +333,7 @@ bool Client::DoInstallation()
char *currentfilename = exe_name(); char *currentfilename = exe_name();
FILE *f; FILE *f;
char *mimedata = const char *mimedata =
"<?xml version=\"1.0\"?>\n" "<?xml version=\"1.0\"?>\n"
" <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n" " <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
" <mime-type type=\"application/vnd.powdertoy.save\">\n" " <mime-type type=\"application/vnd.powdertoy.save\">\n"
@ -348,7 +348,7 @@ bool Client::DoInstallation()
fwrite(mimedata, 1, strlen(mimedata), f); fwrite(mimedata, 1, strlen(mimedata), f);
fclose(f); fclose(f);
char *protocolfiledata_tmp = const char *protocolfiledata_tmp =
"[Desktop Entry]\n" "[Desktop Entry]\n"
"Type=Application\n" "Type=Application\n"
"Name=Powder Toy\n" "Name=Powder Toy\n"
@ -367,7 +367,7 @@ bool Client::DoInstallation()
fclose(f); fclose(f);
system("xdg-desktop-menu install powdertoy-tpt-ptsave.desktop"); system("xdg-desktop-menu install powdertoy-tpt-ptsave.desktop");
char *desktopfiledata_tmp = const char *desktopfiledata_tmp =
"[Desktop Entry]\n" "[Desktop Entry]\n"
"Type=Application\n" "Type=Application\n"
"Name=Powder Toy\n" "Name=Powder Toy\n"
@ -893,8 +893,8 @@ RequestStatus Client::UploadSave(SaveInfo & save)
char *session = new char[authUser.SessionID.length() + 1]; char *session = new char[authUser.SessionID.length() + 1];
std::strcpy (session, authUser.SessionID.c_str()); std::strcpy (session, authUser.SessionID.c_str());
char * postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL }; const char *const postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL };
char * postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") }; const char *const postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") };
int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 }; int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 };
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl; //std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength); data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
@ -1120,8 +1120,8 @@ RequestStatus Client::ExecVote(int saveID, int direction)
char *session = new char[authUser.SessionID.length() + 1]; char *session = new char[authUser.SessionID.length() + 1];
std::strcpy (session, authUser.SessionID.c_str()); std::strcpy (session, authUser.SessionID.c_str());
char * postNames[] = { "ID", "Action", NULL }; const char *const postNames[] = { "ID", "Action", NULL };
char * postDatas[] = { id, directionText }; const char *const postDatas[] = { id, directionText };
int postLengths[] = { saveIDText.length(), strlen(directionText) }; int postLengths[] = { saveIDText.length(), strlen(directionText) };
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl; //std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength); data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
@ -1221,9 +1221,7 @@ RequestBroker::Request * Client::SaveUserInfoAsync(UserInfo info)
json::Reader::Read(objDocument, dataStream); json::Reader::Read(objDocument, dataStream);
json::Number tempStatus = objDocument["Status"]; json::Number tempStatus = objDocument["Status"];
bool returnValue = tempStatus.Value() == 1; return (void*)(tempStatus.Value() == 1);
return (void*)(returnValue ? 1 : 0);
} }
catch (json::Exception &e) catch (json::Exception &e)
{ {
@ -1303,8 +1301,8 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
char * data; char * data;
int dataStatus, dataLength; int dataStatus, dataLength;
char * postNames[] = { "Username", "Hash", NULL }; const char *const postNames[] = { "Username", "Hash", NULL };
char * postDatas[] = { (char*)username.c_str(), totalHash }; const char *const postDatas[] = { (char*)username.c_str(), totalHash };
int postLengths[] = { username.length(), 32 }; int postLengths[] = { username.length(), 32 };
data = http_multipart_post("http://" SERVER "/Login.json", postNames, postDatas, postLengths, NULL, NULL, NULL, &dataStatus, &dataLength); data = http_multipart_post("http://" SERVER "/Login.json", postNames, postDatas, postLengths, NULL, NULL, NULL, &dataStatus, &dataLength);
if(dataStatus == 200 && data) if(dataStatus == 200 && data)
@ -1432,8 +1430,8 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.ID;
char * postNames[] = { "Comment", NULL }; const char *const postNames[] = { "Comment", NULL };
char * postDatas[] = { (char*)(comment.c_str()) }; const char *const postDatas[] = { (char*)(comment.c_str()) };
int postLengths[] = { comment.length() }; int postLengths[] = { comment.length() };
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
@ -1548,8 +1546,8 @@ RequestStatus Client::ReportSave(int saveID, std::string message)
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.ID;
char * postNames[] = { "Reason", NULL }; const char *const postNames[] = { "Reason", NULL };
char * postDatas[] = { (char*)(message.c_str()) }; const char *const postDatas[] = { (char*)(message.c_str()) };
int postLengths[] = { message.length() }; int postLengths[] = { message.length() };
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }

View File

@ -49,6 +49,7 @@
#endif #endif
#include "Config.h" #include "Config.h"
#include "Misc.h"
#include "HTTP.h" #include "HTTP.h"
#include "MD5.h" #include "MD5.h"
@ -87,34 +88,25 @@ static char * eatwhitespace(char * s)
return s; return s;
} }
static char *mystrdup(char *s) static int splituri(const char *uri, char **host, char **path)
{ {
char *x; const char *q;
if (s) char *x,*y;
{ if (!strncmp(uri, "http://", 7))
x = (char *)malloc(strlen(s)+1); uri += 7;
strcpy(x, s); q = strchr(uri, '/');
return x;
}
return s;
}
static int splituri(char *uri, char **host, char **path)
{
char *p=uri,*q,*x,*y;
if (!strncmp(p, "http://", 7))
p += 7;
q = strchr(p, '/');
if (!q) if (!q)
q = p + strlen(p); q = uri + strlen(uri);
x = (char *)malloc(q-p+1); x = (char *)malloc(q-uri+1);
if (*q) if (*q)
y = mystrdup(q); y = mystrdup(q);
else else
{
y = mystrdup("/"); y = mystrdup("/");
strncpy(x, p, q-p); }
x[q-p] = 0; strncpy(x, uri, q-uri);
if (q==p || x[q-p-1]==':') x[q-uri] = 0;
if (q==uri || x[q-uri-1]==':')
{ {
free(x); free(x);
free(y); free(y);
@ -244,7 +236,7 @@ struct http_ctx
int fd; int fd;
char *fdhost; char *fdhost;
}; };
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep) void *http_async_req_start(void *ctx, const char *uri, const char *data, int dlen, int keep)
{ {
struct http_ctx *cx = (http_ctx *)ctx; struct http_ctx *cx = (http_ctx *)ctx;
if (!ctx) if (!ctx)
@ -298,7 +290,7 @@ void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep)
{ {
if (!dlen) if (!dlen)
dlen = strlen(data); dlen = strlen(data);
cx->txd = (char*)malloc(dlen); cx->txd = (char *)malloc(dlen);
memcpy(cx->txd, data, dlen); memcpy(cx->txd, data, dlen);
cx->txdl = dlen; cx->txdl = dlen;
} }
@ -319,7 +311,7 @@ void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep)
return ctx; return ctx;
} }
void http_async_add_header(void *ctx, char *name, char *data) void http_async_add_header(void *ctx, const char *name, const char *data)
{ {
struct http_ctx *cx = (http_ctx *)ctx; struct http_ctx *cx = (http_ctx *)ctx;
cx->thdr = (char *)realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 5); cx->thdr = (char *)realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 5);
@ -694,7 +686,7 @@ void http_async_req_close(void *ctx)
free(ctx); free(ctx);
} }
char *http_simple_get(char *uri, int *ret, int *len) char *http_simple_get(const char *uri, int *ret, int *len)
{ {
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0); void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
if (!ctx) if (!ctx)
@ -707,7 +699,7 @@ char *http_simple_get(char *uri, int *ret, int *len)
} }
return http_async_req_stop(ctx, ret, len); return http_async_req_stop(ctx, ret, len);
} }
void http_auth_headers(void *ctx, char *user, char *pass, char *session_id) void http_auth_headers(void *ctx, const char *user, const char *pass, const char *session_id)
{ {
char *tmp; char *tmp;
int i; int i;
@ -747,7 +739,7 @@ void http_auth_headers(void *ctx, char *user, char *pass, char *session_id)
} }
} }
} }
char *http_auth_get(char *uri, char *user, char *pass, char *session_id, int *ret, int *len) char *http_auth_get(const char *uri, const char *user, const char *pass, const char *session_id, int *ret, int *len)
{ {
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0); void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
@ -763,7 +755,7 @@ char *http_auth_get(char *uri, char *user, char *pass, char *session_id, int *re
return http_async_req_stop(ctx, ret, len); return http_async_req_stop(ctx, ret, len);
} }
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len) char *http_simple_post(const char *uri, const char *data, int dlen, int *ret, int *len)
{ {
void *ctx = http_async_req_start(NULL, uri, data, dlen, 0); void *ctx = http_async_req_start(NULL, uri, data, dlen, 0);
if (!ctx) if (!ctx)
@ -777,7 +769,7 @@ char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len)
return http_async_req_stop(ctx, ret, len); return http_async_req_stop(ctx, ret, len);
} }
char *http_ret_text(int ret) const char *http_ret_text(int ret)
{ {
switch (ret) switch (ret)
{ {
@ -914,10 +906,10 @@ char *http_ret_text(int ret)
return "Unknown Status Code"; return "Unknown Status Code";
} }
} }
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char *session_id, int *ret, int *len) char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id, int *ret, int *len)
{ {
void *ctx; void *ctx;
char *data = NULL, *tmp, *p; char *data = NULL, *tmp;
int dlen = 0, i, j; int dlen = 0, i, j;
unsigned char hash[16]; unsigned char hash[16];
unsigned char boundary[32], ch; unsigned char boundary[32], ch;
@ -987,12 +979,11 @@ retry:
if (strchr(names[i], ':')) if (strchr(names[i], ':'))
{ {
tmp = mystrdup(names[i]); tmp = mystrdup(names[i]);
p = strchr(tmp, ':'); char *p = strchr(tmp, ':');
*p = 0; *p = 0;
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp); dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
free(tmp); free(tmp);
p = strchr(names[i], ':'); dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", strchr(names[i], ':')+1);
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", p+1);
} }
else else
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]); dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
@ -1022,7 +1013,7 @@ retry:
{ {
//md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY? //md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY?
//md5_update(&md5, (unsigned char *)"-", 1); //md5_update(&md5, (unsigned char *)"-", 1);
p = strchr(names[i], ':'); const char *p = strchr(names[i], ':');
if (p) if (p)
m += (p - names[i]) + 1; m += (p - names[i]) + 1;
else else
@ -1033,7 +1024,7 @@ retry:
m = 0; m = 0;
for (i=0; names[i]; i++) for (i=0; names[i]; i++)
{ {
p = strchr(names[i], ':'); const char *p = strchr(names[i], ':');
if (m) if (m)
{ {
tmp[m] = ' '; tmp[m] = ' ';
@ -1104,10 +1095,10 @@ fail:
} }
void *http_multipart_post_async(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char *session_id) void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id)
{ {
void *ctx; void *ctx;
char *data = NULL, *tmp, *p; char *data = NULL, *tmp;
int dlen = 0, i, j; int dlen = 0, i, j;
unsigned char hash[16]; unsigned char hash[16];
unsigned char boundary[32], ch; unsigned char boundary[32], ch;
@ -1177,12 +1168,11 @@ retry:
if (strchr(names[i], ':')) if (strchr(names[i], ':'))
{ {
tmp = mystrdup(names[i]); tmp = mystrdup(names[i]);
p = strchr(tmp, ':'); char *p = strchr(tmp, ':');
*p = 0; *p = 0;
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp); dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
free(tmp); free(tmp);
p = strchr(names[i], ':'); dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", strchr(names[i], ':')+1);
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", p+1);
} }
else else
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]); dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
@ -1212,7 +1202,7 @@ retry:
{ {
//md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY? //md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY?
//md5_update(&md5, (unsigned char *)"-", 1); //md5_update(&md5, (unsigned char *)"-", 1);
p = strchr(names[i], ':'); const char *p = strchr(names[i], ':');
if (p) if (p)
m += (p - names[i]) + 1; m += (p - names[i]) + 1;
else else
@ -1223,7 +1213,7 @@ retry:
m = 0; m = 0;
for (i=0; names[i]; i++) for (i=0; names[i]; i++)
{ {
p = strchr(names[i], ':'); const char *p = strchr(names[i], ':');
if (m) if (m)
{ {
tmp[m] = ' '; tmp[m] = ' ';

View File

@ -25,22 +25,22 @@ static char hexChars[] = "0123456789abcdef";
void http_init(char *proxy); void http_init(char *proxy);
void http_done(void); void http_done(void);
char *http_simple_get(char *uri, int *ret, int *len); char *http_simple_get(const char *uri, int *ret, int *len);
char *http_auth_get(char *uri, char *user, char *pass, char * session_id, int *ret, int *len); char *http_auth_get(const char *uri, const char *user, const char *pass, const char *session_id, int *ret, int *len);
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len); char *http_simple_post(const char *uri, const char *data, int dlen, int *ret, int *len);
void http_auth_headers(void *ctx, char *user, char *pass, char * session_id); void http_auth_headers(void *ctx, const char *user, const char *pass, const char *session_id);
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep); void *http_async_req_start(void *ctx, const char *uri, const char *data, int dlen, int keep);
void http_async_add_header(void *ctx, char *name, char *data); void http_async_add_header(void *ctx, const char *name, const char *data);
int http_async_req_status(void *ctx); int http_async_req_status(void *ctx);
void http_async_get_length(void *ctx, int *total, int *done); void http_async_get_length(void *ctx, int *total, int *done);
char *http_async_req_stop(void *ctx, int *ret, int *len); char *http_async_req_stop(void *ctx, int *ret, int *len);
void http_async_req_close(void *ctx); void http_async_req_close(void *ctx);
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char * session_id, int *ret, int *len); char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
void *http_multipart_post_async(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char * session_id); void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id);
char *http_ret_text(int ret); const char *http_ret_text(int ret);
#endif #endif

View File

@ -1,5 +1,3 @@
#pragma once
#include "ElementPopulation.h" #include "ElementPopulation.h"
#include "gui/interface/Engine.h" #include "gui/interface/Engine.h"
#include "simulation/Simulation.h" #include "simulation/Simulation.h"

View File

@ -14,4 +14,4 @@
void clearrect(int x, int y, int width, int height); void clearrect(int x, int y, int width, int height);
void gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2); void gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2);
void draw_image(pixel *img, int x, int y, int w, int h, int a); void draw_image(pixel *img, int x, int y, int w, int h, int a);

View File

@ -163,7 +163,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_NO_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a) 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

@ -128,7 +128,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_NO_INLINE int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a) 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];
@ -461,4 +461,4 @@ void PIXELMETHODS_CLASS::draw_image(const VideoBuffer & vidBuf, int x, int y, in
void PIXELMETHODS_CLASS::draw_image(VideoBuffer * vidBuf, int x, int y, int a) void PIXELMETHODS_CLASS::draw_image(VideoBuffer * vidBuf, int x, int y, int a)
{ {
draw_image(vidBuf->Buffer, x, y, vidBuf->Width, vidBuf->Height, a); draw_image(vidBuf->Buffer, x, y, vidBuf->Width, vidBuf->Height, a);
} }

View File

@ -13,8 +13,8 @@
#include "client/Client.h" #include "client/Client.h"
#include "client/GameSave.h" #include "client/GameSave.h"
#include "gui/game/DecorationTool.h" #include "gui/game/DecorationTool.h"
#include "GameModelException.h"
#include "QuickOptions.h" #include "QuickOptions.h"
#include "GameModelException.h"
#include "Format.h" #include "Format.h"
GameModel::GameModel(): GameModel::GameModel():

View File

@ -12,7 +12,7 @@
#include "Brush.h" #include "Brush.h"
#include "client/User.h" #include "client/User.h"
#include "Notification.h" #include "Notification.h"
#include "QuickOption.h"
#include "Tool.h" #include "Tool.h"
#include "Menu.h" #include "Menu.h"
@ -23,7 +23,6 @@ class GameController;
class Simulation; class Simulation;
class Renderer; class Renderer;
class QuickOption;
class ToolSelection class ToolSelection
{ {
public: public:

View File

@ -15,7 +15,7 @@
#include "simulation/SimulationData.h" #include "simulation/SimulationData.h"
#include "gui/dialogues/ConfirmPrompt.h" #include "gui/dialogues/ConfirmPrompt.h"
#include "Format.h" #include "Format.h"
#include "QuickOption.h" #include "QuickOptions.h"
#include "IntroText.h" #include "IntroText.h"
#include "DecorationTool.h" #include "DecorationTool.h"

View File

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

View File

@ -43,8 +43,8 @@ public:
virtual void DoAltAction(); //action of button what ever it may be virtual void DoAltAction(); //action of button what ever it may be
void SetTogglable(bool isTogglable); void SetTogglable(bool isTogglable);
bool GetTogglable(); bool GetTogglable();
TPT_NO_INLINE bool GetToggleState(); bool GetToggleState();
TPT_NO_INLINE void SetToggleState(bool state); 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

@ -63,7 +63,7 @@ namespace ui
inline int GetMaxWidth() { return maxWidth; } inline int GetMaxWidth() { return maxWidth; }
inline int GetMaxHeight() { return maxHeight; } inline int GetMaxHeight() { return maxHeight; }
TPT_NO_INLINE void SetMaxSize(int width, int height); void SetMaxSize(int width, int height);
inline void SetSize(int width, int height); inline void SetSize(int width, int height);

View File

@ -1,4 +1,3 @@
#pragma once
#include <vector> #include <vector>
//#include "Platform.h" //#include "Platform.h"

View File

@ -1,7 +1,7 @@
#include <cmath> #include <cmath>
#include "PreviewModel.h" #include "PreviewModel.h"
#include "client/Client.h" #include "client/Client.h"
#include "client/GameSave.h"; #include "client/GameSave.h"
#include "PreviewModelException.h" #include "PreviewModelException.h"
PreviewModel::PreviewModel(): PreviewModel::PreviewModel():

View File

@ -166,4 +166,4 @@ JNIEXPORT void JNICALL Java_OpenGLCanvas_releaseOpenGL(JNIEnv *env, jobject canv
freeContext(env, canvas, ci); freeContext(env, canvas, ci);
} }
#endif #endif

View File

@ -3,7 +3,7 @@
struct menu_section struct menu_section
{ {
char *icon; const char *icon;
const char *name; const char *name;
int itemcount; int itemcount;
int doshow; int doshow;

View File

@ -1663,7 +1663,7 @@ void *Simulation::transform_save(void *odata, int *size, matrix2d transform, vec
return ndata; return ndata;
} }
TPT_NO_INLINE void Simulation::orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]) 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;
@ -1676,7 +1676,7 @@ TPT_NO_INLINE void Simulation::orbitalparts_get(int block1, int block2, int resb
resblock2[3] = (block2&0xFF000000)>>24; resblock2[3] = (block2&0xFF000000)>>24;
} }
TPT_NO_INLINE void Simulation::orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]) void Simulation::orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[])
{ {
int block1tmp = 0; int block1tmp = 0;
int block2tmp = 0; int block2tmp = 0;

View File

@ -123,36 +123,36 @@ public:
Snapshot * CreateSnapshot(); Snapshot * CreateSnapshot();
void Restore(const Snapshot & snap); void Restore(const Snapshot & snap);
TPT_NO_INLINE int is_blocking(int t, int x, int y); int is_blocking(int t, int x, int y);
TPT_NO_INLINE int is_boundary(int pt, int x, int y); int is_boundary(int pt, int x, int y);
TPT_NO_INLINE int find_next_boundary(int pt, int *x, int *y, int dm, int *em); int find_next_boundary(int pt, int *x, int *y, int dm, int *em);
TPT_NO_INLINE int pn_junction_sprk(int x, int y, int pt); int pn_junction_sprk(int x, int y, int pt);
TPT_NO_INLINE void photoelectric_effect(int nx, int ny); void photoelectric_effect(int nx, int ny);
TPT_NO_INLINE unsigned direction_to_map(float dx, float dy, int t); unsigned direction_to_map(float dx, float dy, int t);
TPT_NO_INLINE int do_move(int i, int x, int y, float nxf, float nyf); int do_move(int i, int x, int y, float nxf, float nyf);
TPT_NO_INLINE int try_move(int i, int x, int y, int nx, int ny); int try_move(int i, int x, int y, int nx, int ny);
TPT_NO_INLINE int eval_move(int pt, int nx, int ny, unsigned *rr); int eval_move(int pt, int nx, int ny, unsigned *rr);
void init_can_move(); void init_can_move();
bool IsWallBlocking(int x, int y, int type); bool IsWallBlocking(int x, int y, int type);
void create_cherenkov_photon(int pp); void create_cherenkov_photon(int pp);
void create_gain_photon(int pp); void create_gain_photon(int pp);
TPT_NO_INLINE void kill_part(int i); void kill_part(int i);
bool FloodFillPmapCheck(int x, int y, int type); bool FloodFillPmapCheck(int x, int y, int type);
int flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype); int flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype);
int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap); int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap);
int flood_water(int x, int y, int i, int originaly, int check); int flood_water(int x, int y, int i, int originaly, int check);
int FloodINST(int x, int y, int fullc, int cm); int FloodINST(int x, int y, int fullc, int cm);
TPT_NO_INLINE void detach(int i); void detach(int i);
TPT_NO_INLINE void part_change_type(int i, int x, int y, int t); void part_change_type(int i, int x, int y, int t);
//int InCurrentBrush(int i, int j, int rx, int ry); //int InCurrentBrush(int i, int j, int rx, int ry);
//int get_brush_flags(); //int get_brush_flags();
TPT_NO_INLINE int create_part(int p, int x, int y, int t); int create_part(int p, int x, int y, int t);
TPT_NO_INLINE void delete_part(int x, int y); void delete_part(int x, int y);
void get_sign_pos(int i, int *x0, int *y0, int *w, int *h); void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
TPT_NO_INLINE int is_wire(int x, int y); int is_wire(int x, int y);
TPT_NO_INLINE int is_wire_off(int x, int y); int is_wire_off(int x, int y);
TPT_NO_INLINE void set_emap(int x, int y); void set_emap(int x, int y);
TPT_NO_INLINE int parts_avg(int ci, int ni, int t); 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);
@ -195,11 +195,11 @@ 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);
TPT_NO_INLINE void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]);
TPT_NO_INLINE void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]);
TPT_NO_INLINE int get_wavelength_bin(int *wm); int get_wavelength_bin(int *wm);
TPT_NO_INLINE int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny); int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny);
TPT_NO_INLINE int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, float *ny); int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, float *ny);
void clear_sim(); void clear_sim();
void UpdateParticles(); void UpdateParticles();
Simulation(); Simulation();

View File

@ -12,8 +12,8 @@ struct Particle;
class Element class Element
{ {
public: public:
char *Identifier; const char *Identifier;
char *Name; const char *Name;
pixel Colour; pixel Colour;
float Advection; float Advection;
float AirDrag; float AirDrag;
@ -34,7 +34,7 @@ public:
int MenuSection; int MenuSection;
float Temperature; float Temperature;
unsigned char HeatConduct; unsigned char HeatConduct;
char *Description; const char *Description;
char State; char State;
unsigned int Properties; unsigned int Properties;
int (*Update) (UPDATE_FUNC_ARGS); int (*Update) (UPDATE_FUNC_ARGS);

View File

@ -10,10 +10,10 @@ struct Particle;
class SimTool class SimTool
{ {
public: public:
char *Identifier; const char *Identifier;
char *Name; const char *Name;
pixel Colour; pixel Colour;
char *Description; const char *Description;
SimTool(); SimTool();
virtual ~SimTool() {} virtual ~SimTool() {}