Small fixes.

This commit is contained in:
Quentin Bazin 2020-07-17 04:19:04 +02:00
parent 22552dab86
commit 886aba1d0f
3 changed files with 13 additions and 13 deletions

View File

@ -35,11 +35,11 @@ Skybox::Skybox(gk::Camera &camera, ClientWorld &world) : m_camera(camera), m_wor
m_shader.addShader(GL_FRAGMENT_SHADER, "resources/shaders/skybox.f.glsl");
m_shader.linkProgram();
m_sun.setSize(200, 200);
m_sun.setSize(256, 256);
m_sun.setPosition(500, -m_sun.width() / 2, -m_sun.height() / 2);
m_sun.setTexture("texture-sun");
m_moon.setSize(200, 200);
m_moon.setSize(256, 256);
m_moon.setPosition(-500, -m_moon.width() / 2, -m_moon.height() / 2);
m_moon.setTexture("texture-moon_phases");
m_moon.setPhaseCount(8, 32);
@ -48,8 +48,8 @@ Skybox::Skybox(gk::Camera &camera, ClientWorld &world) : m_camera(camera), m_wor
for (int i = 0 ; i < 1000 ; ++i) {
auto &star = m_stars.emplace_back();
star.setColor(gk::Color{0, 0, 0, 0});
star.setSize(5, 5);
star.setPosition(600 * ((rand() % 2) * 2 - 1), (rand() % 500) * 2 - 500, (rand() % 500) * 2 - 500);
star.setSize(4, 4);
star.setPosition(650 * ((rand() % 2) * 2 - 1), (rand() % 500) * 2 - 500, (rand() % 500) * 2 - 500);
star.setRotationOffset(rand() % GameTime::dayLength);
star.setRotationAxis({rand() % 100 / 100.f, rand() % 100 / 100.f, rand() % 100 / 100.f});
}

View File

@ -35,7 +35,7 @@ class GameTime {
public:
static constexpr float daySpeed = 1.f;
static constexpr u32 dayLength = 24000;
static constexpr u32 dayStartOffset = 3000;
static constexpr u32 dayStartOffset = 0;
// Note: These 3 functions are only needed in the client
static float getCurrentTime(float offset = 0.f, float speed = 1.f);
@ -49,15 +49,15 @@ class GameTime {
static u64 getTicks() { return s_ticks; }
static u32 getCurrentDay() {
return (s_ticks + dayStartOffset + 3000.f) / 1000.f / 24 + 1;
return (s_ticks + dayStartOffset + 6000.f) / 1000.f / 24 + 1;
}
static u8 getCurrentHour() {
return u64((s_ticks + dayStartOffset + 3000.f) / 1000.f) % 24;
return u64((s_ticks + dayStartOffset + 6000.f) / 1000.f) % 24;
}
static u8 getCurrentMinute() {
return u64((s_ticks + dayStartOffset + 3000.f) / 1000.f * 60.0f) % 60;
return u64((s_ticks + dayStartOffset + 6000.f) / 1000.f * 60.0f) % 60;
}
private:

View File

@ -131,10 +131,10 @@ void ChatCommandHandler::timeCommand(const std::vector<std::string> &command, Cl
static const std::unordered_map<std::string, u64> values = {
{"day", 1000},
{"noon", 6000},
{"sunset", 12000},
{"sunset", 11000},
{"night", 13000},
{"midnight", 18000},
{"sunrise", 23000},
{"sunrise", 1000},
};
if (auto it = values.find(command.at(2)) ; it != values.end()) {
@ -150,7 +150,7 @@ void ChatCommandHandler::timeCommand(const std::vector<std::string> &command, Cl
m_server.sendChatMessage(0, "Time set to " + std::to_string(ticks), &client);
}
catch (std::out_of_range &e) {
catch (...) {
m_server.sendChatMessage(0, "Invalid time", &client);
}
}
@ -163,7 +163,7 @@ void ChatCommandHandler::timeCommand(const std::vector<std::string> &command, Cl
m_server.sendChatMessage(0, "Added " + std::to_string(ticks) + " to the time", &client);
}
catch (std::out_of_range &e) {
catch (...) {
m_server.sendChatMessage(0, "Invalid time", &client);
}
}
@ -185,7 +185,7 @@ void ChatCommandHandler::tpCommand(const std::vector<std::string> &command, Clie
m_server.sendChatMessage(0, "Teleported to " + std::to_string(x) + " " + std::to_string(y) + " " + std::to_string(z), &client);
}
catch (std::out_of_range &e) {
catch (...) {
m_server.sendChatMessage(0, "Invalid coordinates", &client);
}
}