Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/enums/SimDataGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
{
"displayType": "enum",
"values": [
{
"name": "AccountReward",
"value": "0x000F1963"
},
{
"name": "Achievement",
"value": "0x00559EE6"
Expand Down Expand Up @@ -99,6 +103,10 @@
"name": "CasPreferenceCategory",
"value": "0x0004FC85"
},
{
"name": "CasPreferenceGroup",
"value": "0x0090F742"
},
{
"name": "CasPreferenceItem",
"value": "0x0068FDCE"
Expand Down
20 changes: 20 additions & 0 deletions docs/enums/TuningResourceType.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
{
"displayType": "enum",
"values": [
{
"name": "AccountReward",
"value": "0xBB0F19D8"
},
{
"name": "Achievement",
"value": "0x78559E9E"
Expand Down Expand Up @@ -119,6 +123,10 @@
"name": "CasPreferenceCategory",
"value": "0xCE04FC4B"
},
{
"name": "CasPreferenceGroup",
"value": "0x6690F724"
},
{
"name": "CasPreferenceItem",
"value": "0xEC68FD22"
Expand All @@ -135,6 +143,10 @@
"name": "CasStoriesTraitChooser",
"value": "0x8DAD1549"
},
{
"name": "CheatSheet",
"value": "0x16B37B7A"
},
{
"name": "Clan",
"value": "0xDEBEE6A5"
Expand Down Expand Up @@ -339,6 +351,14 @@
"name": "SlotTypeSet",
"value": "0x3F163505"
},
{
"name": "SmallBusinessBinary",
"value": "0x057424DD"
},
{
"name": "SmallBusinessSeed",
"value": "0xB22EA24D"
},
{
"name": "Snippet",
"value": "0x7DF2169C"
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
},
"main": "./models.js",
"scripts": {
"clean": "rm -rf ./dst/**",
"dev": "npm run clean ; tsc --watch",
"clean": "rm -rf ./dst/** || true",
"dev": "npm run clean && tsc --watch",
"dev:serve": "npm run build && ts-node \"./server/app.ts\"",
"build": "npm run clean ; tsc ; node scripts/prepublish.cjs",
"build": "npm run clean && tsc && node scripts/prepublish.cjs",
"publish": "npm run build && sh scripts/publish.sh",
"test": "mocha -r ts-node/register \"test/**/*.test.ts\"",
"test:coverage": "nyc mocha -r ts-node/register \"test/**/*.test.ts\"",
"test:current": "mocha -r ts-node/register \"test/**/combined-tuning-resource.test.ts\""
"test:current": "mocha -r ts-node/register \"test/**/combined-tuning-resource.test.ts\"",
"extractsimdata": "npm run build && ts-node \"./scripts/extract-simdata-types.ts\""
},
"author": "frankkulak",
"funding": {
Expand Down
34 changes: 19 additions & 15 deletions scripts/extract-simdata-types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import fs from "fs";
import glob from "glob";
import path from "path";
import { Package, SimDataResource } from "../dst/models";
import { BinaryResourceType, SimDataGroup, TuningResourceType } from "../dst/enums";
import { ResourceKeyPair } from "../dst/lib/packages/types";
import { formatAsHexString } from "@s4tk/hashing/formatting"
import { formatAsHexString } from "@s4tk/hashing/formatting";
import { registerPlugin } from "../dst/plugins";
import BufferFromFile from "@s4tk/plugin-bufferfromfile";
registerPlugin(BufferFromFile);

const directories = [
'/Applications/The Sims 4 Packs',
'/Applications/The Sims 4.app',
'C:/Program Files/EA Games/The Sims 4',
'D:/Program Files/EA Games/The Sims 4',
];

const groupsToIgnore = new Set([
Expand All @@ -25,11 +30,11 @@ const groupsToIgnore = new Set([

function findPackagePaths(): Promise<string[]> {
return new Promise(resolve => {
const packagePaths = [];
const packagePaths: string[] = [];

directories.forEach(directory => {
const files = glob.sync(directory + '/**/*.package');
packagePaths.push(...files);
packagePaths.push(...files.filter((p) => !path.basename(p).startsWith("Strings_")));
});

resolve(packagePaths);
Expand All @@ -44,21 +49,20 @@ findPackagePaths().then(packagePaths => {

console.log("Reading packages...");
packagePaths.forEach((path, i) => {
const buffer = fs.readFileSync(path);

const entries = Package.extractResources(buffer, {
resourceFilter(type, group, inst) {
if (type === BinaryResourceType.SimData) {
try {
const entries = Package.streamResources(path, {
resourceFilter(type, group, inst) {
if (type !== BinaryResourceType.SimData) return false;
if (groupsToIgnore.has(group)) return false;
if (group in SimDataGroup) return false;
return true;
} else {
return false;
}
}
});

allFiles.push(...entries);
});

allFiles.push(...entries);
} catch (error: any) {
console.error(error.message);
}
console.log(`(${i + 1}/${packagePaths.length}) Read ${path}`);
});

Expand Down
2 changes: 2 additions & 0 deletions src/lib/enums/simdata-groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TuningResourceType from "./tuning-resources";
* Groups for SimDatas.
*/
enum SimDataGroup {
AccountReward = 0x000F1963,
Achievement = 0x00559EE6,
AchievementCategory = 0x0051C125,
AchievementCollection = 0x00D2B461,
Expand All @@ -25,6 +26,7 @@ enum SimDataGroup {
CasMenuItem = 0x00BA50F8,
CasOccultSkintone = 0x00C36C35, // uses TuningResourceType.Tuning
CasPreferenceCategory = 0x0004FC85,
CasPreferenceGroup = 0x0090F742,
CasPreferenceItem = 0x0068FDCE,
CasStoriesAnswer = 0x00F12D97,
CasStoriesQuestion = 0x00246B9E,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/enums/tuning-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getAllEnumValues, pascalToSnake, snakeToPascal } from "../common/helper
* Types for tuning resources (i.e. any XML resource that is loaded as tuning).
*/
enum TuningResourceType {
AccountReward = 0xBB0F19D8,
Achievement = 0x78559E9E,
AchievementCategory = 0x2451C101,
AchievementCollection = 0x04D2B465,
Expand All @@ -29,10 +30,12 @@ enum TuningResourceType {
CasMenu = 0x935A83C2,
CasMenuItem = 0x0CBA50F4,
CasPreferenceCategory = 0xCE04FC4B,
CasPreferenceGroup = 0x6690F724,
CasPreferenceItem = 0xEC68FD22,
CasStoriesAnswer = 0x80F12D17,
CasStoriesQuestion = 0x03246B9D,
CasStoriesTraitChooser = 0x8DAD1549,
CheatSheet = 0x16B37B7A,
Clan = 0xDEBEE6A5,
ClanValue = 0x998ED0AB,
ClubInteractionGroup = 0xFA0FFA34,
Expand Down Expand Up @@ -84,6 +87,8 @@ enum TuningResourceType {
SituationJob = 0x9C07855F,
SlotType = 0x69A5DAA4,
SlotTypeSet = 0x3F163505,
SmallBusinessBinary = 0x057424DD,
SmallBusinessSeed = 0xB22EA24D,
Snippet = 0x7DF2169C,
SocialGroup = 0x2E47A104,
Spell = 0x1F3413D9,
Expand Down