Raised This Month: $ Target: $400
 0% 

Solved File cannot be read correctly (only reads 1 character)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
EfeDursun125
Senior Member
Join Date: Feb 2019
Location: Turkey
Old 04-11-2022 , 03:39   File cannot be read correctly (only reads 1 character)
Reply With Quote #1

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.
__________________
CS 1.6 E-BOT (Best Bot For Zombie Plague): https://github.com/EfeDursun125/CS-EBOT

Last edited by EfeDursun125; 04-11-2022 at 19:10.
EfeDursun125 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode