Skip to content

Commit 0f0477e

Browse files
authored
Merge pull request #19 from tslashd/reworks
Refactor and enhance SurfTimer functionality
2 parents 604eee0 + e22e616 commit 0f0477e

Some content is hidden

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

52 files changed

+5082
-3021
lines changed

.github/dependabot.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
# .github/dependabot.yml
7+
# Keep GitHub Actions up to date and open a SINGLE PR that aggregates all updates.
8+
9+
version: 2
10+
updates:
11+
- package-ecosystem: "github-actions" # manage versions of actions used in .github/workflows
12+
directory: "/" # repo root (covers .github/workflows)
13+
schedule:
14+
interval: "weekly" # run once a week
15+
day: "monday" # every Monday
16+
time: "04:00" # at 04:00 local time
17+
timezone: "Europe/Sofia"
18+
target-branch: "main" # PRs will target this branch
19+
open-pull-requests-limit: 10 # safety cap (not really needed with grouping)
20+
commit-message:
21+
prefix: "chore" # e.g., "chore: bump actions/*"
22+
include: "scope"
23+
groups:
24+
all-actions: # SINGLE PR with everything inside
25+
patterns: ["*"] # match all actions
26+
update-types: ["major", "minor", "patch"] # include all types of bumps
27+
28+
- package-ecosystem: "nuget" # manage NuGet packages in .csproj/.sln files
29+
directory: "/" # Dependabot discovers projects recursively
30+
schedule:
31+
interval: "weekly" # run once a week
32+
day: "monday" # every Monday
33+
time: "04:00" # at 04:00 local time
34+
timezone: "Europe/Sofia"
35+
target-branch: "main" # PRs will target this branch
36+
open-pull-requests-limit: 10 # safety cap (not really needed with grouping)
37+
commit-message:
38+
prefix: "chore" # e.g., "chore: bump MySqlConnector"
39+
include: "scope"
40+
groups:
41+
all-nuget: # SINGLE PR with everything inside
42+
patterns: ["*"] # match all packages
43+
update-types: ["major", "minor", "patch"] # include all types of bumps

