MCPcopy Create free account
hub / github.com/adventuregamestudio/ags / PostScriptProcessing

Function PostScriptProcessing

Engine/script/script.cpp:716–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714}
715
716void PostScriptProcessing()
717{
718 // should do any post-script stuff here, like go to new room
719 if (cc_has_error())
720 quit(cc_get_error().ErrorString);
721
722 std::unique_ptr<ExecutingScript> copyof;
723 // save current ExecutingScript until the end of function
724 if (!executingScripts.empty())
725 {
726 copyof = std::move(executingScripts.top());
727 executingScripts.pop();
728 }
729 inside_script--;
730
731 curExecScript = !executingScripts.empty() ? executingScripts.top().get() : nullptr;
732
733 // If there was no current executing script, then bail out now
734 // (this might happen if script got stopped and disposed in the midst of run).
735 if (!copyof)
736 {
737 return;
738 }
739
740 // If there's still a pending script in the callstack (or rather thread stack),
741 // then reschedule post-script actions to the previous exec script in stack, and break
742 if (curExecScript)
743 {
744 for (auto &act : copyof->PostScriptActions)
745 curExecScript->QueueAction(std::move(act));
746 return;
747 }
748
749 // FIXME: sync audio in case any screen changing or time-consuming post-script actions were scheduled
750 if (copyof->PostScriptActions.size() > 0)
751 {
752 sync_audio_playback();
753 }
754
755 const int old_room_number = displayed_room;
756
757 // run the queued post-script actions
758 for (auto &act : copyof->PostScriptActions)
759 {
760 const int data1 = act.Data[0];
761 const int data2 = act.Data[1];
762
763 switch (act.Type)
764 {
765 case ePSANewRoom:
766 new_room(data1, playerchar);
767 return; // skip any remaining scheduled actions
768 case ePSARestoreGame:
769 AbortAllScripts();
770 try_restore_save(data1);
771 return; // skip any remaining scheduled actions
772 case ePSARestoreGameDialog:
773 do_restore_game_dialog(data1 & 0xFFFF, (data1 >> 16), data2);

Callers 1

RunScriptFunctionFunction · 0.85

Calls 15

cc_has_errorFunction · 0.85
sync_audio_playbackFunction · 0.85
new_roomFunction · 0.85
AbortAllScriptsFunction · 0.85
try_restore_saveFunction · 0.85
do_restore_game_dialogFunction · 0.85
is_in_dialogFunction · 0.85
set_dialog_result_gotoFunction · 0.85
do_conversationFunction · 0.85
set_dialog_result_stopFunction · 0.85
is_in_dialogoptionsFunction · 0.85

Tested by

no test coverage detected