]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Another block of 'GameTick.cpp' converted file paths to use ConvertFileName(), so...
[lugaru.git] / Source / GameTick.cpp
index 853c5ca73494709a566634564dcdf90ed4c1c1e5..557c2728051095d4f78228208ee9b3ad8380d00c 100644 (file)
@@ -1,3 +1,24 @@
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+
 #if PLATFORM_UNIX
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -8,6 +29,7 @@
 
 #include <ctime>
 #include "Game.h"
+#include "openal_wrapper.h"
 
 using namespace std;
 
@@ -16,7 +38,7 @@ extern XYZ viewer;
 extern int environment;
 extern float texscale;
 extern Terrain terrain;
-extern FSOUND_SAMPLE   *samp[100];
+extern OPENAL_SAMPLE   *samp[100];
 extern int channels[100];
 extern Sprites sprites;
 extern int kTextureSize;
@@ -54,8 +76,6 @@ extern bool mousejump;
 extern float viewdistance;
 extern bool freeze;
 extern bool autoslomo;
-extern int newnetmessages;
-extern char netmessages[256];
 extern bool keyboardfrozen;
 extern int netdatanew;
 extern bool loadingstuff;
@@ -203,9 +223,9 @@ extern float accountcampaigntime[10];
 extern int accountcampaignchoicesmade[10];
 extern int accountcampaignchoices[10][5000];
 /********************> Tick() <*****/
-extern FSOUND_STREAM * strm[10];
-extern "C"     void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
-extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
+extern OPENAL_STREAM * strm[20];
+extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
+extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 
 extern void ScreenShot(const char * fname);
 void Screenshot        (void)
@@ -215,17 +235,22 @@ void Screenshot   (void)
        struct  tm *tme = localtime(&t);
        sprintf(temp, "Screenshots\\Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
 
+       #if defined(_WIN32)
+       mkdir("Screenshots");
+       #else
        mkdir("Screenshots", S_IRWXU);
+       #endif
+
        ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
 
-       /*FSSpec                                MAC_file;
-       GraphicsExportComponent         QT_exporter;
+       /*FSSpec                                MAC_file;
+       GraphicsExportComponent QT_exporter;
        OSErr                           MAC_error_code;
        CGrafPtr                        MAC_currentPort;
        GDHandle                        MAC_currentDevice;
        unsigned char*          MAC_pixels;
        Rect                            MAC_picture_rectangle;
-       GWorldPtr                       MAC_offscreen_graphics_port;
+       GWorldPtr                       MAC_offscreen_graphics_port;
 
        static int numscreenshots=0;
 
@@ -286,7 +311,7 @@ void Screenshot     (void)
 
 
        // Get the GWorld
-       GWorldPtr                       MAC_gWorld = (CGrafPtr) FrontWindow();
+       GWorldPtr                       MAC_gWorld = (CGrafPtr) FrontWindow();
        //assert(MAC_gWorld != NULL);
 
        // Allocate memory for loading image
@@ -297,18 +322,18 @@ void Screenshot   (void)
        }
 
        // Get GWorld
-       ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);      
+       ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
 
        // Make a picture Rectangle
        MAC_picture_rectangle.left = 0;
        MAC_picture_rectangle.right = screenwidth;
        MAC_picture_rectangle.top = 0;
-       MAC_picture_rectangle.bottom = screenheight;    
+       MAC_picture_rectangle.bottom = screenheight;
 
        // Create new offscreen GWorld
        MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
        if (MAC_error_code)     {
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);        
+       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
        delete MAC_pixels;
        //UTIL_Error("Could not create offscreen GWorld. ");
        return;
@@ -316,7 +341,7 @@ void Screenshot     (void)
        }
 
        // Copy OpenGL Context to new GWorld
-       glReadBuffer(GL_FRONT); 
+       glReadBuffer(GL_FRONT);
        glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
 
        // Swizzle texture
@@ -334,7 +359,7 @@ void Screenshot     (void)
        int dst_index;
        unsigned char temp;
        for (int horz = 0; horz < screenwidth; ++horz)
-       for (vert = 0; vert < screenheight / 2; ++vert) {               
+       for (vert = 0; vert < screenheight / 2; ++vert) {
        src_index = (screenwidth * vert + horz) * 4;
        dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
 
@@ -360,12 +385,12 @@ void Screenshot   (void)
        // Export the Gworld
        MAC_error_code =  OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
        if (MAC_error_code) {
-       //UTIL_Warning("Unable to export screenshot."); 
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);        
+       //UTIL_Warning("Unable to export screenshot.");
+       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
        ::DisposeGWorld(MAC_offscreen_graphics_port);
        delete MAC_pixels;
        return;
-       }                                                                                               
+       }
 
        MAC_error_code =  GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
        if (MAC_error_code) {
@@ -375,27 +400,27 @@ void Screenshot   (void)
        delete MAC_pixels;
        //UTIL_Warning("Unable to export screenshot.");
        return;
-       }                                                               
+       }
 
        MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
        if (MAC_error_code) {
        ::CloseComponent(QT_exporter);
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);        
+       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
        ::DisposeGWorld(MAC_offscreen_graphics_port);
        delete MAC_pixels;
        //UTIL_Warning("Unable to export screenshot.");
        return;
-       }                                                       
+       }
 
        MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
        if (MAC_error_code) {
        ::CloseComponent(QT_exporter);
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);                        
+       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
        ::DisposeGWorld(MAC_offscreen_graphics_port);
        delete MAC_pixels;
        //UTIL_Warning("Unable to export screenshot.");
        return;
-       }                                               
+       }
 
        ::CloseComponent(QT_exporter);
        ::SetGWorld(MAC_currentPort, MAC_currentDevice);
@@ -406,14 +431,14 @@ void Screenshot   (void)
 
 
 
-void   Game::SetUpLighting(){
+void   Game::SetUpLighting(){
        if(environment==snowyenvironment){
                light.color[0]=.65;
                light.color[1]=.65;
                light.color[2]=.7;
                light.ambient[0]=.4;
                light.ambient[1]=.4;
-               light.ambient[2]=.44;           
+               light.ambient[2]=.44;
        }
        if(environment==desertenvironment){
                light.color[0]=.95;
@@ -421,7 +446,7 @@ void        Game::SetUpLighting(){
                light.color[2]=.95;
                light.ambient[0]=.4;
                light.ambient[1]=.35;
-               light.ambient[2]=.3;            
+               light.ambient[2]=.3;
        }
 
        if(environment==grassyenvironment){
@@ -430,7 +455,7 @@ void        Game::SetUpLighting(){
                light.color[2]=1;
                light.ambient[0]=.4;
                light.ambient[1]=.4;
-               light.ambient[2]=.44;           
+               light.ambient[2]=.44;
        }
        if(!skyboxtexture){
                light.color[0]=1;
@@ -438,7 +463,7 @@ void        Game::SetUpLighting(){
                light.color[2]=1;
                light.ambient[0]=.4;
                light.ambient[1]=.4;
-               light.ambient[2]=.4;    
+               light.ambient[2]=.4;
        }
        float average;
        average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
@@ -447,7 +472,7 @@ void        Game::SetUpLighting(){
        light.color[2]*=(skyboxlightb+average)/2;
        light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
        light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
-       light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;   
+       light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
        /*
        light.ambient[0]=0;
        light.ambient[1]=0;
@@ -534,7 +559,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint){
                        if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
                                colviewer=startpoint;
                                coltarget=endpoint;
-                               if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;  
+                               if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
                        }
                }
        }
@@ -580,7 +605,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
                        if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
                                colviewer=startpoint;
                                coltarget=endpoint;
-                               if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i; 
+                               if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
                        }
                }
        }
@@ -590,7 +615,7 @@ int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
        return -1;
 }
 
-void   Game::Setenvironment(int which)
+void   Game::Setenvironment(int which)
 {
        LOGFUNC;
 
@@ -599,66 +624,66 @@ void      Game::Setenvironment(int which)
        float temptexdetail;
        environment=which;
 /*
-       FSOUND_SetPaused(channels[music1snow], TRUE);
-       FSOUND_SetPaused(channels[music1grass], TRUE);
-       FSOUND_SetPaused(channels[music1desert], TRUE);
-       FSOUND_SetPaused(channels[wind], TRUE);
-       FSOUND_SetPaused(channels[desertambient], TRUE);
+       OPENAL_SetPaused(channels[music1snow], true);
+       OPENAL_SetPaused(channels[music1grass], true);
+       OPENAL_SetPaused(channels[music1desert], true);
+       OPENAL_SetPaused(channels[wind], true);
+       OPENAL_SetPaused(channels[desertambient], true);
 */
-       FSOUND_SetPaused(channels[stream_music1snow], TRUE);
-       FSOUND_SetPaused(channels[stream_music1grass], TRUE);
-       FSOUND_SetPaused(channels[stream_music1desert], TRUE);
-       FSOUND_SetPaused(channels[stream_wind], TRUE);
-       FSOUND_SetPaused(channels[stream_desertambient], TRUE);
+       OPENAL_SetPaused(channels[stream_music1snow], true);
+       OPENAL_SetPaused(channels[stream_music1grass], true);
+       OPENAL_SetPaused(channels[stream_music1desert], true);
+       OPENAL_SetPaused(channels[stream_wind], true);
+       OPENAL_SetPaused(channels[stream_desertambient], true);
 
 
        if(environment==snowyenvironment){
                windvector=0;
                windvector.z=3;
                if(ambientsound){
-                       //PlaySoundEx( wind, samp[wind], NULL, TRUE);
-                       PlayStreamEx(stream_wind, strm[stream_wind], 0, TRUE);
-                       FSOUND_SetPaused(channels[stream_wind], FALSE);
-                       FSOUND_SetVolume(channels[stream_wind], 256);
+                       //PlaySoundEx( wind, samp[wind], NULL, true);
+                       PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
+                       OPENAL_SetPaused(channels[stream_wind], false);
+                       OPENAL_SetVolume(channels[stream_wind], 256);
                }
 
-               LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
-               LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
-               LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
-               LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:snowtree.png"),&objects.treetextureptr,0,1);
+               LoadTexture(ConvertFileName(":Data:Textures:bushsnow.png"),&objects.bushtextureptr,0,1);
+               LoadTexture(ConvertFileName(":Data:Textures:bouldersnow.jpg"),&objects.rocktextureptr,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:snowbox.jpg"),&objects.boxtextureptr,1,0);
 
-               FSOUND_Sample_Free(samp[footstepsound]);
-               FSOUND_Sample_Free(samp[footstepsound2]);
-               FSOUND_Sample_Free(samp[footstepsound3]);
-               FSOUND_Sample_Free(samp[footstepsound4]);
-               samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);    
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);   
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);   
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);   
+               OPENAL_Sample_Free(samp[footstepsound]);
+               OPENAL_Sample_Free(samp[footstepsound2]);
+               OPENAL_Sample_Free(samp[footstepsound3]);
+               OPENAL_Sample_Free(samp[footstepsound4]);
+               samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
 
-               LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:snow.jpg"),&terraintexture,1,0);
 
-               LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:rock.jpg"),&terraintexture2,1,0);
 
-               //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
+               //LoadTexture(ConvertFileName(":Data:Textures:detailgrain.png"),&terraintexture3,1);
 
 
 
 
                temptexdetail=texdetail;
                if(texdetail>1)texdetail=4;
-               skybox.load(    ":Data:Textures:Skybox(snow):Front.jpg",
-                       ":Data:Textures:Skybox(snow):Left.jpg",
-                       ":Data:Textures:Skybox(snow):Back.jpg",
-                       ":Data:Textures:Skybox(snow):Right.jpg",
-                       ":Data:Textures:Skybox(snow):Up.jpg",
-                       ":Data:Textures:Skybox(snow):Down.jpg",
-                       ":Data:Textures:Skybox(snow):Cloud.jpg",
-                       ":Data:Textures:Skybox(snow):Reflect.jpg");
+               skybox.load(    ConvertFileName(":Data:Textures:Skybox(snow):Front.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Left.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Back.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Right.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Up.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Down.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Cloud.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(snow):Reflect.jpg"));
 
 
 
@@ -668,50 +693,50 @@ void      Game::Setenvironment(int which)
        if(environment==desertenvironment){
                windvector=0;
                windvector.z=2;
-               LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
-               LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
-               LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
-               LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:deserttree.png"),&objects.treetextureptr,0,1);
+               LoadTexture(ConvertFileName(":Data:Textures:bushdesert.png"),&objects.bushtextureptr,0,1);
+               LoadTexture(ConvertFileName(":Data:Textures:boulderdesert.jpg"),&objects.rocktextureptr,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:desertbox.jpg"),&objects.boxtextureptr,1,0);
 
 
                if(ambientsound){
-                       //PlaySoundEx( desertambient, samp[desertambient], NULL, TRUE);
-                       PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, TRUE);
-                       FSOUND_SetPaused(channels[stream_desertambient], FALSE);
-                       FSOUND_SetVolume(channels[stream_desertambient], 256);
+                       //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
+                       PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
+                       OPENAL_SetPaused(channels[stream_desertambient], false);
+                       OPENAL_SetVolume(channels[stream_desertambient], 256);
                }
 
-               FSOUND_Sample_Free(samp[footstepsound]);
-               FSOUND_Sample_Free(samp[footstepsound2]);
-               FSOUND_Sample_Free(samp[footstepsound3]);
-               FSOUND_Sample_Free(samp[footstepsound4]);
-               samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);    
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);   
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);   
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);   
+               OPENAL_Sample_Free(samp[footstepsound]);
+               OPENAL_Sample_Free(samp[footstepsound2]);
+               OPENAL_Sample_Free(samp[footstepsound3]);
+               OPENAL_Sample_Free(samp[footstepsound4]);
+               samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
 
-               LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:sand.jpg"),&terraintexture,1,0);
 
-               LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:sandslope.jpg"),&terraintexture2,1,0);
 
-               //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
+               //LoadTexture(ConvertFileName(":Data:Textures:detailgrain.png"),&terraintexture3,1);
 
 
 
                temptexdetail=texdetail;
                if(texdetail>1)texdetail=4;
-               skybox.load(    ":Data:Textures:Skybox(sand):Front.jpg",
-                       ":Data:Textures:Skybox(sand):Left.jpg",
-                       ":Data:Textures:Skybox(sand):Back.jpg",
-                       ":Data:Textures:Skybox(sand):Right.jpg",
-                       ":Data:Textures:Skybox(sand):Up.jpg",
-                       ":Data:Textures:Skybox(sand):Down.jpg",
-                       ":Data:Textures:Skybox(sand):Cloud.jpg",
-                       ":Data:Textures:Skybox(sand):Reflect.jpg");
+               skybox.load(    ConvertFileName(":Data:Textures:Skybox(sand):Front.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Left.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Back.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Right.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Up.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Down.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Cloud.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(sand):Reflect.jpg"));
 
 
 
@@ -721,48 +746,48 @@ void      Game::Setenvironment(int which)
        if(environment==grassyenvironment){
                windvector=0;
                windvector.z=2;
-               LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
-               LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
-               LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
-               LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:tree.png"),&objects.treetextureptr,0,1);
+               LoadTexture(ConvertFileName(":Data:Textures:bush.png"),&objects.bushtextureptr,0,1);
+               LoadTexture(ConvertFileName(":Data:Textures:boulder.jpg"),&objects.rocktextureptr,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:grassbox.jpg"),&objects.boxtextureptr,1,0);
 
                if(ambientsound){
-                       PlayStreamEx( stream_wind, strm[stream_wind], NULL, TRUE);
-                       FSOUND_SetPaused(channels[stream_wind], FALSE);
-                       FSOUND_SetVolume(channels[stream_wind], 100);
+                       PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
+                       OPENAL_SetPaused(channels[stream_wind], false);
+                       OPENAL_SetVolume(channels[stream_wind], 100);
                }
 
-               FSOUND_Sample_Free(samp[footstepsound]);
-               FSOUND_Sample_Free(samp[footstepsound2]);
-               FSOUND_Sample_Free(samp[footstepsound3]);
-               FSOUND_Sample_Free(samp[footstepsound4]);
-               samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
-               samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);    
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);   
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);   
-               FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);   
+               OPENAL_Sample_Free(samp[footstepsound]);
+               OPENAL_Sample_Free(samp[footstepsound2]);
+               OPENAL_Sample_Free(samp[footstepsound3]);
+               OPENAL_Sample_Free(samp[footstepsound4]);
+               samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
+               samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
+               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
 
-               LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:grassdirt.jpg"),&terraintexture,1,0);
 
