mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-04-26 02:00:32 -05:00
Added new Admin Tool page to manage the different versions we need to control. These are:
- launcher version (updating launcher) - game version - content version (for catalog) - catalog version Also added checks that when the wrong content version you dont get a catalog until you update tha game. And added another check when queuing when using the wrong game version you dont get queued. (so that hunters on the wrong version cannot block the matchmaking)
This commit is contained in:
parent
55f8f94f16
commit
dfbb8f34c0
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Api\Catalog;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Admin\Versioning\CurrentCatalogVersion;
|
||||
use App\Models\Game\CatalogItem;
|
||||
use Auth;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
|
@ -16,6 +17,9 @@ class CatalogController extends Controller
|
|||
|
||||
public function getCatalog(string $catalogVersion): string
|
||||
{
|
||||
if($catalogVersion !== CurrentCatalogVersion::get()?->catalogVersion)
|
||||
abort(404);
|
||||
|
||||
return Storage::disk('local')->get('/catalog/catalog.json');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
use App\Http\Responses\Api\Matchmaking\QueueResponse;
|
||||
use App\Models\Admin\Archive\ArchivedGame;
|
||||
use App\Models\Admin\Archive\ArchivedPlayerProgression;
|
||||
use App\Models\Admin\Versioning\CurrentGameVersion;
|
||||
use App\Models\Game\Matchmaking\Game;
|
||||
use App\Models\Game\Matchmaking\QueuedPlayer;
|
||||
use App\Models\User\User;
|
||||
|
|
@ -37,6 +38,9 @@ public function getRegions()
|
|||
|
||||
public function queue(QueueRequest $request)
|
||||
{
|
||||
if($request->category !== CurrentGameVersion::get()?->gameVersion)
|
||||
abort(403, 'Too old mod version');
|
||||
|
||||
if($request->checkOnly)
|
||||
return json_encode($this->checkQueueStatus($request));
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Responses\Api\Statistics\OnlinePlayersResponse;
|
||||
use App\Models\Admin\LauncherMessage;
|
||||
use App\Models\Admin\Versioning\LauncherVersion;
|
||||
use App\Models\Game\Matchmaking\Game;
|
||||
use App\Models\Game\Matchmaking\QueuedPlayer;
|
||||
use DB;
|
||||
|
|
@ -37,7 +38,7 @@ public function getOnlinePlayers() {
|
|||
}
|
||||
|
||||
public function getLauncherVersion(): ?string {
|
||||
return json_encode(config('app.launcher_version'));
|
||||
return json_encode(LauncherVersion::get()?->launcherVersion);
|
||||
}
|
||||
|
||||
public function getLauncherMessage(): ?string {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Responses\TexResponse;
|
||||
use App\Models\Admin\Versioning\CurrentCatalogVersion;
|
||||
use App\Models\Admin\Versioning\CurrentContentVersion;
|
||||
use App\Models\Admin\Versioning\CurrentGameVersion;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -37,15 +40,10 @@ public function getLatestClientData()
|
|||
|
||||
public function getLatestContentVersion(string $version)
|
||||
{
|
||||
$supportedVersion = match($version) {
|
||||
'0' => 'dev030',
|
||||
'2.0' => 'dev020',
|
||||
'2.2' => 'te-23ebf96c-27498-ue4-7172a3f5',
|
||||
'2.5' => 'te-40131b9e-33193-ue4-fbccc218',
|
||||
'3.0' => 'dev030',
|
||||
default => 'te-18f25613-36778-ue4-374f864b'
|
||||
};
|
||||
$currentVersion = CurrentContentVersion::get()?->contentVersion;
|
||||
if($currentVersion === $version)
|
||||
return ['LatestSupportedVersion' => CurrentCatalogVersion::get()?->catalogVersion];
|
||||
|
||||
return ['LatestSupportedVersion' => $supportedVersion];
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ final public static function getAllTools(): array
|
|||
return [
|
||||
GameNewsController::class,
|
||||
FileManagerController::class,
|
||||
VersioningController::class,
|
||||
LauncherMessageController::class,
|
||||
LogViewerController::class,
|
||||
UsersController::class,
|
||||
|
|
|
|||
66
dist/app/Http/Controllers/Web/Admin/Tools/VersioningController.php
vendored
Normal file
66
dist/app/Http/Controllers/Web/Admin/Tools/VersioningController.php
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Admin\Tools;
|
||||
|
||||
use App\Enums\Auth\Permissions;
|
||||
use App\Http\Requests\Api\Admin\Tools\SaveLauncherMessageRequest;
|
||||
use App\Http\Requests\Api\Admin\Tools\SaveVersioningRequest;
|
||||
use App\Models\Admin\LauncherMessage;
|
||||
use App\Models\Admin\Versioning\CurrentCatalogVersion;
|
||||
use App\Models\Admin\Versioning\CurrentContentVersion;
|
||||
use App\Models\Admin\Versioning\CurrentGameVersion;
|
||||
use App\Models\Admin\Versioning\LauncherVersion;
|
||||
use Session;
|
||||
|
||||
class VersioningController extends AdminToolController
|
||||
{
|
||||
protected static string $name = 'Versioning';
|
||||
|
||||
protected static string $description = 'Manage the Launcher & Game Versions.';
|
||||
protected static string $iconComponent = 'icons.arrow-left-right';
|
||||
|
||||
protected static Permissions $neededPermission = Permissions::FILE_UPLOAD;
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('admin.tools.versioning', [
|
||||
'message' => LauncherMessage::getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function save(SaveVersioningRequest $request) {
|
||||
$errorMessage = '';
|
||||
$successMessage= '';
|
||||
|
||||
$success = (new CurrentGameVersion($request->gameVersion))->save();
|
||||
if($success === true)
|
||||
$successMessage .= "Game version saved\n\n";
|
||||
else
|
||||
$errorMessage .= "Game version saving failed: ' . $success\n\n";
|
||||
|
||||
$success = (new CurrentContentVersion($request->contentVersion))->save();
|
||||
if($success === true)
|
||||
$successMessage .= "Content version saved\n\n";
|
||||
else
|
||||
$errorMessage .= "Content version saving failed: ' . $success\n\n";
|
||||
|
||||
(new CurrentCatalogVersion($request->catalogVersion))->save();
|
||||
if($success === true)
|
||||
$successMessage .= "Catalog version saved\n\n";
|
||||
else
|
||||
$errorMessage .= "Catalog version saving failed: ' . $success\n\n";
|
||||
|
||||
(new LauncherVersion($request->launcherVersion))->save();
|
||||
if($success === true)
|
||||
$successMessage .= "Launcher version saved\n\n";
|
||||
else
|
||||
$errorMessage .= "Launcher version saving failed: ' . $success\n\n";
|
||||
|
||||
if($success !== '')
|
||||
Session::flash('alert-success', nl2br(trim($successMessage)));
|
||||
if($errorMessage !== '')
|
||||
Session::flash('alert-error', nl2br(trim($errorMessage)));
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
39
dist/app/Http/Requests/Api/Admin/Tools/SaveVersioningRequest.php
vendored
Normal file
39
dist/app/Http/Requests/Api/Admin/Tools/SaveVersioningRequest.php
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Admin\Tools;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SaveVersioningRequest extends FormRequest
|
||||
{
|
||||
public string $launcherVersion;
|
||||
|
||||
public string $gameVersion;
|
||||
|
||||
public string $contentVersion;
|
||||
|
||||
public string $catalogVersion;
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'launcherVersion' => 'required|string',
|
||||
'gameVersion' => 'required|string',
|
||||
'contentVersion' => 'required|string',
|
||||
'catalogVersion' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
protected function passedValidation()
|
||||
{
|
||||
$this->launcherVersion = $this->input('launcherVersion');
|
||||
$this->gameVersion = $this->input('gameVersion');
|
||||
$this->contentVersion = $this->input('contentVersion');
|
||||
$this->catalogVersion = $this->input('catalogVersion');
|
||||
}
|
||||
}
|
||||
41
dist/app/Models/AbstractFileBasedModel.php
vendored
Normal file
41
dist/app/Models/AbstractFileBasedModel.php
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
abstract class AbstractFileBasedModel
|
||||
{
|
||||
const FILE_NAME = 'file-name';
|
||||
|
||||
const CACHE_DURATION = 3600;
|
||||
|
||||
protected static ?FilesystemAdapter $disk = null;
|
||||
|
||||
public function save(): bool|string {
|
||||
$success = static::getDisk()->put(static::FILE_NAME, serialize($this));
|
||||
|
||||
if($success === true)
|
||||
Cache::forget(static::FILE_NAME);
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public static function get(): ?static {
|
||||
return Cache::remember(
|
||||
static::FILE_NAME,
|
||||
static::CACHE_DURATION,
|
||||
function () {
|
||||
$data = static::getDisk()->get(static::FILE_NAME);
|
||||
|
||||
return $data === null ? null : unserialize($data);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected static function getDisk(): FilesystemAdapter {
|
||||
return static::$disk ?? static::$disk = Storage::disk('local');
|
||||
}
|
||||
}
|
||||
17
dist/app/Models/Admin/Versioning/CurrentCatalogVersion.php
vendored
Normal file
17
dist/app/Models/Admin/Versioning/CurrentCatalogVersion.php
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Admin\Versioning;
|
||||
|
||||
use App\Models\AbstractFileBasedModel;
|
||||
|
||||
class CurrentCatalogVersion extends AbstractFileBasedModel
|
||||
{
|
||||
const FILE_NAME = 'current-catalog-version';
|
||||
|
||||
const CACHE_DURATION = 86400; // 1 Day
|
||||
|
||||
public function __construct(
|
||||
public string $catalogVersion
|
||||
)
|
||||
{}
|
||||
}
|
||||
17
dist/app/Models/Admin/Versioning/CurrentContentVersion.php
vendored
Normal file
17
dist/app/Models/Admin/Versioning/CurrentContentVersion.php
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Admin\Versioning;
|
||||
|
||||
use App\Models\AbstractFileBasedModel;
|
||||
|
||||
class CurrentContentVersion extends AbstractFileBasedModel
|
||||
{
|
||||
const FILE_NAME = 'current-content-version';
|
||||
|
||||
const CACHE_DURATION = 86400; // 1 Day
|
||||
|
||||
public function __construct(
|
||||
public string $contentVersion,
|
||||
)
|
||||
{}
|
||||
}
|
||||
17
dist/app/Models/Admin/Versioning/CurrentGameVersion.php
vendored
Normal file
17
dist/app/Models/Admin/Versioning/CurrentGameVersion.php
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Admin\Versioning;
|
||||
|
||||
use App\Models\AbstractFileBasedModel;
|
||||
|
||||
class CurrentGameVersion extends AbstractFileBasedModel
|
||||
{
|
||||
const FILE_NAME = 'current-game-version';
|
||||
|
||||
const CACHE_DURATION = 86400; // 1 Day
|
||||
|
||||
public function __construct(
|
||||
public string $gameVersion,
|
||||
)
|
||||
{}
|
||||
}
|
||||
17
dist/app/Models/Admin/Versioning/LauncherVersion.php
vendored
Normal file
17
dist/app/Models/Admin/Versioning/LauncherVersion.php
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Admin\Versioning;
|
||||
|
||||
use App\Models\AbstractFileBasedModel;
|
||||
|
||||
class LauncherVersion extends AbstractFileBasedModel
|
||||
{
|
||||
const FILE_NAME = 'current-launcher-version';
|
||||
|
||||
const CACHE_DURATION = 86400; // 1 Day
|
||||
|
||||
public function __construct(
|
||||
public string $launcherVersion,
|
||||
)
|
||||
{}
|
||||
}
|
||||
2
dist/config/app.php
vendored
2
dist/config/app.php
vendored
|
|
@ -126,8 +126,6 @@
|
|||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'launcher_version' => env('LAUNCHER_VERSION', 'null'),
|
||||
|
||||
'roles_allowed_to_play' => env('ROLES_ALLOWED_TO_PLAY', '') === '' ? null : explode(',', env('ROLES_ALLOWED_TO_PLAY', 'null')),
|
||||
|
||||
/*
|
||||
|
|
|
|||
70
dist/resources/views/admin/tools/versioning.blade.php
vendored
Normal file
70
dist/resources/views/admin/tools/versioning.blade.php
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
@props([
|
||||
'message' => null
|
||||
])
|
||||
|
||||
@php
|
||||
use App\Models\Admin\LauncherMessage;
|
||||
use App\Models\Admin\Versioning\CurrentCatalogVersion;
|
||||
use App\Models\Admin\Versioning\CurrentContentVersion;
|
||||
use App\Models\Admin\Versioning\CurrentGameVersion;
|
||||
use App\Models\Admin\Versioning\LauncherVersion;
|
||||
|
||||
/** @var ?LauncherMessage $message */
|
||||
@endphp
|
||||
|
||||
<x-layouts.admin>
|
||||
<div class="container mx-auto border bg-slate-800 border-slate-500 rounded-xl p-4 my-6">
|
||||
<form action="{{ route('versioning.save') }}" method="post">
|
||||
@csrf
|
||||
<div class="flex flex-col gap-4">
|
||||
<label for="message" class="headline">
|
||||
Launcher Version
|
||||
</label>
|
||||
|
||||
<x-inputs.text
|
||||
id="launcherVersion"
|
||||
name="launcherVersion"
|
||||
value="{{ LauncherVersion::get()?->launcherVersion }}"
|
||||
required
|
||||
/>
|
||||
|
||||
<label for="message" class="headline mt-4">
|
||||
Game Version
|
||||
</label>
|
||||
|
||||
<x-inputs.text
|
||||
id="gameVersion"
|
||||
name="gameVersion"
|
||||
value="{{ CurrentGameVersion::get()?->gameVersion }}"
|
||||
required
|
||||
/>
|
||||
|
||||
<label for="message" class="headline mt-4">
|
||||
Content Version
|
||||
</label>
|
||||
|
||||
<x-inputs.text
|
||||
id="contentVersion"
|
||||
name="contentVersion"
|
||||
value="{{ CurrentContentVersion::get()?->contentVersion }}"
|
||||
required
|
||||
/>
|
||||
|
||||
<label for="message" class="headline mt-4">
|
||||
Catalog Version
|
||||
</label>
|
||||
|
||||
<x-inputs.text
|
||||
id="catalogVersion"
|
||||
name="catalogVersion"
|
||||
value="{{ CurrentCatalogVersion::get()?->catalogVersion }}"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<x-inputs.button class="save mt-8">
|
||||
Save
|
||||
</x-inputs.button>
|
||||
</form>
|
||||
</div>
|
||||
</x-layouts.admin>
|
||||
3
dist/resources/views/components/icons/arrow-left-right.blade.php
vendored
Normal file
3
dist/resources/views/components/icons/arrow-left-right.blade.php
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" {{ $attributes }}>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 278 B |
4
dist/routes/admin.php
vendored
4
dist/routes/admin.php
vendored
|
|
@ -10,6 +10,7 @@
|
|||
use App\Http\Controllers\Web\Admin\Tools\LogViewerController;
|
||||
use App\Http\Controllers\Web\Admin\Tools\PlayerReportsController;
|
||||
use App\Http\Controllers\Web\Admin\Tools\UsersController;
|
||||
use App\Http\Controllers\Web\Admin\Tools\VersioningController;
|
||||
|
||||
Route::redirect('', 'admin/dashboard');
|
||||
Route::redirect('logs', 'log-viewer')->name(LogViewerController::class);
|
||||
|
|
@ -48,6 +49,9 @@
|
|||
Route::get('launcher-message', [LauncherMessageController::class, 'index'])->name(LauncherMessageController::class);
|
||||
Route::post('launcher-message', [LauncherMessageController::class, 'saveMessage'])->name('launcherMessage.save');
|
||||
|
||||
Route::get('versioning', [VersioningController::class, 'index'])->name(VersioningController::class);
|
||||
Route::post('versioning', [VersioningController::class, 'save'])->name('versioning.save');
|
||||
|
||||
Route::fallback(function () {
|
||||
return redirect(route('admin.dashboard'));
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user