Skip to content

Commit

Permalink
Fix screen hooks removing on scrip end
Browse files Browse the repository at this point in the history
GetCollision returns avoid flag on invalid point instead of error, no longer level specific 
fix possible crashes with reveal room
  • Loading branch information
bobode committed Dec 11, 2013
1 parent 867bbce commit f22334e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 6 additions & 3 deletions JSGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ JSAPI_FUNC(my_getCollision)
{ THROW_ERROR(cx, "Level Not loaded");}

ActMap* map = ActMap::GetMap(level);
if(!map->IsValidPoint(point))
{ map->CleanUp(); THROW_ERROR(cx, "Invalid point!");}
//if(!map->IsValidPoint(point)) //return avoid instead and make it not lvl depenant
// { map->CleanUp(); THROW_ERROR(cx, "Invalid point!");}

jsval rval;
JS_BeginRequest(cx);
Expand Down Expand Up @@ -1621,10 +1621,13 @@ JSAPI_FUNC(my_revealLevel)
if (argc == 1 && JSVAL_IS_BOOLEAN(JS_ARGV(cx, vp)[0])) {
bDrawPresets = !!JSVAL_TO_BOOLEAN(JS_ARGV(cx, vp)[0]);
}
AutoCriticalRoom* cRoom = new AutoCriticalRoom;
if(!GameReady())
{delete cRoom; return JS_TRUE;}

for(Room2* room = level->pRoom2First; room; room = room->pRoom2Next) {
RevealRoom(room, bDrawPresets);
}

delete cRoom;
return JS_TRUE;
}
9 changes: 5 additions & 4 deletions JSRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ JSAPI_FUNC(room_getPresetUnits)
AutoCriticalRoom* cRoom = new AutoCriticalRoom;
if(!pRoom2 || !GameReady())
{delete cRoom; return JS_TRUE;}

if(!pRoom2->pRoom1)
{
bAdded = TRUE;
Expand Down Expand Up @@ -457,15 +458,15 @@ JSAPI_FUNC(room_unitInRoom)
JSAPI_FUNC(room_reveal)
{
Room2* pRoom2 = (Room2*)JS_GetPrivate(cx, JS_THIS_OBJECT(cx, vp));
if(!pRoom2)
return JS_TRUE;


BOOL bDrawPresets = false;
if (argc == 1 && JSVAL_IS_BOOLEAN(JS_ARGV(cx, vp)[0]))
bDrawPresets = !!JSVAL_TO_BOOLEAN(JS_ARGV(cx, vp)[0]);

AutoCriticalRoom* cRoom = new AutoCriticalRoom;

if(!pRoom2 || !GameReady())
{delete cRoom; return JS_TRUE;}

JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(RevealRoom(pRoom2, bDrawPresets)));
delete cRoom;
return JS_TRUE;
Expand Down
4 changes: 2 additions & 2 deletions ScreenHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void Genhook::Clean(Script* owner)
HookIterator it = visible.begin();
while(it != visible.end())
{
if( (*it)->owner != owner)
if( (*it)->owner == owner)
{
Genhook* i = *it;
it = invisible.erase(it);
Expand All @@ -191,7 +191,7 @@ void Genhook::Clean(Script* owner)
it = invisible.begin();
while(it != invisible.end())
{
if( (*it)->owner != owner)
if( (*it)->owner == owner)
{
Genhook* i = *it;
it = invisible.erase(it);
Expand Down

0 comments on commit f22334e

Please sign in to comment.