Skip to content

Commit

Permalink
v3.9.X Support, and Garbage Collector Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ekky committed Jul 9, 2024
1 parent 99f8220 commit 6ed18e8
Show file tree
Hide file tree
Showing 608 changed files with 12,170 additions and 5,160 deletions.
44 changes: 22 additions & 22 deletions Client/RAID-REVIEW.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AssemblyVersion>0.1.1</AssemblyVersion>
<Copyright>2024 © Ekky</Copyright>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>D:\Games\SPT_3.8.1_DEV\BepInEx\plugins\</OutputPath>
<OutputPath>D:\Games\SPT_3.9.0_DEV\BepInEx\plugins\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -19,80 +19,80 @@

<ItemGroup>
<Reference Include="0Harmony">
<HintPath>dependencies\0Harmony.dll</HintPath>
<HintPath>dependencies\3.9.x\0Harmony.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Aki.Common">
<HintPath>dependencies\Aki.Common.dll</HintPath>
<Reference Include="spt-common">
<HintPath>dependencies\3.9.x\spt-common.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Aki.Reflection">
<HintPath>dependencies\Aki.Reflection.dll</HintPath>
<Reference Include="spt-Reflection">
<HintPath>dependencies\3.9.x\spt-reflection.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>dependencies\Assembly-CSharp.dll</HintPath>
<HintPath>dependencies\3.9.x\Assembly-CSharp.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="BepInEx">
<HintPath>dependencies\BepInEx.dll</HintPath>
<HintPath>dependencies\3.9.x\BepInEx.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Comfort">
<HintPath>dependencies\Comfort.dll</HintPath>
<HintPath>dependencies\3.9.x\Comfort.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>dependencies\Newtonsoft.Json.dll</HintPath>
<HintPath>dependencies\3.9.x\Newtonsoft.Json.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="BepInEx.Harmony.dll">
<HintPath>dependencies\BepInEx.Harmony.dll</HintPath>
<HintPath>dependencies\3.9.x\BepInEx.Harmony.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations">
<HintPath>dependencies\System.ComponentModel.DataAnnotations.dll</HintPath>
<HintPath>dependencies\3.9.x\System.ComponentModel.DataAnnotations.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="System.Runtime" />
<Reference Include="UnityEngine">
<HintPath>dependencies\UnityEngine.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>dependencies\UnityEngine.AssetBundleModule.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.AssetBundleModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>dependencies\UnityEngine.CoreModule.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.CoreModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>dependencies\UnityEngine.AudioModule.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.AudioModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.InputModule">
<HintPath>dependencies\UnityEngine.InputModule.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.InputModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>dependencies\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.InputLegacyModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>dependencies\UnityEngine.UI.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.UI.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>dependencies\UnityEngine.UIModule.dll</HintPath>
<HintPath>dependencies\3.9.x\UnityEngine.UIModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="websocket-sharp">
<HintPath>dependencies\websocket-sharp.dll</HintPath>
<HintPath>dependencies\3.9.x\websocket-sharp.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Sirenix.Serialization">
<HintPath>dependencies\Sirenix.Serialization.dll</HintPath>
<HintPath>dependencies\3.9.x\Sirenix.Serialization.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Client/integrations/SAIN.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aki.Reflection.Patching;
using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using EFT.Communications;
Expand Down
4 changes: 2 additions & 2 deletions Client/patches/menuTaskBar_setButtonsAvailablePatch.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Aki.Reflection.Patching;
using EFT;
using EFT;
using EFT.UI;
using Newtonsoft.Json;
using RAID_REVIEW;
using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
8 changes: 4 additions & 4 deletions Client/patches/player_killpatch.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using EFT;
using System.Reflection;
using Aki.Reflection.Patching;
using SPT.Reflection.Patching;
using UnityEngine;
using Newtonsoft.Json;
using System;
Expand All @@ -11,7 +11,7 @@ public class RAID_REVIEW_Player_OnBeenKilledByAggressorPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(Player).GetMethod("OnBeenKilledByAggressor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return typeof(Player).GetMethod("OnBeenKilledByAggressor", BindingFlags.Instance | BindingFlags.Public);
}

