void
Sector::try_expose(GameObject* object)
{
- ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
- if(interface != NULL) {
+ ScriptInterface* object_ = dynamic_cast<ScriptInterface*> (object);
+ if(object_ != NULL) {
HSQUIRRELVM vm = scripting::global_vm;
sq_pushobject(vm, sector_table);
- interface->expose(vm, -1);
+ object_->expose(vm, -1);
sq_pop(vm, 1);
}
}
{
HSQUIRRELVM vm = scripting::global_vm;
sq_pushobject(vm, sector_table);
- scripting::SSector* interface = static_cast<scripting::SSector*> (this);
- expose_object(vm, -1, interface, "settings", false);
+ scripting::SSector* this_ = static_cast<scripting::SSector*> (this);
+ expose_object(vm, -1, this_, "settings", false);
sq_pop(vm, 1);
}
void
Sector::try_unexpose(GameObject* object)
{
- ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
- if(interface != NULL) {
+ ScriptInterface* object_ = dynamic_cast<ScriptInterface*> (object);
+ if(object_ != NULL) {
HSQUIRRELVM vm = scripting::global_vm;
SQInteger oldtop = sq_gettop(vm);
sq_pushobject(vm, sector_table);
try {
- interface->unexpose(vm, -1);
+ object_->unexpose(vm, -1);
} catch(std::exception& e) {
log_warning << "Couldn't unregister object: " << e.what() << std::endl;
}
if(fabsf(movement.y) > fabsf(movement.x)) {
if(ileft < SHIFT_DELTA) {
- constraints->right = std::min(constraints->right, r2.get_left());
+ constraints->min_right(r2.get_left());
return;
} else if(iright < SHIFT_DELTA) {
- constraints->left = std::max(constraints->left, r2.get_right());
+ constraints->max_left(r2.get_right());
return;
}
} else {
// shiftout bottom/top
if(itop < SHIFT_DELTA) {
- constraints->bottom = std::min(constraints->bottom, r2.get_top());
+ constraints->min_bottom(r2.get_top());
return;
} else if(ibottom < SHIFT_DELTA) {
- constraints->top = std::max(constraints->top, r2.get_bottom());
+ constraints->max_top(r2.get_bottom());
return;
}
}
float horiz_penetration = std::min(ileft, iright);
if(vert_penetration < horiz_penetration) {
if(itop < ibottom) {
- constraints->bottom = std::min(constraints->bottom, r2.get_top());
+ constraints->min_bottom(r2.get_top());
constraints->hit.bottom = true;
} else {
- constraints->top = std::max(constraints->top, r2.get_bottom());
+ constraints->max_top(r2.get_bottom());
constraints->hit.top = true;
}
} else {
if(ileft < iright) {
- constraints->right = std::min(constraints->right, r2.get_left());
+ constraints->min_right(r2.get_left());
constraints->hit.right = true;
} else {
- constraints->left = std::max(constraints->left, r2.get_right());
+ constraints->max_left(r2.get_right());
constraints->hit.left = true;
}
}
AATriangle triangle;
Vector p1(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset());
Vector p2((x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
- triangle = AATriangle(p1, p2, tile->getData());
+ int slope_data = tile->getData();
+ if (solids->get_drawing_effect() == VERTICAL_FLIP)
+ slope_data = AATriangle::vertical_flip(slope_data);
+ triangle = AATriangle(p1, p2, slope_data);
collision::rectangle_aatriangle(constraints, dest, triangle, solids->get_movement());
} else { // normal rectangular tile
float x1 = dest.p1.x;
float y1 = dest.p1.y;
float x2 = dest.p2.x;
- float y2 = dest.p2.y + SHIFT_DELTA;
+ float y2 = dest.p2.y;
uint32_t result = 0;
for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
int starttiley = int(y1 - solids->get_y_offset()) / 32;
int max_x = int(x2 - solids->get_x_offset());
int max_y = int(y2+1 - solids->get_y_offset());
+ int max_y_ice = int(max_y + SHIFT_DELTA);
for(int x = starttilex; x*32 < max_x; ++x) {
- for(int y = starttiley; y*32 < max_y; ++y) {
+ int y;
+ for(y = starttiley; y*32 < max_y; ++y) {
const Tile* tile = solids->get_tile(x, y);
if(!tile)
continue;
result |= tile->getAttributes();
}
+ for(; y*32 < max_y_ice; ++y) {
+ const Tile* tile = solids->get_tile(x, y);
+ if(!tile)
+ continue;
+ result |= (tile->getAttributes() & Tile::ICE);
+ }
}
}
break;
// apply calculated vertical constraints
- if(constraints.right < infinity) {
- float width = constraints.right - constraints.left;
+ float width = constraints.right - constraints.left;
+ if(width < infinity) {
if(width + SHIFT_DELTA < owidth) {
#if 0
printf("Object %p crushed horizontally... L:%f R:%f\n", &object,
h.crush = true;
object.collision_solid(h);
} else {
- dest.p2.x = constraints.right - DELTA;
- dest.p1.x = dest.p2.x - owidth;
+ float xmid = (constraints.left + constraints.right) / 2;
+ dest.p1.x = xmid - owidth/2;
+ dest.p2.x = xmid + owidth/2;
}
+ } else if(constraints.right < infinity) {
+ dest.p2.x = constraints.right - DELTA;
+ dest.p1.x = dest.p2.x - owidth;
} else if(constraints.left > -infinity) {
dest.p1.x = constraints.left + DELTA;
dest.p2.x = dest.p1.x + owidth;
continue;
uint32_t tile_attributes = collision_tile_attributes(moving_object->dest);
- if(tile_attributes > Tile::FIRST_INTERESTING_FLAG) {
+ if(tile_attributes >= Tile::FIRST_INTERESTING_FLAG) {
moving_object->collision_tile(tile_attributes);
}
}