.github/workflows/release.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Release SurfTimer.Plugin
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # auto trigger on tags like v1.2.3
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Tag to release (e.g., v1.2.3)"
11+
required: true
12+
default: "v0.0.0"
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Resolve release tag
23+
id: vars
24+
shell: bash
25+
run: |
26+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
27+
TAG="${{ github.event.inputs.tag }}"
28+
else
29+
TAG="${{ github.ref_name }}"
30+
fi
31+
if ! echo "$TAG" | grep -Eq '^v[0-9]'; then
32+
echo "Tag must start with 'v' (e.g., v1.2.3). Got: $TAG"
33+
exit 1
34+
fi
35+
echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV
36+
echo "tag=$TAG" >> $GITHUB_OUTPUT
37+
38+
# Checkout plugin repo at the tag
39+
- name: Checkout plugin repository (Timer)
40+
uses: actions/checkout@v4
41+
with:
42+
path: Timer
43+
ref: ${{ env.RELEASE_TAG }}
44+
45+
# Checkout SurfTimer.Shared as sibling folder (ProjectReference resolves via ../../SurfTimer.Shared)
46+
- name: Checkout SurfTimer.Shared
47+
uses: actions/checkout@v4
48+
with:
49+
repository: tslashd/SurfTimer.Shared
50+
path: SurfTimer.Shared
51+
# If private:
52+
# token: ${{ secrets.SHARED_REPO_PAT }}
53+
# Optionally pin to a tag/commit:
54+
# ref: vX.Y.Z
55+
56+
- name: Setup .NET 8
57+
uses: actions/setup-dotnet@v4
58+
with:
59+
dotnet-version: 8.0.x
60+
61+
# From Timer/src, ProjectReference ../../SurfTimer.Shared/... resolves correctly
62+
- name: Restore (plugin)
63+
working-directory: Timer/src
64+
run: dotnet restore SurfTimer.Plugin.csproj
65+
66+
- name: Build (Release)
67+
working-directory: Timer/src
68+
run: dotnet build SurfTimer.Plugin.csproj -c Release --no-restore
69+
70+
- name: Prepare package layout
71+
id: prep
72+
shell: bash
73+
env:
74+
OUT_ROOT: out
75+
run: |
76+
set -euo pipefail
77+
78+
BIN="Timer/src/bin/Release/net8.0"
79+
PKG="$OUT_ROOT"
80+
ADDONS="$PKG/addons/SurfTimer.Plugin"
81+
CFGDST="$PKG/cfg/SurfTimer"
82+
83+
mkdir -p "$ADDONS/data/GeoIP" "$ADDONS/lang" "$CFGDST"
84+
85+
echo "Build output listing (should contain only selected DLLs):"
86+
ls -la "$BIN"
87+
88+
# Required artifacts (these should exist thanks to your KeepOnlySelectedDlls target)
89+
for f in SurfTimer.Plugin.dll SurfTimer.Shared.dll Dapper.dll MaxMind.Db.dll MaxMind.GeoIP2.dll MySqlConnector.dll; do
90+
test -f "$BIN/$f" || { echo "Missing $f in $BIN"; exit 1; }
91+
done
92+
93+
# Copy all dlls that remain after your KeepOnlySelectedDlls pruning
94+
cp -v "$BIN"/*.dll "$ADDONS/"
95+
96+
# data/GeoIP
97+
SRC_MMDB="Timer/data/GeoIP/GeoLite2-Country.mmdb"
98+
test -f "$SRC_MMDB" || { echo "Missing $SRC_MMDB"; exit 1; }
99+
cp -v "$SRC_MMDB" "$ADDONS/data/GeoIP/"
100+
101+
# lang/en.json
102+
SRC_LANG="Timer/lang/en.json"
103+
test -f "$SRC_LANG" || { echo "Missing $SRC_LANG"; exit 1; }
104+
cp -v "$SRC_LANG" "$ADDONS/lang/"
105+
106+
# cfg/SurfTimer (copy entire folder)
107+
test -d "Timer/cfg/SurfTimer" || { echo "Missing Timer/cfg/SurfTimer"; exit 1; }
108+
cp -vr "Timer/cfg/SurfTimer/." "$CFGDST/"
109+
110+
echo "PKG_PATH=$PKG" >> $GITHUB_OUTPUT
111+
112+
- name: Create ZIP
113+
shell: bash
114+
env:
115+
PKG_NAME: SurfTimer.Plugin-${{ env.RELEASE_TAG }}
116+
run: |
117+
cd out
118+
# zip the *contents* so archive root is addons/ and cfg/
119+
zip -r "${PKG_NAME}.zip" addons cfg
120+
sha256sum "${PKG_NAME}.zip" > "${PKG_NAME}.zip.sha256"
121+
ls -la
122+
123+
- name: Upload artifact
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: SurfTimer.Plugin-${{ env.RELEASE_TAG }}
127+
path: |
128+
out/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip
129+
out/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip.sha256
130+
131+
release:
132+
runs-on: ubuntu-latest
133+
needs: build
134+
steps:
135+
- name: Download artifacts
136+
uses: actions/download-artifact@v4
137+
with:
138+
path: ./artifacts
139+
140+
- name: Determine tag
141+
id: vars
142+
shell: bash
143+
run: |
144+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
145+
TAG="${{ github.event.inputs.tag }}"
146+
else
147+
TAG="${{ github.ref_name }}"
148+
fi
149+
echo "tag=$TAG" >> $GITHUB_OUTPUT
150+
echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV
151+
152+
- name: List artifacts
153+
run: ls -R ./artifacts
154+
155+
- name: Create GitHub Release and upload assets
156+
uses: softprops/action-gh-release@v2
157+
with:
158+
tag_name: ${{ steps.vars.outputs.tag }}
159+
name: SurfTimer.Plugin ${{ steps.vars.outputs.tag }}
160+
draft: false
161+
prerelease: ${{ contains(steps.vars.outputs.tag, '-rc') || contains(steps.vars.outputs.tag, '-beta') || contains(steps.vars.outputs.tag, '-alpha') }}
162+
files: |
163+
artifacts/SurfTimer.Plugin-${{ env.RELEASE_TAG }}/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip
164+
artifacts/SurfTimer.Plugin-${{ env.RELEASE_TAG }}/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip.sha256
165+
env:
166+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
src/bin/Debug/*
66
src/bin/Release/*
77
src/obj/*
8-
src/SurfTimer.csproj
8+
src/SurfTimer.csproj
9+
*.puml
10+
out/uml/include/full.png

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "process",
88
"args": [
99
"build",
10-
"${workspaceFolder}/src/SurfTimer.csproj",
10+
"${workspaceFolder}/src/SurfTimer.Plugin.csproj",
1111
"/property:Configuration=Debug"
1212
],
1313
"problemMatcher": "$msCompile"
@@ -18,7 +18,7 @@
1818
"type": "process",
1919
"args": [
2020
"build",
21-
"${workspaceFolder}/src/SurfTimer.csproj",
21+
"${workspaceFolder}/src/SurfTimer.Plugin.csproj",
2222
"/property:Configuration=Release"
2323
],
2424
"problemMatcher": "$msCompile"

CS2SurfTimer.sln

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ VisualStudioVersion = 17.5.002.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A9962DB7-AE8A-4370-B381-19529A91B7EC}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SurfTimer", "src\SurfTimer.csproj", "{98841535-B479-49B7-8D35-03786D4C31B9}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SurfTimer.Plugin", "src\SurfTimer.Plugin.csproj", "{98841535-B479-49B7-8D35-03786D4C31B9}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurfTimer.Api", "..\SurfTimer.Api\SurfTimer.Api.csproj", "{F53C6067-0A4E-18EF-53CB-69AB97901241}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurfTimer.Shared", "..\SurfTimer.Shared\SurfTimer.Shared.csproj", "{6FA80551-EAFE-9030-69AA-1CEE7BEC44FB}"
913
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,6 +21,14 @@ Global
1721
{98841535-B479-49B7-8D35-03786D4C31B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
1822
{98841535-B479-49B7-8D35-03786D4C31B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
1923
{98841535-B479-49B7-8D35-03786D4C31B9}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{F53C6067-0A4E-18EF-53CB-69AB97901241}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{F53C6067-0A4E-18EF-53CB-69AB97901241}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{F53C6067-0A4E-18EF-53CB-69AB97901241}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{F53C6067-0A4E-18EF-53CB-69AB97901241}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{6FA80551-EAFE-9030-69AA-1CEE7BEC44FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{6FA80551-EAFE-9030-69AA-1CEE7BEC44FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{6FA80551-EAFE-9030-69AA-1CEE7BEC44FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{6FA80551-EAFE-9030-69AA-1CEE7BEC44FB}.Release|Any CPU.Build.0 = Release|Any CPU
2032
EndGlobalSection
2133
GlobalSection(SolutionProperties) = preSolution
2234
HideSolutionNode = FALSE

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# DEVELOPMENT IS NOT ACTIVE
2-
3-
## EVERYONE IS WELCOME TO BUILD UP ON THIS PROJECT AND CONTRIBUTE. ISSUES ARE DISABLED FOR THE TIME BEING
1+
# EVERYONE IS WELCOME TO BUILD UP ON THIS PROJECT AND CONTRIBUTE. ISSUES ARE DISABLED FOR THE TIME BEING
42
## Please join the Discord: https://discord.cs.surf
53

64
# Timer
@@ -162,11 +160,16 @@ Core plugin for CS2 Surf Servers. This project is aimed to be fully open-source
162160
</details>
163161
</br>
164162

163+
## 🔗 Dependencies
164+
- [`CounterStrikeSharp`](https://github.com/roflmuffin/CounterStrikeSharp) - **required** minimum version [v1.0.337](https://github.com/roflmuffin/CounterStrikeSharp/releases/tag/v1.0.337).
165+
- [`SurfTimer.Shared`](https://github.com/tslashd/SurfTimer.Shared)**required** shared library for DTOs, entities, and database integration.
166+
- [`SurfTimer.Api`](https://github.com/tslashd/SurfTimer.Api)*optional* REST API for faster, centralized communication with the database.
167+
165168
# Main list with tasks (more details can be found [here](https://github.com/CS2Surf/Timer/blob/dev/TODO)):
166169
*Note: This is not definitive/complete and simply serves as a reference for what we should try to achieve. Subject to change.*
167170
Bold & Italics = being worked on.
168171
- [ ] Database
169-
- [X] MySQL database schema ([Design Diagram](https://dbdiagram.io/d/CS2Surf-Timer-DB-Schema-6560b76b3be1495787ace4d2))
172+
- [X] MySQL database schema ([Design Diagram](https://dbdiagram.io/d/Copy-of-CS2Surf-Timer-DB-Schema-6582e6e456d8064ca06328b9))
170173
- [ ] Plugin auto-create tables for easier setup?
171174
- [X] Base database class implementation
172175
- [X] Maps
@@ -207,12 +210,12 @@ Bold & Italics = being worked on.
207210
- [ ] Stretch goal: sub-tick timing
208211
- [ ] Player Data
209212
- [X] Base player class
210-
- [ ] Player stat classes
211-
- [ ] Profile implementation (DB)
213+
- [X] Player stat classes
214+
- [X] Profile implementation (DB)
212215
- [ ] Points/Skill Groups (DB)
213216
- [ ] Player settings (DB)
214217
- [x] Replays
215-
- [x] Personal Best
218+
- [x] Personal Best - Data for the PB replays is saved but no functionality to replay them yet is available
216219
- [x] Map Record
217220
- [X] Stage Record
218221
- [X] Bonus Record
@@ -222,4 +225,4 @@ Bold & Italics = being worked on.
222225
- [X] Bonus Record
223226
- [ ] Style implementation (SW, HSW, BW)
224227
- [ ] Paint (?)
225-
- [ ] API Integration (Repo can be found [here](https://github.com/CS2Surf/CS2-Surf-API))
228+
- [x] API Integration (Repo can be found [here](https://github.com/tslashd/SurfTimer.Api))

TODO

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
- Re-add the MySQL queries in code and make it switch between API and DB functions
2-
- Map Time is NOT being saved with API
1+
- Replay Bot Scoreboard names NOT changing when setting new recs
2+
3+
+ Re-add the MySQL queries in code and make it switch between API and DB functions
4+
+ Map Time is NOT being saved with API
35
- Make configs generate themselves inside the `./configs/plugins/...` folder
4-
- Fix loading MapTimes for each type (stage, bonus, maps)
5-
- API
6-
- DB
7-
- Change `DB_QUERY_MAP_GET_RUNS` query with `DB_QUERY_MAP_GET_RECORD_RUNS_AND_COUNT` in API and edit code in plugin
8-
- Change `DB_QUERY_PB_GET_RUNTIME` query in API
6+
+ Fix loading MapTimes for each type (stage, bonus, maps)
7+
+ API
8+
+ DB
9+
+ Change `DB_QUERY_MAP_GET_RUNS` query with `DB_QUERY_MAP_GET_RECORD_RUNS_AND_COUNT` in API and edit code in plugin
10+
+ Change `DB_QUERY_PB_GET_RUNTIME` query in API
911

1012
- Double check the Start/End velocities for End Zone,Checkpoints, Stages, Bonuses
1113
+ Maps
@@ -14,7 +16,7 @@
1416
- Try and get the Start/End velocity values from the Checkpoint object in Map Run
1517
+ Bonuses
1618

17-
- Using `!spec` from any start zone and going back to CT starts your timer
19+
- Using `!spec` from any start zone and going back to CT starts your timer - Will be in a PR
1820

1921
- Try and determine Left/Right side for Bonuses (surf_ace)
2022
- Try and determine Left/Right side for Maps

cfg/SurfTimer/api_config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"api_url": "API_URL_HERE",
3+
"api_enabled": false
4+
}

cfg/SurfTimer/timer_settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
{}
1+
{
2+
"replays_enabled": true,
3+
"replays_pre": 64
4+
}

0 commit comments

Comments
 (0)