MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SV_WriteDownloadToClient

Function SV_WriteDownloadToClient

codemp/server/sv_client.cpp:714–934  ·  view source on GitHub ↗

================== SV_WriteDownloadToClient Check to see if the client wants a file, open it if needed and start pumping the client Fill up msg with data ================== */

Source from the content-addressed store, hash-verified

712==================
713*/
714void SV_WriteDownloadToClient(client_t *cl, msg_t *msg)
715{
716 int curindex;
717 int rate;
718 int blockspersnap;
719 int unreferenced = 1;
720 char errorMessage[1024];
721 char pakbuf[MAX_QPATH], *pakptr;
722 int numRefPaks;
723
724 if (!*cl->downloadName)
725 return; // Nothing being downloaded
726
727 if(!cl->download)
728 {
729 qboolean idPack = qfalse;
730 qboolean missionPack = qfalse;
731
732 // Chop off filename extension.
733 Com_sprintf(pakbuf, sizeof(pakbuf), "%s", cl->downloadName);
734 pakptr = strrchr(pakbuf, '.');
735
736 if(pakptr)
737 {
738 *pakptr = '\0';
739
740 // Check for pk3 filename extension
741 if(!Q_stricmp(pakptr + 1, "pk3"))
742 {
743 const char *referencedPaks = FS_ReferencedPakNames();
744
745 // Check whether the file appears in the list of referenced
746 // paks to prevent downloading of arbitrary files.
747 Cmd_TokenizeStringIgnoreQuotes(referencedPaks);
748 numRefPaks = Cmd_Argc();
749
750 for(curindex = 0; curindex < numRefPaks; curindex++)
751 {
752 if(!FS_FilenameCompare(Cmd_Argv(curindex), pakbuf))
753 {
754 unreferenced = 0;
755
756 // now that we know the file is referenced,
757 // check whether it's legal to download it.
758 missionPack = FS_idPak(pakbuf, "missionpack");
759 idPack = missionPack;
760 idPack = (qboolean)(idPack || FS_idPak(pakbuf, BASEGAME));
761
762 break;
763 }
764 }
765 }
766 }
767
768 cl->download = 0;
769
770 // We open the file here
771 if ( !sv_allowDownload->integer ||

Callers 1

SV_SendClientSnapshotFunction · 0.85

Calls 15

Q_stricmpFunction · 0.85
FS_ReferencedPakNamesFunction · 0.85
FS_idPakFunction · 0.85
Com_sprintfFunction · 0.50
Cmd_ArgcFunction · 0.50
FS_FilenameCompareFunction · 0.50
Cmd_ArgvFunction · 0.50
FS_SV_FOpenFileReadFunction · 0.50
Com_PrintfFunction · 0.50
MSG_WriteByteFunction · 0.50
MSG_WriteShortFunction · 0.50

Tested by

no test coverage detected