A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(bindings): the physics side module builds again — BoundarySpan goes dependency-free
esenginee1d773c48da8
diff --git a/src/esengine/bindings/BoundarySpan.hpp b/src/esengine/bindings/BoundarySpan.hppindex 5abecf34b..f4d14958a 100644--- a/src/esengine/bindings/BoundarySpan.hpp+++ b/src/esengine/bindings/BoundarySpan.hpp@@ -20,13 +20,13 @@#pragma once#include "../core/Types.hpp"-#include "../core/Log.hpp"#ifdef __EMSCRIPTEN__#include <emscripten/heap.h>#endif#include <cstdint>+#include <cstdio>namespace esengine {@@ -45,22 +45,29 @@ inline usize boundaryHeapSize() {* @brief Validates a JS-supplied pointer to @p count elements of T and returns it typed.* @return The typed pointer, or nullptr (after an always-on error log) when the pointer* is null, the byte size overflows, or the span leaves the wasm heap.+ * @note Errors go straight to stderr (→ the module's printErr → console), not the+ * engine Log: this gate is shared by side modules (physics) that do not link+ * the Log implementation, so the header must stay dependency-free.*/template <typename T>inline const T* boundarySpan(uintptr_t ptr, u64 count, const char* what) {if (ptr == 0) {- ES_LOG_ERROR("{}: null buffer pointer; rejected", what);+ std::fprintf(stderr, "[boundary] %s: null buffer pointer; rejected\n", what);return nullptr;}const u64 bytes = count * static_cast<u64>(sizeof(T));if (count != 0 && bytes / count != sizeof(T)) {- ES_LOG_ERROR("{}: byte size overflows (count {}); rejected", what, count);+ std::fprintf(stderr, "[boundary] %s: byte size overflows (count %llu); rejected\n",+ what, static_cast<unsigned long long>(count));return nullptr;}const u64 heap = static_cast<u64>(detail::boundaryHeapSize());if (static_cast<u64>(ptr) > heap || bytes > heap - static_cast<u64>(ptr)) {- ES_LOG_ERROR("{}: span [{} + {} bytes] exceeds the wasm heap ({}); rejected",- what, ptr, bytes, heap);+ std::fprintf(stderr,+ "[boundary] %s: span [%llu + %llu bytes] exceeds the wasm heap (%llu); rejected\n",+ what, static_cast<unsigned long long>(ptr),+ static_cast<unsigned long long>(bytes),+ static_cast<unsigned long long>(heap));return nullptr;}return reinterpret_cast<const T*>(ptr);diff --git a/src/esengine/bindings/PhysicsShapes.cpp b/src/esengine/bindings/PhysicsShapes.cppindex 0b3517a25..69bb68e92 100644--- a/src/esengine/bindings/PhysicsShapes.cpp+++ b/src/esengine/bindings/PhysicsShapes.cpp@@ -136,7 +136,7 @@ void physics_addPolygonShape(uint32_t entityId, uintptr_t verticesPtr, int verteshapeDef.filter.categoryBits = static_cast<uint64_t>(categoryBits);shapeDef.filter.maskBits = static_cast<uint64_t>(maskBits);- auto* floats = boundarySpan<float>(verticesPtr, static_cast<u64>(vertexCount) * 2, "physics_addPolygonShape");+ auto* floats = esengine::boundarySpan<float>(verticesPtr, static_cast<esengine::u64>(vertexCount) * 2, "physics_addPolygonShape");if (!floats) return;b2Vec2 points[B2_MAX_POLYGON_VERTICES];for (int i = 0; i < vertexCount; i++) {@@ -163,7 +163,7 @@ void physics_addChainShape(uint32_t entityId, uintptr_t pointsPtr, int pointCoun// count can't allocate gigabytes or walk the heap.if (pointCount < 4 || pointCount > 65536) return;- auto* floats = boundarySpan<float>(pointsPtr, static_cast<u64>(pointCount) * 2, "physics_addChainShape");+ auto* floats = esengine::boundarySpan<float>(pointsPtr, static_cast<esengine::u64>(pointCount) * 2, "physics_addChainShape");if (!floats) return;std::vector<b2Vec2> points(pointCount);for (int i = 0; i < pointCount; i++) {diff --git a/src/esengine/bindings/ResourceManagerBindings.cpp b/src/esengine/bindings/ResourceManagerBindings.cppindex cb3cd7c28..2213bf178 100644--- a/src/esengine/bindings/ResourceManagerBindings.cpp+++ b/src/esengine/bindings/ResourceManagerBindings.cpp@@ -6,6 +6,7 @@#include "../resource/TextureMetadata.hpp"#include "../text/BitmapFont.hpp"#include "../core/Types.hpp"+#include "../core/Log.hpp"#include <emscripten/val.h>