40250 classic W2: EntityStore data-layer only + net_world visibility (增量 50)
CLIENT-GAP-FIX §2.1/§2.3/§2.4/§2.5 (+ §2.2 steps 4-5): - §2.1 two-layer model: EntityStore is data-only. Entries are created only by mut_spawn / mut_spawn_full / mut_spawn_main and removed only by mut_despawn / main-vid table clear. Every other mut_* now does find-or-return with a MT_NET_TRACE-gated debug log; no pending / replay buffer. Visibility moves to net_world.gd::_update_visibility() — per frame it walks client.get_entities() and mirrors is_main / AFFECT_SHOW_ALWAYS(bit 7) / IsWall(14201-14204) / planar-distance < CHAR_STAGE_VIEW_BOUND (200*100 cm), building a node on entry and fading + freeing it past +10 while keeping the data row (_fading guard). Gate is fail-open when the data layer is not queryable (no get_entities / _main_vid == 0 / no pos_cm) so existing fake-client tests are unaffected. - §2.3 one overwrite rule: mut_spawn_full() does a clean whole-row value replace (m_ents[vid] = e), no preservation of prior move state on VID reuse; mut_spawn() now delegates to it. net_world._on_spawn destroys + recreates a node when the vid already has one; mount/dismount rebuild keeps the old global_position. - §2.4 points bounds: mut_set_points() clamps counts > POINT_MAX_NUM (255) and zeroes the tail of a short snapshot; mut_set_point() rejects type >= 255. - §2.5 field apply order + affect flags: new EntityStore::mut_affect_flags(vid, lo, hi) assembles v = lo | (hi << 32) and queues a dirty tick; mut_char_update guild/alignment/pk changes now also push Info. net_world._apply_field_updates() applies fields in the reference call order (NetworkActorManager.cpp:470). - §2.2 steps 4-5: mut_char_info() / mut_shop_sign() drop the touch()-creates- entity path. Steps 1-3 (m_pending_actor two-packet merge) remain W1-owned. Tests: ./build.sh Debug exit 0; ctest 16/16 (net.entity_store gains a §2.1 data-layer assertion block). New project/net_world_vis_test.gd for scene-node visibility. GDScript regressions green: netbridge_test, gamescene_test, netplay_test, p9_test, combat_fx_test, player_motion_test, net_world_vis_test. Follow-up for W1: call mut_affect_flags(vid, affect_flag[0], affect_flag[1]) from classic_parser.cpp after GC_CHARACTER_ADD[2] / GC_CHARACTER_UPDATE (mut_char_update has no affect param). wire_classic.h already has the wanted static_assert on GCPoints.points. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yvAPqPivoY7vmBbzgqK4W
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
f32064c74a
commit
3487df2a16
@@ -1590,6 +1590,49 @@ int main() {
|
||||
CHECK(despawn, "despawn change emitted");
|
||||
}
|
||||
|
||||
// --- CLIENT-GAP §2.1: EntityStore is the data layer. A far entity is a full
|
||||
// row here with a queued Spawn/dirty; no scene, no replay buffer. Scene-
|
||||
// node visibility (CHAR_STAGE_VIEW_BOUND cull / re-show) is asserted by
|
||||
// project/net_world_vis_test.gd, which drives net_world.gd directly. ---
|
||||
{
|
||||
EntityStore d;
|
||||
d.set_now(0);
|
||||
d.mut_spawn_main(1, 1, "hero", 0, 0, 0);
|
||||
d.drain_changes();
|
||||
|
||||
// GC_CHARACTER_ADD far outside any view bound -> still a full data row.
|
||||
d.mut_spawn(4242, 101, 2, "far-orc", 900000.0f, 0.0f, 0.0f, 0.0f, 300, 90);
|
||||
const Entity *orc = d.get(4242);
|
||||
CHECK(orc && orc->race == 101 && orc->attack_speed == 90 && orc->name == "far-orc",
|
||||
"§2.1 data layer: far GC_CHARACTER_ADD populates the entity row");
|
||||
{
|
||||
auto ch = d.drain_changes();
|
||||
bool spawn = false;
|
||||
for (auto &c : ch) {
|
||||
if (c.kind == EntityStore::ChangeKind::Spawn && c.vid == 4242) {
|
||||
spawn = true;
|
||||
}
|
||||
}
|
||||
CHECK(spawn, "§2.1 data layer: a Spawn change is queued for the far entity");
|
||||
}
|
||||
|
||||
// GC_CHARACTER_UPDATE for that same VID updates the row in place.
|
||||
d.mut_char_update(4242, nullptr, 40, 120, 7, -3, 1, 0);
|
||||
orc = d.get(4242);
|
||||
CHECK(orc && orc->attack_speed == 120 && orc->moving_speed == 40 && orc->guild == 7,
|
||||
"§2.1 data layer: UPDATE mutates the existing row");
|
||||
|
||||
// Unknown VID: no create, no replay buffer, no size growth.
|
||||
const size_t n_before = d.size();
|
||||
d.mut_char_update(999999, nullptr, 10, 10, 0, 0, 0, 0);
|
||||
d.mut_move(999999, 90.0f, 1, 5.0f, 5.0f, 200);
|
||||
d.mut_mount(999999, 20101);
|
||||
d.mut_char_info(999999, "ghost", nullptr, 1, 0, 5, 0, 0, 0);
|
||||
d.mut_shop_sign(999999, "ghost shop");
|
||||
CHECK(d.size() == n_before && d.get(999999) == nullptr,
|
||||
"§2.1 data layer: mutators for an unknown VID never spawn or buffer");
|
||||
}
|
||||
|
||||
// --- ClientVS22 loading reset: discard map-local state, retain no stale deltas ---
|
||||
es.mut_spawn(99, 101, 1, "reset-me", 10, 20, 0, 0);
|
||||
es.mut_ground_add(700, 27100, 12, 24, 0);
|
||||
|
||||
Reference in New Issue
Block a user