Hello, i'm trying to implement a waypoint based pathfinding it's working but it's not saving correctly or not readed correctly i dont know, its ported from C++ version.
Code:
enum struct WaypointHeader
{
char author[32];
char editor[32];
int fileVersion;
int pointNumber;
}
enum struct Path
{
int index;
int activeArea;
int flags;
int radius;
int distance[8];
int pathIndex[8];
int origin[3];
int campStart[3];
int campEnd[3];
}
// read the all waypoint data
for (int i = 0; i < m_waypointNumber; i++)
{
fp.Read(m_paths[i].index, 1, 4);
fp.Read(m_paths[i].activeArea, 1, 1);
fp.Read(m_paths[i].flags, 1, 1);
fp.Read(m_paths[i].radius, 1, 4);
fp.Read(m_paths[i].distance, MaxPathIndex, 2);
fp.Read(m_paths[i].pathIndex, MaxPathIndex, 2);
fp.Read(m_paths[i].origin, 3, 4);
fp.Read(m_paths[i].campStart, 3, 4);
fp.Read(m_paths[i].campEnd, 3, 4);
}
// write about the file and author
fp.WriteString(header.author, false);
fp.Write(header.pointNumber, 1, 1);
fp.Write(header.fileVersion, 1, 1);
// write the all waypoint data
for (int i = 0; i < m_waypointNumber; i++)
{
fp.Write(m_paths[i].index, 1, 4);
fp.Write(m_paths[i].activeArea, 1, 1);
fp.Write(m_paths[i].flags, 1, 1);
fp.Write(m_paths[i].radius, 1, 4);
fp.Write(m_paths[i].distance, MaxPathIndex, 2);
fp.Write(m_paths[i].pathIndex, MaxPathIndex, 2);
fp.Write(m_paths[i].origin, 3, 4);
fp.Write(m_paths[i].campStart, 3, 4);
fp.Write(m_paths[i].campEnd, 3, 4);
}
but always reads first character of waypoint author and writes the all data but only goes in 1 line
C++ writes and reads like (and not the all writed data goes on 1 line)
Code:
// write the waypoint header to the file...
fp.Write(&header, sizeof(header), 1);
// save the waypoint paths...
for (int i = 0; i < m_waypointNumber; i++)
fp.Write(m_paths[i], sizeof(Path));
// read the waypoint header to the file...
fp.Read(&header, sizeof(header), 1);
// save the waypoint paths...
for (int i = 0; i < m_waypointNumber; i++)
fp.Read(m_paths[i], sizeof(Path));
i don't know how to fix this, thanks.
__________________