diff options
author | Filippos Karapetis | 2009-09-04 15:04:13 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-09-04 15:04:13 +0000 |
commit | 32af5eb3bedd5c17cb73e59760f30278b0f03a8b (patch) | |
tree | 0768d1af4266cc41f0481543be4d0005fc828e7c | |
parent | dd0ebb71161de842fd376485a0abb0dc51865e65 (diff) | |
download | scummvm-rg350-32af5eb3bedd5c17cb73e59760f30278b0f03a8b.tar.gz scummvm-rg350-32af5eb3bedd5c17cb73e59760f30278b0f03a8b.tar.bz2 scummvm-rg350-32af5eb3bedd5c17cb73e59760f30278b0f03a8b.zip |
- Removed the gfx error defines. When resources are not found, or are corrupted, we should error out instead of piggy-banking an error flag to another function
- Do not try and set the position of the mouse cursor when it's hidden
svn-id: r43941
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 86 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_gui.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 15 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 4 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_support.cpp | 18 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_system.h | 8 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.h | 4 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 13 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 53 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 17 | ||||
-rw-r--r-- | engines/sci/gfx/res_font.cpp | 12 |
11 files changed, 66 insertions, 170 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 7cc80bee3f..4287bf37a8 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -300,7 +300,7 @@ static reg_t kSetCursorSci0(EngineState *s, int, int argc, reg_t *argv) { gfxop_set_pointer_cursor(s->gfx_state, cursor); // Set pointer position, if requested - if (argc >= 4) { + if (argc >= 4 && cursor != GFXOP_NO_POINTER) { Common::Point newPos = Common::Point(argv[2].toSint16() + s->port->_bounds.x, argv[3].toSint16() + s->port->_bounds.y); gfxop_set_pointer_position(s->gfx_state, newPos); } @@ -710,10 +710,7 @@ void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) maxloops = gfxop_lookup_view_get_loops(s->gfx_state, view); - if (maxloops == GFX_ERROR) { - error("Invalid view.%03d", view); - return; - } else if ((loop > 1) && (maxloops < 4)) + if ((loop > 1) && (maxloops < 4)) return; PUT_SEL32V(obj, loop, loop); @@ -900,11 +897,8 @@ reg_t kCelHigh(EngineState *s, int, int argc, reg_t *argv) { warning("CelHigh called with %d parameters", argc); } - if (gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset)) { - error("Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid", loop, cel, view, view); - return NULL_REG; - } else - return make_reg(0, height); + gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset); + return make_reg(0, height); } reg_t kCelWide(EngineState *s, int, int argc, reg_t *argv) { @@ -918,11 +912,8 @@ reg_t kCelWide(EngineState *s, int, int argc, reg_t *argv) { warning("CelHigh called with %d parameters", argc); } - if (gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset)) { - error("Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid", loop, cel, view, view); - return NULL_REG; - } else - return make_reg(0, width); + gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset); + return make_reg(0, width); } reg_t kNumLoops(EngineState *s, int, int argc, reg_t *argv) { @@ -948,12 +939,7 @@ reg_t kNumCels(EngineState *s, int, int argc, reg_t *argv) { int view = GET_SEL32V(obj, view); int cel = 0xffff; - if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { - // OK, this is a hack and there's a - // real function to calculate cel numbers... - error("view.%d (0x%x) not found", view, view); - return NULL_REG; - } + gfxop_check_cel(s->gfx_state, view, &loop, &cel); debugC(2, kDebugLevelGraphics, "NumCels(view.%d, %d) = %d\n", view, loop, cel + 1); @@ -1085,27 +1071,23 @@ Common::Rect set_base(EngineState *s, reg_t object) { oldloop = loop = sign_extend_byte(GET_SEL32V(object, loop)); oldcel = cel = sign_extend_byte(GET_SEL32V(object, cel)); - if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { - xsize = ysize = xmod = ymod = 0; - } else { - Common::Point offset = Common::Point(0, 0); + Common::Point offset = Common::Point(0, 0); - if (loop != oldloop) { - loop = 0; - PUT_SEL32V(object, loop, 0); - debugC(2, kDebugLevelGraphics, "Resetting loop for %04x:%04x!\n", PRINT_REG(object)); - } + if (loop != oldloop) { + loop = 0; + PUT_SEL32V(object, loop, 0); + debugC(2, kDebugLevelGraphics, "Resetting loop for %04x:%04x!\n", PRINT_REG(object)); + } - if (cel != oldcel) { - cel = 0; - PUT_SEL32V(object, cel, 0); - } + if (cel != oldcel) { + cel = 0; + PUT_SEL32V(object, cel, 0); + } - gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); + gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); - xmod = offset.x; - ymod = offset.y; - } + xmod = offset.x; + ymod = offset.y; xbase = x - xmod - (xsize >> 1); xend = xbase + xsize; @@ -1176,16 +1158,12 @@ static Common::Rect calculate_nsrect(EngineState *s, int x, int y, int view, int int xmod = 0, ymod = 0; Common::Rect retval(0, 0, 0, 0); - if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { - xsize = ysize = xmod = ymod = 0; - } else { - Common::Point offset = Common::Point(0, 0); + Common::Point offset = Common::Point(0, 0); - gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); + gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); - xmod = offset.x; - ymod = offset.y; - } + xmod = offset.x; + ymod = offset.y; xbase = x - xmod - (xsize >> 1); xend = xbase + xsize; @@ -1913,9 +1891,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i palette = 0; // Clip loop and cel, write back if neccessary - if (gfxop_check_cel(s->gfx_state, view_nr, &loop, &cel)) { - return NULL; - } + gfxop_check_cel(s->gfx_state, view_nr, &loop, &cel); if (loop != oldloop) loop = 0; @@ -2421,17 +2397,7 @@ reg_t kDrawCel(EngineState *s, int, int argc, reg_t *argv) { int priority = (argc > 5) ? argv[5].toSint16() : -1; GfxView *new_view; -/* - if (!view) { - error("Attempt to draw non-existing view.%03d", view); - return; - } -*/ - - if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { - error("Attempt to draw non-existing view.%03d", view); - return s->r_acc; - } + gfxop_check_cel(s->gfx_state, view, &loop, &cel); debugC(2, kDebugLevelGraphics, "DrawCel((%d,%d), (view.%d, %d, %d), p=%d)\n", x, y, view, loop, cel, priority); diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index 2659704d7e..b4479b7341 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -455,12 +455,6 @@ GfxList *sciw_new_list_control(GfxPort *port, reg_t ID, rect_t zone, int font_nr font_height = gfxop_get_font_height(port->_visual->_gfxState, font_nr); columns = (zone.height - 20); - if (font_height <= 0) { - error("Attempt to create list control with invalid font %d", font_nr); - delete list; - return NULL; - } - columns /= font_height; gfxw_set_id(list, ID.segment, ID.offset); diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 12551fa0f9..940fed21d6 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -76,7 +76,7 @@ GfxResManager::~GfxResManager() { _staticPalette = 0; } -int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr) { +void GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr) { Resource *res = _resMan->findResource(ResourceId(kResourceTypePic, nr), 0); int need_unscaled = unscaled_pic != NULL; gfxr_pic0_params_t style, basic_style; @@ -93,7 +93,7 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic #endif if (!res || !res->data) - return GFX_ERROR; + error("calculatePic(): pic number %d not found", nr); if (need_unscaled) { if (_resMan->sciVersion() == SCI_VERSION_1_1) @@ -132,8 +132,6 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic if (unscaled_pic) unscaled_pic->visual_map->loop = default_palette; - - return GFX_OK; } int GfxResManager::getOptionsHash(gfx_resource_type_t type) { @@ -363,12 +361,9 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale } gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); } - if (calculatePic(pic, unscaled_pic, flags, default_palette, num)) { - gfxr_free_pic(pic); - if (unscaled_pic) - gfxr_free_pic(unscaled_pic); - return NULL; - } + + calculatePic(pic, unscaled_pic, flags, default_palette, num); + if (!res) { res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t)); res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num); diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 3b19fd4eed..98cc06c5d7 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -225,10 +225,8 @@ public: * @param[in] default_palette The default palette to use for pic * drawing (interpreter dependant) * @param[in] nr pic resource number - * @return GFX_ERROR if the resource could not be - * found, GFX_OK otherwise */ - int calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, + void calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr); diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 40da361f91..4f247e2cb1 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -194,7 +194,7 @@ void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_l } } -int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect_t src_coords, rect_t dest_coords, +void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect_t src_coords, rect_t dest_coords, byte *dest, int dest_line_width, byte *priority_dest, int priority_line_width, int priority_skip, int flags) { int maxx = 320 * mode->xfact; int maxy = 200 * mode->yfact; @@ -217,9 +217,9 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect // --???-- if (src_coords.y > yl) - return GFX_OK; + return; if (src_coords.x > xl) - return GFX_OK; + return; // --???-- if (dest_coords.x + xl >= maxx) @@ -231,10 +231,10 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect yl -= yoffset; if (!pxm->data) - return GFX_ERROR; + error("Attempted to crossblit an empty pixmap"); if (xl <= 0 || yl <= 0) - return GFX_OK; + return; // Set destination offsets @@ -275,10 +275,8 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect int shift_nr = 0; alpha_mask = 0; - if (!alpha_mask && pxm->alpha_map) { + if (!alpha_mask && pxm->alpha_map) error("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white"); - return GFX_ERROR; - } if (alpha_mask) { while (!(alpha_mask & 0xff)) { @@ -319,7 +317,6 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect 0, 0, 0, 0); else { error("Invalid mode->bytespp: %d", mode->bytespp); - return GFX_ERROR; } } else { // priority if (bpp > 0 && bpp < 5) @@ -328,11 +325,8 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect priority_pos, priority_line_width, priority_skip, priority); else { error("Invalid mode->bytespp: %d", mode->bytespp); - return GFX_ERROR; } } - - return GFX_OK; } } // End of namespace Sci diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 21ce9a8175..9bc2c82605 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -223,14 +223,6 @@ struct gfx_pixmap_t { /** @name Constant values * @{ */ -/** Return values */ -enum gfx_return_value_t { - GFX_OK = 0, /**< Indicates "operation successful" */ - GFX_ERROR = -1, /**< Indicates "operation failed" */ - GFX_FATAL = -2 /**< Fatal error: Used by graphics drivers to indicate - that they were unable to do anything useful */ -}; - /** Map masks */ enum gfx_map_mask_t { GFX_MASK_NONE = 0, diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h index 69e82a92d6..a17760f16d 100644 --- a/engines/sci/gfx/gfx_tools.h +++ b/engines/sci/gfx/gfx_tools.h @@ -200,10 +200,8 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode); * @param[in] priority_skip Amount of bytes allocated by each priority * value * @param[in] flags Any crossblit flags - * @return GFX_OK, or GFX_ERROR if the specified mode - * was invalid or unsupported */ -int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, +void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect_t src_coords, rect_t dest_coords, byte *dest, int dest_line_width, byte *priority_dest, int priority_line_width, int priority_skip, int flags); diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index 0bea12fca8..3d94bf1342 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -537,10 +537,7 @@ GfxView::GfxView(GfxState *state, Common::Point pos_, int view_, int loop_, int error("Attempt to create view widget with NULL state"); } - if (gfxop_get_cel_parameters(state, view_, loop_, cel_, &width, &height, &offset)) { - error("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)", - view_, cel_, loop_); - } + gfxop_get_cel_parameters(state, view_, loop_, cel_, &width, &height, &offset); _pos = pos_; _color.mask = ((priority < 0) ? 0 : GFX_MASK_PRIORITY) | ((control < 0) ? 0 : GFX_MASK_CONTROL); @@ -743,14 +740,10 @@ GfxDynView::GfxDynView(GfxState *state, Common::Point pos_, int z_, int view_, i _type = GFXW_DYN_VIEW; - if (!state) { + if (!state) error("Attempt to create view widget with NULL state"); - } - if (gfxop_get_cel_parameters(state, view_, loop_, cel_, &width, &height, &offset)) { - error("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)", - view_, cel_, loop_); - } + gfxop_get_cel_parameters(state, view_, loop_, cel_, &width, &height, &offset); _pos = pos_; _color.mask = ((priority < 0) ? 0 : GFX_MASK_PRIORITY) | ((control < 0) ? 0 : GFX_MASK_CONTROL); diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 2da129ca69..8d15b51696 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -1059,8 +1059,10 @@ static void _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point } void gfxop_set_pointer_cursor(GfxState *state, int nr) { - if (nr == GFXOP_NO_POINTER) + if (nr == GFXOP_NO_POINTER) { _gfxop_set_pointer(state, NULL, NULL); + return; + } gfx_pixmap_t *new_pointer = state->gfxResMan->getCursor(nr); @@ -1502,8 +1504,7 @@ int gfxop_lookup_view_get_loops(GfxState *state, int nr) { view = state->gfxResMan->getView(nr, &loop, &cel, 0); if (!view) { - warning("[GFX] Attempt to retrieve number of loops from invalid view %d", nr); - return 0; + error("[GFX] Attempt to retrieve number of loops from invalid view %d", nr); } return view->loops_nr; @@ -1525,27 +1526,21 @@ int gfxop_lookup_view_get_cels(GfxState *state, int nr, int loop) { return view->loops[real_loop].cels_nr; } -int gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel) { +void gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel) { gfxr_view_t *testView = state->gfxResMan->getView(nr, loop, cel, 0); - if (!testView) { - warning("[GFX] Attempt to verify loop/cel values for invalid view %d", nr); - return GFX_ERROR; - } - - return GFX_OK; + if (!testView) + error("[GFX] Attempt to verify loop/cel values for invalid view %d", nr); } -int gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel) { +void gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel) { int loop_v = *loop; int cel_v = *cel; gfxr_view_t *testView = state->gfxResMan->getView(nr, &loop_v, &cel_v, 0); - if (!testView) { - warning("[GFX] Attempt to verify loop/cel values for invalid view %d", nr); - return GFX_ERROR; - } + if (!testView) + error("[GFX] Attempt to verify loop/cel values for invalid view %d", nr); if (loop_v != *loop) *loop = 0; @@ -1553,28 +1548,22 @@ int gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel) { if (loop_v != *loop || cel_v != *cel) *cel = 0; - - return GFX_OK; } -int gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { +void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { gfxr_view_t *view = NULL; gfx_pixmap_t *pxm = NULL; view = state->gfxResMan->getView(nr, &loop, &cel, 0); - if (!view) { - warning("[GFX] Attempt to get cel parameters for invalid view %d", nr); - return GFX_ERROR; - } + if (!view) + error("[GFX] Attempt to get cel parameters for invalid view %d", nr); pxm = view->loops[loop].cels[cel]; *width = pxm->index_width; *height = pxm->index_height; offset->x = pxm->xoffset; offset->y = pxm->yoffset; - - return GFX_OK; } static void _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int static_buf, int palette) { @@ -1706,12 +1695,12 @@ int gfxop_get_font_height(GfxState *state, int font_nr) { font = state->gfxResMan->getFont(font_nr); if (!font) - return GFX_ERROR; + error("gfxop_get_font_height(): Font number %d not found", font_nr); return font->line_height; } -int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int text_flags, +void gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int text_flags, int *lines_nr, int *lineheight, int *lastline_width) { Common::Array<TextFragment> fragments; bool textsplits; @@ -1719,11 +1708,8 @@ int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int ma font = state->gfxResMan->getFont(font_nr); - if (!font) { + if (!font) error("Attempt to calculate text size with invalid font #%d", font_nr); - *width = *height = 0; - return GFX_ERROR; - } #ifdef CUSTOM_GRAPHICS_OPTIONS textsplits = gfxr_font_calculate_size(fragments, font, maxwidth, text, width, height, lineheight, lastline_width, @@ -1732,16 +1718,11 @@ int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int ma textsplits = gfxr_font_calculate_size(fragments, font, maxwidth, text, width, height, lineheight, lastline_width, text_flags); #endif - if (!textsplits) { + if (!textsplits) error("Could not calculate text size"); - *width = *height = 0; - return GFX_ERROR; - } if (lines_nr) *lines_nr = fragments.size(); - - return GFX_OK; } TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &text, int maxwidth, gfx_alignment_t halign, diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 359b437d94..7ca714aaed 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -452,9 +452,8 @@ int gfxop_lookup_view_get_cels(GfxState *state, int nr, int loop); * @param[in] nr Number of the view to use * @param[in] loop Pointer to the variable storing the loop number to verify * @param[in] cel Pointer to the variable storing the cel number to check - * @return GFX_OK or GFX_ERROR if the view didn't exist */ -int gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel); +void gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel); /** * Resets loop/cel values to zero if they have become invalid. @@ -463,11 +462,8 @@ int gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel); * @param[in] nr Number of the view to use * @param[in] loop Pointer to the variable storing the loop number to verify * @param[in] cel Pointer to the variable storing the cel number to check - * @return GFX_OK or GFX_ERROR if the view didn't exist *loop is - * clipped first, then *cel. The resulting setup will be a - * valid view configuration. */ -int gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel); +void gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel); /** * Retrieves the width and height of a cel. @@ -479,10 +475,8 @@ int gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel); * @param[in] width The variable the width will be stored in * @param[in] height The variable the height will be stored in * @param[in] offset The variable the cel's x/y offset will be stored in - * @return GFX_OK if the lookup succeeded, GFX_ERROR if the - * nr/loop/cel combination was invalid */ -int gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, +void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset); /** @@ -582,7 +576,7 @@ void gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette); * * @param[in] state The state to work on * @param[in] font_nr Number of the font to inspect - * @return GFX_ERROR, GFX_FATAL, or the font line height + * @return The font line height */ int gfxop_get_font_height(GfxState *state, int font_nr); @@ -601,9 +595,8 @@ int gfxop_get_font_height(GfxState *state, int font_nr); * @param[out] lineheight Pixel height (SCI scale) of each text line * @param[out] lastline_width Pixel offset (SCI scale) of the space after * the last character in the last line - * @return GFX_OK or GFX_ERROR if the font didn't exist */ -int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, +void gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int flags, int *lines_nr, int *lineheight, int *lastline_width); diff --git a/engines/sci/gfx/res_font.cpp b/engines/sci/gfx/res_font.cpp index cddbade845..fd2cae08e6 100644 --- a/engines/sci/gfx/res_font.cpp +++ b/engines/sci/gfx/res_font.cpp @@ -35,7 +35,7 @@ extern int font_counter; #define FONT_HEIGHT_OFFSET 4 #define FONT_MAXCHAR_OFFSET 2 -static int calc_char(byte *dest, int total_width, int total_height, byte *src, int size) { +static void calc_char(byte *dest, int total_width, int total_height, byte *src, int size) { int width = src[0]; int height = src[1]; int byte_width = (width + 7) >> 3; @@ -45,12 +45,10 @@ static int calc_char(byte *dest, int total_width, int total_height, byte *src, i if ((width >> 3) > total_width || height > total_height) { error("Weird character: width=%d/%d, height=%d/%d", width, total_width, height, total_height); - return GFX_ERROR; } if (byte_width * height + 2 > size) { error("Character extends to %d of %d allowed bytes", byte_width * height + 2, size); - return GFX_ERROR; } for (y = 0; y < height; y++) { @@ -58,8 +56,6 @@ static int calc_char(byte *dest, int total_width, int total_height, byte *src, i src += byte_width; dest += total_width; } - - return GFX_OK; } gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { @@ -129,11 +125,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { for (i = 0; i < chars_nr; i++) { int offset = READ_LE_UINT16(resource + (i << 1) + 6); - if (calc_char(font->data + (font->char_size * i), font->row_size, max_height, resource + offset, size - offset)) { - error("Problem occured in font %04x, char %d/%d", id, i, chars_nr); - gfxr_free_font(font); - return NULL; - } + calc_char(font->data + (font->char_size * i), font->row_size, max_height, resource + offset, size - offset); } return font; |