Fix windows build

Signed-off-by: Nicole Collings <100Toby1@gmail.com>
master
Jordan Snelling 2020-02-29 02:14:02 +00:00 committed by Nicole Collings
parent 338cae6a1e
commit 37f20b9978
15 changed files with 54 additions and 27 deletions

View File

@ -43,7 +43,7 @@ struct BlockModel {
{{0, 1, 1}, {}, {1, 0}, {1, 0}},
{{0, 1, 0}, {}, {0, 0}, {0, 0}}};
indices = {0, 1, 2, 2, 3, 0};
accessInd = std::max(0, std::min(static_cast<int>(textureRefs.size() - 1), 2));
accessInd = (std::max)(0, (std::min)(static_cast<int>(textureRefs.size() - 1), 2));
MeshPart leftMeshPart(vertices, indices, textureRefs[accessInd], blendInds[accessInd], blendMaskRefs[accessInd]);
blockModel.parts[static_cast<int>(Dir::LEFT)].push_back(leftMeshPart);
@ -54,7 +54,7 @@ struct BlockModel {
{{1, 0, 0}, {}, {0, 1}, {0, 1}},
{{1, 1, 0}, {}, {0, 0}, {0, 0}}};
indices = {0, 1, 2, 2, 3, 0};
accessInd = std::max(0, std::min(static_cast<int>(textureRefs.size() - 1), 3));
accessInd = (std::max)(0, (std::min)(static_cast<int>(textureRefs.size() - 1), 3));
MeshPart rightMeshPart(vertices, indices, textureRefs[accessInd], blendInds[accessInd], blendMaskRefs[accessInd]);
blockModel.parts[static_cast<int>(Dir::RIGHT)].push_back(rightMeshPart);
@ -65,7 +65,7 @@ struct BlockModel {
{{1, 1, 1}, {}, {1, 1}, {1, 1}},
{{1, 1, 0}, {}, {1, 0}, {1, 0}}};
indices = {0, 1, 2, 2, 3, 0};
accessInd = std::max(0, std::min(static_cast<int>(textureRefs.size() - 1), 0));
accessInd = (std::max)(0, (std::min)(static_cast<int>(textureRefs.size() - 1), 0));
MeshPart topMeshPart(vertices, indices, textureRefs[accessInd], blendInds[accessInd], blendMaskRefs[accessInd]);
blockModel.parts[static_cast<int>(Dir::TOP)].push_back(topMeshPart);
@ -76,7 +76,7 @@ struct BlockModel {
{{1, 0, 1}, {}, {1, 1}, {1, 1}},
{{0, 0, 1}, {}, {0, 1}, {0, 1}}};
indices = {0, 1, 2, 2, 3, 0};
accessInd = std::max(0, std::min(static_cast<int>(textureRefs.size() - 1), 1));
accessInd = (std::max)(0, (std::min)(static_cast<int>(textureRefs.size() - 1), 1));
MeshPart bottomMeshPart(vertices, indices, textureRefs[accessInd], blendInds[accessInd], blendMaskRefs[accessInd]);
blockModel.parts[static_cast<int>(Dir::BOTTOM)].push_back(bottomMeshPart);
@ -87,7 +87,7 @@ struct BlockModel {
{{1, 1, 1}, {}, {1, 0}, {1, 0}},
{{0, 1, 1}, {}, {0, 0}, {0, 0}}};
indices = {0, 1, 2, 2, 3, 0};
accessInd = std::max(0, std::min(static_cast<int>(textureRefs.size() - 1), 4));
accessInd = (std::max)(0, (std::min)(static_cast<int>(textureRefs.size() - 1), 4));
MeshPart frontMeshPart(vertices, indices, textureRefs[accessInd], blendInds[accessInd], blendMaskRefs[accessInd]);
blockModel.parts[static_cast<int>(Dir::FRONT)].push_back(frontMeshPart);
@ -98,7 +98,7 @@ struct BlockModel {
{{1, 1, 0}, {}, {1, 0}, {1, 0}},
{{1, 0, 0}, {}, {1, 1}, {1, 1}}};
indices = {0, 1, 2, 2, 3, 0};
accessInd = std::max(0, std::min(static_cast<int>(textureRefs.size() - 1), 5));
accessInd = (std::max)(0, (std::min)(static_cast<int>(textureRefs.size() - 1), 5));
MeshPart backMeshPart(vertices, indices, textureRefs[accessInd], blendInds[accessInd], blendMaskRefs[accessInd]);
blockModel.parts[static_cast<int>(Dir::BACK)].push_back(backMeshPart);

