1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-16 03:20:48 +00:00

Misc code cleanups, little SkeletalSprite loading improvement.

- Removed some unused member variables.

- The BBGE_BUILD_WIDESCREEN define is now gone.

- Added an TiXMLDocument cache to prevent parsing the same file
once for each entity on the map with the same skeletal.

- Removed Lua func entity_warpToPathStart, which was essentially a no-op
because Entity::followingPath was always NULL. Removed related code.

- Set texture wrap only when required.

(Some changes taken from https://bitbucket.org/mattbierner/ios-aquaria,
special thanks for changeset 72d6460d9e60)
This commit is contained in:
fgenesis 2012-02-19 04:57:04 +01:00
commit 9b63b400d5
23 changed files with 209 additions and 764 deletions

View file

@ -1201,6 +1201,7 @@ void AnimationEditor::saveFile()
void AnimationEditor::loadFile()
{
SkeletalSprite::clearCache();
lastSelectedBone = 0;
editingBone = 0;
clearUndoHistory();

View file

@ -3996,7 +3996,6 @@ void Avatar::lockToWallCommon()
dsq->spawnParticleEffect("LockToWall", position);
stopBurst();
stopRoll();
disableOverideMaxSpeed();
core->sound->playSfx("LockToWall", 1.0, 0);//, (1000+rand()%100)/1000.0f);
//bursting = false;
animatedBurst = false;
@ -4307,7 +4306,6 @@ void Avatar::lockToWall()
void Avatar::applyTripEffects()
{
color.interpolateTo(BLIND_COLOR, 0.5);
currentColor = BLIND_COLOR;
tripper->alpha.interpolateTo(1, 8);
@ -4334,7 +4332,6 @@ void Avatar::applyTripEffects()
void Avatar::removeTripEffects()
{
color.interpolateTo(Vector(1,1,1),0.5);
currentColor = Vector(1,1,1);
tripper->alpha.interpolateTo(0, 4);
if (dsq->loops.trip != BBGE_AUDIO_NOCHANNEL)
@ -4350,7 +4347,6 @@ void Avatar::applyBlindEffects()
// character black
color.interpolateTo(BLIND_COLOR, 0.5);
currentColor = BLIND_COLOR;
blinder->alpha.interpolateTo(1, 0.5);
blinder->rotation.z = 0;
@ -4364,7 +4360,6 @@ void Avatar::applyBlindEffects()
void Avatar::removeBlindEffects()
{
color.interpolateTo(Vector(1,1,1),0.5);
currentColor = Vector(1,1,1);
blinder->alpha.interpolateTo(0, 0.5);
//dsq->toggleMuffleSound(0);
}

View file

@ -1057,11 +1057,7 @@ This build is not yet final, and as such there are a couple things lacking. They
debugLog("Init Graphics Library...");
initGraphicsLibrary(user.video.resx, user.video.resy, fullscreen, user.video.vsync, user.video.bits);
#ifdef BBGE_BUILD_WIDESCREEN
core->enable2DWide(user.video.resx, user.video.resy);
#else
core->enable2D(800, 600, 1);
#endif
core->initFrameBuffer();
debugLog("OK");
@ -2245,6 +2241,7 @@ void DSQ::shutdown()
core->particleManager->clearParticleBank();
Shot::clearShotBank();
SkeletalSprite::clearCache();
cursor->setTexturePointer(0, RenderObject::NO_ADD_REF);

View file

@ -232,7 +232,6 @@ Entity::Entity() : StateMachine(), DFSprite()
}
entityTypeIdx = -1;
damageTime = vars->entityDamageTime;
pushAvatar= false;
slowingToStopPathTimer = 0;
slowingToStopPath = 0;
followPos = 0;
@ -240,21 +239,16 @@ Entity::Entity() : StateMachine(), DFSprite()
swimPath = false;
currentEntityTarget = 0;
deleteOnPathEnd = false;
overideMaxSpeedValue= 0;
overideMaxSpeedTime=0;
followingPath = 0;
multColor = Vector(1,1,1);
collideRadius = 24;
entityType = EntityType(0);
targets.resize(10);
attachedTo = 0;
currentPathNode = -1;
//target = 0;
frozenTimer = 0;
canBeTargetedByAvatar = false;
activationRange = 0;
activationType = ACT_NONE;
currentColor = Vector(1,1,1);
pushDamage = 0;
//debugLog("dsq->addEntity()");
@ -262,7 +256,6 @@ Entity::Entity() : StateMachine(), DFSprite()
dsq->addEntity(this);
maxSpeed = oldMaxSpeed = 300;
entityDead = false;
takeDamage = true;
health = maxHealth = 5;
invincibleBreak = false;
activationRadius = 40;
@ -485,7 +478,6 @@ void Entity::setName(const std::string &name)
void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
{
//Path *p = dsq->game->getPathByName(name);
if (p)
{
deleteOnPathEnd = deleteOnEnd;
@ -514,15 +506,6 @@ void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
debugLog("Starting");
position.data->path.getPathNode(0)->value = position;
position.startPath(time);//, 1.0f/2.0f);
//swimPath = true;
/*
currentPathNode = 1;
followingPath = p;
setMaxSpeed(spd);
pathDefaultMaxSpeed = spd;
lastPathMaxSpeed = spd;
followingPathLoop = loop;
*/
}
}
@ -538,16 +521,16 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
position.stop();
swimPath = swim;
debugLog("Generating path to: " + path->name);
//debugLog("Generating path to: " + path->name);
dsq->pathFinding.generatePath(this, TileVector(start), TileVector(dest));
int sz = position.data->path.getNumPathNodes();
position.data->path.addPathNode(path->nodes[0].position, 1);
VectorPath old = position.data->path;
std::ostringstream os;
/*std::ostringstream os;
os << "Path length: " << sz;
debugLog(os.str());
debugLog(os.str());*/
debugLog("Regenerating section");
//debugLog("Regenerating section");
//int ms = sz % 12;
/*
@ -561,19 +544,19 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
*/
this->vel = 0;
debugLog("Molesting Path");
//debugLog("Molesting Path");
dsq->pathFinding.molestPath(position.data->path);
//position.data->path.realPercentageCalc();
//position.data->path.cut(4);
debugLog("forcing path to minimum 2 nodes");
//debugLog("forcing path to minimum 2 nodes");
dsq->pathFinding.forceMinimumPath(position.data->path, start, dest);
debugLog("Done");
//debugLog("Done");
debugLog("Calculating Time");
//debugLog("Calculating Time");
float time = position.data->path.getLength()/(float)dsq->continuity.getSpeedType(speedType);
debugLog("Starting");
//debugLog("Starting");
position.data->path.getPathNode(0)->value = position;
position.startPath(time);//, 1.0f/2.0f);
@ -582,10 +565,10 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
position.endOfPathEvent.set(MakeFunctionEvent(Entity, safeKill));
*/
debugLog("Set delete on Path end");
//debugLog("Set delete on Path end");
deleteOnPathEnd = dieOnPathEnd;
debugLog("End of Generate Path");
//debugLog("End of Generate Path");
//position.startSpeedPath(dsq->continuity.getSpeedType(speedType));
//position.startPath(((position.data->path.getNumPathNodes()*TILE_SIZE*4)-2)/dsq->continuity.getSpeedType(speedType));
@ -624,7 +607,6 @@ void Entity::setNodeGroupActive(int group, bool v)
void Entity::stopFollowingPath()
{
followingPath = 0;
position.stopPath();
}
@ -693,12 +675,6 @@ bool Entity::hasTarget(int t)
return (targets[t]!=0);
}
void Entity::warpToPathStart()
{
if (followingPath && !followingPath->nodes.empty())
position = followingPath->nodes[0].position;
}
void Entity::watchEntity(Entity *e)
{
watchingEntity = e;
@ -1396,7 +1372,7 @@ bool Entity::pathBurst(bool wallJump)
bool Entity::isFollowingPath()
{
return followingPath != 0 || position.isFollowingPath();
return position.isFollowingPath();
}
void Entity::onPathEnd()
@ -1820,15 +1796,6 @@ void Entity::onUpdate(float dt)
//vel2=0;
Vector lastPos = position;
if (overideMaxSpeedTime > 0)
{
overideMaxSpeedTime-= dt;
if (overideMaxSpeedTime < 0)
{
overideMaxSpeedTime = 0;
overideMaxSpeedValue = 0;
}
}
if (ridingOnEntity)
{
@ -1953,56 +1920,6 @@ void Entity::onUpdate(float dt)
}
*/
if (followingPath && currentPathNode != -1 && life == 1)
{
PathNode *node = &followingPath->nodes[currentPathNode];
Vector v = node->position - this->position;
v.setLength2D(1000*dt);
vel += v;
int ms = pathDefaultMaxSpeed;
if (node->maxSpeed != -1)
{
ms = node->maxSpeed;
}
if (ms != lastPathMaxSpeed)
{
float distFromNode = 0, distBetweenNodes = 0;
distFromNode = (node->position - this->position).getLength2D();
if (currentPathNode > 0)
{
PathNode *previousNode = &followingPath->nodes[currentPathNode-1];
distBetweenNodes = (node->position - previousNode->position).getLength2D();
}
setMaxSpeed(lastPathMaxSpeed + (ms - lastPathMaxSpeed)*(1.0f-(distFromNode/distBetweenNodes)));
}
//setMaxSpeed(ms);
Vector diffVec = (node->position - this->position);
if (diffVec.getSquaredLength2D() < sqr(200))
{
currentPathNode ++;
lastPathMaxSpeed = ms;
if (currentPathNode >= followingPath->nodes.size())
{
if (followingPathLoop == -1)
{
warpToPathStart();
currentPathNode = 1;
}
else
{
if (deleteOnPathEnd)
this->safeKill();
position.interpolateTo(followingPath->nodes[followingPath->nodes.size()-1].position, 0.5);
//position = followingPath->nodes[followingPath->nodes.size()-1].position;
vel = 0;
followingPath = 0;
}
}
}
}
if (getState() == STATE_PUSH)
{
//vel = pushVec * this->time;
@ -2415,24 +2332,9 @@ void Entity::setMaxSpeed(int ms)
maxSpeed = oldMaxSpeed = ms;
}
void Entity::overideMaxSpeed(int ms, float time)
{
overideMaxSpeedTime = time;
overideMaxSpeedValue = ms;
}
void Entity::disableOverideMaxSpeed()
{
overideMaxSpeedValue =0;
overideMaxSpeedTime = 0;
}
int Entity::getMaxSpeed()
{
if (overideMaxSpeedValue)
return overideMaxSpeedValue;
else
return maxSpeed;
return maxSpeed;
}
void Entity::songNote(int note)
@ -2450,10 +2352,6 @@ void Entity::sound(const std::string &sound, float freq, float fadeOut)
Vector Entity::getEnergyShotTargetPosition()
{
if (!energyShotTargetPosition.isZero())
{
return energyShotTargetPosition;
}
return getWorldPosition();
}
@ -2883,7 +2781,7 @@ bool Entity::damage(const DamageData &dmgData)
if (d.damageType == DT_NONE)
return false;
//if () return true;
if (!takeDamage || isEntityDead())
if (isEntityDead())
{
//DUPE: same as below
//HACK: hackish

View file

@ -277,7 +277,6 @@ public:
void freeze(float time);
int leaches;
virtual void onSceneFlipped() {}
bool isNearObstruction(int sz, int type=0, TileVector *hitTile=0);
@ -308,10 +307,7 @@ public:
virtual void onNotify(Entity *notify){}
//void followPath(Path *p, int spd, int loop, bool deleteOnEnd = false);
void followPath(Path *p, int speedType, int dir, bool deleteOnEnd = false);
void warpToPathStart();
int currentPathNode;
Entity *attachedTo;
Path *followingPath;
bool touchAvatarDamage(int radius, float dmg, const Vector &override=Vector(-1,-1,-1), int speed=0, float pushTime = 0, Vector collidePos = Vector(0,0,0));
void moveTowards(Vector p, float dt, int spd);
@ -372,7 +368,6 @@ public:
void slowToStopPath(float t);
bool isSlowingToStopPath();
Vector lastMove;
int pushAvatar;
float damageTime;
void setEntityProperty(EntityProperty ep, bool value=true);
@ -419,7 +414,6 @@ public:
Vector getEnergyShotTargetPosition();
int getRandomTargetPoint();
Vector energyShotTargetPosition;
Vector ridingOnEntityOffset;
void moveOutOfWall();
bool isSittingOnInvisibleIn();
@ -458,7 +452,6 @@ public:
bool checkSplash(const Vector &override=Vector(0,0,0));
EatData eatData;
InterpolatedVector flipScale;
SkeletalSprite copySkel;
bool beautyFlip;
void attachLance();
void setInvincible(bool inv);
@ -564,18 +557,11 @@ protected:
virtual void onPathEnd();
bool swimPath;
bool deleteOnPathEnd;
int overideMaxSpeedValue;
float overideMaxSpeedTime;
InterpolatedVector multColor;
EntityType entityType;
std::vector<Entity*> attachedEntities;
std::vector<Vector> attachedEntitiesOffsets;
int pathDefaultMaxSpeed;
int lastPathMaxSpeed;
int followingPathLoop;
virtual void onFreeze(){}
//Entity *target;
@ -587,8 +573,6 @@ protected:
void doDeathEffects(int manaBallEnergy=0, bool die=true);
Vector currentColor;
bool takeDamage;
void onEnterState(int action);
void onExitState(int action);
//virtual bool onDamage(int amount, Spell *spell, Entity *attacker);

View file

@ -2845,7 +2845,6 @@ void Game::generateCollisionMask(Quad *q, int overrideCollideRadius)
q->collideRadius = overrideCollideRadius;
else
q->collideRadius = TILE_SIZE/2;
q->useCollisionMask = true;
q->collisionMask.clear();
std::vector<TileVector> obs;
TileVector tpos(q->position);
@ -4295,7 +4294,6 @@ bool Game::loadSceneXML(std::string scene)
addProgress();
clearObsRows();
jetStreams.clear();
warpAreas.clear();
TiXmlElement *lensFlare = doc.FirstChildElement("LensFlare");
while (lensFlare)
@ -6481,10 +6479,8 @@ void Game::applyState()
//dsq->getRenderObjectLayer(LR_ELEMENTS5)->update = false;
backgroundImageRepeat = 1;
jetStreams.clear();
grad = 0;
maxZoom = -1;
followSym = 0;
saveFile = 0;
deathTimer = 0.9;
runGameOverScript = false;
@ -6495,6 +6491,7 @@ void Game::applyState()
elementTemplatePack ="";
clearGrid();
clearPointers();
SkeletalSprite::clearCache();
StateObject::applyState();
@ -10976,9 +10973,6 @@ void Game::removeState()
clearControlHint();
dsq->overlay->color = 0;
if (dsq->game->avatar->attachedTo)
avatarTransit = dsq->game->avatar->attachedTo->name;
//dsq->overlay->alpha = 0;
dsq->overlay->alpha.interpolateTo(1, fadeTime);
dsq->main(fadeTime);

View file

@ -73,7 +73,6 @@ struct RecipeMenu
std::vector<RecipeMenuEntry*> recipeMenuEntries;
};
class JetStream;
class Avatar;
class Gradient;
class CurrentRender;
@ -134,14 +133,6 @@ enum EditTypes
};
#endif
class FollowSym : public Quad
{
public:
FollowSym();
protected:
void onUpdate(float dt);
};
class ManaBall : public Quad
{
public:
@ -739,8 +730,6 @@ public:
TiXmlDocument *saveFile;
std::vector<JetStream*> jetStreams;
FollowSym *followSym;
Vector positionToAvatar;
float getCoverage(Vector pos, int sampleArea = 5);
@ -800,7 +789,6 @@ public:
Path *getNearestPath(const Vector &pos, PathType pathType=PATH_NONE);
Path *getNearestPath(Path *p, std::string name);
std::string avatarTransit;
#ifdef AQUARIA_BUILD_SCENEEDITOR
SceneEditor sceneEditor;
bool isSceneEditorActive() {return sceneEditor.isOn();}

View file

@ -2394,8 +2394,6 @@ void SceneEditor::removeEntity()
void SceneEditor::placeAvatar()
{
dsq->game->avatar->position = dsq->getGameCursorPosition();
QuadLight::clearQuadLights();
QuadLight::addQuadLight(QuadLight(Vector(dsq->game->avatar->position), Vector(1, 0, 0), 1200));
}
void SceneEditor::scaleElementUp()

View file

@ -2672,23 +2672,6 @@ luaFunc(entity_followPath)
luaReturnNil();
}
luaFunc(entity_warpToPathStart)
{
ScriptedEntity *e = scriptedEntity(L);
std::string s;
if (lua_isstring(L, 2))
s = lua_tostring(L, 2);
if (s.empty())
e->warpToPathStart();
else
{
//e->followPath(s, 0, 0);
e->warpToPathStart();
e->stopFollowingPath();
}
luaReturnNil();
}
luaFunc(getIngredientGfx)
{
luaReturnStr(dsq->continuity.getIngredientGfx(getString(L, 1)).c_str());
@ -7482,7 +7465,6 @@ static const struct {
luaRegister(entity_setAnimLayerTimeMult),
luaRegister(entity_setCurrentTarget),
luaRegister(entity_warpToPathStart),
luaRegister(entity_stopInterpolating),
luaRegister(entity_followPath),