penguins
1.0.0
|
An entry in the Game::log_buffer, implemented as a tagged union.
The way log entries are stored is basically a union + a type tag. A union in C is a construct which allows interpreting the same data stored in the same memory location in different ways. Sometimes this is used for converting between types (e.g. unpacking an int
into the bytes it is comprised of), in our case it is used for the purpose of compact storage of the different log entry types. Basically, the field type indicates the kind of entry stored within the data field, so, for inspecting this struct, you first ALWAYS need to check the type, and then you can access the appropriate entry data:
The data structs of particular entry kinds should contain the delta (difference) between the previous and the next game state – this is enough information to both undo and redo the performed action. Also note that the total union (and consequently this struct) will be as large as the longest struct it can contain, the shorter structs will be padded to the longest length – this padding is wasted memory (currently the largest entry is GameLogMovement, though most of entries will be of this kind anyway, so we aren't wasting much).
Data Structures | |
union | GameLogEntryData |
Data Fields | |
GameLogEntryType | type |
union GameLogEntry::GameLogEntryData | data |
GameLogEntryType GameLogEntry::type |
Definition at line 157 of file game.h.
Referenced by GamePanel::describe_game_log_entry(), Game::game_pop_log_entry(), Game::game_push_log_entry(), Game::game_rewind_state_to_log_entry(), LogEntryViewerController::on_activated(), and LogEntryViewerController::paint_overlay().
union GameLogEntry::GameLogEntryData GameLogEntry::data |
Referenced by GamePanel::describe_game_log_entry(), Game::game_rewind_state_to_log_entry(), Game::game_set_current_player(), Game::game_set_phase(), Game::move_penguin(), LogEntryViewerController::on_activated(), LogEntryViewerController::paint_overlay(), Game::place_penguin(), Game::undo_move_penguin(), and Game::undo_place_penguin().