author | rubidium |
Wed, 09 Jan 2008 18:11:12 +0000 | |
branch | noai |
changeset 9723 | eee46cb39750 |
parent 9631 | 8a2d1c2ceb88 |
child 9724 | b39bc69bb2f2 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6451
7baba06b4b85
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6360
diff
changeset
|
3 |
/** @file driver.cpp */ |
7baba06b4b85
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6360
diff
changeset
|
4 |
|
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
6 |
#include "openttd.h" |
2210
58a293892a66
(svn r2728) -Fix/Feature: Change the driver probing algorithm
tron
parents:
2186
diff
changeset
|
7 |
#include "debug.h" |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
8 |
#include "driver.h" |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
9 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
10 |
#include "sound/sound_driver.hpp" |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
11 |
#include "music/music_driver.hpp" |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
12 |
#include "video/video_driver.hpp" |
2222
d227c0207a02
(svn r2740) MSCV doesn't seem to like forward declared static arrays
tron
parents:
2219
diff
changeset
|
13 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
14 |
SoundDriver *_sound_driver; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
15 |
MusicDriver *_music_driver; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
16 |
VideoDriver *_video_driver; |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
17 |
|
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
18 |
static const char* GetDriverParam(const char* const* parm, const char* name) |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
19 |
{ |
2458
c95808cd2ac9
(svn r2984) Use adequate types, this should aid portability a bit
tron
parents:
2303
diff
changeset
|
20 |
size_t len; |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
21 |
|
2224
e210db34b7ec
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
22 |
if (parm == NULL) return NULL; |
e210db34b7ec
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
23 |
|
e210db34b7ec
(svn r2742) Get rid of some void pointers plus a few minor changes, like 0 -> '\0'
tron
parents:
2222
diff
changeset
|
24 |
len = strlen(name); |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
25 |
for (; *parm != NULL; parm++) { |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
26 |
const char* p = *parm; |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
27 |
|
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
28 |
if (strncmp(p, name, len) == 0) { |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
29 |
if (p[len] == '=') return p + len + 1; |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
30 |
if (p[len] == '\0') return p + len; |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
31 |
} |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
32 |
} |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
33 |
return NULL; |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
34 |
} |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
35 |
|
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
36 |
bool GetDriverParamBool(const char* const* parm, const char* name) |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
37 |
{ |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
38 |
return GetDriverParam(parm, name) != NULL; |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
39 |
} |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
40 |
|
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
41 |
int GetDriverParamInt(const char* const* parm, const char* name, int def) |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
42 |
{ |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
43 |
const char* p = GetDriverParam(parm, name); |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
44 |
return p != NULL ? atoi(p) : def; |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
diff
changeset
|
45 |
} |