Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/cutscene/cutscenes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ void parse_cutscene_table(const char* filename)
cutscene_info_init(&csnt);

cutscene_info *csnp;
bool create_if_not_found = true;

try
{
Expand All @@ -106,6 +105,7 @@ void parse_cutscene_table(const char* filename)

while (required_string_either("#End", "$Filename:"))
{
bool create_if_not_found = true;
bool csn_new = false;

required_string("$Filename:");
Expand Down
2 changes: 1 addition & 1 deletion code/iff_defs/iff_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ void parse_iff_table(const char* filename)
iff_info ifft;
iff_info* iffp;
int cur_iff;
bool create_if_not_found = true;

try
{
Expand Down Expand Up @@ -455,6 +454,7 @@ void parse_iff_table(const char* filename)
// begin reading data
while (required_string_either("#End", "$IFF Name:"))
{
bool create_if_not_found = true;

// get the iff name
required_string("$IFF Name:");
Expand Down
32 changes: 32 additions & 0 deletions test/src/cutscene/test_cutscene_parse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "cutscene/cutscenes.h"
#include "util/FSTestFixture.h"

#include <gtest/gtest.h>

// Defined in cutscenes.cpp for shutdown; reuse it to free test descriptions.
void cutscene_close();

class CutsceneParseTest : public test::FSTestFixture {
public:
CutsceneParseTest() : test::FSTestFixture(INIT_CFILE)
{
pushModDir("cutscene");
}

protected:
void TearDown() override
{
cutscene_close();
Cutscenes.clear();
test::FSTestFixture::TearDown();
}
};

TEST_F(CutsceneParseTest, ModularNocreateAppliesOnlyToItsEntry)
{
cutscene_init();

EXPECT_GE(get_cutscene_index_by_name("Intro Override"), 0);
EXPECT_GE(get_cutscene_index_by_name("New Cutscene"), 0);
EXPECT_LT(get_cutscene_index_by_name("Missing Cutscene"), 0);
}
2 changes: 2 additions & 0 deletions test/src/iff_defs/test_iff_accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ TEST_F(IffAccessibilityTest, TbmIffsKeepTheirColorsAndBuiltInsUseAccessibilityCo
{
iff_init();

// Pirate follows a +nocreate override in pirate-iff.tbm, so this checks that +nocreate applies only to its own entry.
const int pirate = iff_lookup("Pirate");
const int friendly = iff_lookup("Friendly");
EXPECT_LT(iff_lookup("Missing IFF"), 0);
ASSERT_GE(pirate, 0);
ASSERT_GE(friendly, 0);

Expand Down
4 changes: 4 additions & 0 deletions test/src/source_groups.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ add_file_folder("Controlconfig"
controlconfig/test_bindings.cpp
)

add_file_folder("Cutscene"
cutscene/test_cutscene_parse.cpp
)

add_file_folder("Globalincs"
globalincs/test_flagset.cpp
globalincs/test_polymorphic.cpp
Expand Down
6 changes: 6 additions & 0 deletions test/test_data/cutscene/data/tables/cutscenes.tbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Cutscenes

$Filename: intro.mve
$Name: Introduction

#End
14 changes: 14 additions & 0 deletions test/test_data/cutscene/data/tables/nocreate-csn.tbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Cutscenes

$Filename: intro.mve
+nocreate
$Name: Intro Override

$Filename: new.mve
$Name: New Cutscene

$Filename: missing.mve
+nocreate
$Name: Missing Cutscene

#End
9 changes: 7 additions & 2 deletions test/test_data/iff/tbm_adds_iff/data/tables/pirate-iff.tbm
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#IFFs

; Pirate follows this +nocreate override to check that +nocreate applies only to its own entry.
$IFF Name: Unknown
+nocreate
$Color: ( 0, 0, 255 )

$IFF Name: Pirate
$Color: ( 200, 0, 200 )
$Attacks: ( "Friendly" )
+Sees Friendly As: ( 250, 250, 0 )

$IFF Name: Unknown
$Color: ( 0, 0, 255 )
$IFF Name: Missing IFF
+nocreate

#End
Loading