Lowercase namespaces; move states to state/; cmd-based render groundwork
parent
85cb2a8623
commit
8f02acdf09
|
@ -1,6 +1,6 @@
|
|||
#include "AABB.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
template class AABB<>;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "platform/types/vec3.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
///
|
||||
/// @brief Axis-Aligned Bounding Box.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#define AUDIO_GC_DEBUG 0
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Sound.hpp"
|
||||
#include "SoundBuffer.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
|
|
|
@ -17,11 +17,9 @@ diggler_add_sources(
|
|||
${CSD}/Chunk.cpp
|
||||
${CSD}/Clouds.cpp
|
||||
${CSD}/Config.cpp
|
||||
${CSD}/ConnectingState.cpp
|
||||
${CSD}/EscMenu.cpp
|
||||
${CSD}/Frustum.cpp
|
||||
${CSD}/Game.cpp
|
||||
${CSD}/GameState.cpp
|
||||
${CSD}/GameWindow.cpp
|
||||
${CSD}/GLFWHandler.cpp
|
||||
${CSD}/GlobalProperties.cpp
|
||||
|
@ -31,7 +29,6 @@ diggler_add_sources(
|
|||
${CSD}/KeyBinds.cpp
|
||||
${CSD}/LocalPlayer.cpp
|
||||
${CSD}/main.cpp
|
||||
${CSD}/MessageState.cpp
|
||||
${CSD}/network/client/BlockUpdateHandler.cpp
|
||||
${CSD}/network/client/ChatHandler.cpp
|
||||
${CSD}/network/client/ChunkTransferHandler.cpp
|
||||
|
@ -60,13 +57,16 @@ diggler_add_sources(
|
|||
${CSD}/Skybox.cpp
|
||||
${CSD}/SoundBuffer.cpp
|
||||
${CSD}/Sound.cpp
|
||||
${CSD}/states/ConnectingState.cpp
|
||||
${CSD}/states/GameState.cpp
|
||||
${CSD}/states/MessageState.cpp
|
||||
${CSD}/states/UITestState.cpp
|
||||
${CSD}/Texture.cpp
|
||||
${CSD}/ui/Button.cpp
|
||||
${CSD}/ui/Element.cpp
|
||||
${CSD}/ui/Font.cpp
|
||||
${CSD}/ui/FontManager.cpp
|
||||
${CSD}/ui/Manager.cpp
|
||||
${CSD}/UITestState.cpp
|
||||
${CSD}/ui/Text.cpp
|
||||
${CSD}/Universe.cpp
|
||||
${CSD}/World.cpp
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtx/rotate_vector.hpp>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Camera::Camera() {
|
||||
m_worldUp = vec3(0, 1, 0);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Frustum.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Camera {
|
||||
friend class LocalPlayer;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Platform.hpp"
|
||||
#include <simplexnoise.h>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
CaveGenerator::GenConf::GenConf() :
|
||||
groundLevel(0.9), oreFactor(0.5) {
|
||||
|
@ -62,11 +62,11 @@ void CaveGenerator::Generate(WorldRef wr, const GenConf &gc, ChunkRef cr) {
|
|||
for (int y = 0; y < CY; ++y)
|
||||
for (int x = 0; x < CX; ++x)
|
||||
for (int z = 0; z < CZ; ++z)
|
||||
c.setBlock(x, y, z, y < 8 ? Content::BlockUnknownId : Content::BlockAirId);
|
||||
c.setBlock(x, y, z, y < 8 ? content::BlockUnknownId : content::BlockAirId);
|
||||
for (int y = CY; y > 8; --y)
|
||||
for (int x = 0; x < CX; ++x) {
|
||||
c.setBlock(x, y, 0, Content::BlockUnknownId);
|
||||
c.setBlock(x, y, CZ-1, Content::BlockUnknownId);
|
||||
c.setBlock(x, y, 0, content::BlockUnknownId);
|
||||
c.setBlock(x, y, CZ-1, content::BlockUnknownId);
|
||||
}*/
|
||||
|
||||
constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ;
|
||||
|
@ -78,9 +78,9 @@ void CaveGenerator::Generate(WorldRef wr, const GenConf &gc, ChunkRef cr) {
|
|||
for (int lz = 0; lz < CZ; ++lz) {
|
||||
int z = cp.z + lz;
|
||||
if (y >= -8) {
|
||||
c.setBlock(lx, ly, lz, y < raw_noise_3d(x/16.f, 0, z/16.f)*8 ? Content::BlockUnknownId : Content::BlockAirId);
|
||||
c.setBlock(lx, ly, lz, y < raw_noise_3d(x/16.f, 0, z/16.f)*8 ? content::BlockUnknownId : content::BlockAirId);
|
||||
} else {
|
||||
c.setBlock(lx, ly, lz, raw_noise_3d(x/16.f, y/16.f, z/16.f) > 0.7 ? Content::BlockAirId : Content::BlockUnknownId);
|
||||
c.setBlock(lx, ly, lz, raw_noise_3d(x/16.f, y/16.f, z/16.f) > 0.7 ? content::BlockAirId : content::BlockUnknownId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "World.hpp"
|
||||
#include "WorldGenerator.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class CaveGenerator : public WorldGenerator {
|
||||
private:
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
#include "render/gl/ProgramManager.hpp"
|
||||
#include "ui/Manager.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
const Render::gl::Program *Chatbox::RenderProgram = nullptr;
|
||||
const render::gl::Program *Chatbox::RenderProgram = nullptr;
|
||||
GLint Chatbox::RenderProgram_coord = -1;
|
||||
GLint Chatbox::RenderProgram_color = -1;
|
||||
GLint Chatbox::RenderProgram_mvp = -1;
|
||||
|
||||
Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G),
|
||||
m_posX(0), m_posY(0) {
|
||||
m_chatText = G->UIM->addManual<UI::Text>("", 2, 2);
|
||||
m_chatText = G->UIM->addManual<ui::Text>("", 2, 2);
|
||||
m_chatText->setPos(0, 0);
|
||||
if (RenderProgram == nullptr) {
|
||||
RenderProgram = G->PM->getProgram("2d", "color0");
|
||||
|
@ -35,7 +35,7 @@ Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G),
|
|||
{0.f, 100.f, 0.f, 0.f, 0.f, .5f}
|
||||
};
|
||||
m_vbo.setData(verts, 6);
|
||||
{ Render::gl::VAO::Config cfg = m_vao.configure();
|
||||
{ render::gl::VAO::Config cfg = m_vao.configure();
|
||||
cfg.vertexAttrib(m_vbo, RenderProgram_coord, 2, GL_FLOAT, sizeof(Vertex), 0);
|
||||
cfg.vertexAttrib(m_vbo, RenderProgram_color, 4, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, r));
|
||||
cfg.commit();
|
||||
|
@ -64,7 +64,7 @@ void Chatbox::addChatEntry(const std::string &text) {
|
|||
m_chatEntries.emplace_back();
|
||||
ChatEntry &entry = m_chatEntries.back();
|
||||
entry.date = system_clock::now();
|
||||
entry.text = G->UIM->addManual<UI::Text>(text);
|
||||
entry.text = G->UIM->addManual<ui::Text>(text);
|
||||
entry.height = entry.text->getSize().y;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include "render/gl/VBO.hpp"
|
||||
#include "ui/Text.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace Render {
|
||||
namespace render {
|
||||
namespace gl {
|
||||
class Program;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
using time_point = std::chrono::time_point<system_clock>;
|
||||
|
||||
private:
|
||||
static const Render::gl::Program *RenderProgram;
|
||||
static const render::gl::Program *RenderProgram;
|
||||
static GLint RenderProgram_coord, RenderProgram_color, RenderProgram_mvp;
|
||||
|
||||
bool m_isChatting;
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
struct ChatEntry {
|
||||
time_point date;
|
||||
int height;
|
||||
std::shared_ptr<UI::Text> text;
|
||||
std::shared_ptr<ui::Text> text;
|
||||
|
||||
~ChatEntry();
|
||||
};
|
||||
|
@ -44,12 +44,12 @@ private:
|
|||
// TODO: Update when libstdc++ supports locale codecvt facets
|
||||
//std::u32string m_chatString;
|
||||
std::string m_chatString;
|
||||
std::shared_ptr<UI::Text> m_chatText;
|
||||
std::shared_ptr<ui::Text> m_chatText;
|
||||
struct Vertex {
|
||||
float x, y, r, g, b, a;
|
||||
};
|
||||
Render::gl::VBO m_vbo;
|
||||
Render::gl::VAO m_vao;
|
||||
render::gl::VBO m_vbo;
|
||||
render::gl::VAO m_vao;
|
||||
int m_posX, m_posY;
|
||||
|
||||
public:
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#define SHOW_CHUNK_UPDATES 1
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
@ -52,7 +52,7 @@ void Chunk::ChangeHelper::add(int x, int y, int z) {
|
|||
m_changes.emplace_back(x, y, z);
|
||||
}
|
||||
|
||||
using Net::MsgTypes::BlockUpdateNotify;
|
||||
using net::MsgTypes::BlockUpdateNotify;
|
||||
void Chunk::ChangeHelper::flush(BlockUpdateNotify &bun) {
|
||||
for (glm::ivec3 &c : m_changes) {
|
||||
bun.updates.emplace_back();
|
||||
|
@ -284,7 +284,7 @@ void Chunk::updateClient() {
|
|||
imcUncompress();
|
||||
#endif
|
||||
mut.lock();
|
||||
Content::Registry &CR = *G->CR;
|
||||
content::Registry &CR = *G->CR;
|
||||
Vertex vertex[CX * CY * CZ * 6 /* faces */ * 4 /* vertices */ / 2 /* face removing (HSR) makes a lower vert max */];
|
||||
ushort idxOpaque[CX * CY * CZ * 6 /* faces */ * 6 /* indices */ / 2 /* HSR */],
|
||||
idxTransp[CX*CY*CZ*6*6/2];
|
||||
|
@ -299,8 +299,8 @@ void Chunk::updateClient() {
|
|||
bt = data->id[I(x,y,z)];
|
||||
|
||||
// Empty block?
|
||||
if (bt == Content::BlockAirId ||
|
||||
bt == Content::BlockIgnoreId)
|
||||
if (bt == content::BlockAirId ||
|
||||
bt == content::BlockIgnoreId)
|
||||
continue;
|
||||
|
||||
#if 0
|
||||
|
@ -429,7 +429,7 @@ void Chunk::updateClient() {
|
|||
mut.unlock();
|
||||
}
|
||||
|
||||
void Chunk::write(IO::OutStream &os) const {
|
||||
void Chunk::write(io::OutStream &os) const {
|
||||
const uint dataSize = Chunk::AllocaSize;
|
||||
uint compressedSize;
|
||||
byte *compressed = new byte[dataSize];
|
||||
|
@ -448,7 +448,7 @@ void Chunk::write(IO::OutStream &os) const {
|
|||
delete[] compressed;
|
||||
}
|
||||
|
||||
void Chunk::read(IO::InStream &is) {
|
||||
void Chunk::read(io::InStream &is) {
|
||||
uint compressedSize = is.readU16();
|
||||
const uint targetDataSize = Chunk::AllocaSize;
|
||||
byte *compressedData = new byte[compressedSize];
|
||||
|
|
|
@ -13,18 +13,18 @@
|
|||
#define CHUNK_INMEM_COMPRESS 1
|
||||
#define CHUNK_INMEM_COMPRESS_DELAY 2000 /* ms */
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class CaveGenerator;
|
||||
class Game;
|
||||
class World;
|
||||
using WorldRef = std::shared_ptr<World>;
|
||||
|
||||
namespace Render {
|
||||
namespace render {
|
||||
class WorldRenderer;
|
||||
}
|
||||
|
||||
namespace Net {
|
||||
namespace net {
|
||||
namespace MsgTypes {
|
||||
struct BlockUpdateNotify;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Chunk {
|
|||
private:
|
||||
friend World;
|
||||
friend CaveGenerator;
|
||||
friend class Render::WorldRenderer;
|
||||
friend class render::WorldRenderer;
|
||||
uintptr_t rendererData;
|
||||
|
||||
public:
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
void add(int x, int y, int z);
|
||||
bool empty() const;
|
||||
int count() const;
|
||||
void flush(Net::MsgTypes::BlockUpdateNotify&);
|
||||
void flush(net::MsgTypes::BlockUpdateNotify&);
|
||||
void discard();
|
||||
} CH;
|
||||
|
||||
|
@ -240,8 +240,8 @@ public:
|
|||
|
||||
/* ============ Serialization ============ */
|
||||
|
||||
void write(IO::OutStream&) const;
|
||||
void read(IO::InStream&);
|
||||
void write(io::OutStream&) const;
|
||||
void read(io::InStream&);
|
||||
};
|
||||
|
||||
using ChunkRef = std::shared_ptr<Chunk>;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "render/Renderer.hpp"
|
||||
#include "Texture.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Clouds::Renderer Clouds::R = {0};
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
#include "platform/Types.hpp"
|
||||
#include "render/gl/VBO.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
class Texture;
|
||||
|
||||
namespace Render {
|
||||
namespace render {
|
||||
namespace gl {
|
||||
class Program;
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ class Program;
|
|||
class Clouds {
|
||||
private:
|
||||
static struct Renderer {
|
||||
const Render::gl::Program *prog;
|
||||
const render::gl::Program *prog;
|
||||
GLint att_coord, att_texcoord, uni_mvp, uni_texshift;
|
||||
} R;
|
||||
std::vector<std::shared_ptr<Texture>> m_tex;
|
||||
Render::gl::VBO m_vbo;
|
||||
render::gl::VBO m_vbo;
|
||||
int m_layers;
|
||||
Game *G;
|
||||
struct Coord { uint8 x, y, z, u, v; };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Config.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Config::Config() {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define SETTINGS_HPP
|
||||
#include <string>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Config {
|
||||
private:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define ENTITY_HPP
|
||||
#include "Platform.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
#include "ui/Manager.hpp"
|
||||
#include "ui/Text.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
struct EscMenu::MenuEntryImpl {
|
||||
Area inputArea;
|
||||
std::shared_ptr<UI::Text> txtText;
|
||||
std::shared_ptr<ui::Text> txtText;
|
||||
};
|
||||
|
||||
EscMenu::EscMenu(UI::Manager *UIM) :
|
||||
UI::Element(UIM),
|
||||
EscMenu::EscMenu(ui::Manager *UIM) :
|
||||
ui::Element(UIM),
|
||||
G(UIM->G) {
|
||||
txtMenuTitle = G->UIM->addManual<UI::Text>(" Menu", 3, 3);
|
||||
txtMenuTitle = G->UIM->addManual<ui::Text>(" Menu", 3, 3);
|
||||
//m_button = new UIButton(G, glm::mat);
|
||||
for (int i=0;i<10;++i)
|
||||
addMenuEntry("hello " + std::to_string(i));
|
||||
|
@ -43,7 +43,7 @@ void EscMenu::refresh() {
|
|||
|
||||
void EscMenu::addMenuEntry(const std::string &text) {
|
||||
entries.emplace_back(MenuEntry { text, std::make_unique<MenuEntryImpl>() });
|
||||
entries.back().impl->txtText = G->UIM->addManual<UI::Text>(text, 2, 2);
|
||||
entries.back().impl->txtText = G->UIM->addManual<ui::Text>(text, 2, 2);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ void EscMenu::onInputAreaChanged() {
|
|||
}
|
||||
|
||||
void EscMenu::setVisible(bool v) {
|
||||
UI::Element::setVisible(v);
|
||||
ui::Element::setVisible(v);
|
||||
if (v) {
|
||||
m_transition.start = G->Time;
|
||||
m_transition.duration = .3;
|
||||
|
@ -89,7 +89,7 @@ void EscMenu::render(const glm::mat4 &baseMatrix) const {
|
|||
|
||||
const int width = renderArea().w;
|
||||
const int pxScroll = (1 - scroll) * width;
|
||||
G->UIM->drawRect(baseMatrix, UI::Element::Area { pxScroll, 0, width, renderArea().h },
|
||||
G->UIM->drawRect(baseMatrix, ui::Element::Area { pxScroll, 0, width, renderArea().h },
|
||||
glm::vec4(0.f, 0.f, 0.f, 0.8f));
|
||||
|
||||
int y = renderArea().h;
|
||||
|
|
|
@ -8,23 +8,23 @@
|
|||
#include "render/gl/Program.hpp"
|
||||
#include "ui/Element.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
namespace UI {
|
||||
namespace ui {
|
||||
class Button;
|
||||
class Text;
|
||||
}
|
||||
|
||||
class EscMenu : public UI::Element {
|
||||
class EscMenu : public ui::Element {
|
||||
private:
|
||||
Game *G;
|
||||
mutable struct {
|
||||
double start, duration;
|
||||
bool active;
|
||||
} m_transition;
|
||||
std::shared_ptr<UI::Text> txtMenuTitle;
|
||||
std::shared_ptr<UI::Button> m_button;
|
||||
std::shared_ptr<ui::Text> txtMenuTitle;
|
||||
std::shared_ptr<ui::Button> m_button;
|
||||
struct MenuEntryImpl;
|
||||
struct MenuEntry {
|
||||
std::string text;
|
||||
|
@ -35,7 +35,7 @@ private:
|
|||
void refresh();
|
||||
|
||||
public:
|
||||
EscMenu(UI::Manager*);
|
||||
EscMenu(ui::Manager*);
|
||||
~EscMenu();
|
||||
|
||||
void addMenuEntry(const std::string &text);
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
void setVisible(bool) override;
|
||||
|
||||
void render(const glm::mat4&) const override;
|
||||
using UI::Element::render;
|
||||
using ui::Element::render;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <cmath>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
void Frustum::setCamInternals(vec3vt rad, vec3vt ratio, vec3vt nearD, vec3vt farD) {
|
||||
this->ratio = ratio;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#undef NEAR
|
||||
#undef FAR
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Frustum {
|
||||
private:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "GLFWHandler.hpp"
|
||||
#include "GameWindow.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
void GLFWHandler::mouseButtonImpl(GLFWwindow *window, int key, int action, int mods) {
|
||||
(void)window;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class GameWindow;
|
||||
|
||||
|
|
27
src/Game.cpp
27
src/Game.cpp
|
@ -1,18 +1,19 @@
|
|||
#include "Game.hpp"
|
||||
|
||||
#include "Audio.hpp"
|
||||
#include "content/AssetManager.hpp"
|
||||
#include "content/ModManager.hpp"
|
||||
#include "content/Registry.hpp"
|
||||
#include "GlobalProperties.hpp"
|
||||
#include "KeyBinds.hpp"
|
||||
#include "LocalPlayer.hpp"
|
||||
#include "gfx/Device.hpp"
|
||||
#include "render/gl/ProgramManager.hpp"
|
||||
#include "render/gl/Renderer.hpp"
|
||||
#include "scripting/lua/State.hpp"
|
||||
#include "ui/FontManager.hpp"
|
||||
#include "Audio.hpp"
|
||||
#include "GlobalProperties.hpp"
|
||||
#include "KeyBinds.hpp"
|
||||
#include "LocalPlayer.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Game::Game() :
|
||||
C(nullptr),
|
||||
|
@ -35,9 +36,9 @@ Game::Game() :
|
|||
}
|
||||
|
||||
void Game::init() {
|
||||
AM = std::make_unique<Content::AssetManager>(this);
|
||||
MM = std::make_unique<Content::ModManager>(this);
|
||||
LS = new Scripting::Lua::State(this);
|
||||
AM = std::make_unique<content::AssetManager>(this);
|
||||
MM = std::make_unique<content::ModManager>(this);
|
||||
LS = new scripting::lua::State(this);
|
||||
if (GlobalProperties::IsClient) {
|
||||
initClient();
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ void Game::init() {
|
|||
}
|
||||
|
||||
void Game::initClient() {
|
||||
PM = new Render::gl::ProgramManager(*this);
|
||||
PM = new render::gl::ProgramManager(*this);
|
||||
LP = new LocalPlayer(this);
|
||||
RP = new RenderProperties; { // TODO move somewhere else?
|
||||
RP->bloom = true;
|
||||
|
@ -55,9 +56,9 @@ void Game::initClient() {
|
|||
RP->fogStart = 16;
|
||||
RP->fogEnd = 24;
|
||||
}
|
||||
R = new Render::gl::GLRenderer(this);
|
||||
CR = new Content::Registry(*this);
|
||||
FM = std::make_unique<UI::FontManager>(*this);
|
||||
R = new render::gl::GLRenderer(this);
|
||||
CR = new content::Registry(*this);
|
||||
FM = std::make_unique<ui::FontManager>(*this);
|
||||
A = new Audio(*this);
|
||||
KB = new KeyBinds;
|
||||
LP = new LocalPlayer(this);
|
||||
|
@ -65,7 +66,7 @@ void Game::initClient() {
|
|||
}
|
||||
|
||||
void Game::initServer() {
|
||||
CR = new Content::Registry(*this);
|
||||
CR = new content::Registry(*this);
|
||||
}
|
||||
|
||||
void Game::finalize() {
|
||||
|
|
37
src/Game.hpp
37
src/Game.hpp
|
@ -8,28 +8,32 @@
|
|||
|
||||
using std::shared_ptr;
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace Content {
|
||||
namespace content {
|
||||
class AssetManager;
|
||||
class ModManager;
|
||||
class Registry;
|
||||
}
|
||||
|
||||
namespace Render {
|
||||
namespace gfx {
|
||||
class Device;
|
||||
}
|
||||
|
||||
namespace render {
|
||||
class Renderer;
|
||||
namespace gl {
|
||||
class ProgramManager;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Scripting {
|
||||
namespace Lua {
|
||||
namespace scripting {
|
||||
namespace lua {
|
||||
class State;
|
||||
}
|
||||
}
|
||||
|
||||
namespace UI {
|
||||
namespace ui {
|
||||
class FontManager;
|
||||
class Manager;
|
||||
}
|
||||
|
@ -50,30 +54,31 @@ public:
|
|||
// Shared
|
||||
Config *C;
|
||||
double Time; uint64 TimeMs;
|
||||
Net::Host H;
|
||||
net::Host H;
|
||||
Universe *U;
|
||||
PlayerList players;
|
||||
Content::Registry *CR;
|
||||
ptr<Content::AssetManager> AM;
|
||||
ptr<Content::ModManager> MM;
|
||||
Scripting::Lua::State *LS;
|
||||
content::Registry *CR;
|
||||
ptr<content::AssetManager> AM;
|
||||
ptr<content::ModManager> MM;
|
||||
scripting::lua::State *LS;
|
||||
|
||||
// Server
|
||||
Server *S;
|
||||
|
||||
// Client
|
||||
ptr<gfx::Device> GD;
|
||||
GameWindow *GW;
|
||||
UI::Manager *UIM;
|
||||
ui::Manager *UIM;
|
||||
LocalPlayer *LP;
|
||||
Render::gl::ProgramManager *PM;
|
||||
Render::Renderer *R;
|
||||
ptr<UI::FontManager> FM;
|
||||
render::gl::ProgramManager *PM;
|
||||
render::Renderer *R;
|
||||
ptr<ui::FontManager> FM;
|
||||
struct RenderProperties {
|
||||
bool bloom, wavingLiquids;
|
||||
float fogStart, fogEnd;
|
||||
} *RP;
|
||||
Audio *A;
|
||||
Net::Peer *NS;
|
||||
net::Peer *NS;
|
||||
KeyBinds *KB;
|
||||
int PlayerPosUpdateFreq;
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "Game.hpp"
|
||||
#include "GlobalProperties.hpp"
|
||||
#include "GLFWHandler.hpp"
|
||||
#include "GameState.hpp"
|
||||
#include "MessageState.hpp"
|
||||
#include "states/GameState.hpp"
|
||||
#include "states/MessageState.hpp"
|
||||
#include "Audio.hpp"
|
||||
#include "ui/FontManager.hpp"
|
||||
#include "ui/Manager.hpp"
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include "util/Log.hpp"
|
||||
#include "util/MemoryTracker.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
@ -50,10 +50,10 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||
|
||||
m_w = 640; m_h = 480;
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API /*GLFW_OPENGL_ES_API*/);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere
|
||||
//glfwWindowHint(GLFW_STENCIL_BITS, 8);
|
||||
|
||||
|
@ -68,10 +68,10 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||
}
|
||||
glfwMakeContextCurrent(m_window);
|
||||
|
||||
Render::gl::OpenGL::init();
|
||||
render::gl::OpenGL::init();
|
||||
|
||||
#ifdef DEBUG
|
||||
Render::gl::Debug::enable();
|
||||
render::gl::Debug::enable();
|
||||
#endif
|
||||
glfwSetFramebufferSizeCallback(m_window, GLFWHandler::resize);
|
||||
glfwSetCursorPosCallback(m_window, GLFWHandler::cursorPos);
|
||||
|
@ -111,9 +111,9 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||
#endif
|
||||
;
|
||||
|
||||
auto glver = Render::gl::OpenGL::version();
|
||||
Log(Info, TAG) << Render::gl::OpenGL::loaderName() << ' ' <<
|
||||
Render::gl::OpenGL::loaderVersion() << " -- GL" <<
|
||||
auto glver = render::gl::OpenGL::version();
|
||||
Log(Info, TAG) << render::gl::OpenGL::loaderName() << ' ' <<
|
||||
render::gl::OpenGL::loaderVersion() << " -- GL" <<
|
||||
(glver.isGLES ? "ES" : "") << ' ' <<
|
||||
glver.major << '.' << glver.minor <<
|
||||
(glver.isCore ? " Core" : "") <<
|
||||
|
@ -127,7 +127,7 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||
}
|
||||
|
||||
{ Util::MemoryTracker::ScopedCategory sc(nullptr);
|
||||
UIM = new UI::Manager;
|
||||
UIM = new ui::Manager;
|
||||
UIM->onResize(m_w, m_h);
|
||||
|
||||
G->init();
|
||||
|
@ -203,7 +203,11 @@ void GameWindow::cbResize(int w, int h) {
|
|||
m_currentState->onResize(w, h);
|
||||
}
|
||||
|
||||
void GameWindow::setNextState(std::unique_ptr<State> &&next) {
|
||||
states::State& GameWindow::state() const {
|
||||
return *m_currentState;
|
||||
}
|
||||
|
||||
void GameWindow::setNextState(std::unique_ptr<states::State> &&next) {
|
||||
m_nextState = std::move(next);
|
||||
}
|
||||
|
||||
|
@ -230,7 +234,7 @@ void GameWindow::run() {
|
|||
}
|
||||
|
||||
void GameWindow::showMessage(const std::string &msg, const std::string &submsg) {
|
||||
setNextState(std::make_unique<MessageState>(this, msg, submsg));
|
||||
setNextState(std::make_unique<states::MessageState>(this, msg, submsg));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
#include "StateMachine.hpp"
|
||||
#include "Platform.hpp"
|
||||
#include "platform/Types.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
class State;
|
||||
|
||||
namespace UI {
|
||||
namespace ui {
|
||||
class Manager;
|
||||
}
|
||||
|
||||
|
@ -30,15 +30,15 @@ private:
|
|||
GLFWwindow *m_window;
|
||||
int m_w, m_h;
|
||||
|
||||
std::unique_ptr<State> m_currentState, m_nextState;
|
||||
std::unique_ptr<states::State> m_currentState, m_nextState;
|
||||
|
||||
public:
|
||||
UI::Manager *UIM;
|
||||
ui::Manager *UIM;
|
||||
|
||||
Game *G;
|
||||
|
||||
GameWindow(Game*);
|
||||
~GameWindow();
|
||||
~GameWindow() override;
|
||||
|
||||
operator GLFWwindow&() const { return *m_window; }
|
||||
operator GLFWwindow*() const { return m_window; }
|
||||
|
@ -60,7 +60,9 @@ public:
|
|||
|
||||
void updateViewport();
|
||||
|
||||
void setNextState(std::unique_ptr<State> &&next) override;
|
||||
states::State& state() const override;
|
||||
void setNextState(std::unique_ptr<states::State> &&next) override;
|
||||
|
||||
void run();
|
||||
|
||||
void showMessage(const std::string &msg, const std::string &submsg = "");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "GlobalProperties.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
bool GlobalProperties::IsClient = true;
|
||||
bool GlobalProperties::IsServer = false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef GLOBAL_PROPERTIES_HPP
|
||||
#define GLOBAL_PROPERTIES_HPP
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace GlobalProperties {
|
||||
extern bool IsClient;
|
||||
|
|
|
@ -7,7 +7,7 @@ using std::fwrite;
|
|||
using std::fread;
|
||||
using std::fclose;
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
KeyBinds::KeyBinds() {
|
||||
loadDefaults();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define KEY_BINDS_HPP
|
||||
#include <string>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class KeyBinds {
|
||||
public:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "render/gl/ProgramManager.hpp"
|
||||
#include "util/Log.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
@ -148,7 +148,7 @@ void LocalPlayer::update(float delta) {
|
|||
for (int cz = min.z; cz < max.z; ++cz) {
|
||||
blockBox.v1.z = cz; blockBox.v2.z = cz + 1;
|
||||
BlockId id = W->getBlockId(cx, cy, cz);
|
||||
if (id != Content::BlockAirId) {
|
||||
if (id != content::BlockAirId) {
|
||||
glm::vec3 normal;
|
||||
float d = plrBox.sweptCollision(blockBox, dtvel.x, dtvel.y, dtvel.z, normal.x, normal.y, normal.z);
|
||||
if (d < pdelta) {
|
||||
|
@ -210,10 +210,10 @@ void LocalPlayer::render(const glm::mat4 &transform) const {
|
|||
{ min.x, min.y, max.z, 0, 1, 0 },
|
||||
};
|
||||
vbo.setDataGrow(pts, sizeof(pts)/sizeof(Coord), GL_STREAM_DRAW);
|
||||
const Render::gl::Program &P = *G->PM->getProgram("3d", "color0");
|
||||
const render::gl::Program &P = *G->PM->getProgram("3d", "color0");
|
||||
if (!vaoConfigured) {
|
||||
vaoConfigured = true;
|
||||
Render::gl::VAO::Config cfg = vao.configure();
|
||||
render::gl::VAO::Config cfg = vao.configure();
|
||||
cfg.vertexAttrib(vbo, P.att("coord"), 3, GL_FLOAT, sizeof(Coord), 0);
|
||||
cfg.vertexAttrib(vbo, P.att("color"), 3, GL_UNSIGNED_BYTE, sizeof(Coord), offsetof(Coord, r));
|
||||
cfg.commit();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "render/gl/VAO.hpp"
|
||||
#include "render/gl/VBO.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
|
@ -20,8 +20,8 @@ private:
|
|||
bool hasGravity, hasNoclip, onGround, onRoad;
|
||||
|
||||
// debugging
|
||||
mutable Render::gl::VBO vbo;
|
||||
mutable Render::gl::VAO vao;
|
||||
mutable render::gl::VBO vbo;
|
||||
mutable render::gl::VAO vao;
|
||||
mutable bool vaoConfigured = false;
|
||||
|
||||
public:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Game.hpp"
|
||||
#include "render/Renderer.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
ParticleEmitter::ParticleEmitter(Game *G) :
|
||||
G(G) {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include <glm/vec4.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace Render {
|
||||
namespace render {
|
||||
class ParticlesRenderer;
|
||||
}
|
||||
class Game;
|
||||
|
@ -22,7 +22,7 @@ struct Particle {
|
|||
};
|
||||
|
||||
class ParticleEmitter {
|
||||
friend class Render::ParticlesRenderer;
|
||||
friend class render::ParticlesRenderer;
|
||||
uintptr_t rendererData;
|
||||
|
||||
Game *G;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "platform/Types.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
enum class PixelFormat : uint8 {
|
||||
RGB,
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
#include "util/Log.hpp"
|
||||
|
||||
using Diggler::Util::Log;
|
||||
using namespace Diggler::Util::Logging::LogLevels;
|
||||
using diggler::Util::Log;
|
||||
using namespace diggler::Util::Logging::LogLevels;
|
||||
|
||||
static const char *TAG = "Platform";
|
||||
|
||||
const char *Diggler::UserdataDirsName = "Diggler";
|
||||
const char *diggler::UserdataDirsName = "Diggler";
|
||||
|
||||
static struct PathCache {
|
||||
std::string
|
||||
|
@ -27,7 +27,7 @@ static struct PathCache {
|
|||
#include <windows.h>
|
||||
#include "platform/Fixes.hpp"
|
||||
|
||||
std::string Diggler::proc::getExecutablePath() {
|
||||
std::string diggler::proc::getExecutablePath() {
|
||||
if (pathCache.executableBin.length() == 0) {
|
||||
HMODULE hModule = GetModuleHandleW(NULL);
|
||||
WCHAR path[MAX_PATH];
|
||||
|
@ -39,7 +39,7 @@ std::string Diggler::proc::getExecutablePath() {
|
|||
return pathCache.executableBin;
|
||||
}
|
||||
|
||||
std::string Diggler::proc::getExecutableDirectory() {
|
||||
std::string diggler::proc::getExecutableDirectory() {
|
||||
if (pathCache.executableDir.length() == 0) {
|
||||
std::string filename(getExecutablePath());
|
||||
const size_t last_sep_idx = filename.rfind('\\');
|
||||
|
@ -53,7 +53,7 @@ std::string Diggler::proc::getExecutableDirectory() {
|
|||
return pathCache.executableDir;
|
||||
}
|
||||
|
||||
std::string Diggler::getCacheDirectory() {
|
||||
std::string diggler::getCacheDirectory() {
|
||||
if (pathCache.cacheDir.length() == 0) {
|
||||
WCHAR ucs2Path[MAX_PATH];
|
||||
SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path);
|
||||
|
@ -64,7 +64,7 @@ std::string Diggler::getCacheDirectory() {
|
|||
return pathCache.cacheDir;
|
||||
}
|
||||
|
||||
std::string Diggler::getConfigDirectory() {
|
||||
std::string diggler::getConfigDirectory() {
|
||||
if (pathCache.cacheDir.length() == 0) {
|
||||
WCHAR ucs2Path[MAX_PATH];
|
||||
SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path);
|
||||
|
@ -86,7 +86,7 @@ std::string do_readlink(const char *path);
|
|||
std::string do_readlink(const std::string &path);
|
||||
|
||||
#if defined(BUILDINFO_PLATFORM_LINUX)
|
||||
std::string Diggler::proc::getExecutablePath() {
|
||||
std::string diggler::proc::getExecutablePath() {
|
||||
if (pathCache.executableBin.length() == 0) {
|
||||
pid_t pid = getpid();
|
||||
// Assuming 32-bit pid -> max of 10 digits, we need only "/proc/xxxxxxxxxx/exe" space
|
||||
|
@ -100,7 +100,7 @@ std::string Diggler::proc::getExecutablePath() {
|
|||
// TODO: getExecutablePath for those without procfs
|
||||
#endif
|
||||
|
||||
std::string Diggler::proc::getExecutableDirectory() {
|
||||
std::string diggler::proc::getExecutableDirectory() {
|
||||
if (pathCache.executableDir.length() == 0) {
|
||||
std::string filename(getExecutablePath());
|
||||
const size_t last_slash_idx = filename.rfind('/');
|
||||
|
@ -114,7 +114,7 @@ std::string Diggler::proc::getExecutableDirectory() {
|
|||
return pathCache.executableDir;
|
||||
}
|
||||
|
||||
std::string Diggler::getCacheDirectory() {
|
||||
std::string diggler::getCacheDirectory() {
|
||||
if (pathCache.cacheDir.length() == 0) {
|
||||
const char *xdgCache = std::getenv("XDG_CACHE_HOME");
|
||||
if (xdgCache) {
|
||||
|
@ -126,7 +126,7 @@ std::string Diggler::getCacheDirectory() {
|
|||
return pathCache.cacheDir;
|
||||
}
|
||||
|
||||
std::string Diggler::getConfigDirectory() {
|
||||
std::string diggler::getConfigDirectory() {
|
||||
if (pathCache.configDir.length() == 0) {
|
||||
const char *xdgCache = std::getenv("XDG_CONFIG_HOME");
|
||||
if (xdgCache) {
|
||||
|
@ -148,7 +148,7 @@ std::string Diggler::getConfigDirectory() {
|
|||
|
||||
#endif
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
std::string getAssetsDirectory() {
|
||||
return proc::getExecutableDirectory() + "/assets";
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "platform/Math.hpp"
|
||||
#include "platform/Types.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace proc {
|
||||
/// @returns The executable's absolute path
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "render/gl/ProgramManager.hpp"
|
||||
#include "render/gl/VBO.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Player::Renderer Player::R = {};
|
||||
|
||||
|
@ -38,7 +38,7 @@ Player::Player(Game *G) :
|
|||
-sz, .0f, 0.0f,
|
||||
sz, szH, 0.0f,
|
||||
};
|
||||
R.vbo = std::make_unique<Render::gl::VBO>();
|
||||
R.vbo = std::make_unique<render::gl::VBO>();
|
||||
R.vbo->setData(coords, 6*3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "network/Network.hpp"
|
||||
#include "World.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace Render {
|
||||
namespace render {
|
||||
class PlayerRenderer;
|
||||
namespace gl {
|
||||
class Program;
|
||||
|
@ -29,17 +29,17 @@ using PlayerGameID = uint32;
|
|||
|
||||
class Player {
|
||||
protected:
|
||||
friend class Render::PlayerRenderer;
|
||||
friend class render::PlayerRenderer;
|
||||
uintptr_t rendererData;
|
||||
|
||||
static struct Renderer {
|
||||
const Render::gl::Program *prog;
|
||||
const render::gl::Program *prog;
|
||||
GLint att_coord,
|
||||
uni_mvp,
|
||||
uni_unicolor,
|
||||
uni_fogStart,
|
||||
uni_fogEnd;
|
||||
std::unique_ptr<Render::gl::VBO> vbo;
|
||||
std::unique_ptr<render::gl::VBO> vbo;
|
||||
} R;
|
||||
double m_lastPosTime;
|
||||
glm::vec3 m_predictPos;
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
using SessionID = uint32;
|
||||
SessionID sessId;
|
||||
bool isAlive;
|
||||
Net::Peer *peer;
|
||||
net::Peer *peer;
|
||||
std::list<ChunkRef> pendingChunks;
|
||||
|
||||
Player(Game *G = nullptr);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Game.hpp"
|
||||
#include "LocalPlayer.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
PlayerList::PlayerList(Game *G) : G(G) {
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ Player* PlayerList::getByName(const std::string &name) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Player* PlayerList::getByPeer(const Net::Peer &peer) {
|
||||
Player* PlayerList::getByPeer(const net::Peer &peer) {
|
||||
for (auto it = begin();
|
||||
it != end(); ++it) {
|
||||
if (*it->peer == peer) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
#include "Player.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
* @brief Gets a Player using its network peer object
|
||||
* @return Pointer to Player, may be nullptr if not found
|
||||
*/
|
||||
Player* getByPeer(const Net::Peer&);
|
||||
Player* getByPeer(const net::Peer&);
|
||||
|
||||
Player& add();
|
||||
void remove(const Player&);
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
using namespace Diggler::Net;
|
||||
using namespace diggler::net;
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
@ -135,8 +135,8 @@ void Server::handleDisconnect(Peer &peer) {
|
|||
handlePlayerQuit(peer, QuitReason::Timeout);
|
||||
}
|
||||
|
||||
void Server::handleContentMessage(Net::InMessage &msg, Net::Peer &peer) {
|
||||
using namespace Net::MsgTypes;
|
||||
void Server::handleContentMessage(net::InMessage &msg, net::Peer &peer) {
|
||||
using namespace net::MsgTypes;
|
||||
using S = ContentSubtype;
|
||||
switch (msg.getSubtype<MsgTypes::ContentSubtype>()) {
|
||||
case S::ModListRequest: {
|
||||
|
@ -152,7 +152,7 @@ void Server::handleContentMessage(Net::InMessage &msg, Net::Peer &peer) {
|
|||
}
|
||||
|
||||
void Server::handleChat(InMessage &msg, Player *plr) {
|
||||
using namespace Net::MsgTypes;
|
||||
using namespace net::MsgTypes;
|
||||
using S = ChatSubtype;
|
||||
switch (msg.getSubtype<S>()) {
|
||||
case S::Send: {
|
||||
|
@ -178,7 +178,7 @@ void Server::handleCommand(Player *plr, const std::string &command, const std::v
|
|||
}
|
||||
|
||||
void Server::handlePlayerUpdate(InMessage &msg, Player &plr) {
|
||||
using namespace Net::MsgTypes;
|
||||
using namespace net::MsgTypes;
|
||||
using S = PlayerUpdateSubtype;
|
||||
switch (msg.getSubtype<S>()) {
|
||||
case S::Move: {
|
||||
|
@ -207,9 +207,9 @@ void Server::schedSendChunk(ChunkRef C, Player &P) {
|
|||
}
|
||||
|
||||
void Server::sendChunks(const std::list<ChunkRef> &cs, Player &P) {
|
||||
using namespace Net::MsgTypes;
|
||||
using namespace net::MsgTypes;
|
||||
ChunkTransferResponse ctr;
|
||||
std::vector<IO::OutMemoryStream> chunkBufs(cs.size());
|
||||
std::vector<io::OutMemoryStream> chunkBufs(cs.size());
|
||||
size_t i = 0;
|
||||
for (const ChunkRef &cr : cs) {
|
||||
ctr.chunks.emplace_back();
|
||||
|
@ -228,7 +228,7 @@ void Server::sendChunks(const std::list<ChunkRef> &cs, Player &P) {
|
|||
}
|
||||
|
||||
void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) {
|
||||
using namespace Net::MsgTypes;
|
||||
using namespace net::MsgTypes;
|
||||
using S = ChunkTransferSubtype;
|
||||
switch (msg.getSubtype<S>()) {
|
||||
case S::Request: {
|
||||
|
@ -251,7 +251,7 @@ void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) {
|
|||
|
||||
void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
||||
// TODO: distance & tool check, i.e. legitimate update
|
||||
using namespace Net::MsgTypes;
|
||||
using namespace net::MsgTypes;
|
||||
using S = BlockUpdateSubtype;
|
||||
constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ;
|
||||
switch (msg.getSubtype<S>()) {
|
||||
|
@ -285,7 +285,7 @@ void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
|||
ChunkRef c = w->getChunkAtCoords(bub.pos);
|
||||
if (c) {
|
||||
c->setBlock(rmod(bub.pos.x, CX), rmod(bub.pos.y, CY), rmod(bub.pos.z, CZ),
|
||||
Content::BlockAirId, 0);
|
||||
content::BlockAirId, 0);
|
||||
if (!c->CH.empty()) {
|
||||
BlockUpdateNotify bun;
|
||||
c->CH.flush(bun);
|
||||
|
@ -300,7 +300,7 @@ void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
|||
}
|
||||
|
||||
void Server::handlePlayerDeath(InMessage &msg, Player &plr) {
|
||||
using namespace Net::MsgTypes;
|
||||
using namespace net::MsgTypes;
|
||||
PlayerUpdateDie pud;
|
||||
pud.readFromMsg(msg);
|
||||
pud.plrSessId = plr.sessId;
|
||||
|
@ -340,7 +340,7 @@ Server::Server(Game &G, uint16 port) : G(G) {
|
|||
|
||||
try {
|
||||
H.create(port);
|
||||
} catch (Net::Exception &e) {
|
||||
} catch (net::Exception &e) {
|
||||
Log(Error, TAG) << "Couldn't open port " << port << " for listening\n" <<
|
||||
"Make sure no other server instance is running";
|
||||
if (port <= 1024) {
|
||||
|
@ -392,7 +392,7 @@ void Server::chunkUpdater(WorldRef WR, bool &continueUpdate) {
|
|||
for (auto pair : W) {
|
||||
if ((c = pair.second.lock()) && !c->CH.empty()) {
|
||||
// TODO: view range
|
||||
Net::MsgTypes::BlockUpdateNotify bun;
|
||||
net::MsgTypes::BlockUpdateNotify bun;
|
||||
c->CH.flush(bun);
|
||||
OutMessage msg;
|
||||
bun.writeToMsg(msg);
|
||||
|
@ -481,7 +481,7 @@ bool Server::isPlayerOnline(const std::string &playername) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Server::kick(Player &p, Net::QuitReason r, const std::string &message) {
|
||||
void Server::kick(Player &p, net::QuitReason r, const std::string &message) {
|
||||
OutMessage msg(MessageType::PlayerQuit, r);
|
||||
msg.writeU32(p.sessId);
|
||||
msg.writeString(message);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
using std::unique_ptr;
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
|
@ -21,18 +21,18 @@ private:
|
|||
|
||||
void handleCommand(Player*, const std::string &command, const std::vector<std::string> &args);
|
||||
|
||||
void handlePlayerJoin(Net::InMessage&, Net::Peer&);
|
||||
void handlePlayerQuit(Net::Peer&, Net::QuitReason reason = Net::QuitReason::Quit);
|
||||
void handleDisconnect(Net::Peer&);
|
||||
void handlePlayerJoin(net::InMessage&, net::Peer&);
|
||||
void handlePlayerQuit(net::Peer&, net::QuitReason reason = net::QuitReason::Quit);
|
||||
void handleDisconnect(net::Peer&);
|
||||
|
||||
void handleContentMessage(Net::InMessage&, Net::Peer&);
|
||||
void handleContentMessage(net::InMessage&, net::Peer&);
|
||||
|
||||
void handleChat(Net::InMessage&, Player*);
|
||||
void handleChat(net::InMessage&, Player*);
|
||||
|
||||
void handlePlayerUpdate(Net::InMessage&, Player&);
|
||||
void handlePlayerDeath(Net::InMessage&, Player&);
|
||||
void handlePlayerChunkRequest(Net::InMessage&, Player&);
|
||||
void handlePlayerMapUpdate(Net::InMessage&, Player&);
|
||||
void handlePlayerUpdate(net::InMessage&, Player&);
|
||||
void handlePlayerDeath(net::InMessage&, Player&);
|
||||
void handlePlayerChunkRequest(net::InMessage&, Player&);
|
||||
void handlePlayerMapUpdate(net::InMessage&, Player&);
|
||||
|
||||
void schedSendChunk(ChunkRef, Player&);
|
||||
void sendChunks(const std::list<ChunkRef>&, Player&);
|
||||
|
@ -40,7 +40,7 @@ private:
|
|||
void chunkUpdater(WorldRef WR, bool &continueUpdate);
|
||||
|
||||
public:
|
||||
Net::Host H;
|
||||
net::Host H;
|
||||
|
||||
Server(Game &G, uint16 port);
|
||||
~Server();
|
||||
|
@ -53,9 +53,9 @@ public:
|
|||
bool isPlayerOnline(const std::string &playername) const;
|
||||
bool isIPOnline(const std::string &ip) const;
|
||||
Player* getPlayerBySessId(uint32 id);
|
||||
Player* getPlayerByPeer(const Net::Peer &peer);
|
||||
Player* getPlayerByPeer(const net::Peer &peer);
|
||||
Player* getPlayerByName(const std::string &name);
|
||||
void kick(Player &p, Net::QuitReason r = Net::QuitReason::Kicked, const std::string& message = "");
|
||||
void kick(Player &p, net::QuitReason r = net::QuitReason::Kicked, const std::string& message = "");
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "render/gl/ProgramManager.hpp"
|
||||
#include "Texture.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
const Render::gl::Program *Skybox::RenderProgram = nullptr;
|
||||
const render::gl::Program *Skybox::RenderProgram = nullptr;
|
||||
GLint Skybox::RenderProgram_attrib_texcoord = -1;
|
||||
GLint Skybox::RenderProgram_attrib_coord = -1;
|
||||
GLint Skybox::RenderProgram_uni_mvp = -1;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "render/gl/VBO.hpp"
|
||||
#include "Game.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
namespace Render {
|
||||
namespace render {
|
||||
namespace gl {
|
||||
class Program;
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ class Texture;
|
|||
|
||||
class Skybox {
|
||||
private:
|
||||
static const Render::gl::Program *RenderProgram;
|
||||
static const render::gl::Program *RenderProgram;
|
||||
static GLint RenderProgram_attrib_coord, RenderProgram_attrib_texcoord, RenderProgram_uni_mvp;
|
||||
Render::gl::VBO m_vbo;
|
||||
render::gl::VBO m_vbo;
|
||||
Texture *m_top, *m_w, *m_e, *m_n, *m_s, *m_bottom;
|
||||
Game *G;
|
||||
struct Coord { int8 x, y, z, u, v; };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Sound.hpp"
|
||||
#include "Platform.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Sound::Sound(const SoundBuffer *buffer) : buffer(buffer), createdRelative(true) {
|
||||
alGenSources(1, &id);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "SoundBuffer.hpp"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Sound {
|
||||
private:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "platform/Types.hpp"
|
||||
#include "util/Log.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <AL/al.h>
|
||||
#include <string>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class SoundBuffer {
|
||||
private:
|
||||
|
|
|
@ -3,13 +3,16 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "State.hpp"
|
||||
#include "states/State.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class StateMachine {
|
||||
public:
|
||||
virtual void setNextState(std::unique_ptr<State> &&next) = 0;
|
||||
virtual ~StateMachine() {}
|
||||
|
||||
virtual states::State& state() const = 0;
|
||||
virtual void setNextState(std::unique_ptr<states::State> &&next) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Texture.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
uint Texture::requiredBufferSize() {
|
||||
uint texelSize;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// TODO: remove me
|
||||
#include "render/gl/OpenGL.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Universe.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
Universe::Universe(Game *G, bool remote) :
|
||||
G(G), isRemote(remote) {
|
||||
|
@ -33,7 +33,7 @@ WorldRef Universe::createWorld(WorldId id) {
|
|||
return w;
|
||||
}
|
||||
|
||||
void Universe::recv(Net::InMessage &msg) {
|
||||
void Universe::recv(net::InMessage &msg) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <map>
|
||||
#include "World.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using UniverseWorldMap = std::map<WorldId, WorldWeakRef>;
|
||||
|
||||
|
@ -47,10 +47,10 @@ public:
|
|||
|
||||
/* ============ Serialization ============ */
|
||||
|
||||
void write(IO::OutStream&) const;
|
||||
void read(IO::InStream&);
|
||||
void write(io::OutStream&) const;
|
||||
void read(io::InStream&);
|
||||
|
||||
void recv(Net::InMessage&);
|
||||
void recv(net::InMessage&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DIGGLER_VERSION_INFO_HPP
|
||||
#define DIGGLER_VERSION_INFO_HPP
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
const char* VersionString = "0.1.0";
|
||||
int VersionMajor = 0;
|
||||
int VersionMinor = 1;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "Universe.hpp"
|
||||
#include "util/Log.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
@ -156,7 +156,7 @@ BlockId World::getBlockId(int x, int y, int z) {
|
|||
return cr->getBlockId(rmod(x, CX), rmod(y, CY), rmod(z, CZ));
|
||||
}
|
||||
}
|
||||
return Content::BlockIgnoreId;
|
||||
return content::BlockIgnoreId;
|
||||
}
|
||||
|
||||
BlockData World::getBlockData(int x, int y, int z) {
|
||||
|
@ -191,7 +191,7 @@ bool World::raytrace(glm::vec3 pos, glm::vec3 dir, float range, glm::ivec3 *poin
|
|||
do {
|
||||
BlockId testBlock = getBlockId(xPos, yPos, zPos);
|
||||
/// @todo Actual block non-solidity (cursorwise) check
|
||||
if (testBlock != Content::BlockAirId) {
|
||||
if (testBlock != content::BlockAirId) {
|
||||
if (pointed)
|
||||
*pointed = glm::ivec3(xPos, yPos, zPos);
|
||||
if (facing)
|
||||
|
@ -308,7 +308,7 @@ void World::refresh() {
|
|||
c->markAsDirty();
|
||||
}
|
||||
|
||||
void World::write(IO::OutStream &msg) const {
|
||||
void World::write(io::OutStream &msg) const {
|
||||
const void *chunkData = nullptr;
|
||||
const uint dataSize = Chunk::AllocaSize;
|
||||
uint compressedSize;
|
||||
|
@ -336,7 +336,7 @@ void World::write(IO::OutStream &msg) const {
|
|||
delete[] compressed;
|
||||
}
|
||||
|
||||
void World::read(IO::InStream &M) {
|
||||
void World::read(io::InStream &M) {
|
||||
int bytesRead = 0;
|
||||
uint size = M.readU16();
|
||||
for (uint n=0; n < size; ++n) {
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "network/Network.hpp"
|
||||
#include "Particles.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
namespace Net {
|
||||
namespace net {
|
||||
class InMessage;
|
||||
class OutMessage;
|
||||
}
|
||||
|
@ -165,10 +165,10 @@ public:
|
|||
|
||||
/* ============ Serialization ============ */
|
||||
|
||||
void write(IO::OutStream&) const;
|
||||
void read(IO::InStream&);
|
||||
void send(Net::OutMessage&) const;
|
||||
void recv(Net::InMessage&);
|
||||
void write(io::OutStream&) const;
|
||||
void read(io::InStream&);
|
||||
void send(net::OutMessage&) const;
|
||||
void recv(net::InMessage&);
|
||||
};
|
||||
|
||||
using WorldRef = std::shared_ptr<World>;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class World;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include "AssetManager.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
Asset::Asset(const std::shared_ptr<AssetContentMetadata> &acm) :
|
||||
m_contentMetadata(acm) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "../crypto/SHA256.hpp"
|
||||
#include "AssetContentMetadata.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
class AssetManager;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include <goodform/variant.hpp>
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
AssetContentMetadata::AssetContentMetadata(AssetManager &am) :
|
||||
m_assetManager(am) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "../crypto/SHA256.hpp"
|
||||
#include "../platform/Types.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
class AssetManager;
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "../Game.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
AssetManager::AssetManager(Game *G) :
|
||||
G(G) {
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#include "Asset.hpp"
|
||||
#include "Mod.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
namespace Content {
|
||||
namespace content {
|
||||
|
||||
class AssetManager final {
|
||||
private:
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#include "../util/TexturePacker.hpp"
|
||||
//#include "../AABB.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
class BlockDef : public ObjectDef {
|
||||
public:
|
||||
struct Appearance {
|
||||
Variability variability;
|
||||
struct Texture {
|
||||
Diggler::Texture *tex;
|
||||
diggler::Texture *tex;
|
||||
Util::TexturePacker::Coord coord;
|
||||
std::vector<Util::TexturePacker::Coord> divCoords;
|
||||
struct Repeat {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
using BlockId = uint16;
|
||||
using BlockData = uint16;
|
||||
|
@ -36,7 +36,7 @@ struct LightData {
|
|||
static_assert(sizeof(LightData) == 2, "LightData has extra padding");
|
||||
static_assert(std::is_pod<LightData>::value, "LightData is not POD");
|
||||
|
||||
namespace Content {
|
||||
namespace content {
|
||||
const BlockId BlockAirId = 0;
|
||||
const BlockId BlockIgnoreId = std::numeric_limits<BlockData>::max();
|
||||
const BlockId BlockUnknownId = 1;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "../Platform.hpp"
|
||||
#include "../crypto/Sign.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
union ModId {
|
||||
struct Parts {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "../Game.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
ModManager::ModManager(Game *G) :
|
||||
G(G) {
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include "Mod.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
namespace Content {
|
||||
namespace content {
|
||||
|
||||
class ModManager final {
|
||||
private:
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define DIGGLER_CONTENT_OBJECT_DEF_HPP
|
||||
#include "../Platform.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
class ObjectDef {
|
||||
public:
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#define PRINT_BLOCK_REGISTRATIONS 1
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
|
||||
using Util::Log;
|
||||
using namespace Util::Logging::LogLevels;
|
||||
|
@ -82,7 +82,7 @@ static const DefBlocksInfo DefBlocksInfos[] = {
|
|||
};
|
||||
|
||||
bool Registry::isTransparent(BlockId id) const {
|
||||
if (id == Content::BlockAirId)
|
||||
if (id == content::BlockAirId)
|
||||
return true;
|
||||
return false;
|
||||
// TODO return getBlockDef(id).isTransparent;
|
||||
|
@ -98,7 +98,7 @@ bool Registry::isFaceVisible(BlockId id1, BlockId id2) const {
|
|||
}
|
||||
|
||||
bool Registry::canEntityGoThrough(BlockId id/* , Entity& ent*/) const {
|
||||
if (id == Content::BlockAirId)
|
||||
if (id == content::BlockAirId)
|
||||
return true;
|
||||
return false;
|
||||
/*return (t == BlockType::TransRed && team == Player::Team::Red) ||
|
||||
|
@ -110,13 +110,13 @@ static Coord unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8;
|
|||
#define AddTex(b, t) Coord b = m_texturePacker->add(getAssetPath("blocks", t));
|
||||
Registry::Registry(Game &G) :
|
||||
m_atlas(nullptr),
|
||||
m_nextMaxBlockId(Content::BlockUnknownId + 1) {
|
||||
{ Registry::BlockRegistration br(registerBlock(Content::BlockAirId, "air"));
|
||||
m_nextMaxBlockId(content::BlockUnknownId + 1) {
|
||||
{ Registry::BlockRegistration br(registerBlock(content::BlockAirId, "air"));
|
||||
br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden;
|
||||
br.def.phys.hasCollision = false;
|
||||
br.commit();
|
||||
}
|
||||
{ Registry::BlockRegistration br(registerBlock(Content::BlockUnknownId, "unknown"));
|
||||
{ Registry::BlockRegistration br(registerBlock(content::BlockUnknownId, "unknown"));
|
||||
br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden;
|
||||
br.def.phys.hasCollision = true;
|
||||
br.commit();
|
||||
|
@ -158,7 +158,7 @@ Util::TexturePacker::Coord Registry::addTexture(const std::string &texName,
|
|||
|
||||
const Util::TexturePacker::Coord* Registry::blockTexCoord(BlockId t, FaceDirection d,
|
||||
const glm::ivec3 &pos) const {
|
||||
if (t == Content::BlockUnknownId) {
|
||||
if (t == content::BlockUnknownId) {
|
||||
const Coord *unk[] = {
|
||||
&unk1, &unk2, &unk3, &unk4, &unk5, &unk6, &unk7, &unk8
|
||||
};
|
||||
|
@ -226,7 +226,7 @@ Registry::BlockRegistration Registry::registerBlock(BlockId id, const char *name
|
|||
}
|
||||
|
||||
Registry::BlockRegistration Registry::registerBlock(const char *name) {
|
||||
BlockId id = Content::BlockUnknownId;
|
||||
BlockId id = content::BlockUnknownId;
|
||||
if (m_freedBlockIds.empty()) {
|
||||
id = m_nextMaxBlockId;
|
||||
++m_nextMaxBlockId;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "../Texture.hpp"
|
||||
#include "../util/TexturePacker.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
enum class FaceDirection : uint8_t {
|
||||
XInc = 0,
|
||||
|
@ -24,7 +24,7 @@ enum class FaceDirection : uint8_t {
|
|||
|
||||
class Game;
|
||||
|
||||
namespace Content {
|
||||
namespace content {
|
||||
|
||||
class Registry {
|
||||
public:
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "../../../../util/StringUtil.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Font {
|
||||
namespace Formats {
|
||||
namespace BDF {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "../../platform/FourCC.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
|
||||
using Format = FourCC;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#include "formats/png/PNGLoader.hpp"
|
||||
#include "formats/ImageLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
|
||||
ImageLoader::Loading::Loading(std::unique_ptr<IO::InStream> &&stream, const LoadParams &lp) :
|
||||
ImageLoader::Loading::Loading(std::unique_ptr<io::InStream> &&stream, const LoadParams &lp) :
|
||||
stream(std::move(stream)),
|
||||
loadParams(lp),
|
||||
w(0),
|
||||
|
@ -40,7 +40,7 @@ std::shared_ptr<ImageLoader::Loading> ImageLoader::load(Format format, const std
|
|||
}
|
||||
|
||||
std::shared_ptr<ImageLoader::Loading> ImageLoader::load(Format format,
|
||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) {
|
||||
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) {
|
||||
return getFormatLoader(format)->load(format, std::move(stream), pixFormat, lp);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "../../PixelFormat.hpp"
|
||||
#include "ImageFormat.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
|
||||
class ImageLoader final {
|
||||
|
@ -60,12 +60,12 @@ public:
|
|||
|
||||
class Loading {
|
||||
protected:
|
||||
Loading(std::unique_ptr<IO::InStream>&&, const LoadParams&);
|
||||
Loading(std::unique_ptr<io::InStream>&&, const LoadParams&);
|
||||
|
||||
public:
|
||||
virtual ~Loading();
|
||||
|
||||
std::unique_ptr<IO::InStream> stream;
|
||||
std::unique_ptr<io::InStream> stream;
|
||||
LoadParams loadParams;
|
||||
uint w, h;
|
||||
byte *pixels;
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
static std::shared_ptr<Loading> load(Format, const std::string &path, PixelFormat pixFormat,
|
||||
const LoadParams&);
|
||||
|
||||
static std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
||||
static std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||
PixelFormat pixFormat, const LoadParams&);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ImageLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "../../../PixelFormat.hpp"
|
||||
#include "../ImageLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
virtual std::shared_ptr<Loading> load(Format, const std::string &path, PixelFormat pixFormat,
|
||||
const LoadParams&) const = 0;
|
||||
|
||||
virtual std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
||||
virtual std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||
PixelFormat pixFormat, const LoadParams&) const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,30 +4,30 @@
|
|||
|
||||
#include <stb_image.h>
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
|
||||
static int stream_read(void *user, char *data, int size) {
|
||||
IO::InStream &stream = *reinterpret_cast<IO::InStream*>(user);
|
||||
io::InStream &stream = *reinterpret_cast<io::InStream*>(user);
|
||||
stream.readData(data, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
static void stream_skip(void *user, int n) {
|
||||
IO::InStream &stream = *reinterpret_cast<IO::InStream*>(user);
|
||||
io::InStream &stream = *reinterpret_cast<io::InStream*>(user);
|
||||
stream.skip(n);
|
||||
}
|
||||
|
||||
static int stream_eof(void *user) {
|
||||
IO::InStream &stream = *reinterpret_cast<IO::InStream*>(user);
|
||||
io::InStream &stream = *reinterpret_cast<io::InStream*>(user);
|
||||
return stream.eos();
|
||||
}
|
||||
|
||||
class STBILoading final : public STBImageLoader::Loading {
|
||||
public:
|
||||
STBILoading(std::unique_ptr<IO::InStream> &&stream, const ImageLoader::LoadParams &lp) :
|
||||
STBILoading(std::unique_ptr<io::InStream> &&stream, const ImageLoader::LoadParams &lp) :
|
||||
Loading(std::move(stream), lp) {
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ STBILoading::~STBILoading() {
|
|||
}
|
||||
|
||||
std::shared_ptr<STBImageLoader::Loading> STBImageLoader::load(Format format,
|
||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
auto loading = std::make_shared<STBILoading>(std::move(stream), lp);
|
||||
loading->thread = std::thread([pixFormat, loading]() {
|
||||
stbi_io_callbacks cbs;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "../../../io/FileStream.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
|
||||
|
@ -17,10 +17,10 @@ class STBImageLoader final : public ImageLoader {
|
|||
public:
|
||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||
const LoadParams &lp) const override {
|
||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
||||
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||
}
|
||||
|
||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream, PixelFormat format,
|
||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream, PixelFormat format,
|
||||
const LoadParams&) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "FLIFLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace FLIF {
|
||||
|
||||
std::shared_ptr<FLIFLoader::Loading> FLIFLoader::load(Format format,
|
||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include "../../../../io/FileStream.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace FLIF {
|
||||
|
@ -15,10 +15,10 @@ class FLIFLoader final : public ImageLoader {
|
|||
public:
|
||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||
const LoadParams &lp) const override {
|
||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
||||
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||
}
|
||||
|
||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||
PixelFormat pixFormat, const LoadParams&) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "JPEGLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace JPEG {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include "../../../../io/FileStream.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace JPEG {
|
||||
|
@ -15,10 +15,10 @@ class JPEGLoader final : public ImageLoader {
|
|||
public:
|
||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||
const LoadParams &lp) const override {
|
||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
||||
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||
}
|
||||
|
||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||
PixelFormat pixFormat, const LoadParams&) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
#include "../STBImageLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace JPEG {
|
||||
|
||||
std::shared_ptr<JPEGLoader::Loading> JPEGLoader::load(Format format,
|
||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
return STBImageLoader().load(format, std::move(stream), pixFormat, lp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "PNGLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace PNG {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include "../../../../io/FileStream.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace PNG {
|
||||
|
@ -15,10 +15,10 @@ class PNGLoader final : public ImageLoader {
|
|||
public:
|
||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||
const LoadParams &lp) const override {
|
||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
||||
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||
}
|
||||
|
||||
std::shared_ptr<Loading> load(Format format, std::unique_ptr<IO::InStream> &&stream,
|
||||
std::shared_ptr<Loading> load(Format format, std::unique_ptr<io::InStream> &&stream,
|
||||
PixelFormat pixFormat, const LoadParams&) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
#include "../STBImageLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Image {
|
||||
namespace Formats {
|
||||
namespace PNG {
|
||||
|
||||
std::shared_ptr<PNGLoader::Loading> PNGLoader::load(Format format,
|
||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||
return STBImageLoader().load(format, std::move(stream), pixFormat, lp);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "../../render/Renderer.hpp"
|
||||
#include "../../util/ColorUtil.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace Content {
|
||||
namespace diggler {
|
||||
namespace content {
|
||||
namespace Texture {
|
||||
|
||||
using Loading = TextureLoader::Loading;
|
||||
|
@ -57,7 +57,7 @@ std::shared_ptr<Loading> TextureLoader::load(Game &G, Image::Format format, cons
|
|||
}
|
||||
|
||||
std::shared_ptr<Loading> TextureLoader::load(Game &G, Image::Format format,
|
||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat) {
|
||||
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat) {
|
||||
LoadParams lp = getLoadParams(pixFormat);
|
||||
std::shared_ptr<Loading> l = std::make_shared<Loading>();
|
||||
lp.userdata = l;
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "../../Texture.hpp"
|
||||
#include "../image/ImageLoader.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
|
||||
class Game;
|
||||
|
||||
namespace Content {
|
||||
namespace content {
|
||||
namespace Texture {
|
||||
|
||||
class TextureLoader {
|
||||
|
@ -20,13 +20,13 @@ public:
|
|||
using LoadParams = Image::ImageLoader::LoadParams;
|
||||
|
||||
std::shared_ptr<Image::ImageLoader::Loading> imageLoading;
|
||||
std::shared_ptr<Diggler::Texture> texture;
|
||||
std::shared_ptr<diggler::Texture> texture;
|
||||
};
|
||||
|
||||
static std::shared_ptr<Loading> load(Game&, Image::Format, const std::string &path,
|
||||
PixelFormat pixFormat);
|
||||
|
||||
static std::shared_ptr<Loading> load(Game&, Image::Format, std::unique_ptr<IO::InStream> &&stream,
|
||||
static std::shared_ptr<Loading> load(Game&, Image::Format, std::unique_ptr<io::InStream> &&stream,
|
||||
PixelFormat pixFormat);
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <sodium.h>
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
namespace Crypto {
|
||||
|
||||
template<size_t B>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "CryptoData.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
namespace Crypto {
|
||||
namespace DiffieHellman {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "CryptoData.hpp"
|
||||
#include "../platform/Types.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
namespace Crypto {
|
||||
namespace Random {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "CryptoData.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
namespace Crypto {
|
||||
|
||||
struct SHA256 {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "CryptoData.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
namespace Crypto {
|
||||
namespace Sign {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DIGGLER_CRYPTO_SODIUM_HPP
|
||||
#define DIGGLER_CRYPTO_SODIUM_HPP
|
||||
|
||||
namespace Diggler {
|
||||
namespace diggler {
|
||||
namespace Crypto {
|
||||
|
||||
class Sodium {
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef DIGGLER_GFX_COMMAND_HPP
|
||||
#define DIGGLER_GFX_COMMAND_HPP
|
||||
|
||||
#include <future>
|
||||
|
||||
#include "../platform/Types.hpp"
|
||||
|
||||
namespace diggler {
|
||||
namespace gfx {
|
||||
|
||||
struct Command {
|
||||
enum class Class : uint8 {
|
||||
CommandBuffer,
|
||||
RenderPass,
|
||||
Framebuffer,
|
||||
ShaderModule,
|
||||
Pipeline,
|
||||
Buffer,
|
||||
Texture,
|
||||
Clear,
|
||||
Draw,
|
||||
} klass;
|
||||
uint8 cmd;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct ReturnCommand : public Command {
|
||||
std::promise<T> returnValue;
|
||||
};
|
||||
|
||||
namespace cmd {
|
||||
struct Draw : public Command {
|
||||
enum class Opacity {
|
||||
Opaque,
|
||||
Translucent,
|
||||
Transparent
|
||||
} opacity = Opacity::Opaque; // Reorderability
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DIGGLER_GFX_COMMAND_HPP */
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef DIGGLER_GFX_DEVICE_HPP
|
||||
#define DIGGLER_GFX_DEVICE_HPP
|
||||
|
||||
#include "Command.hpp"
|
||||
|
||||
namespace diggler {
|
||||
namespace gfx {
|
||||
|
||||
class Device {
|
||||
public:
|
||||
virtual ~Device() = 0;
|
||||
|
||||
virtual void queue(Command&&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DIGGLER_GFX_DEVICE_HPP */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue