From 4a88ce37ddfc66d124e0e7bb8f6e3f87f993083a Mon Sep 17 00:00:00 2001 From: johndoe123 Date: Fri, 16 Sep 2011 13:23:03 +0000 Subject: NEVERHOOD: Use InsertKlayman --- engines/neverhood/klayman.cpp | 19 +++++++++-- engines/neverhood/klayman.h | 11 +++---- engines/neverhood/module1000.cpp | 29 ++++++++--------- engines/neverhood/module1200.cpp | 16 ++++----- engines/neverhood/module1300.cpp | 44 +++++++++++-------------- engines/neverhood/module1400.cpp | 34 +++++++++---------- engines/neverhood/module1700.cpp | 12 +++---- engines/neverhood/module2000.cpp | 11 +++---- engines/neverhood/module2200.cpp | 70 ++++++++++++++++++---------------------- engines/neverhood/scene.h | 3 +- 10 files changed, 118 insertions(+), 131 deletions(-) diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index e0ca57ceca..7102870f1e 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -2125,6 +2125,11 @@ KmScene1002::KmScene1002(NeverhoodEngine *vm, Entity *parentScene, int16 x, int1 } +void KmScene1002::init(Sprite *class599, Sprite *ssLadderArch) { + _class599 = class599; + _ssLadderArch = ssLadderArch; +} + void KmScene1002::xUpdate() { if (_x >= 250 && _x <= 435 && _y >= 420) { if (_status == 0) { @@ -2692,14 +2697,18 @@ void KmScene1004::sub478170() { // KmScene1201 -KmScene1201::KmScene1201(NeverhoodEngine *vm, Entity *parentScene, Entity *class464, int16 x, int16 y) - : Klayman(vm, parentScene, x, y, 1000, 1000), _class464(class464), _countdown(0) { +KmScene1201::KmScene1201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) + : Klayman(vm, parentScene, x, y, 1000, 1000), _countdown(0) { // TODO setKlaymanTable(dword_4AEF10, 3); _flagF6 = true; } +void KmScene1201::init(Entity *class464) { + _class464 = class464; +} + uint32 KmScene1201::xHandleMessage(int messageNum, const MessageParam ¶m) { switch (messageNum) { case 0x4001: @@ -3872,7 +3881,7 @@ void KmScene2001::sub440270() { SetMessageHandler(&KmScene2001::handleMessage4401A0); } -KmScene2201::KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, NRect *rect1, int16 unk) +KmScene2201::KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) // TODO: NRect *rect1, int16 unk in Klayman ctor : Klayman(vm, parentScene, x, y, 1000, 1000) { @@ -3880,6 +3889,10 @@ KmScene2201::KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int1 _flagF6 = false; } +void KmScene2201::init(NRect *clipRects, int clipRectsCount) { + // TODO +} + uint32 KmScene2201::xHandleMessage(int messageNum, const MessageParam ¶m) { switch (messageNum) { case 0x4001: diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h index 23bd110568..a25176eefd 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -261,10 +261,7 @@ protected: class KmScene1002 : public Klayman { public: KmScene1002(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); - void init(Sprite *class599, Sprite *ssLadderArch) { - _class599 = class599; - _ssLadderArch = ssLadderArch; - } + void init(Sprite *class599, Sprite *ssLadderArch); protected: Sprite *_class599; Sprite *_ssLadderArch; @@ -310,7 +307,8 @@ protected: class KmScene1201 : public Klayman { public: - KmScene1201(NeverhoodEngine *vm, Entity *parentScene, Entity *class464, int16 x, int16 y); + KmScene1201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); + void init(Entity *class464); protected: Entity *_class464; int _countdown; @@ -431,7 +429,8 @@ protected: class KmScene2201 : public Klayman { public: - KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, NRect *rect1, int16 unk); + KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); + void init(NRect *clipRects, int clipRectsCount); protected: uint32 xHandleMessage(int messageNum, const MessageParam ¶m); }; diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp index 011ea9e1de..7c3c3ba138 100644 --- a/engines/neverhood/module1000.cpp +++ b/engines/neverhood/module1000.cpp @@ -410,27 +410,26 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which) if (which < 0) { setRectList(0x004B49F0); - _klayman = new KmScene1001(_vm, this, 200, 433); + InsertKlayman(KmScene1001, 200, 433); setMessageList(0x004B4888); } else if (which == 1) { setRectList(0x004B49F0); - _klayman = new KmScene1001(_vm, this, 640, 433); + InsertKlayman(KmScene1001, 640, 433); setMessageList(0x004B4898); } else if (which == 2) { setRectList(0x004B49F0); if (getGlobalVar(0xC0418A02)) { - _klayman = new KmScene1001(_vm, this, 390, 433); + InsertKlayman(KmScene1001, 390, 433); _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene1001(_vm, this, 300, 433); + InsertKlayman(KmScene1001, 300, 433); } setMessageList(0x004B4970); } else { setRectList(0x004B4A00); - _klayman = new KmScene1001(_vm, this, 200, 433); + InsertKlayman(KmScene1001, 200, 433); setMessageList(0x004B4890); } - addSprite(_klayman); tempSprite = insertStaticSprite(0x2080A3A8, 1300); @@ -1425,7 +1424,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which) if (which < 0) { if (_vm->_gameState.field2 == 0) { - InsertKlayman(KmScene1002, 90, 226, (_class599, _ssLadderArch)); + InsertKlaymanInitArgs(KmScene1002, 90, 226, (_class599, _ssLadderArch)); _class478 = addSprite(new Class478(_vm, _klayman)); setMessageList(0x004B4270); _klayman->getSurface()->getClipRect().x1 = 31; @@ -1435,7 +1434,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which) _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect(); _klayman->setRepl(64, 0); } else { - InsertKlayman(KmScene1002, 379, 435, (_class599, _ssLadderArch)); + InsertKlaymanInitArgs(KmScene1002, 379, 435, (_class599, _ssLadderArch)); _class478 = addSprite(new Class478(_vm, _klayman)); setMessageList(0x004B4270); _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x; @@ -1445,7 +1444,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which) _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect(); } } else if (which == 1) { - InsertKlayman(KmScene1002, 650, 435, (_class599, _ssLadderArch)); + InsertKlaymanInitArgs(KmScene1002, 650, 435, (_class599, _ssLadderArch)); _class478 = addSprite(new Class478(_vm, _klayman)); setMessageList(0x004B4478); _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x; @@ -1455,7 +1454,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which) _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect(); _vm->_gameState.field2 = 1; } else if (which == 2) { - InsertKlayman(KmScene1002, 68, 645, (_class599, _ssLadderArch)); + InsertKlaymanInitArgs(KmScene1002, 68, 645, (_class599, _ssLadderArch)); _class478 = addSprite(new Class478(_vm, _klayman)); setMessageList(0x004B4298); _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x; @@ -1466,7 +1465,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which) _vm->_gameState.field2 = 1; sendMessage(_klayman, 0x4820, 0); } else { - InsertKlayman(KmScene1002, 90, 226, (_class599, _ssLadderArch)); + InsertKlaymanInitArgs(KmScene1002, 90, 226, (_class599, _ssLadderArch)); _class478 = addSprite(new Class478(_vm, _klayman)); setMessageList(0x004B4470); _klayman->getSurface()->getClipRect().x1 = 31; @@ -1766,20 +1765,18 @@ Scene1004::Scene1004(NeverhoodEngine *vm, Module *parentModule, int which) if (which < 0) { setRectList(0x004B7C70); - _klayman = new KmScene1004(_vm, this, 330, 327); + InsertKlayman(KmScene1004, 330, 327); setMessageList(0x004B7C18); } else if (which == 1) { setRectList(0x004B7C70); - _klayman = new KmScene1004(_vm, this, 330, 327); + InsertKlayman(KmScene1004, 330, 327); setMessageList(0x004B7C08); } else { loadDataResource(0x01900A04); - _klayman = new KmScene1004(_vm, this, _dataResource.getPoint(0x80052A29).x, 27); + InsertKlayman(KmScene1004, _dataResource.getPoint(0x80052A29).x, 27); setMessageList(0x004B7BF0); } - addSprite(_klayman); - updatePaletteArea(); _class478 = addSprite(new Class478(_vm, _klayman)); diff --git a/engines/neverhood/module1200.cpp b/engines/neverhood/module1200.cpp index 5a564ccfa1..212fc874c6 100644 --- a/engines/neverhood/module1200.cpp +++ b/engines/neverhood/module1200.cpp @@ -845,29 +845,29 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which) class464 = addSprite(new Class464(_vm)); if (which < 0) { - _klayman = new KmScene1201(_vm, this, class464, 364, 333); + InsertKlaymanInitArgs(KmScene1201, 364, 333, (class464)); setMessageList(0x004AEC08); } else if (which == 3) { - _klayman = new KmScene1201(_vm, this, class464, 400, 329); + InsertKlaymanInitArgs(KmScene1201, 400, 329, (class464)); setMessageList(0x004AEC08); } else if (which == 2) { if (getGlobalVar(0x0A310817) && !getGlobalVar(0x0A18CA33)) { - _klayman = new KmScene1201(_vm, this, class464, 374, 333); + InsertKlaymanInitArgs(KmScene1201, 374, 333, (class464)); setMessageList(0x004AEC08); } else { - _klayman = new KmScene1201(_vm, this, class464, 640, 329); + InsertKlaymanInitArgs(KmScene1201, 640, 329, (class464)); setMessageList(0x004AEC20); } } else if (which == 1) { if (getGlobalVar(0xC0418A02)) { - _klayman = new KmScene1201(_vm, this, class464, 364, 333); + InsertKlaymanInitArgs(KmScene1201, 364, 333, (class464)); _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene1201(_vm, this, class464, 246, 333); + InsertKlaymanInitArgs(KmScene1201, 246, 333, (class464)); } setMessageList(0x004AEC30); } else { - _klayman = new KmScene1201(_vm, this, class464, 0, 336); + InsertKlaymanInitArgs(KmScene1201, 0, 336, (class464)); setMessageList(0x004AEC10); } @@ -877,8 +877,6 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->getClipRect().y2 = 480; _klayman->setRepl(64, 0); - addSprite(_klayman); - if (getGlobalVar(0x0A310817) && !getGlobalVar(0x0A18CA33)) { _background = addBackground(new DirtyBackground(_vm, 0x4019A2C4, 0, 0)); _palette = new Palette(_vm, 0x4019A2C4); diff --git a/engines/neverhood/module1300.cpp b/engines/neverhood/module1300.cpp index d148018d47..8085eb681c 100644 --- a/engines/neverhood/module1300.cpp +++ b/engines/neverhood/module1300.cpp @@ -664,13 +664,12 @@ Scene1302::Scene1302(NeverhoodEngine *vm, Module *parentModule, int which) _ssFence->getSurface()->getClipRect().y2 = _sprite1->getSurface()->getDrawRect().y + _sprite1->getSurface()->getDrawRect().height; if (which < 0) { -// _klayman = new KmScene1002(_vm, this, _class595, NULL, 380, 364); + InsertKlaymanInitArgs(KmScene1002, 380, 364, (_class595, NULL)); setMessageList(0x004B0868); } else { -// _klayman = new KmScene1002(_vm, this, _class595, NULL, 293, 330); + InsertKlaymanInitArgs(KmScene1002, 293, 330, (_class595, NULL)); setMessageList(0x004B0870); } - addSprite(_klayman); _klayman->getSurface()->getClipRect().x1 = 0; _klayman->getSurface()->getClipRect().y1 = 0; @@ -877,8 +876,7 @@ Scene1303::Scene1303(NeverhoodEngine *vm, Module *parentModule, int which) _sprite1 = insertStaticSprite(0xA014216B, 1100); - _klayman = new KmScene1303(_vm, this, 207, 332); - addSprite(_klayman); + InsertKlayman(KmScene1303, 207, 332); setMessageList(0x004AF9A0); _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x; @@ -963,13 +961,12 @@ Scene1304::Scene1304(NeverhoodEngine *vm, Module *parentModule, int which) insertStaticSprite(0x090AF033, 1100); if (which < 0) { - _klayman = new KmScene1304(_vm, this, 217, 347); + InsertKlayman(KmScene1304, 217, 347); setMessageList(0x004B90E8); } else { - _klayman = new KmScene1304(_vm, this, 100, 347); + InsertKlayman(KmScene1304, 100, 347); setMessageList(0x004B90F0); } - addSprite(_klayman); _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x; _klayman->getSurface()->getClipRect().y1 = 0; @@ -1016,13 +1013,12 @@ Scene1305::Scene1305(NeverhoodEngine *vm, Module *parentModule, int which) _mouseCursor = addSprite(new Mouse433(_vm, 0x01B60280, NULL)); if (which < 0) { - _klayman = new KmScene1305(_vm, this, 212, 441); + InsertKlayman(KmScene1305, 212, 441); setMessageList(0x004B6E40); } else { - _klayman = new KmScene1305(_vm, this, 212, 441); + InsertKlayman(KmScene1305, 212, 441); setMessageList(0x004B6E48); } - addSprite(_klayman); } @@ -1153,45 +1149,45 @@ Scene1306::Scene1306(NeverhoodEngine *vm, Module *parentModule, int which) insertStaticSprite(0x00042313, 1100); if (which < 0) { - _klayman = new KmScene1306(_vm, this, 380, 440); + InsertKlayman(KmScene1306, 380, 440); setMessageList(0x004AFAD0); sendMessage(this, 0x2000, 0); _vm->_collisionMan->addSprite(_asTape); } else if (which == 1) { - _klayman = new KmScene1306(_vm, this, 136, 440); + InsertKlayman(KmScene1306, 136, 440); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004AFAF0); sendMessage(this, 0x2000, 1); _vm->_collisionMan->addSprite(_asTape); } else if (which == 2) { if (getGlobalVar(0xC0418A02)) { - _klayman = new KmScene1306(_vm, this, 515, 440); + InsertKlayman(KmScene1306, 515, 440); _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene1306(_vm, this, 355, 440); + InsertKlayman(KmScene1306, 355, 440); } setMessageList(0x004AFBC8); sendMessage(this, 0x2000, 0); _vm->_collisionMan->addSprite(_asTape); } else if (which == 3) { - _klayman = new KmScene1306(_vm, this, 534, 440); + InsertKlayman(KmScene1306, 534, 440); setMessageList(0x004AFC30); sendMessage(this, 0x2000, 0); _vm->_collisionMan->addSprite(_asTape); } else if (which == 4) { - _klayman = new KmScene1306(_vm, this, 136, 440); + InsertKlayman(KmScene1306, 136, 440); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004AFC38); sendMessage(this, 0x2000, 1); _vm->_collisionMan->addSprite(_asTape); } else if (which == 5) { - _klayman = new KmScene1306(_vm, this, 136, 440); + InsertKlayman(KmScene1306, 136, 440); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004AFB00); sendMessage(this, 0x2000, 1); _vm->_collisionMan->addSprite(_asTape); } else { - _klayman = new KmScene1306(_vm, this, 286, 408); + InsertKlayman(KmScene1306, 286, 408); setSurfacePriority(_asElevator->getSurface(), 1100); setSurfacePriority(_asElevatorDoor->getSurface(), 1090); setSurfacePriority(_sprite1->getSurface(), 1080); @@ -1200,7 +1196,6 @@ Scene1306::Scene1306(NeverhoodEngine *vm, Module *parentModule, int which) clearRectList(); sendMessage(_asElevator, 0x4808, 0); } - addSprite(_klayman); } @@ -1879,7 +1874,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) _sprite4 = NULL; if (which < 0) { - _klayman = new KmScene1308(_vm, this, 380, 440); + InsertKlayman(KmScene1308, 380, 440); setMessageList(0x004B57C0); if (getGlobalVar(0x80455A41)) { _sprite4 = insertStaticSprite(0x0101A624, 1100); @@ -1889,7 +1884,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) setRectList(0x004B5980); } } else if (which == 1) { - _klayman = new KmScene1308(_vm, this, 640, 440); + InsertKlayman(KmScene1308, 640, 440); setMessageList(0x004B57C8); if (getGlobalVar(0x80455A41)) { _sprite4 = insertStaticSprite(0x0101A624, 1100); @@ -1899,7 +1894,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) setRectList(0x004B5980); } } else if (which == 2) { - _klayman = new KmScene1308(_vm, this, 475, 440); + InsertKlayman(KmScene1308, 475, 440); setMessageList(0x004B58B0); if (getGlobalVar(0x80455A41)) { _sprite5 = addSprite(new Class592(_vm, this)); @@ -1910,7 +1905,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) setRectList(0x004B5980); } } else { - _klayman = new KmScene1308(_vm, this, 41, 440); + InsertKlayman(KmScene1308, 41, 440); setMessageList(0x004B57D0); sendMessage(_class549, 0x4808, 0); _sprite1->getSurface()->setVisible(false); @@ -1922,7 +1917,6 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->setVisible(false); } } - addSprite(_klayman); if (_sprite4) { _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x; diff --git a/engines/neverhood/module1400.cpp b/engines/neverhood/module1400.cpp index 5dc74787a1..b4f07447d1 100644 --- a/engines/neverhood/module1400.cpp +++ b/engines/neverhood/module1400.cpp @@ -777,23 +777,22 @@ Scene1401::Scene1401(NeverhoodEngine *vm, Module *parentModule, int which) _sprite2->getSurface()->setVisible(false); if (which < 0) { - _klayman = new KmScene1401(_vm, this, 380, 447); + InsertKlayman(KmScene1401, 380, 447); setMessageList(0x004B65C8); _sprite1->getSurface()->setVisible(false); } else if (which == 1) { - _klayman = new KmScene1401(_vm, this, 0, 447); + InsertKlayman(KmScene1401, 0, 447); setMessageList(0x004B65D0); _sprite1->getSurface()->setVisible(false); } else if (which == 2) { - _klayman = new KmScene1401(_vm, this, 660, 447); + InsertKlayman(KmScene1401, 660, 447); setMessageList(0x004B65D8); _sprite1->getSurface()->setVisible(false); } else { - _klayman = new KmScene1401(_vm, this, 290, 413); + InsertKlayman(KmScene1401, 290, 413); setMessageList(0x004B65E8); _sprite1->getSurface()->setVisible(false); } - addSprite(_klayman); if (getGlobalVar(0x04A105B3) == 2) { _class489 = addSprite(new Class489(_vm, this, _klayman, _class525)); @@ -994,16 +993,16 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which) setRectList(0x004B0C98); if (which < 0) { - _klayman = new KmScene1402(_vm, this, 377, 391); + InsertKlayman(KmScene1402, 377, 391); setMessageList(0x004B0B48); if (!getGlobalVar(0x70A1189C)) { _class482 = addSprite(new Class482(_vm, this, 0)); } } else if (which == 1) { - _klayman = new KmScene1402(_vm, this, 42, 391); + InsertKlayman(KmScene1402, 42, 391); setMessageList(0x004B0B50); } else if (which == 2) { - _klayman = new KmScene1402(_vm, this, 377, 391); + InsertKlayman(KmScene1402, 377, 391); setMessageList(0x004B0B60); _klayman->setDoDeltaX(1); if (getGlobalVar(0x70A1189C)) { @@ -1015,14 +1014,13 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which) _class482 = addSprite(new Class482(_vm, this, 0)); } } else { - _klayman = new KmScene1402(_vm, this, 513, 391); + InsertKlayman(KmScene1402, 513, 391); setMessageList(0x004B0B58); if (!getGlobalVar(0x70A1189C)) { _class482 = addSprite(new Class482(_vm, this, 2)); sub428220(); } } - addSprite(_klayman); if (_class482) { _class482->getSurface()->getClipRect().x1 = 0; @@ -1471,13 +1469,12 @@ Scene1403::Scene1403(NeverhoodEngine *vm, Module *parentModule, int which) _asTape2->setRepl(64, 0); if (which < 0) { - _klayman = new KmScene1403(_vm, this, 380, 463); + InsertKlayman(KmScene1403, 380, 463); setMessageList(0x004B1F18); } else { - _klayman = new KmScene1403(_vm, this, 640, 463); + InsertKlayman(KmScene1403, 640, 463); setMessageList(0x004B1F20); } - addSprite(_klayman); _klayman->setRepl(64, 0); if (getGlobalVar(0x04A105B3) == 4) { @@ -1589,24 +1586,23 @@ Scene1404::Scene1404(NeverhoodEngine *vm, Module *parentModule, int which) _vm->_collisionMan->addSprite(_asTape); if (which < 0) { - _klayman = new KmScene1404(_vm, this, 376, 406); + InsertKlayman(KmScene1404, 376, 406); setMessageList(0x004B8C28); } else if (which == 1) { - _klayman = new KmScene1404(_vm, this, 376, 406); + InsertKlayman(KmScene1404, 376, 406); setMessageList(0x004B8C30); } else if (which == 2) { if (getGlobalVar(0xC0418A02)) { - _klayman = new KmScene1404(_vm, this, 347, 406); + InsertKlayman(KmScene1404, 347, 406); _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene1404(_vm, this, 187, 406); + InsertKlayman(KmScene1404, 187, 406); } setMessageList(0x004B8D28); } else { - _klayman = new KmScene1404(_vm, this, 30, 406); + InsertKlayman(KmScene1404, 30, 406); setMessageList(0x004B8C38); } - addSprite(_klayman); if (getGlobalVar(0x04A105B3) == 3) { _class489 = addSprite(new Class489(_vm, this, _klayman, 0)); diff --git a/engines/neverhood/module1700.cpp b/engines/neverhood/module1700.cpp index 30fe95297b..43a30f9b22 100644 --- a/engines/neverhood/module1700.cpp +++ b/engines/neverhood/module1700.cpp @@ -262,7 +262,7 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which) which = 4; if (which < 0) { - _klayman = new KmScene1705(_vm, this, 231, 434); + InsertKlayman(KmScene1705, 231, 434); setMessageList(0x004B69E8); sendMessage(this, 0x2000, 0); _klayman->getSurface()->getClipRect().x1 = 0; @@ -270,7 +270,7 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width; _klayman->getSurface()->getClipRect().y2 = 480; } else if (which == 1) { - _klayman = new KmScene1705(_vm, this, 431, 434); + InsertKlayman(KmScene1705, 431, 434); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004B6A08); sendMessage(this, 0x2000, 1); @@ -279,7 +279,7 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width; _klayman->getSurface()->getClipRect().y2 = 480; } else if (which == 2) { - _klayman = new KmScene1705(_vm, this, 431, 434); + InsertKlayman(KmScene1705, 431, 434); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004B6AA0); sendMessage(this, 0x2000, 1); @@ -288,7 +288,7 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width; _klayman->getSurface()->getClipRect().y2 = 480; } else if (which == 3) { - _klayman = new KmScene1705(_vm, this, 431, 434); + InsertKlayman(KmScene1705, 431, 434); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004B6A18); sendMessage(this, 0x2000, 1); @@ -297,7 +297,7 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width; _klayman->getSurface()->getClipRect().y2 = 480; } else { - _klayman = new KmScene1705(_vm, this, 231, 74); + InsertKlayman(KmScene1705, 231, 74); sendMessage(_klayman, 0x2000, 0); setMessageList(0x004B69F0); sendMessage(this, 0x2000, 0); @@ -308,8 +308,6 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which) _klayman->getSurface()->getClipRect().y2 = 480; } - addSprite(_klayman); - } void Scene1705::update() { diff --git a/engines/neverhood/module2000.cpp b/engines/neverhood/module2000.cpp index ecd4e705a3..bca54eb1f0 100644 --- a/engines/neverhood/module2000.cpp +++ b/engines/neverhood/module2000.cpp @@ -142,31 +142,30 @@ Scene2001::Scene2001(NeverhoodEngine *vm, Module *parentModule, int which) _class401 = insertStaticSprite(0x0D641724, 1100); if (which < 0) { - _klayman = new KmScene2001(_vm, this, 300, 345); + InsertKlayman(KmScene2001, 300, 345); setMessageList(0x004B3538); sendMessage(this, 0x2000, 0); } else if (which == 1) { - _klayman = new KmScene2001(_vm, this, 116, 345); + InsertKlayman(KmScene2001, 116, 345); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004B3540); sendMessage(this, 0x2000, 1); } else if (which == 2) { - _klayman = new KmScene2001(_vm, this, 116, 345); + InsertKlayman(KmScene2001, 116, 345); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004B35F0); sendMessage(this, 0x2000, 1); } else if (which == 3) { - _klayman = new KmScene2001(_vm, this, 116, 345); + InsertKlayman(KmScene2001, 116, 345); sendMessage(_klayman, 0x2000, 1); setMessageList(0x004B3550); sendMessage(this, 0x2000, 1); } else { - _klayman = new KmScene2001(_vm, this, 390, 345); + InsertKlayman(KmScene2001, 390, 345); setMessageList(0x004B3530); sendMessage(this, 0x2000, 0); _klayman->setDoDeltaX(1); } - addSprite(_klayman); _klayman->getSurface()->getClipRect().x1 = _class401->getSurface()->getDrawRect().x; _klayman->getSurface()->getClipRect().y1 = 0; diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp index 3faad252bc..27fb21ac6f 100644 --- a/engines/neverhood/module2200.cpp +++ b/engines/neverhood/module2200.cpp @@ -1547,29 +1547,28 @@ Scene2201::Scene2201(NeverhoodEngine *vm, Module *parentModule, int which) _doorLightSprite = insertStaticSprite(0xA4062212, 900); if (which < 0) { - _klayman = new KmScene2201(_vm, this, 300, 427, &_rect1, 2); + InsertKlaymanInitArgs(KmScene2201, 300, 427, (&_rect1, 2)); setMessageList(0x004B8118); _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, false)); } else if (which == 1) { - _klayman = new KmScene2201(_vm, this, 412, 393, &_rect1, 2); + InsertKlaymanInitArgs(KmScene2201, 412, 393, (&_rect1, 2)); setMessageList(0x004B8130); _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, false)); } else if (which == 2) { if (getGlobalVar(0xC0418A02)) { - _klayman = new KmScene2201(_vm, this, 379, 427, &_rect1, 2); + InsertKlaymanInitArgs(KmScene2201, 379, 427, (&_rect1, 2)); _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene2201(_vm, this, 261, 427, &_rect1, 2); + InsertKlaymanInitArgs(KmScene2201, 261, 427, (&_rect1, 2)); } setMessageList(0x004B8178); _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, false)); } else { NPoint pt = _dataResource.getPoint(0x0304D8DC); - _klayman = new KmScene2201(_vm, this, pt.x, pt.y, &_rect1, 2); + InsertKlaymanInitArgs(KmScene2201, pt.x, pt.y, (&_rect1, 2)); setMessageList(0x004B8120); _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, true)); } - addSprite(_klayman); addSprite(new AsScene2201CeilingFan(_vm)); @@ -2162,24 +2161,23 @@ Scene2203::Scene2203(NeverhoodEngine *vm, Module *parentModule, int which) _vm->_collisionMan->addSprite(_asRightDoor); if (which < 0) { - _klayman = new KmScene2203(_vm, this, 200, 427); + InsertKlayman(KmScene2203, 200, 427); setMessageList(0x004B8340); } else if (which == 1) { - _klayman = new KmScene2203(_vm, this, 640, 427); + InsertKlayman(KmScene2203, 640, 427); setMessageList(0x004B8350); } else if (which == 2) { if (getGlobalVar(0xC0418A02)) { - _klayman = new KmScene2203(_vm, this, 362, 427); + InsertKlayman(KmScene2203, 362, 427); _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene2203(_vm, this, 202, 427); + InsertKlayman(KmScene2203, 202, 427); } setMessageList(0x004B8358); } else { - _klayman = new KmScene2203(_vm, this, 0, 427); + InsertKlayman(KmScene2203, 0, 427); setMessageList(0x004B8348); } - addSprite(_klayman); if (getGlobalVar(0x9A500914)) { _ssSmallLeftDoor->getSurface()->setVisible(false); @@ -2315,25 +2313,24 @@ Scene2205::Scene2205(NeverhoodEngine *vm, Module *parentModule, int which) _ssDoorFrame = addSprite(new SsScene2205DoorFrame(_vm)); if (which < 0) { - _klayman = new KmScene2205(_vm, this, 320, 417); + InsertKlayman(KmScene2205, 320, 417); setMessageList(0x004B0658); if (!getGlobalVar(0x4D080E54)) { _palette->addPalette(0x68033B1C, 0, 65, 0); } _isKlaymanInLight = false; } else if (which == 1) { - _klayman = new KmScene2205(_vm, this, 640, 417); + InsertKlayman(KmScene2205, 640, 417); setMessageList(0x004B0648); if (!getGlobalVar(0x4D080E54)) { _palette->addPalette(0x68033B1C, 0, 65, 0); } _isKlaymanInLight = false; } else { - _klayman = new KmScene2205(_vm, this, 0, 417); + InsertKlayman(KmScene2205, 0, 417); setMessageList(0x004B0640); _isKlaymanInLight = true; } - addSprite(_klayman); _klayman->getSurface()->getClipRect().x1 = _ssDoorFrame->getSurface()->getDrawRect().x; _klayman->getSurface()->getClipRect().y1 = 0; @@ -2606,27 +2603,26 @@ Scene2206::Scene2206(NeverhoodEngine *vm, Module *parentModule, int which) _vm->_collisionMan->addSprite(_class607); if (which < 0) { - _klayman = new KmScene2206(_vm, this, 200, 430); + InsertKlayman(KmScene2206, 200, 430); setMessageList(0x004B88A8); } else if (which == 1) { - _klayman = new KmScene2206(_vm, this, 640, 430); + InsertKlayman(KmScene2206, 640, 430); setMessageList(0x004B88B8); } else if (which == 2) { - _klayman = new KmScene2206(_vm, this, 205, 396); + InsertKlayman(KmScene2206, 205, 396); setMessageList(0x004B88C8); _palette->addPalette(getGlobalVar(0x4D080E54) ? 0xB103B604 : 0x0263D144, 0, 65, 0); sub4819D0(); _soundResource.play(0x53B8284A); } else if (which == 3) { - _klayman = new KmScene2206(_vm, this, kScene2206XPositions[getGlobalVar(0x48A68852)], 430); + InsertKlayman(KmScene2206, kScene2206XPositions[getGlobalVar(0x48A68852)], 430); if (getGlobalVar(0xC0418A02)) _klayman->setDoDeltaX(1); setMessageList(0x004B8A70); } else { - _klayman = new KmScene2206(_vm, this, 0, 430); + InsertKlayman(KmScene2206, 0, 430); setMessageList(0x004B88B0); } - addSprite(_klayman); _klayman->setSoundFlag(true); _klayman->setKlaymanTable2(); @@ -3069,8 +3065,7 @@ Scene2207::Scene2207(NeverhoodEngine *vm, Module *parentModule, int which) SetUpdateHandler(&Scene2207::update); _surfaceFlag = true; - _klayman = new KmScene2207(_vm, this, 0, 0); // CHECKME: Stack vars are uninitialized?! - addSprite(_klayman); + InsertKlayman(KmScene2207, 0, 0); _klayman->setRepl(64, 0); setMessageList(0x004B38E8); @@ -3518,21 +3513,20 @@ Scene2242::Scene2242(NeverhoodEngine *vm, Module *parentModule, int which) _vm->_collisionMan->addSprite(_asTape); if (which < 0) { - _klayman = new KmScene2242(_vm, this, 200, 430); + InsertKlayman(KmScene2242, 200, 430); setMessageList(0x004B3C18); } else if (which == 1) { - _klayman = new KmScene2242(_vm, this, 530, 430); + InsertKlayman(KmScene2242, 530, 430); setMessageList(0x004B3D60); } else if (which == 2) { - _klayman = new KmScene2242(_vm, this, kScene2242XPositions[!getGlobalVar(0x48A68852) ? 0 : 1], 430); + InsertKlayman(KmScene2242, kScene2242XPositions[!getGlobalVar(0x48A68852) ? 0 : 1], 430); setMessageList(0x004B3D48); if (getGlobalVar(0xC0418A02)) _klayman->setDoDeltaX(1); } else { - _klayman = new KmScene2242(_vm, this, 0, 430); + InsertKlayman(KmScene2242, 0, 430); setMessageList(0x004B3C20); } - addSprite(_klayman); _klayman->setSoundFlag(true); @@ -3650,21 +3644,20 @@ HallOfRecordsScene::HallOfRecordsScene(NeverhoodEngine *vm, Module *parentModule } if (which < 0) { - _klayman = new KmHallOfRecords(_vm, this, 200, 430); + InsertKlayman(KmHallOfRecords, 200, 430); setMessageList(0x004B2900); } else if (which == 1) { - _klayman = new KmHallOfRecords(_vm, this, 640, 430); + InsertKlayman(KmHallOfRecords, 640, 430); setMessageList(0x004B2910); } else if (which == 2) { - _klayman = new KmHallOfRecords(_vm, this, kHallOfRecordsKlaymanXPos[getGlobalVar(0x48A68852) - _sceneInfo140->xPosIndex], 430); + InsertKlayman(KmHallOfRecords, kHallOfRecordsKlaymanXPos[getGlobalVar(0x48A68852) - _sceneInfo140->xPosIndex], 430); setMessageList(0x004B2B70); if (getGlobalVar(0xC0418A02)) _klayman->setDoDeltaX(1); } else { - _klayman = new KmHallOfRecords(_vm, this, 0, 430); + InsertKlayman(KmHallOfRecords, 0, 430); setMessageList(0x004B2908); } - addSprite(_klayman); _klayman->setSoundFlag(true); _klayman->setKlaymanTable2(); @@ -3748,21 +3741,20 @@ Scene2247::Scene2247(NeverhoodEngine *vm, Module *parentModule, int which) } if (which < 0) { - _klayman = new KmScene2247(_vm, this, 200, 430); + InsertKlayman(KmScene2247, 200, 430); setMessageList(0x004B5428); } else if (which == 1) { - _klayman = new KmScene2247(_vm, this, 640, 430); + InsertKlayman(KmScene2247, 640, 430); setMessageList(0x004B5438); } else if (which == 2) { - _klayman = new KmScene2247(_vm, this, kScene2247XPositions[getGlobalVar(0xC8C28808) == 0x0008E486 ? 0 : 1], 430); + InsertKlayman(KmScene2247, kScene2247XPositions[getGlobalVar(0xC8C28808) == 0x0008E486 ? 0 : 1], 430); if (getGlobalVar(0xC0418A02)) _klayman->setDoDeltaX(1); setMessageList(0x004B5530); } else { - _klayman = new KmScene2247(_vm, this, 0, 430); + InsertKlayman(KmScene2247, 0, 430); setMessageList(0x004B5430); } - addSprite(_klayman); _klayman->setSoundFlag(true); diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h index 067e86f5fc..9b928bb19c 100644 --- a/engines/neverhood/scene.h +++ b/engines/neverhood/scene.h @@ -37,7 +37,8 @@ namespace Neverhood { -#define InsertKlayman(KlaymanClass, X, Y, InitArgs) _klayman = new KlaymanClass(_vm, this, X, Y); ((KlaymanClass*)_klayman)->init InitArgs; addSprite(_klayman) +#define InsertKlayman(KlaymanClass, X, Y) _klayman = new KlaymanClass(_vm, this, X, Y); addSprite(_klayman) +#define InsertKlaymanInitArgs(KlaymanClass, X, Y, InitArgs) _klayman = new KlaymanClass(_vm, this, X, Y); ((KlaymanClass*)_klayman)->init InitArgs; addSprite(_klayman) class Scene : public Entity { public: -- cgit v1.2.3