[PatchPostfix]
Expand All @@ -33,8 +33,8 @@ private static void PatchPostFix(ref Player __instance, IPlayer aggressor, Damag
weapon = damageInfo.Weapon == null ? "?" : damageInfo.Weapon.Name,
bodyPart = bodyPart.ToString(),
type = lethalDamageType.ToString(),
positionKiller = aggressor.Position.ToJson(),
positionKilled = __instance.Position.ToJson(),
positionKiller = JsonConvert.SerializeObject(aggressor.Position),
positionKilled = JsonConvert.SerializeObject(__instance.Position),
};

Telemetry.Send("KILL", JsonConvert.SerializeObject(newKill));
Expand Down
2 changes: 1 addition & 1 deletion Client/patches/player_onGameSessionEndPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aki.Reflection.Patching;
using SPT.Reflection.Patching;
using EFT;
using EFT.Communications;
using Newtonsoft.Json;
Expand Down
2 changes: 1 addition & 1 deletion Client/patches/player_onGameStartedPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aki.Reflection.Patching;
using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using EFT.Communications;
Expand Down
2 changes: 1 addition & 1 deletion Client/patches/player_onItemAddedOrRemovedPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aki.Reflection.Patching;
using SPT.Reflection.Patching;
using EFT.InventoryLogic;
using EFT;
using Newtonsoft.Json;
Expand Down
14 changes: 7 additions & 7 deletions Private/src/api/api.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAkiProfile } from '../../../Server/types/models/eft/profile/IAkiProfile';
import { ISptProfile } from '../../../Server/types/models/eft/profile/ISptProfile';
import { TrackingRaidData, RaidReviewServerSettings, TrackingCoreDataRaids } from '../types/api_types';

let isDev = window.location.host.includes("5173");
Expand Down Expand Up @@ -64,11 +64,11 @@ const api = {
},


