mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-14 13:51:31 +00:00
Paginate PutFileNeeded
This commit is contained in:
parent
430831423c
commit
6c5ac8e942
4 changed files with 33 additions and 11 deletions
|
@ -1433,7 +1433,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
|||
|
||||
netbuffer->u.serverinfo.actnum = 0; //mapheaderinfo[gamemap-1]->actnum
|
||||
|
||||
p = PutFileNeeded();
|
||||
p = PutFileNeeded(0);
|
||||
|
||||
HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u));
|
||||
}
|
||||
|
@ -2022,10 +2022,6 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
|
|||
}
|
||||
|
||||
cl_mode = CL_ASKDOWNLOADFILES;
|
||||
|
||||
// no problem if can't send packet, we will retry later
|
||||
//if (CL_SendRequestFile())
|
||||
// cl_mode = CL_DOWNLOADFILES;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -376,6 +376,8 @@ typedef struct
|
|||
|
||||
#define MAXSERVERNAME 32
|
||||
#define MAXFILENEEDED 915
|
||||
#define MAXFILENEEDEDPAGES MAX_WADFILES
|
||||
#define FILENEEDED_MORE 0x80
|
||||
// This packet is too large
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -101,25 +101,49 @@ char downloaddir[512] = "DOWNLOAD";
|
|||
INT32 lastfilenum = -1;
|
||||
#endif
|
||||
|
||||
UINT16 fileneededpages = 0;
|
||||
static size_t fileneededpagestart[MAXFILENEEDEDPAGES];
|
||||
|
||||
/** Fills a serverinfo packet with information about wad files loaded.
|
||||
*
|
||||
* \todo Give this function a better name since it is in global scope.
|
||||
* Used to have size limiting built in - now handed via W_LoadWadFile in w_wad.c
|
||||
*
|
||||
*/
|
||||
UINT8 *PutFileNeeded(void)
|
||||
UINT8 *PutFileNeeded(UINT16 page)
|
||||
{
|
||||
size_t i, count = 0;
|
||||
size_t i;
|
||||
UINT8 count = 0;
|
||||
UINT8 *p = netbuffer->u.serverinfo.fileneeded;
|
||||
char wadfilename[MAX_WADPATH] = "";
|
||||
UINT8 filestatus;
|
||||
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
if (page > fileneededpages)
|
||||
I_Error("Fileneeded page %d accessed before a prior page", page);
|
||||
else if (page == 0)
|
||||
{
|
||||
fileneededpages = 0;
|
||||
memset(fileneededpagestart, 0, sizeof(fileneededpagestart)); // ??? I guess.
|
||||
fileneededpagestart[0] = mainwads;
|
||||
}
|
||||
|
||||
for (i = fileneededpagestart[page]; i < (fileneededpagestart[page+1] ?: numwadfiles); i++)
|
||||
{
|
||||
// If it has only music/sound lumps, don't put it in the list
|
||||
if (!wadfiles[i]->important)
|
||||
continue;
|
||||
|
||||
nameonly(strcpy(wadfilename, wadfiles[i]->filename));
|
||||
|
||||
if (p + 1 + 4 + strlen(wadfilename) + 16 > netbuffer->u.serverinfo.fileneeded + MAXFILENEEDED)
|
||||
{
|
||||
// Too many files for this page, so mark the next page to start here and finish up.
|
||||
fileneededpagestart[page+1] = i;
|
||||
fileneededpages = page+1;
|
||||
count |= FILENEEDED_MORE;
|
||||
break;
|
||||
}
|
||||
|
||||
filestatus = 1; // Importance - not really used any more, holds 1 by default for backwards compat with MS
|
||||
|
||||
// Store in the upper four bits
|
||||
|
@ -134,11 +158,10 @@ UINT8 *PutFileNeeded(void)
|
|||
|
||||
count++;
|
||||
WRITEUINT32(p, wadfiles[i]->filesize);
|
||||
nameonly(strcpy(wadfilename, wadfiles[i]->filename));
|
||||
WRITESTRINGN(p, wadfilename, MAX_WADPATH);
|
||||
WRITEMEM(p, wadfiles[i]->md5sum, 16);
|
||||
}
|
||||
netbuffer->u.serverinfo.fileneedednum = (UINT8)count;
|
||||
netbuffer->u.serverinfo.fileneedednum = count;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ extern char downloaddir[512];
|
|||
extern INT32 lastfilenum;
|
||||
#endif
|
||||
|
||||
UINT8 *PutFileNeeded(void);
|
||||
extern UINT16 fileneededpages;
|
||||
UINT8 *PutFileNeeded(UINT16 page);
|
||||
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr);
|
||||
void CL_PrepareDownloadSaveGame(const char *tmpsave);
|
||||
|
||||
|
|
Loading…
Reference in a new issue