File tumiki-fighters-dlang_v2.patch of Package tumiki-fighters

Description: port to D language version 2
  With this patch the code is accapted by gdc-4.6 0.29.1-4.6.4-3 without
  triggering deprecated feature warnings/errors.
Author: Peter De Wachter <pdewacht@gmail.com>

--- a/src/abagames/tf/attractmanager.d
+++ b/src/abagames/tf/attractmanager.d
@@ -6,6 +6,7 @@
 module abagames.tf.attractmanager;
 
 private import std.string;
+private import std.conv;
 private import opengl;
 private import abagames.util.sdl.pad;
 private import abagames.tf.gamemanager;
@@ -65,7 +66,7 @@
       if (dr > PrefManager.RANKING_NUM)
 	dr = PrefManager.RANKING_NUM;
       for (int i = 0; i < dr; i++) {
-	char[] rs = std.string.toString(i + 1);
+	string rs = to!string(i + 1);
 	float x = 100;
 	float y = i * 30 + 32;
 	switch (i) {
@@ -91,7 +92,7 @@
 	if (prefManager.ranking[i].stage >= StageManager.STAGE_NUM)
 	  rs = "A";
 	else
-	  rs = std.string.toString(prefManager.ranking[i].stage + 1);
+	  rs = to!string(prefManager.ranking[i].stage + 1);
 	LetterRender.drawString
 	  (rs, 500, y, 9, LetterRender.Direction.TO_RIGHT, 3);
       }
@@ -123,7 +124,7 @@
     glScalef(s, s, s);
     int tx, ty;
     ty = 0;
-    foreach (int[] tpl; TITLE_PTN) {
+    foreach (const(int[]) tpl; TITLE_PTN) {
       tx = 0;
       foreach (int tp; tpl) {
 	int c = TITLE_CLR[ty][tx];
--- a/src/abagames/tf/barragemanager.d
+++ b/src/abagames/tf/barragemanager.d
@@ -17,17 +17,18 @@
  */
 public class BarrageManager {
  private:
-  static BulletMLParserTinyXML *parser[char[]];
-  static const char[] BARRAGE_DIR_NAME = "/usr/share/games/tumiki-fighters/barrage";
+  static BulletMLParserTinyXML *parser[string];
+  static const string BARRAGE_DIR_NAME = "/usr/share/games/tumiki-fighters/barrage";
 
   public static void loadBulletMLs() {
-    char[][] dirs = listdir(BARRAGE_DIR_NAME);
-    foreach (char[] dirName; dirs) {
-      char[][] files = listdir(BARRAGE_DIR_NAME ~ "/" ~ dirName);
-      foreach (char[] fileName; files) {
-	if (getExt(fileName) != "xml")
+    auto dirs = dirEntries(BARRAGE_DIR_NAME, SpanMode.shallow);
+    foreach (string dirName; dirs) {
+      auto files = dirEntries(dirName, SpanMode.shallow);
+      foreach (string fullName; files) {
+        string fileName = baseName(fullName);
+	if (extension(fileName) != ".xml")
 	  continue;
-	char[] barrageName = dirName ~ "/" ~ fileName;
+	string barrageName = baseName(dirName) ~ "/" ~ fileName;
 	Logger.info("Load BulletML: " ~ barrageName);
 	parser[barrageName] = 
 	  BulletMLParserTinyXML_new(std.string.toStringz(BARRAGE_DIR_NAME ~ "/" ~ barrageName));
@@ -42,7 +43,7 @@
     }
   }
 
-  public static BulletMLParserTinyXML* getInstance(char[] fileName) {
+  public static BulletMLParserTinyXML* getInstance(string fileName) {
     return parser[fileName];
   }
 }
--- a/src/abagames/tf/boot.d
+++ b/src/abagames/tf/boot.d
@@ -7,6 +7,7 @@
 
 private import std.c.string;
 private import std.c.stdlib;
+private import std.conv;
 private import abagames.util.logger;
 private import abagames.util.sdl.mainloop;
 private import abagames.util.sdl.pad;
@@ -25,12 +26,12 @@
 PrefManager prefManager;
 MainLoop mainLoop;
 
-private void usage(char[] args0) {
+private void usage(string args0) {
   Logger.error
     ("Usage: " ~ args0 ~ " [-brightness [0-100]] [-window] [-fullscreen] [-res x y] [-nosound] [-reverse]");
 }
 
-private void parseArgs(char[][] args) {
+private void parseArgs(string[] args) {
   for (int i = 1; i < args.length; i++) {
     switch (args[i]) {
     case "-brightness":
@@ -39,7 +40,7 @@
 	throw new Exception("Invalid options");
       }
       i++;
-      float b = cast(float) atoi(args[i]) / 100;
+      float b = cast(float) to!int(args[i]) / 100;
       if (b < 0 || b > 1) {
 	usage(args[0]);
 	throw new Exception("Invalid options");
@@ -58,9 +59,9 @@
 	throw new Exception("Invalid options");
       }
       i++;
-      int w = atoi(args[i]);
+      int w = to!int(args[i]);
       i++;
-      int h = atoi(args[i]);
+      int h = to!int(args[i]);
       Screen.width = w;
       Screen.height = h;
       break;
@@ -80,7 +81,7 @@
   }
 }
 
-public int boot(char[][] args) {
+public int boot(string[] args) {
   screen = new Screen;
   input = new Pad;
   try {
@@ -103,6 +104,7 @@
 // Boot as the Windows executable.
 import std.c.windows.windows;
 import std.string;
+private import std.conv;
 
 extern (C) void gc_init();
 extern (C) void gc_term();
@@ -122,10 +124,10 @@
     _moduleCtor();
     char exe[4096];
     GetModuleFileNameA(null, exe, 4096);
-    char[][1] prog;
-    prog[0] = std.string.toString(exe);
-    result = boot(prog ~ std.string.split(std.string.toString(lpCmdLine)));
-  } catch (Object o) {
+    string[1] prog;
+    prog[0] = to!string(exe);
+    result = boot(prog ~ std.string.split(to!string(lpCmdLine)));
+  } catch (Throwable o) {
     //Logger.error("Exception: " ~ o.toString());
     Logger.info("Exception: " ~ o.toString());
     result = EXIT_FAILURE;
@@ -137,7 +139,7 @@
 } else {
 
 // Boot as the general executable.
-public int main(char[][] args) {
+public int main(string[] args) {
   return boot(args);
 }
 
--- a/src/abagames/tf/bulletactor.d
+++ b/src/abagames/tf/bulletactor.d
@@ -244,7 +244,7 @@
     bullet.pos.y += 
       (cos(bullet.deg) * bullet.speed - bullet.acc.y) * bullet.speedRank * bullet.yReverse;
     if (isVisible) {
-      switch (bullet.type) {
+      switch (bullet.type) { default: break;
       case BulletInst.Type.ENEMY:
 	totalBulletsSpeed += bullet.speed * bullet.speedRank;
 	if (splinters.checkHit(bullet.pos)) {
@@ -291,7 +291,7 @@
     glPushMatrix();
     glTranslatef(bullet.pos.x, bullet.pos.y, 0);
     int s;
-    switch (bullet.shape) {
+    switch (bullet.shape) { default: break;
     case 0:
       glRotatef(rtod(d), 0, 0, 1);
       glScalef(bullet.bulletSize * 0.2, bullet.bulletSize * 0.5, 0.3);
--- a/src/abagames/tf/bulletactorpool.d
+++ b/src/abagames/tf/bulletactorpool.d
@@ -27,7 +27,7 @@
   int cnt;
 
   public this(int n, ActorInitializer ini) {
-    auto BulletActor bulletActorClass = new BulletActor;
+    scope BulletActor bulletActorClass = new BulletActor;
     super(n, bulletActorClass, ini);
     Bullet.setBulletsManager(this);
     BulletActor.init();
@@ -98,7 +98,7 @@
     ba.set(runner, x, y, deg, speed, 
 	   ranks[0], speeds[0], 
 	   shape, color, size, xReverse, yReverse, target, type,
-	   parser, ranks, speeds, parser.length, 0);
+	   parser, ranks, speeds, cast(uint)parser.length, 0);
     ba.setWait(prevWait, postWait);
     ba.setTop();
     return ba;
--- a/src/abagames/tf/bullettarget.d
+++ b/src/abagames/tf/bullettarget.d
@@ -3,7 +3,7 @@
  *
  * Copyright 2004 Kenta Cho. All rights reserved.
  */
-module abagames.tf.bullettaget;
+module abagames.tf.bullettarget;
 
 private import abagames.util.vector;
 
--- a/src/abagames/tf/damagegauge.d
+++ b/src/abagames/tf/damagegauge.d
@@ -19,7 +19,7 @@
   DamageGaugeItem[3] item;
 
   public this() {
-    foreach (inout DamageGaugeItem dgi; item)
+    foreach (ref DamageGaugeItem dgi; item)
       dgi = new DamageGaugeItem;
   }
 
--- a/src/abagames/tf/enemy.d
+++ b/src/abagames/tf/enemy.d
@@ -69,7 +69,7 @@
     gauge = ei.gauge;
     pos = new Vector;
     mv = new EnemyMovement;
-    foreach (inout EnemyPart ep; parts)
+    foreach (ref EnemyPart ep; parts)
       ep = new EnemyPart(ship, bullets, fragments);
   }
 
@@ -399,7 +399,7 @@
  private:
 
   public this(int n, ActorInitializer ini) {
-    auto Enemy enemyClass = new Enemy;
+    scope Enemy enemyClass = new Enemy;
     super(n, enemyClass, ini);
   }
 
@@ -437,7 +437,7 @@
     this.target = target;
     this.bullets = bullets;
     this.fragments = fragments;
-    foreach (inout EnemyTopBullet etb; topBullet)
+    foreach (ref EnemyTopBullet etb; topBullet)
       etb = new EnemyTopBullet;
   }
 
@@ -497,8 +497,8 @@
 	etb.actor.bullet.pos.x = x + ofsx;
 	etb.actor.bullet.pos.y = y + ofsy;
 	if (coverPartsNum > 0 && !etb.coverChecked) {
-	  for (int i = 0; i < coverPartsNum; i++) {
-	    if (coverParts[i].shield > 0 && coverParts[i].covers(ofsx, ofsy)) {
+	  for (int j = 0; j < coverPartsNum; j++) {
+	    if (coverParts[j].shield > 0 && coverParts[j].covers(ofsx, ofsy)) {
 	      etb.actor.removeForced();
 	      etb.actor = null;
 	      etb.deactivated = true;
--- a/src/abagames/tf/enemyspec.d
+++ b/src/abagames/tf/enemyspec.d
@@ -6,6 +6,7 @@
 module abagames.tf.enemyspec;
 
 private import std.string;
+private import std.conv;
 private import abagames.util.vector;
 private import abagames.util.csv;
 private import abagames.util.iterator;
@@ -21,26 +22,26 @@
   AttackForm[] attackForm;
   float sizeXm, sizeXp, sizeYm, sizeYp;
  private:
-  static EnemySpec[char[]] instances;
-  static const char[] ENEMYSPEC_DIR_NAME = "/usr/share/games/tumiki-fighters/enemy";
+  static EnemySpec[string] instances;
+  static const string ENEMYSPEC_DIR_NAME = "/usr/share/games/tumiki-fighters/enemy";
 
   // Initialize EnemySpec with the array.
   // Tumiki file name(main),
   // [shield, [attackPeriod, breakPeriod]],
   // (end when breakPeriod == e, shield == e)
   // [Tumiki file name(part), x, y, shield, destroyedFormIdx, damageToMainBody],
-  private this(char[][] data) {
+  private this(string[] data) {
     StringIterator si = new StringIterator(data);
-    char[] fn = si.next;
+    string fn = si.next;
     EnemyPartSpec bodySpec = new EnemyPartSpec(fn);
     parts ~= bodySpec;
     bool bodyShieldSet = false;
     int ai = 0;
     for (;;) {
-      char[] v = si.next;
+      string v = si.next;
       if (v == "e")
 	break;
-      float shield = atof(v);
+      float shield = to!float(v);
       if (!bodyShieldSet) {
 	bodySpec.shield = shield;
 	bodyShieldSet = true;
@@ -50,8 +51,8 @@
 	v = si.next;
 	if (v == "e")
 	  break;
-	int attackPeriod = atoi(v);
-	int breakPeriod = atoi(si.next);
+	int attackPeriod = to!int(v);
+	int breakPeriod = to!int(si.next);
 	af.addPeriod(attackPeriod, breakPeriod);
 	ai++;
       }
@@ -60,13 +61,13 @@
     for (;;) {
       if (!si.hasNext)
 	break;
-      char[] fn = si.next;
-      float x = atof(si.next);
-      float y = atof(si.next);
-      float shield = atof(si.next);
-      int dfi = atoi(si.next);
-      float dtm = atof(si.next);
-      EnemyPartSpec tp = new EnemyPartSpec(fn, x, y, shield, dfi, dtm);
+      string fn_ = si.next;
+      float x = to!float(si.next);
+      float y = to!float(si.next);
+      float shield = to!float(si.next);
+      int dfi = to!int(si.next);
+      float dtm = to!float(si.next);
+      EnemyPartSpec tp = new EnemyPartSpec(fn_, x, y, shield, dfi, dtm);
       parts ~= tp;
     }
     sizeXm = sizeYm = float.max;
@@ -83,12 +84,12 @@
     }
   }
 
-  private this(char[] fileName) {
-    char[][] data = CSVTokenizer.readFile(ENEMYSPEC_DIR_NAME ~ "/" ~ fileName);
+  private this(string fileName) {
+    string[] data = CSVTokenizer.readFile(ENEMYSPEC_DIR_NAME ~ "/" ~ fileName);
     this(data);
   }
 
-  public static EnemySpec getInstance(char[] fileName) {
+  public static EnemySpec getInstance(string fileName) {
     if ((fileName in instances) == null) {
       Logger.info("Load enemy spec: " ~ fileName);
       instances[fileName] = new EnemySpec(fileName);
@@ -107,20 +108,20 @@
 
  private:
 
-  public this(char[] fileName) {
+  public this(string fileName) {
     tumikiSet = TumikiSet.getInstance(fileName);
     ofs = new Vector;
     destroyedFormIdx = 99999;
     damageToMainBody = 0;
   }
 
-  public this(char[] fileName, float x, float y) {
+  public this(string fileName, float x, float y) {
     this(fileName);
     ofs.x = x;
     ofs.y = y;
   }  
 
-  public this(char[] fileName, float x, float y, float s, int dfi, float dtm) {
+  public this(string fileName, float x, float y, float s, int dfi, float dtm) {
     this(fileName, x, y);
     shield = s;
     destroyedFormIdx = dfi;
--- a/src/abagames/tf/field.d
+++ b/src/abagames/tf/field.d
@@ -6,6 +6,7 @@
 module abagames.tf.field;
 
 private import std.string;
+private import std.conv;
 private import std.math;
 private import opengl;
 private import abagames.util.vector;
@@ -41,14 +42,14 @@
     size.y = 16;
     eyeZ = 20;
     uint sn = 1;
-    foreach (inout FieldPattern fp; fieldPattern) {
-      Logger.info("Load field: " ~ std.string.toString(sn));
-      fp = new FieldPattern("fld" ~ std.string.toString(sn) ~ ".fld");
+    foreach (ref FieldPattern fp; fieldPattern) {
+      Logger.info("Load field: " ~ to!string(sn));
+      fp = new FieldPattern("fld" ~ to!string(sn) ~ ".fld");
       sn++;
     }
     Logger.info("Load fields completed.");
-    auto FieldObj fieldObjClass = new FieldObj;
-    auto FieldObjInitializer foi = new FieldObjInitializer(this);
+    scope FieldObj fieldObjClass = new FieldObj;
+    scope FieldObjInitializer foi = new FieldObjInitializer(this);
     fieldObjs = new ActorPool(64, fieldObjClass, foi);
     rand = new Rand;
   }
@@ -61,7 +62,7 @@
     rand.setSeed(pattern.randSeed);
     Screen.setClearColor(pattern.br, pattern.bg, pattern.bb, 1);
     foreach (FieldLinePattern flp; pattern.line)
-      flp.cnt = flp.interval[rand.nextInt(flp.interval.length)];
+      flp.cnt = flp.interval[rand.nextInt(cast(uint)flp.interval.length)];
     fieldObjs.clear();
     float x = 0, nx, tx, ty;
     for (int i = 0; i < 4; i++) {
@@ -86,13 +87,13 @@
       if (flp.cnt <= 0) {
 	FieldObj fo = cast(FieldObj) fieldObjs.getInstance();
 	if (fo) {
-	  TumikiSet ts = flp.tumikiSet[rand.nextInt(flp.tumikiSet.length)];
+	  TumikiSet ts = flp.tumikiSet[rand.nextInt(cast(uint)flp.tumikiSet.length)];
 	  if (flp.onGround)
 	    fo.setGround(ts, flp.z, pattern.scrollSpeed);
 	  else
 	    fo.setSky(ts, flp.z, pattern.scrollSpeed / 3 * 2, rand);
 	}
-	flp.cnt = flp.interval[rand.nextInt(flp.interval.length)];
+	flp.cnt = flp.interval[rand.nextInt(cast(uint)flp.interval.length)];
       }
     }
     mnx += pattern.scrollSpeed;
@@ -249,26 +250,26 @@
   float mtr, mtg, mtb;
   float mrr, mrg, mrb;
  private:
-  static const char[] FIELD_DIR_NAME = "/usr/share/games/tumiki-fighters/field";
+  static const string FIELD_DIR_NAME = "/usr/share/games/tumiki-fighters/field";
   
   // Initialize FieldPattern with the array.
   // randSeed, scrollSpeed,
   // [z, [interval], [TumikiSetName]]
   // (end when interval == "e", TumikiSetName == "e")
-  public this(char[][] data) {
+  public this(string[] data) {
     StringIterator si = new StringIterator(data);
-    randSeed = atoi(si.next);
-    scrollSpeed = atof(si.next);
-    br = atof(si.next); bg = atof(si.next); bb = atof(si.next);
-    gr = atof(si.next); gg = atof(si.next); gb = atof(si.next);
-    mtr = atof(si.next); mtg = atof(si.next); mtb = atof(si.next);
+    randSeed = to!int(si.next);
+    scrollSpeed = to!float(si.next);
+    br = to!float(si.next); bg = to!float(si.next); bb = to!float(si.next);
+    gr = to!float(si.next); gg = to!float(si.next); gb = to!float(si.next);
+    mtr = to!float(si.next); mtg = to!float(si.next); mtb = to!float(si.next);
     mrr = (br * 2+ gr) / 3;
     mrg = (bg * 2+ gg) / 3;
     mrb = (bb * 2+ gb) / 3;
     for (;;) {
       if (!si.hasNext)
 	break;
-      float z = atof(si.next);
+      float z = to!float(si.next);
       FieldLinePattern flp = new FieldLinePattern;
       if (z > 0) {
 	flp.z = -z;
@@ -278,13 +279,13 @@
 	flp.onGround = false;
       }
       for (;;) {
-	char[] v = si.next;
+	string v = si.next;
 	if (v == "e")
 	  break;
-	flp.addInterval(atoi(v));
+	flp.addInterval(to!int(v));
       }
       for (;;) {
-	char[] v = si.next;
+	string v = si.next;
 	if (v == "e")
 	  break;
 	flp.addTumikiSet(TumikiSet.getInstance(v));
@@ -293,8 +294,8 @@
     }
   }
 
-  public this(char[] fileName) {
-    char[][] data = CSVTokenizer.readFile(FIELD_DIR_NAME ~ "/" ~ fileName);
+  public this(string fileName) {
+    string[] data = CSVTokenizer.readFile(FIELD_DIR_NAME ~ "/" ~ fileName);
     this(data);
   }
 }
--- a/src/abagames/tf/gamemanager.d
+++ b/src/abagames/tf/gamemanager.d
@@ -6,6 +6,7 @@
 module abagames.tf.gamemanager;
 
 private import std.math;
+private import std.conv;
 private import opengl;
 private import SDL;
 private import bulletml;
@@ -92,7 +93,7 @@
   int credit;
 
   // Initialize actor pools, load BGMs/SEfs and textures.
-  public void init() {
+  public override void init() {
     BarrageManager.loadBulletMLs();
     pad = cast(Pad) input;
     prefManager = cast(PrefManager) abstPrefManager;
@@ -101,28 +102,28 @@
     rand = new Rand;
     field = new Field;
     field.init();
-    auto ParticleInitializer pi = new ParticleInitializer;
+    scope ParticleInitializer pi = new ParticleInitializer;
     particles = new ParticlePool(128, pi);
-    auto Fragment fragmentClass = new Fragment;
-    auto FragmentInitializer fi = new FragmentInitializer;
+    scope Fragment fragmentClass = new Fragment;
+    scope FragmentInitializer fi = new FragmentInitializer;
     fragments = new ActorPool(128, fragmentClass, fi);
     ship = new Ship;
     ship.init(pad, field, particles, fragments, this);
-    auto SplinterInitializer si = new SplinterInitializer(ship, field, particles, this);
+    scope SplinterInitializer si = new SplinterInitializer(ship, field, particles, this);
     splinters = new SplinterPool(144, si);
-    auto BulletActorInitializer bi = new BulletActorInitializer(field, ship, particles, splinters);
+    scope BulletActorInitializer bi = new BulletActorInitializer(field, ship, particles, splinters);
     bullets = new BulletActorPool(512, bi);
     ship.setBulletActorPool(bullets);
     ship.initStuckEnemies(splinters);
     gauge = new DamageGauge;
-    auto EnemyInitializer ei = new EnemyInitializer
+    scope EnemyInitializer ei = new EnemyInitializer
       (this, field, bullets, ship, splinters, particles, fragments, gauge);
     enemies = new EnemyPool(64, ei);
     bullets.setEnemies(enemies);
-    auto ScoreSignInitializer ssi = new ScoreSignInitializer;
-    auto ScoreSign scoreSignClass = new ScoreSign;
+    scope ScoreSignInitializer ssi = new ScoreSignInitializer;
+    scope ScoreSign scoreSignClass = new ScoreSign;
     signs = new ActorPool(32, scoreSignClass, ssi);
-    auto MobileLetterInitializer mli = new MobileLetterInitializer;
+    scope MobileLetterInitializer mli = new MobileLetterInitializer;
     letters = new MobileLetterPool(32, mli, field);
     stageManager = new StageManager(this, enemies, field);
     bullets.setStageManager(stageManager);
@@ -132,12 +133,12 @@
     LetterRender.createDisplayLists();
   }
 
-  public void start() {
+  public override void start() {
     stage = 0;
     startTitle();
   }
 
-  public void close() {
+  public override void close() {
     BarrageManager.unloadBulletMLs();
     SoundManager.close();
     LetterRender.deleteDisplayLists();
@@ -204,7 +205,7 @@
     state = State.IN_GAME;
   }
 
-  private const char[][] stageMessage = 
+  private const string[] stageMessage = 
     [
      "WE ARE TUMIKI FIGHTERS!",
      "JUST OVER THE HORIZON",
@@ -225,7 +226,7 @@
     gauge.init();
     bossTimer = BOSSTIMER_FREEZED;
     bossDstCnt = -1;
-    letters.add("STAGE " ~ std.string.toString(stage + 1), 180, 150, 24, 240, -4);
+    letters.add("STAGE " ~ to!string(stage + 1), 180, 150, 24, 240, -4);
     letters.add(stageMessage[stage], 320 - stageMessage[stage].length * 10, 270, 10, 240, -2);
     int si = stage % (SoundManager.STAGE_BGM_NUM * 2 - 1);
     if (si >= SoundManager.STAGE_BGM_NUM)
@@ -306,12 +307,12 @@
   }
 
   // Move actors in game(called once per frame).
-  public void move() {
+  public override void move() {
     if (pad.keys[SDLK_ESCAPE] == SDL_PRESSED) {
       mainLoop.breakLoop();
       return;
     }
-    switch (state) {
+    switch (state) { default: break;
     case State.START_GAME:
     case State.IN_GAME:
     case State.END_GAME:
@@ -479,7 +480,7 @@
   }
 
   // Draw actors in game(called once per frame).
-  public void draw() {
+  public override void draw() {
     SDL_Event e = mainLoop.event;
     if (e.type == SDL_VIDEORESIZE) {
       SDL_ResizeEvent re = e.resize;
@@ -495,7 +496,7 @@
 
     glPushMatrix();
     setEyepos();
-    switch (state) {
+    switch (state) { default: break;
     case State.START_GAME:
     case State.IN_GAME:
     case State.PAUSE:
@@ -514,7 +515,7 @@
     screen.viewOrthoFixed();
     glDisable(GL_CULL_FACE);
     letters.draw();
-    switch (state) {
+    switch (state) { default: break;
     case State.IN_GAME:
       drawStatusInGame();
       break;
@@ -616,7 +617,7 @@
 	LetterRender.drawString("YES", 483, 402, 8, LetterRender.Direction.TO_RIGHT, 2);
 	LetterRender.drawString("NO", 560, 400, 12, LetterRender.Direction.TO_RIGHT, 0);
       }
-      LetterRender.drawString("CREDIT " ~ std.string.toString(credit), 32, 420, 8, 
+      LetterRender.drawString("CREDIT " ~ to!string(credit), 32, 420, 8, 
 			      LetterRender.Direction.TO_RIGHT, 3);
     }
   }
--- a/src/abagames/tf/letterrender.d
+++ b/src/abagames/tf/letterrender.d
@@ -19,8 +19,8 @@
   static const float LETTER_WIDTH = 2.1f;
   static const float LETTER_HEIGHT = 3.0f;
   static const int COLOR_NUM = 6;
- private:
   static const int LETTER_NUM = 43;
+ private:
   static const int DISPLAY_LIST_NUM = LETTER_NUM * COLOR_NUM;
   static Rand rand;
 
@@ -76,7 +76,7 @@
     return idx;
   }
 
-  public static void drawString(char[] str, float lx, float y, float s, int d, int cl, 
+  public static void drawString(string str, float lx, float y, float s, int d, int cl, 
 				bool rev) {
     if (cl < 0)
       rand.setSeed(-cl);
@@ -85,7 +85,7 @@
     float x = lx;
     int idx;
     float ld;
-    switch (d) {
+    switch (d) { default: break;
     case Direction.TO_RIGHT:
       ld = 0;
       break;
@@ -114,7 +114,7 @@
 	    drawLetter(idx, x, y, s, ld, rand.nextInt(COLOR_NUM));
 	}
       }
-      switch(d) {
+      switch(d) { default: break;
       case Direction.TO_RIGHT:
 	x += s * LETTER_WIDTH;
 	break;
@@ -131,7 +131,7 @@
     }
   }
 
-  public static void drawString(char[] str, float lx, float y, float s, int d, int cl) {
+  public static void drawString(string str, float lx, float y, float s, int d, int cl) {
     drawString(str, lx, y, s, d, cl, false);
   }
 
@@ -141,7 +141,7 @@
     int n = num;
     float x = lx;
     float ld;
-    switch (d) {
+    switch (d) { default: break;
     case Direction.TO_RIGHT:
       ld = 0;
       break;
@@ -157,7 +157,7 @@
     }
     for (;;) {
       drawLetter(n % 10, x, y, s, ld, cl);
-      switch(d) {
+      switch(d) { default: break;
       case Direction.TO_RIGHT:
 	x -= s * LETTER_WIDTH;
 	break;
--- a/src/abagames/tf/mobileletter.d
+++ b/src/abagames/tf/mobileletter.d
@@ -31,8 +31,8 @@
   float size;
   int cnt;
 
-  public static this() {
-    rand = new Rand;
+  public this() {
+    if (rand is null) rand = new Rand;
   }
 
   public override Actor newActor() {
@@ -103,12 +103,12 @@
   
   public this(int n, ActorInitializer ini, Field f) {
     field = f;
-    auto MobileLetter mlClass = new MobileLetter;
+    scope MobileLetter mlClass = new MobileLetter;
     super(n, mlClass, ini);
     rand = new Rand;
   }
 
-  public void add(char[] str, float x, float lgt, float size, int cnt, int col) {
+  public void add(string str, float x, float lgt, float size, int cnt, int col) {
     int color = col;
     if (col < 0)
       rand.setSeed(-col);
--- a/src/abagames/tf/particle.d
+++ b/src/abagames/tf/particle.d
@@ -30,8 +30,8 @@
   int type;
   int cnt;
 
-  public static this() {
-    rand = new Rand;
+  public this() {
+    if (rand is null) rand = new Rand;
   }
 
   public override Actor newActor() {
@@ -67,7 +67,7 @@
     pos.add(vel);
     vel.mul(0.9);
     alpha *= 0.9;
-    switch (type) {
+    switch (type) { default: break;
     case TypeName.SMOKE:
       size *= 1.025;
       break;
@@ -78,12 +78,12 @@
   }
 
   public override void draw() {
-    switch (type) {
+    switch (type) { default: break;
     case TypeName.SMOKE:
       Screen.setColor(0.8, 0.8, 0.8, alpha);
       break;
     case TypeName.SPARK:
-      if (cnt & 1 == 0)
+      if ((cnt & 1) == 0)
 	Screen.setColor(1, 0.4, 0.2, alpha);
       else
 	Screen.setColor(1, 1, 0.1, alpha);
@@ -103,7 +103,7 @@
  private:
   
   public this(int n, ActorInitializer ini) {
-    auto Particle particleClass = new Particle;
+    scope Particle particleClass = new Particle;
     super(n, particleClass, ini);
   }
 
--- a/src/abagames/tf/prefmanager.d
+++ b/src/abagames/tf/prefmanager.d
@@ -7,6 +7,7 @@
 
 private import std.stream;
 private import std.string;
+private import std.conv;
 private import std.c.stdlib;
 private import abagames.util.prefmanager;
 
@@ -16,21 +17,21 @@
 public class PrefManager: abagames.util.prefmanager.PrefManager {
  public:
   static const int VERSION_NUM = 20;
-  static const char[] PREF_FILE = ".tumiki-fighters.prf";
+  static const string PREF_FILE = ".tumiki-fighters.prf";
   static const int RANKING_NUM = 10;
   static const int DEFAULT_HISCORE = 10000;
   RankingItem[RANKING_NUM] ranking;
 
   public this() {
-    foreach (inout RankingItem ri; ranking)
+    foreach (ref RankingItem ri; ranking)
       ri = new RankingItem;
   }
 
-  public static char[] home_dir() {
-    char * home = getenv("HOME");
+  public static string home_dir() {
+    const(char)* home = getenv("HOME");
     if (home is null)
       throw new Error("HOME environment variable is not defined");
-    return std.string.toString(home);
+    return to!string(home);
   }
 
   private void init() {
@@ -43,7 +44,7 @@
   }
 
   public void load() {
-    auto File fd = new File;
+    scope File fd = new File;
     try {
       int ver;
       fd.open(home_dir() ~ "/" ~ PREF_FILE);
@@ -60,7 +61,7 @@
   }
 
   public void save() {
-    auto File fd = new File;
+    scope File fd = new File;
     fd.create(home_dir() ~ "/" ~ PREF_FILE);
     fd.write(VERSION_NUM);
     foreach (RankingItem ri; ranking)
--- a/src/abagames/tf/screen.d
+++ b/src/abagames/tf/screen.d
@@ -3,7 +3,7 @@
  *
  * Copyright 2004 Kenta Cho. All rights reserved.
  */
-module abagames.tf.playscreen;
+module abagames.tf.screen;
 
 private import std.math;
 private import opengl;
@@ -14,7 +14,7 @@
  */
 public class Screen: Screen3D {
  public:
-  static const char[] CAPTION = "TUMIKI Fighters";
+  static const string CAPTION = "TUMIKI Fighters";
 
   protected override void init() {
     setCaption(CAPTION);
--- a/src/abagames/tf/ship.d
+++ b/src/abagames/tf/ship.d
@@ -88,7 +88,7 @@
     target = new VirtualBulletTarget;
     etb[0] = new EnemyTopBullet;
     createTumiki();
-    foreach (inout Vector fp; friendPos) {
+    foreach (ref Vector fp; friendPos) {
       fp = new Vector;
     }
   }
--- a/src/abagames/tf/soundmanager.d
+++ b/src/abagames/tf/soundmanager.d
@@ -28,14 +28,14 @@
   GameManager manager;
   Music bgm[BGM_NUM];
   Chunk se[SE_NUM];
-  const char[][] bgmFileName = 
+  const string[] bgmFileName = 
     ["we_are_tumiki_fighters.ogg",
     "just_over_the_horizon.ogg",
     "panic_on_meadow.ogg",
     "here_comes_a_gigantic_toy.ogg",
     "battle_over_the_junk_city.ogg",
     "return_to_home.ogg"];
-  const char[][] seFileName = 
+  const string[] seFileName = 
     ["ship_shot.wav", "stuck.wav", "stuck_bonus.wav",
     "stuck_destroyed.wav", "ship_destroyed.wav",
     "enemy_damaged.wav", "small_enemy_destroyed.wav", "enemy_destroyed.wav", "boss_destroyed.wav",
@@ -52,13 +52,13 @@
     if (Sound.noSound)
       return;
     int i = 0;
-    foreach (inout Music b; bgm) {
+    foreach (ref Music b; bgm) {
       b = new Music;
       b.load(bgmFileName[i]);
       i++;
     }
     i = 0;
-    foreach (inout Chunk c; se) {
+    foreach (ref Chunk c; se) {
       c = new Chunk;
       c.load(seFileName[i], seChannel[i]);
       i++;
--- a/src/abagames/tf/splinter.d
+++ b/src/abagames/tf/splinter.d
@@ -40,8 +40,8 @@
   bool isBoss;
   bool flyin;
 
-  public static this() {
-    rand = new Rand;
+  public this() {
+    if (rand is null) rand = new Rand;
   }
 
   public static void setSignNum(int n) {
@@ -60,7 +60,7 @@
     manager = si.manager;
     pos = new Vector;
     vel = new Vector;
-    foreach (inout Vector cd; colDatums)
+    foreach (ref Vector cd; colDatums)
       cd = new Vector;
   }
 
@@ -153,8 +153,8 @@
       }
       if (ship.cnt < -Ship.INVINCIBLE_CNT)
 	return;
-      foreach (Vector cd; colDatums) {
-	if (ship.stuckEnemies.checkHit(cd)) {
+      foreach (Vector cd_; colDatums) {
+	if (ship.stuckEnemies.checkHit(cd_)) {
 	  StuckEnemy se = cast(StuckEnemy) ship.stuckEnemies.getInstance();
 	  if (se) {
 	    float ox = pos.x - ship.pos.x, oy = pos.y - ship.pos.y;
@@ -228,7 +228,7 @@
  private:
   
   public this(int n, ActorInitializer ini) {
-    auto Splinter splinterClass = new Splinter;
+    scope Splinter splinterClass = new Splinter;
     super(n, splinterClass, ini);
   }
 
--- a/src/abagames/tf/stagemanager.d
+++ b/src/abagames/tf/stagemanager.d
@@ -6,6 +6,7 @@
 module abagames.tf.stagemanager;
 
 private import std.string;
+private import std.conv;
 private import std.math;
 private import bulletml;
 private import abagames.util.logger;
@@ -52,13 +53,13 @@
     this.enemies = enemies;
     this.field = field;
     rand = new Rand;
-    foreach (inout EnemyAppearance ea; appearance)
+    foreach (ref EnemyAppearance ea; appearance)
       ea = new EnemyAppearance;
     eaIdx = appearance.length;
     uint sn = 1;
-    foreach (inout StagePattern sp; stage) {
-      Logger.info("Load stage: " ~ std.string.toString(sn));
-      sp = new StagePattern("stg" ~ std.string.toString(sn) ~ ".stg");
+    foreach (ref StagePattern sp; stage) {
+      Logger.info("Load stage: " ~ to!string(sn));
+      sp = new StagePattern("stg" ~ to!string(sn) ~ ".stg");
       sn++;
     }
     Logger.info("Load stages completed.");
@@ -124,7 +125,7 @@
       if ((ea.cnt % ea.pattern.interval) == 0) {
 	EnemyAppearancePattern p = ea.pattern;
 	float x, y;
-	switch (p.posType) {
+	switch (p.posType) { default: break;
 	case EnemyAppearancePattern.AppearancePos.FRONT:
 	  x = field.size.x - p.spec.sizeXm * 1.1f;
 	  y = field.size.y * (p.pos + rand.nextSignedFloat(p.width));
@@ -171,8 +172,8 @@
   long randSeed;
   int warningCnt;
  private:
-  static const char[] STAGE_DIR_NAME = "/usr/share/games/tumiki-fighters/stage";
-  static int[char[]] posTypeStr;
+  static const string STAGE_DIR_NAME = "/usr/share/games/tumiki-fighters/stage";
+  static int[string] posTypeStr;
 
   public static this() {
     posTypeStr["f"] = 0;
@@ -186,20 +187,20 @@
   // EnemySpec file name,
   // move BulletML file name, {speedRank}/{withdrawCnt, speed, [x, y], [idx, speed, [x, y]]}],
   // (use PointsMovePattern when moveBulletML == "p", end when x == "e", idx == "e")
-  public this(char[][] data) {
+  public this(string[] data) {
     StringIterator si = new StringIterator(data);
-    randSeed = atoi(si.next);
-    warningCnt = atoi(si.next);
+    randSeed = to!int(si.next);
+    warningCnt = to!int(si.next);
     for (;;) {
       if (!si.hasNext)
 	break;
-      int startTime = atoi(si.next);
-      int duration = atoi(si.next);
-      int interval = atoi(si.next);
-      char[] v = si.next;
+      int startTime = to!int(si.next);
+      int duration = to!int(si.next);
+      int interval = to!int(si.next);
+      string v = si.next;
       int posType = posTypeStr[v];
-      float pos = atof(si.next);
-      float width = atof(si.next);
+      float pos = to!float(si.next);
+      float width = to!float(si.next);
       v = si.next;
       bool wted;
       if (v == "y")
@@ -214,29 +215,29 @@
       v = si.next;
       if (v == "p") {
 	eap.startSetPointsMove();
-	eap.setWithdrawCnt(atoi(si.next));
+	eap.setWithdrawCnt(to!int(si.next));
 	int atIdx = PointsMovePattern.BASIC_PATTERN_IDX;
 	for (;;) {
-	  float speed = atof(si.next);
+	  float speed = to!float(si.next);
 	  eap.setMoveSpeed(atIdx, speed);
 	  for (;;) {
 	    v = si.next;
 	    if (v == "e")
 	      break;
-	    float x = atof(v);
-	    float y = atof(si.next);
+	    float x = to!float(v);
+	    float y = to!float(si.next);
 	    eap.addMovePoint(atIdx, x, y);
 	  }
 	  v = si.next;
 	  if (v == "e")
 	    break;
-	  atIdx = atoi(v);
+	  atIdx = to!int(v);
 	}
       } else {
 	eap.setMoveBulletML(v);
-	eap.setSpeedRank(atof(si.next));
+	eap.setSpeedRank(to!float(si.next));
       }
-      switch (posType) {
+      switch (posType) { default: break;
       case EnemyAppearancePattern.AppearancePos.FRONT:
 	d = PI / 2 * 3;
 	break;
@@ -249,8 +250,8 @@
     }
   }
 
-  public this(char[] fileName) {
-    char[][] data = CSVTokenizer.readFile(STAGE_DIR_NAME ~ "/" ~ fileName);
+  public this(string fileName) {
+    string[] data = CSVTokenizer.readFile(STAGE_DIR_NAME ~ "/" ~ fileName);
     this(data);
   }
 }
@@ -298,7 +299,7 @@
     (cast(PointsMovePattern) move).point[idx] ~= new Vector(x, y);
   }
 
-  public void setMoveBulletML(char[] fn) {
+  public void setMoveBulletML(string fn) {
     move = new BulletMLMovePattern;
     (cast(BulletMLMovePattern) move).parser = BarrageManager.getInstance(fn);
     if (!(cast(BulletMLMovePattern) move).parser)
--- a/src/abagames/tf/stuckenemy.d
+++ b/src/abagames/tf/stuckenemy.d
@@ -69,9 +69,9 @@
     lofs = new Vector;
     pos = new Vector;
     target = new VirtualBulletTarget;
-    foreach (inout Vector cd; colDatums)
+    foreach (ref Vector cd; colDatums)
       cd = new Vector;
-    foreach (inout EnemyTopBullet etb; topBullet)
+    foreach (ref EnemyTopBullet etb; topBullet)
       etb = new EnemyTopBullet;
   }
 
@@ -328,7 +328,7 @@
   GameManager manager;
 
   public this(int n, ActorInitializer ini) {
-    auto StuckEnemy seClass = new StuckEnemy;
+    scope StuckEnemy seClass = new StuckEnemy;
     super(n, seClass, ini);
     manager = (cast(StuckEnemyInitializer) ini).manager;
   }
--- a/src/abagames/tf/tumiki.d
+++ b/src/abagames/tf/tumiki.d
@@ -32,7 +32,7 @@
   Barrage[] barrage;
   static int propellerCnt = 0;
 
-  private final const float CHECK_HIT_SIZE_RETIO = 0.7;
+  private const float CHECK_HIT_SIZE_RETIO = 0.7;
 
   public this(int shape, int color,
 	      float x, float y, float sx, float sy, float sizeRatio) {
@@ -218,10 +218,10 @@
     return checkDistHit(p.x - px, p.y - py, ofs, size);
   }
 
-  private static const int DISPLAY_LIST_NUM = SHAPE_NUM * COLOR_NUM * SHADE_NUM;
   public static const int COLOR_NUM = 12;
   public static const int DAMAGED_COLOR = 6;
   public static const int WOUNDED_COLOR = 0;
+  private static const int DISPLAY_LIST_NUM = SHAPE_NUM * COLOR_NUM * SHADE_NUM;
   private static const float[3][COLOR_NUM] colorParams = 
     [
      [0.9, 0.6, 0.6], [0.6, 0.9, 0.6], [0.6, 0.6, 0.9],
@@ -251,7 +251,7 @@
   }
 
   private static void setSideColor(int j, int i) {
-    switch (i) {
+    switch (i) { default: break;
     case 0:
       Screen.setColor
 	(colorParams[j][0] * 0.7, colorParams[j][1] * 0.7, colorParams[j][2] * 0.7); 
@@ -506,7 +506,7 @@
     this.postWait = postWait;
   }
 
-  public void addBml(char[] bmlFileName, float r, float s) {
+  public void addBml(string bmlFileName, float r, float s) {
     BulletMLParser *p = BarrageManager.getInstance(bmlFileName);
     if (!p)
       throw new Error("File not found: " ~ bmlFileName);
@@ -523,7 +523,7 @@
       return null;
     int cl;
     float xrev, yrev;
-    switch (type) {
+    switch (type) { default: break;
     case BulletInst.Type.ENEMY:
       cl = color;
       xrev = yrev = 1;
--- a/src/abagames/tf/tumikiset.d
+++ b/src/abagames/tf/tumikiset.d
@@ -6,6 +6,7 @@
 module abagames.tf.tumikiset;
 
 private import std.string;
+private import std.conv;
 private import std.math;
 private import abagames.util.vector;
 private import abagames.util.csv;
@@ -28,42 +29,42 @@
   int score, fireScore, fireScoreInterval;
   float sizeXm, sizeXp, sizeYm, sizeYp, size;
  private:
-  static TumikiSet[char[]] instances;
-  static const char[] TUMIKI_DIR_NAME = "/usr/share/games/tumiki-fighters/tumiki";
+  static TumikiSet[string] instances;
+  static const string TUMIKI_DIR_NAME = "/usr/share/games/tumiki-fighters/tumiki";
   static const float BULLET_SPEED_RATIO = 1.2;
-  static int[char[]] shapeStr;
-  static char[][] SHAPE_STR = 
+  static int[string] shapeStr;
+  static string[] SHAPE_STR = 
     ["s", "ul", "ur", "dr", "dl", "u", "r", "d", "l", "pu", "pdr", "pr", "pur", "pd", "pf"];
-  static int[char[]] colorStr;
-  static char[][] COLOR_STR = 
+  static int[string] colorStr;
+  static string[] COLOR_STR = 
     ["r", "g", "b", "y", "p", "a", "w", "gr"];
-  static int[char[]] bulletShapeStr;
-  static char[][] BULLET_SHAPE_STR = 
+  static int[string] bulletShapeStr;
+  static string[] BULLET_SHAPE_STR = 
     ["b", "a", "r"];
-  static int[char[]] bulletColorStr;
-  static char[][] BULLET_COLOR_STR = 
+  static int[string] bulletColorStr;
+  static string[] BULLET_COLOR_STR = 
     ["r", "a", "p"];
 
   private static void init() {
     if (shapeStr.length != 0) return; // already initialized
 
     int i = 0;
-    foreach (char[] s; SHAPE_STR) {
+    foreach (string s; SHAPE_STR) {
       shapeStr[s] = i;
       i++;
     }
     i = 0;
-    foreach (char[] s; COLOR_STR) {
+    foreach (string s; COLOR_STR) {
       colorStr[s] = i;
       i++;
     }
     i = 0;
-    foreach (char[] s; BULLET_SHAPE_STR) {
+    foreach (string s; BULLET_SHAPE_STR) {
       bulletShapeStr[s] = i;
       i++;
     }
     i = 0;
-    foreach (char[] s; BULLET_COLOR_STR) {
+    foreach (string s; BULLET_COLOR_STR) {
       bulletColorStr[s] = i;
       i++;
     }
@@ -77,26 +78,26 @@
   //   [BulletML, rank, speed]],
   //  (end when BulletML == e, shape == e)(set a empty barrage when shape == s),
   // ],
-  private this(char[][] data) {
+  private this(string[] data) {
     init();
     sizeXm = sizeYm = float.max;
     sizeXp = sizeYp = float.min;
     StringIterator si = new StringIterator(data);
-    float sizeRatio = atof(si.next);
-    score = atoi(si.next);
-    fireScore = atoi(si.next);
-    fireScoreInterval = atoi(si.next);
+    float sizeRatio = to!float(si.next);
+    score = to!int(si.next);
+    fireScore = to!int(si.next);
+    fireScoreInterval = to!int(si.next);
     for (;;) {
       if (!si.hasNext)
 	break;
-      char[] v = si.next;
+      string v = si.next;
       int shape = ((v in shapeStr) != null) ? shapeStr[v] : 0; //the data files contain undefined codes
       v = si.next;
       int color = ((v in colorStr) != null) ? colorStr[v] : 0;
-      float x = atof(si.next);
-      float y = atof(si.next);
-      float sizex = atof(si.next);
-      float sizey = atof(si.next);
+      float x = to!float(si.next);
+      float y = to!float(si.next);
+      float sizex = to!float(si.next);
+      float sizey = to!float(si.next);
       Tumiki ti = new Tumiki(shape, color, x, y, sizex, sizey, sizeRatio);
       if (sizeXp < ti.ofs.x + ti.size.x)
 	sizeXp = ti.ofs.x + ti.size.x;
@@ -114,21 +115,21 @@
 	  ti.addBarrage(new Barrage);
 	  continue;
 	}
-	int shape = ((v in bulletShapeStr) != null) ? bulletShapeStr[v] : 0;
+	int shape_ = ((v in bulletShapeStr) != null) ? bulletShapeStr[v] : 0;
 	v = si.next;
-	int color = ((v in bulletColorStr) != null) ? bulletColorStr[v] : 0;
-	float size = atof(si.next);
-	float yReverse = atof(si.next);
-	int prevWait = atoi(si.next);
-	int postWait = atoi(si.next);
+	int color_ = ((v in bulletColorStr) != null) ? bulletColorStr[v] : 0;
+	float size = to!float(si.next);
+	float yReverse = to!float(si.next);
+	int prevWait = to!int(si.next);
+	int postWait = to!int(si.next);
 	Barrage br = new Barrage
-	  (shape, color, size, yReverse, prevWait, postWait);
+	  (shape_, color_, size, yReverse, prevWait, postWait);
 	for (;;) {
-	  char[] bml = si.next;
+	  string bml = si.next;
 	  if (bml == "e")
 	    break;
-	  float rank = atof(si.next);
-	  float speed = atof(si.next);
+	  float rank = to!float(si.next);
+	  float speed = to!float(si.next);
 	  br.addBml(bml, rank, speed * BULLET_SPEED_RATIO);
 	}
 	ti.addBarrage(br);
@@ -139,13 +140,13 @@
   }
 
   // Initialize TumikiSet from the file.
-  public this(char[] fileName) {
+  public this(string fileName) {
     Logger.info("Load tumiki set: " ~ fileName);
-    char[][] data = CSVTokenizer.readFile(TUMIKI_DIR_NAME ~ "/" ~ fileName);
+    string[] data = CSVTokenizer.readFile(TUMIKI_DIR_NAME ~ "/" ~ fileName);
     this(data);
   }
 
-  public static TumikiSet getInstance(char[] fileName) {
+  public static TumikiSet getInstance(string fileName) {
     if ((fileName in instances) == null) {
       instances[fileName] = new TumikiSet(fileName);
     }
--- a/src/abagames/util/actorpool.d
+++ b/src/abagames/util/actorpool.d
@@ -14,11 +14,11 @@
  public:
   Actor[] actor;
  protected:
-  int actorIdx;
+  ptrdiff_t actorIdx;
 
   public this(int n, Actor act, ActorInitializer ini) {
     actor = new Actor[n];
-    foreach (inout Actor a; actor) {
+    foreach (ref Actor a; actor) {
       a = act.newActor();
       a.isExist = false;
       a.init(ini);
--- a/src/abagames/util/csv.d
+++ b/src/abagames/util/csv.d
@@ -7,6 +7,7 @@
 
 private import std.stream;
 private import std.string;
+private import std.conv;
 
 /**
  * CSV format Tokenizer.
@@ -14,17 +15,17 @@
 public class CSVTokenizer {
  private:
 
-  public static char[][] readFile(char[] fileName) {
-    char[][] result;
-    auto File fd = new File;
+  public static string[] readFile(string fileName) {
+    string[] result;
+    scope File fd = new File;
     fd.open(fileName);
     for (;;) {
-      char[] line = fd.readLine();
+      string line = to!string(fd.readLine());
       if (!line)
 	break;
-      char[][] spl = split(line, ",");
-      foreach (char[] s; spl) {
-	char[] r = strip(s);
+      string[] spl = split(line, ",");
+      foreach (string s; spl) {
+	string r = strip(s);
 	if (r.length > 0)
 	  result ~= r;
       }
--- a/src/abagames/util/iterator.d
+++ b/src/abagames/util/iterator.d
@@ -36,4 +36,4 @@
 }
 }
 
-alias ArrayIterator!(char[]) StringIterator;
+alias ArrayIterator!(string) StringIterator;
--- a/src/abagames/util/logger.d
+++ b/src/abagames/util/logger.d
@@ -7,6 +7,7 @@
 
 private import std.cstream;
 private import std.string;
+private import std.conv;
 
 /**
  * Logger(error/info).
@@ -18,32 +19,28 @@
 
 public class Logger {
 
-  public static void info(char[] msg) {
+  public static void info(string msg) {
     // Win32 exe file crashes if it writes something to stderr.
     //stderr.writeLine("Info: " ~ msg);
   }
 
   public static void info(int n) {
-    //stderr.writeLine("Info: " ~ std.string.toString(n));
+    //stderr.writeLine("Info: " ~ to!string(n));
   }
 
   public static void info(float n) {
-    //stderr.writeLine("Info: -" ~ std.string.toString(n));
+    //stderr.writeLine("Info: -" ~ to!string(n));
   }
 
-  private static void putMessage(char[] msg) {
+  private static void putMessage(string msg) {
     MessageBoxA(null, std.string.toStringz(msg), "Error", MB_OK | MB_ICONEXCLAMATION);
   }
 
-  public static void error(char[] msg) {
+  public static void error(string msg) {
     putMessage("Error: " ~ msg);
   }
 
-  public static void error(Exception e) {
-    putMessage("Error: " ~ e.toString());
-  }
-
-  public static void error(Error e) {
+  public static void error(Throwable e) {
     putMessage("Error: " ~ e.toString());
   }
 }
@@ -52,27 +49,23 @@
 
 public class Logger {
 
-  public static void info(char[] msg) {
+  public static void info(string msg) {
     derr.writeLine("Info: " ~ msg);
   }
 
   public static void info(int n) {
-    derr.writeLine("Info: " ~ std.string.toString(n));
+    derr.writeLine("Info: " ~ to!string(n));
   }
 
   public static void info(float n) {
-    derr.writeLine("Info: -" ~ std.string.toString(n));
+    derr.writeLine("Info: -" ~ to!string(n));
   }
 
-  public static void error(char[] msg) {
+  public static void error(string msg) {
     derr.writeLine("Error: " ~ msg);
   }
 
-  public static void error(Exception e) {
-    derr.writeLine("Error: " ~ e.toString());
-  }
-
-  public static void error(Error e) {
+  public static void error(Throwable e) {
     derr.writeLine("Error: " ~ e.toString());
     if (e.next)
       error(e.next);
--- a/src/abagames/util/rand.d
+++ b/src/abagames/util/rand.d
@@ -6,7 +6,7 @@
 module abagames.util.rand;
 
 private import std.stream;
-private import std.date;
+private import std.datetime;
 
 /**
  * Random number generator.
@@ -14,12 +14,12 @@
 public class Rand {
   
   public this() {
-    d_time timer = getUTCtime();
-    init_genrand(timer);
+    long timer = Clock.currStdTime();
+    init_genrand(cast(uint)timer);
   }
 
   public void setSeed(long n) {
-    init_genrand(n);
+    init_genrand(cast(uint)n);
   }
 
   public int nextInt(int n) {
@@ -45,7 +45,7 @@
      Matthe Bellew, and Isaku Wada
    Andrew C. Edwards  v0.1  30 September 2003  edwardsac@ieee.org
 
-   Before using, initialize the state by using init_genrand(seed) 
+   Before using, initialize the state by using init_genrand(cast(uint)seed) 
    or init_by_array(init_key, key_length).
 
    Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
@@ -113,7 +113,7 @@
 {
     state[0]= s & 0xffffffffUL;
     for (int j=1; j<N; j++) {
-        state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j); 
+        state[j] = (1812433253U * (state[j-1] ^ (state[j-1] >> 30)) + j); 
         /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
         /* In the previous versions, MSBs of the seed affect   */
         /* only MSBs of the array state[].                        */
@@ -131,11 +131,11 @@
 void init_by_array(uint init_key[], uint key_length)
 {
     int i, j, k;
-    init_genrand(19650218UL);
+    init_genrand(cast(uint)19650218UL);
     i=1; j=0;
     k = (N>key_length ? N : key_length);
     for (; k; k--) {
-        state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525UL))
+        state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525U))
           + init_key[j] + j; /* non linear */
         state[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
         i++; j++;
@@ -143,7 +143,7 @@
         if (j>=key_length) j=0;
     }
     for (k=N-1; k; k--) {
-        state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941UL))
+        state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941U))
           - i; /* non linear */
         state[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
         i++;
@@ -156,14 +156,14 @@
 
 void next_state()
 {
-    uint *p=state;
+    uint *p=state.ptr;
 
-    /* if init_genrand() has not been called, */
+    /* if init_genrand(cast(uint)) has not been called, */
     /* a default initial seed is used         */
-    if (initf==0) init_genrand(5489UL);
+    if (initf==0) init_genrand(cast(uint)5489UL);
 
     left = N;
-    next = state;
+    next = state.ptr;
     
     for (int j=N-M+1; --j; p++) 
         *p = p[M] ^ TWIST(p[0], p[1]);
--- a/src/abagames/util/sdl/mainloop.d
+++ b/src/abagames/util/sdl/mainloop.d
@@ -91,7 +91,7 @@
       frame = cast(int) (nowTick-prvTickCount) / interval;
       if (frame <= 0) {
 	frame = 1;
-	SDL_Delay(prvTickCount+interval-nowTick);
+	SDL_Delay(cast(uint)(prvTickCount+interval-nowTick));
 	if (accframe) {
 	  prvTickCount = SDL_GetTicks();
 	} else {
--- a/src/abagames/util/sdl/pad.d
+++ b/src/abagames/util/sdl/pad.d
@@ -6,6 +6,7 @@
 module abagames.util.sdl.pad;
 
 private import std.string;
+private import std.conv;
 private import SDL;
 private import abagames.util.sdl.input;
 private import abagames.util.sdl.sdlexception;
@@ -31,7 +32,7 @@
   public void openJoystick() {
     if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
       throw new SDLInitFailedException(
-	"Unable to init SDL joystick: " ~ std.string.toString(SDL_GetError()));
+	"Unable to init SDL joystick: " ~ to!string(SDL_GetError()));
     }
     stick = SDL_JoystickOpen(0);
   }
--- a/src/abagames/util/sdl/screen3d.d
+++ b/src/abagames/util/sdl/screen3d.d
@@ -6,6 +6,7 @@
 module abagames.util.sdl.screen3d;
 
 private import std.string;
+private import std.conv;
 private import SDL;
 private import opengl;
 private import abagames.util.logger;
@@ -34,7 +35,7 @@
     // Initialize SDL.
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
       throw new SDLInitFailedException(
-	"Unable to initialize SDL: " ~ std.string.toString(SDL_GetError()));
+	"Unable to initialize SDL: " ~ to!string(SDL_GetError()));
     }
     // Create an OpenGL screen.
     if (windowMode) {
@@ -44,7 +45,7 @@
     } 
     if (SDL_SetVideoMode(width, height, 0, videoFlags) == null) {
       throw new SDLInitFailedException
-	("Unable to create SDL screen: " ~ std.string.toString(SDL_GetError()));
+	("Unable to create SDL screen: " ~ to!string(SDL_GetError()));
     }
     glViewport(0, 0, width, height);
     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -58,7 +59,7 @@
   public void screenResized() {
     if (SDL_SetVideoMode(width, height, 0, videoFlags) == null) {
       throw new Exception
-        ("Unable to resize SDL screen: " ~ std.string.toString(SDL_GetError()));
+        ("Unable to resize SDL screen: " ~ to!string(SDL_GetError()));
     }
     glViewport(0, 0, width, height);
     glMatrixMode(GL_PROJECTION);
@@ -98,7 +99,7 @@
     throw new Exception("OpenGL error");
   }
 
-  protected void setCaption(char[] name) {
+  protected void setCaption(string name) {
     SDL_WM_SetCaption(std.string.toStringz(name), null);
   }
 
--- a/src/abagames/util/sdl/sdlexception.d
+++ b/src/abagames/util/sdl/sdlexception.d
@@ -9,7 +9,7 @@
  * SDL initialize failed.
  */
 public class SDLInitFailedException: Exception {
-  public this(char[] msg) {
+  public this(string msg) {
     super(msg);
   }
 }
--- a/src/abagames/util/sdl/sound.d
+++ b/src/abagames/util/sdl/sound.d
@@ -6,6 +6,7 @@
 module abagames.util.sdl.sound;
 
 private import std.string;
+private import std.conv;
 private import SDL;
 private import SDL_mixer;
 private import abagames.util.sdl.sdlexception;
@@ -28,7 +29,7 @@
     if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
       noSound = 1;
       throw new SDLInitFailedException
-	("Unable to initialize SDL_AUDIO: " ~ std.string.toString(SDL_GetError()));
+	("Unable to initialize SDL_AUDIO: " ~ to!string(SDL_GetError()));
     }
     audio_rate = 44100;
     audio_format = AUDIO_S16;
@@ -37,7 +38,7 @@
     if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
       noSound = 1;
       throw new SDLInitFailedException
-	("Couldn't open audio: " ~ std.string.toString(SDL_GetError()));
+	("Couldn't open audio: " ~ to!string(SDL_GetError()));
     }
     Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
   }
@@ -51,8 +52,8 @@
     Mix_CloseAudio();
   }
 
-  public abstract void load(char[] name);
-  public abstract void load(char[] name, int ch);
+  public abstract void load(string name);
+  public abstract void load(string name, int ch);
   public abstract void free();
   public abstract void play();
   public abstract void fade();
@@ -62,34 +63,34 @@
 public class Music: Sound {
  public:
   static int fadeOutSpeed = 1280;
-  static char[] dir = "/usr/share/games/tumiki-fighters/sounds/";
+  static string dir = "/usr/share/games/tumiki-fighters/sounds/";
  private:
   Mix_Music* music;
 
-  public void load(char[] name) {
+  public override void load(string name) {
     if (noSound)
       return;
-    char[] fileName = dir ~ name;
+    string fileName = dir ~ name;
     music = Mix_LoadMUS(std.string.toStringz(fileName));
     if (!music) {
       noSound = true;
       throw new SDLInitFailedException("Couldn't load: " ~ fileName ~ 
-				       " (" ~ std.string.toString(Mix_GetError()) ~ ")");
+				       " (" ~ to!string(Mix_GetError()) ~ ")");
     }
   }
   
-  public void load(char[] name, int ch) {
+  public override void load(string name, int ch) {
     load(name);
   }
 
-  public void free() {
+  public override void free() {
     if (music) {
       halt();
       Mix_FreeMusic(music);
     }
   }
 
-  public void play() {
+  public override void play() {
     if (noSound) return;
     Mix_PlayMusic(music, -1);
   }
@@ -99,11 +100,11 @@
     Mix_PlayMusic(music, 1);
   }
 
-  public void fade() {
+  public override void fade() {
     Music.fadeMusic();
   }
 
-  public void halt() {
+  public override void halt() {
     Music.haltMusic();
   }
 
@@ -122,46 +123,46 @@
 
 public class Chunk: Sound {
  public:
-  static char[] dir = "/usr/share/games/tumiki-fighters/sounds/";
+  static string dir = "/usr/share/games/tumiki-fighters/sounds/";
  private:
   Mix_Chunk* chunk;
   int chunkChannel;
 
-  public void load(char[] name) {
+  public override void load(string name) {
     load(name, 0);
   }
   
-  public void load(char[] name, int ch) {
+  public override void load(string name, int ch) {
     if (noSound)
       return;
-    char[] fileName = dir ~ name;
+    string fileName = dir ~ name;
     chunk = Mix_LoadWAV(std.string.toStringz(fileName));
     if (!chunk) {
       noSound = true;
       throw new SDLInitFailedException("Couldn't load: " ~ fileName ~ 
-				       " (" ~ std.string.toString(Mix_GetError()) ~ ")");
+				       " (" ~ to!string(Mix_GetError()) ~ ")");
     }
     chunkChannel = ch;
   }
 
-  public void free() {
+  public override void free() {
     if (chunk) {
       halt();
       Mix_FreeChunk(chunk);
     }
   }
 
-  public void play() {
+  public override void play() {
     if (noSound) return;
     Mix_PlayChannel(chunkChannel, chunk, 0);
   }
 
-  public void halt() {
+  public override void halt() {
     if (noSound) return;
     Mix_HaltChannel(chunkChannel);
   }
 
-  public void fade() {
+  public override void fade() {
     halt();
   }
 }
--- a/src/abagames/util/sdl/texture.d
+++ b/src/abagames/util/sdl/texture.d
@@ -15,13 +15,13 @@
  */
 public class Texture {
  public:
-  static char[] imagesDir = "/usr/share/games/tumiki-fighters/images/";
+  static string imagesDir = "/usr/share/games/tumiki-fighters/images/";
 
  private:
   GLuint num;
 
-  public this(char[] name) {
-    char[] fileName = imagesDir ~ name;
+  public this(string name) {
+    string fileName = imagesDir ~ name;
     SDL_Surface *surface;    
     surface = SDL_LoadBMP(std.string.toStringz(fileName));
     if (!surface) {
--- a/src/abagames/tf/fragment.d
+++ b/src/abagames/tf/fragment.d
@@ -26,8 +26,8 @@
   int shape, color;
   int cnt;
 
-  public static this() {
-    rand = new Rand;
+  public this() {
+    if (rand is null) rand = new Rand;
   }
 
   public override Actor newActor() {