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
|
Description: More fixes for D language changes
With this patch the code is accepted by gdc-8 8-20180414-1 without
triggering deprecated feature warnings.
- Convert I/O to use std.stdio module
- Fix some unused broken code by deleting it
- Avoid C-style array type notation
- Use "goto case" to mark fall-through in switch statements
Author: Peter De Wachter <pdewacht@gmail.com>
Forwarded: no
--- a/src/br/boss.d
+++ b/src/br/boss.d
@@ -1026,6 +1026,7 @@
addAnimation(new Magnification(500 ,100.0f) ,"mag");
changeState("startA");
}
+ break;
default:break;
}
--- a/src/br/bullet.d
+++ b/src/br/bullet.d
@@ -164,6 +164,7 @@
switch(kind){
case CollisionManager.kind.SHIP:
destroy();
+ goto case;
case CollisionManager.kind.WALL:
if(re <= 0){
if(vel.x<0)pos = new Vector3(p.pos.x+(p.collisionRange+collisionRange) ,pos.y ,pos.z);
@@ -228,6 +229,7 @@
switch(kind){
case CollisionManager.kind.SHIP:
destroy();
+ goto case;
case CollisionManager.kind.WALL:
if(!hit){
if(vel.x<0){
--- a/src/br/enemy.d
+++ b/src/br/enemy.d
@@ -773,7 +773,7 @@
// this.acc = (cast(Vector3)vel.clone()) * -0.01f;
if(ENEMYDSHAPE is null){
- Shape s = OctaShape.getShape(1.0f ,1.0f).transformMatrix(matRotateZ(-90));;
+ Shape s = OctaShape.getShape(1.0f ,1.0f).transformMatrix(matRotateZ(-90));
Shape s1 = OctaShape.getShape(0.6f ,3.0f).scalef(0.8f,0.8f,0.8f).transformMatrix(matTranslate(1.5f,0.0f,0.0f)*matRotateZ(45));
Shape s2 = OctaShape.getShape(0.6f ,3.0f).scalef(0.8f,0.8f,0.8f).transformMatrix(matTranslate(1.5f,0.0f,0.0f)*matRotateZ(135));
ENEMYDSHAPE = s + s1 + s2;
--- a/src/br/wall.d
+++ b/src/br/wall.d
@@ -10,7 +10,7 @@
public void makeWall(string type ,Vector3 pos ,Vector3 vel ,Object par = null){
switch(type){
- case "1" : new Wall1(pos ,vel);
+ case "1" : new Wall1(pos ,vel); break;
default:break;
}
--- a/src/util/log.d
+++ b/src/util/log.d
@@ -3,11 +3,11 @@
private import std.conv;
private import std.file;
private import std.path;
-private import std.cstream;
+private import std.stdio;
static const string g_logname = "run.log";
void Log_write(string msg)
{
- std.cstream.dout.writeLine(msg);
+ stdout.writeln(msg);
append(g_logname, msg ~ "\n");
}
void Log_write(int msg)
@@ -17,6 +17,6 @@
}
void Log_write(Exception e)
{
- std.cstream.dout.writeLine(e.toString());
+ stdout.writeln(e.toString());
append(g_logname, e.toString() ~ "\n");
}
--- a/src/util/mouse.d
+++ b/src/util/mouse.d
@@ -6,7 +6,6 @@
module util.mouse;
private import std.string;
-private import std.stream;
private import SDL;
private import br.screen;
@@ -107,18 +106,6 @@
button = 0;
}
- public void read(File fd) {
- fd.read(x);
- fd.read(y);
- fd.read(button);
- }
-
- public void write(File fd) {
- fd.write(x);
- fd.write(y);
- fd.write(button);
- }
-
public bool equals(MouseState s) {
if (x == s.x && y == s.y && button == s.button)
return true;
--- a/src/util/rand.d
+++ b/src/util/rand.d
@@ -5,7 +5,6 @@
*/
module util.rand;
-private import std.stream;
private import std.datetime;
/**
@@ -112,7 +111,7 @@
uint MIXBITS(uint u, uint v) { return (u & UMASK) | (v & LMASK); }
uint TWIST(uint u,uint v) { return (MIXBITS(u,v) >> 1) ^ (v&1 ? MATRIX_A : 0); }
-uint state[N]; /* the array for the state vector */
+uint[N] state; /* the array for the state vector */
int left = 1;
int initf = 0;
uint *next;
@@ -137,7 +136,7 @@
/* key_length is its length */
//uint init_key[];
//uint key_length;
-void init_by_array(uint init_key[], uint key_length)
+void init_by_array(uint[] init_key, uint key_length)
{
int i, j, k;
init_genrand(cast(uint)19650218UL);
--- a/src/util/record.d
+++ b/src/util/record.d
@@ -1,5 +1,4 @@
module util.record;
-private import std.stream;
public class Record{
@@ -32,30 +31,6 @@
}
}
}
- public void load(File fd){
- foreach(ref int[] lap;lapTime){
- foreach(ref int l;lap){
- fd.read(l);
- }
- }
- foreach(ref int[] total;totalTime){
- foreach(ref int t;total){
- fd.read(t);
- }
- }
- }
- public void save(File fd){
- foreach(ref int[] lap;lapTime){
- foreach(ref int l;lap){
- fd.write(l);
- }
- }
- foreach(ref int[] total;totalTime){
- foreach(ref int t;total){
- fd.write(t);
- }
- }
- }
public int updateLapRecord(int stage ,int lap){
int rank = -1;
if(lapTime.length <= stage)return -1;
--- a/import/hell2.d
+++ b/import/hell2.d
@@ -1,10 +1,8 @@
module hell2;
-private import core.vararg;
private import std.string;
private import std.conv;
private import std.file;
private import std.path;
-private import std.cstream;
private import std.ascii;
private import std.math;
private import std.format;
@@ -186,79 +184,6 @@
}
/**
- * SDL初期化
- */
-void Hell_init(string caption, int width=640, int height=480, bool fullscreen=false)
-{
- if(g_init) return;
- g_width = width;
- g_height = height;
- g_videoBpp = 0;
- g_videoFlags = SDL_OPENGL;
- if(fullscreen)
- {
- g_videoFlags |= SDL_FULLSCREEN;
- }
-
- if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
- {
- throw new Error("Hell_init: Couldn't initialize SDL");
- }
- // スクリーン初期化
- if((g_screen = SDL_SetVideoMode(g_width, g_height, g_videoBpp, g_videoFlags)) is null)
- {
- throw new Error("Hell_init: Couldn't set video mode");
- }
- if(fullscreen)
- {
- _toggleShowCursor(); // フルスクリーン時はマウスカーソルを消す
- }
-
- glOrtho(0, g_width, g_height, 0, -1, 1);
- glViewport(0, 0, g_width, g_height);
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- Hell_setCaption(caption);
- // アイコン設定
- SDL_Surface* icon = SDL_LoadBMP("resource/hell.bmp");
- SDL_WM_SetIcon(icon, null);
- // サウンド初期化(音を良くしたい場合、下のコメントを外す)
-// if(Mix_OpenAudio(44100, AUDIO_S16, 2, 8192) < 0)
- if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
- {
- throw new Error("Hell_init: " ~ to!string(SDL_GetError()));
- }
-
- // ログ初期化
- write(g_logname, "");
- if(SDL_NumJoysticks() > 0)
- {
- // ジョイスティック生成
- g_joy = SDL_JoystickOpen(0);
- if(!g_joy)
- {
- throw new Error(to!string(SDL_GetError()));
- }
- g_joyButtonNum = SDL_JoystickNumButtons(g_joy);
- g_joyButtonPrev = new bool[g_joyButtonNum];
- g_joyButton = new bool[g_joyButtonNum];
- }
- else
- {
- g_joy = null;
- g_joyButtonNum = 0;
- }
-
- // フォントの読込
- Hell_loadFont();
-
- // 曲面オブジェクト生成
-// g_quadricObj = gluNewQuadric();
-
- glEnable(GL_BLEND);
- g_init = true;
-}
-
-/**
* 終了処理
*/
void Hell_quit()
@@ -283,42 +208,6 @@
}
/**
- * キャプション設定(※日本語不可)
- */
-void Hell_setCaption(...)
-{
- string _caption = "";
- void _putc(dchar c)
- {
- scope tmp = [c];
- _caption ~= toUTF8(tmp);
- }
- doFormat(&_putc, _arguments, _argptr);
- SDL_WM_SetCaption(toStringz(_caption), null);
-}
-
-
-/**
- * ログ書き込み
- */
-void Hell_write(...)
-{
- void _putc(dchar c)
- {
- fputc(c, stdout);
- scope tmp = [c];
- append(g_logname, toUTF8(tmp));
- }
- doFormat(&_putc, _arguments, _argptr);
-}
-
-void Hell_write(Exception e)
-{
- dout.writeLine(e.toString());
- append(g_logname, e.toString() ~ "\n");
-}
-
-/**
* 画面を消去
*/
void Hell_begin()
@@ -952,18 +841,6 @@
tex.unbind();
}
-void Hell_drawFontEx(int x, int y, float zoom=1.0f, ubyte r=0xff, ubyte g=0xff, ubyte b=0xff, ubyte a=0xff, ...)
-{
- string _tmpString = "";
- void _putc(dchar c)
- {
- scope tmp = [c];
- _tmpString ~= toUTF8(tmp);
- }
- doFormat(&_putc, _arguments, _argptr);
- Hell_drawFont(_tmpString, x, y, zoom, r, g, b, a);
-}
-
/**
* αブレンド定数
*/
|