-               LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
+               LoadTexture(ConvertFileName(":Data:Textures:mossrock.jpg"),&terraintexture2,1,0);
 
-               //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
+               //LoadTexture(ConvertFileName(":Data:Textures:detail.png"),&terraintexture3,1);
 
 
 
                temptexdetail=texdetail;
                if(texdetail>1)texdetail=4;
-               skybox.load(    ":Data:Textures:Skybox(grass):Front.jpg",
-                       ":Data:Textures:Skybox(grass):Left.jpg",
-                       ":Data:Textures:Skybox(grass):Back.jpg",
-                       ":Data:Textures:Skybox(grass):Right.jpg",
-                       ":Data:Textures:Skybox(grass):Up.jpg",
-                       ":Data:Textures:Skybox(grass):Down.jpg",
-                       ":Data:Textures:Skybox(grass):Cloud.jpg",
-                       ":Data:Textures:Skybox(grass):Reflect.jpg");
+               skybox.load(    ConvertFileName(":Data:Textures:Skybox(grass):Front.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Left.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Back.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Right.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Up.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Down.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Cloud.jpg"),
+                       ConvertFileName(":Data:Textures:Skybox(grass):Reflect.jpg"));
 
 
 
@@ -770,33 +795,33 @@ void      Game::Setenvironment(int which)
        }
        temptexdetail=texdetail;
        texdetail=1;
-       terrain.load(":Data:Textures:heightmap.png");
+       terrain.load(ConvertFileName(":Data:Textures:heightmap.png"));
 
        texdetail=temptexdetail;
 }
 
 
