diff --git a/src/achievements/achievement_info.cpp b/src/achievements/achievement_info.cpp index eda7b4c73..6000205a1 100644 --- a/src/achievements/achievement_info.cpp +++ b/src/achievements/achievement_info.cpp @@ -20,8 +20,6 @@ #include "utils/log.hpp" #include "utils/translation.hpp" -#include "io/xml_writer.hpp" - #include #include diff --git a/src/achievements/achievements_manager.cpp b/src/achievements/achievements_manager.cpp index db24f23dc..661c31a98 100644 --- a/src/achievements/achievements_manager.cpp +++ b/src/achievements/achievements_manager.cpp @@ -21,7 +21,6 @@ #include "utils/log.hpp" #include "utils/translation.hpp" #include "io/file_manager.hpp" -#include "io/xml_writer.hpp" #include "config/player.hpp" #include "config/user_config.hpp" #include "online/current_user.hpp" diff --git a/src/achievements/achievements_slot.cpp b/src/achievements/achievements_slot.cpp index 931c4164c..ec36d8771 100644 --- a/src/achievements/achievements_slot.cpp +++ b/src/achievements/achievements_slot.cpp @@ -24,12 +24,13 @@ #include "utils/log.hpp" #include "utils/ptr_vector.hpp" #include "utils/translation.hpp" -#include "io/xml_writer.hpp" #include "online/current_user.hpp" #include +#include #include #include + // ============================================================================ AchievementsSlot::AchievementsSlot(const XMLNode * input) { diff --git a/src/challenges/unlock_manager.cpp b/src/challenges/unlock_manager.cpp index 247b627a0..47099068e 100644 --- a/src/challenges/unlock_manager.cpp +++ b/src/challenges/unlock_manager.cpp @@ -27,11 +27,10 @@ #include "achievements/achievements_manager.hpp" #include "audio/sfx_base.hpp" #include "audio/sfx_manager.hpp" +#include "challenges/challenge_data.hpp" #include "config/player.hpp" #include "config/user_config.hpp" -#include "challenges/challenge_data.hpp" #include "io/file_manager.hpp" -#include "io/xml_writer.hpp" #include "karts/kart_properties_manager.hpp" #include "race/race_manager.hpp" #include "tracks/track_manager.hpp" diff --git a/src/config/user_config.cpp b/src/config/user_config.cpp index 9f36ee033..c37edfc77 100644 --- a/src/config/user_config.cpp +++ b/src/config/user_config.cpp @@ -18,34 +18,33 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include -#include -#include -#include -#include -#include "io/xml_writer.hpp" -#include "utils/ptr_vector.hpp" - -class UserConfigParam; -static PtrVector all_params; - - // X-macros #define PARAM_PREFIX #define PARAM_DEFAULT(X) = X #include "config/user_config.hpp" -#include "config/saved_grand_prix.hpp" #include "config/player.hpp" +#include "config/saved_grand_prix.hpp" #include "config/stk_config.hpp" #include "guiengine/engine.hpp" #include "io/file_manager.hpp" +#include "io/utf_writer.hpp" #include "io/xml_node.hpp" #include "race/race_manager.hpp" #include "utils/ptr_vector.hpp" #include "utils/string_utils.hpp" #include "utils/translation.hpp" +#include +#include +#include +#include +#include + +class UserConfigParam; +static PtrVector all_params; + + const int UserConfig::m_current_config_version = 8; @@ -60,7 +59,7 @@ UserConfigParam::~UserConfigParam() * \param stream the xml writer. * \param level determines indentation level. */ -void UserConfigParam::writeInner(XMLWriter& stream, int level) const +void UserConfigParam::writeInner(UTFWriter& stream, int level) const { std::string tab(level * 4,' '); stream << L" " << tab.c_str() << m_param_name.c_str() << L"=\"" @@ -87,7 +86,7 @@ GroupUserConfigParam::GroupUserConfigParam(const char* group_name, } // GroupUserConfigParam // ---------------------------------------------------------------------------- -void GroupUserConfigParam::write(XMLWriter& stream) const +void GroupUserConfigParam::write(UTFWriter& stream) const { const int attr_amount = m_attributes.size(); @@ -117,7 +116,7 @@ void GroupUserConfigParam::write(XMLWriter& stream) const } // write // ---------------------------------------------------------------------------- -void GroupUserConfigParam::writeInner(XMLWriter& stream, int level) const +void GroupUserConfigParam::writeInner(UTFWriter& stream, int level) const { std::string tab(level * 4,' '); for(int i = 0; i < level; i++) tab =+ " "; @@ -244,7 +243,7 @@ ListUserConfigParam::ListUserConfigParam(const char* param_name, // ---------------------------------------------------------------------------- template -void ListUserConfigParam::write(XMLWriter& stream) const +void ListUserConfigParam::write(UTFWriter& stream) const { const int elts_amount = m_elements.size(); @@ -350,7 +349,7 @@ IntUserConfigParam::IntUserConfigParam(int default_value, } // IntUserConfigParam // ---------------------------------------------------------------------------- -void IntUserConfigParam::write(XMLWriter& stream) const +void IntUserConfigParam::write(UTFWriter& stream) const { if(m_comment.size() > 0) stream << L" \n"; @@ -412,7 +411,7 @@ TimeUserConfigParam::TimeUserConfigParam(StkTime::TimeType default_value, } // TimeUserConfigParam // ---------------------------------------------------------------------------- -void TimeUserConfigParam::write(XMLWriter& stream) const +void TimeUserConfigParam::write(UTFWriter& stream) const { if(m_comment.size() > 0) stream << L" \n"; @@ -483,7 +482,7 @@ StringUserConfigParam::StringUserConfigParam(const char* default_value, } // StringUserConfigParam // ---------------------------------------------------------------------------- -void StringUserConfigParam::write(XMLWriter& stream) const +void StringUserConfigParam::write(UTFWriter& stream) const { if(m_comment.size() > 0) stream << L" \n"; @@ -535,7 +534,7 @@ WStringUserConfigParam::WStringUserConfigParam(const core::stringw& default_valu } // WStringUserConfigParam // ---------------------------------------------------------------------------- -void WStringUserConfigParam::write(XMLWriter& stream) const +void WStringUserConfigParam::write(UTFWriter& stream) const { if(m_comment.size() > 0) stream << L" \n"; @@ -586,7 +585,7 @@ BoolUserConfigParam::BoolUserConfigParam(bool default_value, // ---------------------------------------------------------------------------- -void BoolUserConfigParam::write(XMLWriter& stream) const +void BoolUserConfigParam::write(UTFWriter& stream) const { if(m_comment.size() > 0) stream << L" \n"; @@ -673,7 +672,7 @@ FloatUserConfigParam::FloatUserConfigParam(float default_value, } // FloatUserConfigParam // ---------------------------------------------------------------------------- -void FloatUserConfigParam::write(XMLWriter& stream) const +void FloatUserConfigParam::write(UTFWriter& stream) const { if(m_comment.size() > 0) stream << L" \n"; @@ -878,7 +877,7 @@ void UserConfig::saveConfig() try { - XMLWriter configfile(filename.c_str()); + UTFWriter configfile(filename.c_str()); configfile << L"\n"; configfile << L" #include #include using namespace irr; -#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) - // ---------------------------------------------------------------------------- -XMLWriter::XMLWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary) +UTFWriter::UTFWriter(const char* dest) + : m_base(dest, std::ios::out | std::ios::binary) { if (!m_base.is_open()) { - throw std::runtime_error("Failed to open file for writing : " + std::string(dest)); + throw std::runtime_error("Failed to open file for writing : " + + std::string(dest)); } // FIXME: make sure to properly handle endianness - wchar_t BOM = 0xFEFF; // UTF-16 BOM is 0xFEFF; UTF-32 BOM is 0x0000FEFF. So this works in either case + // UTF-16 BOM is 0xFEFF; UTF-32 BOM is 0x0000FEFF. So this works in either case + wchar_t BOM = 0xFEFF; m_base.write((char *) &BOM, sizeof(wchar_t)); -} +} // UTFWriter // ---------------------------------------------------------------------------- -XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt) +UTFWriter& UTFWriter::operator<< (const irr::core::stringw& txt) { m_base.write((char *) txt.c_str(), txt.size() * sizeof(wchar_t)); return *this; -} +} // operator<< (stringw) // ---------------------------------------------------------------------------- -XMLWriter& XMLWriter::operator<< (const wchar_t*txt) +UTFWriter& UTFWriter::operator<< (const wchar_t*txt) { m_base.write((char *) txt, wcslen(txt) * sizeof(wchar_t)); return *this; -} +} // operator<< (wchar_t) // ---------------------------------------------------------------------------- -void XMLWriter::close() +void UTFWriter::close() { m_base.close(); -} - -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- - -#else // Non-unicode version for irrlicht 1.7 and before - -XMLWriter::XMLWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary) -{ - if (!m_base.is_open()) - { - throw std::runtime_error("Failed to open file for writing : " + std::string(dest)); - } -} +} // close // ---------------------------------------------------------------------------- -XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt) -{ - core::stringc s( txt.c_str() ); - m_base.write((char *) s.c_str(), s.size()); - return *this; -} - -// ---------------------------------------------------------------------------- - -XMLWriter& XMLWriter::operator<< (const wchar_t*txt) -{ - core::stringc s( txt ); - m_base.write((char *) s.c_str(), s.size()); - return *this; -} - -// ---------------------------------------------------------------------------- - -void XMLWriter::close() -{ - m_base.close(); -} - -// ---------------------------------------------------------------------------- - -#endif diff --git a/src/io/xml_writer.hpp b/src/io/utf_writer.hpp similarity index 85% rename from src/io/xml_writer.hpp rename to src/io/utf_writer.hpp index 3fcb9132b..25d447cd0 100644 --- a/src/io/xml_writer.hpp +++ b/src/io/utf_writer.hpp @@ -16,8 +16,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HEADER_XML_WRITER_HPP -#define HEADER_XML_WRITER_HPP +#ifndef HEADER_UTF_WRITER_HPP +#define HEADER_UTF_WRITER_HPP #include #include @@ -28,18 +28,18 @@ * we only want to accept arrays of wchar_t to make sure we get reasonable files out * \ingroup io */ -class XMLWriter +class UTFWriter { std::ofstream m_base; public: - XMLWriter(const char* dest); + UTFWriter(const char* dest); - XMLWriter& operator<< (const irr::core::stringw& txt); - XMLWriter& operator<< (const wchar_t* txt); + UTFWriter& operator<< (const irr::core::stringw& txt); + UTFWriter& operator<< (const wchar_t* txt); template - XMLWriter& operator<< (const T t) + UTFWriter& operator<< (const T t) { irr::core::stringw tmp; tmp += t; diff --git a/src/race/highscore_manager.cpp b/src/race/highscore_manager.cpp index 58a4d38b4..d65d7162e 100644 --- a/src/race/highscore_manager.cpp +++ b/src/race/highscore_manager.cpp @@ -23,7 +23,7 @@ #include "config/user_config.hpp" #include "io/file_manager.hpp" -#include "io/xml_writer.hpp" +#include "io/utf_writer.hpp" #include "race/race_manager.hpp" #include "utils/constants.hpp" #include "utils/string_utils.hpp" @@ -149,7 +149,7 @@ void HighscoreManager::saveHighscores() try { - XMLWriter highscore_file(m_filename.c_str()); + UTFWriter highscore_file(m_filename.c_str()); highscore_file << L"\n"; highscore_file << L"\n"; diff --git a/src/race/highscores.cpp b/src/race/highscores.cpp index 034ca8a87..f00fd036a 100644 --- a/src/race/highscores.cpp +++ b/src/race/highscores.cpp @@ -18,13 +18,13 @@ #include "race/highscores.hpp" +#include "io/utf_writer.hpp" +#include "io/xml_node.hpp" +#include "race/race_manager.hpp" + #include #include -#include "io/xml_node.hpp" -#include "io/xml_writer.hpp" -#include "race/race_manager.hpp" - // ----------------------------------------------------------------------------- Highscores::Highscores(const HighscoreType highscore_type, int num_karts, @@ -105,7 +105,7 @@ void Highscores::readEntry(const XMLNode &node) * resulting in empty entries here. * \param writer The file stream to write the data to. */ -void Highscores::writeEntry(XMLWriter &writer) +void Highscores::writeEntry(UTFWriter &writer) { // Only bool one_is_set = false; diff --git a/src/race/highscores.hpp b/src/race/highscores.hpp index b713bc7f0..a321f9d9e 100644 --- a/src/race/highscores.hpp +++ b/src/race/highscores.hpp @@ -27,7 +27,7 @@ #include class XMLNode; -class XMLWriter; +class UTFWriter; /** * Represents one highscore entry, i.e. the (atm up to three) highscores @@ -62,7 +62,7 @@ public: Highscores (const XMLNode &node); void readEntry (const XMLNode &node); - void writeEntry(XMLWriter &writer); + void writeEntry(UTFWriter &writer); int matches (HighscoreType highscore_type, int num_karts, const RaceManager::Difficulty difficulty, const std::string track, const int number_of_laps, diff --git a/tools/find_unused.sh b/tools/find_unused.sh new file mode 100755 index 000000000..fd9385edc --- /dev/null +++ b/tools/find_unused.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "Searching for unused stkgui files" +echo "---------------------------------" +cd data/gui +l="" +for i in $(find . -iname "*.stkgui"); do + s=$(basename $i) + x=$(find ../../src/states_screens -exec grep -H $s \{} \; | wc -l) + echo -n "." + if [ $x == "0" ]; then + l="$l $i" + fi +done +echo + +for i in $l; do + echo "$i appears to be not used." +done + +echo "done" + + +