Skip to content
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

Migrate monstdat to a data file #5220

Merged
merged 3 commits into from
Nov 10, 2023
Merged

Conversation

glebm
Copy link
Collaborator

@glebm glebm commented Aug 8, 2022

We may want to migrate this to 1 file per monster but for now the format is as close to the hard-coded version as possible.

Sprites that are used by multiple monsters are only loaded from disk once.

With the CSV editor extension in VS Code:

image

@glebm glebm force-pushed the load-sprites-once branch 2 times, most recently from c2a195a to 87c1fae Compare October 11, 2023 07:37
@glebm glebm marked this pull request as draft October 11, 2023 07:38
@glebm glebm force-pushed the load-sprites-once branch 2 times, most recently from 179b7ff to f28ab66 Compare October 11, 2023 08:11
@glebm glebm marked this pull request as ready for review October 11, 2023 08:11
@glebm glebm force-pushed the load-sprites-once branch 3 times, most recently from 00cbe14 to dddf285 Compare October 11, 2023 08:21
@glebm glebm enabled auto-merge (rebase) October 11, 2023 08:25
@glebm glebm force-pushed the load-sprites-once branch 2 times, most recently from 1b54134 to 8d6bf4f Compare October 11, 2023 08:30
@glebm glebm requested a review from AJenbo October 12, 2023 09:23
@glebm glebm marked this pull request as draft November 2, 2023 11:57
auto-merge was automatically disabled November 2, 2023 11:57

Pull request was converted to draft

@glebm glebm force-pushed the load-sprites-once branch from 8d6bf4f to e065fde Compare November 2, 2023 13:03
@glebm glebm changed the title Slightly optimize loading same-sprite monsters Migrate monstdat to a data file Nov 2, 2023
@glebm glebm marked this pull request as ready for review November 2, 2023 13:17
@glebm glebm enabled auto-merge (rebase) November 2, 2023 13:17
@AJenbo
Copy link
Member

AJenbo commented Nov 2, 2023

Yes!

@glebm glebm force-pushed the load-sprites-once branch from e065fde to 0c4dd3d Compare November 2, 2023 14:11
Source/monstdat.cpp Outdated Show resolved Hide resolved
@AJenbo
Copy link
Member

AJenbo commented Nov 9, 2023

@glebm I just have that one single comment, but also now that debug.cpp has been rewritten this is going to need a little rebase if you have the time :)

@AJenbo
Copy link
Member

AJenbo commented Nov 10, 2023

Ok, it looks like you haven't made any adjustments for picking up the monster names when translation files are updated.
Do you have any thought about how that should be handled?
Maybe we could actually just grab the second column and do away with the handeling of P_("monster", ).

Text extraction is normally done by calling xgettext (often by the translators them selfs from the Poedit gui).

For monsters with the same sprite, load the sprite from the file system only once.

Example:

```
VERBOSE: Loaded monster graphics: falspear\phall   452 KiB   x1
VERBOSE: Loaded monster graphics: skelbow\sklbw    618 KiB   x1
VERBOSE: Loaded monster graphics: skelsd\sklsr     610 KiB   x1
VERBOSE: Loaded monster graphics: goatbow\goatb    832 KiB   x1
VERBOSE: Loaded monster graphics: bat\bat          282 KiB   x2 <-- here we only load the sprite once
VERBOSE: Loaded monster graphics: rhino\rhino     1306 KiB   x1
VERBOSE: Loaded monster graphics: golem\golem      298 KiB   x1
VERBOSE:  Total monster graphics:                 4401 KiB 4684 KiB
```

Here, the bat sprite will be loaded from the MPQ only once.
For the second sprite, we simply clone the first sprite before applying TRNs.

This also reduces the size of `MonsterData` from 88 bytes to 80.

When we migrate monster data to a TSV, the sprite IDs can be generated automatically at load time.
@AJenbo
Copy link
Member

AJenbo commented Nov 10, 2023

We may want to migrate this to 1 file per monster

I actually much prefer it as a table of monsters. I'm not sure how it would look if split up though, but it sounds like it would mostly just complicates editing them and be easy to make one of them not align with the others etc.

glebm and others added 2 commits November 10, 2023 06:42
We may want to migrate this to 1 file per monster but for now the
migration is as close to the hard-coded version as possible.

Sprites that are used by multiple monsters are only loaded from disk
once.
@AJenbo
Copy link
Member

AJenbo commented Nov 10, 2023

I had a little chat with chatGPT and we came to the conclusion that we should make a python script that the developers run each time the tsv file is updated. This lets the translation process work with out changes and also addresses my only comment to your code and gives us a simpler data file.

I got excited and made an implementation for it, hope you like it :)

@glebm glebm merged commit 4c2ca1e into diasurgical:master Nov 10, 2023
19 checks passed
@glebm glebm deleted the load-sprites-once branch November 10, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants