Fix string overrun error

This commit is contained in:
Bailey Harrison 2023-07-31 22:55:06 +01:00
parent dec9289d77
commit d6848fffea
4 changed files with 7 additions and 8 deletions

View File

@ -870,6 +870,8 @@ gfx::Pipeline* GFXDevice::CreatePipeline(const gfx::PipelineInfo& info) {
auto vertShaderCode = util::ReadTextFile(info.vert_shader_path);
auto fragShaderCode = util::ReadTextFile(info.frag_shader_path);
LOG_INFO("vert shader vector size: {}", vertShaderCode->size());
VkShaderModule vertShaderModule =
compileShader(pimpl->device.device, shaderc_vertex_shader,
vertShaderCode->data(), info.vert_shader_path);

View File

@ -39,7 +39,7 @@ uint32_t Scene::CreateEntity(const std::string& tag, uint32_t parent,
auto t = AddComponent<TransformComponent>(id);
t->position = {0.0f, 0.0f, 0.0f};
t->position = pos;
t->rotation = {};
t->scale = {1.0f, 1.0f, 1.0f};

View File

@ -13,7 +13,7 @@ std::unique_ptr<std::vector<char>> ReadTextFile(const std::string& path) {
throw std::runtime_error("Unable to open file " + path);
}
auto buffer = std::make_unique<std::vector<char>>(file.tellg());
auto buffer = std::make_unique<std::vector<char>>(static_cast<size_t>(file.tellg()) + 1);
file.seekg(0);
@ -27,6 +27,9 @@ std::unique_ptr<std::vector<char>> ReadTextFile(const std::string& path) {
++i;
}
// append zero byte
buffer->data()[buffer->size()] = '\0';
file.close();
return buffer;

View File

@ -30,12 +30,6 @@ void CameraControllerSystem::OnUpdate(float ts) {
const float dt = ts;
constexpr float G = 9.8f;
glm::vec3 dir =
glm::normalize(glm::rotateY(glm::vec3{1.0f, 0.0f, 0.0f}, c->yaw) +
glm::rotateY(glm::vec3{0.0f, 0.0f, 1.0f}, c->yaw));
// in metres per second
float speed = c->kWalkSpeed;
if (scene_->app()->input_manager()->GetButton("sprint")) speed *= 10.0f;