-void   Game::Loadlevel(int which){
+void   Game::Loadlevel(int which){
        stealthloading=0;
 
-       if(which==0)Loadlevel((char *)":Data:Maps:map1");
-       else if(which==1)Loadlevel((char *)":Data:Maps:map2");
-       else if(which==2)Loadlevel((char *)":Data:Maps:map3");
-       else if(which==3)Loadlevel((char *)":Data:Maps:map4");
-       else if(which==4)Loadlevel((char *)":Data:Maps:map5");
-       else if(which==5)Loadlevel((char *)":Data:Maps:map6");
-       else if(which==6)Loadlevel((char *)":Data:Maps:map7");
-       else if(which==7)Loadlevel((char *)":Data:Maps:map8");
-       else if(which==8)Loadlevel((char *)":Data:Maps:map9");
-       else if(which==9)Loadlevel((char *)":Data:Maps:map10");
-       else if(which==10)Loadlevel((char *)":Data:Maps:map11");
-       else if(which==11)Loadlevel((char *)":Data:Maps:map12");
-       else if(which==12)Loadlevel((char *)":Data:Maps:map13");
-       else if(which==13)Loadlevel((char *)":Data:Maps:map14");
-       else if(which==14)Loadlevel((char *)":Data:Maps:map15");
-       else if(which==15)Loadlevel((char *)":Data:Maps:map16");
-       else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
-       else Loadlevel((char *)":Data:Maps:mapsave");
+       if(which==0)Loadlevel((char *)ConvertFileName(":Data:Maps:map1"));
+       else if(which==1)Loadlevel((char *)ConvertFileName(":Data:Maps:map2"));
+       else if(which==2)Loadlevel((char *)ConvertFileName(":Data:Maps:map3"));
+       else if(which==3)Loadlevel((char *)ConvertFileName(":Data:Maps:map4"));
+       else if(which==4)Loadlevel((char *)ConvertFileName(":Data:Maps:map5"));
+       else if(which==5)Loadlevel((char *)ConvertFileName(":Data:Maps:map6"));
+       else if(which==6)Loadlevel((char *)ConvertFileName(":Data:Maps:map7"));
+       else if(which==7)Loadlevel((char *)ConvertFileName(":Data:Maps:map8"));
+       else if(which==8)Loadlevel((char *)ConvertFileName(":Data:Maps:map9"));
+       else if(which==9)Loadlevel((char *)ConvertFileName(":Data:Maps:map10"));
+       else if(which==10)Loadlevel((char *)ConvertFileName(":Data:Maps:map11"));
+       else if(which==11)Loadlevel((char *)ConvertFileName(":Data:Maps:map12"));
+       else if(which==12)Loadlevel((char *)ConvertFileName(":Data:Maps:map13"));
+       else if(which==13)Loadlevel((char *)ConvertFileName(":Data:Maps:map14"));
+       else if(which==14)Loadlevel((char *)ConvertFileName(":Data:Maps:map15"));
+       else if(which==15)Loadlevel((char *)ConvertFileName(":Data:Maps:map16"));
+       else if(which==-1){tutoriallevel=-1;Loadlevel((char *)ConvertFileName(":Data:Maps:tutorial"));}
+       else Loadlevel((char *)ConvertFileName(":Data:Maps:mapsave"));
 
        whichlevel=which;
 }
@@ -806,9 +831,9 @@ char temp[50];
 char temp2[100];
 
 strcpy(temp2,(const char *)string);
-strcat((char *)temp2,(const char *)"Lugaru");                                  
+strcat((char *)temp2,(const char *)"Lugaru");
 sprintf (temp, "%d",strlen((char *)temp2));
-strcat((char *)temp2,temp);                                    
+strcat((char *)temp2,temp);
 
 MD5 context;
 unsigned int len = strlen ( (char *)temp2);
@@ -821,7 +846,7 @@ return context.hex_digest();
 
 
 
-void   Game::Loadlevel(char *name){
+void   Game::Loadlevel(char *name){
        int i,j,k,l,m;
        static int oldlevel;
        int templength;
@@ -855,15 +880,18 @@ void      Game::Loadlevel(char *name){
        if(!firstload){
                oldlevel=50;
        }
-       FSOUND_SetPaused(channels[whooshsound], TRUE);
-       FSOUND_SetPaused(channels[stream_firesound], TRUE);
+       OPENAL_SetPaused(channels[whooshsound], true);
+       OPENAL_SetPaused(channels[stream_firesound], true);
+
+       // Change the map filename into something that is os specific
+       char *FixedFN = ConvertFileName(name);
 
        int mapvers;
        FILE                    *tfile;
-       tfile=fopen( name, "rb" );
+       tfile=fopen( FixedFN, "rb" );
        if(tfile)
        {
-               FSOUND_SetPaused(channels[stream_firesound], TRUE);
+               OPENAL_SetPaused(channels[stream_firesound], true);
 
 
                scoreadded=0;
@@ -874,7 +902,7 @@ void        Game::Loadlevel(char *name){
                won=0;
 
                //campaign=0;
-               animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
+               animation[bounceidleanim].Load((char *)ConvertFileName(":Data:Animations:Idle"),middleheight,neutral);
 
                numdialogues=0;
 
@@ -934,9 +962,9 @@ void        Game::Loadlevel(char *name){
                changedelay=0;
                if(console)
                {
-                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                       OPENAL_SetPaused(channels[consolesuccesssound], false);
                        freeze=0;
                        console=0;
                }
@@ -1087,7 +1115,7 @@ void      Game::Loadlevel(char *name){
                                                        for(m=0;m<templength;m++){
                                                                funpackf(tfile, "Bb", &dialoguename[k][l][m]);
                                                                if(dialoguename[k][l][m]=='\0'){
-                                                                       break;  
+                                                                       break;
                                                                }
                                                        }
                                                        funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
@@ -1113,7 +1141,7 @@ void      Game::Loadlevel(char *name){
                                for(l=0;l<templength;l++)
                                        funpackf(tfile, "Bb", &player[0].clothes[k][l]);
                                player[0].clothes[k][templength]='\0';
-                               funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);                                                                        
+                               funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
                        }
                }
 
@@ -1155,7 +1183,7 @@ void      Game::Loadlevel(char *name){
                        objects.center=0;
                        for(i=0;i<objects.numobjects;i++)
                        {
-                               objects.center+=objects.position[i];    
+                               objects.center+=objects.position[i];
                        }
                        objects.center/=objects.numobjects;
 
@@ -1175,7 +1203,7 @@ void      Game::Loadlevel(char *name){
                                }
                        }
                        objects.radius=fast_sqrt(maxdistance);
-               }                               
+               }
 
                if(visibleloading){loadscreencolor=4; LoadingScreen();}
                //mapcenter=objects.center;
@@ -1271,7 +1299,7 @@ void      Game::Loadlevel(char *name){
                                                        for(l=0;l<templength;l++)
                                                                funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
                                                        player[i-howmanyremoved].clothes[k][templength]='\0';
-                                                       funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);                                                                   
+                                                       funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
                                                }
                                        }
                                }
@@ -1340,15 +1368,15 @@ void    Game::Loadlevel(char *name){
                        //if(Random()%2==0)player[i].creature=wolftype;
                        //else player[i].creature=rabbittype;
                        if(i==0&&mapvers<9)player[i].creature=rabbittype;
-                       if(player[i].creature!=wolftype)player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",0);
+                       if(player[i].creature!=wolftype)player[i].skeleton.Load((char *)ConvertFileName(":Data:Skeleton:Basic Figure"),(char *)ConvertFileName(":Data:Skeleton:Basic Figurelow"),(char *)ConvertFileName(":Data:Skeleton:Rabbitbelt"),(char *)ConvertFileName(":Data:Models:Body.solid"),(char *)ConvertFileName(":Data:Models:Body2.solid"),(char *)ConvertFileName(":Data:Models:Body3.solid"),(char *)ConvertFileName(":Data:Models:Body4.solid"),(char *)ConvertFileName(":Data:Models:Body5.solid"),(char *)ConvertFileName(":Data:Models:Body6.solid"),(char *)ConvertFileName(":Data:Models:Body7.solid"),(char *)ConvertFileName(":Data:Models:Bodylow.solid"),(char *)ConvertFileName(":Data:Models:Belt.solid"),0);
                        else
                        {
                                if(player[i].creature!=wolftype){
-                                       player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
-                                       LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
+                                       player[i].skeleton.Load((char *)ConvertFileName(":Data:Skeleton:Basic Figure"),(char *)ConvertFileName(":Data:Skeleton:Basic Figurelow"),(char *)ConvertFileName(":Data:Skeleton:Rabbitbelt"),(char *)ConvertFileName(":Data:Models:Body.solid"),(char *)ConvertFileName(":Data:Models:Body2.solid"),(char *)ConvertFileName(":Data:Models:Body3.solid"),(char *)ConvertFileName(":Data:Models:Body4.solid"),(char *)ConvertFileName(":Data:Models:Body5.solid"),(char *)ConvertFileName(":Data:Models:Body6.solid"),(char *)ConvertFileName(":Data:Models:Body7.solid"),(char *)ConvertFileName(":Data:Models:Bodylow.solid"),(char *)ConvertFileName(":Data:Models:Belt.solid"),1);
+                                       LoadTexture(ConvertFileName(":Data:Textures:Belt.png"),&player[i].skeleton.drawmodelclothes.textureptr,1,1);
                                }
                                if(player[i].creature==wolftype){
-                                       player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
+                                       player[i].skeleton.Load((char *)ConvertFileName(":Data:Skeleton:Basic Figure Wolf"),(char *)ConvertFileName(":Data:Skeleton:Basic Figure Wolf Low"),(char *)ConvertFileName(":Data:Skeleton:Rabbitbelt"),(char *)ConvertFileName(":Data:Models:Wolf.solid"),(char *)ConvertFileName(":Data:Models:Wolf2.solid"),(char *)ConvertFileName(":Data:Models:Wolf3.solid"),(char *)ConvertFileName(":Data:Models:Wolf4.solid"),(char *)ConvertFileName(":Data:Models:Wolf5.solid"),(char *)ConvertFileName(":Data:Models:Wolf6.solid"),(char *)ConvertFileName(":Data:Models:Wolf7.solid"),(char *)ConvertFileName(":Data:Models:Wolflow.solid"),(char *)ConvertFileName(":Data:Models:Belt.solid"),0);
                                }
                        }
 
@@ -1361,47 +1389,47 @@ void    Game::Loadlevel(char *name){
                        if(player[i].creature==rabbittype)
                        {
                                if(player[i].whichskin==0){
-                                       LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur3.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==1){
-                                       LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==2){
-                                       LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur2.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==3){
-                                       LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Lynx.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==4){
-                                       LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Otter.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==5){
-                                       LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Opal.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==6){
-                                       LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Sable.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==7){
-                                       LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Chocolate.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==8){
-                                       LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:BW2.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==9){
-                                       LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:WB2.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                        }
                        if(player[i].creature==wolftype)
                        {
                                //k=abs(Random()%3);
                                if(player[i].whichskin==0){
-                                       LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Wolf.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==1){
-                                       LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Darkwolf.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                                else if(player[i].whichskin==2){
-                                       LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                       LoadTextureSave(ConvertFileName(":Data:Textures:Snowwolf.jpg"),&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
                        }
 
@@ -1474,7 +1502,7 @@ void      Game::Loadlevel(char *name){
                                if(i==0||player[i].scale<0)player[i].scale=.23;
 
                                player[i].damagetolerance=300;
-                       }                               
+                       }
 
                        if(visibleloading){loadscreencolor=4; LoadingScreen();}
                        if(cellophane)
@@ -1485,7 +1513,7 @@ void      Game::Loadlevel(char *name){
                                player[i].proportionlegs.z=0;
                        }
 
-                       player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
+                       player[i].tempanimation.Load((char *)ConvertFileName(":Data:Animations:Tempanim"),0,0);
 
                        player[i].headmorphness=0;
                        player[i].targetheadmorphness=1;
@@ -1580,20 +1608,20 @@ void    Game::Loadlevel(char *name){
                }
 
 /*             for(i=0;i<32;i++){
-                       //if(i<16||i>20)                                
-                       FSOUND_StopSound(i);
+                       //if(i<16||i>20)
+                       OPENAL_StopSound(i);
                }
 */
                LOG("Starting background music...");
 
-               FSOUND_StopSound(FSOUND_ALL);
+               OPENAL_StopSound(OPENAL_ALL);
                if(environment==snowyenvironment)
                {
                        if(ambientsound)
                        {
-                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
-                               FSOUND_SetPaused(channels[stream_wind], FALSE);
-                               FSOUND_SetVolume(channels[stream_wind], 256);
+                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
+                               OPENAL_SetPaused(channels[stream_wind], false);
+                               OPENAL_SetVolume(channels[stream_wind], 256);
                        }
                }
                else if(environment==desertenvironment)
@@ -1601,21 +1629,21 @@ void    Game::Loadlevel(char *name){
                        if(ambientsound)
                        {
                                //PlaySoundEx(desertambient,
-                               //      samp[desertambient], NULL, TRUE);
+                               //      samp[desertambient], NULL, true);
                                PlayStreamEx(stream_desertambient,
-                                       strm[stream_desertambient], NULL, TRUE);
-                               FSOUND_SetPaused(channels[stream_desertambient], FALSE);
-                               FSOUND_SetVolume(channels[stream_desertambient], 256);
+                                       strm[stream_desertambient], NULL, true);
+                               OPENAL_SetPaused(channels[stream_desertambient], false);
+                               OPENAL_SetVolume(channels[stream_desertambient], 256);
                        }
                }
                else if(environment==grassyenvironment)
                {
                        if(ambientsound)
                        {
-                               //PlaySoundEx(wind, samp[wind], NULL, TRUE);
-                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
-                               FSOUND_SetPaused(channels[stream_wind], FALSE);
-                               FSOUND_SetVolume(channels[stream_wind], 100);
+                               //PlaySoundEx(wind, samp[wind], NULL, true);
+                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
+                               OPENAL_SetPaused(channels[stream_wind], false);
+                               OPENAL_SetVolume(channels[stream_wind], 100);
                        }
                }
                oldmusicvolume[0]=0;
@@ -1624,14 +1652,14 @@ void    Game::Loadlevel(char *name){
                oldmusicvolume[3]=0;
 
 
-               /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
-               LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
-               LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
-               LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
-               LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
-               LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
-               LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
-               LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
+               /*LoadTexture(ConvertFileName(":Data:Textures:cloud.png"),&sprites.cloudtexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:cloudimpact.png"),&sprites.cloudimpacttexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:bloodparticle.png"),&sprites.bloodtexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:snowflake.png"),&sprites.snowflaketexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:flame.png"),&sprites.flametexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:bloodflame.png"),&sprites.bloodflametexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:smoke.png"),&sprites.smoketexture,1,1);
+               LoadTexture(ConvertFileName(":Data:Textures:shine.png"),&sprites.shinetexture,1,0);
                */
 
                if(!firstload)
@@ -1644,7 +1672,7 @@ void      Game::Loadlevel(char *name){
        visibleloading=0;
 }
 
-void   Game::Tick()
+void   Game::Tick()
 {
        static int i,k,j,l,m;
        static XYZ facing,flatfacing,absflatfacing;
@@ -1664,36 +1692,6 @@ void     Game::Tick()
 
        float headprop,bodyprop,armprop,legprop;
 
-       if(newnetmessages){
-               newnetmessages=0;
-               PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-               FSOUND_SetVolume(channels[consolesuccesssound], 256);
-               FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
-
-               for(k=14;k>=2;k--){
-                       for(j=0;j<255;j++){
-                               consoletext[k][j]=consoletext[k-1][j];
-                       }
-                       consolechars[k]=consolechars[k-1];
-               }
-               for(k=14;k>=2;k--){
-                       for(j=0;j<255;j++){
-                               displaytext[k][j]=displaytext[k-1][j];
-                       }
-                       displaychars[k]=displaychars[k-1];
-                       displaytime[k]=displaytime[k-1];
-               }
-               for(j=0;j<255;j++){
-                       consoletext[1][j]=' ';
-                       displaytext[1][j]=' ';
-               }
-               sprintf (consoletext[1], netmessages);
-               sprintf (displaytext[1], netmessages);
-               consolechars[1]=255;
-               displaychars[1]=255;
-               displaytime[1]=0;
-       }
-
        for(i=0;i<15;i++){
                displaytime[i]+=multiplier;
        }
@@ -1716,7 +1714,7 @@ void      Game::Tick()
                        entername=0;
                        mainmenutogglekeydown=1;
                }
-               if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||(mainmenu==12&&!tryquit)||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17||mainmenu==10)){
+               if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10)){
                        selected=-1;
                        if(mainmenu==1||mainmenu==2||mainmenu==0){
                                if(mainmenu==0&&!winfreeze)mainmenu=2;
@@ -1729,12 +1727,12 @@ void    Game::Tick()
                                        if(!stealthloading){
                                        float gLoc[3]={0,0,0};
                                        float vel[3]={0,0,0};
-                                       FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                       FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                       FSOUND_SetVolume(channels[firestartsound], 256);
-                                       FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                       FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                       OPENAL_SetVolume(channels[firestartsound], 256);
+                                       OPENAL_SetPaused(channels[firestartsound], false);
+                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                        flashr=1;
                                        flashg=0;
@@ -1807,34 +1805,34 @@ void    Game::Tick()
                                        campaign=1;
                                        mainmenu=0;
                                        gameon=1;
-                                       FSOUND_SetPaused(channels[music3], TRUE);
+                                       OPENAL_SetPaused(channels[music3], true);
 
                                        stealthloading=0;*/
                                }
                                else if(mainmenu==1||mainmenu==2)mainmenu=0;
                                if(mainmenu&&musictoggle){
                                        if(mainmenu==1||mainmenu==2||mainmenu==100){
-                                               FSOUND_SetFrequency(FSOUND_ALL, 0.001);
-                                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                                               FSOUND_SetPaused(channels[stream_music3], FALSE);
-                                               FSOUND_SetVolume(channels[stream_music3], 256);
-                                               FSOUND_SetPaused(channels[music1], TRUE);
+                                               OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                               OPENAL_SetPaused(channels[stream_music3], false);
+                                               OPENAL_SetVolume(channels[stream_music3], 256);
+                                               OPENAL_SetPaused(channels[music1], true);
                                        }
                                }
                                if(!mainmenu){
-                                       FSOUND_SetPaused(channels[stream_music3], TRUE);
-                                       FSOUND_SetPaused(channels[music1], FALSE);
+                                       OPENAL_SetPaused(channels[stream_music3], true);
+                                       OPENAL_SetPaused(channels[music1], false);
                                }
                        }
                        if(mainmenu==3){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -1844,13 +1842,10 @@ void    Game::Tick()
 
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
-                               if(newscreenwidth>3000)newscreenwidth=screenwidth;
                                if(newscreenwidth<0)newscreenwidth=screenwidth;
-                               if(newscreenheight>3000)newscreenheight=screenheight;
                                if(newscreenheight<0)newscreenheight=screenheight;
 
-                               //ofstream opstream(":Data:config.txt"); 
-                               ofstream opstream("./Data/config.txt"); 
+                               ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
                                opstream << "Screenwidth:\n";
                                opstream << newscreenwidth;
                                opstream << "\nScreenheight:\n";
@@ -1925,23 +1920,23 @@ void    Game::Tick()
                                opstream << "\nChat key:\n";
                                opstream << KeyToChar(chatkey);
                                opstream.close();
-                       }       
-                       if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
+                       }
+                       if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
                                flashb=0;
                                flashamount=1;
                                flashdelay=1;
-                       }       
+                       }
                        if(mainmenu==3&&gameon)mainmenu=2;
                        if(mainmenu==3&&!gameon)mainmenu=1;
                        if(mainmenu==5&&gameon)mainmenu=2;
@@ -1951,9 +1946,7 @@ void      Game::Tick()
                        if(mainmenu==7)mainmenu=1;
                        if(mainmenu==9)mainmenu=5;
                        if(mainmenu==11)mainmenu=5;
-                       if(mainmenu==12)mainmenu=5;
                        if(mainmenu==13)mainmenu=12;
-                       if(mainmenu==14)mainmenu=13;
                        if(mainmenu==10)mainmenu=5;
                        if(mainmenu==100){
                                mainmenu=5;
@@ -1981,9 +1974,9 @@ void      Game::Tick()
        if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
                if(tutorialstage!=51)
                        tutorialstagetime=tutorialmaxtime;
-               PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
-               FSOUND_SetVolume(channels[consolefailsound], 128);
-               FSOUND_SetPaused(channels[consolefailsound], FALSE);
+               PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
+               OPENAL_SetVolume(channels[consolefailsound], 128);
+               OPENAL_SetPaused(channels[consolefailsound], false);
                minimaptogglekeydown=1;
        }
        if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
@@ -1997,12 +1990,12 @@ void    Game::Tick()
                                if(!gameon){
                                        float gLoc[3]={0,0,0};
                                        float vel[3]={0,0,0};
-                                       FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                       FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                       FSOUND_SetVolume(channels[firestartsound], 256);
-                                       FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                       FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                       OPENAL_SetVolume(channels[firestartsound], 256);
+                                       OPENAL_SetPaused(channels[firestartsound], false);
+                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                        flashr=1;
                                        flashg=0;
@@ -2025,26 +2018,26 @@ void    Game::Tick()
                                        }
                                        mainmenu=0;
                                        gameon=1;
-                                       FSOUND_SetPaused(channels[music3], TRUE);       */                      
+                                       OPENAL_SetPaused(channels[music3], true);       */
                                }
                                else
                                {
                                        //resume
                                        mainmenu=0;
-                                       FSOUND_SetPaused(channels[stream_music3], TRUE);
-                                       FSOUND_SetPaused(channels[music1], FALSE);
+                                       OPENAL_SetPaused(channels[stream_music3], true);
+                                       OPENAL_SetPaused(channels[music1], false);
                                }
                        }
 
                        if(Button()&&!oldbutton&&selected==2){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2054,25 +2047,25 @@ void    Game::Tick()
 
                                //options
 
-                               mainmenu=3;                     
+                               mainmenu=3;
 
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
                                if(newscreenwidth>3000)newscreenwidth=screenwidth;
                                if(newscreenwidth<0)newscreenwidth=screenwidth;
                                if(newscreenheight>3000)newscreenheight=screenheight;
-                               if(newscreenheight<0)newscreenheight=screenheight;      
+                               if(newscreenheight<0)newscreenheight=screenheight;
                        }
 
                        if(Button()&&!oldbutton&&selected==3){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2083,7 +2076,7 @@ void      Game::Tick()
                                if(!gameon){
                                        //quit
                                        tryquit=1;
-                                       if(registered)FSOUND_SetPaused(channels[stream_music3], TRUE);
+                                       OPENAL_SetPaused(channels[stream_music3], true);
                                }
                                else{
                                        //end game
@@ -2099,57 +2092,60 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected!=-1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
                        }
                        if(Button()&&!oldbutton&&selected==0){
-                               int whichres;
-                               whichres=-1;
-                               if(newscreenwidth==640&&newscreenheight==480)whichres=0;
-                               if(newscreenwidth==800&&newscreenheight==600)whichres=1;
-                               if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
-                               if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
-                               if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
-                               if(newscreenwidth==840&&newscreenheight==524)whichres=5;
-                               if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
-                               if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
-
-                               if(whichres==-1||whichres==7){
-                                       newscreenwidth=640;
-                                       newscreenheight=480;
-                               }
-                               if(whichres==0){
-                                       newscreenwidth=800;
-                                       newscreenheight=600;
-                               }
-                               if(whichres==1){
-                                       newscreenwidth=1024;
-                                       newscreenheight=768;
-                               }
-                               if(whichres==2){
-                                       newscreenwidth=1280;
-                                       newscreenheight=1024;
-                               }
-                               if(whichres==3){
-                                       newscreenwidth=1600;
-                                       newscreenheight=1200;
-                               }
-                               if(whichres==4){
-                                       newscreenwidth=840;
-                                       newscreenheight=524;
-                               }
-                               if(whichres==5){
-                                       newscreenwidth=1024;
-                                       newscreenheight=640;
+                       
+                               extern SDL_Rect **resolutions;
+                               bool isCustomResolution = true;
+                               bool found = false;
+                               for (int i = 0; (!found) && (resolutions[i]); i++)
+                               {
+                                       if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
+                                               isCustomResolution = false;
+
+                                       if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
+                                       {
+                                               i++;
+                                               if (resolutions[i] != NULL)
+                                               {
+                                                       newscreenwidth = (int) resolutions[i]->w;
+                                                       newscreenheight = (int) resolutions[i]->h;
+                                               }
+                                               else if (isCustomResolution)
+                                               {
+                                                       if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
+                                                       {
+                                                               newscreenwidth = (int) resolutions[0]->w;
+                                                               newscreenheight = (int) resolutions[0]->h;
+                                                       }
+                                                       else
+                                                       {
+                                                               newscreenwidth = screenwidth;
+                                                               newscreenheight = screenheight;
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       newscreenwidth = (int) resolutions[0]->w;
+                                                       newscreenheight = (int) resolutions[0]->h;
+                                               }
+                                               found = true;
+                                       }
                                }
-                               if(whichres==6){
-                                       newscreenwidth=1344;
-                                       newscreenheight=840;
+
+                               if (!found)
+                               {
+                                       newscreenwidth = (int) resolutions[0]->w;
+                                       newscreenheight = (int) resolutions[0]->h;
                                }
+
+                               
                        }
                        if(Button()&&!oldbutton&&selected==1){
                                newdetail++;
@@ -2173,9 +2169,9 @@ void      Game::Tick()
                                musictoggle=1-musictoggle;
 
                                if(!musictoggle){
-                                       FSOUND_SetPaused(channels[music1], TRUE);
-                                       FSOUND_SetPaused(channels[stream_music2], TRUE);
-                                       FSOUND_SetPaused(channels[stream_music3], TRUE);
+                                       OPENAL_SetPaused(channels[music1], true);
+                                       OPENAL_SetPaused(channels[stream_music2], true);
+                                       OPENAL_SetPaused(channels[stream_music3], true);
 
                                        for(i=0;i<4;i++){
                                                oldmusicvolume[i]=0;
@@ -2184,9 +2180,9 @@ void      Game::Tick()
                                }
 
                                if(musictoggle){
-                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                                       FSOUND_SetPaused(channels[stream_music3], FALSE);
-                                       FSOUND_SetVolume(channels[stream_music3], 256);                         
+                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                       OPENAL_SetPaused(channels[stream_music3], false);
+                                       OPENAL_SetVolume(channels[stream_music3], 256);
                                }
                        }
                        if(Button()&&!oldbutton&&selected==9){
@@ -2199,17 +2195,17 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==11){
                                volume+=.1f;
                                if(volume>1.0001f)volume=0;
-                               FSOUND_SetSFXMasterVolume((int)(volume*255));
+                               OPENAL_SetSFXMasterVolume((int)(volume*255));
                        }
                        if(Button()&&!oldbutton&&selected==7){
                                /*float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
                                */
                                flashr=1;
                                flashg=0;
@@ -2219,18 +2215,18 @@ void    Game::Tick()
 
                                //options
 
-                               mainmenu=4;             
+                               mainmenu=4;
                                keyselect=-1;
                        }
                        if(Button()&&!oldbutton&&selected==8){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2240,14 +2236,11 @@ void    Game::Tick()
 
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
-                               if(newscreenwidth>3000)newscreenwidth=screenwidth;
                                if(newscreenwidth<0)newscreenwidth=screenwidth;
-                               if(newscreenheight>3000)newscreenheight=screenheight;
                                if(newscreenheight<0)newscreenheight=screenheight;
 
 
-                               //ofstream opstream(":Data:config.txt"); 
-                               ofstream opstream("./Data/config.txt"); 
+                               ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
                                opstream << "Screenwidth:\n";
                                opstream << newscreenwidth;
                                opstream << "\nScreenheight:\n";
@@ -2333,12 +2326,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
                        }
                        if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
                                keyselect=selected;
@@ -2354,12 +2347,12 @@ void    Game::Tick()
                                                if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
                                                        float gLoc[3]={0,0,0};
                                                        float vel[3]={0,0,0};
-                                                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
-                                                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                                                       OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                       OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                       OPENAL_SetVolume(channels[fireendsound], 256);
+                                                       OPENAL_SetPaused(channels[fireendsound], false);
+                                                       OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                                        int keynum;
                                                        keynum=i;
@@ -2384,12 +2377,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==9){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2409,33 +2402,6 @@ void     Game::Tick()
                }
 
                if(mainmenu==5){
-                       if(accountcampaignchoicesmade[accountactive]>8&&!registered){
-                               FSOUND_SetFrequency(FSOUND_ALL, 0.001);         
-                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                               FSOUND_SetPaused(channels[stream_music3], FALSE);
-                               FSOUND_SetVolume(channels[stream_music3], 256);
-
-                               gameon=0;
-                               mainmenu=12;
-                               accountcampaignchoicesmade[accountactive]=0;
-                               accountcampaignscore[accountactive]=0;
-                               accountcampaigntime[accountactive]=0;
-
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-                       }
 
                        if(endgame==2){
                                accountcampaignchoicesmade[accountactive]=0;
@@ -2444,15 +2410,15 @@ void    Game::Tick()
                                endgame=0;
                        }
 
-                       if(Button()&&!oldbutton&&selected==1){                  
+                       if(Button()&&!oldbutton&&selected==1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2473,17 +2439,17 @@ void    Game::Tick()
 
                                mainmenu=0;
                                gameon=1;
-                               FSOUND_SetPaused(channels[stream_music3], TRUE);
+                               OPENAL_SetPaused(channels[stream_music3], true);
                        }
-                       if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){                       
+                       if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2523,17 +2489,17 @@ void    Game::Tick()
                                campaign=1;
                                mainmenu=0;
                                gameon=1;
-                               FSOUND_SetPaused(channels[stream_music3], TRUE);
+                               OPENAL_SetPaused(channels[stream_music3], true);
                        }
                        if(Button()&&!oldbutton&&selected==4){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2547,12 +2513,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==5){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2565,12 +2531,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==3){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2583,12 +2549,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==2){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2602,15 +2568,15 @@ void    Game::Tick()
                        else oldbutton=0;
                }
                if(mainmenu==9){
-                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){                   
+                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2632,17 +2598,17 @@ void    Game::Tick()
 
                                mainmenu=0;
                                gameon=1;
-                               FSOUND_SetPaused(channels[stream_music3], TRUE);
+                               OPENAL_SetPaused(channels[stream_music3], true);
                        }
                        if(Button()&&!oldbutton&&selected==numchallengelevels){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2656,15 +2622,15 @@ void    Game::Tick()
                        else oldbutton=0;
                }
                if(mainmenu==11){
-                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){                   
+                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2686,17 +2652,17 @@ void    Game::Tick()
 
                                mainmenu=0;
                                gameon=1;
-                               FSOUND_SetPaused(channels[stream_music3], TRUE);
+                               OPENAL_SetPaused(channels[stream_music3], true);
                        }
                        if(Button()&&!oldbutton&&selected==numchallengelevels){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2714,12 +2680,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==3){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2733,114 +2699,26 @@ void   Game::Tick()
                        else oldbutton=0;
                }
 
-               if(mainmenu==15||mainmenu==16){
-                       if(Button()&&!oldbutton&&selected==1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               if(mainmenu==15)mainmenu=5;
-                               else mainmenu=12;
-                       }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
-               }
-
-               if(mainmenu==12){
-                       endgame=2;
-                       if(Button()&&!oldbutton&&selected==3){
-                               if(tryquit)quit=1;
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               mainmenu=5;
-                       }
-
-                       if(Button()&&!oldbutton&&selected==4){
-                               registernow=1;
-                               quit=1;
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-                       }
-
-
-                       if(Button()&&!oldbutton&&selected==5){
-                               tryquit=0;
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               mainmenu=13;
-                       }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
-               }
                if(mainmenu==6){
                        if(Button()&&!oldbutton&&selected!=-1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
                        }
                        if(Button()&&!oldbutton&&selected==1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2881,12 +2759,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==2){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2903,12 +2781,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected!=-1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
                        }
                        if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
                                entername=1;
@@ -2925,12 +2803,12 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected==numaccounts+1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[fireendsound], 256);
-                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[fireendsound], 256);
+                               OPENAL_SetPaused(channels[fireendsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                flashr=1;
                                flashg=0;
@@ -2954,18 +2832,18 @@ void    Game::Tick()
                        if(Button()&&!oldbutton&&selected!=-1){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               FSOUND_SetVolume(channels[firestartsound], 256);
-                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                               OPENAL_SetVolume(channels[firestartsound], 256);
+                               OPENAL_SetPaused(channels[firestartsound], false);
+                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                if(selected==0)accountdifficulty[accountactive]=0;
                                if(selected==1)accountdifficulty[accountactive]=1;
                                if(selected==2)accountdifficulty[accountactive]=2;
 
-                               mainmenu=5;     
+                               mainmenu=5;
 
                                flashr=1;
                                flashg=0;
@@ -2987,13 +2865,10 @@ void    Game::Tick()
                        if(mainmenu==3){
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
-                               if(newscreenwidth>3000)newscreenwidth=screenwidth;
                                if(newscreenwidth<0)newscreenwidth=screenwidth;
-                               if(newscreenheight>3000)newscreenheight=screenheight;
                                if(newscreenheight<0)newscreenheight=screenheight;
 
-                               //ofstream opstream(":Data:config.txt"); 
-                               ofstream opstream("./Data/config.txt"); 
+                               ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
                                opstream << "Screenwidth:\n";
                                opstream << newscreenwidth;
                                opstream << "\nScreenheight:\n";
@@ -3080,9 +2955,9 @@ void      Game::Tick()
                                loaddistrib=0;
                        }
                }
-               FSOUND_SetFrequency(channels[stream_music3], 22050);            
+               OPENAL_SetFrequency(channels[stream_music3], 22050);
 
-               if(entername||mainmenu==13||mainmenu==14){
+               if(entername){
                        for(i=0;i<140;i++){
                                if(IsKeyDown(theKeyMap, i)){
                                        togglekeydelay[i]+=multiplier;
@@ -3152,12 +3027,12 @@ void    Game::Tick()
 
                                                                float gLoc[3]={0,0,0};
                                                                float vel[3]={0,0,0};
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[firestartsound], 256);
-                                                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[firestartsound], 256);
+                                                               OPENAL_SetPaused(channels[firestartsound], false);
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                                                for(j=0;j<255;j++){
                                                                        displaytext[0][j]=' ';
@@ -3168,108 +3043,13 @@ void   Game::Tick()
                                                                displayselected=0;
                                                        }}
 
-                                               if(i==MAC_RETURN_KEY&&mainmenu==14){
-                                                       if(displaychars[0]){
-                                                               char serialstring[256];
-                                                               char tempstring[256];
-                                                               sprintf (tempstring, "%s-windows", registrationname);
-                                                               long num1;
-                                                               long num2;
-                                                               long num3;
-                                                               long num4;
-                                                               long long longnum;
-                                                               longnum = MD5_string ( tempstring);
-                                                               //longnum = 1111111111111111;
-                                                               num1 = longnum/100000000;
-                                                               num2 = longnum%100000000;
-                                                               sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
-
-                                                               int goodcode=3;
-                                                               int numchars=3;
-                                                               if(num1/10000>999)numchars+=4;
-                                                               else if(num1/10000>99)numchars+=3;
-                                                               else if(num1/10000>9)numchars+=2;
-                                                               else numchars+=1;
-                                                               if(num1%10000>999)numchars+=4;
-                                                               else if(num1%10000>99)numchars+=3;
-                                                               else if(num1%10000>9)numchars+=2;
-                                                               else numchars+=1;
-                                                               if(num2/10000>999)numchars+=4;
-                                                               else if(num2/10000>99)numchars+=3;
-                                                               else if(num2/10000>9)numchars+=2;
-                                                               else numchars+=1;
-                                                               if(num2%10000>999)numchars+=4;
-                                                               else if(num2%10000>99)numchars+=3;
-                                                               else if(num2%10000>9)numchars+=2;
-                                                               else numchars+=1;
-
-                                                               //numchars=12;
-
-                                                               for(j=0;j<numchars;j++){
-                                                                       if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
-                                                               }
-
-                                                               if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
-
-                                                               if(goodcode<0)goodcode=0;
-
-                                                               if(goodcode){
-                                                                       registered=1;
-                                                                       mainmenu=15;
-
-                                                                       FILE                    *tfile;
-                                                                       tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
-                                                                       if (tfile)
-                                                                       {
-                                                                               int numchars;
-                                                                               numchars=strlen(registrationname);
-                                                                               fpackf(tfile, "Bb", registered);
-                                                                               fpackf(tfile, "Bi", numchars);
-                                                                               if(numchars>0)
-                                                                               {
-                                                                                       for(j=0;j<numchars;j++)
-                                                                                       {
-                                                                                               fpackf(tfile, "Bb",  registrationname[j]);
-                                                                                       }
-                                                                               }
-                                                                               fpackf(tfile, "Bi", num1);
-                                                                               fpackf(tfile, "Bi", num2);
-                                                                               fclose(tfile);
-                                                                       }
-                                                               }
-                                                               else
-                                                               {
-                                                                       mainmenu=16;
-                                                               }
-                                                               flashr=1;
-                                                               flashg=0;
-                                                               flashb=0;
-                                                               flashamount=1;
-                                                               flashdelay=1;
-
-                                                               float gLoc[3]={0,0,0};
-                                                               float vel[3]={0,0,0};
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[firestartsound], 256);
-                                                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
-
-                                                               for(j=0;j<255;j++){
-                                                                       displaytext[0][j]=' ';
-                                                               }
-                                                               displaychars[0]=0;
-                                                               displayselected=0;
-                                                       }}
-
                                                if(i==MAC_RETURN_KEY&&mainmenu==13){
                                                        if(displaychars[0]){
                                                                sprintf (registrationname, "%s", displaytext[0]);
                                                                if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
 
-                                                               mainmenu=14;
-
+                                                               mainmenu=5;
+                        
                                                                flashr=1;
                                                                flashg=0;
                                                                flashb=0;
@@ -3278,32 +3058,18 @@ void    Game::Tick()
 
                                                                float gLoc[3]={0,0,0};
                                                                float vel[3]={0,0,0};
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[firestartsound], 256);
-                                                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[firestartsound], 256);
+                                                               OPENAL_SetPaused(channels[firestartsound], false);
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                                                for(j=0;j<255;j++){
                                                                        displaytext[0][j]=' ';
                                                                }
                                                                displaychars[0]=0;
-
-                                                               /*char tempstring[50];
-                                                               sprintf (tempstring, registrationname);
-                                                               long num1;
-                                                               long num2;
-                                                               long num3;
-                                                               long num4;
-                                                               long long longnum;
-                                                               longnum = MD5_string ( tempstring);
-                                                               num1 = longnum/100000000;
-                                                               num2 = longnum%100000000;
-                                                               sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
-
-                                                               displaychars[0]=strlen(displaytext[0]);
-                                                               */
+                        
                                                                displayselected=0;
                                                        }}
                                        }
@@ -3323,7 +3089,7 @@ void      Game::Tick()
                }
        }
 
-       if(!mainmenu){  
+       if(!mainmenu){
                if(hostile==1)hostiletime+=multiplier;
                else hostiletime=0;
                if(!winfreeze)leveltime+=multiplier;
@@ -3415,7 +3181,7 @@ void      Game::Tick()
                if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
                        freeze=1-freeze;
                        if(freeze){
-                               FSOUND_SetFrequency(FSOUND_ALL, 0.001);
+                               OPENAL_SetFrequency(OPENAL_ALL, 0.001);
                        }
                        freezetogglekeydown=1;
                }
@@ -3428,7 +3194,7 @@ void      Game::Tick()
                        console=1-console;
                        if(!console)freeze=0;
                        if(console){
-                               FSOUND_SetFrequency(FSOUND_ALL, 0.001);
+                               OPENAL_SetFrequency(OPENAL_ALL, 0.001);
                        }
                        consoletogglekeydown=1;
                }
@@ -3499,9 +3265,9 @@ void      Game::Tick()
                                                        archiveselected=0;
                                                        donesomething=0;
                                                        if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
-                                                               PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                               FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                               FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                               PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                               OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                               OPENAL_SetPaused(channels[consolesuccesssound], false);
                                                                donesomething=1;
                                                                tryquit=1;
                                                        }
