Skip to content

Instantly share code, notes, and snippets.

@TSedlar
Last active February 3, 2024 22:24
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save TSedlar/99339b9c73f19f7e6ec620f5fdba78ad to your computer and use it in GitHub Desktop.
Save TSedlar/99339b9c73f19f7e6ec620f5fdba78ad to your computer and use it in GitHub Desktop.
@echo off
if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit
SetLocal EnableDelayedExpansion
set worlds=2 3 4 5 6 7 9 10 11 12 13 14 17 18 19 20 21 22 27 28 29 30 33 34 36 38 41 42 43 44 46 49 50 51 53 54 58 59 60 61 62 65 66 67 68 69 70 73 74 75 76 77 78 86
set pos=0
set found=false
: Ping all worlds and order array by best result
echo ----- Pinging Worlds -----
for %%w in (%worlds%) do (
set url=oldschool%%w.runescape.com
for /F "tokens=1-9 delims==< " %%a in ('PING -n 3 -w 10000 !url!') do if "%%h"=="TTL" set response=%%g
echo Pinging !url! .. !response!
set current=!response:~0, -2!
for /L %%n in (0, 1, !pos!-1) do (
if !found!==false (
set item=!pings[%%n]!
if !current! lss !item! (
set found=true
set /A insert=%%n
)
)
)
if !found!==true (
for /L %%x in (!pos!, -1, !insert!) do (
set /A idx=%%x+1
set pings[!idx!]=!pings[%%x]!
set ordered[!idx!]=!ordered[%%x]!
)
set pings[!insert!]=!current!
set ordered[!insert!]=%%w
) else (
set pings[!pos!]=!current!
set ordered[!pos!]=%%w
)
set found=false
set /A pos+=1
)
: Index array
set pos=0
for %%p in (!worlds!) do ( set "worlds[!pos!]=%%p" & set /A "pos+=1" )
: List top 5 worlds
echo ------ Top 5 Worlds ------
for /L %%x in (0, 1, 4) do (
set /A rank=%%x+1
echo !rank!. World !ordered[%%x]! has !pings[%%x]!ms ping
)
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment