forked from teamnwah/openmw-tes3coop
[Server] Send stable C string in GetCellStateDescription()
This commit is contained in:
parent
4f288ab558
commit
0ccfe66212
2 changed files with 9 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
||||||
return player->cellStateChanges.count;
|
return player->cellStateChanges.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int i) noexcept
|
char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int i) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, "");
|
GET_PLAYER(pid, player, "");
|
||||||
|
|
@ -24,10 +24,15 @@ const char* CellFunctions::GetCellStateDescription(unsigned short pid, unsigned
|
||||||
if (i >= player->cellStateChanges.count)
|
if (i >= player->cellStateChanges.count)
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
||||||
return player->cellStateChanges.cells.at(i).getDescription().c_str();
|
std::string cellDescription = player->cellStateChanges.cells.at(i).getDescription();
|
||||||
|
|
||||||
|
char *cstrDescription = new char[cellDescription.length() + 1];
|
||||||
|
std::strcpy(cstrDescription, cellDescription.c_str());
|
||||||
|
|
||||||
|
return cstrDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CellFunctions::GetCell(unsigned short pid) noexcept
|
const char *CellFunctions::GetCell(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class CellFunctions
|
||||||
public:
|
public:
|
||||||
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
|
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
|
||||||
|
|
||||||
static const char *GetCellStateDescription(unsigned short pid, unsigned int i) noexcept;
|
static char *GetCellStateDescription(unsigned short pid, unsigned int i) noexcept;
|
||||||
|
|
||||||
static const char *GetCell(unsigned short pid) noexcept;
|
static const char *GetCell(unsigned short pid) noexcept;
|
||||||
static void SetCell(unsigned short pid, const char *name) noexcept;
|
static void SetCell(unsigned short pid, const char *name) noexcept;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue