(images "tilesets/brick1.png"))
)
+ (sprite (name "infoblock")
+ (action
+ (name "default")
+ (images "tilesets/infoblock.png")
+ )
+ )
+
(sprite (name "rock")
(action
(name "normal")
"rainsplash-vertical-3.png")
(anim-fps 15)
)
- (tile
- (id 1321)
- (images
- "messagebox.png")
- )
- (solid #t)
- )
)
#include "lisp/lisp.h"
InfoBlock::InfoBlock(const lisp::Lisp& lisp)
- : Block(sprite_manager->create("bonusblock"))
+ : Block(sprite_manager->create("infoblock"))
{
Vector pos;
lisp.get("x", pos.x);
#ifndef __SCRIPT_INTERPRETER_H__
#define __SCRIPT_INTERPRETER_H__
+#include <squirrel.h>
+#include <iostream>
+
class ScriptInterpreter
{
public:
ScriptInterpreter();
~ScriptInterpreter();
- void load_script(const std::istream& in);
+ void load_script(std::istream& in, const std::string& sourcename = "");
void run_script();
void resume_script();
- bool script_suspended() const;
+ bool script_suspended();
+
+private:
+ HSQUIRRELVM v;
};
#endif
:major-mode 'c++-mode
:tokens '(("__DISPLAY_H__" variable nil nil ((const . t)) nil nil [23 55]) ("Scripting" type "namespace" (("Display" type "class" (("public" label ((reparse-symbol . classsubparts)) [85 92]) ("Display" function ("Display" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [119 129]) ("Display" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [134 145]) ("set_effect" function ("void") (("effect" variable ("std::string" type "class") nil ((const . t)) nil nil [174 200])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [158 201])) nil nil nil ((reparse-symbol . namespacesubparts)) [69 204])) nil nil nil nil [46 207]))
)
+ (semanticdb-table "script_interpreter.cpp"
+ :file "script_interpreter.cpp"
+ :pointmax 2199
+ :major-mode 'c++-mode
+ :tokens '(("config.h" include t nil nil [1 20]) ("script_interpreter.h" include nil nil nil [22 53]) ("stdarg.h" include t nil nil [55 74]) ("stdexcept" include t nil nil [75 95]) ("sstream" include t nil nil [96 114]) ("sqstdio.h" include t nil nil [115 135]) ("sqstdaux.h" include t nil nil [136 157]) ("sqstdblob.h" include t nil nil [158 180]) ("sqstdsystem.h" include t nil nil [181 205]) ("sqstdmath.h" include t nil nil [206 228]) ("sqstdstring.h" include t nil nil [229 253]) ("wrapper.h" include nil nil nil [255 275]) ("wrapper_util.h" include nil nil nil [276 301]) ("printfunc" function ("void") (("" variable ("HSQUIRRELVM" type "class") nil nil nil nil [325 337]) ("str" variable "char" nil ((const . t) (pointer . 1)) nil nil [338 354]) ("..." ((reparse-symbol . arg-sub-list)) [355 359])) ((typemodifiers "static")) nil nil [303 452]) ("ScriptInterpreter" function ("ScriptInterpreter" type "class") nil ((parent . "ScriptInterpreter") (constructor . t)) nil nil [454 1375]) ("ScriptInterpreter" function "void" nil ((parent . "ScriptInterpreter") (destructor . t)) nil nil [1377 1420]) ("squirrel_read_char" function ("SQInteger" type "class") (("file" variable ("SQUserPointer" type "class") nil nil nil nil [1458 1477])) ((typemodifiers "static")) nil nil [1422 1595]) ("load_script" function ("void") (("in" variable ("std::istream" type "class") nil nil nil nil [1634 1651]) ("sourcename" variable ("std::string" type "class") nil ((const . t)) nil nil [1652 1682])) ((parent . "ScriptInterpreter")) nil nil [1598 1814]) ("run_script" function ("void") nil ((parent . "ScriptInterpreter")) nil nil [1816 1986]) ("resume_script" function ("void") nil ((parent . "ScriptInterpreter")) nil nil [1988 2124]) ("script_suspended" function ("bool" type "class") nil ((parent . "ScriptInterpreter")) nil nil [2126 2198]))
+ :unmatched-syntax 'nil
+ )
+ (semanticdb-table "wrapper_util.h"
+ :file "wrapper_util.h"
+ :pointmax 772
+ :major-mode 'c++-mode
+ :tokens '(("__WRAPPERUTIL_HPP__" variable nil nil ((const . t)) nil nil [29 59]) ("squirrel.h" include t nil nil [58 79]) ("exception" include t nil nil [80 100]) ("string" include t nil nil [101 118]) ("WrappedFunction" type "struct" (("name" variable "char" nil ((const . t) (pointer . 1)) nil nil [149 166]) ("f" variable ("SQFUNCTION" type "class") nil nil nil nil [171 184])) nil nil nil nil [120 187]) ("WrappedClass" type "struct" (("name" variable "char" nil ((const . t) (pointer . 1)) nil nil [214 231]) ("functions" variable ("WrappedFunction" type "class") nil ((pointer . 1)) nil nil [236 263])) nil nil nil nil [188 266]) ("SquirrelException" type "class" (("public" label ((reparse-symbol . classsubparts)) [314 321]) ("SquirrelException" function ("SquirrelException" type "class") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [338 352]) ("message" variable ("std::string" type "class") nil ((const . t)) nil nil [353 380])) ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [324 389]) ("Exception" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [392 425]) ("what" function ("char") nil ((const . t) (pointer . 1) (prototype . t)) nil ((reparse-symbol . classsubparts)) [429 462]) ("private" label ((reparse-symbol . classsubparts)) [463 471]) ("message" variable ("std::string" type "class") nil nil nil nil [474 494])) (("std::exception")) nil nil nil [268 497]) ("register_functions" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [523 537]) ("functions" variable ("WrappedFunction" type "class") nil ((pointer . 1)) nil nil [538 565])) ((prototype . t)) nil nil [499 566]) ("register_classes" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [589 603]) ("classes" variable ("WrappedClass" type "class") nil ((pointer . 1)) nil nil [604 626])) ((prototype . t)) nil nil [567 627]) ("expose_object" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [648 662]) ("object" variable "void" nil ((pointer . 1)) nil nil [663 676]) ("type" variable "char" nil ((const . t) (pointer . 1)) nil nil [677 694]) ("name" variable "char" nil ((const . t) (pointer . 1)) nil nil [703 720])) ((prototype . t)) nil nil [629 721]))
+ :unmatched-syntax 'nil
+ )
+ (semanticdb-table "wrapper_util.cpp"
+ :file "wrapper_util.cpp"
+ :pointmax 4581
+ :major-mode 'c++-mode
+ :tokens '(("config.h" include t nil nil [1 20]) ("stdexcept" include t nil nil [22 42]) ("sstream" include t nil nil [43 61]) ("wrapper_util.h" include nil nil nil [62 87]) ("register_function" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [119 133]) ("func" variable ("SQFUNCTION" type "class") nil nil nil nil [134 150]) ("name" variable "char" nil ((const . t) (pointer . 1)) nil nil [151 168])) ((typemodifiers "static")) nil nil [89 285]) ("register_class" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [314 328]) ("wclass" variable ("WrappedClass" type "class") nil ((pointer . 1)) nil nil [329 350])) ((typemodifiers "static")) nil nil [287 582]) ("register_functions" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [608 622]) ("functions" variable ("WrappedFunction" type "class") nil ((pointer . 1)) nil nil [623 650])) nil nil nil [584 824]) ("register_classes" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [848 862]) ("classes" variable ("WrappedClass" type "class") nil ((pointer . 1)) nil nil [863 885])) nil nil nil [826 1044]) ("print_squirrel_stack" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [1072 1086])) nil nil nil [1046 2978]) ("expose_object" function ("void") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [2999 3013]) ("object" variable "void" nil ((pointer . 1)) nil nil [3014 3027]) ("type" variable "char" nil ((const . t) (pointer . 1)) nil nil [3028 3045]) ("name" variable "char" nil ((const . t) (pointer . 1)) nil nil [3054 3071])) nil nil nil [2980 4070]) ("SquirrelError" function ("SquirrelError" type "class") (("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [4181 4195]) ("message" variable ("std::string" type "class") nil ((const . t)) nil nil [4196 4223])) ((parent . "SquirrelError") (constructor . t)) nil nil [4152 4457]) ("SquirrelError" function "void" nil ((parent . "SquirrelError") (destructor . t)) nil nil [4459 4501]) ("what" function ("char") nil ((const . t) (parent . "SquirrelError") (pointer . 1)) nil nil [4503 4580]))
+ :unmatched-syntax 'nil
+ )
+ (semanticdb-table "script_interpreter.h"
+ :file "script_interpreter.h"
+ :pointmax 392
+ :major-mode 'c++-mode
+ :tokens '(("__SCRIPT_INTERPRETER_H__" variable nil nil ((const . t)) nil nil [34 69]) ("squirrel.h" include t nil nil [68 89]) ("iostream" include t nil nil [90 109]) ("ScriptInterpreter" type "class" (("public" label ((reparse-symbol . classsubparts)) [137 144]) ("ScriptInterpreter" function ("ScriptInterpreter" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [149 169]) ("ScriptInterpreter" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [174 195]) ("load_script" function ("void") (("in" variable ("std::istream" type "class") nil nil nil nil [218 235]) ("sourcename" variable ("std::string" type "class") "\"\"" ((const . t)) nil nil [236 270])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [201 272]) ("run_script" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [277 295]) ("resume_script" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [300 321]) ("script_suspended" function ("bool" type "class") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [326 350]) ("private" label ((reparse-symbol . classsubparts)) [352 360]) ("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [365 379])) nil nil nil nil [111 382]))
+ :unmatched-syntax 'nil
+ )
)
)
sq_pop(v, 1);
}
-static void print_stack(HSQUIRRELVM v)
+void print_squirrel_stack(HSQUIRRELVM v)
{
printf("--------------------------------------------------------------\n");
int count = sq_gettop(v);
printf("--------------------------------------------------------------\n");
}
-#define check(x) \
- if((x) < 0) { \
- std::stringstream msg; \
- sq_getlasterror(v); \
- const char* error; \
- sq_getstring(v, -1, &error); \
- msg << "Error: " << error; \
- throw std::runtime_error(msg.str()); \
- }
-
void expose_object(HSQUIRRELVM v, void* object, const char* type,
const char* name)
{
// resolve class name
sq_pushroottable(v);
sq_pushstring(v, type, -1);
- print_stack(v);
if(sq_get(v, -2) < 0) {
std::ostringstream msg;
msg << "Couldn't resolve squirrel type '" << type << "'.";
throw std::runtime_error(msg.str());
}
sq_remove(v, -2); // remove roottable
- print_stack(v);
// create an instance and set pointer to c++ object
- print_stack(v);
- check(sq_createinstance(v, -1));
- printf("after creatinstance\n");
- print_stack(v);
- check(sq_setinstanceup(v, -1, object));
- printf("after setinstanceup\n");
- print_stack(v);
-
- sq_remove(v, -2); // remove class
+ if(sq_createinstance(v, -1) < 0 || sq_setinstanceup(v, -1, object)) {
+ std::ostringstream msg;
+ msg << "Couldn't setup squirrel instance for object '"
+ << name << "' of type '" << type << "'.";
+ throw SquirrelError(v, msg.str());
+ }
+
+ sq_remove(v, -2); // remove class from stack
// part2 of registration of the instance in the root table
- print_stack(v);
- check(sq_createslot(v, -3));
- sq_pop(v, 1);
+ if(sq_createslot(v, -3) < 0)
+ throw SquirrelError(v, "Couldn't register object in squirrel root table");
+ sq_pop(v, 2);
+}
+
+//----------------------------------------------------------------------------
+
+SquirrelError::SquirrelError(HSQUIRRELVM v, const std::string& message) throw()
+{
+ std::ostringstream msg;
+ msg << "SQuirrel error: " << message << " (";
+ const char* lasterr;
+ sq_getlasterror(v);
+ sq_getstring(v, -1, &lasterr);
+ sq_pop(v, 1);
+ msg << lasterr << ")";
+ this->message = msg.str();
}
+SquirrelError::~SquirrelError() throw()
+{}
+
+const char*
+SquirrelError::what() const throw()
+{
+ return message.c_str();
+}
#define __WRAPPERUTIL_HPP__
#include <squirrel.h>
+#include <exception>
+#include <string>
struct WrappedFunction {
const char* name;
WrappedFunction* functions;
};
+class SquirrelError : public std::exception
+{
+public:
+ SquirrelError(HSQUIRRELVM v, const std::string& message) throw();
+ virtual ~SquirrelError() throw();
+
+ const char* what() const throw();
+private:
+ std::string message;
+};
+
void register_functions(HSQUIRRELVM v, WrappedFunction* functions);
void register_classes(HSQUIRRELVM v, WrappedClass* classes);
void expose_object(HSQUIRRELVM v, void* object, const char* type,
const char* name);
+void print_squirrel_stack(HSQUIRRELVM v);
#endif
continue;
if(!(tile->getAttributes() & Tile::SOLID))
continue;
- if((tile->getAttributes() & Tile::UNISOLID) && object->movement.y < 0)
+ if(tile->getAttributes() & Tile::UNISOLID
+ && (object->movement.y < 0 || dest.p2.y > y*32))
continue;
if(tile->getAttributes() & Tile::SLOPE) { // slope tile
Library squirrel
: [ Wildcard squirrel : *.cpp *.h ]
- [ Wildcard sqstdlib : *.cpp *.h ]
+ [ Wildcard sqstdlib : *.cpp *.c *.h ]
: noinstall
;
IncludeDir squirrel : include ;
case OP_OR: {
const SQChar *asd = str;
SQRexNode *temp=&exp->_nodes[node->left];
- while(asd = sqstd_rex_matchnode(exp,temp,asd)) {
+ while( (asd = sqstd_rex_matchnode(exp,temp,asd)) ) {
if(temp->next != -1)
temp = &exp->_nodes[temp->next];
else
}
asd = str;
temp = &exp->_nodes[node->right];
- while(asd = sqstd_rex_matchnode(exp,temp,asd)) {
+ while( (asd = sqstd_rex_matchnode(exp,temp,asd)) ) {
if(temp->next != -1)
temp = &exp->_nodes[temp->next];
else
return cur;
}
case OP_WB:
- if(str == exp->_bol && !isspace(*str)
+ if((str == exp->_bol && !isspace(*str))
|| (str == exp->_eol && !isspace(*(str-1)))
- || (!isspace(*str) && isspace(*(str+1)))
- || (isspace(*str) && !isspace(*(str+1))) ) {
+ || ((!isspace(*str) && isspace(*(str+1))))
+ || ((isspace(*str) && !isspace(*(str+1)))) ) {
return (node->left == 'b')?str:NULL;
}
return (node->left == 'b')?NULL:str;
} else if(iter.item() == "properties") {
// deprecated
} else {
- std::cerr << "Unknown symbol '" << iter.item() << "'.\n";
+ std::cerr << "Unknown symbol '" << iter.item() << "' tile defintion file.\n";
}
}
}