Index: trunk/code/botlib/l_script.c =================================================================== --- trunk/code/botlib/l_script.c (revision 1288) +++ trunk/code/botlib/l_script.c (working copy) @@ -1314,11 +1314,10 @@ FILE *fp; #endif int length; - void *buffer; script_t *script; #ifdef BOTLIB - if (strlen(basefolder)) + if (basefolder[0]) Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename); else Com_sprintf(pathname, sizeof(pathname), "%s", filename); @@ -1331,12 +1330,24 @@ length = FileLength(fp); #endif - buffer = GetClearedMemory(sizeof(script_t) + length + 1); - script = (script_t *) buffer; - Com_Memset(script, 0, sizeof(script_t)); - strcpy(script->filename, filename); - script->buffer = (char *) buffer + sizeof(script_t); + script = (script_t *) GetClearedMemory(sizeof(script_t) + length + 1); + script->buffer = (char *)script + sizeof(script_t); +#ifdef BOTLIB + botimport.FS_Read(script->buffer, length, fp); + botimport.FS_FCloseFile(fp); +#else + if (fread(script->buffer, length, 1, fp) != 1) + { + FreeMemory(buffer); + fclose(fp); + return NULL; + } + fclose(fp); +#endif script->buffer[length] = 0; + + length = COM_Compress( script->buffer ); + script->length = length; //pointer in script buffer script->script_p = script->buffer; @@ -1352,17 +1363,7 @@ // SetScriptPunctuations(script, NULL); // -#ifdef BOTLIB - botimport.FS_Read(script->buffer, length, fp); - botimport.FS_FCloseFile(fp); -#else - if (fread(script->buffer, length, 1, fp) != 1) - { - FreeMemory(buffer); - script = NULL; - } //end if - fclose(fp); -#endif + strcpy(script->filename, filename); return script; } //end of the function LoadScriptFile