-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add flatbuffers for base world state #7
Conversation
server/src/main.rs
Outdated
#[allow(dead_code, unused_imports, clippy::redundant_field_names)] | ||
#[path = "../target/flatbuffers/world_generated.rs"] | ||
mod world_generated; | ||
pub use world_generated::tankrs::{get_root_as_world, World, WorldArgs}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need pub here.
server/schema/world.fbs
Outdated
namespace Tankrs; | ||
|
||
table World { | ||
width: uint16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments for these fields (e.g. how wide the world is in number of blocks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, I would like us to use id number for these schemas so we can order them logically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write an example for how an id number annotation looks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
width: uint16 (id: 0);
However, this does look more cluttered. I don't know if the advantage of being able to logically group fields outweighs this.
server/build.rs
Outdated
|
||
fn main() { | ||
flatc_rust::run(flatc_rust::Args { | ||
inputs: &[Path::new("schema/world.fbs")], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we glob **.fbs? That way we would not have to add to this every time we make a new flatb module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Unfortunately the type specification is a slice of paths. We can dynamically generate a slice of paths in the future.
a89a7ac
to
5280e91
Compare
schema/world.fbs
Outdated
cell_width: uint16 = 40; | ||
cell_height: uint16 = 40; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constant will be determined on the frontend.
No part of the backend should need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not frontend. We will need these attributes in order to do projectile physics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I am under the impression that this flatbuffer will only be generated to send through the wire. Nothing that the user does not need will not be here.
-
We can do the projectile physics without a set pixel width for each cell. We will have an implicit coordinate system, mapping the coordinate system to actual pixels is only necessary to render, not do math.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then we don't need to have an explicit grid. Our coordinate system can be smooth
|
||
jobs: | ||
flatbuffers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you describe in the PR description why all of this is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.github/workflows/main.yml
Outdated
@@ -66,4 +145,5 @@ jobs: | |||
- uses: actions-rs/cargo@v1 | |||
with: | |||
command: clippy | |||
args: --manifest-path=${{env.cargo-path}} -- -W clippy::all -W clippy::pedantic -D warnings | |||
args: --manifest-path=${{env.cargo-path}} | |||
# args: --manifest-path=${{env.cargo-path}} -- -W clippy::all -W clippy::pedantic -D warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep all of these if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the severities must be set elsewhere. If they are specified in flags, they will lint the generated Rust code by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yizzlez PTAL |
This PR adds the base flatbuffers for use as the base world state.
Test Plan:
Run
cargo run
.flatc
is a tool to generate Rust code given a flatbuffers schema. In order to get this working with Github Actions, a build step must be added to installflatc
.