- material = matlib->find(newmat);
- }
- if (!material) {
- SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
- continue;
- }
-
-
- // set material states (lighted & unlighted)
- Effect *lighted_state = material->get_effect();
- Effect *unlighted_state;
- string u = newmat + ".unlighted";
-
- SGMaterial *m = matlib->find(u);
- if (m) {
- unlighted_state = m->get_effect();
- } else {
- SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << u << '\'');
- unlighted_state = lighted_state;
+ SGMaterial *m = matlib->find(newmat);
+ if (!m) {
+ // log error, but keep using previous material to at least show something
+ SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
+ } else {
+ material = m;
+ // set material states (lighted & unlighted)
+ lighted_state = material->get_effect();
+ newmat.append(".unlighted");
+
+ m = matlib->find(newmat);
+ if (m) {
+ unlighted_state = m->get_effect();
+ } else {
+ SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
+ unlighted_state = lighted_state;
+ }
+ }
+ newmat.clear();