How jameskmonger/317refactor works
Project Type and Purpose
• This is a standalone game‐client monolith (Java), specifically a refactored RuneScape 317 client for educational purposes.
• Its primary responsibility is to run the game loop: load resources, handle input, process game logic, render graphics, play audio, and communicate with a server.
High‐Level Architecture Analysis
• Top‐level “src/com/jagex/runescape” contains core game classes (Client, RSApplet, RSFrame).
• Subpackages break out subsystems:
• audio – sound generation and filtering
• bzip2 – data decompression
• collection – custom data structures and caches
• definition – game‐asset metadata (items, objects, animations)
• isaac – random number generator for packet obfuscation
• scene – world‐model and tile/objects spatial data
• screen – UI layers (title, game screen, minimap)
• sign – networking helper (signlink, RSSocket, OnDemandFetcher)
• docs/tile_rendering.md gives insight into tile rendering logic.
Key Components
a. Game Client Core
• RSApplet/RSFrame: windowing and bootstrapping
• Client.java: main game loop (tick, render, update)
b. Input Handling
• MouseDetection, TextInput, TextClass
c. Networking & Data Fetching
• signlink.java, RSSocket, OnDemandFetcher, OnDemandData, PacketInformation
• ISAACRandomGenerator: packet stream encryption/decryption
d. Resource Management
• Archive, FileCache, Buffer, bzip2 Decompressor, IndexedImage, Sprite
• collection.Cache, CacheableQueue for in‐memory asset caches
e. Game World & Logic
• WorldController, Region, CollisionMap, GameObject, NPC, Player, Projectile
• definition.*: metadata loaders for entities, animations, maps
f. Rendering Engine
• Rasterizer, DrawingArea, TiledUtils, Model/ModelHeader, VertexNormal
• scene.tile and scene.object classes
g. UI / Screen Layers
• RSInterface, TitleScreen, FlameColours, Minimap
h. Audio Subsystem
• Instrument, Effect, SoundFilter, Envelope
Relationships and Data Flows
• On start, RSApplet → Client.main initializes signlink, caching, resource archives.
• Client enters game loop:
1. Input Handling → updates input state
2. Game Logic (Client) → uses definitions, world state, collision maps to update entities
3. Networking → send/receive packets via RSSocket; pack/unpack with ISAAC
4. Resource Manager → fetch missing assets on demand (OnDemandFetcher) → decompress with Bzip2 → cache
5. Rendering → Rasterizer and DrawingArea render tiles, models, UI
6. Audio → generate sounds per game events via audio subsystem
• Subsystems talk to central caches (collection.Cache) and archives.
Architectural Patterns and Principles
• Modular subsystems organized by feature (rendering, audio, networking).
• Custom caching layer to manage memory usage.
• Single‐threaded game loop driving all subsystems.
• Data‐driven definitions for game assets.