Skip to content

Addition of background prop to pokemon#312

Open
Petap0w wants to merge 9 commits intoUnownHash:mainfrom
Petap0w:background
Open

Addition of background prop to pokemon#312
Petap0w wants to merge 9 commits intoUnownHash:mainfrom
Petap0w:background

Conversation

@Petap0w
Copy link

@Petap0w Petap0w commented Oct 12, 2025

Experimental but worked well all day for me here.
Will send "background" in pokemon webhook (either null or int value)

Copy link
Collaborator

@jfberry jfberry left a comment

Choose a reason for hiding this comment

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

looks good, subject only to data type issue in db

@Fabio1988
Copy link
Collaborator

So testing contained C-Day? Thanks a lot, looks good

@Petap0w
Copy link
Author

Petap0w commented Oct 12, 2025

So testing contained C-Day? Thanks a lot, looks good

Yes good for easy Solosis shundo with background :)
Capture d’écran 2025-10-12 à 22 13 07

@Fabio1988 Fabio1988 requested a review from jfberry October 13, 2025 17:52
@jfberry
Copy link
Collaborator

jfberry commented Oct 13, 2025

I'm happy once someone has run this on db mode to prove it works (it looks ok, but...)

@Mygod
Copy link
Contributor

Mygod commented Oct 13, 2025

I think the rest of the codebase uses LocationCard though. https://github.com/search?q=repo%3AUnownHash%2FGolbat+locationcard&type=code

@Mygod
Copy link
Contributor

Mygod commented Oct 13, 2025

We should consider having consistency so change one to the other. AFAIC only ReactMap uses LocationCard internally currently but is not exposed to the frontend yet so you could consider changing all to Background. This would not have any user-facing consequences.

@jfberry
Copy link
Collaborator

jfberry commented Oct 13, 2025

We should consider having consistency so change one to the other. AFAIC only ReactMap uses LocationCard internally currently but is not exposed to the frontend yet so you could consider changing all to Background. This would not have any user-facing consequences.

I agree +1 for consistency here. Have no opinion on terminology one way or the other, either works for me

Copy link
Collaborator

@Fabio1988 Fabio1988 left a comment

Choose a reason for hiding this comment

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

As mentioned from @Mygod we should try to be consistent with other location card props, thanks for the hint

@Mygod
Copy link
Contributor

Mygod commented Oct 15, 2025

So we shake on background?

@Petap0w
Copy link
Author

Petap0w commented Oct 16, 2025

@Mygod please confirm changes are ok as I don't know what I am doing.

@Fabio1988 Fabio1988 self-requested a review October 16, 2025 16:51
@Petap0w Petap0w force-pushed the background branch 2 times, most recently from 2c1f4c1 to 1b8b30e Compare October 16, 2025 18:33
@Fabio1988
Copy link
Collaborator

@Petap0w to reuse the util method we just needed to change to int64, in JSON it doesn't even matter but null.IntFrom requires int64... It's safe to use that type and instead of converting the value we just adapt the function, pushed the updated version

One more comment, wihch would need to change I guess :)

Copy link
Contributor

@Mygod Mygod left a comment

Choose a reason for hiding this comment

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

[P0] Preserve null background when no location card — decoder/pokemon.go:1113-1116
With the new util helper we now call null.IntFrom(util.ExtractBackgroundFromDisplay(...)) (e.g. here and in setPokemonDisplay). When the proto has no LocationCard, ExtractBackgroundFromDisplay returns 0, and null.IntFrom(0) marks the column as valid. Previously we only populated the field when LocationCard != nil, so those records stayed NULL. After this change the majority of encounters will be persisted and webhooked with background = 0, which
is incorrect data and breaks the previous semantics consumers rely on to tell the difference between “no background” and “background id 0”. Please keep returning an invalid null.Int when the card is absent (e.g. only set Background if the card exists).

Copy link
Contributor

@Mygod Mygod left a comment

Choose a reason for hiding this comment

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

Given that 0 represents no location card in GM, we should not have both null and 0 as options in the database creating confusion and unnecessarily complicated logic.

@Mygod
Copy link
Contributor

Mygod commented Oct 16, 2025

Actually I suppose GM can send both null and 0 as location card: LocationCard can be null and LocationCard.LocationCard can be 0. In that case, we should try to support both even though I don't think 0 is used.

@Fabio1988 Fabio1988 requested a review from Mygod October 17, 2025 07:56
@Fabio1988 Fabio1988 self-requested a review October 17, 2025 07:56
Copy link
Contributor

