Improve handling of an error in NETsendfile reported in issue #215. Add TODO about
rewriting this whole function and reference to ticket. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6580 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
449d93267e
commit
4cae3b8f1b
|
@ -1129,7 +1129,8 @@ BOOL NETsetupTCPIP(const char *machine)
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////////
|
||||||
// File Transfer programs.
|
// File Transfer programs.
|
||||||
// send file. it returns % of file sent. when 100 it's complete. call until it returns 100.
|
/** Send file. It returns % of file sent when 100 it's complete. Call until it returns 100.
|
||||||
|
* @TODO Needs to be rewritten. See issue #215. */
|
||||||
#define MAX_FILE_TRANSFER_PACKET 256
|
#define MAX_FILE_TRANSFER_PACKET 256
|
||||||
UBYTE NETsendFile(BOOL newFile, char *fileName, UDWORD player)
|
UBYTE NETsendFile(BOOL newFile, char *fileName, UDWORD player)
|
||||||
{
|
{
|
||||||
|
@ -1147,7 +1148,7 @@ UBYTE NETsendFile(BOOL newFile, char *fileName, UDWORD player)
|
||||||
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
|
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
|
||||||
if (pFileHandle == NULL)
|
if (pFileHandle == NULL)
|
||||||
{
|
{
|
||||||
debug(LOG_ERROR, "Failed");
|
debug(LOG_ERROR, "Failed to open %s for reading: %s", fileName, PHYSFS_getLastError());
|
||||||
return 0; // failed
|
return 0; // failed
|
||||||
}
|
}
|
||||||
// get the file's size.
|
// get the file's size.
|
||||||
|
@ -1162,6 +1163,11 @@ UBYTE NETsendFile(BOOL newFile, char *fileName, UDWORD player)
|
||||||
PHYSFS_seek(pFileHandle, 0);
|
PHYSFS_seek(pFileHandle, 0);
|
||||||
}
|
}
|
||||||
// read some bytes.
|
// read some bytes.
|
||||||
|
if (!pFileHandle)
|
||||||
|
{
|
||||||
|
debug(LOG_ERROR, "No filehandle");
|
||||||
|
return 0; // failed
|
||||||
|
}
|
||||||
bytesRead = PHYSFS_read(pFileHandle, inBuff,1, MAX_FILE_TRANSFER_PACKET);
|
bytesRead = PHYSFS_read(pFileHandle, inBuff,1, MAX_FILE_TRANSFER_PACKET);
|
||||||
|
|
||||||
if (player == 0)
|
if (player == 0)
|
||||||
|
|
Loading…
Reference in New Issue