From cac8631eea5e2aa012e76c65955de7f9b795c4f3 Mon Sep 17 00:00:00 2001 From: dga Date: Fri, 18 Jul 2025 01:20:09 +0300 Subject: [PATCH] Revert "more debug info" This reverts commit 65cda064aa93f0be3d859e92673ce449bbbaa930. --- Makefile.emcc | 2 +- src/EntityManager.cpp | 8 ------ src/FileManager.cpp | 40 +-------------------------- src/Main.cpp | 18 ------------ src/RenderManager.cpp | 63 ++---------------------------------------- src/RoomEntity.cpp | 9 +----- src/SurfaceManager.cpp | 18 +----------- 7 files changed, 7 insertions(+), 151 deletions(-) diff --git a/Makefile.emcc b/Makefile.emcc index ad808b0..7764b63 100644 --- a/Makefile.emcc +++ b/Makefile.emcc @@ -4,7 +4,7 @@ CC = emcc CXX = emcc CXXFLAGS ?= -sUSE_SDL=2 -std=c++17 -Iinclude -fexceptions -LDFLAGS ?= -sUSE_SDL=2 -fexceptions --embed-file=data.pak@data.pak -sMAX_WEBGL_VERSION=2 -sALLOW_MEMORY_GROWTH=1 -sASYNCIFY=1 +LDFLAGS ?= -sUSE_SDL=2 -fexceptions --embed-file=data.pak@data.pak -sMAX_WEBGL_VERSION=2 TARGET = eulamadness.html # System configuration diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp index ebae16c..3ff2747 100644 --- a/src/EntityManager.cpp +++ b/src/EntityManager.cpp @@ -134,14 +134,6 @@ void TEntityManager::Update() { } void TEntityManager::Draw() { - #ifdef __EMSCRIPTEN__ - static int drawCount = 0; - drawCount++; - if (drawCount % 60 == 0) { - printf("Emscripten: Drawing %zu entities\n", Entities_.size()); - } - #endif - std::for_each(Entities_.begin(), Entities_.end(), [&](auto& pair) { auto& entity = pair.second; entity->Draw(); diff --git a/src/FileManager.cpp b/src/FileManager.cpp index 33dc060..9f8a32c 100644 --- a/src/FileManager.cpp +++ b/src/FileManager.cpp @@ -18,31 +18,18 @@ std::string TFileManager::Get(const std::string& path) { return Cache_.Get(path); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: FileManager::Get(%s)\n", path.c_str()); - #endif - auto getAttempt = FromFilesystem(path); if (getAttempt.second) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Found file %s in filesystem\n", path.c_str()); - #endif Cache_.Set(path, getAttempt.first); return getAttempt.first; } getAttempt = FromArchive(path); if (getAttempt.second) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Found file %s in archive\n", path.c_str()); - #endif Cache_.Set(path, getAttempt.first); return getAttempt.first; } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to find file %s\n", path.c_str()); - #endif throw std::runtime_error("can't find file " + path); } @@ -60,36 +47,18 @@ std::pair TFileManager::FromFilesystem(const std::string& pat } std::pair TFileManager::FromArchive(const std::string& path) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Trying to open archive: %s\n", ArchivePath_.c_str()); - #endif - std::ifstream archiveStream(ArchivePath_, std::ios::in | std::ios::binary); if (!archiveStream.is_open()) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to open archive: %s\n", ArchivePath_.c_str()); - #endif return std::make_pair({}, false); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Successfully opened archive: %s\n", ArchivePath_.c_str()); - #endif - // Identify and validate PAK file char identifier[4]; archiveStream.read(identifier, 4); if (std::memcmp(identifier, "PACK", 4)) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Invalid PAK header, expected PACK, got %.4s\n", identifier); - #endif return std::make_pair({}, false); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Valid PAK header found\n"); - #endif - std::uint32_t tocOffset = ReadInt32(archiveStream); std::uint32_t tocSize = ReadInt32(archiveStream) / 64; @@ -111,10 +80,6 @@ std::pair TFileManager::FromArchive(const std::string& path) continue; } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Found file %s in archive at offset %u, size %u\n", path.c_str(), fileOffset, fileSize); - #endif - archiveStream.seekg(fileOffset); std::string result(fileSize, 0); archiveStream.read(result.data(), result.size()); @@ -122,9 +87,6 @@ std::pair TFileManager::FromArchive(const std::string& path) return std::make_pair(result, true); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: File %s not found in archive\n", path.c_str()); - #endif return std::make_pair({}, false); } @@ -134,4 +96,4 @@ std::uint32_t TFileManager::ReadInt32(std::ifstream& stream) { return (bytes[0] << 0) | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); } -} // namespace NGame +} // namespace NGame \ No newline at end of file diff --git a/src/Main.cpp b/src/Main.cpp index 271f107..7c02441 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -15,10 +15,6 @@ static NGame::TApp *app = nullptr; static void InitApp(void) { app = NGame::TApp::Instance(); - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Registering entities...\n"); - #endif - app->EntityManager().RegisterEntity("Hero"); app->EntityManager().RegisterEntity("DirtEntity"); app->EntityManager().RegisterEntity("GrassEntity"); @@ -36,33 +32,19 @@ static void InitApp(void) { app->EntityManager().RegisterEntity("BackgroundTiler"); app->EntityManager().RegisterEntity("RoomEntity"); - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Creating initial entities...\n"); - #endif - app->EntityManager().MakeEntityByName("RoomEntity"); app->EntityManager().MakeEntityByName("BackgroundTiler"); auto h = app->EntityManager().MakeEntityByName("Hero"); h->SetPosition({0, -64}); app->EntityManager().UpdateCollision(h); - - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Initial entities created\n"); - #endif } static void MainLoop(void) { if (app) { app->Run(); } else { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Initializing app...\n"); - #endif InitApp(); - #ifdef __EMSCRIPTEN__ - printf("Emscripten: App initialized\n"); - #endif } } diff --git a/src/RenderManager.cpp b/src/RenderManager.cpp index 09b9f32..0f29686 100644 --- a/src/RenderManager.cpp +++ b/src/RenderManager.cpp @@ -9,56 +9,27 @@ namespace NGame { TRenderManager::TRenderManager(TSurfaceManager& surfaceManager, int width, int height, const std::string& title, std::size_t cacheSize) : SurfaceManager_(surfaceManager), Cache_(cacheSize), Size_(width, height) { - - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Creating window with size %dx%d\n", width, height); - #endif - Window_ = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_RESIZABLE); if (!Window_) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to create window: %s\n", SDL_GetError()); - #endif throw std::runtime_error("Can't create window"); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Window created successfully\n"); - #endif - Renderer_ = SDL_CreateRenderer(Window_, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (!Renderer_) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to create renderer: %s\n", SDL_GetError()); - #endif SDL_DestroyWindow(Window_); throw std::runtime_error("Can't create renderer"); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Renderer created successfully\n"); - #endif - ScreenTexture_ = SDL_CreateTexture(Renderer_, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height); if (!ScreenTexture_) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to create screen texture: %s\n", SDL_GetError()); - #endif SDL_DestroyRenderer(Renderer_); SDL_DestroyWindow(Window_); throw std::runtime_error("Can't create screen texture"); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Screen texture created successfully\n"); - #endif - LightTexture_ = SDL_CreateTexture(Renderer_, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height); if (!LightTexture_) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to create light texture: %s\n", SDL_GetError()); - #endif SDL_DestroyTexture(ScreenTexture_); SDL_DestroyRenderer(Renderer_); SDL_DestroyWindow(Window_); @@ -66,20 +37,12 @@ TRenderManager::TRenderManager(TSurfaceManager& surfaceManager, int width, int h } SDL_SetTextureBlendMode(LightTexture_, SDL_BLENDMODE_MOD); - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Light texture created successfully\n"); - #endif - // Make window bigger if (width < 640 && height < 480) { SDL_SetWindowSize(Window_, 640, 480); } Reset(); - - #ifdef __EMSCRIPTEN__ - printf("Emscripten: RenderManager initialization complete\n"); - #endif } std::shared_ptr TRenderManager::Get(const std::string& path) { @@ -87,23 +50,12 @@ std::shared_ptr TRenderManager::Get(const std::string& path) { return Cache_.Get(path); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Loading texture: %s\n", path.c_str()); - #endif - std::shared_ptr surface = SurfaceManager_.Get(path); SDL_Texture* texture = SDL_CreateTextureFromSurface(Renderer_, surface.get()); if (!texture) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to create texture from surface %s: %s\n", path.c_str(), SDL_GetError()); - #endif std::runtime_error("Can't create texture from surface " + path); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Successfully loaded texture: %s\n", path.c_str()); - #endif - std::shared_ptr result(texture, [](SDL_Texture* texture) { SDL_DestroyTexture(texture); }); Cache_.Set(path, result); return result; @@ -189,15 +141,6 @@ void TRenderManager::Run() { return; } - #ifdef __EMSCRIPTEN__ - static int frameCount = 0; - frameCount++; - if (frameCount % 60 == 0) { - printf("Emscripten: Frame %d, Commands: Tile=%zu, Background=%zu, Foreground=%zu\n", - frameCount, Commands_[Tile].size(), Commands_[Background].size(), Commands_[Foreground].size()); - } - #endif - for (size_t layer = 0; layer < SentinelMax; ++layer) { switch (layer) { case ELayer::BackgroundGlow: @@ -387,11 +330,11 @@ void TRenderManager::Reset() { SDL_Rect a; SDL_RenderGetViewport(Renderer_, &a); - SDL_SetRenderDrawColor(Renderer_, 0, 0, 0, 255); + SDL_SetRenderDrawColor(Renderer_, 0, 0, 0, 0); SDL_SetRenderTarget(Renderer_, NULL); SDL_RenderClear(Renderer_); - SDL_SetRenderDrawColor(Renderer_, 0, 0, 0, 255); + SDL_SetRenderDrawColor(Renderer_, 0, 0, 0, 0); SDL_SetRenderTarget(Renderer_, ScreenTexture_); SDL_RenderClear(Renderer_); @@ -402,4 +345,4 @@ void TRenderManager::Reset() { } } -} // namespace NGame +} // namespace NGame \ No newline at end of file diff --git a/src/RoomEntity.cpp b/src/RoomEntity.cpp index 9418a44..2907b1f 100644 --- a/src/RoomEntity.cpp +++ b/src/RoomEntity.cpp @@ -887,13 +887,6 @@ void TBackgroundTiler::Draw() const { tileOffset.X %= 16; tileOffset.Y %= 16; - #ifdef __EMSCRIPTEN__ - static int bgDrawCount = 0; - bgDrawCount++; - if (bgDrawCount % 60 == 0) { - printf("Emscripten: Drawing background tiles, camera: (%d, %d)\n", cameraPosition.X, cameraPosition.Y); - } - #endif renderManager.SetLayer(NGame::TRenderManager::Tile); for (int i = -1; i <= 320 / 16; ++i) { @@ -901,4 +894,4 @@ void TBackgroundTiler::Draw() const { spriteManager.Draw(Background_, 0, NGame::Vec2i(i * 16, j * 16) + cameraPosition - tileOffset); } } -} +} \ No newline at end of file diff --git a/src/SurfaceManager.cpp b/src/SurfaceManager.cpp index 5449ae4..259f650 100644 --- a/src/SurfaceManager.cpp +++ b/src/SurfaceManager.cpp @@ -16,33 +16,17 @@ std::shared_ptr TSurfaceManager::Get(const std::string& path) { return Cache_.Get(path); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Loading surface: %s\n", path.c_str()); - #endif - std::string data = FileManager_.Get(path); - - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Got data for %s, size: %zu\n", path.c_str(), data.size()); - #endif - SDL_RWops* rw = SDL_RWFromConstMem(data.data(), data.size()); SDL_Surface* surface = SDL_LoadBMP_RW(rw, 1); if (!surface) { - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Failed to create surface from file %s: %s\n", path.c_str(), SDL_GetError()); - #endif std::runtime_error("Can't create surface from file " + path); } - #ifdef __EMSCRIPTEN__ - printf("Emscripten: Successfully loaded surface: %s\n", path.c_str()); - #endif - std::shared_ptr result(surface, [](SDL_Surface* surface) { SDL_FreeSurface(surface); }); Cache_.Set(path, result); return result; } -} // namespace NGame +} // namespace NGame \ No newline at end of file