Skip to content

Commit c8f75ec

Browse files
committed
Merge origin/modernize-codebase-final-final into main
2 parents c540bc0 + 899c60b commit c8f75ec

325 files changed

Lines changed: 6480 additions & 1063 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gradle.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Java CI with Gradle
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: '21'
21+
distribution: 'temurin'
22+
- name: Setup Gradle
23+
uses: gradle/gradle-build-action@v2
24+
- name: Build with Gradle
25+
run: ./gradlew build

.gitignore

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
.idea/
2-
3-
target/
4-
bin/
5-
res/data/
6-
7-
8-
nullexitautosave.h.zip
9-
exitautosave.h.zip
10-
nullexitautosave.h.zip.temp
11-
12-
dependency-reduced-pom.xml
13-
1+
.gradle
2+
build
3+
out
4+
bin
145
*.class
156
*.bak
167
build/

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM gradle:8.5-jdk21 AS builder
2+
WORKDIR /app
3+
COPY . .
4+
RUN ./gradlew :server:installDist -x test
5+
6+
FROM eclipse-temurin:21-jre-alpine
7+
WORKDIR /app
8+
COPY --from=builder /app/server/build/install/server /app/server
9+
COPY entrypoint.sh /app/
10+
RUN chmod +x /app/entrypoint.sh
11+
12+
EXPOSE 4444 4445 4446/udp
13+
14+
ENTRYPOINT ["/app/entrypoint.sh"]

README.md

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,93 @@
22

33
# bob's game
44

5-
https://youtu.be/IAD7phjdMQo
5+
This repository contains the modernized source code for "Bob's Game" (2012), updated to run on modern Java 21 infrastructure.
66

7-
https://youtu.be/EBC1QKso3II
7+
## Architecture
88

9-
## Setup
9+
The project is split into three Gradle modules:
1010

11-
Open project in IntelliJ or Eclipse.
11+
- **`:client`**: The game client (LWJGL 3, OpenGL, OpenAL).
12+
- **`:server`**: The backend infrastructure (Game Server, Index Server, STUN Server).
13+
- **`:shared`**: Shared logic, networking packets, and utilities.
1214

13-
Run STUN Server, Index Server, Server, and then Client.
15+
For a detailed breakdown of the project structure and dependencies, see [STRUCTURE.md](STRUCTURE.md).
1416

15-
Or, run Editor, then open bobsgame_v8830.zip. Export data to create local cache server. (to be detailed further)
17+
## Prerequisites
1618

17-
discussion here: <https://discord.gg/FfDxFc4JuS>
19+
- JDK 21
20+
- Docker (optional, for server deployment)
21+
22+
## Building
23+
24+
To build all modules:
25+
26+
```bash
27+
./gradlew build
28+
```
29+
30+
## Running the Client
31+
32+
```bash
33+
./gradlew :client:run
34+
```
35+
36+
## Running the Editor
37+
38+
To run the legacy Swing-based Level Editor:
39+
40+
```bash
41+
./gradlew :client:runEditor
42+
```
43+
44+
**New Editor Features:**
45+
- **Select All (Ctrl+A)**: Selects the entire map, sprite, or tileset in the respective editors.
46+
- **Replace Color**: New menu item in "Palette Tools" to swap a color index globally across the tileset.
47+
48+
## Running the Server
49+
50+
You can run the server locally or via Docker.
51+
52+
### Local
53+
54+
```bash
55+
./gradlew :server:run
56+
```
57+
58+
### Docker
59+
60+
Build and start the full stack (Game Server, STUN Server, MySQL Database):
61+
62+
```bash
63+
docker-compose up --build
64+
```
65+
66+
Configuration is handled via Environment Variables (see `docker-compose.yml`) or a `server.properties` file in the working directory.
67+
68+
## Features
69+
70+
- **Modern Tech Stack**: Java 21, Gradle 8.5, LWJGL 3, Netty 4, HikariCP.
71+
- **Security**: BCrypt password hashing with automatic legacy migration.
72+
- **Containerization**: Full Docker support.
73+
- **CI/CD**: GitHub Actions workflow included.
74+
75+
## Changelog
76+
77+
### Modernization Phase (Current)
78+
- **Migrated to Gradle**: Multi-module project structure.
79+
- **Updated Java**: Targeted Java 21.
80+
- **Upgraded LWJGL**: Migrated from 2 to 3 (GLFW, OpenAL, STB).
81+
- **Upgraded Netty**: Migrated from 3 to 4.
82+
- **Security**: Added BCrypt password hashing.
83+
- **Infrastructure**: Added Docker and CI/CD support.
84+
- **Editor**: Re-enabled legacy Swing Editor, added 'Select All' and 'Replace Color' features.
85+
86+
## Roadmap
87+
88+
- [x] Modernize Build System (Gradle)
89+
- [x] Upgrade Java to 21
90+
- [x] Migrate Networking to Netty 4
91+
- [x] Migrate Graphics to LWJGL 3
92+
- [x] Re-enable Level Editor
93+
- [ ] Port Editor to LibGDX / Scene2D (Future)
94+
- [ ] Implement remaining TODO items

