aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/lights.cpp
diff options
context:
space:
mode:
authorPeter Kohaut2016-09-29 01:15:07 +0200
committerEugene Sandulenko2016-09-29 22:33:42 +0200
commitc7f7341f69b4f1b44c82b3693d7f51d9b570df46 (patch)
tree77b43059b791b51bd311170666126ebc6caec575 /engines/bladerunner/lights.cpp
parentf1cb735ee07c11785f67080ea800a72dd551ae19 (diff)
downloadscummvm-rg350-c7f7341f69b4f1b44c82b3693d7f51d9b570df46.tar.gz
scummvm-rg350-c7f7341f69b4f1b44c82b3693d7f51d9b570df46.tar.bz2
scummvm-rg350-c7f7341f69b4f1b44c82b3693d7f51d9b570df46.zip
BLADERUNNER: fixed lightning
Diffstat (limited to 'engines/bladerunner/lights.cpp')
-rw-r--r--engines/bladerunner/lights.cpp63
1 files changed, 19 insertions, 44 deletions
diff --git a/engines/bladerunner/lights.cpp b/engines/bladerunner/lights.cpp
index 0d6a1be175..e8660a27db 100644
--- a/engines/bladerunner/lights.cpp
+++ b/engines/bladerunner/lights.cpp
@@ -8,9 +8,9 @@ Lights::Lights(BladeRunnerEngine *vm) {
_ambientLightColor.r = 1.0;
_ambientLightColor.g = 0.0;
_ambientLightColor.b = 0.0;
-
- _lights = nullptr;
+
_lightsCount = 0;
+ _lights.clear();
_frame = 0;
}
@@ -42,34 +42,22 @@ void Lights::read(Common::ReadStream *stream, int framesCount) {
light = new Light4();
break;
case 5:
- light = new Light5();
+ light = new LightAmbient();
break;
default:
light = new Light();
}
light->read(stream, framesCount, _frame, 0);
- light->_next = _lights;
- _lights = light;
+ _lights.push_back(light);
}
}
void Lights::removeAnimated() {
- Light **nextLight;
- Light *light;
-
- nextLight = &this->_lights;
- light = this->_lights;
- if (light) {
- do {
- if (light->_animated) {
- *nextLight = light->_next;
- delete light;
- } else {
- nextLight = &light->_next;
- }
- light = *nextLight;
- } while (*nextLight);
+ for (int i = (int)(_lights.size() - 1); i > 0; i--) {
+ if (_lights[i]->_animated) {
+ delete _lights.remove_at(i);
+ }
}
}
@@ -85,7 +73,7 @@ void Lights::readVqa(Common::ReadStream *stream) {
Light *light;
switch (lightType) {
case 5:
- light = new Light5();
+ light = new LightAmbient();
break;
case 4:
light = new Light4();
@@ -101,40 +89,27 @@ void Lights::readVqa(Common::ReadStream *stream) {
break;
default:
light = new Light();
- }
+ }
light->readVqa(stream, framesCount, _frame, 1);
- light->_next = _lights;
- _lights = light;
+ _lights.push_back(light);
}
}
void Lights::setupFrame(int frame) {
- Light *light;
-
- if (frame == _frame)
- return;
-
- if (!_lights)
+ if (frame == _frame) {
return;
+ }
- for (light = _lights; light; light = light->_next) {
- light->setupFrame(frame);
+ for (uint i = 0; i < _lights.size(); i++) {
+ _lights[i]->setupFrame(frame);
}
}
void Lights::reset() {
- Light *light;
- Light *nextLight;
-
- if (!_lights)
- return;
-
- do {
- light = _lights;
- nextLight = light->_next;
- delete light;
- _lights = nextLight;
- } while (nextLight);
+ for (int i = (int)(_lights.size() - 1); i > 0; i--) {
+ delete _lights.remove_at(i);
+ }
+ _lights.clear();
}
} // End of namespace BladeRunner