mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-10 04:31:34 -10:00
Protects `Fiction_viewer_active_stage` if it reads a stage of -1 (it would have thrown a vector access error because the index is out of range). Also, given a lot of other scripting functions have additional built in error checks, I just added those to the fiction viewer functions.
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#include "fictionviewer.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
|
|
//**********HANDLE: cmd_briefing
|
|
ADE_OBJ(l_FictionViewerStage, fiction_viewer_stage, "fiction_viewer_stage", "Fiction Viewer stage handle");
|
|
|
|
ADE_VIRTVAR(TextFile, l_FictionViewerStage, nullptr, "The text file of the stage", "fiction_viewer_stage", "The text filename")
|
|
{
|
|
fiction_viewer_stage* stage = nullptr;
|
|
if (!ade_get_args(L, "o", l_FictionViewerStage.GetPtr(&stage))) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (stage == nullptr) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (ADE_SETTING_VAR) {
|
|
LuaError(L, "This property is read only.");
|
|
}
|
|
|
|
return ade_set_args(L, "s", stage->story_filename);
|
|
}
|
|
|
|
ADE_VIRTVAR(FontFile, l_FictionViewerStage, nullptr, "The font file of the stage", "fiction_viewer_stage", "The font filename")
|
|
{
|
|
fiction_viewer_stage* stage = nullptr;
|
|
if (!ade_get_args(L, "o", l_FictionViewerStage.GetPtr(&stage))) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (stage == nullptr) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (ADE_SETTING_VAR) {
|
|
LuaError(L, "This property is read only.");
|
|
}
|
|
|
|
return ade_set_args(L, "s", stage->font_filename);
|
|
}
|
|
|
|
ADE_VIRTVAR(VoiceFile, l_FictionViewerStage, nullptr, "The voice file of the stage", "fiction_viewer_stage", "The voice filename")
|
|
{
|
|
fiction_viewer_stage* stage = nullptr;
|
|
if (!ade_get_args(L, "o", l_FictionViewerStage.GetPtr(&stage))) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (stage == nullptr) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (ADE_SETTING_VAR) {
|
|
LuaError(L, "This property is read only.");
|
|
}
|
|
|
|
return ade_set_args(L, "s", stage->voice_filename);
|
|
}
|
|
|
|
} // namespace api
|
|
} // namespace scripting
|