1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 22:25:46 +00:00

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
This commit is contained in:
fgenesis 2012-02-10 01:06:44 +01:00
parent 75e7b137d6
commit 88a62567ed
6 changed files with 23 additions and 10 deletions

View file

@ -3170,7 +3170,7 @@ void Entity::fillGrid()
{ {
if (fillGridFromQuad) if (fillGridFromQuad)
{ {
dsq->game->fillGridFromQuad(this, OT_INVISIBLE); dsq->game->fillGridFromQuad(this, OT_INVISIBLEENT);
} }
} }

View file

@ -2176,7 +2176,7 @@ std::string Game::getNoteName(int n, const std::string &pre)
return os.str(); 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, // 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 // 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]; signed char *gridstart = &grid[0][0];
uint32 *gridend = (uint32*)(gridstart + sizeof(grid)); uint32 *gridend = (uint32*)(gridstart + sizeof(grid));
uint32 *gridptr = (uint32*)gridstart; 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. // 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 do
{ {
*gridptr &= mask; *gridptr &= mask;
@ -2198,7 +2198,7 @@ void Game::clearDynamicGrid()
void Game::reconstructEntityGrid() void Game::reconstructEntityGrid()
{ {
clearDynamicGrid(); clearDynamicGrid(~OT_INVISIBLEENT);
FOR_ENTITIES(i) FOR_ENTITIES(i)
{ {
@ -6774,6 +6774,10 @@ void Game::applyState()
addRenderObject(edgeRender, LR_DEBUG_TEXT); addRenderObject(edgeRender, LR_DEBUG_TEXT);
edgeRender->alpha = 0; edgeRender->alpha = 0;
gridRenderEnt = new GridRender(OT_INVISIBLEENT);
addRenderObject(gridRenderEnt, LR_DEBUG_TEXT);
gridRenderEnt->alpha = 0;
waterSurfaceRender = new WaterSurfaceRender(); waterSurfaceRender = new WaterSurfaceRender();
//waterSurfaceRender->setRenderPass(-1); //waterSurfaceRender->setRenderPass(-1);
addRenderObject(waterSurfaceRender, LR_WATERSURFACE); addRenderObject(waterSurfaceRender, LR_WATERSURFACE);
@ -8788,6 +8792,7 @@ void Game::toggleGridRender()
gridRender2->alpha.interpolateTo(0.5, t); gridRender2->alpha.interpolateTo(0.5, t);
gridRender3->alpha.interpolateTo(0.5, t); gridRender3->alpha.interpolateTo(0.5, t);
edgeRender->alpha.interpolateTo(0.5, t); edgeRender->alpha.interpolateTo(0.5, t);
gridRenderEnt->alpha.interpolateTo(0.5, t);
} }
else if (gridRender->alpha == 0.5) else if (gridRender->alpha == 0.5)
{ {
@ -8795,6 +8800,7 @@ void Game::toggleGridRender()
gridRender2->alpha.interpolateTo(0, t); gridRender2->alpha.interpolateTo(0, t);
gridRender3->alpha.interpolateTo(0, t); gridRender3->alpha.interpolateTo(0, t);
edgeRender->alpha.interpolateTo(0, t); edgeRender->alpha.interpolateTo(0, t);
gridRenderEnt->alpha.interpolateTo(0, t);
} }
} }

View file

@ -606,10 +606,13 @@ enum ObsType
OT_BLACKINVIS = 0x02, // same as OT_BLACK, but not drawn OT_BLACKINVIS = 0x02, // same as OT_BLACK, but not drawn
OT_MASK_BLACK = OT_BLACK | OT_BLACKINVIS, OT_MASK_BLACK = OT_BLACK | OT_BLACKINVIS,
// set by entities or tiles // set by tiles
OT_INVISIBLE = 0x04, OT_INVISIBLE = 0x04,
OT_INVISIBLEIN = 0x08, OT_INVISIBLEIN = 0x08,
OT_HURT = 0x10, OT_HURT = 0x10,
// set by entities
OT_INVISIBLEENT = 0x20,
}; };
struct EntitySaveData struct EntitySaveData
@ -660,7 +663,7 @@ public:
bool loadScene(std::string scene); bool loadScene(std::string scene);
void clearGrid(int v = 0); void clearGrid(int v = 0);
void clearDynamicGrid(); void clearDynamicGrid(unsigned char maskbyte = OT_MASK_BLACK);
void toggleWorldMap(); void toggleWorldMap();
@ -985,7 +988,7 @@ public:
void createGradient(); void createGradient();
std::string saveMusic; std::string saveMusic;
GridRender *gridRender, *gridRender2, *gridRender3, *edgeRender; GridRender *gridRender, *gridRender2, *gridRender3, *edgeRender, *gridRenderEnt;
void toggleGridRender(); void toggleGridRender();
ElementUpdateList elementUpdateList; ElementUpdateList elementUpdateList;

View file

@ -74,6 +74,9 @@ void GridRender::onRender()
case OT_INVISIBLEIN: case OT_INVISIBLEIN:
core->setColor(1, 0.5, 0, alpha.getValue()); core->setColor(1, 0.5, 0, alpha.getValue());
break; break;
case OT_INVISIBLEENT:
core->setColor(0, 1, 0.5, alpha.getValue());
break;
case OT_BLACK: case OT_BLACK:
core->setColor(0, 0, 0, 1); core->setColor(0, 0, 0, 1);
break; break;

View file

@ -549,7 +549,7 @@ Quad *getQuad(lua_State *L, int slot = 1)
Quad *q = (Quad*)lua_touserdata(L, slot); Quad *q = (Quad*)lua_touserdata(L, slot);
ENSURE_TYPE(q, SCO_QUAD); ENSURE_TYPE(q, SCO_QUAD);
if (!q) if (!q)
errorLog("Invalid Quad"); scriptDebug(L, "Invalid Quad");
return q; return q;
} }
@ -559,7 +559,7 @@ BaseText *getText(lua_State *L, int slot = 1)
BaseText *q = (BaseText*)lua_touserdata(L, slot); BaseText *q = (BaseText*)lua_touserdata(L, slot);
ENSURE_TYPE(q, SCO_TEXT); ENSURE_TYPE(q, SCO_TEXT);
if (!q) if (!q)
errorLog("Invalid Text"); scriptDebug(L, "Invalid Text");
return q; return q;
} }

View file

@ -363,6 +363,7 @@ SET(BBGE_SRCS
${BBGEDIR}/DarkLayer.cpp ${BBGEDIR}/DarkLayer.cpp
${BBGEDIR}/Datafile.cpp ${BBGEDIR}/Datafile.cpp
${BBGEDIR}/DebugFont.cpp ${BBGEDIR}/DebugFont.cpp
${BBGEDIR}/DeflateCompressor.cpp
${BBGEDIR}/DFSprite.cpp ${BBGEDIR}/DFSprite.cpp
${BBGEDIR}/Effects.cpp ${BBGEDIR}/Effects.cpp
${BBGEDIR}/Emitter.cpp ${BBGEDIR}/Emitter.cpp