diff --git a/crates/cli/src/subcommands/dev.rs b/crates/cli/src/subcommands/dev.rs index 8badb72773a..70acd76eadc 100644 --- a/crates/cli/src/subcommands/dev.rs +++ b/crates/cli/src/subcommands/dev.rs @@ -81,7 +81,7 @@ pub fn cli() -> Command { Arg::new("client-lang") .long("client-lang") .value_parser(clap::value_parser!(Language)) - .help("The programming language for the generated client module bindings (e.g., typescript, csharp, python). If not specified, it will be detected from the project."), + .help("The programming language for the generated client module bindings (e.g., typescript, csharp, rust, unrealcpp). If not specified, it will be detected from the project."), ) .arg(common_args::server().help("The nickname, host name or URL of the server to publish to")) .arg(common_args::yes()) diff --git a/docs/docs/00100-intro/00100-getting-started/00300-language-support.md b/docs/docs/00100-intro/00100-getting-started/00300-language-support.md index 6f5ab3a9f5e..f5ead25e91d 100644 --- a/docs/docs/00100-intro/00100-getting-started/00300-language-support.md +++ b/docs/docs/00100-intro/00100-getting-started/00300-language-support.md @@ -6,11 +6,12 @@ slug: /intro/language-support ## Server Database Modules -SpacetimeDB modules define your database schema and server-side business logic. Modules can be written in three languages: +SpacetimeDB modules define your database schema and server-side business logic. Modules can be written in four languages: - **[Rust](../../00200-core-concepts/00100-databases.md)** - High performance, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00500-rust.md) - **[C#](../../00200-core-concepts/00100-databases.md)** - Great for Unity developers, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00600-c-sharp.md) - **[TypeScript](../../00200-core-concepts/00100-databases.md)** - Ideal for web developers, runs on V8 [(Quickstart)](../00200-quickstarts/00400-typescript.md) +- **[C++](../../00200-core-concepts/00100-databases.md)** - Fits Unreal and C++ workflows, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00700-cpp.md) ## Client SDKs diff --git a/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md b/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md index e0bf1e4daac..3f2936ca7ea 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md +++ b/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md @@ -5,6 +5,7 @@ slug: /tables/event-tables import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; +import { CppModuleVersionNotice } from "@site/src/components/CppModuleVersionNotice"; In many applications, particularly games and real-time systems, modules need to notify clients about things that happened without storing that information permanently. A combat system might need to tell clients "entity X took 50 damage" so they can display a floating damage number, but there is no reason to keep that record in the database after the moment has passed. @@ -60,6 +61,21 @@ pub struct DamageEvent { } ``` + + + + + +```cpp +struct DamageEvent { + Identity entity_id; + uint32_t damage; + std::string source; +}; +SPACETIMEDB_STRUCT(DamageEvent, entity_id, damage, source) +SPACETIMEDB_TABLE(DamageEvent, damage_event, Public, true) +``` + @@ -128,6 +144,21 @@ fn attack(ctx: &ReducerContext, target_id: Identity, damage: u32) { } ``` + + + + + +```cpp +SPACETIMEDB_REDUCER(attack, ReducerContext ctx, Identity target_id, uint32_t damage) { + // Game logic... + + // Publish the event + ctx.db[damage_event].insert(DamageEvent{target_id, damage, "melee_attack"}); + return Ok(); +} +``` + diff --git a/docs/docs/00300-resources/00200-reference/00100-cli-reference/00100-cli-reference.md b/docs/docs/00300-resources/00200-reference/00100-cli-reference/00100-cli-reference.md index 0ac1cd74511..baa45386817 100644 --- a/docs/docs/00300-resources/00200-reference/00100-cli-reference/00100-cli-reference.md +++ b/docs/docs/00300-resources/00200-reference/00100-cli-reference/00100-cli-reference.md @@ -249,7 +249,7 @@ Start development mode with auto-regenerate client module bindings, auto-rebuild Default value: `src/module_bindings` * `--module-path ` — Path to the SpacetimeDB server module, relative to current directory. Defaults to `/spacetimedb`. -* `--client-lang ` — The programming language for the generated client module bindings (e.g., typescript, csharp, python). If not specified, it will be detected from the project. +* `--client-lang ` — The programming language for the generated client module bindings (e.g., typescript, csharp, rust, unrealcpp). If not specified, it will be detected from the project. Possible values: `csharp`, `typescript`, `rust`, `unrealcpp` @@ -659,4 +659,3 @@ Run `spacetime version --help` to see all options. This document was generated automatically by clap-markdown. - diff --git a/skills/cpp-server/SKILL.md b/skills/cpp-server/SKILL.md index 8a920c2e3e3..8d270e93080 100644 --- a/skills/cpp-server/SKILL.md +++ b/skills/cpp-server/SKILL.md @@ -37,7 +37,9 @@ FIELD_PrimaryKeyAutoInc(entity, id) FIELD_Index(entity, name) ``` -Options: `SPACETIMEDB_TABLE(Type, accessor, Public|Private)` +Options: +- `SPACETIMEDB_TABLE(Type, accessor, Public|Private)`: regular table +- `SPACETIMEDB_TABLE(Type, accessor, Public|Private, true)`: event table Field constraints: - `FIELD_PrimaryKey(accessor, field)`: primary key