Permalink
Browse files

draw piles after corpses, so they are harder to miss

  • Loading branch information...
1 parent 6c8253e commit 703def024d61f4b069d137b9db8781dab6d755db @lynxlynxlynx lynxlynxlynx committed Jul 27, 2013
Showing with 59 additions and 20 deletions.
  1. +55 −18 gemrb/core/Map.cpp
  2. +4 −2 gemrb/core/Map.h
View
@@ -105,7 +105,7 @@ void Map::ReleaseMemory()
}
}
-static inline AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimation *a, ScriptedAnimation *sca, Particles *spark, Projectile *pro)
+static inline AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimation *a, ScriptedAnimation *sca, Particles *spark, Projectile *pro, Container *pile)
{
int actorh;
if (actor) {
@@ -145,6 +145,14 @@ static inline AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimatio
proh = 0x7fffffff;
}
+ // piles should always be drawn last, except if there is a corpse in the way
+ if (actor && (actor->GetStat(IE_STATE_ID) & STATE_DEAD)) {
+ return AOT_ACTOR;
+ }
+ if (pile) {
+ return AOT_PILE;
+ }
+
if (proh<actorh && proh<scah && proh<aah && proh<spah) return AOT_PROJECTILE;
if (spah<actorh && spah<scah && spah<aah) return AOT_SPARK;
@@ -949,28 +957,17 @@ void Map::ClearSearchMapFor( Movable *actor ) {
free(nearActors);
}
-void Map::DrawHighlightables( Region screen )
+void Map::DrawHighlightables()
{
- Region vp = core->GetVideoDriver()->GetViewport();
+ // NOTE: piles are drawn in the main queue
unsigned int i = 0;
Container *c;
while ( (c = TMap->GetContainer(i++))!=NULL ) {
- Color tint = LightMap->GetPixel( c->Pos.x / 16, c->Pos.y / 12);
- tint.a = 255;
-
if (c->Highlight) {
- if (c->Type==IE_CONTAINER_PILE) {
- Color tint = LightMap->GetPixel( c->Pos.x / 16, c->Pos.y / 12);
- tint.a = 255;
- c->DrawPile(true, screen, tint);
- } else {
+ if (c->Type != IE_CONTAINER_PILE) {
c->DrawOutline();
}
- } else if (c->Type==IE_CONTAINER_PILE) {
- if (c->outline->BBox.InsideRegion( vp )) {
- c->DrawPile(false, screen, tint);
- }
}
}
@@ -987,6 +984,37 @@ void Map::DrawHighlightables( Region screen )
}
}
+void Map::DrawPile(Region screen, int pileidx)
+{
+ Region vp = core->GetVideoDriver()->GetViewport();
+ Container *c = TMap->GetContainer(pileidx);
+ assert(c != NULL);
+
+ Color tint = LightMap->GetPixel(c->Pos.x / 16, c->Pos.y / 12);
+ tint.a = 255;
+
+ if (c->Highlight) {
+ c->DrawPile(true, screen, tint);
+ } else {
+ if (c->outline->BBox.InsideRegion(vp)) {
+ c->DrawPile(false, screen, tint);
+ }
+ }
+}
+
+Container *Map::GetNextPile(int &index) const
+{
+ Container *c = TMap->GetContainer(index++);
+
+ while (c) {
+ if (c->Type == IE_CONTAINER_PILE) {
+ return c;
+ }
+ c = TMap->GetContainer(index++);
+ }
+ return NULL;
+}
+
Actor *Map::GetNextActor(int &q, int &index)
{
retry:
@@ -1140,6 +1168,8 @@ void Map::DrawMap(Region screen)
scaIterator scaidx = vvcCells.begin();
proIterator proidx = projectiles.begin();
spaIterator spaidx = particles.begin();
+ int pileidx = 0;
+ Container *pile = GetNextPile(pileidx);
AreaAnimation *a = GetNextAreaAnimation(aniidx, gametime);
ScriptedAnimation *sca = GetNextScriptedAnimation(scaidx);
@@ -1154,20 +1184,27 @@ void Map::DrawMap(Region screen)
if (!bgoverride) {
//Draw Outlines
- DrawHighlightables(screen);
+ DrawHighlightables();
}
// TODO: In at least HOW/IWD2 actor ground circles will be hidden by
// an area animation with height > 0 even if the actors themselves are not
// hidden by it.
- while (actor || a || sca || spark || pro) {
- switch(SelectObject(actor,q,a,sca,spark,pro)) {
+ while (actor || a || sca || spark || pro || pile) {
+ switch(SelectObject(actor,q,a,sca,spark,pro,pile)) {
case AOT_ACTOR:
actor->Draw( screen );
actor->UpdateAnimations();
actor = GetNextActor(q, index);
break;
+ case AOT_PILE:
+ // draw piles
+ if (!bgoverride) {
+ DrawPile(screen, pileidx-1);
+ pile = GetNextPile(pileidx);
+ }
+ break;
case AOT_AREA:
//draw animation
a->Draw( screen, this );
View
@@ -230,7 +230,7 @@ class GEM_EXPORT AreaAnimation {
Animation *GetAnimationPiece(AnimationFactory *af, int animCycle);
};
-enum AnimationObjectType {AOT_AREA, AOT_SCRIPTED, AOT_ACTOR, AOT_SPARK, AOT_PROJECTILE};
+enum AnimationObjectType {AOT_AREA, AOT_SCRIPTED, AOT_ACTOR, AOT_SPARK, AOT_PROJECTILE, AOT_PILE};
//i believe we need only the active actors/visible inactive actors queues
#define QUEUE_COUNT 2
@@ -317,7 +317,7 @@ class GEM_EXPORT Map : public Scriptable {
void MoveVisibleGroundPiles(const Point &Pos);
/* draws stationary vvc graphics */
//void DrawVideocells(Region screen);
- void DrawHighlightables(Region screen);
+ void DrawHighlightables();
void DrawMap(Region screen);
void PlayAreaSong(int SongType, bool restart = true, bool hard = false);
void AddAnimation(AreaAnimation* anim);
@@ -510,6 +510,8 @@ class GEM_EXPORT Map : public Scriptable {
Particles *GetNextSpark(spaIterator &iter);
ScriptedAnimation *GetNextScriptedAnimation(scaIterator &iter);
Actor *GetNextActor(int &q, int &index);
+ Container *GetNextPile (int &index) const;
+ void DrawPile (Region screen, int pileidx);
void DrawSearchMap(const Region &screen);
void GenerateQueues();
void SortQueues();

0 comments on commit 703def0

Please sign in to comment.