diff --git a/src/audio.cpp b/src/audio.cpp index ed699dd..5221987 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -67,9 +67,9 @@ void CSound::LoadSoundList() { CSPList list; if (list.Load(param.sounds_dir, "sounds.lst")) { for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { - string name = SPStrN(*line, "name"); - string soundfile = SPStrN(*line, "file"); - string path = MakePathStr(param.sounds_dir, soundfile); + std::string name = SPStrN(*line, "name"); + std::string soundfile = SPStrN(*line, "file"); + std::string path = MakePathStr(param.sounds_dir, soundfile); LoadChunk(name, path); } } @@ -77,13 +77,13 @@ void CSound::LoadSoundList() { void CSound::FreeSounds() { HaltAll(); - for (size_t i = 0; i < sounds.size(); i++) + for (std::size_t i = 0; i < sounds.size(); i++) delete sounds[i]; sounds.clear(); SoundIndex.clear(); } -size_t CSound::GetSoundIdx(const string& name) const { +std::size_t CSound::GetSoundIdx(const std::string& name) const { try { return SoundIndex.at(name); } catch (...) { @@ -91,30 +91,30 @@ size_t CSound::GetSoundIdx(const string& name) const { } } -void CSound::SetVolume(size_t soundid, int volume) { +void CSound::SetVolume(std::size_t soundid, int volume) { if (soundid >= sounds.size()) return; volume = clamp(0, volume, MIX_MAX_VOLUME); sounds[soundid]->setVolume(volume); } -void CSound::SetVolume(const string& name, int volume) { +void CSound::SetVolume(const std::string& name, int volume) { SetVolume(GetSoundIdx(name), volume); } // ------------------- play ------------------------------------------- -void CSound::Play(size_t soundid, bool loop) { +void CSound::Play(std::size_t soundid, bool loop) { if (soundid >= sounds.size()) return; sounds[soundid]->Play(loop); } -void CSound::Play(const string& name, bool loop) { +void CSound::Play(const std::string& name, bool loop) { Play(GetSoundIdx(name), loop); } -void CSound::Play(size_t soundid, bool loop, int volume) { +void CSound::Play(std::size_t soundid, bool loop, int volume) { if (soundid >= sounds.size()) return; volume = clamp(0, volume, MIX_MAX_VOLUME); @@ -122,11 +122,11 @@ void CSound::Play(size_t soundid, bool loop, int volume) { sounds[soundid]->Play(loop); } -void CSound::Play(const string& name, bool loop, int volume) { +void CSound::Play(const std::string& name, bool loop, int volume) { Play(GetSoundIdx(name), loop, volume); } -void CSound::Halt(size_t soundid) { +void CSound::Halt(std::size_t soundid) { if (soundid >= sounds.size()) return; // loop_count must be -1 (endless loop) for halt @@ -134,12 +134,12 @@ void CSound::Halt(size_t soundid) { sounds[soundid]->player.stop(); } -void CSound::Halt(const string& name) { +void CSound::Halt(const std::string& name) { Halt(GetSoundIdx(name)); } void CSound::HaltAll() { - for (size_t i = 0; i < sounds.size(); i++) { + for (std::size_t i = 0; i < sounds.size(); i++) { sounds[i]->player.stop(); } } @@ -156,7 +156,7 @@ CMusic::~CMusic() { FreeMusics(); } -bool CMusic::LoadPiece(const string& name, const string& filename) { +bool CMusic::LoadPiece(const std::string& name, const std::string& filename) { sf::Music* m = new sf::Music(); if (!m->openFromFile(filename)) { Message("could not load music", filename); @@ -172,9 +172,9 @@ void CMusic::LoadMusicList() { CSPList list; if (list.Load(param.music_dir, "music.lst")) { for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { - string name = SPStrN(*line, "name"); - string musicfile = SPStrN(*line, "file"); - string path = MakePathStr(param.music_dir, musicfile); + std::string name = SPStrN(*line, "name"); + std::string musicfile = SPStrN(*line, "file"); + std::string path = MakePathStr(param.music_dir, musicfile); LoadPiece(name, path); } } else { @@ -187,11 +187,11 @@ void CMusic::LoadMusicList() { ThemesIndex.clear(); if (list.Load(param.music_dir, "racing_themes.lst")) { themes.resize(list.size()); - size_t i = 0; + std::size_t i = 0; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { - string name = SPStrN(*line, "name"); + std::string name = SPStrN(*line, "name"); ThemesIndex[name] = i; - string item = SPStrN(*line, "race", "race_1"); + std::string item = SPStrN(*line, "race", "race_1"); themes[i].situation[0] = musics[MusicIndex[item]]; item = SPStrN(*line, "wonrace", "wonrace_1"); themes[i].situation[1] = musics[MusicIndex[item]]; @@ -203,7 +203,7 @@ void CMusic::LoadMusicList() { void CMusic::FreeMusics() { Halt(); - for (size_t i = 0; i < musics.size(); i++) + for (std::size_t i = 0; i < musics.size(); i++) delete musics[i]; musics.clear(); MusicIndex.clear(); @@ -214,7 +214,7 @@ void CMusic::FreeMusics() { curr_music = nullptr; } -size_t CMusic::GetMusicIdx(const string& name) const { +std::size_t CMusic::GetMusicIdx(const std::string& name) const { try { return MusicIndex.at(name); } catch (...) { @@ -222,7 +222,7 @@ size_t CMusic::GetMusicIdx(const string& name) const { } } -size_t CMusic::GetThemeIdx(const string& theme) const { +std::size_t CMusic::GetThemeIdx(const std::string& theme) const { try { return ThemesIndex.at(theme); } catch (...) { @@ -253,27 +253,27 @@ bool CMusic::Play(sf::Music* music, bool loop, int volume) { return true; } -bool CMusic::Play(size_t musid, bool loop) { +bool CMusic::Play(std::size_t musid, bool loop) { if (musid >= musics.size()) return false; sf::Music* music = musics[musid]; return Play(music, loop, curr_volume); } -bool CMusic::Play(const string& name, bool loop) { +bool CMusic::Play(const std::string& name, bool loop) { return Play(GetMusicIdx(name), loop); } -bool CMusic::Play(size_t musid, bool loop, int volume) { +bool CMusic::Play(std::size_t musid, bool loop, int volume) { if (musid >= musics.size()) return false; sf::Music* music = musics[musid]; return Play(music, loop, volume); } -bool CMusic::Play(const string& name, bool loop, int volume) { +bool CMusic::Play(const std::string& name, bool loop, int volume) { return Play(GetMusicIdx(name), loop, volume); } -bool CMusic::PlayTheme(size_t theme, ESituation situation) { +bool CMusic::PlayTheme(std::size_t theme, ESituation situation) { if (theme >= themes.size()) return false; if (situation >= SITUATION_COUNT) return false; sf::Music* music = themes[theme].situation[situation]; diff --git a/src/audio.h b/src/audio.h index 9ee4542..63b003f 100644 --- a/src/audio.h +++ b/src/audio.h @@ -30,24 +30,24 @@ struct TSound; class CSound { private: - vector sounds; - map SoundIndex; + std::vector sounds; + std::map SoundIndex; public: ~CSound(); bool LoadChunk(const std::string& name, const std::string& filename); void LoadSoundList(); - size_t GetSoundIdx(const string& name) const; + std::size_t GetSoundIdx(const std::string& name) const; - void SetVolume(size_t soundid, int volume); - void SetVolume(const string& name, int volume); + void SetVolume(std::size_t soundid, int volume); + void SetVolume(const std::string& name, int volume); - void Play(size_t soundid, bool loop); - void Play(const string& name, bool loop); - void Play(size_t soundid, bool loop, int volume); - void Play(const string& name, bool loop, int volume); + void Play(std::size_t soundid, bool loop); + void Play(const std::string& name, bool loop); + void Play(std::size_t soundid, bool loop, int volume); + void Play(const std::string& name, bool loop, int volume); - void Halt(size_t soundid); - void Halt(const string& name); + void Halt(std::size_t soundid); + void Halt(const std::string& name); void HaltAll(); void FreeSounds(); @@ -70,12 +70,12 @@ class Music; class CMusic { private: - vector musics; - map MusicIndex; + std::vector musics; + std::map MusicIndex; struct Situation { sf::Music* situation[SITUATION_COUNT]; }; - vector themes; - map ThemesIndex; + std::vector themes; + std::map ThemesIndex; sf::Music* curr_music; // current music piece int curr_volume; @@ -85,17 +85,17 @@ public: CMusic(); ~CMusic(); - bool LoadPiece(const string& name, const string& filename); + bool LoadPiece(const std::string& name, const std::string& filename); void LoadMusicList(); - size_t GetMusicIdx(const string& name) const; - size_t GetThemeIdx(const string& theme) const; + std::size_t GetMusicIdx(const std::string& name) const; + std::size_t GetThemeIdx(const std::string& theme) const; void SetVolume(int volume); - bool Play(size_t musid, bool loop); - bool Play(const string& name, bool loop); - bool Play(size_t musid, bool loop, int volume); - bool Play(const string& name, bool loop, int volume); - bool PlayTheme(size_t theme, ESituation situation); + bool Play(std::size_t musid, bool loop); + bool Play(const std::string& name, bool loop); + bool Play(std::size_t musid, bool loop, int volume); + bool Play(const std::string& name, bool loop, int volume); + bool PlayTheme(std::size_t theme, ESituation situation); void Halt(); void FreeMusics(); }; diff --git a/src/bh.h b/src/bh.h index bd9616d..2380962 100644 --- a/src/bh.h +++ b/src/bh.h @@ -69,17 +69,12 @@ GNU General Public License for more details. # define SEP "/" #endif -// -------------------------------------------------------------------- -// defines -// -------------------------------------------------------------------- #define USE_STENCIL_BUFFER #include "version.h" #define WINDOW_TITLE "Extreme Tux Racer " ETR_VERSION_STRING -using namespace std; - #include "etr_types.h" #include "common.h" #include "game_config.h" diff --git a/src/common.cpp b/src/common.cpp index 6c0d851..3ee150e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -56,65 +56,65 @@ const sf::Color colSky = TColor(0.82, 0.86, 0.88, 1.0); // -------------------------------------------------------------------- void PrintInt(const int val) { - cout << "Integer: " << val << '\n'; + std::cout << "Integer: " << val << '\n'; } -void PrintInt(const string& s, const int val) { - cout << s << val << endl; +void PrintInt(const std::string& s, const int val) { + std::cout << s << val << std::endl; } void PrintStr(const char *val) { - cout << val << '\n'; + std::cout << val << '\n'; } -void PrintString(const string& s) { - cout << s << endl; +void PrintString(const std::string& s) { + std::cout << s << std::endl; } void PrintDouble(const double val) { - cout.precision(4); - cout << val << '\n'; + std::cout.precision(4); + std::cout << val << '\n'; } void PrintVector4(const TVector4d& v) { - cout.precision(3); - cout << v.x << " " << v.y << " " << v.z << " " << v.w << '\n'; + std::cout.precision(3); + std::cout << v.x << " " << v.y << " " << v.z << " " << v.w << '\n'; } void PrintColor(const sf::Color& v) { - cout.precision(3); - cout << v.r << " " << v.g << " " << v.b << '\n'; + std::cout.precision(3); + std::cout << v.r << " " << v.g << " " << v.b << '\n'; } void PrintVector2(const TVector2d& v) { - cout.precision(3); - cout << v.x << " " << v.y << '\n'; + std::cout.precision(3); + std::cout << v.x << " " << v.y << '\n'; } void PrintVector(const TVector3d& v) { - cout.precision(5); - cout << v.x << " " << v.y << " " << v.z << '\n'; + std::cout.precision(5); + std::cout << v.x << " " << v.y << " " << v.z << '\n'; } template void PrintMatrix(const TMatrix& mat) { - cout << '\n'; - cout.precision(3); + std::cout << '\n'; + std::cout.precision(3); for (int i=0; i=0) cout << ' '; - cout << " " << mat[i][j]; + if (mat[i][j]>=0) std::cout << ' '; + std::cout << " " << mat[i][j]; } - cout << '\n'; + std::cout << '\n'; } - cout << '\n'; + std::cout << '\n'; } template void PrintMatrix<4, 4>(const TMatrix<4, 4>& mat); template void PrintMatrix<3, 3>(const TMatrix<3, 3>& mat); void PrintQuaternion(const TQuaternion& q) { - cout.precision(5); - cout << "Quaternion: " << q.x << " " << q.y << " " << q.z << " " << q.w << '\n'; + std::cout.precision(5); + std::cout << "Quaternion: " << q.x << " " << q.y << " " << q.z << " " << q.w << '\n'; } // -------------------------------------------------------------------- @@ -129,29 +129,29 @@ void SaveMessages() { void Message(const char *msg, const char *desc) { if (*msg == 0 && *desc == 0) { - cout << '\n'; + std::cout << '\n'; return; } - string aa = msg; - string bb = desc; - cout << aa << " " << bb << '\n'; + std::string aa = msg; + std::string bb = desc; + std::cout << aa << " " << bb << '\n'; msg_list.Add(aa + bb); } void Message(const char *msg) { - cout << msg << '\n'; + std::cout << msg << '\n'; if (*msg != 0) msg_list.Add(msg); } -void Message(const string& a, const string& b) { - cout << a << ' ' << b << endl; +void Message(const std::string& a, const std::string& b) { + std::cout << a << ' ' << b << std::endl; msg_list.Add(a + b); } -void Message(const string& msg) { - cout << msg << endl; +void Message(const std::string& msg) { + std::cout << msg << std::endl; msg_list.Add(msg); } @@ -159,7 +159,7 @@ void Message(const string& msg) { // file utils // -------------------------------------------------------------------- -bool FileExists(const string& filename) { +bool FileExists(const std::string& filename) { struct stat stat_info; if (stat(filename.c_str(), &stat_info) != 0) { if (errno != ENOENT) Message("couldn't stat", filename); @@ -167,7 +167,7 @@ bool FileExists(const string& filename) { } else return true; } -bool FileExists(const string& dir, const string& filename) { +bool FileExists(const std::string& dir, const std::string& filename) { return FileExists(dir + SEP + filename); } @@ -199,12 +199,12 @@ void GetTimeComponents(double time, int *min, int *sec, int *hundr) { *hundr = ((int)(time * 100 + 0.5)) % 100; } -string GetTimeString() { +std::string GetTimeString() { time_t rawtime; time(&rawtime); struct tm* timeinfo = localtime(&rawtime); - string line = Int_StrN(timeinfo->tm_mon + 1); + std::string line = Int_StrN(timeinfo->tm_mon + 1); line += '_' + Int_StrN(timeinfo->tm_mday); line += '_' + Int_StrN(timeinfo->tm_hour); line += Int_StrN(timeinfo->tm_min); diff --git a/src/common.h b/src/common.h index e6903dd..58b8029 100644 --- a/src/common.h +++ b/src/common.h @@ -21,8 +21,6 @@ GNU General Public License for more details. #include "bh.h" #include "matrices.h" -using namespace std; - #define clamp(minimum, x, maximum) (max(min(x, maximum), minimum)) @@ -80,9 +78,9 @@ extern const sf::Color colSky; // some simple functions to print out values on the // terminal. Only used for development. void PrintInt(const int val); -void PrintInt(const string& s, const int val); +void PrintInt(const std::string& s, const int val); void PrintStr(const char *val); -void PrintString(const string& s); +void PrintString(const std::string& s); void PrintDouble(const double val); void PrintVector(const TVector3d& v); void PrintVector4(const TVector4d& v); @@ -97,8 +95,8 @@ void PrintQuaternion(const TQuaternion& q); // file utils // -------------------------------------------------------------------- -bool FileExists(const string& filename); -bool FileExists(const string& dir, const string& filename); +bool FileExists(const std::string& filename); +bool FileExists(const std::string& dir, const std::string& filename); bool DirExists(const char *dirname); // -------------------------------------------------------------------- @@ -107,8 +105,8 @@ bool DirExists(const char *dirname); void Message(const char *msg, const char *desc); void Message(const char *msg); -void Message(const string& a, const string& b); -void Message(const string& a); +void Message(const std::string& a, const std::string& b); +void Message(const std::string& a); void SaveMessages(); // -------------------------------------------------------------------- @@ -116,7 +114,7 @@ void SaveMessages(); // -------------------------------------------------------------------- void GetTimeComponents(double time, int *min, int *sec, int *hundr); -string GetTimeString(); +std::string GetTimeString(); #endif diff --git a/src/config_screen.cpp b/src/config_screen.cpp index 7e065ed..259d7c3 100644 --- a/src/config_screen.cpp +++ b/src/config_screen.cpp @@ -50,7 +50,7 @@ Then edit the below functions: #include "winsys.h" CGameConfig GameConfig; -static string res_names[NUM_RESOLUTIONS]; +static std::string res_names[NUM_RESOLUTIONS]; static TCheckbox* fullscreen; static TUpDown* language; diff --git a/src/course.cpp b/src/course.cpp index b1fc406..77a2bdb 100644 --- a/src/course.cpp +++ b/src/course.cpp @@ -40,10 +40,10 @@ GNU General Public License for more details. void TCourse::SetDescription(const std::string& description) { FT.AutoSizeN(2); - vector desclist = FT.MakeLineList(description.c_str(), 335.f * Winsys.scale - 16.f); - size_t cnt = min(desclist.size(), MAX_DESCRIPTION_LINES); + std::vector desclist = FT.MakeLineList(description.c_str(), 335.f * Winsys.scale - 16.f); + std::size_t cnt = std::min(desclist.size(), MAX_DESCRIPTION_LINES); num_lines = cnt; - for (size_t ll = 0; ll < cnt; ll++) { + for (std::size_t ll = 0; ll < cnt; ll++) { desc[ll] = desclist[ll]; } } @@ -87,16 +87,16 @@ double CCourse::GetMaxHeight(double distance) const { return GetBaseHeight(distance) + curr_course->scale; } -const TPolyhedron& CCourse::GetPoly(size_t type) const { +const TPolyhedron& CCourse::GetPoly(std::size_t type) const { return PolyArr[ObjTypes[type].poly]; } -TCourse* CCourse::GetCourse(const string& group, const string& dir) { +TCourse* CCourse::GetCourse(const std::string& group, const std::string& dir) { return &CourseLists.at(group)[dir]; } -size_t CCourse::GetCourseIdx(const TCourse* course) const { - size_t idx = (course - &(*currentCourseList)[0]); +std::size_t CCourse::GetCourseIdx(const TCourse* course) const { + std::size_t idx = (course - &(*currentCourseList)[0]); if (idx >= currentCourseList->size()) return -1; return idx; @@ -284,7 +284,7 @@ void CCourse::MakeStandardPolyhedrons() { PolyArr[1].vertices[5] = TVector3d(0, 1, 0); PolyArr[1].polygons.resize(8); - for (size_t i = 0; i < 8; i++) { + for (std::size_t i = 0; i < 8; i++) { PolyArr[1].polygons[i].vertices.resize(3); } PolyArr[1].polygons[0].vertices[0] = 0; @@ -321,14 +321,14 @@ void CCourse::MakeStandardPolyhedrons() { } void CCourse::FreeTerrainTextures() { - for (size_t i=0; isize.x; double zz = -(int)(ny - z) / (double)((double)ny - 1.0) * curr_course->size.y; - string name = SPStrN(*line, "name"); - size_t type = ObjectIndex[name]; + std::string name = SPStrN(*line, "name"); + std::size_t type = ObjectIndex[name]; if (ObjTypes[type].texture == nullptr && ObjTypes[type].drawable) { - string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile; + std::string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile; ObjTypes[type].texture = new TTexture(); ObjTypes[type].texture->Load(terrpath, false); } @@ -475,7 +475,7 @@ bool CCourse::LoadAndConvertObjectMap() { double xx = (nx - x) / (double)((double)nx - 1.0) * curr_course->size.x; double zz = -(int)(ny - y) / (double)((double)ny - 1.0) * curr_course->size.y; if (ObjTypes[type].texture == nullptr && ObjTypes[type].drawable) { - string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile; + std::string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile; ObjTypes[type].texture = new TTexture(); ObjTypes[type].texture->Load(terrpath, false); } @@ -509,7 +509,7 @@ bool CCourse::LoadAndConvertObjectMap() { else NocollArr.emplace_back(xx, FindYCoord(xx, zz), zz, height, diam, ObjTypes[type]); - string line = "*[name]"; + std::string line = "*[name]"; line += ObjTypes[type].name; SPSetIntN(line, "x", x); SPSetIntN(line, "z", y); @@ -520,7 +520,7 @@ bool CCourse::LoadAndConvertObjectMap() { } pad += (nx * depth) % 4; } - string itemfile = CourseDir + SEP "items.lst"; + std::string itemfile = CourseDir + SEP "items.lst"; savelist.Save(itemfile); // Convert trees.png to items.lst return true; } @@ -538,7 +538,7 @@ bool CCourse::LoadObjectTypes() { } ObjTypes.resize(list.size()); - size_t i = 0; + std::size_t i = 0; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { ObjTypes[i].name = SPStrN(*line, "name"); ObjTypes[i].textureFile = ObjTypes[i].name; @@ -572,7 +572,7 @@ bool CCourse::LoadObjectTypes() { // ==================================================================== int CCourse::GetTerrain(const unsigned char* pixel) const { - for (size_t i=0; iLoad(previewfile, false)) { Message("couldn't load previewfile"); } // params - string paramfile = coursepath + SEP "course.dim"; + std::string paramfile = coursepath + SEP "course.dim"; if (!paramlist.Load(paramfile)) { Message("could not load course.dim"); } - const string& line2 = paramlist.front(); + const std::string& line2 = paramlist.front(); courses[i].author = SPStrN(line2, "author", "unknown"); courses[i].size.x = SPFloatN(line2, "width", 100); courses[i].size.y = SPFloatN(line2, "length", 1000); @@ -708,7 +708,7 @@ bool CCourseList::Load(const std::string& dir) { } void CCourseList::Free() { - for (size_t i = 0; i < courses.size(); i++) { + for (std::size_t i = 0; i < courses.size(); i++) { delete courses[i].preview; } courses.clear(); @@ -736,7 +736,7 @@ bool CCourse::LoadCourseList() { return true; } -CCourseList* CCourse::getGroup(size_t index) { +CCourseList* CCourse::getGroup(std::size_t index) { std::map::iterator i = CourseLists.begin(); std::advance(i, index); return &i->second; @@ -785,7 +785,7 @@ bool CCourse::LoadCourse(TCourse* course) { } // ................................................................ - string itemfile = CourseDir + SEP "items.lst"; + std::string itemfile = CourseDir + SEP "items.lst"; bool itemsexists = FileExists(itemfile); const CControl *ctrl = g_game.player->ctrl; @@ -812,7 +812,7 @@ bool CCourse::LoadCourse(TCourse* course) { return true; } -size_t CCourse::GetEnv() const { +std::size_t CCourse::GetEnv() const { return curr_course->env; } @@ -829,22 +829,22 @@ void CCourse::MirrorCourseData() { int idx1 = (x+1) + nx*(y); int idx2 = (nx-1-x) + nx*(y); - swap(Fields[idx1].terrain, Fields[idx2].terrain); + std::swap(Fields[idx1].terrain, Fields[idx2].terrain); idx1 = (x) + nx*(y); idx2 = (nx-1-x) + nx*(y); - swap(Fields[idx1].nml, Fields[idx2].nml); + std::swap(Fields[idx1].nml, Fields[idx2].nml); Fields[idx1].nml.x *= -1; Fields[idx2].nml.x *= -1; } } - for (size_t i=0; isize.x - CollArr[i].pt.x; CollArr[i].pt.y = FindYCoord(CollArr[i].pt.x, CollArr[i].pt.z); } - for (size_t i=0; isize.x - NocollArr[i].pt.x; NocollArr[i].pt.y = FindYCoord(NocollArr[i].pt.x, NocollArr[i].pt.z); } @@ -1002,7 +1002,7 @@ void CCourse::GetSurfaceType(double x, double z, double weights[]) const { double u, v; FindBarycentricCoords(x, z, &idx0, &idx1, &idx2, &u, &v); - for (size_t i=0; i courses; - map index; + std::map index; public: - string name; + std::string name; bool Load(const std::string& dir); void Free(); - TCourse& operator[](size_t idx) { return courses[idx]; } - const TCourse& operator[](size_t idx) const { return courses[idx]; } - TCourse& operator[](string name_) { return courses[index.at(name_)]; } - const TCourse& operator[](string name_) const { return courses[index.at(name_)]; } - size_t size() const { return courses.size(); } + TCourse& operator[](std::size_t idx) { return courses[idx]; } + const TCourse& operator[](std::size_t idx) const { return courses[idx]; } + TCourse& operator[](std::string name_) { return courses[index.at(name_)]; } + const TCourse& operator[](std::string name_) const { return courses[index.at(name_)]; } + std::size_t size() const { return courses.size(); } }; class CCourse { private: const TCourse* curr_course; - map ObjectIndex; - string CourseDir; + std::map ObjectIndex; + std::string CourseDir; unsigned int nx; unsigned int ny; @@ -161,22 +161,22 @@ public: CCourse(); ~CCourse(); - map CourseLists; - CCourseList* currentCourseList; - vector TerrList; - vector ObjTypes; - vector CollArr; - vector NocollArr; - vector PolyArr; + std::map CourseLists; + CCourseList* currentCourseList; + std::vector TerrList; + std::vector ObjTypes; + std::vector CollArr; + std::vector NocollArr; + std::vector PolyArr; - vector Fields; + std::vector Fields; GLubyte *vnc_array; - CCourseList* getGroup(size_t index); + CCourseList* getGroup(std::size_t index); void ResetCourse(); - TCourse* GetCourse(const string& group, const string& dir); - size_t GetCourseIdx(const TCourse* course) const; + TCourse* GetCourse(const std::string& group, const std::string& dir); + std::size_t GetCourseIdx(const TCourse* course) const; void FreeCourseList(); bool LoadCourseList(); bool LoadCourse(TCourse* course); @@ -191,9 +191,9 @@ public: double GetCourseAngle() const { return curr_course->angle; } double GetBaseHeight(double distance) const; double GetMaxHeight(double distance) const; - size_t GetEnv() const; + std::size_t GetEnv() const; const TVector2d& GetStartPoint() const { return start_pt; } - const TPolyhedron& GetPoly(size_t type) const; + const TPolyhedron& GetPoly(std::size_t type) const; void MirrorCourse(); void GetIndicesForPoint(double x, double z, unsigned int* x0, unsigned int* y0, unsigned int* x1, unsigned int* y1) const; diff --git a/src/course_render.cpp b/src/course_render.cpp index 7d14c2c..d450f2a 100644 --- a/src/course_render.cpp +++ b/src/course_render.cpp @@ -50,7 +50,7 @@ void RenderCourse() { } void DrawTrees() { - size_t tree_type = -1; + std::size_t tree_type = -1; const CControl* ctrl = g_game.player->ctrl; ScopedRenderMode rm(TREES); @@ -61,7 +61,7 @@ void DrawTrees() { set_material(colWhite, colBlack, 1.0); // Trees - for (size_t i = 0; i< Course.CollArr.size(); i++) { + for (std::size_t i = 0; i< Course.CollArr.size(); i++) { if (clip_course) { if (ctrl->viewpos.z - Course.CollArr[i].pt.z > fwd_clip_limit) continue; if (Course.CollArr[i].pt.z - ctrl->viewpos.z > bwd_clip_limit) continue; @@ -118,7 +118,7 @@ void DrawTrees() { // Items const TObjectType* item_type = nullptr; - for (size_t i = 0; i< Course.NocollArr.size(); i++) { + for (std::size_t i = 0; i< Course.NocollArr.size(); i++) { if (Course.NocollArr[i].collectable == 0 || Course.NocollArr[i].type.drawable == false) continue; if (clip_course) { if (ctrl->viewpos.z - Course.NocollArr[i].pt.z > fwd_clip_limit) continue; diff --git a/src/credits.cpp b/src/credits.cpp index 7d4a6d4..758c3ed 100644 --- a/src/credits.cpp +++ b/src/credits.cpp @@ -50,7 +50,7 @@ void CCredits::LoadCreditList() { return; } - forward_list::iterator last = CreditList.before_begin(); + std::forward_list::iterator last = CreditList.before_begin(); for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { int old_offs = (last != CreditList.before_begin()) ? last->offs : 0; last = CreditList.emplace_after(last); @@ -74,7 +74,7 @@ void CCredits::DrawCreditsText(float time_step) { sf::Text text; text.setFont(FT.getCurrentFont()); RT->clear(colTBackr); - for (forward_list::const_iterator i = CreditList.begin(); i != CreditList.end(); ++i) { + for (std::forward_list::const_iterator i = CreditList.begin(); i != CreditList.end(); ++i) { offs = h - TOP_Y - y_offset + i->offs; if (offs > h || offs < -100.f) // Draw only visible lines continue; diff --git a/src/credits.h b/src/credits.h index a18f904..7a14050 100644 --- a/src/credits.h +++ b/src/credits.h @@ -22,7 +22,7 @@ GNU General Public License for more details. #include struct TCredits { - string text; + std::string text; float size; int offs; int font; @@ -30,7 +30,7 @@ struct TCredits { }; class CCredits : public State { - forward_list CreditList; + std::forward_list CreditList; void DrawCreditsText(float time_step); void Enter(); diff --git a/src/env.cpp b/src/env.cpp index 52b28c9..e71fac6 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -53,7 +53,7 @@ CEnvironment::CEnvironment() { lightcond[1] = "cloudy"; lightcond[2] = "evening"; lightcond[3] = "night"; - for (size_t i = 0; i < 4; i++) + for (std::size_t i = 0; i < 4; i++) LightIndex[lightcond[i]] = i; Skybox = nullptr; @@ -131,7 +131,7 @@ bool CEnvironment::LoadEnvironmentList() { } locs.resize(list.size()); - size_t i = 0; + std::size_t i = 0; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { locs[i].name = SPStrN(*line, "location"); locs[i].high_res = SPBoolN(*line, "high_res", false); @@ -140,16 +140,16 @@ bool CEnvironment::LoadEnvironmentList() { return true; } -string CEnvironment::GetDir(size_t location, size_t light) const { +std::string CEnvironment::GetDir(std::size_t location, std::size_t light) const { if (location >= locs.size()) return ""; if (light >= 4) return ""; - string res = + std::string res = param.env_dir2 + SEP + locs[location].name + SEP + lightcond[light]; return res; } -void CEnvironment::LoadSkyboxSide(size_t index, const string& EnvDir, const string& name, bool high_res) { +void CEnvironment::LoadSkyboxSide(std::size_t index, const std::string& EnvDir, const std::string& name, bool high_res) { bool loaded = false; if (param.perf_level > 3 && high_res) loaded = Skybox[index].Load(EnvDir, name + "H.png"); @@ -158,7 +158,7 @@ void CEnvironment::LoadSkyboxSide(size_t index, const string& EnvDir, const stri Skybox[index].Load(EnvDir, name + ".png"); } -void CEnvironment::LoadSkybox(const string& EnvDir, bool high_res) { +void CEnvironment::LoadSkybox(const std::string& EnvDir, bool high_res) { Skybox = new TTexture[param.full_skybox ? 6 : 3]; LoadSkyboxSide(0, EnvDir, "front", high_res); LoadSkyboxSide(1, EnvDir, "left", high_res); @@ -170,8 +170,8 @@ void CEnvironment::LoadSkybox(const string& EnvDir, bool high_res) { } } -void CEnvironment::LoadLight(const string& EnvDir) { - static const string idxstr = "[fog]-1[0]0[1]1[2]2[3]3[4]4[5]5[6]6"; +void CEnvironment::LoadLight(const std::string& EnvDir) { + static const std::string idxstr = "[fog]-1[0]0[1]1[2]2[3]3[4]4[5]5[6]6"; CSPList list; if (!list.Load(EnvDir, "light.lst")) { @@ -180,7 +180,7 @@ void CEnvironment::LoadLight(const string& EnvDir) { } for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { - string item = SPStrN(*line, "light", "none"); + std::string item = SPStrN(*line, "light", "none"); int idx = SPIntN(idxstr, item, -1); if (idx < 0) { fog.is_on = SPBoolN(*line, "fog", true); @@ -377,19 +377,19 @@ void CEnvironment::DrawFog() { } -void CEnvironment::LoadEnvironment(size_t loc, size_t light) { +void CEnvironment::LoadEnvironment(std::size_t loc, std::size_t light) { if (loc >= locs.size()) loc = 0; if (light >= 4) light = 0; // remember: with (example) 3 locations and 4 lights there // are 12 different environments - size_t env_id = loc * 100 + light; + std::size_t env_id = loc * 100 + light; if (env_id == EnvID) return; // Already loaded EnvID = env_id; // Set directory. The dir is used several times. - string EnvDir = GetDir(loc, light); + std::string EnvDir = GetDir(loc, light); // Load skybox. If the sky can't be loaded for any reason, the // texture id's are set to 0 and the sky will not be drawn. @@ -403,10 +403,10 @@ void CEnvironment::LoadEnvironment(size_t loc, size_t light) { LoadLight(EnvDir); } -size_t CEnvironment::GetEnvIdx(const string& tag) const { +std::size_t CEnvironment::GetEnvIdx(const std::string& tag) const { return EnvIndex.at(tag); } -size_t CEnvironment::GetLightIdx(const string& tag) const { +std::size_t CEnvironment::GetLightIdx(const std::string& tag) const { return LightIndex.at(tag); } diff --git a/src/env.h b/src/env.h index f470a65..fcb88cb 100644 --- a/src/env.h +++ b/src/env.h @@ -46,43 +46,43 @@ struct TLight { }; struct TEnvironment { - string name; + std::string name; bool high_res; }; class CEnvironment { private: - size_t EnvID; + std::size_t EnvID; TTexture* Skybox; - vector locs; - string lightcond[4]; + std::vector locs; + std::string lightcond[4]; TLight default_light; TLight lights[4]; TFog fog; TFog default_fog; - map EnvIndex; - map LightIndex; + std::map EnvIndex; + std::map LightIndex; void ResetSkybox(); - void LoadSkybox(const string& EnvDir, bool high_res); - void LoadSkyboxSide(size_t index, const string& EnvDir, const string& name, bool high_res); + void LoadSkybox(const std::string& EnvDir, bool high_res); + void LoadSkyboxSide(std::size_t index, const std::string& EnvDir, const std::string& name, bool high_res); void ResetLight(); - void LoadLight(const string& EnvDir); + void LoadLight(const std::string& EnvDir); void ResetFog(); void Reset(); - string GetDir(size_t location, size_t light) const; + std::string GetDir(std::size_t location, std::size_t light) const; public: CEnvironment(); bool LoadEnvironmentList(); - void LoadEnvironment(size_t loc, size_t light); + void LoadEnvironment(std::size_t loc, std::size_t light); void DrawSkybox(const TVector3d& pos); void SetupLight(); void SetupFog(); void DrawFog(); const sf::Color& ParticleColor() const { return fog.part_color; } - size_t GetEnvIdx(const string& tag) const; - size_t GetLightIdx(const string& tag) const; + std::size_t GetEnvIdx(const std::string& tag) const; + std::size_t GetLightIdx(const std::string& tag) const; }; extern CEnvironment Env; diff --git a/src/etr_types.h b/src/etr_types.h index d3b44de..dd19eb9 100644 --- a/src/etr_types.h +++ b/src/etr_types.h @@ -69,15 +69,15 @@ struct TGameData { bool mirrorred; TPlayer* player; TCharacter* character; - size_t start_player; + std::size_t start_player; TCup* cup; TRace* race; // Only valid if not in practice mode TCourse* course; - size_t location_id; - size_t light_id; + std::size_t location_id; + std::size_t light_id; int snow_id; int wind_id; - size_t theme_id; + std::size_t theme_id; // race results (better in player.ctrl ?) float time; // reached time diff --git a/src/event.cpp b/src/event.cpp index d8e8b2a..ac6f9c3 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -41,8 +41,8 @@ CEvent Event; // ready: 0 - racing 1 - ready with success 2 - ready with failure static int ready = 0; // indicates if last race is done static TCup *ecup = 0; -static size_t curr_race = 0; -static size_t curr_bonus = 0; +static std::size_t curr_race = 0; +static std::size_t curr_bonus = 0; static TWidget* textbuttons[3]; static TLabel* headline; static TLabel* info1; @@ -107,7 +107,7 @@ void InitCupRacing() { } void UpdateCupRacing() { - size_t lastrace = ecup->races.size() - 1; + std::size_t lastrace = ecup->races.size() - 1; curr_bonus += g_game.race_result; if (g_game.race_result >= 0) { if (curr_race < lastrace) curr_race++; @@ -157,7 +157,7 @@ void CEvent::Enter() { FT.AutoSizeN(3); int ddd = FT.AutoDistanceN(1); - string info = Trans.Text(11); + std::string info = Trans.Text(11); info += " " + Int_StrN(ecup->races[curr_race]->herrings.x); info += " " + Int_StrN(ecup->races[curr_race]->herrings.y); info += " " + Int_StrN(ecup->races[curr_race]->herrings.z); @@ -177,7 +177,7 @@ void CEvent::Enter() { Music.Play(param.menu_music, true); } -int resultlevel(size_t num, size_t numraces) { +int resultlevel(std::size_t num, std::size_t numraces) { if (num < 1) return 0; int q = (int)((num - 0.01) / numraces); return q + 1; @@ -200,7 +200,7 @@ void CEvent::Loop(float timestep) { (int)ecup->races.size() * dist + 20, 3, colBackgr, colWhite, 1); TCheckbox checkbox(area.right - 50, frametop, texsize, ""); - for (size_t i=0; iraces.size(); i++) { + for (std::size_t i=0; iraces.size(); i++) { FT.AutoSizeN(4); int y = frametop + 10 + (int)i * dist; diff --git a/src/font.cpp b/src/font.cpp index 2db04c8..7f1fff3 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -33,9 +33,9 @@ GNU General Public License for more details. // CFont::MakeLineList. This bundle of functions generates // a vector from a textstring and adapts the lines to the textbox -static void MakeWordList(vector& wordlist, const char *s) { - size_t start = 0; - for (size_t i = 0; s[i] != '\0'; i++) { +static void MakeWordList(std::vector& wordlist, const char *s) { + std::size_t start = 0; + for (std::size_t i = 0; s[i] != '\0'; i++) { if (s[i] == ' ') { if (i != start) wordlist.emplace_back(s + start, i - start); @@ -48,10 +48,10 @@ static void MakeWordList(vector& wordlist, const char *s) { wordlist.emplace_back(s + start); } -static size_t MakeLine(size_t first, const vector& wordlist, vector& linelist, float width) { +static std::size_t MakeLine(std::size_t first, const std::vector& wordlist, std::vector& linelist, float width) { if (first >= wordlist.size()) return wordlist.size()-1; - size_t last = first; + std::size_t last = first; float lng = 0; float spacelng = FT.GetTextWidth("a a") - FT.GetTextWidth("aa"); @@ -64,8 +64,8 @@ static size_t MakeLine(size_t first, const vector& wordlist, vectorloadFromFile(path)) { Message("Failed to open font"); @@ -119,8 +119,8 @@ int CFont::LoadFont(const string& name, const string& path) { return (int)fonts.size()-1; } -int CFont::LoadFont(const string& name, const string& dir, const string& filename) { - string path = dir; +int CFont::LoadFont(const std::string& name, const std::string& dir, const std::string& filename) { + std::string path = dir; path += SEP; path += filename; return LoadFont(name, path); @@ -134,8 +134,8 @@ bool CFont::LoadFontlist() { } for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { - string fontfile = SPStrN(*line, "file"); - string name = SPStrN(*line, "name"); + std::string fontfile = SPStrN(*line, "file"); + std::string name = SPStrN(*line, "name"); int ftidx = LoadFont(name, param.font_dir, fontfile); if (ftidx < 0) { @@ -145,21 +145,21 @@ bool CFont::LoadFontlist() { return true; } -size_t CFont::GetFontIdx(const string &name) const { +std::size_t CFont::GetFontIdx(const std::string &name) const { return fontindex.at(name); } -void CFont::SetProps(const string &fontname, float size, const sf::Color& col) { +void CFont::SetProps(const std::string &fontname, float size, const sf::Color& col) { SetProps(fontname, size); curr_col = col; } -void CFont::SetProps(const string &fontname, float size) { +void CFont::SetProps(const std::string &fontname, float size) { curr_font = (int)GetFontIdx(fontname); curr_size = size; } -void CFont::SetFont(const string& fontname) { +void CFont::SetFont(const std::string& fontname) { try { curr_font = (int)fontindex[fontname]; } catch (...) { @@ -195,7 +195,7 @@ int CFont::AutoDistanceN(int rel_val) { // -------------------- draw (x, y, text) ----------------------------- -void CFont::DrawText(float x, float y, const sf::String& text, size_t font, float size) const { +void CFont::DrawText(float x, float y, const sf::String& text, std::size_t font, float size) const { if (font >= fonts.size()) return; sf::Text temp(text, *fonts[font], size); @@ -210,14 +210,14 @@ void CFont::DrawString(float x, float y, const sf::String &s) const { DrawText(x, y, s, curr_font, curr_size); } -void CFont::DrawString(float x, float y, const sf::String& s, const string &fontname, float size) const { +void CFont::DrawString(float x, float y, const sf::String& s, const std::string &fontname, float size) const { DrawText(x, y, s, GetFontIdx(fontname), size); } // --------------------- metrics -------------------------------------- -void CFont::GetTextSize(const sf::String& text, float &x, float &y, size_t font, float size) const { +void CFont::GetTextSize(const sf::String& text, float &x, float &y, std::size_t font, float size) const { if (font >= fonts.size()) { x = 0; y = 0; return; } sf::Text temp(text, *fonts[font], size); @@ -225,7 +225,7 @@ void CFont::GetTextSize(const sf::String& text, float &x, float &y, size_t font, y = temp.getGlobalBounds().height; } -void CFont::GetTextSize(const sf::String& text, float &x, float &y, const string &fontname, float size) const { +void CFont::GetTextSize(const sf::String& text, float &x, float &y, const std::string &fontname, float size) const { GetTextSize(text, x, y, GetFontIdx(fontname), size); } @@ -239,19 +239,19 @@ float CFont::GetTextWidth(const sf::String& text) const { return x; } -float CFont::GetTextWidth(const sf::String& text, const string &fontname, float size) const { - size_t temp_font = GetFontIdx(fontname); +float CFont::GetTextWidth(const sf::String& text, const std::string &fontname, float size) const { + std::size_t temp_font = GetFontIdx(fontname); float x, y; GetTextSize(text, x, y, temp_font, size); return x; } -vector CFont::MakeLineList(const char *source, float width) { - vector wordlist; +std::vector CFont::MakeLineList(const char *source, float width) { + std::vector wordlist; MakeWordList(wordlist, source); - vector linelist; + std::vector linelist; - for (size_t last = 0; last < wordlist.size();) + for (std::size_t last = 0; last < wordlist.size();) last = MakeLine(last, wordlist, linelist, width)+1; return linelist; diff --git a/src/font.h b/src/font.h index 48cf603..d01b4d8 100644 --- a/src/font.h +++ b/src/font.h @@ -30,34 +30,34 @@ GNU General Public License for more details. class CFont { private: - vector fonts; - map fontindex; + std::vector fonts; + std::map fontindex; int curr_font; sf::Color curr_col; float curr_size; float curr_fact; // the length factor - void DrawText(float x, float y, const sf::String& text, size_t font, float size) const; - void GetTextSize(const sf::String& text, float &x, float &y, size_t font, float size) const; + void DrawText(float x, float y, const sf::String& text, std::size_t font, float size) const; + void GetTextSize(const sf::String& text, float &x, float &y, std::size_t font, float size) const; public: CFont(); ~CFont(); void Clear(); - int LoadFont(const string& name, const string& dir, const string& filename); - int LoadFont(const string& name, const string& path); + int LoadFont(const std::string& name, const std::string& dir, const std::string& filename); + int LoadFont(const std::string& name, const std::string& path); bool LoadFontlist(); - size_t GetFontIdx(const string &name) const; + std::size_t GetFontIdx(const std::string &name) const; const sf::Font& getCurrentFont() const { return *fonts[curr_font]; } float GetSize() const { return curr_size; } // properties - void SetProps(const string &fontname, float size, const sf::Color& col); - void SetProps(const string &fontname, float size); + void SetProps(const std::string &fontname, float size, const sf::Color& col); + void SetProps(const std::string &fontname, float size); void SetColor(const sf::Color& col) { curr_col = col; } void SetSize(float size) { curr_size = size; } - void SetFont(const string& fontname); + void SetFont(const std::string& fontname); void SetFontFromSettings(); // auto @@ -66,15 +66,15 @@ public: // draw void DrawString(float x, float y, const sf::String &s) const; // sf::String class - void DrawString(float x, float y, const sf::String &s, const string &fontname, float size) const; + void DrawString(float x, float y, const sf::String &s, const std::string &fontname, float size) const; // metrics void GetTextSize(const sf::String& text, float &x, float &y) const; - void GetTextSize(const sf::String& text, float &x, float &y, const string &fontname, float size) const; + void GetTextSize(const sf::String& text, float &x, float &y, const std::string &fontname, float size) const; float GetTextWidth(const sf::String& text) const; - float GetTextWidth(const sf::String& text, const string &fontname, float size) const; + float GetTextWidth(const sf::String& text, const std::string &fontname, float size) const; - vector MakeLineList(const char *source, float width); + std::vector MakeLineList(const char *source, float width); }; extern CFont FT; diff --git a/src/game_config.cpp b/src/game_config.cpp index 1b8778a..3c57e53 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -89,7 +89,7 @@ void SetConfigDefaults() { param.fullscreen = true; param.res_type = 0; // 0=auto / 1=800x600 / 2=1024x768 ... param.perf_level = 3; // detail level - param.language = string::npos; // If language is set to npos, ETR will try to load default system language + param.language = std::string::npos; // If language is set to npos, ETR will try to load default system language param.sound_volume = 90; param.music_volume = 20; @@ -118,14 +118,14 @@ void SetConfigDefaults() { template -void AddItem(CSPList &list, const string& tag, T content) { - ostringstream os; +void AddItem(CSPList &list, const std::string& tag, T content) { + std::ostringstream os; os << " [" << tag << "] " << content; list.Add(os.str()); } -void AddComment(CSPList &list, const string& comment) { - string line = "# " + comment; +void AddComment(CSPList &list, const std::string& comment) { + std::string line = "# " + comment; list.Add(line); } diff --git a/src/game_config.h b/src/game_config.h index 925c885..95b5716 100644 --- a/src/game_config.h +++ b/src/game_config.h @@ -21,31 +21,30 @@ GNU General Public License for more details. struct TParam { // defined at runtime: - // string prog_dir; - string config_dir; - string data_dir; - string common_course_dir; - string obj_dir; - string terr_dir; - string char_dir; - string env_dir2; - string tex_dir; - string sounds_dir; - string music_dir; - string screenshot_dir; - string font_dir; - string trans_dir; - string player_dir; - string configfile; + std::string config_dir; + std::string data_dir; + std::string common_course_dir; + std::string obj_dir; + std::string terr_dir; + std::string char_dir; + std::string env_dir2; + std::string tex_dir; + std::string sounds_dir; + std::string music_dir; + std::string screenshot_dir; + std::string font_dir; + std::string trans_dir; + std::string player_dir; + std::string configfile; // ------------------------------------ // main config params: - size_t res_type; + std::size_t res_type; uint32_t framerate; - int perf_level; - size_t language; - int sound_volume; - int music_volume; + int perf_level; + std::size_t language; + int sound_volume; + int music_volume; int forward_clip_distance; int backward_clip_distance; @@ -62,9 +61,9 @@ struct TParam { bool use_quad_scale; // scaling type for menus bool fullscreen; - string menu_music; - string credits_music; - string config_music; + std::string menu_music; + std::string credits_music; + std::string config_music; // these params are not saved in options file TViewMode view_mode; diff --git a/src/game_ctrl.cpp b/src/game_ctrl.cpp index 0358049..46297c3 100644 --- a/src/game_ctrl.cpp +++ b/src/game_ctrl.cpp @@ -66,7 +66,7 @@ bool CEvents::LoadEventList() { int num = SPIntN(*line, "num", 0); CupList.back().races.resize(num); for (int ii=0; ii= EventList.size()) return errorString; if (cup >= EventList[event].cups.size()) return errorString; return EventList[event].cups[cup]->cup; } -const string& CEvents::GetCupTrivialName(size_t event, size_t cup) const { +const std::string& CEvents::GetCupTrivialName(std::size_t event, std::size_t cup) const { if (event >= EventList.size()) return errorString; if (cup >= EventList[event].cups.size()) return errorString; return EventList[event].cups[cup]->name; } -void CEvents::MakeUnlockList(const string& unlockstr) { - for (size_t event=0; eventUnlocked = false; } } - for (size_t event=0; eventUnlocked = true; if (passed) { EventList[event].cups[cup]->Unlocked = true; @@ -135,7 +135,7 @@ void CEvents::MakeUnlockList(const string& unlockstr) { } } -bool CEvents::IsUnlocked(size_t event, size_t cup) const { +bool CEvents::IsUnlocked(std::size_t event, std::size_t cup) const { if (event >= EventList.size()) return false; if (cup >= EventList[event].cups.size()) return false; return EventList[event].cups[cup]->Unlocked; @@ -149,11 +149,11 @@ CPlayers Players; CPlayers::~CPlayers() { ResetControls(); - for (size_t i = 0; i < avatars.size(); i++) + for (std::size_t i = 0; i < avatars.size(); i++) delete avatars[i].texture; } -void CPlayers::AddPlayer(const string& name, const string& avatar) { +void CPlayers::AddPlayer(const std::string& name, const std::string& avatar) { plyr.emplace_back(name, FindAvatar(avatar)); } @@ -178,7 +178,7 @@ bool CPlayers::LoadPlayers() { g_game.start_player = 0; plyr.resize(list.size()); - size_t i = 0; + std::size_t i = 0; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { plyr[i].name = SPStrN(*line, "name", "unknown"); plyr[i].funlocked = SPStrN(*line, "unlocked"); @@ -196,10 +196,10 @@ bool CPlayers::LoadPlayers() { } void CPlayers::SavePlayers() const { - string playerfile = param.config_dir + SEP "players"; + std::string playerfile = param.config_dir + SEP "players"; CSPList list(plyr.size()); - for (size_t i=0; ifilename; item += "[unlocked]" + plyr[i].funlocked; if (&plyr[i] == g_game.player) item += "[active]1"; @@ -209,28 +209,28 @@ void CPlayers::SavePlayers() const { list.Save(playerfile); } -const TAvatar* CPlayers::FindAvatar(const string& name) const { - for (size_t i = 0; i < avatars.size(); i++) +const TAvatar* CPlayers::FindAvatar(const std::string& name) const { + for (std::size_t i = 0; i < avatars.size(); i++) if (avatars[i].filename == name) return &avatars[i]; return 0; } -void CPlayers::AddPassedCup(const string& cup) { +void CPlayers::AddPassedCup(const std::string& cup) { if (SPIntN(g_game.player->funlocked, cup, -1) > 0) return; g_game.player->funlocked += ' '; g_game.player->funlocked += cup; } void CPlayers::ResetControls() { - for (size_t i=0; i= plyr.size()) return; if (plyr[player].ctrl != nullptr) return; plyr[player].ctrl = new CControl; @@ -247,7 +247,7 @@ bool CPlayers::LoadAvatars() { } for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { - string filename = SPStrN(*line, "file", "unknown"); + std::string filename = SPStrN(*line, "file", "unknown"); TTexture* texture = new TTexture(); if (texture && texture->Load(param.player_dir, filename)) { avatars.emplace_back(filename, texture); @@ -257,12 +257,12 @@ bool CPlayers::LoadAvatars() { return true; } -TTexture* CPlayers::GetAvatarTexture(size_t avatar) const { +TTexture* CPlayers::GetAvatarTexture(std::size_t avatar) const { if (avatar >= avatars.size()) return 0; return avatars[avatar].texture; } -const string& CPlayers::GetDirectAvatarName(size_t avatar) const { +const std::string& CPlayers::GetDirectAvatarName(std::size_t avatar) const { if (avatar >= avatars.size()) return emptyString; return avatars[avatar].filename; } @@ -279,10 +279,10 @@ CKeyframe* TCharacter::GetKeyframe(TFrameType type_) { CCharacter Char; -static const string char_type_index = "[spheres]0[3d]1"; +static const std::string char_type_index = "[spheres]0[3d]1"; CCharacter::~CCharacter() { - for (size_t i = 0; i < CharList.size(); i++) { + for (std::size_t i = 0; i < CharList.size(); i++) { delete CharList[i].preview; delete CharList[i].shape; } @@ -297,16 +297,16 @@ bool CCharacter::LoadCharacterList() { } CharList.resize(list.size()); - size_t i = 0; + std::size_t i = 0; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { CharList[i].name = SPStrN(*line, "name"); CharList[i].dir = SPStrN(*line, "dir"); - string typestr = SPStrN(*line, "type", "unknown"); + std::string typestr = SPStrN(*line, "type", "unknown"); CharList[i].type = SPIntN(char_type_index, typestr, -1); - string charpath = param.char_dir + SEP + CharList[i].dir; + std::string charpath = param.char_dir + SEP + CharList[i].dir; if (DirExists(charpath.c_str())) { - string previewfile = charpath + SEP "preview.png"; + std::string previewfile = charpath + SEP "preview.png"; TCharacter* ch = &CharList[i]; ch->preview = new TTexture(); @@ -336,7 +336,7 @@ bool CCharacter::LoadCharacterList() { } void CCharacter::FreeCharacterPreviews() { - for (size_t i=0; i races; + std::string cup; + std::string name; + std::string desc; + std::vector races; bool Unlocked; - TCup(const string& cup_, const string& name_, const string& desc_) + TCup(const std::string& cup_, const std::string& name_, const std::string& desc_) : cup(cup_), name(name_), desc(desc_), Unlocked(false) {} }; struct TEvent { - string name; - vector cups; + std::string name; + std::vector cups; - explicit TEvent(const string& name_) + explicit TEvent(const std::string& name_) : name(name_) {} }; class CEvents { private: - map RaceIndex; - map CupIndex; - map EventIndex; + std::map RaceIndex; + std::map CupIndex; + std::map EventIndex; public: - vector RaceList; - vector CupList; - vector EventList; + std::vector RaceList; + std::vector CupList; + std::vector EventList; bool LoadEventList(); - size_t GetRaceIdx(const string& race) const; - size_t GetCupIdx(const string& cup) const; - size_t GetEventIdx(const string& event) const; - const string& GetCup(size_t event, size_t cup) const; - const string& GetCupTrivialName(size_t event, size_t cup) const; + std::size_t GetRaceIdx(const std::string& race) const; + std::size_t GetCupIdx(const std::string& cup) const; + std::size_t GetEventIdx(const std::string& event) const; + const std::string& GetCup(std::size_t event, std::size_t cup) const; + const std::string& GetCupTrivialName(std::size_t event, std::size_t cup) const; - void MakeUnlockList(const string& unlockstr); - bool IsUnlocked(size_t event, size_t cup) const; + void MakeUnlockList(const std::string& unlockstr); + bool IsUnlocked(std::size_t event, std::size_t cup) const; }; extern CEvents Events; @@ -96,48 +96,48 @@ extern CEvents Events; // -------------------------------------------------------------------- struct TAvatar { - string filename; + std::string filename; TTexture* texture; - TAvatar(const string& filename_, TTexture* texture_) + TAvatar(const std::string& filename_, TTexture* texture_) : filename(filename_), texture(texture_) {} }; struct TPlayer { - string name; + std::string name; CControl *ctrl; - string funlocked; + std::string funlocked; const TAvatar* avatar; - TPlayer(const string& name_ = emptyString, const TAvatar* avatar_ = nullptr) + TPlayer(const std::string& name_ = emptyString, const TAvatar* avatar_ = nullptr) : name(name_), ctrl(nullptr), avatar(avatar_) {} }; class CPlayers { private: - vector plyr; + std::vector plyr; void SetDefaultPlayers(); - vector avatars; + std::vector avatars; - const TAvatar* FindAvatar(const string& name) const; + const TAvatar* FindAvatar(const std::string& name) const; public: ~CPlayers(); - TPlayer* GetPlayer(size_t index) { return &plyr[index]; } - void AddPassedCup(const string& cup); - void AddPlayer(const string& name, const string& avatar); + TPlayer* GetPlayer(std::size_t index) { return &plyr[index]; } + void AddPassedCup(const std::string& cup); + void AddPlayer(const std::string& name, const std::string& avatar); bool LoadPlayers(); void SavePlayers() const; void ResetControls(); - void AllocControl(size_t player); + void AllocControl(std::size_t player); bool LoadAvatars(); - size_t numAvatars() const { return avatars.size(); } - size_t numPlayers() const { return plyr.size(); } + std::size_t numAvatars() const { return avatars.size(); } + std::size_t numPlayers() const { return plyr.size(); } - TTexture* GetAvatarTexture(size_t avatar) const; - const string& GetDirectAvatarName(size_t avatar) const; + TTexture* GetAvatarTexture(std::size_t avatar) const; + const std::string& GetDirectAvatarName(std::size_t avatar) const; }; extern CPlayers Players; @@ -145,8 +145,8 @@ extern CPlayers Players; // -------------------------------- characters ------------------------ struct TCharacter { - string name; - string dir; + std::string name; + std::string dir; TTexture* preview; CCharShape *shape; CKeyframe frames[NUM_FRAME_TYPES]; @@ -158,7 +158,7 @@ struct TCharacter { class CCharacter { public: - vector CharList; + std::vector CharList; ~CCharacter(); diff --git a/src/game_over.cpp b/src/game_over.cpp index fd596f6..f65718b 100644 --- a/src/game_over.cpp +++ b/src/game_over.cpp @@ -88,7 +88,7 @@ void GameOverMessage(const CControl *ctrl) { if (g_game.race_result >= 0 || g_game.game_type != CUPRACING) FT.SetColor(colDBlue); else FT.SetColor(colDRed); - string line = Trans.Text(84) + ": "; + std::string line = Trans.Text(84) + ": "; FT.DrawString(firstMarker, topframe + 15, line); line = Int_StrN(g_game.score); line += " pts"; diff --git a/src/gui.cpp b/src/gui.cpp index c37fc31..8ac2728 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -29,7 +29,7 @@ GNU General Public License for more details. #define CURSOR_SIZE 10 -static vector Widgets; +static std::vector Widgets; static int lock_focussed = -1; static int focussed = -1; static bool locked_LR = false; @@ -224,14 +224,14 @@ void TTextField::TextEnter(char key) { } } -void TTextField::SetCursorPos(size_t new_pos) { +void TTextField::SetCursorPos(std::size_t new_pos) { cursorPos = new_pos; int x = mouseRect.left + 20 - 2; if (cursorPos != 0) { // substring() is very new addition to SFML2 string class, so // for compatibility with older version we use std::string to do it. - string temp = text.getString(); + std::string temp = text.getString(); FT.AutoSizeN(5); x += FT.GetTextWidth(temp.substr(0, cursorPos)); } @@ -249,7 +249,7 @@ void TTextField::Focussed() { } } -static void eraseFromText(sf::Text& text, size_t pos) { +static void eraseFromText(sf::Text& text, std::size_t pos) { sf::String str = text.getString(); str.erase(pos, 1); text.setString(str); @@ -562,8 +562,8 @@ void DrawFrameX(int x, int y, int w, int h, int line, const sf::Color& backcol, Winsys.draw(shape); } -void DrawBonusExt(int y, size_t numraces, size_t num) { - size_t maxtux = numraces * 3; +void DrawBonusExt(int y, std::size_t numraces, std::size_t num) { + std::size_t maxtux = numraces * 3; if (num > maxtux) return; static const sf::Color col2(115, 166, 217); @@ -585,9 +585,9 @@ void DrawBonusExt(int y, size_t numraces, size_t num) { sf::Vector2u size = tuxbonus.getTexture()->getSize(); tuxbonus.setTextureRect(sf::IntRect(0, 0, size.x, 0.5*size.y)); - for (size_t i=0; i 2) majr = 2; int x = lleft[majr] + (int)minr * 40 + 6; @@ -639,7 +639,7 @@ void DrawCursor() { // ------------------ Main GUI functions --------------------------------------------- void DrawGUI() { - for (size_t i = 0; i < Widgets.size(); i++) + for (std::size_t i = 0; i < Widgets.size(); i++) if (Widgets[i]->GetVisible()) Widgets[i]->Draw(); if (param.ice_cursor) @@ -648,7 +648,7 @@ void DrawGUI() { TWidget* ClickGUI(int x, int y) { TWidget* clicked = nullptr; - for (size_t i = 0; i < Widgets.size(); i++) { + for (std::size_t i = 0; i < Widgets.size(); i++) { if (Widgets[i]->Click(x, y)) { clicked = Widgets[i]; lock_focussed = focussed; @@ -660,7 +660,7 @@ TWidget* ClickGUI(int x, int y) { TWidget* MouseMoveGUI(int x, int y) { if (x != 0 || y != 0) { focussed = -1; - for (size_t i = 0; i < Widgets.size(); i++) { + for (std::size_t i = 0; i < Widgets.size(); i++) { Widgets[i]->MouseMove(cursor_pos.x, cursor_pos.y); if (Widgets[i]->focussed()) focussed = (int)i; @@ -724,7 +724,7 @@ void SetFocus(TWidget* widget) { if (!widget) focussed = -1; else - for (size_t i = 0; i < Widgets.size(); i++) { + for (std::size_t i = 0; i < Widgets.size(); i++) { if (Widgets[i] == widget) { Widgets[i]->focus = true; Widgets[i]->Focussed(); @@ -793,7 +793,7 @@ void DecreaseFocus() { } void ResetGUI() { - for (size_t i = 0; i < Widgets.size(); i++) + for (std::size_t i = 0; i < Widgets.size(); i++) delete Widgets[i]; Widgets.clear(); focussed = 0; diff --git a/src/gui.h b/src/gui.h index 42ed88d..d85cd60 100644 --- a/src/gui.h +++ b/src/gui.h @@ -106,12 +106,12 @@ class TTextField : public TWidget { sf::Text text; sf::RectangleShape frame; sf::RectangleShape cursorShape; - size_t cursorPos; - size_t maxLng; + std::size_t cursorPos; + std::size_t maxLng; float time; bool cursor; - void SetCursorPos(size_t new_pos); + void SetCursorPos(std::size_t new_pos); public: TTextField(int x, int y, int width, int height, const sf::String& text_); void Draw() const; @@ -203,7 +203,7 @@ void ResetGUI(); void DrawFrameX(int x, int y, int w, int h, int line, const sf::Color& backcol, const sf::Color& framecol, double transp); -void DrawBonusExt(int y, size_t numraces, size_t num); +void DrawBonusExt(int y, std::size_t numraces, std::size_t num); void DrawGUIBackground(float scale); void DrawGUIFrame(); void DrawCursor(); diff --git a/src/hud.cpp b/src/hud.cpp index 32f7e5a..9b08da4 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -57,9 +57,9 @@ static void draw_time() { int min, sec, hundr; GetTimeComponents(g_game.time, &min, &sec, &hundr); - string timestr = Int_StrN(min, 2); - string secstr = Int_StrN(sec, 2); - string hundrstr = Int_StrN(hundr, 2); + std::string timestr = Int_StrN(min, 2); + std::string secstr = Int_StrN(sec, 2); + std::string hundrstr = Int_StrN(hundr, 2); timestr += ':'; timestr += secstr; @@ -81,7 +81,7 @@ static void draw_time() { static void draw_herring_count(int herring_count) { Tex.Draw(HERRING_ICON, Winsys.resolution.width - 59, 12, 1); - string hcountstr = Int_StrN(herring_count, 3); + std::string hcountstr = Int_StrN(herring_count, 3); if (param.use_papercut_font < 2) { Tex.DrawNumStr(hcountstr, Winsys.resolution.width - 130, 12, 1, colWhite); } else { @@ -213,7 +213,7 @@ void draw_gauge(double speed, double energy) { } void DrawSpeed(double speed) { - string speedstr = Int_StrN((int)speed, 3); + std::string speedstr = Int_StrN((int)speed, 3); if (param.use_papercut_font < 2) { Tex.DrawNumStr(speedstr, Winsys.resolution.width - 87, Winsys.resolution.height-73, 1, colWhite); @@ -279,7 +279,7 @@ void DrawWind(float dir, float speed, const CControl *ctrl) { glEnable(GL_TEXTURE_2D); Tex.Draw(SPEED_KNOB, 5 + texWidth / 2 - 8, Winsys.resolution.height - 5 - texWidth / 2 - 8, 1.0); - string windstr = Int_StrN((int)speed, 3); + std::string windstr = Int_StrN((int)speed, 3); if (param.use_papercut_font < 2) { Tex.DrawNumStr(windstr, 120, Winsys.resolution.height - 45, 1, colWhite); } else { @@ -309,7 +309,7 @@ void DrawFps() { } if (averagefps < 1) return; - string fpsstr = Int_StrN((int)averagefps); + std::string fpsstr = Int_StrN((int)averagefps); if (param.use_papercut_font < 2) { Tex.DrawNumStr(fpsstr, (Winsys.resolution.width - 60) / 2, 10, 1, colWhite); } else { diff --git a/src/intro.cpp b/src/intro.cpp index bfd0139..cda4f58 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -78,8 +78,8 @@ void CIntro::Enter() { SetCameraDistance(4.0); SetStationaryCamera(false); update_view(ctrl, EPS); - size_t num_items = Course.NocollArr.size(); - for (size_t i = 0; i < num_items; i++) { + std::size_t num_items = Course.NocollArr.size(); + for (std::size_t i = 0; i < num_items; i++) { if (Course.NocollArr[i].collectable != -1) { Course.NocollArr[i].collectable = 1; } diff --git a/src/keyframe.cpp b/src/keyframe.cpp index a06edfb..f0fc2a1 100644 --- a/src/keyframe.cpp +++ b/src/keyframe.cpp @@ -33,7 +33,7 @@ static const int numJoints = 19; // The jointnames are shown on the tools screen and define the // possible rotations. A joint can be rotated around 3 axis, so // a joint can contain up to 3 joinnames. -static const string jointnames[numJoints] = { +static const std::string jointnames[numJoints] = { "time","pos.x","pos.y","pos.z","yaw","pitch","roll","neck","head", "l_shldr","r_shldr","l_arm","r_arm", "l_hip","r_hip","l_knee","r_knee","l_ankle","r_ankle" @@ -42,7 +42,7 @@ static const string jointnames[numJoints] = { // The highlightnames must be official joint identifiers, defined in // the character description. They are used to find the port nodes // for highlighting -static const string highlightnames[numJoints] = { +static const std::string highlightnames[numJoints] = { "","","","","","","","neck","head", "left_shldr","right_shldr","left_shldr","right_shldr", "left_hip","right_hip","left_knee","right_knee","left_ankle","right_ankle" @@ -104,13 +104,13 @@ void CKeyframe::Reset() { frames.clear(); } -bool CKeyframe::Load(const string& dir, const string& filename) { +bool CKeyframe::Load(const std::string& dir, const std::string& filename) { if (loaded && loadedfile == filename) return true; CSPList list; if (list.Load(dir, filename)) { frames.resize(list.size()); - size_t i = 0; + std::size_t i = 0; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { frames[i].val[0] = SPFloatN(*line, "time", 0); TVector3d posit = SPVector3d(*line, "pos"); @@ -151,7 +151,7 @@ bool CKeyframe::Load(const string& dir, const string& filename) { // there are more possibilities for rotating the parts of the body, // that will be implemented later -void CKeyframe::InterpolateKeyframe(size_t idx, double frac, CCharShape *shape) { +void CKeyframe::InterpolateKeyframe(std::size_t idx, double frac, CCharShape *shape) { double vv; vv = interp(frac, frames[idx].val[4], frames[idx+1].val[4]); shape->RotateNode("root", 2, vv); @@ -199,7 +199,7 @@ void CKeyframe::InterpolateKeyframe(size_t idx, double frac, CCharShape *shape) shape->RotateNode("right_ankle", 3, vv); } -void CKeyframe::CalcKeyframe(size_t idx, CCharShape *shape, const TVector3d& refpos_) { +void CKeyframe::CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos_) { double vv; TVector3d pos; @@ -329,17 +329,17 @@ void CKeyframe::ResetFrame2(TKeyframe *frame) { frame->val[0] = 0.5; // time } -TKeyframe *CKeyframe::GetFrame(size_t idx) { +TKeyframe *CKeyframe::GetFrame(std::size_t idx) { if (idx >= frames.size()) return nullptr; return &frames[idx]; } -const string& CKeyframe::GetJointName(size_t idx) { +const std::string& CKeyframe::GetJointName(std::size_t idx) { if (idx >= numJoints) return emptyString; return jointnames[idx]; } -const string& CKeyframe::GetHighlightName(size_t idx) { +const std::string& CKeyframe::GetHighlightName(std::size_t idx) { if (idx >= numJoints) return emptyString; return highlightnames[idx]; } @@ -348,12 +348,12 @@ int CKeyframe::GetNumJoints() { return numJoints; } -void CKeyframe::SaveTest(const string& dir, const string& filename) const { +void CKeyframe::SaveTest(const std::string& dir, const std::string& filename) const { CSPList list; - for (size_t i=0; ival[0], 1); + std::string line = "*[time] " + Float_StrN(frame->val[0], 1); line += " [pos] " + Float_StrN(frame->val[1], 2); line += " " + Float_StrN(frame->val[2], 2); line += " " + Float_StrN(frame->val[3], 2); @@ -393,7 +393,7 @@ void CKeyframe::SaveTest(const string& dir, const string& filename) const { list.Save(dir, filename); } -void CKeyframe::CopyFrame(size_t prim_idx, size_t sec_idx) { +void CKeyframe::CopyFrame(std::size_t prim_idx, std::size_t sec_idx) { TKeyframe *ppp = &frames[prim_idx]; TKeyframe *sss = &frames[sec_idx]; std::copy_n(ppp->val, MAX_FRAME_VALUES, sss->val); @@ -403,7 +403,7 @@ void CKeyframe::AddFrame() { frames.emplace_back(); } -size_t CKeyframe::DeleteFrame(size_t idx) { +std::size_t CKeyframe::DeleteFrame(std::size_t idx) { if (frames.size() < 2) return idx; if (idx > frames.size() - 1) return 0; @@ -413,7 +413,7 @@ size_t CKeyframe::DeleteFrame(size_t idx) { return max(idx, frames.size() - 2); } -void CKeyframe::InsertFrame(size_t idx) { +void CKeyframe::InsertFrame(std::size_t idx) { if (idx > frames.size() - 1) return; std::vector::iterator i = frames.begin(); @@ -421,17 +421,17 @@ void CKeyframe::InsertFrame(size_t idx) { frames.emplace(i); } -void CKeyframe::CopyToClipboard(size_t idx) { +void CKeyframe::CopyToClipboard(std::size_t idx) { if (idx >= frames.size()) return; std::copy_n(frames[idx].val, MAX_FRAME_VALUES, clipboard.val); } -void CKeyframe::PasteFromClipboard(size_t idx) { +void CKeyframe::PasteFromClipboard(std::size_t idx) { if (idx >= frames.size()) return; std::copy_n(clipboard.val, MAX_FRAME_VALUES, frames[idx].val); } -void CKeyframe::ClearFrame(size_t idx) { +void CKeyframe::ClearFrame(std::size_t idx) { if (idx >= frames.size()) return; ResetFrame2(&frames[idx]); } diff --git a/src/keyframe.h b/src/keyframe.h index 61dd360..29e6033 100644 --- a/src/keyframe.h +++ b/src/keyframe.h @@ -35,16 +35,16 @@ struct TKeyframe { class CKeyframe { private: - vector frames; + std::vector frames; TVector3d refpos; - string loadedfile; + std::string loadedfile; TKeyframe clipboard; double keytime; double heightcorr; - size_t keyidx; + std::size_t keyidx; static double interp(double frac, double v1, double v2); - void InterpolateKeyframe(size_t idx, double frac, CCharShape *shape); + void InterpolateKeyframe(std::size_t idx, double frac, CCharShape *shape); // test and editing void ResetFrame2(TKeyframe *frame); @@ -59,23 +59,23 @@ public: void Reset(); void Update(float timestep); void UpdateTest(float timestep, CCharShape *shape); - bool Load(const string& dir, const string& filename); - void CalcKeyframe(size_t idx, CCharShape *shape, const TVector3d& refpos); + bool Load(const std::string& dir, const std::string& filename); + void CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos); // test and editing - TKeyframe *GetFrame(size_t idx); - static const string& GetHighlightName(size_t idx); - static const string& GetJointName(size_t idx); + TKeyframe *GetFrame(std::size_t idx); + static const std::string& GetHighlightName(std::size_t idx); + static const std::string& GetJointName(std::size_t idx); static int GetNumJoints(); - void SaveTest(const string& dir, const string& filename) const; - void CopyFrame(size_t prim_idx, size_t sec_idx); + void SaveTest(const std::string& dir, const std::string& filename) const; + void CopyFrame(std::size_t prim_idx, std::size_t sec_idx); void AddFrame(); - size_t DeleteFrame(size_t idx); - void InsertFrame(size_t idx); - void CopyToClipboard(size_t idx); - void PasteFromClipboard(size_t idx); - void ClearFrame(size_t idx); - size_t numFrames() const { return frames.size(); } + std::size_t DeleteFrame(std::size_t idx); + void InsertFrame(std::size_t idx); + void CopyToClipboard(std::size_t idx); + void PasteFromClipboard(std::size_t idx); + void ClearFrame(std::size_t idx); + std::size_t numFrames() const { return frames.size(); } }; extern CKeyframe TestFrame; diff --git a/src/main.cpp b/src/main.cpp index 0c80391..d21db36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,8 +62,8 @@ void InitGame(int argc, char **argv) { } int main(int argc, char **argv) { - cout << "\n----------- Extreme Tux Racer " ETR_VERSION_STRING " ----------------"; - cout << "\n----------- (C) 2010-2016 Extreme Tuxracer Team --------\n\n"; + std::cout << "\n----------- Extreme Tux Racer " ETR_VERSION_STRING " ----------------"; + std::cout << "\n----------- (C) 2010-2016 Extreme Tuxracer Team --------\n\n"; srand(time(nullptr)); InitConfig(); diff --git a/src/mathlib.cpp b/src/mathlib.cpp index 67b7301..94ba65d 100644 --- a/src/mathlib.cpp +++ b/src/mathlib.cpp @@ -355,7 +355,7 @@ void backsb(double *matrix, int n, double *soln) { // *************************************************************************** // *************************************************************************** -bool IntersectPolygon(const TPolygon& p, vector& v) { +bool IntersectPolygon(const TPolygon& p, std::vector& v) { TRay ray; double d, s, nuDotProd; double distsq; @@ -372,7 +372,7 @@ bool IntersectPolygon(const TPolygon& p, vector& v) { if (fabs(d) > 1) return false; - for (size_t i=0; i < p.vertices.size(); i++) { + for (std::size_t i=0; i < p.vertices.size(); i++) { TVector3d *v0, *v1; v0 = &v[p.vertices[i]]; @@ -398,7 +398,7 @@ bool IntersectPolygon(const TPolygon& p, vector& v) { s = - (d + DotProduct(nml, ray.pt)) / nuDotProd; TVector3d pt = ray.pt + s * ray.vec; - for (size_t i = 0; i < p.vertices.size(); i++) { + for (std::size_t i = 0; i < p.vertices.size(); i++) { TVector3d edge_nml = CrossProduct(nml, v[p.vertices[(i + 1) % p.vertices.size()]] - v[p.vertices[i]]); @@ -410,7 +410,7 @@ bool IntersectPolygon(const TPolygon& p, vector& v) { bool IntersectPolyhedron(TPolyhedron& p) { bool hit = false; - for (size_t i = 0; i < p.polygons.size(); i++) { + for (std::size_t i = 0; i < p.polygons.size(); i++) { hit = IntersectPolygon(p.polygons[i], p.vertices); if (hit == true) break; } @@ -428,7 +428,7 @@ TVector3d MakeNormal(const TPolygon& p, const TVector3d *v) { void TransPolyhedron(const TMatrix<4, 4>& mat, TPolyhedron& ph) { - for (size_t i = 0; i < ph.vertices.size(); i++) + for (std::size_t i = 0; i < ph.vertices.size(); i++) ph.vertices[i] = TransformPoint(mat, ph.vertices[i]); } diff --git a/src/mathlib.h b/src/mathlib.h index 6733bd5..53e11ec 100644 --- a/src/mathlib.h +++ b/src/mathlib.h @@ -36,13 +36,13 @@ struct TPlane { {} }; -struct TPolygon { vector vertices; }; +struct TPolygon { std::vector vertices; }; struct TSphere { double radius; int divisions; }; struct TRay { TVector3d pt; TVector3d vec; }; struct TPolyhedron { - vector vertices; - vector polygons; + std::vector vertices; + std::vector polygons; }; TVector3d ProjectToPlane(const TVector3d& nml, const TVector3d& v); @@ -62,7 +62,7 @@ TQuaternion MakeRotationQuaternion(const TVector3d& s, const TVector3d& t); TQuaternion InterpolateQuaternions(const TQuaternion& q, TQuaternion r, double t); TVector3d RotateVector(const TQuaternion& q, const TVector3d& v); -bool IntersectPolygon(const TPolygon& p, vector& v); +bool IntersectPolygon(const TPolygon& p, std::vector& v); bool IntersectPolyhedron(TPolyhedron& p); TVector3d MakeNormal(const TPolygon& p, const TVector3d *v); void TransPolyhedron(const TMatrix<4, 4>& mat, TPolyhedron& ph); diff --git a/src/ogl.cpp b/src/ogl.cpp index 8387da2..d89e47b 100644 --- a/src/ogl.cpp +++ b/src/ogl.cpp @@ -70,15 +70,15 @@ void PrintGLInfo() { Message("Gl vendor: ", (char*)glGetString(GL_VENDOR)); Message("Gl renderer: ", (char*)glGetString(GL_RENDERER)); Message("Gl version: ", (char*)glGetString(GL_VERSION)); - string extensions = (char*)glGetString(GL_EXTENSIONS); + std::string extensions = (char*)glGetString(GL_EXTENSIONS); Message(""); Message("Gl extensions:"); Message(""); - size_t oldpos = 0; - size_t pos; - while ((pos = extensions.find(' ', oldpos)) != string::npos) { - string s = extensions.substr(oldpos, pos-oldpos); + std::size_t oldpos = 0; + std::size_t pos; + while ((pos = extensions.find(' ', oldpos)) != std::string::npos) { + std::string s = extensions.substr(oldpos, pos-oldpos); Message(s); oldpos = pos+1; } @@ -90,21 +90,21 @@ void PrintGLInfo() { case GL_INT: { GLint int_val; glGetIntegerv(gl_values[i].value, &int_val); - string ss = Int_StrN(int_val); + std::string ss = Int_StrN(int_val); Message(gl_values[i].name, ss); break; } case GL_FLOAT: { GLfloat float_val; glGetFloatv(gl_values[i].value, &float_val); - string ss = Float_StrN(float_val, 2); + std::string ss = Float_StrN(float_val, 2); Message(gl_values[i].name, ss); break; } case GL_UNSIGNED_BYTE: { GLboolean boolean_val; glGetBooleanv(gl_values[i].value, &boolean_val); - string ss = Int_StrN(boolean_val); + std::string ss = Int_StrN(boolean_val); Message(gl_values[i].name, ss); break; } @@ -389,7 +389,7 @@ void set_gl_options(TRenderMode mode) { } } -static stack modestack; +static std::stack modestack; void PushRenderMode(TRenderMode mode) { if (currentMode != mode) set_gl_options(mode); diff --git a/src/particles.cpp b/src/particles.cpp index 3f57564..98178bb 100644 --- a/src/particles.cpp +++ b/src/particles.cpp @@ -61,7 +61,7 @@ struct TGuiParticle { void Update(float time_step, float push_timestep, const TVector2d& push_vector); }; -static list particles_2d; +static std::list particles_2d; static TVector2d push_position(0, 0); static TVector2d last_push_position; static bool push_position_initialized = false; @@ -150,7 +150,7 @@ void update_ui_snow(float time_step) { } last_push_position = push_position; - for (list::iterator p = particles_2d.begin(); p != particles_2d.end(); ++p) { + for (std::list::iterator p = particles_2d.begin(); p != particles_2d.end(); ++p) { p->Update(time_step, push_timestep, push_vector); } @@ -158,7 +158,7 @@ void update_ui_snow(float time_step) { particles_2d.emplace_back(static_cast(FRandom()), -0.05f); } - for (list::iterator p = particles_2d.begin(); p != particles_2d.end();) { + for (std::list::iterator p = particles_2d.begin(); p != particles_2d.end();) { if (p->sprite.getPosition().y / static_cast(Winsys.resolution.height) > 1.05) { if (particles_2d.size() > BASE_snowparticles * Winsys.resolution.width && FRandom() > 0.2) { p = particles_2d.erase(p); @@ -184,7 +184,7 @@ void update_ui_snow(float time_step) { } } void draw_ui_snow() { - for (list::const_iterator i = particles_2d.begin(); i != particles_2d.end(); ++i) { + for (std::list::const_iterator i = particles_2d.begin(); i != particles_2d.end(); ++i) { i->Draw(); } } @@ -235,7 +235,7 @@ private: void draw_billboard(const CControl *ctrl, double width, double height, bool use_world_y_axis, const GLfloat* tex) const; }; -static list particles; +static std::list particles; void Particle::Draw(const CControl* ctrl) const { static const GLfloat tex_coords[4][8] = { @@ -338,7 +338,7 @@ void create_new_particles(const TVector3d& loc, const TVector3d& vel, int num) { } } void update_particles(float time_step) { - for (list::iterator p = particles.begin(); p != particles.end();) { + for (std::list::iterator p = particles.begin(); p != particles.end();) { p->age += time_step; if (p->age < 0) { ++p; @@ -368,7 +368,7 @@ void draw_particles(const CControl *ctrl) { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glColor4f(1.f, 1.f, 1.f, 0.8f); - for (list::const_iterator p = particles.begin(); p != particles.end(); ++p) { + for (std::list::const_iterator p = particles.begin(); p != particles.end(); ++p) { if (p->age >= 0) p->Draw(ctrl); } @@ -471,7 +471,7 @@ void TFlake::Draw(const TPlane& lp, const TPlane& rp, bool rotate_flake, float d TFlakeArea::TFlakeArea( - size_t num_flakes, + std::size_t num_flakes, float _xrange, float _ytop, float _yrange, @@ -510,7 +510,7 @@ void TFlakeArea::Draw(const CControl *ctrl) const { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - for (size_t i=0; i < flakes.size(); i++) { + for (std::size_t i=0; i < flakes.size(); i++) { flakes[i].Draw(lp, rp, rotate_flake, dir_angle); } glDisableClientState(GL_VERTEX_ARRAY); @@ -518,7 +518,7 @@ void TFlakeArea::Draw(const CControl *ctrl) const { } void TFlakeArea::Update(float timestep, float xcoeff, float ycoeff, float zcoeff) { - for (size_t i=0; icpos; - for (size_t ar=0; arcpos.x - areas[ar].xrange / 2; areas[ar].right = areas[ar].left + areas[ar].xrange; areas[ar].back = ctrl->cpos.z - areas[ar].zback; @@ -665,14 +665,14 @@ void CFlakes::Update(float timestep, const CControl *ctrl) { float ycoeff = (ydiff * YDRIFT) + (winddrift.z * timestep); float zcoeff = (zdiff * ZDRIFT) + (winddrift.z * timestep); - for (size_t ar=0; arcpos; } void CFlakes::Draw(const CControl *ctrl) const { - for (size_t ar=0; ar flakes; + std::vector flakes; float left; float right; @@ -75,7 +75,7 @@ struct TFlakeArea { bool rotate_flake; TFlakeArea( - size_t num_flakes, + std::size_t num_flakes, float xrange, float ytop, float yrange, @@ -92,8 +92,8 @@ struct TFlakeArea { class CFlakes { private: TVector3d snow_lastpos; - vector areas; - void MakeSnowFlake(size_t ar, size_t i); + std::vector areas; + void MakeSnowFlake(std::size_t ar, std::size_t i); void GenerateSnowFlakes(const CControl *ctrl); void UpdateAreas(const CControl *ctrl); public: @@ -155,7 +155,7 @@ private: class CCurtain { private: - vector curtains; + std::vector curtains; void SetStartParams(const CControl *ctrl); public: diff --git a/src/physics.cpp b/src/physics.cpp index ef87c0e..85473b0 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -118,7 +118,7 @@ bool CControl::CheckTreeCollisions(const TVector3d& pos, TVector3d *tree_loc) { bool hit = false; TMatrix<4, 4> mat; - for (size_t i = 0; i surfweights; + static std::vector surfweights; if (surfweights.size() != Course.TerrList.size()) surfweights.resize(Course.TerrList.size()); Course.GetSurfaceType(ff.pos.x, ff.pos.z, &surfweights[0]); ff.frict_coeff = ff.comp_depth = 0; - for (size_t i=0; i maxerror) maxerror = Error[i+2]; } - size_t *terrain_count = new size_t[numTerr]; + std::size_t *terrain_count = new std::size_t[numTerr]; memset(terrain_count, 0, sizeof(*terrain_count)*numTerr); for (int i=cd.xorg; i<=cd.xorg+whole; i++) { @@ -343,9 +343,9 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) { } } - size_t max_count = 0; - size_t total = 0; - for (size_t t=0; t max_count) { max_count = terrain_count[t]; } @@ -746,8 +746,8 @@ void quadsquare::InitArrayCounters() { void quadsquare::Render(const quadcornerdata& cd, GLubyte *vnc_array) { VNCArray = vnc_array; - size_t numTerrains = Course.TerrList.size(); - for (size_t j=0; j 0) { Course.TerrList[j].texture->Bind(); diff --git a/src/race_select.cpp b/src/race_select.cpp index 53deda2..1c76a18 100644 --- a/src/race_select.cpp +++ b/src/race_select.cpp @@ -46,7 +46,7 @@ static TIconButton* wind; static TIconButton* mirror; static TIconButton* random_btn; static TWidget* textbuttons[2]; -static string info; +static std::string info; static int prevGroup = 0; static void UpdateInfo() { @@ -196,7 +196,7 @@ void CRaceSelect::Loop(float timestep) { if (courseGroup->GetValue() != prevGroup) { prevGroup = courseGroup->GetValue(); - Course.currentCourseList = Course.getGroup((size_t)courseGroup->GetValue()); + Course.currentCourseList = Course.getGroup((std::size_t)courseGroup->GetValue()); g_game.course = nullptr; course->SetValue(0); course->SetMaximum((int)Course.currentCourseList->size()-1); @@ -214,7 +214,7 @@ void CRaceSelect::Loop(float timestep) { FT.AutoSizeN(2); FT.SetColor(colWhite); int dist = FT.AutoDistanceN(0); - for (size_t i = 0; i<(*Course.currentCourseList)[course->GetValue()].num_lines; i++) { + for (std::size_t i = 0; i<(*Course.currentCourseList)[course->GetValue()].num_lines; i++) { FT.DrawString(boxleft + 8, prevtop + i*dist, (*Course.currentCourseList)[course->GetValue()].desc[i]); } @@ -225,7 +225,7 @@ void CRaceSelect::Loop(float timestep) { if (g_game.force_treemap) { FT.AutoSizeN(4); static const sf::String forcetrees = "Load trees.png"; - string sizevar = "Size: "; + std::string sizevar = "Size: "; sizevar += Int_StrN(g_game.treesize); sizevar += " Variation: "; sizevar += Int_StrN(g_game.treevar); diff --git a/src/reset.cpp b/src/reset.cpp index 627ad79..c16942d 100644 --- a/src/reset.cpp +++ b/src/reset.cpp @@ -70,7 +70,7 @@ void CReset::Loop(float time_step) { if (elapsed_time > BLINK_IN_PLACE_TIME && !position_reset) { // Determine optimal location for reset int best_loc = -1; - for (size_t i = 0; i < Course.NocollArr.size(); i++) { + for (std::size_t i = 0; i < Course.NocollArr.size(); i++) { if (Course.NocollArr[i].type.reset_point && Course.NocollArr[i].pt.z > ctrl->cpos.z) { if (best_loc == -1 || Course.NocollArr[i].pt.z < Course.NocollArr[best_loc].pt.z) { best_loc = (int)i; diff --git a/src/score.cpp b/src/score.cpp index 64281bd..9e666a6 100644 --- a/src/score.cpp +++ b/src/score.cpp @@ -69,7 +69,7 @@ void CScore::PrintScorelist(const std::string& group, const std::string& course) PrintStr("no entries in this score list"); } else { for (int i=0; inumScores; i++) { - string line = "player: " + list->scores[i].player; + std::string line = "player: " + list->scores[i].player; line += " points: " + Int_StrN(list->scores[i].points); line += " herrings: " + Int_StrN(list->scores[i].herrings); line += " time: " + Float_StrN(list->scores[i].time, 2); @@ -97,7 +97,7 @@ bool CScore::SaveHighScore() const { if (num > 0) { for (int sc = 0; scscores[sc]; - string line = "*[group] " + i->first; + std::string line = "*[group] " + i->first; line += " [course] " + j->first; line += " [plyr] " + score.player; line += " [pts] " + Int_StrN(score.points); @@ -125,8 +125,8 @@ bool CScore::LoadHighScore() { } for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { - string group = SPStrN(*line, "group", "default"); - string course = SPStrN(*line, "course", "unknown"); + std::string group = SPStrN(*line, "group", "default"); + std::string course = SPStrN(*line, "course", "unknown"); try { AddScore(group, course, TScore( SPStrN(*line, "plyr", "unknown"), @@ -243,7 +243,7 @@ void CScore::Enter() { courseName = AddFramedText(area.left, frametop - 2 + frameheight + 20, framewidth, frameheight, 3, colMBackgr, "", FT.GetSize(), true); } -const string ordinals[10] = +const std::string ordinals[10] = {"1:st", "2:nd", "3:rd", "4:th", "5:th", "6:th", "7:th", "8:th", "9:th", "10:th"}; void CScore::Loop(float timestep) { @@ -259,7 +259,7 @@ void CScore::Loop(float timestep) { if (courseGroup->GetValue() != prevGroup) { prevGroup = courseGroup->GetValue(); - CourseList = Course.getGroup((size_t)courseGroup->GetValue()); + CourseList = Course.getGroup((std::size_t)courseGroup->GetValue()); course->SetValue(0); course->SetMaximum((int)CourseList->size() - 1); courseGroupName->SetString(CourseList->name); diff --git a/src/score.h b/src/score.h index edd2493..c55c961 100644 --- a/src/score.h +++ b/src/score.h @@ -25,12 +25,12 @@ GNU General Public License for more details. #define MAX_SCORES 8 struct TScore { - string player; + std::string player; int points; int herrings; float time; - TScore(const string& player_ = emptyString, int points_ = 0, int herrings_ = 0, double time_ = 0) + TScore(const std::string& player_ = emptyString, int points_ = 0, int herrings_ = 0, double time_ = 0) : player(player_), points(points_), herrings(herrings_), time(time_) {} }; diff --git a/src/spx.cpp b/src/spx.cpp index 676a987..8de14e4 100644 --- a/src/spx.cpp +++ b/src/spx.cpp @@ -25,47 +25,47 @@ GNU General Public License for more details. #include #include -const string emptyString = ""; -const string errorString = "error"; +const std::string emptyString = ""; +const std::string errorString = "error"; // -------------------------------------------------------------------- // elementary string functions // -------------------------------------------------------------------- -string MakePathStr(const string& src, const string& add) { - string res = src; +std::string MakePathStr(const std::string& src, const std::string& add) { + std::string res = src; res += SEP; res += add; return res; } -void SInsertN(string &s, size_t pos, const string& ins) { +void SInsertN(std::string &s, std::size_t pos, const std::string& ins) { if (pos > s.size()) pos = s.size(); s.insert(pos, ins); } -void SDeleteN(string &s, size_t pos, size_t count) { +void SDeleteN(std::string &s, std::size_t pos, std::size_t count) { if (pos > s.size()) pos = s.size(); s.erase(pos, count); } -size_t SPosN(const string &s, const string& find) { +std::size_t SPosN(const std::string &s, const std::string& find) { return s.find(find); } -void STrimLeftN(string &s) { - size_t i = s.find_first_not_of(" \t"); +void STrimLeftN(std::string &s) { + std::size_t i = s.find_first_not_of(" \t"); if (i > 0) SDeleteN(s, 0, i); } -void STrimRightN(string &s) { - size_t i = s.find_last_not_of(" \t"); +void STrimRightN(std::string &s) { + std::size_t i = s.find_last_not_of(" \t"); if (i != s.size()-1) s.erase(i+1); } -void STrimN(string &s) { +void STrimN(std::string &s) { STrimLeftN(s); STrimRightN(s); } @@ -74,43 +74,43 @@ void STrimN(string &s) { // conversion functions // -------------------------------------------------------------------- -string Int_StrN(const int val) { +std::string Int_StrN(const int val) { return std::to_string(val); } -string Int_StrN(const int val, const streamsize count) { - ostringstream os; - os << setw(count) << setfill('0') << val; +std::string Int_StrN(const int val, const std::streamsize count) { + std::ostringstream os; + os << std::setw(count) << std::setfill('0') << val; return os.str(); } -string Float_StrN(const float val, const streamsize count) { - ostringstream os; - os << setprecision(count) << fixed << val; +std::string Float_StrN(const float val, const std::streamsize count) { + std::ostringstream os; + os << std::setprecision(count) << std::fixed << val; return os.str(); } -string Vector_StrN(const TVector3d& v, const streamsize count) { - string res = Float_StrN(v.x, count); +std::string Vector_StrN(const TVector3d& v, const std::streamsize count) { + std::string res = Float_StrN(v.x, count); res += ' ' + Float_StrN(v.y, count); res += ' ' + Float_StrN(v.z, count); return res; } -string Bool_StrN(const bool val) { +std::string Bool_StrN(const bool val) { if (val == true) return "true"; else return "false"; } -int Str_IntN(const string &s, const int def) { +int Str_IntN(const std::string &s, const int def) { int val; - istringstream is(s); + std::istringstream is(s); is >> val; if (is.fail()) return def; else return val; } -bool Str_BoolN(const string &s, const bool def) { +bool Str_BoolN(const std::string &s, const bool def) { if (s == "0" || s == "false") return false; if (s == "1" || s == "true") @@ -118,84 +118,84 @@ bool Str_BoolN(const string &s, const bool def) { return Str_IntN(s, (int)def) != 0; // Try to parse as int } -float Str_FloatN(const string &s, const float def) { +float Str_FloatN(const std::string &s, const float def) { float val; - istringstream is(s); + std::istringstream is(s); is >> val; if (is.fail()) return def; else return val; } template -TVector2 Str_Vector2(const string &s, const TVector2 &def) { +TVector2 Str_Vector2(const std::string &s, const TVector2 &def) { T x, y; - istringstream is(s); + std::istringstream is(s); is >> x >> y; if (is.fail()) return def; else return TVector2(x, y); } -template TVector2 Str_Vector2(const string &s, const TVector2 &def); -template TVector2 Str_Vector2(const string &s, const TVector2 &def); +template TVector2 Str_Vector2(const std::string &s, const TVector2 &def); +template TVector2 Str_Vector2(const std::string &s, const TVector2 &def); template -TVector3 Str_Vector3(const string &s, const TVector3 &def) { +TVector3 Str_Vector3(const std::string &s, const TVector3 &def) { T x, y, z; - istringstream is(s); + std::istringstream is(s); is >> x >> y >> z; if (is.fail()) return def; else return TVector3(x, y, z); } -template TVector3 Str_Vector3(const string &s, const TVector3 &def); -template TVector3 Str_Vector3(const string &s, const TVector3 &def); +template TVector3 Str_Vector3(const std::string &s, const TVector3 &def); +template TVector3 Str_Vector3(const std::string &s, const TVector3 &def); template -TVector4 Str_Vector4(const string &s, const TVector4 &def) { +TVector4 Str_Vector4(const std::string &s, const TVector4 &def) { T x, y, z, w; - istringstream is(s); + std::istringstream is(s); is >> x >> y >> z >> w; if (is.fail()) return def; else return TVector4(x, y, z, w); } -template TVector4 Str_Vector4(const string &s, const TVector4 &def); -template TVector4 Str_Vector4(const string &s, const TVector4 &def); +template TVector4 Str_Vector4(const std::string &s, const TVector4 &def); +template TVector4 Str_Vector4(const std::string &s, const TVector4 &def); -sf::Color Str_ColorN(const string &s, const sf::Color &def) { +sf::Color Str_ColorN(const std::string &s, const sf::Color &def) { float r, g, b, a; - istringstream is(s); + std::istringstream is(s); is >> r >> g >> b >> a; if (is.fail()) return def; else return sf::Color(r * 255, g * 255, b * 255, a * 255); } -TColor3 Str_Color3N(const string &s, const TColor3 &def) { +TColor3 Str_Color3N(const std::string &s, const TColor3 &def) { int r, g, b; - istringstream is(s); + std::istringstream is(s); is >> r >> g >> b; if (is.fail()) return def; else return TColor3(r, g, b); } -void Str_ArrN(const string &s, float *arr, size_t count, float def) { - istringstream is(s); - for (size_t i = 0; i < count; i++) +void Str_ArrN(const std::string &s, float *arr, std::size_t count, float def) { + std::istringstream is(s); + for (std::size_t i = 0; i < count; i++) is >> arr[i]; if (is.fail()) - for (size_t i=0; i -TVector2 SPVector2(const string &s, const string &tag, const TVector2& def) { +TVector2 SPVector2(const std::string &s, const std::string &tag, const TVector2& def) { return (Str_Vector2(SPItemN(s, tag), def)); } -template TVector2 SPVector2(const string &s, const string &tag, const TVector2& def); -template TVector2 SPVector2(const string &s, const string &tag, const TVector2& def); +template TVector2 SPVector2(const std::string &s, const std::string &tag, const TVector2& def); +template TVector2 SPVector2(const std::string &s, const std::string &tag, const TVector2& def); template -TVector3 SPVector3(const string &s, const string &tag, const TVector3& def) { +TVector3 SPVector3(const std::string &s, const std::string &tag, const TVector3& def) { return (Str_Vector3(SPItemN(s, tag), def)); } -template TVector3 SPVector3(const string &s, const string &tag, const TVector3& def); -template TVector3 SPVector3(const string &s, const string &tag, const TVector3& def); +template TVector3 SPVector3(const std::string &s, const std::string &tag, const TVector3& def); +template TVector3 SPVector3(const std::string &s, const std::string &tag, const TVector3& def); template -TVector4 SPVector4(const string &s, const string &tag, const TVector4& def) { +TVector4 SPVector4(const std::string &s, const std::string &tag, const TVector4& def) { return (Str_Vector4(SPItemN(s, tag), def)); } -template TVector4 SPVector4(const string &s, const string &tag, const TVector4& def); -template TVector4 SPVector4(const string &s, const string &tag, const TVector4& def); +template TVector4 SPVector4(const std::string &s, const std::string &tag, const TVector4& def); +template TVector4 SPVector4(const std::string &s, const std::string &tag, const TVector4& def); -sf::Color SPColorN(const string &s, const string &tag, const sf::Color& def) { +sf::Color SPColorN(const std::string &s, const std::string &tag, const sf::Color& def) { return (Str_ColorN(SPItemN(s, tag), def)); } -TColor3 SPColor3N(const string &s, const string &tag, const TColor3& def) { +TColor3 SPColor3N(const std::string &s, const std::string &tag, const TColor3& def) { return (Str_Color3N(SPItemN(s, tag), def)); } -void SPArrN(const string &s, const string &tag, float *arr, size_t count, float def) { +void SPArrN(const std::string &s, const std::string &tag, float *arr, std::size_t count, float def) { Str_ArrN(SPItemN(s, tag), arr, count, def); } -size_t SPPosN(const string &s, const string &tag) { - string tg = '[' + tag + ']'; +std::size_t SPPosN(const std::string &s, const std::string &tag) { + std::string tg = '[' + tag + ']'; return SPosN(s, tg); } // ------------------ add --------------------------------------------- -void SPAddIntN(string &s, const string &tag, const int val) { +void SPAddIntN(std::string &s, const std::string &tag, const int val) { s += '['; s += tag; s += ']'; s += Int_StrN(val); } -void SPAddFloatN(string &s, const string &tag, const float val, size_t count) { +void SPAddFloatN(std::string &s, const std::string &tag, const float val, std::size_t count) { s += '['; s += tag; s += ']'; s += Float_StrN(val, count); } -void SPAddStrN(string &s, const string &tag, const string &val) { +void SPAddStrN(std::string &s, const std::string &tag, const std::string &val) { s += '['; s += tag; s += ']'; s += val; } -void SPAddVec2N(string &s, const string &tag, const TVector2d &val, size_t count) { +void SPAddVec2N(std::string &s, const std::string &tag, const TVector2d &val, std::size_t count) { s += '['; s += tag; s += ']'; @@ -302,7 +302,7 @@ void SPAddVec2N(string &s, const string &tag, const TVector2d &val, size_t count s += Float_StrN(val.y, count); } -void SPAddVec3N(string &s, const string &tag, const TVector3d &val, size_t count) { +void SPAddVec3N(std::string &s, const std::string &tag, const TVector3d &val, std::size_t count) { s += '['; s += tag; s += ']'; @@ -314,7 +314,7 @@ void SPAddVec3N(string &s, const string &tag, const TVector3d &val, size_t count s += Float_StrN(val.z, count); } -void SPAddBoolN(string &s, const string &tag, const bool val) { +void SPAddBoolN(std::string &s, const std::string &tag, const bool val) { s += '['; s += tag; s += ']'; @@ -324,32 +324,32 @@ void SPAddBoolN(string &s, const string &tag, const bool val) { // -------------------------------------------------------------------- -void SPSetIntN(string &s, const string &tag, const int val) { - size_t pos = SPPosN(s, tag); - if (pos != string::npos) { - size_t ipos = pos + tag.size() + 2; - string item = SPItemN(s, tag); - if (item.size() != string::npos) SDeleteN(s, ipos, item.size()); +void SPSetIntN(std::string &s, const std::string &tag, const int val) { + std::size_t pos = SPPosN(s, tag); + if (pos != std::string::npos) { + std::size_t ipos = pos + tag.size() + 2; + std::string item = SPItemN(s, tag); + if (item.size() != std::string::npos) SDeleteN(s, ipos, item.size()); SInsertN(s, ipos, Int_StrN(val)); } else SPAddIntN(s, tag, val); } -void SPSetFloatN(string &s, const string &tag, const float val, size_t count) { - size_t pos = SPPosN(s, tag); - if (pos != string::npos) { - size_t ipos = pos + tag.size() + 2; - string item = SPItemN(s, tag); - if (item.size() != string::npos) SDeleteN(s, ipos, item.size()); +void SPSetFloatN(std::string &s, const std::string &tag, const float val, std::size_t count) { + std::size_t pos = SPPosN(s, tag); + if (pos != std::string::npos) { + std::size_t ipos = pos + tag.size() + 2; + std::string item = SPItemN(s, tag); + if (item.size() != std::string::npos) SDeleteN(s, ipos, item.size()); SInsertN(s, ipos, Float_StrN(val, count)); } else SPAddFloatN(s, tag, val, count); } -void SPSetStrN(string &s, const string &tag, const string &val) { - size_t pos = SPPosN(s, tag); - if (pos != string::npos) { - size_t ipos = pos + tag.size() + 2; - string item = SPItemN(s, tag); - if (item.size() != string::npos) SDeleteN(s, ipos, item.size()); +void SPSetStrN(std::string &s, const std::string &tag, const std::string &val) { + std::size_t pos = SPPosN(s, tag); + if (pos != std::string::npos) { + std::size_t ipos = pos + tag.size() + 2; + std::string item = SPItemN(s, tag); + if (item.size() != std::string::npos) SDeleteN(s, ipos, item.size()); SInsertN(s, ipos, val); } else SPAddStrN(s, tag, val); } @@ -363,20 +363,20 @@ CSPList::CSPList(bool newlineflag) { fnewlineflag = newlineflag; } -void CSPList::Add(const string& line) { +void CSPList::Add(const std::string& line) { push_back(line); } -void CSPList::Add(string&& line) { +void CSPList::Add(std::string&& line) { push_back(line); } void CSPList::Print() const { for (const_iterator line = cbegin(); line != cend(); ++line) - cout << *line << endl; + std::cout << *line << std::endl; } -bool CSPList::Load(const string &filepath) { +bool CSPList::Load(const std::string &filepath) { std::ifstream tempfile(filepath.c_str()); if (!tempfile) { @@ -384,12 +384,12 @@ bool CSPList::Load(const string &filepath) { return false; } else { bool backflag = false; - string line; + std::string line; while (getline(tempfile, line)) { // delete new line char if in string - size_t npos = line.rfind('\n'); - if (npos != string::npos) SDeleteN(line, npos, 1); + std::size_t npos = line.rfind('\n'); + if (npos != std::string::npos) SDeleteN(line, npos, 1); bool valid = true; if (line.empty()) valid = false; // empty line @@ -420,11 +420,11 @@ bool CSPList::Load(const string &filepath) { } } -bool CSPList::Load(const string& dir, const string& filename) { +bool CSPList::Load(const std::string& dir, const std::string& filename) { return Load(dir + SEP + filename); } -bool CSPList::Save(const string &filepath) const { +bool CSPList::Save(const std::string &filepath) const { std::ofstream tempfile(filepath.c_str()); if (!tempfile) { Message("CSPList::Save - unable to open " + filepath); @@ -437,16 +437,16 @@ bool CSPList::Save(const string &filepath) const { } } -bool CSPList::Save(const string& dir, const string& filename) const { +bool CSPList::Save(const std::string& dir, const std::string& filename) const { return Save(dir + SEP + filename); } -void CSPList::MakeIndex(map& index, const string &tag) { +void CSPList::MakeIndex(std::map& index, const std::string &tag) { index.clear(); - size_t idx = 0; + std::size_t idx = 0; for (const_iterator line = cbegin(); line != cend(); ++line) { - string item = SPItemN(*line, tag); + std::string item = SPItemN(*line, tag); STrimN(item); if (!item.empty()) { index[item] = idx; diff --git a/src/spx.h b/src/spx.h index 11b9ca9..229ccb8 100644 --- a/src/spx.h +++ b/src/spx.h @@ -22,93 +22,93 @@ GNU General Public License for more details. #include #include -extern const string emptyString; -extern const string errorString; +extern const std::string emptyString; +extern const std::string errorString; // ----- elementary string functions ---------------------------------- -string MakePathStr(const string& src, const string& add); -void SInsertN(string &s, size_t pos, const string& ins); -void SDeleteN(string &s, size_t pos, size_t count); -size_t SPosN(const string &s, const string& find); -void STrimLeftN(string &s); -void STrimRightN(string &s); -void STrimN(string &s); +std::string MakePathStr(const std::string& src, const std::string& add); +void SInsertN(std::string &s, std::size_t pos, const std::string& ins); +void SDeleteN(std::string &s, std::size_t pos, std::size_t count); +std::size_t SPosN(const std::string &s, const std::string& find); +void STrimLeftN(std::string &s); +void STrimRightN(std::string &s); +void STrimN(std::string &s); // ----- conversion functions ----------------------------------------- -string Int_StrN(const int val); -string Int_StrN(const int val, const streamsize count); -string Float_StrN(const float val, const streamsize count); -string Bool_StrN(const bool val); -string Vector_StrN(const TVector3d& v, const streamsize count); -int Str_IntN(const string &s, const int def); -bool Str_BoolN(const string &s, const bool def); -float Str_FloatN(const string &s, const float def); +std::string Int_StrN(const int val); +std::string Int_StrN(const int val, const std::streamsize count); +std::string Float_StrN(const float val, const std::streamsize count); +std::string Bool_StrN(const bool val); +std::string Vector_StrN(const TVector3d& v, const std::streamsize count); +int Str_IntN(const std::string &s, const int def); +bool Str_BoolN(const std::string &s, const bool def); +float Str_FloatN(const std::string &s, const float def); template -TVector2 Str_Vector2(const string &s, const TVector2& def); +TVector2 Str_Vector2(const std::string &s, const TVector2& def); template -TVector3 Str_Vector3(const string &s, const TVector3& def); +TVector3 Str_Vector3(const std::string &s, const TVector3& def); template -TVector4 Str_Vector4(const string &s, const TVector4& def); -sf::Color Str_ColorN(const string &s, const sf::Color& def); -TColor3 Str_Color3N(const string &s, const TColor3& def); -void Str_ArrN(const string &s, float *arr, size_t count, float def); +TVector4 Str_Vector4(const std::string &s, const TVector4& def); +sf::Color Str_ColorN(const std::string &s, const sf::Color& def); +TColor3 Str_Color3N(const std::string &s, const TColor3& def); +void Str_ArrN(const std::string &s, float *arr, std::size_t count, float def); // ----- SP functions for parsing lines -------------------------------- -size_t SPPosN(const string &s, const string &tag); +std::size_t SPPosN(const std::string &s, const std::string &tag); -string SPStrN(const string &s, const string &tag, const string& def = emptyString); -string SPStrN(const string &s, const char* tag, const char* def); -int SPIntN(const string &s, const string &tag, const int def); -bool SPBoolN(const string &s, const string &tag, const bool def); -float SPFloatN(const string &s, const string &tag, const float def); +std::string SPStrN(const std::string &s, const std::string &tag, const std::string& def = emptyString); +std::string SPStrN(const std::string &s, const char* tag, const char* def); +int SPIntN(const std::string &s, const std::string &tag, const int def); +bool SPBoolN(const std::string &s, const std::string &tag, const bool def); +float SPFloatN(const std::string &s, const std::string &tag, const float def); template -TVector2 SPVector2(const string &s, const string &tag, const TVector2& def); -static inline TVector2d SPVector2d(const string &s, const string &tag) { return SPVector2(s, tag, NullVec2); } -static inline TVector2i SPVector2i(const string &s, const string &tag) { return SPVector2(s, tag, NullVec2i); } +TVector2 SPVector2(const std::string &s, const std::string &tag, const TVector2& def); +static inline TVector2d SPVector2d(const std::string &s, const std::string &tag) { return SPVector2(s, tag, NullVec2); } +static inline TVector2i SPVector2i(const std::string &s, const std::string &tag) { return SPVector2(s, tag, NullVec2i); } template -TVector3 SPVector3(const string &s, const string &tag, const TVector3& def); -static inline TVector3d SPVector3d(const string &s, const string &tag) { return SPVector3(s, tag, NullVec3); } -static inline TVector3i SPVector3i(const string &s, const string &tag) { return SPVector3(s, tag, NullVec3i); } +TVector3 SPVector3(const std::string &s, const std::string &tag, const TVector3& def); +static inline TVector3d SPVector3d(const std::string &s, const std::string &tag) { return SPVector3(s, tag, NullVec3); } +static inline TVector3i SPVector3i(const std::string &s, const std::string &tag) { return SPVector3(s, tag, NullVec3i); } template -TVector4 SPVector4(const string &s, const string &tag, const TVector4& def); -static inline TVector4d SPVector4d(const string &s, const string &tag) { return SPVector4(s, tag, NullVec4); } -static inline TVector4i SPVector4i(const string &s, const string &tag) { return SPVector4(s, tag, NullVec4i); } -sf::Color SPColorN(const string &s, const string &tag, const sf::Color& def); -TColor3 SPColor3N(const string &s, const string &tag, const TColor3& def); -void SPArrN(const string &s, const string &tag, float *arr, size_t count, float def); +TVector4 SPVector4(const std::string &s, const std::string &tag, const TVector4& def); +static inline TVector4d SPVector4d(const std::string &s, const std::string &tag) { return SPVector4(s, tag, NullVec4); } +static inline TVector4i SPVector4i(const std::string &s, const std::string &tag) { return SPVector4(s, tag, NullVec4i); } +sf::Color SPColorN(const std::string &s, const std::string &tag, const sf::Color& def); +TColor3 SPColor3N(const std::string &s, const std::string &tag, const TColor3& def); +void SPArrN(const std::string &s, const std::string &tag, float *arr, std::size_t count, float def); // ----- making SP strings -------------------------------------------- -void SPAddIntN(string &s, const string &tag, const int val); -void SPAddFloatN(string &s, const string &tag, const float val, size_t count); -void SPAddStrN(string &s, const string &tag, const string &val); -void SPAddVec2N(string &s, const string &tag, const TVector2d& val, size_t count); -void SPAddVec3N(string &s, const string &tag, const TVector3d& val, size_t count); -void SPAddBoolN(string &s, const string &tag, const bool val); +void SPAddIntN(std::string &s, const std::string &tag, const int val); +void SPAddFloatN(std::string &s, const std::string &tag, const float val, std::size_t count); +void SPAddStrN(std::string &s, const std::string &tag, const std::string &val); +void SPAddVec2N(std::string &s, const std::string &tag, const TVector2d& val, std::size_t count); +void SPAddVec3N(std::string &s, const std::string &tag, const TVector3d& val, std::size_t count); +void SPAddBoolN(std::string &s, const std::string &tag, const bool val); // ----- manipulating SP strings -------------------------------------- -void SPSetIntN(string &s, const string &tag, const int val); -void SPSetFloatN(string &s, const string &tag, const float val, size_t count); -void SPSetStrN(string &s, const string &tag, const string &val); +void SPSetIntN(std::string &s, const std::string &tag, const int val); +void SPSetFloatN(std::string &s, const std::string &tag, const float val, std::size_t count); +void SPSetStrN(std::string &s, const std::string &tag, const std::string &val); // -------------------------------------------------------------------- // string list // -------------------------------------------------------------------- -class CSPList : public std::list { +class CSPList : public std::list { private: bool fnewlineflag; public: CSPList(bool newlineflag = false); - void Add(const string& line = emptyString); - void Add(string&& line); + void Add(const std::string& line = emptyString); + void Add(std::string&& line); void Print() const; - bool Load(const string &filepath); - bool Load(const string& dir, const string& filename); - bool Save(const string &filepath) const; - bool Save(const string& dir, const string& filename) const; + bool Load(const std::string &filepath); + bool Load(const std::string& dir, const std::string& filename); + bool Save(const std::string &filepath) const; + bool Save(const std::string& dir, const std::string& filename) const; - void MakeIndex(map& index, const string &tag); + void MakeIndex(std::map& index, const std::string &tag); }; #endif diff --git a/src/textures.cpp b/src/textures.cpp index f86a888..114615b 100644 --- a/src/textures.cpp +++ b/src/textures.cpp @@ -39,13 +39,13 @@ static const GLshort fullsize_texture[] = { // class TTexture // -------------------------------------------------------------------- -bool TTexture::Load(const string& filename, bool repeatable) { +bool TTexture::Load(const std::string& filename, bool repeatable) { texture.setSmooth(true); texture.setRepeated(repeatable); return texture.loadFromFile(filename); } -bool TTexture::Load(const string& dir, const string& filename, bool repeatable) { +bool TTexture::Load(const std::string& dir, const std::string& filename, bool repeatable) { return Load(dir + SEP + filename, repeatable); } @@ -182,8 +182,8 @@ bool CTexture::LoadTextureList() { if (list.Load(param.tex_dir, "textures.lst")) { for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { int id = SPIntN(*line, "id", -1); - CommonTex.resize(max(CommonTex.size(), (size_t)id+1)); - string texfile = SPStrN(*line, "file"); + CommonTex.resize(max(CommonTex.size(), (std::size_t)id+1)); + std::string texfile = SPStrN(*line, "file"); bool rep = SPBoolN(*line, "repeat", false); if (id >= 0) { CommonTex[id] = new TTexture(); @@ -198,22 +198,22 @@ bool CTexture::LoadTextureList() { } void CTexture::FreeTextureList() { - for (size_t i=0; i= CommonTex.size()) return nullptr; return CommonTex[idx]; } -const sf::Texture& CTexture::GetSFTexture(size_t idx) const { +const sf::Texture& CTexture::GetSFTexture(std::size_t idx) const { return CommonTex[idx]->texture; } -bool CTexture::BindTex(size_t idx) { +bool CTexture::BindTex(std::size_t idx) { if (idx >= CommonTex.size()) return false; CommonTex[idx]->Bind(); return true; @@ -221,22 +221,22 @@ bool CTexture::BindTex(size_t idx) { // ---------------------------- Draw ---------------------------------- -void CTexture::Draw(size_t idx) { +void CTexture::Draw(std::size_t idx) { if (CommonTex.size() > idx) CommonTex[idx]->Draw(); } -void CTexture::Draw(size_t idx, int x, int y, float size) { +void CTexture::Draw(std::size_t idx, int x, int y, float size) { if (CommonTex.size() > idx) CommonTex[idx]->Draw(x, y, size); } -void CTexture::Draw(size_t idx, int x, int y, int width, int height) { +void CTexture::Draw(std::size_t idx, int x, int y, int width, int height) { if (CommonTex.size() > idx) CommonTex[idx]->Draw(x, y, width, height); } -void CTexture::DrawFrame(size_t idx, int x, int y, double w, double h, int frame, const sf::Color& col) { +void CTexture::DrawFrame(std::size_t idx, int x, int y, double w, double h, int frame, const sf::Color& col) { if (CommonTex.size() > idx) CommonTex[idx]->DrawFrame(x, y, w, h, frame, col); } @@ -278,7 +278,7 @@ void CTexture::DrawNumChr(char c, int x, int y, int w, int h) { glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } -void CTexture::DrawNumStr(const string& s, int x, int y, float size, const sf::Color& col) { +void CTexture::DrawNumStr(const std::string& s, int x, int y, float size, const sf::Color& col) { if (!BindTex(NUMERIC_FONT)) { Message("DrawNumStr: missing texture"); return; @@ -291,7 +291,7 @@ void CTexture::DrawNumStr(const string& s, int x, int y, float size, const sf::C glColor(col); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - for (size_t i=0; i < s.size(); i++) { + for (std::size_t i=0; i < s.size(); i++) { DrawNumChr(s[i], x + (int)i*qw, y, qw, qh); } glDisableClientState(GL_TEXTURE_COORD_ARRAY); diff --git a/src/textures.h b/src/textures.h index 07e2087..cc579f0 100644 --- a/src/textures.h +++ b/src/textures.h @@ -65,9 +65,9 @@ class TTexture { sf::Texture texture; friend class CTexture; public: - bool Load(const string& filename, bool repeatable = false); - bool Load(const string& dir, const string& filename, bool repeatable = false); - bool Load(const string& dir, const char* filename, bool repeatable = false) { return Load(dir, string(filename), repeatable); } + bool Load(const std::string& filename, bool repeatable = false); + bool Load(const std::string& dir, const std::string& filename, bool repeatable = false); + bool Load(const std::string& dir, const char* filename, bool repeatable = false) { return Load(dir, std::string(filename), repeatable); } void Bind(); void Draw(); @@ -78,7 +78,7 @@ public: class CTexture { private: - vector CommonTex; + std::vector CommonTex; void DrawNumChr(char c, int x, int y, int w, int h); public: @@ -87,17 +87,17 @@ public: bool LoadTextureList(); void FreeTextureList(); - TTexture* GetTexture(size_t idx) const; - const sf::Texture& GetSFTexture(size_t idx) const; - bool BindTex(size_t idx); + TTexture* GetTexture(std::size_t idx) const; + const sf::Texture& GetSFTexture(std::size_t idx) const; + bool BindTex(std::size_t idx); - void Draw(size_t idx); - void Draw(size_t idx, int x, int y, float size); - void Draw(size_t idx, int x, int y, int width, int height); + void Draw(std::size_t idx); + void Draw(std::size_t idx, int x, int y, float size); + void Draw(std::size_t idx, int x, int y, int width, int height); - void DrawFrame(size_t idx, int x, int y, double w, double h, int frame, const sf::Color& col); + void DrawFrame(std::size_t idx, int x, int y, double w, double h, int frame, const sf::Color& col); - void DrawNumStr(const string& s, int x, int y, float size, const sf::Color& col); + void DrawNumStr(const std::string& s, int x, int y, float size, const sf::Color& col); }; extern CTexture Tex; diff --git a/src/tool_char.cpp b/src/tool_char.cpp index 4d9f2d6..af6f3d7 100644 --- a/src/tool_char.cpp +++ b/src/tool_char.cpp @@ -28,12 +28,12 @@ GNU General Public License for more details. #include "tux.h" #include "winsys.h" -static size_t firstnode = 0; -static size_t lastnode; -static size_t curr_node = 0; -static size_t firstact = 0; -static size_t lastact; -static size_t curr_act = 0; +static std::size_t firstnode = 0; +static std::size_t lastnode; +static std::size_t curr_node = 0; +static std::size_t firstact = 0; +static std::size_t lastact; +static std::size_t curr_act = 0; static float xposition = 0; static float yposition = 0; @@ -68,14 +68,14 @@ void InitCharTools() { } void StoreAction(TCharAction *act) { - for (size_t i=0; i<=act->num; i++) { + for (std::size_t i=0; i<=act->num; i++) { Undo.vec[i] = act->vec[i]; Undo.dval[i] = act->dval[i]; } } void RecallAction(TCharAction *act) { - for (size_t i=0; i<=act->num; i++) { + for (std::size_t i=0; i<=act->num; i++) { act->vec[i] = Undo.vec[i]; act->dval[i] = Undo.dval[i]; } @@ -286,7 +286,7 @@ void CharMotion(int x, int y) { } } -void DrawActionVec(size_t nr, const string& s, int y, const TVector3d& v) { +void DrawActionVec(std::size_t nr, const std::string& s, int y, const TVector3d& v) { FT.SetColor(colLGrey); FT.DrawString(20, y, s); if (nr == curr_act) { @@ -313,7 +313,7 @@ void DrawActionVec(size_t nr, const string& s, int y, const TVector3d& v) { } } -void DrawActionFloat(size_t nr, const string& s, int y, float f) { +void DrawActionFloat(std::size_t nr, const std::string& s, int y, float f) { FT.SetColor(colLGrey); FT.DrawString(20, y, s); if (nr == curr_act) FT.SetColor(colYellow); @@ -355,7 +355,7 @@ void RenderChar(float timestep) { if (CharHasChanged()) DrawChanged(); FT.SetSize(16); - for (size_t i=0; i<=lastnode; i++) { + for (std::size_t i=0; i<=lastnode; i++) { if (i != curr_node) { FT.SetColor(colLGrey); FT.SetFont("normal"); @@ -368,8 +368,8 @@ void RenderChar(float timestep) { FT.DrawString(xl, yt, TestChar.GetNodeJoint(i)); } - size_t num = action->num; - for (size_t i=0; inum; + for (std::size_t i=0; itype[i]; int yt = Winsys.resolution.height - 120 + (int)i * 18; diff --git a/src/tool_frame.cpp b/src/tool_frame.cpp index 66d3f2e..c394fdf 100644 --- a/src/tool_frame.cpp +++ b/src/tool_frame.cpp @@ -29,7 +29,7 @@ GNU General Public License for more details. #include "tux.h" #include "winsys.h" -static size_t curr_frame = 0; +static std::size_t curr_frame = 0; static int curr_joint = 0; static int last_joint = 0; static TVector3d ref_position(0, 0, 0); @@ -232,7 +232,7 @@ void RenderSingleFrame(float timestep) { ScopedRenderMode rm1(TUX); ClearRenderContext(colDDBackgr); - const string& hlname = TestFrame.GetHighlightName(curr_joint); + const std::string& hlname = TestFrame.GetHighlightName(curr_joint); TestChar.highlight_node = TestChar.GetNodeName(hlname); glPushMatrix(); @@ -253,7 +253,7 @@ void RenderSingleFrame(float timestep) { FT.DrawString(-1, 10, "Keyframe mode"); FT.SetProps("normal", 16); - for (size_t i=0; i quads; - list::iterator current_mark; + std::list quads; + std::list::iterator current_mark; }; static track_marks_t track_marks; @@ -106,7 +106,7 @@ void DrawTrackmarks() { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - for (list::const_iterator q = track_marks.quads.begin(); q != track_marks.quads.end(); ++q) { + for (std::list::const_iterator q = track_marks.quads.begin(); q != track_marks.quads.end(); ++q) { if (q->alpha != track_colour.a) { track_colour.a = q->alpha; set_material_diffuse(track_colour); @@ -152,7 +152,7 @@ void DrawTrackmarks() { glTexCoord2(q->t3); glVertex3(q->v3); - list::const_iterator qnext = q; + std::list::const_iterator qnext = q; ++qnext; while (qnext != track_marks.quads.end() && qnext->track_type != TRACK_TAIL) { q = qnext; @@ -180,14 +180,14 @@ void break_track_marks() { if (!continuing_track) return; - list::iterator q = track_marks.current_mark; + std::list::iterator q = track_marks.current_mark; if (q != track_marks.quads.end()) { q->track_type = TRACK_TAIL; q->t1 = TVector2d(0.0, 0.0); q->t2 = TVector2d(1.0, 0.0); q->t3 = TVector2d(0.0, 1.0); q->t4 = TVector2d(1.0, 1.0); - list::iterator qprev = decrementRingIterator(q); + std::list::iterator qprev = decrementRingIterator(q); if (qprev != track_marks.quads.end()) { qprev->t3.y = max(qprev->t3.y+0.5, qprev->t1.y+1.0); qprev->t4.y = max(qprev->t3.y+0.5, qprev->t1.y+1.0); @@ -246,12 +246,12 @@ void add_track_mark(const CControl *ctrl, int *id) { if (track_marks.quads.size() < MAX_TRACK_MARKS) track_marks.quads.emplace_back(); - list::iterator qprev = track_marks.current_mark; + std::list::iterator qprev = track_marks.current_mark; if (track_marks.current_mark == track_marks.quads.end()) track_marks.current_mark = track_marks.quads.begin(); else track_marks.current_mark = incrementRingIterator(track_marks.current_mark); - list::iterator q = track_marks.current_mark; + std::list::iterator q = track_marks.current_mark; if (!continuing_track) { q->track_type = TRACK_HEAD; diff --git a/src/translation.cpp b/src/translation.cpp index 3f7b5b9..3f1b842 100644 --- a/src/translation.cpp +++ b/src/translation.cpp @@ -146,18 +146,18 @@ void CTranslation::SetDefaultTranslations() { texts[98] = "sec"; } -const sf::String& CTranslation::Text(size_t idx) const { +const sf::String& CTranslation::Text(std::size_t idx) const { static const sf::String empty; if (idx >= NUM_COMMON_TEXTS) return empty; return texts[idx]; } -static wstring UnicodeStr(const std::string& s) { - size_t len = s.length(); - wstring res; +static std::wstring UnicodeStr(const std::string& s) { + std::size_t len = s.length(); + std::wstring res; res.resize(len); - for (size_t i = 0, j = 0; i < len; ++i, ++j) { + for (std::size_t i = 0, j = 0; i < len; ++i, ++j) { wchar_t ch = (unsigned char)s[i]; if (ch >= 0xF0) { ch = (wchar_t)(s[i] & 0x07) << 18; @@ -188,28 +188,28 @@ void CTranslation::LoadLanguages() { languages.resize(list.size()+1); languages[0].lang = "en_GB"; languages[0].language = "English"; - size_t i = 1; + std::size_t i = 1; for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) { languages[i].lang = SPStrN(*line, "lang", "en_GB"); languages[i].language = UnicodeStr(SPStrN(*line, "language", "English")); } - if (param.language == string::npos) + if (param.language == std::string::npos) param.language = GetSystemDefaultLangIdx(); } -const sf::String& CTranslation::GetLanguage(size_t idx) const { +const sf::String& CTranslation::GetLanguage(std::size_t idx) const { static const sf::String error = "error"; if (idx >= languages.size()) return error; return languages[idx].language; } -void CTranslation::LoadTranslations(size_t langidx) { +void CTranslation::LoadTranslations(std::size_t langidx) { SetDefaultTranslations(); if (langidx == 0 || langidx >= languages.size()) return; CSPList list; - string filename = languages[langidx].lang + ".lst"; + std::string filename = languages[langidx].lang + ".lst"; if (!list.Load(param.trans_dir, filename)) { Message("could not load translations list:", filename); return; @@ -223,7 +223,7 @@ void CTranslation::LoadTranslations(size_t langidx) { } } -void CTranslation::ChangeLanguage(size_t langidx) { +void CTranslation::ChangeLanguage(std::size_t langidx) { LoadTranslations(langidx); // The course description and name translations are stored in the course files. @@ -231,14 +231,14 @@ void CTranslation::ChangeLanguage(size_t langidx) { Course.LoadCourseList(); } -string CTranslation::GetSystemDefaultLang() { +std::string CTranslation::GetSystemDefaultLang() { #ifdef _WIN32 wchar_t buf[10] = {0}; GetUserDefaultLocaleName(buf, 10); char buf2[10] = {0}; WideCharToMultiByte(CP_ACP, 0, buf, -1, buf2, 10, nullptr, nullptr); - string ret = buf2; - while (ret.find('-') != string::npos) + std::string ret = buf2; + while (ret.find('-') != std::string::npos) ret[ret.find('-')] = '_'; return ret; #else @@ -246,13 +246,13 @@ string CTranslation::GetSystemDefaultLang() { #endif } -size_t CTranslation::GetSystemDefaultLangIdx() const { +std::size_t CTranslation::GetSystemDefaultLangIdx() const { std::string name = GetSystemDefaultLang(); return GetLangIdx(name); } -size_t CTranslation::GetLangIdx(const string& lang) const { - for (size_t i = 0; i < languages.size(); i++) +std::size_t CTranslation::GetLangIdx(const std::string& lang) const { + for (std::size_t i = 0; i < languages.size(); i++) if (languages[i].lang == lang) return i; return 0; diff --git a/src/translation.h b/src/translation.h index 6e94e9b..adc7542 100644 --- a/src/translation.h +++ b/src/translation.h @@ -31,7 +31,7 @@ Name convention: ---------------------------------------------------------------------*/ struct TLang { - string lang; + std::string lang; sf::String language; }; @@ -39,17 +39,17 @@ class CTranslation { private: sf::String texts[NUM_COMMON_TEXTS]; public: - vector languages; + std::vector languages; void LoadLanguages(); - const sf::String& GetLanguage(size_t idx) const; + const sf::String& GetLanguage(std::size_t idx) const; void SetDefaultTranslations(); - const sf::String& Text(size_t idx) const; - void LoadTranslations(size_t langidx); - void ChangeLanguage(size_t langidx); - static string GetSystemDefaultLang(); - size_t GetSystemDefaultLangIdx() const; - size_t GetLangIdx(const string& lang) const; + const sf::String& Text(std::size_t idx) const; + void LoadTranslations(std::size_t langidx); + void ChangeLanguage(std::size_t langidx); + static std::string GetSystemDefaultLang(); + std::size_t GetSystemDefaultLangIdx() const; + std::size_t GetLangIdx(const std::string& lang) const; }; extern CTranslation Trans; diff --git a/src/tux.cpp b/src/tux.cpp index 0be51fe..ae84bd6 100644 --- a/src/tux.cpp +++ b/src/tux.cpp @@ -80,13 +80,13 @@ CCharShape::~CCharShape() { // nodes // -------------------------------------------------------------------- -size_t CCharShape::GetNodeIdx(size_t node_name) const { +std::size_t CCharShape::GetNodeIdx(std::size_t node_name) const { if (node_name >= MAX_CHAR_NODES) return -1; return Index[node_name]; } -TCharNode *CCharShape::GetNode(size_t node_name) { - size_t idx = GetNodeIdx(node_name); +TCharNode *CCharShape::GetNode(std::size_t node_name) { + std::size_t idx = GetNodeIdx(node_name); if (idx >= numNodes) return nullptr; return Nodes[idx]; } @@ -115,7 +115,7 @@ void CCharShape::CreateRootNode() { numNodes = 1; } -bool CCharShape::CreateCharNode(int parent_name, size_t node_name, const string& joint, const string& name, const string& order, bool shadow) { +bool CCharShape::CreateCharNode(int parent_name, std::size_t node_name, const std::string& joint, const std::string& name, const std::string& order, bool shadow) { TCharNode *parent = GetNode(parent_name); if (parent == nullptr) { Message("wrong parent node"); @@ -167,8 +167,8 @@ bool CCharShape::CreateCharNode(int parent_name, size_t node_name, const string& return true; } -void CCharShape::AddAction(size_t node_name, int type, const TVector3d& vec, double val) { - size_t idx = GetNodeIdx(node_name); +void CCharShape::AddAction(std::size_t node_name, int type, const TVector3d& vec, double val) { + std::size_t idx = GetNodeIdx(node_name); TCharAction *act = Nodes[idx]->action; act->type[act->num] = type; act->vec[act->num] = vec; @@ -176,7 +176,7 @@ void CCharShape::AddAction(size_t node_name, int type, const TVector3d& vec, dou act->num++; } -bool CCharShape::TranslateNode(size_t node_name, const TVector3d& vec) { +bool CCharShape::TranslateNode(std::size_t node_name, const TVector3d& vec) { TCharNode *node = GetNode(node_name); if (node == nullptr) return false; @@ -191,7 +191,7 @@ bool CCharShape::TranslateNode(size_t node_name, const TVector3d& vec) { return true; } -bool CCharShape::RotateNode(size_t node_name, int axis, double angle) { +bool CCharShape::RotateNode(std::size_t node_name, int axis, double angle) { TCharNode *node = GetNode(node_name); if (node == nullptr) return false; @@ -220,13 +220,13 @@ bool CCharShape::RotateNode(size_t node_name, int axis, double angle) { return true; } -bool CCharShape::RotateNode(const string& node_trivialname, int axis, double angle) { - map::const_iterator i = NodeIndex.find(node_trivialname); +bool CCharShape::RotateNode(const std::string& node_trivialname, int axis, double angle) { + std::map::const_iterator i = NodeIndex.find(node_trivialname); if (i == NodeIndex.end()) return false; return RotateNode(i->second, axis, angle); } -void CCharShape::ScaleNode(size_t node_name, const TVector3d& vec) { +void CCharShape::ScaleNode(std::size_t node_name, const TVector3d& vec) { TCharNode *node = GetNode(node_name); if (node == nullptr) return; @@ -240,7 +240,7 @@ void CCharShape::ScaleNode(size_t node_name, const TVector3d& vec) { if (newActions && useActions) AddAction(node_name, 4, vec, 0); } -bool CCharShape::VisibleNode(size_t node_name, float level) { +bool CCharShape::VisibleNode(std::size_t node_name, float level) { TCharNode *node = GetNode(node_name); if (node == nullptr) return false; @@ -255,7 +255,7 @@ bool CCharShape::VisibleNode(size_t node_name, float level) { return true; } -bool CCharShape::MaterialNode(size_t node_name, const string& mat_name) { +bool CCharShape::MaterialNode(std::size_t node_name, const std::string& mat_name) { TCharNode *node = GetNode(node_name); if (node == nullptr) return false; TCharMaterial *mat = GetMaterial(mat_name); @@ -265,7 +265,7 @@ bool CCharShape::MaterialNode(size_t node_name, const string& mat_name) { return true; } -bool CCharShape::ResetNode(size_t node_name) { +bool CCharShape::ResetNode(std::size_t node_name) { TCharNode *node = GetNode(node_name); if (node == nullptr) return false; @@ -274,13 +274,13 @@ bool CCharShape::ResetNode(size_t node_name) { return true; } -bool CCharShape::ResetNode(const string& node_trivialname) { - map::const_iterator i = NodeIndex.find(node_trivialname); +bool CCharShape::ResetNode(const std::string& node_trivialname) { + std::map::const_iterator i = NodeIndex.find(node_trivialname); if (i == NodeIndex.end()) return false; return ResetNode(i->second); } -bool CCharShape::TransformNode(size_t node_name, const TMatrix<4, 4>& mat, const TMatrix<4, 4>& invmat) { +bool CCharShape::TransformNode(std::size_t node_name, const TMatrix<4, 4>& mat, const TMatrix<4, 4>& invmat) { TCharNode *node = GetNode(node_name); if (node == nullptr) return false; @@ -329,15 +329,15 @@ void CCharShape::Reset() { // materials // -------------------------------------------------------------------- -TCharMaterial* CCharShape::GetMaterial(const string& mat_name) { - map::const_iterator i = MaterialIndex.find(mat_name); +TCharMaterial* CCharShape::GetMaterial(const std::string& mat_name) { + std::map::const_iterator i = MaterialIndex.find(mat_name); if (i != MaterialIndex.end() && i->second < Materials.size()) { return &Materials[i->second]; } return nullptr; } -void CCharShape::CreateMaterial(const string& line) { +void CCharShape::CreateMaterial(const std::string& line) { TVector3d diff = SPVector3d(line, "diff"); TVector3d spec = SPVector3d(line, "spec"); float exp = SPFloatN(line, "exp", 50); @@ -419,7 +419,7 @@ void CCharShape::Draw() { // -------------------------------------------------------------------- -bool CCharShape::Load(const string& dir, const string& filename, bool with_actions) { +bool CCharShape::Load(const std::string& dir, const std::string& filename, bool with_actions) { CSPList list; useActions = with_actions; @@ -434,20 +434,20 @@ bool CCharShape::Load(const string& dir, const string& filename, bool with_actio for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { int node_name = SPIntN(*line, "node", -1); int parent_name = SPIntN(*line, "par", -1); - string mat_name = SPStrN(*line, "mat"); - string name = SPStrN(*line, "joint"); - string fullname = SPStrN(*line, "name"); + std::string mat_name = SPStrN(*line, "mat"); + std::string name = SPStrN(*line, "joint"); + std::string fullname = SPStrN(*line, "name"); if (SPIntN(*line, "material", 0) > 0) { CreateMaterial(*line); } else { float visible = SPFloatN(*line, "vis", -1.f); bool shadow = SPBoolN(*line, "shad", false); - string order = SPStrN(*line, "order"); + std::string order = SPStrN(*line, "order"); CreateCharNode(parent_name, node_name, name, fullname, order, shadow); TVector3d rot = SPVector3d(*line, "rot"); MaterialNode(node_name, mat_name); - for (size_t ii = 0; ii < order.size(); ii++) { + for (std::size_t ii = 0; ii < order.size(); ii++) { int act = order[ii]-48; switch (act) { case 0: { @@ -760,7 +760,7 @@ void CCharShape::DrawShadow() { // testing and tools // -------------------------------------------------------------------- -string CCharShape::GetNodeJoint(size_t idx) const { +std::string CCharShape::GetNodeJoint(std::size_t idx) const { if (idx >= numNodes) return ""; TCharNode *node = Nodes[idx]; if (node == nullptr) return ""; @@ -768,17 +768,17 @@ string CCharShape::GetNodeJoint(size_t idx) const { else return Int_StrN((int)node->node_name); } -size_t CCharShape::GetNodeName(size_t idx) const { +std::size_t CCharShape::GetNodeName(std::size_t idx) const { if (idx >= numNodes) return -1; return Nodes[idx]->node_name; } -size_t CCharShape::GetNodeName(const string& node_trivialname) const { +std::size_t CCharShape::GetNodeName(const std::string& node_trivialname) const { return NodeIndex.at(node_trivialname); } -void CCharShape::RefreshNode(size_t idx) { +void CCharShape::RefreshNode(std::size_t idx) { if (idx >= numNodes) return; TMatrix<4, 4> TempMatrix; char caxis; @@ -792,7 +792,7 @@ void CCharShape::RefreshNode(size_t idx) { node->trans.SetIdentity(); node->invtrans.SetIdentity(); - for (size_t i=0; inum; i++) { + for (std::size_t i=0; inum; i++) { int type = act->type[i]; const TVector3d& vec = act->vec[i]; double dval = act->dval[i]; @@ -843,33 +843,33 @@ void CCharShape::RefreshNode(size_t idx) { } } -const string& CCharShape::GetNodeFullname(size_t idx) const { +const std::string& CCharShape::GetNodeFullname(std::size_t idx) const { if (idx >= numNodes) return emptyString; return Nodes[idx]->action->name; } -size_t CCharShape::GetNumActs(size_t idx) const { +std::size_t CCharShape::GetNumActs(std::size_t idx) const { if (idx >= numNodes) return -1; return Nodes[idx]->action->num; } -TCharAction *CCharShape::GetAction(size_t idx) const { +TCharAction *CCharShape::GetAction(std::size_t idx) const { if (idx >= numNodes) return nullptr; return Nodes[idx]->action; } -void CCharShape::PrintAction(size_t idx) const { +void CCharShape::PrintAction(std::size_t idx) const { if (idx >= numNodes) return; TCharAction *act = Nodes[idx]->action; PrintInt((int)act->num); - for (size_t i=0; inum; i++) { + for (std::size_t i=0; inum; i++) { PrintInt(act->type[i]); PrintDouble(act->dval[i]); PrintVector(act->vec[i]); } } -void CCharShape::PrintNode(size_t idx) const { +void CCharShape::PrintNode(std::size_t idx) const { TCharNode *node = Nodes[idx]; PrintInt("node: ", (int)node->node_name); PrintInt("parent: ", (int)node->parent_name); @@ -877,32 +877,32 @@ void CCharShape::PrintNode(size_t idx) const { PrintInt("next: ", (int)node->next_name); } -void CCharShape::SaveCharNodes(const string& dir, const string& filename) { +void CCharShape::SaveCharNodes(const std::string& dir, const std::string& filename) { CSPList list; list.Add("# Generated by Tuxracer tools"); list.Add(); if (!Materials.empty()) { list.Add("# Materials:"); - for (size_t i=0; iaction; if (node->parent_name >= node->node_name) Message("wrong parent index"); - string line = "*[node] " + Int_StrN((int)node->node_name); + std::string line = "*[node] " + Int_StrN((int)node->node_name); line += " [par] " + Int_StrN((int)node->parent_name); if (!act->order.empty()) { bool rotflag = false; TVector3d rotation; line += " [order] " + act->order; - for (size_t ii=0; iiorder.size(); ii++) { + for (std::size_t ii=0; iiorder.size(); ii++) { int aa = act->order[ii]-48; switch (aa) { case 0: @@ -942,7 +942,7 @@ void CCharShape::SaveCharNodes(const string& dir, const string& filename) { list.Add(line); if (ivisible && !Nodes[i+1]->visible) list.Add(); - const string& joint = Nodes[i+2]->joint; + const std::string& joint = Nodes[i+2]->joint; if (joint.empty()) list.Add("# " + joint); } } diff --git a/src/tux.h b/src/tux.h index 6d929e9..0f81534 100644 --- a/src/tux.h +++ b/src/tux.h @@ -33,17 +33,17 @@ struct TCharMaterial { sf::Color diffuse; sf::Color specular; float exp; - string matline; + std::string matline; }; struct TCharAction { - size_t num; + std::size_t num; int type[MAX_ACTIONS]; TVector3d vec[MAX_ACTIONS]; double dval[MAX_ACTIONS]; - string name; - string order; - string mat; + std::string name; + std::string order; + std::string mat; }; struct TCharNode { @@ -53,13 +53,13 @@ struct TCharNode { TCharAction* action; - size_t node_idx; // number in node_array - size_t node_name; // int identifier of node itself - size_t parent_name; // int identifier of parent - size_t child_name; - size_t next_name; + std::size_t node_idx; // number in node_array + std::size_t node_name; // int identifier of node itself + std::size_t parent_name; // int identifier of parent + std::size_t child_name; + std::size_t next_name; - string joint; + std::string joint; TMatrix<4, 4> trans; TMatrix<4, 4> invtrans; double radius; @@ -72,26 +72,26 @@ struct TCharNode { class CCharShape { private: TCharNode *Nodes[MAX_CHAR_NODES]; - size_t Index[MAX_CHAR_NODES]; - size_t numNodes; - vector Materials; - map MaterialIndex; + std::size_t Index[MAX_CHAR_NODES]; + std::size_t numNodes; + std::vector Materials; + std::map MaterialIndex; bool useActions; bool newActions; // nodes - size_t GetNodeIdx(size_t node_name) const; - TCharNode *GetNode(size_t node_name); + std::size_t GetNodeIdx(std::size_t node_name) const; + TCharNode *GetNode(std::size_t node_name); void CreateRootNode(); - bool CreateCharNode(int parent_name, size_t node_name, const string& joint, - const string& name, const string& order, bool shadow); - bool VisibleNode(size_t node_name, float level); - bool MaterialNode(size_t node_name, const string& mat_name); - bool TransformNode(size_t node_name, const TMatrix<4, 4>& mat, const TMatrix<4, 4>& invmat); + bool CreateCharNode(int parent_name, std::size_t node_name, const std::string& joint, + const std::string& name, const std::string& order, bool shadow); + bool VisibleNode(std::size_t node_name, float level); + bool MaterialNode(std::size_t node_name, const std::string& mat_name); + bool TransformNode(std::size_t node_name, const TMatrix<4, 4>& mat, const TMatrix<4, 4>& invmat); // material - TCharMaterial* GetMaterial(const string& mat_name); - void CreateMaterial(const string& line); + TCharMaterial* GetMaterial(const std::string& mat_name); + void CreateMaterial(const std::string& line); // drawing void DrawCharSphere(int num_divisions); @@ -109,23 +109,23 @@ private: void TraverseDagForShadow(const TCharNode *node, const TMatrix<4, 4>& mat); // testing and developing - void AddAction(size_t node_name, int type, const TVector3d& vec, double val); + void AddAction(std::size_t node_name, int type, const TVector3d& vec, double val); public: CCharShape(); ~CCharShape(); bool useMaterials; bool useHighlighting; bool highlighted; - size_t highlight_node; - map NodeIndex; + std::size_t highlight_node; + std::map NodeIndex; // nodes - bool ResetNode(size_t node_name); - bool ResetNode(const string& node_trivialname); - bool TranslateNode(size_t node_name, const TVector3d& vec); - bool RotateNode(size_t node_name, int axis, double angle); - bool RotateNode(const string& node_trivialname, int axis, double angle); - void ScaleNode(size_t node_name, const TVector3d& vec); + bool ResetNode(std::size_t node_name); + bool ResetNode(const std::string& node_trivialname); + bool TranslateNode(std::size_t node_name, const TVector3d& vec); + bool RotateNode(std::size_t node_name, int axis, double angle); + bool RotateNode(const std::string& node_trivialname, int axis, double angle); + void ScaleNode(std::size_t node_name, const TVector3d& vec); void ResetRoot() { ResetNode(0); } void ResetJoints(); @@ -133,7 +133,7 @@ public: void Reset(); void Draw(); void DrawShadow(); - bool Load(const string& dir, const string& filename, bool with_actions); + bool Load(const std::string& dir, const std::string& filename, bool with_actions); void AdjustOrientation(CControl *ctrl, double dtime, double dist_from_surface, const TVector3d& surf_nml); @@ -142,17 +142,17 @@ public: const TVector3d& net_force, double flap_factor); bool Collision(const TVector3d& pos, const TPolyhedron& ph); - size_t GetNodeName(size_t idx) const; - size_t GetNodeName(const string& node_trivialname) const; - string GetNodeJoint(size_t idx) const; - size_t GetNumNodes() const { return numNodes; } - const string& GetNodeFullname(size_t idx) const; - size_t GetNumActs(size_t idx) const; - TCharAction *GetAction(size_t idx) const; - void PrintAction(size_t idx) const; - void PrintNode(size_t idx) const; - void RefreshNode(size_t idx); - void SaveCharNodes(const string& dir, const string& filename); + std::size_t GetNodeName(std::size_t idx) const; + std::size_t GetNodeName(const std::string& node_trivialname) const; + std::string GetNodeJoint(std::size_t idx) const; + std::size_t GetNumNodes() const { return numNodes; } + const std::string& GetNodeFullname(std::size_t idx) const; + std::size_t GetNumActs(std::size_t idx) const; + TCharAction *GetAction(std::size_t idx) const; + void PrintAction(std::size_t idx) const; + void PrintNode(std::size_t idx) const; + void RefreshNode(std::size_t idx); + void SaveCharNodes(const std::string& dir, const std::string& filename); }; // only for char tools, the characters for playing are in diff --git a/src/winsys.cpp b/src/winsys.cpp index 5d46979..baa3c0d 100644 --- a/src/winsys.cpp +++ b/src/winsys.cpp @@ -56,15 +56,15 @@ CWinsys::CWinsys() resolutions[9] = TScreenRes(1680, 1050); } -const TScreenRes& CWinsys::GetResolution(size_t idx) const { +const TScreenRes& CWinsys::GetResolution(std::size_t idx) const { if (idx >= NUM_RESOLUTIONS || (idx == 0 && !param.fullscreen)) return auto_resolution; return resolutions[idx]; } -string CWinsys::GetResName(size_t idx) const { +std::string CWinsys::GetResName(std::size_t idx) const { if (idx >= NUM_RESOLUTIONS) return "800 x 600"; if (idx == 0) return ("auto"); - string line = Int_StrN(resolutions[idx].width); + std::string line = Int_StrN(resolutions[idx].width); line += " x " + Int_StrN(resolutions[idx].height); return line; } @@ -108,7 +108,7 @@ void CWinsys::SetupVideoMode(const TScreenRes& resolution_) { if (param.use_quad_scale) scale = sqrt(scale); } -void CWinsys::SetupVideoMode(size_t idx) { +void CWinsys::SetupVideoMode(std::size_t idx) { SetupVideoMode(GetResolution(idx)); } @@ -138,22 +138,22 @@ void CWinsys::Terminate() { void CWinsys::PrintJoystickInfo() const { if (numJoysticks == 0) { - cout << "No joystick found\n"; + std::cout << "No joystick found\n"; return; } - cout << '\n'; + std::cout << '\n'; for (unsigned int i = 0; i < numJoysticks; i++) { - cout << "Joystick " << i << '\n'; + std::cout << "Joystick " << i << '\n'; int buttons = sf::Joystick::getButtonCount(i); - cout << "Joystick has " << buttons << " button" << (buttons == 1 ? "" : "s") << '\n'; - cout << "Axes: "; - if (sf::Joystick::hasAxis(i, sf::Joystick::R)) cout << "R "; - if (sf::Joystick::hasAxis(i, sf::Joystick::U)) cout << "U "; - if (sf::Joystick::hasAxis(i, sf::Joystick::V)) cout << "V "; - if (sf::Joystick::hasAxis(i, sf::Joystick::X)) cout << "X "; - if (sf::Joystick::hasAxis(i, sf::Joystick::Y)) cout << "Y "; - if (sf::Joystick::hasAxis(i, sf::Joystick::Z)) cout << "Z "; - cout << '\n'; + std::cout << "Joystick has " << buttons << " button" << (buttons == 1 ? "" : "s") << '\n'; + std::cout << "Axes: "; + if (sf::Joystick::hasAxis(i, sf::Joystick::R)) std::cout << "R "; + if (sf::Joystick::hasAxis(i, sf::Joystick::U)) std::cout << "U "; + if (sf::Joystick::hasAxis(i, sf::Joystick::V)) std::cout << "V "; + if (sf::Joystick::hasAxis(i, sf::Joystick::X)) std::cout << "X "; + if (sf::Joystick::hasAxis(i, sf::Joystick::Y)) std::cout << "Y "; + if (sf::Joystick::hasAxis(i, sf::Joystick::Z)) std::cout << "Z "; + std::cout << '\n'; } } @@ -163,7 +163,7 @@ void CWinsys::TakeScreenshot() const { tex.update(window); sf::Image img = tex.copyToImage(); - string path = param.screenshot_dir; + std::string path = param.screenshot_dir; path += SEP; path += g_game.course->dir; path += '_'; diff --git a/src/winsys.h b/src/winsys.h index 779df88..2459b3c 100644 --- a/src/winsys.h +++ b/src/winsys.h @@ -48,11 +48,11 @@ public: CWinsys(); // sdl window - const TScreenRes& GetResolution(size_t idx) const; - string GetResName(size_t idx) const; + const TScreenRes& GetResolution(std::size_t idx) const; + std::string GetResName(std::size_t idx) const; void Init(); void SetupVideoMode(const TScreenRes& resolution); - void SetupVideoMode(size_t idx); + void SetupVideoMode(std::size_t idx); void SetupVideoMode(int width, int height); void KeyRepeat(bool repeat); void PrintJoystickInfo() const;