From 88a62567edbf06f18346bb3c5bdc2f550a624f5f Mon Sep 17 00:00:00 2001 From: fgenesis Date: Fri, 10 Feb 2012 01:06:44 +0100 Subject: [PATCH] Fix some bugs introduced in my prev. commits: - Game::reconstructEntityGrid() now really clears only entity grid, and not the tile grid as well (Added OT_INVISIBLEENT do further distinguish entity from tile obstruction) - Invalid script pointers should not pop up message boxes - Lost an include and CMakeLists changes --- Aquaria/Entity.cpp | 2 +- Aquaria/Game.cpp | 14 ++++++++++---- Aquaria/Game.h | 9 ++++++--- Aquaria/GridRender.cpp | 3 +++ Aquaria/ScriptInterface.cpp | 4 ++-- CMakeLists.txt | 1 + 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index c57e676..5b59fe6 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -3170,7 +3170,7 @@ void Entity::fillGrid() { if (fillGridFromQuad) { - dsq->game->fillGridFromQuad(this, OT_INVISIBLE); + dsq->game->fillGridFromQuad(this, OT_INVISIBLEENT); } } diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index fb82365..13b128a 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2176,7 +2176,7 @@ std::string Game::getNoteName(int n, const std::string &pre) return os.str(); } -void Game::clearDynamicGrid() +void Game::clearDynamicGrid(unsigned char maskbyte /* = OT_MASK_BLACK */) { // just to be sure in case the grid/type sizes change, // otherwise there is a chance to write a few bytes over the end of the buffer -- FG @@ -2185,9 +2185,9 @@ void Game::clearDynamicGrid() signed char *gridstart = &grid[0][0]; uint32 *gridend = (uint32*)(gridstart + sizeof(grid)); uint32 *gridptr = (uint32*)gridstart; - // mask out non-black bytes (which are those set by entites or tiles), + // mask out specific bytes // use full uint32 rounds instead of single-bytes to speed things up. - const unsigned int mask = OT_MASK_BLACK | (OT_MASK_BLACK << 8) | (OT_MASK_BLACK << 16) | (OT_MASK_BLACK << 24); + const uint32 mask = maskbyte | (maskbyte << 8) | (maskbyte << 16) | (maskbyte << 24); do { *gridptr &= mask; @@ -2198,7 +2198,7 @@ void Game::clearDynamicGrid() void Game::reconstructEntityGrid() { - clearDynamicGrid(); + clearDynamicGrid(~OT_INVISIBLEENT); FOR_ENTITIES(i) { @@ -6774,6 +6774,10 @@ void Game::applyState() addRenderObject(edgeRender, LR_DEBUG_TEXT); edgeRender->alpha = 0; + gridRenderEnt = new GridRender(OT_INVISIBLEENT); + addRenderObject(gridRenderEnt, LR_DEBUG_TEXT); + gridRenderEnt->alpha = 0; + waterSurfaceRender = new WaterSurfaceRender(); //waterSurfaceRender->setRenderPass(-1); addRenderObject(waterSurfaceRender, LR_WATERSURFACE); @@ -8788,6 +8792,7 @@ void Game::toggleGridRender() gridRender2->alpha.interpolateTo(0.5, t); gridRender3->alpha.interpolateTo(0.5, t); edgeRender->alpha.interpolateTo(0.5, t); + gridRenderEnt->alpha.interpolateTo(0.5, t); } else if (gridRender->alpha == 0.5) { @@ -8795,6 +8800,7 @@ void Game::toggleGridRender() gridRender2->alpha.interpolateTo(0, t); gridRender3->alpha.interpolateTo(0, t); edgeRender->alpha.interpolateTo(0, t); + gridRenderEnt->alpha.interpolateTo(0, t); } } diff --git a/Aquaria/Game.h b/Aquaria/Game.h index 8204807..c53143b 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -606,10 +606,13 @@ enum ObsType OT_BLACKINVIS = 0x02, // same as OT_BLACK, but not drawn OT_MASK_BLACK = OT_BLACK | OT_BLACKINVIS, - // set by entities or tiles + // set by tiles OT_INVISIBLE = 0x04, OT_INVISIBLEIN = 0x08, OT_HURT = 0x10, + + // set by entities + OT_INVISIBLEENT = 0x20, }; struct EntitySaveData @@ -660,7 +663,7 @@ public: bool loadScene(std::string scene); void clearGrid(int v = 0); - void clearDynamicGrid(); + void clearDynamicGrid(unsigned char maskbyte = OT_MASK_BLACK); void toggleWorldMap(); @@ -985,7 +988,7 @@ public: void createGradient(); std::string saveMusic; - GridRender *gridRender, *gridRender2, *gridRender3, *edgeRender; + GridRender *gridRender, *gridRender2, *gridRender3, *edgeRender, *gridRenderEnt; void toggleGridRender(); ElementUpdateList elementUpdateList; diff --git a/Aquaria/GridRender.cpp b/Aquaria/GridRender.cpp index 14e9a8d..f95ae1c 100644 --- a/Aquaria/GridRender.cpp +++ b/Aquaria/GridRender.cpp @@ -74,6 +74,9 @@ void GridRender::onRender() case OT_INVISIBLEIN: core->setColor(1, 0.5, 0, alpha.getValue()); break; + case OT_INVISIBLEENT: + core->setColor(0, 1, 0.5, alpha.getValue()); + break; case OT_BLACK: core->setColor(0, 0, 0, 1); break; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index e8b3da5..c288ade 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -549,7 +549,7 @@ Quad *getQuad(lua_State *L, int slot = 1) Quad *q = (Quad*)lua_touserdata(L, slot); ENSURE_TYPE(q, SCO_QUAD); if (!q) - errorLog("Invalid Quad"); + scriptDebug(L, "Invalid Quad"); return q; } @@ -559,7 +559,7 @@ BaseText *getText(lua_State *L, int slot = 1) BaseText *q = (BaseText*)lua_touserdata(L, slot); ENSURE_TYPE(q, SCO_TEXT); if (!q) - errorLog("Invalid Text"); + scriptDebug(L, "Invalid Text"); return q; } diff --git a/CMakeLists.txt b/CMakeLists.txt index 86ed884..f841a31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,6 +363,7 @@ SET(BBGE_SRCS ${BBGEDIR}/DarkLayer.cpp ${BBGEDIR}/Datafile.cpp ${BBGEDIR}/DebugFont.cpp + ${BBGEDIR}/DeflateCompressor.cpp ${BBGEDIR}/DFSprite.cpp ${BBGEDIR}/Effects.cpp ${BBGEDIR}/Emitter.cpp