Skip to content

Commit

Permalink
Fix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Jul 16, 2023
1 parent 1225211 commit a3ff536
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 87 deletions.
24 changes: 0 additions & 24 deletions src/scripting/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,6 @@ bool check_cutscene()
return session->get_current_level().m_is_in_cutscene;
}

void pause_target_timer()
{
auto session = GameSession::current();
if (session == nullptr)
{
log_info << "No game session" << std::endl;
return;
}

return session->set_target_timer_paused(true);
}

void resume_target_timer()
{
auto session = GameSession::current();
if (session == nullptr)
{
log_info << "No game session" << std::endl;
return;
}

return session->set_target_timer_paused(false);
}

void wait(HSQUIRRELVM vm, float seconds)
{
if(GameSession::current()->get_current_level().m_skip_cutscene)
Expand Down
11 changes: 0 additions & 11 deletions src/scripting/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ void end_cutscene();
*/
bool check_cutscene();

/**
* Pauses the target timer
*/
void pause_target_timer();

/**
* Resumes the target timer
*/
void resume_target_timer();


/**
* Suspends the script execution for a specified number of seconds.
* @param float $seconds
Expand Down
14 changes: 14 additions & 0 deletions src/scripting/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ Level_edit(bool edit_mode)
game_session.set_editmode(edit_mode);
}

void
Level_pause_target_timer()
{
SCRIPT_GUARD_GAMESESSION;
game_session.set_target_timer_paused(true);
}

void
Level_resume_target_timer()
{
SCRIPT_GUARD_GAMESESSION;
game_session.set_target_timer_paused(false);
}

} // namespace scripting

/* EOF */
10 changes: 10 additions & 0 deletions src/scripting/level.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ void Level_toggle_pause();
*/
void Level_edit(bool edit_mode);

/**
* Pauses the target timer.
*/
void Level_pause_target_timer();

/**
* Resumes the target timer.
*/
void Level_resume_target_timer();

#ifdef DOXYGEN_SCRIPTING
}
#endif
Expand Down
104 changes: 52 additions & 52 deletions src/scripting/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11319,44 +11319,6 @@ static SQInteger check_cutscene_wrapper(HSQUIRRELVM vm)

}

static SQInteger pause_target_timer_wrapper(HSQUIRRELVM vm)
{
(void) vm;

try {
scripting::pause_target_timer();

return 0;

} catch(std::exception& e) {
sq_throwerror(vm, e.what());
return SQ_ERROR;
} catch(...) {
sq_throwerror(vm, _SC("Unexpected exception while executing function 'pause_target_timer'"));
return SQ_ERROR;
}

}

static SQInteger resume_target_timer_wrapper(HSQUIRRELVM vm)
{
(void) vm;

try {
scripting::resume_target_timer();

return 0;

} catch(std::exception& e) {
sq_throwerror(vm, e.what());
return SQ_ERROR;
} catch(...) {
sq_throwerror(vm, _SC("Unexpected exception while executing function 'resume_target_timer'"));
return SQ_ERROR;
}

}

static SQInteger wait_wrapper(HSQUIRRELVM vm)
{
HSQUIRRELVM arg0 = vm;
Expand Down Expand Up @@ -12384,6 +12346,44 @@ static SQInteger Level_edit_wrapper(HSQUIRRELVM vm)

}

static SQInteger Level_pause_target_timer_wrapper(HSQUIRRELVM vm)
{
(void) vm;

try {
scripting::Level_pause_target_timer();

return 0;

} catch(std::exception& e) {
sq_throwerror(vm, e.what());
return SQ_ERROR;
} catch(...) {
sq_throwerror(vm, _SC("Unexpected exception while executing function 'Level_pause_target_timer'"));
return SQ_ERROR;
}

}

static SQInteger Level_resume_target_timer_wrapper(HSQUIRRELVM vm)
{
(void) vm;

try {
scripting::Level_resume_target_timer();

return 0;

} catch(std::exception& e) {
sq_throwerror(vm, e.what());
return SQ_ERROR;
} catch(...) {
sq_throwerror(vm, _SC("Unexpected exception while executing function 'Level_resume_target_timer'"));
return SQ_ERROR;
}

}

} // namespace wrapper
void create_squirrel_instance(HSQUIRRELVM v, scripting::AmbientSound* object, bool setup_releasehook)
{
Expand Down Expand Up @@ -13352,20 +13352,6 @@ void register_supertux_wrapper(HSQUIRRELVM v)
throw SquirrelError(v, "Couldn't register function 'check_cutscene'");
}

sq_pushstring(v, "pause_target_timer", -1);
sq_newclosure(v, &pause_target_timer_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".");
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register function 'pause_target_timer'");
}

sq_pushstring(v, "resume_target_timer", -1);
sq_newclosure(v, &resume_target_timer_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".");
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register function 'resume_target_timer'");
}

sq_pushstring(v, "wait", -1);
sq_newclosure(v, &wait_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n");
Expand Down Expand Up @@ -13674,6 +13660,20 @@ void register_supertux_wrapper(HSQUIRRELVM v)
throw SquirrelError(v, "Couldn't register function 'Level_edit'");
}

sq_pushstring(v, "Level_pause_target_timer", -1);
sq_newclosure(v, &Level_pause_target_timer_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".");
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register function 'Level_pause_target_timer'");
}

sq_pushstring(v, "Level_resume_target_timer", -1);
sq_newclosure(v, &Level_resume_target_timer_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".");
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register function 'Level_resume_target_timer'");
}

// Register class AmbientSound
sq_pushstring(v, "AmbientSound", -1);
if(sq_newclass(v, SQFalse) < 0) {
Expand Down

0 comments on commit a3ff536

Please sign in to comment.