diff --git a/audio.d b/audio.d index 41f5436..b053100 100644 --- a/audio.d +++ b/audio.d @@ -4,8 +4,6 @@ module arsd.audio; import sdl.SDL; import sdl.SDL_mixer; -import std.string; - import arsd.engine; bool audioIsLoaded; // potential hack material @@ -15,7 +13,7 @@ class Sound { this(char[] filename){ if(!audioIsLoaded) return; - sfx = Mix_LoadWAV(std.string.toStringz(filename)); + sfx = Mix_LoadWAV((filename ~ "\0").ptr); if(sfx is null) throw new Exception(immutableString("Sound load " ~ filename)); } @@ -45,7 +43,7 @@ class Music { this(char[] filename){ if(!audioIsLoaded) return; - mus = Mix_LoadMUS(std.string.toStringz(filename)); + mus = Mix_LoadMUS((filename~"\0").ptr); if(mus is null) throw new Exception(immutableString("Music load " ~ filename)); } diff --git a/engine.d b/engine.d index 0da83ad..d9297d0 100644 --- a/engine.d +++ b/engine.d @@ -21,13 +21,13 @@ pragma(lib, "GL"); import sdl.SDL; import sdl.SDL_net; -import std.string; version(D_Version2) { import random = core.stdc.stdlib; alias random.srand srand; - import std.conv; - char[] convToString(T)(T t) { return to!(char[])(t); } + char[] convToString(int a) { + return null; + } string immutableString(in char[] a) { return a.idup; } } else { import random = std.random; @@ -49,7 +49,12 @@ version(D_Version2) else import std.stdarg; -import std.stdio; +version(D_Version2) { + import core.stdc.stdio; + void writefln(string s) { printf("%*s", s.length, s.ptr); } + void writefln(string s, int i) { printf(s.ptr, i); } +} else + import std.stdio; //version(linux) pragma(lib, "kbhit.o"); int randomNumber(int min, int max){ @@ -317,7 +322,7 @@ class Engine{ IPaddress ip; - if(SDLNet_ResolveHost(&ip, std.string.toStringz(whom), NET_PORT) == -1) + if(SDLNet_ResolveHost(&ip, (whom~"\0").ptr, NET_PORT) == -1) throw new Exception("Resolve host"); clientsock = SDLNet_TCP_Open(&ip); @@ -661,7 +666,7 @@ class Engine{ } void setTitle(in char[] title){ - SDL_WM_SetCaption(std.string.toStringz(title), null); + SDL_WM_SetCaption((title~"\0").ptr, null); } bool buttonWasPressed(Buttons button, int which = 0){ @@ -979,7 +984,7 @@ class Engine{ buttonLagQueueEnd[button][which] = 0; } else { if(when < globalTimer) - throw new Exception(immutableString("Impossible control timing " ~ convToString(when) ~ " @ " ~ convToString(globalTimer))); + throw new Exception(immutableString("Impossible control timing"));// " ~ convToString(when) ~ " @ " ~ convToString(globalTimer))); buttonsDown[button][which] = type; buttonsChecked[button][which] = false; }