View File

@ -4,7 +4,14 @@
#include "ClientState.h"
#ifdef _WIN32
ClientState::ClientState(const std::string& path, Renderer& renderer) :
path(path),
renderer(renderer),
defs(path + "assets\\textures") {}
#else
ClientState::ClientState(const std::string &path, Renderer &renderer) :
path(path),
renderer(renderer),
defs(path + "/assets/textures") {}
#endif

View File

@ -66,16 +66,16 @@ bool Collidable::collidesAt(glm::vec3& pos, float stepUpMax) {
if (def.solid)
for (auto &cBox : def.cBoxes)
stepUpAmount = std::max(cBox.b.y + offsetPos.y - pos.y, stepUpAmount);
stepUpAmount = (std::max)(cBox.b.y + offsetPos.y - pos.y, stepUpAmount);
if (offset.z == collisionBox.b.z) break;
offset.z = std::min(std::floor(offset.z + 1), collisionBox.b.z);
offset.z = (std::min)(std::floor(offset.z + 1), collisionBox.b.z);
}
if (offset.y == collisionBox.a.y + stepUpMax + 0.025f) break; // Hack for precision errors
offset.y = std::min(std::floor(offset.y + 1), collisionBox.a.y + stepUpMax + 0.025f);
offset.y = (std::min)(std::floor(offset.y + 1), collisionBox.a.y + stepUpMax + 0.025f);
}
if (offset.x == collisionBox.b.x) break;
offset.x = std::min(std::floor(offset.x + 1), collisionBox.b.x);
offset.x = (std::min)(std::floor(offset.x + 1), collisionBox.b.x);
}
}
@ -107,13 +107,13 @@ bool Collidable::collidesAt(glm::vec3& pos, float stepUpMax) {
}
if (offset.z == collisionBox.b.z) break;
offset.z = std::min(std::floor(offset.z + 1), collisionBox.b.z);
offset.z = (std::min)(std::floor(offset.z + 1), collisionBox.b.z);
}
if (offset.y == collisionBox.b.y) break;
offset.y = std::min(std::floor(offset.y + 1), collisionBox.b.y);
offset.y = (std::min)(std::floor(offset.y + 1), collisionBox.b.y);
}
if (offset.x == collisionBox.b.x) break;
offset.x = std::min(std::floor(offset.x + 1), collisionBox.b.x);
offset.x = (std::min)(std::floor(offset.x + 1), collisionBox.b.x);
}
return false;

View File

@ -38,7 +38,7 @@ private:
std::string readFile(const std::string& fileLocation);
void compileShader(const std::string& vertexSource, const std::string& fragmentSource);
void addShader(uint program, const std::string& shaderCode, GLenum shaderType);
void addShader(unsigned int program, const std::string& shaderCode, GLenum shaderType);
void crashIfInactive();

View File

@ -11,6 +11,7 @@
#include <cerrno>
#include <cstdlib>
#include <stdexcept>
#include <glm/vec2.hpp>
#include <glm/vec4.hpp>

View File

