From 995a7760509ef16899e975871b6c36af71ee7612 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Mon, 17 Jun 2002 21:37:40 +0000
Subject: [PATCH] Random heading for new created units (Didn't work during map
 setup, no graphics are loaded yet).

---
 src/unit/unit.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp
index 891eeb9b1..f52e9c361 100644
--- a/src/unit/unit.cpp
+++ b/src/unit/unit.cpp
@@ -292,8 +292,10 @@ global void InitUnit (Unit *unit, UnitType *type)
 	}
     }
 
-    if( !type->Building ) {
+    if( !type->Building && type->Sprite
+	    && VideoGraphicFrames(type->Sprite)>5 ) {
         unit->Direction=(MyRand()>>8)&0xFF;	// random heading
+	UnitUpdateHeading(unit);
     }
 
     if( type->CanCastSpell ) {