Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 17, 2020
1 parent 22552da commit 886aba1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions source/client/graphics/Skybox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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});
}
Expand Down
8 changes: 4 additions & 4 deletions source/common/core/GameTime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions source/server/network/ChatCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 886aba1

Please sign in to comment.