File: dlang_v2.patch

package info (click to toggle)
a7xpg 0.11.dfsg1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,864 kB
  • sloc: xml: 56; makefile: 28
file content (446 lines) | stat: -rw-r--r-- 13,303 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
Description: port to D language version 2
  With this patch the code is accepted by gdc-4.6 0.29.1-4.6.4-3 without
  triggering deprecated feature warnings/errors.
Author: Barry deFreese <bdefreese@debian.org>
Author: Peter De Wachter <pdewacht@gmail.com>

--- a/src/abagames/util/Rand.d
+++ b/src/abagames/util/Rand.d
@@ -6,27 +6,30 @@
 module abagames.util.Rand;
 
 import std.random;
-import std.date;
+import std.datetime;
 
 /**
  * Random number generator.
  */
 public class Rand {
+  private Random rand;
   
   public this() {
-    d_time timer = getUTCtime();
-    rand_seed(timer, 0);   
+    rand.seed(unpredictableSeed);
   }
 
   public int nextInt(int n) {
-    return rand() % n;
+    rand.popFront();
+    return rand.front() % n;
   }
 
   public int nextSignedInt(int n) {
-    return rand() % (n * 2) - n;
+    rand.popFront();
+    return rand.front() % (n * 2) - n;
   }
 
   public float nextFloat(float n) {
-    return (cast(float)(rand() % (n * 10000))) / 10000;
+    rand.popFront();
+    return (cast(float)(rand.front() % (n * 10000))) / 10000;
   }
 }
--- a/src/abagames/util/sdl/Sound.d
+++ b/src/abagames/util/sdl/Sound.d
@@ -5,7 +5,8 @@
  */
 module abagames.util.sdl.Sound;
 
-import string = std.string;
+import std.conv;
+import std.string;
 import SDL;
 import SDL_mixer;
 import abagames.util.sdl.SDLInitFailedException;
@@ -18,8 +19,8 @@
  public:
   static bool noSound = false;
   static int fadeOutSpeed = 1280;
-  static char[] soundsDir = "/usr/share/games/a7xpg/sounds/";
-  static char[] chunksDir = "/usr/share/games/a7xpg/sounds/";
+  static string soundsDir = "/usr/share/games/a7xpg/sounds/";
+  static string chunksDir = "/usr/share/games/a7xpg/sounds/";
 
   public static void init() {
     if (noSound) return;
@@ -31,7 +32,7 @@
 
     if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
       noSound = 1;
-      derr.writeLine("Unable to initialize SDL audio: " ~ string.toString(SDL_GetError()));
+      derr.writeLine("Unable to initialize SDL audio: " ~ to!string(SDL_GetError()));
     }
 
     audio_rate = 44100;
@@ -40,7 +41,7 @@
     audio_buffers = 4096;
     if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
       noSound = 1;
-      derr.writeLine("Couldn't open audio: " ~ string.toString(SDL_GetError()));
+      derr.writeLine("Couldn't open audio: " ~ to!string(SDL_GetError()));
     }
     Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
   }
@@ -62,25 +63,25 @@
 
   // Load a sound or a chunk.
 
-  public void loadSound(char[] name) {
+  public void loadSound(string name) {
     if (noSound) return;
-    char[] fileName = soundsDir ~ name;
-    music = Mix_LoadMUS(string.toStringz(fileName));
+    string fileName = soundsDir ~ name;
+    music = Mix_LoadMUS(toStringz(fileName));
     if (!music) {
       noSound = true;
       throw new SDLInitFailedException("Couldn't load: " ~ fileName ~ 
-				       " (" ~ string.toString(Mix_GetError()) ~ ")");
+				       " (" ~ to!string(Mix_GetError()) ~ ")");
     }
   }
   
-  public void loadChunk(char[] name, int ch) {
+  public void loadChunk(string name, int ch) {
     if (noSound) return;
-    char[] fileName = chunksDir ~ name;
-    chunk = Mix_LoadWAV(string.toStringz(fileName));
+    string fileName = chunksDir ~ name;
+    chunk = Mix_LoadWAV(toStringz(fileName));
     if (!chunk) {
       noSound = true;
       throw new SDLInitFailedException("Couldn't load: " ~ fileName ~ 
-				       " (" ~ string.toString(Mix_GetError()) ~ ")");
+				       " (" ~ to!string(Mix_GetError()) ~ ")");
     }
     chunkChannel = ch;
   }
--- a/src/abagames/util/sdl/SDLInitFailedException.d
+++ b/src/abagames/util/sdl/SDLInitFailedException.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/a7xpg/A7xBoot.d
+++ b/src/abagames/a7xpg/A7xBoot.d
@@ -5,6 +5,7 @@
  */
 module abagames.a7xpg.A7xBoot;
 
+import std.conv;
 import std.string;
 import std.c.stdlib: exit, EXIT_SUCCESS, EXIT_FAILURE;
 import abagames.a7xpg.A7xScreen;
@@ -30,7 +31,7 @@
     ("Usage: a7xpg [-brightness [0-100]] [-luminous [0-100]] [-nosound] [-window] [-fullscreen] [-lowres]");
 }
 
-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 @@
 	exit(EXIT_FAILURE);
       }
       i++;
-      float b = cast(float) atoi(args[i]) / 100;
+      float b = to!float(args[i]) / 100;
       if (b < 0 || b > 1) {
 	usage();
 	exit(EXIT_FAILURE);
@@ -52,7 +53,7 @@
 	exit(EXIT_FAILURE);
       }
       i++;
-      float l = cast(float) atoi(args[i]) / 100;
+      float l = to!float(args[i]) / 100;
       if (l < 0 || l > 1) {
 	usage();
 	exit(EXIT_FAILURE);
@@ -81,7 +82,7 @@
   }
 }
 
-public int main(char[][] args) {
+public int main(string[] args) {
   screen = new A7xScreen;
   input = new Input;
   try {
--- a/src/abagames/a7xpg/A7xGameManager.d
+++ b/src/abagames/a7xpg/A7xGameManager.d
@@ -126,18 +126,18 @@
     ship = new Ship;
     ship.init(input, field, this);
     Gold.createDisplayLists();
-    auto Gold goldClass = new Gold;
-    auto GoldInitializer gi = new GoldInitializer(ship, field, rand, this);
+    scope Gold goldClass = new Gold;
+    scope GoldInitializer gi = new GoldInitializer(ship, field, rand, this);
     golds = new LuminousActorPool(16, goldClass, gi);
     Enemy.createDisplayLists();
-    auto Enemy enemyClass = new Enemy;
-    auto EnemyInitializer ei = new EnemyInitializer(ship, field, rand, this);
+    scope Enemy enemyClass = new Enemy;
+    scope EnemyInitializer ei = new EnemyInitializer(ship, field, rand, this);
     enemies = new LuminousActorPool(ENEMY_MAX, enemyClass, ei);
-    auto Particle particleClass = new Particle;
-    auto ParticleInitializer pi = new ParticleInitializer(field, rand);
+    scope Particle particleClass = new Particle;
+    scope ParticleInitializer pi = new ParticleInitializer(field, rand);
     particles = new LuminousActorPool(256, particleClass, pi);
-    auto Bonus bonusClass = new Bonus;
-    auto BonusInitializer bi = new BonusInitializer();
+    scope Bonus bonusClass = new Bonus;
+    scope BonusInitializer bi = new BonusInitializer();
     bonuses = new ActorPool(8, bonusClass, bi);
     LetterRender.createDisplayLists();
     for (int i = 0; i < bgm.length; i++)
--- a/src/abagames/a7xpg/A7xPrefManager.d
+++ b/src/abagames/a7xpg/A7xPrefManager.d
@@ -8,6 +8,7 @@
 import std.stream;
 import std.c.stdlib;
 import std.string;
+import std.conv;
 import abagames.util.PrefManager;
 
 /**
@@ -16,22 +17,22 @@
 public class A7xPrefManager: PrefManager {
  public:
   static const int VERSION_NUM = 10;
-  static const char[] PREF_FILE = ".a7xpg.prf";
+  static const string PREF_FILE = ".a7xpg.prf";
   int hiScore;
 
   private void init() {
     hiScore = 0;
   }
 
-  public char[] pref_file() {
+  public string pref_file() {
     char * home = getenv("HOME");
     if (home is null)
       throw new Error("HOME environment variable is not defined");
-    return std.string.toString(home) ~ "/" ~ PREF_FILE;
+    return to!string(home) ~ "/" ~ PREF_FILE;
   }
 
-  public void load() {
-    auto File fd = new File;
+  public override void load() {
+    scope File fd = new File;
     try {
       int ver;
       fd.open(pref_file());
@@ -46,8 +47,8 @@
     }
   }
 
-  public void save() {
-    auto File fd = new File;
+  public override void save() {
+    scope File fd = new File;
     fd.create(pref_file());
     fd.write(VERSION_NUM);
     fd.write(hiScore);
--- a/src/abagames/a7xpg/A7xScreen.d
+++ b/src/abagames/a7xpg/A7xScreen.d
@@ -14,7 +14,7 @@
  */
 public class A7xScreen: Screen3D {
  public:
-  static const char[] CAPTION = "A7Xpg";
+  static const string CAPTION = "A7Xpg";
   static float brightness = 1;
   static float luminous = 0.5;
 
--- a/src/abagames/a7xpg/LetterRender.d
+++ b/src/abagames/a7xpg/LetterRender.d
@@ -31,7 +31,7 @@
     glPopMatrix();
   }
 
-  public static void drawString(char[] str, float lx, float y, float s) {
+  public static void drawString(string str, float lx, float y, float s) {
     float x = lx;
     int c;
     int idx;
--- a/src/abagames/util/ActorPool.d
+++ b/src/abagames/util/ActorPool.d
@@ -14,7 +14,7 @@
  public:
   Actor[] actor;
  protected:
-  int actorIdx;
+  ptrdiff_t actorIdx;
 
   public this(int n, Actor act, ActorInitializer ini) {
     actor = new Actor[n];
--- a/src/abagames/util/Logger.d
+++ b/src/abagames/util/Logger.d
@@ -11,11 +11,11 @@
  * Logger(error/info).
  */
 public class Logger {
-  public static void info(char[] msg) {
+  public static void info(string msg) {
     derr.writeLine("Info: " ~ msg);
   }
 
-  public static void error(char[] msg) {
+  public static void error(string msg) {
     //derr.writeLine("Error: " ~ msg);
     throw new Exception("Error: " ~ msg ~ "\0");
   }
--- a/src/abagames/util/sdl/Input.d
+++ b/src/abagames/util/sdl/Input.d
@@ -5,7 +5,8 @@
  */
 module abagames.util.sdl.Input;
 
-import string = std.string;
+import std.conv;
+import std.string;
 import SDL;
 import abagames.util.sdl.SDLInitFailedException;
 
@@ -30,7 +31,7 @@
   public void openJoystick() {
     if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
       throw new SDLInitFailedException(
-	"Unable to init SDL joystick: " ~ string.toString(SDL_GetError()));
+	"Unable to init SDL joystick: " ~ to!string(SDL_GetError()));
     }
     stick = SDL_JoystickOpen(0);
   }
--- a/src/abagames/util/sdl/MainLoop.d
+++ b/src/abagames/util/sdl/MainLoop.d
@@ -90,7 +90,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/Screen3D.d
+++ b/src/abagames/util/sdl/Screen3D.d
@@ -5,7 +5,8 @@
  */
 module abagames.util.sdl.Screen3D;
 
-import string = std.string;
+import std.conv;
+import std.string;
 import std.c.stdlib;
 import SDL;
 import opengl;
@@ -31,7 +32,7 @@
   protected abstract void init();
   protected abstract void close();
 
-  public void initSDL() {
+  public override void initSDL() {
     if (lowres) {
       width /= 2;
       height /= 2;
@@ -39,7 +40,7 @@
     // Initialize SDL.
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
       throw new SDLInitFailedException(
-	"Unable to initialize SDL: " ~ string.toString(SDL_GetError()));
+	"Unable to initialize SDL: " ~ to!string(SDL_GetError()));
     }
     // Create an OpenGL screen.
     if (windowMode) {
@@ -49,7 +50,7 @@
     } 
     if (SDL_SetVideoMode(width, height, 0, videoFlags) == null) {
       throw new SDLInitFailedException
-	("Unable to create SDL screen: " ~ 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);
@@ -63,7 +64,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);
@@ -83,17 +84,17 @@
     screenResized();
   }
 
-  public void closeSDL() {
+  public override void closeSDL() {
     close();
     SDL_ShowCursor(SDL_ENABLE);
   }
 
-  public void flip() {
+  public override void flip() {
     handleError();
     SDL_GL_SwapBuffers();
   }
 
-  public void clear() {
+  public override void clear() {
     glClear(GL_COLOR_BUFFER_BIT);
   }
 
@@ -105,7 +106,7 @@
     exit(EXIT_FAILURE);
   }
 
-  protected void setCaption(char[] name) {
-    SDL_WM_SetCaption(string.toStringz(name), null);
+  protected void setCaption(string name) {
+    SDL_WM_SetCaption(toStringz(name), null);
   }
 }
--- a/src/abagames/util/sdl/Texture.d
+++ b/src/abagames/util/sdl/Texture.d
@@ -5,7 +5,7 @@
  */
 module abagames.util.sdl.Texture;
 
-import string = std.string;
+import std.string;
 import opengl;
 import SDL;
 import abagames.util.sdl.SDLInitFailedException;
@@ -15,15 +15,15 @@
  */
 public class Texture {
  public:
-  static char[] imagesDir = "/usr/share/games/a7xpg/images/";
+  static string imagesDir = "/usr/share/games/a7xpg/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(string.toStringz(fileName));
+    surface = SDL_LoadBMP(toStringz(fileName));
     if (!surface) {
       throw new SDLInitFailedException("Unable to load: " ~ fileName);
     }