refactor: remove usage of raw pointers
This commit is contained in:
parent
032581512d
commit
9592833ddf
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <memory>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "Domain/Services/EntityService.h"
|
#include "Domain/Services/EntityService.h"
|
||||||
#include "Domain/Serializers/SerializableStateContainer.h"
|
#include "Domain/Serializers/SerializableStateContainer.h"
|
||||||
@ -113,29 +115,24 @@ private:
|
|||||||
|
|
||||||
const std::vector<Serializers::Node> GetData()
|
const std::vector<Serializers::Node> GetData()
|
||||||
{
|
{
|
||||||
std::vector<Serializers::Serializable*> items
|
std::vector<Serializers::SerializableStateContainer> items
|
||||||
{
|
{
|
||||||
new Serializers::SerializableStateContainer(m_HeroService.GetEntities(), "hero"),
|
Serializers::SerializableStateContainer{m_HeroService.GetEntities(), "hero"},
|
||||||
new Serializers::SerializableStateContainer(m_DropService.GetEntities(), "drop"),
|
Serializers::SerializableStateContainer{m_DropService.GetEntities(), "drop"},
|
||||||
new Serializers::SerializableStateContainer(m_NPCService.GetEntities(), "npc"),
|
Serializers::SerializableStateContainer{m_NPCService.GetEntities(), "npc"},
|
||||||
new Serializers::SerializableStateContainer(m_PlayerService.GetEntities(), "player"),
|
Serializers::SerializableStateContainer{m_PlayerService.GetEntities(), "player"},
|
||||||
new Serializers::SerializableStateContainer(m_SkillService.GetEntities(), "skill"),
|
Serializers::SerializableStateContainer{m_SkillService.GetEntities(), "skill"},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Serializers::Node> result;
|
std::vector<Serializers::Node> result;
|
||||||
for (const auto& item : items)
|
for (const auto& item : items)
|
||||||
{
|
{
|
||||||
for (const auto node : item->BuildSerializationNodes())
|
for (const auto node : item.BuildSerializationNodes())
|
||||||
{
|
{
|
||||||
result.push_back(node);
|
result.push_back(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& item : items)
|
|
||||||
{
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define BUFFER_SIZE 16384
|
#define BUFFER_SIZE 16384
|
||||||
@ -95,8 +96,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
DWORD dwRead;
|
DWORD dwRead;
|
||||||
char* buffer = new char[BUFFER_SIZE];
|
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(BUFFER_SIZE);
|
||||||
const auto result = ReadFile(m_Pipe, buffer, BUFFER_SIZE * sizeof(char), &dwRead, &m_ReadingOverlapped);
|
const auto result = ReadFile(m_Pipe, buffer.get(), BUFFER_SIZE * sizeof(char), &dwRead, &m_ReadingOverlapped);
|
||||||
|
|
||||||
const auto lastError = GetLastError();
|
const auto lastError = GetLastError();
|
||||||
if (!result)
|
if (!result)
|
||||||
@ -108,21 +109,18 @@ public:
|
|||||||
const auto overlappedResult = GetOverlappedResult(m_Pipe, &m_ReadingOverlapped, &ret, false);
|
const auto overlappedResult = GetOverlappedResult(m_Pipe, &m_ReadingOverlapped, &ret, false);
|
||||||
if (!overlappedResult)
|
if (!overlappedResult)
|
||||||
{
|
{
|
||||||
delete[] buffer;
|
|
||||||
m_Connected = false;
|
m_Connected = false;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete[] buffer;
|
|
||||||
m_Connected = false;
|
m_Connected = false;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string message = std::string(buffer);
|
std::string message = std::string(buffer.get());
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user