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

Function SE_Load

code/qcommon/stringed_ingame.cpp:927–983  ·  view source on GitHub ↗

filename is local here, eg: "strings/german/obj.str" return is either NULL for good else error message to display...

Source from the content-addressed store, hash-verified

925// return is either NULL for good else error message to display...
926//
927const char *SE_Load( const char *psFileName, SE_BOOL bLoadDebug = SE_TRUE, SE_BOOL bFailIsCritical = SE_TRUE )
928{
929 ////////////////////////////////////////////////////
930 //
931 // ingame here tends to pass in names without paths, but I expect them when doing a language load, so...
932 //
933 char sTemp[1000]={0};
934 if (!strchr(psFileName,'/'))
935 {
936 strcpy(sTemp,sSE_STRINGS_DIR);
937 strcat(sTemp,"/");
938 if (se_language)
939 {
940 strcat(sTemp,se_language->string);
941 strcat(sTemp,"/");
942 }
943 }
944 strcat(sTemp,psFileName);
945 COM_DefaultExtension( sTemp, sizeof(sTemp), sSE_INGAME_FILE_EXTENSION);
946 psFileName = &sTemp[0];
947 //
948 ////////////////////////////////////////////////////
949
950
951 const char *psErrorMessage = SE_Load_Actual( psFileName, bLoadDebug, SE_FALSE );
952
953 // check for any corresponding / overriding .STE files and load them afterwards...
954 //
955 if ( !psErrorMessage )
956 {
957 char sFileName[ iSE_MAX_FILENAME_LENGTH ];
958 strncpy( sFileName, psFileName, sizeof(sFileName)-1 );
959 sFileName[ sizeof(sFileName)-1 ] = '\0';
960 char *p = strrchr( sFileName, '.' );
961 if (p && strlen(p) == strlen(sSE_EXPORT_FILE_EXTENSION))
962 {
963 strcpy( p, sSE_EXPORT_FILE_EXTENSION );
964
965 psErrorMessage = SE_Load_Actual( sFileName, bLoadDebug, SE_TRUE );
966 }
967 }
968
969 if (psErrorMessage)
970 {
971 if (bFailIsCritical)
972 {
973 // TheStringPackage.Clear(TRUE); // Will we want to do this? Any errors that arise should be fixed immediately
974 Com_Error( ERR_DROP, "SE_Load(): Couldn't load \"%s\"!\n\nError: \"%s\"\n", psFileName, psErrorMessage );
975 }
976 else
977 {
978 Com_DPrintf(S_COLOR_YELLOW "SE_Load(): Couldn't load \"%s\"!\n", psFileName );
979 }
980 }
981
982 return psErrorMessage;
983}
984

Callers 1

SE_LoadLanguageFunction · 0.70

Calls 4

COM_DefaultExtensionFunction · 0.70
SE_Load_ActualFunction · 0.70
Com_ErrorFunction · 0.70
Com_DPrintfFunction · 0.70

Tested by

no test coverage detected