-
Notifications
You must be signed in to change notification settings - Fork 39
1.33 object data #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-4.0.5
Are you sure you want to change the base?
1.33 object data #76
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { HexBuffer } from '../HexBuffer'; | ||
| import { W3Buffer } from '../W3Buffer'; | ||
| import { WarResult, JsonResult } from '../CommonInterfaces' | ||
| import {HexBuffer} from '../HexBuffer'; | ||
| import {W3Buffer} from '../W3Buffer'; | ||
| import {WarResult, JsonResult} from '../CommonInterfaces' | ||
|
|
||
| enum TableType { | ||
| original = 'original', | ||
|
|
@@ -85,7 +85,10 @@ export abstract class ObjectsTranslator { | |
| // Original and new object ids | ||
| if (tableType === TableType.original) { | ||
| outBufferToWar.addChars(defKey); | ||
| outBufferToWar.addByte(0); outBufferToWar.addByte(0); outBufferToWar.addByte(0); outBufferToWar.addByte(0); // no new Id is assigned | ||
| outBufferToWar.addByte(0); | ||
| outBufferToWar.addByte(0); | ||
| outBufferToWar.addByte(0); | ||
| outBufferToWar.addByte(0); // no new Id is assigned | ||
| } else { | ||
| // e.g. "h000:hfoo" | ||
| outBufferToWar.addChars(defKey.substring(5, 9)); // original id | ||
|
|
@@ -174,7 +177,7 @@ export abstract class ObjectsTranslator { | |
| } | ||
|
|
||
| public static warToJson(type: string, buffer: Buffer): JsonResult<ObjectModificationTable> { | ||
| const result = { original: {}, custom: {} }; | ||
| const result = {original: {}, custom: {}}; | ||
| const outBufferToJSON = new W3Buffer(buffer); | ||
|
|
||
| const fileVersion = outBufferToJSON.readInt(); | ||
|
|
@@ -185,42 +188,51 @@ export abstract class ObjectsTranslator { | |
| for (let i = 0; i < numTableModifications; i++) { | ||
| const objectDefinition = []; // object definition will store one or more modification objects | ||
|
|
||
| const originalId = outBufferToJSON.readChars(4), | ||
| customId = outBufferToJSON.readChars(4), | ||
| modificationCount = outBufferToJSON.readInt(); | ||
|
|
||
| for (let j = 0; j < modificationCount; j++) { | ||
| const modification: Modification = { | ||
| id: '', | ||
| type: ModificationType.string, | ||
| level: 0, | ||
| column: 0, | ||
| value: {} | ||
| }; | ||
|
|
||
| modification.id = outBufferToJSON.readChars(4); | ||
| modification.type = this.varTypes[outBufferToJSON.readInt()]; // 'int' | 'real' | 'unreal' | 'string', | ||
| const originalId = outBufferToJSON.readChars(4); | ||
| const customId = outBufferToJSON.readChars(4); | ||
| let sets = 1; | ||
| const setsFlag: number[] = []; | ||
| if (fileVersion >= 3) { | ||
| sets = outBufferToJSON.readInt(); | ||
| } | ||
|
|
||
| if (type === ObjectType.Doodads || type === ObjectType.Abilities || type === ObjectType.Upgrades) { | ||
| modification.level = outBufferToJSON.readInt(); | ||
| modification.column = outBufferToJSON.readInt(); | ||
| for (let set = 0; set < sets; set++) { | ||
| if(fileVersion >=3) { | ||
| setsFlag[set] = outBufferToJSON.readInt(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is It doesn't look like you're using this variable anywhere.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could probably remove as we don't patch existing object Giles, only generate new ones |
||
| } | ||
| const modificationCount = outBufferToJSON.readInt(); | ||
| for (let j = 0; j < modificationCount; j++) { | ||
| const modification: Modification = { | ||
| id: '', | ||
| type: ModificationType.string, | ||
| level: 0, | ||
| column: 0, | ||
| value: {} | ||
| }; | ||
|
|
||
| modification.id = outBufferToJSON.readChars(4); | ||
| modification.type = this.varTypes[outBufferToJSON.readInt()]; // 'int' | 'real' | 'unreal' | 'string', | ||
|
|
||
| if (type === ObjectType.Doodads || type === ObjectType.Abilities || type === ObjectType.Upgrades) { | ||
| modification.level = outBufferToJSON.readInt(); | ||
| modification.column = outBufferToJSON.readInt(); | ||
| } | ||
|
|
||
| if (modification.type === 'int') { | ||
| modification.value = outBufferToJSON.readInt(); | ||
| } else if (modification.type === 'real' || modification.type === 'unreal') { | ||
| modification.value = outBufferToJSON.readFloat(); | ||
| } else { // modification.type === 'string' | ||
| modification.value = outBufferToJSON.readString(); | ||
| } | ||
| if (modification.type === 'int') { | ||
| modification.value = outBufferToJSON.readInt(); | ||
| } else if (modification.type === 'real' || modification.type === 'unreal') { | ||
| modification.value = outBufferToJSON.readFloat(); | ||
| } else { // modification.type === 'string' | ||
| modification.value = outBufferToJSON.readString(); | ||
| } | ||
|
|
||
| if (isOriginalTable) { | ||
| outBufferToJSON.readInt(); // should be 0 for original objects | ||
| } else { | ||
| outBufferToJSON.readChars(4); // should be object ID for custom objects | ||
| if (isOriginalTable) { | ||
| outBufferToJSON.readInt(); // should be 0 for original objects | ||
| } else { | ||
| outBufferToJSON.readChars(4); // should be object ID for custom objects | ||
| } | ||
| objectDefinition.push(modification); | ||
| } | ||
|
|
||
| objectDefinition.push(modification); | ||
| } | ||
|
|
||
| if (isOriginalTable) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can you clarify since I haven't looked at a 1.33 object data diff: the entire modification table is now wrapped in an additional loop? What do the sets represent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure, I'll have to do some research, this was copied from mdx-model-viewer
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea if you could also dig around to figure out what it is, that would be useful.
Here's an experiment I did:
.w3ufile to check for new dataI am seeing some new bytes that aren't accounted for in the version 2 of the parser: