Skip to content

Game films#505

Draft
assertivist wants to merge 9 commits into
mainfrom
feat-films
Draft

Game films#505
assertivist wants to merge 9 commits into
mainfrom
feat-films

Conversation

@assertivist

Copy link
Copy Markdown
Member

First prototype of game films

TODO:

  • playback
  • test with more than one player
  • maximum number of films saved in the database with rotation of old games into files

I wanted to get this reviewable ASAP. There are around ~3k frame function tables, or about 90kb of database, per player per minute of game.

@assertivist

Copy link
Copy Markdown
Member Author

TODO CONT'D:

  • try to skip storing frame function tables with all 0s (nothing input for these frames)
  • decide whether or not to save custom hull colors for a game, rather than loading whatever the most current custom colors that were last seen for a player
  • writing frame data occurs when the next level load occurs and the film has unsaved frames--find a better place to find out when the game is over and we can write the stored frame data

Comment thread src/game/CRUDsqlite.cpp
Comment on lines +76 to +78
"ALTER TABLE games ADD COLUMN properties TEXT ",
"ALTER TABLE games ADD COLUMN spawn_order INTEGER ",
"ALTER TABLE games ADD COLUMN frame_time INTEGER ",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm torn on spawn_order here. I think we have pretty much settled on using the hybrid setting for games so I think maybe it should be left out of this table and perhaps added to properties? I assume properties would capture one-off settings for a game? And ideally spawn_order is something you can override in an ALF file for a level.

Also, setting the frame_time implies that it can't be changed during a game. I'm actually fine with that limitation but some code might have to change to ensure that frame_time isn't changed during a recorded game (or maybe any game, nobody is changing that setting any more).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Properties was at first going to be a list of the players, but then I added a players table. I was going to store some of these attributes in there. But then I decided not to involve JSON serialization if I could just make more columns on these tables. Everything so far fits pretty easily, I left it in just in case.

re: frameTime, if we want to support changing it, I think we can capture the ConfigPlayer packet and mirror the frame changes in the recording. This setting is just for the starting frameTime. But I think it probably also makes sense to lock it down per-game. It makes for a really cool demonstration of variable fps but in practice switching between them is whiplash.

Comment thread src/game/CAvaraApp.cpp Outdated

OSErr CAvaraAppImpl::LoadLevel(std::string set, std::string levelTag, CPlayerManager *sendingPlayer) {
SDL_Log("LOADING LEVEL %s FROM %s\n", levelTag.c_str(), set.c_str());
if (itsGame->itsFilm->HasUnflushedFrames()) itsAPI->RecordFrames(itsGame);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need a way to enable/disable saving game recordings, like a check against kSaveGameRecordings, off by default?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Instead I would like to have it keep the last N games, lets say 30 by default, rotating out the oldest film that isn't marked to be saved explicitly. A value of 0 would mean to never rotate out any games (record and keep all).

I do think recording is something that should be enabled by default but I'm willing to hear opposing arguments.

@assertivist

Copy link
Copy Markdown
Member Author
  • added draft film serialization to binary file (it ended up being about the same size as the database size increase)
  • added hull colors to game metadata

I'm planning to leave the updates to game metadata in place, but remove the function tables from the database and only save them in files, then I'm going to focus on playback.

After playback is working, and some tests for serialization are in, I plan on integrating zlib + zstr. That way we can wrap the input/output streams for some compression. Using macOS "compress file" on the binary film reduced it from 100kb to 15kb for a minute of (~3500) player frames.

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