@@ -3585,12 +3351,12 @@ void    Game::Tick()
                                                        consoleselected=0;
                                                        }
                                                        }
-                                                       else 
+                                                       else
                                                        {
                                                        donesomething=1;
-                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                       OPENAL_SetPaused(channels[consolesuccesssound], false);
 
                                                        if(consolechars[0]>0){
                                                        for(k=14;k>=1;k--){
@@ -3647,9 +3413,9 @@ void      Game::Tick()
                                                        else
                                                        {
                                                        donesomething=1;
-                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                       OPENAL_SetPaused(channels[consolesuccesssound], false);
 
                                                        if(consolechars[0]>0){
                                                        for(k=14;k>=1;k--){
@@ -3686,9 +3452,9 @@ void      Game::Tick()
                                                                }
                                                                mapname[consolechars[0]-5+11]='\0';
 
-                                                               PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                               FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                               FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                               PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                               OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                               OPENAL_SetPaused(channels[consolesuccesssound], false);
 
                                                                int mapvers;
                                                                mapvers=12;
@@ -3746,7 +3512,7 @@ void      Game::Tick()
                                                                                                        fpackf(tfile, "Bi",templength);
                                                                                                        for(m=0;m<templength;m++){
                                                                                                                fpackf(tfile, "Bb", dialoguename[k][l][m]);
-                                                                                                               if(dialoguename[k][l][m]=='\0')break;   
+                                                                                                               if(dialoguename[k][l][m]=='\0')break;
                                                                                                        }
 
                                                                                                        fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
@@ -3766,7 +3532,7 @@ void      Game::Tick()
                                                                                                fpackf(tfile, "Bi", templength);
                                                                                                for(l=0;l<templength;l++)
                                                                                                        fpackf(tfile, "Bb", player[0].clothes[k][l]);
-                                                                                               fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);                                                                                                                                             
+                                                                                               fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
                                                                                        }
 
                                                                                        fpackf(tfile, "Bi", environment);
@@ -3843,7 +3609,7 @@ void      Game::Tick()
                                                                                                                                                fpackf(tfile, "Bi", templength);
                                                                                                                                                for(l=0;l<templength;l++)
                                                                                                                                                        fpackf(tfile, "Bb", player[j].clothes[k][l]);
-                                                                                                                                               fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);                                                                                                                             
+                                                                                                                                               fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
                                                                                                                                        }
                                                                                                                }
 
@@ -3894,12 +3660,12 @@ void    Game::Tick()
                                                                                                                        for(k=0;k<player[0].numclothes;k++){
                                                                                                                        int templength;
                                                                                                                        templength=strlen(player[0].clothes[k]);
-                                                                                                                       fwrite( &templength,1,sizeof(int),tfile);       
+                                                                                                                       fwrite( &templength,1,sizeof(int),tfile);
                                                                                                                        for(l=0;l<templength;l++)
                                                                                                                        fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
-                                                                                                                       fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);      
-                                                                                                                       fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);      
-                                                                                                                       fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);                                                                              
+                                                                                                                       fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
+                                                                                                                       fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
+                                                                                                                       fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
                                                                                                                        }
 
                                                                                                                        fwrite( &environment, 1, sizeof(int), tfile );
@@ -3963,12 +3729,12 @@ void    Game::Tick()
                                                                                                                        for(k=0;k<player[j].numclothes;k++){
                                                                                                                        int templength;
                                                                                                                        templength=strlen(player[j].clothes[k]);
-                                                                                                                       fwrite( &templength,1,sizeof(int),tfile);       
+                                                                                                                       fwrite( &templength,1,sizeof(int),tfile);
                                                                                                                        for(l=0;l<templength;l++)
                                                                                                                        fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
-                                                                                                                       fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);      
-                                                                                                                       fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);      
-                                                                                                                       fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);                                                                              
+                                                                                                                       fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
+                                                                                                                       fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
+                                                                                                                       fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
                                                                                                                        }
                                                                                                                        }
                                                                                                                        fwrite( &numpathpoints, 1, sizeof(int), tfile );
@@ -4010,9 +3776,9 @@ void      Game::Tick()
                                                        }
                                                        mapname[consolechars[0]-5+11]='\0';
 
-                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                       OPENAL_SetPaused(channels[consolesuccesssound], false);
 
                                                        FILE                    *tfile;
                                                        tfile=fopen( mapname, "wb" );
@@ -4068,11 +3834,11 @@ void    Game::Tick()
                                                        donesomething=1;
                                                        }*/
                                                        if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
-                                                               LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Furdarko.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }
                                                        /*if(Compare(consoletext[0],"Pants ",0,5)){
-                                                       AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+                                                       AddClothes(ConvertFileName(":Data:Textures:Pants.png"),0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                                        player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
                                                        donesomething=1;
                                                        }*/
@@ -4518,7 +4284,7 @@ void      Game::Tick()
                                                                        }
                                                                }
 
-                                                               ifstream ipstream(mapname);
+                                                               ifstream ipstream(ConvertFileName(mapname));
                                                                ipstream.ignore(256,':');
                                                                ipstream >> numdialogueboxes[numdialogues];
                                                                for(i=0;i<numdialogueboxes[numdialogues];i++){
@@ -4611,7 +4377,7 @@ void      Game::Tick()
                                                                        }
                                                                }
 
-                                                               ifstream ipstream(mapname);
+                                                               ifstream ipstream(ConvertFileName(mapname));
                                                                ipstream.ignore(256,':');
                                                                ipstream >> numdialogueboxes[whichdi];
                                                                for(i=0;i<numdialogueboxes[whichdi];i++){
@@ -4753,10 +4519,10 @@ void    Game::Tick()
                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
-                                                                       PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[whichsoundplay], 256);
-                                                                       FSOUND_SetPaused(channels[whichsoundplay], FALSE);
+                                                                       PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[whichsoundplay], 256);
+                                                                       OPENAL_SetPaused(channels[whichsoundplay], false);
                                                                        //}
                                                                }
                                                        }
@@ -4877,34 +4643,34 @@ void    Game::Tick()
 
                                                                player[0].numclothes=0;
                                                                if(player[0].whichskin==0){
-                                                                       LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur3.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==1){
-                                                                       LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==2){
-                                                                       LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur2.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==3){
-                                                                       LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Lynx.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==4){
-                                                                       LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Otter.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==5){
-                                                                       LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Opal.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==6){
-                                                                       LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Sable.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==7){
-                                                                       LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Chocolate.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==8){
-                                                                       LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:BW2.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
                                                                else if(player[0].whichskin==9){
-                                                                       LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:WB2.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                }
 
                                                                editoractive=typeactive;
@@ -5005,7 +4771,7 @@ void      Game::Tick()
                                                                else terrain.DoLighting();
                                                                */
                                                                donesomething=1;
-                                                       } 
+                                                       }
 
                                                        if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
                                                                int startpoint;
@@ -5053,7 +4819,7 @@ void      Game::Tick()
                                                                else terrain.DoLighting();
                                                                */
                                                                donesomething=1;
-                                                       } 
+                                                       }
 
                                                        if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
                                                                skyboxtexture=1-skyboxtexture;
