Portable single-threaded C client for early RS2, the last update before a new cache format and ondemand protocol.
Compatible with 2004Scape, the most accurate runescape remake
Features:
- should run on any 32 bit system with 64 MB of RAM on lowmem
- webassembly build to avoid javascript code being optimized out by the browser.
- optional config.ini file to change client behaviour, see config.ini.example for options. To avoid passing command line arguments each time you can create an empty config.ini.
During limited playtesting the client seems to be stable, but it could crash at any time! Run sanitizer or tcc debug backtrace build to share errors
See known issues before reporting an issue.
All you need to build for 32 bit windows is included:
- tinycc (C compiler, built with
TCC_C=..\tcc.c
env var and some removed libs for smaller distribution) - libeay32.dll for faster rsa https://gnuwin32.sourceforge.net/packages/openssl.htm
- all 32 bit SDL dlls, only SDL1 works prior to windows XP and is always 32 bit unlike the others
To build simply run build.bat
in cmd to get the client.exe, it depends on the cache + SDL.dll, libeay32.dll, and optionally .sf2 soundfont/config.ini
build.bat -h
shows options, EG -v 1|2|3
sets SDL version and -c tcc|gcc|emcc
for system tcc, gcc, emcc
Both tcc and old mingw-gcc can target windows 9x with SDL 1. This (unofficial) release doesn't require msys install: https://github.com/fsb4000/gcc-for-Windows98/releases. mingw-gcc 11 optimizations seem to only be slightly faster than tcc though.
type ::perf
command ingame to see fps and lrucache size
- If the client fails to start it most likely means you are using a SDL dll for the wrong architecture. Delete them and it should copy during next build
- If the server changes cache it has to be manually updated in cache/ directory for now (still happens if new mapdata is found). Crc is disabled for maps and archives for time being.
- You first have to put a
#
in front of all lines that contain the fields below to ignore them
# nodeid = 1
# portoff = 0
# server = localhost
# http_port = 80
- Then remove the
#
from the grouped fields of the world you want to access, some worlds don't need all fields and use the defaults.
auto-generated js by emscripten is blocking default browser shortcuts why exactly, also pressing fkeys types uppercase letters even if it doesn't steal input
server cache changes would require manual cache update in client for now, it isn't supposed to change but as of right now there's an issue with client map crcs being changed when server maps get updated (also the cache has some interface changes rn for quest tab and another one) enable crc again after fixes. Maybe also use emscripten indexeddb api to store data file?
figure out rsaenc bug(s), i'm thinking there are multiple issues (chance of failing login), RSA_BIGINT can still fail due to wrong enc length, but the others fail due to other reasons too...
no midi fading, causes death sound to cut off or other issue? pass midi fade data to callback?
emscripten wasm on firefox has js leaks on highmem, gets cleaned up by pressing GC in about:memory but why does this happen
emscripten wasm can speed up if the tab was unfocused but doesn't always speed up? need absolute time not idle_time for web, also test requestanimationframe again for 50 fps firefox hack ONLY if it supports absolute time (didn't seem like it)
set_pixels is using memcpy to copy surface pixels each time, but this is inefficient and very noticable on weak hardware. But causes crash on login/exit when the surface gets freed (apply this to all SDL if fixed)
the most complete platform layer is SDL2, but keyboard input is just an unfinished hack but usable except ctrl doesn't work for running yet.
locs like fires have no animations as pushLocs is disabled for now, it constantly allocates memory which requires a different approach
wordfilter isn't ported yet, so you will see your own swear words but others don't as it gets filtered by the server still.
the game uses 3 titles: "RuneScape - the massive online adventure game by Jagex Ltd" (website), "RuneScape Game" (html) and "Jagex" (jar), maybe show the first as it was most commonly seen
some bits from signlink missing (uid, reporterror, findcachedir, openurl, opensocket etc, move map loading to cacheload?
remove the refcounting from model/pix24/lrucache for components and do smth else (kept to avoid leak spam rn) as components get assigned models from packets which are put into lrucaches, so global component doesn't own the memory anymore
there are a few more small memleaks to work out, but they shouldn't become a problem outside of very memory constrained environments.
Firefox "lag" is due to setTimeout being broken with wasm as using the firefox profiler increases fps. Asyncify is not the problem here I've had it happen in wasm without emscripten, https://github.com/lesleyrs/web-gbc?tab=readme-ov-file#limitations
The "fix" is to use emscripten_set_main_loop_arg
with 0 fps which calls requestAnimationFrame instead. The function to be called should be the contents of the while loop in gameshell_run (delete the while loop itself) which will get you full FPS. If it still lags close devtools and refresh page. Downsides are that if the tab goes inactive it will speed up when returning, it doesn't seem fixable the same way as in Client2 since they still use setTimeout. Also Firefox won't have the benefit of the websocket never timing out anymore.
dnslookup on web just shows your public ip instead of dns, this is expected and the same applies to Client2. If dnslookup fails to resolve and welcome screen lags you can set hide_dns = 1
in config.ini to skip it.
SDL3 has high dpi support so window size might be smaller than SDL1/2 https://github.com/libsdl-org/SDL/blob/main/docs/README-highdpi.md
Outside of SDL3 or TCC the SDL header is exposed on windows ONLY to have SDL_main replace entrypoint for windows subsystem, don't use it
On windows we aren't loading system gm.dls but use a similar sf2 soundfont instead
emrun causes extra batch job message on windows sigint, can swap it for py -m http.server
or so to avoid it
Recompile is needed to change between different RSA key lengths, RSA_BUF_LEN needs to be set at compile time because it's needed for stack allocated arrays and BN_ARRAY_SIZE define.
instead of a clean target, try: git clean -fXdn
, remove n to delete files for real
- https://github.com/2004Scape/Server/wiki/FAQ
- https://runescape.wiki/w/Build_number
- https://oldschool.runescape.wiki/w/Graphical_updates_(historical)
- https://oldschool.runescape.wiki/w/User:Hlwys
The 2004 jar is stored for comparisons, run with EG: java -cp cache/runescape.jar client 10 0 highmem members
but:
- there is no audio, it saves audio files for the browser to play which is no longer applicable
- right clicking breaks past java 8
- window insets on modern systems are causing the sides of the game to be cut off slightly
- outside of windows it saves the cache to
/tmp
so every reboot you may have to redownload it - it only connects to localhost if it's not running as applet
- server http port needs to be set to 80 (2004scape on linux defaults to 8888 right now to avoid sudo)
- TODO confirm: to connect to local java servers on WSL from Windows you might need to add
-Djava.net.preferIPv6Addresses=true
when running client
build.bat(32 bit): tcc (included), mingw-gcc, emcc
run.ps1: cl, clang, tcc, mingw-gcc, emcc
You might want the updated PowerShell for run.ps1
Makefile: gcc, clang, tcc, mingw-gcc, emcc
If tcc isn't working you should build latest tcc from source
- micro-bunzip | https://landley.net/code/bunzip-4.1.c
- isaac | https://burtleburtle.net/bob/c/readable.c
- tiny-bignum-c
- ini
- TinySoundFont
- stb_image and stb_truetype
32 bit libeay32.dll from: gnuwin32
emcc libcrypto.a from: get-openssl-wasm.sh
VC and MinGW dlls seem to be the same?
Using prebuilt SDL releases but removed tests dir, removed dotfiles from mingw SDL1 and fixes in VC SDL1 for tcc. Latest SDL1 already contains the tcc fix but they don't make new releases for it.
- tcc | https://bellard.org/tcc/
- emsdk | https://emscripten.org/docs/getting_started/downloads.html
- devkitpro | https://devkitpro.org/
- https://github.com/2003scape/rsc-c - did a lot of the dirty work in advance (finding libs, networking, input)
- https://github.com/2004Scape/Client - renamed java client deob that the port was based on
- https://github.com/2004Scape/Client2 | https://github.com/LostCityRS/Client-TS - typescript port
- https://github.com/Pazaz/RS2-225
- https://github.com/RuneWiki/rs-deob