mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-10-03 10:03:49 -04:00
[Server] Use cleaner solution for safely reading cell descriptions
This commit is contained in:
parent
78f29302ef
commit
66a3f3d475
@ -8,6 +8,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
static std::string tempCellDescription;
|
||||||
|
|
||||||
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
@ -32,13 +34,8 @@ const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned
|
|||||||
if (i >= player->cellStateChanges.count)
|
if (i >= player->cellStateChanges.count)
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
||||||
string cellDescription = player->cellStateChanges.cellStates.at(i).cell.getDescription();
|
tempCellDescription = player->cellStateChanges.cellStates.at(i).cell.getDescription();
|
||||||
|
return tempCellDescription.c_str();
|
||||||
static vector<char> cstrDescription;
|
|
||||||
cstrDescription.reserve(cellDescription.size() + 1);
|
|
||||||
strncpy(&cstrDescription[0], cellDescription.c_str(), cstrDescription.capacity());
|
|
||||||
|
|
||||||
return &cstrDescription[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CellFunctions::GetCell(unsigned short pid) noexcept
|
const char *CellFunctions::GetCell(unsigned short pid) noexcept
|
||||||
@ -46,13 +43,8 @@ const char *CellFunctions::GetCell(unsigned short pid) noexcept
|
|||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
string cellDescription = player->cell.getDescription().c_str();
|
tempCellDescription = player->cell.getDescription().c_str();
|
||||||
|
return tempCellDescription.c_str();
|
||||||
static vector<char> cstrDescription;
|
|
||||||
cstrDescription.reserve(cellDescription.size() + 1);
|
|
||||||
strncpy(&cstrDescription[0], cellDescription.c_str(), cstrDescription.capacity());
|
|
||||||
|
|
||||||
return &cstrDescription[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
|
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
|
||||||
|
Loading…
x
Reference in New Issue
Block a user