Skip to content

Portrait support#1534

Merged
Flamefire merged 19 commits into
Return-To-The-Roots:masterfrom
tehKaiN:portrait-support
Jun 17, 2025
Merged

Portrait support#1534
Flamefire merged 19 commits into
Return-To-The-Roots:masterfrom
tehKaiN:portrait-support

Conversation

@tehKaiN

@tehKaiN tehKaiN commented Sep 16, 2022

Copy link
Copy Markdown
Contributor

fixes #798
fixes #1181

I still have unit tests and other stuff to fix, but I think it's ready for reviews.

There's small problem with column names on 800x600 resolution, but who plays using that res anymore?

obraz

This will be split into lesser PRs:

@tehKaiN tehKaiN force-pushed the portrait-support branch 5 times, most recently from c93a8b2 to 0aade21 Compare September 17, 2022 06:39
@tehKaiN

tehKaiN commented Sep 17, 2022

Copy link
Copy Markdown
Contributor Author

the thing about lua test is funny:

/home/runner/work/s25client/s25client/tests/s25Main/integration/testWorld.cpp(261): fatal error: in "MapTestSuite/LoadLua": Unexpected log: Lua script did not provide the function getRequiredLuaVersion()! It is probably outdated.

on my local machine it prints space between function name and () - very strange

[ctest] D:/git/s25client/tests/s25Main/integration/testWorld.cpp(261): fatal error: in "MapTestSuite/LoadLua": Unexpected log: Skrypt Lua nie udostępnił funkcji getRequiredLuaVersion ()! Prawdopodobnie jest nieaktualny.

but only when I run it via ctest, when I run it manually it works fine. Perhaps some kind of log formatting from cmake?

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

on my local machine it prints space between function name and () - very strange

This is a translation bug. Fixed by Return-To-The-Roots/languages@d465390

Besides that the PR is really big although the changes are related. This may make the review and fixing iterations a bit longer, but should work out. So don't mind the many comments.

Comment thread doc/lua/functions.md Outdated
Comment thread libs/common/include/helpers/mathFuncs.h Outdated
Comment thread libs/common/include/helpers/mathFuncs.h Outdated
Comment thread libs/s25main/BasePlayerInfo.cpp
Comment thread libs/s25main/BasePlayerInfo.h Outdated
Comment thread libs/s25main/gameData/PortraitConsts.h Outdated
Comment thread libs/s25main/network/GameMessages.h Outdated
Comment thread libs/s25main/network/GameServer.cpp Outdated
Comment thread libs/s25main/ogl/ITexture.h Outdated
Comment thread libs/s25main/ogl/glSmartBitmap.cpp Outdated
@tehKaiN

tehKaiN commented Sep 18, 2022

Copy link
Copy Markdown
Contributor Author

I'm a bit worried about breaking changes in serialization - I'm planning to tackle some more issues blocking single player campaign implementation and perhaps there will be more serialization-intrusive things along the way. Perhaps we should merge it into separate branch (something like campaign) and then merge in all the changes at once into master, breaking stuff only once?

@Flamefire

Copy link
Copy Markdown
Member

I'm a bit worried about breaking changes in serialization

Then maybe factor out the other changes into separate PRs. E.g. the use of enum-IDs for the controls, the image-handling etc. So all that is left is really only the portrait.

If you don't know yet: git add -p allows to chose which changes to stage at the hunk level. So you can then commit only parts of the changes in a file. I found that very useful when splitting up commits.

@tehKaiN

tehKaiN commented Sep 18, 2022

Copy link
Copy Markdown
Contributor Author

The thing is, image handling was required to make portraits in lobby in reasonable shape. Splitting settings and lobby portrait into separate PRs seems like an overkill to me. I can make lua thingy and IDs separate, but dunno if it's really worth it.

What I meant regarding breaking serialization is that with portrait change I introduce serialization version 10. Perhaps with future PRs I'll introduce another breaking changes, bumping it e.g. to 11, 12 and 13. Perhaps it's wise to cram up as many serialization-breaking changes to a single version bump (e.g. by preparing them on separate feature branch), so that nightly players won't have their save files unusable too often.

@Flamefire

Copy link
Copy Markdown
Member

The thing is, image handling was required to make portraits in lobby in reasonable shape. Splitting settings and lobby portrait into separate PRs seems like an overkill to me. I can make lua thingy and IDs separate, but dunno if it's really worth it.

ca7a173 and 1367fcc potentially with tests can go into a separate PR, especially as there is a remark for the latter. IMO that is a standalone change worth of its own PR and maybe we can come up with a few (automatic or manual) tests to check that it works as expected.

The ID change could be extracted. Yes it might not be really worth it but the idea is to bring as much into master as possible. I'm even thinking about making a change to the Serializer so the portrait change can be backwards compatible.

@tehKaiN

tehKaiN commented Sep 18, 2022

Copy link
Copy Markdown
Contributor Author

Ok, I'll split my changes into separate branches and we'll merge them in more granular manner - probably not today though.

@tehKaiN tehKaiN force-pushed the portrait-support branch 2 times, most recently from 4be1f51 to 5b5f81d Compare September 20, 2022 15:41
@tehKaiN

