Refactorizations:
- Store time as float, resolving several compilation issues with clang - Added missing virtual destructor in GUI - Fixed typo in OS_WIN32_MINGW (bh.h) git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/branches/SFML2@503 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
49969b7924
commit
a6f5aecdb1
2
src/bh.h
2
src/bh.h
|
@ -55,7 +55,7 @@ GNU General Public License for more details.
|
|||
# define SEP "\\"
|
||||
# undef DrawText
|
||||
# undef GetObject
|
||||
#elif defined OS_WON32_MINGW
|
||||
#elif defined OS_WIN32_MINGW
|
||||
# include <dirent.h>
|
||||
# include <GL/glext.h>
|
||||
# define SEP "/"
|
||||
|
|
|
@ -162,7 +162,7 @@ void Message(const string& msg) {
|
|||
bool FileExists(const string& filename) {
|
||||
struct stat stat_info;
|
||||
if (stat(filename.c_str(), &stat_info) != 0) {
|
||||
if (errno != ENOENT) Message("couldn't stat ", filename);
|
||||
if (errno != ENOENT) Message("couldn't stat", filename);
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ void CGameConfig::Enter() {
|
|||
Music.Play(param.config_music, true);
|
||||
}
|
||||
|
||||
void CGameConfig::Loop(double time_step) {
|
||||
void CGameConfig::Loop(float time_step) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CGameConfig : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -64,7 +64,7 @@ void CCredits::LoadCreditList() {
|
|||
}
|
||||
}
|
||||
|
||||
void CCredits::DrawCreditsText(double time_step) {
|
||||
void CCredits::DrawCreditsText(float time_step) {
|
||||
int h = Winsys.resolution.height;
|
||||
double offs = 0.0;
|
||||
if (moving) y_offset += time_step * 30;
|
||||
|
@ -150,7 +150,7 @@ void CCredits::Exit() {
|
|||
CreditList.clear();
|
||||
}
|
||||
|
||||
void CCredits::Loop(double time_step) {
|
||||
void CCredits::Loop(float time_step) {
|
||||
check_gl_error();
|
||||
ClearRenderContext();
|
||||
Winsys.clear();
|
||||
|
|
|
@ -34,10 +34,10 @@ struct TCredits {
|
|||
class CCredits : public State {
|
||||
list<TCredits> CreditList;
|
||||
|
||||
void DrawCreditsText(double time_step);
|
||||
void DrawCreditsText(float time_step);
|
||||
void Enter();
|
||||
void Exit();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -60,7 +60,7 @@ struct TCharacter;
|
|||
|
||||
struct TGameData {
|
||||
TToolMode toolmode;
|
||||
double time_step;
|
||||
float time_step;
|
||||
TGameType game_type;
|
||||
bool force_treemap;
|
||||
int treesize;
|
||||
|
@ -85,7 +85,7 @@ struct TGameData {
|
|||
size_t theme_id;
|
||||
|
||||
// race results (better in player.ctrl ?)
|
||||
double time; // reached time
|
||||
float time; // reached time
|
||||
int score; // reached score
|
||||
int herring; // catched herrings during the race
|
||||
int race_result; // tuxlifes, only for a single race, see game_ctrl
|
||||
|
|
|
@ -183,7 +183,7 @@ int resultlevel(size_t num, size_t numraces) {
|
|||
return q + 1;
|
||||
}
|
||||
|
||||
void CEvent::Loop(double timestep) {
|
||||
void CEvent::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CEvent : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -120,7 +120,7 @@ void CEventSelect::Enter() {
|
|||
Music.Play(param.menu_music, true);
|
||||
}
|
||||
|
||||
void CEventSelect::Loop(double timestep) {
|
||||
void CEventSelect::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CEventSelect : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -39,14 +39,11 @@ Then edit the below functions:
|
|||
#include <etr_config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "game_config.h"
|
||||
#include "spx.h"
|
||||
#include "translation.h"
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
TParam param;
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ void CGameOver::Enter() {
|
|||
}
|
||||
|
||||
|
||||
void CGameOver::Loop(double time_step) {
|
||||
void CGameOver::Loop(float time_step) {
|
||||
CControl *ctrl = g_game.player->ctrl;
|
||||
int width = Winsys.resolution.width;
|
||||
int height = Winsys.resolution.height;
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CGameOver : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
public:
|
||||
|
|
|
@ -121,7 +121,7 @@ void CGameTypeSelect::Enter() {
|
|||
Music.Play(param.menu_music, true);
|
||||
}
|
||||
|
||||
void CGameTypeSelect::Loop(double time_step) {
|
||||
void CGameTypeSelect::Loop(float time_step) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CGameTypeSelect : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -253,7 +253,7 @@ void TTextField::Key(sf::Keyboard::Key key, unsigned int mod, bool released) {
|
|||
}
|
||||
}
|
||||
|
||||
void TTextField::UpdateCursor(double timestep) {
|
||||
void TTextField::UpdateCursor(float timestep) {
|
||||
time += timestep;
|
||||
if (time > CRSR_PERIODE) {
|
||||
time = 0;
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
bool focus;
|
||||
|
||||
TWidget(int x, int y, int width, int height, bool interactive_ = true);
|
||||
virtual ~TWidget() {}
|
||||
virtual void Draw() const = 0;
|
||||
virtual bool Click(int x, int y);
|
||||
virtual void TextEnter(char text) {}
|
||||
|
@ -105,7 +106,7 @@ class TTextField : public TWidget {
|
|||
sf::RectangleShape cursorShape;
|
||||
size_t cursorPos;
|
||||
size_t maxLng;
|
||||
double time;
|
||||
float time;
|
||||
bool cursor;
|
||||
|
||||
void SetCursorPos(size_t new_pos);
|
||||
|
@ -114,7 +115,7 @@ public:
|
|||
void Draw() const;
|
||||
void TextEnter(char text);
|
||||
void Key(sf::Keyboard::Key key, unsigned int mod, bool released);
|
||||
void UpdateCursor(double timestep);
|
||||
void UpdateCursor(float timestep);
|
||||
const sf::String& Text() const { return text; }
|
||||
};
|
||||
TTextField* AddTextField(const sf::String& text, int x, int y, int width, int height);
|
||||
|
|
|
@ -67,7 +67,7 @@ void CHelp::Enter() {
|
|||
footnote = AddLabel(Trans.Text(65), CENTER, AutoYPosN(90), colWhite);
|
||||
}
|
||||
|
||||
void CHelp::Loop(double timestep) {
|
||||
void CHelp::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CHelp : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -66,7 +66,7 @@ void CIntro::Enter() {
|
|||
// reset of result values
|
||||
g_game.herring = 0;
|
||||
g_game.score = 0;
|
||||
g_game.time = 0.0;
|
||||
g_game.time = 0.f;
|
||||
g_game.race_result = -1;
|
||||
g_game.raceaborted = false;
|
||||
|
||||
|
@ -93,7 +93,7 @@ void CIntro::Enter() {
|
|||
param.show_hud = true;
|
||||
}
|
||||
|
||||
void CIntro::Loop(double time_step) {
|
||||
void CIntro::Loop(float time_step) {
|
||||
CControl *ctrl = g_game.player->ctrl;
|
||||
int width = Winsys.resolution.width;
|
||||
int height = Winsys.resolution.height;
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CIntro : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
public:
|
||||
};
|
||||
|
|
|
@ -256,7 +256,7 @@ void CKeyframe::CalcKeyframe(size_t idx, CCharShape *shape, const TVector3d& ref
|
|||
shape->RotateNode("right_ankle", 3, vv);
|
||||
}
|
||||
|
||||
void CKeyframe::Update(double timestep) {
|
||||
void CKeyframe::Update(float timestep) {
|
||||
if (!loaded) return;
|
||||
if (!active) return;
|
||||
|
||||
|
@ -293,7 +293,7 @@ void CKeyframe::Update(double timestep) {
|
|||
InterpolateKeyframe(keyidx, frac, shape);
|
||||
}
|
||||
|
||||
void CKeyframe::UpdateTest(double timestep, CCharShape *shape) {
|
||||
void CKeyframe::UpdateTest(float timestep, CCharShape *shape) {
|
||||
if (!active) return;
|
||||
|
||||
keytime += timestep;
|
||||
|
|
|
@ -53,8 +53,8 @@ public:
|
|||
void Init(const TVector3d& ref_position, double height_correction, CCharShape *shape);
|
||||
void InitTest(const TVector3d& ref_position, CCharShape *shape);
|
||||
void Reset();
|
||||
void Update(double timestep);
|
||||
void UpdateTest(double timestep, CCharShape *shape);
|
||||
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);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ void CLoading::Enter() {
|
|||
Music.Play("loading", true);
|
||||
}
|
||||
|
||||
void CLoading::Loop(double time_step) {
|
||||
void CLoading::Loop(float time_step) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CLoading : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
public:
|
||||
};
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void CNewPlayer::Enter() {
|
|||
textfield = AddTextField(emptyString, area.left, frametop, framewidth, frameheight);
|
||||
}
|
||||
|
||||
void CNewPlayer::Loop(double timestep) {
|
||||
void CNewPlayer::Loop(float timestep) {
|
||||
sf::Color col;
|
||||
|
||||
ScopedRenderMode rm(GUI);
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CNewPlayer : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void TextEntered(char text);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
|
|
|
@ -56,7 +56,7 @@ void COglTest::Enter() {
|
|||
Winsys.KeyRepeat(true);
|
||||
}
|
||||
|
||||
void COglTest::Loop(double timestep) {
|
||||
void COglTest::Loop(float timestep) {
|
||||
// ------------- 3d scenery ---------------------------------------
|
||||
ScopedRenderMode rm(TUX);
|
||||
ClearRenderContext(colDDBackgr);
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class COglTest : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
public:
|
||||
};
|
||||
|
|
|
@ -124,7 +124,7 @@ void TGuiParticle::Update(float time_step, float push_timestep, const TVector2d&
|
|||
x += vel.x * time_step * (size / PARTICLE_SIZE_RANGE);
|
||||
y += vel.y * time_step * (size / PARTICLE_SIZE_RANGE);
|
||||
|
||||
x = clamp(-0.05, x, 1);
|
||||
x = clamp(-0.05f, x, 1.f);
|
||||
sprite.setPosition(x*Winsys.resolution.width, y*Winsys.resolution.height);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ void init_ui_snow() {
|
|||
push_position = TVector2d(0.0, 0.0);
|
||||
}
|
||||
|
||||
void update_ui_snow(double time_step) {
|
||||
void update_ui_snow(float time_step) {
|
||||
static sf::Clock timer;
|
||||
float time = timer.getElapsedTime().asSeconds();
|
||||
timer.restart();
|
||||
|
@ -337,7 +337,7 @@ void create_new_particles(const TVector3d& loc, const TVector3d& vel, int num) {
|
|||
VARIANCE_FACTOR * (FRandom() - 0.5) * speed);
|
||||
}
|
||||
}
|
||||
void update_particles(double time_step) {
|
||||
void update_particles(float time_step) {
|
||||
for (list<Particle>::iterator p = particles.begin(); p != particles.end();) {
|
||||
p->age += time_step;
|
||||
if (p->age < 0) {
|
||||
|
@ -345,7 +345,7 @@ void update_particles(double time_step) {
|
|||
continue;
|
||||
}
|
||||
|
||||
p->pt += time_step * p->vel;
|
||||
p->pt += static_cast<double>(time_step) * p->vel;
|
||||
double ycoord = Course.FindYCoord(p->pt.x, p->pt.z);
|
||||
if (p->pt.y < ycoord - 3) {p->age = p->death + 1;}
|
||||
if (p->age >= p->death) {
|
||||
|
@ -646,7 +646,7 @@ void CFlakes::Init(int grade, const CControl *ctrl) {
|
|||
GenerateSnowFlakes(ctrl);
|
||||
}
|
||||
|
||||
void CFlakes::Update(double timestep, const CControl *ctrl) {
|
||||
void CFlakes::Update(float timestep, const CControl *ctrl) {
|
||||
if (g_game.snow_id < 1)
|
||||
return;
|
||||
|
||||
|
@ -703,7 +703,7 @@ void InitChanges() {
|
|||
}
|
||||
}
|
||||
|
||||
void UpdateChanges(double timestep) {
|
||||
void UpdateChanges(float timestep) {
|
||||
for (int i=0; i<NUM_CHANGES; i++) {
|
||||
TChange* ch = &changes[i];
|
||||
if (ch->forward) {
|
||||
|
@ -1105,7 +1105,7 @@ void InitSnow(const CControl *ctrl) {
|
|||
Curtain.Init(ctrl);
|
||||
}
|
||||
|
||||
void UpdateSnow(double timestep, const CControl *ctrl) {
|
||||
void UpdateSnow(float timestep, const CControl *ctrl) {
|
||||
if (g_game.snow_id < 1 || g_game.snow_id > 3) return;
|
||||
Flakes.Update(timestep, ctrl);
|
||||
Curtain.Update(timestep, ctrl);
|
||||
|
@ -1121,6 +1121,6 @@ void InitWind() {
|
|||
Wind.Init(g_game.wind_id);
|
||||
}
|
||||
|
||||
void UpdateWind(double timestep) {
|
||||
void UpdateWind(float timestep) {
|
||||
Wind.Update(timestep);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ GNU General Public License for more details.
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
void init_ui_snow();
|
||||
void update_ui_snow(double time_step);
|
||||
void update_ui_snow(float time_step);
|
||||
void push_ui_snow(const TVector2i& pos);
|
||||
void draw_ui_snow();
|
||||
|
||||
|
@ -36,7 +36,7 @@ void draw_ui_snow();
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
void create_new_particles(const TVector3d& loc, const TVector3d& vel, int num);
|
||||
void update_particles(double time_step);
|
||||
void update_particles(float time_step);
|
||||
void clear_particles();
|
||||
void draw_particles(const CControl *ctrl);
|
||||
void generate_particles(const CControl *ctrl, double dtime, const TVector3d& pos, double speed);
|
||||
|
@ -99,7 +99,7 @@ private:
|
|||
public:
|
||||
void Init(int grade, const CControl *ctrl);
|
||||
void Reset();
|
||||
void Update(double timestep, const CControl *ctrl);
|
||||
void Update(float timestep, const CControl *ctrl);
|
||||
void Draw(const CControl *ctrl) const;
|
||||
};
|
||||
|
||||
|
@ -224,9 +224,9 @@ extern CWind Wind;
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
void InitSnow(const CControl *ctrl);
|
||||
void UpdateSnow(double timestep, const CControl *ctrl);
|
||||
void UpdateSnow(float timestep, const CControl *ctrl);
|
||||
void DrawSnow(const CControl *ctrl);
|
||||
void InitWind();
|
||||
void UpdateWind(double timestep);
|
||||
void UpdateWind(float timestep);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -71,7 +71,7 @@ void CPaused::Mouse(int button, int state, int x, int y) {
|
|||
|
||||
// ====================================================================
|
||||
|
||||
void CPaused::Loop(double time_step) {
|
||||
void CPaused::Loop(float time_step) {
|
||||
CControl *ctrl = g_game.player->ctrl;
|
||||
int width = Winsys.resolution.width;
|
||||
int height = Winsys.resolution.height;
|
||||
|
|
|
@ -22,7 +22,7 @@ GNU General Public License for more details.
|
|||
#include "states.h"
|
||||
|
||||
class CPaused : public State {
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
public:
|
||||
|
|
|
@ -592,7 +592,7 @@ void CControl::SolveOdeSystem(double timestep) {
|
|||
// update tux position
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void CControl::UpdatePlayerPos(double timestep) {
|
||||
void CControl::UpdatePlayerPos(float timestep) {
|
||||
CCharShape *shape = g_game.character->shape;
|
||||
double paddling_factor;
|
||||
double flap_factor;
|
||||
|
|
|
@ -148,7 +148,7 @@ public:
|
|||
double minFrictspeed;
|
||||
|
||||
void Init();
|
||||
void UpdatePlayerPos(double timestep);
|
||||
void UpdatePlayerPos(float timestep);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -178,7 +178,7 @@ void CRaceSelect::Enter() {
|
|||
name = AddFramedText(area.left, frametop, framewidth, frameheight, 3, colMBackgr, "", FT.GetSize(), true);
|
||||
}
|
||||
|
||||
void CRaceSelect::Loop(double timestep) {
|
||||
void CRaceSelect::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CRaceSelect : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -166,7 +166,7 @@ void CRacing::Jbutt(int button, int state) {
|
|||
}
|
||||
}
|
||||
|
||||
void CalcJumpEnergy(double time_step) {
|
||||
void CalcJumpEnergy(float time_step) {
|
||||
CControl *ctrl = g_game.player->ctrl;
|
||||
|
||||
if (ctrl->jump_charging) {
|
||||
|
@ -250,7 +250,7 @@ void PlayTerrainSound(CControl *ctrl, bool airborne) {
|
|||
}
|
||||
|
||||
// ----------------------- controls -----------------------------------
|
||||
void CalcSteeringControls(CControl *ctrl, double time_step) {
|
||||
void CalcSteeringControls(CControl *ctrl, float time_step) {
|
||||
if (stick_turn) {
|
||||
ctrl->turn_fact = stick_turnfact;
|
||||
ctrl->turn_animation += ctrl->turn_fact * 2 * time_step;
|
||||
|
@ -291,7 +291,7 @@ void CalcSteeringControls(CControl *ctrl, double time_step) {
|
|||
}
|
||||
}
|
||||
|
||||
void CalcFinishControls(CControl *ctrl, double timestep, bool airborne) {
|
||||
void CalcFinishControls(CControl *ctrl, float timestep, bool airborne) {
|
||||
double speed = ctrl->cvel.Length();
|
||||
double dir_angle = RADIANS_TO_ANGLES(atan(ctrl->cvel.x / ctrl->cvel.z));
|
||||
|
||||
|
@ -310,7 +310,7 @@ void CalcFinishControls(CControl *ctrl, double timestep, bool airborne) {
|
|||
|
||||
// ----------------------- trick --------------------------------------
|
||||
|
||||
void CalcTrickControls(CControl *ctrl, double time_step, bool airborne) {
|
||||
void CalcTrickControls(CControl *ctrl, float time_step, bool airborne) {
|
||||
if (airborne && trick_modifier) {
|
||||
if (left_turn) ctrl->roll_left = true;
|
||||
if (right_turn) ctrl->roll_right = true;
|
||||
|
@ -338,7 +338,7 @@ void CalcTrickControls(CControl *ctrl, double time_step, bool airborne) {
|
|||
// loop
|
||||
// ====================================================================
|
||||
|
||||
void CRacing::Loop(double time_step) {
|
||||
void CRacing::Loop(float time_step) {
|
||||
CControl *ctrl = g_game.player->ctrl;
|
||||
double ycoord = Course.FindYCoord(ctrl->cpos.x, ctrl->cpos.z);
|
||||
bool airborne = (bool)(ctrl->cpos.y > (ycoord + JUMP_MAX_START_HEIGHT));
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CRacing : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Jaxis(int axis, float value);
|
||||
void Jbutt(int button, int state);
|
||||
|
|
|
@ -121,7 +121,7 @@ void CRegist::Enter() {
|
|||
Winsys.Terminate(); // Characters are necessary - ETR is unusable otherwise
|
||||
}
|
||||
|
||||
void CRegist::Loop(double timestep) {
|
||||
void CRegist::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CRegist : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -49,7 +49,7 @@ void CReset::Enter() {
|
|||
position_reset = false;
|
||||
}
|
||||
|
||||
void CReset::Loop(double time_step) {
|
||||
void CReset::Loop(float time_step) {
|
||||
CControl *ctrl = g_game.player->ctrl;
|
||||
float elapsed_time = reset_timer.getElapsedTime().asSeconds();
|
||||
static bool tux_visible = true;
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CReset : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
public:
|
||||
};
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ void CScore::Enter() {
|
|||
const 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(double timestep) {
|
||||
void CScore::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
vector<TScoreList> Scorelist;
|
||||
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -42,7 +42,7 @@ void CSplashScreen::Enter() {
|
|||
Music.Play(param.menu_music, true);
|
||||
}
|
||||
|
||||
void CSplashScreen::Loop(double timestep) {
|
||||
void CSplashScreen::Loop(float timestep) {
|
||||
ScopedRenderMode rm(GUI);
|
||||
Winsys.clear();
|
||||
Trans.LoadTranslations(param.language); // Before first texts are being displayed
|
||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CSplashScreen : public State {
|
||||
void Enter();
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
public:
|
||||
};
|
||||
|
||||
|
|
16
src/spx.cpp
16
src/spx.cpp
|
@ -75,9 +75,7 @@ void STrimN(string &s) {
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
string Int_StrN(const int val) {
|
||||
ostringstream os;
|
||||
os << val;
|
||||
return os.str();
|
||||
return std::to_string(val);
|
||||
}
|
||||
|
||||
string Int_StrN(const int val, const streamsize count) {
|
||||
|
@ -171,7 +169,7 @@ sf::Color Str_ColorN(const string &s, const sf::Color &def) {
|
|||
}
|
||||
|
||||
TColor3 Str_Color3N(const string &s, const TColor3 &def) {
|
||||
float r, g, b;
|
||||
int r, g, b;
|
||||
istringstream is(s);
|
||||
is >> r >> g >> b;
|
||||
if (is.fail()) return def;
|
||||
|
@ -372,15 +370,15 @@ void CSPList::Print() const {
|
|||
|
||||
bool CSPList::Load(const string &filepath) {
|
||||
std::ifstream tempfile(filepath.c_str());
|
||||
string line;
|
||||
|
||||
if (!tempfile) {
|
||||
Message("CSPList::Load - unable to open " + filepath);
|
||||
return false;
|
||||
} else {
|
||||
bool backflag = false;
|
||||
while (getline(tempfile, line)) {
|
||||
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);
|
||||
|
@ -395,12 +393,10 @@ bool CSPList::Load(const string &filepath) {
|
|||
if (line[0] == '*' || empty()) Add(line);
|
||||
else back() += line;
|
||||
} else {
|
||||
bool fwdflag;
|
||||
if (line[line.length()-1] == '\\') {
|
||||
bool fwdflag = false;
|
||||
if (line.back() == '\\') {
|
||||
SDeleteN(line, line.length()-1, 1);
|
||||
fwdflag = true;
|
||||
} else {
|
||||
fwdflag = false;
|
||||
}
|
||||
|
||||
if (backflag == false) Add(line);
|
||||
|
|
|
@ -118,7 +118,7 @@ void State::Manager::PollEvent() {
|
|||
void State::Manager::CallLoopFunction() {
|
||||
check_gl_error();
|
||||
|
||||
g_game.time_step = max(0.0001, timer.getElapsedTime().asSeconds());
|
||||
g_game.time_step = max(0.0001f, timer.getElapsedTime().asSeconds());
|
||||
timer.restart();
|
||||
current->Loop(g_game.time_step);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
static Manager manager;
|
||||
|
||||
virtual void Enter() {}
|
||||
virtual void Loop(double time_step) {}
|
||||
virtual void Loop(float time_step) {}
|
||||
virtual void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y) {}
|
||||
virtual void Mouse(int button, int state, int x, int y) {}
|
||||
virtual void Motion(int x, int y) {}
|
||||
|
|
|
@ -323,7 +323,7 @@ void DrawActionFloat(size_t nr, const string& s, int y, float f) {
|
|||
FT.DrawString(100, y, Float_StrN(f, 2));
|
||||
}
|
||||
|
||||
void RenderChar(double timestep) {
|
||||
void RenderChar(float timestep) {
|
||||
if (!must_render) return;
|
||||
bool is_visible = false;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void InitCharTools();
|
|||
void CharKeys(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void CharMouse(int button, int state, int x, int y);
|
||||
void CharMotion(int x, int y);
|
||||
void RenderChar(double timestep);
|
||||
void RenderChar(float timestep);
|
||||
void StoreAction(TCharAction *act);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -225,7 +225,7 @@ void PrintFrameParams(int ytop, TKeyframe *frame) {
|
|||
}
|
||||
}
|
||||
|
||||
void RenderSingleFrame(double timestep) {
|
||||
void RenderSingleFrame(float timestep) {
|
||||
if (!must_render) return;
|
||||
|
||||
// ------------------ 3d scenery ----------------------------------
|
||||
|
@ -305,7 +305,7 @@ void SequenceKeys(sf::Keyboard::Key key, bool special, bool release, int x, int
|
|||
void SequenceMouse(int button, int state, int x, int y) {}
|
||||
void SequenceMotion(int x, int y) {}
|
||||
|
||||
void RenderSequence(double timestep) {
|
||||
void RenderSequence(float timestep) {
|
||||
ScopedRenderMode rm(TUX);
|
||||
ClearRenderContext(colDDBackgr);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ void InitFrameTools();
|
|||
void SingleFrameKeys(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void SingleFrameMouse(int button, int state, int x, int y);
|
||||
void SingleFrameMotion(int x, int y);
|
||||
void RenderSingleFrame(double timestep);
|
||||
void RenderSingleFrame(float timestep);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// frame sequence
|
||||
|
@ -33,7 +33,7 @@ void RenderSingleFrame(double timestep);
|
|||
void SequenceKeys(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void SequenceMouse(int button, int state, int x, int y);
|
||||
void SequenceMotion(int x, int y);
|
||||
void RenderSequence(double timestep);
|
||||
void RenderSequence(float timestep);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ CGluCamera::CGluCamera() {
|
|||
farther = false;
|
||||
}
|
||||
|
||||
void CGluCamera::Update(double timestep) {
|
||||
void CGluCamera::Update(float timestep) {
|
||||
if (turnright) angle += timestep * 2000;
|
||||
if (turnleft) angle -= timestep * 2000;
|
||||
if (nearer) distance -= timestep * 100;
|
||||
|
@ -281,7 +281,7 @@ void CTools::Motion(int x, int y) {
|
|||
}
|
||||
}
|
||||
|
||||
void CTools::Loop(double timestep) {
|
||||
void CTools::Loop(float timestep) {
|
||||
switch (tool_mode) {
|
||||
case 0:
|
||||
RenderChar(timestep);
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
CGluCamera();
|
||||
double distance;
|
||||
double angle;
|
||||
void Update(double timestep);
|
||||
void Update(float timestep);
|
||||
|
||||
bool turnright;
|
||||
bool turnleft;
|
||||
|
@ -87,7 +87,7 @@ void DrawChanged();
|
|||
|
||||
|
||||
class CTools : public State {
|
||||
void Loop(double time_step);
|
||||
void Loop(float time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
void Motion(int x, int y);
|
||||
|
|
|
@ -291,7 +291,7 @@ void add_track_mark(const CControl *ctrl, int *id) {
|
|||
q->t4 = TVector2d(1.0, q->t2.y + tex_end);
|
||||
}
|
||||
}
|
||||
q->alpha = min((2*comp_depth-dist_from_surface)/(4*comp_depth)*255, 255);
|
||||
q->alpha = min(static_cast<uint8_t>((2*comp_depth-dist_from_surface)/(4*comp_depth)*255), 255);
|
||||
continuing_track = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,13 +140,13 @@ const sf::String& CTranslation::Text(size_t idx) const {
|
|||
return texts[idx];
|
||||
}
|
||||
|
||||
static wstring UnicodeStr(const char *s) {
|
||||
size_t len = strlen(s);
|
||||
static wstring UnicodeStr(const std::string& s) {
|
||||
size_t len = s.length();
|
||||
wstring res;
|
||||
res.resize(len);
|
||||
|
||||
for (size_t i = 0, j = 0; i < len; ++i, ++j) {
|
||||
wchar_t ch = ((const unsigned char *) s)[i];
|
||||
wchar_t ch = (unsigned char)s[i];
|
||||
if (ch >= 0xF0) {
|
||||
ch = (wchar_t)(s[i] & 0x07) << 18;
|
||||
ch |= (wchar_t)(s[++i] & 0x3F) << 12;
|
||||
|
@ -179,7 +179,7 @@ void CTranslation::LoadLanguages() {
|
|||
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").c_str());
|
||||
languages[i].language = UnicodeStr(SPStrN(*line, "language", "English"));
|
||||
}
|
||||
|
||||
if (param.language == string::npos)
|
||||
|
@ -206,7 +206,7 @@ void CTranslation::LoadTranslations(size_t langidx) {
|
|||
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
|
||||
int idx = SPIntN(*line, "idx", -1);
|
||||
if (idx >= 0 && idx < NUM_COMMON_TEXTS) {
|
||||
texts[idx] = UnicodeStr(SPStrN(*line, "trans", texts[idx]).c_str());
|
||||
texts[idx] = UnicodeStr(SPStrN(*line, "trans", texts[idx]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void SetStationaryCamera(bool stat) {
|
|||
}
|
||||
|
||||
static double camera_distance = 4.0;
|
||||
void IncCameraDistance(double timestep) {
|
||||
void IncCameraDistance(float timestep) {
|
||||
camera_distance += timestep * CAMERA_DISTANCE_INCREMENT;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ TVector3d interpolate_view_pos(const TVector3d& ctrl_pos1, const TVector3d& ctrl
|
|||
double max_vec_angle,
|
||||
const TVector3d& pos1, const TVector3d& pos2,
|
||||
double dist, double dt,
|
||||
double time_constant) {
|
||||
float time_constant) {
|
||||
static TVector3d y_vec(0.0, 1.0, 0.0);
|
||||
|
||||
TVector3d vec1 = pos1 - ctrl_pos1;
|
||||
|
@ -93,7 +93,7 @@ TVector3d interpolate_view_pos(const TVector3d& ctrl_pos1, const TVector3d& ctrl
|
|||
|
||||
void interpolate_view_frame(const TVector3d& up1, const TVector3d& dir1,
|
||||
TVector3d *p_up2, TVector3d *p_dir2,
|
||||
double dt, double time_constant) {
|
||||
float dt, double time_constant) {
|
||||
TVector3d z1 = -1.0 * dir1;
|
||||
z1.Norm();
|
||||
TVector3d y1 = ProjectToPlane(z1, up1);
|
||||
|
|
|
@ -25,7 +25,7 @@ void set_view_mode(CControl *ctrl, TViewMode mode);
|
|||
void update_view(CControl *ctrl, double dt);
|
||||
|
||||
void SetStationaryCamera(bool stat); // 0 follow, 1 stationary
|
||||
void IncCameraDistance(double timestep);
|
||||
void IncCameraDistance(float timestep);
|
||||
void SetCameraDistance(double val);
|
||||
|
||||
// ------------- viewfrustum ------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue