LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File tumiki-fighters-fixes.patch of Package tumiki-fighters (Project home:ykoba)

# Copyright (C) 2007  Marcel Unbehaun <frostworks@gmx.de>
# Copyright (C) 2007  Miriam Ruiz <little_miry@yahoo.es>
# Distributed under the same license as the game. See debian/copyright.

Index: tf/src/abagames/tf/boot.d
===================================================================
--- tf.orig/src/abagames/tf/boot.d
+++ tf/src/abagames/tf/boot.d
@@ -5,7 +5,7 @@
  */
 module abagames.tf.boot;
 
-private import std.string;
+private import std.c.string;
 private import std.c.stdlib;
 private import abagames.util.logger;
 private import abagames.util.sdl.mainloop;
Index: tf/src/abagames/util/logger.d
===================================================================
--- tf.orig/src/abagames/util/logger.d
+++ tf/src/abagames/util/logger.d
@@ -5,7 +5,7 @@
  */
 module abagames.util.logger;
 
-private import std.stream;
+private import std.cstream;
 private import std.string;
 
 /**
@@ -53,27 +53,27 @@ public class Logger {
 public class Logger {
 
   public static void info(char[] msg) {
-    stderr.writeLine("Info: " ~ msg);
+    derr.writeLine("Info: " ~ msg);
   }
 
   public static void info(int n) {
-    stderr.writeLine("Info: " ~ std.string.toString(n));
+    derr.writeLine("Info: " ~ std.string.toString(n));
   }
 
   public static void info(float n) {
-    stderr.writeLine("Info: -" ~ std.string.toString(n));
+    derr.writeLine("Info: -" ~ std.string.toString(n));
   }
 
   public static void error(char[] msg) {
-    stderr.writeLine("Error: " ~ msg);
+    derr.writeLine("Error: " ~ msg);
   }
 
   public static void error(Exception e) {
-    stderr.writeLine("Error: " ~ e.toString());
+    derr.writeLine("Error: " ~ e.toString());
   }
 
   public static void error(Error e) {
-    stderr.writeLine("Error: " ~ e.toString());
+    derr.writeLine("Error: " ~ e.toString());
     if (e.next)
       error(e.next);
   }
Index: tf/src/dirent.d
===================================================================
--- /dev/null
+++ tf/src/dirent.d
@@ -0,0 +1,10 @@
+import std.string;
+
+extern (C) {
+	alias void DIR;
+	alias void dirent;
+	DIR* opendir(char* name);
+	dirent* readdir(DIR* dir);
+	int closedir(DIR* dir);
+	char* readdir_filename(DIR* ent);
+}
Index: tf/src/abagames/tf/tumikiset.d
===================================================================
--- tf.orig/src/abagames/tf/tumikiset.d
+++ tf/src/abagames/tf/tumikiset.d
@@ -44,7 +44,9 @@ public class TumikiSet {
   static char[][] BULLET_COLOR_STR = 
     ["r", "a", "p"];
 
-  public static this() {
+  private static void init() {
+    if (shapeStr.length != 0) return; // already initialized
+
     int i = 0;
     foreach (char[] s; SHAPE_STR) {
       shapeStr[s] = i;
@@ -76,6 +78,7 @@ public class TumikiSet {
   //  (end when BulletML == e, shape == e)(set a empty barrage when shape == s),
   // ],
   private this(char[][] data) {
+    init();
     sizeXm = sizeYm = float.max;
     sizeXp = sizeYp = float.min;
     StringIterator si = new StringIterator(data);
@@ -87,9 +90,9 @@ public class TumikiSet {
       if (!si.hasNext)
 	break;
       char[] v = si.next;
-      int shape = shapeStr[v];
+      int shape = ((v in shapeStr) != null) ? shapeStr[v] : 0; //the data files contain undefined codes
       v = si.next;
-      int color = colorStr[v];
+      int color = ((v in colorStr) != null) ? colorStr[v] : 0;
       float x = atof(si.next);
       float y = atof(si.next);
       float sizex = atof(si.next);
@@ -111,9 +114,9 @@ public class TumikiSet {
 	  ti.addBarrage(new Barrage);
 	  continue;
 	}
-	int shape = bulletShapeStr[v];
+	int shape = ((v in bulletShapeStr) != null) ? bulletShapeStr[v] : 0;
 	v = si.next;
-	int color = bulletColorStr[v];
+	int color = ((v in bulletColorStr) != null) ? bulletColorStr[v] : 0;
 	float size = atof(si.next);
 	float yReverse = atof(si.next);
 	int prevWait = atoi(si.next);
@@ -136,19 +139,17 @@ public class TumikiSet {
   }
 
   // Initialize TumikiSet from the file.
-  private this(char[] fileName) {
+  public this(char[] fileName) {
     Logger.info("Load tumiki set: " ~ fileName);
     char[][] data = CSVTokenizer.readFile(TUMIKI_DIR_NAME ~ "/" ~ fileName);
     this(data);
   }
 
   public static TumikiSet getInstance(char[] fileName) {
-    TumikiSet inst = instances[fileName];
-    if (!inst) {
-      inst = new TumikiSet(fileName);
-      instances[fileName] = inst;
+    if ((fileName in instances) == null) {
+      instances[fileName] = new TumikiSet(fileName);
     }
-    return inst;
+    return instances[fileName];
   }
 
   public int addTopBullets(int barragePtnIdx, BulletActorPool bullets, EnemyTopBullet[] etb,
Index: tf/src/abagames/tf/enemy.d
===================================================================
--- tf.orig/src/abagames/tf/enemy.d
+++ tf/src/abagames/tf/enemy.d
@@ -142,11 +142,11 @@ public class Enemy: Actor {
     float speed;
     Vector[] pt;
     if (!mv.withdraw) {
-      pt = mv.pattern.point[barragePtnIdx];
-      if (!pt) {
+      if ((barragePtnIdx in mv.pattern.point) == null) {
 	pt = mv.pattern.point[PointsMovePattern.BASIC_PATTERN_IDX];
 	speed = mv.pattern.speed[PointsMovePattern.BASIC_PATTERN_IDX];
       } else {
+        pt = mv.pattern.point[barragePtnIdx];
 	speed = mv.pattern.speed[barragePtnIdx];
       }
       if (!mv.reachFirstPointFirst)
@@ -272,7 +272,7 @@ public class Enemy: Actor {
       if (attackPtnIdx >= af.attackPeriod.length)
 	attackPtnIdx = 0;
       if (!mv.moveBullet) {
-	if (mv.pattern.point[barragePtnIdx])
+	if ((barragePtnIdx in mv.pattern.point) != null)
 	  movePatternChanged();
       }
     } else if (fireCnt < af.breakPeriod[attackPtnIdx]) {
@@ -329,7 +329,7 @@ public class Enemy: Actor {
 	if (ep.shield <= 0) {
 	  if (ep.spec.damageToMainBody > 0) {
 	    parts[0].shield -= ep.spec.damageToMainBody;
-	    particles.add(5, pos, 0, PI * 2, 0.1, parts[0].spec.size / 4, Particle.TypeName.SMOKE);
+	    particles.add(5, pos, 0, PI * 2, 0.1, parts[0].spec.sizeof / 4, Particle.TypeName.SMOKE);
 	  }
 	  manager.addScore(ep.spec.tumikiSet.score, p);
 	  if (ep.firstShield <= 1)
Index: tf/src/abagames/tf/letterrender.d
===================================================================
--- tf.orig/src/abagames/tf/letterrender.d
+++ tf/src/abagames/tf/letterrender.d
@@ -32,7 +32,7 @@ public class LetterRender {
     return s * LETTER_HEIGHT;
   }
 
-  private static void drawLetter(int n, float x, float y, float s, float d, int c) {
+  public static void drawLetter(int n, float x, float y, float s, float d, int c) {
     glPushMatrix();
     glTranslatef(x, y, 0);
     glScalef(s, s, s);
Index: tf/src/abagames/tf/ship.d
===================================================================
--- tf.orig/src/abagames/tf/ship.d
+++ tf/src/abagames/tf/ship.d
@@ -70,8 +70,8 @@ public class Ship: BulletTarget {
   bool btnPrsd;
   bool pullIn;
 
-  public static this() {
-    rand = new Rand;
+  public this() {
+    if (rand is null) rand = new Rand;
   }
 
   public void init(Pad pad, Field field, ParticlePool particles, ActorPool fragments,
Index: tf/src/abagames/tf/enemyspec.d
===================================================================
--- tf.orig/src/abagames/tf/enemyspec.d
+++ tf/src/abagames/tf/enemyspec.d
@@ -89,13 +89,11 @@ public class EnemySpec {
   }
 
   public static EnemySpec getInstance(char[] fileName) {
-    EnemySpec inst = instances[fileName];
-    if (!inst) {
+    if ((fileName in instances) == null) {
       Logger.info("Load enemy spec: " ~ fileName);
-      inst = new EnemySpec(fileName);
-      instances[fileName] = inst;
+      instances[fileName] = new EnemySpec(fileName);
     }
-    return inst;
+    return instances[fileName];
   }
 }