Skip to content

Commit

Permalink
Fix editor save generating unusable levels without sprites.
Browse files Browse the repository at this point in the history
The argument inversion mistake causing the problem was introduced with
the removal of the package manager. fs::relative() takes the arguments
the other way round than fs_relative(). fs_relative() should be
removed to reduce this confusion...
  • Loading branch information
Quintus committed Aug 7, 2019
1 parent e93813a commit a481165
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tsc/src/level/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ bool cLevel::Joy_Button_Up(unsigned int button)

fs::path cLevel::Get_Music_Filename() const
{
return fs::relative(pResource_Manager->Get_Game_Music_Directory(), m_musicfile);
return fs::relative(m_musicfile, pResource_Manager->Get_Game_Music_Directory());
}

void cLevel::Set_Music(fs::path filename)
Expand Down
2 changes: 1 addition & 1 deletion tsc/src/level/level_background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void cBackground::Set_Image(const fs::path& img_file_1)

// Make the path relative to pixmaps/ if it isn’t yet
if (m_image_1_filename.is_absolute())
m_image_1_filename = fs::relative(pResource_Manager->Get_Game_Pixmaps_Directory(), m_image_1_filename);
m_image_1_filename = fs::relative(m_image_1_filename, pResource_Manager->Get_Game_Pixmaps_Directory());

Clear_Images();
Add_Image_Set("main", m_image_1_filename);
Expand Down
4 changes: 2 additions & 2 deletions tsc/src/objects/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ xmlpp::Element* cSprite::Save_To_XML_Node(xmlpp::Element* p_element)
// Only save the relative part of the filename -- otherwise the
// generated levels wouldn’t be portable.
if (img_filename.is_absolute())
img_filename = fs::relative(pResource_Manager->Get_Game_Pixmaps_Directory(), img_filename);
img_filename = fs::relative(img_filename, pResource_Manager->Get_Game_Pixmaps_Directory());

Add_Property(p_node, "image", img_filename.generic_string());

Expand Down Expand Up @@ -1453,7 +1453,7 @@ void cSprite::Editor_Activate(void)

p_editor->Add_Config_Widget(UTF8_("Image"), UTF8_("Image filename"), editbox);

fs::path rel = fs::relative(pResource_Manager->Get_Game_Pixmaps_Directory(), m_start_image->Get_Path());
fs::path rel = fs::relative(m_start_image->Get_Path(), pResource_Manager->Get_Game_Pixmaps_Directory());
editbox->setText(path_to_utf8(rel));
editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cSprite::Editor_Image_Text_Changed, this));

Expand Down
2 changes: 1 addition & 1 deletion tsc/src/video/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ void cParticle_Emitter::Set_Image_Filename(const fs::path& filename)
// remember the filename for saving
m_image_filename = filename;
if (filename.is_absolute())
m_image_filename = fs::relative(pResource_Manager->Get_Game_Pixmaps_Directory(), filename);
m_image_filename = fs::relative(filename, pResource_Manager->Get_Game_Pixmaps_Directory());

// set new image
Set_Image(pVideo->Get_Surface(m_image_filename, 0));
Expand Down

0 comments on commit a481165

Please sign in to comment.