@Mygod Mygod left a comment

Choose a reason for hiding this comment

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

Running codex review

@Mygod
Copy link
Contributor

Mygod commented Oct 17, 2025

One thing that should be tested is whether location card is sent in wild not just encounter. Since we couldn't test it now, we could merge it first and fix it later if this turns out to be broken.

@jfberry
Copy link
Collaborator

jfberry commented Oct 17, 2025

One thing that should be tested is whether location card is sent in wild not just encounter. Since we couldn't test it now, we could merge it first and fix it later if this turns out to be broken.

We know the display object is only filled in a limited way in wild overworld contexts. Since we encounter anyway it seems pointless to try to populate from wild - there is only downside to this

Some people do not process wild at all because it doesn’t especially help anything only slows down processing

@Mygod
Copy link
Contributor

Mygod commented Oct 17, 2025

When I said wild, I was referring to WildPokemonProto which could be picked up from nearby as well.

@jfberry
Copy link
Collaborator

jfberry commented Oct 18, 2025

When I said wild, I was referring to WildPokemonProto which could be picked up from nearby as well.

All the GMO based Pokémon have a limited pokemondisplay population, so acting on any potential pre-setting of background here without evidence would be a mistake IMO. It’s far more likely this would end up removing any background capture from an encounter

@Mygod
Copy link
Contributor

Mygod commented Oct 18, 2025

AFAIC the only thing that is not populated in PokemonDisplayProto is Shiny which is per-account, so I would think the most natural conjecture is that LocationCard is sent in GMO. Given that this is not visible in the game, there is a good chance that this is how it is implemented.

@Fabio1988 Fabio1988 requested a review from Mygod October 18, 2025 07:58
@Mygod
Copy link
Contributor

Mygod commented Oct 20, 2025

From codex:

[P0] Add background column to SQLite schema — sql/50_pokemon_background.up.sql:1-2
The decoder now reads and writes pokemon.Background (e.g. via the INSERT/UPDATE statements in decoder/pokemon.go), so every deployment needs a background column on the pokemon table. The MySQL migration adds it, but the SQLite schema in sql/sqlite/create.sql still lacks this column. Any SQLite install that uses that schema (fresh setups or regenerated databases) will start returning SQL errors as soon as the decoder tries to insert or update a Pokémon. Please add the column to the SQLite schema (and any other canonical schema dumps you maintain) to keep SQLite deployments working.

@jfberry
Copy link
Collaborator

jfberry commented Oct 20, 2025

From codex:

[P0] Add background column to SQLite schema — sql/50_pokemon_background.up.sql:1-2

I'd be concerned if we used sqlite. But we don't.

@Mygod
Copy link
Contributor

Mygod commented Oct 20, 2025

Even if your deployment doesn’t touch SQLite today, this repo still ships sql/sqlite/create.sql as the canonical schema for SQLite users. With the new pokemon.background writes landing in decoder/pokemon.go, any fresh SQLite setup—or anyone regenerating their DB from that script—will start failing inserts/updates immediately. Unless we’re officially dropping SQLite support (which would require ripping out quite a bit more), we still need to add the column in sql/sqlite/create.sql to keep that audience running. Let me know if you’d rather take the “remove SQLite support” path instead.

@jfberry
Copy link
Collaborator

jfberry commented Oct 20, 2025

Even if your deployment doesn’t touch SQLite today, this repo still ships sql/sqlite/create.sql as the canonical schema for SQLite users.

This file can be deleted, it has not been used since very early trials of in memory
It can be deleted in this PR or separately.

@Mygod
Copy link
Contributor

Mygod commented Oct 29, 2025

We should probably also have API support filtering by background too?

@jfberry
Copy link
Collaborator

jfberry commented Oct 29, 2025

Since gmo arrives much more frequently (and this proto doesn’t even get sent by some systems/modes) we deliberately only took missing data (name, desc, and latterly defenders)

Probably the only bit in this PR that has value is being able to ignore the proto if gyms are turned off. Which I’m not sure anyone does

@Fabio1988
Copy link
Collaborator

Since gmo arrives much more frequently (and this proto doesn’t even get sent by some systems/modes) we deliberately only took missing data (name, desc, and latterly defenders)

Probably the only bit in this PR that has value is being able to ignore the proto if gyms are turned off. Which I’m not sure anyone does

I assume you wanted to comment on #315 ?

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.

4 participants