mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Fix some texture pack urls with non-ascii characters not downloading on windows (Thanks cybertoon)
This commit is contained in:
parent
8a64e278e8
commit
a03dbe2429
@ -304,7 +304,7 @@ struct NbtTag {
|
||||
struct { String text; char buffer[NBT_STRING_SIZE]; } str;
|
||||
} value;
|
||||
char _nameBuffer[NBT_STRING_SIZE];
|
||||
cc_result err;
|
||||
cc_result result;
|
||||
};
|
||||
|
||||
static cc_uint8 NbtTag_U8(struct NbtTag* tag) {
|
||||
@ -433,11 +433,11 @@ static cc_result Nbt_ReadTag(cc_uint8 typeId, cc_bool readTagName, struct Stream
|
||||
}
|
||||
|
||||
if (res) return res;
|
||||
tag.err = 0;
|
||||
tag.result = 0;
|
||||
callback(&tag);
|
||||
/* NOTE: callback must set DataBig to NULL, if doesn't want it to be freed */
|
||||
if (!NbtTag_IsSmall(&tag)) Mem_Free(tag.value.big);
|
||||
return tag.err;
|
||||
return tag.result;
|
||||
}
|
||||
#define IsTag(tag, tagName) (String_CaselessEqualsConst(&tag->name, tagName))
|
||||
|
||||
@ -503,7 +503,7 @@ static void Cw_Callback_1(struct NbtTag* tag) {
|
||||
|
||||
if (IsTag(tag, "UUID")) {
|
||||
if (tag->dataSize != WORLD_UUID_LEN) {
|
||||
tag->err = CW_ERR_UUID_LEN;
|
||||
tag->result = CW_ERR_UUID_LEN;
|
||||
} else {
|
||||
Mem_Copy(World.Uuid, tag->value.small, WORLD_UUID_LEN);
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ static struct HttpCacheEntry http_cache[HTTP_CACHE_ENTRIES];
|
||||
|
||||
/* Splits up the components of a URL */
|
||||
static void HttpCache_MakeEntry(const String* url, struct HttpCacheEntry* entry, String* resource) {
|
||||
String scheme, path, addr, name, port;
|
||||
String scheme, path, addr, name, port, _resource;
|
||||
/* URL is of form [scheme]://[server name]:[server port]/[resource] */
|
||||
int idx = String_IndexOfConst(url, "://");
|
||||
|
||||
@ -682,8 +682,10 @@ static void HttpCache_MakeEntry(const String* url, struct HttpCacheEntry* entry,
|
||||
path = idx == -1 ? *url : String_UNSAFE_SubstringAt(url, idx + 3);
|
||||
entry->Https = String_CaselessEqualsConst(&scheme, "https");
|
||||
|
||||
String_UNSAFE_Separate(&path, '/', &addr, resource);
|
||||
String_UNSAFE_Separate(&path, '/', &addr, &_resource);
|
||||
String_UNSAFE_Separate(&addr, ':', &name, &port);
|
||||
/* Address may have unicode characters - need to percent encode them */
|
||||
Http_UrlEncodeUtf8(resource, &_resource);
|
||||
|
||||
String_InitArray_NT(entry->Address, entry->_addressBuffer);
|
||||
String_Copy(&entry->Address, &name);
|
||||
@ -766,8 +768,8 @@ static cc_result Http_StartRequest(struct HttpRequest* req, String* url, HINTERN
|
||||
DWORD flags, bufferLen;
|
||||
cc_result res;
|
||||
|
||||
String_InitArray_NT(path, pathBuffer);
|
||||
HttpCache_MakeEntry(url, &entry, &path);
|
||||
Mem_Copy(pathBuffer, path.buffer, path.length);
|
||||
pathBuffer[path.length] = '\0';
|
||||
if ((res = HttpCache_Lookup(&entry))) return res;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user