This commit is contained in:
MihailRis 2023-11-16 20:28:20 +03:00
parent 0ec7f3348e
commit 47e24cb468
3 changed files with 11 additions and 11 deletions

View File

@ -227,13 +227,13 @@ void WorldFiles::writeWorldInfo(const WorldInfo& info) {
bool WorldFiles::readWorldInfo(WorldInfo& info) { bool WorldFiles::readWorldInfo(WorldInfo& info) {
size_t length = 0; size_t length = 0;
ubyte* data = (ubyte*)files::read_bytes(getPlayerFile(), length); ubyte* data = (ubyte*)files::read_bytes(getWorldFile(), length);
if (data == nullptr){ if (data == nullptr){
std::cerr << "could not to read world.bin (ignored)" << std::endl; std::cerr << "could not to read world.bin (ignored)" << std::endl;
return false; return false;
} }
BinaryReader inp(data, length); BinaryReader inp(data, length);
inp.checkMagic(WORLD_FORMAT_MAGIC, length); inp.checkMagic(WORLD_FORMAT_MAGIC, 8);
/*ubyte version = */inp.get(); /*ubyte version = */inp.get();
while (inp.hasNext()) { while (inp.hasNext()) {
ubyte section = inp.get(); ubyte section = inp.get();

View File

@ -128,7 +128,7 @@ float BinaryReader::getFloat32() {
string BinaryReader::getString() { string BinaryReader::getString() {
uint16_t length = (uint16_t)getInt16(); uint16_t length = (uint16_t)getInt16();
if (pos+length >= size) { if (pos+length > size) {
throw std::underflow_error("unexpected end"); throw std::underflow_error("unexpected end");
} }
pos += length; pos += length;

View File

@ -143,25 +143,25 @@ void WorldRenderer::draw(Camera* camera, bool occlusion, float fogFactor, float
} }
if (level->player->debug) { if (level->player->debug) {
float lenght = 40.f; float length = 40.f;
linesShader->use(); linesShader->use();
glm::mat4 model(glm::translate(glm::mat4(1.f), vec3(Window::width >> 1, -static_cast<int>(Window::height) >> 1, 0.f))); glm::mat4 model(glm::translate(glm::mat4(1.f), vec3(Window::width >> 1, -static_cast<int>(Window::height) >> 1, 0.f)));
linesShader->uniformMatrix("u_projview", glm::ortho(0.f, static_cast<float>(Window::width), -static_cast<float>(Window::height), 0.f, -lenght, lenght) * model * glm::inverse(camera->rotation)); linesShader->uniformMatrix("u_projview", glm::ortho(0.f, static_cast<float>(Window::width), -static_cast<float>(Window::height), 0.f, -length, length) * model * glm::inverse(camera->rotation));
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glLineWidth(4.0f); glLineWidth(4.0f);
lineBatch->line(0.f, 0.f, 0.f, lenght, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, length, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
lineBatch->line(0.f, 0.f, 0.f, 0.f, lenght, 0.f, 0.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 0.f, 0.f, 1.f);
lineBatch->line(0.f, 0.f, 0.f, 0.f, 0.f, lenght, 0.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 0.f, 1.f);
lineBatch->render(); lineBatch->render();
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glLineWidth(2.0f); glLineWidth(2.0f);
lineBatch->line(0.f, 0.f, 0.f, lenght, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f);
lineBatch->line(0.f, 0.f, 0.f, 0.f, lenght, 0.f, 0.f, 1.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 0.f, 1.f);
lineBatch->line(0.f, 0.f, 0.f, 0.f, 0.f, lenght, 0.f, 0.f, 1.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 1.f);
lineBatch->render(); lineBatch->render();
} }
} }