@@ -5320,34 +5086,34 @@ void    Game::Tick()
                                                                        }
                                                                        player[closest].numclothes=0;
                                                                        if(player[closest].whichskin==0){
-                                                                               LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Fur3.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==1){
-                                                                               LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Fur.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==2){
-                                                                               LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Fur2.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==3){
-                                                                               LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Lynx.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==4){
-                                                                               LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Otter.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==5){
-                                                                               LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Opal.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==6){
-                                                                               LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Sable.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==7){
-                                                                               LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Chocolate.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==8){
-                                                                               LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:BW2.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
                                                                        else if(player[closest].whichskin==9){
-                                                                               LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                               LoadTextureSave(ConvertFileName(":Data:Textures:WB2.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
 
                                                                        donesomething=1;
@@ -5358,34 +5124,34 @@ void    Game::Tick()
 
                                                                player[closest].numclothes=0;
                                                                if(player[closest].whichskin==0){
-                                                                       LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur3.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==1){
-                                                                       LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==2){
-                                                                       LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Fur2.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==3){
-                                                                       LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Lynx.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==4){
-                                                                       LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Otter.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==5){
-                                                                       LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Opal.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==6){
-                                                                       LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Sable.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==7){
-                                                                       LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Chocolate.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==8){
-                                                                       LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:BW2.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
                                                                else if(player[closest].whichskin==9){
-                                                                       LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+                                                                       LoadTextureSave(ConvertFileName(":Data:Textures:WB2.jpg"),&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                }
 
                                                                donesomething=1;
@@ -5416,7 +5182,7 @@ void      Game::Tick()
                                                                mapname[consolechars[0]-8+18]='g';
                                                                mapname[consolechars[0]-8+19]='\0';
 
-                                                               //:Data:Textures:Pants.png
+                                                               //ConvertFileName(:Data:Textures:Pants.png)
 
                                                                if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
                                                                        player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
@@ -5512,8 +5278,8 @@ void      Game::Tick()
 
                                                        if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
                                                                player[0].skeleton.id=0;
-                                                               player[0].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
-                                                               LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               player[0].skeleton.Load((char *)ConvertFileName(":Data:Skeleton:Basic Figure"),(char *)ConvertFileName(":Data:Skeleton:Basic Figurelow"),(char *)ConvertFileName(":Data:Skeleton:Rabbitbelt"),(char *)ConvertFileName(":Data:Models:Body.solid"),(char *)ConvertFileName(":Data:Models:Body2.solid"),(char *)ConvertFileName(":Data:Models:Body3.solid"),(char *)ConvertFileName(":Data:Models:Body4.solid"),(char *)ConvertFileName(":Data:Models:Body5.solid"),(char *)ConvertFileName(":Data:Models:Body6.solid"),(char *)ConvertFileName(":Data:Models:Body7.solid"),(char *)ConvertFileName(":Data:Models:Bodylow.solid"),(char *)ConvertFileName(":Data:Models:Belt.solid"),1);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:fur3.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                player[0].creature=rabbittype;
                                                                player[0].scale=.2;
 
@@ -5530,8 +5296,8 @@ void      Game::Tick()
                                                        }
                                                        if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
                                                                player[0].skeleton.id=0;
-                                                               player[0].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
-                                                               LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               player[0].skeleton.Load((char *)ConvertFileName(":Data:Skeleton:Basic Figure Wolf"),(char *)ConvertFileName(":Data:Skeleton:Basic Figure Wolf Low"),(char *)ConvertFileName(":Data:Skeleton:Rabbitbelt"),(char *)ConvertFileName(":Data:Models:Wolf.solid"),(char *)ConvertFileName(":Data:Models:Wolf2.solid"),(char *)ConvertFileName(":Data:Models:Wolf3.solid"),(char *)ConvertFileName(":Data:Models:Wolf4.solid"),(char *)ConvertFileName(":Data:Models:Wolf5.solid"),(char *)ConvertFileName(":Data:Models:Wolf6.solid"),(char *)ConvertFileName(":Data:Models:Wolf7.solid"),(char *)ConvertFileName(":Data:Models:Wolflow.solid"),(char *)ConvertFileName(":Data:Models:Belt.solid"),0);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Wolf.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                player[0].creature=wolftype;
 
                                                                player[0].proportionhead=1.1;
@@ -5546,43 +5312,43 @@ void    Game::Tick()
                                                                donesomething=1;
                                                        }
                                                        /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
-                                                       LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Kungfu.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                        donesomething=1;
                                                        }
                                                        if(Compare(consoletext[0],"rambo ",0,5)){
-                                                       LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                       LoadTextureSave(ConvertFileName(":Data:Textures:Leather.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                        donesomething=1;
                                                        }
                                                        if(Compare(consoletext[0],"david ",0,5)){
-                                                       LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                       LoadTextureSave(ConvertFileName(":Data:Textures:David.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                        donesomething=1;
                                                        }*/
                                                        if(Compare(consoletext[0],"wolf ",0,4)){
-                                                               LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Wolf.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }
                                                        if(Compare(consoletext[0],"darkwolf ",0,8)){
-                                                               LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:DarkWolf.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }
                                                        if(Compare(consoletext[0],"snowwolf ",0,8)){
-                                                               LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:Snowwolf.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }/*
                                                         if(Compare(consoletext[0],"lizardwolf ",0,10)){
-                                                        LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                        LoadTextureSave(ConvertFileName(":Data:Textures:Lizardwolf.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                         donesomething=1;
                                                         }*/
                                                        if(Compare(consoletext[0],"white ",0,5)){
-                                                               LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:fur.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }
                                                        if(Compare(consoletext[0],"brown ",0,5)){
-                                                               LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:fur3.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }
                                                        if(Compare(consoletext[0],"black ",0,5)){
-                                                               LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+                                                               LoadTextureSave(ConvertFileName(":Data:Textures:fur2.jpg"),&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
                                                                donesomething=1;
                                                        }
                                                        if(consolechars[0]>0){
@@ -5599,9 +5365,9 @@ void      Game::Tick()
                                                                consoleselected=0;
 
                                                                if(!donesomething){
-                                                                       PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
-                                                                       FSOUND_SetVolume(channels[consolefailsound], 256);
-                                                                       FSOUND_SetPaused(channels[consolefailsound], FALSE);
+                                                                       PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
+                                                                       OPENAL_SetVolume(channels[consolefailsound], 256);
+                                                                       OPENAL_SetPaused(channels[consolefailsound], false);
                                                                }
                                                        }
                                                }
@@ -5626,13 +5392,10 @@ void    Game::Tick()
                        if(mainmenu==3){
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
-                               if(newscreenwidth>3000)newscreenwidth=screenwidth;
                                if(newscreenwidth<0)newscreenwidth=screenwidth;
-                               if(newscreenheight>3000)newscreenheight=screenheight;
                                if(newscreenheight<0)newscreenheight=screenheight;
 
-                               //ofstream opstream(":Data:config.txt"); 
-                               ofstream opstream("./Data/config.txt"); 
+                               ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
                                opstream << "Screenwidth:\n";
                                opstream << newscreenwidth;
                                opstream << "\nScreenheight:\n";
@@ -5712,10 +5475,10 @@ void    Game::Tick()
 
                static int oldwinfreeze;
                if(winfreeze&&!oldwinfreeze){
-                       FSOUND_SetFrequency(FSOUND_ALL, 0.001);
-                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                       OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                       OPENAL_SetPaused(channels[consolesuccesssound], false);
                }
                if(winfreeze==0)oldwinfreeze=winfreeze;
                else oldwinfreeze++;
@@ -5748,23 +5511,23 @@ void    Game::Tick()
                                                int realdialoguetype;
                                                bool special;
                                                if(dialoguetype[i]>49){
-                                                       realdialoguetype=dialoguetype[i]-50; 
+                                                       realdialoguetype=dialoguetype[i]-50;
                                                        special=1;
                                                }
                                                else if(dialoguetype[i]>39){
-                                                       realdialoguetype=dialoguetype[i]-40; 
+                                                       realdialoguetype=dialoguetype[i]-40;
                                                        special=1;
                                                }
                                                else if(dialoguetype[i]>29){
-                                                       realdialoguetype=dialoguetype[i]-30; 
+                                                       realdialoguetype=dialoguetype[i]-30;
                                                        special=1;
                                                }
                                                else if(dialoguetype[i]>19){
-                                                       realdialoguetype=dialoguetype[i]-20; 
+                                                       realdialoguetype=dialoguetype[i]-20;
                                                        special=1;
                                                }
                                                else if(dialoguetype[i]>9){
-                                                       realdialoguetype=dialoguetype[i]-10; 
+                                                       realdialoguetype=dialoguetype[i]-10;
                                                        special=1;
                                                }
                                                else {
@@ -5821,10 +5584,10 @@ void    Game::Tick()
                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
-                                                                       PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[whichsoundplay], 256);
-                                                                       FSOUND_SetPaused(channels[whichsoundplay], FALSE);
+                                                                       PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[whichsoundplay], 256);
+                                                                       OPENAL_SetPaused(channels[whichsoundplay], false);
                                                                }
                                                                if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
                                                        }
@@ -5852,7 +5615,7 @@ void      Game::Tick()
                                                                hotspotsprite+=hotspot[i];
                                                                sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
                                                                hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
-                                                       }                               
+                                                       }
                                                }
 
                                                for(i=0;i<numhotspots;i++){
@@ -5932,10 +5695,10 @@ void    Game::Tick()
                                                        vel[0]=0;
                                                        vel[1]=0;
                                                        vel[2]=0;
-                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
+                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                       OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                       OPENAL_SetVolume(channels[fireendsound], 256);
+                                                       OPENAL_SetPaused(channels[fireendsound], false);
 
                                                        for(i=0;i<player[1].skeleton.num_joints;i++){
                                                                if(Random()%2==0){
@@ -6159,10 +5922,10 @@ void    Game::Tick()
                                                        weapons.owner[1]=0;
                                                        player[0].weaponactive=0;
                                                        player[0].num_weapons=1;
-                                                       player[0].weaponids[0]=1;       
+                                                       player[0].weaponids[0]=1;
                                                        player[1].weaponactive=0;
                                                        player[1].num_weapons=1;
-                                                       player[1].weaponids[0]=0;       
+                                                       player[1].weaponids[0]=0;
 
                                                        weapons.numweapons++;
                                                }
@@ -6177,7 +5940,7 @@ void      Game::Tick()
                                                        weapons.owner[1]=0;
                                                        player[0].weaponactive=0;
                                                        player[0].num_weapons=1;
-                                                       player[0].weaponids[0]=1;       
+                                                       player[0].weaponids[0]=1;
                                                        player[1].weaponactive=0;
                                                        player[1].num_weapons=1;
                                                        player[1].weaponids[0]=0;
@@ -6203,7 +5966,7 @@ void      Game::Tick()
                                                        player[1].num_weapons=0;
                                                        player[0].weaponactive=0;
                                                        player[0].num_weapons=1;
-                                                       player[0].weaponids[0]=0;       
+                                                       player[0].weaponids[0]=0;
 
                                                        weapons.type[0]=knife;
 
@@ -6221,10 +5984,10 @@ void    Game::Tick()
                                                        vel[0]=0;
                                                        vel[1]=0;
                                                        vel[2]=0;
-                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
+                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                       OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                       OPENAL_SetVolume(channels[fireendsound], 256);
+                                                       OPENAL_SetPaused(channels[fireendsound], false);
 
                                                        for(i=0;i<player[1].skeleton.num_joints;i++){
                                                                if(Random()%2==0){
@@ -6369,9 +6132,9 @@ void      Game::Tick()
 
 
                                                if(tutorialstagetime==tutorialmaxtime-3){
-                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                       OPENAL_SetPaused(channels[consolesuccesssound], false);
                                                }
 
                                                if(tutorialsuccess>=1){
@@ -6389,16 +6152,16 @@ void    Game::Tick()
 
                                        if(tutoriallevel!=1){
                                                if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
-                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
-                                                       FSOUND_SetVolume(channels[consolesuccesssound], 256);
-                                                       FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
+                                                       PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
+                                                       OPENAL_SetVolume(channels[consolesuccesssound], 256);
+                                                       OPENAL_SetPaused(channels[consolesuccesssound], false);
                                                }
                                        }
                                        else
                                                if(bonustime==0){
-                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
+                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                       OPENAL_SetVolume(channels[fireendsound], 256);
+                                                       OPENAL_SetPaused(channels[fireendsound], false);
                                                }
                                                if(bonustime==0){
                                                        if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
@@ -6512,11 +6275,11 @@ void    Game::Tick()
                                                                                                                        vel[0]=0;
                                                                                                                        vel[1]=0;
                                                                                                                        vel[2]=0;
-                                                                                                                       PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
-                                                                                                                       FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
-                                                                                                                       FSOUND_SetVolume(channels[movewhooshsound], 256);
-                                                                                                                       FSOUND_SetPaused(channels[movewhooshsound], FALSE);
-                                                                                                                       if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                                                                                       PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
+                                                                                                                       OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
+                                                                                                                       OPENAL_SetVolume(channels[movewhooshsound], 256);
+                                                                                                                       OPENAL_SetPaused(channels[movewhooshsound], false);
+                                                                                                                       if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
 
                                                                                                                        lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
                                                                                                                        player[k].rotation=-asin(0-lowpointtarget.x);
@@ -6543,11 +6306,11 @@ void    Game::Tick()
                                                                                                                                vel[0]=0;
                                                                                                                                vel[1]=0;
                                                                                                                                vel[2]=0;
-                                                                                                                               PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
-                                                                                                                               FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
-                                                                                                                               FSOUND_SetVolume(channels[movewhooshsound], 256);
-                                                                                                                               FSOUND_SetPaused(channels[movewhooshsound], FALSE);
-                                                                                                                               if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                                                                                               PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
+                                                                                                                               OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
+                                                                                                                               OPENAL_SetVolume(channels[movewhooshsound], 256);
+                                                                                                                               OPENAL_SetPaused(channels[movewhooshsound], false);
+                                                                                                                               if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
 
                                                                                                                                lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
                                                                                                                                player[k].rotation=-asin(0-lowpointtarget.x);
@@ -6574,11 +6337,11 @@ void    Game::Tick()
                                                                                                                                        vel[0]=0;
                                                                                                                                        vel[1]=0;
                                                                                                                                        vel[2]=0;
-                                                                                                                                       PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
-                                                                                                                                       FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
-                                                                                                                                       FSOUND_SetVolume(channels[movewhooshsound], 256);
-                                                                                                                                       FSOUND_SetPaused(channels[movewhooshsound], FALSE);
-                                                                                                                                       if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                                                                                                       PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
+                                                                                                                                       OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
+                                                                                                                                       OPENAL_SetVolume(channels[movewhooshsound], 256);
+                                                                                                                                       OPENAL_SetPaused(channels[movewhooshsound], false);
+                                                                                                                                       if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
 
                                                                                                                                        lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
                                                                                                                                        player[k].rotation=-asin(0-lowpointtarget.x);
@@ -6605,11 +6368,11 @@ void    Game::Tick()
                                                                                                                                                vel[0]=0;
                                                                                                                                                vel[1]=0;
                                                                                                                                                vel[2]=0;
-                                                                                                                                               PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
-                                                                                                                                               FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
-                                                                                                                                               FSOUND_SetVolume(channels[movewhooshsound], 256);
-                                                                                                                                               FSOUND_SetPaused(channels[movewhooshsound], FALSE);
-                                                                                                                                               if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                                                                                                               PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
+                                                                                                                                               OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
+                                                                                                                                               OPENAL_SetVolume(channels[movewhooshsound], 256);
+                                                                                                                                               OPENAL_SetPaused(channels[movewhooshsound], false);
+                                                                                                                                               if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
 
                                                                                                                                                lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
                                                                                                                                                player[k].rotation=-asin(0-lowpointtarget.x);
@@ -6640,12 +6403,12 @@ void    Game::Tick()
 
                                                                                                                if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
                                                                                                                player[k].target=0;
-                                                                                                               player[k].targetframe=0;        
+                                                                                                               player[k].targetframe=0;
                                                                                                                player[k].onterrain=1;
 
                                                                                                                if(player[k].id==0){
-                                                                                                                       FSOUND_SetPaused(channels[whooshsound], TRUE);
-                                                                                                                       FSOUND_SetVolume(channels[whooshsound], 0);
+                                                                                                                       OPENAL_SetPaused(channels[whooshsound], true);
+                                                                                                                       OPENAL_SetVolume(channels[whooshsound], 0);
                                                                                                                }
 
                                                                                                                if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
@@ -6659,10 +6422,10 @@ void    Game::Tick()
                                                                                                                        vel[0]=player[k].velocity.x;
                                                                                                                        vel[1]=player[k].velocity.y;
                                                                                                                        vel[2]=player[k].velocity.z;
-                                                                                                                       PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
-                                                                                                                       FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
-                                                                                                                       FSOUND_SetVolume(channels[landsound], 128);
-                                                                                                                       FSOUND_SetPaused(channels[landsound], FALSE);
+                                                                                                                       PlaySoundEx( landsound, samp[landsound], NULL, true);
+                                                                                                                       OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
+                                                                                                                       OPENAL_SetVolume(channels[landsound], 128);
+                                                                                                                       OPENAL_SetPaused(channels[landsound], false);
                                                                                                                        if(k==0){
                                                                                                                                envsound[numenvsounds]=player[k].coords;
                                                                                                                                envsoundvol[numenvsounds]=16;
@@ -6672,7 +6435,7 @@ void      Game::Tick()
 
                                                                                                                }
                                                                                                        }
-                                                                                               }                               
+                                                                                               }
                                                                                        }
                                                                                }
                                                                                if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
@@ -6682,10 +6445,10 @@ void    Game::Tick()
                                                                                                lowpoint.y+=1.35;
                                                                                                if(objects.type[i]!=rocktype)
                                                                                                        if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
-                                                                                                               if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;               
+                                                                                                               if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
                                                                                                                player[k].coords=lowpoint;
                                                                                                                player[k].coords.y-=1.35;
-                                                                                                               player[k].collide=1;    
+                                                                                                               player[k].collide=1;
 
                                                                                                                if((player[k].grabdelay<=0||player[k].aitype!=playercontrolled)&&((/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)&&*/player[k].currentanimation!=climbanim&&player[k].currentanimation!=hanganim&&!player[k].isWallJump())||player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
                                                                                                                        lowpoint=player[k].coords;
@@ -6758,9 +6521,9 @@ void      Game::Tick()
                                                                                                                                                                                                        player[k].coords.y=lowpointtarget.y-.07;
                                                                                                                                                                                                        player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
 
-                                                                                                                                                                                                       if(j>10||!player[k].isRun()){                                                                                                   
+                                                                                                                                                                                                       if(j>10||!player[k].isRun()){
                                                                                                                                                                                                                if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
-                                                                                                                                                                                                                       if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                                                                                                                                                                                       if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
                                                                                                                                                                                                                }
                                                                                                                                                                                                                float gLoc[3];
                                                                                                                                                                                                                float vel[3];
@@ -6770,10 +6533,10 @@ void    Game::Tick()
                                                                                                                                                                                                                vel[0]=player[k].velocity.x;
                                                                                                                                                                                                                vel[1]=player[k].velocity.y;
                                                                                                                                                                                                                vel[2]=player[k].velocity.z;
-                                                                                                                                                                                                               PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
-                                                                                                                                                                                                               FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
-                                                                                                                                                                                                               FSOUND_SetVolume(channels[jumpsound], 128);
-                                                                                                                                                                                                               FSOUND_SetPaused(channels[jumpsound], FALSE);
+                                                                                                                                                                                                               PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
+                                                                                                                                                                                                               OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
+                                                                                                                                                                                                               OPENAL_SetVolume(channels[jumpsound], 128);
+                                                                                                                                                                                                               OPENAL_SetPaused(channels[jumpsound], false);
 
                                                                                                                                                                                                                lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
                                                                                                                                                                                                                player[k].rotation=-asin(0-lowpointtarget.x);
@@ -6802,7 +6565,7 @@ void      Game::Tick()
                                                                                                                                                                                                                        //player[k].currentanimation=hanganim;
                                                                                                                                                                                                                        player[k].targetanimation=hanganim;
                                                                                                                                                                                                                        player[k].jumppower=0;
-                                                                                                                                                                                                               }       
+                                                                                                                                                                                                               }
                                                                                                                                                                                                        }
                                                                                                                                                                                                        j=100;
                                                                                                                                                                                                }
