Some set objects (eg, 'al') do not have ZBuffers.

This commit is contained in:
James Brown 2003-08-18 13:59:33 +00:00
parent 7fe43e09c2
commit c6e192d37b
3 changed files with 18 additions and 2 deletions

View File

@ -130,8 +130,14 @@ void Scene::Setup::load(TextSplitter &ts) {
ts.scanString(" background %256s", 1, buf);
bkgnd_bm_ = ResourceLoader::instance()->loadBitmap(buf);
ts.scanString(" zbuffer %256s", 1, buf);
bkgnd_zbm_ = ResourceLoader::instance()->loadBitmap(buf);
// ZBuffer is optional
if (!ts.checkString("zbuffer")) {
bkgnd_zbm_ = NULL;
} else {
ts.scanString(" zbuffer %256s", 1, buf);
bkgnd_zbm_ = ResourceLoader::instance()->loadBitmap(buf);
}
ts.scanString(" position %f %f %f", 3, &pos_.x(), &pos_.y(), &pos_.z());
ts.scanString(" interest %f %f %f", 3, &interest_.x(), &interest_.y(),

View File

@ -50,6 +50,13 @@ TextSplitter::TextSplitter(const char *data, int len) {
processLine();
}
bool TextSplitter::checkString(const char *needle) {
if (std::strstr(currentLine(), needle))
return true;
else
return false;
}
void TextSplitter::expectString(const char *expected) {
if (eof())
error("Expected `%s', got EOF\n", expected);

View File

@ -38,6 +38,9 @@ public:
const char *currentLine() const { return curr_line_; }
bool eof() const { return curr_line_ == NULL; }
// Check if the current line contains 'needle'
bool TextSplitter::checkString(const char *needle);
// Expect a certain fixed string; bail out with an error if not
// found. Advance to the next line.
void expectString(const char *expected);