getProfiles: async function() : Promise<IAkiProfile[]> {
let profiles = [] as IAkiProfile[];
getProfiles: async function() : Promise<ISptProfile[]> {
let profiles = [] as ISptProfile[];
try {
const response = await fetch(hostname + '/api/profile/all');
const data = await response.json() as IAkiProfile[];
const data = await response.json() as ISptProfile[];

Object.keys(data).forEach((profile : string) => {
// @ts-ignore
Expand All @@ -83,11 +83,11 @@ const api = {
}
},

getProfile : async function(profileId: string) : Promise<IAkiProfile> {
let profile = {} as IAkiProfile;
getProfile : async function(profileId: string) : Promise<ISptProfile> {
let profile = {} as ISptProfile;
try {
const response = await fetch(hostname + `/api/profile/${profileId}`);
const data = await response.json() as IAkiProfile;
const data = await response.json() as ISptProfile;
profile = data;
return profile
}
Expand Down
2 changes: 1 addition & 1 deletion Private/src/pages/About.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import { Link, useLoaderData, useSearchParams } from "react-router-dom";
// import api from "../api/api";
// import { IAkiProfile } from "../../../../../types/models/eft/profile/IAkiProfile";
// import { ISptProfile } from "../../../../../types/models/eft/profile/ISptProfile";

import './About.css'

Expand Down
4 changes: 2 additions & 2 deletions Private/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link, useLoaderData, useNavigation, useSearchParams } from "react-router-dom";
import api from "../api/api";
import { IAkiProfile } from "../../../Server/types/models/eft/profile/IAkiProfile";
import { ISptProfile } from "../../../Server/types/models/eft/profile/ISptProfile";

import './Home.css'
import GlobalSpinner from "../component/GlobalSpinner";
Expand All @@ -15,7 +15,7 @@ export async function loader() {
export default function Home() {
const [ searchParams ] = useSearchParams();
const navigation = useNavigation();
const { profiles } = useLoaderData() as { profiles: IAkiProfile[], hideUpdateMessage: boolean };
const { profiles } = useLoaderData() as { profiles: ISptProfile[], hideUpdateMessage: boolean };

function renderError(profileId: string) {
const error = searchParams.get('error');
Expand Down
6 changes: 3 additions & 3 deletions Private/src/pages/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import moment from "moment";

import api from "../api/api";
import { getCookie } from "../modules/utils";
import { IAkiProfile } from "../../../Server/types/models/eft/profile/IAkiProfile";
import { ISptProfile } from "../../../Server/types/models/eft/profile/ISptProfile";

import "./Profile.css";
import GlobalSpinner from "../component/GlobalSpinner";
Expand Down Expand Up @@ -45,7 +45,7 @@ export function msToHMS( ms: number ) : string {
}

export default function Profile() {
const { profile, core } = useLoaderData() as { profile: IAkiProfile, core : any };
const { profile, core } = useLoaderData() as { profile: ISptProfile, core : any };
const navigation = useNavigation();
const [ isAdmin, setIsAdmin ] = useState(false);

Expand Down Expand Up @@ -124,7 +124,7 @@ export default function Profile() {
);
}

function RaidSelector(profile: IAkiProfile, raid: any, locations: { [ key :string ] : string }, msToHMS: (ms: number) => string) {
function RaidSelector(profile: ISptProfile, raid: any, locations: { [ key :string ] : string }, msToHMS: (ms: number) => string) {
return <Link to={`/p/${profile.info.id}/raid/${raid.raidId}`} key={raid.raidId} className="raid__selector bg-eft w-full px-4 py-1 text-xl font-black flex flex-col hover:opacity-75 cursor-pointer">
<div className="w-full flex items-center">
<div className="w-full flex items-center">
Expand Down
2 changes: 1 addition & 1 deletion Server/base_directory
Original file line number Diff line number Diff line change
@@ -1 +1 @@
D:\Games\SPT_3.8.1_DEV\
D:\Games\SPT_3.9.0_DEV\
2 changes: 1 addition & 1 deletion Server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "src/mod.js",
"license": "MIT",
"author": "ekky",
"akiVersion": "~3.8.x",
"sptVersion": "~3.9.X",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import _ from 'lodash';
import sqlite3 from 'sqlite3';
import { Database } from "sqlite"
import { IAkiProfile } from '@spt-aki/models/eft/profile/IAkiProfile';
import { ISptProfile } from '@spt/models/eft/profile/ISptProfile';
import { Logger } from '../../Utils/logger';

async function CheckForMissingMainPlayer(db: Database<sqlite3.Database, sqlite3.Statement>, logger: Logger, profiles: Record<string, IAkiProfile>) {
async function CheckForMissingMainPlayer(db: Database<sqlite3.Database, sqlite3.Statement>, logger: Logger, profiles: Record<string, ISptProfile>) {

logger.log(`Starting 'Missing main player' check.`);

// Get All The Raids
const raids_sql = `SELECT * FROM raid WHERE timeInRaid > 0;`;
const raids_sql = `SELECT * FROM raid WHERE timeInRaid > 0 AND type = 'PMC';`;
const raids = await db.all(raids_sql).catch((e: Error) => logger.error(`[ERR:MISSING_PLAYER_ALL_RAIDS] `, e)) as any[];
const raidsByPlayer = _.groupBy(raids, 'profileId');

Expand Down
4 changes: 2 additions & 2 deletions Server/src/Controllers/Integrations/modDetection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import { DependencyContainer } from "tsyringe"
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader"
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader"
import { MOD_SIGNATURES } from '../../constant';
import { Logger } from '../../Utils/logger';

Expand All @@ -25,7 +25,7 @@ export class ModDetector {
}

getInstalledMods(container: DependencyContainer) : RaidReviewDetectedMods {
const ModLoader : PreAkiModLoader = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const ModLoader : PreSptModLoader = container.resolve<PreSptModLoader>("PreSptModLoader");

const clientPluginsPath = `${__dirname}/../../../../../../BepInEx/plugins/`;
const isLocalInstall = fs.existsSync(clientPluginsPath)
Expand Down
4 changes: 2 additions & 2 deletions Server/src/Controllers/PacketHandler/packetHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { SessionManager, SessionManagerPlayerMap } from "../StateManagers/sessio
import { ModDetector } from "../Integrations/modDetection";
import { CONSTANTS } from "../../constant";
import { Logger } from '../../Utils/logger';
import { IAkiProfile } from '@spt-aki/models/eft/profile/IAkiProfile';
import { ISptProfile } from '@spt/models/eft/profile/ISptProfile';
import { CheckForMissingMainPlayer } from '../DataIntegrity/CheckForMissingMainPlayer';

async function messagePacketHandler(rawData: RawData, db: Database<sqlite3.Database, sqlite3.Statement>, sessionManager: SessionManager, modDetector: ModDetector, logger : Logger, profiles: Record<string, IAkiProfile>, post_raid_processing: cron.ScheduledTask) {
async function messagePacketHandler(rawData: RawData, db: Database<sqlite3.Database, sqlite3.Statement>, sessionManager: SessionManager, modDetector: ModDetector, logger : Logger, profiles: Record<string, ISptProfile>, post_raid_processing: cron.ScheduledTask) {
try {

// Convert RawData to string if it's a buffer
Expand Down
6 changes: 3 additions & 3 deletions Server/src/Controllers/StateManagers/sessionManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAkiProfile } from '@spt-aki/models/eft/profile/IAkiProfile'
import { ISptProfile } from '@spt/models/eft/profile/ISptProfile'
import { CONSTANTS } from '../../constant'
import { Logger } from 'src/Utils/logger'

Expand All @@ -8,11 +8,11 @@ export interface SessionManagerRaid {
timeout: number
}

export type SessionManagerPlayerMap = Map<string, IAkiProfile>
export type SessionManagerPlayerMap = Map<string, ISptProfile>

export interface SessionManagerPlayer {
raidId: string
profile: IAkiProfile
profile: ISptProfile
timeout: number
}

Expand Down
14 changes: 7 additions & 7 deletions Server/src/Server/Express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import cookieParser from 'cookie-parser'
import basicAuth from 'express-basic-auth'
import compression from 'compression'

import { SaveServer } from '@spt-aki/servers/SaveServer'
import { IAkiProfile } from '@spt-aki/models/eft/profile/IAkiProfile'
import { ProfileHelper } from '@spt-aki/helpers/ProfileHelper'
import { LocaleService } from '@spt-aki/services/LocaleService'
import { SaveServer } from '@spt/servers/SaveServer'
import { ISptProfile } from '@spt/models/eft/profile/ISptProfile'
import { ProfileHelper } from '@spt/helpers/ProfileHelper'
import { LocaleService } from '@spt/services/LocaleService'

import config from '../../config.json'
import { DeleteFile, ReadFile } from '../Controllers/FileSystem/DataSaver'
Expand Down Expand Up @@ -52,7 +52,7 @@ function StartWebServer(saveServer: SaveServer, profileServer: ProfileHelper, db
app.use(compression())

const basicAuthUsers = {};
Object.values(profileServer.getProfiles()).map((p : IAkiProfile) => basicAuthUsers[p.info.username] = p.info.password);
Object.values(profileServer.getProfiles()).map((p : ISptProfile) => basicAuthUsers[p.info.username] = p.info.password);

// Basic Auth has been implemented for people who host Fika remotely.
// It's not the greatest level of protection, but I cannot be arsed to implement oAuth for sucha niche use case.
Expand Down Expand Up @@ -156,7 +156,7 @@ function StartWebServer(saveServer: SaveServer, profileServer: ProfileHelper, db
})

app.get('/api/profile/all', (req: Request, res: Response) => {
let profiles = saveServer.getProfiles() as Record<string, IAkiProfile>
let profiles = saveServer.getProfiles() as Record<string, ISptProfile>

for (const profile_k in profiles) {
let profile = profiles[profile_k]
Expand All @@ -170,7 +170,7 @@ function StartWebServer(saveServer: SaveServer, profileServer: ProfileHelper, db
})

app.get('/api/profile/:profileId', (req: Request, res: Response) => {
const profiles = saveServer.getProfiles() as Record<string, IAkiProfile>
const profiles = saveServer.getProfiles() as Record<string, ISptProfile>

return res.json(profiles[req.params.profileId])
})
Expand Down
Loading

0 comments on commit 6ed18e8

Please sign in to comment.