tehKaiN commented Sep 20, 2022

Copy link
Copy Markdown
Contributor Author

Somehow I've missed some of your comments - all are fixed now. I'll continue to split the PR into smaller ones and I guess we'll leave portrait part unmerged until we decide if save compatibility should be broken or add support so that it'll be prevented

@tehKaiN

tehKaiN commented Apr 26, 2025

Copy link
Copy Markdown
Contributor Author

Oops, looks like this thing got buried under the rubble of my other activities, sorry! 👀

Is that thing still desired for the project? If yes, then I could get back to this #1536 soon.

@Flamefire

Copy link
Copy Markdown
Member

Is that thing still desired for the project? If yes, then I could get back to this #1536 soon.

Sure. IIRC the main issue in that other PR was a clear definition of the behavior (also in corner cases). Best to be done in code (tests). But has been a while and would need to read up on it again when you work on it

@tehKaiN

tehKaiN commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

I've tweaked the field sizes a bit so that it looks better on 800x600:

obraz

The only problem is that AI (medium) doesn't fit the display. I could probably make some room by moving the map preview to the right, but that would also mean moving bottom controls so that they end at the same X pos.

The problem would be non-existant if we'd somehow get rid of "Ready?" column on top - perhaps adding a tooltip to the checkbox class? Nevermind that each row displays the checkbox - I've hacked it in for sake of preview.

Apart from that, setting the preferred portrait in options desktop works as intended, as well as (de)serialize in game config. I still need to check if those portraits survive the game save/load correctly.

EDIT: the column names are all over the place with some languages and sadly there's not much to do about them. But still, I guess that proper display of English/German is enough on such low resolution.

obraz

@Flamefire

Copy link
Copy Markdown
Member

Savegames and replays are all incompatible due to a new field in the player info.

This indeed requires some kind of migration code.

Would you be up to adding such? I guess you'd need to start at GamePlayerInfo and go up from there.

Well, I guess the firest packet in communication could contain some kind of version field so that incompatible clients are rejected early on or they refuse to connect to too new servers? That would mean another breaking change if there's no field like that, but that would be future-proof.

I found we already require clients to have the same revision:

else if(msg.revision != rttr::version::GetRevision())
typeok = GameMessage_Server_TypeOK::StatusCode::WrongVersion;

So that should be enough.

There is a new network message but it uses the ID of an existing message

Sounds like sloppiness /auto-merge break and shouldn't be the case!

Given it is not possible that a client communicates with an incompatible client I think we can keep the messages ordered by name as you had before.

I don't fully understand the change to dskOptions. What does this do?

Similar to gif in the issue page (with correct label right now, of course):

I see. Where is this used? I though portraits are only for ingame use and hence the selection only makes sense in the lobby screen.

@tehKaiN

tehKaiN commented Jun 5, 2025

Copy link
Copy Markdown
Contributor Author

Would you be up to adding such? I guess you'd need to start at GamePlayerInfo and go up from there.

Of course!

Given it is not possible that a client communicates with an incompatible client I think we can keep the messages ordered by name as you had before.

Alright, I'll revert my change on my nearest commit spree.

I see. Where is this used? I though portraits are only for ingame use and hence the selection only makes sense in the lobby screen.

The portrait selection in options screen sets up the default portrait, so that if you create a game and want to play as Knut, you don't have to cycle through portraits each time.

Comment thread libs/s25main/ingameWindows/iwStatistics.cpp
Comment thread libs/s25main/BasePlayerInfo.cpp Outdated
@tehKaiN tehKaiN force-pushed the portrait-support branch 2 times, most recently from f3f3314 to 4685d27 Compare June 14, 2025 12:06
Comment thread libs/s25main/SerializedGameData.cpp Outdated
Comment thread libs/s25main/BasePlayerInfo.h Outdated
Comment thread libs/s25main/BasePlayerInfo.h Outdated
Comment thread libs/s25main/BasePlayerInfo.cpp Outdated

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Final polishing then it's good to go 👍

Comment thread libs/s25main/SavedFile.cpp
Comment thread libs/s25main/SavedFile.h Outdated
Comment thread libs/s25main/SavedFile.h Outdated
Comment thread libs/s25main/desktops/dskGameLobby.cpp
Comment thread libs/s25main/gameData/PortraitConsts.h Outdated
Comment thread libs/s25main/ingameWindows/iwStatistics.cpp

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final place in need for range check I missed before

Comment thread libs/s25main/BasePlayerInfo.cpp
Comment thread libs/s25main/ingameWindows/iwStatistics.cpp
@tehKaiN tehKaiN force-pushed the portrait-support branch from a28daca to 0307ea3 Compare June 16, 2025 16:38
Comment thread libs/s25main/gameData/PortraitConsts.h
@Flamefire Flamefire enabled auto-merge June 17, 2025 08:30

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a lot of work, so thanks!

@Flamefire Flamefire merged commit 819c9b8 into Return-To-The-Roots:master Jun 17, 2025
16 checks passed
@tehKaiN tehKaiN deleted the portrait-support branch June 17, 2025 09:20
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.

[LUA] function setPortrait Player avatars

3 participants