From c8948909d37e1421d4faf7959ab9be29ec4277a4 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Tue, 19 May 2020 23:50:37 +0200 Subject: [PATCH] Fix I_Error when queuing multiple Lua files --- src/blua/liolib.c | 6 ++++++ src/d_clisrv.c | 1 + src/d_netfil.c | 13 +++++++++++++ src/d_netfil.h | 2 ++ 4 files changed, 22 insertions(+) diff --git a/src/blua/liolib.c b/src/blua/liolib.c index 2ccfa70e8..a055aad3f 100644 --- a/src/blua/liolib.c +++ b/src/blua/liolib.c @@ -321,6 +321,12 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum) RemoveLuaFileTransfer(); + if (waitingforluafilecommand) + { + waitingforluafilecommand = false; + CL_PrepareDownloadLuaFile(); + } + if (server && luafiletransfers) SV_PrepareSendLuaFile(); } diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 275eb790e..dbf10d58e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3256,6 +3256,7 @@ void D_QuitNetGame(void) CloseNetFile(); RemoveAllLuaFileTransfers(); waitingforluafiletransfer = false; + waitingforluafilecommand = false; if (server) { diff --git a/src/d_netfil.c b/src/d_netfil.c index da190bc5c..c5f3d8658 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -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 diff --git a/src/d_netfil.h b/src/d_netfil.h index dce2c929f..be58f807f 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -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);