From a7519549f773946a4735fd322fbf5f14df620bfe Mon Sep 17 00:00:00 2001
From: jsalmon3 <>
Date: Thu, 9 Oct 2003 22:04:04 +0000
Subject: [PATCH] Cleanup

---
 src/map/tileset.cpp         |    2 +-
 src/stratagus/construct.cpp |  386 ++++++-------
 src/stratagus/groups.cpp    |   98 ++--
 src/stratagus/iolib.cpp     |  278 +++++-----
 src/stratagus/missile.cpp   |    2 +-
 src/stratagus/stratagus.cpp |  660 +++++++++++-----------
 src/ui/icons.cpp            |    2 +-
 src/unit/unit_draw.cpp      | 1041 +++++++++++++++++------------------
 src/unit/unittype.cpp       |    8 +-
 src/video/cursor.cpp        |    5 +-
 src/video/font.cpp          |    4 +-
 11 files changed, 1228 insertions(+), 1258 deletions(-)

diff --git a/src/map/tileset.cpp b/src/map/tileset.cpp
index d2d82f829..082d1485a 100644
--- a/src/map/tileset.cpp
+++ b/src/map/tileset.cpp
@@ -125,7 +125,7 @@ global void LoadTileset(void)
     //
     buf = alloca(strlen(Tilesets[i]->ImageFile) + 9 + 1);
     strcat(strcpy(buf, "graphics/"), Tilesets[i]->ImageFile);
-    ShowLoadProgress("\tTileset `%s'\n", Tilesets[i]->ImageFile);
+    ShowLoadProgress("Tileset `%s'", Tilesets[i]->ImageFile);
     TheMap.TileData = LoadGraphic(buf);
 #ifdef USE_OPENGL
     MakeTexture(TheMap.TileData, TheMap.TileData->Width, TheMap.TileData->Height);
diff --git a/src/stratagus/construct.cpp b/src/stratagus/construct.cpp
index cd7e81e01..35ea110c6 100644
--- a/src/stratagus/construct.cpp
+++ b/src/stratagus/construct.cpp
@@ -87,46 +87,46 @@ global void LoadConstructions(void)
     const char* file;
     Construction** cop;
 