@@ -6832,10 +6595,10 @@ void    Game::Tick()
                                                                                                                vel[1]=player[k].velocity.y;
                                                                                                                vel[2]=player[k].velocity.z;
                                                                                                                if(k==0){
-                                                                                                                       PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
-                                                                                                                       FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
-                                                                                                                       FSOUND_SetVolume(channels[whooshsound], 128);
-                                                                                                                       FSOUND_SetPaused(channels[whooshsound], FALSE);
+                                                                                                                       PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
+                                                                                                                       OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
+                                                                                                                       OPENAL_SetVolume(channels[whooshsound], 128);
+                                                                                                                       OPENAL_SetPaused(channels[whooshsound], false);
                                                                                                                }
                                                                                                        }
                                                                                                        player[k].velocity.y+=gravity;
@@ -6876,7 +6639,7 @@ void      Game::Tick()
                                                static bool endkeydown;
                                                if(indialogue!=-1){
                                                        cameramode=1;
-                                                       if(directing){  
+                                                       if(directing){
                                                                facing=0;
                                                                facing.z=-1;
 
@@ -6962,10 +6725,10 @@ void    Game::Tick()
                                                                                                if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
                                                                                                if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
                                                                                                if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
-                                                                                               PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
-                                                                                               FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
-                                                                                               FSOUND_SetVolume(channels[whichsoundplay], 256);
-                                                                                               FSOUND_SetPaused(channels[whichsoundplay], FALSE);
+                                                                                               PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
+                                                                                               OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
+                                                                                               OPENAL_SetVolume(channels[whichsoundplay], 256);
+                                                                                               OPENAL_SetPaused(channels[whichsoundplay], false);
                                                                                        }
                                                                                }
 
@@ -7002,12 +6765,12 @@ void    Game::Tick()
                                                                                                cameramode=0;
                                                                                        }
                                                        }
-                                                       if(!directing){ 
-                                                               FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                       if(!directing){
+                                                               OPENAL_SetPaused(channels[whooshsound], true);
                                                                viewer=dialoguecamera[whichdialogue][indialogue];
                                                                if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
                                                                        viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
-                                                               }                               
+                                                               }
                                                                rotation=dialoguecamerarotation[whichdialogue][indialogue];
                                                                rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
                                                                if(dialoguetime>0.5)
@@ -7054,10 +6817,10 @@ void    Game::Tick()
                                                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
                                                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
                                                                                                        if(dialogueboxsound[whichdialogue][indialogue]!=-5){
-                                                                                                               PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
-                                                                                                               FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
-                                                                                                               FSOUND_SetVolume(channels[whichsoundplay], 256);
-                                                                                                               FSOUND_SetPaused(channels[whichsoundplay], FALSE);
+                                                                                                               PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
+                                                                                                               OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
+                                                                                                               OPENAL_SetVolume(channels[whichsoundplay], 256);
+                                                                                                               OPENAL_SetPaused(channels[whichsoundplay], false);
                                                                                                        }
                                                                                                        if(dialogueboxsound[whichdialogue][indialogue]==-5){
                                                                                                                hotspot[numhotspots]=player[0].coords;
@@ -7241,10 +7004,10 @@ void    Game::Tick()
                                                        vel[0]=0;
                                                        vel[1]=0;
                                                        vel[2]=0;
-                                                       PlaySoundEx( hawksound, samp[hawksound], NULL, TRUE);
-                                                       FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
-                                                       FSOUND_SetVolume(channels[hawksound], 128);
-                                                       FSOUND_SetPaused(channels[hawksound], FALSE);
+                                                       PlaySoundEx( hawksound, samp[hawksound], NULL, true);
+                                                       OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
+                                                       OPENAL_SetVolume(channels[hawksound], 128);
+                                                       OPENAL_SetPaused(channels[hawksound], false);
 
                                                        hawkcalldelay=16+abs(Random()%8);
                                                }
@@ -7314,7 +7077,7 @@ void      Game::Tick()
                                                        for(j=0;j<objects.numobjects;j++){
                                                        if(objects.type[j]==treetrunktype)
                                                        if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
-                                                       objects.scale[i]=objects.scale[j];      
+                                                       objects.scale[i]=objects.scale[j];
                                                        }
                                                        }
                                                        }*/
@@ -7583,7 +7346,7 @@ void      Game::Tick()
                                                                                }
                                                                }
 
-                                                               if(closest!=-1){                
+                                                               if(closest!=-1){
                                                                        XYZ headspurtdirection;
                                                                        int i = player[closest].skeleton.jointlabels[head];
                                                                        for(k=0;k<player[closest].skeleton.num_joints; k++){
@@ -7610,15 +7373,15 @@ void    Game::Tick()
                                                                        vel[0]=0;
                                                                        vel[1]=0;
                                                                        vel[2]=0;
-                                                                       PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[splattersound], 256);
-                                                                       FSOUND_SetPaused(channels[splattersound], FALSE);
+                                                                       PlaySoundEx( splattersound, samp[splattersound], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[splattersound], 256);
+                                                                       OPENAL_SetPaused(channels[splattersound], false);
 
-                                                                       PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[breaksound2], 100);
-                                                                       FSOUND_SetPaused(channels[breaksound2], FALSE);
+                                                                       PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[breaksound2], 100);
+                                                                       OPENAL_SetPaused(channels[breaksound2], false);
 
                                                                        if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
                                                                        player[closest].RagDoll(0);
@@ -7649,7 +7412,7 @@ void      Game::Tick()
                                                                                }
                                                                }
 
-                                                               if(closest!=-1){                
+                                                               if(closest!=-1){
                                                                        float gLoc[3];
                                                                        float vel[3];
                                                                        gLoc[0]=blah.x;
@@ -7659,15 +7422,15 @@ void    Game::Tick()
                                                                        vel[1]=0;
                                                                        vel[2]=0;
 
-                                                                       PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[splattersound], 256);
-                                                                       FSOUND_SetPaused(channels[splattersound], FALSE);
+                                                                       PlaySoundEx( splattersound, samp[splattersound], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[splattersound], 256);
+                                                                       OPENAL_SetPaused(channels[splattersound], false);
 
-                                                                       PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[breaksound2], 600);
-                                                                       FSOUND_SetPaused(channels[breaksound2], FALSE);
+                                                                       PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[breaksound2], 600);
+                                                                       OPENAL_SetPaused(channels[breaksound2], false);
 
                                                                        for(i=0;i<player[closest].skeleton.num_joints; i++){
                                                                                if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
@@ -7828,11 +7591,11 @@ void    Game::Tick()
                                                                vel[0]=0;
                                                                vel[1]=0;
                                                                vel[2]=0;
-                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[fireendsound], 256);
-                                                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                                                               FSOUND_SetPaused(channels[stream_firesound], TRUE);
+                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[fireendsound], 256);
+                                                               OPENAL_SetPaused(channels[fireendsound], false);
+                                                               OPENAL_SetPaused(channels[stream_firesound], true);
                                                        }
                                                        slomotogglekeydown=1;
                                                }
@@ -7884,7 +7647,7 @@ void      Game::Tick()
                                                if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
                                                        //drawmode++;
                                                        //if(drawmode>2)drawmode=0;
-                                                       if(objects.numobjects<max_objects-1){                   
+                                                       if(objects.numobjects<max_objects-1){
                                                                XYZ boxcoords;
                                                                boxcoords.x=player[0].coords.x;
                                                                boxcoords.z=player[0].coords.z;
@@ -7998,7 +7761,7 @@ void      Game::Tick()
                                                                        player[numplayers].proportionlegs.z=0;
                                                                }
 
-                                                               player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
+                                                               player[numplayers].tempanimation.Load((char *)ConvertFileName(":Data:Animations:Tempanim"),0,0);
 
                                                                player[numplayers].damagetolerance=200;
 
@@ -8229,7 +7992,7 @@ void      Game::Tick()
                                                                        closest=i;
                                                                }
                                                        }
-                                                       if(closestdist>0&&closest>=0)objects.DeleteObject(closest);             
+                                                       if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
                                                        drawmodetogglekeydown=1;
                                                }
 
@@ -8252,11 +8015,11 @@ void    Game::Tick()
                                                        vel[0]=player[0].velocity.x;
                                                        vel[1]=player[0].velocity.y;
                                                        vel[2]=player[0].velocity.z;
-                                                       PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
-                                                       FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
-                                                       FSOUND_SetVolume(channels[whooshsound], 128);
-                                                       FSOUND_SetPaused(channels[whooshsound], FALSE);
-                                                       //FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                       PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
+                                                       OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
+                                                       OPENAL_SetVolume(channels[whooshsound], 128);
+                                                       OPENAL_SetPaused(channels[whooshsound], false);
+                                                       //OPENAL_SetPaused(channels[whooshsound], true);
 
                                                        texturesizetogglekeydown=1;
                                                }
