Fix I_Error when queuing multiple Lua files

This commit is contained in:
Louis-Antoine 2020-05-19 23:50:37 +02:00
parent f620b52672
commit c8948909d3
4 changed files with 22 additions and 0 deletions

View File

@ -321,6 +321,12 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum)
RemoveLuaFileTransfer();
if (waitingforluafilecommand)
{
waitingforluafilecommand = false;
CL_PrepareDownloadLuaFile();
}
if (server && luafiletransfers)
SV_PrepareSendLuaFile();
}

View File

@ -3256,6 +3256,7 @@ void D_QuitNetGame(void)
CloseNetFile();
RemoveAllLuaFileTransfers();
waitingforluafiletransfer = false;
waitingforluafilecommand = false;
if (server)
{

View File

@ -110,6 +110,7 @@ INT32 lastfilenum = -1;
luafiletransfer_t *luafiletransfers = NULL;
boolean waitingforluafiletransfer = false;
boolean waitingforluafilecommand = false;
char luafiledir[256 + 16] = "luafiles";
@ -536,6 +537,8 @@ void AddLuaFileTransfer(const char *filename, const char *mode)
// Only if there is no transfer already going on
if (server && filetransfer == luafiletransfers)
SV_PrepareSendLuaFile();
else
filetransfer->ongoing = false;
// Store the callback so it can be called once everyone has the file
filetransfer->id = id;
@ -578,6 +581,8 @@ void SV_PrepareSendLuaFile(void)
char *binfilename;
INT32 i;
luafiletransfers->ongoing = true;
// Set status to "waiting" for everyone
for (i = 0; i < MAXNETNODES; i++)
luafiletransfers->nodestatus[i] = LFTNS_WAITING;
@ -660,6 +665,12 @@ void CL_PrepareDownloadLuaFile(void)
return;
}
if (luafiletransfers->ongoing)
{
waitingforluafilecommand = true;
return;
}
// Tell the server we are ready to receive the file
netbuffer->packettype = PT_ASKLUAFILE;
HSendPacket(servernode, true, 0, 0);
@ -674,6 +685,8 @@ void CL_PrepareDownloadLuaFile(void)
// Make sure all directories in the file path exist
MakePathDirs(fileneeded[0].filename);
luafiletransfers->ongoing = true;
}
// Number of files to send

View File

@ -95,12 +95,14 @@ typedef struct luafiletransfer_s
char *realfilename;
char mode[4]; // rb+/wb+/ab+ + null character
INT32 id; // Callback ID
boolean ongoing;
luafiletransfernodestatus_t nodestatus[MAXNETNODES];
struct luafiletransfer_s *next;
} luafiletransfer_t;
extern luafiletransfer_t *luafiletransfers;
extern boolean waitingforluafiletransfer;
extern boolean waitingforluafilecommand;
extern char luafiledir[256 + 16];
void AddLuaFileTransfer(const char *filename, const char *mode);