Some stuff toward reading those files

This commit is contained in:
fickleheart 2019-04-17 23:42:49 -05:00
parent 6c5ac8e942
commit a36700e176
3 changed files with 73 additions and 59 deletions

View file

@ -1129,6 +1129,7 @@ typedef enum
#endif
CL_CONNECTED,
CL_ABORTED,
CL_ASKFULLFILELIST,
CL_ASKDOWNLOADFILES,
CL_WAITDOWNLOADFILESRESPONSE,
CL_CHALLENGE
@ -1924,51 +1925,9 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
#endif // ifndef NONET
/** Called by CL_ServerConnectionTicker
*
* \param viams ???
* \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit.
* \return False if the connection was aborted
* \sa CL_ServerConnectionTicker
* \sa CL_ConnectToServer
*
*/
static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
static boolean CL_FinishedFileList(void)
{
#ifndef NONET
INT32 i;
// serverlist is updated by GetPacket function
if (serverlistcount > 0)
{
// this can be a responce to our broadcast request
if (servernode == -1 || servernode >= MAXNETNODES)
{
i = 0;
servernode = serverlist[i].node;
CONS_Printf(M_GetText("Found, "));
}
else
{
i = SL_SearchServer(servernode);
if (i < 0)
return true;
}
// Quit here rather than downloading files and being refused later.
if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer)
{
D_QuitNetGame();
CL_Reset();
D_StartTitle();
M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING);
return false;
}
if (client)
{
D_ParseFileneeded(serverlist[i].info.fileneedednum,
serverlist[i].info.fileneeded);
CONS_Printf(M_GetText("Checking files...\n"));
i = CL_CheckFiles();
if (i == 3) // too many files
@ -2023,6 +1982,61 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
cl_mode = CL_ASKDOWNLOADFILES;
}
return true;
}
/** Called by CL_ServerConnectionTicker
*
* \param viams ???
* \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit.
* \return False if the connection was aborted
* \sa CL_ServerConnectionTicker
* \sa CL_ConnectToServer
*
*/
static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
{
#ifndef NONET
INT32 i;
// serverlist is updated by GetPacket function
if (serverlistcount > 0)
{
// this can be a responce to our broadcast request
if (servernode == -1 || servernode >= MAXNETNODES)
{
i = 0;
servernode = serverlist[i].node;
CONS_Printf(M_GetText("Found, "));
}
else
{
i = SL_SearchServer(servernode);
if (i < 0)
return true;
}
// Quit here rather than downloading files and being refused later.
if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer)
{
D_QuitNetGame();
CL_Reset();
D_StartTitle();
M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING);
return false;
}
if (client)
{
D_ParseFileneeded(serverlist[i].info.fileneedednum, serverlist[i].info.fileneeded, 0);
if (serverlist[i].info.fileneedednum & FILENEEDED_MORE)
{
cl_mode = CL_ASKFULLFILELIST;
return true;
}
if (!CL_FinishedFileList())
return false;
}
else
cl_mode = CL_ASKJOIN; // files need not be checked for the server.

View file

@ -168,19 +168,19 @@ UINT8 *PutFileNeeded(UINT16 page)
/** Parses the serverinfo packet and fills the fileneeded table on client
*
* \param fileneedednum_parm The number of files needed to join the server
* \param fileneedednum_parm The number of files (sent in this page) needed to join the server
* \param fileneededstr The memory block containing the list of needed files
*
* \param firstfile The first file index to read from
*/
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 firstfile)
{
INT32 i;
UINT8 *p;
UINT8 filestatus;
fileneedednum = fileneedednum_parm;
fileneedednum = firstfile + (fileneedednum_parm & ~FILENEEDED_MORE);
p = (UINT8 *)fileneededstr;
for (i = 0; i < fileneedednum; i++)
for (i = firstfile; i < fileneedednum; i++)
{
fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
filestatus = READUINT8(p); // The first byte is the file status

View file

@ -55,7 +55,7 @@ extern INT32 lastfilenum;
extern UINT16 fileneededpages;
UINT8 *PutFileNeeded(UINT16 page);
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr);
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 firstfile);
void CL_PrepareDownloadSaveGame(const char *tmpsave);
INT32 CL_CheckFiles(void);