diff --git a/src/Chat.c b/src/Chat.c index 9e57dc9b1..4d7732510 100644 --- a/src/Chat.c +++ b/src/Chat.c @@ -429,6 +429,19 @@ static struct ChatCommand ModelCommand = { } }; +static void ClearDeniedCommand_Execute(const String* args, int argsCount) { + int count = TextureCache_ClearDenied(); + Chat_Add1("Removed &e%i &fdenied texture pack URLs.", &count); +} + +static struct ChatCommand ClearDeniedCommand = { + "ClearDenied", ClearDeniedCommand_Execute, false, + { + "&a/client cleardenied", + "&eClears the list of texture pack URLs you have denied", + } +}; + /*########################################################################################################################* *-------------------------------------------------------CuboidCommand-----------------------------------------------------* @@ -589,6 +602,7 @@ static void Chat_Init(void) { Commands_Register(&ModelCommand); Commands_Register(&CuboidCommand); Commands_Register(&TeleportCommand); + Commands_Register(&ClearDeniedCommand); Chat_Logging = Options_GetBool(OPT_CHAT_LOGGING, true); } diff --git a/src/TexturePack.c b/src/TexturePack.c index 8510448f5..89d0daf4b 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -527,15 +527,22 @@ void TextureCache_Init(void) { cc_bool TextureCache_HasAccepted(const String* url) { return EntryList_Find(&acceptedList, url) >= 0; } cc_bool TextureCache_HasDenied(const String* url) { return EntryList_Find(&deniedList, url) >= 0; } -void TextureCache_Accept(const String* url) { +void TextureCache_Accept(const String* url) { EntryList_Set(&acceptedList, url, &String_Empty); EntryList_Save(&acceptedList); } -void TextureCache_Deny(const String* url) { +void TextureCache_Deny(const String* url) { EntryList_Set(&deniedList, url, &String_Empty); EntryList_Save(&deniedList); } +int TextureCache_ClearDenied(void) { + int count = deniedList.entries.count; + StringsBuffer_Clear(&deniedList.entries); + EntryList_Save(&deniedList); + return count; +} + CC_INLINE static void TextureCache_HashUrl(String* key, const String* url) { String_AppendUInt32(key, Utils_CRC32((const cc_uint8*)url->buffer, url->length)); } diff --git a/src/TexturePack.h b/src/TexturePack.h index e503bd5d0..caceb7da9 100644 --- a/src/TexturePack.h +++ b/src/TexturePack.h @@ -82,6 +82,8 @@ void TextureCache_Accept(const String* url); /* Adds the given URL to list of denied URLs, then saves it. */ /* Denied URLs are never loaded. */ void TextureCache_Deny(const String* url); +/* Clears the list of denied URLs, returning number removed. */ +int TextureCache_ClearDenied(void); /* Returns whether the given URL has been cached. */ cc_bool TextureCache_Has(const String* url);