Remove unused index argument from Utils_IsUrlPrefix

This commit is contained in:
UnknownShadow200 2019-07-15 21:34:18 +10:00
parent ec39ee90a7
commit 5c0cd0d871
7 changed files with 12 additions and 11 deletions

View file

@ -154,7 +154,7 @@ void Entity_SetModel(struct Entity* e, const String* model) {
Entity_UpdateModelBounds(e);
skin = String_FromRawArray(e->SkinNameRaw);
if (Utils_IsUrlPrefix(&skin, 0)) { e->MobTextureId = e->TextureId; }
if (Utils_IsUrlPrefix(&skin)) e->MobTextureId = e->TextureId;
}
void Entity_UpdateModelBounds(struct Entity* e) {
@ -349,7 +349,7 @@ static void Entity_CopySkin(struct Entity* dst, struct Entity* src) {
/* Custom mob textures */
dst->MobTextureId = GFX_NULL;
skin = String_FromRawArray(dst->SkinNameRaw);
if (Utils_IsUrlPrefix(&skin, 0)) dst->MobTextureId = dst->TextureId;
if (Utils_IsUrlPrefix(&skin)) dst->MobTextureId = dst->TextureId;
}
/* Resets skin data for the given entity */

View file

@ -895,7 +895,7 @@ void Http_AsyncGetSkin(const String* skinName) {
String url; char urlBuffer[STRING_SIZE];
String_InitArray(url, urlBuffer);
if (Utils_IsUrlPrefix(skinName, 0)) {
if (Utils_IsUrlPrefix(skinName)) {
String_Copy(&url, skinName);
} else {
String_AppendConst(&url, SKIN_SERVER);

View file

@ -31,8 +31,8 @@ void Inventory_SetHotbarIndex(int index) {
void Inventory_SetSelectedBlock(BlockID block) {
int i;
if (!Inventory_CheckChangeSelected()) return;
/* Swap with the current, if the new block is already in the hotbar */
/* Swap with currently selected block if given block is already in the hotbar */
for (i = 0; i < INVENTORY_BLOCKS_PER_HOTBAR; i++) {
if (Inventory_Get(i) != block) continue;
Inventory_Set(i, Inventory_SelectedBlock);

View file

@ -1193,7 +1193,7 @@ static void CPE_SetTextColor(uint8_t* data) {
static void CPE_SetMapEnvUrl(uint8_t* data) {
String url = Protocol_UNSAFE_GetString(data);
if (!url.length || Utils_IsUrlPrefix(&url, 0)) {
if (!url.length || Utils_IsUrlPrefix(&url)) {
Server_RetrieveTexturePack(&url);
}
Platform_Log1("Tex url: %s", &url);

View file

@ -1022,7 +1022,7 @@ static bool ChatScreen_MouseDown(void* screen, int x, int y, MouseButton btn) {
TextGroupWidget_GetSelected(&s->chat, &text, x, y);
if (!text.length) return false;
if (Utils_IsUrlPrefix(&text, 0)) {
if (Utils_IsUrlPrefix(&text)) {
Gui_ShowOverlay(UrlWarningOverlay_MakeInstance(&text));
} else if (Gui_ClickableChat) {
InputWidget_AppendString(&s->input.base, &text);

View file

@ -19,12 +19,12 @@ int Utils_ParseEnum(const String* text, int defValue, const char** names, int na
return defValue;
}
bool Utils_IsUrlPrefix(const String* value, int index) {
bool Utils_IsUrlPrefix(const String* value) {
static const String http = String_FromConst("http://");
static const String https = String_FromConst("https://");
return String_IndexOfString(value, &http) == index
|| String_IndexOfString(value, &https) == index;
return String_IndexOfString(value, &http) == 0
|| String_IndexOfString(value, &https) == 0;
}
bool Utils_EnsureDirectory(const char* dirName) {

View file

@ -28,7 +28,8 @@ struct DateTime {
#define MILLIS_PER_DAY (1000 * 60 * 60 * 24)
CC_NOINLINE int Utils_ParseEnum(const String* text, int defValue, const char** names, int namesCount);
bool Utils_IsUrlPrefix(const String* value, int index);
/* Returns whether value starts with http:// or https:// */
bool Utils_IsUrlPrefix(const String* value);
/* Creates the directory if it doesn't exist. (logs failure using Logger_Warn2) */
bool Utils_EnsureDirectory(const char* dirName);