Ticket #6513: neverhood-debugmessages.txt

File neverhood-debugmessages.txt, 4.2 KB (added by eriktorbjorn, 10 years ago)
Line 
1diff --git a/engines/neverhood/graphics.cpp b/engines/neverhood/graphics.cpp
2index 939428e..036a56c 100644
3--- a/engines/neverhood/graphics.cpp
4+++ b/engines/neverhood/graphics.cpp
5@@ -113,19 +113,29 @@ void BaseSurface::drawMouseCursorResource(MouseCursorResource &mouseCursorResour
6 }
7 }
8
9-void BaseSurface::copyFrom(Graphics::Surface *sourceSurface, int16 x, int16 y, NDrawRect &sourceRect) {
10+bool BaseSurface::copyFrom(Graphics::Surface *sourceSurface, int16 x, int16 y, NDrawRect &sourceRect) {
11 // Copy a rectangle from sourceSurface, no clipping is performed, 0 is the transparent color
12+ bool result = true;
13 byte *source = (byte*)sourceSurface->getBasePtr(sourceRect.x, sourceRect.y);
14 byte *dest = (byte*)_surface->getBasePtr(x, y);
15 int height = sourceRect.height;
16+ int realY = y;
17 while (height--) {
18 for (int xc = 0; xc < sourceRect.width; xc++)
19- if (source[xc] != 0)
20- dest[xc] = source[xc];
21+ if (source[xc] != 0) {
22+ if (realY >= _surface->h) {
23+ debug("Out of bounds: Y=%d, %dx%d, %dx%d", realY, sourceRect.width, sourceRect.height, _surface->w, _surface->h);
24+ result = false;
25+ } else {
26+ dest[xc] = source[xc];
27+ }
28+ }
29 source += sourceSurface->pitch;
30 dest += _surface->pitch;
31+ realY++;
32 }
33 ++_version;
34+ return result;
35 }
36
37 // ShadowSurface
38@@ -172,7 +182,9 @@ void FontSurface::drawChar(BaseSurface *destSurface, int16 x, int16 y, byte chr)
39 sourceRect.y = (chr / _charsPerRow) * _charHeight;
40 sourceRect.width = _charWidth;
41 sourceRect.height = _charHeight;
42- destSurface->copyFrom(_surface, x, y, sourceRect);
43+ if (!destSurface->copyFrom(_surface, x, y, sourceRect)) {
44+ debug("drawChar: Out of bounds detected while drawing '%c'", chr);
45+ }
46 }
47
48 void FontSurface::drawString(BaseSurface *destSurface, int16 x, int16 y, const byte *string, int stringLen) {
49@@ -200,6 +212,7 @@ FontSurface *FontSurface::createFontSurface(NeverhoodEngine *vm, uint32 fileHash
50 uint16 firstChar = fontData.getPoint(calcHash("meFirstChar")).x;
51 uint16 charWidth = fontData.getPoint(calcHash("meCharWidth")).x;
52 uint16 charHeight = fontData.getPoint(calcHash("meCharHeight")).x;
53+ debug("charWidth = %d, charHeight = %d", charWidth, charHeight);
54 NPointArray *tracking = fontData.getPointArray(calcHash("meTracking"));
55 fontSprite.load(fileHash, true);
56 fontSurface = new FontSurface(vm, tracking, 16, numRows, firstChar, charWidth, charHeight);
57diff --git a/engines/neverhood/graphics.h b/engines/neverhood/graphics.h
58index 12fb2d2..ab4362b 100644
59--- a/engines/neverhood/graphics.h
60+++ b/engines/neverhood/graphics.h
61@@ -93,7 +93,7 @@ public:
62 void drawSpriteResourceEx(SpriteResource &spriteResource, bool flipX, bool flipY, int16 width, int16 height);
63 void drawAnimResource(AnimResource &animResource, uint frameIndex, bool flipX, bool flipY, int16 width, int16 height);
64 void drawMouseCursorResource(MouseCursorResource &mouseCursorResource, int frameNum);
65- void copyFrom(Graphics::Surface *sourceSurface, int16 x, int16 y, NDrawRect &sourceRect);
66+ bool copyFrom(Graphics::Surface *sourceSurface, int16 x, int16 y, NDrawRect &sourceRect);
67 int getPriority() const { return _priority; }
68 void setPriority(int priority) { _priority = priority; }
69 NDrawRect& getDrawRect() { return _drawRect; }
70diff --git a/engines/neverhood/modules/module2200.cpp b/engines/neverhood/modules/module2200.cpp
71index 6618cb3..02719d2 100644
72--- a/engines/neverhood/modules/module2200.cpp
73+++ b/engines/neverhood/modules/module2200.cpp
74@@ -1086,6 +1086,7 @@ void Scene2206::readClickedColumn() {
75 setGlobalVar(V_CLICKED_COLUMN_INDEX, (_mouseClickPos.x - 354) / 96);
76 if (getGlobalVar(V_CLICKED_COLUMN_INDEX) > 2)
77 setGlobalVar(V_CLICKED_COLUMN_INDEX, 2);
78+ debug("Clicked on %d, %d", _mouseClickPos.x, _mouseClickPos.y);
79 setGlobalVar(V_CLICKED_COLUMN_ROW, (_mouseClickPos.y - 183) / 7);
80 setGlobalVar(V_COLUMN_TEXT_NAME, calcHash("stLineagex"));
81 setGlobalVar(V_COLUMN_BACK_NAME, 0);
82@@ -1432,6 +1433,7 @@ void Scene2208::drawRow(int16 rowIndex) {
83 _background->getSurface()->copyFrom(_backgroundSurface->getSurface(), 0, y, sourceRect);
84 if (rowIndex < (int)_strings.size()) {
85 const char *text = _strings[rowIndex];
86+ debug("Row %d: Y=%d - %s", rowIndex, y, text);
87 _fontSurface->drawString(_background->getSurface(), 95, y, (const byte*)text);
88 }
89 }