Removed "using namespace std;"

git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@598 0420edf4-82e4-42fc-9478-35b55e6d67a3
master
pkeus 2016-01-18 16:55:59 +00:00
parent 5b57a1380b
commit 85a6b4d9f9
55 changed files with 850 additions and 858 deletions

View File

@ -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];

View File

@ -30,24 +30,24 @@ struct TSound;
class CSound {
private:
vector<TSound*> sounds;
map<string, size_t> SoundIndex;
std::vector<TSound*> sounds;
std::map<std::string, std::size_t> 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<sf::Music*> musics;
map<string, size_t> MusicIndex;
std::vector<sf::Music*> musics;
std::map<std::string, std::size_t> MusicIndex;
struct Situation { sf::Music* situation[SITUATION_COUNT]; };
vector<Situation> themes;
map<string, size_t> ThemesIndex;
std::vector<Situation> themes;
std::map<std::string, std::size_t> 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();
};

View File

@ -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"

View File

@ -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<int x, int y>
void PrintMatrix(const TMatrix<x, y>& mat) {
cout << '\n';
cout.precision(3);
std::cout << '\n';
std::cout.precision(3);
for (int i=0; i<x; i++) {
for (int j=0; j<y; j++) {
if (mat[i][j]>=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);

View File

@ -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

View File

@ -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;

View File

@ -40,10 +40,10 @@ GNU General Public License for more details.
void TCourse::SetDescription(const std::string& description) {
FT.AutoSizeN(2);
vector<string> desclist = FT.MakeLineList(description.c_str(), 335.f * Winsys.scale - 16.f);
size_t cnt = min<size_t>(desclist.size(), MAX_DESCRIPTION_LINES);
std::vector<std::string> desclist = FT.MakeLineList(description.c_str(), 335.f * Winsys.scale - 16.f);
std::size_t cnt = std::min<std::size_t>(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; i<TerrList.size(); i++) {
for (std::size_t i=0; i<TerrList.size(); i++) {
delete TerrList[i].texture;
TerrList[i].texture = nullptr;
}
}
void CCourse::FreeObjectTextures() {
for (size_t i=0; i<ObjTypes.size(); i++) {
for (std::size_t i=0; i<ObjTypes.size(); i++) {
delete ObjTypes[i].texture;
ObjTypes[i].texture = nullptr;
}
@ -395,10 +395,10 @@ void CCourse::LoadItemList() {
double xx = (nx - x) / (double)((double)nx - 1.0) * curr_course->size.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; i<TerrList.size(); i++) {
for (std::size_t i=0; i<TerrList.size(); i++) {
if (abs(pixel[0]-TerrList[i].col.r) < 30
&& abs(pixel[1]-TerrList[i].col.g) < 30
&& abs(pixel[2]-TerrList[i].col.b) < 30) {
@ -595,7 +595,7 @@ bool CCourse::LoadTerrainTypes() {
}
TerrList.resize(list.size());
size_t i = 0;
std::size_t i = 0;
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) {
TerrList[i].textureFile = SPStrN(*line, "texture");
TerrList[i].sound = Sound.GetSoundIdx(SPStrN(*line, "sound"));
@ -664,27 +664,27 @@ bool CCourseList::Load(const std::string& dir) {
CSPList paramlist;
courses.resize(list.size());
size_t i = 0;
std::size_t i = 0;
for (CSPList::const_iterator line1 = list.cbegin(); line1 != list.cend(); ++line1, i++) {
courses[i].name = SPStrN(*line1, "name");
courses[i].dir = SPStrN(*line1, "dir", "nodir");
string coursepath = dir + SEP + courses[i].dir;
std::string coursepath = dir + SEP + courses[i].dir;
if (DirExists(coursepath.c_str())) {
// preview
string previewfile = coursepath + SEP "preview.png";
std::string previewfile = coursepath + SEP "preview.png";
courses[i].preview = new TTexture();
if (!courses[i].preview->Load(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<std::string, CCourseList>::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; i<CollArr.size(); i++) {
for (std::size_t i=0; i<CollArr.size(); i++) {
CollArr[i].pt.x = curr_course->size.x - CollArr[i].pt.x;
CollArr[i].pt.y = FindYCoord(CollArr[i].pt.x, CollArr[i].pt.z);
}
for (size_t i=0; i<NocollArr.size(); i++) {
for (std::size_t i=0; i<NocollArr.size(); i++) {
NocollArr[i].pt.x = curr_course->size.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<Course.TerrList.size(); i++) {
for (std::size_t i=0; i<Course.TerrList.size(); i++) {
weights[i] = 0;
if (Course.Fields[idx0.x + nx*idx0.y].terrain == i) weights[i] += u;
if (Course.Fields[idx1.x + nx*idx1.y].terrain == i) weights[i] += v;
@ -1015,7 +1015,7 @@ int CCourse::GetTerrainIdx(double x, double z, double level) const {
double u, v;
FindBarycentricCoords(x, z, &idx0, &idx1, &idx2, &u, &v);
for (size_t i=0; i<Course.TerrList.size(); i++) {
for (std::size_t i=0; i<Course.TerrList.size(); i++) {
double wheight = 0.0;
if (Course.Fields[idx0.x + nx*idx0.y].terrain == i) wheight += u;
if (Course.Fields[idx1.x + nx*idx1.y].terrain == i) wheight += v;

View File

@ -39,9 +39,9 @@ class TTexture;
struct TTerrType {
string textureFile;
std::string textureFile;
TTexture* texture;
size_t sound;
std::size_t sound;
TColor3 col;
bool particles;
@ -56,8 +56,8 @@ struct TTerrType {
};
struct TObjectType {
string name;
string textureFile;
std::string name;
std::string textureFile;
TTexture* texture;
int collectable;
bool collidable;
@ -78,8 +78,8 @@ struct TObject {
};
struct TCollidable : public TObject {
size_t tree_type;
TCollidable(double x, double y, double z, double height_, double diam_, size_t type)
std::size_t tree_type;
TCollidable(double x, double y, double z, double height_, double diam_, std::size_t type)
: TObject(x, y, z, height_, diam_), tree_type(type)
{}
};
@ -93,19 +93,19 @@ struct TItem : public TObject {
};
struct TCourse {
string name;
string dir;
string author;
string desc[MAX_DESCRIPTION_LINES];
size_t num_lines;
std::string name;
std::string dir;
std::string author;
std::string desc[MAX_DESCRIPTION_LINES];
std::size_t num_lines;
TTexture* preview;
TVector2d size;
TVector2d play_size;
double angle;
double scale;
TVector2d start;
size_t env;
size_t music_theme;
std::size_t env;
std::size_t music_theme;
double finish_brake;
bool use_keyframe;
@ -121,24 +121,24 @@ struct CourseFields {
class CCourseList {
std::vector<TCourse> courses;
map<string, size_t> index;
std::map<std::string, std::size_t> 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<string, size_t> ObjectIndex;
string CourseDir;
std::map<std::string, std::size_t> ObjectIndex;
std::string CourseDir;
unsigned int nx;
unsigned int ny;
@ -161,22 +161,22 @@ public:
CCourse();
~CCourse();
map<string, CCourseList> CourseLists;
CCourseList* currentCourseList;
vector<TTerrType> TerrList;
vector<TObjectType> ObjTypes;
vector<TCollidable> CollArr;
vector<TItem> NocollArr;
vector<TPolyhedron> PolyArr;
std::map<std::string, CCourseList> CourseLists;
CCourseList* currentCourseList;
std::vector<TTerrType> TerrList;
std::vector<TObjectType> ObjTypes;
std::vector<TCollidable> CollArr;
std::vector<TItem> NocollArr;
std::vector<TPolyhedron> PolyArr;
vector<CourseFields> Fields;
std::vector<CourseFields> 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;

View File

@ -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;

View File

@ -50,7 +50,7 @@ void CCredits::LoadCreditList() {
return;
}
forward_list<TCredits>::iterator last = CreditList.before_begin();
std::forward_list<TCredits>::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<TCredits>::const_iterator i = CreditList.begin(); i != CreditList.end(); ++i) {
for (std::forward_list<TCredits>::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;

View File

@ -22,7 +22,7 @@ GNU General Public License for more details.
#include <forward_list>
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<TCredits> CreditList;
std::forward_list<TCredits> CreditList;
void DrawCreditsText(float time_step);
void Enter();

View File

@ -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);
}

View File

@ -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<TEnvironment> locs;
string lightcond[4];
std::vector<TEnvironment> locs;
std::string lightcond[4];
TLight default_light;
TLight lights[4];
TFog fog;
TFog default_fog;
map<string, size_t> EnvIndex;
map<string, size_t> LightIndex;
std::map<std::string, std::size_t> EnvIndex;
std::map<std::string, std::size_t> 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;

View File

@ -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

View File

@ -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; i<ecup->races.size(); i++) {
for (std::size_t i=0; i<ecup->races.size(); i++) {
FT.AutoSizeN(4);
int y = frametop + 10 + (int)i * dist;

View File

@ -33,9 +33,9 @@ GNU General Public License for more details.
// CFont::MakeLineList. This bundle of functions generates
// a vector<string> from a textstring and adapts the lines to the textbox
static void MakeWordList(vector<string>& wordlist, const char *s) {
size_t start = 0;
for (size_t i = 0; s[i] != '\0'; i++) {
static void MakeWordList(std::vector<std::string>& 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<string>& wordlist, const char *s) {
wordlist.emplace_back(s + start);
}
static size_t MakeLine(size_t first, const vector<string>& wordlist, vector<string>& linelist, float width) {
static std::size_t MakeLine(std::size_t first, const std::vector<std::string>& wordlist, std::vector<std::string>& 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<string>& wordlist, vector<stri
last++;
}
string line;
for (size_t j=first; j<last; j++) {
std::string line;
for (std::size_t j=first; j<last; j++) {
line += wordlist[j];
if (j < last)
line += ' ';
@ -98,7 +98,7 @@ CFont::~CFont() {
}
void CFont::Clear() {
for (size_t i = 0; i < fonts.size(); i++)
for (std::size_t i = 0; i < fonts.size(); i++)
delete fonts[i];
fonts.clear();
fontindex.clear();
@ -108,7 +108,7 @@ void CFont::Clear() {
// public
// --------------------------------------------------------------------
int CFont::LoadFont(const string& name, const string& path) {
int CFont::LoadFont(const std::string& name, const std::string& path) {
fonts.push_back(new sf::Font());
if (!fonts.back()->loadFromFile(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<string> CFont::MakeLineList(const char *source, float width) {
vector<string> wordlist;
std::vector<std::string> CFont::MakeLineList(const char *source, float width) {
std::vector<std::string> wordlist;
MakeWordList(wordlist, source);
vector<string> linelist;
std::vector<std::string> 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;

View File

@ -30,34 +30,34 @@ GNU General Public License for more details.
class CFont {
private:
vector<sf::Font*> fonts;
map<string, size_t> fontindex;
std::vector<sf::Font*> fonts;
std::map<std::string, std::size_t> 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<string> MakeLineList(const char *source, float width);
std::vector<std::string> MakeLineList(const char *source, float width);
};
extern CFont FT;

View File

@ -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<typename T>
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);
}

View File

@ -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;

View File

@ -66,7 +66,7 @@ bool CEvents::LoadEventList() {
int num = SPIntN(*line, "num", 0);
CupList.back().races.resize(num);
for (int ii=0; ii<num; ii++) {
string race = SPStrN(*line, Int_StrN(ii+1));
std::string race = SPStrN(*line, Int_StrN(ii+1));
CupList.back().races[ii] = &RaceList[GetRaceIdx(race)];
}
}
@ -81,7 +81,7 @@ bool CEvents::LoadEventList() {
int num = SPIntN(*line, "num", 0);
EventList.back().cups.resize(num);
for (int ii=0; ii<num; ii++) {
string cup = SPStrN(*line, Int_StrN(ii+1));
std::string cup = SPStrN(*line, Int_StrN(ii+1));
EventList.back().cups[ii] = &CupList[GetCupIdx(cup)];
}
}
@ -91,40 +91,40 @@ bool CEvents::LoadEventList() {
return true;
}
size_t CEvents::GetRaceIdx(const string& race) const {
std::size_t CEvents::GetRaceIdx(const std::string& race) const {
return RaceIndex.at(race);
}
size_t CEvents::GetCupIdx(const string& cup) const {
std::size_t CEvents::GetCupIdx(const std::string& cup) const {
return CupIndex.at(cup);
}
size_t CEvents::GetEventIdx(const string& event) const {
std::size_t CEvents::GetEventIdx(const std::string& event) const {
return EventIndex.at(event);
}
const string& CEvents::GetCup(size_t event, size_t cup) const {
const std::string& CEvents::GetCup(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]->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; event<EventList.size(); event++) {
for (size_t cup=0; cup<EventList[event].cups.size(); cup++) {
void CEvents::MakeUnlockList(const std::string& unlockstr) {
for (std::size_t event=0; event<EventList.size(); event++) {
for (std::size_t cup=0; cup<EventList[event].cups.size(); cup++) {
EventList[event].cups[cup]->Unlocked = false;
}
}
for (size_t event=0; event<EventList.size(); event++) {
for (size_t cup=0; cup<EventList[event].cups.size(); cup++) {
const string& cp = GetCup(event, cup);
bool passed = SPosN(unlockstr, cp) != string::npos;
for (std::size_t event=0; event<EventList.size(); event++) {
for (std::size_t cup=0; cup<EventList[event].cups.size(); cup++) {
const std::string& cp = GetCup(event, cup);
bool passed = SPosN(unlockstr, cp) != std::string::npos;
if (cup < 1) EventList[event].cups[0]->Unlocked = 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; i<plyr.size(); i++) {
string item = "*[name]" + plyr[i].name;
for (std::size_t i=0; i<plyr.size(); i++) {
std::string item = "*[name]" + plyr[i].name;
item +="[avatar]" + plyr[i].avatar->filename;
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(); i++) {
for (std::size_t i=0; i<plyr.size(); i++) {
delete plyr[i].ctrl;
plyr[i].ctrl = nullptr;
}
}
// called in module regist.cpp:
void CPlayers::AllocControl(size_t player) {
void CPlayers::AllocControl(std::size_t player) {
if (player >= 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<CharList.size(); i++) {
for (std::size_t i=0; i<CharList.size(); i++) {
delete CharList[i].preview;
CharList[i].preview = 0;
}

View File

@ -36,57 +36,57 @@ class TTexture;
struct TRace {
TCourse* course;
size_t light;
std::size_t light;
int snow;
int wind;
TVector3i herrings;
TVector3d time;
size_t music_theme;
std::size_t music_theme;
TRace(TCourse* course_, size_t light_, int snow_, int wind_, const TVector3i& herrings_, const TVector3d& time_, size_t music_theme_)
TRace(TCourse* course_, std::size_t light_, int snow_, int wind_, const TVector3i& herrings_, const TVector3d& time_, std::size_t music_theme_)
: course(course_), light(light_), snow(snow_), wind(wind_), herrings(herrings_), time(time_), music_theme(music_theme_)
{}
};
struct TCup {
string cup;
string name;
string desc;
vector<TRace*> races;
std::string cup;
std::string name;
std::string desc;
std::vector<TRace*> 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<TCup*> cups;
std::string name;
std::vector<TCup*> cups;
explicit TEvent(const string& name_)
explicit TEvent(const std::string& name_)
: name(name_)
{}
};
class CEvents {
private:
map<string, size_t> RaceIndex;
map<string, size_t> CupIndex;
map<string, size_t> EventIndex;
std::map<std::string, std::size_t> RaceIndex;
std::map<std::string, std::size_t> CupIndex;
std::map<std::string, std::size_t> EventIndex;
public:
vector<TRace> RaceList;
vector<TCup> CupList;
vector<TEvent> EventList;
std::vector<TRace> RaceList;
std::vector<TCup> CupList;
std::vector<TEvent> 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<TPlayer> plyr;
std::vector<TPlayer> plyr;
void SetDefaultPlayers();
vector<TAvatar> avatars;
std::vector<TAvatar> 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<TCharacter> CharList;
std::vector<TCharacter> CharList;
~CCharacter();

View File

@ -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";

View File

@ -29,7 +29,7 @@ GNU General Public License for more details.
#define CURSOR_SIZE 10
static vector<TWidget*> Widgets;
static std::vector<TWidget*> 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<maxtux; i++) {
size_t majr = (i/numraces);
size_t minr = i - majr * numraces;
for (std::size_t i=0; i<maxtux; i++) {
std::size_t majr = (i/numraces);
std::size_t minr = i - majr * numraces;
if (majr > 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;

View File

@ -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();

View File

@ -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 {

View File

@ -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;
}

View File

@ -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; i<frames.size(); i++) {
for (std::size_t i=0; i<frames.size(); i++) {
const TKeyframe* frame = &frames[i];
string line = "*[time] " + Float_StrN(frame->val[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<TKeyframe>::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]);
}

View File

@ -35,16 +35,16 @@ struct TKeyframe {
class CKeyframe {
private:
vector<TKeyframe> frames;
std::vector<TKeyframe> 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;

View File

@ -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();

View File

@ -355,7 +355,7 @@ void backsb(double *matrix, int n, double *soln) {
// ***************************************************************************
// ***************************************************************************
bool IntersectPolygon(const TPolygon& p, vector<TVector3d>& v) {
bool IntersectPolygon(const TPolygon& p, std::vector<TVector3d>& v) {
TRay ray;
double d, s, nuDotProd;
double distsq;
@ -372,7 +372,7 @@ bool IntersectPolygon(const TPolygon& p, vector<TVector3d>& 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<TVector3d>& 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<TVector3d>& 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]);
}

View File

@ -36,13 +36,13 @@ struct TPlane {
{}
};
struct TPolygon { vector<int> vertices; };
struct TPolygon { std::vector<int> vertices; };
struct TSphere { double radius; int divisions; };
struct TRay { TVector3d pt; TVector3d vec; };
struct TPolyhedron {
vector<TVector3d> vertices;
vector<TPolygon> polygons;
std::vector<TVector3d> vertices;
std::vector<TPolygon> 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<TVector3d>& v);
bool IntersectPolygon(const TPolygon& p, std::vector<TVector3d>& v);
bool IntersectPolyhedron(TPolyhedron& p);
TVector3d MakeNormal(const TPolygon& p, const TVector3d *v);
void TransPolyhedron(const TMatrix<4, 4>& mat, TPolyhedron& ph);

View File

@ -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<TRenderMode> modestack;
static std::stack<TRenderMode> modestack;
void PushRenderMode(TRenderMode mode) {
if (currentMode != mode)
set_gl_options(mode);

View File

@ -61,7 +61,7 @@ struct TGuiParticle {
void Update(float time_step, float push_timestep, const TVector2d& push_vector);
};
static list<TGuiParticle> particles_2d;
static std::list<TGuiParticle> 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<TGuiParticle>::iterator p = particles_2d.begin(); p != particles_2d.end(); ++p) {
for (std::list<TGuiParticle>::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<float>(FRandom()), -0.05f);
}
for (list<TGuiParticle>::iterator p = particles_2d.begin(); p != particles_2d.end();) {
for (std::list<TGuiParticle>::iterator p = particles_2d.begin(); p != particles_2d.end();) {
if (p->sprite.getPosition().y / static_cast<float>(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<TGuiParticle>::const_iterator i = particles_2d.begin(); i != particles_2d.end(); ++i) {
for (std::list<TGuiParticle>::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<Particle> particles;
static std::list<Particle> 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<Particle>::iterator p = particles.begin(); p != particles.end();) {
for (std::list<Particle>::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<Particle>::const_iterator p = particles.begin(); p != particles.end(); ++p) {
for (std::list<Particle>::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; i<flakes.size(); i++) {
for (std::size_t i=0; i<flakes.size(); i++) {
flakes[i].pt.x += xcoeff;
flakes[i].pt.y += flakes[i].vel.y * timestep + ycoeff;
flakes[i].pt.z += zcoeff;
@ -543,7 +543,7 @@ void CFlakes::Reset() {
areas.clear();
}
void CFlakes::MakeSnowFlake(size_t ar, size_t i) {
void CFlakes::MakeSnowFlake(std::size_t ar, std::size_t i) {
areas[ar].flakes[i].pt.x = XRandom(areas[ar].left, areas[ar].right);
areas[ar].flakes[i].pt.y = -XRandom(areas[ar].top, areas[ar].bottom);
areas[ar].flakes[i].pt.z = areas[ar].back - FRandom() * (areas[ar].back - areas[ar].front);
@ -585,13 +585,13 @@ void CFlakes::MakeSnowFlake(size_t ar, size_t i) {
void CFlakes::GenerateSnowFlakes(const CControl *ctrl) {
if (g_game.snow_id < 1) return;
snow_lastpos = ctrl->cpos;
for (size_t ar=0; ar<areas.size(); ar++) {
for (size_t i=0; i<areas[ar].flakes.size(); i++) MakeSnowFlake(ar, i);
for (std::size_t ar=0; ar<areas.size(); ar++) {
for (std::size_t i=0; i<areas[ar].flakes.size(); i++) MakeSnowFlake(ar, i);
}
}
void CFlakes::UpdateAreas(const CControl *ctrl) {
for (size_t ar=0; ar<areas.size(); ar++) {
for (std::size_t ar=0; ar<areas.size(); ar++) {
areas[ar].left = ctrl->cpos.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; ar<areas.size(); ar++) {
for (std::size_t ar=0; ar<areas.size(); ar++) {
areas[ar].Update(timestep, xcoeff, ycoeff, zcoeff);
}
snow_lastpos = ctrl->cpos;
}
void CFlakes::Draw(const CControl *ctrl) const {
for (size_t ar=0; ar<areas.size(); ar++)
for (std::size_t ar=0; ar<areas.size(); ar++)
areas[ar].Draw(ctrl);
}
@ -834,7 +834,7 @@ void CCurtain::Draw() {
glColor(particle_colour, 255);
// glEnable (GL_NORMALIZE);
for (size_t i=0; i<curtains.size(); i++) {
for (std::size_t i=0; i<curtains.size(); i++) {
curtains[i].Draw();
}
}
@ -844,7 +844,7 @@ void CCurtain::Update(float timestep, const CControl *ctrl) {
const TVector3d& drift = Wind.WindDrift();
UpdateChanges(timestep);
for (size_t i=0; i<curtains.size(); i++) {
for (std::size_t i=0; i<curtains.size(); i++) {
curtains[i].Update(timestep, drift, ctrl);
}
Draw();
@ -855,7 +855,7 @@ void CCurtain::Reset() {
}
void CCurtain::SetStartParams(const CControl *ctrl) {
for (size_t i=0; i<curtains.size(); i++) {
for (std::size_t i=0; i<curtains.size(); i++) {
curtains[i].SetStartParams(ctrl);
}
}

View File

@ -55,7 +55,7 @@ struct TFlake {
};
struct TFlakeArea {
vector<TFlake> flakes;
std::vector<TFlake> 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<TFlakeArea> areas;
void MakeSnowFlake(size_t ar, size_t i);
std::vector<TFlakeArea> 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<TCurtain> curtains;
std::vector<TCurtain> curtains;
void SetStartParams(const CControl *ctrl);
public:

View File

@ -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<Course.CollArr.size(); i++) {
for (std::size_t i = 0; i<Course.CollArr.size(); i++) {
double diam = Course.CollArr[i].diam;
double height = Course.CollArr[i].height;
loc = Course.CollArr[i].pt;
@ -177,9 +177,9 @@ void CControl::AdjustTreeCollision(const TVector3d& pos, TVector3d *vel) {
}
void CControl::CheckItemCollection(const TVector3d& pos) {
size_t num_items = Course.NocollArr.size();
std::size_t num_items = Course.NocollArr.size();
for (size_t i=0; i<num_items; i++) {
for (std::size_t i=0; i<num_items; i++) {
if (Course.NocollArr[i].collectable != 1) continue;
double diam = Course.NocollArr[i].diam;
@ -398,12 +398,12 @@ TVector3d CControl::CalcNetForce(const TVector3d& pos, const TVector3d& vel) {
double speed = ff.frictdir.Norm();
ff.frictdir *= -1.0;
static vector<double> surfweights;
static std::vector<double> 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<Course.TerrList.size(); i++) {
for (std::size_t i=0; i<Course.TerrList.size(); i++) {
ff.frict_coeff += surfweights[i] * Course.TerrList[i].friction;
ff.comp_depth += surfweights[i] * Course.TerrList[i].depth;
}

View File

@ -206,7 +206,7 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
float maxerror = 0;
float e;
size_t numTerr = Course.TerrList.size();
std::size_t numTerr = Course.TerrList.size();
if (cd.ChildIndex & 1) {
e = fabs(Vertex[0].Y - (cd.Verts[1].Y + cd.Verts[3].Y) * 0.5);
} else {
@ -327,7 +327,7 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
if (Error[i+2] > 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<numTerr; t++) {
std::size_t max_count = 0;
std::size_t total = 0;
for (std::size_t t=0; t<numTerr; t++) {
if (terrain_count[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<numTerrains; j++) {
std::size_t numTerrains = Course.TerrList.size();
for (std::size_t j=0; j<numTerrains; j++) {
if (Course.TerrList[j].texture != nullptr) {
InitArrayCounters();
RenderAux(cd, SomeClip, (int)j);
@ -781,7 +781,7 @@ void quadsquare::Render(const quadcornerdata& cd, GLubyte *vnc_array) {
colorval(VertexArrayIndices[i], 2) = 255;
}
for (size_t j=0; j<numTerrains; j++) {
for (std::size_t j=0; j<numTerrains; j++) {
if (Course.TerrList[j].texture > 0) {
Course.TerrList[j].texture->Bind();

View File

@ -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);

View File

@ -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;

View File

@ -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; i<list->numScores; 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; sc<num; sc++) {
const TScore& score = list->scores[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);

View File

@ -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_)
{}
};

View File

@ -25,47 +25,47 @@ GNU General Public License for more details.
#include <iostream>
#include <fstream>
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<typename T>
TVector2<T> Str_Vector2(const string &s, const TVector2<T> &def) {
TVector2<T> Str_Vector2(const std::string &s, const TVector2<T> &def) {
T x, y;
istringstream is(s);
std::istringstream is(s);
is >> x >> y;
if (is.fail()) return def;
else return TVector2<T>(x, y);
}
template TVector2<double> Str_Vector2(const string &s, const TVector2<double> &def);
template TVector2<int> Str_Vector2(const string &s, const TVector2<int> &def);
template TVector2<double> Str_Vector2(const std::string &s, const TVector2<double> &def);
template TVector2<int> Str_Vector2(const std::string &s, const TVector2<int> &def);
template<typename T>
TVector3<T> Str_Vector3(const string &s, const TVector3<T> &def) {
TVector3<T> Str_Vector3(const std::string &s, const TVector3<T> &def) {
T x, y, z;
istringstream is(s);
std::istringstream is(s);
is >> x >> y >> z;
if (is.fail()) return def;
else return TVector3<T>(x, y, z);
}
template TVector3<double> Str_Vector3(const string &s, const TVector3<double> &def);
template TVector3<int> Str_Vector3(const string &s, const TVector3<int> &def);
template TVector3<double> Str_Vector3(const std::string &s, const TVector3<double> &def);
template TVector3<int> Str_Vector3(const std::string &s, const TVector3<int> &def);
template<typename T>
TVector4<T> Str_Vector4(const string &s, const TVector4<T> &def) {
TVector4<T> Str_Vector4(const std::string &s, const TVector4<T> &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<T>(x, y, z, w);
}
template TVector4<double> Str_Vector4(const string &s, const TVector4<double> &def);
template TVector4<int> Str_Vector4(const string &s, const TVector4<int> &def);
template TVector4<double> Str_Vector4(const std::string &s, const TVector4<double> &def);
template TVector4<int> Str_Vector4(const std::string &s, const TVector4<int> &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<count; i++) arr[i] = def;
for (std::size_t i=0; i<count; i++) arr[i] = def;
}
// --------------------------------------------------------------------
// SP functions for parsing lines
// --------------------------------------------------------------------
static string SPItemN(const string &s, const string &tag) {
static std::string SPItemN(const std::string &s, const std::string &tag) {
if (s.empty() || tag.empty()) return "";
string tg = '[' + tag + ']';
size_t i = SPosN(s, tg);
if (i == string::npos) return "";
size_t ii = i + tg.size();
string item;
std::string tg = '[' + tag + ']';
std::size_t i = SPosN(s, tg);
if (i == std::string::npos) return "";
std::size_t ii = i + tg.size();
std::string item;
while (ii < s.size() && s[ii] != '[' && s[ii] != '#') {
item += s[ii];
ii++;
@ -203,96 +203,96 @@ static string SPItemN(const string &s, const string &tag) {
return item;
}
string SPStrN(const string &s, const string &tag, const string& def) {
string item = SPItemN(s, tag);
std::string SPStrN(const std::string &s, const std::string &tag, const std::string& def) {
std::string item = SPItemN(s, tag);
if (item.empty()) return def;
STrimN(item);
return item;
}
string SPStrN(const string &s, const char* tag, const char* def) {
string item = SPItemN(s, tag);
std::string SPStrN(const std::string &s, const char* tag, const char* def) {
std::string item = SPItemN(s, tag);
if (item.empty()) return def;
STrimN(item);
return item;
}
int SPIntN(const string &s, const string &tag, const int def) {
int SPIntN(const std::string &s, const std::string &tag, const int def) {
return (Str_IntN(SPItemN(s, tag), def));
}
bool SPBoolN(const string &s, const string &tag, const bool def) {
string item = SPItemN(s, tag);
bool SPBoolN(const std::string &s, const std::string &tag, const bool def) {
std::string item = SPItemN(s, tag);
STrimN(item);
return Str_BoolN(item, def);
}
float SPFloatN(const string &s, const string &tag, const float def) {
float SPFloatN(const std::string &s, const std::string &tag, const float def) {
return (Str_FloatN(SPItemN(s, tag), def));
}
template<typename T>
TVector2<T> SPVector2(const string &s, const string &tag, const TVector2<T>& def) {
TVector2<T> SPVector2(const std::string &s, const std::string &tag, const TVector2<T>& def) {
return (Str_Vector2(SPItemN(s, tag), def));
}
template TVector2<int> SPVector2(const string &s, const string &tag, const TVector2<int>& def);
template TVector2<double> SPVector2(const string &s, const string &tag, const TVector2<double>& def);
template TVector2<int> SPVector2(const std::string &s, const std::string &tag, const TVector2<int>& def);
template TVector2<double> SPVector2(const std::string &s, const std::string &tag, const TVector2<double>& def);
template<typename T>
TVector3<T> SPVector3(const string &s, const string &tag, const TVector3<T>& def) {
TVector3<T> SPVector3(const std::string &s, const std::string &tag, const TVector3<T>& def) {
return (Str_Vector3(SPItemN(s, tag), def));
}
template TVector3<int> SPVector3(const string &s, const string &tag, const TVector3<int>& def);
template TVector3<double> SPVector3(const string &s, const string &tag, const TVector3<double>& def);
template TVector3<int> SPVector3(const std::string &s, const std::string &tag, const TVector3<int>& def);
template TVector3<double> SPVector3(const std::string &s, const std::string &tag, const TVector3<double>& def);
template<typename T>
TVector4<T> SPVector4(const string &s, const string &tag, const TVector4<T>& def) {
TVector4<T> SPVector4(const std::string &s, const std::string &tag, const TVector4<T>& def) {
return (Str_Vector4(SPItemN(s, tag), def));
}
template TVector4<int> SPVector4(const string &s, const string &tag, const TVector4<int>& def);
template TVector4<double> SPVector4(const string &s, const string &tag, const TVector4<double>& def);
template TVector4<int> SPVector4(const std::string &s, const std::string &tag, const TVector4<int>& def);
template TVector4<double> SPVector4(const std::string &s, const std::string &tag, const TVector4<double>& 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<string, size_t>& index, const string &tag) {
void CSPList::MakeIndex(std::map<std::string, std::size_t>& 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;

116
src/spx.h
View File

@ -22,93 +22,93 @@ GNU General Public License for more details.
#include <list>
#include <map>
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<typename T>
TVector2<T> Str_Vector2(const string &s, const TVector2<T>& def);
TVector2<T> Str_Vector2(const std::string &s, const TVector2<T>& def);
template<typename T>
TVector3<T> Str_Vector3(const string &s, const TVector3<T>& def);
TVector3<T> Str_Vector3(const std::string &s, const TVector3<T>& def);
template<typename T>
TVector4<T> Str_Vector4(const string &s, const TVector4<T>& 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<T> Str_Vector4(const std::string &s, const TVector4<T>& 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<typename T>
TVector2<T> SPVector2(const string &s, const string &tag, const TVector2<T>& 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<T> SPVector2(const std::string &s, const std::string &tag, const TVector2<T>& 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<typename T>
TVector3<T> SPVector3(const string &s, const string &tag, const TVector3<T>& 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<T> SPVector3(const std::string &s, const std::string &tag, const TVector3<T>& 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<typename T>
TVector4<T> SPVector4(const string &s, const string &tag, const TVector4<T>& 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<T> SPVector4(const std::string &s, const std::string &tag, const TVector4<T>& 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<string> {
class CSPList : public std::list<std::string> {
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<string, size_t>& index, const string &tag);
void MakeIndex(std::map<std::string, std::size_t>& index, const std::string &tag);
};
#endif

View File

@ -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(); i++) {
for (std::size_t i=0; i<CommonTex.size(); i++) {
delete CommonTex[i];
}
CommonTex.clear();
}
TTexture* CTexture::GetTexture(size_t idx) const {
TTexture* CTexture::GetTexture(std::size_t idx) const {
if (idx >= 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);

View File

@ -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<TTexture*> CommonTex;
std::vector<TTexture*> 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;

View File

@ -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; i<num; i++) {
std::size_t num = action->num;
for (std::size_t i=0; i<num; i++) {
is_visible = false;
int type = action->type[i];
int yt = Winsys.resolution.height - 120 + (int)i * 18;

View File

@ -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<TestFrame.numFrames(); i++) {
for (std::size_t i=0; i<TestFrame.numFrames(); i++) {
if (i != curr_frame) {
FT.SetColor(colLGrey);
FT.SetFont("normal");

View File

@ -122,9 +122,9 @@ CTools Tools;
static bool finalstage = false;
static bool charchanged = false;
static bool framechanged = false;
static string char_dir;
static string char_file;
static string frame_file;
static std::string char_dir;
static std::string char_file;
static std::string frame_file;
static const TLight toollight = {
{0.45f, 0.53f, 0.75f, 1.f},
@ -215,7 +215,7 @@ void SaveToolFrame() {
framechanged = false;
}
void CTools::SetParameter(const string& dir, const string& file) {
void CTools::SetParameter(const std::string& dir, const std::string& file) {
char_dir = param.char_dir + SEP + dir;
char_file = "shape.lst";
frame_file = file;

View File

@ -93,7 +93,7 @@ class CTools : public State {
void Motion(int x, int y);
public:
void Enter();
static void SetParameter(const string& dir, const string& file);
static void SetParameter(const std::string& dir, const std::string& file);
};
extern CTools Tools;

View File

@ -49,8 +49,8 @@ struct track_quad_t {
};
struct track_marks_t {
list<track_quad_t> quads;
list<track_quad_t>::iterator current_mark;
std::list<track_quad_t> quads;
std::list<track_quad_t>::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<track_quad_t>::const_iterator q = track_marks.quads.begin(); q != track_marks.quads.end(); ++q) {
for (std::list<track_quad_t>::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<track_quad_t>::const_iterator qnext = q;
std::list<track_quad_t>::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<track_quad_t>::iterator q = track_marks.current_mark;
std::list<track_quad_t>::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<track_quad_t>::iterator qprev = decrementRingIterator(q);
std::list<track_quad_t>::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<track_quad_t>::iterator qprev = track_marks.current_mark;
std::list<track_quad_t>::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<track_quad_t>::iterator q = track_marks.current_mark;
std::list<track_quad_t>::iterator q = track_marks.current_mark;
if (!continuing_track) {
q->track_type = TRACK_HEAD;

View File

@ -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;

View File

@ -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<TLang> languages;
std::vector<TLang> 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;

View File

@ -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<string, size_t>::const_iterator i = NodeIndex.find(node_trivialname);
bool CCharShape::RotateNode(const std::string& node_trivialname, int axis, double angle) {
std::map<std::string, std::size_t>::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<string, size_t>::const_iterator i = NodeIndex.find(node_trivialname);
bool CCharShape::ResetNode(const std::string& node_trivialname) {
std::map<std::string, std::size_t>::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<string, size_t>::const_iterator i = MaterialIndex.find(mat_name);
TCharMaterial* CCharShape::GetMaterial(const std::string& mat_name) {
std::map<std::string, std::size_t>::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; i<act->num; i++) {
for (std::size_t i=0; i<act->num; 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; i<act->num; i++) {
for (std::size_t i=0; i<act->num; 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; i<Materials.size(); i++)
for (std::size_t i=0; i<Materials.size(); i++)
if (!Materials[i].matline.empty())
list.Add(Materials[i].matline);
list.Add();
}
list.Add("# Nodes:");
for (size_t i=1; i<numNodes; i++) {
for (std::size_t i=1; i<numNodes; i++) {
TCharNode* node = Nodes[i];
TCharAction* act = node->action;
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; ii<act->order.size(); ii++) {
for (std::size_t ii=0; ii<act->order.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 (i<numNodes-3) {
if (node->visible && !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);
}
}

View File

@ -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<TCharMaterial> Materials;
map<string, size_t> MaterialIndex;
std::size_t Index[MAX_CHAR_NODES];
std::size_t numNodes;
std::vector<TCharMaterial> Materials;
std::map<std::string, std::size_t> 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<string, size_t> NodeIndex;
std::size_t highlight_node;
std::map<std::string, std::size_t> 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

View File

@ -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 += '_';

View File

@ -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;