STRUCTURE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Project Structure & Dashboard
2+
3+
## Modules
4+
5+
### Root Project
6+
* `build.gradle`: Root build configuration (versions, plugins, repositories).
7+
* `settings.gradle`: Module definitions (`include 'client', 'server', 'shared'`).
8+
9+
### `:shared`
10+
* **Path**: `shared/src/main/java/com/bobsgame`
11+
* **Purpose**: Common logic shared between Client and Server.
12+
* **Key Packages**:
13+
* `utils`: `HexDumper`, `Compression`, `Ternary`.
14+
* `net`: `WaveData` (Audio), Networking constants.
15+
16+
### `:server`
17+
* **Path**: `server/src/main/java/com/bobsgame`
18+
* **Purpose**: The authoritative game server and STUN server.
19+
* **Key Components**:
20+
* `ServerMain`: Entry point.
21+
* `GameServerTCP`: Netty-based TCP server handler.
22+
* `UDPConnection`: Netty-based UDP handling.
23+
* `DBHandler`: Database interaction (HikariCP/MySQL).
24+
* `Match`: Handles game session logic.
25+
26+
### `:client`
27+
* **Path**: `client/src/main/java/com/bobsgame`
28+
* **Purpose**: The Game Client (LWJGL 3) and Level Editor (Swing).
29+
* **Key Components**:
30+
* `ClientMain`: Game entry point.
31+
* `EditorMain`: Level Editor entry point (Swing).
32+
* `GameClientTCP`: Netty-based client networking.
33+
* `Texture`, `Font`: Custom rendering wrappers (stb/GL).
34+
35+
## Resources (`res/`)
36+
* `gfx/`: Sprites and textures.
37+
* `sfx/`: Audio files.
38+
* `music/`: Background music.
39+
* `maps/`: Game maps (`.map`).
40+
* `tilesets/`: Tileset definitions.
41+
42+
## Documentation
43+
* `README.md`: General usage and setup.
44+
* `HANDOFF.md`: Modernization details and notes for developers.
45+
* `docs/`: Legacy documentation and todo lists.

client/build.gradle

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import org.gradle.internal.os.OperatingSystem
2+
3+
plugins {
4+
id 'java'
5+
id 'application'
6+
}
7+
8+
project.ext.lwjglVersion = "3.3.3"
9+
10+
switch (OperatingSystem.current()) {
11+
case OperatingSystem.LINUX:
12+
project.ext.lwjglNatives = "natives-linux"
13+
break
14+
case OperatingSystem.MAC_OS:
15+
project.ext.lwjglNatives = "natives-macos"
16+
break
17+
case OperatingSystem.WINDOWS:
18+
project.ext.lwjglNatives = "natives-windows"
19+
break
20+
}
21+
22+
dependencies {
23+
implementation project(':shared')
24+
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
25+
26+
implementation "org.lwjgl:lwjgl"
27+
implementation "org.lwjgl:lwjgl-glfw"
28+
implementation "org.lwjgl:lwjgl-opengl"
29+
implementation "org.lwjgl:lwjgl-openal"
30+
implementation "org.lwjgl:lwjgl-stb"
31+
implementation "org.lwjgl:lwjgl-jemalloc"
32+
33+
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
34+
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
35+
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
36+
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
37+
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
38+
runtimeOnly "org.lwjgl:lwjgl-jemalloc::$lwjglNatives"
39+
40+
implementation files('../libs/TWL.jar')
41+
implementation files('../libs/TWLEffects.jar')
42+
implementation files('../libs/ibxm77.jar')
43+
44+
implementation 'com.googlecode.soundlibs:jorbis:0.0.17.4'
45+
implementation 'org.apache.httpcomponents.client5:httpclient5:5.1.3'
46+
implementation 'net.java.jinput:jinput:2.0.9'
47+
implementation 'commons-net:commons-net:3.8.0'
48+
implementation 'com.restfb:restfb:2022.10.0'
49+
implementation 'xpp3:xpp3:1.1.4c'
50+
51+
// Editor dependencies were here but removed/excluded
52+
}
53+
54+
sourceSets {
55+
main {
56+
java {
57+
srcDirs = ['src/main/java', '../libs/twl-lwjgl3/src']
58+
}
59+
resources {
60+
srcDirs = ['src/main/resources', '../res']
61+
}
62+
}
63+
}
64+
65+
application {
66+
mainClass = 'com.bobsgame.ClientMain'
67+
}
68+
69+
tasks.register('runEditor', JavaExec) {
70+
mainClass = 'com.bobsgame.EditorMain'
71+
classpath = sourceSets.main.runtimeClasspath
72+
jvmArgs = ['-Djava.library.path=../libs/natives'] // Might not be needed with LWJGL3
73+
}

src/main/java/com/bobsgame/ClientMain.java renamed to client/src/main/java/com/bobsgame/ClientMain.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -368,31 +368,6 @@ public void showControlsImage() {
368368
}
369369
}
370370

371-
public void makeGhostThread() {
372-
// ghost thread to prevent stuttering
373-
// this is due to windows aero, for some reason creating a ghost thread prevents it for some fucking reason
374-
new Thread(new Runnable() {
375-
@Override
376-
public void run() {
377-
try {
378-
Thread.currentThread().setName("ClientMain_ghostThreadToPreventAeroStutter");
379-
} catch (SecurityException e) {
380-
e.printStackTrace();
381-
}
382-
383-
while (exit == false) {
384-
try {
385-
Thread.sleep(16);//this only seems to work at 16
386-
387-
//Thread.yield(); //high cpu usage
388-
//if(Display.isActive()==false)Display.processMessages();
389-
} catch (Exception e) {
390-
e.printStackTrace();
391-
}
392-
}
393-
}
394-
}).start();
395-
}
396371

397372
public void initDebugLogger() {
398373
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
@@ -702,7 +677,6 @@ public void setFacebookCredentials(String facebookID, String accessToken) {
702677
}
703678

704679
public void mainLoop() {
705-
makeGhostThread();
706680
focus();
707681
StatsUtils.initTimers();
708682

0 commit comments

Comments
 (0)