TWINE: use constants for magic numbers
This commit is contained in:
parent
f4fa272b26
commit
438deb671f
6 changed files with 31 additions and 31 deletions
|
@ -343,9 +343,9 @@ void Redraw::processDrawListShadows(const DrawListStruct &drawCmd) {
|
|||
_engine->_grid->drawSprite(drawCmd.offset, renderRect.left, renderRect.top, _engine->_resources->spriteShadowPtr);
|
||||
}
|
||||
|
||||
const int32 tmpX = (drawCmd.x + 256) / 512;
|
||||
const int32 tmpY = drawCmd.y / 256;
|
||||
const int32 tmpZ = (drawCmd.z + 256) / 512;
|
||||
const int32 tmpX = (drawCmd.x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
const int32 tmpY = drawCmd.y / BRICK_HEIGHT;
|
||||
const int32 tmpZ = (drawCmd.z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
|
||||
_engine->_grid->drawOverModelActor(tmpX, tmpY, tmpZ);
|
||||
|
||||
|
@ -388,9 +388,9 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
|
|||
if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
|
||||
actor->dynamicFlags.bIsVisible = 1;
|
||||
|
||||
const int32 tempX = (actor->x + 256) / 512;
|
||||
int32 tempY = actor->y / 256;
|
||||
const int32 tempZ = (actor->z + 256) / 512;
|
||||
const int32 tempX = (actor->x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
int32 tempY = actor->y / BRICK_HEIGHT;
|
||||
const int32 tempZ = (actor->z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
if (actor->brickShape() != ShapeType::kNone) {
|
||||
tempY++;
|
||||
}
|
||||
|
@ -443,14 +443,14 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
|
|||
actor->dynamicFlags.bIsVisible = 1;
|
||||
|
||||
if (actor->staticFlags.bUsesClipping) {
|
||||
const int32 tmpX = (actor->lastX + 256) / 512;
|
||||
const int32 tmpY = actor->lastY / 256;
|
||||
const int32 tmpZ = (actor->lastZ + 256) / 512;
|
||||
const int32 tmpX = (actor->lastX + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
const int32 tmpY = actor->lastY / BRICK_HEIGHT;
|
||||
const int32 tmpZ = (actor->lastZ + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
_engine->_grid->drawOverSpriteActor(tmpX, tmpY, tmpZ);
|
||||
} else {
|
||||
const int32 tmpX = (actor->x + actor->boudingBox.x.topRight + 256) / 512;
|
||||
int32 tmpY = actor->y / 256;
|
||||
const int32 tmpZ = (actor->z + actor->boudingBox.z.topRight + 256) / 512;
|
||||
const int32 tmpX = (actor->x + actor->boudingBox.x.topRight + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
int32 tmpY = actor->y / BRICK_HEIGHT;
|
||||
const int32 tmpZ = (actor->z + actor->boudingBox.z.topRight + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
if (actor->brickShape() != ShapeType::kNone) {
|
||||
tmpY++;
|
||||
}
|
||||
|
@ -495,9 +495,9 @@ void Redraw::processDrawListExtras(const DrawListStruct &drawCmd) {
|
|||
_engine->_interface->setClip(renderRect);
|
||||
|
||||
if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
|
||||
const int32 tmpX = (drawCmd.x + 256) / 512;
|
||||
const int32 tmpY = drawCmd.y / 256;
|
||||
const int32 tmpZ = (drawCmd.z + 256) / 512;
|
||||
const int32 tmpX = (drawCmd.x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
const int32 tmpY = drawCmd.y / BRICK_HEIGHT;
|
||||
const int32 tmpZ = (drawCmd.z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
|
||||
_engine->_grid->drawOverModelActor(tmpX, tmpY, tmpZ);
|
||||
addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
|
||||
|
|
|
@ -46,8 +46,8 @@ Renderer::Renderer(TwinEEngine *engine) : _engine(engine), shadeAngleTab3(&shade
|
|||
|
||||
int32 Renderer::projectPositionOnScreen(int32 cX, int32 cY, int32 cZ) {
|
||||
if (isUsingOrhoProjection) {
|
||||
projPosX = ((cX - cZ) * 24) / 512 + orthoProjX;
|
||||
projPosY = (((cX + cZ) * 12) - cY * 30) / 512 + orthoProjY;
|
||||
projPosX = ((cX - cZ) * 24) / BRICK_SIZE + orthoProjX;
|
||||
projPosY = (((cX + cZ) * 12) - cY * 30) / BRICK_SIZE + orthoProjY;
|
||||
projPosZ = cZ - cY - cX;
|
||||
return 1;
|
||||
}
|
||||
|
@ -1253,8 +1253,8 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
|
|||
const int32 coY = pointPtr->y + renderY;
|
||||
const int32 coZ = -(pointPtr->z + renderZ);
|
||||
|
||||
pointPtrDest->x = (coX + coZ) * 24 / 512 + orthoProjX;
|
||||
pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / 512 + orthoProjY;
|
||||
pointPtrDest->x = (coX + coZ) * 24 / BRICK_SIZE + orthoProjX;
|
||||
pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / BRICK_SIZE + orthoProjY;
|
||||
pointPtrDest->z = coZ - coX - coY;
|
||||
|
||||
if (pointPtrDest->x < _engine->_redraw->renderRect.left) {
|
||||
|
|
|
@ -757,7 +757,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
|
|||
_engine->_renderer->destZ += _engine->_movements->processActorZ;
|
||||
|
||||
if (_engine->_renderer->destX >= 0 && _engine->_renderer->destZ >= 0 && _engine->_renderer->destX <= 0x7E00 && _engine->_renderer->destZ <= 0x7E00) {
|
||||
if (_engine->_grid->getBrickShape(_engine->_renderer->destX, _engine->_movements->processActorY + 256, _engine->_renderer->destZ) != ShapeType::kNone && _engine->cfgfile.WallCollision) { // avoid wall hit damage
|
||||
if (_engine->_grid->getBrickShape(_engine->_renderer->destX, _engine->_movements->processActorY + BRICK_HEIGHT, _engine->_renderer->destZ) != ShapeType::kNone && _engine->cfgfile.WallCollision) { // avoid wall hit damage
|
||||
_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, ExtraSpecialType::kHitStars);
|
||||
initAnim(AnimationTypes::kBigHit, 2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
|
||||
|
||||
|
|
|
@ -186,16 +186,16 @@ void Collision::reajustActorPosition(ShapeType brickShape) {
|
|||
if (brickShape >= ShapeType::kStairsTopLeft && brickShape <= ShapeType::kStairsBottomRight) {
|
||||
switch (brickShape) {
|
||||
case ShapeType::kStairsTopLeft:
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(0, 256, 512, _engine->_movements->processActorX - brkX);
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(0, BRICK_HEIGHT, BRICK_SIZE, _engine->_movements->processActorX - brkX);
|
||||
break;
|
||||
case ShapeType::kStairsTopRight:
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(0, 256, 512, _engine->_movements->processActorZ - brkZ);
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(0, BRICK_HEIGHT, BRICK_SIZE, _engine->_movements->processActorZ - brkZ);
|
||||
break;
|
||||
case ShapeType::kStairsBottomLeft:
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(256, 0, 512, _engine->_movements->processActorZ - brkZ);
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(BRICK_HEIGHT, 0, BRICK_SIZE, _engine->_movements->processActorZ - brkZ);
|
||||
break;
|
||||
case ShapeType::kStairsBottomRight:
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(256, 0, 512, _engine->_movements->processActorX - brkX);
|
||||
_engine->_movements->processActorY = brkY + getAverageValue(BRICK_HEIGHT, 0, BRICK_SIZE, _engine->_movements->processActorX - brkX);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -450,7 +450,7 @@ void Collision::stopFalling() { // ReceptionObj()
|
|||
if (IS_HERO(_engine->_animations->currentlyProcessedActorIdx)) {
|
||||
const int32 fall = _engine->_scene->heroYBeforeFall - _engine->_movements->processActorY;
|
||||
|
||||
if (fall >= 2048) {
|
||||
if (fall >= BRICK_HEIGHT * 8) {
|
||||
_engine->_extra->addExtraSpecial(_engine->_actor->processActorPtr->x, _engine->_actor->processActorPtr->y + 1000, _engine->_actor->processActorPtr->z, ExtraSpecialType::kHitStars);
|
||||
_engine->_actor->processActorPtr->life--;
|
||||
_engine->_animations->initAnim(AnimationTypes::kLandingHit, 2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
|
||||
|
|
|
@ -178,6 +178,9 @@ private:
|
|||
int32 blockBufferSize = 0;
|
||||
uint8 *blockBuffer = nullptr;
|
||||
|
||||
uint8 *getBlockBuffer(int32 x, int32 y, int32 z);
|
||||
|
||||
void updateCollisionCoordinates(int32 x, int32 y, int32 z);
|
||||
public:
|
||||
Grid(TwinEEngine *engine);
|
||||
~Grid();
|
||||
|
@ -185,14 +188,11 @@ public:
|
|||
/** Grid block entry types */
|
||||
typedef struct BlockEntry blockMap[GRID_SIZE_X][GRID_SIZE_Z][GRID_SIZE_Y];
|
||||
|
||||
uint8 *getBlockBuffer(int32 x, int32 y, int32 z);
|
||||
/**
|
||||
* search down until either ground is found or lower border of the cube is reached
|
||||
*/
|
||||
const uint8 *getBlockBufferGround(int32 x, int32 y, int32 z, int16 &ground) const;
|
||||
|
||||
void updateCollisionCoordinates(int32 x, int32 y, int32 z);
|
||||
|
||||
/** New grid camera X coordinates */
|
||||
int32 newCameraX = 0;
|
||||
/** New grid camera Y coordinates */
|
||||
|
|
|
@ -708,9 +708,9 @@ static int32 lCAM_FOLLOW(TwinEEngine *engine, LifeScriptContext &ctx) {
|
|||
|
||||
if (engine->_scene->currentlyFollowedActor != followedActorIdx) {
|
||||
const ActorStruct *followedActor = engine->_scene->getActor(followedActorIdx);
|
||||
engine->_grid->newCameraX = followedActor->x / 512;
|
||||
engine->_grid->newCameraY = followedActor->y / 256;
|
||||
engine->_grid->newCameraZ = followedActor->z / 512;
|
||||
engine->_grid->newCameraX = followedActor->x / BRICK_SIZE;
|
||||
engine->_grid->newCameraY = followedActor->y / BRICK_HEIGHT;
|
||||
engine->_grid->newCameraZ = followedActor->z / BRICK_SIZE;
|
||||
|
||||
engine->_scene->currentlyFollowedActor = followedActorIdx;
|
||||
engine->_redraw->reqBgRedraw = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue