mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Merge branch 'master' of https://github.com/whatsavalue3/ClassiCube
This commit is contained in:
commit
eecd3fbdeb
@ -273,7 +273,7 @@ static struct ChatCommand SkinCommand = {
|
||||
};
|
||||
|
||||
static void ClearDeniedCommand_Execute(const cc_string* args, int argsCount) {
|
||||
int count = TextureCache_ClearDenied();
|
||||
int count = TextureUrls_ClearDenied();
|
||||
Chat_Add1("Removed &e%i &fdenied texture pack URLs.", &count);
|
||||
}
|
||||
|
||||
|
@ -2738,7 +2738,7 @@ static cc_bool TexPackOverlay_IsAlways(void* screen, void* w) {
|
||||
static void TexPackOverlay_YesClick(void* screen, void* widget) {
|
||||
struct TexPackOverlay* s = (struct TexPackOverlay*)screen;
|
||||
TexturePack_Extract(&s->url);
|
||||
if (TexPackOverlay_IsAlways(s, widget)) TextureCache_Accept(&s->url);
|
||||
if (TexPackOverlay_IsAlways(s, widget)) TextureUrls_Accept(&s->url);
|
||||
Gui_Remove((struct Screen*)s);
|
||||
|
||||
if (TexPackOverlay_IsAlways(s, widget)) CPE_SendNotifyAction(NOTIFY_ACTION_TEXTURE_PROMPT_RESPONDED, 3);
|
||||
@ -2754,7 +2754,7 @@ static void TexPackOverlay_NoClick(void* screen, void* widget) {
|
||||
|
||||
static void TexPackOverlay_ConfirmNoClick(void* screen, void* b) {
|
||||
struct TexPackOverlay* s = (struct TexPackOverlay*)screen;
|
||||
if (s->alwaysDeny) TextureCache_Deny(&s->url);
|
||||
if (s->alwaysDeny) TextureUrls_Deny(&s->url);
|
||||
Gui_Remove((struct Screen*)s);
|
||||
|
||||
if (s->alwaysDeny) CPE_SendNotifyAction(NOTIFY_ACTION_TEXTURE_PROMPT_RESPONDED, 0);
|
||||
|
@ -45,9 +45,9 @@ static void Server_ResetState(void) {
|
||||
}
|
||||
|
||||
void Server_RetrieveTexturePack(const cc_string* url) {
|
||||
if (!Game_AllowServerTextures || TextureCache_HasDenied(url)) return;
|
||||
if (!Game_AllowServerTextures || TextureUrls_HasDenied(url)) return;
|
||||
|
||||
if (!url->length || TextureCache_HasAccepted(url)) {
|
||||
if (!url->length || TextureUrls_HasAccepted(url)) {
|
||||
TexturePack_Extract(url);
|
||||
} else {
|
||||
TexPackOverlay_Show(url);
|
||||
|
@ -255,40 +255,62 @@ cc_bool Atlas_TryChange(struct Bitmap* atlas) {
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------TextureCache-------------------------------------------------------*
|
||||
*------------------------------------------------------TextureUrls--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static struct StringsBuffer acceptedList, deniedList, etagCache, lastModCache;
|
||||
#ifdef CC_BUILD_NETWORKING
|
||||
static struct StringsBuffer acceptedList, deniedList;
|
||||
#define ACCEPTED_TXT "texturecache/acceptedurls.txt"
|
||||
#define DENIED_TXT "texturecache/deniedurls.txt"
|
||||
#define ETAGS_TXT "texturecache/etags.txt"
|
||||
#define LASTMOD_TXT "texturecache/lastmodified.txt"
|
||||
|
||||
/* Initialises cache state (loading various lists) */
|
||||
static void TextureCache_Init(void) {
|
||||
static void TextureUrls_Init(void) {
|
||||
EntryList_UNSAFE_Load(&acceptedList, ACCEPTED_TXT);
|
||||
EntryList_UNSAFE_Load(&deniedList, DENIED_TXT);
|
||||
EntryList_UNSAFE_Load(&etagCache, ETAGS_TXT);
|
||||
EntryList_UNSAFE_Load(&lastModCache, LASTMOD_TXT);
|
||||
}
|
||||
|
||||
cc_bool TextureCache_HasAccepted(const cc_string* url) { return EntryList_Find(&acceptedList, url, ' ') >= 0; }
|
||||
cc_bool TextureCache_HasDenied(const cc_string* url) { return EntryList_Find(&deniedList, url, ' ') >= 0; }
|
||||
cc_bool TextureUrls_HasAccepted(const cc_string* url) { return EntryList_Find(&acceptedList, url, ' ') >= 0; }
|
||||
cc_bool TextureUrls_HasDenied(const cc_string* url) { return EntryList_Find(&deniedList, url, ' ') >= 0; }
|
||||
|
||||
void TextureCache_Accept(const cc_string* url) {
|
||||
void TextureUrls_Accept(const cc_string* url) {
|
||||
EntryList_Set(&acceptedList, url, &String_Empty, ' ');
|
||||
EntryList_Save(&acceptedList, ACCEPTED_TXT);
|
||||
}
|
||||
void TextureCache_Deny(const cc_string* url) {
|
||||
|
||||
void TextureUrls_Deny(const cc_string* url) {
|
||||
EntryList_Set(&deniedList, url, &String_Empty, ' ');
|
||||
EntryList_Save(&deniedList, DENIED_TXT);
|
||||
}
|
||||
|
||||
int TextureCache_ClearDenied(void) {
|
||||
int TextureUrls_ClearDenied(void) {
|
||||
int count = deniedList.count;
|
||||
StringsBuffer_Clear(&deniedList);
|
||||
EntryList_Save(&deniedList, DENIED_TXT);
|
||||
return count;
|
||||
}
|
||||
#else
|
||||
static void TextureUrls_Init(void) { }
|
||||
|
||||
cc_bool TextureUrls_HasAccepted(const cc_string* url) { return false; }
|
||||
cc_bool TextureUrls_HasDenied(const cc_string* url) { return false; }
|
||||
|
||||
void TextureUrls_Accept(const cc_string* url) { }
|
||||
|
||||
void TextureUrls_Deny(const cc_string* url) { }
|
||||
|
||||
int TextureUrls_ClearDenied(void) { return 0; }
|
||||
#endif
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------TextureCache-------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static struct StringsBuffer etagCache, lastModCache;
|
||||
#define ETAGS_TXT "texturecache/etags.txt"
|
||||
#define LASTMOD_TXT "texturecache/lastmodified.txt"
|
||||
|
||||
static void TextureCache_Init(void) {
|
||||
EntryList_UNSAFE_Load(&etagCache, ETAGS_TXT);
|
||||
EntryList_UNSAFE_Load(&lastModCache, LASTMOD_TXT);
|
||||
}
|
||||
|
||||
CC_INLINE static void HashUrl(cc_string* key, const cc_string* url) {
|
||||
String_AppendUInt32(key, Utils_CRC32((const cc_uint8*)url->buffer, url->length));
|
||||
@ -696,6 +718,7 @@ static void OnInit(void) {
|
||||
Utils_EnsureDirectory("texpacks");
|
||||
Utils_EnsureDirectory("texturecache");
|
||||
TextureCache_Init();
|
||||
TextureUrls_Init();
|
||||
}
|
||||
|
||||
static void OnReset(void) {
|
||||
|
@ -80,17 +80,17 @@ TextureRec Atlas1D_TexRec(TextureLoc texLoc, int uCount, int* index);
|
||||
void Atlas1D_Bind(int index);
|
||||
|
||||
/* Whether the given URL is in list of accepted URLs. */
|
||||
cc_bool TextureCache_HasAccepted(const cc_string* url);
|
||||
cc_bool TextureUrls_HasAccepted(const cc_string* url);
|
||||
/* Whether the given URL is in list of denied URLs. */
|
||||
cc_bool TextureCache_HasDenied(const cc_string* url);
|
||||
cc_bool TextureUrls_HasDenied(const cc_string* url);
|
||||
/* Adds the given URL to list of accepted URLs, then saves it. */
|
||||
/* Accepted URLs are loaded without prompting the user. */
|
||||
void TextureCache_Accept(const cc_string* url);
|
||||
void TextureUrls_Accept(const cc_string* url);
|
||||
/* Adds the given URL to list of denied URLs, then saves it. */
|
||||
/* Denied URLs are never loaded. */
|
||||
void TextureCache_Deny(const cc_string* url);
|
||||
void TextureUrls_Deny(const cc_string* url);
|
||||
/* Clears the list of denied URLs, returning number removed. */
|
||||
int TextureCache_ClearDenied(void);
|
||||
int TextureUrls_ClearDenied(void);
|
||||
|
||||
/* Request ID of texture pack currently being downloaded */
|
||||
extern int TexturePack_ReqID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user