diff --git a/src/Client/Program.c b/src/Client/Program.c index b5a3539ed..5b37eb2ac 100644 --- a/src/Client/Program.c +++ b/src/Client/Program.c @@ -43,6 +43,16 @@ int main(void) { ErrorHandler_CheckOrFail(result, "Program - creating texturecache directory"); } + UInt8 defPathBuffer[String_BufferSize(STRING_SIZE)]; + String defPath = String_InitAndClearArray(defPathBuffer); + String_Format1(&defPath, "texpacks%rdefault.zip", &Platform_DirectorySeparator); + + if (!Platform_FileExists(&defPath)) { + ErrorHandler_ShowDialog("Missing file", "default.zip missing, try running launcher first"); + Platform_Exit(1); + return 1; + } + Platform_LogConst("Starting " PROGRAM_APP_NAME " .."); Options_Init(); Options_Load(); diff --git a/src/Client/TexturePack.c b/src/Client/TexturePack.c index b352ea8f6..80e8c182d 100644 --- a/src/Client/TexturePack.c +++ b/src/Client/TexturePack.c @@ -17,7 +17,9 @@ /*########################################################################################################################* *--------------------------------------------------------ZipEntry---------------------------------------------------------* *#########################################################################################################################*/ +#define ZIP_MAXNAMELEN 512 String Zip_ReadFixedString(Stream* stream, UInt8* buffer, UInt16 length) { + if (length > ZIP_MAXNAMELEN) ErrorHandler_Fail("Zip string too long"); String fileName = String_Init(buffer, length, length); Stream_Read(stream, buffer, length); buffer[length] = NULL; /* Ensure null terminated */ @@ -39,7 +41,7 @@ void Zip_ReadLocalFileHeader(ZipState* state, ZipEntry* entry) { UInt16 fileNameLen = Stream_ReadU16_LE(stream); UInt16 extraFieldLen = Stream_ReadU16_LE(stream); - UInt8 filenameBuffer[String_BufferSize(UInt16_MaxValue)]; + UInt8 filenameBuffer[String_BufferSize(ZIP_MAXNAMELEN)]; String filename = Zip_ReadFixedString(stream, filenameBuffer, fileNameLen); if (!state->SelectEntry(&filename)) return; diff --git a/src/Client/WinPlatform.c b/src/Client/WinPlatform.c index 3c5921ae8..5ed4f1b76 100644 --- a/src/Client/WinPlatform.c +++ b/src/Client/WinPlatform.c @@ -665,6 +665,9 @@ ReturnCode Platform_HttpGetRequestData(AsyncRequest* request, void* handle, void UInt32 left = size, read, totalRead = 0; while (left > 0) { + //UInt32 toRead = min(4096, left); + //UInt32 avail = 0; + //InternetQueryDataAvailable(handle, &avail, 0, NULL); bool success = InternetReadFile(handle, buffer, left, &read); if (!success) { Platform_MemFree(data); return GetLastError(); }