diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/grammar.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/kernel.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 30 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 47 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 2 |
8 files changed, 46 insertions, 50 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index b5160df12b..c65beea38e 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -66,8 +66,6 @@ static int _init_vocabulary(EngineState *s) { // initialize vocabulary and relat return 0; } -extern int _allocd_rules; - int _reset_graphics_input(EngineState *s) { Resource *resource; int font_nr; diff --git a/engines/sci/engine/grammar.cpp b/engines/sci/engine/grammar.cpp index 63cd8a9b4a..f7d86a85ca 100644 --- a/engines/sci/engine/grammar.cpp +++ b/engines/sci/engine/grammar.cpp @@ -42,7 +42,7 @@ namespace Sci { #define TOKEN_NON_NT (TOKEN_OPAREN | TOKEN_TERMINAL_CLASS | TOKEN_TERMINAL_GROUP | TOKEN_STUFFING_WORD) #define TOKEN_TERMINAL (TOKEN_TERMINAL_CLASS | TOKEN_TERMINAL_GROUP) -int _allocd_rules = 0; +static int _allocd_rules = 0; // FIXME: Avoid static vars static void vocab_print_rule(parse_rule_t *rule) { int i; @@ -420,8 +420,7 @@ int vocab_build_parse_tree(parse_tree_node_t *nodes, const ResultWordList &words return vocab_gnf_parse(nodes, words, branch0, rules, 0); } -static int -_vbpt_pareno(parse_tree_node_t *nodes, int *pos, int base) { +static int _vbpt_pareno(parse_tree_node_t *nodes, int *pos, int base) { // Opens parentheses nodes[base].content.branches[0] = (*pos) + 1; nodes[++(*pos)].type = PARSE_TREE_NODE_BRANCH; diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 10c7a3c14b..76e181e4df 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -47,7 +47,7 @@ struct SciKernelFunction { const char *signature; /* kfunct signature */ }; -static int sci_max_allowed_unknown_kernel_functions[] = { +static const int sci_max_allowed_unknown_kernel_functions[] = { 0, 0x72, // SCI0 0x7b, // SCI01/EGA diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 2cd78c3ac0..b6d7c90624 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -95,6 +95,7 @@ bool FileHandle::isOpen() const { +// FIXME: Avoid static vars static int _savegame_indices_nr = -1; // means 'uninitialized' struct SavegameDesc { @@ -103,6 +104,7 @@ struct SavegameDesc { int time; }; +// FIXME: Avoid static vars static SavegameDesc _savegame_indices[MAX_SAVEGAME_NR]; diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 61a9ca4e52..03ccd82f87 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -360,7 +360,6 @@ extern int oldx, oldy; reg_t kMoveCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) { Common::Point newpos; - static Common::Point oldpos(0, 0); newpos = s->gfx_state->pointer_pos; @@ -377,8 +376,6 @@ reg_t kMoveCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (newpos.x < 0) newpos.x = 0; if (newpos.y < 0) newpos.y = 0; - - oldpos = newpos; } GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newpos)); @@ -471,9 +468,9 @@ void _k_graph_rebuild_port_with_color(EngineState *s, gfx_color_t newbgcolor) { delete port; } -static int activated_icon_bar = 0; -static int port_origin_x = 0; -static int port_origin_y = 0; +static bool activated_icon_bar = false; // FIXME: Avoid static vars +static int port_origin_x = 0; // FIXME: Avoid static vars +static int port_origin_y = 0; // FIXME: Avoid static vars reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) { rect_t area; @@ -1783,7 +1780,7 @@ void _k_view_list_mark_free(EngineState *s, reg_t off) { } } -static int _k_animate_ran = 0; +static bool _k_animate_ran = false; // FIXME: Avoid static vars int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, int funct_nr, int argc, reg_t *argv) { // disposes all list members flagged for disposal; funct_nr is the invoking kfunction @@ -1791,7 +1788,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in int signal; int dropped = 0; - _k_animate_ran = 0; + _k_animate_ran = false; if (widget) { int retval; @@ -1870,10 +1867,11 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in return dropped; } - -#define _K_MAKE_VIEW_LIST_CYCLE 1 -#define _K_MAKE_VIEW_LIST_CALC_PRIORITY 2 -#define _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP 4 +enum { + _K_MAKE_VIEW_LIST_CYCLE = 1, + _K_MAKE_VIEW_LIST_CALC_PRIORITY = 2, + _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP = 4 +}; static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, int nr, int funct_nr, int argc, reg_t *argv) { short oldloop, oldcel; @@ -2100,7 +2098,7 @@ static void _k_prepare_view_list(EngineState *s, GfxList *list, int options) { static void _k_update_signals_in_view_list(GfxList *old_list, GfxList *new_list) { // O(n^2)... a bit painful, but much faster than the redraws it helps prevent - GfxDynView *old_widget = (GfxDynView *) old_list->_contents; + GfxDynView *old_widget = (GfxDynView *)old_list->_contents; /* Traverses all old widgets, updates them with signals from the new widgets. ** This is done to avoid evil hacks in widget.c; widgets with unique IDs are @@ -2332,7 +2330,7 @@ reg_t kGetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (activated_icon_bar && argc == 6) { port_origin_x = port_origin_y = 0; - activated_icon_bar = 0; + activated_icon_bar = false; return s->r_acc; } @@ -2367,7 +2365,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (SKPV(0) == -10) { s->port->draw(gfxw_point_zero); // Update the port we're leaving s->port = s->iconbar_port; - activated_icon_bar = 1; + activated_icon_bar = true; return s->r_acc; } @@ -2974,7 +2972,7 @@ reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) { int open_animation = 0; process_sound_events(s); // Take care of incoming events (kAnimate is called semi-regularly) - _k_animate_ran = 1; // Used by some of the invoked functions to check for recursion, which may, + _k_animate_ran = true; // Used by some of the invoked functions to check for recursion, which may, // after all, damage the cast list if (cast_list_ref.segment) { diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 32007e93b4..5e3da6403b 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -231,11 +231,13 @@ reg_t kInitBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) { #define MOVING_ON_X (((axis == _K_BRESEN_AXIS_X)&&bi1) || dx) #define MOVING_ON_Y (((axis == _K_BRESEN_AXIS_Y)&&bi1) || dy) -static enum { +enum Movecnt { IGNORE_MOVECNT, INCREMENT_MOVECNT, UNINITIALIZED -} handle_movecnt = UNINITIALIZED; +}; + +static Movecnt handle_movecnt = UNINITIALIZED; // FIXME: Avoid static vars int parse_reg_t(EngineState *s, const char *str, reg_t *dest); diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 32d1a1d010..fd0d710b7b 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -244,11 +244,8 @@ struct PathfindingState { ~PathfindingState() { free(vertex_index); - if (_prependPoint) - delete _prependPoint; - - if (_appendPoint) - delete _appendPoint; + delete _prependPoint; + delete _appendPoint; for (PolygonList::iterator it = polygons.begin(); it != polygons.end(); ++it) { delete *it; @@ -257,7 +254,7 @@ struct PathfindingState { }; -static Vertex *vertex_cur; // FIXME +static Vertex *s_vertex_cur; // FIXME: Avoid static vars // FIXME: Temporary hack to deal with points in reg_ts static bool polygon_is_reg_t(const byte *list, int size) { @@ -286,8 +283,7 @@ static Common::Point read_point(const byte *list, int is_reg_t, int offset) { /** * Checks whether two polygons are equal */ -static bool polygons_equal(EngineState *s, reg_t p1, reg_t p2) -{ +static bool polygons_equal(EngineState *s, reg_t p1, reg_t p2) { // Check for same type if (KP_UINT(GET_SEL32(p1, type)) != KP_UINT(GET_SEL32(p2, type))) return false; @@ -618,12 +614,12 @@ static void fix_vertex_order(Polygon *polygon) { static int vertex_compare(const void *a, const void *b) { // Compares two vertices by angle (first) and distance (second) in relation - // to vertex_cur. The angle is relative to the horizontal line extending - // right from vertex_cur, and increases clockwise + // to s_vertex_cur. The angle is relative to the horizontal line extending + // right from s_vertex_cur, and increases clockwise // Parameters: (const void *) a, b: The vertices // Returns : (int) -1 if a is smaller than b, 1 if a is larger than b, and // 0 if a and b are equal - const Common::Point &p0 = vertex_cur->v; + const Common::Point &p0 = s_vertex_cur->v; const Common::Point &p1 = (*(Vertex **) a)->v; const Common::Point &p2 = (*(Vertex **) b)->v; @@ -664,7 +660,7 @@ static int vertex_compare(const void *a, const void *b) { return -1; } -static void clockwise(const Vertex *v, const Common::Point *&p1, const Common::Point *&p2) { +static void clockwise(const Vertex *vertex_cur, const Vertex *v, const Common::Point *&p1, const Common::Point *&p2) { // Orders the points of an edge clockwise around vertex_cur. If all three // points are collinear the original order is used // Parameters: (const Vertex *) v: The first vertex of the edge @@ -688,7 +684,7 @@ static void clockwise(const Vertex *v, const Common::Point *&p1, const Common::P * @param b the second edge * @return true if a is closer to vertex_cur than b, false otherwise */ -static bool edgeIsCloser(const Vertex *a, const Vertex *b) { +static bool edgeIsCloser(const Vertex *vertex_cur, const Vertex *a, const Vertex *b) { const Common::Point *v1, *v2, *w1, *w2; // Check for comparison of the same edge @@ -700,8 +696,8 @@ static bool edgeIsCloser(const Vertex *a, const Vertex *b) { // Order vertices clockwise so we know vertex_cur is to the right of // directed edges (v1, v2) and (w1, w2) - clockwise(a, v1, v2); - clockwise(b, w1, w2); + clockwise(vertex_cur, a, v1, v2); + clockwise(vertex_cur, b, w1, w2); // At this point we know that one edge must lie entirely to one side // of the other, as the edges are not collinear and cannot intersect @@ -741,13 +737,14 @@ static int inside(const Common::Point &p, Vertex *vertex) { /** * Determines whether or not a vertex is visible from vertex_cur. + * @param vertex_cur the base vertex * @param vertex the vertex * @param vertex_prev the previous vertex in the sort order, or NULL * @param visible true if vertex_prev is visible, false otherwise * @param intersected the list of edges intersected by the sweeping line * @return true if vertex is visible from vertex_cur, false otherwise */ -static bool visible(Vertex *vertex, Vertex *vertex_prev, bool visible, const VertexList &intersected) { +static bool visible(Vertex *vertex_cur, Vertex *vertex, Vertex *vertex_prev, bool visible, const VertexList &intersected) { const Common::Point &p = vertex_cur->v; const Common::Point &w = vertex->v; @@ -771,14 +768,14 @@ static bool visible(Vertex *vertex, Vertex *vertex_prev, bool visible, const Ver const Vertex *edge = *it++; for (; it != intersected.end(); ++it) { - if (edgeIsCloser(*it, edge)) + if (edgeIsCloser(vertex_cur, *it, edge)) edge = *it; } const Common::Point *p1, *p2; // Check for intersection with sweeping line before vertex - clockwise(edge, p1, p2); + clockwise(vertex_cur, edge, p1, p2); if (left(*p2, *p1, p) && left(*p1, *p2, w)) return false; @@ -788,17 +785,17 @@ static bool visible(Vertex *vertex, Vertex *vertex_prev, bool visible, const Ver /** * Returns a list of all vertices that are visible from a particular vertex. * @param s the pathfinding state - * @param vert the vertex + * @param vertex_cur the vertex * @return list of vertices that are visible from vert */ -static VertexList *visible_vertices(PathfindingState *s, Vertex *vert) { +static VertexList *visible_vertices(PathfindingState *s, Vertex *vertex_cur) { // List of edges intersected by the sweeping line VertexList intersected; VertexList *visVerts = new VertexList(); - const Common::Point &p = vert->v; + const Common::Point &p = vertex_cur->v; // Sort vertices by angle (first) and distance (second) - vertex_cur = vert; + s_vertex_cur = vertex_cur; qsort(s->vertex_index, s->vertices, sizeof(Vertex *), vertex_compare); for (PolygonList::iterator it = s->polygons.begin(); it != s->polygons.end(); ++it) { @@ -812,7 +809,7 @@ static VertexList *visible_vertices(PathfindingState *s, Vertex *vert) { const Common::Point *high, *low; // Add edges that intersect the initial position of the sweeping line - clockwise(vertex, high, low); + clockwise(vertex_cur, vertex, high, low); if ((high->y < p.y) && (low->y >= p.y) && (*low != p)) intersected.push_front(vertex); @@ -822,12 +819,12 @@ static VertexList *visible_vertices(PathfindingState *s, Vertex *vert) { int is_visible = 1; - // The first vertex will be vertex_cur, so we skip it + // The first vertex will be s_vertex_cur, so we skip it for (int i = 1; i < s->vertices; i++) { Vertex *v1; // Compute visibility of vertex_index[i] - is_visible = visible(s->vertex_index[i], s->vertex_index[i - 1], is_visible, intersected); + is_visible = visible(s_vertex_cur, s->vertex_index[i], s->vertex_index[i - 1], is_visible, intersected); // Update visibility matrix if (is_visible) diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 9cad1f118f..4583a56ac0 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -663,7 +663,7 @@ reg_t kGetFarText(EngineState *s, int funct_nr, int argc, reg_t *argv) { #define DUMMY_MESSAGE "Message not found!" -static MessageState state; +static MessageState state; // FIXME: Avoid static vars enum kMessageFunc { K_MESSAGE_GET, |