-    if( (cop=Constructions) ) {
-	while( *cop ) {
-	    if( !(*cop)->Ident ) {
+    if ((cop = Constructions)) {
+	while (*cop) {
+	    if (!(*cop)->Ident) {
 		continue;
 	    }
-	    file=(*cop)->File[TheMap.Terrain].File;
-	    if( file ) {			// default one
-		(*cop)->Width=(*cop)->File[TheMap.Terrain].Width;
-		(*cop)->Height=(*cop)->File[TheMap.Terrain].Height;
+	    file = (*cop)->File[TheMap.Terrain].File;
+	    if (file) {			// default one
+		(*cop)->Width = (*cop)->File[TheMap.Terrain].Width;
+		(*cop)->Height = (*cop)->File[TheMap.Terrain].Height;
 	    } else {
-		file=(*cop)->File[0].File;
-		(*cop)->Width=(*cop)->File[0].Width;
-		(*cop)->Height=(*cop)->File[0].Height;
+		file = (*cop)->File[0].File;
+		(*cop)->Width = (*cop)->File[0].Width;
+		(*cop)->Height = (*cop)->File[0].Height;
 	    }
-	    if( *file ) {
+	    if (*file) {
 		char* buf;
 
-		buf=alloca(strlen(file)+9+1);
-		file=strcat(strcpy(buf,"graphics/"),file);
-		ShowLoadProgress("\tConstruction %s\n",file);
-		(*cop)->Sprite=LoadSprite(file
-			,(*cop)->Width,(*cop)->Height);
+		buf = alloca(strlen(file) + 9 + 1);
+		file = strcat(strcpy(buf, "graphics/"), file);
+		ShowLoadProgress("Construction %s", file);
+		(*cop)->Sprite = LoadSprite(file,
+		    (*cop)->Width, (*cop)->Height);
 	    }
-	    file=(*cop)->ShadowFile[TheMap.Terrain].File;
-	    if( file ) {
-		(*cop)->ShadowWidth=(*cop)->ShadowFile[TheMap.Terrain].Width;
-		(*cop)->ShadowHeight=(*cop)->ShadowFile[TheMap.Terrain].Height;
+	    file = (*cop)->ShadowFile[TheMap.Terrain].File;
+	    if (file) {
+		(*cop)->ShadowWidth = (*cop)->ShadowFile[TheMap.Terrain].Width;
+		(*cop)->ShadowHeight = (*cop)->ShadowFile[TheMap.Terrain].Height;
 	    } else {
-		file=(*cop)->ShadowFile[0].File;
-		(*cop)->ShadowWidth=(*cop)->ShadowFile[0].Width;
-		(*cop)->ShadowHeight=(*cop)->ShadowFile[0].Height;
+		file = (*cop)->ShadowFile[0].File;
+		(*cop)->ShadowWidth = (*cop)->ShadowFile[0].Width;
+		(*cop)->ShadowHeight = (*cop)->ShadowFile[0].Height;
 	    }
-	    if( file && *file ) {
-		char *buf;
+	    if (file && *file) {
+		char* buf;
 
-		buf=alloca(strlen(file)+9+1);
-		file=strcat(strcpy(buf,"graphics/"),file);
-		ShowLoadProgress("\tConstruction %s\n",file);
-		(*cop)->ShadowSprite=LoadSprite(file
-			,(*cop)->ShadowWidth,(*cop)->ShadowHeight);
+		buf = alloca(strlen(file) + 9 + 1);
+		file = strcat(strcpy(buf, "graphics/"), file);
+		ShowLoadProgress("Construction %s", file);
+		(*cop)->ShadowSprite = LoadSprite(file,
+		    (*cop)->ShadowWidth, (*cop)->ShadowHeight);
 	    }
 	    ++cop;
 	}
@@ -146,72 +146,72 @@ global void SaveConstructions(CLFile* file)
     Construction** cop;
     ConstructionFrame* cframe;
 
-    CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: constructions $Id$\n\n");
+    CLprintf(file, "\n;;; -----------------------------------------\n");
+    CLprintf(file, ";;; MODULE: constructions $Id$\n\n");
 
     // FIXME: needed?
     
     //
     //	Dump table wc2 construction numbers -> internal symbol.
     //
-    if( (cp=ConstructionWcNames) ) {
-	CLprintf(file,"(define-construction-wc-names");
+    if ((cp = ConstructionWcNames)) {
+	CLprintf(file, "(define-construction-wc-names");
 
-	i=90;
-	while( *cp ) {
-	    if( i+strlen(*cp)>79 ) {
-		i=CLprintf(file,"\n ");
+	i = 90;
+	while (*cp) {
+	    if (i + strlen(*cp) > 79) {
+		i = CLprintf(file, "\n ");
 	    }
-	    i+=CLprintf(file," '%s",*cp++);
+	    i += CLprintf(file, " '%s", *cp++);
 	}
-	CLprintf(file,")\n\n");
+	CLprintf(file, ")\n\n");
     }
 
     //
     //	Dump table of all constructions
     //
-    if( (cop=Constructions) ) {
-	while( *cop ) {
-	    if( !(*cop)->Ident ) {
+    if ((cop = Constructions)) {
+	while (*cop) {
+	    if (!(*cop)->Ident) {
 		continue;
 	    }
-	    CLprintf(file,"(define-construction '%s\n",(*cop)->Ident);
-	    for( j=0; j<TilesetMax; ++j ) {
-		if( !(*cop)->File[j].File ) {
+	    CLprintf(file, "(define-construction '%s\n", (*cop)->Ident);
+	    for (j = 0; j < TilesetMax; ++j) {
+		if (!(*cop)->File[j].File) {
 		    continue;
 		}
-		CLprintf(file,"  'file '(\n");
-		CLprintf(file,"    tileset %s\n",Tilesets[j]->Class);
-		CLprintf(file,"    file  \"%s\"\n",(*cop)->File[j].File);
-		CLprintf(file,"    size (%d %d))\n",(*cop)->File[j].Width,
-			(*cop)->File[j].Height);
+		CLprintf(file, "  'file '(\n");
+		CLprintf(file, "    tileset %s\n", Tilesets[j]->Class);
+		CLprintf(file, "    file  \"%s\"\n", (*cop)->File[j].File);
+		CLprintf(file, "    size (%d %d))\n", (*cop)->File[j].Width,
+		    (*cop)->File[j].Height);
 	    }
-	    for( j=0; j<TilesetMax; ++j ) {
-		if( !(*cop)->ShadowFile[j].File ) {
+	    for (j = 0; j < TilesetMax; ++j) {
+		if (!(*cop)->ShadowFile[j].File) {
 		    continue;
 		}
-		CLprintf(file,"  'shadow-file '(\n");
-		CLprintf(file,"    tileset %s\n",Tilesets[j]->Class);
-		CLprintf(file,"    file  \"%s\"\n",(*cop)->ShadowFile[j].File);
-		CLprintf(file,"    size (%d %d))\n",(*cop)->ShadowFile[j].Width,
-			(*cop)->ShadowFile[j].Height);
+		CLprintf(file, "  'shadow-file '(\n");
+		CLprintf(file, "    tileset %s\n", Tilesets[j]->Class);
+		CLprintf(file, "    file  \"%s\"\n", (*cop)->ShadowFile[j].File);
+		CLprintf(file, "    size (%d %d))\n", (*cop)->ShadowFile[j].Width,
+		    (*cop)->ShadowFile[j].Height);
 	    }
-	    cframe=(*cop)->Frames;
-	    if( cframe ) {
-		CLprintf(file,"  'constructions (list");
-		while( cframe ) {
-		    CLprintf(file,"\n    '(percent %d\n",cframe->Percent);
-		    if( cframe->File==ConstructionFileConstruction ) {
-			CLprintf(file,"      file construction\n");
+	    cframe = (*cop)->Frames;
+	    if (cframe) {
+		CLprintf(file, "  'constructions (list");
+		while (cframe) {
+		    CLprintf(file, "\n    '(percent %d\n", cframe->Percent);
+		    if (cframe->File == ConstructionFileConstruction) {
+			CLprintf(file, "      file construction\n");
 		    } else {
-			CLprintf(file,"      file main\n");
+			CLprintf(file, "      file main\n");
 		    }
-		    CLprintf(file,"      frame %d)",cframe->Frame);
-		    cframe=cframe->Next;
+		    CLprintf(file, "      frame %d)",cframe->Frame);
+		    cframe = cframe->Next;
 		}
-		CLprintf(file,")\n");
+		CLprintf(file, ")\n");
 	    }
-	    CLprintf(file,")\n\n");
+	    CLprintf(file, ")\n\n");
 	    ++cop;
 	}
     }
@@ -231,45 +231,45 @@ global void CleanConstructions(void)
     //
     //	Mapping original construction numbers in puds to our internal strings
     //
-    if( (cp=ConstructionWcNames) ) {	// Free all old names
-	while( *cp ) {
+    if ((cp = ConstructionWcNames)) {	// Free all old names
+	while (*cp) {
 	    free(*cp++);
 	}
 	free(ConstructionWcNames);
-	ConstructionWcNames=NULL;
+	ConstructionWcNames = NULL;
     }
 
     //
     //	Free the construction table.
     //
-    if( (cop=Constructions) ) {
-	while( *cop ) {
-	    if( (*cop)->Ident ) {
+    if ((cop = Constructions)) {
+	while (*cop) {
+	    if ((*cop)->Ident) {
 		free((*cop)->Ident);
 	    }
-	    for( j=0; j<TilesetMax; ++j ) {
-		if( (*cop)->File[j].File ) {
+	    for (j = 0; j < TilesetMax; ++j) {
+		if ((*cop)->File[j].File) {
 		    free((*cop)->File[j].File);
 		}
 	    }
 	    VideoSaveFree((*cop)->Sprite);
-	    for( j=0; j<TilesetMax; ++j ) {
-		if( (*cop)->ShadowFile[j].File ) {
+	    for (j = 0; j < TilesetMax; ++j) {
+		if ((*cop)->ShadowFile[j].File) {
 		    free((*cop)->ShadowFile[j].File);
 		}
 	    }
 	    VideoSaveFree((*cop)->ShadowSprite);
-	    cframe=(*cop)->Frames;
-	    while( cframe ) {
-		tmp=cframe->Next;
+	    cframe = (*cop)->Frames;
+	    while (cframe) {
+		tmp = cframe->Next;
 		free(cframe);
-		cframe=tmp;
+		cframe = tmp;
 	    }
 	    free(*cop);
 	    ++cop;
 	}
 	free(Constructions);
-	Constructions=NULL;
+	Constructions = NULL;
     }
 }
 
@@ -284,9 +284,9 @@ global Construction* ConstructionByIdent(const char* ident)
 {
     Construction** cop;
 
-    if( (cop=Constructions) ) {
-	while( *cop ) {
-	    if( (*cop)->Ident && !strcmp(ident,(*cop)->Ident) ) {
+    if ((cop = Constructions)) {
+	while (*cop) {
+	    if ((*cop)->Ident && !strcmp(ident, (*cop)->Ident)) {
 		return *cop;
 	    }
 	    ++cop;
@@ -318,8 +318,8 @@ local SCM CclDefineConstructionWcNames(SCM list)
     int i;
     char** cp;
 
-    if( (cp=ConstructionWcNames) ) {		// Free all old names
-	while( *cp ) {
+    if ((cp = ConstructionWcNames)) {		// Free all old names
+	while (*cp) {
 	    free(*cp++);
 	}
 	free(ConstructionWcNames);
@@ -328,13 +328,13 @@ local SCM CclDefineConstructionWcNames(SCM list)
     //
     //	Get new table.
     //
-    i=gh_length(list);
-    ConstructionWcNames=cp=malloc((i+1)*sizeof(char*));
-    while( i-- ) {
-	*cp++=gh_scm2newstr(gh_car(list),NULL);
-	list=gh_cdr(list);
+    i = gh_length(list);
+    ConstructionWcNames = cp = malloc((i + 1) * sizeof(char*));
+    while (i--) {
+	*cp++ = gh_scm2newstr(gh_car(list), NULL);
+	list = gh_cdr(list);
     }
-    *cp=NULL;
+    *cp = NULL;
 
     return SCM_UNSPECIFIED;
 }
@@ -357,162 +357,162 @@ local SCM CclDefineConstruction(SCM list)
 
     //	Slot identifier
 
-    str=gh_scm2newstr(gh_car(list),NULL);
-    list=gh_cdr(list);
+    str = gh_scm2newstr(gh_car(list), NULL);
+    list = gh_cdr(list);
 
-    for( i=0; ConstructionWcNames[i]; ++i ) {
-	if( !strcmp(ConstructionWcNames[i],str) ) {
+    for (i = 0; ConstructionWcNames[i]; ++i) {
+	if (!strcmp(ConstructionWcNames[i], str)) {
 	    break;
 	}
     }
-    if( !ConstructionWcNames[i] ) {
+    if (!ConstructionWcNames[i]) {
 	DebugLevel0Fn("Construction not found.\n");
 	free(str);
 	return SCM_UNSPECIFIED;
     }
 
-    if( (cop=Constructions)==NULL ) {
-	Constructions=malloc(2*sizeof(Construction*));
-	Constructions[0]=calloc(1,sizeof(Construction));
-	Constructions[1]=NULL;
-	construction=Constructions[0];
+    if ((cop = Constructions) == NULL) {
+	Constructions = malloc(2 * sizeof(Construction*));
+	Constructions[0] = calloc(1, sizeof(Construction));
+	Constructions[1] = NULL;
+	construction = Constructions[0];
     } else {
-	for( i=0; *cop; ++i,++cop ) {
+	for (i = 0; *cop; ++i, ++cop) {
 	}
-	Constructions=realloc(Constructions,(i+2)*sizeof(Construction*));
-	Constructions[i]=calloc(1,sizeof(Construction));
-	Constructions[i+1]=NULL;
-	construction=Constructions[i];
+	Constructions = realloc(Constructions, (i + 2) * sizeof(Construction*));
+	Constructions[i] = calloc(1, sizeof(Construction));
+	Constructions[i+1] = NULL;
+	construction = Constructions[i];
     }
-    construction->OType=ConstructionType;
-    construction->Ident=str;
+    construction->OType = ConstructionType;
+    construction->Ident = str;
 
     //
     //	Parse the arguments, in tagged format.
     //
-    while( !gh_null_p(list) ) {
+    while (!gh_null_p(list)) {
 	int files;
 
-	value=gh_car(list);
-	list=gh_cdr(list);
+	value = gh_car(list);
+	list = gh_cdr(list);
 
-	if( (files=gh_eq_p(value,gh_symbol2scm("file")))
-		|| gh_eq_p(value,gh_symbol2scm("shadow-file")) ) {
+	if ((files = gh_eq_p(value, gh_symbol2scm("file"))) ||
+		gh_eq_p(value, gh_symbol2scm("shadow-file"))) {
 	    int tileset;
 	    char* file;
 	    int w;
 	    int h;
 
-	    tileset=0;
-	    file=NULL;
-	    w=0;
-	    h=0;
+	    tileset = 0;
+	    file = NULL;
+	    w = 0;
+	    h = 0;
 
-	    sublist=gh_car(list);
-	    while( !gh_null_p(sublist) ) {
-		value=gh_car(sublist);
-		sublist=gh_cdr(sublist);
+	    sublist = gh_car(list);
+	    while (!gh_null_p(sublist)) {
+		value = gh_car(sublist);
+		sublist = gh_cdr(sublist);
 
-		if( gh_eq_p(value,gh_symbol2scm("tileset")) ) {
-		    str=gh_scm2newstr(gh_car(sublist),NULL);
-		    sublist=gh_cdr(sublist);
+		if (gh_eq_p(value, gh_symbol2scm("tileset"))) {
+		    str = gh_scm2newstr(gh_car(sublist), NULL);
+		    sublist = gh_cdr(sublist);
 
 		    // FIXME: use a general get tileset function here!
-		    i=0; 
-		    if( strcmp(str,"default") ) {
-			for( ; i<NumTilesets; ++i ) {
-			    if( !strcmp(str,Tilesets[i]->Ident) ) {
+		    i = 0;
+		    if (strcmp(str, "default")) {
+			for (; i < NumTilesets; ++i) {
+			    if (!strcmp(str,Tilesets[i]->Ident)) {
 				break;
 			    }
-			    if( !strcmp(str,Tilesets[i]->Class) ) {
+			    if (!strcmp(str,Tilesets[i]->Class)) {
 				break;
 			    }
 			}
-			if( i==NumTilesets ) {
-			    fprintf(stderr,"Tileset `%s' not available\n",str);
-			    errl("tileset not available",gh_car(sublist));
+			if (i == NumTilesets) {
+			    fprintf(stderr, "Tileset `%s' not available\n", str);
+			    errl("tileset not available", gh_car(sublist));
 			}
 		    }
-		    tileset=i;
+		    tileset = i;
 		    free(str);
-		} else if( gh_eq_p(value,gh_symbol2scm("file")) ) {
-		    file=gh_scm2newstr(gh_car(sublist),NULL);
-		    sublist=gh_cdr(sublist);
-		} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
-		    value=gh_car(sublist);
-		    sublist=gh_cdr(sublist);
-		    w=gh_scm2int(gh_car(value));
-		    value=gh_cdr(value);
-		    h=gh_scm2int(gh_car(value));
+		} else if (gh_eq_p(value, gh_symbol2scm("file"))) {
+		    file = gh_scm2newstr(gh_car(sublist), NULL);
+		    sublist = gh_cdr(sublist);
+		} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
+		    value = gh_car(sublist);
+		    sublist = gh_cdr(sublist);
+		    w = gh_scm2int(gh_car(value));
+		    value = gh_cdr(value);
+		    h = gh_scm2int(gh_car(value));
 		} else {
-		    errl("Unsupported tag",value);
+		    errl("Unsupported tag", value);
 		}
 	    }
-	    if( files ) {
+	    if (files) {
 		free(construction->File[tileset].File);
-		construction->File[tileset].File=file;
-		construction->File[tileset].Width=w;
-		construction->File[tileset].Height=h;
+		construction->File[tileset].File = file;
+		construction->File[tileset].Width = w;
+		construction->File[tileset].Height = h;
 	    } else {
 		free(construction->ShadowFile[tileset].File);
-		construction->ShadowFile[tileset].File=file;
-		construction->ShadowFile[tileset].Width=w;
-		construction->ShadowFile[tileset].Height=h;
+		construction->ShadowFile[tileset].File = file;
+		construction->ShadowFile[tileset].Width = w;
+		construction->ShadowFile[tileset].Height = h;
 	    }
-	} else if( gh_eq_p(value,gh_symbol2scm("constructions")) ) {
-	    sublist=gh_car(list);
-	    while( !gh_null_p(sublist) ) {
+	} else if (gh_eq_p(value, gh_symbol2scm("constructions"))) {
+	    sublist = gh_car(list);
+	    while (!gh_null_p(sublist)) {
 		SCM slist;
 		int percent;
 		int file;
 		int frame;
 		ConstructionFrame** cframe;
 
-		percent=0;
-		file=0;
-		frame=0;
+		percent = 0;
+		file = 0;
+		frame = 0;
 
-		slist=gh_car(sublist);
-		sublist=gh_cdr(sublist);
-		while( !gh_null_p(slist) ) {
-		    value=gh_car(slist);
-		    slist=gh_cdr(slist);
+		slist = gh_car(sublist);
+		sublist = gh_cdr(sublist);
+		while (!gh_null_p(slist)) {
+		    value = gh_car(slist);
+		    slist = gh_cdr(slist);
 
-		    if( gh_eq_p(value,gh_symbol2scm("percent")) ) {
-			percent=gh_scm2int(gh_car(slist));
-			slist=gh_cdr(slist);
-		    } else if( gh_eq_p(value,gh_symbol2scm("file")) ) {
-			value=gh_car(slist);
-			if( gh_eq_p(value,gh_symbol2scm("construction")) ) {
-			    file=ConstructionFileConstruction;
-			} else if( gh_eq_p(value,gh_symbol2scm("main")) ) {
-			    file=ConstructionFileMain;
+		    if (gh_eq_p(value, gh_symbol2scm("percent"))) {
+			percent = gh_scm2int(gh_car(slist));
+			slist = gh_cdr(slist);
+		    } else if (gh_eq_p(value, gh_symbol2scm("file"))) {
+			value = gh_car(slist);
+			if (gh_eq_p(value, gh_symbol2scm("construction"))) {
+			    file = ConstructionFileConstruction;
+			} else if (gh_eq_p(value, gh_symbol2scm("main"))) {
+			    file = ConstructionFileMain;
 			} else {
-			    errl("Unsupported tag",value);
+			    errl("Unsupported tag", value);
 			}
-			slist=gh_cdr(slist);
-		    } else if( gh_eq_p(value,gh_symbol2scm("frame")) ) {
-			frame=gh_scm2int(gh_car(slist));
-			slist=gh_cdr(slist);
+			slist = gh_cdr(slist);
+		    } else if (gh_eq_p(value, gh_symbol2scm("frame"))) {
+			frame = gh_scm2int(gh_car(slist));
+			slist = gh_cdr(slist);
 		    } else {
-			errl("Unsupported tag",value);
+			errl("Unsupported tag", value);
 		    }
 		}
-		cframe=&construction->Frames;
-		while( *cframe ) {
-		    cframe=&((*cframe)->Next);
+		cframe = &construction->Frames;
+		while (*cframe) {
+		    cframe = &((*cframe)->Next);
 		}
-		(*cframe)=malloc(sizeof(ConstructionFrame));
-		(*cframe)->Percent=percent;
-		(*cframe)->File=file;
-		(*cframe)->Frame=frame;
-		(*cframe)->Next=NULL;
+		(*cframe) = malloc(sizeof(ConstructionFrame));
+		(*cframe)->Percent = percent;
+		(*cframe)->File = file;
+		(*cframe)->Frame = frame;
+		(*cframe)->Next = NULL;
 	    }
 	} else {
 	    // FIXME: this leaves a half initialized construction
-	    errl("Unsupported tag",value);
+	    errl("Unsupported tag", value);
 	}
-	list=gh_cdr(list);
+	list = gh_cdr(list);
     }
 
     return SCM_UNSPECIFIED;
@@ -526,8 +526,8 @@ local SCM CclDefineConstruction(SCM list)
 global void ConstructionCclRegister(void)
 {
     gh_new_procedureN("define-construction-wc-names",
-	    CclDefineConstructionWcNames);
-    gh_new_procedureN("define-construction",CclDefineConstruction);
+	CclDefineConstructionWcNames);
+    gh_new_procedureN("define-construction", CclDefineConstruction);
 
 }
 //@}
diff --git a/src/stratagus/groups.cpp b/src/stratagus/groups.cpp
index 32e0c6d0e..bc058320e 100644
--- a/src/stratagus/groups.cpp
+++ b/src/stratagus/groups.cpp
@@ -10,7 +10,7 @@
 //
 /**@name groups.c	-	The units' groups handling. */
 //
-//	(c) Copyright 1999-2002 by Patrice Fortier and Lutz Sammer
+//	(c) Copyright 1999-2003 by Patrice Fortier and Lutz Sammer
 //
 //      This program is free software; you can redistribute it and/or modify
 //      it under the terms of the GNU General Public License as published by
@@ -69,13 +69,13 @@ global void InitGroups(void)
 {
     int i;
 
-    for( i=0; i<NUM_GROUPS; i++ ) {
+    for (i = 0; i < NUM_GROUPS; ++i) {
 	int n;
 
-	if( (n=Groups[i].NumUnits) ) {		// Cleanup after load
-	    while( n-- ) {
+	if ((n = Groups[i].NumUnits)) {		// Cleanup after load
+	    while (n--) {
 		DebugLevel0Fn("FIXME: old code!\n");
-		Groups[i].Units[n]=UnitSlots[(int)Groups[i].Units[n]];
+		Groups[i].Units[n] = UnitSlots[(int)Groups[i].Units[n]];
 	    }
 	}
     }
@@ -92,17 +92,17 @@ global void SaveGroups(CLFile* file)
     int g;
     char* ref;
 
-    CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: groups $Id$\n\n");
+    CLprintf(file, "\n;;; -----------------------------------------\n");
+    CLprintf(file, ";;; MODULE: groups $Id$\n\n");
 
-    for( g=0; g<NUM_GROUPS; g++ ) {
-	CLprintf(file,"(group %d %d '(",g,Groups[g].NumUnits);
-	for( i=0; i<Groups[g].NumUnits; ++i ) {
-	    ref=UnitReference(Groups[g].Units[i]);
-	    CLprintf(file,"%s ",ref);
+    for (g = 0; g < NUM_GROUPS; ++g) {
+	CLprintf(file, "(group %d %d '(", g, Groups[g].NumUnits);
+	for (i = 0; i < Groups[g].NumUnits; ++i) {
+	    ref = UnitReference(Groups[g].Units[i]);
+	    CLprintf(file, "%s ", ref);
 	    free(ref);
 	}
-	CLprintf(file,"))\n");
+	CLprintf(file, "))\n");
     }
 }
 
@@ -113,8 +113,8 @@ global void CleanGroups(void)
 {
     int i;
 
-    for( i=0; i<NUM_GROUPS; i++ ) {
-        memset(&Groups[i],0,sizeof(Groups[i]));
+    for (i = 0; i < NUM_GROUPS; ++i) {
+        memset(&Groups[i], 0, sizeof(Groups[i]));
     }
 }
 
@@ -150,12 +150,12 @@ global void ClearGroup(int num)
     UnitGroup *group;
     int i;
 
-    group=&Groups[num];
-    for( i=0; i<group->NumUnits; i++ ) {
-	group->Units[i]->GroupId &= ~(1<<num);
-	DebugCheck( group->Units[i]->Destroyed );
+    group = &Groups[num];
+    for (i = 0; i < group->NumUnits; ++i) {
+	group->Units[i]->GroupId &= ~(1 << num);
+	DebugCheck(group->Units[i]->Destroyed);
     }
-    group->NumUnits=0;
+    group->NumUnits = 0;
 }
 
 /**
@@ -165,17 +165,17 @@ global void ClearGroup(int num)
  **	@param nunits	Number of units in array.
  **	@param num	Group number for storage.
  */
-global void AddToGroup(Unit **units,int nunits,int num)
+global void AddToGroup(Unit** units, int nunits, int num)
 {
-    UnitGroup *group;
+    UnitGroup* group;
     int i;
 
-    DebugCheck(num>NUM_GROUPS);
+    DebugCheck(num > NUM_GROUPS);
 
-    group=&Groups[num];
-    for( i=0; group->NumUnits<NUM_UNITS_PER_GROUP && i<nunits; i++ ) {
-        group->Units[group->NumUnits++]=units[i];
-	units[i]->GroupId |= (1<<num);
+    group = &Groups[num];
+    for (i = 0; group->NumUnits < NUM_UNITS_PER_GROUP && i < nunits; ++i) {
+        group->Units[group->NumUnits++] = units[i];
+	units[i]->GroupId |= (1 << num);
     }
 }
 
@@ -186,12 +186,12 @@ global void AddToGroup(Unit **units,int nunits,int num)
  **	@param nunits	Number of units in array.
  **	@param num	Group number for storage.
  */
-global void SetGroup(Unit **units,int nunits,int num)
+global void SetGroup(Unit** units, int nunits, int num)
 {
-    DebugCheck(num>NUM_GROUPS || nunits>NUM_UNITS_PER_GROUP);
+    DebugCheck(num > NUM_GROUPS || nunits > NUM_UNITS_PER_GROUP);
 
     ClearGroup(num);
-    AddToGroup(units,nunits,num);
+    AddToGroup(units, nunits, num);
 }
 
 /**
@@ -199,30 +199,30 @@ global void SetGroup(Unit **units,int nunits,int num)
  **
  **	@param unit	Unit to remove from group.
  */
-global void RemoveUnitFromGroups(Unit *unit)
+global void RemoveUnitFromGroups(Unit* unit)
 {
-    UnitGroup *group;
+    UnitGroup* group;
     int num;
     int i;
 
-    DebugCheck( unit->GroupId==0 );	// unit doesn't belong to a group
+    DebugCheck(unit->GroupId == 0);	// unit doesn't belong to a group
 
-    for( num=0; unit->GroupId; num++,unit->GroupId>>=1 ) {
-	if( (unit->GroupId & 1) != 1 ) {
+    for (num = 0; unit->GroupId; ++num, unit->GroupId >>= 1) {
+	if ((unit->GroupId & 1) != 1) {
 	    continue;
 	}
 
-	group=&Groups[num];
-	for( i=0; group->Units[i]!=unit; i++ ) {
+	group = &Groups[num];
+	for (i = 0; group->Units[i] != unit; ++i) {
 	    ;
 	}
 
-	DebugCheck( i>=group->NumUnits );	// oops not found
+	DebugCheck(i >= group->NumUnits);	// oops not found
 
 	// This is a clean way that will allow us to add a unit
 	// to a group easily, or make an easy array walk...
-	if( i<--group->NumUnits ) {
-	    group->Units[i]=group->Units[group->NumUnits];
+	if (i < --group->NumUnits) {
+	    group->Units[i] = group->Units[group->NumUnits];
 	}
     }
 }
@@ -236,21 +236,21 @@ global void RemoveUnitFromGroups(Unit *unit)
 **	@param num	Number of units in group
 **	@param units	Units in group
 */
-local SCM CclGroup(SCM group,SCM num,SCM units)
+local SCM CclGroup(SCM group, SCM num, SCM units)
 {
     int i;
     UnitGroup* grp;
 
-    grp=&Groups[gh_scm2int(group)];
-    grp->NumUnits=gh_scm2int(num);
-    i=0;
-    while( !gh_null_p(units) ) {
+    grp = &Groups[gh_scm2int(group)];
+    grp->NumUnits = gh_scm2int(num);
+    i = 0;
+    while (!gh_null_p(units)) {
 	char* str;
 
-	str=gh_scm2newstr(gh_car(units),NULL);
-	grp->Units[i++]=(Unit*)strtol(str+1,NULL,16);
+	str = gh_scm2newstr(gh_car(units), NULL);
+	grp->Units[i++] = (Unit*)strtol(str + 1, NULL, 16);
 	free(str);
-	units=gh_cdr(units);
+	units = gh_cdr(units);
     }
 
     return SCM_UNSPECIFIED;
@@ -261,7 +261,7 @@ local SCM CclGroup(SCM group,SCM num,SCM units)
 */
 global void GroupCclRegister(void)
 {
-    gh_new_procedure3_0("group",CclGroup);
+    gh_new_procedure3_0("group", CclGroup);
 }
 
 //@}
diff --git a/src/stratagus/iolib.cpp b/src/stratagus/iolib.cpp
index 44543a92e..74f620fa3 100644
--- a/src/stratagus/iolib.cpp
+++ b/src/stratagus/iolib.cpp
@@ -74,15 +74,15 @@
 **	@param offset	Seek position
 **	@param whence	How to seek
 */
-local int gzseek(CLFile* file,unsigned offset,int whence)
+local int gzseek(CLFile* file, unsigned offset, int whence)
 {
     char buf[32];
 
-    while( offset>sizeof(buf) ) {
-	gzread(file,buf,sizeof(buf));
-	offset-=sizeof(buf);
+    while (offset > sizeof(buf)) {
+	gzread(file, buf, sizeof(buf));
+	offset -= sizeof(buf);
     }
-    return gzread(file,buf,offset);
+    return gzread(file, buf, offset);
 }
 
 #endif	// } ZLIB_VERSION<="1.0.4"
@@ -106,43 +106,19 @@ local int gzseek(CLFile* file,unsigned offset,int whence)
 **	@param offset	Seek position
 **	@param whence	How to seek
 */
-local void bzseek(BZFILE* file,unsigned offset,int whence __attribute__((unused)))
+local void bzseek(BZFILE* file, unsigned offset, int whence __attribute__((unused)))
 {
     char buf[32];
 
-    while( offset>sizeof(buf) ) {
-	bzread(file,buf,sizeof(buf));
-	offset-=sizeof(buf);
+    while (offset > sizeof(buf)) {
+	bzread(file, buf, sizeof(buf));
+	offset -= sizeof(buf);
     }
-    bzread(file,buf,offset);
+    bzread(file, buf, offset);
 }
 
 #endif	// USE_BZ2LIB
 
-#ifdef USE_ZZIPLIB
-
-#if 0
-/**
-**	Seek on compressed input. (I hope newer libs support it directly)
-**
-**	@param file	File handle
-**	@param offset	Seek position
-**	@param whence	How to seek
-*/
-local void zzip_seek(ZZIP_FILE* file,unsigned offset,int whence __attribute__((unused)))
-{
-    char buf[32];
-
-    while( offset>sizeof(buf) ) {
-	zzip_read(file,buf,sizeof(buf));
-	offset-=sizeof(buf);
-    }
-    zzip_read(file,buf,offset);
-}
-#endif
-
-#endif	// USE_ZZIPLIB
-
 #if defined(USE_ZLIB) || defined(USE_BZ2LIB) || defined(USE_ZZIPLIB)
 
 /**
@@ -153,17 +129,18 @@ local void zzip_seek(ZZIP_FILE* file,unsigned offset,int whence __attribute__((u
 **
 **	@return			File Pointer
 */
-global CLFile *CLopen(const char *fn,long openflags)
+global CLFile* CLopen(const char* fn, long openflags)
 {
     CLFile clf;
-    CLFile *result;
+    CLFile* result;
     char buf[512];
     char openstring[5];
-    if ( (openflags&CL_OPEN_READ) && (openflags&CL_OPEN_WRITE) ) {
-	strcpy(openstring,"rwb");
-    } else if (openflags&CL_OPEN_READ) {
-	strcpy(openstring,"rb");
-    } else if (openflags&CL_OPEN_WRITE) {
+
+    if ((openflags & CL_OPEN_READ) && (openflags & CL_OPEN_WRITE)) {
+	strcpy(openstring, "rwb");
+    } else if (openflags &CL_OPEN_READ) {
+	strcpy(openstring, "rb");
+    } else if (openflags & CL_OPEN_WRITE) {
 	strcpy(openstring,"wb");
     } else {
 	DebugLevel0("Bad CLopen flags");
@@ -173,36 +150,36 @@ global CLFile *CLopen(const char *fn,long openflags)
 
     clf.cl_type = CLF_TYPE_INVALID;
 
-    if (openflags&CL_OPEN_WRITE) {
+    if (openflags & CL_OPEN_WRITE) {
 #ifdef USE_BZ2LIB
-	if ( (openflags&CL_WRITE_BZ2) &&
-		( clf.cl_bz = bzopen(strcat(strcpy(buf,fn),".bz2"), openstring)) ) {
+	if ((openflags & CL_WRITE_BZ2) &&
+		(clf.cl_bz = bzopen(strcat(strcpy(buf, fn), ".bz2"), openstring))) {
 	    clf.cl_type = CLF_TYPE_BZIP2;
 	} else
 #endif
 #ifdef USE_ZLIB
-	if ( (openflags&CL_WRITE_GZ) &&
-	    	( clf.cl_gz = gzopen(strcat(strcpy(buf,fn),".gz"), openstring)) ) {
-	    clf.cl_type = CLF_TYPE_GZIP;		
+	if ((openflags & CL_WRITE_GZ) &&
+	    	(clf.cl_gz = gzopen(strcat(strcpy(buf, fn), ".gz"), openstring))) {
+	    clf.cl_type = CLF_TYPE_GZIP;
 	} else
 #endif
-	if  ((clf.cl_plain = fopen(fn,openstring))) {
+	if ((clf.cl_plain = fopen(fn, openstring))) {
 	    clf.cl_type = CLF_TYPE_PLAIN;
 	}
     } else {
 	if (!(clf.cl_plain = fopen(fn, openstring))) {		// try plain first
 #ifdef USE_ZLIB
-	    if ((clf.cl_gz = gzopen(strcat(strcpy(buf,fn),".gz"), "rb"))) {
+	    if ((clf.cl_gz = gzopen(strcat(strcpy(buf, fn), ".gz"), "rb"))) {
 		clf.cl_type = CLF_TYPE_GZIP;
 	    } else
 #endif
 #ifdef USE_BZ2LIB
-	    if ((clf.cl_bz = bzopen(strcat(strcpy(buf,fn),".bz2"), "rb"))) {
+	    if ((clf.cl_bz = bzopen(strcat(strcpy(buf, fn), ".bz2"), "rb"))) {
 		clf.cl_type = CLF_TYPE_BZIP2;
 	    } else
 #endif
 #ifdef USE_ZZIPLIB
-	    if ((clf.cl_zz = zzip_open(strcpy(buf,fn),O_RDONLY|O_BINARY) )) {
+	    if ((clf.cl_zz = zzip_open(strcpy(buf, fn), O_RDONLY | O_BINARY))) {
 		clf.cl_type = CLF_TYPE_ZZIP;
 	    } else
 #endif
@@ -244,12 +221,12 @@ global CLFile *CLopen(const char *fn,long openflags)
     }
 
     if (clf.cl_type == CLF_TYPE_INVALID) {
-	//fprintf(stderr,"%s in ", buf);
+	//fprintf(stderr, "%s in ", buf);
 	return NULL;
     }
 
     // ok, here we go
-    result = (CLFile *)malloc(sizeof(CLFile));
+    result = (CLFile*)malloc(sizeof(CLFile));
     if (result) {
 	*result = clf;
     }
@@ -261,7 +238,7 @@ global CLFile *CLopen(const char *fn,long openflags)
 **
 **	@param file	CLFile pointer.
 */
-global int CLclose(CLFile *file)
+global int CLclose(CLFile* file)
 {
     int tp;
     int ret;
@@ -303,7 +280,7 @@ global int CLclose(CLFile *file)
 **	@param buf	Pointer to read the data to.
 **	@param len	number of bytes to read.
 */
-global int CLread(CLFile *file, void *buf, size_t len)
+global int CLread(CLFile* file, void* buf, size_t len)
 {
     int tp;
     int ret;
@@ -342,24 +319,24 @@ global int CLread(CLFile *file, void *buf, size_t len)
 **	@param format	String Format.
 **	@param ...	Parameter List.
 */
-global int CLprintf(CLFile *file, char *format, ...)
+global int CLprintf(CLFile* file, char* format, ...)
 {
     int n;
     int size;
     int ret;
     int tp;
-    char *p;
+    char* p;
     va_list ap;
 
-    size=100;
-    ret=-1;
-    if ((p = malloc (size)) == NULL) {
+    size = 100;
+    ret = -1;
+    if ((p = malloc(size)) == NULL) {
 	return -1;
     }
     while (1) {
 	/* Try to print in the allocated space. */
 	va_start(ap, format);
-	n = vsnprintf (p, size, format, ap);
+	n = vsnprintf(p, size, format, ap);
 	va_end(ap);
 	/* If that worked, string was processed. */
 	if (n > -1 && n < size) {
@@ -367,11 +344,11 @@ global int CLprintf(CLFile *file, char *format, ...)
 	}
 	/* Else try again with more space. */
 	if (n > -1) { /* glibc 2.1 */
-	    size = n+1; /* precisely what is needed */
+	    size = n + 1; /* precisely what is needed */
 	} else {           /* glibc 2.0 */
 	    size *= 2;  /* twice the old size */
 	}
-	if ((p = realloc (p, size)) == NULL) {
+	if ((p = realloc(p, size)) == NULL) {
 	    return -1;
 	}
     }
@@ -381,7 +358,7 @@ global int CLprintf(CLFile *file, char *format, ...)
 
     if (file && (tp = file->cl_type) != CLF_TYPE_INVALID) {
 	if (tp == CLF_TYPE_PLAIN) {
-	    ret = fwrite(p,size,1,file->cl_plain);
+	    ret = fwrite(p, size, 1, file->cl_plain);
 	}
 #ifdef USE_ZLIB
 	if (tp == CLF_TYPE_GZIP) {
@@ -414,7 +391,7 @@ global int CLprintf(CLFile *file, char *format, ...)
 **	@param offset	Seek position
 **	@param whence	How to seek
 */
-global int CLseek(CLFile *file, long offset, int whence)
+global int CLseek(CLFile* file, long offset, int whence)
 {
     int tp;
     int ret;
@@ -461,7 +438,7 @@ global int CLseek(CLFile *file, long offset, int whence)
 **
 **	@return		Pointer to buffer.
 */
-global char* LibraryFileName(const char* file,char* buffer)
+global char* LibraryFileName(const char* file, char* buffer)
 {
 #ifdef USE_ZZIPLIB
     ZZIP_FILE* zp;
@@ -471,25 +448,25 @@ global char* LibraryFileName(const char* file,char* buffer)
     //
     //	Absolute path or in current directory.
     //
-    strcpy(buffer,file);
-    if( *buffer=='/' || !access(buffer,R_OK) ) {
+    strcpy(buffer, file);
+    if (*buffer == '/' || !access(buffer, R_OK)) {
 	return buffer;
     }
 #ifdef USE_ZLIB		// gzip or bzip2 in current directory
-    sprintf(buffer,"%s.gz",file);
-    if( !access(buffer,R_OK) ) {
+    sprintf(buffer, "%s.gz", file);
+    if (!access(buffer, R_OK)) {
 	return buffer;
     }
 #endif
 #ifdef USE_BZ2LIB
-    sprintf(buffer,"%s.bz2",file);
-    if( !access(buffer,R_OK) ) {
+    sprintf(buffer, "%s.bz2", file);
+    if (!access(buffer, R_OK)) {
 	return buffer;
     }
 #endif
 #ifdef USE_ZZIPLIB
-    strcpy(buffer,file);
-    if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
+    strcpy(buffer, file);
+    if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
 	zzip_close(zp);
 	return buffer;
     }
@@ -498,74 +475,74 @@ global char* LibraryFileName(const char* file,char* buffer)
     //
     //	Try in map directory
     //
-    if( *CurrentMapPath ) {
+    if (*CurrentMapPath) {
 	DebugLevel3Fn("Map   path: %s\n" _C_ CurrentMapPath);
-	if( *CurrentMapPath=='.' || *CurrentMapPath=='/' ) {
-	    strcpy(buffer,CurrentMapPath);
-	    if( (s=strrchr(buffer,'/')) ) {
-		s[1]='\0';
+	if (*CurrentMapPath == '.' || *CurrentMapPath == '/') {
+	    strcpy(buffer, CurrentMapPath);
+	    if ((s = strrchr(buffer, '/'))) {
+		s[1] = '\0';
 	    }
-	    strcat(buffer,file);
+	    strcat(buffer, file);
 	} else {
-	    strcpy(buffer,StratagusLibPath);
-	    if( *buffer ) {
-		strcat(buffer,"/");
+	    strcpy(buffer, StratagusLibPath);
+	    if (*buffer) {
+		strcat(buffer, "/");
 	    }
-	    strcat(buffer,CurrentMapPath);
-	    if( (s=strrchr(buffer,'/')) ) {
-		s[1]='\0';
+	    strcat(buffer, CurrentMapPath);
+	    if ((s = strrchr(buffer, '/'))) {
+		s[1] = '\0';
 	    }
-	    strcat(buffer,file);
+	    strcat(buffer, file);
 	}
-	if( !access(buffer,R_OK) ) {
+	if (!access(buffer, R_OK)) {
 	    return buffer;
 	}
 
 #ifdef USE_ZLIB		// gzip or bzip2 in map directory directory
-	strcat(buffer,".gz");
-	if( !access(buffer,R_OK) ) {
+	strcat(buffer, ".gz");
+	if (!access(buffer, R_OK)) {
 	    return buffer;
 	}
-	*strrchr(buffer,'.')='\0';
+	*strrchr(buffer, '.') = '\0';
 #endif
 #ifdef USE_BZ2LIB
-	strcat(buffer,".bz2");
-	if( !access(buffer,R_OK) ) {
+	strcat(buffer, ".bz2");
+	if (!access(buffer, R_OK)) {
 	    return buffer;
 	}
-	*strrchr(buffer,'.')='\0';
+	*strrchr(buffer, '.') = '\0';
 #endif
 #ifdef USE_ZZIPLIB
-	if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
+	if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
 	    zzip_close(zp);
 	    return buffer;
 	}
 #endif	// USE_ZZIPLIB
     }
 
-    if( (s = getenv("HOME")) ) {
+    if ((s = getenv("HOME"))) {
 	//
 	//	In user home directory
 	//
-	sprintf(buffer,"%s/%s/%s/%s",s,STRATAGUS_HOME_PATH,GameName,file);
-	if( !access(buffer,R_OK) ) {
+	sprintf(buffer, "%s/%s/%s/%s", s, STRATAGUS_HOME_PATH, GameName, file);
+	if (!access(buffer,R_OK)) {
 	    return buffer;
 	}
 #ifdef USE_ZLIB		// gzip or bzip2 in user home directory
-	sprintf(buffer,"%s/%s/%s/%s.gz",s,STRATAGUS_HOME_PATH,GameName,file);
-	if( !access(buffer,R_OK) ) {
+	sprintf(buffer, "%s/%s/%s/%s.gz", s, STRATAGUS_HOME_PATH, GameName, file);
+	if (!access(buffer, R_OK)) {
 	    return buffer;
 	}
 #endif
 #ifdef USE_BZ2LIB
-	sprintf(buffer,"%s/%s/%s/%s.bz2",s,STRATAGUS_HOME_PATH,GameName,file);
-	if( !access(buffer,R_OK) ) {
+	sprintf(buffer, "%s/%s/%s/%s.bz2", s, STRATAGUS_HOME_PATH, GameName, file);
+	if (!access(buffer, R_OK)) {
 	    return buffer;
 	}
 #endif
 #ifdef USE_ZZIPLIB
-	sprintf(buffer,"%s/%s/%s/%s",s,STRATAGUS_HOME_PATH,GameName,file);
-	if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
+	sprintf(buffer, "%s/%s/%s/%s", s, STRATAGUS_HOME_PATH, GameName, file);
+	if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
 	    zzip_close(zp);
 	    return buffer;
 	}
@@ -575,32 +552,32 @@ global char* LibraryFileName(const char* file,char* buffer)
     //
     //	In global shared directory
     //
-    sprintf(buffer,"%s/%s",StratagusLibPath,file);
-    if( !access(buffer,R_OK) ) {
+    sprintf(buffer, "%s/%s", StratagusLibPath, file);
+    if (!access(buffer, R_OK)) {
 	return buffer;
     }
 #ifdef USE_ZLIB		// gzip or bzip2 in global shared directory
-    sprintf(buffer,"%s/%s.gz",StratagusLibPath,file);
-    if( !access(buffer,R_OK) ) {
+    sprintf(buffer, "%s/%s.gz", StratagusLibPath, file);
+    if (!access(buffer, R_OK)) {
 	return buffer;
     }
 #endif
 #ifdef USE_BZ2LIB
-    sprintf(buffer,"%s/%s.bz2",StratagusLibPath,file);
-    if( !access(buffer,R_OK) ) {
+    sprintf(buffer, "%s/%s.bz2", StratagusLibPath, file);
+    if (!access(buffer, R_OK)) {
 	return buffer;
     }
 #endif
 #ifdef USE_ZZIPLIB
-    sprintf(buffer,"%s/%s",StratagusLibPath,file);
-    if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
+    sprintf(buffer, "%s/%s", StratagusLibPath, file);
+    if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
 	zzip_close(zp);
 	return buffer;
     }
 #endif	// USE_ZZIPLIB
     DebugLevel0Fn("File `%s' not found\n" _C_ file);
 
-    strcpy(buffer,file);
+    strcpy(buffer, file);
     return buffer;
 }
 
@@ -612,10 +589,10 @@ global char* LibraryFileName(const char* file,char* buffer)
 **
 **	@return		v1-v2
 */
-local int flqcmp(const void *v1, const void *v2)
+local int flqcmp(const void* v1, const void* v2)
 {
-    const FileList *c1;
-    const FileList *c2;
+    const FileList* c1;
+    const FileList* c2;
 
     c1 = v1;
     c2 = v2;
@@ -654,18 +631,18 @@ __my_zzip_open_zip(const char* filename, int filemode)
     fd = -1;
     len = strlen(filename);
 #ifdef USE_WIN32
-    if (len+4 < PATH_MAX) {
+    if (len + 4 < PATH_MAX) {
 	strcpy(file, filename);
-	strcpy(file+len, ".zip");
+	strcpy(file + len, ".zip");
 	fd = open(file, filemode);
     }
 #else
     ext = my_zzip_default_fileext;
-    if (len+4 < PATH_MAX) {
-	memcpy(file, filename, len+1);
+    if (len + 4 < PATH_MAX) {
+	memcpy(file, filename, len + 1);
 
-	for ( ; *ext ; ++ext) {
-	    strcpy (file+len, *ext);
+	for (; *ext ; ++ext) {
+	    strcpy(file + len, *ext);
 	    fd = open(file, filemode);
 	    if (fd != -1) {
 		break;
@@ -686,11 +663,11 @@ __my_zzip_open_zip(const char* filename, int filemode)
 **
 **	@return		Pointer to FileList struct describing Files found.
 */
-global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *),FileList **flp)
+global int ReadDataDirectory(const char* dirname, int (*filter)(char*, FileList*), FileList** flp)
 {
 #ifdef USE_ZZIPLIB
-    ZZIP_DIR *dirp = NULL;
-    ZZIP_DIRENT *dp;
+    ZZIP_DIR* dirp = NULL;
+    ZZIP_DIRENT* dp;
     // ATTENTION: valid until end of file!
     #define readdir zzip_readdir
     #define closedir zzip_closedir
@@ -698,11 +675,11 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
     int entvalid;
     char zzbasepath[PATH_MAX];
     struct stat st;
-    char *cp;
+    char* cp;
 #else
 #ifndef _MSC_VER
-    DIR *dirp;
-    struct dirent *dp;
+    DIR* dirp;
+    struct dirent* dp;
 #endif
     struct stat st;
 #endif
@@ -710,13 +687,13 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
     struct _finddata_t fileinfo;
     long hFile;
 #endif
-    FileList *nfl;
-    FileList *fl = NULL;
+    FileList* nfl;
+    FileList* fl = NULL;
     int n;
     int isdir = 0; // silence gcc..
-    char *np;
+    char* np;
     char buffer[PATH_MAX];
-    char *filename;
+    char* filename;
 
     strcpy(buffer, dirname);
     n = strlen(buffer);
@@ -728,15 +705,14 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
     n = 0;
 
 #ifdef USE_ZZIPLIB
-    strcpy (zzbasepath, dirname);
+    strcpy(zzbasepath, dirname);
     /* per each slash in filename, check if it there is a zzip around */
-    while ((cp = strrchr(zzbasepath, '/')))
-    {
+    while ((cp = strrchr(zzbasepath, '/'))) {
 	int fd;
 	zzip_error_t e;
 
 	*cp = '\0'; /* cut at path separator == possible zipfile basename */
-	fd = __my_zzip_open_zip(zzbasepath, O_RDONLY|O_BINARY);
+	fd = __my_zzip_open_zip(zzbasepath, O_RDONLY | O_BINARY);
 	if (fd != -1) {
 	    /* found zip-file, now open it */
 	    dirp = zzip_dir_fdopen(fd, &e);
@@ -757,7 +733,7 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
 	// and we want it vice versa in this special case. Otherwise it would not
 	// match the path separator backtrace above, which relies on recursive
 	// __zip_open_dir(). __zip_open_dir() only detects zipfiles, not real dirs!
-	fd = __my_zzip_open_zip(dirname, O_RDONLY|O_BINARY);
+	fd = __my_zzip_open_zip(dirname, O_RDONLY | O_BINARY);
 	if (fd == -1) {
 	    dirp = zzip_opendir(dirname);
 	    zzbasepath[0] = 0;
@@ -768,14 +744,16 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
 		close(fd);
 		dirp = NULL;
 	    } else {
-		strcpy (zzbasepath, dirname);
+		strcpy(zzbasepath, dirname);
 	    }
-	    DebugLevel3Fn("zzbasepath `%s', dirname `%s'\n"
-		_C_ zzbasepath _C_ dirname);
+	    DebugLevel3Fn("zzbasepath `%s', dirname `%s'\n" _C_
+		zzbasepath _C_ dirname);
 	}
     }
-#ifndef _MSC_VER
-    IfDebug(if (!dirp) { DebugLevel0Fn("Dir `%s' not found\n" _C_ dirname); });
+#if !defined(_MSC_VER) && defined(DEBUG)
+    if (!dirp) {
+	DebugLevel0Fn("Dir `%s' not found\n" _C_ dirname);
+    }
 #endif
 #else
 #ifndef _MSC_VER
@@ -821,10 +799,12 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
 #endif
 #endif
 
-	    if (strcmp(filename, ".") == 0)
+	    if (strcmp(filename, ".") == 0) {
 		continue;
-	    if (strcmp(filename, "..") == 0)
+	    }
+	    if (strcmp(filename, "..") == 0) {
 		continue;
+	    }
 
 	    strcpy(np, filename);
 #ifdef USE_ZZIPLIB
@@ -856,10 +836,10 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
 		    len = strlen(zzbasepath);
 		    isdir = 0;
 		    if (strlen(dirname) > len) {
-			cp = (char *)dirname + len + 1;
+			cp = (char*)dirname + len + 1;
 			len = strlen(cp);
 			if (strlen(filename) >= len && memcmp(filename, cp, len) == 0 &&
-				    filename[len] == '/' && filename[len + 1]) {
+				filename[len] == '/' && filename[len + 1]) {
 			    strcpy(np, filename + len + 1);
 			    goto zzentry;
 			}
@@ -875,7 +855,7 @@ zzentry:
 		    if (cp) {
 			isdir = 1;
 			*cp = 0;
-			for (i = 0; i < n; i++) {
+			for (i = 0; i < n; ++i) {
 			    if (fl[i].type == 0 && strcmp(fl[i].name, np) == 0) {
 				entvalid = 0;	// already there
 				break;
@@ -932,7 +912,7 @@ zzentry:
 			    }
 			}
 		    }
-		    n++;
+		    ++n;
 		}
 	    }
 #ifndef _MSC_VER
@@ -955,7 +935,7 @@ zzentry:
     if (n == 0) {
 	fl = NULL;
     } else {
-	qsort((char *)fl, n, sizeof(FileList), flqcmp);
+	qsort((char*)fl, n, sizeof(FileList), flqcmp);
     }
     *flp = fl;
     return n;
diff --git a/src/stratagus/missile.cpp b/src/stratagus/missile.cpp
index ff4e38bc9..f191c74ef 100644
--- a/src/stratagus/missile.cpp
+++ b/src/stratagus/missile.cpp
@@ -147,7 +147,7 @@ global void LoadMissileSprites(void)
 
 	    buf = alloca(strlen(file) + 9 + 1);
 	    file = strcat(strcpy(buf, "graphics/"), file);
-	    ShowLoadProgress("\tMissile %s\n", file);
+	    ShowLoadProgress("Missile %s", file);
 	    MissileTypes[i].Sprite = LoadSprite(
 		    file, MissileTypes[i].Width, MissileTypes[i].Height);
 
diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp
index 70a89ca5f..51fad046e 100644
--- a/src/stratagus/stratagus.cpp
+++ b/src/stratagus/stratagus.cpp
@@ -256,10 +256,10 @@ local char* MapName;			/// Filename of the map to load
 
 global int SpeedResourcesHarvest[MaxCosts]; /// speed factor for harvesting resources
 global int SpeedResourcesReturn[MaxCosts];  /// speed factor for returning resources
-global int SpeedBuild=SPEED_BUILD;	/// speed factor for building
-global int SpeedTrain=SPEED_TRAIN;	/// speed factor for training
-global int SpeedUpgrade=SPEED_UPGRADE;	/// speed factor for upgrading
-global int SpeedResearch=SPEED_RESEARCH;/// speed factor for researching
+global int SpeedBuild = SPEED_BUILD;	    /// speed factor for building
+global int SpeedTrain = SPEED_TRAIN;	    /// speed factor for training
+global int SpeedUpgrade = SPEED_UPGRADE;    /// speed factor for upgrading
+global int SpeedResearch = SPEED_RESEARCH;  /// speed factor for researching
 
 /*============================================================================
 ==	DISPLAY
@@ -275,8 +275,8 @@ global unsigned long FrameCounter;	/// Current frame number
 global int SlowFrameCounter;		/// Profile, frames out of sync
 
 // FIXME: not the correct place
-global int MustRedraw=RedrawEverything;	/// Redraw flags
-global int EnableRedraw=RedrawEverything;/// Enable flags
+global int MustRedraw = RedrawEverything;   /// Redraw flags
+global int EnableRedraw = RedrawEverything; /// Enable flags
 
 global unsigned long GameCycle;		/// Game simulation cycle counter
 global unsigned long FastForwardCycle;	/// Cycle to fastforward to in a replay
@@ -378,12 +378,12 @@ global char* strcasestr(const char* a, const char* b)
     x = 0;
     while (*a) {
 	if (a[x] && (tolower(a[x]) == tolower(b[x]))) {
-	    x++;
+	    ++x;
 	} else if (b[x]) {
-	    a++;
+	    ++a;
 	    x = 0;
 	} else {
-	    return (char *)a;
+	    return (char*)a;
 	}
     }
 
@@ -460,7 +460,7 @@ local void WaitCallbackKey(unsigned dummy __attribute__((unused)))
 **	Callback for input.
 */
 local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
-	unsigned dummy2 __attribute__((unused)))
+    unsigned dummy2 __attribute__((unused)))
 {
     DebugLevel3Fn("Pressed %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
     WaitNoEvent=0;
@@ -470,7 +470,7 @@ local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
 **	Callback for input.
 */
 local void WaitCallbackKey3(unsigned dummy1 __attribute__((unused)),
-	unsigned dummy2 __attribute__((unused)))
+    unsigned dummy2 __attribute__((unused)))
 {
     DebugLevel3Fn("Repeated %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
     WaitNoEvent=0;
@@ -482,8 +482,8 @@ local void WaitCallbackKey3(unsigned dummy1 __attribute__((unused)),
 local void WaitCallbackMouse(int x, int y)
 {
     DebugLevel3Fn("Moved %d,%d\n" _C_ x _C_ y);
-    WaitMouseX=x;
-    WaitMouseY=y;
+    WaitMouseX = x;
+    WaitMouseY = y;
 }
 
 /**
@@ -509,34 +509,34 @@ local void VideoEffect0(int frame, const EventCallback* callbacks)
     //
     //	Cleanup
     //
-    if( frame==-1 ) {
+    if (frame == -1) {
 	VideoFree(Logo);
-	Logo=NULL;
+	Logo = NULL;
 	return;
     }
 
     //
     //	Inititialize
     //
-    if( !Logo ) {
-	Logo=LoadSprite("stratagus.png",628,141);
+    if (!Logo) {
+	Logo = LoadSprite("stratagus.png", 628, 141);
     }
     VideoLockScreen();
 
-    switch( VideoDepth ) {
+    switch (VideoDepth) {
 	case 15:
 	case 16:
-	    for( i=0; i<VideoWidth*VideoHeight; ++i ) {
+	    for (i = 0; i < VideoWidth * VideoHeight; ++i) {
 		int j;
 
-		j=MyRand()&0x1F;
-		VideoMemory16[i]=(j<<11)|(j<<6)|(j);
+		j = MyRand() & 0x1F;
+		VideoMemory16[i] = (j << 11) | (j << 6) | (j);
 	    }
 	    break;
     }
 
-    VideoDrawTextCentered(VideoWidth/2,5,LargeFont,"Press SPACE to continue.");
-    VideoDraw(Logo,0,(VideoWidth-VideoGraphicWidth(Logo))/2,50);
+    VideoDrawTextCentered(VideoWidth / 2, 5, LargeFont, "Press SPACE to continue.");
+    VideoDraw(Logo, 0, (VideoWidth - VideoGraphicWidth(Logo)) / 2, 50);
 
     VideoUnlockScreen();
 
@@ -557,7 +557,7 @@ local void VideoEffect0(int frame, const EventCallback* callbacks)
 **
 **	@note if you like optimize play here.
 */
-global void EffectDrawCircle(int* ptr,int depth,int x,int y,int r)
+global void EffectDrawCircle(int* ptr, int depth, int x, int y, int r)
 {
     int cx;
     int cy;
@@ -565,52 +565,53 @@ global void EffectDrawCircle(int* ptr,int depth,int x,int y,int r)
     int d_e;
     int d_se;
 
-    cx=0;
-    cy=r;
-    df=1-r;
-    d_e=3;
-    d_se=-2*r+5;
+    cx = 0;
+    cy = r;
+    df = 1 - r;
+    d_e = 3;
+    d_se = -2 * r + 5;
 
-#define EffectDrawPixel(depth,x,y) \
+#define EffectDrawPixel(depth, x, y) \
     do {								\
-	if( 0<(x) && (x)<VideoWidth-1 && 0<(y) && (y)<VideoHeight-1 ) {	\
-	    ptr[(x)+(y)*VideoWidth]+=depth;				\
+	if (0 < (x) && (x) < VideoWidth - 1 &&				\
+		0 < (y) && (y) < VideoHeight - 1) {			\
+	    ptr[(x) + (y) * VideoWidth] += depth;			\
 	}								\
-    } while( 0 )
+    } while(0)
 
     do {
-	if( !cx ) {
-	    EffectDrawPixel(depth,x,y+cy);
-	    EffectDrawPixel(depth,x,y-cy);
-	    EffectDrawPixel(depth,x+cy,y);
-	    EffectDrawPixel(depth,x-cy,y);
-	} else if ( cx==cy ) {
-	    EffectDrawPixel(depth,x+cx,y+cy);
-	    EffectDrawPixel(depth,x-cx,y+cy);
-	    EffectDrawPixel(depth,x+cx,y-cy);
-	    EffectDrawPixel(depth,x-cx,y-cy);
-	} else if ( cx<cy ) {
-	    EffectDrawPixel(depth,x+cx,y+cy);
-	    EffectDrawPixel(depth,x+cx,y-cy);
-	    EffectDrawPixel(depth,x+cy,y+cx);
-	    EffectDrawPixel(depth,x+cy,y-cx);
-	    EffectDrawPixel(depth,x-cx,y+cy);
-	    EffectDrawPixel(depth,x-cx,y-cy);
-	    EffectDrawPixel(depth,x-cy,y+cx);
-	    EffectDrawPixel(depth,x-cy,y-cx);
+	if (!cx) {
+	    EffectDrawPixel(depth, x, y + cy);
+	    EffectDrawPixel(depth, x, y - cy);
+	    EffectDrawPixel(depth, x + cy, y);
+	    EffectDrawPixel(depth, x - cy, y);
+	} else if (cx == cy) {
+	    EffectDrawPixel(depth, x + cx, y + cy);
+	    EffectDrawPixel(depth, x - cx, y + cy);
+	    EffectDrawPixel(depth, x + cx, y - cy);
+	    EffectDrawPixel(depth, x - cx, y - cy);
+	} else if (cx < cy) {
+	    EffectDrawPixel(depth, x + cx, y + cy);
+	    EffectDrawPixel(depth, x + cx, y - cy);
+	    EffectDrawPixel(depth, x + cy, y + cx);
+	    EffectDrawPixel(depth, x + cy, y - cx);
+	    EffectDrawPixel(depth, x - cx, y + cy);
+	    EffectDrawPixel(depth, x - cx, y - cy);
+	    EffectDrawPixel(depth, x - cy, y + cx);
+	    EffectDrawPixel(depth, x - cy, y - cx);
 	}
-	if( df<0 ) {
-	    df+=d_e;
-	    d_se+=2;
+	if (df < 0) {
+	    df += d_e;
+	    d_se += 2;
 	} else {
-	    df+=d_se;
-	    d_se+=4;
-	    cy--;
+	    df += d_se;
+	    d_se += 4;
+	    --cy;
 	}
-	d_e+=2;
-	cx++;
+	d_e += 2;
+	++cx;
 
-    } while( cx <= cy );
+    } while (cx <= cy);
 }
 
 /**
@@ -621,14 +622,14 @@ global void EffectDrawCircle(int* ptr,int depth,int x,int y,int r)
 */
 #ifdef USE_OPENGL
 local void VideoEffect0(int frame __attribute__((unused)),
-	const EventCallback* callbacks __attribute__((unused)))
+    const EventCallback* callbacks __attribute__((unused)))
 {
 }
 
 #else
 
 local void VideoEffect0(int frame,
-	const EventCallback* callbacks __attribute__((unused)))
+    const EventCallback* callbacks __attribute__((unused)))
 {
     static int* buf1;
     static int* buf2;
@@ -640,48 +641,48 @@ local void VideoEffect0(int frame,
     //
     //	Cleanup
     //
-    if( frame==-1 ) {
+    if (frame == -1) {
 	free(buf1);
 	free(buf2);
 	free(vmem);
-	vmem=buf1=buf2=NULL;
+	vmem = buf1 = buf2 = NULL;
 	return;
     }
 
     //
     //	Inititialize
     //
-    if( !buf1 ) {
-	buf1=calloc(VideoWidth*VideoHeight,sizeof(int));
-	buf2=calloc(VideoWidth*VideoHeight,sizeof(int));
+    if (!buf1) {
+	buf1 = calloc(VideoWidth * VideoHeight, sizeof(int));
+	buf2 = calloc(VideoWidth * VideoHeight, sizeof(int));
 	VideoLockScreen();
-	switch( VideoBpp ) {
+	switch (VideoBpp) {
 	    case 15:
 	    case 16:
-		vmem=malloc(VideoWidth*VideoHeight*sizeof(VMemType16));
-		memcpy(vmem,VideoMemory,VideoWidth*VideoHeight*sizeof(VMemType16));
+		vmem = malloc(VideoWidth * VideoHeight * sizeof(VMemType16));
+		memcpy(vmem, VideoMemory, VideoWidth * VideoHeight * sizeof(VMemType16));
 		break;
 	    case 24:
-		vmem=malloc(VideoWidth*VideoHeight*sizeof(VMemType24));
-		memcpy(vmem,VideoMemory,VideoWidth*VideoHeight*sizeof(VMemType24));
+		vmem = malloc(VideoWidth * VideoHeight * sizeof(VMemType24));
+		memcpy(vmem, VideoMemory, VideoWidth * VideoHeight * sizeof(VMemType24));
 		break;
 	    case 32:
-		vmem=malloc(VideoWidth*VideoHeight*sizeof(VMemType32));
-		memcpy(vmem,VideoMemory,VideoWidth*VideoHeight*sizeof(VMemType32));
+		vmem = malloc(VideoWidth * VideoHeight * sizeof(VMemType32));
+		memcpy(vmem, VideoMemory, VideoWidth * VideoHeight * sizeof(VMemType32));
 		break;
 	}
 	VideoUnlockScreen();
 
-	if( 1 ) {
-	    for( y=1; y<VideoHeight-1; y+=16 ) {
-		for( x=1; x<VideoWidth-1; x+=16 ) {
-		    buf1[y*VideoWidth+x] = (rand()%10)*20;
+	if (1) {
+	    for (y = 1; y < VideoHeight - 1; y += 16) {
+		for (x = 1; x < VideoWidth - 1; x += 16) {
+		    buf1[y * VideoWidth + x] = (rand() % 10) * 20;
 		}
 	    }
 	}
-	if( 0 ) {
-	    for( x=1; x<VideoWidth-1; ++x ) {
-		buf2[(VideoHeight-1)*VideoWidth+x] = !(x%20)*-100;
+	if (0) {
+	    for (x = 1; x < VideoWidth - 1; ++x) {
+		buf2[(VideoHeight - 1) * VideoWidth + x] = !(x % 20) * -100;
 	    }
 	}
     }
@@ -689,45 +690,46 @@ local void VideoEffect0(int frame,
     //
     //	Generate waves
     //
-    for( y=1; y<VideoHeight-1; ++y ) {
-	for( x=1; x<VideoWidth-1; ++x ) {
+    for (y = 1; y < VideoHeight - 1; ++y) {
+	for (x = 1; x < VideoWidth - 1; ++x) {
 	    int i;
 
-	    i = ((buf1[y*VideoWidth+x-1]+
-		buf1[y*VideoWidth+x+1]+
-		buf1[y*VideoWidth-VideoWidth+x]+
-		buf1[y*VideoWidth+VideoWidth+x])>>1) - buf2[y*VideoWidth+x];
-	    buf2[y*VideoWidth+x] = i - (i >> 7);
+	    i = ((buf1[y * VideoWidth + x - 1] +
+		buf1[y * VideoWidth + x + 1] +
+		buf1[y * VideoWidth - VideoWidth + x] +
+		buf1[y * VideoWidth + VideoWidth + x]) >> 1) -
+		buf2[y * VideoWidth + x];
+	    buf2[y * VideoWidth + x] = i - (i >> 7);
 	}
     }
 
     //
     //	Add mouse
     //
-    if( WaitMouseY && WaitMouseX
-	    && WaitMouseX!=VideoWidth-1 && WaitMouseY!=VideoHeight-1 ) {
-	EffectDrawCircle(buf2,10,WaitMouseX,WaitMouseY,10);
-	//buf2[WaitMouseY*VideoWidth+WaitMouseX]-=100;
+    if (WaitMouseY && WaitMouseX &&
+	    WaitMouseX != VideoWidth - 1 && WaitMouseY != VideoHeight - 1) {
+	EffectDrawCircle(buf2, 10, WaitMouseX, WaitMouseY, 10);
+	//buf2[WaitMouseY * VideoWidth + WaitMouseX] -= 100;
     }
     //
     //	Random drops
     //
-    if( 0 ) {
-	EffectDrawCircle(buf2,20,rand()%(VideoWidth-1),rand()%(VideoHeight-1),
-	    rand()%7);
+    if (0) {
+	EffectDrawCircle(buf2, 20, rand() % (VideoWidth - 1),
+	    rand() % (VideoHeight - 1), rand() % 7);
     }
 
     //
     //	Draw it
     //
     VideoLockScreen();
-    for( y=1; y<VideoHeight-1; ++y ) {
+    for (y = 1; y < VideoHeight - 1; ++y) {
 #ifdef WITH_ARTSC
 	if (ArtsGetSpace() >= 1024) {
 	    callbacks->SoundReady();
 	}
 #endif
-	for( x=1; x<VideoWidth-1; ++x ) {
+	for (x = 1; x < VideoWidth - 1; ++x) {
 	    int xo;
 	    int yo;
 	    int xt;
@@ -736,100 +738,108 @@ local void VideoEffect0(int frame,
 	    VMemType24 pixel24;
 	    VMemType32 pixel32;
 
-	    xo=buf2[y*VideoWidth+x-1] - buf2[y*VideoWidth+x+1];
-	    yo=buf2[y*VideoWidth-VideoWidth+x] -
-		    buf2[y*VideoWidth+VideoWidth+x];
+	    xo = buf2[y * VideoWidth + x - 1] - buf2[y * VideoWidth + x + 1];
+	    yo = buf2[y * VideoWidth - VideoWidth + x] -
+		    buf2[y * VideoWidth + VideoWidth + x];
 
-	    xt=x+xo;
-	    if( xt<0 ) {
-		xt=0;
-	    } else if( xt>=VideoWidth ) {
-		xt=VideoWidth-1;
+	    xt = x + xo;
+	    if (xt < 0) {
+		xt = 0;
+	    } else if (xt >= VideoWidth) {
+		xt = VideoWidth - 1;
 	    }
-	    yt=y+yo;
-	    if( yt<0 ) {
-		yt=0;
-	    } else if( yt>=VideoHeight ) {
-		yt=VideoHeight-1;
+	    yt = y + yo;
+	    if (yt < 0) {
+		yt = 0;
+	    } else if (yt >= VideoHeight) {
+		yt = VideoHeight - 1;
 	    }
 
-	    switch( VideoDepth ) {
+	    switch (VideoDepth) {
 		case 15:
-		    pixel16=((VMemType16*)vmem)[xt+yt*VideoWidth];
-		    if( xo ) {		// Shading
-			int r,g,b;
+		    pixel16 = ((VMemType16*)vmem)[xt + yt * VideoWidth];
+		    if (xo) {		// Shading
+			int r;
+			int g;
+			int b;
 
-			r=(pixel16>>0)&0x1F;
-			g=(pixel16>>5)&0x1F;
-			b=(pixel16>>10)&0x1F;
-			r+=xo;
-			g+=xo;
-			b+=xo;
-			r= r<0 ? 0 : r>0x1F ? 0x1F : r;
-			g= g<0 ? 0 : g>0x1F ? 0x1F : g;
-			b= b<0 ? 0 : b>0x1F ? 0x1F : b;
-			pixel16=r|(g<<5)|(b<<10);
+			r = (pixel16 >> 0) & 0x1F;
+			g = (pixel16 >> 5) & 0x1F;
+			b = (pixel16 >> 10) & 0x1F;
+			r += xo;
+			g += xo;
+			b += xo;
+			r = r < 0 ? 0 : r > 0x1F ? 0x1F : r;
+			g = g < 0 ? 0 : g > 0x1F ? 0x1F : g;
+			b = b < 0 ? 0 : b > 0x1F ? 0x1F : b;
+			pixel16 = r | (g << 5) | (b << 10);
 		    }
-		    VideoMemory16[x+VideoWidth*y]=pixel16;
+		    VideoMemory16[x + VideoWidth * y] = pixel16;
 		    break;
 		case 16:
-		    pixel16=((VMemType16*)vmem)[xt+yt*VideoWidth];
-		    if( xo ) {		// Shading
-			int r,g,b;
+		    pixel16 = ((VMemType16*)vmem)[xt + yt * VideoWidth];
+		    if (xo) {		// Shading
+			int r;
+			int g;
+			int b;
 
-			r=(pixel16>>0)&0x1F;
-			g=(pixel16>>5)&0x3F;
-			b=(pixel16>>11)&0x1F;
-			r+=xo;
-			g+=xo*2;
-			b+=xo;
-			r= r<0 ? 0 : r>0x1F ? 0x1F : r;
-			g= g<0 ? 0 : g>0x3F ? 0x3F : g;
-			b= b<0 ? 0 : b>0x1F ? 0x1F : b;
-			pixel16=r|(g<<5)|(b<<11);
+			r = (pixel16 >> 0) & 0x1F;
+			g = (pixel16 >> 5) & 0x3F;
+			b = (pixel16 >> 11) & 0x1F;
+			r += xo;
+			g += xo * 2;
+			b += xo;
+			r = r < 0 ? 0 : r > 0x1F ? 0x1F : r;
+			g = g < 0 ? 0 : g > 0x3F ? 0x3F : g;
+			b = b < 0 ? 0 : b > 0x1F ? 0x1F : b;
+			pixel16 = r | (g << 5) | (b << 11);
 		    }
-		    VideoMemory16[x+VideoWidth*y]=pixel16;
+		    VideoMemory16[x + VideoWidth * y] = pixel16;
 		    break;
 		case 24:
-		    if( VideoBpp==24 ) {
-			pixel24=((VMemType24*)vmem)[xt+yt*VideoWidth];
-			if( xo ) {
-			    int r,g,b;
+		    if (VideoBpp == 24) {
+			pixel24 = ((VMemType24*)vmem)[xt + yt * VideoWidth];
+			if (xo) {
+			    int r;
+			    int g;
+			    int b;
 
-			    r=(pixel24.a)&0xFF;
-			    g=(pixel24.b)&0xFF;
-			    b=(pixel24.c)&0xFF;
-			    r+=xo<<3;
-			    g+=xo<<3;
-			    b+=xo<<3;
-			    r= r<0 ? 0 : r>0xFF ? 0xFF : r;
-			    g= g<0 ? 0 : g>0xFF ? 0xFF : g;
-			    b= b<0 ? 0 : b>0xFF ? 0xFF : b;
-			    pixel24.a=r;
-			    pixel24.b=g;
-			    pixel24.c=b;
+			    r = (pixel24.a) & 0xFF;
+			    g = (pixel24.b) & 0xFF;
+			    b = (pixel24.c) & 0xFF;
+			    r += xo << 3;
+			    g += xo << 3;
+			    b += xo << 3;
+			    r = r < 0 ? 0 : r > 0xFF ? 0xFF : r;
+			    g = g < 0 ? 0 : g > 0xFF ? 0xFF : g;
+			    b = b < 0 ? 0 : b > 0xFF ? 0xFF : b;
+			    pixel24.a = r;
+			    pixel24.b = g;
+			    pixel24.c = b;
 			}
-			VideoMemory24[x+VideoWidth*y]=pixel24;
+			VideoMemory24[x + VideoWidth * y] = pixel24;
 			break;
 		    }
 		    // FALL THROUGH
 		case 32:
-		    pixel32=((VMemType32*)vmem)[xt+yt*VideoWidth];
-		    if( xo ) {
-			int r,g,b;
+		    pixel32 = ((VMemType32*)vmem)[xt + yt * VideoWidth];
+		    if (xo) {
+			int r;
+			int g;
+			int b;
 
-			r=(pixel32>>0)&0xFF;
-			g=(pixel32>>8)&0xFF;
-			b=(pixel32>>16)&0xFF;
-			r+=xo<<3;
-			g+=xo<<3;
-			b+=xo<<3;
-			r= r<0 ? 0 : r>0xFF ? 0xFF : r;
-			g= g<0 ? 0 : g>0xFF ? 0xFF : g;
-			b= b<0 ? 0 : b>0xFF ? 0xFF : b;
-			pixel32=r|(g<<8)|(b<<16);
+			r = (pixel32 >> 0) & 0xFF;
+			g = (pixel32 >> 8) & 0xFF;
+			b = (pixel32 >> 16) & 0xFF;
+			r += xo << 3;
+			g += xo << 3;
+			b += xo << 3;
+			r = r < 0 ? 0 : r > 0xFF ? 0xFF : r;
+			g = g < 0 ? 0 : g > 0xFF ? 0xFF : g;
+			b = b < 0 ? 0 : b > 0xFF ? 0xFF : b;
+			pixel32 = r | (g << 8) | (b << 16);
 		    }
-		    VideoMemory32[x+VideoWidth*y]=pixel32;
+		    VideoMemory32[x + VideoWidth * y] = pixel32;
 		    break;
 	    }
 	}
@@ -842,9 +852,9 @@ local void VideoEffect0(int frame,
     //
     //	Swap buffers
     //
-    tmp=buf1;
-    buf1=buf2;
-    buf2=tmp;
+    tmp = buf1;
+    buf1 = buf2;
+    buf2 = tmp;
 }
 #endif
 
@@ -854,47 +864,38 @@ local void VideoEffect0(int frame,
 */
 local void DebugDrawFonts(void)
 {
+    char* text1 = "Stratagus";
+    char* text2 = "~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7"
+	"~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C"
+	"~light-magenta~D~light-cyan~E~light-grey~F";
+    char* text3 = "abdefgABCDEFQ";
+
     VideoLockScreen();
     VideoClearScreen();
 
     PushClipping();
-    SetClipping(0,0,VideoWidth-1,VideoHeight-1);
+    SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
 
-    VideoFillRectangle(ColorWhite,0,0,40,VideoHeight-1);
-    VideoDrawTextClip(8,   0+ 10,SmallFont,"Stratagus");
-    VideoDrawTextClip(8,   0+ 20,SmallFont,
-	"~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7"
-	"~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C"
-	"~light-magenta~D~light-cyan~E~light-grey~F");
-    VideoDrawTextClip(8,   0+ 30,SmallFont,"abdefgABCDEFQ");
+    VideoFillRectangle(ColorWhite, 0, 0, 40, VideoHeight - 1);
+    VideoDrawTextClip(8,   0 + 10, SmallFont, text1);
+    VideoDrawTextClip(8,   0 + 20, SmallFont, text1);
+    VideoDrawTextClip(8,   0 + 30, SmallFont, text3);
 
-    VideoDrawTextClip(8,  40+ 10,GameFont,"Stratagus");
-    VideoDrawTextClip(8,  40+ 25,GameFont,
-	"~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7"
-	"~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C"
-	"~light-magenta~D~light-cyan~E~light-grey~F");
-    VideoDrawTextClip(8,  40+ 40,GameFont,"abdefgABCDEFQ");
+    VideoDrawTextClip(8,  40 + 10, GameFont, text1);
+    VideoDrawTextClip(8,  40 + 25, GameFont, text2);
+    VideoDrawTextClip(8,  40 + 40, GameFont, text3);
 
-    VideoDrawTextClip(8, 100+ 10,LargeFont,"Stratagus");
-    VideoDrawTextClip(8, 100+ 25,LargeFont,
-	"~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7"
-	"~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C"
-	"~light-magenta~D~light-cyan~E~light-grey~F");
-    VideoDrawTextClip(8, 100+ 40,LargeFont,"abdefgABCDEFQ");
+    VideoDrawTextClip(8, 100 + 10, LargeFont, text1);
+    VideoDrawTextClip(8, 100 + 25, LargeFont, text2);
+    VideoDrawTextClip(8, 100 + 40, LargeFont, text3);
 
-    VideoDrawTextClip(8, 160+ 10,SmallTitleFont,"Stratagus");
-    VideoDrawTextClip(8, 160+ 35,SmallTitleFont,
-	"~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7"
-	"~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C"
-	"~light-magenta~D~light-cyan~E~light-grey~F");
-    VideoDrawTextClip(8, 160+ 60,SmallTitleFont,"abdefgABCDEFQ");
+    VideoDrawTextClip(8, 160 + 10, SmallTitleFont, text1);
+    VideoDrawTextClip(8, 160 + 35, SmallTitleFont, text2);
+    VideoDrawTextClip(8, 160 + 60, SmallTitleFont, text3);
 
-    VideoDrawTextClip(8, 260+ 10,LargeTitleFont,"Stratagus");
-    VideoDrawTextClip(8, 260+ 55,LargeTitleFont,
-	"~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7"
-	"~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C"
-	"~light-magenta~D~light-cyan~E~light-grey~F");
-    VideoDrawTextClip(8, 260+ 100,LargeTitleFont,"abdefgABCDEFQ");
+    VideoDrawTextClip(8, 260 + 10, LargeTitleFont, text1);
+    VideoDrawTextClip(8, 260 + 55, LargeTitleFont, text2);
+    VideoDrawTextClip(8, 260 + 100, LargeTitleFont, text3);
 
     PopClipping();
 
@@ -914,51 +915,50 @@ local void WaitForInput(int timeout)
     EventCallback callbacks;
 #ifdef linux
     char* s;
-    char ddate[72+1];
+    char ddate[72 + 1];
     FILE* ddfile;
 #endif
 
     SetVideoSync();
 
-    callbacks.ButtonPressed=WaitCallbackKey;
-    callbacks.ButtonReleased=WaitCallbackKey;
-    callbacks.MouseMoved=WaitCallbackMouse;
-    callbacks.MouseExit=WaitCallbackExit;
-    callbacks.KeyPressed=WaitCallbackKey2;
-    callbacks.KeyReleased=WaitCallbackKey2;
-    callbacks.KeyRepeated=WaitCallbackKey3;
-    callbacks.NetworkEvent=NetworkEvent;
-    callbacks.SoundReady=WriteSound;
+    callbacks.ButtonPressed = WaitCallbackKey;
+    callbacks.ButtonReleased = WaitCallbackKey;
+    callbacks.MouseMoved = WaitCallbackMouse;
+    callbacks.MouseExit = WaitCallbackExit;
+    callbacks.KeyPressed = WaitCallbackKey2;
+    callbacks.KeyReleased = WaitCallbackKey2;
+    callbacks.KeyRepeated = WaitCallbackKey3;
+    callbacks.NetworkEvent = NetworkEvent;
+    callbacks.SoundReady = WriteSound;
 
     //
     //	FIXME: more work needed, scrolling credits, animations, ...
-#ifdef _DEBUG
-    WaitNoEvent=1;
-    while( WaitNoEvent ) {
+#ifdef DEBUG
+    WaitNoEvent = 1;
+    while (WaitNoEvent) {
 	DebugDrawFonts();
 	WaitEventsOneFrame(&callbacks);
     }
 #else
     VideoLockScreen();
-    //VideoDrawTextCentered(VideoWidth/2,5,LargeTitleFont,"Press SPACE to continue.");
-    VideoDrawTextCentered(VideoWidth/2,5,LargeFont,"Press SPACE to continue.");
+    VideoDrawTextCentered(VideoWidth / 2, 5, LargeFont, "Press SPACE to continue.");
 #ifdef linux
-    ddate[0]='\0';
-    ddfile=popen("`which ddate`","r");
-    fgets(ddate,72,ddfile);
+    ddate[0] = '\0';
+    ddfile = popen("`which ddate`", "r");
+    fgets(ddate, 72, ddfile);
     pclose(ddfile);
-    if( (s=strrchr(ddate,'\n')) ) {
-	*s='\0';
+    if ((s = strrchr(ddate, '\n'))) {
+	*s = '\0';
     }
-    VideoDrawTextCentered(VideoWidth/2,20,LargeFont,ddate);
+    VideoDrawTextCentered(VideoWidth / 2, 20, LargeFont, ddate);
 #endif
     VideoUnlockScreen();
     Invalidate();
     RealizeVideoMemory();
 
-    WaitNoEvent=1;
-    timeout*=CYCLES_PER_SECOND;
-    while( timeout-- && WaitNoEvent ) {
+    WaitNoEvent = 1;
+    timeout *= CYCLES_PER_SECOND;
+    while (timeout-- && WaitNoEvent) {
 	VideoEffect0(timeout, &callbacks);
 	WaitEventsOneFrame(&callbacks);
     }
@@ -966,7 +966,7 @@ local void WaitForInput(int timeout)
 #endif
 
     VideoLockScreen();
-    VideoDrawTextCentered(VideoWidth/2,5,LargeFont,
+    VideoDrawTextCentered(VideoWidth / 2, 5, LargeFont,
 	"----------------------------");
     VideoUnlockScreen();
     Invalidate();
@@ -979,27 +979,27 @@ local void WaitForInput(int timeout)
 **
 **	@param fmt	printf format string.
 */
-global void ShowLoadProgress(const char* fmt,...)
+global void ShowLoadProgress(const char* fmt, ...)
 {
     va_list va;
     char temp[4096];
     char* s;
 
-    va_start(va,fmt);
-    vsnprintf(temp,sizeof(temp),fmt,va);
+    va_start(va, fmt);
+    vsnprintf(temp, sizeof(temp), fmt, va);
     va_end(va);
 
-    if( VideoDepth && IsFontLoaded(GameFont) ) {
+    if (VideoDepth && IsFontLoaded(GameFont)) {
 	VideoLockScreen();
-	for( s=temp; *s; ++s ) {	// Remove non printable chars
-	    if( *s<32 ) {
-		*s=' ';
+	for (s = temp; *s; ++s) {	// Remove non printable chars
+	    if (*s < 32) {
+		*s = ' ';
 	    }
 	}
-	VideoFillRectangle(ColorBlack,5,VideoHeight-18,VideoWidth-10,18);
-	VideoDrawTextCentered(VideoWidth/2,VideoHeight-16,GameFont,temp);
+	VideoFillRectangle(ColorBlack, 5, VideoHeight - 18, VideoWidth - 10, 18);
+	VideoDrawTextCentered(VideoWidth / 2, VideoHeight - 16, GameFont, temp);
 	VideoUnlockScreen();
-	InvalidateArea(5,VideoHeight-18,VideoWidth-10,18);
+	InvalidateArea(5, VideoHeight - 18, VideoWidth - 10, 18);
 	RealizeVideoMemory();
     } else {
 	DebugLevel0Fn("!!!!%s" _C_ temp);
@@ -1019,14 +1019,14 @@ global void PreMenuSetup(void)
     //  Initial menus require some gfx.
     //
     // FIXME: must search tileset by identifier or use a gui palette?
-    TheMap.TerrainName=Tilesets[0]->Ident;
+    TheMap.TerrainName = Tilesets[0]->Ident;
     LoadTileset();
-    LoadRGB(GlobalPalette, s=strdcat3(StratagusLibPath,
-	    "/graphics/",Tilesets[0]->PaletteFile));
-    TheMap.TerrainName=NULL;
+    LoadRGB(GlobalPalette, s = strdcat3(StratagusLibPath,
+	"/graphics/", Tilesets[0]->PaletteFile));
+    TheMap.TerrainName = NULL;
     free(s);
     VideoCreatePalette(GlobalPalette);
-    SetDefaultTextColors(FontYellow,FontWhite);
+    SetDefaultTextColors(FontYellow, FontWhite);
 
     LoadFonts();
 
@@ -1052,7 +1052,7 @@ global void PreMenuSetup(void)
 global void MenuLoop(char* filename, WorldMap* map)
 {
 
-    for( ;; ) {
+    for (;;) {
 	//
 	//	Clear screen
 	//
@@ -1065,7 +1065,7 @@ global void MenuLoop(char* filename, WorldMap* map)
 	//
 	//	Network part 1 (port set-up)
 	//
-	if( NetworkFildes!=(Socket)-1 ) {
+	if (NetworkFildes != (Socket)-1) {
 	    ExitNetwork1();
 	}
 	InitNetwork1();
@@ -1081,49 +1081,49 @@ global void MenuLoop(char* filename, WorldMap* map)
 	//
 	//	No filename given, choose with the menus
 	//
-	if ( !filename ) {
+	if (!filename) {
 	    NetPlayers = 0;
 
 	    // Start new music for menus
 	    PlaySectionMusic(PlaySectionMainMenu);
 
-	    EnableRedraw=RedrawMenu;
+	    EnableRedraw = RedrawMenu;
 
 	    GuiGameStarted = 0;
 	    while (GuiGameStarted == 0) {
-		if( EditorRunning == 2 ) {
+		if (EditorRunning == 2) {
 		    SetupEditor();
 		}
-		if( EditorRunning ) {
+		if (EditorRunning) {
 		    ProcessMenu("menu-editor-select", 1);
 		} else {
 		    ProcessMenu("menu-program-start", 1);
 		}
 	    }
 
-	    EnableRedraw=RedrawEverything;
+	    EnableRedraw = RedrawEverything;
 	    DebugLevel0Fn("Menu start: NetPlayers %d\n" _C_ NetPlayers);
 	    filename = CurrentMapPath;
 	} else {
 	    if (EditorRunning) {
 		SetupEditor();
 	    }
-	    strcpy(CurrentMapPath,filename);
+	    strcpy(CurrentMapPath, filename);
 	}
-	if( NetworkFildes!=(Socket)-1 && NetPlayers<2 ) {
+	if (NetworkFildes != (Socket)-1 && NetPlayers < 2) {
 	    ExitNetwork1();
 	}
 
 	//
 	//	Start editor or game.
 	//
-	if( EditorRunning ) {
+	if (EditorRunning) {
 	    EditorMainLoop();
 	} else {
 	    //
 	    //	Create the game.
 	    //
-	    CreateGame(filename,map);
+	    CreateGame(filename, map);
 
 	    SetStatusLine(NameLine);
 	    SetMessage("Do it! Do it now!");
@@ -1141,7 +1141,7 @@ global void MenuLoop(char* filename, WorldMap* map)
 
 	PreMenuSetup();
 
-	filename=NextChapter();
+	filename = NextChapter();
 	DebugLevel0Fn("Next chapter %s\n" _C_ filename);
     }
 }
@@ -1154,7 +1154,7 @@ global void MenuLoop(char* filename, WorldMap* map)
 local void PrintHeader(void)
 {
     // vvv---- looks wired, but is needed for GNU brain damage
-    fprintf(stdout,"%s\n  written by Lutz Sammer, Fabrice Rossi, Vladi Shabanski, Patrice Fortier,\n  Jon Gabrielson, Andreas Arens, Nehal Mistry, Jimmy Salmon and others.\n"
+    fprintf(stdout, "%s\n  written by Lutz Sammer, Fabrice Rossi, Vladi Shabanski, Patrice Fortier,\n  Jon Gabrielson, Andreas Arens, Nehal Mistry, Jimmy Salmon and others.\n"
     "\t(http://Stratagus.Org)"
     "\n  SIOD Copyright by George J. Carrette."
 #ifdef USE_LIBMODPLUG
@@ -1231,7 +1231,7 @@ local void PrintHeader(void)
 #ifdef SLOW_INPUT
     "SLOW-INPUT "
 #endif
-	,NameLine);
+	, NameLine);
 }
 
 /**
@@ -1241,7 +1241,7 @@ local void PrintHeader(void)
 **	@param	argv	Vector of arguments.
 */
 global int main1(int argc __attribute__ ((unused)),
-	char** argv __attribute__ ((unused)))
+    char** argv __attribute__ ((unused)))
 {
     int i;
 
@@ -1259,9 +1259,9 @@ Use it at your own risk.\n\n");
     //
     InitVideo();			// setup video display
 #ifdef WITH_SOUND
-    if( !SoundOff && InitSound() ) {			// setup sound card
-	SoundOff=1;
-	SoundFildes=-1;
+    if (!SoundOff && InitSound()) {			// setup sound card
+	SoundOff = 1;
+	SoundFildes = -1;
     }
 #endif
 
@@ -1274,11 +1274,11 @@ Use it at your own risk.\n\n");
     //
     //	Show title screen.
     //
-    i=1;
-    SetClipping(0,0,VideoWidth-1,VideoHeight-1);
-    if( TitleScreen ) {
-	if( (i=PlayMovie(TitleScreen,
-		PlayMovieZoomScreen|PlayMovieKeepAspect)) ) {
+    i = 1;
+    SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
+    if (TitleScreen) {
+	if ((i = PlayMovie(TitleScreen,
+		PlayMovieZoomScreen | PlayMovieKeepAspect))) {
 	    DisplayPicture(TitleScreen);
 	    Invalidate();
 	}
@@ -1287,11 +1287,11 @@ Use it at your own risk.\n\n");
     InitUnitsMemory();		// Units memory management
     PreMenuSetup();		// Load everything needed for menus
 
-    if( i ) {
-	WaitForInput(20);		// Show game intro
+    if (i) {
+	WaitForInput(20);	// Show game intro
     }
 
-    MenuLoop(MapName,&TheMap);	// Enter the menu loop
+    MenuLoop(MapName, &TheMap);	// Enter the menu loop
 
     return 0;
 }
@@ -1305,12 +1305,12 @@ Use it at your own risk.\n\n");
 */
 global volatile void Exit(int err)
 {
-    IfDebug(
-	extern unsigned PfCounterFail;
-	extern unsigned PfCounterOk;
-	extern unsigned PfCounterDepth;
-	extern unsigned PfCounterNotReachable;
-    );
+#ifdef DEBUG
+    extern unsigned PfCounterFail;
+    extern unsigned PfCounterOk;
+    extern unsigned PfCounterDepth;
+    extern unsigned PfCounterNotReachable;
+#endif
 
     StopMusic();
     QuitSound();
@@ -1318,15 +1318,15 @@ global volatile void Exit(int err)
     NetworkQuit();
 
     ExitNetwork1();
-    IfDebug(
-	DebugLevel0( "Frames %lu, Slow frames %d = %ld%%\n"
-	    _C_ FrameCounter _C_ SlowFrameCounter
-	    _C_ (SlowFrameCounter*100)/(FrameCounter ? FrameCounter : 1) );
-	UnitCacheStatistic();
-	DebugLevel0("Path: Error: %u Unreachable: %u OK: %u Depth: %u\n"
-		_C_ PfCounterFail _C_ PfCounterNotReachable
-		_C_ PfCounterOk _C_ PfCounterDepth);
-    );
+#ifdef DEBUG
+    DebugLevel0("Frames %lu, Slow frames %d = %ld%%\n" _C_
+	FrameCounter _C_ SlowFrameCounter _C_
+	(SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1));
+    UnitCacheStatistic();
+    DebugLevel0("Path: Error: %u Unreachable: %u OK: %u Depth: %u\n" _C_
+	PfCounterFail _C_ PfCounterNotReachable _C_
+	PfCounterOk _C_ PfCounterDepth);
+#endif
 #ifdef DEBUG
     CclUnits();
     CleanModules();
@@ -1335,7 +1335,7 @@ global volatile void Exit(int err)
 
     CleanMovie();
 
-    fprintf(stderr,"Thanks for playing Stratagus.\n");
+    fprintf(stderr, "Thanks for playing Stratagus.\n");
     exit(err);
 }
 
@@ -1390,23 +1390,23 @@ map is relative to StratagusLibPath=datapath, use ./map for relative to cwd\n\
 **	@param	argc	Number of arguments.
 **	@param	argv	Vector of arguments.
 */
-global int main(int argc,char** argv)
+global int main(int argc, char** argv)
 {
 #ifdef USE_BEOS
     //
     //	Parse arguments for BeOS
     //
-    beos_init( argc, argv );
+    beos_init(argc, argv);
 #endif
 
     //
     //	Setup some defaults.
     //
 #ifndef __APPLE__
-    StratagusLibPath=STRATAGUS_LIB_PATH;
+    StratagusLibPath = STRATAGUS_LIB_PATH;
 #endif
-    CclStartFile="ccl/stratagus.ccl";
-    EditorStartFile="ccl/editor.ccl";
+    CclStartFile = "ccl/stratagus.ccl";
+    EditorStartFile = "ccl/editor.ccl";
 
     memset(LocalPlayerName, 0, 16);
     strcpy(LocalPlayerName, "Anonymous");
@@ -1416,65 +1416,65 @@ global int main(int argc,char** argv)
     //
     //	Parse commandline
     //
-    for( ;; ) {
-	switch( getopt(argc,argv,"c:d:ef:hln:P:s:t:v:wD:N:E:FL:S:U:W?") ) {
+    for (;;) {
+	switch (getopt(argc, argv, "c:d:ef:hln:P:s:t:v:wD:N:E:FL:S:U:W?")) {
 	    case 'c':
-		CclStartFile=optarg;
+		CclStartFile = optarg;
 		continue;
             case 'd':
-                StratagusLibPath=optarg;
+                StratagusLibPath = optarg;
                 continue;
 	    case 'e':
-		EditorRunning=2;
+		EditorRunning = 2;
 		continue;
 	    case 'E':
-		EditorStartFile=optarg;
+		EditorStartFile = optarg;
 		continue;
 	    case 'f':
-		AiCostFactor=atoi(optarg);
+		AiCostFactor = atoi(optarg);
 		continue;
 	    case 'l':
-		CommandLogDisabled=1;
+		CommandLogDisabled = 1;
 		continue;
 	    case 'P':
-		NetworkPort=atoi(optarg);
+		NetworkPort = atoi(optarg);
 		continue;
 	    case 'n':
-		NetworkArg=strdup(optarg);
+		NetworkArg = strdup(optarg);
 		continue;
 	    case 'N':
 		memset(LocalPlayerName, 0, 16);
 		strncpy(LocalPlayerName, optarg, 16);
 		continue;
 	    case 's':
-		AiSleepCycles=atoi(optarg);
+		AiSleepCycles = atoi(optarg);
 		continue;
 	    case 't':
-		AiTimeFactor=atoi(optarg);
+		AiTimeFactor = atoi(optarg);
 		continue;
 	    case 'v':
-		switch( atoi(optarg) ) {
+		switch (atoi(optarg)) {
 		    case 0:
 			continue;
 		    case 1:
-			VideoWidth=640;
-			VideoHeight=480;
+			VideoWidth = 640;
+			VideoHeight = 480;
 			continue;
 		    case 2:
-			VideoWidth=800;
-			VideoHeight=600;
+			VideoWidth = 800;
+			VideoHeight = 600;
 			continue;
 		    case 3:
-			VideoWidth=1024;
-			VideoHeight=768;
+			VideoWidth = 1024;
+			VideoHeight = 768;
 			continue;
 		    case 4:
-			VideoWidth=1280;
-			VideoHeight=960;
+			VideoWidth = 1280;
+			VideoHeight = 960;
 			continue;
 		    case 5:
-			VideoWidth=1600;
-			VideoHeight=1200;
+			VideoWidth = 1600;
+			VideoHeight = 1200;
 			continue;
 		    default:
 			Usage();
@@ -1483,32 +1483,32 @@ global int main(int argc,char** argv)
 		continue;
 
 	    case 'w':
-		WaitForSoundDevice=1;
+		WaitForSoundDevice = 1;
 		continue;
 
 	    case 'L':
-		NetworkLag=atoi(optarg);
-		if( !NetworkLag ) {
-		    fprintf(stderr,"FIXME: zero lag not supported\n");
+		NetworkLag = atoi(optarg);
+		if (!NetworkLag) {
+		    fprintf(stderr, "FIXME: zero lag not supported\n");
 		    Usage();
 		    ExitFatal(-1);
 		}
 		continue;
 	    case 'U':
-		NetworkUpdates=atoi(optarg);
+		NetworkUpdates = atoi(optarg);
 		continue;
 
 	    case 'F':
-		VideoFullScreen=1;
+		VideoFullScreen = 1;
 		continue;
 	    case 'W':
-		VideoFullScreen=0;
+		VideoFullScreen = 0;
 		continue;
 	    case 'D':
-		VideoDepth=atoi(optarg);
+		VideoDepth = atoi(optarg);
 		continue;
 	    case 'S':
-		VideoSyncSpeed=atoi(optarg);
+		VideoSyncSpeed = atoi(optarg);
 		continue;
 
 	    case -1:
@@ -1522,21 +1522,21 @@ global int main(int argc,char** argv)
 	break;
     }
 
-    if( argc-optind>1 ) {
-	fprintf(stderr,"too many files\n");
+    if (argc - optind > 1) {
+	fprintf(stderr, "too many files\n");
 	Usage();
 	ExitFatal(-1);
     }
 
-    if( argc-optind ) {
-	MapName=argv[optind];
+    if (argc - optind) {
+	MapName = argv[optind];
 	--argc;
     }
 
     InitCcl();				// init CCL and load configurations!
     LoadCcl();
 
-    main1(argc,argv);
+    main1(argc, argv);
 
     return 0;
 }
diff --git a/src/ui/icons.cpp b/src/ui/icons.cpp
index 60809246e..550813c4c 100644
--- a/src/ui/icons.cpp
+++ b/src/ui/icons.cpp
@@ -210,7 +210,7 @@ global void LoadIcons(void)
 		file = icon->File->FileName;
 		buf = alloca(strlen(file) + 9 + 1);
 		file = strcat(strcpy(buf, "graphics/"), file);
-		ShowLoadProgress("\tIcons %s\n", file);
+		ShowLoadProgress("Icons %s", file);
 		icon->File->Sprite = LoadSprite(file,IconWidth,IconHeight);
 #ifdef USE_OPENGL
 		MakeTexture(icon->File->Sprite, icon->File->Sprite->Width,
diff --git a/src/unit/unit_draw.cpp b/src/unit/unit_draw.cpp
index fb48e37f1..2617cf83a 100644
--- a/src/unit/unit_draw.cpp
+++ b/src/unit/unit_draw.cpp
@@ -114,7 +114,7 @@ global const Viewport* CurrentViewport;	/// FIXME: quick hack for split screen
 */
 local VMemType* SelectionColor(const Unit* unit)
 {
-    if( unit->Selected || (unit->Blink & 1) ) {
+    if (unit->Selected || (unit->Blink & 1)) {
 	if (unit->Player->Player == PlayerNumNeutral) {
 	    return &ColorYellow;
 	}
@@ -305,15 +305,15 @@ global Decoration SpellSprite;
 **	@param w	Mana width.
 **	@param h	Mana height.
 */
-global SCM CclManaSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
+global SCM CclManaSprite(SCM file, SCM x, SCM y, SCM w, SCM h)
 {
     free(ManaSprite.File);
 
-    ManaSprite.File=gh_scm2newstr(file,NULL);
-    ManaSprite.HotX=gh_scm2int(x);
-    ManaSprite.HotY=gh_scm2int(y);
-    ManaSprite.Width=gh_scm2int(w);
-    ManaSprite.Height=gh_scm2int(h);
+    ManaSprite.File = gh_scm2newstr(file, NULL);
+    ManaSprite.HotX = gh_scm2int(x);
+    ManaSprite.HotY = gh_scm2int(y);
+    ManaSprite.Width = gh_scm2int(w);
+    ManaSprite.Height = gh_scm2int(h);
 
     return SCM_UNSPECIFIED;
 }
@@ -327,15 +327,15 @@ global SCM CclManaSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
 **	@param w	Health width.
 **	@param h	Health height.
 */
-global SCM CclHealthSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
+global SCM CclHealthSprite(SCM file, SCM x, SCM y, SCM w, SCM h)
 {
     free(HealthSprite.File);
 
-    HealthSprite.File=gh_scm2newstr(file,NULL);
-    HealthSprite.HotX=gh_scm2int(x);
-    HealthSprite.HotY=gh_scm2int(y);
-    HealthSprite.Width=gh_scm2int(w);
-    HealthSprite.Height=gh_scm2int(h);
+    HealthSprite.File = gh_scm2newstr(file, NULL);
+    HealthSprite.HotX = gh_scm2int(x);
+    HealthSprite.HotY = gh_scm2int(y);
+    HealthSprite.Width = gh_scm2int(w);
+    HealthSprite.Height = gh_scm2int(h);
 
     return SCM_UNSPECIFIED;
 }
@@ -349,15 +349,15 @@ global SCM CclHealthSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
 **	@param w	Shadow width.
 **	@param h	Shadow height.
 */
-global SCM CclShadowSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
+global SCM CclShadowSprite(SCM file, SCM x, SCM y, SCM w, SCM h)
 {
     free(ShadowSprite.File);
 
-    ShadowSprite.File=gh_scm2newstr(file,NULL);
-    ShadowSprite.HotX=gh_scm2int(x);
-    ShadowSprite.HotY=gh_scm2int(y);
-    ShadowSprite.Width=gh_scm2int(w);
-    ShadowSprite.Height=gh_scm2int(h);
+    ShadowSprite.File = gh_scm2newstr(file, NULL);
+    ShadowSprite.HotX = gh_scm2int(x);
+    ShadowSprite.HotY = gh_scm2int(y);
+    ShadowSprite.Width = gh_scm2int(w);
+    ShadowSprite.Height = gh_scm2int(h);
 
     return SCM_UNSPECIFIED;
 }
@@ -371,15 +371,15 @@ global SCM CclShadowSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
 **	@param w	Spell width.
 **	@param h	Spell height.
 */
-global SCM CclSpellSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
+global SCM CclSpellSprite(SCM file, SCM x, SCM y, SCM w, SCM h)
 {
     free(SpellSprite.File);
 
-    SpellSprite.File=gh_scm2newstr(file,NULL);
-    SpellSprite.HotX=gh_scm2int(x);
-    SpellSprite.HotY=gh_scm2int(y);
-    SpellSprite.Width=gh_scm2int(w);
-    SpellSprite.Height=gh_scm2int(h);
+    SpellSprite.File = gh_scm2newstr(file, NULL);
+    SpellSprite.HotX = gh_scm2int(x);
+    SpellSprite.HotY = gh_scm2int(y);
+    SpellSprite.Width = gh_scm2int(w);
+    SpellSprite.Height = gh_scm2int(h);
 
     return SCM_UNSPECIFIED;
 }
@@ -389,8 +389,8 @@ global SCM CclSpellSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
 */
 local SCM CclShowHealthBar(void)
 {
-    ShowHealthBar=1;
-    ShowHealthDot=0;
+    ShowHealthBar = 1;
+    ShowHealthDot = 0;
 
     return SCM_UNSPECIFIED;
 }
@@ -400,8 +400,8 @@ local SCM CclShowHealthBar(void)
 */
 local SCM CclShowHealthDot(void)
 {
-    ShowHealthBar=0;
-    ShowHealthDot=1;
+    ShowHealthBar = 0;
+    ShowHealthDot = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -411,9 +411,9 @@ local SCM CclShowHealthDot(void)
 */
 local SCM CclShowHealthHorizontal(void)
 {
-    ShowHealthBar=1;
-    ShowHealthDot=0;
-    ShowHealthHorizontal=1;
+    ShowHealthBar = 1;
+    ShowHealthDot = 0;
+    ShowHealthHorizontal = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -423,9 +423,9 @@ local SCM CclShowHealthHorizontal(void)
 */
 local SCM CclShowHealthVertical(void)
 {
-    ShowHealthBar=1;
-    ShowHealthDot=0;
-    ShowHealthHorizontal=0;
+    ShowHealthBar = 1;
+    ShowHealthDot = 0;
+    ShowHealthHorizontal = 0;
 
     return SCM_UNSPECIFIED;
 }
@@ -435,8 +435,8 @@ local SCM CclShowHealthVertical(void)
 */
 local SCM CclShowManaBar(void)
 {
-    ShowManaBar=1;
-    ShowManaDot=0;
+    ShowManaBar = 1;
+    ShowManaDot = 0;
 
     return SCM_UNSPECIFIED;
 }
@@ -446,8 +446,8 @@ local SCM CclShowManaBar(void)
 */
 local SCM CclShowManaDot(void)
 {
-    ShowManaBar=0;
-    ShowManaDot=1;
+    ShowManaBar = 0;
+    ShowManaDot = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -457,7 +457,7 @@ local SCM CclShowManaDot(void)
 */
 local SCM CclShowEnergySelected(void)
 {
-    ShowEnergySelectedOnly=1;
+    ShowEnergySelectedOnly = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -468,7 +468,7 @@ local SCM CclShowEnergySelected(void)
 */
 local SCM CclShowFull(void)
 {
-    ShowNoFull=0;
+    ShowNoFull = 0;
 
     return SCM_UNSPECIFIED;
 }
@@ -478,9 +478,9 @@ local SCM CclShowFull(void)
 */
 local SCM CclShowManaHorizontal(void)
 {
-    ShowManaBar=1;
-    ShowManaDot=0;
-    ShowManaHorizontal=1;
+    ShowManaBar = 1;
+    ShowManaDot = 0;
+    ShowManaHorizontal = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -490,9 +490,9 @@ local SCM CclShowManaHorizontal(void)
 */
 local SCM CclShowManaVertical(void)
 {
-    ShowManaBar=1;
-    ShowManaDot=0;
-    ShowManaHorizontal=0;
+    ShowManaBar = 1;
+    ShowManaDot = 0;
+    ShowManaHorizontal = 0;
 
     return SCM_UNSPECIFIED;
 }
@@ -502,7 +502,7 @@ local SCM CclShowManaVertical(void)
 */
 local SCM CclShowNoFull(void)
 {
-    ShowNoFull=1;
+    ShowNoFull = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -512,7 +512,7 @@ local SCM CclShowNoFull(void)
 */
 local SCM CclDecorationOnTop(void)
 {
-    DecorationOnTop=1;
+    DecorationOnTop = 1;
 
     return SCM_UNSPECIFIED;
 }
@@ -522,26 +522,26 @@ local SCM CclDecorationOnTop(void)
 */
 global void DecorationCclRegister(void)
 {
-    gh_new_procedure5_0("mana-sprite",CclManaSprite);
-    gh_new_procedure5_0("health-sprite",CclHealthSprite);
-    gh_new_procedure5_0("shadow-sprite",CclShadowSprite);
-    gh_new_procedure5_0("spell-sprite",CclSpellSprite);
+    gh_new_procedure5_0("mana-sprite", CclManaSprite);
+    gh_new_procedure5_0("health-sprite", CclHealthSprite);
+    gh_new_procedure5_0("shadow-sprite", CclShadowSprite);
+    gh_new_procedure5_0("spell-sprite", CclSpellSprite);
 
-    gh_new_procedure0_0("show-health-bar",CclShowHealthBar);
-    gh_new_procedure0_0("show-health-dot",CclShowHealthDot);
+    gh_new_procedure0_0("show-health-bar", CclShowHealthBar);
+    gh_new_procedure0_0("show-health-dot", CclShowHealthDot);
 // adicionado por protoman
-    gh_new_procedure0_0("show-health-vertical",CclShowHealthVertical);
-    gh_new_procedure0_0("show-health-horizontal",CclShowHealthHorizontal);
-    gh_new_procedure0_0("show-mana-vertical",CclShowManaVertical);
-    gh_new_procedure0_0("show-mana-horizontal",CclShowManaHorizontal);
+    gh_new_procedure0_0("show-health-vertical", CclShowHealthVertical);
+    gh_new_procedure0_0("show-health-horizontal", CclShowHealthHorizontal);
+    gh_new_procedure0_0("show-mana-vertical", CclShowManaVertical);
+    gh_new_procedure0_0("show-mana-horizontal", CclShowManaHorizontal);
 // fim
 
-    gh_new_procedure0_0("show-mana-bar",CclShowManaBar);
-    gh_new_procedure0_0("show-mana-dot",CclShowManaDot);
-    gh_new_procedure0_0("show-energy-selected-only",CclShowEnergySelected);
-    gh_new_procedure0_0("show-full",CclShowFull);
-    gh_new_procedure0_0("show-no-full",CclShowNoFull);
-    gh_new_procedure0_0("decoration-on-top",CclDecorationOnTop);
+    gh_new_procedure0_0("show-mana-bar", CclShowManaBar);
+    gh_new_procedure0_0("show-mana-dot", CclShowManaDot);
+    gh_new_procedure0_0("show-energy-selected-only", CclShowEnergySelected);
+    gh_new_procedure0_0("show-full", CclShowFull);
+    gh_new_procedure0_0("show-no-full", CclShowNoFull);
+    gh_new_procedure0_0("decoration-on-top", CclDecorationOnTop);
 }
 
 /**
@@ -549,25 +549,25 @@ global void DecorationCclRegister(void)
 */
 global void LoadDecorations(void)
 {
-    if( HealthSprite.File ) {
-	ShowLoadProgress("\tDecorations `%s'\n",HealthSprite.File);
-	HealthSprite.Sprite=LoadSprite(HealthSprite.File
-		,HealthSprite.Width,HealthSprite.Height);
+    if (HealthSprite.File) {
+	ShowLoadProgress("Decorations `%s'", HealthSprite.File);
+	HealthSprite.Sprite = LoadSprite(HealthSprite.File,
+	    HealthSprite.Width, HealthSprite.Height);
     }
-    if( ManaSprite.File ) {
-	ShowLoadProgress("\tDecorations `%s'\n",ManaSprite.File);
-	ManaSprite.Sprite=LoadSprite(ManaSprite.File
+    if (ManaSprite.File) {
+	ShowLoadProgress("Decorations `%s'", ManaSprite.File);
+	ManaSprite.Sprite = LoadSprite(ManaSprite.File
 		,ManaSprite.Width,ManaSprite.Height);
     }
-    if( ShadowSprite.File ) {
-	ShowLoadProgress("\tDecorations `%s'\n",ShadowSprite.File);
-	ShadowSprite.Sprite=LoadSprite(ShadowSprite.File
-		,ShadowSprite.Width,ShadowSprite.Height);
+    if (ShadowSprite.File) {
+	ShowLoadProgress("Decorations `%s'", ShadowSprite.File);
+	ShadowSprite.Sprite = LoadSprite(ShadowSprite.File,
+	    ShadowSprite.Width, ShadowSprite.Height);
     }
-    if( SpellSprite.File ) {
-	ShowLoadProgress("\tDecorations `%s'\n",SpellSprite.File);
-	SpellSprite.Sprite=LoadSprite(SpellSprite.File
-		,SpellSprite.Width,SpellSprite.Height);
+    if (SpellSprite.File) {
+	ShowLoadProgress("Decorations `%s'", SpellSprite.File);
+	SpellSprite.Sprite = LoadSprite(SpellSprite.File,
+	    SpellSprite.Width, SpellSprite.Height);
     }
 }
 
@@ -576,61 +576,61 @@ global void LoadDecorations(void)
 */
 global void SaveDecorations(CLFile* file)
 {
-    CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: decorations $Id$\n\n");
+    CLprintf(file, "\n;;; -----------------------------------------\n");
+    CLprintf(file, ";;; MODULE: decorations $Id$\n\n");
 
-    CLprintf(file,"(mana-sprite \"%s\"  %d %d  %d %d)\n",
+    CLprintf(file, "(mana-sprite \"%s\"  %d %d  %d %d)\n",
 	ManaSprite.File,ManaSprite.HotX,ManaSprite.HotY,
 	ManaSprite.Width,ManaSprite.Height);
-    CLprintf(file,"(health-sprite \"%s\"  %d %d  %d %d)\n",
+    CLprintf(file, "(health-sprite \"%s\"  %d %d  %d %d)\n",
 	HealthSprite.File,HealthSprite.HotX,HealthSprite.HotY,
 	HealthSprite.Width,HealthSprite.Height);
-    CLprintf(file,"(shadow-sprite \"%s\"  %d %d  %d %d)\n",
+    CLprintf(file, "(shadow-sprite \"%s\"  %d %d  %d %d)\n",
 	ShadowSprite.File,ShadowSprite.HotX,ShadowSprite.HotY,
 	ShadowSprite.Width,ShadowSprite.Height);
-    CLprintf(file,"(spell-sprite \"%s\"  %d %d  %d %d)\n",
+    CLprintf(file, "(spell-sprite \"%s\"  %d %d  %d %d)\n",
 	SpellSprite.File,SpellSprite.HotX,SpellSprite.HotY,
 	SpellSprite.Width,SpellSprite.Height);
 
     // This belongs to the config and not save file
-    if( ShowHealthBar ) {
-	CLprintf(file,";(show-health-bar)\n");
+    if (ShowHealthBar) {
+	CLprintf(file, ";(show-health-bar)\n");
     }
-    if( ShowHealthDot ) {
-	CLprintf(file,";(show-health-dot)\n");
+    if (ShowHealthDot) {
+	CLprintf(file, ";(show-health-dot)\n");
     }
-    if( ShowHealthHorizontal ) {
-	CLprintf(file,";(show-health-horizontal)\n");
+    if (ShowHealthHorizontal) {
+	CLprintf(file, ";(show-health-horizontal)\n");
     } else {
-	CLprintf(file,";(show-health-vertical)\n");
+	CLprintf(file, ";(show-health-vertical)\n");
     }
-    if( ShowHealthBackgroundLong ) {
-	CLprintf(file,";(show-health-blackground-long)\n");
+    if (ShowHealthBackgroundLong) {
+	CLprintf(file, ";(show-health-blackground-long)\n");
     }
-    if( ShowManaBar ) {
-	CLprintf(file,";(show-mana-bar)\n");
+    if (ShowManaBar) {
+	CLprintf(file, ";(show-mana-bar)\n");
     }
-    if( ShowManaDot ) {
-	CLprintf(file,";(show-mana-dot)\n");
+    if (ShowManaDot) {
+	CLprintf(file, ";(show-mana-dot)\n");
     }
-    if( ShowManaHorizontal ) {
-	CLprintf(file,";(show-mana-horizontal)\n");
+    if (ShowManaHorizontal) {
+	CLprintf(file, ";(show-mana-horizontal)\n");
     } else {
-	CLprintf(file,";(show-mana-vertical)\n");
+	CLprintf(file, ";(show-mana-vertical)\n");
     }
-    if( ShowManaBackgroundLong ) {
-	CLprintf(file,";(show-mana-blackground-long)\n");
+    if (ShowManaBackgroundLong) {
+	CLprintf(file, ";(show-mana-blackground-long)\n");
     }
-    if( ShowEnergySelectedOnly ) {
-	CLprintf(file,";(show-energy-selected-only)\n");
+    if (ShowEnergySelectedOnly) {
+	CLprintf(file, ";(show-energy-selected-only)\n");
     }
-    if( ShowNoFull ) {
-	CLprintf(file,";(show-no-full)\n");
+    if (ShowNoFull) {
+	CLprintf(file, ";(show-no-full)\n");
     } else {
-	CLprintf(file,";(show-full)\n");
+	CLprintf(file, ";(show-full)\n");
     }
-    if( DecorationOnTop ) {
-	CLprintf(file,";(decoration-on-top)\n");
+    if (DecorationOnTop) {
+	CLprintf(file, ";(decoration-on-top)\n");
     }
 }
 
@@ -639,33 +639,33 @@ global void SaveDecorations(CLFile* file)
 */
 global void CleanDecorations(void)
 {
-    if( HealthSprite.File ) {
+    if (HealthSprite.File) {
 	free(HealthSprite.File);
     }
     VideoSaveFree(HealthSprite.Sprite);
-    HealthSprite.File=NULL;
-    HealthSprite.Sprite=NULL;
+    HealthSprite.File = NULL;
+    HealthSprite.Sprite = NULL;
 
-    if( ManaSprite.File ) {
+    if (ManaSprite.File) {
 	free(ManaSprite.File);
     }
     VideoSaveFree(ManaSprite.Sprite);
-    ManaSprite.File=NULL;
-    ManaSprite.Sprite=NULL;
+    ManaSprite.File = NULL;
+    ManaSprite.Sprite = NULL;
 
-    if( ShadowSprite.File ) {
+    if (ShadowSprite.File) {
 	free(ShadowSprite.File);
     }
     VideoSaveFree(ShadowSprite.Sprite);
-    ShadowSprite.File=NULL;
-    ShadowSprite.Sprite=NULL;
+    ShadowSprite.File = NULL;
+    ShadowSprite.Sprite = NULL;
 
-    if( SpellSprite.File ) {
+    if (SpellSprite.File) {
 	free(SpellSprite.File);
     }
     VideoSaveFree(SpellSprite.Sprite);
-    SpellSprite.File=NULL;
-    SpellSprite.Sprite=NULL;
+    SpellSprite.File = NULL;
+    SpellSprite.Sprite = NULL;
 }
 
 /**
@@ -677,36 +677,36 @@ global void CleanDecorations(void)
 **	@param full	Full value
 **	@param ready	Ready value
 */
-local void DrawManaSprite(int x,int y,const UnitType* type,int full,int ready)
+local void DrawManaSprite(int x, int y, const UnitType* type, int full, int ready)
 {
     int n;
 
-    if( !full ) {
+    if (!full) {
 	return;
     }
-    n=VideoGraphicFrames(ManaSprite.Sprite)-1;
-    n-=(n*ready)/full;
+    n = VideoGraphicFrames(ManaSprite.Sprite) - 1;
+    n -= (n * ready) / full;
 
-    DebugCheck( n<0 || n>=VideoGraphicFrames(ManaSprite.Sprite)) ;
-    if( ManaSprite.HotX<0 ) {
-	x+=ManaSprite.HotX
-		+(type->TileWidth*TileSizeX+type->BoxWidth+1)/2;
-    } else if( ManaSprite.HotX>0 ) {
-	x+=1-ManaSprite.HotX
-		+(type->TileWidth*TileSizeX-type->BoxWidth)/2;
+    DebugCheck(n < 0 || n >= VideoGraphicFrames(ManaSprite.Sprite));
+    if (ManaSprite.HotX < 0) {
+	x += ManaSprite.HotX +
+	    (type->TileWidth * TileSizeX + type->BoxWidth + 1) / 2;
+    } else if (ManaSprite.HotX>0) {
+	x += 1 - ManaSprite.HotX +
+	    (type->TileWidth * TileSizeX - type->BoxWidth) / 2;
     } else {
-	x+=(type->TileWidth*TileSizeX-ManaSprite.Width+1)/2;
+	x += (type->TileWidth * TileSizeX - ManaSprite.Width + 1) / 2;
     }
-    if( ManaSprite.HotY<0 ) {
-	y+=ManaSprite.HotY
-		+(type->TileHeight*TileSizeY+type->BoxHeight+1)/2;
-    } else if( ManaSprite.HotY>0 ) {
-	y+=1-ManaSprite.HotY
-		+(type->TileHeight*TileSizeY-type->BoxHeight)/2;
+    if (ManaSprite.HotY < 0) {
+	y += ManaSprite.HotY +
+	    (type->TileHeight * TileSizeY + type->BoxHeight + 1) / 2;
+    } else if (ManaSprite.HotY > 0) {
+	y += 1 - ManaSprite.HotY +
+	    (type->TileHeight * TileSizeY - type->BoxHeight) / 2;
     } else {
-	y+=(type->TileHeight*TileSizeY-ManaSprite.Height+1)/2;
+	y += (type->TileHeight * TileSizeY - ManaSprite.Height + 1) / 2;
     }
-    VideoDrawClip(ManaSprite.Sprite,n,x,y);
+    VideoDrawClip(ManaSprite.Sprite, n, x, y);
 }
 
 /**
@@ -718,49 +718,45 @@ local void DrawManaSprite(int x,int y,const UnitType* type,int full,int ready)
 **	@param full	Full value
 **	@param ready	Ready value
 */
-local void DrawManaBar(int x,int y,const UnitType* type,int full,int ready)
+local void DrawManaBar(int x, int y, const UnitType* type, int full, int ready)
 {
     int f;
     int w;
 
-    if( !full ) {
+    if (!full) {
 	return;
     }
-    f=(100*ready)/full;
-    if ( ShowManaHorizontal == 0)  {
-	VideoFillRectangleClip(ColorBlue
-		,x+(type->TileWidth*TileSizeX
-			+type->BoxWidth)/2
-		,y+(type->TileHeight*TileSizeY
-			-type->BoxHeight)/2
-		,2,(f*type->BoxHeight)/100);
+    f = (100 * ready) / full;
+    if (ShowManaHorizontal == 0)  {
+	VideoFillRectangleClip(ColorBlue,
+	    x + (type->TileWidth * TileSizeX + type->BoxWidth) / 2,
+	    y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2,
+	    2, (f * type->BoxHeight) / 100);
     }  else  {
 	//
 	//	Draw the black rectangle in full size?
 	//
-	if( ShowManaBackgroundLong ) {
-	    VideoFillRectangleClip(ColorBlack
-		,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
-		,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-			+type->BoxHeight+5
-		,(type->BoxHeight)+1
-		,5);
+	if (ShowManaBackgroundLong) {
+	    VideoFillRectangleClip(ColorBlack,
+		x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2),
+		(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+		    type->BoxHeight + 5,
+		type->BoxHeight + 1, 5);
 	} else {
-	    VideoDrawRectangleClip(ColorBlack
-		,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
-		,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-			+type->BoxHeight+5
-		,(f*type->BoxHeight)/100
-		,4);
+	    VideoDrawRectangleClip(ColorBlack,
+		x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2),
+		(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+		    type->BoxHeight + 5,
+		(f * type->BoxHeight) / 100, 4);
+	}
+        w = (f * type->BoxHeight) / 100 - 1;
+        if (w > 0) { // Prevents -1 turning into unsigned int
+	    VideoFillRectangleClip(ColorBlue,
+		x + (type->TileWidth * TileSizeX - type->BoxWidth) / 2 + 1,
+		(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+		    type->BoxHeight + 6,
+		w, 3);
 	}
-        w=(f*type->BoxHeight)/100-1;
-        if (  w > 0 ) // Prevents -1 turning into unsigned int
-	    VideoFillRectangleClip(ColorBlue
-		,x+(type->TileWidth*TileSizeX-type->BoxWidth)/2+1
-		,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-			+type->BoxHeight+6
-		,w
-		,3);
     }
 }
 
@@ -772,7 +768,7 @@ local void DrawManaBar(int x,int y,const UnitType* type,int full,int ready)
 **	@param x	Screen X position of the unit.
 **	@param y	Screen Y position of the unit.
 */
-local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
+local void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
 {
     int f;
     VMemType color;
@@ -785,94 +781,84 @@ local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
     //
     //	Show the number of references.
     //
-    VideoDrawNumberClip(x+1,y+1,GameFont,unit->Refs);
+    VideoDrawNumberClip(x + 1, y + 1, GameFont, unit->Refs);
 #endif
 
     //
     //	Only for selected units?
     //
-    if( ShowEnergySelectedOnly && !unit->Selected ) {
+    if (ShowEnergySelectedOnly && !unit->Selected) {
 	return;
     }
 
     //
     //	Health bar on left side of unit.
     //
-    stats=unit->Stats;
+    stats = unit->Stats;
     //  Why remove the neutral race?
-    if( (unit->Player->Type!=PlayerNeutral)
-		&& ShowHealthBar ) {
-	if( stats->HitPoints
-		&& !(ShowNoFull && unit->HP==stats->HitPoints) ) {
-	    f=(100*unit->HP)/stats->HitPoints;
-	    if( f>75) {
+    if ((unit->Player->Type != PlayerNeutral) && ShowHealthBar) {
+	if (stats->HitPoints && !(ShowNoFull && unit->HP == stats->HitPoints)) {
+	    f = (100 * unit->HP) / stats->HitPoints;
+	    if (f > 75) {
 		color = ColorDarkGreen;
-	    } else if( f>50 ) {
+	    } else if (f > 50) {
 		color = ColorYellow;
-	    } else if( f>25 ) {
+	    } else if (f > 25) {
 		color = ColorOrange;
 	    } else {
 		color = ColorRed;
 	    }
-	    if ( ShowHealthHorizontal )  {
+	    if (ShowHealthHorizontal)  {
 		//
 		//	Draw the black rectangle in full size?
 		//
-		if( ShowHealthBackgroundLong ) {
-#if defined(DEBUG)
+		if (ShowHealthBackgroundLong) {
+#ifdef DEBUG
 		    // Johns: I want to see fast moving.
 		    // VideoFillRectangleClip(unit->Data.Move.Fast
 		    // Johns: I want to see the AI active flag
-		    VideoFillRectangleClip(unit->Active? ColorBlack : ColorWhite
-			,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
-			,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-				+type->BoxHeight+1
-			,type->BoxHeight+1
-			,5);
+		    VideoFillRectangleClip(unit->Active? ColorBlack : ColorWhite,
+			x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2),
+			(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+			    type->BoxHeight + 1,
+			type->BoxHeight + 1, 5);
 #else
-		    VideoFillRectangleClip(ColorBlack
-			 ,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
-			,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-				+type->BoxHeight+1
-			,type->BoxHeight+1
-			,5);
-
+		    VideoFillRectangleClip(ColorBlack,
+			x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2),
+			(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+			    type->BoxHeight + 1,
+			type->BoxHeight + 1, 5);
 #endif
 		} else {
-#if defined(DEBUG)
+#ifdef DEBUG
 		    // Johns: I want to see fast moving.
-		    VideoFillRectangleClip(unit->Data.Move.Fast?ColorBlack:ColorWhite
-			,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
-			,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-				+type->BoxHeight+1
-			,((f*type->BoxHeight)/100)+1
-			,5);
+		    VideoFillRectangleClip(unit->Data.Move.Fast ? ColorBlack : ColorWhite,
+			x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2),
+			(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+			    type->BoxHeight + 1,
+			((f * type->BoxHeight) / 100) + 1, 5);
 
 #else
-		    VideoFillRectangleClip(ColorBlack
-			,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
-			,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-				+type->BoxHeight+1
-			,((f*type->BoxHeight)/100)+1
-			,5);
+		    VideoFillRectangleClip(ColorBlack,
+			x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2),
+			(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+			    type->BoxHeight + 1,
+			((f * type->BoxHeight) / 100) + 1, 5);
 #endif
 		}
-                w = (f*type->BoxHeight)/100-1;
-                if ( w > 0 ) { // Prevents -1 turning into unsigned int
-		VideoFillRectangleClip(color
-		    ,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)+1
-		    ,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
-			    +type->BoxHeight+2
-		    ,w
-		    ,3);
+                w = (f * type->BoxHeight) / 100 - 1;
+                if (w > 0) { // Prevents -1 turning into unsigned int
+		    VideoFillRectangleClip(color,
+			x + ((type->TileWidth * TileSizeX - type->BoxWidth) / 2) + 1,
+			(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
+			    type->BoxHeight + 2,
+			w, 3);
 		}
 	    }  else  {
-		VideoFillRectangleClip(color
-		    ,x+(type->TileWidth*TileSizeX
-			    -type->BoxWidth)/2
-		    ,y+(type->TileHeight*TileSizeY
-			    -type->BoxHeight)/2
-		    ,2,(f*type->BoxHeight)/100);
+		VideoFillRectangleClip(color,
+		    x + (type->TileWidth * TileSizeX - type->BoxWidth) / 2,
+		    y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2,
+		    2, (f * type->BoxHeight) / 100);
 	    }
 	}
     }
@@ -881,112 +867,112 @@ local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
     //	Health dot on left side of unit.
     //  Why skip the neutral units?
     //
-    if( (unit->Player->Type!=PlayerNeutral)
-		&& ShowHealthDot ) {
-	if( stats->HitPoints
-		&& !(ShowNoFull && unit->HP==stats->HitPoints) ) {
+    if ((unit->Player->Type != PlayerNeutral) && ShowHealthDot) {
+	if (stats->HitPoints &&
+		!(ShowNoFull && unit->HP == stats->HitPoints)) {
 	    int n;
 
-	    n=VideoGraphicFrames(HealthSprite.Sprite)-1;
-	    n-=(n*unit->HP)/stats->HitPoints;
+	    n = VideoGraphicFrames(HealthSprite.Sprite) - 1;
+	    n -= (n * unit->HP) / stats->HitPoints;
 #if 0
-	    f=(100*unit->HP)/stats->HitPoints;
-	    if( f>75) {
-		n=3-((f-75)/(25/3))+ 0;
-	    } else if( f>50 ) {
-		n=3-((f-50)/(25/3))+ 4;
+	    f = (100 * unit->HP) / stats->HitPoints;
+	    if (f > 75) {
+		n = 3 - ((f - 75) / (25 / 3)) + 0;
+	    } else if (f > 50) {
+		n = 3 - ((f - 50) / (25 / 3)) + 4;
 		DebugLevel3("%d - %d\n" _C_ f _C_ n);
 	    } else {
-		n=3-(f/(50/3))+ 8;
+		n = 3 - (f / (50 / 3)) + 8;
 		DebugLevel3("%d - %d\n" _C_ f _C_ n);
 	    }
 #endif
-	    DebugCheck( n<0 );
-	    if( HealthSprite.HotX<0 ) {
-		x1=x+HealthSprite.HotX
-			+(type->TileWidth*TileSizeX+type->BoxWidth+1)/2;
-	    } else if( HealthSprite.HotX>0 ) {
-		x1=x+1-HealthSprite.HotX
-			+(type->TileWidth*TileSizeX-type->BoxWidth)/2;
+	    DebugCheck(n < 0);
+	    if (HealthSprite.HotX < 0) {
+		x1 = x + HealthSprite.HotX +
+		    (type->TileWidth * TileSizeX + type->BoxWidth + 1) / 2;
+	    } else if (HealthSprite.HotX > 0) {
+		x1 = x + 1 - HealthSprite.HotX +
+		    (type->TileWidth * TileSizeX - type->BoxWidth) / 2;
 	    } else {
-		x1=x+(type->TileWidth*TileSizeX-HealthSprite.Width+1)/2;
+		x1 = x + (type->TileWidth * TileSizeX - HealthSprite.Width + 1) / 2;
 	    }
-	    if( HealthSprite.HotY<0 ) {
-		y1=y+HealthSprite.HotY
-			+(type->TileHeight*TileSizeY+type->BoxHeight+1)/2;
-	    } else if( HealthSprite.HotY>0 ) {
-		y1=y+1-HealthSprite.HotY
-			+(type->TileHeight*TileSizeY-type->BoxHeight)/2;
+	    if (HealthSprite.HotY < 0) {
+		y1 = y + HealthSprite.HotY +
+		    (type->TileHeight * TileSizeY + type->BoxHeight + 1) / 2;
+	    } else if (HealthSprite.HotY > 0) {
+		y1 = y + 1 - HealthSprite.HotY +
+		    (type->TileHeight * TileSizeY - type->BoxHeight) / 2;
 	    } else {
-		y1=y+(type->TileHeight*TileSizeY-HealthSprite.Height+1)/2;
+		y1 = y + (type->TileHeight * TileSizeY - HealthSprite.Height + 1) / 2;
 	    }
-	    VideoDrawClip(HealthSprite.Sprite,n,x1,y1);
+	    VideoDrawClip(HealthSprite.Sprite, n, x1, y1);
 	}
     }
 
     //
     //	Mana bar on right side of unit. FIXME: combine bar and sprite
     //
-    if( ShowManaBar ) {
-	if( type->CanCastSpell
-		&& !(ShowNoFull && unit->Mana==unit->Type->_MaxMana) ) {
+    if (ShowManaBar) {
+	if (type->CanCastSpell &&
+		!(ShowNoFull && unit->Mana == unit->Type->_MaxMana)) {
 	    // s0m3body: mana bar should display mana proportionally
 	    //		to unit's max mana (unit->Type->_MaxMana)
-	    DrawManaBar(x,y,type,unit->Type->_MaxMana,unit->Mana);
-	} else if( type->GivesResource ) {
-	    DrawManaBar(x,y,type,655350,unit->Value);
+	    DrawManaBar(x, y, type, unit->Type->_MaxMana, unit->Mana);
+	} else if (type->GivesResource) {
+	    DrawManaBar(x, y, type, 655350, unit->Value);
 	}
 	//
 	//	Show working of units.
 	//
-	if( unit->Player==ThisPlayer ) {
+	if (unit->Player==ThisPlayer) {
 
 	    //
 	    //	Building under constuction.
 	    //
 	    /*
-	    if( unit->Orders[0].Action==UnitActionBuilded ) {
-		DrawManaBar(x,y,type,stats->HitPoints,unit->HP);
+	    if (unit->Orders[0].Action == UnitActionBuilded) {
+		DrawManaBar(x, y, type, stats->HitPoints, unit->HP);
 	    } else
 	    */
 
 	    //
 	    //	Building training units.
 	    //
-	    if( unit->Orders[0].Action==UnitActionTrain ) {
-		DrawManaBar(x,y,type,unit->Data.Train.What[0]
-			    ->Stats[unit->Player->Player].Costs[TimeCost]
-			,unit->Data.Train.Ticks);
+	    if (unit->Orders[0].Action == UnitActionTrain) {
+		DrawManaBar(x, y, type, unit->Data.Train.What[0]->Stats[
+			unit->Player->Player].Costs[TimeCost],
+		    unit->Data.Train.Ticks);
 
 	    //
 	    //	Building upgrading to better type.
 	    //
-	    } else if( unit->Orders[0].Action==UnitActionUpgradeTo ) {
-		DrawManaBar(x,y,type,unit->Orders[0].Type
-			    ->Stats[unit->Player->Player].Costs[TimeCost]
-			,unit->Data.UpgradeTo.Ticks);
+	    } else if (unit->Orders[0].Action == UnitActionUpgradeTo) {
+		DrawManaBar(x, y, type, unit->Orders[0].Type->Stats[
+			unit->Player->Player].Costs[TimeCost],
+		    unit->Data.UpgradeTo.Ticks);
 
 	    //
 	    //	Carry resource.
 	    //	Don't display if empty.
 	    //
-	    } else if( unit->Type->Harvester&&unit->CurrentResource&&unit->Value>0 ) {
-		DrawManaBar(x,y,type,unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity,
-			unit->Value);
+	    } else if (unit->Type->Harvester && unit->CurrentResource && unit->Value > 0) {
+		DrawManaBar(x, y, type, unit->Type->ResInfo[
+			unit->CurrentResource]->ResourceCapacity,
+		    unit->Value);
 
 	    //
 	    //	Building research new technologie.
 	    //
-	    } else if( unit->Orders[0].Action==UnitActionResearch ) {
-		DrawManaBar(x,y,type,unit->Data.Research.Upgrade
-			    ->Costs[TimeCost],
-			unit->Player->UpgradeTimers.Upgrades[
-			    unit->Data.Research.Upgrade-Upgrades]);
+	    } else if (unit->Orders[0].Action == UnitActionResearch) {
+		DrawManaBar(x, y, type,
+		    unit->Data.Research.Upgrade->Costs[TimeCost],
+		    unit->Player->UpgradeTimers.Upgrades[
+			unit->Data.Research.Upgrade - Upgrades]);
 	    //
 	    //	Transporter with units on board.
 	    //
-	    } else if( unit->Type->Transporter ) {
-		DrawManaBar(x,y,type,unit->Type->MaxOnBoard,unit->InsideCount);
+	    } else if (unit->Type->Transporter) {
+		DrawManaBar(x, y, type, unit->Type->MaxOnBoard, unit->InsideCount);
 	    }
 	}
     }
@@ -994,127 +980,131 @@ local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
     //
     //	Mana dot on right side of unit.
     //
-    if( ShowManaDot ) {
-	    // s0m3body: MaxMana can vary for each unit,
-	    // 		it is stored in unit->Type->_MaxMana
-	if( type->CanCastSpell
-		&& !(ShowNoFull && unit->Mana==unit->Type->_MaxMana) ) {
-	    DrawManaSprite(x,y,type,unit->Type->_MaxMana,unit->Mana);
-	} else if( type->GivesResource ) {
-	    DrawManaSprite(x,y,type,655350,unit->Value);
+    if (ShowManaDot) {
+	// s0m3body: MaxMana can vary for each unit,
+	// 		it is stored in unit->Type->_MaxMana
+	if (type->CanCastSpell &&
+		!(ShowNoFull && unit->Mana == unit->Type->_MaxMana)) {
+	    DrawManaSprite(x, y, type,unit->Type->_MaxMana, unit->Mana);
+	} else if (type->GivesResource) {
+	    DrawManaSprite(x, y, type, 655350, unit->Value);
 	}
 	//
 	//	Show working of units.
 	//
-	if( unit->Player==ThisPlayer ) {
+	if (unit->Player == ThisPlayer) {
 
 	    //
 	    //	Building under constuction.
 	    //
 	    /*
-	    if( unit->Orders[0].Action==UnitActionBuilded ) {
-		DrawManaSprite(x,y,type,stats->HitPoints,unit->HP);
+	    if (unit->Orders[0].Action == UnitActionBuilded) {
+		DrawManaSprite(x, y, type, stats->HitPoints, unit->HP);
 	    } else
 	    */
 
 	    //
 	    //	Building training units.
 	    //
-	    if( unit->Orders[0].Action==UnitActionTrain ) {
-		DrawManaSprite(x,y,type,unit->Data.Train.What[0]
-			    ->Stats[unit->Player->Player].Costs[TimeCost]
-			,unit->Data.Train.Ticks);
+	    if (unit->Orders[0].Action == UnitActionTrain) {
+		DrawManaSprite(x, y, type, unit->Data.Train.What[0]->Stats[
+			unit->Player->Player].Costs[TimeCost],
+		    unit->Data.Train.Ticks);
 
 	    //
 	    //	Building upgrading to better type.
 	    //
-	    } else if( unit->Orders[0].Action==UnitActionUpgradeTo ) {
-		DrawManaSprite(x,y,type,unit->Orders[0].Type
-			    ->Stats[unit->Player->Player].Costs[TimeCost]
-			,unit->Data.UpgradeTo.Ticks);
+	    } else if (unit->Orders[0].Action == UnitActionUpgradeTo) {
+		DrawManaSprite(x,y,type,unit->Orders[0].Type->Stats[
+			unit->Player->Player].Costs[TimeCost],
+		    unit->Data.UpgradeTo.Ticks);
 		
 	    //
 	    //	Carry resource.
 	    //
-	    } else if( unit->Type->Harvester&&unit->CurrentResource&&unit->Value>0 ) {
-		DrawManaSprite(x,y,type,unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity,
-			unit->Value);
+	    } else if (unit->Type->Harvester &&
+		    unit->CurrentResource&&unit->Value > 0) {
+		DrawManaSprite(x, y, type,
+		    unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity,
+		    unit->Value);
 
 	    //
 	    //	Building research new technologie.
 	    //
-	    } else if( unit->Orders[0].Action==UnitActionResearch ) {
-		DrawManaSprite(x,y,type,unit->Data.Research.Upgrade
-			    ->Costs[TimeCost],
-			unit->Player->UpgradeTimers.Upgrades[
-			    unit->Data.Research.Upgrade-Upgrades]);
+	    } else if (unit->Orders[0].Action == UnitActionResearch) {
+		DrawManaSprite(x, y, type,
+		    unit->Data.Research.Upgrade->Costs[TimeCost],
+		    unit->Player->UpgradeTimers.Upgrades[
+			unit->Data.Research.Upgrade-Upgrades]);
 	    //
 	    //	Transporter with units on board.
 	    //
-	    } else if( unit->Type->Transporter ) {
-		DrawManaSprite(x,y,type,unit->Type->MaxOnBoard,unit->InsideCount);
+	    } else if (unit->Type->Transporter) {
+		DrawManaSprite(x, y, type, unit->Type->MaxOnBoard, unit->InsideCount);
 	    }
 	}
     }
 
     // FIXME: Johns there is 100% a way to remove this calculation from
     //		runtime.
-    x1=x;
-    y1=y;
-    if( SpellSprite.HotX<0 ) {
-	x1+=SpellSprite.HotX
-		+(type->TileWidth*TileSizeX+type->BoxWidth+1)/2;
-    } else if( SpellSprite.HotX>0 ) {
-	x1+=1-SpellSprite.HotX
-		+(type->TileWidth*TileSizeX-type->BoxWidth)/2;
+    x1 = x;
+    y1 = y;
+    if (SpellSprite.HotX < 0) {
+	x1 += SpellSprite.HotX +
+	    (type->TileWidth * TileSizeX + type->BoxWidth + 1) / 2;
+    } else if (SpellSprite.HotX>0) {
+	x1 += 1 - SpellSprite.HotX +
+	    (type->TileWidth * TileSizeX - type->BoxWidth) / 2;
     } else {
-	x1+=(type->TileWidth*TileSizeX-SpellSprite.Width+1)/2;
+	x1 += (type->TileWidth * TileSizeX - SpellSprite.Width + 1) / 2;
     }
-    if( SpellSprite.HotY<0 ) {
-	y1+=SpellSprite.HotY
-		+(type->TileHeight*TileSizeY+type->BoxHeight+1)/2;
-    } else if( SpellSprite.HotY>0 ) {
-	y1+=1-SpellSprite.HotY
-		+(type->TileHeight*TileSizeY-type->BoxHeight)/2;
+    if (SpellSprite.HotY < 0) {
+	y1 += SpellSprite.HotY +
+	    (type->TileHeight * TileSizeY + type->BoxHeight + 1) / 2;
+    } else if (SpellSprite.HotY > 0) {
+	y1 += 1 - SpellSprite.HotY +
+	    (type->TileHeight * TileSizeY - type->BoxHeight) / 2;
     } else {
-	y1+=(type->TileHeight*TileSizeY-SpellSprite.Height+1)/2;
+	y1 += (type->TileHeight * TileSizeY - SpellSprite.Height + 1) / 2;
     }
 
     //
     // Draw spells decoration
     //
-    if ( unit->Bloodlust ) {
-	VideoDrawClip( SpellSprite.Sprite, 0, x1, y1 );
+    if (unit->Bloodlust) {
+	VideoDrawClip(SpellSprite.Sprite, 0, x1, y1);
     }
-    if ( unit->Haste ) {	// same slot as slow
-	VideoDrawClip( SpellSprite.Sprite, 1, x1+16, y1 );
+    if (unit->Haste) {	// same slot as slow
+	VideoDrawClip(SpellSprite.Sprite, 1, x1 + 16, y1);
     }
-    if ( unit->Slow ) {		// same slot as haste
-	VideoDrawClip( SpellSprite.Sprite, 2, x1+16, y1 );
+    if (unit->Slow) {		// same slot as haste
+	VideoDrawClip(SpellSprite.Sprite, 2, x1 + 16, y1);
     }
-    if ( unit->Invisible ) {
-	VideoDrawClip( SpellSprite.Sprite, 3, x1+16+16, y1 );
+    if (unit->Invisible) {
+	VideoDrawClip(SpellSprite.Sprite, 3, x1 + 16 + 16, y1);
     }
-    if ( unit->UnholyArmor ) {
-	VideoDrawClip( SpellSprite.Sprite, 4, x1+16+16+16, y1 );
+    if (unit->UnholyArmor) {
+	VideoDrawClip(SpellSprite.Sprite, 4, x1 + 16 + 16 + 16, y1);
     }
 
     //
     //	Draw group number
     //
-    if( unit->Selected && unit->GroupId!=0 ) {
+    if (unit->Selected && unit->GroupId != 0) {
 	char buf[2];
 	int num;
 
 	// FIXME: shows the smallest group number, is this what we want?
-	for( num=0; !(unit->GroupId & (1<<num)); num++) ;
-	buf[0]=num+'0';
-	buf[1]='\0';
-	f=VideoTextLength(GameFont,buf);
-	x+=(type->TileWidth*TileSizeX+type->BoxWidth)/2-f;
-	f=VideoTextHeight(GameFont);
-	y+=(type->TileHeight*TileSizeY+type->BoxHeight)/2-f;
-	VideoDrawNumberClip(x,y,GameFont,num);
+	for (num = 0; !(unit->GroupId & (1 << num)); ++num) {
+	    ;
+	}
+	buf[0] = num + '0';
+	buf[1] = '\0';
+	f = VideoTextLength(GameFont, buf);
+	x += (type->TileWidth * TileSizeX + type->BoxWidth) / 2 - f;
+	f = VideoTextHeight(GameFont);
+	y += (type->TileHeight * TileSizeY + type->BoxHeight) / 2 - f;
+	VideoDrawNumberClip(x, y, GameFont, num);
     }
 }
 
@@ -1162,11 +1152,9 @@ local void DrawShadow(const Unit* unit, int x, int y)
 		unit->Type->TileHeight * TileSizeY) / 2;
 	    y += unit->Type->ShadowOffset;
 	    if (unit->Frame < 0) {
-		VideoDrawShadowClipX(unit->Type->ShadowSprite, -unit->Frame, x,
-		    y);
+		VideoDrawShadowClipX(unit->Type->ShadowSprite, -unit->Frame, x, y);
 	    } else {
-		VideoDrawShadowClip(unit->Type->ShadowSprite, unit->Frame, x,
-		    y);
+		VideoDrawShadowClip(unit->Type->ShadowSprite, unit->Frame, x, y);
 	    }
 	}
 	return;
@@ -1185,11 +1173,9 @@ local void DrawShadow(const Unit* unit, int x, int y)
 	y += unit->Type->ShadowOffset;
 
 	if (unit->Frame < 0) {
-	    VideoDrawShadowClipX(unit->Type->ShadowSprite, -unit->Frame, x,
-		y);
+	    VideoDrawShadowClipX(unit->Type->ShadowSprite, -unit->Frame, x, y);
 	} else {
-	    VideoDrawShadowClip(unit->Type->ShadowSprite, unit->Frame, x,
-		y);
+	    VideoDrawShadowClip(unit->Type->ShadowSprite, unit->Frame, x, y);
 	}
 	return;
     }
@@ -1267,50 +1253,50 @@ global void DrawPath(const Unit* unit)
 	    return;
 	}
 	// CLIPPING
-	VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		y1) + TileSizeY / 2 - 3, 6, 6);
+	VideoDrawRectangleClip(ColorGray,
+	    Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+	    Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 	while (x1 != x2) {
 	    x1 += xstep;
-	    VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		    x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		    y1) + TileSizeY / 2 - 3, 6, 6);
+	    VideoDrawRectangleClip(ColorGray,
+		Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+		Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 	}
 	return;
     }
 
     if (dx == 0) {			// vertical line
 	// CLIPPING
-	VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		y1) + TileSizeY / 2 - 3, 6, 6);
+	VideoDrawRectangleClip(ColorGray,
+	    Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+	    Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 	while (y1 != y2) {
-	    y1++;
-	    VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		    x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		    y1) + TileSizeY / 2 - 3, 6, 6);
+	    ++y1;
+	    VideoDrawRectangleClip(ColorGray,
+		Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+		Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 	}
 	return;
     }
 
-    VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-	    x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-	    y1) + TileSizeY / 2 - 3, 6, 6);
+    VideoDrawRectangleClip(ColorGray,
+	Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+	Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 
     if (dx < dy) {			// step in vertical direction
 	d = dy - 1;
 	dx += dx;
 	dy += dy;
 	while (y1 != y2) {
-	    y1++;
+	    ++y1;
 	    d -= dx;
 	    if (d < 0) {
 		d += dy;
 		x1 += xstep;
 	    }
-	    VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		    x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		    y1) + TileSizeY / 2 - 3, 6, 6);
+	    VideoDrawRectangleClip(ColorGray,
+		Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+		Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 	}
 	return;
     }
@@ -1327,9 +1313,9 @@ global void DrawPath(const Unit* unit)
 		d += dx;
 		++y1;
 	    }
-	    VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		    x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		    y1) + TileSizeY / 2 - 3, 6, 6);
+	    VideoDrawRectangleClip(ColorGray,
+		Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+		Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
 	}
 	return;
     }
@@ -1337,10 +1323,10 @@ global void DrawPath(const Unit* unit)
     // diagonal line
     while (y1 != y2) {
 	x1 += xstep;
-	y1++;
-	VideoDrawRectangleClip(ColorGray, Map2ViewportX(CurrentViewport,
-		x1) + TileSizeX / 2 - 3, Map2ViewportY(CurrentViewport,
-		y1) + TileSizeY / 2 - 3, 6, 6);
+	++y1;
+	VideoDrawRectangleClip(ColorGray,
+	    Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
+	    Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
     }
 }
 
@@ -1548,9 +1534,9 @@ global void ShowOrder(const Unit* unit)
 
     ShowSingleOrder(unit, x1, y1, unit->Orders);
 #if 1
-    for (i=1;i<unit->OrderCount;i++) {
-	GetOrderPosition(unit,unit->Orders+i-1,&x1,&y1);
-	ShowSingleOrder(unit,x1,y1,unit->Orders+i);
+    for (i = 1; i < unit->OrderCount; ++i) {
+	GetOrderPosition(unit, unit->Orders + i - 1, &x1, &y1);
+	ShowSingleOrder(unit, x1, y1, unit->Orders + i);
     }
 #endif
     if (unit->Type->Building) {
@@ -1568,61 +1554,60 @@ global void ShowOrder(const Unit* unit)
 **
 **	@todo FIXME: The different styles should become a function call.
 */
-local void DrawInformations(const Unit* unit,const UnitType* type,int x,int y)
+local void DrawInformations(const Unit* unit,const UnitType* type, int x, int y)
 {
     const UnitStats* stats;
     int r;
 
-    stats=unit->Stats;
+    stats = unit->Stats;
 
     //
     //	For debug draw sight, react and attack range!
     //
-    if( NumSelected==1 && unit->Selected ) {
-	if( ShowSightRange ) {
-	    if( ShowSightRange == 1 ) {
-		VideoFill75TransRectangleClip(ColorGreen
-		    ,x+type->TileWidth*TileSizeX/2-stats->SightRange*TileSizeX
-		    ,y+type->TileHeight*TileSizeY/2-stats->SightRange*TileSizeY
-		    ,stats->SightRange*TileSizeX*2
-		    ,stats->SightRange*TileSizeY*2);
-	    } else if( ShowSightRange == 2 ) {
-		VideoFill75TransCircleClip(ColorGreen
-			,x+type->TileWidth*TileSizeX/2
-			,y+type->TileHeight*TileSizeY/2
-			,min((stats->SightRange+(type->TileWidth-1)/2)*TileSizeX
-			    ,(stats->SightRange+(type->TileHeight-1)/2)*TileSizeY));
+    if (NumSelected == 1 && unit->Selected) {
+	if (ShowSightRange) {
+	    if (ShowSightRange == 1) {
+		VideoFill75TransRectangleClip(ColorGreen,
+		    x + type->TileWidth * TileSizeX / 2 - stats->SightRange * TileSizeX,
+		    y + type->TileHeight * TileSizeY / 2 - stats->SightRange * TileSizeY,
+		    stats->SightRange * TileSizeX * 2,
+		    stats->SightRange * TileSizeY * 2);
+	    } else if (ShowSightRange == 2) {
+		VideoFill75TransCircleClip(ColorGreen,
+		    x + type->TileWidth * TileSizeX / 2,
+		    y + type->TileHeight * TileSizeY / 2,
+		    min((stats->SightRange + (type->TileWidth - 1) / 2) * TileSizeX,
+		    (stats->SightRange + (type->TileHeight - 1) / 2) * TileSizeY));
 	    } else {
-		VideoDrawCircleClip(ColorGreen
-		    ,x+type->TileWidth*TileSizeX/2
-		    ,y+type->TileHeight*TileSizeY/2
-		    ,(stats->SightRange+(type->TileWidth-1)/2)*TileSizeX*2);
+		VideoDrawCircleClip(ColorGreen,
+		    x + type->TileWidth * TileSizeX / 2,
+		    y + type->TileHeight * TileSizeY / 2,
+		    (stats->SightRange + (type->TileWidth - 1) / 2) * TileSizeX * 2);
 	    }
 	}
-	if( type->CanAttack ) {
-	    if( ShowReactionRange ) {
-		r= (unit->Player->Type==PlayerPerson)
-			? type->ReactRangePerson
-			: type->ReactRangeComputer;
-		if( r ) {
-		    VideoDrawCircleClip(ColorBlue
-			,x+type->TileWidth*TileSizeX/2
-			,y+type->TileHeight*TileSizeY/2
-			,r*TileSizeX);
+	if (type->CanAttack) {
+	    if (ShowReactionRange) {
+		r = (unit->Player->Type==PlayerPerson) ?
+		    type->ReactRangePerson : type->ReactRangeComputer;
+		if (r) {
+		    VideoDrawCircleClip(ColorBlue,
+			x + type->TileWidth * TileSizeX / 2,
+			y + type->TileHeight * TileSizeY / 2,
+			r * TileSizeX);
 		}
 	    }
-	    if( ShowAttackRange && stats->AttackRange ) {
-		VideoDrawCircleClip(ColorRed
-		    ,x+type->TileWidth*TileSizeX/2
-		    ,y+type->TileHeight*TileSizeY/2
-		    ,stats->AttackRange*TileSizeX);
+	    if (ShowAttackRange && stats->AttackRange) {
+		VideoDrawCircleClip(ColorRed,
+		    x + type->TileWidth * TileSizeX / 2,
+		    y + type->TileHeight * TileSizeY / 2,
+		    stats->AttackRange * TileSizeX);
 	    }
 	}
     }
 
     // FIXME: johns: ugly check here, should be removed!
-    if( unit->Orders[0].Action!=UnitActionDie ) {
-	DrawDecoration(unit,type,x,y);
+    if (unit->Orders[0].Action != UnitActionDie) {
+	DrawDecoration(unit, type, x, y);
     }
 }
 
@@ -1636,23 +1621,23 @@ local void DrawInformations(const Unit* unit,const UnitType* type,int x,int y)
 */
 local void GraphicUnitPixels(const Unit* unit,const Graphic* sprite)
 {
-    switch( VideoBpp ) {
+    switch (VideoBpp) {
 	case 8:
-	    *((struct __4pixel8__*)(((VMemType8*)sprite->Pixels)+208))
-		    =unit->Colors->Depth8;
+	    *((struct __4pixel8__*)(((VMemType8*)sprite->Pixels) + 208)) =
+		unit->Colors->Depth8;
 	    break;
 	case 15:
 	case 16:
-	    *((struct __4pixel16__*)(((VMemType16*)sprite->Pixels)+208))
-		    =unit->Colors->Depth16;
+	    *((struct __4pixel16__*)(((VMemType16*)sprite->Pixels) + 208)) =
+		unit->Colors->Depth16;
 	    break;
 	case 24:
-	    *((struct __4pixel24__*)(((VMemType24*)sprite->Pixels)+208))
-		    =unit->Colors->Depth24;
+	    *((struct __4pixel24__*)(((VMemType24*)sprite->Pixels) + 208)) =
+		unit->Colors->Depth24;
 	    break;
 	case 32:
-	    *((struct __4pixel32__*)(((VMemType32*)sprite->Pixels)+208))
-		    =unit->Colors->Depth32;
+	    *((struct __4pixel32__*)(((VMemType32*)sprite->Pixels) + 208)) =
+		unit->Colors->Depth32;
 	    break;
     }
 }
@@ -1661,37 +1646,39 @@ local void GraphicUnitPixels(const Unit* unit,const Graphic* sprite)
 /**
 **	FIXME: docu?
 */
-local void DrawUnitPlayerColor(const UnitType* type,int player,int frame,int x,int y)
+local void DrawUnitPlayerColor(const UnitType* type, int player, int frame, int x, int y)
 {
-    if( !type->PlayerColorSprite[player] ||
-	!type->PlayerColorSprite[player]->TextureNames[frame<0?-frame:frame] ) {
-	unsigned char mapping[4*2];
+    if (!type->PlayerColorSprite[player] ||
+	    !type->PlayerColorSprite[player]->TextureNames[
+		frame < 0 ? -frame : frame]) {
+	unsigned char mapping[4 * 2];
 	int i;
-	if( player==7 || player==15 ) {
-	    for( i=0; i<4; ++i ) {
-		mapping[i*2+0] = 208+i;
-		mapping[i*2+1] = player*4+12+i;
+
+	if (player == 7 || player == 15) {
+	    for (i = 0; i < 4; ++i) {
+		mapping[i * 2 + 0] = 208 + i;
+		mapping[i * 2 + 1] = player * 4 + 12 + i;
 	    }
 	} else {
-	    for( i=0; i<4; ++i ) {
-		mapping[i*2+0] = 208+i;
-		mapping[i*2+1] = player*4+208+i;
+	    for (i = 0; i < 4; ++i) {
+		mapping[i * 2 + 0] = 208 + i;
+		mapping[i * 2 + 1] = player * 4 + 208 + i;
 	    }
 	}
 	fprintf(stderr,"%s (%d)\n", type->Ident, player);
 	MakePlayerColorTexture(&((UnitType*)type)->PlayerColorSprite[player],
-	    type->Sprite, frame<0?-frame:frame, mapping, 4);
+	    type->Sprite, frame < 0 ? -frame : frame, mapping, 4);
     }
 
     // FIXME: move this calculation to high level.
-    x-=(type->Width-type->TileWidth*TileSizeX)/2;
-    y-=(type->Height-type->TileHeight*TileSizeY)/2;
+    x -= (type->Width - type->TileWidth * TileSizeX) / 2;
+    y -= (type->Height - type->TileHeight * TileSizeY) / 2;
 
     // FIXME: This is a hack for mirrored sprites
-    if( frame<0 ) {
-	VideoDrawClipX(type->PlayerColorSprite[player],-frame,x,y);
+    if (frame < 0) {
+	VideoDrawClipX(type->PlayerColorSprite[player], -frame, x, y);
     } else {
-	VideoDrawClip(type->PlayerColorSprite[player],frame,x,y);
+	VideoDrawClip(type->PlayerColorSprite[player],frame, x, y);
     }
 }
 #endif
@@ -1704,26 +1691,26 @@ local void DrawUnitPlayerColor(const UnitType* type,int player,int frame,int x,i
 **	@param x	X position.
 **	@param y	Y position.
 */
-local void DrawConstruction(const Unit* unit,int frame,int x,int y)
+local void DrawConstruction(const Unit* unit, int frame, int x, int y)
 {
     ConstructionFrame* cframe;
 
-    cframe=unit->Data.Builded.Frame;
-    if( cframe->File==ConstructionFileConstruction ) {
+    cframe = unit->Data.Builded.Frame;
+    if (cframe->File == ConstructionFileConstruction) {
 	const Construction* construction;
 
-	construction=unit->Type->Construction;
-	x-=construction->Width/2;
-	y-=construction->Height/2;
-	GraphicUnitPixels(unit,construction->Sprite);
-	VideoDrawClip(construction->Sprite,frame,x,y);
+	construction = unit->Type->Construction;
+	x -= construction->Width / 2;
+	y -= construction->Height / 2;
+	GraphicUnitPixels(unit, construction->Sprite);
+	VideoDrawClip(construction->Sprite, frame, x, y);
     } else {
-	x-=unit->Type->TileWidth*TileSizeX/2;
-	y-=unit->Type->TileHeight*TileSizeY/2;
-	GraphicUnitPixels(unit,unit->Type->Sprite);
-	DrawUnitType(unit->Type,frame,x,y);
+	x -= unit->Type->TileWidth * TileSizeX / 2;
+	y -= unit->Type->TileHeight * TileSizeY / 2;
+	GraphicUnitPixels(unit, unit->Type->Sprite);
+	DrawUnitType(unit->Type, frame, x, y);
 #ifdef USE_OPENGL
-	DrawUnitPlayerColor(unit->Type,unit->Player->Player,frame,x,y);
+	DrawUnitPlayerColor(unit->Type, unit->Player->Player, frame, x, y);
 #endif
     }
 }
@@ -1755,34 +1742,35 @@ global void DrawBuilding(const Unit* unit)
     int state;
     int constructed;
 
-    visible=BuildingVisibleOnMap(unit);
-    
-    if( ReplayRevealMap ) {
+    visible = BuildingVisibleOnMap(unit);
+
+    if (ReplayRevealMap) {
 	type = unit->Type;
 	frame = unit->Frame;
-	y=unit->IY;
-	x=unit->IX;
-	state = (unit->Orders[0].Action==UnitActionBuilded) |
-			((unit->Orders[0].Action==UnitActionUpgradeTo) << 1);
+	y = unit->IY;
+	x = unit->IX;
+	state = (unit->Orders[0].Action == UnitActionBuilded) |
+	    ((unit->Orders[0].Action == UnitActionUpgradeTo) << 1);
 	constructed = unit->Constructed;
     } else {
-	y=unit->SeenIY;
-	x=unit->SeenIX;
+	y = unit->SeenIY;
+	x = unit->SeenIX;
 	frame = unit->SeenFrame;
 	type = unit->SeenType;
 	constructed = unit->SeenConstructed;
 	state = unit->SeenState;
     }
 
-    x+=Map2ViewportX(CurrentViewport,unit->X);
-    y+=Map2ViewportY(CurrentViewport,unit->Y);
+    x += Map2ViewportX(CurrentViewport, unit->X);
+    y += Map2ViewportY(CurrentViewport, unit->Y);
 
-    if( frame==UnitNotSeen ) {
-	DebugLevel0Fn("FIXME: Something is wrong, unit %d not seen time %lu?.\n"_C_ unit->Slot _C_ GameCycle);
+    if (frame == UnitNotSeen) {
+	DebugLevel0Fn("FIXME: Something is wrong, unit %d not seen time %lu?.\n" _C_
+	    unit->Slot _C_ GameCycle);
 	return;
     }
-    
-    DrawShadow(unit,x,y);
+
+    DrawShadow(unit, x, y);
 
     //
     //	Show that the unit is selected
@@ -1792,33 +1780,34 @@ global void DrawBuilding(const Unit* unit)
     //
     //	Buildings under construction/upgrade/ready.
     //
-    if( state == 1 ) {
-	if( constructed ) {
-	    DrawConstruction(unit,frame
-		,x+(type->TileWidth*TileSizeX)/2
-		,y+(type->TileHeight*TileSizeY)/2);
+    if (state == 1) {
+	if (constructed) {
+	    DrawConstruction(unit, frame,
+		x + (type->TileWidth * TileSizeX) / 2,
+		y + (type->TileHeight * TileSizeY) / 2);
 	}
     //
     //	Draw the future unit type, if upgrading to it.
     //
-    } else if( state == 2 ) {
+    } else if (state == 2) {
 	// FIXME: this frame is hardcoded!!!
-	GraphicUnitPixels(unit,unit->Orders[0].Type->Sprite);
-	DrawUnitType(unit->Orders[0].Type,frame<0?-1:1,x,y);
+	GraphicUnitPixels(unit, unit->Orders[0].Type->Sprite);
+	DrawUnitType(unit->Orders[0].Type, frame < 0 ? -1 : 1, x, y);
 #ifdef USE_OPENGL
-	DrawUnitPlayerColor(unit->Orders[0].Type,unit->Player->Player,frame<0?-1:1,x,y);
+	DrawUnitPlayerColor(unit->Orders[0].Type, unit->Player->Player,
+	    frame < 0 ? -1 : 1, x, y);
 #endif
     } else {
-	GraphicUnitPixels(unit,type->Sprite);
-	DrawUnitType(type,frame,x,y);
+	GraphicUnitPixels(unit, type->Sprite);
+	DrawUnitType(type, frame, x, y);
 #ifdef USE_OPENGL
-	DrawUnitPlayerColor(type,unit->Player->Player,frame,x,y);
+	DrawUnitPlayerColor(type, unit->Player->Player, frame, x, y);
 #endif
     }
 
     // FIXME: johns: ugly check here, should be removed!
-    if( visible || ReplayRevealMap ) {
-	DrawInformations(unit,type,x,y);
+    if (visible || ReplayRevealMap) {
+	DrawInformations(unit, type, x, y);
     }
 }
 
@@ -1831,21 +1820,21 @@ global void DrawUnit(const Unit* unit)
 {
     int x;
     int y;
-    Graphic* Sprite;
+    Graphic* sprite;
     ResourceInfo* resinfo;
     const UnitType* type;
 
-    if ( unit->Type->Revealer ) {		// Revealers are not drawn
+    if (unit->Type->Revealer) {		// Revealers are not drawn
 	DebugLevel3Fn("Drawing revealer %d\n" _C_ UnitNumber(unit));
 	return;
     }
 
-    x=Map2ViewportX(CurrentViewport,unit->X)+unit->IX;
-    y=Map2ViewportY(CurrentViewport,unit->Y)+unit->IY;
+    x = Map2ViewportX(CurrentViewport, unit->X) + unit->IX;
+    y = Map2ViewportY(CurrentViewport, unit->Y) + unit->IY;
 
-    type=unit->Type;
+    type = unit->Type;
 
-    DrawShadow(unit,x,y);
+    DrawShadow(unit, x, y);
 
     //
     //	Show that the unit is selected
@@ -1854,35 +1843,35 @@ global void DrawUnit(const Unit* unit)
 
     GraphicUnitPixels(unit,type->Sprite);
 
-    Sprite=type->Sprite;
+    sprite = type->Sprite;
     if (type->Harvester && unit->CurrentResource) {
-	resinfo=type->ResInfo[unit->CurrentResource];
+	resinfo = type->ResInfo[unit->CurrentResource];
 	if (unit->Value) {
 	    if (resinfo->SpriteWhenLoaded) {
-		Sprite=resinfo->SpriteWhenLoaded;
+		sprite = resinfo->SpriteWhenLoaded;
 	    }
 	} else {
 	    if (resinfo->SpriteWhenEmpty) {
-		Sprite=resinfo->SpriteWhenEmpty;
+		sprite = resinfo->SpriteWhenEmpty;
 	    }
 	}
     }
-    if( unit->Frame<0 ) {
-	VideoDrawClipX(Sprite,-unit->Frame,
-		x-(type->Width-type->TileWidth*TileSizeX)/2,
-		y-(type->Height-type->TileHeight*TileSizeY)/2);
+    if (unit->Frame < 0) {
+	VideoDrawClipX(sprite, -unit->Frame,
+	    x - (type->Width - type->TileWidth * TileSizeX) / 2,
+	    y - (type->Height - type->TileHeight * TileSizeY) / 2);
     } else {
-	VideoDrawClip(Sprite,unit->Frame,
-		x-(type->Width-type->TileWidth*TileSizeX)/2,
-		y-(type->Height-type->TileHeight*TileSizeY)/2);
+	VideoDrawClip(sprite, unit->Frame,
+	    x - (type->Width - type->TileWidth * TileSizeX) / 2,
+	    y - (type->Height - type->TileHeight * TileSizeY) / 2);
     }
 #ifdef USE_OPENGL
-    DrawUnitPlayerColor(type,unit->Player->Player,unit->Frame,x,y);
+    DrawUnitPlayerColor(type, unit->Player->Player, unit->Frame, x, y);
 #endif
 
 #ifndef NEW_DECODRAW
 // Unit's extras not fully supported.. need to be decorations themselves.
-    DrawInformations(unit,type,x,y);
+    DrawInformations(unit, type, x, y);
 #endif
 }
 
@@ -1899,20 +1888,20 @@ local int DrawLevelCompare(const void* v1, const void* v2) {
     c1 = *(Unit**)v1;
     c2 = *(Unit**)v2;
 
-    if( c1->Orders[0].Action == UnitActionDie && c1->Type->CorpseType) {
+    if (c1->Orders[0].Action == UnitActionDie && c1->Type->CorpseType) {
 	drawlevel1 = c1->Type->CorpseType->DrawLevel;
     } else {
 	drawlevel1 = c1->Type->DrawLevel;
     }
-    if( c2->Orders[0].Action == UnitActionDie && c2->Type->CorpseType) {
+    if (c2->Orders[0].Action == UnitActionDie && c2->Type->CorpseType) {
 	drawlevel2 = c2->Type->CorpseType->DrawLevel;
     } else {
 	drawlevel2 = c2->Type->DrawLevel;
     }
-    if( drawlevel1 == drawlevel2 ) {
-	return c1->Y*MaxMapWidth+c1->X - c2->Y*MaxMapWidth+c2->X ? 
-		c1->Y*MaxMapWidth+c1->X - c2->Y*MaxMapWidth+c2->X : 
-		c1->Slot - c2->Slot;
+    if (drawlevel1 == drawlevel2) {
+	return c1->Y * MaxMapWidth + c1->X - c2->Y * MaxMapWidth + c2->X ? 
+	    c1->Y * MaxMapWidth + c1->X - c2->Y * MaxMapWidth + c2->X : 
+	    c1->Slot - c2->Slot;
     } else {
 	return drawlevel1 <= drawlevel2 ? -1 : 1;
     }
@@ -1940,28 +1929,28 @@ global int FindAndSortUnits(const Viewport* vp, Unit** table)
     //  Add Corpses to the list.
     //
     corpses = &CorpseList;
-    while( *corpses ) {
-	if( UnitVisibleInViewport(vp,*corpses) && !(*corpses)->Destroyed ) {
+    while (*corpses) {
+	if (UnitVisibleInViewport(vp,*corpses) && !(*corpses)->Destroyed) {
 	    table[n++] = *corpses;
 	}
-	corpses=&(*corpses)->Next;
+	corpses = &(*corpses)->Next;
     }
 
     //
     //  Add Destroyed Buildings
     //
     corpses = &DestroyedBuildings;
-    while( *corpses ) {
-	if( UnitVisibleInViewport(vp,*corpses) && !(*corpses)->SeenDestroyed
-		&& (((*corpses)->Visible & 1<<ThisPlayer->Player)
-			|| !(*corpses)->Destroyed)) {
+    while (*corpses) {
+	if (UnitVisibleInViewport(vp, *corpses) && !(*corpses)->SeenDestroyed &&
+		(((*corpses)->Visible & 1 << ThisPlayer->Player) ||
+		    !(*corpses)->Destroyed)) {
 	    table[n++] = *corpses;
 	}
-	corpses=&(*corpses)->Next;
+	corpses = &(*corpses)->Next;
     }
     // Only draw if there are units to draw :)
-    if( n ) {
-	qsort((void *)table,n,sizeof(Unit*),DrawLevelCompare);
+    if (n) {
+	qsort((void *)table, n, sizeof(Unit*), DrawLevelCompare);
     }
 
     return n;
diff --git a/src/unit/unittype.cpp b/src/unit/unittype.cpp
index d090c47b1..666b4a5bd 100644
--- a/src/unit/unittype.cpp
+++ b/src/unit/unittype.cpp
@@ -1315,7 +1315,7 @@ global void LoadUnitTypes(void)
 	type = UnitTypes[i];
 	if ((file = type->ShadowFile)) {
 	    file = strcat(strcpy(buf, "graphics/"), file);
-	    ShowLoadProgress("\tUnit `%s'\n", file);
+	    ShowLoadProgress("Unit `%s'", file);
 	    type->ShadowSprite = LoadSprite(file, type->ShadowWidth,
 		type->ShadowHeight);
 	}
@@ -1326,13 +1326,13 @@ global void LoadUnitTypes(void)
 		if ((resinfo = type->ResInfo[res])) {
 		    if ((file = resinfo->FileWhenLoaded)) {
 			file = strcat(strcpy(buf, "graphics/"), file);
-			ShowLoadProgress("\tUnit `%s'\n", file);
+			ShowLoadProgress("Unit `%s'", file);
 			resinfo->SpriteWhenLoaded = LoadSprite(file, type->Width,
 			    type->Height);
 		    }
 		    if ((file = resinfo->FileWhenEmpty)) {
 			file = strcat(strcpy(buf, "graphics/"), file);
-			ShowLoadProgress("\tUnit `%s'\n", file);
+			ShowLoadProgress("Unit `%s'", file);
 			resinfo->SpriteWhenEmpty = LoadSprite(file, type->Width,
 			    type->Height);
 		    }
@@ -1360,7 +1360,7 @@ global void LoadUnitTypes(void)
 
 	    buf = alloca(strlen(file) + 9 + 1);
 	    file = strcat(strcpy(buf, "graphics/"), file);
-	    ShowLoadProgress("\tUnit `%s'\n", file);
+	    ShowLoadProgress("Unit `%s'", file);
 	    type->Sprite = LoadSprite(file, type->Width, type->Height);
 	}
     }
diff --git a/src/video/cursor.cpp b/src/video/cursor.cpp
index 9a46220ba..b4144fe75 100644
--- a/src/video/cursor.cpp
+++ b/src/video/cursor.cpp
@@ -228,7 +228,7 @@ global void LoadCursors(const char* race)
 
 	    buf = alloca(strlen(file) + 9 + 1);
 	    file = strcat(strcpy(buf,"graphics/"), file);
-	    ShowLoadProgress("\tCursor %s\n", file);
+	    ShowLoadProgress("Cursor %s", file);
 	    Cursors[i].Sprite = LoadSprite(file,
 		Cursors[i].Width, Cursors[i].Height);
 	}
@@ -680,7 +680,8 @@ local void DrawCursor(const CursorType* type, int x, int y, int frame)
 
     //Save (seen) area behind sprite
     CLIP_RECTANGLE(x, y, w, h);
-    SaveCursorBackground(OldCursorX = x, OldCursorY = y, OldCursorW = w, OldCursorH = h);
+    SaveCursorBackground(OldCursorX = x, OldCursorY = y,
+	OldCursorW = w, OldCursorH = h);
 
     //Draw sprite (using its own clipping)  FIXME: prevent clipping twice
     VideoDrawClip(type->Sprite, frame, spritex, spritey);
diff --git a/src/video/font.cpp b/src/video/font.cpp
index f5f947501..af5e4f7d5 100644
--- a/src/video/font.cpp
+++ b/src/video/font.cpp
@@ -871,7 +871,7 @@ global void LoadFonts(void)
 
     for (i = 0; i<sizeof(Fonts) / sizeof(*Fonts); ++i) {
 	if (Fonts[i].File) {
-	    ShowLoadProgress("\tFonts %s\n", Fonts[i].File);
+	    ShowLoadProgress("Fonts %s", Fonts[i].File);
 	    Fonts[i].Graphic = LoadGraphic(Fonts[i].File);
 	    FontMeasureWidths(Fonts + i);
 #ifdef USE_OPENGL
@@ -964,7 +964,7 @@ local SCM CclDefineFont(SCM type, SCM file, SCM width, SCM height)
     i = CclFontByIdentifier(type);
     free(Fonts[i].File);
     VideoSaveFree(Fonts[i].Graphic);
-    Fonts[i].Graphic=NULL;
+    Fonts[i].Graphic = NULL;
     Fonts[i].File = gh_scm2newstr(file, NULL);
     Fonts[i].Width = gh_scm2int(width);
     Fonts[i].Height = gh_scm2int(height);