From c3ef6811b340b72e59d9bae35bc544cdcebe91e3 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 24 Dec 2021 14:47:01 +0100 Subject: [PATCH] Small cleanup --- qcsrc/menu/xonotic/serverlist.qc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index f62b2f231..e20a13a8e 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -452,10 +452,11 @@ void XonoticServerList_draw(entity me) for(int i = 0; i < category_draw_count; ++i) { category_name[i] = -1; category_item[i] = -1; } category_draw_count = 0; + me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); + if(autocvar_menu_slist_categories >= 0) // if less than 0, don't even draw a category heading for favorites { - float itemcount = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); - me.nItems = itemcount; + int itemcount = me.nItems; //float visible = floor(me.scrollPos / me.itemHeight); // ^ unfortunately no such optimization can be made-- we must process through the @@ -538,7 +539,6 @@ void XonoticServerList_draw(entity me) me.nItems = itemcount; } } - else { me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); } me.connectButton.disabled = (me.ipAddressBox.text == ""); //me.disconnectButton.disabled = (!(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))); @@ -783,8 +783,8 @@ void ServerList_Info_Click(entity btn, entity me) if (me.nItems != 0) main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem); - float thisPos = me.getItemStart(me, me.selectedItem); - float thisHeight = me.getItemHeight(me, me.selectedItem); + float thisPos = me.getItemStart(me, me.selectedItem); + float thisHeight = me.getItemHeight(me, me.selectedItem); vector org = boxToGlobal(eY * (thisPos - me.scrollPos), me.origin, me.size); vector sz = boxToGlobalSize(eY * thisHeight + eX * (1 - me.controlWidth), me.size); DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz); @@ -1153,7 +1153,7 @@ int XonoticServerList_getItemAtPos(entity me, float pos) pos = pos / me.itemHeight; for (int i = category_draw_count - 1; i >= 0; --i) { int itemidx = category_item[i]; - float itempos = i * me.categoriesHeight + category_item[i] * me.serversHeight; + float itempos = i * me.categoriesHeight + itemidx * me.serversHeight; if (pos >= itempos + me.categoriesHeight + me.serversHeight) return itemidx + 1 + floor((pos - (itempos + me.categoriesHeight + me.serversHeight)) / me.serversHeight); if (pos >= itempos) @@ -1166,7 +1166,7 @@ float XonoticServerList_getItemStart(entity me, int item) { for (int i = category_draw_count - 1; i >= 0; --i) { int itemidx = category_item[i]; - float itempos = i * me.categoriesHeight + category_item[i] * me.serversHeight; + float itempos = i * me.categoriesHeight + itemidx * me.serversHeight; if (item >= itemidx + 1) return (itempos + me.categoriesHeight + (1 + item - (itemidx + 1)) * me.serversHeight) * me.itemHeight; if (item >= itemidx) -- 2.39.2