[Super-tux-commit] supertux/lib/utils configfile.cpp,1.7,1.8 lispreader.cpp,1.4,1.5 lispreader.h,1.3
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-20 22:15:16
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/utils Modified Files: configfile.cpp lispreader.cpp lispreader.h lispwriter.cpp Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: lispwriter.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispwriter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lispwriter.cpp 22 Jul 2004 19:07:51 -0000 1.3 +++ lispwriter.cpp 20 Nov 2004 22:14:36 -0000 1.4 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <iostream> #include "../utils/lispwriter.h" Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- configfile.cpp 6 Aug 2004 11:43:08 -0000 1.7 +++ configfile.cpp 20 Nov 2004 22:14:36 -0000 1.8 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <cstdlib> #include <string> Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- lispreader.cpp 25 Jul 2004 19:03:35 -0000 1.4 +++ lispreader.cpp 20 Nov 2004 22:14:36 -0000 1.5 @@ -20,8 +20,11 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include <config.h> + #include <iostream> #include <vector> +#include <stdexcept> #include <string> #include <cctype> #include <cstdlib> @@ -68,7 +71,7 @@ _token_append (char c) { if (token_length >= MAX_TOKEN_LENGTH) - throw LispReaderException("_token_append()", __FILE__, __LINE__); + throw std::runtime_error("token too long."); token_string[token_length++] = c; token_string[token_length] = '\0'; @@ -98,7 +101,7 @@ return stream->v.any.next_char(stream->v.any.data); } - throw LispReaderException("_next_char()", __FILE__, __LINE__); + assert(false); return EOF; } @@ -120,7 +123,7 @@ break; default : - throw LispReaderException("_unget_char()", __FILE__, __LINE__); + assert(false); } } @@ -272,7 +275,7 @@ } } - throw LispReaderException("_scan()", __FILE__, __LINE__); + throw std::runtime_error("invalid token in lisp file"); return TOKEN_ERROR; } @@ -311,7 +314,7 @@ void (*unget_char) (char c, void *data)) { if (next_char == 0 || unget_char == 0) - throw LispReaderException("lisp_stream_init_any()", __FILE__, __LINE__); + throw std::runtime_error("no data"); stream->type = LISP_STREAM_ANY; stream->v.any.data = data; @@ -499,7 +502,7 @@ return lisp_make_boolean(0); } - throw LispReaderException("lisp_read()", __FILE__, __LINE__); + throw std::runtime_error("syntax error in lisp file"); return &error_object; } @@ -663,7 +666,7 @@ _match_pattern_var (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars) { if (lisp_type(pattern) != LISP_TYPE_PATTERN_VAR) - throw LispReaderException("_match_pattern_var", __FILE__, __LINE__); + throw std::runtime_error("type is not a var"); switch (pattern->v.pattern.type) { @@ -708,7 +711,7 @@ for (sub = pattern->v.pattern.sub; sub != 0; sub = lisp_cdr(sub)) { if (lisp_type(sub) != LISP_TYPE_CONS) - throw LispReaderException("_match_pattern_var()", __FILE__, __LINE__); + throw std::runtime_error("type isn't a car/cons"); if (_match_pattern(lisp_car(sub), obj, vars)) matched = 1; @@ -720,7 +723,7 @@ break; default : - throw LispReaderException("_match_pattern_var()", __FILE__, __LINE__); + assert(false); } if (vars != 0) @@ -770,7 +773,7 @@ break; default : - throw LispReaderException("_match_pattern()", __FILE__, __LINE__); + assert(false); } return 0; @@ -826,7 +829,7 @@ SuperTux::lisp_integer (lisp_object_t *obj) { if (obj->type != LISP_TYPE_INTEGER) - throw LispReaderException("lisp_integer()", __FILE__, __LINE__); + throw std::runtime_error("expected integer"); return obj->v.integer; } @@ -835,7 +838,7 @@ SuperTux::lisp_symbol (lisp_object_t *obj) { if (obj->type != LISP_TYPE_SYMBOL) - throw LispReaderException("lisp_symbol()", __FILE__, __LINE__); + throw std::runtime_error("expected symbol"); return obj->v.string; } @@ -844,7 +847,7 @@ SuperTux::lisp_string (lisp_object_t *obj) { if (obj->type != LISP_TYPE_STRING) - throw LispReaderException("lisp_string()", __FILE__, __LINE__); + throw std::runtime_error("expected string"); return obj->v.string; } @@ -853,7 +856,7 @@ SuperTux::lisp_boolean (lisp_object_t *obj) { if (obj->type != LISP_TYPE_BOOLEAN) - throw LispReaderException("lisp_boolean()", __FILE__, __LINE__); + throw std::runtime_error("expected boolean"); return obj->v.integer; } @@ -862,7 +865,7 @@ SuperTux::lisp_real (lisp_object_t *obj) { if (obj->type != LISP_TYPE_REAL && obj->type != LISP_TYPE_INTEGER) - throw LispReaderException("lisp_real()", __FILE__, __LINE__); + throw std::runtime_error("expected real"); if (obj->type == LISP_TYPE_INTEGER) return obj->v.integer; @@ -873,7 +876,7 @@ SuperTux::lisp_car (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_car()", __FILE__, __LINE__); + throw std::runtime_error("expected car"); return obj->v.cons.car; } @@ -882,7 +885,7 @@ SuperTux::lisp_cdr (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_cdr()", __FILE__, __LINE__); + throw std::runtime_error("expected cons"); return obj->v.cons.cdr; } @@ -898,7 +901,7 @@ else if (x[i] == 'd') obj = lisp_cdr(obj); else - throw LispReaderException("lisp_cxr()", __FILE__, __LINE__); + throw std::runtime_error("couldn't parse cxr"); return obj; } @@ -911,7 +914,7 @@ while (obj != 0) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_list_length()", __FILE__, __LINE__); + throw std::runtime_error("expected cons"); ++length; obj = obj->v.cons.cdr; @@ -926,9 +929,9 @@ while (index > 0) { if (obj == 0) - throw LispReaderException("lisp_list_nth_cdr()", __FILE__, __LINE__); + throw std::runtime_error("list too short"); if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_list_nth_cdr()", __FILE__, __LINE__); + throw std::runtime_error("expected cons"); --index; obj = obj->v.cons.cdr; @@ -943,7 +946,7 @@ obj = lisp_list_nth_cdr(obj, index); if (obj == 0) - throw LispReaderException("lisp_list_nth()", __FILE__, __LINE__); + throw std::runtime_error("list too short"); return obj->v.cons.car; } @@ -1025,7 +1028,7 @@ break; default : - throw LispReaderException("lisp_dump()", __FILE__, __LINE__); + throw std::runtime_error("unknown list type"); } } @@ -1049,13 +1052,12 @@ if(obj->type == LISP_TYPE_EOF || obj->type == LISP_TYPE_PARSE_ERROR) { lisp_free(obj); - throw LispReaderException("LispReader::load", __FILE__, __LINE__); + throw std::runtime_error("Error while parsing lispfile"); } if(toplevellist != lisp_symbol(lisp_car(obj))) { lisp_car(obj); - throw LispReaderException("LispReader::load wrong toplevel symbol", - __FILE__, __LINE__); + throw std::runtime_error("Worng toplevel symbol in lisp file"); } LispReader* reader = new LispReader(lisp_cdr(obj)); @@ -1077,7 +1079,6 @@ if (!lisp_cons_p(cur) || !lisp_symbol_p (lisp_car(cur))) { lisp_dump(cur, stdout); - //throw ConstruoError (std::string("LispReader: Read error in search_for ") + name); printf("LispReader: Read error in search\n"); } else @@ -1108,6 +1109,20 @@ } bool +LispReader::read_uint (const char* name, unsigned int& i) +{ + lisp_object_t* obj = search_for (name); + if(!obj) + return false; + + if (!lisp_integer_p(lisp_car(obj))) + return false; + + i = (unsigned int) lisp_integer(lisp_car(obj)); + return true; +} + +bool LispReader::read_lisp(const char* name, lisp_object_t*& b) { lisp_object_t* obj = search_for (name); @@ -1291,5 +1306,3 @@ return obj; } - -// EOF // Index: lispreader.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lispreader.h 22 Jul 2004 19:07:51 -0000 1.3 +++ lispreader.h 20 Nov 2004 22:14:36 -0000 1.4 @@ -61,14 +61,6 @@ #define LISP_PATTERN_LIST 7 #define LISP_PATTERN_OR 8 -// Exception -class LispReaderException : public SuperTuxException -{ - public: - LispReaderException(const char* _message = "lispreader error", const char* _file = "", const unsigned int _line = 0) - : SuperTuxException(_message, _file, _line) { }; -}; - typedef struct { int type; @@ -191,6 +183,7 @@ bool read_string_vector(const char* name, std::vector<std::string>& vec); bool read_string(const char* name, std::string& str, bool translatable = false); bool read_int(const char* name, int& i); + bool read_uint(const char* name, unsigned int& i); bool read_float(const char* name, float& f); bool read_bool(const char* name, bool& b); bool read_lisp(const char* name, lisp_object_t*& b); |