@@ -8336,7 +8099,7 @@ void      Game::Tick()
                                                                                for(i=0;i<numplayers;i++){
                                                                                        if(i==k)i++;
                                                                                        if(!player[k].hasvictim)
-                                                                                               if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){      
+                                                                                               if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
                                                                                                        if(findDistancefast(&player[k].coords,&player[i].coords)<4.5&&!player[i].skeleton.free&&player[i].howactive<typedead1&&player[i].targetanimation!=jumpreversedanim&&player[i].targetanimation!=rabbitkickreversedanim&&player[i].targetanimation!=rabbitkickanim&&player[k].targetanimation!=rabbitkickanim&&player[i].targetanimation!=getupfrombackanim&&(player[i].targetanimation!=staggerbackhighanim&&(player[i].targetanimation!=staggerbackhardanim||animation[staggerbackhardanim].label[player[i].targetframe]==6))&&player[i].targetanimation!=jumpdownanim&&player[i].targetanimation!=jumpupanim&&player[i].targetanimation!=getupfromfrontanim){
                                                                                                                player[k].victim=&player[i];
                                                                                                                player[k].hasvictim=1;
@@ -8481,7 +8244,7 @@ void      Game::Tick()
                                                                                if(numplayers>1)
                                                                                        for(i=0;i<numplayers;i++){
                                                                                                if(i==k)i++;
-                                                                                               if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){   
+                                                                                               if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
                                                                                                        if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
                                                                                                                if(player[i].skeleton.free)
                                                                                                                        if(findDistancefast(&player[k].coords,&player[i].coords)<3.5*(player[k].scale*5)*(player[k].scale*5)&&(player[i].dead||player[i].skeleton.longdead>1000||player[k].isRun()||(hasstaff)||(player[k].weaponactive!=-1&&player[i].skeleton.free&&(player[i].skeleton.longdead>2000||player[i].damage>player[i].damagetolerance/8||player[i].bloodloss>player[i].damagetolerance/2)&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)))){
@@ -8625,7 +8388,7 @@ void      Game::Tick()
                                                                                                                                                                                if(player[i].onfire||player[k].onfire){
                                                                                                                                                                                        if(!player[i].onfire)player[i].CatchFire();
                                                                                                                                                                                        if(!player[k].onfire)player[k].CatchFire();
-                                                                                                                                                                               }       
+                                                                                                                                                                               }
                                                                                                                                                                        }
 
                                                                                                                                                                        tempcoords1=player[i].coords;
@@ -8635,7 +8398,7 @@ void      Game::Tick()
                                                                                                                                                                        collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
                                                                                                                                                                        if(player[0].hasvictim)
                                                                                                                                                                                if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
-                                                                                                                                                                       if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){   
+                                                                                                                                                                       if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
                                                                                                                                                                                if(k==0)
                                                                                                                                                                                        if(player[k].targetanimation==jumpdownanim&&!player[k].skeleton.oldfree&&!player[k].skeleton.free&&player[i].skeleton.oldfree&&player[i].skeleton.free&&player[i].dead&&player[k].lastcollide<=0&&abs(player[i].coords.y-player[k].coords.y)<.2&&findDistancefast(&player[k].coords,&player[i].coords)<.7*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
                                                                                                                                                                                                player[k].coords.y=player[i].coords.y;
@@ -8646,7 +8409,7 @@ void      Game::Tick()
                                                                                                                                                                                                player[i].DoDamage(20);
                                                                                                                                                                                                if(k==0)camerashake+=.3;
                                                                                                                                                                                                player[i].skeleton.longdead=0;
-                                                                                                                                                                                               player[k].lastcollide=1;        
+                                                                                                                                                                                               player[k].lastcollide=1;
                                                                                                                                                                                        }
                                                                                                                                                                                        if(i==0)
                                                                                                                                                                                                if(player[i].targetanimation==jumpdownanim&&!player[i].skeleton.oldfree&&!player[i].skeleton.free&&player[k].skeleton.oldfree&&player[k].skeleton.free&&player[k].dead&&player[i].lastcollide<=0&&abs(player[i].coords.y-player[k].coords.y)<.2&&findDistancefast(&player[k].coords,&player[i].coords)<.7*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
@@ -8658,10 +8421,10 @@ void    Game::Tick()
                                                                                                                                                                                                        player[k].DoDamage(20);
                                                                                                                                                                                                        if(i==0)camerashake+=.3;
                                                                                                                                                                                                        player[k].skeleton.longdead=0;
-                                                                                                                                                                                                       player[i].lastcollide=1;        
+                                                                                                                                                                                                       player[i].lastcollide=1;
                                                                                                                                                                                                }
 
-                                                                                                                                                                                               if((player[i].skeleton.oldfree==1&&findLengthfast(&player[i].velocity)>1)||(player[k].skeleton.oldfree==1&&findLengthfast(&player[k].velocity)>1)||(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0)){     
+                                                                                                                                                                                               if((player[i].skeleton.oldfree==1&&findLengthfast(&player[i].velocity)>1)||(player[k].skeleton.oldfree==1&&findLengthfast(&player[k].velocity)>1)||(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0)){
                                                                                                                                                                                                        rotatetarget=player[k].velocity-player[i].velocity;
                                                                                                                                                                                                        if(((player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim)||player[i].skeleton.free)&&((player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim)||player[k].skeleton.free))
                                                                                                                                                                                                                if(((((findLengthfast(&rotatetarget)>150&&(i!=0&&k!=0))||(findLengthfast(&rotatetarget)>50&&player[0].rabbitkickragdoll/*currentanimation==rabbitkickanim*/&&(i==0||k==0)))&&normaldotproduct(rotatetarget,player[k].coords-player[i].coords)>0)&&((i==0||k==0)||((player[i].skeleton.oldfree==1&&k!=0&&animation[player[k].currentanimation].attack==neutral)||(player[k].skeleton.oldfree==1&&i!=0&&animation[player[i].currentanimation].attack==neutral)||(player[i].isFlip()&&!player[i].skeleton.oldfree&&(i==0||k==0))||(player[k].isFlip()&&!player[k].skeleton.oldfree&&(i==0||k==0))||(i==0||k==0))))||((player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip())&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&(i==0||k==0)&&(!player[i].skeleton.oldfree&&!player[k].skeleton.oldfree))){
@@ -8676,10 +8439,10 @@ void    Game::Tick()
                                                                                                                                                                                                                                vel[1]=player[i].velocity.y;
                                                                                                                                                                                                                                vel[2]=player[i].velocity.z;
                                                                                                                                                                                                                                if(tutoriallevel!=1){
-                                                                                                                                                                                                                                       PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
-                                                                                                                                                                                                                                       FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
-                                                                                                                                                                                                                                       FSOUND_SetVolume(channels[heavyimpactsound], 256);
-                                                                                                                                                                                                                                       FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
+                                                                                                                                                                                                                                       PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
+                                                                                                                                                                                                                                       OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
+                                                                                                                                                                                                                                       OPENAL_SetVolume(channels[heavyimpactsound], 256);
+                                                                                                                                                                                                                                       OPENAL_SetPaused(channels[heavyimpactsound], false);
                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                //player[i].velocity=player[k].velocity;
                                                                                                                                                                                                                                //player[k].velocity=player[i].velocity;
@@ -8760,7 +8523,7 @@ void      Game::Tick()
                                                                                                                                                                                                                                                player[k].velocity.y=player[i].velocity.y;
                                                                                                                                                                                                                                                player[i].DoDamage(20);
                                                                                                                                                                                                                                                player[i].RagDoll(0);
-                                                                                                                                                                                                                                               player[k].lastcollide=1;        
+                                                                                                                                                                                                                                               player[k].lastcollide=1;
                                                                                                                                                                                                                                                if(k==0){
                                                                                                                                                                                                                                                        bonus=AboveBonus;
                                                                                                                                                                                                                                                        bonustime=0;
@@ -8773,8 +8536,8 @@ void      Game::Tick()
                                                                                                                                                                                                                                                //player[k].velocity.y-=10;
                                                                                                                                                                                                                                                player[i].velocity.y=player[k].velocity.y;
                                                                                                                                                                                                                                                player[k].DoDamage(20);
-                                                                                                                                                                                                                                               player[k].RagDoll(0);   
-                                                                                                                                                                                                                                               player[i].lastcollide=1;        
+                                                                                                                                                                                                                                               player[k].RagDoll(0);
+                                                                                                                                                                                                                                               player[i].lastcollide=1;
                                                                                                                                                                                                                                                if(i==0){
                                                                                                                                                                                                                                                        bonus=AboveBonus;
                                                                                                                                                                                                                                                        bonustime=0;
@@ -8977,7 +8740,7 @@ void      Game::Tick()
                                                        /*
                                                        if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
                                                        //Respawn
-                                                       FSOUND_SetPaused(channels[whooshsound], TRUE);
+                                                       OPENAL_SetPaused(channels[whooshsound], true);
                                                        changedelay=0;
                                                        for(k=0;k<numplayers;k++){
                                                        player[k].dead=0;
@@ -9001,7 +8764,7 @@ void      Game::Tick()
 
                                                        //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
 
-               for(int i=0;i<numplayers;i++){  
+               for(int i=0;i<numplayers;i++){
                                                                if(!player[i].skeleton.free){
                                                                        oldtargetrotation=player[i].targetrotation;
                                                                        if(i==0&&indialogue==-1){
@@ -9023,7 +8786,7 @@ void      Game::Tick()
                                                                                player[0].lookrotation=-rotation;
 
                                                                                player[i].targetheadrotation=rotation;
-                                                                               player[i].targetheadrotation2=rotation2;                        
+                                                                               player[i].targetheadrotation2=rotation2;
                                                                        }
                                                                        if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
                                                                                if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim&&player[i].targetanimation!=walljumprightkickanim&&player[i].targetanimation!=walljumpleftkickanim){
@@ -9039,7 +8802,7 @@ void      Game::Tick()
                                                                                facing=DoRotation(facing,0,0-player[i].lookrotation,0);
 
                                                                                player[i].targetheadrotation=player[i].lookrotation;
-                                                                               player[i].targetheadrotation2=player[i].lookrotation2;                  
+                                                                               player[i].targetheadrotation2=player[i].lookrotation2;
                                                                        }
                                                                        if(indialogue!=-1){
                                                                                rotatetarget=participantfacing[whichdialogue][indialogue][i];
@@ -9263,7 +9026,7 @@ void      Game::Tick()
                                                                                                                }
                                                                                                        }
                                                                                                }
-                                                                                       }       
+                                                                                       }
                                                                                        if(player[i].aitype==attacktypecutoff&&musictype!=2){
                                                                                                if(player[i].creature!=wolftype){
                                                                                                        player[i].stunned=.6;
@@ -9299,7 +9062,7 @@ void      Game::Tick()
                                                                                                                if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
 
                                                                                                        }
-                                                                                               }                       
+                                                                                               }
 
                                                                                                if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
                                                                                                else player[i].forwardkeydown=0;
@@ -9323,7 +9086,7 @@ void      Game::Tick()
                                                                                                                else player[i].targetrotation-=90;
                                                                                                        }
                                                                                                }
-                                                                                       }                       
+                                                                                       }
                                                                                        if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
                                                                                        if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
 
@@ -9355,7 +9118,7 @@ void      Game::Tick()
 
                                                                                                                                        player[i].howactive=typeactive;
                                                                                                                                }
-                                                                                       }                       
+                                                                                       }
 
                                                                                        if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
                                                                                                if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
@@ -9396,7 +9159,7 @@ void      Game::Tick()
                                                                                                                                                if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords)&&!player[j].isWallJump())||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
                                                                                                                                                        player[i].lastseentime-=.2;
                                                                                                                                                        if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
-                                                                                                                                                       else player[i].lastseentime-=.6;                                                                
+                                                                                                                                                       else player[i].lastseentime-=.6;
                                                                                                                                                }
                                                                                                                                                if(player[i].lastseentime<=0){
                                                                                                                                                        player[i].aitype=searchtype;
@@ -9419,7 +9182,7 @@ void      Game::Tick()
                                                                                                }
                                                                                                numseen++;
                                                                                        }
-                                                                               }               
+                                                                               }
 
                                                                                if(player[i].aitype==searchtype){
                                                                                        player[i].aiupdatedelay-=multiplier;
@@ -9454,7 +9217,7 @@ void      Game::Tick()
                                                                                                        }
                                                                                                        else player[i].laststanding=j;
                                                                                                }
-                                                                                       }       
+                                                                                       }
                                                                                        if(player[i].aiupdatedelay<0){
                                                                                                rotatetarget=player[i].lastseen-player[i].coords;
                                                                                                Normalise(&rotatetarget);
@@ -9589,7 +9352,7 @@ void      Game::Tick()
                                                                                                        if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
                                                                                                        player[i].lookrotation=player[i].targetrotation;
                                                                                                        player[i].aiupdatedelay=.05;
-                                                                                                       player[i].forwardkeydown=1;                                     
+                                                                                                       player[i].forwardkeydown=1;
 
                                                                                                        if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
                                                                                                                player[i].aitype=searchtype;
@@ -9661,7 +9424,7 @@ void      Game::Tick()
                                                                                                        if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
                                                                                                                player[i].aitype=attacktypecutoff;
                                                                                                                player[i].lastseentime=1;
-                                                                                                       }                                       
+                                                                                                       }
                                                                                                        if(!player[0].dead)
                                                                                                                if(player[i].ally>=0){
                                                                                                                        if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
@@ -9675,7 +9438,7 @@ void      Game::Tick()
                                                                                                                        if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
                                                                                                                        player[i].lookrotation=player[i].targetrotation;
                                                                                                                        player[i].aiupdatedelay=.05;
-                                                                                                                       player[i].forwardkeydown=1;                                     
+                                                                                                                       player[i].forwardkeydown=1;
 
 
                                                                                                                        if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
@@ -9713,7 +9476,7 @@ void      Game::Tick()
                                                                                                                player[i].rightkeydown=0;
                                                                                                                player[i].attackkeydown=0;
                                                                                                                player[i].throwkeydown=1;
-                                                                                                               player[i].crouchkeydown=0;      
+                                                                                                               player[i].crouchkeydown=0;
                                                                                                                if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
                                                                                                                player[i].drawkeydown=0;
                                                                                        }
@@ -9805,7 +9568,7 @@ void      Game::Tick()
                                                                                                                                player[i].lastpathfindpoint2=-1;
                                                                                                                                player[i].lastpathfindpoint3=-1;
                                                                                                                                player[i].lastpathfindpoint4=-1;
-                                                                                                                       }       
+                                                                                                                       }
                                                                                                                        if(player[i].aiupdatedelay<0&&!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
                                                                                                                                if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
                                                                                                                                else player[i].drawkeydown=0;
@@ -10050,10 +9813,10 @@ void   Game::Tick()
                                                                                                                                                        vel[1]=player[i].velocity.y;
                                                                                                                                                        vel[2]=player[i].velocity.z;
                                                                                                                                                        if(weapons.type[j]!=staff){
-                                                                                                                                                               PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
-                                                                                                                                                               FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
-                                                                                                                                                               FSOUND_SetVolume(channels[knifedrawsound], 128);
-                                                                                                                                                               FSOUND_SetPaused(channels[knifedrawsound], FALSE);
+                                                                                                                                                               PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
+                                                                                                                                                               OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
+                                                                                                                                                               OPENAL_SetVolume(channels[knifedrawsound], 128);
+                                                                                                                                                               OPENAL_SetPaused(channels[knifedrawsound], false);
                                                                                                                                                        }
 
                                                                                                                                                        player[i].weaponactive=0;
@@ -10097,10 +9860,10 @@ void   Game::Tick()
                                                                                                                                                                vel[1]=player[i].velocity.y;
                                                                                                                                                                vel[2]=player[i].velocity.z;
                                                                                                                                                                if(weapons.type[k]!=staff){
-                                                                                                                                                                       PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
-                                                                                                                                                                       FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
-                                                                                                                                                                       FSOUND_SetVolume(channels[knifedrawsound], 128);
-                                                                                                                                                                       FSOUND_SetPaused(channels[knifedrawsound], FALSE);
+                                                                                                                                                                       PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
+                                                                                                                                                                       OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
+                                                                                                                                                                       OPENAL_SetVolume(channels[knifedrawsound], 128);
+                                                                                                                                                                       OPENAL_SetPaused(channels[knifedrawsound], false);
                                                                                                                                                                }
 
                                                                                                                                                                player[i].weaponactive=0;
@@ -10158,17 +9921,17 @@ void   Game::Tick()
                                                                                                                                                        }
                                                                                                                                                        if(!fleshstuck){
                                                                                                                                                                if(weapons.type[k]!=staff){
-                                                                                                                                                                       PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
-                                                                                                                                                                       FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
-                                                                                                                                                                       FSOUND_SetVolume(channels[knifedrawsound], 128);
-                                                                                                                                                                       FSOUND_SetPaused(channels[knifedrawsound], FALSE);
+                                                                                                                                                                       PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
+                                                                                                                                                                       OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
+                                                                                                                                                                       OPENAL_SetVolume(channels[knifedrawsound], 128);
+                                                                                                                                                                       OPENAL_SetPaused(channels[knifedrawsound], false);
                                                                                                                                                                }
                                                                                                                                                        }
                                                                                                                                                        if(fleshstuck){
-                                                                                                                                                               PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
-                                                                                                                                                               FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
-                                                                                                                                                               FSOUND_SetVolume(channels[fleshstabremovesound], 128);
-                                                                                                                                                               FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
+                                                                                                                                                               PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
+                                                                                                                                                               OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
+                                                                                                                                                               OPENAL_SetVolume(channels[fleshstabremovesound], 128);
+                                                                                                                                                               OPENAL_SetPaused(channels[fleshstabremovesound], false);
                                                                                                                                                        }
 
                                                                                                                                                        player[i].weaponactive=0;
@@ -10256,7 +10019,7 @@ void    Game::Tick()
                                                                                                                                                                        player[i].victim=&player[j];
                                                                                                                                                                        XYZ aim;
                                                                                                                                                                        weapons.owner[player[i].weaponids[0]]=-1;
-                                                                                                                                                                       aim=player[i].victim->coords+DoRotation(player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[righthand]].position,0,player[i].rotation,0)*player[i].scale);                                                
+                                                                                                                                                                       aim=player[i].victim->coords+DoRotation(player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[righthand]].position,0,player[i].rotation,0)*player[i].scale);
                                                                                                                                                                        Normalise(&aim);
 
                                                                                                                                                                        aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
@@ -10272,7 +10035,7 @@ void    Game::Tick()
                                                                                                                                                                                player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
                                                                                                                                                                        }
                                                                                                                                                                        player[i].weaponactive=-1;
-                                                                                                                                                               }               
+                                                                                                                                                               }
                                                                                                                                                        }
                                                                                                                                                }
                                                                                                                }
@@ -10332,7 +10095,7 @@ void    Game::Tick()
                                                                                                        player[i].target=0;
                                                                                                        player[i].drawtogglekeydown=1;
                                                                                                }
-                                                                                       }                        
+                                                                                       }
                                                                                }
                                                                                if(player[i].isCrouch()&&weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&bloodtoggle&&player[i].onterrain&&player[i].num_weapons&&player[i].weaponactive!=-1&&player[i].attackkeydown){
                                                                                        if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
@@ -10430,7 +10193,7 @@ void    Game::Tick()
                                                                                                                if(target>=0)player[target].Reverse();
                                                                                                                player[i].highreversaldelay=.5;
 
-                                                                                                               if(player[i].isCrouch()){                                               
+                                                                                                               if(player[i].isCrouch()){
                                                                                                                        if(!player[i].wasCrouch()){
                                                                                                                                player[i].currentanimation=player[i].getCrouch();
                                                                                                                                player[i].currentframe=0;
@@ -10593,17 +10356,17 @@ void  Game::Tick()
                                                                                                                vel[2]=player[i].velocity.z;
 
                                                                                                                if(i==0){
-                                                                                                                       PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
-                                                                                                                       FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
-                                                                                                                       FSOUND_SetVolume(channels[whooshsound], 128);
-                                                                                                                       FSOUND_SetPaused(channels[whooshsound], FALSE);
+                                                                                                                       PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
+                                                                                                                       OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
+                                                                                                                       OPENAL_SetVolume(channels[whooshsound], 128);
+                                                                                                                       OPENAL_SetPaused(channels[whooshsound], false);
                                                                                                                }
 
-                                                                                                               PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
-                                                                                                               FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
-                                                                                                               FSOUND_SetVolume(channels[jumpsound], 128);
-                                                                                                               FSOUND_SetPaused(channels[jumpsound], FALSE);
-                                                                                               }               
+                                                                                                               PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
+                                                                                                               OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
+                                                                                                               OPENAL_SetVolume(channels[jumpsound], 128);
+                                                                                                               OPENAL_SetPaused(channels[jumpsound], false);
+                                                                                               }
                                                                                                if((player[i].isIdle())&&player[i].jumppower>1){
                                                                                                        player[i].targetanimation=player[i].getLanding();
                                                                                                        player[i].landhard=0;
@@ -10611,7 +10374,7 @@ void    Game::Tick()
                                                                                                        player[i].targetframe=2;
                                                                                                        player[i].jumpstart=1;
                                                                                                        player[i].tempdeltav=deltav;
-                                                                                               }               
+                                                                                               }
                                                                                                if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
                                                                                                        if(player[i].jumppower>multiplier*6){
                                                                                                                player[i].velocity.y+=multiplier*6;
@@ -10622,7 +10385,7 @@ void    Game::Tick()
                                                                                                                player[i].jumppower=0;
                                                                                                        }
                                                                                                }
-                                                                                               if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;           
+                                                                                               if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
                                                                                        }
 
                                                                                        if(!movekey){
@@ -10744,8 +10507,8 @@ void    Game::Tick()
                                                                                envsound[j]=envsound[numenvsounds];
                                                                        }
                                                                }
-                                                               if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
-                                                               if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
+                                                               if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
+                                                               if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
 
                                                                if(tutoriallevel==1){
                                                                        XYZ temp;
@@ -10766,23 +10529,24 @@ void  Game::Tick()
                                                                        oldtemp2=temp2;
                                                                        if(tutorialstage>=51)
                                                                                if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
-                                                                                       FSOUND_SetFrequency(FSOUND_ALL, 0.001);
+                                                   OPENAL_StopSound(OPENAL_ALL);  // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
+                                                                                       OPENAL_SetFrequency(OPENAL_ALL, 0.001);
 
-                                                                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                                                                                       FSOUND_SetPaused(channels[stream_music3], FALSE);
-                                                                                       FSOUND_SetVolume(channels[stream_music3], 256);
+                                                                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                                                                       OPENAL_SetPaused(channels[stream_music3], false);
+                                                                                       OPENAL_SetVolume(channels[stream_music3], 256);
 
                                                                                        gameon=0;
                                                                                        mainmenu=5;
 
                                                                                        float gLoc[3]={0,0,0};
                                                                                        float vel[3]={0,0,0};
-                                                                                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                                                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                                                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
-                                                                                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                                                                                       OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                                                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                                                       OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                                                       OPENAL_SetVolume(channels[fireendsound], 256);
+                                                                                       OPENAL_SetPaused(channels[fireendsound], false);
+                                                                                       OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                                                                        flashr=1;
                                                                                        flashg=0;
@@ -10800,10 +10564,10 @@ void  Game::Tick()
                                                                                                vel[0]=0;
                                                                                                vel[1]=0;
                                                                                                vel[2]=0;
-                                                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                                                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                                                               FSOUND_SetVolume(channels[fireendsound], 256);
-                                                                                               FSOUND_SetPaused(channels[fireendsound], FALSE);
+                                                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                                                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                                                               OPENAL_SetVolume(channels[fireendsound], 256);
+                                                                                               OPENAL_SetPaused(channels[fireendsound], false);
 
                                                                                                player[0].coords=(oldtemp+oldtemp2)/2;
 
@@ -10823,10 +10587,10 @@ void  Game::Tick()
                                                                                                        vel[0]=0;
                                                                                                        vel[1]=0;
                                                                                                        vel[2]=0;
-                                                                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                                                                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
+                                                                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                                                                       OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                                                                       OPENAL_SetVolume(channels[fireendsound], 256);
+                                                                                                       OPENAL_SetPaused(channels[fireendsound], false);
 
                                                                                                        for(int i=0;i<player[1].skeleton.num_joints;i++){
                                                                                                                if(Random()%2==0){
@@ -10873,11 +10637,11 @@ void  Game::Tick()
 
                                                                facing=0;
                                                                facing.z=-1;
-                                                               
+
                                                                facing=DoRotation(facing,-rotation2,0,0);
                                                                facing=DoRotation(facing,0,0-rotation,0);
-               
-               
+
+
                                                                static float ori[6];
                                                                ori[0] = -facing.x;
                                                                ori[1] = facing.y;
@@ -10886,8 +10650,8 @@ void    Game::Tick()
                                                                ori[4] = upvector.y;
                                                                ori[5] = -upvector.z;
 
-                                                               FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
-                                                               FSOUND_Update();
+                                                               OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
+                                                               OPENAL_Update();
 
                                                                oldviewer=viewer;
                }
@@ -10899,7 +10663,7 @@ void    Game::Tick()
        }
 }
 
-void   Game::TickOnce(){
+void   Game::TickOnce(){
        //if(!console){
        if(!mainmenu)
                if(directing||indialogue==-1){
@@ -10910,59 +10674,11 @@ void  Game::TickOnce(){
                        if(rotation2<-70)rotation2=-70;
                }
                if(mainmenu)rotation+=multiplier*5;
-               if(!mainmenu&&!indemo&&!registered){
-                       FSOUND_SetFrequency(FSOUND_ALL, 0.001);         
-                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                       FSOUND_SetPaused(channels[stream_music3], FALSE);
-                       FSOUND_SetVolume(channels[stream_music3], 256);
-
-                       gameon=0;
-                       mainmenu=12;
-
-                       float gLoc[3]={0,0,0};
-                       float vel[3]={0,0,0};
-                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                       FSOUND_SetVolume(channels[fireendsound], 256);
-                       FSOUND_SetPaused(channels[fireendsound], FALSE);
-                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                       flashr=1;
-                       flashg=0;
-                       flashb=0;
-                       flashamount=1;
-                       flashdelay=1;
-               }
-
-               if(tryquit==1&&!registered&&mainmenu!=12){
-                       FSOUND_SetFrequency(FSOUND_ALL, 0.001);         
-                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                       FSOUND_SetPaused(channels[stream_music3], FALSE);
-                       FSOUND_SetVolume(channels[stream_music3], 256);
-
-                       gameon=0;
-                       mainmenu=12;
-
-                       float gLoc[3]={0,0,0};
-                       float vel[3]={0,0,0};
-                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                       FSOUND_SetVolume(channels[fireendsound], 256);
-                       FSOUND_SetPaused(channels[fireendsound], FALSE);
-                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                       flashr=1;
-                       flashg=0;
-                       flashb=0;
-                       flashamount=1;
-                       flashdelay=1;
-               }
+      
                //}
 }
 
-void   Game::TickOnceAfter(){
+void   Game::TickOnceAfter(){
        static XYZ colviewer;
        static XYZ coltarget;
        static XYZ target;
@@ -11011,9 +10727,9 @@ void    Game::TickOnceAfter(){
                        musicvolume[0]=0;
                        musicvolume[1]=0;
                        musicvolume[3]=0;
-               }       
+               }
 
-               if(musictoggle){                        
+               if(musictoggle){
                        if(musictype!=oldmusictype&&musictype==stream_music2){
                                static float gLoc[3];
                                static float vel[3];
@@ -11023,9 +10739,9 @@ void    Game::TickOnceAfter(){
                                vel[0]=0;
                                vel[1]=0;
                                vel[2]=0;
-                               PlaySoundEx( alarmsound, samp[alarmsound], NULL, TRUE);
-                               FSOUND_SetVolume(channels[alarmsound], 512);
-                               FSOUND_SetPaused(channels[alarmsound], FALSE);
+                               PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
+                               OPENAL_SetVolume(channels[alarmsound], 512);
+                               OPENAL_SetPaused(channels[alarmsound], false);
 
                        }
                }
@@ -11053,25 +10769,25 @@ void  Game::TickOnceAfter(){
 
                if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
 
-               if(musictoggle){                
+               if(musictoggle){
                        if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
-                               PlayStreamEx( music1, strm[music1], NULL, TRUE);
-                               FSOUND_SetPaused(channels[music1], FALSE);
+                               PlayStreamEx( music1, strm[music1], NULL, true);
+                               OPENAL_SetPaused(channels[music1], false);
                        }
                        if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
-                               PlayStreamEx( stream_music2, strm[stream_music2], NULL, TRUE);
-                               FSOUND_SetPaused(channels[stream_music2], FALSE);
+                               PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
+                               OPENAL_SetPaused(channels[stream_music2], false);
                        }
                        if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
-                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                               FSOUND_SetPaused(channels[stream_music3], FALSE);
+                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                               OPENAL_SetPaused(channels[stream_music3], false);
                        }
                }
 
-               if(!musictoggle){               
-                       FSOUND_SetPaused(channels[music1], TRUE);
-                       FSOUND_SetPaused(channels[stream_music2], TRUE);
-                       FSOUND_SetPaused(channels[stream_music3], TRUE);
+               if(!musictoggle){
+                       OPENAL_SetPaused(channels[music1], true);
+                       OPENAL_SetPaused(channels[stream_music2], true);
+                       OPENAL_SetPaused(channels[stream_music3], true);
 
                        for(i=0;i<4;i++){
                                oldmusicvolume[i]=0;
@@ -11079,25 +10795,25 @@ void  Game::TickOnceAfter(){
                        }
                }
 
-               if(musictoggle){                
+               if(musictoggle){
                        if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
-                               FSOUND_SetPaused(channels[music1], TRUE);
+                               OPENAL_SetPaused(channels[music1], true);
                        }
                        if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
-                               FSOUND_SetPaused(channels[stream_music2], TRUE);
+                               OPENAL_SetPaused(channels[stream_music2], true);
                        }
                        if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
-                               FSOUND_SetPaused(channels[stream_music3], TRUE);
+                               OPENAL_SetPaused(channels[stream_music3], true);
                        }
 
                        if(musicvolume[0]!=oldmusicvolume[0]){
-                               FSOUND_SetVolume(channels[music1], musicvolume[0]);
+                               OPENAL_SetVolume(channels[music1], musicvolume[0]);
                        }
                        if(musicvolume[1]!=oldmusicvolume[1]){
-                               FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
+                               OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
                        }
                        if(musicvolume[2]!=oldmusicvolume[2]){
-                               FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
+                               OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
                        }
 
                        for(i=0;i<3;i++){
@@ -11130,19 +10846,19 @@ void  Game::TickOnceAfter(){
 
                                int numalarmed=0;
                                if(numplayers>1)
-                                       for(i=1;i<numplayers;i++){              
+                                       for(i=1;i<numplayers;i++){
                                                if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
                                        }
                                        if(numalarmed>maxalarmed)maxalarmed=numalarmed;
 
-                                       if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){          
+                                       if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
                                                if(player[0].dead&&changedelay<=0){
                                                        changedelay=1;
                                                        targetlevel=whichlevel;
                                                }
                                                alldead=1;
                                                if(numplayers>1)
-                                                       for(i=1;i<numplayers;i++){              
+                                                       for(i=1;i<numplayers;i++){
                                                                if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
                                                        }
 
@@ -11183,7 +10899,7 @@ void    Game::TickOnceAfter(){
                                                                        won=1;
                                                                        if(!debugmode){
                                                                                if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
-                                                                               if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;            
+                                                                               if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
                                                                        }
                                                                        if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
 
@@ -11214,12 +10930,12 @@ void  Game::TickOnceAfter(){
 
                                                                float gLoc[3]={0,0,0};
                                                                float vel[3]={0,0,0};
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[firestartsound], 256);
-                                                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[firestartsound], 256);
+                                                               OPENAL_SetPaused(channels[firestartsound], false);
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                                                if(!player[0].dead&&targetlevel!=whichlevel){
                                                                        startbonustotal=bonustotal;
@@ -11227,12 +10943,12 @@ void  Game::TickOnceAfter(){
                                                                if(!player[0].dead)Loadlevel(targetlevel);
                                                                if(player[0].dead)Loadlevel(whichlevel);
 
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[fireendsound], 256);
-                                                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[fireendsound], 256);
+                                                               OPENAL_SetPaused(channels[fireendsound], false);
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                                                loading=3;
                                                        }
@@ -11246,12 +10962,12 @@ void  Game::TickOnceAfter(){
 
                                                                float gLoc[3]={0,0,0};
                                                                float vel[3]={0,0,0};
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[firestartsound], 256);
-                                                               FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[firestartsound], 256);
+                                                               OPENAL_SetPaused(channels[firestartsound], false);
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                                                for(i=0;i<255;i++){
                                                                        mapname[i]='\0';
@@ -11270,43 +10986,18 @@ void  Game::TickOnceAfter(){
                                                                strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
                                                                Loadlevel(mapname);
 
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                               FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                               FSOUND_SetVolume(channels[fireendsound], 256);
-                                                               FSOUND_SetPaused(channels[fireendsound], FALSE);
-                                                               FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
+                                                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
+                                                               OPENAL_SetVolume(channels[fireendsound], 256);
+                                                               OPENAL_SetPaused(channels[fireendsound], false);
+                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
                                                                loading=3;
                                                        }
                                                        if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
                                                        if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
-                                                               if(accountprogress[accountactive]>3&&!registered){
-                                                                       FSOUND_SetFrequency(FSOUND_ALL, 0.001);         
-                                                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
-                                                                       FSOUND_SetPaused(channels[stream_music3], FALSE);
-                                                                       FSOUND_SetVolume(channels[stream_music3], 256);
-
-                                                                       gameon=0;
-                                                                       mainmenu=12;
-                                                                       accountprogress[accountactive]=3;
-
-                                                                       float gLoc[3]={0,0,0};
-                                                                       float vel[3]={0,0,0};
-                                                                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); 
-                                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[fireendsound], 256);
-                                                                       FSOUND_SetPaused(channels[fireendsound], FALSE);
-                                                                       FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);     
-
-                                                                       flashr=1;
-                                                                       flashg=0;
-                                                                       flashb=0;
-                                                                       flashamount=1;
-                                                                       flashdelay=1;
-                                                               }
-                                                               else{
+                        {
                                                                        if(whichlevel!=-2&&!loading&&!player[0].dead){
                                                                                winfreeze=1;
                                                                                changedelay=-999;
@@ -11330,12 +11021,12 @@ void  Game::TickOnceAfter(){
                                                                if(!stealthloading){
                                                                        float gLoc[3]={0,0,0};
                                                                        float vel[3]={0,0,0};
-                                                                       FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);       
-                                                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
-                                                                       FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                                       FSOUND_SetVolume(channels[firestartsound], 256);
-                                                                       FSOUND_SetPaused(channels[firestartsound], FALSE);
-                                                                       FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);   
+                                                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
+                                                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
+                                                                       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
+                                                                       OPENAL_SetVolume(channels[firestartsound], 256);
+                                                                       OPENAL_SetPaused(channels[firestartsound], false);
+                                                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
 
                                                                        flashr=1;
                                                                        flashg=0;
@@ -11346,8 +11037,7 @@ void    Game::TickOnceAfter(){
 
                                                                startbonustotal=0;
 
-                                                               //              ifstream ipstream(":Data:Campaigns:main.txt");  
-                                                               ifstream ipstream("./Data/Campaigns/main.txt"); 
+                                                               ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
                                                                //campaignnumlevels=0;
                                                                //accountcampaignchoicesmade[accountactive]=0;
                                                                ipstream.ignore(256,':');
@@ -11447,7 +11137,7 @@ void    Game::TickOnceAfter(){
                                                                        campaign=1;
                                                                        mainmenu=0;
                                                                        gameon=1;
-                                                                       FSOUND_SetPaused(channels[stream_music3], TRUE);
+                                                                       OPENAL_SetPaused(channels[stream_music3], true);
 
                                                                        stealthloading=0;
                                                        }
@@ -11473,7 +11163,7 @@ void    Game::TickOnceAfter(){
                target.y+=.1;
                if(player[0].skeleton.free){
                        for(i=0;i<player[0].skeleton.num_joints;i++){
-                               if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)                         
+                               if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
                                        target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
                        }
                        target.y+=.1;
@@ -11503,7 +11193,7 @@ void    Game::TickOnceAfter(){
                                        i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
                                        colviewer=viewer;
                                        coltarget=cameraloc;
-                                       if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;     
+                                       if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
                                }
                                if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
                                        for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
@@ -11547,7 +11237,7 @@ void    Game::TickOnceAfter(){
                                        i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
                                        colviewer=viewer;
                                        coltarget=cameraloc;
-                                       if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;     
+                                       if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
                                }
                                if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
                                        for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){