~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/gfx.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman
  • Date: 2008-08-08 11:07:05 UTC
  • mfrom: (1.1.4 upstream) (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080808110705-zq0eo95c4pexg70i
* New upstream release.
  - Fixes remote crash vulnerability CVE-2008-3547. Closes: #493714

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: gfx.cpp 12335 2008-03-04 12:14:34Z peter1138 $ */
 
1
/* $Id: gfx.cpp 13811 2008-07-23 21:51:25Z rubidium $ */
2
2
 
3
3
/** @file gfx.cpp */
4
4
 
230
230
                        w += GetCharacterWidth(size, c);
231
231
 
232
232
                        if (w >= maxw) {
233
 
                                /* string got too big... insert dotdotdot */
234
 
                                ddd_pos[0] = ddd_pos[1] = ddd_pos[2] = '.';
235
 
                                ddd_pos[3] = '\0';
 
233
                                /* string got too big... insert dotdotdot, but make sure we do not
 
234
                                 * print anything beyond the string termination character. */
 
235
                                for (int i = 0; *ddd_pos != '\0' && i < 3; i++, ddd_pos++) *ddd_pos = '.';
 
236
                                *ddd_pos = '\0';
236
237
                                return ddd_w;
237
238
                        }
238
239
                } else {
239
 
                        if (c == SCC_SETX) str++;
240
 
                        else if (c == SCC_SETXY) str += 2;
241
 
                        else if (c == SCC_TINYFONT) {
 
240
                        if (c == SCC_SETX) {
 
241
                                w = *str;
 
242
                                str++;
 
243
                        } else if (c == SCC_SETXY) {
 
244
                                w = *str;
 
245
                                str += 2;
 
246
                        } else if (c == SCC_TINYFONT) {
242
247
                                size = FS_SMALL;
243
248
                                ddd = GetCharacterWidth(size, '.') * 3;
244
249
                        } else if (c == SCC_BIGFONT) {
669
674
        }
670
675
}
671
676
 
672
 
static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
 
677
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
673
678
{
674
679
        const DrawPixelInfo *dpi = _cur_dpi;
675
680
        Blitter::BlitterParams bp;
695
700
        bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom);
696
701
        bp.top = 0;
697
702
        bp.left = 0;
698
 
        bp.skip_left = UnScaleByZoom(clip_left, dpi->zoom);
699
 
        bp.skip_top = UnScaleByZoom(clip_top, dpi->zoom);
 
703
        bp.skip_left = UnScaleByZoomLower(clip_left, dpi->zoom);
 
704
        bp.skip_top = UnScaleByZoomLower(clip_top, dpi->zoom);
700
705
 
701
706
        x += ScaleByZoom(bp.skip_left, dpi->zoom);
702
707
        y += ScaleByZoom(bp.skip_top, dpi->zoom);
747
752
                if (bp.width <= 0) return;
748
753
        }
749
754
 
 
755
        assert(bp.skip_left + bp.width <= UnScaleByZoom(sprite->width, dpi->zoom));
 
756
        assert(bp.skip_top + bp.height <= UnScaleByZoom(sprite->height, dpi->zoom));
 
757
 
750
758
        BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom);
751
759
}
752
760
 
957
965
        }
958
966
 
959
967
        w = _cursor.size.x;
960
 
        x = _cursor.pos.x + _cursor.offs.x;
 
968
        x = _cursor.pos.x + _cursor.offs.x + _cursor.short_vehicle_offset;
961
969
        if (x < 0) {
962
970
                w += x;
963
971
                x = 0;
985
993
 
986
994
        /* Draw cursor on screen */
987
995
        _cur_dpi = &_screen;
988
 
        DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x, _cursor.pos.y);
 
996
        DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x + _cursor.short_vehicle_offset, _cursor.pos.y);
989
997
 
990
998
        _video_driver->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
991
999
 
1236
1244
        cv->offs.y = p->y_offs;
1237
1245
 
1238
1246
        cv->dirty = true;
 
1247
        cv->short_vehicle_offset = 0;
1239
1248
}
1240
1249
 
1241
1250
static void SwitchAnimatedCursor()