From 25b9dc9ba643ce7737a31670acf8e20e0495c1ad Mon Sep 17 00:00:00 2001 From: Buginator Date: Sat, 28 Nov 2009 20:48:29 +0000 Subject: [PATCH] Add more documentation about the Map issues and note in logs about map transfers (if exists / file size mismatch) (r8548/r8549) git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8555 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/netplay/netplay.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/netplay/netplay.c b/lib/netplay/netplay.c index dc8950e1c..0b750e926 100644 --- a/lib/netplay/netplay.c +++ b/lib/netplay/netplay.c @@ -2718,6 +2718,10 @@ UBYTE NETsendFile(BOOL newFile, char *fileName, UDWORD player) // even if they already have it? multiplay.c 1529 & 1550 are both // NETsendFile(true,mapStr,0); & NETsendFile(false,game.map,0); // so we ALWAYS send it, it seems? + // NOTE: we send to everyone since there is no way to signal the host + // to stop sending the map. Which means that everytime a player joins + // that doesn't have the map, it will send to all players again. + // We also are limited by fps(!) to the amount of time the loop runs. NETbeginEncode(FILEMSG, NET_ALL_PLAYERS); // send it. } else @@ -2744,7 +2748,7 @@ UBYTE NETsendFile(BOOL newFile, char *fileName, UDWORD player) return (currPos * 100) / fileSize_64; } - +/* @TODO Needs to be rewritten. See issue #215. */ // recv file. it returns % of the file so far recvd. UBYTE NETrecvFile(void) { @@ -2768,6 +2772,30 @@ UBYTE NETrecvFile(void) if (currPos == 0) // first packet! { + if (PHYSFS_exists(fileName)) + { + PHYSFS_file *fin; + PHYSFS_sint64 fsize; + fin = PHYSFS_openRead(fileName); + fsize = PHYSFS_fileLength(fin); + if ((int32_t) fsize == fileSize) + { + // NOTE: we would send a abort message to host, but since we can't, + // we won't. +#ifdef DEBUG + debug(LOG_NET, "We already have the file %s.", fileName); +#endif + + // NOTE: we can't abort out, since the host ALWAYS sends the data until done + // PHYSFS_close(fin); + // NETend(); + // return 100; + } + PHYSFS_close(fin); +#ifdef DEBUG + debug(LOG_NET, "We have the same named file, but different size. Redownloading %s", fileName); +#endif + } pFileHandle = PHYSFS_openWrite(fileName); // create a new file. }