@ -131,11 +131,11 @@ void GuiComponent::update(double delta) {
}
}
bool GuiComponent::leftClickEvent(bool state, glm::ivec2 pos) {
void GuiComponent::leftClickEvent(bool state, glm::ivec2 pos) {
clickEvent(true, state, pos);
}
bool GuiComponent::rightClickEvent(bool state, glm::ivec2 pos) {
void GuiComponent::rightClickEvent(bool state, glm::ivec2 pos) {
clickEvent(false, state, pos);
}

View File

@ -31,8 +31,8 @@ public:
virtual void update(double delta) override;
bool mouseActivity(glm::ivec2 pos);
bool leftClickEvent(bool state, glm::ivec2 pos);
bool rightClickEvent(bool state, glm::ivec2 pos);
void leftClickEvent(bool state, glm::ivec2 pos);
void rightClickEvent(bool state, glm::ivec2 pos);
virtual void setHoverCallback(const callback& hoverCallback);
virtual void setLeftClickCallback(const callback& leftClickCallback);

View File

@ -35,7 +35,7 @@ public:
private:
unsigned long timeout = 1000;
unsigned int attempts = 3;
unsigned int attempts = 10;
ENetHost* host = nullptr;
ENetPeer* peer = nullptr;

View File

@ -3,6 +3,7 @@
//
#include "ErrorFormatter.h"
#include <algorithm>
std::string ErrorFormatter::formatError(const std::string &fileName, int line, const std::string &stack,
std::string file, bool ansiColors) {
@ -28,7 +29,7 @@ std::string ErrorFormatter::formatError(const std::string &fileName, int line, c
while (fileLines.back() == "") fileLines.pop_back();
// Format and add lines to the stringstream
for (unsigned int i = std::max(0, line - 6); i < std::min(static_cast<int>(fileLines.size()), line + 5); i++) {
for (unsigned int i = (std::max)(0, line - 6); i < (std::min)(static_cast<int>(fileLines.size()), line + 5); i++) {
for (unsigned int j = 0; j < 3 - std::to_string(i + 1).length(); j++) out << " ";
out << red << (i+1 == line ? unbl : "") << (i+1) << (i+1 == line ? " # " : " | ") << fileLines[i] << endl;
}

View File

@ -5,6 +5,9 @@
#include "VenusParser.h"
#include "ErrorFormatter.h"
#include <stdio.h>
#include <stdlib.h>
namespace {
#ifdef _WIN32
const static char* EXECUTABLE_NAME = "zepha-venus-win.exe";
@ -16,12 +19,16 @@ namespace {
}
std::string VenusParser::parse(const std::string& fileName, const std::string& fileContents) {
#ifdef _WIN32
const static std::string path = "zepha-venus\\" + std::string(EXECUTABLE_NAME);
#else
const static std::string path = "../zepha-venus/" + std::string(EXECUTABLE_NAME);
#endif
const static bool exists = cf_file_exists(path.data());
if (!exists) throw std::runtime_error("Trying to compile a venus file when zepha-venus has not been built!");
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen((path + " " + fileName).data(), "r"), pclose);
std::unique_ptr<FILE, decltype(&_pclose)> pipe(_popen((path + " " + fileName).data(), "r"), _pclose);
if (!pipe) throw std::runtime_error("popen() failed!");
std::string result;

View File

@ -14,7 +14,7 @@ namespace Api {
for _, v in pairs(zepha.registered_callbacks[event]) do
if (type(v) == "function") then
v(unpack(arg))
v(...)
end
end
end

View File

@ -31,7 +31,7 @@ bool LocalServerInstance::start() {
return true;
#else
std::thread([&]() {
Server s(path.data(), port, subgame);
Server s(port, subgame);
}).detach();
return true;
#endif

View File

@ -49,9 +49,9 @@ void ClientList::createPlayer(std::shared_ptr<ServerClient> c) {
Packet p(PacketType::THIS_PLAYER_INFO);
p.data = Serializer()
.append<unsigned int>(static_cast<unsigned int>(NetPlayerField::ID))
.append(c->cid)
.append<unsigned int>(c->cid)
.append<unsigned int>(static_cast<unsigned int>(NetPlayerField::POSITION))
.append(c->getPos())
.append<glm::vec3>(c->getPos())
.data;
p.sendTo(c->peer, PacketChannel::ENTITY);

View File

@ -30,7 +30,18 @@ struct RIE {
if (read(ind, data, dataLen) == val) return false;
if (ind == 0) {
if (data[2] == ind + 1) {
if (data.size() == 0) {
data[0] = 0;
data[1] = val;
return true;
}
else if (data.size() == 2) {
data.push_back(1);
data.push_back(data[1]);
data[1] = val;
return true;
}
else if (data[2] == ind + 1) {
data[1] = val;
return true;
}

View File

@ -19,7 +19,7 @@ Packet::Packet(ENetPacket *packet) : reliable(true) {
ENetPacket* Packet::toENetPacket() {
std::string serialized = Serializer().append(static_cast<unsigned int>(type)).data + data;
ENetPacket* enet = enet_packet_create(serialized.data(), serialized.length() + 1, (reliable ? ENET_PACKET_FLAG_RELIABLE : 0));
ENetPacket* enet = enet_packet_create(serialized.data(), serialized.length(), (reliable ? ENET_PACKET_FLAG_RELIABLE : 0));
return enet;
}