mirror of
https://github.com/skillbert/rsmv.git
synced 2025-12-23 21:47:48 -05:00
cs2 improvements
This commit is contained in:
13
src/cache/openrs2loader.ts
vendored
13
src/cache/openrs2loader.ts
vendored
@@ -69,14 +69,14 @@ export function validOpenrs2Caches() {
|
||||
|
||||
1455,//weird clientscript
|
||||
|
||||
312,286,1420,1421,1530,//missing clientscripts
|
||||
312, 286, 1420, 1421, 1530,//missing clientscripts
|
||||
|
||||
|
||||
//TODO fix these or figure out whats wrong with them
|
||||
1480,
|
||||
|
||||
644,257,//incomplete textures
|
||||
1456,1665,//missing materials
|
||||
644, 257,//incomplete textures
|
||||
1456, 1665,//missing materials
|
||||
1479,//missing items could probably be worked around
|
||||
];
|
||||
let allcaches: Openrs2CacheMeta[] = await fetch(`${endpoint}/caches.json`).then(q => q.json());
|
||||
@@ -131,7 +131,7 @@ export class Openrs2CacheSource extends cache.DirectCacheFileSource {
|
||||
getBuildNr() {
|
||||
return this.buildnr;
|
||||
}
|
||||
async getCacheIndex(major) {
|
||||
async getCacheIndex(major: number) {
|
||||
if (this.buildnr <= 700 && !this.xteaKeysLoaded && major == cacheMajors.mapsquares) {
|
||||
this.xteakeysPromise ??= (async () => {
|
||||
this.xteakeys ??= new Map();
|
||||
@@ -149,6 +149,11 @@ export class Openrs2CacheSource extends cache.DirectCacheFileSource {
|
||||
return super.getCacheIndex(major);
|
||||
}
|
||||
|
||||
static async getRecentCache(count = 0) {
|
||||
let relevantcaches = await validOpenrs2Caches();
|
||||
return relevantcaches[count];
|
||||
}
|
||||
|
||||
static async downloadCacheMeta(cacheid: number) {
|
||||
//yep, i used regex on html, sue me
|
||||
let rootindexhtml = await fetch(`${endpoint}/caches/runescape/${cacheid}`).then(q => q.text());
|
||||
|
||||
@@ -496,6 +496,10 @@ export class ClientscriptObfuscation {
|
||||
findOpcodeImmidiates(this);
|
||||
this.parseCandidateContents();
|
||||
callibrateOperants(this, this.candidates);
|
||||
// todo, somehow a extra runs still finds new types, these should have been caught in the first run
|
||||
callibrateOperants(this, this.candidates);
|
||||
callibrateOperants(this, this.candidates);
|
||||
callibrateOperants(this, this.candidates);
|
||||
try {
|
||||
callibrateSubtypes(this, this.candidates);
|
||||
} catch (e) {
|
||||
|
||||
@@ -7,6 +7,8 @@ import { parse } from "../opdecoder";
|
||||
import { astToImJson } from "./jsonwriter";
|
||||
import { clientscript } from "../../generated/clientscript";
|
||||
import { crc32, crc32addInt } from "../libs/crc32util";
|
||||
// import { Openrs2CacheSource } from "../cache/openrs2loader";
|
||||
// import { GameCacheLoader } from "../cache/sqlite";
|
||||
|
||||
export { writeClientVarFile, writeOpcodeFile } from "../clientscript/codeparser";
|
||||
|
||||
@@ -40,10 +42,16 @@ export async function renderClientScript(source: CacheFileSource, buf: Buffer, f
|
||||
|
||||
export async function prepareClientScript(source: CacheFileSource) {
|
||||
if (!source.decodeArgs.clientScriptDeob) {
|
||||
let deob = await ClientscriptObfuscation.create(source);
|
||||
let deobsource = source;
|
||||
// use equivelant openrs2 cache instead to prevent problems with edits begin invalid
|
||||
// if (source instanceof GameCacheLoader) {
|
||||
// deobsource = new Openrs2CacheSource(await Openrs2CacheSource.getRecentCache());
|
||||
// }
|
||||
let deob = await ClientscriptObfuscation.create(deobsource);
|
||||
source.decodeArgs.clientScriptDeob = deob;
|
||||
await deob.runAutoCallibrate(source);
|
||||
await deob.save();
|
||||
|
||||
globalThis.deob = deob;//TODO remove
|
||||
}
|
||||
return source.decodeArgs.clientScriptDeob as ClientscriptObfuscation;
|
||||
|
||||
@@ -35,11 +35,10 @@ function cacheSourceFromString(str: string) {
|
||||
return Openrs2CacheSource.fromId(+arg);
|
||||
case "openrslast":
|
||||
case "openrs2last":
|
||||
let caches = await validOpenrs2Caches();
|
||||
let target = caches[+(arg ?? "0")];
|
||||
let target = await Openrs2CacheSource.getRecentCache(+(arg ?? "0"));
|
||||
if (!target) { throw new Error(`cache index ${arg} not found`); }
|
||||
console.log(`opening openrs2:${target.id}`);
|
||||
return Openrs2CacheSource.fromId(target.id);
|
||||
return new Openrs2CacheSource(target);
|
||||
case "extracted":
|
||||
return new RawFileLoader(arg, 0);
|
||||
case "global":
|
||||
|
||||
@@ -148,10 +148,6 @@ export async function writeCacheFiles(output: ScriptOutput, source: CacheFileSou
|
||||
}
|
||||
|
||||
let processfile = async (filename: string) => {
|
||||
|
||||
//ignore dotfiles
|
||||
if (filename.match(/(^|\/)\.[^\/]*$/)) { return; }
|
||||
|
||||
let singlematch = filename.match(/(^|\/)(\w+)-([\d_]+)\.(\w+)$/);
|
||||
if (singlematch) {
|
||||
let logicalid = singlematch[3].split(/_/g).map(q => +q);
|
||||
@@ -189,6 +185,9 @@ export async function writeCacheFiles(output: ScriptOutput, source: CacheFileSou
|
||||
let files = await diffdir.readDir(node);
|
||||
let base = (node == "." ? "" : node + "/")
|
||||
for (let file of files) {
|
||||
//ignore dotfiles
|
||||
if (file.name.match(/(^|\/)\.[^\/]*$/)) { continue; }
|
||||
|
||||
if (file.kind == "file") { await processfile(base + file.name); }
|
||||
if (file.kind == "directory") { await processdir(base + file.name); }
|
||||
}
|
||||
|
||||
@@ -118,12 +118,9 @@ function OpenRs2IdSelector(p: { initialid: number, onSelect: (id: number) => voi
|
||||
|
||||
let enterCacheId = async (idstring: string) => {
|
||||
let id = +idstring;
|
||||
if (id > 0) {
|
||||
p.onSelect(id);
|
||||
} else {
|
||||
let relevantcaches = await validOpenrs2Caches();
|
||||
p.onSelect(relevantcaches[-id].id);
|
||||
}
|
||||
// negative id means latest-x cache
|
||||
if (id <= 0) { id = (await Openrs2CacheSource.getRecentCache(-id)).id; }
|
||||
p.onSelect(id);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -179,7 +176,7 @@ function OpenRs2IdSelector(p: { initialid: number, onSelect: (id: number) => voi
|
||||
)
|
||||
}
|
||||
|
||||
export class CacheSelector extends React.Component<{ onOpen: (c: SavedCacheSource) => void, noReopen?: boolean }, { lastFolderOpen: FileSystemDirectoryHandle | null }>{
|
||||
export class CacheSelector extends React.Component<{ onOpen: (c: SavedCacheSource) => void, noReopen?: boolean }, { lastFolderOpen: FileSystemDirectoryHandle | null }> {
|
||||
constructor(p) {
|
||||
super(p);
|
||||
this.state = {
|
||||
@@ -351,7 +348,7 @@ export type UIContextReady = UIContext & { source: CacheFileSource, sceneCache:
|
||||
export type UIOpenedFile = { fs: ScriptFS, name: string, data: string | Buffer };
|
||||
|
||||
//i should figure out this redux thing...
|
||||
export class UIContext extends TypedEmitter<{ openfile: UIOpenedFile | null, statechange: undefined }>{
|
||||
export class UIContext extends TypedEmitter<{ openfile: UIOpenedFile | null, statechange: undefined }> {
|
||||
source: CacheFileSource | null = null;
|
||||
sceneCache: ThreejsSceneCache | null = null;
|
||||
renderer: ThreeJsRenderer | null = null;
|
||||
|
||||
Reference in New Issue
Block a user