Skip to content

Commit

Permalink
moved into config manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aquadran committed Jul 31, 2008
1 parent 211d03b commit c629b26
Show file tree
Hide file tree
Showing 19 changed files with 798 additions and 212 deletions.
6 changes: 4 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ By default, the configuration file is saved in, and loaded from:
residual.ini in the current directory

An example config file looks as follows:
[residual]

DataDir=[path to all the .lab files]
good_times=TRUE
[grim]
path=[path to all the .lab files]
game_devel_mode=TRUE

It runs really slow when using -zbuffer!
----------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions common/config-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ bool ConfigFile::saveToStream(WriteStream &stream) {
stream.writeByte('[');
stream.writeString(i->name);
stream.writeByte(']');
#ifdef _WIN32
stream.writeByte(0x0d);
stream.writeByte(0x0a);
#else
stream.writeByte('\n');
#endif

// Write out the key/value pairs
for (List<KeyValue>::iterator kv = i->keys.begin(); kv != i->keys.end(); ++kv) {
Expand All @@ -215,7 +220,12 @@ bool ConfigFile::saveToStream(WriteStream &stream) {
stream.writeString(kv->key);
stream.writeByte('=');
stream.writeString(kv->value);
#ifdef _WIN32
stream.writeByte(0x0d);
stream.writeByte(0x0a);
#else
stream.writeByte('\n');
#endif
}
}

Expand Down
20 changes: 19 additions & 1 deletion common/config-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "common/config-manager.h"
#include "common/file.h"
#include "common/util.h"
#include "common/debug.h"

DECLARE_SINGLETON(Common::ConfigManager);

Expand Down Expand Up @@ -173,7 +172,11 @@ void ConfigManager::loadFile(const String &filename) {

// Read a line
String line;
#ifdef _WIN32
while (line.lastChar() != 0x0a) {
#else
while (line.lastChar() != '\n') {
#endif
char buf[MAXLINELEN];
if (!cfg_file.readLine_NEW(buf, MAXLINELEN))
break;
Expand Down Expand Up @@ -324,7 +327,12 @@ void ConfigManager::writeDomain(WriteStream &stream, const String &name, const D
stream.writeByte('[');
stream.writeString(name);
stream.writeByte(']');
#ifdef _WIN32
stream.writeByte(0x0d);
stream.writeByte(0x0a);
#else
stream.writeByte('\n');
#endif

// Write all key/value pairs in this domain, including comments
Domain::const_iterator x;
Expand All @@ -339,10 +347,20 @@ void ConfigManager::writeDomain(WriteStream &stream, const String &name, const D
stream.writeString(x->_key);
stream.writeByte('=');
stream.writeString(x->_value);
#ifdef _WIN32
stream.writeByte(0x0d);
stream.writeByte(0x0a);
#else
stream.writeByte('\n');
#endif
}
}
#ifdef _WIN32
stream.writeByte(0x0d);
stream.writeByte(0x0a);
#else
stream.writeByte('\n');
#endif
}


Expand Down
12 changes: 12 additions & 0 deletions common/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ extern "C" int residual_main(int argc, char *argv[]);
#endif
#endif

//
// GCC specific stuff
//
#if defined(__GNUC__)
#define NORETURN __attribute__((__noreturn__))
#define PACKED_STRUCT __attribute__((packed))
#define GCC_PRINTF(x, y) __attribute__((format(printf, x, y)))
#else
#define PACKED_STRUCT
#define GCC_PRINTF(x, y)
#endif

//
// Fallbacks / default values for various special macros
//
Expand Down
4 changes: 4 additions & 0 deletions common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "common/sys.h"
#include "common/debug.h"

#if defined(WIN32)
#include <windows.h>
#endif

#ifdef MIN
#undef MIN
#endif
Expand Down
6 changes: 6 additions & 0 deletions dists/msvc7/residual.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@
<File
RelativePath="..\..\engine\bitmap.h">
</File>
<File
RelativePath="..\..\engine\cmd_line.cpp">
</File>
<File
RelativePath="..\..\engine\cmd_line.h">
</File>
<File
RelativePath="..\..\engine\color.h">
</File>
Expand Down
6 changes: 6 additions & 0 deletions dists/msvc71/residual.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@
<File
RelativePath="..\..\engine\bitmap.h">
</File>
<File
RelativePath="..\..\engine\cmd_line.cpp">
</File>
<File
RelativePath="..\..\engine\cmd_line.h">
</File>
<File
RelativePath="..\..\engine\color.h">
</File>
Expand Down
8 changes: 8 additions & 0 deletions dists/msvc8/residual.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@
RelativePath="..\..\engine\bitmap.h"
>
</File>
<File
RelativePath="..\..\engine\cmd_line.cpp"
>
</File>
<File
RelativePath="..\..\engine\cmd_line.h"
>
</File>
<File
RelativePath="..\..\engine\color.h"
>
Expand Down
8 changes: 8 additions & 0 deletions dists/msvc9/residual.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@
RelativePath="..\..\engine\bitmap.h"
>
</File>
<File
RelativePath="..\..\engine\cmd_line.cpp"
>
</File>
<File
RelativePath="..\..\engine\cmd_line.h"
>
</File>
<File
RelativePath="..\..\engine\color.h"
>
Expand Down
8 changes: 6 additions & 2 deletions dists/residual.ini.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
DataDir=C:\Games\Grim
good_times=TRUE
[residual]

[grim]
path=C:\Games\Grim
show_fps=TRUE
game_devel_mode=TRUE
Loading

0 comments on commit c629b26

Please sign in to comment.